pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/graphics/xv



Module Name:    pkgsrc
Committed By:   tsutsui
Date:           Thu Feb 21 14:32:32 UTC 2019

Modified Files:
        pkgsrc/graphics/xv: PLIST distinfo options.mk
Added Files:
        pkgsrc/graphics/xv/patches: patch-Imakefile patch-config.h
            patch-vdcomp.c patch-xv.h patch-xvinfo.c patch-xvpcd.c
            patch-xvpng.c
Removed Files:
        pkgsrc/graphics/xv/patches: patch-aa patch-ab patch-ac patch-ad
            patch-ae patch-af patch-ag

Log Message:
xv: rename patches for maintainability, and also fix pkglint warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 pkgsrc/graphics/xv/PLIST
cvs rdiff -u -r1.22 -r1.23 pkgsrc/graphics/xv/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/graphics/xv/options.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-Imakefile \
    pkgsrc/graphics/xv/patches/patch-config.h \
    pkgsrc/graphics/xv/patches/patch-vdcomp.c \
    pkgsrc/graphics/xv/patches/patch-xv.h \
    pkgsrc/graphics/xv/patches/patch-xvinfo.c \
    pkgsrc/graphics/xv/patches/patch-xvpcd.c \
    pkgsrc/graphics/xv/patches/patch-xvpng.c
cvs rdiff -u -r1.5 -r0 pkgsrc/graphics/xv/patches/patch-aa \
    pkgsrc/graphics/xv/patches/patch-ae pkgsrc/graphics/xv/patches/patch-ag
cvs rdiff -u -r1.10 -r0 pkgsrc/graphics/xv/patches/patch-ab
cvs rdiff -u -r1.11 -r0 pkgsrc/graphics/xv/patches/patch-ac
cvs rdiff -u -r1.12 -r0 pkgsrc/graphics/xv/patches/patch-ad
cvs rdiff -u -r1.9 -r0 pkgsrc/graphics/xv/patches/patch-af

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/graphics/xv/PLIST
diff -u pkgsrc/graphics/xv/PLIST:1.6 pkgsrc/graphics/xv/PLIST:1.7
--- pkgsrc/graphics/xv/PLIST:1.6        Sun Jun 14 17:59:32 2009
+++ pkgsrc/graphics/xv/PLIST    Thu Feb 21 14:32:32 2019
@@ -1,14 +1,14 @@
-@comment $NetBSD: PLIST,v 1.6 2009/06/14 17:59:32 joerg Exp $
+@comment $NetBSD: PLIST,v 1.7 2019/02/21 14:32:32 tsutsui Exp $
 bin/bggen
 bin/vdcomp
 bin/xcmap
 bin/xv
 bin/xvpictoppm
 lib/X11/xv_mgcsfx.sample
-${IMAKE_MAN_DIR}/xv.${IMAKE_MANNEWSUFFIX}
-${IMAKE_MAN_DIR}/bggen.${IMAKE_MANNEWSUFFIX}
-${IMAKE_MAN_DIR}/vdcomp.${IMAKE_MANNEWSUFFIX}
-${IMAKE_MAN_DIR}/xcmap.${IMAKE_MANNEWSUFFIX}
-${IMAKE_MAN_DIR}/xvpictoppm.${IMAKE_MANNEWSUFFIX}
+${IMAKE_MAN_DIR}/xv.${IMAKE_MAN_SUFFIX}
+${IMAKE_MAN_DIR}/bggen.${IMAKE_MAN_SUFFIX}
+${IMAKE_MAN_DIR}/vdcomp.${IMAKE_MAN_SUFFIX}
+${IMAKE_MAN_DIR}/xcmap.${IMAKE_MAN_SUFFIX}
+${IMAKE_MAN_DIR}/xvpictoppm.${IMAKE_MAN_SUFFIX}
 share/doc/xv/README
 share/doc/xv/xvdocs.ps

Index: pkgsrc/graphics/xv/distinfo
diff -u pkgsrc/graphics/xv/distinfo:1.22 pkgsrc/graphics/xv/distinfo:1.23
--- pkgsrc/graphics/xv/distinfo:1.22    Thu Feb 21 01:37:14 2019
+++ pkgsrc/graphics/xv/distinfo Thu Feb 21 14:32:32 2019
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.22 2019/02/21 01:37:14 tsutsui Exp $
+$NetBSD: distinfo,v 1.23 2019/02/21 14:32:32 tsutsui Exp $
 
 SHA1 (xv-3.10a-enhancements.20070520-20081216.diff) = 40bfb0889b820e0f9d3bd7d771144ec3458acc66
 RMD160 (xv-3.10a-enhancements.20070520-20081216.diff) = dbd4ab25b5b62fb543befcf655d928db3a77e005
@@ -12,10 +12,10 @@ SHA1 (xv-3.10a.tar.gz) = 9e6372f154be9e9
 RMD160 (xv-3.10a.tar.gz) = 7d545e0c0e5b0120a7d026ea549cba19a53fbc0d
 SHA512 (xv-3.10a.tar.gz) = 5b8c5890503e2796638921cabae8967e458c73e332acea8561b1025ed13c771bc44c0e309b4592852e33726eeaa9784f933d1312073b0ba2e0b8c0cedabcaa3f
 Size (xv-3.10a.tar.gz) = 2259124 bytes
