diff options
author | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-22 17:34:02 -0200 |
---|---|---|
committer | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-22 17:34:02 -0200 |
commit | f53142c6882f08b646ebe6d614bb6f14d5dcdb57 (patch) | |
tree | 1cb3cb9a9ee9f94fcaf0533d394dd91207bf3da1 | |
parent | bee786458655a081487f2caff112f85aa0c3c8de (diff) |
Correct make distcheck and most gcc/sparse warnings.
Remaining warnings are due to bit/shift operations mixed with
addition/multiplication/etc. "1<<2-1" should be read as
"1 << (2 - 1)", and not "(1 << 2) - 1". The first 2 warnings
appear to be for a confusing case, as a few lines bellow
it is adding parenthesis to the shift operation, but should be
being parsed correctly (not added parenthesis to avoid the
adding them wrong, and "hiding" the warning...)
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | x2jet.c | 50 | ||||
-rw-r--r-- | x2pmp.c | 7 | ||||
-rw-r--r-- | xpr.c | 89 |
6 files changed, 72 insertions, 90 deletions
@@ -20,3 +20,7 @@ xdpr.1 xpr xpr.1 *~ +*.o +xpr-*.tar.* +ChangeLog +tags diff --git a/Makefile.am b/Makefile.am index 558be2a..e9409b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ bin_PROGRAMS = xpr -xpr_CFLAGS = $(XPR_CFLAGS) -DNOINLINE +AM_CFLAGS = $(XPR_CFLAGS) -DNOINLINE xpr_LDADD = $(XPR_LIBS) -lm xpr_SOURCES = \ @@ -51,7 +51,7 @@ MAINTAINERCLEANFILES=ChangeLog .PHONY: ChangeLog ChangeLog: - (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) + $(CHANGELOG_CMD) dist-hook: ChangeLog diff --git a/configure.ac b/configure.ac index 345b072..9c5b5f2 100644 --- a/configure.ac +++ b/configure.ac @@ -26,17 +26,25 @@ AC_INIT(xpr,[1.0.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],x AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE +# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG +m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.2) + AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL +XORG_CWARNFLAGS + # Checks for pkg-config packages PKG_CHECK_MODULES(XPR, xmuu x11) +XPR_CFLAGS="$CWARNFLAGS $XPR_CFLAGS" AC_SUBST(XPR_CFLAGS) AC_SUBST(XPR_LIBS) XORG_MANPAGE_SECTIONS XORG_RELEASE_VERSION +XORG_CHANGELOG AC_OUTPUT([Makefile]) @@ -69,6 +69,7 @@ from the X Consortium. #include <stdio.h> +#include <stdarg.h> #include <X11/Xlib.h> #include <X11/XWDFile.h> @@ -258,7 +259,11 @@ static void write_image ( int scale, enum orientation orient, enum device device); -static void fatal_err (const char *s, ...); +static void fatal_err (const char *s, ...) +#if defined(__GNUC__) && (__GNUC__ > 2) +__attribute__((noreturn, format(printf, 1, 2))) +#endif + ; /* Computes the centipoint width of one printer dot. */ @@ -478,7 +483,8 @@ void scale_and_orient_image ( break; case PJET: *density = 90; break; - case PJETXL: *density = 180; + case PJETXL: + default: *density = 180; break; } } @@ -491,7 +497,7 @@ void scale_and_orient_image ( set_image_limits(*scale, *density, *orient, usable); /* Determine header/trailer string length clipping */ - set_header_trailer_limits(header, trailer, usable.width); + set_header_trailer_limits((char *)header, (char *)trailer, usable.width); /* Calculate locations for page layout */ set_print_locations(*scale, *density, top, left, @@ -500,7 +506,7 @@ void scale_and_orient_image ( } -unsigned short fullintensity; +static unsigned short fullintensity; #define BLACK 1 #define WHITE 0 @@ -514,20 +520,20 @@ unsigned short fullintensity; * numbers into a pjcolor index number. This style of mapping is done when * interpreting non-Direct/TrueColor visual types. */ -long *colormap; +static long *colormap; /* Pjcolor array is used to hold the scaled RGB triple values * programmed into the printer. */ -long pjcolor[MAX_PJ_COLOR]; +static long pjcolor[MAX_PJ_COLOR]; static int color_warning_given = FALSE; /* Global visual type indicator, used to select color interpretation method. */ -char Direct_or_TrueColor; +static char Direct_or_TrueColor; /* Color index element definition, these are linked into a circular list @@ -545,7 +551,7 @@ typedef struct colorindex { * TrueColor visual types). It also holds color processing switches and a * pointer to the output file to reduce parameter passing overhead. */ -struct { +static struct { int PaintJet; int Invert; unsigned int CutOff; @@ -1061,7 +1067,8 @@ void validate_visual(void) break; default: fatal_err((catgets(nlmsg_fd,NL_SETN,26, - "visual class #%d not supported.\n")), xwd_header.visual_class); + "visual class #%d not supported.\n")), + (int)xwd_header.visual_class); } } @@ -1183,8 +1190,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 +1233,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); @@ -1347,6 +1354,9 @@ unsigned long Z_image_pixel (int x, int y) (unsigned long)*(image+2) << 16 | (unsigned long)*(image+3) << 24); break; + default: + pixel = 0; + break; } return (pixel & Z_pixel_mask); } @@ -1685,7 +1695,13 @@ void x2jet( static void fatal_err (const char *s, ...) { - fprintf(stderr, "%s: %s\n", progname, s); - exit(EXIT_FAILURE); + va_list ap; + + fprintf(stderr, "%s: ", progname); + va_start(ap, s); + vfprintf(stderr, s, ap); + va_end(ap); + fputc('\n', stderr); + exit(EXIT_FAILURE); } @@ -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)); @@ -95,6 +95,7 @@ void x2pmp(FILE *in, FILE *out, if (head) real_height += FONT_HEIGHT_PIXELS << 1; if (foot) real_height += FONT_HEIGHT_PIXELS << 1; switch(orient) { + default: case PORTRAIT: case UPSIDE_DOWN: scale = min_((p_width - 2*x_pos) / fixed_width, @@ -165,7 +166,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 ; @@ -131,7 +131,7 @@ int debug = 0; #define DEFAULT_CUTOFF ((unsigned int) (0xFFFF * 0.50)) -char *infilename = NULL; +static char *infilename = NULL; char *progname = NULL; typedef struct _grayRec { @@ -140,29 +140,29 @@ typedef struct _grayRec { unsigned long *grayscales; /* pointer to the encoded pixels */ } GrayRec, *GrayPtr; -unsigned long grayscale2x2[] = +static unsigned long grayscale2x2[] = {0, 1, 9, 11, 15}; -unsigned long grayscale3x3[] = +static unsigned long grayscale3x3[] = {0, 16, 68, 81, 325, 341, 349, 381, 383, 511}; -unsigned long grayscale4x4[] = +static unsigned long grayscale4x4[] = {0, 64, 4160, 4161, 20545, 21057, 23105, 23113, 23145, 24169, 24171, 56939, 55275, 55279, 57327, 65519, 65535}; -GrayRec gray2x2 = {sizeof(grayscale2x2)/sizeof(long), 2, 2, grayscale2x2}; -GrayRec gray3x3 = {sizeof(grayscale3x3)/sizeof(long), 3, 3, grayscale3x3}; -GrayRec gray4x4 = {sizeof(grayscale4x4)/sizeof(long), 4, 4, grayscale4x4}; +static GrayRec gray2x2 = {sizeof(grayscale2x2)/sizeof(long), 2, 2, grayscale2x2}; +static GrayRec gray3x3 = {sizeof(grayscale3x3)/sizeof(long), 3, 3, grayscale3x3}; +static GrayRec gray4x4 = {sizeof(grayscale4x4)/sizeof(long), 4, 4, grayscale4x4}; /* mapping tables to map a byte in to the hex representation of its * bit-reversal */ -const +static const char hex1[]="084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f\ 084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f\ 084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f\ 084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f084c2a6e195d3b7f"; -const +static const char hex2[]="000000000000000088888888888888884444444444444444cccccccccccccccc\ 2222222222222222aaaaaaaaaaaaaaaa6666666666666666eeeeeeeeeeeeeeee\ 111111111111111199999999999999995555555555555555dddddddddddddddd\ @@ -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)[], @@ -423,6 +418,7 @@ int main(int argc, char **argv) if (device == PS) { iw = win.pixmap_width; ih = win.pixmap_height; + sixmap = NULL; } else { /* calculate w and h cell count */ iw = win.pixmap_width; @@ -459,8 +455,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 +1127,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)[]; @@ -1288,7 +1274,7 @@ void dump_prolog(int flags) #else /* XPROLOG */ /* postscript "programs" to unpack and print the bitmaps being sent */ -const +static const char *ps_prolog_compact[] = { "%%Pages: 1", "%%EndProlog", @@ -1359,10 +1345,10 @@ char *ps_prolog_compact[] = { " { bitgen }", " image", " } def", - 0 + NULL }; -const +static const char *ps_prolog[] = { "%%Pages: 1", "%%EndProlog", @@ -1391,7 +1377,7 @@ char *ps_prolog[] = { " { currentfile picstr readhexstring pop }", " image", "} def", - 0 + NULL }; static @@ -1548,56 +1534,23 @@ void ps_setup( } } -const +static const char *ps_epilog[] = { "", "showpage", "%%Trailer", - 0 + NULL }; static void ps_finish(void) { - char **p = ps_epilog; + char **p = (char **)ps_epilog; while (*p) printf("%s\n",*p++); } 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, @@ -1779,7 +1732,7 @@ void ps_output_bits( * to avoid special cases at the boundaries */ obuf = malloc((unsigned)(owidth*oheight)); - if (obuf==0) { + if (obuf==NULL) { fprintf(stderr,"xpr: cannot allocate %d bytes\n",owidth*oheight); exit(1); } @@ -1817,7 +1770,7 @@ void ps_output_bits( } } -const +static const unsigned char _reverse_byte[0x100] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, |