From 62bcd773be19cd81334dd0d2b300df4045c10ca2 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Sun, 16 Mar 2008 18:02:41 -0300 Subject: [PATCH] Compile warning fixes. Add parenthesis around code like "a << b-1" and "foo + (a-b*c) >> d". Cast some print arguments. Remove const char from some prototypes because it actually pass the arguments to a function that changes the string contents. --- x2jet.c | 22 +++++++++++++--------- x2pmp.c | 15 +++++++++------ xpr.c | 55 +++---------------------------------------------------- xpr.h | 2 +- 4 files changed, 26 insertions(+), 68 deletions(-) diff --git a/x2jet.c b/x2jet.c index 26a60ec..410d34a 100644 --- a/x2jet.c +++ b/x2jet.c @@ -147,7 +147,7 @@ static int scale_raster ( static void scale_and_orient_image ( int *scale, int *density, int width, int height, int left, int top, /* in 300ths of an inch */ - const char *header, const char *trailer, + char *header, char *trailer, enum orientation *orient, int position_on_page, enum device device); @@ -411,7 +411,7 @@ static void scale_and_orient_image ( int *scale, int *density, int width, int height, int left, int top, /* in 300ths of an inch */ - const char *header, const char *trailer, + char *header, char *trailer, enum orientation *orient, int position_on_page, enum device device) @@ -480,6 +480,10 @@ void scale_and_orient_image ( break; case PJETXL: *density = 180; break; + default: + fprintf(stderr, "%s:%d: device %d not handled\n", + __FILE__, __LINE__, device); + break; } } @@ -1183,8 +1187,8 @@ void write_image_prefix ( /* Set picture width for PaintJet */ fprintf(out,"\033*r%dS", - ((int) (orient == PORTRAIT) ? limit.width : limit.height) - * scale); + (int)((orient == PORTRAIT ? limit.width : limit.height) + * scale)); } /* Enable various options for PaintJet XL */ @@ -1226,11 +1230,11 @@ void write_image_prefix ( * Set picture width for PaintJet XL * ****************************************/ fprintf(out,"\033*r%dS", - ((int) (orient == PORTRAIT) ? xwd_header.pixmap_width - : xwd_header.pixmap_height)); + (int)(orient == PORTRAIT ? xwd_header.pixmap_width + : xwd_header.pixmap_height)); fprintf(out,"\033*r%dT", - ((int) (orient == PORTRAIT) ? xwd_header.pixmap_height - : xwd_header.pixmap_width)); + (int)(orient == PORTRAIT ? xwd_header.pixmap_height + : xwd_header.pixmap_width)); dotsize = dot_centipoints(scale, density); @@ -1647,7 +1651,7 @@ void x2jet( FILE *in, FILE *out, int scale, int density, int width, int height, int left, int top, /* in 300ths of an inch */ - const char *header, const char *trailer, + char *header, char *trailer, enum orientation orient, int invert, int initial_formfeed, int position_on_page, int slide, enum device device, diff --git a/x2pmp.c b/x2pmp.c index ef1674c..62fe288 100644 --- a/x2pmp.c +++ b/x2pmp.c @@ -34,7 +34,7 @@ static void p_bitmap( unsigned long buflen, unsigned char *buf); -static plane = 0; +static int plane = 0; #define FONT_HEIGHT 40 #define FONT_HEIGHT_PIXELS (FONT_HEIGHT*75/PPI) #define FONT_WIDTH 24 @@ -65,7 +65,7 @@ void x2pmp(FILE *in, FILE *out, if (header.file_version != XWD_FILE_VERSION) { fprintf(stderr,"%s: file format version %d, not %d\n", progname, - header.file_version, XWD_FILE_VERSION); + (int)header.file_version, XWD_FILE_VERSION); } win_name_size = abs_(header.header_size - sizeof(header)); @@ -105,6 +105,9 @@ void x2pmp(FILE *in, FILE *out, scale = min_((p_length - 2*y_pos) / fixed_width, (p_width - 2*x_pos) / real_height); break; + default: + /* Silence compile warning */ + break; } if (scale <= 0) leave("PixMap doesn't fit on page."); @@ -165,7 +168,7 @@ void x2pmp(FILE *in, FILE *out, } /* we don't want the last bits up to the byte/word alignment set */ - if (no_of_bits = fixed_width - width) { + if ((no_of_bits = fixed_width - width)) { int i, j, mask = ~bits_set(no_of_bits % 8); for(i = 0; i < height; i++) { unsigned char *s = buffer + (i+1) * byte_width ; @@ -227,12 +230,12 @@ void x2pmp(FILE *in, FILE *out, p_restore_cursor(out, 0); p_save_cursor(out, 3); if (head != NULL) { - p_move_abs( out, x_pos + (width - strlen(foot)*FONT_WIDTH) >> 1, + p_move_abs( out, x_pos + ((width - strlen(foot)*FONT_WIDTH) >> 1), y_pos - FONT_HEIGHT ); fprintf(out, "%s\n", head); } if (foot != NULL) { - p_move_abs( out, x_pos + (width - strlen(foot)*FONT_WIDTH) >> 1, + p_move_abs( out, x_pos + ((width - strlen(foot)*FONT_WIDTH) >> 1), y_pos + height + (FONT_HEIGHT << 1) ); fprintf(out, "%s\n", foot); } @@ -268,7 +271,7 @@ unsigned char *magnification_table(int scale) last = scale*(bit-1); for(i = scale*bit; i-- > last ;) entry[(scale - 1) - i / 8] |= 1 << (i % 8); - b &= ~(1 << bit-1); + b &= ~(1 << (bit-1)); } } return tbl; diff --git a/xpr.c b/xpr.c index 42ec785..589e164 100644 --- a/xpr.c +++ b/xpr.c @@ -224,7 +224,6 @@ void build_sixmap( int hpad, XWDFileHeader *win, const char *data); -static void build_output_filename(const char *name, enum device device, char *oname); static void ln03_setup( int iw, @@ -257,10 +256,6 @@ void ps_setup( const char *trailer, const char *name); static void ps_finish(void); -static void ln03_alter_background( - unsigned char (*sixmap)[], - int iw, - int ih); static void ln03_output_sixels( unsigned char (*sixmap)[], @@ -459,8 +454,8 @@ int main(int argc, char **argv) /* print some statistics */ if (flags & F_REPORT) { fprintf(stderr, "Name: %s\n", w_name); - fprintf(stderr, "Width: %d, Height: %d\n", win.pixmap_width, - win.pixmap_height); + fprintf(stderr, "Width: %d, Height: %d\n", (int)win.pixmap_width, + (int)win.pixmap_height); fprintf(stderr, "Orientation: %s, Scale: %d\n", (orientation==PORTRAIT) ? "Portrait" : "Landscape", scale); } @@ -1131,16 +1126,6 @@ void build_sixmap( } } -static -void build_output_filename(const char *name, enum device device, char *oname) -{ - while (*name && *name != '.') *oname++ = *name++; - switch (device) { - case LN03: bcopy(".ln03", oname, 6); break; - case LA100: bcopy(".la100", oname, 7); break; - } -} - /* ln03_grind_fonts(sixmap, iw, ih, scale, pixmap) unsigned char (*sixmap)[]; @@ -1548,12 +1533,11 @@ void ps_setup( } } -const char *ps_epilog[] = { "", "showpage", "%%Trailer", - 0 + NULL }; static @@ -1565,39 +1549,6 @@ void ps_finish(void) } static -void ln03_alter_background( - unsigned char (*sixmap)[], - int iw, - int ih) -{ - register unsigned char *c, *stopc; - register unsigned char *startc; - register int n; - - c = (unsigned char *)sixmap; - stopc = c + (iw * ih); - n = 0; - while (c < stopc) { - switch (*c) { - case 0x08: case 0x11: case 0x04: case 0x22: - case 0x20: case 0x21: case 0x24: case 0x00: - if (n == 0) startc = c; - n++; - break; - - default: - if (n >= 2) { - while (n-- > 0) *startc++ = 0x00; - } else { - n = 0; - } - break; - } - c++; - } -} - -static void ln03_output_sixels( unsigned char (*sixmap)[], int iw, diff --git a/xpr.h b/xpr.h index d7c3182..177b276 100644 --- a/xpr.h +++ b/xpr.h @@ -41,7 +41,7 @@ void x2jet( FILE *in, FILE *out, int scale, int density, int width, int height, int left, int top, /* in 300ths of an inch */ - const char *header, const char *trailer, + char *header, char *trailer, enum orientation orient, int invert, int initial_formfeed, int position_on_page, int slide, enum device device, -- 1.5.3.2