-SHA1 (patch-aa) = bd6ef51bf962e1994e2e47ba5197c9729ec5221a
-SHA1 (patch-ab) = 5bfc8ae09b029e4661b27d94bba46540c7f320fb
-SHA1 (patch-ac) = 66430e80d9a17f772abefd14d00af0b5a0f88100
-SHA1 (patch-ad) = 9447ae45ac67f2f9ef7eead8a6a21902f0c7922e
-SHA1 (patch-ae) = 2bda08bae67fcf127c49b9ed780b7a247579c088
-SHA1 (patch-af) = 7f6e771788e04577d8db17bfe8fbcce8dca4a600
-SHA1 (patch-ag) = 120d589f728fd32ea267fd46bcc16f27d9f08116
+SHA1 (patch-Imakefile) = e27d7d2f110d4edbce9a5d236e45a556714b5be0
+SHA1 (patch-config.h) = fd0ef6bbf774a57dd0bb94676927dcc6eeef1014
+SHA1 (patch-vdcomp.c) = 4c603cdc2c01925fed283b2aa6030d1933cdaddc
+SHA1 (patch-xv.h) = 894c5a9d4e1cb5fb18a9914c75408b67f1e6e5d4
+SHA1 (patch-xvinfo.c) = 33b2392de259f1380e5be180f8e7293a9551fc52
+SHA1 (patch-xvpcd.c) = 1825015f441b9af91916f9a62e8d1dee6ddfdef9
+SHA1 (patch-xvpng.c) = 2bda08bae67fcf127c49b9ed780b7a247579c088

Index: pkgsrc/graphics/xv/options.mk
diff -u pkgsrc/graphics/xv/options.mk:1.1 pkgsrc/graphics/xv/options.mk:1.2
--- pkgsrc/graphics/xv/options.mk:1.1   Thu Feb 21 06:00:22 2019
+++ pkgsrc/graphics/xv/options.mk       Thu Feb 21 14:32:32 2019
@@ -1,8 +1,8 @@
-# $NetBSD: options.mk,v 1.1 2019/02/21 06:00:22 tsutsui Exp $
+# $NetBSD: options.mk,v 1.2 2019/02/21 14:32:32 tsutsui Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.xv
 PKG_SUPPORTED_OPTIONS= ghostscript
-PKG_SUGGESTED_OPTIONS= 
+PKG_SUGGESTED_OPTIONS=
 
 .include "../../mk/bsd.options.mk"
 

Added files:

