xv stable port information

Package: xv

Version: 3.10a
Revision: 30

#Maintainer: Eric Lee
Maintainer: Daniel Macks
BuildDepends: <<
fink (>= 0.24.12-1),
fink-package-precedence,
libjasper.1,
libjpeg8,
libpng14,
libtiff,
x11-dev
<<
Depends: <<
ghostscript,
libjasper.1-shlibs,
libjpeg8-shlibs,
libpng14-shlibs,
libtiff-shlibs,
x11
<<

# main program, long-unattended upstream
Source: mirror:custom:xv-%v.tar.gz
CustomMirror: <<
Primary: ftp://ftp.cis.upenn.edu/pub/xv
Secondary: http://www.mirrorservice.org/sites/ftp.cis.upenn.edu/pub/xv
<<
Source-MD5: 2d4fbeec1561304362781cc8e2f7f72d

# large 3rd-party patchset, used in fink up to xv-3.10a-24
#Source2: ftp://ftp.lair.net/pub/unix/graphics/xv/xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch.gz
#Source2: mirror:master:/xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch.gz
#Source2-MD5: f627d0d86b7c948f0b5e389e53271883
#ftp.lair.net no longer hosts the patchfile we need, but opendarwin has it.
#kurt is also hosting a copy at:
#http://schwehr.org/software/xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch.gz
#^--no longer using this patch set

# semi-regularly-updated 3rd-party patchset, fink xv-3.10a-25 is jumbo-20070520
Source2: mirror:sourceforge:png-mng/xv-3.10a-jumbo-patches-20070520.tar.gz
Source2-MD5: 9fb2d0ec320498105cafeba38a588472

#Source3: http://www.sonic.net/~roelofs/code/xv-3.10a-enhancements.20070520-20081216.diff
#^-- incorporated into .patch

PatchFile: %n.patch
PatchFile-MD5: 149800a45bab1f2d8e5cfc2041f7222d
PatchScript: <<
# first apply public 3rd-party stuff
# gunzip --stdout ../xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch.gz | patch -p1
patch -p1 < ../xv-3.10a-jumbo-fix-enh-patch-20070520.txt

# then other stuff
patch -p1 < %{PatchFile}
# perl -pi -e 's,/usr/local,%p,' Makefile
perl -pi -e 's,^(TIFF|JPEG|PNG|JP2K)DIR = .*,\1DIR = %p,' Makefile
<<
CompileScript: <<
make PREFIX=%p
fink-package-precedence --depfile-ext='\.d' .
<<
InstallScript: make install PREFIX=%p DESTDIR=%d
DocFiles: docs/*
Description: Image viewer
DescDetail: <<
xv is an interactive image manipulation program for the X Window
System. It can operate on images in the GIF, JPEG, TIFF, PBM, PGM,
PPM, XPM, X11 bitmap, Sun Rasterfile, Targa, RLE, RGB, BMP, PCX, FITS,
PM, PM, MAG, PIC, MAKI, PI and PICS formats on all known types of X
displays. It can generate PostScript files, and if you have
ghostscript (version 2.6 or above) installed on your machine, it can
also display them.
<<
DescPackaging: <<
Fink's xv-3.10a-24 is a concatenation of many patches:
Fixes for huge patch file by Remi Mommsen

Maintained through 3.10a-24 by Eric Lee, dmacks now surrogate parent.

SourceN patches are semi-official public stuff:
Fink's xv-3.10a-24.1 and -25 is 20070520 from http://www.sonic.net/~roelofs/greg_xv.html

Fink's package revision 29 also includes:
http://www.sonic.net/~roelofs/code/xv-3.10a-enhancements.20070520-20081216.diff
in xv.patch

Patched Makefile to use Fink's graphics-libs
Patched xv.h and vdcomp.c to understand darwin headers

Should re-incorporate parts of old .patch suite...eventually...

Upgrade libpng support for runtime version introspection.

Fix some libpng14 deprecation warnings. These became errors in
libpng15 (cannot upgrade dep until all fixed).
<<
License: Restrictive
Homepage: http://www.trilon.com/xv/index.html


xv stable port .patch

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 + for (col=0, xP=pic24+(row*cols*3); col + CARD32 ul;

- if (byte_order == MSBFirst) {
- for (row=0; row - for (col=0, xP=pic24+(row*cols*3); col - register CARD32 ul = getpixnum(ifp);
+ ul = getpixnum(ifp);
+ switch (bits_per_pixel) {
+ case 16:
+ case 24:
+ case 32:
+ /* SJT: shift all the way to the right and then shift left. The
+ pairs of shifts could be combined. There will be two right and
+ one left shift, but it's unknown which will be which. It seems
+ easier to do the shifts (which might be 0) separately than to
+ have a complex set of tests. I believe this is independent of
+ byte order but I have no way to test.
+ */
+ *xP++ = ((ul & red_mask) >> 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 + default:
+ xwdError("True/Direct supports only 16, 24, and 32 bits");
+ return 0;
+ }
}
- } else {
- for (row=0; row - for (col=0, xP=pic24+(row*cols*3); col - register CARD32 ul = getpixnum(ifp);

- *xP++ = ul >> blue_shift & blue_mask ;
- *xP++ = ul >> green_shift & green_mask;
- *xP++ = ul >> red_shift & red_mask ;
- };
- for (col=0; col - }
+ for (col=0; col }

pinfo->type = 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;

xv _unstable_ port .patch