From 429c34dd75fb1da539d7564045c4b4c6ca73b405 Mon Sep 17 00:00:00 2001 From: ellson Date: Thu, 4 Sep 2008 23:06:28 +0000 Subject: [PATCH] eliminate some "unsigned" qualifiers on char and the casts caused by them --- lib/gvc/gvcproc.h | 2 +- lib/gvc/gvdevice.c | 52 +++++++++++++++++------------------ plugin/lasi/gvrender_lasi.cpp | 22 +++++++-------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/lib/gvc/gvcproc.h b/lib/gvc/gvcproc.h index 7ef94fb6c..58ba9395c 100644 --- a/lib/gvc/gvcproc.h +++ b/lib/gvc/gvcproc.h @@ -67,7 +67,7 @@ extern "C" { extern usershape_t *gvusershape_find(char *name); /* device */ - extern size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len); + extern size_t gvdevice_write (GVJ_t * job, const char *s, unsigned int len); extern void gvdevice_fputs(GVJ_t * job, const char *s); extern void gvdevice_printf(GVJ_t * job, const char *format, ...); diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index bfdc656cc..c593c4db9 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -46,11 +46,11 @@ #ifndef OS_CODE # define OS_CODE 0x03 /* assume Unix */ #endif -static unsigned char z_file_header[] = +static char z_file_header[] = {0x1f, 0x8b, /*magic*/ Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE}; static z_stream z_strm; -static unsigned char *df; +static char *df; static unsigned int dfallocated; static unsigned long int crc; #endif @@ -69,7 +69,7 @@ extern FILE* Output_file; static const int PAGE_ALIGN = 4095; /* align to a 4K boundary (less one), typical for Linux, Mac OS X and Windows memory allocation */ -static size_t gvdevice_write_no_z (GVJ_t * job, const unsigned char *s, unsigned int len) +static size_t gvdevice_write_no_z (GVJ_t * job, const char *s, unsigned int len) { if (job->gvc->write_fn) /* externally provided write dicipline */ return (job->gvc->write_fn)(job, (char*)s, len); @@ -213,7 +213,7 @@ void gvdevice_initialize(GVJ_t * job) #endif } -size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len) +size_t gvdevice_write (GVJ_t * job, const char *s, unsigned int len) { if (!len || !s) return 0; @@ -234,7 +234,7 @@ size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len) } } - z->next_in = (unsigned char*)s; + z->next_in = s; z->avail_in = len; z->next_out = df; z->avail_out = dfallocated; @@ -260,7 +260,7 @@ size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len) void gvdevice_fputs(GVJ_t * job, const char *s) { - gvdevice_write (job, (const unsigned char*)s, strlen(s)); + gvdevice_write (job, s, strlen(s)); } static void gvdevice_flush(GVJ_t * job) @@ -305,7 +305,7 @@ void gvdevice_finalize(GVJ_t * job) if (job->flags & GVDEVICE_COMPRESSED_FORMAT) { #ifdef HAVE_LIBZ z_streamp z = &z_strm; - unsigned char out[8] = ""; + char out[8] = ""; int ret; int cnt = 0; @@ -336,14 +336,14 @@ void gvdevice_finalize(GVJ_t * job) (job->common->errorfn) ("deflation end problem %d\n", ret); exit(1); } - out[0] = (unsigned char)(crc); - out[1] = (unsigned char)(crc >> 8); - out[2] = (unsigned char)(crc >> 16); - out[3] = (unsigned char)(crc >> 24); - out[4] = (unsigned char)(z->total_in); - out[5] = (unsigned char)(z->total_in >> 8); - out[6] = (unsigned char)(z->total_in >> 16); - out[7] = (unsigned char)(z->total_in >> 24); + out[0] = crc; + out[1] = crc >> 8; + out[2] = crc >> 16; + out[3] = crc >> 24; + out[4] = z->total_in; + out[5] = z->total_in >> 8; + out[6] = z->total_in >> 16; + out[7] = z->total_in >> 24; gvdevice_write_no_z(job, out, sizeof(out)); #else (job->common->errorfn) ("No libz support\n"); @@ -393,7 +393,7 @@ void gvdevice_finalize(GVJ_t * job) */ void gvdevice_printf(GVJ_t * job, const char *format, ...) { - unsigned char buf[BUFSIZ]; + char buf[BUFSIZ]; unsigned int len; va_list argp; @@ -417,17 +417,17 @@ void gvdevice_printf(GVJ_t * job, const char *format, ...) #define DECPLACES_SCALE 100 /* use macro so maxnegnum is stated just once for both double and string versions */ -#define val_str(n, x) static double n = x; static unsigned char n##str[] = #x; +#define val_str(n, x) static double n = x; static char n##str[] = #x; val_str(maxnegnum, -999999999999999.99) /* we use len and don't need the string to be terminated */ /* #define TERMINATED_NUMBER_STRING */ /* Note. Returned string is only good until the next call to gvprintnum */ -static unsigned char * gvprintnum (int *len, double number) +static char * gvprintnum (int *len, double number) { - static unsigned char tmpbuf[sizeof(maxnegnumstr)]; /* buffer big enough for worst case */ - unsigned char *result = tmpbuf+sizeof(maxnegnumstr); /* init result to end of tmpbuf */ + static char tmpbuf[sizeof(maxnegnumstr)]; /* buffer big enough for worst case */ + char *result = tmpbuf+sizeof(maxnegnumstr); /* init result to end of tmpbuf */ long int N; boolean showzeros, negative; int digit, i; @@ -455,7 +455,7 @@ static unsigned char * gvprintnum (int *len, double number) N = number + 0.5; if (N == 0) { /* special case for exactly 0 */ *len = 1; - return (unsigned char *)"0"; + return "0"; } if ((negative = (N < 0))) /* avoid "-0" by testing rounded int */ N = -N; /* make number +ve */ @@ -492,7 +492,7 @@ static unsigned char * gvprintnum (int *len, double number) #ifdef GVPRINTNUM_TEST int main (int argc, char *argv[]) { - unsigned char *buf; + char *buf; int len; double test[] = { @@ -517,7 +517,7 @@ int main (int argc, char *argv[]) void gvdevice_printnum(GVJ_t * job, double num) { - unsigned char *buf; + char *buf; int len; buf = gvprintnum(&len, num); @@ -526,12 +526,12 @@ void gvdevice_printnum(GVJ_t * job, double num) void gvdevice_printpointf(GVJ_t * job, pointf p) { - unsigned char *buf; + char *buf; int len; buf = gvprintnum(&len, p.x); gvdevice_write(job, buf, len); - gvdevice_write(job, (unsigned char*)" ", 1); + gvdevice_write(job, " ", 1); buf = gvprintnum(&len, p.y); gvdevice_write(job, buf, len); } @@ -543,7 +543,7 @@ void gvdevice_printpointflist(GVJ_t * job, pointf *p, int n) while (TRUE) { gvdevice_printpointf(job, p[i]); if (++i >= n) break; - gvdevice_write(job, (unsigned char*)" ", 1); + gvdevice_write(job, " ", 1); } } diff --git a/plugin/lasi/gvrender_lasi.cpp b/plugin/lasi/gvrender_lasi.cpp index 13922f8e6..4e9c9299a 100644 --- a/plugin/lasi/gvrender_lasi.cpp +++ b/plugin/lasi/gvrender_lasi.cpp @@ -44,14 +44,14 @@ using namespace std; extern "C" { extern void epsf_define(FILE * of); - extern char *ps_string(char *ins, int latin); - extern size_t gvdevice_write(GVJ_t *job, const unsigned char *s, unsigned int n); +// extern char *ps_string(char *ins, int latin); + extern size_t gvdevice_write(GVJ_t *job, const char *s, unsigned int n); } typedef enum { FORMAT_PS, FORMAT_PS2, FORMAT_EPS } format_type; -static int isLatin1; -static char setupLatin1; +//static int isLatin1; +//static char setupLatin1; PostscriptDocument doc; @@ -129,7 +129,7 @@ private: GVJ_t *thisjob; // write a string s of length n to the current gvdevice int xsputn (char_type* s, streamsize n) { - return gvdevice_write(thisjob, (const unsigned char*)s, n); + return gvdevice_write(thisjob, s, n); } public: Gvout (GVJ_t *job) { @@ -167,7 +167,7 @@ static void lasi_begin_graph(GVJ_t * job) { obj_state_t *obj = job->obj; - setupLatin1 = FALSE; +// setupLatin1 = FALSE; if (job->common->viewNum == 0) { // gvdevice_printf(job, "%%%%Title: %s\n", obj->u.g->name); @@ -207,18 +207,17 @@ static void lasi_begin_graph(GVJ_t * job) cat_libfile(job, NULL, args); } } - isLatin1 = (GD_charset(obj->u.g) == CHAR_LATIN1); +// isLatin1 = (GD_charset(obj->u.g) == CHAR_LATIN1); /* We always setup Latin1. The charset info is always output, * and installing it is cheap. With it installed, we can then * rely on ps_string to convert UTF-8 characters whose encoding * is in the range of Latin-1 into the Latin-1 equivalent and * get the expected PostScript output. */ - if (!setupLatin1) { -// FIXME!! +// if (!setupLatin1) { // gvdevice_fputs(job, "setupLatin1\n"); /* as defined in ps header */ // setupLatin1 = TRUE; - } +// } /* Set base URL for relative links (for Distiller >= 3.0) */ if (obj->url) { // gvdevice_printf(job, "[ {Catalog} << /URI << /Base (%s) >> >>\n" @@ -473,9 +472,8 @@ static void lasi_textpara(GVJ_t * job, pointf p, textpara_t * para) doc.osBody() << "moveto" << endl; // gvdevice_printnum(job, para->width); // str = ps_string(para->str,isLatin1); - str = para->str; // gvdevice_printf(job, " %s alignedtext\n", str); - doc.osBody() << show(str) << endl; + doc.osBody() << show(para->str) << endl; } -- 2.40.0