Index: pkgsrc/graphics/xv/patches/patch-Imakefile
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-Imakefile:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-Imakefile  Thu Feb 21 14:32:32 2019
@@ -0,0 +1,122 @@
+$NetBSD: patch-Imakefile,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- use jpeg, png, tiff, and zlib from pkgsrc
+- make ghostscript support optional
+
+--- Imakefile.orig     2019-02-21 14:07:37.512579350 +0000
++++ Imakefile
+@@ -6,13 +6,15 @@
+ /* if, for whatever reason, you're unable to get the JPEG library to compile
+  * on your machine, *COMMENT OUT* the following line
+  */
+-#define HaveJpeg
++/* #define HaveJpeg */
++#define UseInstalledJpeg
+ 
+ 
+ /* if, for whatever reason, you're unable to get the TIFF library to compile
+  * on your machine, *COMMENT OUT* the following line
+  */
+-#define HaveTiff
++/* #define HaveTiff */
++#define UseInstalledTiff
+ 
+ 
+ /* if, for whatever reason, you're unable to get the PDS/VICAR support
+@@ -21,6 +23,10 @@
+ #define HavePDS
+ 
+ 
++/* #define UseInstalledGhostScript */
++#define UseInstalledPng
++#define UseInstalledZlib
++
+ /*
+  * if you are running on a SysV-based machine, such as HP, Silicon Graphics,
+  * etc, uncomment one of the following lines to get you *most* of the way
+@@ -124,20 +130,66 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
+ JPEG = -DDOJPEG
+ JPEGDIR = jpeg
+ LIBJPEG = $(JPEGDIR)/libjpeg.a
++DEPLIBJPEG = $(LIBJPEG)
+ JPEGINCLUDE = -I$(JPEGDIR)
+ #endif
+ 
++#ifdef UseInstalledJpeg
++JPEG = -DDOJPEG
++LIBJPEG = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ljpeg
++JPEGINCLUDE = -I$(PREFIX)/include
++#endif
++
+ #ifdef HaveTiff
+ TIFF = -DDOTIFF
+ TIFFDIR = tiff
+ LIBTIFF = $(TIFFDIR)/libtiff.a
++DEPLIBTIFF = $(LIBTIFF)
+ TIFFINCLUDE = -I$(TIFFDIR)
+ #endif
+ 
++#ifdef UseInstalledTiff
++TIFF = -DDOTIFF
++LIBTIFF = -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ltiff -ljpeg -lz
++TIFFINCLUDE = -I$(PREFIX)/include
++#endif
++
+ #ifdef HavePDS
+ PDS = -DDOPDS
+ #endif
+ 
++#ifdef UseInstalledGhostScript
++GS = -DDOGS
++#endif
++
++/*
++###
++### if, for whatever reason, you're unable to get the PNG library to compile
++### on your machine, *COMMENT OUT* the following lines
++###
++*/
++#ifdef UseInstalledPng
++PNG    = -DDOPNG
++PNGDIR = ${PREFIX}
++PNGINC = -I$(PNGDIR)/include
++PNGLIB = -L$(PNGDIR)/lib -lpng -lz
++LIBPNG = ${PNGLIB}
++PNGINCLUDE = ${PNGINC}
++#endif
++
++/*
++###
++### if, for whatever reason, you're unable to get the PNG library to compile
++### on your machine, *COMMENT OUT* the following lines
++###
++*/
++#ifdef UseInstalledZlib
++ZLIBDIR = $(PREFIX)
++ZLIBINC = -I$(ZLIBDIR)/include
++ZLIBLIB = -L$(ZLIBDIR)/lib -lz
++LIBZLIB = ${ZLIB}
++ZLIBINCLUDE = ${ZLIBINC}
++#endif
+ 
+ #if defined(SCOArchitecture)
+ SCO= -Dsco -DPOSIX -DNO_RANDOM 
+@@ -149,14 +201,14 @@ SYS_LIBRARIES=        -lm
+ #endif
+ 
+ 
+-DEPLIBS = $(LIBJPEG) $(LIBTIFF)
+-LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS)
++DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBZLIB)
++LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBZLIB)
+ 
+ DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
+-      $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
++      $(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(PDS) $(DXWM) $(RAND) \
+       $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX)
+ 
+-INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)
++INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(ZLIBINCLUDE)
+ 
+ SRCS1 =       xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \
+       xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c xvalg.c \
Index: pkgsrc/graphics/xv/patches/patch-config.h
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-config.h:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-config.h   Thu Feb 21 14:32:32 2019
@@ -0,0 +1,23 @@
+$NetBSD: patch-config.h,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- make ghostscript support optional
+- use pkgsrc ${PREFIX} for ghostscript files
+
+--- config.h.orig      2019-02-21 14:07:37.592173395 +0000
++++ config.h
+@@ -112,10 +112,12 @@
+  * should not need to be changed
+  */
+ 
++#ifdef DOGS
+ /* #define GS_PATH "/usr/local/bin/gs" */
+-#define GS_PATH "gs"
+-/* #define GS_LIB  "."                 */
+-/* #define GS_DEV  "ppmraw"            */
++#define GS_PATH "@PREFIX@/bin/gs"
++#define GS_LIB "@PREFIX@/share/ghostscript"
++#define GS_DEV "ppmraw"
++#endif
+ 
+ 
+ /***************************************************************************
Index: pkgsrc/graphics/xv/patches/patch-vdcomp.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-vdcomp.c:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-vdcomp.c   Thu Feb 21 14:32:32 2019
@@ -0,0 +1,48 @@
+$NetBSD: patch-vdcomp.c,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- don't use malloc.h
+
+--- vdcomp.c.orig      2019-02-21 14:07:37.726880361 +0000
++++ vdcomp.c
+@@ -96,41 +96,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+-/* include a malloc.h of some sort (if needed...most systems use stdlib.h) */
+-#ifndef VMS   /* VMS hates multi-line "#if"s */
+-   /*
+-    * I want to use BSD macro for checking if this OS is *BSD or not,
+-    * but the macro is defined in <sys/parm.h>, which I don't know all
+-    * machine has or not.
+-    */
+-#  if !defined(ibm032)                    && \
+-      !defined(__convex__)                && \
+-      !(defined(vax) && !defined(ultrix)) && \
+-      !defined(mips)                      && \
+-      !defined(apollo)                    && \
+-      !defined(pyr)                       && \
+-      !defined(sequent)                   && \
+-      !defined(__UMAXV__)                 && \
+-      !defined(aux)                       && \
+-      !defined(bsd43)                     && \
+-      !defined(__bsd43)                   && \
+-      !defined(__bsdi__)                  && \
+-      !defined(__386BSD__)                && \
+-      !defined(__FreeBSD__)               && \
+-      !defined(__OpenBSD__)               && \
+-      !defined(__NetBSD__)                && \
+-      !defined(__DARWIN__)
+-
+-#    if defined(hp300) || defined(hp800) || defined(NeXT)
+-#      include <sys/malloc.h>    /* it's in "sys" on HPs and NeXT */
+-#    else
+-#      include <malloc.h>        /* FIXME: should explicitly list systems that NEED this, not everyone that doesn't */
+-#    endif
+-
+-#  endif /* !most modern systems */
+-#endif /* !VMS */
+-
+-
+ #include <X11/Xos.h>
+ 
+ #define TRUE         1
Index: pkgsrc/graphics/xv/patches/patch-xv.h
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xv.h:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-xv.h       Thu Feb 21 14:32:32 2019
@@ -0,0 +1,57 @@
+$NetBSD: patch-xv.h,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- don't declare errno and sys_errlist
+- use strerror
+- use getcwd, not getwd
+
+--- xv.h.orig  2019-02-21 14:07:38.801848956 +0000
++++ xv.h
+@@ -139,9 +139,7 @@
+ #endif
+ 
+ 
+-#if defined(__FreeBSD__)
+-#  include <sys/param.h>
+-#endif
++#include <sys/param.h>
+ 
+ 
+ /* include files */
+@@ -160,7 +158,7 @@
+ #ifndef VMS
+ #  include <errno.h>
+ #  ifndef __NetBSD__
+-#    if !(defined __GLIBC__ && __GLIBC__ >= 2)
++#    if !(defined(BSD) && (BSD >= 199103)) && !(defined __GLIBC__ && __GLIBC__ >= 2)
+        extern int   errno;         /* SHOULD be in errno.h, but often isn't */
+        extern char *sys_errlist[]; /* this too... */
+ #    endif
+@@ -172,7 +170,7 @@
+ #ifdef VMS
+ #  define ERRSTR(x) strerror(x, vaxc$errno)
+ #else
+-#  if defined(__BEOS__) || defined(__linux__) /* or all modern/glibc systems? */
++#  if defined(__BEOS__) || defined(__linux__) || defined(__INTERIX) || defined(__sun) /* or all modern/glibc systems? */
+ #    define ERRSTR(x) strerror(x)
+ #  else
+ #    define ERRSTR(x) sys_errlist[x]
+@@ -208,7 +206,9 @@
+ #  if defined(hp300) || defined(hp800) || defined(NeXT)
+ #    include <sys/malloc.h>    /* it's in "sys" on HPs and NeXT */
+ #  else
+-#    include <malloc.h>
++#    ifndef __DARWIN__
++#      include <malloc.h>
++#    endif
+ #  endif
+ #endif
+ 
+@@ -392,7 +392,7 @@
+ #  endif
+ #endif
+ 
+-#if (defined(SYSV) || defined(SVR4) || defined(linux)) && !defined(USE_GETCWD)
++#if (defined(SYSV) || defined(SVR4) || defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) && !defined(USE_GETCWD)
+ #  define USE_GETCWD
+ #endif
+ 
Index: pkgsrc/graphics/xv/patches/patch-xvinfo.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvinfo.c:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-xvinfo.c   Thu Feb 21 14:32:32 2019
@@ -0,0 +1,15 @@
+$NetBSD: patch-xvinfo.c,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- fix a small string buffer that was truncating some libpng messages
+
+--- xvinfo.c.orig      2019-02-21 14:07:38.372613477 +0000
++++ xvinfo.c
+@@ -26,7 +26,7 @@
+ #define INFOHIGH 270
+ 
+ /* max length of an Info String */
+-#define ISTRLEN 80
++#define ISTRLEN 256
+ 
+ /* baseline of top line of text */
+ #define TOPBASE (36 + penn_height/2 + 4 + 8 + ASCENT)
Index: pkgsrc/graphics/xv/patches/patch-xvpcd.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvpcd.c:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-xvpcd.c    Thu Feb 21 14:32:32 2019
@@ -0,0 +1,16 @@
+$NetBSD: patch-xvpcd.c,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+- remove obsolete alloca check
+
+--- xvpcd.c.orig       2007-05-14 01:02:13.000000000 +0000
++++ xvpcd.c
+@@ -30,9 +30,6 @@
+ #ifdef HAVE_PCD
+ 
+ #include <memory.h>
+-#ifndef alloca
+-#  include <alloca.h> /* "not in POSIX or SUSv3" according to Linux man page */
+-#endif                /* ...but required for Sun C compiler (alloca = macro) */
+ 
+ #define  TRACE  0
+ #if TRACE
Index: pkgsrc/graphics/xv/patches/patch-xvpng.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvpng.c:1.1
--- /dev/null   Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-xvpng.c    Thu Feb 21 14:32:32 2019
@@ -0,0 +1,543 @@
+$NetBSD: patch-xvpng.c,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+
+Fix build with libpng 1.5.
+Fix CVE-2017-18215 from https://bugzilla.suse.com/show_bug.cgi?id=1043479
+
+--- xvpng.c.orig       2007-05-14 00:53:28.000000000 +0000
++++ xvpng.c
+@@ -31,6 +31,7 @@
+ 
+ #ifdef HAVE_PNG
+ 
++#include "zlib.h"
+ #include "png.h"
+ 
+ /*** Stuff for PNG Dialog box ***/
+@@ -41,7 +42,7 @@
+ #define COMPRESSION   6     /* default zlib compression level, not max
+                                (Z_BEST_COMPRESSION) */
+ 
+-#define HAVE_tRNS  (info_ptr->valid & PNG_INFO_tRNS)
++#define HAVE_tRNS  (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ 
+ #define DWIDE    86
+ #define DHIGH    104
+@@ -435,6 +436,16 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+ {
+   png_struct *png_ptr;
+   png_info   *info_ptr;
++  struct {
++    /* IHDR */
++    png_uint_32 width;
++    png_uint_32 height;
++    int bit_depth;
++    int color_type;
++    int interlace_type;
++    /* PLTE */
++    int use_palette;
++  } info_tmp;
+   png_color   palette[256];
+   png_textp   text;
+   byte        r1[256], g1[256], b1[256];  /* storage for deduped palette */
+@@ -444,6 +455,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+   byte       *p, *png_line;
+   char        software[256];
+   char       *savecmnt;
++  int         num_text, max_text;
+ 
+   if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
+        png_xv_error, png_xv_warning)) == NULL) {
+@@ -458,7 +470,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+     FatalError(software);
+   }
+ 
+-  if (setjmp(png_ptr->jmpbuf)) {
++  if (setjmp(png_jmpbuf(png_ptr))) {
+     png_destroy_write_struct(&png_ptr, &info_ptr);
+     return -1;
+   }
+@@ -489,8 +501,8 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+     png_set_filter(png_ptr, 0, filter);
+   }
+ 
+-  info_ptr->width = w;
+-  info_ptr->height = h;
++  info_tmp.width = w;
++  info_tmp.height = h;
+   if (w <= 0 || h <= 0) {
+     SetISTR(ISTR_WARNING, "%s:  image dimensions out of range (%dx%d)",
+       fbasename, w, h);
+@@ -498,7 +510,8 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+     return -1;
+   }
+ 
+-  info_ptr->interlace_type = interCB.val ? 1 : 0;
++  info_tmp.interlace_type =
++    interCB.val ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE;
+ 
+   linesize = 0;   /* quiet a compiler warning */
+ 
+@@ -542,40 +555,40 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+         png_destroy_write_struct(&png_ptr, &info_ptr);
+         return -1;
+       }
+-      info_ptr->color_type = PNG_COLOR_TYPE_RGB;
+-      info_ptr->bit_depth = 8;
++      info_tmp.color_type = PNG_COLOR_TYPE_RGB;
++      info_tmp.bit_depth = 8;
++      info_tmp.use_palette = 0;
+     } else /* ptype == PIC8 */ {
+       linesize = w;
+-      info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
++      info_tmp.color_type = PNG_COLOR_TYPE_PALETTE;
+       if (numuniqcols <= 2)
+-        info_ptr->bit_depth = 1;
++        info_tmp.bit_depth = 1;
+       else
+       if (numuniqcols <= 4)
+-        info_ptr->bit_depth = 2;
++        info_tmp.bit_depth = 2;
+       else
+       if (numuniqcols <= 16)
+-        info_ptr->bit_depth = 4;
++        info_tmp.bit_depth = 4;
+       else
+-        info_ptr->bit_depth = 8;
++        info_tmp.bit_depth = 8;
+ 
+       for (i = 0; i < numuniqcols; i++) {
+         palette[i].red   = r1[i];
+         palette[i].green = g1[i];
+         palette[i].blue  = b1[i];
+       }
+-      info_ptr->num_palette = numuniqcols;
+-      info_ptr->palette = palette;
+-      info_ptr->valid |= PNG_INFO_PLTE;
++      info_tmp.use_palette = 1;
+     }
+   }
+ 
+   else if (colorType == F_GREYSCALE || colorType == F_BWDITHER) {
+-    info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
++    info_tmp.color_type = PNG_COLOR_TYPE_GRAY;
++    info_tmp.use_palette = 0;
+     if (colorType == F_BWDITHER) {
+       /* shouldn't happen */
+       if (ptype == PIC24) FatalError("PIC24 and B/W Stipple in WritePNG()");
+ 
+-      info_ptr->bit_depth = 1;
++      info_tmp.bit_depth = 1;
+       if (MONO(r1[0], g1[0], b1[0]) > MONO(r1[1], g1[1], b1[1])) {
+         remap[0] = 1;
+         remap[1] = 0;
+@@ -595,7 +608,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+           png_destroy_write_struct(&png_ptr, &info_ptr);
+           return -1;
+         }
+-        info_ptr->bit_depth = 8;
++        info_tmp.bit_depth = 8;
+       }
+       else /* ptype == PIC8 */ {
+         int low_precision;
+@@ -617,7 +630,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+         for (; i < 256; i++)
+           remap[i]=0;  /* shouldn't be necessary, but... */
+ 
+-        info_ptr->bit_depth = 8;
++        info_tmp.bit_depth = 8;
+ 
+         /* Note that this fails most of the time because of gamma */
+            /* (and that would be a bug:  GRR FIXME) */
+@@ -636,7 +649,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+           for (i = 0; i < numuniqcols; i++) {
+             remap[i] &= 0xf;
+           }
+-          info_ptr->bit_depth = 4;
++          info_tmp.bit_depth = 4;
+ 
+           /* try to adjust to 2-bit precision grayscale */
+ 
+@@ -652,7 +665,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+           for (i = 0; i < numuniqcols; i++) {
+             remap[i] &= 3;
+           }
+-          info_ptr->bit_depth = 2;
++          info_tmp.bit_depth = 2;
+ 
+           /* try to adjust to 1-bit precision grayscale */
+ 
+@@ -668,7 +681,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+           for (i = 0; i < numuniqcols; i++) {
+             remap[i] &= 1;
+           }
+-          info_ptr->bit_depth = 1;
++          info_tmp.bit_depth = 1;
+         }
+       }
+     }
+@@ -677,6 +690,20 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+   else
+     png_error(png_ptr, "Unknown colorstyle in WritePNG");
+ 
++  png_set_IHDR(png_ptr, info_ptr,
++             info_tmp.width, info_tmp.height,
++             info_tmp.bit_depth, info_tmp.color_type,
++             info_tmp.interlace_type, PNG_COMPRESSION_TYPE_BASE,
++             PNG_FILTER_TYPE_BASE);
++  if (info_tmp.use_palette) {
++    /*
++     * info_ptr->num_palette = numuniqcols;
++     * info_ptr->palette = palette;
++     * info_ptr->valid |= PNG_INFO_PLTE;
++     */
++    png_set_PLTE(png_ptr, info_ptr, palette, numuniqcols);
++  }
++
+   if ((text = (png_textp)malloc(sizeof(png_text)))) {
+     sprintf(software, "XV %s", REVDATE);
+ 
+@@ -684,21 +711,29 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+     text->key = "Software";
+     text->text = software;
+     text->text_length = strlen(text->text);
++    text->lang = NULL;
+ 
+-    info_ptr->max_text = 1;
+-    info_ptr->num_text = 1;
+-    info_ptr->text = text;
++    /*
++     * info_ptr->max_text = 1;
++     * info_ptr->num_text = 1;
++     * info_ptr->text = text;
++     */
++    png_set_text(png_ptr, info_ptr, text, 1);
++    num_text = max_text = 1;
+   }
+ 
+   Display_Gamma = gDial.val;  /* Save the current gamma for loading */
+ 
+ // GRR FIXME:  add .Xdefaults option to omit writing gamma (size, cumulative errors when editing)--alternatively, modify save box to include "omit" checkbox
+-  info_ptr->gamma = 1.0/gDial.val;
+-  info_ptr->valid |= PNG_INFO_gAMA;
++  /*
++   * info_ptr->gamma = 1.0/gDial.val;
++   * info_ptr->valid |= PNG_INFO_gAMA;
++   */
++  png_set_gAMA(png_ptr, info_ptr, 1.0/gDial.val);
+ 
+   png_write_info(png_ptr, info_ptr);
+ 
+-  if (info_ptr->bit_depth < 8)
++  if (info_tmp.bit_depth < 8)
+     png_set_packing(png_ptr);
+ 
+   pass=png_set_interlace_handling(png_ptr);
+@@ -711,13 +746,13 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+     int j;
+     p = pic;
+     for (j = 0; j < h; ++j) {
+-      if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
++      if (info_tmp.color_type == PNG_COLOR_TYPE_GRAY) {
+         int k;
+         for (k = 0; k < w; ++k)
+           png_line[k] = ptype==PIC24 ? MONO(p[k*3], p[k*3+1], p[k*3+2]) :
+                                        remap[pc2nc[p[k]]];
+         png_write_row(png_ptr, png_line);
+-      } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
++      } else if (info_tmp.color_type == PNG_COLOR_TYPE_PALETTE) {
+         int k;
+         for (k = 0; k < w; ++k)
+           png_line[k] = pc2nc[p[k]];
+@@ -743,24 +778,26 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+       strcpy(savecmnt, picComments);
+       key = savecmnt;
+       tp = text;
+-      info_ptr->num_text = 0;
++
++      png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
++      num_text = 0;
+ 
+       comment = strchr(key, ':');
+ 
+       do  {
+         /* Allocate a larger structure for comments if necessary */
+-        if (info_ptr->num_text >= info_ptr->max_text)
++        if (num_text >= max_text)
+         {
+           if ((tp =
+-              realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL)
++              realloc(text, (num_text + 2)*sizeof(png_text))) == NULL)
+           {
+             break;
+           }
+           else
+           {
+             text = tp;
+-            tp = &text[info_ptr->num_text];
+-            info_ptr->max_text += 2;
++            tp = &text[num_text];
++            max_text += 2;
+           }
+         }
+ 
+@@ -810,7 +847,7 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+             }
+ 
+             tp->compression = tp->text_length > 640 ? 0 : -1;
+-            info_ptr->num_text++;
++            num_text++;
+             tp++;
+           }
+         }
+@@ -834,27 +871,29 @@ int WritePNG(fp, pic, ptype, w, h, rmap,
+           tp->text = key;
+           tp->text_length = q - key;
+           tp->compression = tp->text_length > 750 ? 0 : -1;
+-          info_ptr->num_text++;
++          num_text++;
+           key = NULL;
+         }
+       } while (key && *key);
++      png_set_text(png_ptr, info_ptr, text, num_text);
+     }
+     else {
+-      info_ptr->num_text = 0;
++      png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
+     }
+   }
+-  info_ptr->text = text;
+ 
+-  png_convert_from_time_t(&(info_ptr->mod_time), time(NULL));
+-  info_ptr->valid |= PNG_INFO_tIME;
++  {
++     png_time mod_time;
++
++     png_convert_from_time_t(&mod_time, time(NULL));
++     png_set_tIME(png_ptr, info_ptr, &mod_time);
++  }
+ 
+   png_write_end(png_ptr, info_ptr);
+   fflush(fp);   /* just in case we core-dump before finishing... */
+ 
+   if (text) {
+     free(text);
+-    /* must do this or png_destroy_write_struct() 0.97+ will free text again: */
+-    info_ptr->text = (png_textp)NULL;
+     if (savecmnt)
+     {
+       free(savecmnt);
+@@ -886,6 +925,8 @@ int LoadPNG(fname, pinfo)
+   int pass;
+   int gray_to_rgb;
+   size_t commentsize;
++  png_textp text;
++  int num_text;
+ 
+   fbasename = BaseName(fname);
+ 
+@@ -921,7 +962,7 @@ int LoadPNG(fname, pinfo)
+     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) {
+@@ -945,8 +986,8 @@ int LoadPNG(fname, pinfo)
+ #endif
+   png_read_info(png_ptr, info_ptr);
+ 
+-  pinfo->w = pinfo->normw = info_ptr->width;
+-  pinfo->h = pinfo->normh = info_ptr->height;
++  pinfo->w = pinfo->normw = png_get_image_width(png_ptr, info_ptr);
++  pinfo->h = pinfo->normh = png_get_image_height(png_ptr, info_ptr);
+   if (pinfo->w <= 0 || pinfo->h <= 0) {
+     SetISTR(ISTR_WARNING, "%s:  image dimensions out of range (%dx%d)",
+       fbasename, pinfo->w, pinfo->h);
+@@ -957,9 +998,9 @@ int LoadPNG(fname, pinfo)
+   pinfo->frmType = F_PNG;
+ 
+   sprintf(pinfo->fullInfo, "PNG, %d bit ",
+-          info_ptr->bit_depth * info_ptr->channels);
++          png_get_bit_depth(png_ptr,info_ptr) * png_get_channels(png_ptr, info_ptr));
+ 
+-  switch(info_ptr->color_type) {
++  switch(png_get_color_type(png_ptr, info_ptr)) {
+     case PNG_COLOR_TYPE_PALETTE:
+       strcat(pinfo->fullInfo, "palette color");
+       break;
+@@ -983,15 +1024,20 @@ int LoadPNG(fname, pinfo)
+ 
+   sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo),
+         ", %sinterlaced. (%d bytes)",
+-        info_ptr->interlace_type ? "" : "non-", filesize);
++        png_get_interlace_type(png_ptr, info_ptr) ? "" : "non-", filesize);
+ 
+-  sprintf(pinfo->shrtInfo, "%lux%lu PNG", info_ptr->width, info_ptr->height);
++  sprintf(pinfo->shrtInfo, "%lux%lu PNG",
++        png_get_image_width(png_ptr, info_ptr),
++        png_get_image_height(png_ptr, info_ptr));
+ 
+-  if (info_ptr->bit_depth < 8)
++  if (png_get_bit_depth(png_ptr, info_ptr) < 8)
+       png_set_packing(png_ptr);
+ 
+-  if (info_ptr->valid & PNG_INFO_gAMA)
+-    png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma);
++  if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
++    double gamma;
++    png_get_gAMA(png_ptr, info_ptr, &gamma);
++    png_set_gamma(png_ptr, Display_Gamma, gamma);
++  }
+ /*
+  *else
+  *  png_set_gamma(png_ptr, Display_Gamma, 0.45);
+@@ -1000,7 +1046,7 @@ int LoadPNG(fname, pinfo)
+   gray_to_rgb = 0;   /* quiet a compiler warning */
+ 
+   if (have_imagebg) {
+-    if (info_ptr->bit_depth == 16) {
++    if (png_get_bit_depth(png_ptr, info_ptr) == 16) {
+       my_background.red   = imagebgR;
+       my_background.green = imagebgG;
+       my_background.blue  = imagebgB;
+@@ -1013,8 +1059,8 @@ int LoadPNG(fname, pinfo)
+     }
+     png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN,
+                        0, Display_Gamma);
+-    if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
+-         (info_ptr->color_type == PNG_COLOR_TYPE_GRAY && HAVE_tRNS)) &&
++    if ((png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA ||
++         (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY && HAVE_tRNS)) &&
+         (imagebgR != imagebgG || imagebgR != imagebgB))  /* i.e., colored bg */
+     {
+       png_set_gray_to_rgb(png_ptr);
+@@ -1022,8 +1068,10 @@ int LoadPNG(fname, pinfo)
+       gray_to_rgb = 1;
+     }
+   } else {
+-    if (info_ptr->valid & PNG_INFO_bKGD) {
+-      png_set_background(png_ptr, &info_ptr->background,
++    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) {
++      png_color_16p background;
++      png_get_bKGD(png_ptr, info_ptr, &background);
++      png_set_background(png_ptr, background,
+                          PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+     } else {
+       my_background.red = my_background.green = my_background.blue =
+@@ -1033,13 +1081,13 @@ int LoadPNG(fname, pinfo)
+     }
+   }
+ 
+-  if (info_ptr->bit_depth == 16)
++  if (png_get_bit_depth(png_ptr, info_ptr) == 16)
+     png_set_strip_16(png_ptr);
+ 
+-  if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
+-      info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
++  if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
++      png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA)
+   {
+-    if (info_ptr->bit_depth == 1)
++    if (png_get_bit_depth(png_ptr, info_ptr) == 1)
+       pinfo->colType = F_BWDITHER;
+     else
+       pinfo->colType = F_GREYSCALE;
+@@ -1050,8 +1098,8 @@ int LoadPNG(fname, pinfo)
+ 
+   png_read_update_info(png_ptr, info_ptr);
+ 
+-  if (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
+-     info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || gray_to_rgb)
++  if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB ||
++     png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA || gray_to_rgb)
+   {
+     linesize = 3 * pinfo->w;
+     if (linesize/3 < pinfo->w) {   /* know pinfo->w > 0 (see above) */
+@@ -1065,16 +1113,20 @@ int LoadPNG(fname, pinfo)
+   } else {
+     linesize = pinfo->w;
+     pinfo->type = PIC8;
+-    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
+-       info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
++    if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
++       png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) {
+       for (i = 0; i < 256; i++)
+         pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+     } else {
++      png_colorp palette;
++      int num_palette;
++
++      png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
+       pinfo->colType = F_FULLCOLOR;
+-      for (i = 0; i < info_ptr->num_palette; i++) {
+-        pinfo->r[i] = info_ptr->palette[i].red;
+-        pinfo->g[i] = info_ptr->palette[i].green;
+-        pinfo->b[i] = info_ptr->palette[i].blue;
++      for (i = 0; i < num_palette; i++) {
++        pinfo->r[i] = palette[i].red;
++        pinfo->g[i] = palette[i].green;
++        pinfo->b[i] = palette[i].blue;
+       }
+     }
+   }
+@@ -1092,7 +1144,17 @@ int LoadPNG(fname, pinfo)
+     png_error(png_ptr, "can't allocate space for PNG image");
+   }
+ 
+-  png_start_read_image(png_ptr);
++  /*
++   * In png 1.5 (or at least 1.5.1beta06) calling this after calling
++   * png_read_update_info() does nothing besides issue a misleading
++   * warning message. The png docs are not at all clear on what an
++   * application is *supposed* to do, so I'm not sure if this is a
++   * problem with xv or with libpng. However, for now I'll comment
++   * this out as according to the png source that should be harmless
++   * and we don't want to see the warning message every time someone
++   * opens a png.
++   */
++  /*png_start_read_image(png_ptr);*/
+ 
+   for (i = 0; i < pass; i++) {
+     byte *p = pinfo->pic;
+@@ -1106,22 +1168,23 @@ int LoadPNG(fname, pinfo)
+ 
+   png_read_end(png_ptr, info_ptr);
+ 
+-  if (info_ptr->num_text > 0) {
++  png_get_text(png_ptr, info_ptr, &text, &num_text);
++  if (num_text > 0) {
+     commentsize = 1;
+ 
+-    for (i = 0; i < info_ptr->num_text; i++)
+-      commentsize += strlen(info_ptr->text[i].key) + 1 +
+-                     info_ptr->text[i].text_length + 2;
++    for (i = 0; i < num_text; i++)
++      commentsize += strlen(text[i].key) + 1 +
++                     strlen(text[i].text) + 2;
+ 
+     if ((pinfo->comment = malloc(commentsize)) == NULL) {
+       png_warning(png_ptr,"can't allocate comment string");
+     }
+     else {
+       pinfo->comment[0] = '\0';
+-      for (i = 0; i < info_ptr->num_text; i++) {
+-        strcat(pinfo->comment, info_ptr->text[i].key);
++      for (i = 0; i < num_text; i++) {
++        strcat(pinfo->comment, text[i].key);
+         strcat(pinfo->comment, "::");
+-        strcat(pinfo->comment, info_ptr->text[i].text);
++        strcat(pinfo->comment, text[i].text);
+         strcat(pinfo->comment, "\n");
+       }
+     }
+@@ -1143,7 +1206,7 @@ png_xv_error(png_ptr, message)
+ {
+   SetISTR(ISTR_WARNING,"%s:  libpng error: %s", fbasename, message);
+ 
+-  longjmp(png_ptr->jmpbuf, 1);
++  longjmp(png_jmpbuf(png_ptr), 1);
+ }
+ 
+ 



Home | Main Index | Thread Index | Old Index