diff -Nurd -x'*~' xv-3.10a.orig/Makefile xv-3.10a/Makefile --- xv-3.10a.orig/Makefile 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/Makefile 2011-08-11 12:18:52.000000000 -0400 @@ -1,7 +1,7 @@ # Makefile for xv # your C compiler (and options) of choice -CC = cc +CC = gcc #CC = gcc -ansi # note that -ansi kills __USE_MISC (gcc 2.95.3), which, at least on Linux, # determines whether stdlib.h includes prototypes for mktemp(), random(), etc. @@ -18,7 +18,7 @@ # -Wuninitialized -Wparentheses -CCOPTS = -O +CCOPTS = -Os -Wall -pipe -MD # # these are the usual optimization and warning options for gcc; all such # warnings but one (mktemp() use) have been eliminated (at least on Linux): @@ -62,7 +62,7 @@ MANSUF = 1 DOCDIR = $(PREFIX)/share/doc/xv LIBDIR = $(PREFIX)/lib/xv -SYSCONFDIR = /etc +SYSCONFDIR = $(PREFIX)/etc DESTDIR = @@ -164,10 +164,10 @@ #ZLIBDIR = /usr/local #ZLIBDIR = ../../zlib ### -ZLIBINC = -I$(ZLIBDIR)/include +#ZLIBINC = -I$(ZLIBDIR)/include #ZLIBINC = -I$(ZLIBDIR) ### -ZLIBLIB = -L$(ZLIBDIR)/lib -lz +ZLIBLIB = -lz #ZLIBLIB = -L$(ZLIBDIR) -lz #ZLIBLIB = $(ZLIBDIR)/libz.a @@ -182,10 +182,10 @@ JP2KDIR = /usr/local/lib ### #JP2KINC = -I$(JP2KDIR) -JP2KINC = -I/usr/local/include +JP2KINC = -I$(JP2KDIR)/include ### #JP2KLIB = -L$(JP2KDIR) -ljasper -JP2KLIB = $(JP2KDIR)/libjasper.a +JP2KLIB = -L$(JP2KDIR)/lib -ljasper ### @@ -339,7 +339,7 @@ $(TIFF) $(TIFFINC) $(PDS) $(JP2K) $(JP2KINC) $(TVL10N) $(MGCSFX) \ $(UNIX) $(BSDTYPES) $(RAND) $(MALLOC) $(DXWM) $(MCHN) $(NODIRENT) \ $(VPRINTF) $(TIMERS) -DDOCDIR=\"$(DOCDIR)\" \ - -DSYSCONFDIR=\"$(SYSCONFDIR)\" -DXVEXECPATH=\"$(LIBDIR)\" + -DSYSCONFDIR=\"$(SYSCONFDIR)\" -DXVEXECPATH=\"$(LIBDIR)\" -I/usr/X11R6/include ### remove -lm for BeOS: LIBS = $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIBLIB) $(JP2KLIB) -L/usr/X11R6/lib -lX11 -lm diff -Nurd -x'*~' xv-3.10a.orig/vdcomp.c xv-3.10a/vdcomp.c --- xv-3.10a.orig/vdcomp.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/vdcomp.c 2011-08-11 12:18:52.000000000 -0400 @@ -119,7 +119,7 @@ !defined(__FreeBSD__) && \ !defined(__OpenBSD__) && \ !defined(__NetBSD__) && \ - !defined(__DARWIN__) + !defined(__APPLE__) # if defined(hp300) || defined(hp800) || defined(NeXT) # include /* it's in "sys" on HPs and NeXT */ diff -Nurd -x'*~' xv-3.10a.orig/xv.h xv-3.10a/xv.h --- xv-3.10a.orig/xv.h 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xv.h 2011-08-11 12:19:03.000000000 -0400 @@ -16,8 +16,9 @@ /* GRR 2nd public jumbo F+E patches: 20050410 */ /* GRR 3rd public jumbo F+E patches: 20050501 */ /* GRR 4th public jumbo F+E patch: 20070520 */ -#define REVDATE "version 3.10a-jumboFix+Enh of 20070520" -#define VERSTR "3.10a-20070520" +/* GRR 5th public jumbo F+E patch: 200xxxxx (probably mid-2009) */ +#define REVDATE "version 3.10a-jumboFix+Enh of 20081216 (interim!)" +#define VERSTR "3.10a-20081216" /* * uncomment the following, and modify for your site, but only if you've @@ -158,7 +159,7 @@ #ifndef VMS # include -# ifndef __NetBSD__ +# if !(defined __NetBSD__ || defined __APPLE__) # if !(defined __GLIBC__ && __GLIBC__ >= 2) extern int errno; /* SHOULD be in errno.h, but often isn't */ extern char *sys_errlist[]; /* this too... */ diff -Nurd -x'*~' xv-3.10a.orig/xvdir.c xv-3.10a/xvdir.c --- xv-3.10a.orig/xvdir.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xvdir.c 2011-08-11 12:19:03.000000000 -0400 @@ -539,8 +539,9 @@ return -1; } - /* handle clicks inside the filename box */ - if (x > 80 && + /* handle clicks inside the filename box, but only when box is not empty */ + if (enPos > stPos && + x > 80 && y > dList.y + (int) dList.h + 30 && x < 80 + DNAMWIDE+6 && y < dList.y + (int) dList.h + 30 + LINEHIGH+5) { diff -Nurd -x'*~' xv-3.10a.orig/xvgif.c xv-3.10a/xvgif.c --- xv-3.10a.orig/xvgif.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xvgif.c 2011-08-11 12:19:03.000000000 -0400 @@ -700,7 +700,7 @@ * associated output code on the output queue. */ - while (CurCode > BitMask) { + while (CurCode >= ClearCode) { /* Joe Zbiciak fix, 20070621 */ if (OutCount > 4096) break; /* corrupt file */ OutCode[OutCount++] = Suffix[CurCode]; CurCode = Prefix[CurCode]; diff -Nurd -x'*~' xv-3.10a.orig/xviff.c xv-3.10a/xviff.c --- xv-3.10a.orig/xviff.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xviff.c 2011-08-11 12:19:03.000000000 -0400 @@ -73,6 +73,7 @@ int BMHDok, CMAPok, CAMGok; int bmhd_width, bmhd_height, bmhd_bitplanes, bmhd_transcol; int i, j, k, lineskip, colors, fmt; + int npixels = 0; /* needs to be initialized _outside_ while-loop */ byte bmhd_masking, bmhd_compression; long chunkLen, camg_viewmode; byte *databuf, *dataptr, *cmapptr, *picptr, *pic, *bodyptr; @@ -138,7 +139,6 @@ BODY chunk was found or dataptr ran over end of file */ while ((rv<0) && (dataptr < (databuf + filesize))) { - int npixels = 0; chunkLen = (iff_getlong(dataptr + 4) + 1) & 0xfffffffe; /* make even */ if (strncmp((char *) dataptr, "BMHD", (size_t) 4)==0) { /* BMHD chunk? */ diff -Nurd -x'*~' xv-3.10a.orig/xvmisc.c xv-3.10a/xvmisc.c --- xv-3.10a.orig/xvmisc.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xvmisc.c 2011-08-11 12:19:03.000000000 -0400 @@ -561,10 +561,6 @@ if (mgcsfxW) XDestroyWindow(theDisp, mgcsfxW); #endif -#ifdef HAVE_PNG - if (pngW) XDestroyWindow(theDisp, pngW); -#endif - /* if NOT using stdcmap for images, free stdcmap */ if (colorMapMode != CM_STDCMAP) { int j; diff -Nurd -x'*~' xv-3.10a.orig/xvpng.c xv-3.10a/xvpng.c --- xv-3.10a.orig/xvpng.c 2007-05-13 20:53:28.000000000 -0400 +++ xv-3.10a/xvpng.c 2011-08-11 12:38:57.000000000 -0400 @@ -32,6 +32,7 @@ #ifdef HAVE_PNG #include "png.h" +#include "zlib.h" /*** Stuff for PNG Dialog box ***/ #define PWIDE 318 @@ -458,7 +459,7 @@ FatalError(software); } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); return -1; } @@ -921,7 +922,7 @@ FatalError("malloc failure in LoadPNG"); } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(png_jmpbuf(png_ptr))) { fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); if (!read_anything) { @@ -985,7 +986,7 @@ ", %sinterlaced. (%d bytes)", info_ptr->interlace_type ? "" : "non-", filesize); - sprintf(pinfo->shrtInfo, "%lux%lu PNG", info_ptr->width, info_ptr->height); + sprintf(pinfo->shrtInfo, "%ux%u PNG", info_ptr->width, info_ptr->height); if (info_ptr->bit_depth < 8) png_set_packing(png_ptr); @@ -1143,7 +1144,7 @@ { SetISTR(ISTR_WARNING,"%s: libpng error: %s", fbasename, message); - longjmp(png_ptr->jmpbuf, 1); + longjmp(png_jmpbuf(png_ptr), 1); } @@ -1165,7 +1166,7 @@ VersionInfoPNG() /* GRR 19980605 */ { fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); + PNG_LIBPNG_VER_STRING, png_get_header_ver(NULL)); fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", ZLIB_VERSION, zlib_version); } diff -Nurd -x'*~' xv-3.10a.orig/xvxwd.c xv-3.10a/xvxwd.c --- xv-3.10a.orig/xvxwd.c 2011-08-11 12:17:34.000000000 -0400 +++ xv-3.10a/xvxwd.c 2011-08-11 12:19:03.000000000 -0400 @@ -19,6 +19,12 @@ */ #include "xv.h" +#include /* for CHAR_BIT */ + +/* SJT: just in case ... */ +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif /***************************** x11wd.h *****************************/ @@ -83,9 +89,14 @@ static int writebiglong PARM((FILE *, CARD32)); #endif +static void getcolorshift PARM((CARD32, int *, int *)); /* SJT */ + +/* SJT: for 16bpp and 24bpp shifts */ +static int red_shift_right, red_justify_left, + grn_shift_right, grn_justify_left, + blu_shift_right, blu_justify_left; static byte *pic8, *pic24; -static CARD32 red_mask, green_mask, blue_mask; -static int red_shift, green_shift, blue_shift; +static CARD32 red_mask, grn_mask, blu_mask; static int bits_per_item, bits_used, bit_shift, bits_per_pixel, bits_per_rgb; static char buf[4]; @@ -189,38 +200,34 @@ return 0; } - switch (bits_per_pixel) { - case 16: - case 24: - case 32: - ; - default: - xwdError("True/Direct supports only 16, 24, and 32 bits"); - return 0; - } + for (row=0; row> red_shift_right) << red_justify_left; + *xP++ = ((ul & grn_mask) >> grn_shift_right) << grn_justify_left; + *xP++ = ((ul & blu_mask) >> blu_shift_right) << blu_justify_left; + break; - *xP++ = ul >> red_shift & red_mask ; - *xP++ = ul >> green_shift & green_mask; - *xP++ = ul >> blue_shift & blue_mask ; - }; - for (col=0; col> blue_shift & blue_mask ; - *xP++ = ul >> green_shift & green_mask; - *xP++ = ul >> red_shift & red_mask ; - }; - for (col=0; coltype = PIC24; @@ -445,28 +452,18 @@ (i.e., 3 bytes, no alpha/padding) */ - bits_used = bits_per_item; + bits_used = bits_per_item; if (bits_per_pixel == sizeof(pixel_mask) * 8) pixel_mask = (CARD32) -1; else pixel_mask = (1 << bits_per_pixel) - 1; - red_mask = h11P->red_mask; - green_mask = h11P->grn_mask; - blue_mask = h11P->blu_mask; + red_mask = h11P->red_mask; + grn_mask = h11P->grn_mask; + blu_mask = h11P->blu_mask; - red_shift = blue_shift = green_shift = 0; - while (!(red_mask & 1)) { - red_mask >>= 1; - ++red_shift; - } - while (!(blue_mask & 1)) { - blue_mask >>= 1; - ++blue_shift; - } - while (!(green_mask & 1)) { - green_mask >>= 1; - ++green_shift; - } + getcolorshift(red_mask, &red_shift_right, &red_justify_left); + getcolorshift(grn_mask, &grn_shift_right, &grn_justify_left); + getcolorshift(blu_mask, &blu_shift_right, &blu_justify_left); byteP = (char *) buf; shortP = (CARD16 *) buf; @@ -476,6 +473,45 @@ } +/* SJT: figure out the proper shifts */ +static void getcolorshift (CARD32 mask, int *rightshift, int *leftshift) +{ + int lshift, rshift; + unsigned int uu; + + if (mask == 0) + { + *rightshift = *leftshift = 0; + return; + } + + uu = mask; + lshift = rshift = 0; + while ((uu & 0xf) == 0) + { + rshift += 4; + uu >>= 4; + } + while ((uu & 1) == 0) + { + rshift++; + uu >>= 1; + } + + while (uu != 0) + { + if (uu & 1) + { + lshift++; + uu >>= 1; + } + } + *rightshift = rshift; + *leftshift = CHAR_BIT * sizeof(pixel) - lshift; + return; +} + + /******************************/ static CARD32 getpixnum(file) FILE* file;