summaryrefslogtreecommitdiffstats
path: root/source/xap/xv/xv-3.10a-jumbo-additions.diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/xap/xv/xv-3.10a-jumbo-additions.diff (renamed from source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt)15716
1 files changed, 3146 insertions, 12570 deletions
diff --git a/source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt b/source/xap/xv/xv-3.10a-jumbo-additions.diff
index d78b601a9..8f398ddf2 100644
--- a/source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt
+++ b/source/xap/xv/xv-3.10a-jumbo-additions.diff
@@ -1,832 +1,288 @@
-diff : xv-3.10a-jumbo-enh-patch-20050501.txt
-
-This is a unified diff. It should be applied (using Larry Wall's "patch"
-program) to the XV 3.10a sources AFTER the jumbo-fixes patch has already
-been applied.
-
-diffs below:
- Imakefile
- Makefile
- Makefile.std
- README.jumbo
- README.pcd
- bggen.c
- bits/br_bzip2
- bits/br_mag
- bits/br_maki
- bits/br_mgcsfx
- bits/br_pcd
- bits/br_pi
- bits/br_pic
- bits/br_pic2
- bits/br_png
- bits/br_zx
- config.h
- tiff/Makefile
- vdcomp.c
- xcmap.c
- xv.c
- xv.h
- xv_mgcsfx.sample
- xvbmp.c
- xvbrowse.c
- xvctrl.c
- xvdial.c
- xvdir.c
- xvevent.c
- xvfits.c
- xvgam.c
- xvgif.c
- xvgrab.c
- xvhips.c
- xvhips.h
- xvimage.c
- xvinfo.c
- xvjpeg.c
- xvmag.c
- xvmaki.c
- xvmgcsfx.c
- xvmisc.c
- xvml.c
- xvml.h
- xvpbm.c
- xvpcd.c
- xvpds.c
- xvpi.c
- xvpic.c
- xvpic2.c
- xvpng.c
- xvpopup.c
- xvps.c
- xvrle.c
- xvroot.c
- xvsmooth.c
- xvtext.c
- xvtiff.c
- xvtiffwr.c
- xvvd.c
- xvwbmp.c
- xvxpm.c
- xvzx.c
-
-
-diff -ruN xv-3.10a-bugfixes/Imakefile xv-3.10a-enhancements/Imakefile
---- xv-3.10a-bugfixes/Imakefile 1995-01-13 12:24:01.000000000 -0800
-+++ xv-3.10a-enhancements/Imakefile 2005-04-17 14:04:22.000000000 -0700
-@@ -104,6 +104,11 @@
- SGI = -Dsgi
- #endif
-
-+/* install directory of xv_mgcsfx.sample. */
-+MGCSFXDIR = $(LIBDIR)
-+/* Directory of default configuration file. */
-+MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
-+
-
-
-
-@@ -137,6 +142,8 @@
- #if defined(SCOArchitecture)
- SCO= -Dsco -DPOSIX -DNO_RANDOM
- SYS_LIBRARIES= -lm -lc -lx
-+#elif defined(HPArchitecture)
-+SYS_LIBRARIES= -lm -lV3
- #else
- SYS_LIBRARIES= -lm
- #endif
-@@ -147,7 +154,7 @@
-
- DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
- $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
-- $(BACKING_STORE) $(BSDTYPES) $(SGI)
-+ $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX)
-
- INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)
-
-@@ -157,7 +164,9 @@
- xvdial.c xvgraf.c xvsunras.c xvjpeg.c xvps.c xvpopup.c xvdflt.c \
- xvtiff.c xvtiffwr.c xvpds.c xvrle.c xviris.c xvgrab.c vprintf.c \
- xvbrowse.c xvtext.c xvpcx.c xviff.c xvtarga.c xvxpm.c xvcut.c \
-- xvxwd.c xvfits.c
-+ xvxwd.c xvfits.c xvpng.c xvzx.c xvwbmp.c xvpcd.c \
-+ xvmag.c xvpic.c xvmaki.c xvpi.c xvpic2.c xvvd.c xvmgcsfx.c \
-+ xvml.c
-
- OBJS1 = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
- xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
-@@ -165,7 +174,9 @@
- xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
- xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
- xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
-- xvxwd.o xvfits.o
-+ xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o \
-+ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \
-+ xvml.o
-
- SRCS2= bggen.c
- OBJS2= bggen.o
-@@ -266,6 +277,8 @@
- InstallManPageLong(docs/xvp2p,$(MANDIR),xvpictoppm)
- InstallManPageLong(docs/vdcomp,$(MANDIR),vdcomp)
-
-+InstallNonExecFile(xv_mgcsfx.sample,$(MGCSFXDIR))
-+
- tar:
- tar cf xv.tar Makefile* Imakefile *.c *.h bits docs \
- docs unsupt vms $(JPEGDIR) $(TIFFDIR) $(MISC)
-diff -ruN xv-3.10a-bugfixes/Makefile xv-3.10a-enhancements/Makefile
---- xv-3.10a-bugfixes/Makefile 2005-04-06 08:17:13.000000000 -0700
-+++ xv-3.10a-enhancements/Makefile 2005-05-01 10:23:32.000000000 -0700
-@@ -41,10 +41,14 @@
-
-
- ### Installation locations
--BINDIR = /usr/local/bin
--MANDIR = /usr/local/man/man1
-+PREFIX = /usr/local
-+BINDIR = $(PREFIX)/bin
-+MANDIR = $(PREFIX)/man/man1
- MANSUF = 1
--LIBDIR = /usr/local/lib
-+DOCDIR = $(PREFIX)/doc/xv-3.10a
-+LIBDIR = $(PREFIX)/lib/xv
-+SYSCONFDIR = $(PREFIX)/etc
-+DESTDIR =
-
-
- buildit: all
-@@ -59,13 +63,59 @@
- ### on your machine, *COMMENT OUT* the following lines
- ###
- JPEG = -DDOJPEG
--JPEGDIR = jpeg
--JPEGINC = -I$(JPEGDIR)
--JPEGLIB = $(JPEGDIR)/libjpeg.a
--$(JPEGDIR)/jconfig.h:
-- cd $(JPEGDIR) ; ./configure CC='$(CC)'
--$(JPEGLIB): $(JPEGDIR)/jconfig.h
-- cd $(JPEGDIR) ; make
-+#JPEGDIR = jpeg
-+JPEGDIR = /usr
-+#JPEGDIR = /usr/local
-+#JPEGDIR = ../../libjpeg
-+###
-+JPEGINC = -I$(JPEGDIR)/include
-+#JPEGINC = -I$(JPEGDIR)
-+###
-+JPEGLIB = -L$(JPEGDIR)/lib -ljpeg
-+#JPEGLIB = -L$(JPEGDIR) -ljpeg
-+#JPEGLIB = $(JPEGDIR)/libjpeg.a
-+###
-+### this is intended to build the ancient version (5a) that's included in the
-+### "jpeg" subdir of XV, not an arbitrary copy of libjpeg:
-+###
-+#$(JPEGDIR)/jconfig.h:
-+# cd $(JPEGDIR) ; ./configure CC='$(CC)'
-+#$(JPEGLIB): $(JPEGDIR)/jconfig.h
-+# cd $(JPEGDIR) ; make
-+
-+
-+###
-+### if, for whatever reason, you're unable to get the PNG library to compile
-+### on your machine, *COMMENT OUT* the following lines
-+###
-+PNG = -DDOPNG
-+PNGDIR = /usr
-+#PNGDIR = /usr/local
-+#PNGDIR = ../../libpng
-+###
-+PNGINC = -I$(PNGDIR)/include
-+#PNGINC = -I$(PNGDIR)
-+###
-+PNGLIB = -L$(PNGDIR)/lib -lpng
-+#PNGLIB = -L$(PNGDIR) -lpng
-+#PNGLIB = $(PNGDIR)/libpng.a
-+
-+
-+###
-+### if, for whatever reason, you're unable to get both the PNG library and
-+### (newer versions of) the TIFF library to compile on your machine, *COMMENT
-+### OUT* the following lines
-+###
-+ZLIBDIR = /usr
-+#ZLIBDIR = /usr/local
-+#ZLIBDIR = ../../zlib
-+###
-+ZLIBINC = -I$(ZLIBDIR)/include
-+#ZLIBINC = -I$(ZLIBDIR)
-+###
-+ZLIBLIB = -L$(ZLIBDIR)/lib -lz
-+#ZLIBLIB = -L$(ZLIBDIR) -lz
-+#ZLIBLIB = $(ZLIBDIR)/libz.a
-
-
- ###
-@@ -80,17 +130,32 @@
- ###
- #TIFF = -DDOTIFF
- TIFF = -DDOTIFF -DUSE_TILED_TIFF_BOTLEFT_FIX
--TIFFDIR = tiff
--TIFFINC = -I$(TIFFDIR)
--TIFFLIB = $(TIFFDIR)/libtiff.a
--$(TIFFLIB):
-- ( cd $(TIFFDIR) ; make CC='$(CC)' COPTS='$(CCOPTS) $(MCHN)' )
-+#TIFFDIR = tiff
-+TIFFDIR = /usr
-+#TIFFDIR = /usr/local
-+#TIFFDIR = ../../libtiff
-+###
-+TIFFINC = -I$(TIFFDIR)/include
-+#TIFFINC = -I$(TIFFDIR)
-+###
-+### libtiff 3.5 and up may be compiled with zlib and libjpeg, but dependency
-+### is properly handled in LIBS line ~143 lines below
-+###
-+TIFFLIB = -L$(TIFFDIR)/lib -ltiff
-+#TIFFLIB = -L$(TIFFDIR) -ltiff
-+#TIFFLIB = $(TIFFDIR)/libtiff.a
-+###
-+### this is intended to build the ancient version (3.3.016 beta) that's included
-+### in the "tiff" subdir of XV, not an arbitrary copy of libtiff:
-+###
-+#$(TIFFLIB):
-+# ( cd $(TIFFDIR) ; make CC='$(CC)' COPTS='$(CCOPTS) $(MCHN)' )
-
-
- ###
- ### if, for whatever reason, you're unable to get the PDS/VICAR support
- ### to compile (xvpds.c, and vdcomp.c), *COMMENT OUT* the following line,
--### and also remove 'vdcomp' from the 'all:' dependancy
-+### and also remove 'vdcomp' from the 'all:' dependency
- ###
- PDS = -DDOPDS
-
-@@ -98,8 +163,10 @@
- #----------System V----------
-
- # if you are running on a SysV-based machine, such as HP, Silicon Graphics,
--# Solaris, etc., uncomment the following line to get mostly there.
--#UNIX = -DSVR4
-+# Solaris, etc.; uncomment one of the following lines to get you *most* of
-+# the way there. SYSV means System V R3.
-+# UNIX = -DSVR4
-+# UNIX = -DSYSV
-
-
- #----------Machine-Specific Configurations----------
-@@ -121,12 +188,15 @@
- # To use old HP compilers (HPUX 7.0 or so), you may need
- #MCHN= -Dhpux -D_HPUX_SOURCE +Ns4000
- #
--# also, if you're using HP's compiler, add '-Aa' to whichever of those
-+# Also, if you're using HP's compiler, add '-Aa' to whichever of those
- # two lines you're using, to turn on ANSI C mode. Or so I'm told.
- #
--# note: You may need to add '-I/usr/include/X11R5' (or R6, or whatever)
-+# Note: You may need to add '-I/usr/include/X11R5' (or R6, or whatever)
- # to whichever of those lines you used, as HP tends to store their X11
- # include files in a non-standard place...
-+#
-+# And you probably have to add '-lV3' to the end of the LIBS def when
-+# using XV's AUTO_EXPAND option.
-
-
- ### for LINUX, uncomment the following line
-@@ -205,6 +275,16 @@
- #VPRINTF = -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS
-
-
-+# if your X Window System compiled with -DX_LOCALE,
-+# uncomment the following line:
-+# TVL10N = -DX_LOCALE
-+
-+# Install directory of xv_mgcsfx.sample.
-+MGCSFXDIR = $(LIBDIR)
-+# Directory of default configuration file.
-+MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
-+
-+
-
-
- ################ END OF CONFIGURATION OPTIONS #################
-@@ -212,13 +292,14 @@
-
-
-
--CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
-- $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
-- $(DXWM) $(MCHN)
-+CFLAGS = $(CCOPTS) $(PNG) $(PNGINC) $(ZLIBINC) $(JPEG) $(JPEGINC) \
-+ $(TIFF) $(TIFFINC) $(PDS) $(NODIRENT) $(VPRINTF) $(TIMERS) \
-+ $(UNIX) $(BSDTYPES) $(RAND) $(DXWM) $(MCHN) $(TVL10N) $(MGCSFX) \
-+ -DSYSCONFDIR=\"$(SYSCONFDIR)\" -DXVEXECPATH=\"$(LIBDIR)\"
-
- ### remove -lm for BeOS:
--LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
--#LIBS = -lX11 $(JPEGLIB) $(TIFFLIB)
-+LIBS = $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIBLIB) -L/usr/X11R6/lib -lX11 -lm
-+#LIBS = $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIBLIB) -lX11
-
- OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
- xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
-@@ -226,7 +307,9 @@
- xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
- xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
- xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
-- xvxwd.o xvfits.o
-+ xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o xvhips.o \
-+ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \
-+ xvml.o
-
- MISC = README INSTALL CHANGELOG IDEAS
-
-@@ -236,10 +319,12 @@
-
-
-
--all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
-+#all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
-+all: xv bggen vdcomp xcmap xvpictoppm
-
-
--xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
-+#xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
-+xv: $(OBJS)
- $(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)
-
- bggen: bggen.c
-@@ -268,13 +353,14 @@
-
-
- install: all
-- cp xv bggen vdcomp xcmap xvpictoppm $(BINDIR)
-- cp docs/xv.man $(MANDIR)/xv.$(MANSUF)
-- cp docs/bggen.man $(MANDIR)/bggen.$(MANSUF)
-- cp docs/xcmap.man $(MANDIR)/xcmap.$(MANSUF)
-- cp docs/xvp2p.man $(MANDIR)/xvpictoppm.$(MANSUF)
-- cp docs/vdcomp.man $(MANDIR)/vdcomp.$(MANSUF)
-- cp docs/xvdocs.ps* $(LIBDIR)
-+ cp xv bggen vdcomp xcmap xvpictoppm $(DESTDIR)$(BINDIR)
-+ cp docs/xv.man $(DESTDIR)$(MANDIR)/xv.$(MANSUF)
-+ cp docs/bggen.man $(DESTDIR)$(MANDIR)/bggen.$(MANSUF)
-+ cp docs/xcmap.man $(DESTDIR)$(MANDIR)/xcmap.$(MANSUF)
-+ cp docs/xvp2p.man $(DESTDIR)$(MANDIR)/xvpictoppm.$(MANSUF)
-+ cp docs/vdcomp.man $(DESTDIR)$(MANDIR)/vdcomp.$(MANSUF)
-+ cp docs/xvdocs.ps* $(DESTDIR)$(LIBDIR) # or $(DESTDIR)$(DOCDIR)
-+ #cp xv_mgcsfx.sample $(DESTDIR)$(SYSCONFDIR)/xv_mgcsfx
-
- tar:
- # tar only local jpeg and tiff dirs, not user's or system's copies:
-@@ -299,7 +385,7 @@
- xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
- xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
- xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
--xvbrowse.o: bits/br_xwd
-+xvbrowse.o: bits/br_xwd bits/br_png bits/br_zx bits/br_pcd bits/br_bzip2
-
- xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
- xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
-diff -ruN xv-3.10a-bugfixes/Makefile.std xv-3.10a-enhancements/Makefile.std
---- xv-3.10a-bugfixes/Makefile.std 2005-04-06 08:17:13.000000000 -0700
-+++ xv-3.10a-enhancements/Makefile.std 2005-05-01 10:23:32.000000000 -0700
-@@ -41,10 +41,14 @@
-
-
- ### Installation locations
--BINDIR = /usr/local/bin
--MANDIR = /usr/local/man/man1
-+PREFIX = /usr/local
-+BINDIR = $(PREFIX)/bin
-+MANDIR = $(PREFIX)/man/man1
- MANSUF = 1
--LIBDIR = /usr/local/lib
-+DOCDIR = $(PREFIX)/doc/xv-3.10a
-+LIBDIR = $(PREFIX)/lib/xv
-+SYSCONFDIR = $(PREFIX)/etc
-+DESTDIR =
-
-
- buildit: all
-@@ -59,13 +63,59 @@
- ### on your machine, *COMMENT OUT* the following lines
- ###
- JPEG = -DDOJPEG
--JPEGDIR = jpeg
--JPEGINC = -I$(JPEGDIR)
--JPEGLIB = $(JPEGDIR)/libjpeg.a
--$(JPEGDIR)/jconfig.h:
-- cd $(JPEGDIR) ; ./configure CC='$(CC)'
--$(JPEGLIB): $(JPEGDIR)/jconfig.h
-- cd $(JPEGDIR) ; make
-+#JPEGDIR = jpeg
-+JPEGDIR = /usr
-+#JPEGDIR = /usr/local
-+#JPEGDIR = ../../libjpeg
-+###
-+JPEGINC = -I$(JPEGDIR)/include
-+#JPEGINC = -I$(JPEGDIR)
-+###
-+JPEGLIB = -L$(JPEGDIR)/lib -ljpeg
-+#JPEGLIB = -L$(JPEGDIR) -ljpeg
-+#JPEGLIB = $(JPEGDIR)/libjpeg.a
-+###
-+### this is intended to build the ancient version (5a) that's included in the
-+### "jpeg" subdir of XV, not an arbitrary copy of libjpeg:
-+###
-+#$(JPEGDIR)/jconfig.h:
-+# cd $(JPEGDIR) ; ./configure CC='$(CC)'
-+#$(JPEGLIB): $(JPEGDIR)/jconfig.h
-+# cd $(JPEGDIR) ; make
-+
-+
-+###
-+### if, for whatever reason, you're unable to get the PNG library to compile
-+### on your machine, *COMMENT OUT* the following lines
-+###
-+PNG = -DDOPNG
-+PNGDIR = /usr
-+#PNGDIR = /usr/local
-+#PNGDIR = ../../libpng
-+###
-+PNGINC = -I$(PNGDIR)/include
-+#PNGINC = -I$(PNGDIR)
-+###
-+PNGLIB = -L$(PNGDIR)/lib -lpng
-+#PNGLIB = -L$(PNGDIR) -lpng
-+#PNGLIB = $(PNGDIR)/libpng.a
-+
-+
-+###
-+### if, for whatever reason, you're unable to get both the PNG library and
-+### (newer versions of) the TIFF library to compile on your machine, *COMMENT
-+### OUT* the following lines
-+###
-+ZLIBDIR = /usr
-+#ZLIBDIR = /usr/local
-+#ZLIBDIR = ../../zlib
-+###
-+ZLIBINC = -I$(ZLIBDIR)/include
-+#ZLIBINC = -I$(ZLIBDIR)
-+###
-+ZLIBLIB = -L$(ZLIBDIR)/lib -lz
-+#ZLIBLIB = -L$(ZLIBDIR) -lz
-+#ZLIBLIB = $(ZLIBDIR)/libz.a
-
-
- ###
-@@ -80,17 +130,32 @@
- ###
- #TIFF = -DDOTIFF
- TIFF = -DDOTIFF -DUSE_TILED_TIFF_BOTLEFT_FIX
--TIFFDIR = tiff
--TIFFINC = -I$(TIFFDIR)
--TIFFLIB = $(TIFFDIR)/libtiff.a
--$(TIFFLIB):
-- ( cd $(TIFFDIR) ; make CC='$(CC)' COPTS='$(CCOPTS) $(MCHN)' )
-+#TIFFDIR = tiff
-+TIFFDIR = /usr
-+#TIFFDIR = /usr/local
-+#TIFFDIR = ../../libtiff
-+###
-+TIFFINC = -I$(TIFFDIR)/include
-+#TIFFINC = -I$(TIFFDIR)
-+###
-+### libtiff 3.5 and up may be compiled with zlib and libjpeg, but dependency
-+### is properly handled in LIBS line ~143 lines below
-+###
-+TIFFLIB = -L$(TIFFDIR)/lib -ltiff
-+#TIFFLIB = -L$(TIFFDIR) -ltiff
-+#TIFFLIB = $(TIFFDIR)/libtiff.a
-+###
-+### this is intended to build the ancient version (3.3.016 beta) that's included
-+### in the "tiff" subdir of XV, not an arbitrary copy of libtiff:
-+###
-+#$(TIFFLIB):
-+# ( cd $(TIFFDIR) ; make CC='$(CC)' COPTS='$(CCOPTS) $(MCHN)' )
-
-
- ###
- ### if, for whatever reason, you're unable to get the PDS/VICAR support
- ### to compile (xvpds.c, and vdcomp.c), *COMMENT OUT* the following line,
--### and also remove 'vdcomp' from the 'all:' dependancy
-+### and also remove 'vdcomp' from the 'all:' dependency
- ###
- PDS = -DDOPDS
-
-@@ -98,8 +163,10 @@
- #----------System V----------
-
- # if you are running on a SysV-based machine, such as HP, Silicon Graphics,
--# Solaris, etc., uncomment the following line to get mostly there.
--#UNIX = -DSVR4
-+# Solaris, etc.; uncomment one of the following lines to get you *most* of
-+# the way there. SYSV means System V R3.
-+# UNIX = -DSVR4
-+# UNIX = -DSYSV
-
-
- #----------Machine-Specific Configurations----------
-@@ -121,12 +188,15 @@
- # To use old HP compilers (HPUX 7.0 or so), you may need
- #MCHN= -Dhpux -D_HPUX_SOURCE +Ns4000
- #
--# also, if you're using HP's compiler, add '-Aa' to whichever of those
-+# Also, if you're using HP's compiler, add '-Aa' to whichever of those
- # two lines you're using, to turn on ANSI C mode. Or so I'm told.
- #
--# note: You may need to add '-I/usr/include/X11R5' (or R6, or whatever)
-+# Note: You may need to add '-I/usr/include/X11R5' (or R6, or whatever)
- # to whichever of those lines you used, as HP tends to store their X11
- # include files in a non-standard place...
-+#
-+# And you probably have to add '-lV3' to the end of the LIBS def when
-+# using XV's AUTO_EXPAND option.
-
-
- ### for LINUX, uncomment the following line
-@@ -205,6 +275,16 @@
- #VPRINTF = -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS
-
-
-+# if your X Window System compiled with -DX_LOCALE,
-+# uncomment the following line:
-+# TVL10N = -DX_LOCALE
-+
-+# Install directory of xv_mgcsfx.sample.
-+MGCSFXDIR = $(LIBDIR)
-+# Directory of default configuration file.
-+MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
-+
-+
-
-
- ################ END OF CONFIGURATION OPTIONS #################
-@@ -212,13 +292,14 @@
-
-
-
--CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
-- $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
-- $(DXWM) $(MCHN)
-+CFLAGS = $(CCOPTS) $(PNG) $(PNGINC) $(ZLIBINC) $(JPEG) $(JPEGINC) \
-+ $(TIFF) $(TIFFINC) $(PDS) $(NODIRENT) $(VPRINTF) $(TIMERS) \
-+ $(UNIX) $(BSDTYPES) $(RAND) $(DXWM) $(MCHN) $(TVL10N) $(MGCSFX) \
-+ -DSYSCONFDIR=\"$(SYSCONFDIR)\" -DXVEXECPATH=\"$(LIBDIR)\"
-
- ### remove -lm for BeOS:
--LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
--#LIBS = -lX11 $(JPEGLIB) $(TIFFLIB)
-+LIBS = $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIBLIB) -L/usr/X11R6/lib -lX11 -lm
-+#LIBS = $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIBLIB) -lX11
-
- OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
- xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
-@@ -226,7 +307,9 @@
- xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
- xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
- xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
-- xvxwd.o xvfits.o
-+ xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o xvhips.o \
-+ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \
-+ xvml.o
-
- MISC = README INSTALL CHANGELOG IDEAS
-
-@@ -236,10 +319,12 @@
-
-
-
--all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
-+#all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
-+all: xv bggen vdcomp xcmap xvpictoppm
-
-
--xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
-+#xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
-+xv: $(OBJS)
- $(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)
-
- bggen: bggen.c
-@@ -268,13 +353,14 @@
-
-
- install: all
-- cp xv bggen vdcomp xcmap xvpictoppm $(BINDIR)
-- cp docs/xv.man $(MANDIR)/xv.$(MANSUF)
-- cp docs/bggen.man $(MANDIR)/bggen.$(MANSUF)
-- cp docs/xcmap.man $(MANDIR)/xcmap.$(MANSUF)
-- cp docs/xvp2p.man $(MANDIR)/xvpictoppm.$(MANSUF)
-- cp docs/vdcomp.man $(MANDIR)/vdcomp.$(MANSUF)
-- cp docs/xvdocs.ps* $(LIBDIR)
-+ cp xv bggen vdcomp xcmap xvpictoppm $(DESTDIR)$(BINDIR)
-+ cp docs/xv.man $(DESTDIR)$(MANDIR)/xv.$(MANSUF)
-+ cp docs/bggen.man $(DESTDIR)$(MANDIR)/bggen.$(MANSUF)
-+ cp docs/xcmap.man $(DESTDIR)$(MANDIR)/xcmap.$(MANSUF)
-+ cp docs/xvp2p.man $(DESTDIR)$(MANDIR)/xvpictoppm.$(MANSUF)
-+ cp docs/vdcomp.man $(DESTDIR)$(MANDIR)/vdcomp.$(MANSUF)
-+ cp docs/xvdocs.ps* $(DESTDIR)$(LIBDIR) # or $(DESTDIR)$(DOCDIR)
-+ #cp xv_mgcsfx.sample $(DESTDIR)$(SYSCONFDIR)/xv_mgcsfx
-
- tar:
- # tar only local jpeg and tiff dirs, not user's or system's copies:
-@@ -299,7 +385,7 @@
- xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
- xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
- xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
--xvbrowse.o: bits/br_xwd
-+xvbrowse.o: bits/br_xwd bits/br_png bits/br_zx bits/br_pcd bits/br_bzip2
-
- xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
- xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
-diff -ruN xv-3.10a-bugfixes/README.jumbo xv-3.10a-enhancements/README.jumbo
---- xv-3.10a-bugfixes/README.jumbo 2005-04-10 19:55:23.000000000 -0700
-+++ xv-3.10a-enhancements/README.jumbo 2005-05-01 13:45:58.000000000 -0700
-@@ -14,10 +14,10 @@
- available from John's XV site (http://www.trilon.com/xv/downloads.html
- and ftp://ftp.trilon.com/pub/xv/patches/), plus a number of my own fixes
- and additions, plus quite a few from other people--though not all of the
--ones I'd intended to (sorry, SJT, AT, and JPD!) due to lack of time after
--dealing with the latest security issue (which I discovered, sigh). They're
--still not fully complete, and it's possible they never will be, but I do
--plan to continue working on them whenever the mood strikes--and I may even
-+ones I'd intended to, due to lack of time after dealing with the latest
-+set of security issues (one of which I discovered, sigh). They're still
-+not fully complete, and it's possible they never will be, but I do plan
-+to continue tinkering with them whenever the mood strikes--and I may even
- release them publicly on rare occasions. (At the current rate, it looks
- like once a year may be the best we can hope for...we'll see.)
-
-@@ -26,91 +26,86 @@
-
- - Landon Curt "chongo" Noll (http://www.isthe.com/chongo/)
- http://www.isthe.com/chongo/src/xv-patch/
-- - Mark Ashley <mark@ibiblio.org>
+diff -u -r --new-file xv-3.10a.orig/README.jumbo xv-3.10a/README.jumbo
+--- xv-3.10a.orig/README.jumbo 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/README.jumbo 2007-05-21 00:19:20.000000000 -0500
+@@ -0,0 +1,559 @@
++This is the latest version of the XV jumbo patches I originally created in
++February 2000 (but never distributed) and eventually updated and released in
++May 2004, prompted by a discussion on LWN (http://lwn.net/Articles/76391/).
++Information about the patches, updates to the patches, and the patches
++themselves can all be found here:
++
++ http://pobox.com/~newt/greg_xv.html
++ http://freshmeat.net/projects/xvjumbopatches/
++
++(Use the "Subscribe to new releases" link on the latter page if you want to
++be notified of new versions automatically; trivial registration required.)
++
++These patches incorporate all of the fix- and enhancement-patches available
++from John's XV site (http://www.trilon.com/xv/downloads.html and
++ftp://ftp.trilon.com/pub/xv/patches/), plus a number of my own fixes and
++additions (security-related and otherwise), plus quite a few from other
++people. They're still not fully complete, and it's probable they never
++will be, but I do plan to continue tinkering with them whenever the mood
++strikes--and I may even release them publicly on rare occasions. (At the
++current rate, once every few years may be the best we can hope for....)
++
++Also be aware that several other people have had the same idea over the
++years. Ones I've found, more or less by accident, include:
++
++ - Landon Curt "chongo" Noll (http://www.isthe.com/chongo/)
++ http://www.isthe.com/chongo/src/xv-patch/
+ - Mark Ashley <mark ibiblio.org>
- http://www.ibiblio.org/pub/packages/solaris/sparc/html/xv.3.10a.p19.html
-- - Peter Jordan <pete@dc.seflin.org>
++ http://www.ibiblio.org/pub/packages/solaris/sparc/html/xv.3.10a.p19.html
+ - Peter Jordan <pete dc.seflin.org>
- http://www.ibiblio.org/pub/Linux/apps/graphics/viewers/X/xv-3.10a.patch.*
- - Uwe F. Mayer (http://www.tux.org/~mayer/)
- http://www.tux.org/~mayer/linux/book/node311.html
-- - Kurt Wall <kwall@kurtwerks.com>
++ http://www.ibiblio.org/pub/Linux/apps/graphics/viewers/X/xv-3.10a.patch.*
++ - Uwe F. Mayer (http://www.tux.org/~mayer/)
++ http://www.tux.org/~mayer/linux/book/node311.html
+ - Kurt Wall <kwall kurtwerks.com>
- http://www.kurtwerks.com/software/xv.html
- - Chisato Yamauchi (http://phe.phyas.aichi-edu.ac.jp/~cyamauch/index_en.html)
- http://phe.phyas.aichi-edu.ac.jp/~cyamauch/xv.html
-- - Daisuke Yabuki <dxy@optix.org>
++ http://www.kurtwerks.com/software/xv.html
++ - Chisato Yamauchi (http://phe.phyas.aichi-edu.ac.jp/~cyamauch/index_en.html)
++ http://phe.phyas.aichi-edu.ac.jp/~cyamauch/xv.html
+ - Daisuke Yabuki <dxy optix.org>
- http://www.optix.org/~dxy/solaris/xv/
- - Pekoe (http://pekoe.lair.net/)
- http://pekoe.lair.net/diary/xv.html
- - FreeBSD FreshPorts
- http://www.freshports.org/graphics/xv/
-- - <sudakyo@fat.coara.or.jp>
++ http://www.optix.org/~dxy/solaris/xv/
++ - Pekoe (http://pekoe.lair.net/)
++ http://pekoe.lair.net/diary/xv.html
++ - FreeBSD FreshPorts
++ http://www.freshports.org/graphics/xv/
+ - Kyoichiro Suda <sudakyo fat.coara.or.jp>
- http://www.coara.or.jp/~sudakyo/XV_jp.html
-
--I very much doubt that this is an exhaustive list. So far, most of the other
--patch-sets appear not to be quite as extensive or as up-to-date as my own,
--although the last three or four do include the [large] Japanese extension
--patches that I omitted--not because they're unworthy, but simply because I
--didn't find them until collisions between the two sets of patches had become
--a large problem. (Maybe for the next release... I'd intended to try for
--this release, but the security issues ended up taking almost all of my
--available time. And, to be honest, from my perspective, inclusion of the
--jp-extension patches is more for completeness' sake than personal interest,
--so their priority is fairly low.)
-+I very much doubt that this is an exhaustive list. So far, most of the
-+other patch-sets appear not to be as extensive or as up-to-date as my own,
-+particularly now that the (very large) "Japanese extension" patches are
-+incorporated--big thanks to Werner Fink of SuSE for that!
-
- Below I summarize the component patches that are encompassed by my jumbo
- bugfixes and jumbo enhancements patches. Unfortunately, some of my own
- additions never saw the light of day as standalone patches, but considering
- the number of overlaps (collisions) already implicit in this list, it would
--have been difficult to accomplish even if I'd had the time. In any case,
--they're present in these jumbo patches but not chongo's, so those who _really_
--care can "subtract" the two sets of patches to see what I did.
-+have been difficult to accomplish even if I'd had the time.
-
- Here's a quick guide to the "third-party" credits in the lists below:
-
- AAC = Andrey A. Chernov [ache]
- (http://cvsweb.freebsd.org/ports/graphics/xv/files/patch-ab)
-- AD = Andreas Dilger (adilger@clusterfs.com)
-- AL = Alexander Lehmann (lehmann@usa.net)
++ http://www.coara.or.jp/~sudakyo/XV_jp.html
++
++This is not an exhaustive list (e.g., Jörgen Grahn also had one). So far,
++most of the other patch-sets appear not to be as extensive or as up-to-date
++as my own, particularly now that the (very large) "Japanese extension" patches
++are incorporated--big thanks to Werner Fink of SuSE for that!
++
++Below I summarize the component patches that are encompassed by my jumbo
++bugfixes and jumbo enhancements patches, circa 2005. (As of 2007, they're
++distributed as a single monster-patch, and the "component patches" are now
++listed in the changelog section at the bottom of this file.) Unfortunately,
++some of my own additions never saw the light of day as standalone patches,
++but considering the number of overlaps (collisions) already implicit in the
++list, that would have been difficult to accomplish even if I'd had the time.
++
++Here's a quick guide to the "third-party" credits in the lists and changelog
++below:
++
++ AAC = Andrey A. Chernov [ache]
++ (http://cvsweb.freebsd.org/ports/graphics/xv/files/patch-ab)
+ AD = Andreas Dilger (adilger clusterfs.com)
+ AL = Alexander Lehmann (lehmann usa.net)
- AT = Anthony Thyssen (http://www.cit.gu.edu.au/~anthony/)
- DAC = David A. Clunie (http://www.dclunie.com/xv-pcd.html)
-- EK = Egmont Koblinger (egmont@users.sourceforge.net)
++ AS = Alexey Spiridonov (http://www-math.mit.edu/~lesha/)
++ AT = Anthony Thyssen (http://www.cit.gu.edu.au/~anthony/)
++ BR = Bruno Rohee (http://bruno.rohee.com/)
++ DAC = David A. Clunie (http://www.dclunie.com/xv-pcd.html)
++ EAJ = Erling A. Jacobsen (linuxcub email.dk)
+ EK = Egmont Koblinger (egmont users.sourceforge.net)
- GRR = Greg Roelofs (http://pobox.com/~newt/)
- GV = Guido Vollbeding (http://sylvana.net/guido/)
++ FG = Fabian Greffrath (fabian debian-unofficial.org)
++ GRR = Greg Roelofs (http://pobox.com/~newt/greg_contact.html)
++ GV = Guido Vollbeding (http://sylvana.net/guido/)
+ IM = IKEMOTO Masahiro (ikeyan airlab.cs.ritsumei.ac.jp)
- JCE = John C. Elliott (http://www.seasip.demon.co.uk/ZX/zxdload.html)
- JHB = John H. Bradley, of course (http://www.trilon.com/xv/)
- JPD = Jean-Pierre Demailly (http://www-fourier.ujf-grenoble.fr/~demailly/)
- JR = John Rochester (http://www.freebsd.org/cgi/query-pr.cgi?pr=2920)
- (also http://cvsweb.freebsd.org/ports/graphics/xv/files/patch-af, -ag)
- JZ = Joe Zbiciak (http://spatula-city.org/~im14u2c/)
++ JC = John Cooper (john.cooper third-harmonic.com)
++ JCE = John C. Elliott (http://www.seasip.demon.co.uk/ZX/zxdload.html)
++ JDB = John D. Baker (http://mylinuxisp.com/~jdbaker/)
++ JG = Jörgen Grahn (jgrahn algonet.se)
++ JHB = John H. Bradley, of course (http://www.trilon.com/xv/)
++ JPD = Jean-Pierre Demailly (http://www-fourier.ujf-grenoble.fr/~demailly/)
++ JR = John Rochester (http://www.freebsd.org/cgi/query-pr.cgi?pr=2920)
++ (also http://cvsweb.freebsd.org/ports/graphics/xv/files/patch-af, -ag)
++ JRK = James Roberts Kirkpatrick (uwyo.edu)
++ JZ = Joe Zbiciak (http://spatula-city.org/~im14u2c/)
+ KS = Kyoichiro Suda (http://www.coara.or.jp/~sudakyo/XV_jp.html)
- LCN = Landon Curt "chongo" Noll (http://www.isthe.com/chongo/)
++ LCN = Landon Curt "chongo" Noll (http://www.isthe.com/chongo/)
+ LJ = Larry Jones (lawrence.jones ugs.com)
- PBJ = Peter Jordan (http://www.ibiblio.org/pub/Linux/apps/graphics/viewers/X/)
- PSV = Pawel S. Veselov (http://manticore.2y.net/wbmp.html)
- SB = Sean Borman (http://www.nd.edu/~sborman/software/xvwheelmouse.html)
-- SJT = TenThumbs (tenthumbs@cybernex.net)
++ PBJ = Peter Jordan (http://www.ibiblio.org/pub/Linux/apps/graphics/viewers/X/)
++ PSV = Pawel S. Veselov (http://manticore.2y.net/wbmp.html)
++ RAC = Ross Combs (rocombs cs.nmsu.edu)
++ RJH = Robin Humble (http://www.cita.utoronto.ca/~rjh/)
++ SB = Sean Borman (http://www.nd.edu/~sborman/software/xvwheelmouse.html)
+ SJT = TenThumbs (tenthumbs cybernex.net)
- TA = Tim Adye (http://hepwww.rl.ac.uk/Adye/xv-psnewstyle.html)
++ SBM = Scott B. Marovich (formerly marovich hpl.hp.com)
++ TA = Tim Adye (http://hepwww.rl.ac.uk/Adye/xv-psnewstyle.html)
++ TAR = Tim Ramsey (tar pobox.com)
+ TI = Tetsuya INOUE (tin329 chino.it.okayama-u.ac.jp)
+ TO = Tavis Ormandy (taviso gentoo.org)
+ WF = Werner Fink (http://www.suse.de/~werner/)
-
- Other credits are as listed on the XV Downloads page or in the respective
- patches (e.g., the jp-extension patches or within the PNG patch).
-
- Finally, please note that these patches have not been blessed by John Bradley
--in any way (although I copied him on the May 2004 announcement--no response).
--Nor have I personally tested every change and feature! (See the BIG SCARY
--WARNING below for further caveats.) In other words, they're both completely
--unofficial and completely unguaranteed. But they seem to work for me. (And
--when they don't, I fix 'em. Eventually, anyway... ;-) )
--
--One further "final" note: this may well be the last release to include
--separate fix- and enhancements-patches. It is too much of a timesink to
--maintain parallel trees--not to mention parallel makefiles (generic/public
--vs. local/personal, old vs. new libjpeg/libtiff) and xv.h (unregistered/
--public vs. registered/personal), particularly when some fixes come about
--while working on an enhancement. Henceforth--assuming, of course, that
--there _is_ a "henceforth"--I expect to merge the patches into a single
--jumbo patch. (Alternatively, I may simply freeze the current fix-patch
--and continue to evolve only the enhancements patch; in particular, new
--fixes would appear only in it. Either approach would be simple enough;
--feedback as to which would be preferable is welcomed.)
-+in any way (although I copied him on the May 2004 announcement--no response
-+at that time). Nor have I personally tested every change and feature! (See
-+the BIG SCARY WARNING below for further caveats.) In other words, they're
-+both completely unofficial and completely unguaranteed. But they seem to
-+work for me. (And when they don't, I fix 'em. Eventually, anyway... ;-) )
-+
-+One further "final" note: as of this release, I am no longer updating the
-+fixes patch; new stuff (including fixes) now appears only in the enhancements
-+one. It simply became too much of a timesink to maintain parallel trees--not
-+to mention parallel makefiles (generic/public vs. local/personal, old vs.
-+new libjpeg/libtiff) and xv.h (unregistered/public vs. registered/personal),
-+particularly when some fixes came about while working on an enhancement and
-+others were provided by third parties relative to the previous fix+enh state.
-+Hence the mismatched "20050410" date on the fixes patch.
-
--GRR 20050410
-+GRR 20050501
-
-
- How to build
-@@ -158,8 +153,8 @@
- Assuming you have the prerequisites out of the way and aren't scared
- off by the Big Scary Warning, here's the build procedure:
-
-- bzip2 -dc xv-3.10a-jumbo-patches-20050410.tar.bz2 | tar xvf -
-- (or tar xvzf xv-3.10a-jumbo-patches-20050410.tar.gz)
-+ bzip2 -dc xv-3.10a-jumbo-patches-20050501.tar.bz2 | tar xvf -
-+ (or tar xvzf xv-3.10a-jumbo-patches-20050501.tar.gz)
-
- tar xvzf xv-3.10a.tar.gz
-
-@@ -167,7 +162,7 @@
-
- patch -p1 < ../xv-3.10a-jumbo-fix-patch-20050410.txt
-
-- [optional] patch -p1 < ../xv-3.10a-jumbo-enh-patch-20050410.txt
-+ [optional] patch -p1 < ../xv-3.10a-jumbo-enh-patch-20050501.txt
-
- edit Makefile and config.h as directed in INSTALL file (in particular,
- ensure paths to external libraries and header files are correct)
-@@ -221,6 +216,8 @@
- - freebsd-vdcomp-newline.patch (AAC)
- - xv-3.10a.patch.linux (PBJ) [/bin/sh versions of cleandir, RANLIB.sh only]
- - removed trailing white space (GRR) [purely cosmetic]
++
++Other credits are as listed on the XV Downloads page or in the respective
++patches (e.g., the jp-extension patches or within the PNG patch).
++
++Finally, please note that these patches have not been blessed by John Bradley
++in any way (although I copied him on the May 2004 announcement and wrote to
++him again in May 2005), unless you count Debian's redistribution permission
++(Daniel Kirchheimer, 5 Dec 2005). Nor have I personally tested every change
++and feature! (See the BIG SCARY WARNING below for further caveats.) In other
++words, they're both completely unofficial and completely unguaranteed. But
++they seem to work for me. (And when they don't, I try to fix 'em--eventually,
++anyway... ;-) )
++
++Greg Roelofs, 20070520
++http://pobox.com/~newt/greg_contact.html
++
++
++How to build
++------------
++
++The following assumes you, the user, already have the libtiff,[1] libjpeg,[2]
++libpng,[3] zlib,[4] and JasPer[5] libraries downloaded, patched (if necessary),
++compiled, and installed, not to mention a C compiler and the bzip2,[6] tar,[7]
++patch,[8] and make[9] utilities. You should also have downloaded the original
++XV 3.10a source distribution from the XV Downloads page[10] and be able to edit
++its Makefile and config.h files as indicated in the INSTALL file. (Editing
++the Makefile will also allow you to disable some of the third-party libraries
++if you wish.) Finally, you should know what a Unix(-style) command line is,
++where to find one, and how to wield it with abandon (or at least with adult
++supervision)--and preferably not as the root user until the "make install"
++step. (A filesystem is a terrible thing to waste.)
++
++ [1] http://www.remotesensing.org/libtiff/
++ [2] http://www.ijg.org/
++ [3] http://www.libpng.org/pub/png/libpng.html
++ [4] http://www.zlib.net/
++ [5] http://www.ece.uvic.ca/~mdadams/jasper/
++ [6] http://sources.redhat.com/bzip2/
++ [7] http://www.gnu.org/directory/devel/specific/tar.html
++ [8] http://www.gnu.org/directory/devel/specific/patch.html
++ [9] http://www.gnu.org/directory/devel/specific/make.html
++ [10] http://www.trilon.com/xv/downloads.html#src-distrib
++
+++-------------------------------------------------------------------------+
++| |
++| BIG SCARY WARNING |
++| |
++| These patches work for Greg (and parts of them reportedly work for |
++| various other people), and so far Greg's CPU still computes and his |
++| hard disks haven't been wiped. But there's no guarantee that this |
++| will be the case for you! In particular, not every incorporated patch |
++| has been explicitly tested, nor has every possible subcase of the |
++| explicitly tested subset. (Read that again; it's grammatical.) Nor |
++| are these patches officially blessed by John Bradley in any way. In |
++| other words, if you use these patches, you do so at your own risk. |
++| (Greg doesn't believe there are any serious problems remaining, but |
++| then, what programmer ever does? Bugs happen.) |
++| |
+++-------------------------------------------------------------------------+
++
++Assuming you have the prerequisites out of the way and aren't scared
++off by the Big Scary Warning, here's the build procedure:
++
++ tar xvzf xv-3.10a-jumbo-patches-20070520.tar.gz
++ (or: gzip -dc xv-3.10a-jumbo-patches-20070520.tar.gz | tar xvf - )
++
++ tar xvzf xv-3.10a.tar.gz
++
++ cd xv-3.10a
++
++ patch -p1 < ../xv-3.10a-jumbo-fix-enh-patch-20070520.txt
++
++ edit Makefile and config.h as directed in INSTALL file (in particular,
++ ensure paths to external libraries and header files are correct)
++
++ make
++
++ ./xv your_favorite_image your_other_favorite_image etc.
++
++If everything seems to be working to your satisfaction, go ahead and install:
++
++ make -n install (and double-check that things will be installed
++ where you want them to be)
++
++ become root if necessary (e.g., type su)
++
++ make install
++ (or: sudo make install)
++
++That wasn't so hard, was it?
++
++
++Summary of incorporated and unincorporated patches (through 20050501)
++---------------------------------------------------------------------
++(See the ChangeLog at the bottom for more recent incorporated patches.)
++
++fixes ((*) = listed on XV Downloads page, (f) = on ftp site only):
++
++20040516:
++ - grabpatch (*) [obsoleted by new-xvgrab.c below]
++ - vispatch (*)
++ - mp-tiff-patch (*) [technically an enhancement, but JHB says...]
++ - longname.patch (*) [*SECURITY*]
++ - xpm.patch (*)
++ - deepcolor.patch (*) [slightly modified for language conformance]
++ - gifpatch (*)
++ - exceed_grab.patch (*)
++ - xv-redhat6-readme.txt (*) [slightly modified for portability]
++ - beos.patch (*) [modified for portability]
++ - croppad.patch (f)
++ - epsfpatch (f)
++ - tiff1200.patch (*)
++ - gssafer.patch (*) [*SECURITY*]
++ - new-xvgrab.c (f) [includes grabpatch but not exceed_grab.patch]
++ - xcmap.diff (AD) [part of xv-3.10a-png-1.2d.tar.gz]
++ - fixes for huge number gcc -Wall warnings--including two bugs (GRR)
++ - fix for cleandir script when no makefile exists (GRR)
++ - *SECURITY* fix for gets() in vdcomp.c (GRR, LCN vdcomp-security.patch)
++ - *SECURITY* fix for getwd() on Linux (GRR, LCN Linux-compile.patch)
++ - fix for "no fuss" Linux compiles (LCN Linux-compile.patch)
++ - partial *SECURITY* fix for mktemp() in xv.c and xvdir.c (GRR)
++ (remaining instances in xv.c (2), xvimage.c, xvfits.c, xvpds.c, xvps.c, and
++ possibly xvtiff.c--most involve system())
++ - freebsd-vdcomp-newline.patch (AAC)
++ - xv-3.10a.patch.linux (PBJ) [/bin/sh versions of cleandir, RANLIB.sh only]
++ - removed trailing white space (GRR) [purely cosmetic]
+20040523:
+ - fixed compilation error in registered versions (GRR)
- 20050410:
- - fix for YCbCr oversaturated-green bug(s) in TIFF decoder (GRR)
- - provisional fix for contiguous tiled TIFFs with bottom-* orientation (GRR)
-@@ -265,12 +262,50 @@
- - boosted maximum number of files from 4096 to 32768 (GRR)
- (note that OS kernel limits may also apply; for example, in Linux see
- MAX_ARG_PAGES in linux-<version>/include/linux/binfmts.h)
-- - xv-3.10a-bmp16.patch
-- (from http://www.coara.or.jp/~sudakyo/XV_jp.html)
++20050410:
++ - fix for YCbCr oversaturated-green bug(s) in TIFF decoder (GRR)
++ - provisional fix for contiguous tiled TIFFs with bottom-* orientation (GRR)
++ - fixes for gcc 3.3 -Wall warnings (GRR)
++ - fix for incorrect 16/24-bit display of xwd dumps (SJT)
++ - *SECURITY* fix for multiple input-validation bugs (OpenBSD/SuSE, Gentoo, GRR)
++ (this also completes the partial mktemp() security fix listed above)
++ - fix for (probable) 24-bit endianness bug in fixpix code (GRR)
++
++
++enhancements ((*) = listed on XV Downloads page, (<who>) = third-party):
++
++20040516:
++ - xv-3.10a.JPEG-patch (*)
++ (xv-3.10a.JPEG-patch.old differs only in ftp site listed in comments at top)
++ - xv-3.10a.TIFF-patch (*)
++ - xv-3.10a-png-1.2d.tar.gz (AL, AD) (*)
++ (xvjpeg.diff and xvtiff.diff ignored; xcmap.diff included in fixes)
++ - xvpng-1.2d-fix3.patch (GRR, SJT) (*)
++ - pdf.patch (*)
++ - windowid.patch + windowid.patch.readme (*)
++ - bmp32.patch (*)
++ - fixpix-20000610.tar.gz (GV)
++ (identical to 19961127 version except for README updates and new Win32 file)
++ [modified to be runtime-selectable via -/+fixpix option]
++ - browse-remember.patch (JZ)
++ - faster-smooth.patch (JZ)
++ - PAM support (GRR)
++ - PNG/GIF -ibg ("image background") transparency option (GRR)
++ (does not yet support TIFF, XPM or TGA)
++ - VersionInfo* in help screen (GRR)
++ - minor grammar/spelling fixes (GRR)
++ - floating-point support for -wait when USE_TICKS enabled (GRR)
++ - wheelmouse.patch (SB)
++ - freebsd-gravity-hints-patch (JR)
++ - xv-zx.patch (JCE)
++ - xv3.10a.wapbmp.patch (PSV)
++ - xv-3.10a-pcd.patch.20010708 (DAC)
++ - jp-ext-bzip2-1.1.patch
++ (from ftp://ftp.freebsd.org/pub/FreeBSD/ports/local-distfiles/shige/xv/)
++20050410:
++ - boosted maximum number of files from 4096 to 32768 (GRR)
++ (note that OS kernel limits may also apply; for example, in Linux see
++ MAX_ARG_PAGES in linux-<version>/include/linux/binfmts.h)
+ - xv-3.10a-bmp16.patch (KS)
- - final-image delay (e.g., "-wait 0.2,3" : pause 3 secs on final image) (GRR)
- - xv-numpad.patch (EK)
- - xv-delete-is-not-backspace.patch (EK)
- - made browser window (schnauzer) and icons configurable (AT, GRR)
++ - final-image delay (e.g., "-wait 0.2,3" : pause 3 secs on final image) (GRR)
++ - xv-numpad.patch (EK)
++ - xv-delete-is-not-backspace.patch (EK)
++ - made browser window (schnauzer) and icons configurable (AT, GRR)
+20050501:
+ - xv-3.10a-bmpfix.patch (WF) [*SECURITY*]
+ - xv310a-jp-extension-rev5.3.3.tar.gz (TI, IM, ..., WF)
-+ (adds support for MAG, MAKI, Pi, PIC, and PIC2 formats[*]; "magic suffix"
++ (adds support for MAG, MAKI, Pi, PIC, and PIC2 formats[!]; "magic suffix"
+ detection/conversion; MacBinary prefixes; archives as virtual filesystems;
+ multilingual text viewer [though not Unicode]; etc.)
+ - xv-3.10a-yaos.dif (WF, TO) [*SECURITY*]
@@ -844,7 +300,7 @@ diff -ruN xv-3.10a-bugfixes/README.jumbo xv-3.10a-enhancements/README.jumbo
+ - PATCH.stat (LJ)
+ - PATCH.thumbs (LJ)
+ - xv-startgrab-imake-hips.patch (JPD)
-+ ("hips" portion only; adds support for HIPS image format[*])
++ ("hips" portion only; adds support for HIPS image format[!])
+ - xv-3.10a-formatstr.patch (KS)
+ - xv-3.10a-shortsleep.patch (KS)
+ - xv-3.10a-locale-linux.patch (KS)
@@ -854,82 +310,119 @@ diff -ruN xv-3.10a-bugfixes/README.jumbo xv-3.10a-enhancements/README.jumbo
+ - xv-3.10a-xvexecpath.patch (but disabled pending fixes) (KS)
+ - xv-3.10a-zeroquit.patch (KS, GRR)
+
-+
-+[*] Note that all six of these formats may still suffer from exploitable heap
++[!] Note that all six of these formats may still suffer from exploitable heap
+ overflows [*SECURITY*] when decoding images with large (possibly invalid)
+ dimensions; as a result, they are DISABLED by default. (Search for "GRR
+ POSSIBLE OVERFLOW / FIXME" comments in xvmag.c, xvmaki.c, xvpi.c, xvpic.c,
+ xvpic2.c, and xvhips.c, but keep in mind that these may not be exhaustive.)
+ Users who choose to overlook these security issues can enable any or all
+ of them by editing config.h.
-
-
- not (yet?) included:
-@@ -284,31 +319,21 @@
- -rw-r--r-- 42397 Mar 11 2004 xv-3.10a-download-test2.patch
- -rw-r--r-- 47679 Mar 11 2004 xv-3.10a-download-test3.patch
- -rw-r--r-- 52745 Mar 11 2004 xv-3.10a-download-test4.patch
-- -rw-r--r-- 415 Mar 11 2004 xv-3.10a-formatstr.patch
- -rw-r--r-- 3423 Apr 24 2004 xv-3.10a-keyzoom.patch
-- -rw-r--r-- 1461 Mar 11 2004 xv-3.10a-locale-linux.patch
- -rw-r--r-- 12387 Mar 15 2004 xv-3.10a-menubutton.patch
- -rw-r--r-- 1178 Apr 24 2004 xv-3.10a-noblink.patch
-- -rw-r--r-- 484 Mar 11 2004 xv-3.10a-printkey.patch
- -rw-r--r-- 57092 Jul 9 2004 xv-3.10a-resolution.patch
- -rw-r--r-- 4645 Apr 24 2004 xv-3.10a-selall.patch
-- -rw-r--r-- 360 Mar 11 2004 xv-3.10a-shortsleep.patch
- -rw-r--r-- 702 Apr 24 2004 xv-3.10a-showlongname.patch
- -rw-r--r-- 1205 Apr 24 2004 xv-3.10a-staytoppdir.patch
-- -rw-r--r-- 1591 Mar 15 2004 xv-3.10a-sysconfdir.patch
- -rw-r--r-- 4228 Apr 24 2004 xv-3.10a-wheelmouse.patch
- -rw-r--r-- 744 Apr 24 2004 xv-3.10a-xvbutt_wait.patch
-- -rw-r--r-- 712 Mar 11 2004 xv-3.10a-xvexecpath.patch
- -rw-r--r-- 3757 Jul 9 2004 xv-3.10a-xvscrl_button2.patch
- -rw-r--r-- 1494 Jul 9 2004 xv-3.10a-xvscrl_wait.patch
- -rw-r--r-- 19352 Jul 9 2004 xv-3.10a-xvzoom.patch
-- -rw-r--r-- 1827 Apr 24 2004 xv-3.10a-zeroquit.patch
-
-- - xv310a-jp-extension-rev5.3.3.tar.gz [extensive]
-- - xv-3.10a-jp-extension-5.3.3-png-1.2d.patch [PNG patch relative to jp-ext]
-- - xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch [??]
++
++
++not (yet?) included:
++
++ - others from http://www.coara.or.jp/~sudakyo/XV_jp.html (some are duplicates):
++ -rw-r--r-- 4644 Mar 11 2004 xv-3.10a-directory.patch
++ -rw-r--r-- 462 Mar 11 2004 xv-3.10a-dirwkey.patch
++ -rw-r--r-- 688 Mar 11 2004 xv-3.10a-docdir.patch
++ -rw-r--r-- 11952 Mar 11 2004 xv-3.10a-download-test0.patch
++ -rw-r--r-- 41786 Mar 11 2004 xv-3.10a-download-test1.patch
++ -rw-r--r-- 42397 Mar 11 2004 xv-3.10a-download-test2.patch
++ -rw-r--r-- 47679 Mar 11 2004 xv-3.10a-download-test3.patch
++ -rw-r--r-- 52745 Mar 11 2004 xv-3.10a-download-test4.patch
++ -rw-r--r-- 3423 Apr 24 2004 xv-3.10a-keyzoom.patch
++ -rw-r--r-- 12387 Mar 15 2004 xv-3.10a-menubutton.patch
++ -rw-r--r-- 1178 Apr 24 2004 xv-3.10a-noblink.patch
++ -rw-r--r-- 57092 Jul 9 2004 xv-3.10a-resolution.patch
++ -rw-r--r-- 4645 Apr 24 2004 xv-3.10a-selall.patch
++ -rw-r--r-- 702 Apr 24 2004 xv-3.10a-showlongname.patch
++ -rw-r--r-- 1205 Apr 24 2004 xv-3.10a-staytoppdir.patch
++ -rw-r--r-- 4228 Apr 24 2004 xv-3.10a-wheelmouse.patch
++ -rw-r--r-- 744 Apr 24 2004 xv-3.10a-xvbutt_wait.patch
++ -rw-r--r-- 3757 Jul 9 2004 xv-3.10a-xvscrl_button2.patch
++ -rw-r--r-- 1494 Jul 9 2004 xv-3.10a-xvscrl_wait.patch
++ -rw-r--r-- 19352 Jul 9 2004 xv-3.10a-xvzoom.patch
++
+ - xv-3.10a+jp-extension-rev5.3.3+FLmask.v2.1+png+misc.patch ["mask" support]
-
-- - xv-grab-imake-hips.patch (JPD) [HIPS format, -startgrab option]
- - xv-psnewstyle.patch (TA) [coming later in 2005?]
- - xv-3.10a.patch.linux (PBJ) [maybe use vdcomp.c changes?]
- - xvxpm-anthony-thyssen.c (AT) ["slate grey" bug already gone?]
-@@ -332,8 +357,8 @@
- not finished (and/or even started ;-) ):
-
- - fix xvpng.c not to use direct struct access
-- - fix for never-ending pile of SLOW popups when viewing TIFFs with unknown tags
-- (or truncated/corrupted images)
++
++ - xv-psnewstyle.patch (TA) [coming "soon"?]
++ - xv-3.10a.patch.linux (PBJ) [maybe use vdcomp.c changes?]
++ - xvxpm-anthony-thyssen.c (AT) ["slate grey" bug already gone?]
++ - xv-geoff-kuenning-iconsize-slideshow.patch [var. icons; full-screen slides]
++ - xv-scott-marovich-20070214-xvtiff.c.patch6.unified [TIFF CMYK support]
++
++ - stuff in xv/unsupt:
++ -rw-r--r-- 30527 Dec 22 1994 FITS.rite
++ -rw-r--r-- 49152 Dec 22 1994 FITS.tar
++ -rw-r--r-- 3753 Dec 22 1994 G3.patch1
++ -rw-r--r-- 24576 Dec 22 1994 G3.tar
++ -rw-r--r-- 1098 Dec 22 1994 INFO.cgm
++ -rw-r--r-- 1941 Dec 22 1994 README
++ -rwxr-xr-x 1059 Dec 22 1994 getweather
++ -rwxr-xr-x 2186 Dec 22 1994 getweather.ksh
++ -rw-r--r-- 856 Dec 22 1994 twm.fix
++ -rw-r--r-- 844 Dec 22 1994 vargs.c
++ -rw-r--r-- 47626 Dec 22 1994 vis
++ -rw-r--r-- 21097 Dec 22 1994 xscm
++
++
++
++not finished (and/or even started ;-) ):
++
++ - fix xvpng.c not to use direct struct access
+ - (better) fix for never-ending pile of SLOW popups when viewing TIFFs with
+ unknown tags (or truncated/corrupted images)
- - fix for minor .Z inefficiency in xv.c ("FIXME")
- - fix for filename entry-field mouse/cursor bogosity
- (want at least positioning to work; preferably also select/cut/paste)
-@@ -344,6 +369,7 @@
- - transparency support for TIFF, XPM and TGA images
- - support for tiled background image (with transparent foreground image)
- - MNG/JNG support
++ - fix for minor .Z inefficiency in xv.c ("FIXME")
++ - fix for filename entry-field mouse/cursor deficiencies
++ (positioning fixed 20070104 by Ross Combs; would like select/cut/paste, too)
++ - fix for .ppm.gz "disk leak" [can't reproduce...already fixed?]
++ (maybe occurs only if filesystem is already nearly full? bad .gz?)
++
++ - transparency support for TIFF, XPM and TGA images
++ - support for tiled background image (with transparent foreground image)
++ - MNG/JNG support
+ - SVG support
-
-
- ChangeLog
-@@ -364,7 +390,7 @@
- 20040531
- fixed undefined CLK_TCK with gcc -ansi (enh/USE_TICKS option); made
- libjpeg, libtiff, libpng and zlib sections of makefile more consistent
-- (enh);
++
++
++ChangeLog
++---------
++
++ 20000220
++ original pair of jumbo patches, comprising perhaps 16 fix-patches and a
++ dozen enhancement-patches; never publicly released
++
++ 20040516
++ first public release, incorporating 25 fix-patches and 21 enhancement-
++ patches
++
++ 20040523
++ minor fix to xvctrl.c to support registered versions (GRR warnings-patch
++ was slightly overzealous); switched to tarball packaging
++
++ 20040531
++ fixed undefined CLK_TCK with gcc -ansi (enh/USE_TICKS option); made
++ libjpeg, libtiff, libpng and zlib sections of makefile more consistent
+ (enh)
-
- 20040606
- added freshmeat link, build instructions, and changelog to jumbo README
-@@ -385,3 +411,32 @@
- sex bug in 24-bit FixPix display code (enh/USE_24BIT_ENDIAN_FIX option);
- fixed numerical-keypad NumLock behavior and delete-key behavior in file-
- load/save window (enh); made schnauzer window and icons configurable (enh)
++
++ 20040606
++ added freshmeat link, build instructions, and changelog to jumbo README
++ (this file)
++
++ 20050213
++ increased max number of files from 4096 to 32768 (enh)
++
++ 20050320-20050410
++ fixed two very long-standing YCbCr bugs in TIFF decoder (fix);
++ provisionally fixed bug in TIFF decoder for contiguous tiled TIFFs with
++ bottom-* orientation (fix/USE_TILED_TIFF_BOTLEFT_FIX option); fixed new
++ gcc 3.3 warnings (fix); fixed incorrect 16/24-bit display of xwd dumps
++ (fix); fixed multiple input-validation bugs (potential heap overflows)
++ and mktemp() dependencies (*SECURITY* fixes: CAN-2004-1725, CAN-2004-
++ 1726, CAN-2005-0665, CERT VU#622622, and others); added support for 16-
++ and 32-bit BMPs using bitfields "compression" (enh); fixed probable byte-
++ sex bug in 24-bit FixPix display code (enh/USE_24BIT_ENDIAN_FIX option);
++ fixed numerical-keypad NumLock behavior and delete-key behavior in file-
++ load/save window (enh); made schnauzer window and icons configurable (enh)
+
+ 20050417
+ incorporated "Japanese extension" patches, revision 5.3.3 (enh); fixed
@@ -959,9 +452,118 @@ diff -ruN xv-3.10a-bugfixes/README.jumbo xv-3.10a-enhancements/README.jumbo
+ suffix" (xv_mgcsfx) config dir (enh); added PREFIX and DESTDIR support to
+ Makefile (enh); fixed handling of zero-length files and other text-viewer
+ failures (enh)
-diff -ruN xv-3.10a-bugfixes/README.pcd xv-3.10a-enhancements/README.pcd
---- xv-3.10a-bugfixes/README.pcd 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/README.pcd 2001-07-08 11:21:19.000000000 -0700
++
++ 20050528
++ conditionally added missing alloca.h to xvpcd.c (required if alloca() is
++ a macro and alloca.h not included in stdlib.h, for example); fixed bogus
++ __S_IWRITE introduced in 20050501 release; fixed Makefile "install" target
++ (mkdir, chmod); fixed bug in MUST macro in xvwbmp.c; fixed prototype
++ warnings in xvevent.c, xvpcd.c (JRK, GRR)
++ - xv-3.10a-jimkirk-fixes.patch
++
++ 20050630
++ fixed broken mkdir(.xvpics) introduced in 20050501 release (RJH, GRR);
++ tweaked GUNZIP config for OpenBSD (GRR)
++ - xv-3.10a-xvpics-mkdir-fix.patch
++
++ 20051014
++ fixed longstanding xvevent.c typo (wasJpegUp -> wasPngUp) that caused build
++ failure if no JPEG support (TAR)
++
++ 20051019
++ fixed Darwin (Mac OS X) build error in xv.h and vdcomp.c due to lack of
++ malloc.h (JDB)
++
++ 20070210
++ fixed minor grammos (GRR); promoted PNG to first position, demoted GIF to
++ third (GRR); changed internal type of default image to PNG (GRR); increased
++ max files again, to 65536 (GRR)
++
++ 20070310
++ incorporated JPEG-2000 patch (SBM, GRR); added manual fax options for
++ unrecognized G3 images (SBM); relaxed 30-byte minimum file size (SBM)
++ - http://www.ece.uvic.ca/~mdadams/jasper/software/xv-patches
++
++ 20070318
++ incorporated 16bps raw (binary) PPM patch (define ASSUME_RAW_PPM_LSB_FIRST
++ for old behavior) (RAC, GRR); updated format list, web sites in xv man page
++ (GRR); fixed Makefile "install" target to create any necessary directories
++ (RAC, GRR); fixed GIF decoder bug (sizes of global, local color tables
++ different) (GRR)
++ - xv-ross-combs-ppm-16bps-rawbits.patch
++
++ 20070325
++ fixed invalid gamma assumption in PNG decoder (=> progressive color changes
++ over load/save cycles) (GRR)
++
++ 20070328
++ fixed animated-GIF /tmp/xvpgXXXXXX droppings (GRR)
++
++ 20070331
++ fixed PNG duplicate-palette-entries bug (GRR)
++
++ 20070415
++ incorporated EXIF-preserve patch (GHK); added missing JP2/JPC VS bits code
++ (GRR); added extended-warning options to CCOPTS (RAC); added "const" to
++ huge number of function args (RAC, GRR); made more effectively static
++ functions officially static (RAC); added mouse-clickability (but not
++ selectability) to text-entry fields (RAC); fixed window positioning (race
++ conditions?) under some virtual window managers (e.g., tvtwm) (RAC);
++ removed explicit paths for external (de)compressors (GRR, RAC)
++ - xv-geoff-kuenning-jpeg-exif-preserve.patch
++ - xv-ross-combs-20070104.diff
++
++ 20070422
++ incorporated function-key-scripts patch (see contrib/fnkey-scripts) (AS);
++ fixed man-page-section extensions ("1", not "l" or "1X") (FG); switched to
++ more sensible install paths for docs (FG); added Fedora Core build script
++ (see contrib/fedora) (JC); fixed VS to switch from move-mode to copy-mode
++ if source dir is read-only (EAJ); extended VS incremental-search mode (EAJ)
++ - xv-alexey-spiridonov-20070116-fnkey-scripts.tar.bz2
++ - xv-fabian-greffrath-20070215-debian-04-manpages.dpatch
++ - xv-fabian-greffrath-20070215-debian-03-makefiles.dpatch
++ - xv-john-cooper-Build-FC5-script.sh
++ - xv-erling-jacobsen-20060617-incr-search.patch
++
++ 20070428
++ modified install to include README.jumbo in docs (GRR); incorporated PNG
++ no-stdio patch (SBM); fixed XWD endianness support, improved performance
++ (replaces SJT 16/24-bit fix) (SBM)
++ - xv-scott-marovich-20070214-xvpng.diff
++ - xv-scott-marovich-20070214-xvxwd.c.patch
++
++ 20070506
++ added JPEG CMYK support (SBM); fixed TIFF (and others?) /tmp/xvpgXXXXXX
++ droppings (GRR); added VS clipboard support (JG)
++ - xv-scott-marovich-20070214-xvjpeg.c.patch
++ - xv-jurgen-grahn-20051127-schnauzer-clip.patch
++
++ 20070512
++ inverted handling of malloc.h header file to require NEED_MALLOC_H macro
++ for those few systems that actually need it (GRR)
++
++ 20070513
++ fixed GCC 4.1.x warnings (GRR); next round of const cleanup (GRR); fixed
++ minor TIFF memleak (GRR)
++
++ 20070514
++ fixed TIFF YCbCr reference black/white levels (SBM); added option to use
++ libjpeg YCbCr-to-RGB conversion for TIFF images (SBM, GRR)
++ - xv-scott-marovich-20070214-xvtiff.c.patch2.unified
++ - xv-scott-marovich-20070214-xvtiff.c.patch3.unified
++
++ 20070519
++ fixed handling of multi-page JPEG-compressed TIFFs (old or new) (SBM);
++ added TIFF YCbCr separated-color-plane support (may require libtiff
++ patch(es) to tif_ojpeg.c and/or tif_jpeg.c) (SBM)
++ - xv-scott-marovich-20070214-xvtiff.c.patch4.unified
++ - xv-scott-marovich-20070214-xvtiff.c.patch5.unified
++
++ 20070520
++ updated README.jumbo
+diff -u -r --new-file xv-3.10a.orig/README.pcd xv-3.10a/README.pcd
+--- xv-3.10a.orig/README.pcd 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/README.pcd 2001-07-08 13:21:19.000000000 -0500
@@ -0,0 +1,159 @@
+Copyright 1993-2001 David Clunie.
+
@@ -1122,21 +724,9 @@ diff -ruN xv-3.10a-bugfixes/README.pcd xv-3.10a-enhancements/README.pcd
+
+
+
-diff -ruN xv-3.10a-bugfixes/bggen.c xv-3.10a-enhancements/bggen.c
---- xv-3.10a-bugfixes/bggen.c 2004-05-16 17:50:52.000000000 -0700
-+++ xv-3.10a-enhancements/bggen.c 2005-04-17 14:04:22.000000000 -0700
-@@ -34,7 +34,7 @@
- #define MAXCOLS 128
-
- /* some VMS thing... */
--#ifdef vax11c
-+#if defined(vax11c) || (defined(__sony_news) && (defined(bsd43) || defined(__bsd43) || defined(SYSTYPE_BSD) || defined(__SYSTYPE_BSD)))
- #include <ctype.h>
- #endif
-
-diff -ruN xv-3.10a-bugfixes/bits/br_bzip2 xv-3.10a-enhancements/bits/br_bzip2
---- xv-3.10a-bugfixes/bits/br_bzip2 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_bzip2 1998-04-12 19:23:39.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_bzip2 xv-3.10a/bits/br_bzip2
+--- xv-3.10a.orig/bits/br_bzip2 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_bzip2 1998-04-12 21:23:39.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_bzip2_width 48
+#define br_bzip2_height 48
@@ -1165,9 +755,71 @@ diff -ruN xv-3.10a-bugfixes/bits/br_bzip2 xv-3.10a-enhancements/bits/br_bzip2
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_mag xv-3.10a-enhancements/bits/br_mag
---- xv-3.10a-bugfixes/bits/br_mag 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_mag 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_jp2 xv-3.10a/bits/br_jp2
+--- xv-3.10a.orig/bits/br_jp2 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_jp2 2005-05-09 00:00:27.000000000 -0500
+@@ -0,0 +1,27 @@
++#define br_jp2_width 48
++#define br_jp2_height 48
++static unsigned char br_jp2_bits[] = {
++ 0xe0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, 0x00, 0x09, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0xff, 0x03,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0xfb, 0xf1, 0x01, 0x02,
++ 0x20, 0x00, 0xfb, 0xfb, 0x03, 0x02, 0x20, 0x00, 0x1b, 0x1b, 0x03, 0x02,
++ 0x20, 0x00, 0x1b, 0x1b, 0x00, 0x02, 0x20, 0x00, 0x1b, 0x1b, 0x00, 0x02,
++ 0x20, 0x00, 0x9b, 0x1b, 0x00, 0x02, 0x20, 0x00, 0xfb, 0x19, 0x00, 0x02,
++ 0x20, 0x00, 0xfb, 0x18, 0x00, 0x02, 0x20, 0x18, 0x1b, 0x18, 0x00, 0x02,
++ 0x20, 0x18, 0x1b, 0x18, 0x00, 0x02, 0x20, 0xb8, 0x1b, 0x18, 0x03, 0x02,
++ 0x20, 0xf0, 0x19, 0xf8, 0x03, 0x02, 0x20, 0xe0, 0x18, 0xf0, 0x01, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
+diff -u -r --new-file xv-3.10a.orig/bits/br_jpc xv-3.10a/bits/br_jpc
+--- xv-3.10a.orig/bits/br_jpc 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_jpc 2005-05-09 00:00:27.000000000 -0500
+@@ -0,0 +1,27 @@
++#define br_jpc_width 48
++#define br_jpc_height 48
++static unsigned char br_jpc_bits[] = {
++ 0xe0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, 0x00, 0x09, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00,
++ 0x20, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0xff, 0x03,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0xfb, 0xf1, 0x01, 0x02,
++ 0x20, 0x00, 0xfb, 0xfb, 0x03, 0x02, 0x20, 0x00, 0x1b, 0x1b, 0x03, 0x02,
++ 0x20, 0x00, 0x1b, 0x03, 0x03, 0x02, 0x20, 0x00, 0x1b, 0x03, 0x03, 0x02,
++ 0x20, 0x00, 0x9b, 0x83, 0x01, 0x02, 0x20, 0x00, 0xfb, 0xc1, 0x01, 0x02,
++ 0x20, 0x00, 0xfb, 0xe0, 0x00, 0x02, 0x20, 0x18, 0x1b, 0x70, 0x00, 0x02,
++ 0x20, 0x18, 0x1b, 0x38, 0x00, 0x02, 0x20, 0xb8, 0x1b, 0x18, 0x00, 0x02,
++ 0x20, 0xf0, 0x19, 0xf8, 0x03, 0x02, 0x20, 0xe0, 0x18, 0xf8, 0x03, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x7f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
+diff -u -r --new-file xv-3.10a.orig/bits/br_mag xv-3.10a/bits/br_mag
+--- xv-3.10a.orig/bits/br_mag 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_mag 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_mag_width 48
+#define br_mag_height 48
@@ -1196,9 +848,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_mag xv-3.10a-enhancements/bits/br_mag
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_maki xv-3.10a-enhancements/bits/br_maki
---- xv-3.10a-bugfixes/bits/br_maki 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_maki 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_maki xv-3.10a/bits/br_maki
+--- xv-3.10a.orig/bits/br_maki 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_maki 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_maki_width 48
+#define br_maki_height 48
@@ -1227,9 +879,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_maki xv-3.10a-enhancements/bits/br_maki
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_mgcsfx xv-3.10a-enhancements/bits/br_mgcsfx
---- xv-3.10a-bugfixes/bits/br_mgcsfx 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_mgcsfx 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_mgcsfx xv-3.10a/bits/br_mgcsfx
+--- xv-3.10a.orig/bits/br_mgcsfx 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_mgcsfx 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_mgcsfx_width 48
+#define br_mgcsfx_height 48
@@ -1258,9 +910,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_mgcsfx xv-3.10a-enhancements/bits/br_mgcsfx
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_pcd xv-3.10a-enhancements/bits/br_pcd
---- xv-3.10a-bugfixes/bits/br_pcd 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_pcd 1995-06-15 21:31:53.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_pcd xv-3.10a/bits/br_pcd
+--- xv-3.10a.orig/bits/br_pcd 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_pcd 1995-06-15 23:31:53.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_pcd_width 48
+#define br_pcd_height 48
@@ -1289,9 +941,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_pcd xv-3.10a-enhancements/bits/br_pcd
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_pi xv-3.10a-enhancements/bits/br_pi
---- xv-3.10a-bugfixes/bits/br_pi 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_pi 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_pi xv-3.10a/bits/br_pi
+--- xv-3.10a.orig/bits/br_pi 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_pi 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_pi_width 48
+#define br_pi_height 48
@@ -1320,9 +972,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_pi xv-3.10a-enhancements/bits/br_pi
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_pic xv-3.10a-enhancements/bits/br_pic
---- xv-3.10a-bugfixes/bits/br_pic 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_pic 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_pic xv-3.10a/bits/br_pic
+--- xv-3.10a.orig/bits/br_pic 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_pic 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_pic_width 48
+#define br_pic_height 48
@@ -1351,9 +1003,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_pic xv-3.10a-enhancements/bits/br_pic
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_pic2 xv-3.10a-enhancements/bits/br_pic2
---- xv-3.10a-bugfixes/bits/br_pic2 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_pic2 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_pic2 xv-3.10a/bits/br_pic2
+--- xv-3.10a.orig/bits/br_pic2 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_pic2 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,27 @@
+#define br_pic2_width 48
+#define br_pic2_height 48
@@ -1382,9 +1034,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_pic2 xv-3.10a-enhancements/bits/br_pic2
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03};
-diff -ruN xv-3.10a-bugfixes/bits/br_png xv-3.10a-enhancements/bits/br_png
---- xv-3.10a-bugfixes/bits/br_png 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_png 1996-06-13 14:32:08.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_png xv-3.10a/bits/br_png
+--- xv-3.10a.orig/bits/br_png 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_png 1996-06-13 16:32:08.000000000 -0500
@@ -0,0 +1,28 @@
+#define br_png_width 48
+#define br_png_height 48
@@ -1414,9 +1066,9 @@ diff -ruN xv-3.10a-bugfixes/bits/br_png xv-3.10a-enhancements/bits/br_png
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
+ };
-diff -ruN xv-3.10a-bugfixes/bits/br_zx xv-3.10a-enhancements/bits/br_zx
---- xv-3.10a-bugfixes/bits/br_zx 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/bits/br_zx 1998-08-06 13:00:03.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/bits/br_zx xv-3.10a/bits/br_zx
+--- xv-3.10a.orig/bits/br_zx 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/bits/br_zx 1998-08-06 15:00:03.000000000 -0500
@@ -0,0 +1,28 @@
+#define br_zx_width 48
+#define br_zx_height 48
@@ -1446,2778 +1098,320 @@ diff -ruN xv-3.10a-bugfixes/bits/br_zx xv-3.10a-enhancements/bits/br_zx
+ 0x20, 0x00, 0x00, 0x84, 0x87, 0x03, 0x20, 0x00, 0x00, 0xc2, 0xc3, 0x03,
+ 0x20, 0x00, 0x00, 0xe1, 0xe1, 0x03, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
+ };
-diff -ruN xv-3.10a-bugfixes/config.h xv-3.10a-enhancements/config.h
---- xv-3.10a-bugfixes/config.h 2005-03-21 23:21:31.000000000 -0800
-+++ xv-3.10a-enhancements/config.h 2005-04-30 23:52:42.000000000 -0700
-@@ -6,26 +6,46 @@
- /***************************************************************************
- * GZIP'd file support
- *
-- * if you have the gnu uncompression utility 'gunzip', XV can use it to
-- * automatically 'unzip' any gzip'd files. To enable this feature,
-- * change 'undef' to 'define' in the following line. Needless to say, if
-- * your gunzip is installed elsewhere on your machine, change the 'GUNZIP'
-- * definition appropriately. (use 'which gunzip' to find if you have gunzip,
-- * and where it lives)
-+ * if you have the GNU uncompression utility 'gunzip' (or 'gzip' itself,
-+ * which is just a link to gunzip), XV can use it to automatically 'unzip'
-+ * any gzip'd files. To enable this feature, change 'undef' to 'define' in
-+ * the following line. Needless to say, if your gunzip is installed elsewhere
-+ * on your machine, change the 'GUNZIP' definition appropriately. (use
-+ * 'which gunzip' to find if you have gunzip, and where it lives; ditto for
-+ * gzip)
- */
--#undef USE_GUNZIP
-+#define USE_GUNZIP
-
- #ifdef USE_GUNZIP
- # ifdef VMS
- # define GUNZIP "UNCOMPRESS"
- # else
--/* define GUNZIP "/usr/local/bin/gunzip -q" */
--# define GUNZIP "/usr/bin/gzip -dq" /* more portable */
-+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__linux__)
-+# define GUNZIP "/usr/bin/gzip -dq"
-+# else
-+# define GUNZIP "/usr/local/bin/gzip -dq" /* is full path truly needed? */
-+# endif
- # endif
- #endif
-
-
- /***************************************************************************
-+ * BZIP2'd file support
-+ *
-+ * if you have the uncompression utility 'bunzip2' (or 'bzip2' itself, which
-+ * is just a link to bunzip2), XV can use it to automatically 'unzip' any
-+ * bzip2'd files. To enable this feature, change 'undef' to 'define' in the
-+ * following line (if not already done). Use 'which bunzip2' or 'which bzip2'
-+ * to find if you have bzip2/bunzip2, and where it lives.
-+ */
-+#define USE_BUNZIP2
-+
-+#ifdef USE_BUNZIP2
-+# define BUNZIP2 "bzip2 -d" /* should this include the full path? */
-+#endif
-+
-+
-+/***************************************************************************
- * compress'd file support
- *
- * if you have GUNZIP defined above, just ignore this, as 'gunzip' can
-@@ -38,7 +58,14 @@
- */
- #define UNCOMPRESS "/usr/ucb/uncompress"
-
--#if defined(hpux) || defined(SVR4) || defined(__386BSD__)
-+#if defined(hpux) || defined(SVR4) || \
-+ defined(__386BSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
-+ defined(__linux__)
-+ /*
-+ 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.
-+ */
- # undef UNCOMPRESS
- # define UNCOMPRESS "/usr/bin/uncompress"
- #endif
-@@ -90,6 +117,7 @@
- */
-
- /* #define GS_PATH "/usr/local/bin/gs" */
-+#define GS_PATH "/usr/bin/gs"
- /* #define GS_LIB "." */
- /* #define GS_DEV "ppmraw" */
-
-@@ -120,3 +148,201 @@
-
- #define BACKING_STORE
-
-+
-+/***************************************************************************
-+ * PhotoCD/MAG/PIC/MAKI/Pi/PIC2/HIPS format Support:
-+ *
-+ * if, for whatever reason--say, security concerns--you don't want to
-+ * include support for one or more of the PhotoCD, MAG/MAKI/Pi/PIC/PIC2
-+ * (Japanese), or HIPS (astronomical) image formats, change the relevant
-+ * 'define' to 'undef' in the following lines. Conversely, if you *do*
-+ * want them, change 'undef' to 'define' as appropriate.
-+ */
-+
-+#define HAVE_PCD /* believed to be reasonably safe */
-+
-+#undef HAVE_MAG /* probable security issues */
-+#undef HAVE_MAKI /* probable security issues */
-+#undef HAVE_PI /* probable security issues */
-+#undef HAVE_PIC /* probable security issues */
-+#undef HAVE_PIC2 /* probable security issues */
-+
-+#undef HAVE_HIPS /* probable security issues */
-+
-+
-+/***************************************************************************
-+ * MacBinary file support:
-+ *
-+ * if you want XV to be able to handle ``MacBinary'' files (which have
-+ * 128 byte info file header at the head), change 'undef' to 'define'
-+ * in the following line.
-+ */
-+
-+#undef MACBINARY
-+
-+
-+/***************************************************************************
-+ * Auto Expand support:
-+ *
-+ * if you want to extract archived file automatically and regard it as
-+ * a directory, change 'undef' to 'define' in the AUTO_EXPAND line.
-+ *
-+ * Virtual Thumbdir support:
-+ *
-+ * if you want Virtual directory based Thumbdir(It means that XV
-+ * doesn't forget builded Icons still be quited even if the directory
-+ * is read-only), change 'undef' to 'define' the VIRTUAL_TD line.
-+ */
-+
-+#undef AUTO_EXPAND
-+#undef VIRTUAL_TD
-+
-+#if defined(VIRTUAL_TD) && !defined(AUTO_EXPAND)
-+# undef VIRTUAL_TD
-+#endif
-+
-+
-+/***************************************************************************
-+ * Adjust the aspect ratio of Icons:
-+ *
-+ * if you want to adjust the aspect ratio of the icons in Visual
-+ * Schnauzer, change 'undef' to 'define' in the following line.
-+ */
-+
-+#undef VS_ADJUST
-+
-+
-+/***************************************************************************
-+ * Restore original colormap:
-+ *
-+ * if you want to restore original colormap when icons in Visual
-+ * Shunauzer is double-clicked, change 'undef' to 'define' in the
-+ * following line.
-+ */
-+
-+#undef VS_RESCMAP
-+
-+
-+/***************************************************************************
-+ * TextViewer l10n support:
-+ *
-+ * if you want XV to show the text in Japanese on TextViewer, change
-+ * 'undef' to 'define' in the following line.
-+ */
-+
-+#undef TV_L10N
-+
-+#ifdef TV_L10N
-+/*
-+ * if you want to change the default code-set used in case that XV
-+ * fails to select correct code-set, uncomment the '#define
-+ * LOCALE_DEFAULT' line and change the 'LOCALE_DEFAULT' definition
-+ * appropriately.
-+ * (0:ASCII, 1:EUC-j, 2:JIS, 3:MS Kanji) */
-+
-+/* # define LOCALE_DEFAULT 0 */
-+
-+/*
-+ * Uncomment and edit the following lines, if your X Window System was
-+ * not compiled with -DX_LOCALE and you failed to display the Japanese
-+ * text in TextViewer. You don't have to write locale name of JIS code-set
-+ * and Microsoft code-set, if your system doesn't support those code-sets.
-+ */
-+
-+/*
-+# define LOCALE_NAME_EUC "ja_JP.EUC"
-+# define LOCALE_NAME_JIS "ja_JP.JIS"
-+# define LOCALE_NAME_MSCODE "ja_JP.SJIS"
-+*/
-+
-+/*
-+ * if your system doesn't have the Japanese fonts in the sizes,
-+ * Uncomment and edit the following font size entries.
-+ */
-+
-+/* # define TV_FONTSIZE 14,16,24 */
-+
-+/*
-+ * If you need, uncomment and modify the following font name.
-+ */
-+
-+/* # define TV_FONTSET "-*-fixed-medium-r-normal--%d-*" */
-+#endif /* TV_L10N */
-+
-+
-+/***************************************************************************
-+ * User definable filter support:
-+ *
-+ * Use the filters as input and output method for load and save unsupported
-+ * image format file. The filter command is recognized by definition of
-+ * magic number or suffix in "~/.xv_mgcsfx" .
-+ * To enable this feature, change 'undef' to 'define' in the following line.
-+ */
-+#undef HAVE_MGCSFX
-+
-+#ifdef HAVE_MGCSFX
-+/*
-+ * Support symbol 'auto' as <input image type> in startup file. This type
-+ * cannot use pipe as input; it writes to a temporary file and recognizes
-+ * the actual filetype by XV processing.
-+ */
-+# define HAVE_MGCSFX_AUTO
-+
-+/*
-+ * The startup file of definition for MgcSfx. 'MGCSFX_SITE_RC' is read
-+ * first and '~/MGCSFX_RC' is second. So same definitions in both files
-+ * are overridden by '~/MGCSFX_RC'
-+ * To define startup file, see the sample of startup file 'xv_mgcsfx.sample'.
-+ */
-+# define MGCSFX_SITE_RC "xv_mgcsfx"
-+# define MGCSFX_RC ".xv_mgcsfx"
-+
-+/*
-+ * If you want startup file to pass preprocessor in reading time, then
-+ * change 'undef' to 'define' in the following line.
-+ *
-+ * WARNING : If you decide to use preprocessor, you must not write
-+ * '# <comment>' style comment in startup file. Because,
-+ * preprocessor can't recognize. */
-+# undef USE_MGCSFX_PREPROCESSOR
-+
-+# ifdef USE_MGCSFX_PREPROCESSOR
-+/*
-+ * This is used like "system("MGCSFX_PREPROCESSOR MGCSFX_RC > tmp_name");",
-+ * and read tmp_name instead of MGCSFX_RC.
-+ */
-+# define MGCSFX_PREPROCESSOR "/usr/lib/cpp"
-+/* # define MGCSFX_PREPROCESSOR "cc -E" */
-+
-+# endif /* USE_MGCSFX_PREPROCESSOR */
-+
-+/*
-+ * Default string of command. If input command is required for undefined file,
-+ * dialog is popuped with 'MGCSFX_DEFAULT_INPUT_COMMAND'. And, if output
-+ * command is required in save dialog of MgcSfx, dialog is popuped with
-+ * 'MGCSFX_DEFAULT_OUTPUT_COMMAND'.
-+ *
-+ * WARNING : Now, supported only 'PNM' image format, when command input is
-+ * required. You should define filter which use 'PNM' image format
-+ * as input or output.
-+ */
-+# define MGCSFX_DEFAULT_INPUT_COMMAND "tifftopnm"
-+# define MGCSFX_DEFAULT_OUTPUT_COMMAND "pnmtotiff"
-+
-+#endif /* HAVE_MGCSFX */
-+
-+
-+/***************************************************************************
-+ * Multi-Lingual TextViewer
-+ *
-+ * if you want XV to show the text in multi-lingual on TextViewer, change
-+ * 'undef' to 'define' in the following line.
-+ */
-+
-+#undef TV_MULTILINGUAL
-+
-+#define TV_DEFAULT_CODESET TV_EUC_JAPAN
-+
-+#ifdef TV_MULTILINGUAL
-+# undef TV_L10N
-+#endif
-diff -ruN xv-3.10a-bugfixes/tiff/Makefile xv-3.10a-enhancements/tiff/Makefile
---- xv-3.10a-bugfixes/tiff/Makefile 2004-05-16 18:49:11.000000000 -0700
-+++ xv-3.10a-enhancements/tiff/Makefile 2005-04-17 14:45:28.000000000 -0700
-@@ -38,7 +38,7 @@
- IPATH= -I.
-
- COPTS= -O
--CFLAGS= ${COPTS} ${IPATH}
-+CFLAGS= ${COPTS} ${IPATH} -D_BSD_SOURCE
-
- INCS= tiff.h tiffio.h
-
-diff -ruN xv-3.10a-bugfixes/vdcomp.c xv-3.10a-enhancements/vdcomp.c
---- xv-3.10a-bugfixes/vdcomp.c 2005-03-20 17:48:59.000000000 -0800
-+++ xv-3.10a-enhancements/vdcomp.c 2005-04-17 22:59:39.000000000 -0700
-@@ -106,6 +106,7 @@
- !defined(pyr) && \
- !defined(__UMAXV__) && \
- !defined(bsd43) && \
-+ !defined(__bsd43) && \
- !defined(aux) && \
- !defined(__bsdi__) && \
- !defined(sequent) && \
-@@ -115,7 +116,14 @@
- # if defined(hp300) || defined(hp800) || defined(NeXT)
- # include <sys/malloc.h> /* it's in 'sys' on HPs and NeXT */
- # else
--# include <malloc.h>
-+# if !defined(__386BSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
-+ /*
-+ 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.
-+ */
-+# include <malloc.h>
-+# endif
- # endif
- # endif
- #endif /* !VMS */
-diff -ruN xv-3.10a-bugfixes/xcmap.c xv-3.10a-enhancements/xcmap.c
---- xv-3.10a-bugfixes/xcmap.c 2005-03-20 15:51:59.000000000 -0800
-+++ xv-3.10a-enhancements/xcmap.c 2005-04-17 14:45:28.000000000 -0700
-@@ -163,7 +163,7 @@
- XSetBackground(theDisp,theGC,bcol);
-
- CreateMainWindow(cmd,geom,argc,argv);
-- Resize(WIDE,HIGH);
-+ Resize((int)WIDE,(int)HIGH);
-
- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
- | StructureNotifyMask | ButtonPressMask);
-@@ -212,10 +212,10 @@
-
- case ConfigureNotify: {
- XConfigureEvent *conf_event = (XConfigureEvent *) event;
-+ int w = conf_event->width, h = conf_event->height;
-
-- if (conf_event->window == mainW &&
-- (conf_event->width != WIDE || conf_event->height != HIGH))
-- Resize(conf_event->width, conf_event->height);
-+ if (conf_event->window == mainW && (w != WIDE || h != HIGH))
-+ Resize((int)(w ? w : WIDE), (int)(h ? h : HIGH));
- }
- break;
-
-@@ -274,6 +274,8 @@
- WIDE = HIGH = 256; /* default window size */
-
- x=y=w=h=1;
-+ hints.flags = 0;
-+
- i=XParseGeometry(geom,&x,&y,&w,&h);
- if (i&WidthValue)
- {
-diff -ruN xv-3.10a-bugfixes/xv.c xv-3.10a-enhancements/xv.c
---- xv-3.10a-bugfixes/xv.c 2005-03-20 22:25:22.000000000 -0800
-+++ xv-3.10a-enhancements/xv.c 2005-05-01 13:33:25.000000000 -0700
-@@ -62,6 +62,19 @@
-
- static char basefname[128]; /* just the current fname, no path */
-
-+#ifdef TV_L10N
-+# ifndef TV_FONTSET
-+# define TV_FONTSET "-*-fixed-medium-r-normal--%d-*"
-+# endif
-+# ifndef TV_FONTSIZE
-+# define TV_FONTSIZE 14,16
-+# endif
-+
-+static int mfontsize[] = { TV_FONTSIZE, 0 };
-+static char mfontset[256];
-+#endif
-+
-+
- /* things to do upon successfully loading an image */
- static int autoraw = 0; /* force raw if using stdcmap */
- static int autodither = 0; /* dither */
-@@ -78,6 +91,12 @@
-
- static int force8 = 0; /* force 8-bit mode */
- static int force24 = 0; /* force 24-bit mode */
-+#ifdef HAVE_PCD
-+static int PcdSize = -1; /* force dialog to ask */
-+#endif
-+
-+static float waitsec_nonfinal = -1; /* "normal" waitsec value */
-+static float waitsec_final = -1; /* final-image waitsec value */
-
- /* used in DeleteCmd() and Quit() */
- static char **mainargv;
-@@ -103,7 +122,6 @@
- static void openNextLoop PARM((void));
- static void openPrevPic PARM((void));
- static void openNamedPic PARM((void));
--static int findRandomPic PARM((void));
- static void mainLoop PARM((void));
- static void createMainWindow PARM((char *, char *));
- static void setWinIconNames PARM((char *));
-@@ -120,16 +138,17 @@
- int imap, ctrlmap, gmap, browmap, cmtmap, clrroot, nopos, limit2x;
- char *display, *whitestr, *blackstr, *histr, *lostr,
- *infogeom, *fgstr, *bgstr, *ctrlgeom, *gamgeom, *browgeom, *tmpstr;
--char *rootfgstr, *rootbgstr, *visualstr, *textgeom, *cmtgeom;
-+char *rootfgstr, *rootbgstr, *imagebgstr, *visualstr, *textgeom, *cmtgeom;
- char *monofontname, *flistName;
-+#ifdef TV_L10N
-+char **misscharset, *defstr;
-+int nmisscharset;
-+#endif
- int curstype, stdinflag, browseMode, savenorm, preview, pscomp, preset,
- rmodeset, gamset, cgamset, perfect, owncmap, rwcolor, stdcmap;
- int nodecor;
- double gamval, rgamval, ggamval, bgamval;
-
--
--
--
- /*******************************************/
- int main(argc, argv)
- int argc;
-@@ -137,6 +156,9 @@
- /*******************************************/
- {
- int i;
-+#ifdef TV_L10N
-+ int j;
-+#endif
- XColor ecdef;
- Window rootReturn, parentReturn, *children;
- unsigned int numChildren, rootDEEP;
-@@ -153,6 +175,13 @@
- /*** variable Initialization ***/
- /*****************************************************/
-
-+#ifdef TV_L10N
-+ /* setlocale(LC_ALL, localeList[LOCALE_EUCJ]); */
-+ setlocale(LC_ALL, "");
-+ xlocale = (int)XSupportsLocale(); /* assume that (Bool) is (int) */
-+ /* if X doesn't support ja_JP.ujis text viewer l10n doesn't work. */
-+#endif
-+
- xv_getwd(initdir, sizeof(initdir));
- searchdir[0] = '\0';
- fullfname[0] = '\0';
-@@ -162,7 +191,7 @@
-
- /* init internal variables */
- display = NULL;
-- fgstr = bgstr = rootfgstr = rootbgstr = NULL;
-+ fgstr = bgstr = rootfgstr = rootbgstr = imagebgstr = NULL;
- histr = lostr = whitestr = blackstr = NULL;
- visualstr = monofontname = flistName = NULL;
- winTitle = NULL;
-@@ -180,6 +209,7 @@
- autoclose = autoDelete = 0;
- cmapInGam = 0;
- grabDelay = 0;
-+ startGrab = 0;
- showzoomcursor = 0;
- perfect = owncmap = stdcmap = rwcolor = 0;
-
-@@ -228,6 +258,10 @@
- if (!tmpdir) FatalError("can't malloc 'tmpdir'\n");
- strcpy(tmpdir, tmpstr);
- }
-+#ifdef AUTO_EXPAND
-+ Vdinit();
-+ vd_handler_setup();
-+#endif
-
- /* init command-line options flags */
- infogeom = DEFINFOGEOM; ctrlgeom = DEFCTRLGEOM;
-@@ -238,7 +272,7 @@
- ninstall = 0; fixedaspect = 0; noFreeCols = nodecor = 0;
- DEBUG = 0; bwidth = 2;
- nolimits = useroot = clrroot = noqcheck = 0;
-- waitsec = -1; waitloop = 0; automax = 0;
-+ waitsec = waitsec_final = -1.0; waitloop = 0; automax = 0;
- rootMode = 0; hsvmode = 0;
- rmodeset = gamset = cgamset = 0;
- nopos = limit2x = 0;
-@@ -251,6 +285,10 @@
- preset = 0;
- viewonly = 0;
-
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+ do_fixpix_smooth = 0;
-+#endif
-+
- /* init 'xormasks' array */
- xorMasks[0] = 0x01010101;
- xorMasks[1] = 0x02020203;
-@@ -277,6 +315,24 @@
- tiffW = (Window) NULL; tiffUp = 0;
- #endif
-
-+#ifdef HAVE_PNG
-+ pngW = (Window) NULL; pngUp = 0;
-+#endif
-+
-+ pcdW = (Window) NULL; pcdUp = 0;
-+
-+#ifdef HAVE_PIC2
-+ pic2W = (Window) NULL; pic2Up = 0;
-+#endif
-+
-+#ifdef HAVE_PCD
-+ pcdW = (Window) NULL; pcdUp = 0;
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ mgcsfxW = (Window) NULL; mgcsfxUp = 0;
-+#endif
-+
- imap = ctrlmap = gmap = browmap = cmtmap = 0;
-
- ch_offx = ch_offy = p_offx = p_offy = 0;
-@@ -303,13 +359,35 @@
- verifyArgs();
-
-
-+#if 0
-+#ifdef XVEXECPATH
-+ /* set up path to search for external executables */
-+ {
-+ char *systempath = getenv("PATH");
-+ char *xvexecpath = getenv("XVPATH");
-+ if (xvexecpath == NULL) xvexecpath = XVEXECPATH;
-+ /* FIXME: can systempath == NULL? */
-+ strcat(systempath, ":"); /* FIXME: writing to mem we don't own */
-+ strcat(systempath, xvexecpath); /* FIXME: writing to mem we don't own */
-+ /* FIXME: was there supposed to be a setenv() call in here? */
-+ if (DEBUG)
-+ fprintf(stderr, "DEBUG: executable search path: %s\n", systempath);
-+ }
-+#endif
-+#endif
-+
-+
- /*****************************************************/
- /*** X Setup ***/
- /*****************************************************/
-
- theScreen = DefaultScreen(theDisp);
- theCmap = DefaultColormap(theDisp, theScreen);
-- rootW = RootWindow(theDisp,theScreen);
-+ if (spec_window) {
-+ rootW = spec_window;
-+ } else {
-+ rootW = RootWindow(theDisp,theScreen);
-+ }
- theGC = DefaultGC(theDisp,theScreen);
- theVisual = DefaultVisual(theDisp,theScreen);
- ncells = DisplayCells(theDisp, theScreen);
-@@ -320,7 +398,7 @@
-
- rootDEEP = dispDEEP;
-
-- /* things dependant on theVisual:
-+ /* things dependent on theVisual:
- * dispDEEP, theScreen, rootW, ncells, theCmap, theGC,
- * vrWIDE, dispWIDE, vrHIGH, dispHIGH, maxWIDE, maxHIGH
- */
-@@ -500,6 +578,7 @@
- arrow = XCreateFontCursor(theDisp,(u_int) curstype);
- cross = XCreateFontCursor(theDisp,XC_crosshair);
- tcross = XCreateFontCursor(theDisp,XC_tcross);
-+ tlcorner = XCreateFontCursor(theDisp,XC_top_left_corner);
- zoom = XCreateFontCursor(theDisp,XC_sizing);
-
- {
-@@ -575,6 +654,18 @@
- xvAllocColor(theDisp, theCmap, &ecdef)) rootbg = ecdef.pixel;
-
-
-+ /* GRR 19980308: set up image bg color (for transparent images) */
-+ have_imagebg = 0;
-+ if (imagebgstr && XParseColor(theDisp, theCmap, imagebgstr, &ecdef) &&
-+ xvAllocColor(theDisp, theCmap, &ecdef)) {
-+ /* imagebg = ecdef.pixel; */
-+ have_imagebg = 1;
-+ imagebgR = ecdef.red;
-+ imagebgG = ecdef.green;
-+ imagebgB = ecdef.blue;
-+ }
-+
-+
- /* set up hi/lo colors */
- i=0;
- if (dispDEEP > 1) { /* only if we're on a reasonable display */
-@@ -664,6 +755,61 @@
-
- monofont=monofinfo->fid;
-
-+#ifdef TV_L10N
-+ if (xlocale) {
-+ i = 0;
-+ while (mfontsize[i]) {
-+ xlocale = 1; /* True */
-+
-+ sprintf(mfontset, TV_FONTSET, mfontsize[i]);
-+/*fprintf(stderr, "FontSet: %s\n", mfontset);*/
-+
-+ monofset = XCreateFontSet(theDisp, mfontset,
-+ &misscharset, &nmisscharset, &defstr);
-+# if 0 /* not useful */
-+ if (!monofset) {
-+ /* the current locale is not supported */
-+/*fprintf(stderr, "Current locale `%s' is not supported.\n", localeList[i]);*/
-+ xlocale = 0;
-+ break;
-+ }
-+# endif
-+/*fprintf(stderr, "# of misscharset in mfontsize[%d]: %d\n", i,nmisscharset);*/
-+
-+ for (j = 0; j < nmisscharset; j++) {
-+ if (!strncmp(misscharset[j], "jisx0208", 8)) {
-+ /* font for JIS X 0208 is not found */
-+ xlocale = 0;
-+ break;
-+ }
-+ }
+diff -u -r --new-file xv-3.10a.orig/contrib/fedora/Build-FC5 xv-3.10a/contrib/fedora/Build-FC5
+--- xv-3.10a.orig/contrib/fedora/Build-FC5 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fedora/Build-FC5 2006-06-01 10:12:47.000000000 -0500
+@@ -0,0 +1,56 @@
++#!/bin/bash
++#
++# prep and build XV for FC5
++#
++# adapted from Slackware 10.2 -- john.cooper@third-harmonic.com
++#
+
-+ if (xlocale) {
-+ monofsetinfo = XExtentsOfFontSet(monofset);
-+ monofsetinfo->max_logical_extent.width = mfontsize[i];
-+ /* correct size of TextViewer
-+ in case that JIS X 0208 is not found */
-+ break;
-+ }
++if [ ${1}foo == "__LOGGED__foo" ]; then
++ shift
++else
++ for i in `seq 0 9`
++ do
++ if [ -e ${0}.log.$((9-i)) ]; then
++ mv ${0}.log.$((9-i)) ${0}.log.$((9-i+1))
++ fi
++ done
+
-+ i++;
-+ } /* while (mfontsize[i]) */
++ exec $0 __LOGGED__ $@ 2>&1 | tee $BUILDDIR/$0.log.0
++ exit $?
++fi
+
-+# if 0
-+ if (nmisscharset > 0) {
-+ sprintf(str,"missing %d charset:\n", nmisscharset);
-+ for (i = 0; i < nmisscharset; i++) {
-+ sprintf(str, "%s\t%s\n", str, misscharset[i]);
-+ }
-+# if 0
-+ FatalError(str);
-+# else
-+ fprintf(stderr, "%s", str);
-+# endif
-+ }
-+# endif
-+ }
-+#endif /* TV_L10N */
-
-
-
-@@ -693,6 +839,18 @@
- }
- else namelist[0] = NULL;
- }
-+ else if (randomShow) {
-+ int i, j;
-+ char *tmp;
++SOURCE=`pwd`
++if [ "$BUILD" = "" ]; then
++ BUILD=./build
++fi
+
-+ srandom((int)time((time_t *)0));
-+ for (i = numnames; i > 1; i--) {
-+ j = random() % i;
-+ tmp = namelist[i-1];
-+ namelist[i-1] = namelist[j];
-+ namelist[j] = tmp;
-+ }
-+ }
-
- if (numnames) makeDispNames();
-
-@@ -796,6 +954,25 @@
- XSetTransientForHint(theDisp, tiffW, dirW);
- #endif
-
-+#ifdef HAVE_PNG
-+ CreatePNGW();
-+ XSetTransientForHint(theDisp, pngW, dirW);
-+#endif
++if [ ! -d $BUILD ]; then
++ mkdir -p $BUILD
++fi
+
-+#ifdef HAVE_PCD
-+ CreatePCDW();
-+ XSetTransientForHint(theDisp, pcdW, dirW);
-+#endif
++PFLAGS="--verbose --backup --suffix=.orig"
+
-+#ifdef HAVE_PIC2
-+ CreatePIC2W();
-+ XSetTransientForHint(theDisp, pic2W, dirW);
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ CreateMGCSFXW();
-+ XSetTransientForHint(theDisp, mgcsfxW, dirW);
-+#endif
-
- LoadFishCursors();
- SetCursors(-1);
-@@ -964,7 +1141,11 @@
-
- dispDEEP = vinfo[best].depth;
- theScreen = vinfo[best].screen;
-- rootW = RootWindow(theDisp, theScreen);
-+ if (spec_window) {
-+ rootW = spec_window;
-+ } else {
-+ rootW = RootWindow(theDisp,theScreen);
-+ }
- ncells = vinfo[best].colormap_size;
- theCmap = XCreateColormap(theDisp, rootW, theVisual, AllocNone);
-
-@@ -1095,6 +1276,9 @@
-
- if (rd_str ("fileList")) flistName = def_str;
- if (rd_flag("fixed")) fixedaspect = def_int;
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+ if (rd_flag("fixpix")) do_fixpix_smooth = def_int;
-+#endif
- if (rd_flag("force8")) force8 = def_int;
- if (rd_flag("force24")) force24 = def_int;
- if (rd_str ("foreground")) fgstr = def_str;
-@@ -1106,21 +1290,37 @@
- if (rd_str ("highlight")) histr = def_str;
- if (rd_str ("iconGeometry")) icongeom = def_str;
- if (rd_flag("iconic")) startIconic = def_int;
-+ if (rd_str ("imageBackground")) imagebgstr = def_str;
- if (rd_str ("infoGeometry")) infogeom = def_str;
- if (rd_flag("infoMap")) imap = def_int;
- if (rd_flag("loadBrowse")) browseMode = def_int;
- if (rd_str ("lowlight")) lostr = def_str;
-+#ifdef MACBINARY
-+ if (rd_flag("macbinary")) handlemacb = def_int;
-+#endif
-+#ifdef HAVE_MGCSFX
-+ if (rd_flag("mgcsfx")) mgcsfx = def_int;
-+#endif
- if (rd_flag("mono")) mono = def_int;
- if (rd_str ("monofont")) monofontname = def_str;
- if (rd_int ("ncols")) ncols = def_int;
- if (rd_flag("ninstall")) ninstall = def_int;
- if (rd_flag("nodecor")) nodecor = def_int;
- if (rd_flag("nolimits")) nolimits = def_int;
-+#ifdef HAVE_MGCSFX
-+ if (rd_flag("nomgcsfx")) nomgcsfx = def_int;
-+#endif
-+#if defined(HAVE_PIC) || defined(HAVE_PIC2)
-+ if (rd_flag("nopicadjust")) nopicadjust = def_int;
-+#endif
- if (rd_flag("nopos")) nopos = def_int;
- if (rd_flag("noqcheck")) noqcheck = def_int;
- if (rd_flag("nostat")) nostat = def_int;
- if (rd_flag("ownCmap")) owncmap = def_int;
- if (rd_flag("perfect")) perfect = def_int;
-+#ifdef HAVE_PIC2
-+ if (rd_flag("pic2split")) pic2split = def_int;
-+#endif
- if (rd_flag("popupKludge")) winCtrPosKludge = def_int;
- if (rd_str ("print")) strncpy(printCmd, def_str,
- (size_t) PRINTCMDLEN);
-@@ -1138,6 +1338,9 @@
- if (rd_str ("textviewGeometry")) textgeom = def_str;
- if (rd_flag("useStdCmap")) stdcmap = def_int;
- if (rd_str ("visual")) visualstr = def_str;
-+#ifdef VS_ADJUST
-+ if (rd_flag("vsadjust")) vsadjust = def_int;
-+#endif
- if (rd_flag("vsDisable")) novbrowse = def_int;
- if (rd_str ("vsGeometry")) browgeom = def_str;
- if (rd_flag("vsMap")) browmap = def_int;
-@@ -1172,7 +1375,13 @@
- }
-
- if (numnames<MAXNAMES) {
-+#ifdef AUTO_EXPAND
-+ if(Isarchive(argv[i]) == 0){ /* Not archive file */
-+ namelist[numnames++] = argv[i];
++function bail()
++ {
++ echo "$0: failed $1"
++ exit 1
+ }
-+#else
- namelist[numnames++] = argv[i];
-+#endif
- if (numnames==MAXNAMES) {
- fprintf(stderr,"%s: too many filenames. Only using first %d.\n",
- cmd, MAXNAMES);
-@@ -1198,6 +1407,14 @@
- }
- }
-
-+ else if (!argcmp(argv[i],"-windowid",3,0,&pm)) {
-+ if (++i<argc) {
-+ if (sscanf(argv[i], "%ld", &spec_window) != 1) {
-+ fprintf(stderr,"%s: bad argument to -windowid '%s'\n",cmd,argv[i]);
-+ }
-+ }
-+ }
-+
- else if (!argcmp(argv[i],"-best24",3,0,&pm)) /* -best */
- conv24 = CONV24_BEST;
-
-@@ -1289,7 +1506,11 @@
- else if (!argcmp(argv[i],"-fg",3,0,&pm)) /* fg color */
- { if (++i<argc) fgstr = argv[i]; }
-
-- else if (!argcmp(argv[i],"-fixed",3,1,&fixedaspect)); /* fix asp. ratio */
-+ else if (!argcmp(argv[i],"-fixed",5,1,&fixedaspect)); /* fix asp. ratio */
-+
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+ else if (!argcmp(argv[i],"-fixpix",5,1,&do_fixpix_smooth)); /* dithering */
-+#endif
-
- else if (!argcmp(argv[i],"-flist",3,0,&pm)) /* file list */
- { if (++i<argc) flistName = argv[i]; }
-@@ -1330,6 +1551,10 @@
- { if (++i<argc) infogeom = argv[i]; }
-
- else if (!argcmp(argv[i],"-imap", 3,1,&imap)); /* imap */
-+
-+ else if (!argcmp(argv[i],"-ibg",3,0,&pm)) /* GRR: image background color */
-+ { if (++i<argc) imagebgstr = argv[i]; }
-+
- else if (!argcmp(argv[i],"-lbrowse", 3,1,&browseMode)); /* browse mode */
-
- else if (!argcmp(argv[i],"-lo",3,0,&pm)) /* lowlight */
-@@ -1354,9 +1579,17 @@
- else if (!argcmp(argv[i],"-maxpect",5,1,&pm)) /* auto maximize */
- { automax=pm; fixedaspect=pm; }
-
-+#ifdef MACBINARY
-+ else if (!argcmp(argv[i],"-macbinary",3,1,&handlemacb)); /* macbinary */
-+#endif
-+
- else if (!argcmp(argv[i],"-mfn",3,0,&pm)) /* mono font name */
- { if (++i<argc) monofontname = argv[i]; }
-
-+#ifdef HAVE_MGCSFX
-+ else if (!argcmp(argv[i],"-mgcsfx", 4,1,&mgcsfx)); /* mgcsfx */
-+#endif
-+
- else if (!argcmp(argv[i],"-mono",3,1,&mono)); /* mono */
-
- else if (!argcmp(argv[i],"-name",3,0,&pm)) /* name */
-@@ -1365,17 +1598,30 @@
- else if (!argcmp(argv[i],"-ncols",3,0,&pm)) /* ncols */
- { if (++i<argc) ncols=abs(atoi(argv[i])); }
-
-- else if (!argcmp(argv[i],"-ninstall", 3,1,&ninstall)); /* inst cmaps?*/
-+ else if (!argcmp(argv[i],"-ninstall", 3,1,&ninstall)); /* inst cmaps? */
- else if (!argcmp(argv[i],"-nodecor", 4,1,&nodecor));
- else if (!argcmp(argv[i],"-nofreecols",4,1,&noFreeCols));
- else if (!argcmp(argv[i],"-nolimits", 4,1,&nolimits)); /* nolimits */
-+#ifdef HAVE_MGCSFX
-+ else if (!argcmp(argv[i],"-nomgcsfx", 4,1,&nomgcsfx)); /* nomgcsfx */
-+#endif
-+#if defined(HAVE_PIC) || defined(HAVE_PIC2)
-+ else if (!argcmp(argv[i],"-nopicadjust", 4,1,&nopicadjust));/*nopicadjust*/
-+#endif
- else if (!argcmp(argv[i],"-nopos", 4,1,&nopos)); /* nopos */
- else if (!argcmp(argv[i],"-noqcheck", 4,1,&noqcheck)); /* noqcheck */
-- else if (!argcmp(argv[i],"-noresetroot",5,1,&resetroot)); /* reset root*/
-+ else if (!argcmp(argv[i],"-noresetroot",5,1,&resetroot)); /* reset root */
- else if (!argcmp(argv[i],"-norm", 5,1,&autonorm)); /* norm */
- else if (!argcmp(argv[i],"-nostat", 4,1,&nostat)); /* nostat */
- else if (!argcmp(argv[i],"-owncmap", 2,1,&owncmap)); /* own cmap */
-+#ifdef HAVE_PCD
-+ else if (!argcmp(argv[i],"-pcd", 4,0,&pm)) /* pcd with size */
-+ { if (i+1<argc) PcdSize = atoi(argv[++i]); }
-+#endif
- else if (!argcmp(argv[i],"-perfect", 3,1,&perfect)); /* -perfect */
-+#ifdef HAVE_PIC2
-+ else if (!argcmp(argv[i],"-pic2split", 3,1,&pic2split)); /* pic2split */
-+#endif
- else if (!argcmp(argv[i],"-pkludge", 3,1,&winCtrPosKludge));
- else if (!argcmp(argv[i],"-poll", 3,1,&polling)); /* chk mod? */
-
-@@ -1418,6 +1664,7 @@
- conv24 = CONV24_SLOW;
-
- else if (!argcmp(argv[i],"-smooth",3,1,&autosmooth)); /* autosmooth */
-+ else if (!argcmp(argv[i],"-startgrab",3,1,&startGrab)); /* startGrab */
- else if (!argcmp(argv[i],"-stdcmap",3,1,&stdcmap)); /* use stdcmap */
-
- else if (!argcmp(argv[i],"-tgeometry",2,0,&pm)) /* textview geom */
-@@ -1429,6 +1676,10 @@
- else if (!argcmp(argv[i],"-visual",4,0,&pm)) /* visual */
- { if (++i<argc) visualstr = argv[i]; }
-
-+#ifdef VS_ADJUST
-+ else if (!argcmp(argv[i],"-vsadjust", 3,1,&vsadjust)); /* vsadjust */
-+#endif
-+
- else if (!argcmp(argv[i],"-vsdisable",4,1,&novbrowse)); /* disable sch? */
-
- else if (!argcmp(argv[i],"-vsgeometry",4,0,&pm)) /* visSchnauzer geom */
-@@ -1440,8 +1691,9 @@
-
- else if (!argcmp(argv[i],"-wait",3,0,&pm)) { /* secs betwn pics */
- if (++i<argc) {
-- waitsec = abs(atoi(argv[i]));
-- if (waitsec<0) waitsec = 0;
-+ char *comma = strchr(argv[i], ',');
-+ waitsec_nonfinal = fabs(atof(argv[i]));
-+ waitsec_final = comma? fabs(atof(comma+1)) : waitsec_nonfinal;
- }
- }
-
-@@ -1467,7 +1719,11 @@
- /* check options for validity */
-
- if (strlen(searchdir)) { /* got a search directory */
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(searchdir)) {
-+#else
- if (chdir(searchdir)) {
-+#endif
- fprintf(stderr,"xv: unable to cd to directory '%s'.\n",searchdir);
- fprintf(stderr,
- " Ignoring '-dir' option and/or 'xv.searchDirectory' resource\n");
-@@ -1514,7 +1770,7 @@
- preset = 0;
- }
-
-- if (waitsec < 0) noFreeCols = 0; /* disallow nfc if not doing slideshow */
-+ if (waitsec < 0.0) noFreeCols = 0; /* disallow nfc if not doing slideshow */
- if (noFreeCols && perfect) { perfect = 0; owncmap = 1; }
-
- /* decide what default color allocation stuff we've settled on */
-@@ -1556,6 +1812,20 @@
-
- static void cmdSyntax()
- {
-+ /* GRR 19980605: added version info for most common libraries */
-+ fprintf(stderr, "XV - %s.\n", REVDATE);
-+#ifdef HAVE_JPEG
-+ VersionInfoJPEG();
-+#endif
-+#ifdef HAVE_TIFF
-+ VersionInfoTIFF();
-+#endif
-+#ifdef HAVE_PNG
-+ VersionInfoPNG();
-+#endif
-+ /* pbm/pgm/ppm support is native, not via pbmplus/netpbm libraries */
-+ fprintf(stderr, "\n");
-+
- fprintf(stderr, "Usage:\n");
- printoption(cmd);
- printoption("[-]");
-@@ -1595,6 +1865,9 @@
- printoption("[-expand exp | hexp:vexp]");
- printoption("[-fg color]");
- printoption("[-/+fixed]");
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+ printoption("[-/+fixpix]");
-+#endif
- printoption("[-flist fname]");
- printoption("[-gamma val]");
- printoption("[-geometry geom]");
-@@ -1607,6 +1880,7 @@
- printoption("[-hi color]");
- printoption("[-/+hist]");
- printoption("[-/+hsv]");
-+ printoption("[-ibg color]"); /* GRR 19980314 */
- printoption("[-icgeometry geom]");
- printoption("[-/+iconic]");
- printoption("[-igeometry geom]");
-@@ -1614,9 +1888,15 @@
- printoption("[-/+lbrowse]");
- printoption("[-lo color]");
- printoption("[-/+loadclear]");
-+#ifdef MACBINARY
-+ printoption("[-/+macbinary]");
-+#endif
- printoption("[-/+max]");
- printoption("[-/+maxpect]");
- printoption("[-mfn font]");
-+#ifdef HAVE_MGCSFX
-+ printoption("[-/+mgcsfx]");
-+#endif
- printoption("[-/+mono]");
- printoption("[-name str]");
- printoption("[-ncols #]");
-@@ -1624,13 +1904,25 @@
- printoption("[-/+nodecor]");
- printoption("[-/+nofreecols]");
- printoption("[-/+nolimits]");
-+#ifdef HAVE_MGCSFX
-+ printoption("[-/+nomgcsfx]");
-+#endif
-+#if defined(HAVE_PIC) || defined(HAVE_PIC2)
-+ printoption("[-/+nopicadjust]");
-+#endif
- printoption("[-/+nopos]");
- printoption("[-/+noqcheck]");
- printoption("[-/+noresetroot]");
- printoption("[-/+norm]");
- printoption("[-/+nostat]");
- printoption("[-/+owncmap]");
-+#ifdef HAVE_PCD
-+ printoption("[-pcd size(0=192*128,1,2,3,4=3072*2048)]");
-+#endif
- printoption("[-/+perfect]");
-+#ifdef HAVE_PIC2
-+ printoption("[-/+pic2split]");
-+#endif
- printoption("[-/+pkludge]");
- printoption("[-/+poll]");
- printoption("[-preset #]");
-@@ -1649,17 +1941,22 @@
- printoption("[-/+rw]");
- printoption("[-slow24]");
- printoption("[-/+smooth]");
-+ printoption("[-/+startgrab]");
- printoption("[-/+stdcmap]");
- printoption("[-tgeometry geom]");
- printoption("[-/+vflip]");
- printoption("[-/+viewonly]");
- printoption("[-visual type]");
-+#ifdef VS_ADJUST
-+ printoption("[-/+vsadjust]");
-+#endif
- printoption("[-/+vsdisable]");
- printoption("[-vsgeometry geom]");
- printoption("[-/+vsmap]");
- printoption("[-/+vsperfect]");
-- printoption("[-wait seconds]");
-+ printoption("[-wait secs[,final_secs]]");
- printoption("[-white color]");
-+ printoption("[-windowid windowid]");
- printoption("[-/+wloop]");
- printoption("[filename ...]");
- fprintf(stderr,"\n\n");
-@@ -1682,6 +1979,7 @@
- fprintf(stderr,"\t7: centered on a 'brick' background\n");
- fprintf(stderr,"\t8: symmetrical tiling\n");
- fprintf(stderr,"\t9: symmetrical mirrored tiling\n");
-+ fprintf(stderr,"\t10: upper left corner\n");
- fprintf(stderr,"\n");
- Quit(1);
- }
-@@ -1694,7 +1992,7 @@
- int *plusminus;
- {
- /* does a string compare between a1 and a2. To return '0', a1 and a2
-- must match to the length of a2, and that length has to
-+ must match to the length of a1, and that length has to
- be at least 'minlen'. Otherwise, return non-zero. plusminus set to '1'
- if '-option', '0' if '+option' */
-
-@@ -1734,6 +2032,10 @@
- char *tmp;
- char *fullname, /* full name of the original file */
- filename[512]; /* full name of file to load (could be /tmp/xxx)*/
-+#ifdef MACBINARY
-+ char origname[512]; /* file name of original file (NO processing) */
-+ origname[0] = '\0';
-+#endif
-
- xvbzero((char *) &pinfo, sizeof(PICINFO));
-
-@@ -1866,8 +2168,22 @@
- frompipe = 1;
- }
- }
-+#ifdef AUTO_EXPAND
-+ else {
-+ fullname = (char *) malloc(MAXPATHLEN+2);
-+ strcpy(fullname, namelist[filenum]);
-+ freename = 1;
-+ }
-+ tmp = (char *) rindex(fullname, '/');
-+ if (tmp) {
-+ *tmp = '\0';
-+ Mkvdir(fullname);
-+ *tmp = '/';
-+ }
-+ Dirtovd(fullname);
-+#else
- else fullname = namelist[filenum];
--
-+#endif
-
- strcpy(fullfname, fullname);
- tmp = BaseName(fullname);
-@@ -1875,18 +2191,20 @@
-
-
- /* chop off trailing ".Z", ".z", or ".gz" from displayed basefname, if any */
-- if (strlen(basefname) > (size_t) 2 &&
-- strcmp(basefname+strlen(basefname)-2,".Z")==0)
-+ if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".Z")==0)
- basefname[strlen(basefname)-2]='\0';
- else {
- #ifdef GUNZIP
-- if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".Z")==0)
-+ if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".z")==0)
- basefname[strlen(basefname)-2]='\0';
--
-- else if (strlen(basefname)>3 &&
-- strcmp(basefname+strlen(basefname)-3,".gz")==0)
-+ else
-+ if (strlen(basefname)>3 && strcmp(basefname+strlen(basefname)-3,".gz")==0)
- basefname[strlen(basefname)-3]='\0';
--#endif /* GUNZIP */
-+#endif
-+#ifdef BUNZIP2
-+ if (strlen(basefname)>4 && strcmp(basefname+strlen(basefname)-4,".bz2")==0)
-+ basefname[strlen(basefname)-4]='\0';
-+#endif
- }
-
-
-@@ -1973,6 +2291,9 @@
-
- if (strcmp(filename,STDINSTR)==0) {
- FILE *fp = NULL;
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
-
- #ifndef VMS
- sprintf(filename,"%s/xvXXXXXX",tmpdir);
-@@ -1984,13 +2305,18 @@
- fp = fdopen(mkstemp(filename), "w");
- #else
- mktemp(filename);
-- fp = fopen(filename, "w");
-+ tmpfd = open(filename,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) FatalError("openPic(): can't create temporary file");
-+ fp = fdopen(tmpfd,"w");
- #endif
- if (!fp) FatalError("openPic(): can't write temporary file");
-
- clearerr(stdin);
- while ( (i=getchar()) != EOF) putc(i,fp);
- fclose(fp);
-+#ifndef USE_MKSTEMP
-+ close(tmpfd);
-+#endif
-
- /* and remove it from list, since we can never reload from stdin */
- if (strcmp(namelist[0], STDINSTR)==0) deleteFromList(0);
-@@ -2005,15 +2331,21 @@
- (no pipes or stdin, though it could be compressed) to be loaded */
- filetype = ReadFileType(filename);
-
-+#ifdef HAVE_MGCSFX
-+ if (mgcsfx && filetype == RFT_UNKNOWN){ /* force use MgcSfx */
-+ if(getInputCom() != 0) filetype = RFT_MGCSFX;
-+ }
-+#endif
-
-- if (filetype == RFT_COMPRESS) { /* a compressed file. uncompress it */
-+ /* if it's a compressed file, uncompress it: */
-+ if ((filetype == RFT_COMPRESS) || (filetype == RFT_BZIP2)) {
- char tmpname[128];
-
- if (
- #ifndef VMS
-- UncompressFile(filename, tmpname)
-+ UncompressFile(filename, tmpname, filetype)
- #else
-- UncompressFile(basefname, tmpname)
-+ UncompressFile(basefname, tmpname, filetype)
- #endif
- ) {
-
-@@ -2029,6 +2361,57 @@
- WaitCursor();
- }
-
-+#ifdef MACBINARY
-+ if (handlemacb && macb_file == True) {
-+ char tmpname[128];
-+
-+ if (RemoveMacbinary(filename, tmpname)) {
-+ if (strcmp(fullname,filename)!=0) unlink(filename);
-+ strcpy(origname, filename);
-+ strcpy(filename, tmpname);
-+ }
-+ else filetype = RFT_ERROR;
-+
-+ WaitCursor();
-+ }
-+#endif
-+
-+#ifdef HAVE_MGCSFX_AUTO
-+ if (filetype == RFT_MGCSFX) {
-+ char tmpname[128], tmp[256];
-+ char *icom;
-+
-+ if ((icom = mgcsfx_auto_input_com(filename)) != NULL) {
-+ sprintf(tmpname, "%s/xvmsautoXXXXXX", tmpdir);
-+#ifdef USE_MKSTEMP
-+ close(mkstemp(tmpname));
-+#else
-+ mktemp(tmpname);
-+#endif
-+ SetISTR(ISTR_INFO, "Converting to known format by MgcSfx auto...");
-+ sprintf(tmp,"%s >%s", icom, tmpname);
-+ }
-+ else goto ms_auto_no;
-+
-+#ifndef VMS
-+ if (system(tmp))
-+#else
-+ if (!system(tmp))
-+#endif
-+ {
-+ SetISTR(ISTR_INFO, "Unable to convert '%s' by MgcSfx auto.",
-+ BaseName(filename));
-+ Warning();
-+ filetype = RFT_ERROR;
-+ goto ms_auto_no;
-+ }
-+
-+ filetype = ReadFileType(tmpname);
-+ if (strcmp(fullname,filename)!=0) unlink(filename);
-+ strcpy(filename, tmpname);
-+ }
-+ms_auto_no:
-+#endif /* HAVE_MGCSFX_AUTO */
-
- if (filetype == RFT_ERROR) {
- char foostr[512];
-@@ -2042,10 +2425,16 @@
-
- if (filetype == RFT_UNKNOWN) {
- /* view as a text/hex file */
-- TextView(filename);
-+#ifdef MACBINARY
-+ if (origname[0])
-+ i = TextView(origname);
-+ else
-+#endif
-+ i = TextView(filename);
- SetISTR(ISTR_INFO,"'%s' not in a recognized format.", basefname);
- /* Warning(); */
-- goto SHOWN_AS_TEXT;
-+ if (i) goto SHOWN_AS_TEXT;
-+ else goto FAILED;
- }
-
- if (filetype < RFT_ERROR) {
-@@ -2073,8 +2462,9 @@
- if (filetype == RFT_XBM && (!i || pinfo.w==0 || pinfo.h==0)) {
- /* probably just a '.h' file or something... */
- SetISTR(ISTR_INFO," ");
-- TextView(filename);
-- goto SHOWN_AS_TEXT;
-+ i = TextView(filename);
-+ if (i) goto SHOWN_AS_TEXT;
-+ else goto FAILED;
- }
-
- if (!i) {
-@@ -2209,12 +2599,15 @@
- if (fullname && strcmp(fullname,filename)!=0) unlink(filename);
-
-
-- SetISTR(ISTR_INFO,formatStr);
-+ SetISTR(ISTR_INFO, "%s", formatStr);
-
- SetInfoMode(INF_PART);
-- SetISTR(ISTR_FILENAME, "%s",
-- (filenum==DFLTPIC || filenum==GRABBED || frompipe) ?
-- "<none>" : basefname);
-+ if (filenum==DFLTPIC || filenum==GRABBED || frompipe)
-+ SetISTR(ISTR_FILENAME, "<none>");
-+ else if (numPages > 1)
-+ SetISTR(ISTR_FILENAME, "%s Page %d of %d", basefname, curPage+1, numPages);
-+ else
-+ SetISTR(ISTR_FILENAME, "%s", basefname);
-
- SetISTR(ISTR_RES,"%d x %d",pWIDE,pHIGH);
- SetISTR(ISTR_COLOR, "");
-@@ -2424,7 +2817,7 @@
- if (autodither && ncols>0) epicMode = EM_DITH;
-
- /* if in CM_STDCMAP mode, and *not* in '-wait 0', then autodither */
-- if (colorMapMode == CM_STDCMAP && waitsec != 0) epicMode = EM_DITH;
-+ if (colorMapMode == CM_STDCMAP && waitsec != 0.0) epicMode = EM_DITH;
-
- /* if -smooth or image has been shrunk to fit screen */
- if (autosmooth || (pWIDE >maxWIDE || pHIGH>maxHIGH)
-@@ -2510,7 +2903,11 @@
- to generate the correct exposes (particularly with 'BitGravity' turned
- on */
-
-- if (mainW && !useroot) GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
-+ /*Brian T. Schellenberger: fix for X 4.2 refresh problem*/
-+ if (mainW && !useroot) {
-+ XSync(theDisp, False);
-+ GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
-+ }
-
- return 1;
-
-@@ -2542,6 +2939,9 @@
- }
-
-
-+extern byte ZXheader[128]; /* [JCE] Spectrum screen magic number is
-+ defined in xvzx.c */
-+
-
- /********************************/
- int ReadFileType(fname)
-@@ -2554,76 +2954,105 @@
-
- FILE *fp;
- byte magicno[30]; /* first 30 bytes of file */
-- int rv, n;
-+ int rv=RFT_UNKNOWN, n;
-+#ifdef MACBINARY
-+ int macbin_alrchk = False;
-+#endif
-
- if (!fname) return RFT_ERROR; /* shouldn't happen */
-
- fp = xv_fopen(fname, "r");
- if (!fp) return RFT_ERROR;
-
-+ if (strlen(fname) > 4 &&
-+ strcasecmp(fname+strlen(fname)-5, ".wbmp")==0) rv = RFT_WBMP;
-+
- n = fread(magicno, (size_t) 1, (size_t) 30, fp);
- fclose(fp);
-
-- if (n<30) return RFT_UNKNOWN; /* files less than 30 bytes long... */
-+ if (n<30) return rv; /* files less than 30 bytes long... */
-
-- rv = RFT_UNKNOWN;
-+#ifdef MACBINARY
-+ macb_file = False;
-+ while (1) {
-+#endif
-
-- if (strncmp((char *) magicno,"GIF87a", (size_t) 6)==0 ||
-- strncmp((char *) magicno,"GIF89a", (size_t) 6)==0) rv = RFT_GIF;
-+#ifdef HAVE_MGCSFX
-+ if (is_mgcsfx(fname, magicno, 30) != 0) rv = RFT_MGCSFX;
-+ else
-+#endif
-+ if (strncmp((char *) magicno,"GIF87a", (size_t) 6)==0 ||
-+ strncmp((char *) magicno,"GIF89a", (size_t) 6)==0) rv = RFT_GIF;
-
- else if (strncmp((char *) magicno,"VIEW", (size_t) 4)==0 ||
-- strncmp((char *) magicno,"WEIV", (size_t) 4)==0) rv = RFT_PM;
-+ strncmp((char *) magicno,"WEIV", (size_t) 4)==0) rv = RFT_PM;
-+
-+#ifdef HAVE_PIC2
-+ else if (magicno[0]=='P' && magicno[1]=='2' &&
-+ magicno[2]=='D' && magicno[3]=='T') rv = RFT_PIC2;
-+#endif
-
- else if (magicno[0] == 'P' && magicno[1]>='1' &&
-- magicno[1]<='6') rv = RFT_PBM;
-+ (magicno[1]<='6' || magicno[1]=='8')) rv = RFT_PBM;
-
- /* note: have to check XPM before XBM, as first 2 chars are the same */
- else if (strncmp((char *) magicno, "/* XPM */", (size_t) 9)==0) rv = RFT_XPM;
-
- else if (strncmp((char *) magicno,"#define", (size_t) 7)==0 ||
-- (magicno[0] == '/' && magicno[1] == '*')) rv = RFT_XBM;
-+ (magicno[0] == '/' && magicno[1] == '*')) rv = RFT_XBM;
-
- else if (magicno[0]==0x59 && (magicno[1]&0x7f)==0x26 &&
-- magicno[2]==0x6a && (magicno[3]&0x7f)==0x15) rv = RFT_SUNRAS;
-+ magicno[2]==0x6a && (magicno[3]&0x7f)==0x15) rv = RFT_SUNRAS;
-
-- else if (magicno[0] == 'B' && magicno[1] == 'M') rv = RFT_BMP;
-+ else if (magicno[0] == 'B' && magicno[1] == 'M') rv = RFT_BMP;
-
-- else if (magicno[0]==0x52 && magicno[1]==0xcc) rv = RFT_UTAHRLE;
-+ else if (magicno[0]==0x52 && magicno[1]==0xcc) rv = RFT_UTAHRLE;
-
- else if ((magicno[0]==0x01 && magicno[1]==0xda) ||
-- (magicno[0]==0xda && magicno[1]==0x01)) rv = RFT_IRIS;
-+ (magicno[0]==0xda && magicno[1]==0x01)) rv = RFT_IRIS;
-
-- else if (magicno[0]==0x1f && magicno[1]==0x9d) rv = RFT_COMPRESS;
-+ else if (magicno[0]==0x1f && magicno[1]==0x9d) rv = RFT_COMPRESS;
-
- #ifdef GUNZIP
-- else if (magicno[0]==0x1f && magicno[1]==0x8b) rv = RFT_COMPRESS;
-+ else if (magicno[0]==0x1f && magicno[1]==0x8b) rv = RFT_COMPRESS;
- #endif
-
-- else if (magicno[0]==0x0a && magicno[1] <= 5) rv = RFT_PCX;
-+#ifdef BUNZIP2
-+ else if (magicno[0]==0x42 && magicno[1]==0x5a) rv = RFT_BZIP2;
-+#endif
-+
-+ else if (magicno[0]==0x0a && magicno[1] <= 5) rv = RFT_PCX;
-
- else if (strncmp((char *) magicno, "FORM", (size_t) 4)==0 &&
-- strncmp((char *) magicno+8, "ILBM", (size_t) 4)==0) rv = RFT_IFF;
-+ strncmp((char *) magicno+8, "ILBM", (size_t) 4)==0) rv = RFT_IFF;
-
- else if (magicno[0]==0 && magicno[1]==0 &&
- magicno[2]==2 && magicno[3]==0 &&
- magicno[4]==0 && magicno[5]==0 &&
-- magicno[6]==0 && magicno[7]==0) rv = RFT_TARGA;
-+ magicno[6]==0 && magicno[7]==0) rv = RFT_TARGA;
-
- else if (magicno[4]==0x00 && magicno[5]==0x00 &&
-- magicno[6]==0x00 && magicno[7]==0x07) rv = RFT_XWD;
-+ magicno[6]==0x00 && magicno[7]==0x07) rv = RFT_XWD;
-
- else if (strncmp((char *) magicno,"SIMPLE ", (size_t) 8)==0 &&
-- magicno[29] == 'T') rv = RFT_FITS;
-+ magicno[29] == 'T') rv = RFT_FITS;
-
-+ /* [JCE] Spectrum screen */
-+ else if (memcmp(magicno, ZXheader, (size_t) 18)==0) rv = RFT_ZX;
-
- #ifdef HAVE_JPEG
- else if (magicno[0]==0xff && magicno[1]==0xd8 &&
-- magicno[2]==0xff) rv = RFT_JFIF;
-+ magicno[2]==0xff) rv = RFT_JFIF;
- #endif
-
- #ifdef HAVE_TIFF
- else if ((magicno[0]=='M' && magicno[1]=='M') ||
-- (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF;
-+ (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF;
-+#endif
-+
-+#ifdef HAVE_PNG
-+ else if (magicno[0]==0x89 && magicno[1]=='P' &&
-+ magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
- #endif
-
- #ifdef HAVE_PDS
-@@ -2635,11 +3064,59 @@
- rv = RFT_PDSVICAR;
- #endif
-
--#ifdef GS_PATH
-+#ifdef GS_PATH /* Ghostscript handles both PostScript and PDF */
- else if (strncmp((char *) magicno, "%!", (size_t) 2)==0 ||
-- strncmp((char *) magicno, "\004%!", (size_t) 3)==0) rv = RFT_PS;
-+ strncmp((char *) magicno, "\004%!", (size_t) 3)==0 ||
-+ strncmp((char *) magicno, "%PDF", (size_t) 4)==0) rv = RFT_PS;
- #endif
-
-+#ifdef HAVE_MAG
-+ else if (strncmp((char *) magicno,"MAKI02 ", (size_t) 8)==0) rv = RFT_MAG;
-+#endif
-+
-+#ifdef HAVE_MAKI
-+ else if (strncmp((char *) magicno,"MAKI01A ", (size_t) 8)==0 ||
-+ strncmp((char *) magicno,"MAKI01B ", (size_t) 8)==0) rv = RFT_MAKI;
-+#endif
-+
-+#ifdef HAVE_PIC
-+ else if (magicno[0]=='P' && magicno[1]=='I'&&magicno[2]=='C') rv = RFT_PIC;
-+#endif
-+
-+#ifdef HAVE_PI
-+ else if (magicno[0]=='P' && magicno[1]=='i') rv = RFT_PI;
-+#endif
-+
-+#ifdef HAVE_HIPS
-+ else if (strstr((char *) magicno, "./digest")) rv = RFT_HIPS;
-+#endif
-+
-+#ifdef HAVE_PCD
-+ else if (magicno[0]==0xff && magicno[1]==0xff &&
-+ magicno[2]==0xff && magicno[3]==0xff) rv = RFT_PCD;
-+#endif
-+
-+#ifdef MACBINARY
-+ /* Now we try to handle MacBinary files, but the method is VERY dirty... */
-+ if (macbin_alrchk == True) {
-+ macb_file = True;
-+ break;
-+ }
-+
-+ if (rv != RFT_UNKNOWN)
-+ break;
-+
-+ /* Skip MACBSIZE and recheck */
-+ macbin_alrchk = True;
-+ fp = xv_fopen(fname, "r");
-+ if (!fp) return RFT_ERROR;
-+ fseek(fp, MACBSIZE, SEEK_SET);
-+ n = fread(magicno, (size_t) 1, (size_t) 30, fp);
-+ fclose(fp);
-+
-+ if (n<30) return RFT_UNKNOWN; /* files less than 30 bytes long... */
-+ }
-+#endif
- return rv;
- }
-
-@@ -2652,9 +3129,10 @@
- PICINFO *pinfo;
- {
- /* if quick is set, we're being called to generate icons, or something
-- like that. We should load the image as quickly as possible. Currently,
-- this only affects the LoadPS routine, which, if quick is set, only
-- generates the page file for the first page of the document */
-+ like that. We should load the image as quickly as possible. Previously,
-+ this affected only the LoadPS routine, which, if quick is set, only
-+ generates the page file for the first page of the document. Now it
-+ also affects PCD, which loads only a thumbnail. */
-
- int rv = 0;
-
-@@ -2665,7 +3143,11 @@
- switch (ftype) {
- case RFT_GIF: rv = LoadGIF (fname, pinfo); break;
- case RFT_PM: rv = LoadPM (fname, pinfo); break;
-+#ifdef HAVE_MGCSFX
-+ case RFT_PBM: rv = LoadPBM (fname, pinfo, -1); break;
-+#else
- case RFT_PBM: rv = LoadPBM (fname, pinfo); break;
-+#endif
- case RFT_XBM: rv = LoadXBM (fname, pinfo); break;
- case RFT_SUNRAS: rv = LoadSunRas(fname, pinfo); break;
- case RFT_BMP: rv = LoadBMP (fname, pinfo); break;
-@@ -2677,21 +3159,60 @@
- case RFT_XPM: rv = LoadXPM (fname, pinfo); break;
- case RFT_XWD: rv = LoadXWD (fname, pinfo); break;
- case RFT_FITS: rv = LoadFITS (fname, pinfo, quick); break;
-+ case RFT_ZX: rv = LoadZX (fname, pinfo); break; /* [JCE] */
-+ case RFT_WBMP: rv = LoadWBMP (fname, pinfo); break;
-+
-+#ifdef HAVE_PCD
-+ /* if quick is switched on, use the smallest image size; don't ask the user */
-+ case RFT_PCD: rv = LoadPCD (fname, pinfo, quick ? 0 : PcdSize); break;
-+#endif
-
- #ifdef HAVE_JPEG
-- case RFT_JFIF: rv = LoadJFIF (fname, pinfo, quick); break;
-+ case RFT_JFIF: rv = LoadJFIF (fname, pinfo, quick); break;
- #endif
-
- #ifdef HAVE_TIFF
-- case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break;
-+ case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break;
-+#endif
-+
-+#ifdef HAVE_PNG
-+ case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
- #endif
-
- #ifdef HAVE_PDS
-- case RFT_PDSVICAR: rv = LoadPDS (fname, pinfo); break;
-+ case RFT_PDSVICAR: rv = LoadPDS (fname, pinfo); break;
- #endif
-
- #ifdef GS_PATH
-- case RFT_PS: rv = LoadPS (fname, pinfo, quick); break;
-+ case RFT_PS: rv = LoadPS (fname, pinfo, quick); break;
-+#endif
-+
-+#ifdef HAVE_MAG
-+ case RFT_MAG: rv = LoadMAG (fname, pinfo); break;
-+#endif
-+
-+#ifdef HAVE_MAKI
-+ case RFT_MAKI: rv = LoadMAKI (fname, pinfo); break;
-+#endif
-+
-+#ifdef HAVE_PIC
-+ case RFT_PIC: rv = LoadPIC (fname, pinfo); break;
-+#endif
-+
-+#ifdef HAVE_PI
-+ case RFT_PI: rv = LoadPi (fname, pinfo); break;
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ case RFT_PIC2: rv = LoadPIC2 (fname, pinfo, quick); break;
-+#endif
-+
-+#ifdef HAVE_HIPS
-+ case RFT_HIPS: rv = LoadHIPS (fname, pinfo); break;
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ case RFT_MGCSFX: rv = LoadMGCSFX (fname, pinfo); break;
- #endif
-
- }
-@@ -2700,13 +3221,17 @@
-
-
- /********************************/
--int UncompressFile(name, uncompname)
-+int UncompressFile(name, uncompname, filetype)
- char *name, *uncompname;
-+ int filetype;
- {
- /* returns '1' on success, with name of uncompressed file in uncompname
- returns '0' on failure */
-
- char namez[128], *fname, buf[512];
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
-
- fname = name;
- namez[0] = '\0';
-@@ -2746,15 +3271,23 @@
- close(mkstemp(uncompname));
- #else
- mktemp(uncompname);
-+ tmpfd = open(uncompname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) FatalError("UncompressFile(): can't create temporary file");
-+ close(tmpfd);
- #endif
-
- #ifndef VMS
-- sprintf(buf,"%s -c %s >%s", UNCOMPRESS, fname, uncompname);
-+ if (filetype == RFT_COMPRESS)
-+ sprintf(buf,"%s -c '%s' > '%s'", UNCOMPRESS, fname, uncompname);
-+# ifdef BUNZIP2
-+ else if (filetype == RFT_BZIP2)
-+ sprintf(buf,"%s -c '%s' > '%s'", BUNZIP2, fname, uncompname);
-+# endif
- #else /* it IS VMS */
- # ifdef GUNZIP
-- sprintf(buf,"%s %s %s", UNCOMPRESS, fname, uncompname);
-+ sprintf(buf,"%s '%s' '%s'", UNCOMPRESS, fname, uncompname);
- # else
-- sprintf(buf,"%s %s", UNCOMPRESS, fname);
-+ sprintf(buf,"%s '%s'", UNCOMPRESS, fname);
- # endif
- #endif
-
-@@ -2797,6 +3330,62 @@
- }
-
-
-+#ifdef MACBINARY
-+/********************************/
-+int RemoveMacbinary(src, dst)
-+ char *src, *dst;
-+{
-+ char buffer[8192]; /* XXX */
-+ int n, eof;
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
-+ FILE *sfp, *dfp;
-+
-+ sprintf(dst, "%s/xvmXXXXXX", tmpdir);
-+#ifdef USE_MKSTEMP
-+ close(mkstemp(dst));
-+#else
-+ mktemp(dst);
-+ tmpfd = open(dst,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) FatalError("RemoveMacbinary(): can't create temporary file");
-+#endif
-+
-+ SetISTR(ISTR_INFO, "Removing MacBinary...");
-+
-+ sfp = xv_fopen(src, "r");
-+#ifdef USE_MKSTEMP
-+ dfp = xv_fopen(dst, "w");
-+#else
-+ dfp = fdopen(tmpfd, "w");
-+#endif
-+ if (!sfp || !dfp) {
-+ SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src);
-+ Warning();
-+ return 0;
-+ }
-+ fseek(sfp, MACBSIZE, SEEK_SET);
-+ while ((n = fread(buffer, 1, sizeof(buffer), sfp)) == 8192) /* XXX */
-+ fwrite(buffer, 1, n, dfp);
-+ if ((eof = feof(sfp)))
-+ fwrite(buffer, 1, n, dfp);
-+ fclose(sfp);
-+ fflush(dfp);
-+ fclose(dfp);
-+#ifndef USE_MKSTEMP
-+ close(tmpfd);
-+#endif
-+ if (!eof) {
-+ SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src);
-+ Warning();
-+ return 0;
-+ }
-+
-+ return 1;
-+}
-+#endif
-+
-+
- /********************************/
- void KillPageFiles(bname, numpages)
- char *bname;
-@@ -2918,6 +3507,9 @@
-
- char fullcmd[512], tmpname[64], str[512];
- int i;
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
-
- if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
-
-@@ -2926,6 +3518,9 @@
- close(mkstemp(tmpname));
- #else
- mktemp(tmpname);
-+ tmpfd = open(tmpname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) FatalError("openPic(): can't create temporary file");
-+ close(tmpfd);
- #endif
- if (tmpname[0] == '\0') { /* mktemp() or mkstemp() blew up */
- sprintf(str,"Unable to create temporary filename.");
-@@ -2966,26 +3561,21 @@
- {
- int i;
-
-+ waitsec = (numnames <= 1)? waitsec_final : waitsec_nonfinal;
-+
- if (!numnames) { openPic(DFLTPIC); return; }
-
- i = 0;
-- if (!randomShow) {
-- while (numnames>0) {
-- if (openPic(0)) return; /* success */
-- else {
-- if (polling && !i)
-- fprintf(stderr,"%s: POLLING: Waiting for file '%s' \n\tto %s\n",
-- cmd, namelist[0], "be created, or whatever...");
-- i = 1;
-- }
-+ while (numnames>0) {
-+ if (openPic(0)) return; /* success */
-+ else {
-+ if (polling && !i)
-+ fprintf(stderr,"%s: POLLING: Waiting for file '%s' \n\tto %s\n",
-+ cmd, namelist[0], "be created, or whatever...");
-+ i = 1;
- }
- }
-
-- else { /* pick random first picture */
-- for (i=findRandomPic(); i>=0; i=findRandomPic())
-- if (openPic(i)) return; /* success */
-- }
--
- if (numnames>1) FatalError("couldn't open any pictures");
- else Quit(-1);
- }
-@@ -3014,19 +3604,15 @@
- {
- int i;
-
-- if (!randomShow) {
-- if (curname>=0) i = curname+1;
-- else if (nList.selected >= 0 && nList.selected < numnames)
-- i = nList.selected;
-- else i = 0;
-+ if (curname>=0) i = curname+1;
-+ else if (nList.selected >= 0 && nList.selected < numnames)
-+ i = nList.selected;
-+ else i = 0;
-
-- while (i<numnames && !openPic(i));
-- if (i<numnames) return; /* success */
-- }
-- else {
-- for (i=findRandomPic(); i>=0; i=findRandomPic())
-- if (openPic(i)) return;
-- }
-+ waitsec = (i == numnames-1)? waitsec_final : waitsec_nonfinal;
-+
-+ while (i<numnames && !openPic(i));
-+ if (i<numnames) return; /* success */
-
- Quit(0);
- }
-@@ -3039,25 +3625,21 @@
-
- j = loop = 0;
- while (1) {
-- if (!randomShow) {
-
-- if (curname>=0) i = curname+1;
-- else if (nList.selected >= 0 && nList.selected < numnames)
-- i = nList.selected;
-- else i = 0;
-+ if (curname>=0) i = curname+1;
-+ else if (nList.selected >= 0 && nList.selected < numnames)
-+ i = nList.selected;
-+ else i = 0;
-
-- if (loop) { i = 0; loop = 0; }
-+ if (loop) { i = 0; loop = 0; }
-
-- while (i<numnames && !openPic(i));
-- if (i<numnames) return;
-- }
-- else {
-- for (i=findRandomPic(); i>=0; i=findRandomPic())
-- if (openPic(i)) return;
-- }
-+ waitsec = (i == numnames-1)? waitsec_final : waitsec_nonfinal;
-+
-+ while (i<numnames && !openPic(i));
-+ if (i<numnames) return;
-
- loop = 1; /* back to top of list */
-- if (j) break; /* we're in a 'failure loop' */
-+ if (j) break; /* we're in a 'failure loop' */
- j++;
- }
-
-@@ -3090,47 +3672,6 @@
- openPic(LOADPIC);
- }
-
--
--
--
--/****************/
--static int findRandomPic()
--/****************/
--{
-- static byte *loadList;
-- static int left_to_load, listLen = -1;
-- int k;
-- time_t t;
--
-- /* picks a random name out of the list, and returns it's index. If there
-- are no more names to pick, it returns '-1' and resets itself */
--
-- if (!loadList || numnames!=listLen) {
-- if (loadList) free(loadList);
-- else {
-- time(&t);
-- srandom((unsigned int) t); /* seed the random */
-- }
--
-- left_to_load = listLen = numnames;
-- loadList = (byte *) malloc((size_t) listLen);
-- for (k=0; k<listLen; k++) loadList[k] = 0;
-- }
--
-- if (left_to_load <= 0) { /* we've loaded all the pics */
-- for (k=0; k<listLen; k++) loadList[k] = 0; /* clear flags */
-- left_to_load = listLen;
-- return -1; /* 'done' return */
-- }
--
-- for (k=abs(random()) % listLen; loadList[k]; k = (k+1) % listLen);
--
-- left_to_load--;
-- loadList[k] = TRUE;
--
-- return k;
--}
--
- /****************/
- static void mainLoop()
- {
-@@ -3144,10 +3685,11 @@
- selected file (or the 0th file, if no selection either), and 'Prev' means
- view the one right before the selected file */
-
-- openFirstPic(); /* find first displayable picture, exit if none */
-+ /* find first displayable picture, exit if none */
-+ if (!startGrab) openFirstPic();
-
- if (!pic) { /* must've opened a text file... display dflt pic */
-- openPic(DFLTPIC);
-+ if (!startGrab) openPic(DFLTPIC);
- if (mainW && !useroot) RaiseTextWindows();
- }
-
-@@ -3224,8 +3766,16 @@
- hints.flags = 0;
- if ((i&XValue || i&YValue)) hints.flags = USPosition;
-
-- if (i&XValue && i&XNegative) x = vrWIDE - eWIDE - abs(x);
-- if (i&YValue && i&YNegative) y = vrHIGH - eHIGH - abs(y);
-+ hints.win_gravity = NorthWestGravity;
-+ if (i&XValue && i&XNegative) {
-+ hints.win_gravity = NorthEastGravity;
-+ x = vrWIDE - (eWIDE + 2 * bwidth) - abs(x);
-+ }
-+ if (i&YValue && i&YNegative) {
-+ hints.win_gravity = (hints.win_gravity == NorthWestGravity) ?
-+ SouthWestGravity : SouthEastGravity;
-+ y = vrHIGH - (eHIGH + 2 * bwidth) - abs(y);
-+ }
-
- if (x+eWIDE > vrWIDE) x = vrWIDE - eWIDE; /* keep on screen */
- if (y+eHIGH > vrHIGH) y = vrHIGH - eHIGH;
-@@ -3245,7 +3795,7 @@
- hints.x = x; hints.y = y;
- hints.width = eWIDE; hints.height = eHIGH;
- hints.max_width = maxWIDE; hints.max_height = maxHIGH;
-- hints.flags |= USSize | PMaxSize;
-+ hints.flags |= USSize | PMaxSize | PWinGravity;
-
- xswa.bit_gravity = StaticGravity;
- xswa.background_pixel = bg;
-@@ -3294,10 +3844,6 @@
- }
- }
-
--
-- XSetStandardProperties(theDisp,mainW,"","",None,NULL,0,&hints);
-- setWinIconNames(name);
--
- xwmh.input = True;
- xwmh.flags = InputHint;
-
-@@ -3322,12 +3868,13 @@
- }
- }
- }
-- XSetWMHints(theDisp, mainW, &xwmh);
-
- classh.res_name = "xv";
- classh.res_class = "XVroot";
-- XSetClassHint(theDisp, mainW, &classh);
-
-+ XmbSetWMProperties(theDisp, mainW, NULL, NULL, NULL, 0, &hints, &xwmh,
-+ &classh);
-+ setWinIconNames(name);
-
- if (nodecor) { /* turn of image window decorations (in MWM) */
- Atom mwm_wm_hints;
-@@ -4070,16 +4617,30 @@
- unsigned long nitems, nleft;
- byte *data;
-
-- i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0),
-- resAtom, 0L, 1L, False,
-- XA_STRING, &actType, &actFormat, &nitems, &nleft,
-- (unsigned char **) &data);
-+ if (spec_window) {
-+ i = XGetWindowProperty(theDisp, spec_window,
-+ resAtom, 0L, 1L, False,
-+ XA_STRING, &actType, &actFormat, &nitems, &nleft,
-+ (unsigned char **) &data);
-+ } else {
-+ i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0),
-+ resAtom, 0L, 1L, False,
-+ XA_STRING, &actType, &actFormat, &nitems, &nleft,
-+ (unsigned char **) &data);
-+ }
- if (i==Success && actType==XA_STRING && actFormat==8) {
- if (nitems>0 && data) XFree(data);
-- i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L,
-- (long) ((nleft+4+3)/4),
-- False, XA_STRING, &actType, &actFormat,
-- &nitems, &nleft, (unsigned char **) &data);
-+ if (spec_window) {
-+ i = XGetWindowProperty(theDisp, spec_window, resAtom, 0L,
-+ (long) ((nleft+4+3)/4),
-+ False, XA_STRING, &actType, &actFormat,
-+ &nitems, &nleft, (unsigned char **) &data);
-+ } else {
-+ i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L,
-+ (long) ((nleft+4+3)/4),
-+ False, XA_STRING, &actType, &actFormat,
-+ &nitems, &nleft, (unsigned char **) &data);
-+ }
- if (i==Success && actType==XA_STRING && actFormat==8 && data) {
- def_resource = XrmGetStringDatabase((char *) data);
- XFree(data);
-diff -ruN xv-3.10a-bugfixes/xv.h xv-3.10a-enhancements/xv.h
---- xv-3.10a-bugfixes/xv.h 2005-04-10 09:37:18.000000000 -0700
-+++ xv-3.10a-enhancements/xv.h 2005-05-01 13:32:10.000000000 -0700
-@@ -14,8 +14,9 @@
- /* GRR orig jumbo enhancements patch: 20000220 */
- /* GRR 1st public jumbo F+E patches: 20040531 */
- /* GRR 2nd public jumbo F+E patches: 20050410 */
--#define REVDATE "version 3.10a-jumboFix of 20050410"
--#define VERSTR "3.10a-20050410"
-+/* GRR 3rd public jumbo F+E patches: 20050501 */
-+#define REVDATE "version 3.10a-jumboFix+Enh of 20050501"
-+#define VERSTR "3.10a-20050501"
-
- /*
- * uncomment the following, and modify for your site, but only if you've
-@@ -49,6 +50,10 @@
- /* START OF MACHINE-DEPENDENT CONFIGURATION INFO */
- /*************************************************/
-
-+
-+#define ENABLE_FIXPIX_SMOOTH /* GRR 19980607 */
-+
-+
- /* Things to make xv more likely to just build, without the user tweaking
- the makefile */
-
-@@ -67,6 +72,14 @@
- # define SVR4
- #endif
-
-+#if defined(__sony_news) && defined(bsd43) && !defined(__bsd43)
-+# define __bsd43
-+#elif defined(__sony_news) && (defined(SYSTYPE_BSD) || defined(__SYSTYPE_BSD)) && !defined(bsd43) && !defined(__bsd43)
-+# define bsd43
-+# define __bsd43
-+#endif
-+
-+#include <signal.h> /* for interrupt handling */
-
- /* at least on Linux, the following file (1) includes sys/types.h and
- * (2) defines __USE_BSD (which was not defined before here), so __linux__
-@@ -78,7 +91,9 @@
- # ifndef _LINUX_LIMITS_H
- # include <linux/limits.h>
- # endif
--# define USLEEP
-+# ifndef USLEEP
-+# define USLEEP
-+# endif
- /* want only one or the other defined, not both: */
- # if !defined(BSDTYPES) && !defined(__USE_BSD)
- # define BSDTYPES
-@@ -117,6 +132,16 @@
- #endif
-
-
-+#if defined(__sony_news) && defined(__bsd43)
-+# include <unistd.h>
-+#endif
-+
-+
-+#if defined(__FreeBSD__)
-+# include <sys/param.h>
-+#endif
-+
-+
- /* include files */
- #include <stdio.h>
- #include <math.h>
-@@ -132,9 +157,11 @@
-
- #ifndef VMS
- # include <errno.h>
-- extern int errno; /* SHOULD be in errno.h, but often isn't */
--# if !defined(__NetBSD__) && !(defined(__linux__) && defined(__USE_BSD))
-- extern char *sys_errlist[]; /* this too... */
-+# ifndef __NetBSD__
-+# if !(defined __GLIBC__ && __GLIBC__ >= 2)
-+ extern int errno; /* SHOULD be in errno.h, but often isn't */
-+ extern char *sys_errlist[]; /* this too... */
-+# endif
- # endif
- #endif
-
-@@ -203,9 +230,10 @@
- #include <X11/Xatom.h>
- #include <X11/Xmd.h>
-
-+#ifdef TV_L10N
-+# include <X11/Xlocale.h>
-+#endif
-
--#undef SIGCHLD /* defined in both Xos.h and signal.h */
--#include <signal.h> /* for interrupt handling */
-
- #include <sys/types.h>
-
-@@ -316,7 +344,9 @@
- # endif
- #endif
-
--
-+#ifndef S_IRWUSR
-+# define S_IRWUSR (S_IRUSR|__S_IWRITE)
-+#endif
-
- #ifndef MAXPATHLEN
- # define MAXPATHLEN 256
-@@ -343,13 +373,36 @@
- #endif
-
-
--/* GRR 20040430: This is new and still only partially implemented. No doubt
-- * there are many other systems that have mkstemp() (SUSv3),
-- * but let's start small... */
--#if defined(__linux__) || defined(__OpenBSD__)
--# define USE_MKSTEMP /* use 'mkstemp()' instead of 'mktemp()' */
-+/* GRR 20040430: This is new and still not fully deployed. No doubt there
-+ * are other systems that have mkstemp() (SUSv3); we can add
-+ * them later. */
-+#ifndef VMS /* VMS hates multi-line definitions */
-+# if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
-+ defined(__bsdi__)
-+# ifndef USE_MKSTEMP
-+# define USE_MKSTEMP /* use 'mkstemp()' instead of 'mktemp()' */
-+# endif /* >> SECURITY ISSUE << */
-+# endif
-+#endif
-+
-+
-+/* GRR 20040503: This is new and so far tested only under Linux. But it
-+ * allows -wait to work with subsecond values as long as
-+ * times() exists and clock_t is a long int (latter matters
-+ * only if/when clocks wrap, which for Linux is multiples of
-+ * 497.11 days since the last reboot). */
-+#if defined(__linux__)
-+# define USE_TICKS /* use times()/Timer(), not time()/sleep() */
-+# include <limits.h> /* LONG_MAX (really want CLOCK_T_MAX) */
-+# include <sys/times.h> /* times() */
-+# ifndef CLK_TCK /* can be undefined in strict-ANSI mode */
-+# define CLK_TCK CLOCKS_PER_SEC /* claimed to be same thing in time.h */
-+# endif
- #endif
-
-+#if (defined(SYSV) || defined(SVR4) || defined(linux)) && !defined(USE_GETCWD)
-+# define USE_GETCWD
-+#endif
-
- /*****************************/
- /* END OF CONFIGURATION INFO */
-@@ -363,17 +416,21 @@
- # define HAVE_TIFF
- #endif
-
-+#ifdef DOPNG
-+# define HAVE_PNG
-+#endif
-+
- #ifdef DOPDS
- # define HAVE_PDS
- #endif
-
-
-
--#define PROGNAME "xv" /* used in resource database */
-+#define PROGNAME "xv" /* used in resource database */
-
--#define MAXNAMES 4096 /* max # of files in ctrlW list */
-+#define MAXNAMES 32768 /* max # of files in ctrlW list */
-
--#define MAXBRWIN 4 /* max # of vis browser windows */
-+#define MAXBRWIN 16 /* max # of vis browser windows */
-
- /* strings in the INFOBOX (used in SetISTR and GetISTR) */
- #define NISTR 10 /* number of ISTRs */
-@@ -494,24 +551,80 @@
- #define F_TIFINC 0
- #endif
-
-+#ifdef HAVE_PNG
-+#define F_PNGINC 1
-+#else
-+#define F_PNGINC 0
-+#endif
-+
-+#ifdef HAVE_MAG
-+# define F_MAGINC 1
-+#else
-+# define F_MAGINC 0
-+#endif
-+
-+#ifdef HAVE_PIC
-+# define F_PICINC 1
-+#else
-+# define F_PICINC 0
-+#endif
+
-+#ifdef HAVE_MAKI
-+# define F_MAKINC 1
-+#else
-+# define F_MAKINC 0
-+#endif
++cd $BUILD
++rm -rf xv-3.10
++tar xzvf $SOURCE/xv-3.10.tar.gz
++cd xv-3.10
++zcat $SOURCE/xv-3.10a.patch.gz | patch -p0 $PFLAGS || \
++ bail $SOURCE/xv-3.10a.patch.gz
++bzcat $SOURCE/xv-3.10a-jumbo-fix-patch-20050410.txt.bz2 | patch -p1 $PFLAGS || \
++ bail $SOURCE/xv-3.10a-jumbo-fix-patch-20050410.txt.bz2
++bzcat $SOURCE/xv-3.10a-jumbo-enh-patch-20050501.txt.bz2 | patch -p1 $PFLAGS || \
++ bail $SOURCE/xv-3.10a-jumbo-enh-patch-20050501.txt.bz2
++zcat $SOURCE/xv.prefix.diff.gz | patch -p1 $PFLAGS || \
++ bail $SOURCE/xv.prefix.diff.gz
++make -f Makefile.std || bail make
++strip --strip-unneeded bggen vdcomp xcmap xv xvpictoppm || bail strip
++
++exit $?
++
++# vi:set ts=4:
+diff -u -r --new-file xv-3.10a.orig/contrib/fedora/README xv-3.10a/contrib/fedora/README
+--- xv-3.10a.orig/contrib/fedora/README 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fedora/README 2006-06-01 10:12:47.000000000 -0500
+@@ -0,0 +1,16 @@
++Greg,
++ After winding up in dark lonely places trying to
++get xv-3.10a to build on FC5 I suspected I was missing
++something. Then I happened on your patch manifest
++in Slackware 10.2.
++
++I bandsawed the script a bit to use in propagating XV
++to a handful of personal FC5 machines. Attached for
++reference.
+
-+#ifdef HAVE_PI
-+# define F_PAIINC 1
-+#else
-+# define F_PAIINC 0
-+#endif
++Thanks for your effort!
+
-+#ifdef HAVE_PIC2
-+# define F_PC2INC 1
-+#else
-+# define F_PC2INC 0
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+# define F_MGCSFXINC 1
-+#else
-+# define F_MGCSFXINC 0
-+#endif
-+
-+#ifdef MACBINARY
-+# define MACBSIZE 128
-+#endif
-
- #define F_GIF 0
- #define F_JPEG ( 0 + F_JPGINC)
- #define F_TIFF ( 0 + F_JPGINC + F_TIFINC)
--#define F_PS ( 1 + F_JPGINC + F_TIFINC)
--#define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC)
--#define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC)
--#define F_XBM ( 4 + F_JPGINC + F_TIFINC)
--#define F_XPM ( 5 + F_JPGINC + F_TIFINC)
--#define F_BMP ( 6 + F_JPGINC + F_TIFINC)
--#define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC)
--#define F_IRIS ( 8 + F_JPGINC + F_TIFINC)
--#define F_TARGA ( 9 + F_JPGINC + F_TIFINC)
--#define F_FITS (10 + F_JPGINC + F_TIFINC)
--#define F_PM (11 + F_JPGINC + F_TIFINC)
--#define F_DELIM1 (12 + F_JPGINC + F_TIFINC) /* ----- */
--#define F_FILELIST (13 + F_JPGINC + F_TIFINC)
--#define F_MAXFMTS (14 + F_JPGINC + F_TIFINC) /* 15, normally */
-+#define F_PNG ( 0 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PS ( 1 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_XBM ( 4 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_XPM ( 5 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_BMP ( 6 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_IRIS ( 8 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_TARGA ( 9 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_FITS (10 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PM (11 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_ZX (12 + F_JPGINC + F_TIFINC + F_PNGINC) /* [JCE] */
-+#define F_WBMP (13 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define JP_EXT_F (F_WBMP)
-+#define F_MAG (JP_EXT_F + F_MAGINC)
-+#define F_PIC (JP_EXT_F + F_MAGINC + F_PICINC)
-+#define F_MAKI (JP_EXT_F + F_MAGINC + F_PICINC + F_MAKINC)
-+#define F_PI (JP_EXT_F + F_MAGINC + F_PICINC + F_MAKINC + F_PAIINC)
-+#define F_PIC2 (JP_EXT_F + F_MAGINC + F_PICINC + F_MAKINC + F_PAIINC + F_PC2INC)
-+#define F_MGCSFX (JP_EXT_F + F_MAGINC + F_PICINC + F_MAKINC + F_PAIINC + F_PC2INC + F_MGCSFXINC)
-+#define JP_EXT_F_END (F_MGCSFX)
-+#define F_DELIM1 (JP_EXT_F_END + 1) /* ----- */
-+#define F_FILELIST (JP_EXT_F_END + 2)
-+#define F_MAXFMTS (JP_EXT_F_END + 3) /* 23, normally */
-
-
-
-@@ -541,6 +654,19 @@
- #define RFT_XPM 17
- #define RFT_XWD 18
- #define RFT_FITS 19
-+#define RFT_PNG 20
-+#define RFT_ZX 21 /* [JCE] */
-+#define RFT_WBMP 22
-+#define RFT_PCD 23
-+#define RFT_HIPS 24
-+#define RFT_BZIP2 25
-+#define JP_EXT_RFT (RFT_BZIP2)
-+#define RFT_MAG (JP_EXT_RFT + 1)
-+#define RFT_MAKI (JP_EXT_RFT + 2)
-+#define RFT_PIC (JP_EXT_RFT + 3)
-+#define RFT_PI (JP_EXT_RFT + 4)
-+#define RFT_PIC2 (JP_EXT_RFT + 5)
-+#define RFT_MGCSFX (JP_EXT_RFT + 6)
-
- /* definitions for page up/down, arrow up/down list control */
- #define LS_PAGEUP 0
-@@ -599,7 +725,8 @@
- #define RM_CBRICK 7 /* centered on a 'brick' bg */
- #define RM_ECENTER 8 /* symmetrical tiled */
- #define RM_ECMIRR 9 /* symmetrical mirror tiled */
--#define RM_MAX RM_ECMIRR
-+#define RM_UPLEFT 10 /* just in upper left corner */
-+#define RM_MAX RM_UPLEFT
-
-
- /* values of colorMapMode */
-@@ -649,7 +776,8 @@
- #define RMB_CBRICK 8
- #define RMB_ECENTER 9
- #define RMB_ECMIRR 10
--#define RMB_MAX 11
-+#define RMB_UPLEFT 11
-+#define RMB_MAX 12
-
-
- /* indicies into conv24MB */
-@@ -784,9 +912,9 @@
- int len; /* length of major axis */
- int vert; /* true if vertical, else horizontal */
- int active; /* true if scroll bar can do anything*/
-- int min,max; /* min/max values 'pos' can take */
-- int val; /* 'value' of scrollbar */
-- int page; /* amt val change on pageup/pagedown */
-+ double min,max; /* min/max values 'pos' can take */
-+ double val; /* 'value' of scrollbar */
-+ double page; /* amt val change on pageup/pagedown */
- int tpos; /* thumb pos. (pixels from tmin) */
- int tmin,tmax; /* min/max thumb offsets (from 0,0) */
- int tsize; /* size of thumb (in pixels) */
-@@ -801,9 +929,10 @@
- typedef struct { Window win; /* window ID */
- int x,y,w,h; /* window coords in parent */
- int active; /* true if can do anything*/
-- int min,max; /* min/max values 'pos' can take */
-- int val; /* 'value' of dial */
-- int page; /* amt val change on pageup/pagedown */
-+ double min,max; /* min/max values 'pos' can take */
-+ double val; /* 'value' of dial */
-+ double inc; /* amt val change on up/down */
-+ double page; /* amt val change on pageup/pagedown */
- char *title; /* title for this guage */
- char *units; /* string appended to value */
- u_long fg,bg,hi,lo; /* colors */
-@@ -971,15 +1100,19 @@
- WHERE unsigned int ncells, dispWIDE, dispHIGH, dispDEEP;
- WHERE unsigned int vrWIDE, vrHIGH, maxWIDE, maxHIGH;
- WHERE Colormap theCmap, LocalCmap;
--WHERE Window rootW, mainW, vrootW;
-+WHERE Window spec_window, rootW, mainW, vrootW;
- WHERE GC theGC;
- WHERE u_long black, white, fg, bg, infofg, infobg;
- WHERE u_long hicol, locol;
- WHERE u_long blkRGB, whtRGB;
- WHERE Font mfont, monofont;
- WHERE XFontStruct *mfinfo, *monofinfo;
-+#ifdef TV_L10N
-+WHERE XFontSet monofset;
-+WHERE XFontSetExtents *monofsetinfo;
-+#endif
- WHERE Visual *theVisual;
--WHERE Cursor arrow, cross, tcross, zoom, inviso;
-+WHERE Cursor arrow, cross, tcross, zoom, inviso, tlcorner;
- WHERE Pixmap iconPix, iconmask;
- WHERE Pixmap riconPix, riconmask;
- WHERE int showzoomcursor;
-@@ -996,6 +1129,10 @@
- WHERE int picType; /* CONV24_8BIT,CONV24_24BIT,etc.*/
- WHERE char *picComments; /* text comments on current pic */
-
-+#ifdef TV_L10N
-+WHERE int xlocale; /* true if Xlib supports locale */
-+#endif
-+
- WHERE int numPages, curPage; /* for multi-page files */
- WHERE char pageBaseName[64]; /* basename for multi-page files */
-
-@@ -1029,6 +1166,23 @@
- WHERE unsigned long cols[256]; /* maps pic pixel values to X pixel vals */
- WHERE int fc2pcol[256]; /* maps freecols into pic pixel values */
- WHERE int numcols; /* # of desired colors in picture */
-+#ifdef MACBINARY
-+WHERE char macb_file; /* True if this file type is MacBinary */
-+WHERE int handlemacb; /* True if we want to handle MacBinary */
-+#endif
-+#if defined(HAVE_PIC) || defined(HAVE_PIC2)
-+WHERE int nopicadjust; /* True if we don't want to adjust aspect */
-+#endif
-+#ifdef HAVE_PIC2
-+WHERE int pic2split; /* True if we want to split multiblocks */
-+#endif
-+#ifdef VS_ADJUST
-+WHERE int vsadjust; /* True if we want to adjust aspect of icons */
-+#endif
-+#ifdef HAVE_MGCSFX
-+WHERE int mgcsfx; /* True if we want to force use MgcSfx */
-+WHERE int nomgcsfx; /* True if we don't want to use MgcSfx */
-+#endif
-
- /* Std Cmap stuff */
- WHERE byte stdr[256], stdg[256], stdb[256]; /* std 3/3/2 cmap */
-@@ -1083,42 +1237,47 @@
- noFreeCols, /* don't free colors when loading new pic */
- autoquit, /* quit in '-root' or when click on win */
- xerrcode, /* errorcode of last X error */
-- grabDelay; /* # of seconds to sleep at start of Grab */
-+ grabDelay, /* # of seconds to sleep at start of Grab */
-+ startGrab; /* start immediate grab ? */
-
- WHERE int state824; /* displays warning when going 8->24 */
-
- WHERE float defaspect, /* default aspect ratio to use */
- normaspect; /* normal aspect ratio of this picture */
-
--WHERE unsigned long rootbg, rootfg; /* fg/bg for root border */
--WHERE int waitsec; /* secs btwn pics. -1=wait for event */
--WHERE int waitloop; /* loop at end of slide show? */
--WHERE int automax; /* maximize pic on open */
--WHERE int rootMode; /* mode used for -root images */
-+WHERE u_long rootbg, rootfg; /* fg/bg for root border */
-+WHERE u_short imagebgR;
-+WHERE u_short imagebgG; /* GRR 19980308: bg for transpar. images */
-+WHERE u_short imagebgB;
-+WHERE int have_imagebg;
-+WHERE double waitsec; /* secs btwn pics. -1.0=wait for event */
-+WHERE int waitloop; /* loop at end of slide show? */
-+WHERE int automax; /* maximize pic on open */
-+WHERE int rootMode; /* mode used for -root images */
-
--WHERE int nostat; /* if true, don't stat() in LdCurDir */
-+WHERE int nostat; /* if true, don't stat() in LdCurDir */
-
--WHERE int ctrlColor; /* whether or not to use colored butts */
-+WHERE int ctrlColor; /* whether or not to use colored butts */
-
--WHERE char *def_str; /* used by rd_*() routines */
-+WHERE char *def_str; /* used by rd_*() routines */
- WHERE int def_int;
--WHERE char *tmpdir; /* equal to "/tmp" or $TMPDIR env var */
--WHERE Pixmap gray25Tile, /* used for 3d effect on 1-bit disp's */
-+WHERE char *tmpdir; /* equal to "/tmp" or $TMPDIR env var */
-+WHERE Pixmap gray25Tile, /* used for 3d effect on 1-bit disp's */
- gray50Tile;
--WHERE int autoDelete; /* delete cmd-line files on exit? */
-+WHERE int autoDelete; /* delete cmd-line files on exit? */
-
- #define PRINTCMDLEN 256
- WHERE char printCmd[PRINTCMDLEN];
-
- /* stuff used for 'info' box */
- WHERE Window infoW;
--WHERE int infoUp; /* boolean: whether infobox is visible */
-+WHERE int infoUp; /* boolean: whether infobox is visible */
- WHERE int infoMode;
-
-
- /* stuff used for 'ctrl' box */
- WHERE Window ctrlW;
--WHERE int ctrlUp; /* boolean: whether ctrlbox is visible */
-+WHERE int ctrlUp; /* boolean: whether ctrlbox is visible */
- WHERE char *namelist[MAXNAMES]; /* list of file names from argv */
- WHERE char *origlist[MAXNAMES]; /* only names from argv (autoDelete)*/
- WHERE int orignumnames;
-@@ -1157,25 +1316,30 @@
-
-
- /* stuff used for 'browse' box */
--WHERE int anyBrowUp; /* whether *any* browser visible */
-+WHERE int anyBrowUp; /* whether *any* browser visible */
-
- /* stuff used for textview windows */
--WHERE int anyTextUp; /* are any text windows visible? */
--WHERE int commentUp; /* comment window up? */
-+WHERE int anyTextUp; /* are any text windows visible? */
-+WHERE int commentUp; /* comment window up? */
-
- /* stuff used for xvcut.c */
--WHERE int forceClipFile; /* don't use property clipboard */
--WHERE int clearR, clearG, clearB; /* clear color in 24-bit mode */
-+WHERE int forceClipFile; /* don't use property clipboard */
-+WHERE int clearR, clearG, clearB; /* clear color in 24-bit mode */
-
-
- /* stuff used for 'ps' box */
- WHERE Window psW;
--WHERE int psUp; /* is psW mapped, or what? */
-+WHERE int psUp; /* is psW mapped, or what? */
- WHERE CBUTT encapsCB, pscompCB;
- WHERE char *gsDev, *gsGeomStr;
- WHERE int gsRes;
-
-
-+/* stuff used for 'pcd' box */
-+WHERE Window pcdW;
-+WHERE int pcdUp; /* is pcdW mapped, or what? */
-+
-+
- #ifdef HAVE_JPEG
- /* stuff used for 'jpeg' box */
- WHERE Window jpegW;
-@@ -1190,6 +1354,91 @@
- #endif
-
-
-+#ifdef HAVE_PNG
-+/* stuff used for 'png' box */
-+WHERE Window pngW;
-+WHERE int pngUp; /* is pngW mapped, or what? */
-+#endif
++-john
+
++--
++john.cooper@third-harmonic.com
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/README xv-3.10a/contrib/fnkey-scripts/README
+--- xv-3.10a.orig/contrib/fnkey-scripts/README 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/README 2007-01-16 02:41:51.000000000 -0600
+@@ -0,0 +1,111 @@
++-- License and Disclaimer --
++
++This patch & script package was written by Alexey Spiridonov, and is
++licensed under the GNU GPLv2. There is NO WARRANTY.
++
++XV is copyrighted by John Bradley.
+
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+WHERE int do_fixpix_smooth; /* GRR 19980607: runtime FS dithering */
-+#endif
++-- What is this? --
++
++This is a small patch for XV that allows you to run scripts by pressing
++a key from F1 through F12 (or more, just change 12 to your number in the
++patch file).
++
++The patch enables a number of useful features. Here is a my set-up:
++
++F1: Losslessly rotate JPEG 90 degrees to the right.
++F2: Losslessly rotate JPEG 90 degrees to the left.
++
++F3: Print the current selection rectangle (on the terminal where xv was
++ launched). This is useful for quickly recording a bunch of positions in
++ an image. Use case:
++ I'm annotating face positions.
++ 1) Select Joe in picture, hit F3, type "Joe" in the terminal.
++ 2) Select Jane in the picture, ...
++ ...
++ n) Copy the text visible in the terminal, and paste it into the
++ JPEG comment.
++ Of course, i would write a more convenient script if I annotated faces
++ with any any frequency.
++
++F4: Edit JPEG comment (I use it for annotations/tags).
++
++F5: Log a 'losslessly rotate right' command for batch processing. This
++ writes the rotation command for the current file into a shell script
++ somewhere ("~/photos/bin/rotscript" by default). This is great for
++ slower computers because you don't have to wait for each image to
++ rotate; instead, you just rotate them all at once by running the
++ resulting script.
++F6: Log a 'losslessly rotate left' batch command.
++
++F8: Crop image on disk, but back-up the uncropped version. You can make
++ a succession of crops this way, with a backup made at every step.
++ This wastes disk space, so be sure to clean up once you get a crop you
++ like.
++F7: Undo the last crop done on this image. This can be repeated until you're
++ back at the original.
++
++-- Installation --
++
++I'll tell you how to get the set-up I described above. Of course, you can
++customize it to your heart's content.
++
++(( 1 ))
++
++Go to:
++
++ http://www.sonic.net/~roelofs/greg_xv.html
++
++and follow the XV install instructions there. If you are okay with
++reading shell scripts, you might also give this a shot:
++
++ http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/media-gfx/xv/xv-3.10a-r12.ebuild
++
++When you're ready to type "make install", do the following to apply my patch:
++
++ $ cd WHEREVER_YOU_COMPILED_XV
++ $ patch -p1 --dry-run < PATH/TO/xv-3.10a-fkey-command-patch.greg-xv
++
++Hopefully, the above command won't complain; if it does, Greg Roelofs
++probably changed his patchset, and my patch has become out of date -- let me
++know. If that went well, run:
++
++ $ patch -p1 < PATH/TO/xv-3.10a-fkey-command-patch.greg-xv
++
++Now, simply recompile and install as described in the other instructions.
++
++(( 2 ))
++
++Copy 'jpegcrop.sh', 'jpegeditcom.sh', 'jpegundocrop.sh', 'jpegrot.sh',
++'jpeglogrot.sh' to some convenient directory.
++
++Suggestions: ~/photos/bin, /usr/local/bin, etc...
++
++Edit 'jpeglogrot.sh' and 'jpegeditcom.sh'. In the former, you need to
++customize the path to 'jpegrot.sh'. In the latter, you should make set
++your favorite editor. The spots to customize are marked as such.
++
++(( 3 ))
++
++Open .Xdefaults in your favorite text editor, and paste the following lines
++there:
++
++xv.F1command: ~/photos/bin/jpegrot.sh 90 %s
++xv.F2command: ~/photos/bin/jpegrot.sh 270 %s
++xv.F3command: @echo "The selection rect for '%s' is at (%d, %d) of size %dx%d."
++xv.F4command: @~/photos/bin/jpegeditcom.sh %s &
++xv.F5command: @~/photos/bin/jpeglogrot.sh 90 %s
++xv.F6command: @~/photos/bin/jpeglogrot.sh 270 %s
++xv.F7command: ~/photos/bin/jpegundocrop.sh %s
++xv.F8command: ~/photos/bin/jpegcrop.sh %s %d %d %d %d
++
++Change '~/photos/bin/' to the directory you chose in (( 2 )). In case you're
++wondering what the '@' symbol means, it tells XV not to reload the file
++after running this command. The default is to reload the file.
++
++-- Apologies --
++
++I didn't get a chance to run through the above instructions and check
++that they work. I know they're right in spirit, but I might've made a typo
++or two. Even if it's obvious to you, would you please let me know by writing
++to lesha at mit dot edu?
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/jpegcrop.sh xv-3.10a/contrib/fnkey-scripts/jpegcrop.sh
+--- xv-3.10a.orig/contrib/fnkey-scripts/jpegcrop.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/jpegcrop.sh 2006-03-11 21:30:03.000000000 -0600
+@@ -0,0 +1,33 @@
++#!/bin/bash
++FILE=$1
++WIDTH=$4
++HEIGHT=$5
++XPOS=$2
++YPOS=$3
++if [[ $XPOS -lt 0 ]]; then
++ echo "Negative x position $XPOS converted to zero, width adjusted."
++ WIDTH=$((WIDTH+XPOS))
++ XPOS=0
++fi
++if [[ $YPOS -lt 0 ]]; then
++ echo "Negative y position $YPOS converted to zero, height adjusted."
++ HEIGHT=$((HEIGHT+YPOS))
++ YPOS=0
++fi
++if [[ $(($WIDTH+$HEIGHT)) == 0 ]]; then
++ echo "Refusing to crop $FILE with an empty rectangle."
++ exit 1
++fi
++
++TMPFILE=`mktemp $FILE.tmp-jpeg-rot-XXXXXXXX`
++if jpegtran -optimize -progressive -crop ${WIDTH}x${HEIGHT}+${XPOS}+${YPOS} \
++ -copy all $FILE > $TMPFILE; then
++ COUNT=`echo $FILE-uncropped | wc -c`
++ NEXT=$((`ls $FILE-uncropped* | cut -b $COUNT- | grep '^[0-9]*$' \
++ | sed 's/^0*/'/ | sort -n | tail -n 1`+1))
++ # the targets shouldn't exist, but -i just in case
++ mv -i $FILE $FILE-uncropped$NEXT
++ mv -i $TMPFILE $FILE
++else
++ rm $TMPFILE
++fi
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/jpegeditcom.sh xv-3.10a/contrib/fnkey-scripts/jpegeditcom.sh
+--- xv-3.10a.orig/contrib/fnkey-scripts/jpegeditcom.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/jpegeditcom.sh 2007-01-16 00:23:04.000000000 -0600
+@@ -0,0 +1,12 @@
++#!/bin/bash
++CFILE=`mktemp $1.tmp-jpeg-comments-XXXXXXXX`
++TMPFILE=`mktemp $1.tmp-jpeg-XXXXXXXX`
++rdjpgcom $1 > $CFILE
++INITIAL=`md5sum $CFILE`
++xterm -e "$EDITOR" "$CFILE" # customize your editor here
++MODIFIED=`md5sum $CFILE`
++if [[ "$INITIAL" != "$MODIFIED" ]]; then
++ mv $1 $TMPFILE
++ wrjpgcom -replace -cfile $CFILE $TMPFILE > $1
++fi
++rm $TMPFILE $CFILE $CFILE~
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/jpeglogrot.sh xv-3.10a/contrib/fnkey-scripts/jpeglogrot.sh
+--- xv-3.10a.orig/contrib/fnkey-scripts/jpeglogrot.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/jpeglogrot.sh 2007-01-16 00:55:18.000000000 -0600
+@@ -0,0 +1,10 @@
++#!/bin/bash
++curdir="`pwd`"
++LOG=~/photos/bin/rotscript # customize your install dir here
++if [[ ! -e "$LOG" ]]; then
++ echo '#!/bin/bash' >> "$LOG"
++ chmod u+x "$LOG"
++fi
++echo "# following entry made on `date`" >> "$LOG"
++# also customize the following line
++echo ~/photos/bin/jpegrot \""$1"\" \""$curdir/$2"\" >> "$LOG"
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/jpegrot.sh xv-3.10a/contrib/fnkey-scripts/jpegrot.sh
+--- xv-3.10a.orig/contrib/fnkey-scripts/jpegrot.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/jpegrot.sh 2006-07-18 23:10:43.000000000 -0500
+@@ -0,0 +1,7 @@
++#!/bin/bash
++TMPFILE="`mktemp "$2".tmp-jpeg-rot-XXXXXXXX`"
++if jpegtran -perfect -optimize -progressive -rotate "$1" -copy all "$2" > "$TMPFILE"; then
++ mv "$TMPFILE" "$2"
++else
++ rm "$TMPFILE"
++fi
+diff -u -r --new-file xv-3.10a.orig/contrib/fnkey-scripts/jpegundocrop.sh xv-3.10a/contrib/fnkey-scripts/jpegundocrop.sh
+--- xv-3.10a.orig/contrib/fnkey-scripts/jpegundocrop.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/contrib/fnkey-scripts/jpegundocrop.sh 2006-03-11 21:30:04.000000000 -0600
+@@ -0,0 +1,8 @@
++#!/bin/bash
++FILE=$1
++COUNT=`echo $FILE-uncropped | wc -c`
++LATEST=$((`ls $FILE-uncropped* | cut -b $COUNT- | grep '^[0-9]*$' \
++ | sed 's/^0*/'/ | sort -n | tail -n 1`))
++if [[ -f $FILE-uncropped$LATEST ]]; then
++ mv $FILE-uncropped$LATEST $FILE
++fi
+diff -u -r --new-file xv-3.10a.orig/tiff/RANLIB.sh xv-3.10a/tiff/RANLIB.sh
+--- xv-3.10a.orig/tiff/RANLIB.sh 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/tiff/RANLIB.sh 2004-05-11 01:31:38.000000000 -0500
+@@ -0,0 +1,22 @@
++#!/bin/sh -f
++#
++# tests to see if the program 'ranlib' exists. If it does, runs ranlib on
++# the first argument (a library name). Otherwise, does nothing, and returns
++#
++# written by John Bradley for the XV 3.00 release
++# thanks to John Hagan for shell-script hackery
++#
+
-+#ifdef HAVE_PIC2
-+/* stuff used for 'pic2' box */
-+WHERE Window pic2W;
-+WHERE int pic2Up; /* is pic2W mapped, or what? */
-+#endif /* HAVE_PIC2 */
++echo "executing 'ranlib $1'..."
+
-+#ifdef HAVE_PCD
-+/* stuff used for 'pcd' box */
-+WHERE Window pcdW;
-+WHERE int pcdUp; /* is pcdW mapped, or what? */
-+#endif /* HAVE_PCD */
++# Is there a ranlib? Let's try and then suffer the consequences...
++ranlib $1 >& /dev/null
+
-+#ifdef HAVE_MGCSFX
-+/* stuff used for 'mgcsfx' box */
-+WHERE Window mgcsfxW;
-+WHERE Window mgcsfxNameW;
-+WHERE int mgcsfxUp; /* is mgcsfxW mapped, or what? */
-+#endif /* HAVE_MGCSFX */
++if [ $? -ne 0 ]; then
++ echo "There doesn't seem to be a ranlib on this system..."
++ echo "Don't worry about it."
++fi
+
-+#ifdef TV_L10N
-+/* stuff used for TextViewer Japanization */
-+# define LOCALE_USASCII 0
-+# define LOCALE_EUCJ 1
-+# define LOCALE_JIS 2
-+# define LOCALE_MSCODE 3
-+
-+# ifndef LOCALE_DEFAULT
-+# define LOCALE_DEFAULT 0
-+# endif /* !LOCALE_DEFAULT */
-+
-+# ifndef MAIN
-+ extern char *localeList[];
-+# else
-+# ifndef LOCALE_NAME_EUC
-+# ifndef X_LOCALE
-+# if defined(__FreeBSD__)
-+ char *localeList[] = {"", "ja_JP.EUC", "none", "none"};
-+# elif defined(__linux__)
-+ char *localeList[] = {"", "ja_JP.eucJP", "none", "ja_JP.SJIS"};
-+# elif defined(__sun) || defined(sun)
-+ char *localeList[] = {"", "ja", "none", "none"};
-+# elif defined(__sgi) /* sgi, __sgi, __sgi__ (gcc) */
-+ char *localeList[] = {"", "ja_JP.EUC", "none", "none"};
-+# elif defined(sony_news)
-+ char *localeList[] = {"", "ja_JP.EUC", "none", "ja_JP.SJIS"};
-+# elif defined(nec)
-+ char *localeList[] = {"", "japan", "none", "none"};
-+# elif defined(__hpux)
-+ char *localeList[] = {"", "japanese.euc", "none", "japanese"};
-+# elif defined(__osf__)
-+ char *localeList[] = {"", "ja_JP.deckanji", "none", "ja_JP.SJIS"};
-+# elif defined(_AIX)
-+ char *localeList[] = {"", "ja_JP", "none", "Ja_JP" };
-+# elif defined(__bsdi)
-+ char *localeList[] = {"", "Japanese-EUC", "none", "none" };
-+# else
-+ char *localeList[] = {"", "ja_JP.EUC", "ja_JP.JIS", "ja_JP.SJIS"};
-+# endif
-+# else
-+# if (XlibSpecificationRelease > 5)
-+ char *localeList[] = {"", "ja_JP.eucJP", "ja_JP.JIS7",
-+ "ja_JP.SJIS"};
-+# else
-+ char *localeList[] = {"", "ja_JP.ujis", "ja_JP.jis7",
-+ "ja_JP.mscode"};
-+# endif
-+# endif /* X_LOCALE */
-+# else
-+ char *localeList[] = {"", LOCALE_NAME_EUC,
-+ LOCALE_NAME_JIS, LOCALE_NAME_MSCODE};
-+# endif /* LOCALE_NAME_EUC */
-+# endif /* MAIN */
-+#endif /* TV_L10N */
-+
- #undef WHERE
-
-
-@@ -1199,8 +1448,11 @@
- /****************************** XV.C ****************************/
- int ReadFileType PARM((char *));
- int ReadPicFile PARM((char *, int, PICINFO *, int));
--int UncompressFile PARM((char *, char *));
-+int UncompressFile PARM((char *, char *, int));
- void KillPageFiles PARM((char *, int));
-+#ifdef MACBINARY
-+int RemoveMacbinary PARM((char *, char *));
-+#endif
-
- void NewPicGetColors PARM((int, int));
- void FixAspect PARM((int, int *, int *));
-@@ -1429,6 +1681,9 @@
- int CheckPoll PARM((int));
- void DIRDeletedFile PARM((char *));
- void DIRCreatedFile PARM((char *));
-+FILE *pic2_OpenOutFile PARM((char *, int *));
-+void pic2_KillNullFile PARM((FILE *));
-+int OpenOutFileDesc PARM((char *));
-
-
- /*************************** XVBROWSE.C ************************/
-@@ -1448,7 +1703,7 @@
-
- /*************************** XVTEXT.C ************************/
- void CreateTextWins PARM((char *, char *));
--void TextView PARM((char *));
-+int TextView PARM((char *));
- void OpenTextView PARM((char *, int, char *, int));
-
- void OpenCommentText PARM((void));
-@@ -1466,6 +1721,8 @@
- int TextCheckEvent PARM((XEvent *, int *, int *));
- int TextDelWin PARM((Window));
-
-+int CharsetCheckEvent PARM((XEvent *));
-+int CharsetDelWin PARM((Window));
-
-
- /**************************** XVGAM.C **************************/
-@@ -1502,12 +1759,12 @@
-
-
- /*************************** XVDIAL.C ***************************/
--void DCreate PARM((DIAL *, Window, int, int, int, int, int,
-- int, int, int, u_long, u_long, u_long,
-- u_long, char *, char *));
-+void DCreate PARM((DIAL *, Window, int, int, int, int, double,
-+ double, double, double, double, u_long,
-+ u_long, u_long, u_long, char *, char *));
-
--void DSetRange PARM((DIAL *, int, int, int, int));
--void DSetVal PARM((DIAL *, int));
-+void DSetRange PARM((DIAL *, double,double,double,double,double));
-+void DSetVal PARM((DIAL *, double));
- void DSetActive PARM((DIAL *, int));
- void DRedraw PARM((DIAL *));
- int DTrack PARM((DIAL *, int, int));
-@@ -1585,7 +1842,11 @@
- byte *, byte *, int, int, char *));
-
- /**************************** XVPBM.C ***************************/
-+#ifdef HAVE_MGCSFX
-+int LoadPBM PARM((char *, PICINFO *, int));
-+#else
- int LoadPBM PARM((char *, PICINFO *));
-+#endif
- int WritePBM PARM((FILE *, byte *, int, int, int, byte *,
- byte *, byte *, int, int, int, char *));
-
-@@ -1604,6 +1865,11 @@
- int WriteBMP PARM((FILE *, byte *, int, int, int, byte *,
- byte *, byte *, int, int));
-
-+/**************************** XVWBMP.C ***************************/
-+int LoadWBMP PARM((char *, PICINFO *));
-+int WriteWBMP PARM((FILE *, byte *, int, int, int, byte *,
-+ byte *, byte *, int, int));
-+
- /**************************** XVRLE.C ***************************/
- int LoadRLE PARM((char *, PICINFO *));
-
-@@ -1642,6 +1908,7 @@
- void JPEGDialog PARM((int));
- int JPEGCheckEvent PARM((XEvent *));
- void JPEGSaveParams PARM((char *, int));
-+void VersionInfoJPEG PARM((void)); /* GRR 19980605 */
-
- /**************************** XVTIFF.C ***************************/
- int LoadTIFF PARM((char *, PICINFO *, int));
-@@ -1649,6 +1916,15 @@
- void TIFFDialog PARM((int));
- int TIFFCheckEvent PARM((XEvent *));
- void TIFFSaveParams PARM((char *, int));
-+void VersionInfoTIFF PARM((void)); /* GRR 19980605 */
-+
-+/**************************** XVPNG.C ***************************/
-+int LoadPNG PARM((char *, PICINFO *));
-+void CreatePNGW PARM((void));
-+void PNGDialog PARM((int));
-+int PNGCheckEvent PARM((XEvent *));
-+void PNGSaveParams PARM((char *, int));
-+void VersionInfoPNG PARM((void)); /* GRR 19980605 */
-
- /**************************** XVPDS.C ***************************/
- int LoadPDS PARM((char *, PICINFO *));
-@@ -1661,6 +1937,87 @@
- void PSResize PARM((void));
- int LoadPS PARM((char *, PICINFO *, int));
-
-+/************************ [JCE] XVZX.C ***************************/
-+
-+int LoadZX PARM((char *, PICINFO *));
-+int WriteZX PARM((FILE *, byte *, int, int, int, byte *,
-+ byte *, byte *, int, int, char *));
-+
-+/**************************** XVPCD.C ***************************/
-+int LoadPCD PARM((char *, PICINFO *, int));
-+void CreatePCDW PARM((void));
-+void PCDDialog PARM((int));
-+int PCDCheckEvent PARM((XEvent *));
-+void PCDSetParamOptions PARM((char *));
-+
-+/*************************** XVMAG.C ***************************/
-+int LoadMAG PARM((char *, PICINFO *));
-+int WriteMAG PARM((FILE *, byte *, int, int, int,
-+ byte *, byte *, byte *, int, int, char *));
-+
-+/*************************** XVMAKI.C ***************************/
-+int LoadMAKI PARM((char *, PICINFO *));
-+int WriteMAKI PARM((FILE *, byte *, int, int, int,
-+ byte *, byte *, byte *, int, int));
-+
-+/*************************** XVPIC.C ***************************/
-+int LoadPIC PARM((char *, PICINFO *));
-+int WritePIC PARM((FILE *, byte *, int, int, int,
-+ byte *, byte *, byte *, int, int, char *));
-+
-+/*************************** XVPI.C ***************************/
-+int LoadPi PARM((char *, PICINFO *));
-+int WritePi PARM((FILE *, byte *, int, int, int,
-+ byte *, byte *, byte *, int, int, char *));
-+
-+/*************************** XVPIC2.C ***************************/
-+int LoadPIC2 PARM((char *, PICINFO *, int));
-+void CreatePIC2W PARM((void));
-+void PIC2Dialog PARM((int));
-+int PIC2CheckEvent PARM((XEvent *));
-+int PIC2SetParamOptions PARM((char *));
-+
-+/**************************** XVPCD.C ***************************/
-+int LoadPCD PARM((char *, PICINFO *,int));
-+void CreatePCDW PARM((void));
-+void PCDDialog PARM((int));
-+int PCDCheckEvent PARM((XEvent *));
-+void PCDSetParamOptions PARM((char *));
-+
-+/**************************** XVHIPS.C ***************************/
-+int LoadHIPS PARM((char *, PICINFO *));
-+
-+/*************************** XVMGCSFX.C ***************************/
-+int is_mgcsfx PARM((char *, unsigned char *, int));
-+char *mgcsfx_auto_input_com PARM((char *));
-+int LoadMGCSFX PARM((char *, PICINFO *));
-+void CreateMGCSFXW PARM((void));
-+void MGCSFXDialog PARM((int));
-+int MGCSFXCheckEvent PARM((XEvent *));
-+int MGCSFXSaveParams PARM((char *, int));
++echo ""
++echo ""
+
-+int getInputCom PARM((void));
-+int getOutputCom PARM((void));
-+
-+/**************************** XVVD.C ****************************/
-+void Vdinit PARM((void));
-+void Vdsettle PARM((void));
-+int Chvdir PARM((char *));
-+void Dirtovd PARM((char *));
-+void Vdtodir PARM((char *));
-+void Dirtosubst PARM((char *));
-+int Mkvdir PARM((char *));
-+void Mkvdir_force PARM((char *));
-+int Rmvdir PARM((char *));
-+int Movevdir PARM((char *, char *));
-+int Isarchive PARM((char *));
-+int Isvdir PARM((char *));
-+void vd_HUPhandler PARM((void));
-+void vd_handler PARM((int));
-+int vd_Xhandler PARM((Display *, XErrorEvent *));
-+int vd_XIOhandler PARM((Display *));
-+void vd_handler_setup PARM((void));
-+
- /*************************** XVPOPUP.C ***************************/
- void CenterMapWindow PARM((Window, int, int, int, int));
- int PopUp PARM((char *, char **, int));
-@@ -1714,3 +2071,13 @@
- void CoordP2E PARM((int, int, int *, int *));
- void CoordE2P PARM((int, int, int *, int *));
-
-+#if defined(__mips) && defined(__SYSTYPE_BSD43)
-+# define strstr(A,B) pds_strstr((A),(B))
-+# undef S_IFIFO
-+#endif /* !mips_bsd */
-+
-+#ifndef SEEK_SET
-+# define SEEK_SET 0
-+# define SEEK_CUR 1
-+# define SEEK_END 2
-+#endif
-diff -ruN xv-3.10a-bugfixes/xv_mgcsfx.sample xv-3.10a-enhancements/xv_mgcsfx.sample
---- xv-3.10a-bugfixes/xv_mgcsfx.sample 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xv_mgcsfx.sample 2005-04-17 14:04:22.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xv_mgcsfx.sample xv-3.10a/xv_mgcsfx.sample
+--- xv-3.10a.orig/xv_mgcsfx.sample 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xv_mgcsfx.sample 2005-04-17 16:04:22.000000000 -0500
@@ -0,0 +1,125 @@
+#/*
+# Configuration file for XV with recognition of 'Magic and Suffix'
@@ -4344,4166 +1538,9 @@ diff -ruN xv-3.10a-bugfixes/xv_mgcsfx.sample xv-3.10a-enhancements/xv_mgcsfx.sam
+# /* SGI(1):magic:0:\x01\xda:.rgb:::: */
+# /* SGI(2):magic:0:\xda\x01:.rgb:::: */
+# /* XWD:magic:0:\0\0\0\7: :::: */
-diff -ruN xv-3.10a-bugfixes/xvbmp.c xv-3.10a-enhancements/xvbmp.c
---- xv-3.10a-bugfixes/xvbmp.c 2005-03-27 18:12:17.000000000 -0800
-+++ xv-3.10a-enhancements/xvbmp.c 2005-04-17 13:56:31.000000000 -0700
-@@ -1,5 +1,5 @@
- /*
-- * xvbmp.c - i/o routines for .BMP files (MS Windows 3.x)
-+ * xvbmp.c - I/O routines for .BMP files (MS Windows 3.x and later; OS/2)
- *
- * LoadBMP(fname, numcols)
- * WriteBMP(fp, pic, ptype, w, h, r, g, b, numcols, style);
-@@ -9,30 +9,39 @@
-
- #include "xv.h"
-
--/* comments on error handling:
-- a truncated file is not considered a Major Error. The file is loaded, the
-- rest of the pic is filled with 0's.
--
-- a file with garbage characters in it is an unloadable file. All allocated
-- stuff is tossed, and LoadBMP returns non-zero
--
-- not being able to malloc is a Fatal Error. The program is aborted. */
--
--
--#define BI_RGB 0
--#define BI_RLE8 1
--#define BI_RLE4 2
-+/* Comments on error-handling:
-+ A truncated file is not considered a Major Error. The file is loaded,
-+ and the rest of the pic is filled with 0's.
-+
-+ A file with garbage characters in it is an unloadable file. All allocated
-+ stuff is tossed, and LoadBMP returns non-zero.
-+
-+ Not being able to malloc is a Fatal Error. The program is aborted. */
-+
-+
-+#define BI_RGB 0 /* a.k.a. uncompressed */
-+#define BI_RLE8 1
-+#define BI_RLE4 2
-+#define BI_BITFIELDS 3 /* BMP version 4 */
-+#define BI_JPEG 4 /* BMP version 5 (not yet supported) */
-+#define BI_PNG 5 /* BMP version 5 (not yet supported) */
-
- #define WIN_OS2_OLD 12
- #define WIN_NEW 40
- #define OS2_NEW 64
-
-+#if (defined(UINT_MAX) && UINT_MAX != 0xffffffffU)
-+# error XV's BMP code requires 32-bit unsigned integer type, but u_int isn't
-+#endif
-+
- static long filesize;
-
- static int loadBMP1 PARM((FILE *, byte *, u_int, u_int));
- static int loadBMP4 PARM((FILE *, byte *, u_int, u_int, u_int));
- static int loadBMP8 PARM((FILE *, byte *, u_int, u_int, u_int));
--static int loadBMP24 PARM((FILE *, byte *, u_int, u_int));
-+static int loadBMP16 PARM((FILE *, byte *, u_int, u_int, u_int *));
-+static int loadBMP24 PARM((FILE *, byte *, u_int, u_int, u_int));
-+static int loadBMP32 PARM((FILE *, byte *, u_int, u_int, u_int *));
- static u_int getshort PARM((FILE *));
- static u_int getint PARM((FILE *));
- static void putshort PARM((FILE *, int));
-@@ -52,15 +61,14 @@
- PICINFO *pinfo;
- /*******************************************/
- {
-- FILE *fp;
-- int i, c, c1, rv;
-- u_int bfSize, bfOffBits, biSize, biWidth, biHeight, biPlanes;
-- u_int biBitCount, biCompression, biSizeImage, biXPelsPerMeter;
-- u_int biYPelsPerMeter, biClrUsed, biClrImportant;
-- int bPad;
-- char *cmpstr;
-- byte *pic24, *pic8;
-- char buf[512], *bname;
-+ FILE *fp;
-+ int i, c, c1, rv, bPad;
-+ u_int bfSize, bfOffBits, biSize, biWidth, biHeight, biPlanes;
-+ u_int biBitCount, biCompression, biSizeImage, biXPelsPerMeter;
-+ u_int biYPelsPerMeter, biClrUsed, biClrImportant;
-+ u_int colormask[3];
-+ char buf[512], *bname, *cmpstr, rgb_bits[16];
-+ byte *pic24, *pic8;
-
- /* returns '1' on success */
-
-@@ -98,14 +106,13 @@
- biClrUsed = getint(fp);
- biClrImportant = getint(fp);
- }
--
- else { /* old bitmap format */
- biWidth = getshort(fp); /* Types have changed ! */
- biHeight = getshort(fp);
- biPlanes = getshort(fp);
- biBitCount = getshort(fp);
-
-- /* Not in old versions so have to compute them*/
-+ /* not in old versions, so have to compute them */
- biSizeImage = (((biPlanes * biBitCount*biWidth)+31)/32)*4*biHeight;
-
- biCompression = BI_RGB;
-@@ -126,25 +133,39 @@
- if (FERROR(fp)) { bmpError(bname,"EOF reached in file header"); goto ERROR; }
-
-
-- /* error checking */
-- if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) ||
-- biPlanes!=1 || biCompression>BI_RLE4 ||
-+ /* error-checking */
-+ if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 &&
-+ biBitCount!=16 && biBitCount!=24 && biBitCount!=32) ||
-+ biPlanes!=1 || biCompression>BI_PNG ||
- biWidth<=0 || biHeight<=0 ||
- (biClrUsed && biClrUsed > (1 << biBitCount))) {
-
- sprintf(buf,
-- "Bogus BMP File! (%dx%d, Bits=%d, Colors=%d, Planes=%d, Compr=%d)",
-+ "Unsupported BMP type (%dx%d, Bits=%d, Colors=%d, Planes=%d, "
-+ "Compr=%d)",
- biWidth, biHeight, biBitCount, biClrUsed, biPlanes, biCompression);
-
- bmpError(bname, buf);
- goto ERROR;
- }
-
-+ if (biCompression>BI_BITFIELDS) {
-+ sprintf(buf, "Unsupported BMP compression method (%s)",
-+ biCompression == BI_JPEG? "JPEG" :
-+ biCompression == BI_PNG? "PNG" :
-+ "unknown/newer than v5");
-+
-+ bmpError(bname, buf);
-+ goto ERROR;
-+ }
-+
- if (((biBitCount==1 || biBitCount==24) && biCompression != BI_RGB) ||
-- (biBitCount==4 && biCompression==BI_RLE8) ||
-- (biBitCount==8 && biCompression==BI_RLE4)) {
-+ (biBitCount==4 && biCompression!=BI_RGB && biCompression!=BI_RLE4) ||
-+ (biBitCount==8 && biCompression!=BI_RGB && biCompression!=BI_RLE8) ||
-+ ((biBitCount==16 || biBitCount==32) &&
-+ biCompression!=BI_RGB && biCompression!=BI_BITFIELDS)) {
-
-- sprintf(buf,"Bogus BMP File! (bitCount=%d, Compression=%d)",
-+ sprintf(buf,"Unsupported BMP type (bitCount=%d, Compression=%d)",
- biBitCount, biCompression);
-
- bmpError(bname, buf);
-@@ -156,20 +177,23 @@
- if (biSize != WIN_OS2_OLD) {
- /* skip ahead to colormap, using biSize */
- c = biSize - 40; /* 40 bytes read from biSize to biClrImportant */
-- for (i=0; i<c; i++) getc(fp);
--
-+ for (i=0; i<c; i++)
-+ getc(fp);
- bPad = bfOffBits - (biSize + 14);
- }
-
-+ /* 16-bit or 32-bit color mask */
-+ if (biCompression==BI_BITFIELDS) {
-+ colormask[0] = getint(fp);
-+ colormask[1] = getint(fp);
-+ colormask[2] = getint(fp);
-+ bPad -= 12;
-+ }
-+
- /* load up colormap, if any */
-- if (biBitCount!=24) {
-+ if (biBitCount == 1 || biBitCount == 4 || biBitCount == 8) {
- int i, cmaplen;
-
--/* this is superfluous; see identical test in "error checking" block above
-- if (biClrUsed > (1 << biBitCount))
-- biClrUsed = (1 << biBitCount);
-- */
--
- cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount;
- for (i=0; i<cmaplen; i++) {
- pinfo->b[i] = getc(fp);
-@@ -205,7 +229,7 @@
-
- /* create pic8 or pic24 */
-
-- if (biBitCount==24) {
-+ if (biBitCount==16 || biBitCount==24 || biBitCount==32) {
- u_int npixels = biWidth * biHeight;
- u_int count = 3 * npixels;
-
-@@ -227,19 +251,35 @@
- WaitCursor();
-
- /* load up the image */
-- if (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight);
-- else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight,
-- biCompression);
-- else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight,
-- biCompression);
-- else rv = loadBMP24(fp,pic24,biWidth,biHeight);
-+ switch (biBitCount) {
-+ case 1:
-+ rv = loadBMP1(fp, pic8, biWidth, biHeight);
-+ break;
-+ case 4:
-+ rv = loadBMP4(fp, pic8, biWidth, biHeight, biCompression);
-+ break;
-+ case 8:
-+ rv = loadBMP8(fp, pic8, biWidth, biHeight, biCompression);
-+ break;
-+ case 16:
-+ rv = loadBMP16(fp, pic24, biWidth, biHeight, /* v-- BI_RGB */
-+ biCompression == BI_BITFIELDS? colormask : NULL);
-+ break;
-+ default:
-+ if (biBitCount == 32 && biCompression == BI_BITFIELDS)
-+ rv = loadBMP32(fp, pic24, biWidth, biHeight, colormask);
-+ else /* 24 or (32 and BI_RGB) */
-+ rv = loadBMP24(fp, pic24, biWidth, biHeight, biBitCount);
-+ break;
-+ }
-
- if (rv) bmpError(bname, "File appears truncated. Winging it.");
-
-+
- fclose(fp);
-
-
-- if (biBitCount == 24) {
-+ if (biBitCount > 8) {
- pinfo->pic = pic24;
- pinfo->type = PIC24;
- }
-@@ -251,6 +291,22 @@
- cmpstr = "";
- if (biCompression == BI_RLE4) cmpstr = ", RLE4 compressed";
- else if (biCompression == BI_RLE8) cmpstr = ", RLE8 compressed";
-+ else if (biCompression == BI_BITFIELDS) {
-+ int bit, c[3], i;
-+ u_int mask;
-+
-+ for (i = 0; i < 3; ++i) {
-+ mask = colormask[i];
-+ c[i] = 0;
-+ for (bit = 0; bit < 32; ++bit) {
-+ if (mask & 1)
-+ ++c[i];
-+ mask >>= 1;
-+ }
-+ }
-+ sprintf(rgb_bits, ", RGB%d%d%d", c[0], c[1], c[2]);
-+ cmpstr = rgb_bits;
-+ }
-
- pinfo->w = biWidth; pinfo->h = biHeight;
- pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
-@@ -282,12 +338,13 @@
- u_int w,h;
- {
- int i,j,c,bitnum,padw;
-- byte *pp;
-+ byte *pp = pic8 + ((h - 1) * w);
-+ size_t l = w*h;
-
- c = 0;
- padw = ((w + 31)/32) * 32; /* 'w', padded to be a multiple of 32 */
-
-- for (i=h-1; i>=0; i--) {
-+ for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
- pp = pic8 + (i * w);
- if ((i&0x3f)==0) WaitCursor();
- for (j=bitnum=0; j<padw; j++,bitnum++) {
-@@ -316,8 +373,8 @@
- u_int w,h,comp;
- {
- int i,j,c,c1,x,y,nybnum,padw,rv;
-- byte *pp;
--
-+ byte *pp = pic8 + ((h - 1) * w);
-+ size_t l = w*h;
-
- rv = 0;
- c = c1 = 0;
-@@ -325,7 +382,7 @@
- if (comp == BI_RGB) { /* read uncompressed data */
- padw = ((w + 7)/8) * 8; /* 'w' padded to a multiple of 8pix (32 bits) */
-
-- for (i=h-1; i>=0; i--) {
-+ for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
- pp = pic8 + (i * w);
- if ((i&0x3f)==0) WaitCursor();
-
-@@ -353,7 +410,7 @@
-
- if (c) { /* encoded mode */
- c1 = getc(fp);
-- for (i=0; i<c; i++,x++,pp++)
-+ for (i=0; i<c && (pp - pic8 <= l); i++,x++,pp++)
- *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
- }
-
-@@ -373,7 +430,7 @@
- }
-
- else { /* absolute mode */
-- for (i=0; i<c; i++, x++, pp++) {
-+ for (i=0; i<c && (pp - pic8 <= l); i++, x++, pp++) {
- if ((i&1) == 0) c1 = getc(fp);
- *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
- }
-@@ -402,14 +459,18 @@
- u_int w,h,comp;
- {
- int i,j,c,c1,padw,x,y,rv;
-- byte *pp;
-+ byte *pp = pic8 + ((h - 1) * w);
-+ size_t l = w*h;
-+ byte *pend;
-
- rv = 0;
-
-+ pend = pic8 + w * h;
-+
- if (comp == BI_RGB) { /* read uncompressed data */
- padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */
-
-- for (i=h-1; i>=0; i--) {
-+ for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
- pp = pic8 + (i * w);
- if ((i&0x3f)==0) WaitCursor();
-
-@@ -425,12 +486,12 @@
- x = y = 0;
- pp = pic8 + x + (h-y-1)*w;
-
-- while (y<h) {
-+ while (y<h && pp<=pend) {
- c = getc(fp); if (c == EOF) { rv = 1; break; }
-
- if (c) { /* encoded mode */
- c1 = getc(fp);
-- for (i=0; i<c; i++,x++,pp++) *pp = c1;
-+ for (i=0; i<c && pp<=pend; i++,x++,pp++) *pp = c1;
- }
-
- else { /* c==0x00 : escape codes */
-@@ -449,7 +510,7 @@
- }
-
- else { /* absolute mode */
-- for (i=0; i<c; i++, x++, pp++) {
-+ for (i=0; i<c && pp<=pend; i++, x++, pp++) {
- c1 = getc(fp);
- *pp = c1;
- }
-@@ -472,26 +533,133 @@
-
-
- /*******************************************/
--static int loadBMP24(fp, pic24, w, h)
-+static int loadBMP16(fp, pic24, w, h, mask)
-+ FILE *fp;
-+ byte *pic24;
-+ u_int w, h, *mask;
-+{
-+ int x, y;
-+ byte *pp = pic24 + ((h - 1) * w * 3);
-+ size_t l = w*h*3;
-+ u_int buf, colormask[6];
-+ int i, bit, bitshift[6], colorbits[6], bitshift2[6];
-+
-+ if (mask == NULL) { /* RGB555 */
-+ colormask[0] = 0x00007c00;
-+ colormask[1] = 0x000003e0;
-+ colormask[2] = 0x0000001f;
-+ colormask[3] = 0x7c000000;
-+ colormask[4] = 0x03e00000;
-+ colormask[5] = 0x001f0000;
-+ bitshift[0] = 7; bitshift2[0] = 0;
-+ bitshift[1] = 2; bitshift2[1] = 0;
-+ bitshift[2] = 0; bitshift2[2] = 3;
-+ bitshift[3] = 23; bitshift2[3] = 0;
-+ bitshift[4] = 18; bitshift2[4] = 0;
-+ bitshift[5] = 13; bitshift2[5] = 0;
-+ } else {
-+ colormask[0] = mask[0];
-+ colormask[1] = mask[1];
-+ colormask[2] = mask[2];
-+ colormask[3] = (mask[0] & 0xffff) << 16;
-+ colormask[4] = (mask[1] & 0xffff) << 16;
-+ colormask[5] = (mask[2] & 0xffff) << 16;
-+
-+ for (i = 0; i < 3; ++i) {
-+ buf = colormask[i];
-+
-+ bitshift[i] = 0;
-+ for (bit = 0; bit < 32; ++bit) {
-+ if (buf & 1)
-+ break;
-+ else
-+ ++bitshift[i];
-+ buf >>= 1;
-+ }
-+ bitshift[i+3] = bitshift[i] + 16;
-+
-+ colorbits[i] = 0;
-+ for (; bit < 32; ++bit) {
-+ if (buf & 1)
-+ ++colorbits[i];
-+ else
-+ break;
-+ buf >>= 1;
-+ }
-+ if (colorbits[i] > 8) { /* over 8-bit depth */
-+ bitshift[i] += (colorbits[i] - 8);
-+ bitshift[i+3] = bitshift[i] + 16;
-+ bitshift2[i] = bitshift2[i+3] = 0;
-+ } else
-+ bitshift2[i] = bitshift2[i+3] = 8 - colorbits[i];
-+ }
-+ }
-+
-+ if (DEBUG > 1)
-+ fprintf(stderr, "loadBMP16: bitfields\n"
-+ "\tR: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n"
-+ "\t (mask = %08x, shift >>%2d, <<%2d)\n"
-+ "\tG: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n"
-+ "\t (mask = %08x, shift >>%2d, <<%2d)\n"
-+ "\tB: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n"
-+ "\t (mask = %08x, shift >>%2d, <<%2d)\n",
-+ colorbits[0], colormask[0], bitshift[0], bitshift2[0],
-+ colormask[3], bitshift[3], bitshift2[3],
-+ colorbits[1], colormask[1], bitshift[1], bitshift2[1],
-+ colormask[4], bitshift[4], bitshift2[4],
-+ colorbits[2], colormask[2], bitshift[2], bitshift2[2],
-+ colormask[5], bitshift[5], bitshift2[5]);
-+
-+ for (y = h-1; y >= 0 && (pp - pic24 <= l); y--) {
-+ pp = pic24 + (3 * w * y);
-+ if ((y&0x3f)==0) WaitCursor();
-+
-+ for (x = w; x > 1; x -= 2) {
-+ buf = getint(fp);
-+ *(pp++) = (buf & colormask[0]) >> bitshift[0] << bitshift2[0];
-+ *(pp++) = (buf & colormask[1]) >> bitshift[1] << bitshift2[1];
-+ *(pp++) = (buf & colormask[2]) >> bitshift[2] << bitshift2[2];
-+ *(pp++) = (buf & colormask[3]) >> bitshift[3] << bitshift2[3];
-+ *(pp++) = (buf & colormask[4]) >> bitshift[4] << bitshift2[4];
-+ *(pp++) = (buf & colormask[5]) >> bitshift[5] << bitshift2[5];
-+ }
-+ if (w & 1) { /* padded to 2 pix */
-+ buf = getint(fp);
-+ *(pp++) = (buf & colormask[0]) >> bitshift[0];
-+ *(pp++) = (buf & colormask[1]) >> bitshift[1];
-+ *(pp++) = (buf & colormask[2]) >> bitshift[2];
-+ }
-+ }
-+
-+ return FERROR(fp)? 1 : 0;
-+}
-+
-+
-+
-+/*******************************************/
-+static int loadBMP24(fp, pic24, w, h, bits) /* also handles 32-bit BI_RGB */
- FILE *fp;
- byte *pic24;
-- u_int w,h;
-+ u_int w,h, bits;
- {
- int i,j,padb,rv;
-- byte *pp;
-+ byte *pp = pic24 + ((h - 1) * w * 3);
-+ size_t l = w*h*3;
-
- rv = 0;
-
- padb = (4 - ((w*3) % 4)) & 0x03; /* # of pad bytes to read at EOscanline */
-+ if (bits==32) padb = 0;
-
- for (i=h-1; i>=0; i--) {
- pp = pic24 + (i * w * 3);
- if ((i&0x3f)==0) WaitCursor();
-
-- for (j=0; j<w; j++) {
-+ for (j=0; j<w && (pp - pic24 <= l); j++) {
- pp[2] = getc(fp); /* blue */
- pp[1] = getc(fp); /* green */
- pp[0] = getc(fp); /* red */
-+ if (bits==32) getc(fp);
- pp += 3;
- }
-
-@@ -507,6 +675,70 @@
-
-
- /*******************************************/
-+static int loadBMP32(fp, pic24, w, h, colormask) /* 32-bit BI_BITFIELDS only */
-+ FILE *fp;
-+ byte *pic24;
-+ u_int w, h, *colormask;
-+{
-+ int x, y;
-+ byte *pp;
-+ u_int buf;
-+ int i, bit, bitshift[3], colorbits[3], bitshift2[3];
-+
-+ for (i = 0; i < 3; ++i) {
-+ buf = colormask[i];
-+
-+ bitshift[i] = 0;
-+ for (bit = 0; bit < 32; ++bit) {
-+ if (buf & 1)
-+ break;
-+ else
-+ ++bitshift[i];
-+ buf >>= 1;
-+ }
-+
-+ colorbits[i] = 0;
-+ for (; bit < 32; ++bit) {
-+ if (buf & 1)
-+ ++colorbits[i];
-+ else
-+ break;
-+ buf >>= 1;
-+ }
-+ if (colorbits[i] > 8) { /* over 8-bit depth */
-+ bitshift[i] += (colorbits[i] - 8);
-+ bitshift2[i] = 0;
-+ } else
-+ bitshift2[i] = 8 - colorbits[i];
-+ }
-+
-+ if (DEBUG > 1)
-+ fprintf(stderr, "loadBMP32: bitfields\n"
-+ "\tR: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n"
-+ "\tG: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n"
-+ "\tB: bits = %2d, mask = %08x, shift >>%2d, <<%2d\n",
-+ colorbits[0], colormask[0], bitshift[0], bitshift2[0],
-+ colorbits[1], colormask[1], bitshift[1], bitshift2[1],
-+ colorbits[2], colormask[2], bitshift[2], bitshift2[2]);
-+
-+ for (y = h-1; y >= 0; y--) {
-+ pp = pic24 + (3 * w * y);
-+ if ((y&0x3f)==0) WaitCursor();
-+
-+ for(x = w; x > 0; x --) {
-+ buf = getint(fp);
-+ *(pp++) = (buf & colormask[0]) >> bitshift[0] << bitshift2[0];
-+ *(pp++) = (buf & colormask[1]) >> bitshift[1] << bitshift2[1];
-+ *(pp++) = (buf & colormask[2]) >> bitshift[2] << bitshift2[2];
-+ }
-+ }
-+
-+ return FERROR(fp)? 1 : 0;
-+}
-+
-+
-+
-+/*******************************************/
- static u_int getshort(fp)
- FILE *fp;
- {
-@@ -523,7 +755,7 @@
- int c, c1, c2, c3;
- c = getc(fp); c1 = getc(fp); c2 = getc(fp); c3 = getc(fp);
- return ((u_int) c) +
-- (((u_int) c1) << 8) +
-+ (((u_int) c1) << 8) +
- (((u_int) c2) << 16) +
- (((u_int) c3) << 24);
- }
-diff -ruN xv-3.10a-bugfixes/xvbrowse.c xv-3.10a-enhancements/xvbrowse.c
---- xv-3.10a-bugfixes/xvbrowse.c 2004-05-16 18:01:25.000000000 -0700
-+++ xv-3.10a-enhancements/xvbrowse.c 2005-04-25 23:30:27.000000000 -0700
-@@ -24,6 +24,10 @@
- typedef unsigned int mode_t; /* file mode bits */
- #endif
-
-+#ifndef MAX
-+# define MAX(a,b) (((a)>(b))?(a):(b)) /* used only for wheelmouse support */
-+#endif
-+
-
- /* load up built-in icons */
- #include "bits/br_file"
-@@ -36,6 +40,7 @@
- #include "bits/br_error"
- /* #include "bits/br_unknown" commented out (near line 492) */
- #include "bits/br_cmpres"
-+#include "bits/br_bzip2"
-
- #include "bits/br_gif"
- #include "bits/br_pm"
-@@ -50,11 +55,20 @@
- #include "bits/br_tiff"
- #include "bits/br_pds"
- #include "bits/br_ps"
-+#include "bits/br_pcd"
- #include "bits/br_iff"
- #include "bits/br_targa"
- #include "bits/br_xpm"
- #include "bits/br_xwd"
- #include "bits/br_fits"
-+#include "bits/br_png"
-+#include "bits/br_zx" /* [JCE] The Spectrum+3 icon */
-+#include "bits/br_mag"
-+#include "bits/br_maki"
-+#include "bits/br_pic"
-+#include "bits/br_pi"
-+#include "bits/br_pic2"
-+#include "bits/br_mgcsfx"
-
- #include "bits/br_trash"
- #include "bits/fcurs"
-@@ -94,14 +108,23 @@
- #define BF_XPM 25
- #define BF_XWD 26
- #define BF_FITS 27
--#define BF_MAX 28 /* # of built-in icons */
-+#define BF_PNG 28
-+#define BF_ZX 29 /* [JCE] Spectrum SCREEN$ */
-+#define BF_PCD 30
-+#define BF_BZIP2 31
-+#define JP_EXT_BF (BF_BZIP2)
-+#define BF_MAG (JP_EXT_BF + 1)
-+#define BF_MAKI (JP_EXT_BF + 2)
-+#define BF_PIC (JP_EXT_BF + 3)
-+#define BF_PI (JP_EXT_BF + 4)
-+#define BF_PIC2 (JP_EXT_BF + 5)
-+#define BF_MGCSFX (JP_EXT_BF + 6)
-+#define JP_EXT_BF_END (BF_MGCSFX)
-+#define BF_MAX (JP_EXT_BF_END + 1) /* # of built-in icons */
-
- #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \
- ftyp!=BF_SOCK && ftyp!=BF_FIFO)
-
--#define DEF_BROWWIDE 615 /* default size of window */
--#define DEF_BROWHIGH 356
--
- #define SCROLLVERT 8 /* height of scroll region at top/bottom of iconw */
- #define PAGEVERT 40 /* during rect drag, if further than this, page */
-
-@@ -113,16 +136,35 @@
- #define BOTMARGIN 58 /* room for a row of buttons and a line of text */
- #define LRMARGINS 5 /* left and right margins */
-
--#define ISIZE_WIDE 80 /* maximum size of an icon */
--#define ISIZE_HIGH 60
-+/* some people like bigger icons; 4:3 aspect ratio is recommended
-+ * (NOTE: standard XV binaries will not be able to read larger icons!) */
-+#ifndef ISIZE_WIDE
-+# define ISIZE_WIDE 80 /* maximum size of an icon */
-+#endif
-+#ifndef ISIZE_HIGH
-+# define ISIZE_HIGH 60
-+#endif
-
--#define ISPACE_WIDE (ISIZE_WIDE+16) /* icon spacing */
-+#ifndef ISIZE_WPAD
-+# define ISIZE_WPAD 16 /* extra horizontal padding between icons */
-+#endif
-+
-+#ifndef INUM_WIDE
-+# define INUM_WIDE 6 /* size initial window to hold this many icons */
-+#endif
-+#ifndef INUM_HIGH
-+# define INUM_HIGH 3
-+#endif
-+
-+#define ISPACE_WIDE (ISIZE_WIDE+ISIZE_WPAD) /* icon spacing */
- #define ISPACE_TOP 4 /* dist btwn top of ISPACE and ISIZE */
- #define ISPACE_TTOP 4 /* dist btwn bot of icon and title */
- #define ISPACE_HIGH (ISIZE_HIGH+ISPACE_TOP+ISPACE_TTOP+16+4)
-
- #define DBLCLICKTIME 300 /* milliseconds */
-
-+#define COUNT(x) (sizeof (x) / sizeof (x)[0])
-+
- /* button/menu indicies */
- #define BR_CHDIR 0
- #define BR_DELETE 1
-@@ -140,12 +182,23 @@
- #define BR_NBUTTS 13 /* # of command buttons */
- #define BR_SEP1 13 /* separator */
- #define BR_HIDDEN 14
-+#ifdef AUTO_EXPAND
-+#define BR_CLEARVD 15
-+#define BR_SELFILES 16
-+#define BR_NCMDS 17 /* # of menu commands */
-+#else
- #define BR_SELFILES 15
- #define BR_NCMDS 16 /* # of menu commands */
-+#endif
-
- #define BUTTW 80
- #define BUTTH 24
-
-+/* original size of window was 615 x 356 (for 80x60 thumbnails in 6x3 array) */
-+#define DEF_BROWWIDE (ISPACE_WIDE * INUM_WIDE + LRMARGINS * 2 + 29)
-+#define DEF_BROWHIGH (ISPACE_HIGH * INUM_HIGH + BUTTH * 2 + 16 + 28)
-+/* last number is a fudge--e.g., extra spaces, borders, etc. -----^ */
-+
- static char *showHstr = "Show hidden files";
- static char *hideHstr = "Hide 'hidden' files";
-
-@@ -164,6 +217,9 @@
- "Close window\t^c",
- MBSEP,
- "Show hidden files", /* no equiv */
-+#ifdef AUTO_EXPAND
-+ "Clear virtual directory",
-+#endif
- "Select files...\t^f"
- };
-
-@@ -209,6 +265,13 @@
- } BROWINFO;
-
-
-+/* keep track of last icon visible in each path */
-+typedef struct IVIS IVIS;
-+ struct IVIS { IVIS *next;
-+ char *name;
-+ int icon;
-+ };
-+
- static Cursor movecurs, copycurs, delcurs;
- static BROWINFO binfo[MAXBRWIN];
- static Pixmap bfIcons[BF_MAX], trashPix;
-@@ -294,10 +357,16 @@
- static void cp_special PARM((struct stat *, int));
- static void cp_fifo PARM((struct stat *, int));
-
-+#ifdef AUTO_EXPAND
-+static int stat2bf PARM((u_int, char *));
-+#else
- static int stat2bf PARM((u_int));
-+#endif
-
- static int selmatch PARM((char *, char *));
- static int selmatch1 PARM((char *, char *));
-+static void recIconVisible PARM((char *, int));
-+static void restIconVisible PARM((BROWINFO *));
-
-
-
-@@ -511,9 +580,10 @@
- bfIcons[BF_JFIF]=MakePix1(br->win,br_jfif_bits,br_jfif_width,br_jfif_height);
- bfIcons[BF_TIFF]=MakePix1(br->win,br_tiff_bits,br_tiff_width,br_tiff_height);
- bfIcons[BF_PDS] =MakePix1(br->win,br_pds_bits, br_pds_width, br_pds_height);
--
-- bfIcons[BF_COMPRESS]= MakePix1(br->win, br_cmpres_bits,
-- br_cmpres_width, br_cmpres_height);
-+ bfIcons[BF_COMPRESS] = MakePix1(br->win, br_cmpres_bits,
-+ br_cmpres_width, br_cmpres_height);
-+ bfIcons[BF_BZIP2] = MakePix1(br->win, br_bzip2_bits,
-+ br_bzip2_width, br_bzip2_height);
-
- bfIcons[BF_PS] =MakePix1(br->win,br_ps_bits, br_ps_width, br_ps_height);
- bfIcons[BF_IFF] =MakePix1(br->win,br_iff_bits, br_iff_width, br_iff_height);
-@@ -524,6 +594,16 @@
- bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height);
- bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height);
- bfIcons[BF_FITS]=MakePix1(br->win,br_fits_bits,br_fits_width,br_fits_height);
-+ bfIcons[BF_PNG] =MakePix1(br->win,br_png_bits, br_png_width, br_png_height);
-+ bfIcons[BF_ZX] =MakePix1(br->win,br_zx_bits, br_zx_width, br_zx_height);
-+ bfIcons[BF_PCD] =MakePix1(br->win,br_pcd_bits, br_pcd_width, br_pcd_height);
-+ bfIcons[BF_MAG] =MakePix1(br->win,br_mag_bits, br_mag_width, br_mag_height);
-+ bfIcons[BF_MAKI]=MakePix1(br->win,br_maki_bits,br_maki_width,br_maki_height);
-+ bfIcons[BF_PIC] =MakePix1(br->win,br_pic_bits, br_pic_width, br_pic_height);
-+ bfIcons[BF_PI] =MakePix1(br->win,br_pi_bits, br_pi_width, br_pi_height);
-+ bfIcons[BF_PIC2]=MakePix1(br->win,br_pic2_bits,br_pic2_width,br_pic2_height);
-+ bfIcons[BF_MGCSFX] = MakePix1(br->win,br_mgcsfx_bits,
-+ br_mgcsfx_width,br_mgcsfx_height);
-
-
- /* check that they all got built */
-@@ -698,6 +778,9 @@
- }
- }
-
-+#ifdef VS_RESCMAP
-+static int _IfTempOut=0;
-+#endif
-
- /***************************************************************/
- void KillBrowseWindows()
-@@ -730,7 +813,6 @@
- return 0;
- }
-
--
- /***************************************************************/
- static int brChkEvent(br, xev)
- BROWINFO *br;
-@@ -745,15 +827,32 @@
-
- if (!hasBeenSized) return 0; /* ignore evrythng until we get 1st Resize */
-
-+
-+#ifdef VS_RESCMAP
-+ /* force change color map if have LocalCmap */
-+ if (browPerfect && browCmap && (_IfTempOut==2)) {
-+ int i;
-+ XSetWindowAttributes xswa;
-+
-+ xswa.colormap = LocalCmap? LocalCmap : theCmap;
-+ for (i=0; i<MAXBRWIN; ++i)
-+ XChangeWindowAttributes(theDisp, binfo[i].win, CWColormap, &xswa);
-+ XFlush(theDisp);
-+ _IfTempOut=1;
-+ }
-+#endif
-+
- if (xev->type == Expose) {
- int x,y,w,h;
- XExposeEvent *e = (XExposeEvent *) xev;
- x = e->x; y = e->y; w = e->width; h = e->height;
-
- /* throw away excess redraws for 'dumb' windows */
-- if (e->count > 0 && (e->window == br->scrl.win)) {}
-+ if (e->count > 0 && (e->window == br->scrl.win))
-+ ;
-
-- else if (e->window == br->scrl.win) SCRedraw(&(br->scrl));
-+ else if (e->window == br->scrl.win)
-+ SCRedraw(&(br->scrl));
-
- else if (e->window == br->win || e->window == br->iconW) { /* smart wins */
- /* group individual expose rects into a single expose region */
-@@ -806,13 +905,57 @@
- int i,x,y;
- x = e->x; y = e->y;
-
-- if (e->button == Button1) {
-+#ifdef VS_RESCMAP
-+ if (browCmap && browPerfect && (_IfTempOut!=0))
-+ {
-+ XSetWindowAttributes xswa;
-+ _IfTempOut--;
-+ xswa.colormap = browCmap;
-+ for(i=0;i<MAXBRWIN;i++)
-+ XChangeWindowAttributes(theDisp, binfo[i].win, CWColormap, &xswa);
-+ XFlush(theDisp);
-+ }
-+
-+#endif
-+
-+ if (e->button == Button1) {
- if (e->window == br->win) clickBrow(br,x,y);
- else if (e->window == br->scrl.win) SCTrack(&(br->scrl),x,y);
- else if (e->window == br->iconW) {
- i = clickIconWin(br, x,y,(unsigned long) e->time,
- (e->state&ControlMask) || (e->state&ShiftMask));
--
-+ }
-+ else rv = 0;
-+ }
-+ else if (e->button == Button4) { /* note min vs. max, + vs. - */
-+ /* scroll regardless of where we are in the browser window */
-+ if (e->window == br->win ||
-+ e->window == br->scrl.win ||
-+ e->window == br->iconW)
-+ {
-+ SCRL *sp=&(br->scrl);
-+ int halfpage=MAX(1,sp->page/2); /* user resize to 1 line? */
-+
-+ if (sp->val > sp->min+halfpage)
-+ SCSetVal(sp,sp->val-halfpage);
-+ else
-+ SCSetVal(sp,sp->min);
-+ }
-+ else rv = 0;
-+ }
-+ else if (e->button == Button5) { /* note max vs. min, - vs. + */
-+ /* scroll regardless of where we are in the browser window */
-+ if (e->window == br->win ||
-+ e->window == br->scrl.win ||
-+ e->window == br->iconW)
-+ {
-+ SCRL *sp=&(br->scrl);
-+ int halfpage=MAX(1,sp->page/2); /* user resize to 1 line? */
-+
-+ if (sp->val < sp->max-halfpage)
-+ SCSetVal(sp,sp->val+halfpage);
-+ else
-+ SCSetVal(sp,sp->max);
- }
- else rv = 0;
- }
-@@ -1101,6 +1244,10 @@
- case BR_SELFILES: doSelFilesCmd(br); break;
-
- case BR_RECURSUP: doRecurseCmd(br); break;
-+
-+#ifdef AUTO_EXPAND
-+ case BR_CLEARVD: Vdsettle(); break;
-+#endif
- }
- }
-
-@@ -1250,6 +1397,18 @@
- int i, allowtext;
-
- if (!nostr) setSelInfoStr(br, sel);
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(br->path)) {
-+ BTSetActive(&br->but[BR_DELETE], 0);
-+ br->cmdMB.dim[BR_DELETE] = 1;
-+
-+ BTSetActive(&br->but[BR_RENAME], 0);
-+ br->cmdMB.dim[BR_RENAME] = 1;
-+
-+ BTSetActive(&br->but[BR_MKDIR], 0);
-+ br->cmdMB.dim[BR_MKDIR] = 1;
-+ } else {
-+#endif
- BTSetActive(&br->but[BR_DELETE], br->numlit>0);
- br->cmdMB.dim[BR_DELETE] = !(br->numlit>0);
-
-@@ -1258,6 +1417,11 @@
-
- BTSetActive(&br->but[BR_GENICON], br->numlit>0);
- br->cmdMB.dim[BR_GENICON] = !(br->numlit>0);
-+#ifdef AUTO_EXPAND
-+ BTSetActive(&br->but[BR_MKDIR], 1);
-+ br->cmdMB.dim[BR_MKDIR] = 0;
-+ }
-+#endif
-
- /* turn on 'text view' cmd if exactly one non-dir is lit */
- allowtext = 0;
-@@ -1318,8 +1482,11 @@
- struct stat st;
-
- sprintf(buf, "%s%s", br->path, bf->name); /* build filename */
-+#ifdef AUTO_EXPAND
-+ Dirtovd(buf);
-+#endif
- if (stat(buf, &st) == 0) {
-- sprintf(buf, "%s: %ld bytes", bf->name, st.st_size);
-+ sprintf(buf, "%s: %ld bytes", bf->name, (long)st.st_size);
- strcat(buf, buf1);
- }
- }
-@@ -1598,6 +1765,10 @@
- {
- int sval, first, numvis;
-
-+ /* if we know what path we have, remember last visible icon for this path */
-+ if (br->path)
-+ recIconVisible(br->path, num);
-+
- /* if icon #i isn't visible, adjust scrollbar so it *is* */
-
- sval = br->scrl.val;
-@@ -1649,29 +1820,14 @@
- return;
- }
-
--
- /***************************************************************/
--static int clickIconWin(br, mx, my, mtime, multi)
-- BROWINFO *br;
-- int mx,my,multi;
-- unsigned long mtime;
-+static int updateSel(br, sel, multi, mtime)
-+ BROWINFO *br;
-+ int sel, multi;
-+ unsigned long mtime;
- {
-- /* returns '-1' normally, returns an index into bfList[] if the user
-- double-clicks an icon */
--
-- int i,j, rv, sel, cpymode, dodel;
-- BROWINFO *destBr;
-- BFIL *bf;
-- char buf[256], *destFolderName;
--
-- rv = -1; /* default return value */
-- if (!br->bfList || !br->bfLen) return rv;
--
-- destBr = br; destFolderName = ".";
--
-- sel = mouseInWhichIcon(br, mx, my);
--
-- dodel = 0;
-+ int i;
-+ BFIL *bf;
-
- if (sel == -1) { /* clicked on nothing */
- if (!multi) { /* deselect all */
-@@ -1728,11 +1884,12 @@
-
-
- /* see if we've double-clicked something */
-- if (sel==br->lastIconClicked && mtime-br->lastClickTime < DBLCLICKTIME) {
-+ if (mtime &&
-+ sel==br->lastIconClicked && mtime-br->lastClickTime < DBLCLICKTIME) {
- br->lastIconClicked = -1; /* YES */
-
- doubleClick(br, sel);
-- return rv;
-+ return -1;
- }
-
- else {
-@@ -1741,9 +1898,36 @@
- }
- }
-
--
- changedNumLit(br, -1, 0);
-+ return 0;
-+}
-+
-
-+/***************************************************************/
-+static int clickIconWin(br, mx, my, mtime, multi)
-+ BROWINFO *br;
-+ int mx,my,multi;
-+ unsigned long mtime;
-+{
-+ /* returns '-1' normally, returns an index into bfList[] if the user
-+ double-clicks an icon */
-+
-+ int i,j, sel, cpymode, dodel;
-+ BROWINFO *destBr;
-+ BFIL *bf;
-+ char buf[256], *destFolderName;
-+
-+ if (!br->bfList || !br->bfLen) return -1;
-+
-+ destBr = br; destFolderName = ".";
-+
-+ sel = mouseInWhichIcon(br, mx, my);
-+ dodel = 0;
-+
-+ recIconVisible(br->path, sel);
-+
-+ if (updateSel(br, sel, multi, mtime))
-+ return -1;
-
-
- { /* track mouse until button1 is released */
-@@ -2098,7 +2282,7 @@
- }
- } /* end of 'tracking' sub-function */
-
-- return rv;
-+ return -1;
- }
-
- /*******************************************/
-@@ -2164,15 +2348,35 @@
- else sprintf(buf, "%s%s", br->path, br->bfList[sel].name);
- #endif
-
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(buf)) {
-+#else
- if (chdir(buf)) {
-+#endif
- char str[512];
- sprintf(str,"Unable to cd to '%s'\n", br->bfList[sel].name);
- setBrowStr(br, str);
- XBell(theDisp, 50);
- }
- else {
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(buf)) {
-+ BTSetActive(&br->but[BR_DELETE], 0);
-+ br->cmdMB.dim[BR_DELETE] = 1;
-+
-+ BTSetActive(&br->but[BR_RENAME], 0);
-+ br->cmdMB.dim[BR_RENAME] = 1;
-+
-+ BTSetActive(&br->but[BR_MKDIR], 0);
-+ br->cmdMB.dim[BR_MKDIR] = 1;
-+ } else {
-+ BTSetActive(&br->but[BR_MKDIR], 1);
-+ br->cmdMB.dim[BR_MKDIR] = 0;
-+ }
-+#endif
- scanDir(br);
- SCSetVal(&(br->scrl), 0); /* reset to top on a chdir */
-+ restIconVisible(br);
- }
- }
-
-@@ -2193,6 +2397,28 @@
- }
- else { *event_retP = LOADPIC; SetDirFName(buf); }
-
-+#ifdef VS_RESCMAP
-+ /* Change Colormap for browser */
-+ if (browPerfect && browCmap)
-+ {
-+ int i;
-+ XSetWindowAttributes xswa;
-+ if(LocalCmap)
-+ {
-+ xswa.colormap = LocalCmap;
-+ _IfTempOut=2;
-+ }
-+ else
-+ {
-+ xswa.colormap = theCmap;
-+ _IfTempOut=2;
-+ }
-+ for(i=0;i<MAXBRWIN;i++)
-+ XChangeWindowAttributes(theDisp, binfo[i].win, CWColormap, &xswa);
-+ XFlush(theDisp);
-+ }
-+#endif
-+
- *event_doneP = 1; /* make MainLoop load image */
- }
- }
-@@ -2347,6 +2573,9 @@
-
- /* try to open this file */
- sprintf(foo, "%s%s", br->path, br->bfList[i].name);
-+#ifdef AUTO_EXPAND
-+ Dirtovd(foo);
-+#endif
- for (j=0; j<numnames && strcmp(namelist[j],foo); j++);
- if (j<numnames) {
- curname = nList.selected = j;
-@@ -2362,6 +2591,9 @@
- else { /* not SPACE, or SPACE and lit=1 and not shift */
- for (i=0; i<br->bfLen && !br->bfList[i].lit; i++); /* find lit one */
- sprintf(fname, "%s%s", br->path, br->bfList[i].name);
-+#ifdef AUTO_EXPAND
-+ Dirtovd(fname);
-+#endif
- viewsel = !(strcmp(fname, fullfname));
-
- if (viewsel) {
-@@ -2553,7 +2785,11 @@
- }
- #endif
-
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(tmppath)) {
-+#else
- if (chdir(tmppath)) {
-+#endif
- char str[512];
- sprintf(str,"Unable to cd to '%s'\n", tmppath);
- MBRedraw(&(br->dirMB));
-@@ -2561,8 +2797,24 @@
- XBell(theDisp, 50);
- }
- else {
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(tmppath)) {
-+ BTSetActive(&br->but[BR_DELETE], 0);
-+ br->cmdMB.dim[BR_DELETE] = 1;
-+
-+ BTSetActive(&br->but[BR_RENAME], 0);
-+ br->cmdMB.dim[BR_RENAME] = 1;
-+
-+ BTSetActive(&br->but[BR_MKDIR], 0);
-+ br->cmdMB.dim[BR_MKDIR] = 1;
-+ } else {
-+ BTSetActive(&br->but[BR_MKDIR], 1);
-+ br->cmdMB.dim[BR_MKDIR] = 0;
-+ }
-+#endif
- scanDir(br);
- SCSetVal(&br->scrl, 0); /* reset to top of window on a chdir */
-+ restIconVisible(br);
- }
- }
- }
-@@ -2581,7 +2833,11 @@
- if ((strlen(br->path) > (size_t) 2) && br->path[strlen(br->path)-1] == '/')
- br->path[strlen(br->path)-1] = '\0';
-
-+#ifdef AUTO_EXPAND
-+ rv = Chvdir(br->path);
-+#else
- rv = chdir(br->path);
-+#endif
- if (rv) {
- char str[512];
- sprintf(str, "Unable to cd to '%s'\n", br->path);
-@@ -2589,6 +2845,23 @@
- XBell(theDisp, 50);
- }
-
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(br->path)) {
-+ BTSetActive(&br->but[BR_DELETE], 0);
-+ br->cmdMB.dim[BR_DELETE] = 1;
-+
-+ BTSetActive(&br->but[BR_RENAME], 0);
-+ br->cmdMB.dim[BR_RENAME] = 1;
-+
-+ BTSetActive(&br->but[BR_MKDIR], 0);
-+ br->cmdMB.dim[BR_MKDIR] = 1;
-+ } else {
-+ BTSetActive(&br->but[BR_MKDIR], 1);
-+ br->cmdMB.dim[BR_MKDIR] = 0;
-+ }
-+#endif
-+
-+ restIconVisible(br);
- strcat(br->path, "/"); /* put trailing '/' back on */
- return rv;
- }
-@@ -2615,8 +2888,13 @@
- strcpy(dstbr->mblist[i], srcbr->mblist[i]);
- }
-
-- dstbr->dirMB.list = srcbr->mblist;
-+#if 0
-+ dstbr->dirMB.list = srcbr->mblist; /* original bug..? */
- dstbr->dirMB.nlist = srcbr->ndirs;
-+#else
-+ dstbr->dirMB.list = dstbr->mblist; /* fixed by */
-+ dstbr->dirMB.nlist = dstbr->ndirs; /* jp-extension. */
-+#endif
-
- XClearArea(theDisp, dstbr->dirMB.win, dstbr->dirMB.x, dstbr->dirMB.y,
- dstbr->dirMB.w+3, dstbr->dirMB.h+3, False);
-@@ -2974,7 +3252,11 @@
-
-
- if (stat(bf->name, &st)==0) {
-+#ifdef AUTO_EXPAND
-+ bf->ftype = stat2bf((u_int) st.st_mode , bf->name);
-+#else
- bf->ftype = stat2bf((u_int) st.st_mode);
-+#endif
- if (bf->ftype == BF_FILE && (st.st_mode & 0111)) bf->ftype = BF_EXE;
-
- switch (bf->ftype) {
-@@ -3006,6 +3288,7 @@
- case RFT_XBM: bf->ftype = BF_XBM; break;
- case RFT_SUNRAS: bf->ftype = BF_SUNRAS; break;
- case RFT_BMP: bf->ftype = BF_BMP; break;
-+ case RFT_WBMP: bf->ftype = BF_BMP; break;
- case RFT_UTAHRLE: bf->ftype = BF_UTAHRLE; break;
- case RFT_IRIS: bf->ftype = BF_IRIS; break;
- case RFT_PCX: bf->ftype = BF_PCX; break;
-@@ -3013,12 +3296,22 @@
- case RFT_TIFF: bf->ftype = BF_TIFF; break;
- case RFT_PDSVICAR: bf->ftype = BF_PDS; break;
- case RFT_COMPRESS: bf->ftype = BF_COMPRESS; break;
-+ case RFT_BZIP2: bf->ftype = BF_BZIP2; break;
- case RFT_PS: bf->ftype = BF_PS; break;
- case RFT_IFF: bf->ftype = BF_IFF; break;
- case RFT_TARGA: bf->ftype = BF_TARGA; break;
- case RFT_XPM: bf->ftype = BF_XPM; break;
- case RFT_XWD: bf->ftype = BF_XWD; break;
- case RFT_FITS: bf->ftype = BF_FITS; break;
-+ case RFT_PNG: bf->ftype = BF_PNG; break;
-+ case RFT_ZX: bf->ftype = BF_ZX; break; /* [JCE] */
-+ case RFT_PCD: bf->ftype = BF_PCD; break;
-+ case RFT_MAG: bf->ftype = BF_MAG; break;
-+ case RFT_MAKI: bf->ftype = BF_MAKI; break;
-+ case RFT_PIC: bf->ftype = BF_PIC; break;
-+ case RFT_PI: bf->ftype = BF_PI; break;
-+ case RFT_PIC2: bf->ftype = BF_PIC2; break;
-+ case RFT_MGCSFX: bf->ftype = BF_MGCSFX; break;
- }
- }
- }
-@@ -3405,7 +3698,7 @@
- double wexpand,hexpand;
- int iwide, ihigh;
- byte *icon24, *icon8;
-- char str[256], str1[256], *readname, uncompname[128];
-+ char str[256], str1[256], readname[128], uncompname[128];
- char basefname[128], *uncName;
-
-
-@@ -3414,7 +3707,7 @@
- basefname[0] = '\0';
- pinfo.pic = (byte *) NULL;
- pinfo.comment = (char *) NULL;
-- readname = bf->name;
-+ strncpy(readname, bf->name, sizeof(readname) - 1);
-
- /* free any old info in 'bf' */
- if (bf->imginfo) free (bf->imginfo);
-@@ -3431,7 +3724,7 @@
-
- filetype = ReadFileType(bf->name);
-
-- if (filetype == RFT_COMPRESS) {
-+ if ((filetype == RFT_COMPRESS) || (filetype == RFT_BZIP2)) {
- #if (defined(VMS) && !defined(GUNZIP))
- /* VMS decompress doesn't like the file to have a trailing .Z in fname
- however, GUnZip is OK with it, which we are calling UnCompress */
-@@ -3442,9 +3735,9 @@
- uncName = bf->name;
- #endif
-
-- if (UncompressFile(uncName, uncompname)) {
-+ if (UncompressFile(uncName, uncompname, filetype)) {
- filetype = ReadFileType(uncompname);
-- readname = uncompname;
-+ strncpy(readname, uncompname, sizeof(readname) - 1);
- }
- else {
- sprintf(str, "Couldn't uncompress file '%s'", bf->name);
-@@ -3453,6 +3746,56 @@
- }
- }
-
-+#ifdef MACBINARY
-+ if (handlemacb && macb_file == True && bf->ftype != BF_ERROR) {
-+ if (RemoveMacbinary(readname, uncompname)) {
-+ if (strcmp(readname, bf->name)!=0) unlink(readname);
-+ strncpy(readname, uncompname, sizeof(readname) - 1);
-+ }
-+ else {
-+ sprintf(str, "Unable to remove a InfoFile header form '%s'.", bf->name);
-+ setBrowStr(br, str);
-+ bf->ftype = BF_ERROR;
-+ }
-+ }
-+#endif
-+
-+#ifdef HAVE_MGCSFX_AUTO
-+ if (bf->ftype != BF_ERROR) {
-+ if(filetype == RFT_MGCSFX){
-+ char tmpname[128];
-+ char *icom;
-+
-+ if((icom = mgcsfx_auto_input_com(bf->name)) != NULL){
-+ sprintf(tmpname, "%s/xvmsautoXXXXXX", tmpdir);
-+#ifdef USE_MKSTEMP
-+ close(mkstemp(tmpname));
-+#else
-+ mktemp(tmpname);
-+#endif
-+ SetISTR(ISTR_INFO, "Converting to known format by MgcSfx auto...");
-+ sprintf(str,"%s >%s", icom, tmpname);
-+ }else goto ms_auto_no;
-+
-+#ifndef VMS
-+ if (system(str))
-+#else
-+ if (!system(str))
-+#endif
-+ {
-+ sprintf(str, "Unable to convert '%s' by MgcSfx auto.", bf->name);
-+ setBrowStr(br, str);
-+ bf->ftype = BF_ERROR;
-+ } else {
-+ filetype = ReadFileType(tmpname);
-+ if (strcmp(readname, bf->name)!=0) unlink(readname);
-+ strncpy(readname, tmpname, sizeof(readname) - 1);
-+ }
-+ }
-+ }
-+ms_auto_no:
-+#endif /* HAVE_MGCSFX_AUTO */
-+
- /* get rid of comments. don't need 'em */
- if (pinfo.comment) free(pinfo.comment); pinfo.comment = (char *) NULL;
-
-@@ -3470,6 +3813,9 @@
- else {
- /* otherwise it's a known filetype... do the *hard* part now... */
-
-+#ifdef VS_ADJUST
-+ normaspect = defaspect;
-+#endif
- i = ReadPicFile(readname, filetype, &pinfo, 1);
- KillPageFiles(pinfo.pagebname, pinfo.numpages);
-
-@@ -3489,7 +3835,7 @@
- }
-
- /* if we made an uncompressed file, we can rm it now */
-- if (readname != bf->name) unlink(readname);
-+ if (strcmp(readname, bf->name)!=0) unlink(readname);
-
-
- /* at this point either BF_ERROR, BF_UNKNOWN, BF_EXE or pic */
-@@ -3507,16 +3853,30 @@
-
- /* compute size of icon (iwide,ihigh) */
-
-+#ifdef VS_ADJUST
-+ if (!vsadjust) normaspect = 1;
-+
-+ wexpand = (double) (pinfo.w * normaspect) / (double) ISIZE_WIDE;
-+#else
- wexpand = (double) pinfo.w / (double) ISIZE_WIDE;
-+#endif /* VS_ADJUST */
- hexpand = (double) pinfo.h / (double) ISIZE_HIGH;
-
- if (wexpand >= 1.0 || hexpand >= 1.0) { /* don't expand small icons */
- if (wexpand>hexpand) {
-+#ifdef VS_ADJUST
-+ iwide = (int) ((pinfo.w * normaspect) / wexpand + 0.5);
-+#else
- iwide = (int) (pinfo.w / wexpand + 0.5);
-+#endif
- ihigh = (int) (pinfo.h / wexpand + 0.5);
- }
- else {
-+#ifdef VS_ADJUST
-+ iwide = (int) ((pinfo.w * normaspect) / hexpand + 0.5);
-+#else
- iwide = (int) (pinfo.w / hexpand + 0.5);
-+#endif
- ihigh = (int) (pinfo.h / hexpand + 0.5);
- }
- }
-@@ -3566,6 +3926,15 @@
- case RFT_XPM: strcat(str,"XPM file"); break;
- case RFT_XWD: strcat(str,"XWD file"); break;
- case RFT_FITS: strcat(str,"FITS file"); break;
-+ case RFT_PNG: strcat(str,"PNG file"); break;
-+ case RFT_ZX: strcat(str,"Spectrum SCREEN$"); break; /* [JCE] */
-+ case RFT_PCD: strcat(str,"PhotoCD file"); break;
-+ case RFT_MAG: strcat(str,"MAG file"); break;
-+ case RFT_MAKI: strcat(str,"MAKI file"); break;
-+ case RFT_PIC: strcat(str,"PIC file"); break;
-+ case RFT_PI: strcat(str,"PI file"); break;
-+ case RFT_PIC2: strcat(str,"PIC2 file"); break;
-+ case RFT_MGCSFX: strcat(str,"Magic Suffix file"); break;
- default: strcat(str,"file of unknown type"); break;
- }
-
-@@ -3669,6 +4038,10 @@
-
- sprintf(thFname, "%s%s/%s", br->path, THUMBDIR, bf->name);
-
-+#ifdef AUTO_EXPAND
-+ Dirtovd(thFname);
-+#endif
-+
- fp = fopen(thFname, "r");
- if (!fp) return; /* nope, it doesn't have one */
-
-@@ -3784,6 +4157,11 @@
-
- sprintf(thFname, "%s%s/%s", br->path, THUMBDIR, bf->name);
-
-+#ifdef AUTO_EXPAND
-+ Dirtovd(thFname);
-+#endif
-+
-+ unlink(thFname); /* just in case there's already an unwritable one */
- fp = fopen(thFname, "w");
- if (!fp) {
- sprintf(buf, "Can't create thumbnail file '%s': %s", thFname,
-@@ -3848,15 +4226,30 @@
-
- sprintf(thFname, "%s%s", br->path, THUMBDIRNAME);
-
-+#ifdef AUTO_EXPAND
-+ Dirtovd(thFname);
-+#endif
-+
- i = stat(thFname, &st);
- if (i) { /* failed, let's create it */
- sprintf(thFname, "%s.", br->path);
-+#ifdef AUTO_EXPAND
-+ Dirtovd(thFname);
-+#endif
- i = stat(thFname, &st); /* get permissions of parent dir */
- if (!i) perm = st.st_mode & 07777;
- else perm = 0755;
-
- sprintf(thFname, "%s%s", br->path, THUMBDIRNAME);
-+#ifdef AUTO_EXPAND
-+ Dirtovd(thFname);
-+# ifdef VIRTUAL_TD
-+ if (mkdir(thFname, (mode_t) perm) < 0)
-+ Mkvdir_force(thFname);
-+# else
- mkdir(thFname, (mode_t) perm);
-+# endif
-+#endif
- }
- }
-
-@@ -3898,7 +4291,7 @@
- for (i=0, bf=br->bfList; i<br->bfLen; i++, bf++) {
- if (bf->ftype <= BF_FILE || bf->ftype >= BF_ERROR || bf->ftype==BF_EXE) {
-
-- /* ie, not a 'special' file */
-+ /* i.e., not a 'special' file */
-
- int s1, s2;
- char thfname[256];
-@@ -3912,10 +4305,9 @@
- sprintf(thfname, "%s/%s", THUMBDIR, bf->name);
- s2 = stat(thfname, &thumbst);
-
-- if (s1 || s2 || filest.st_mtime > thumbst.st_mtime ||
-- filest.st_ctime > thumbst.st_ctime) {
-+ if (s1 || s2 || filest.st_mtime > thumbst.st_mtime) {
- /* either stat'ing the file or the thumbfile failed, or
-- both stat's succeeded and the file has a newer mod or creation
-+ both stat's succeeded and the file has a newer mod
- time than the thumbnail file */
-
- makeIconVisible(br, i);
-@@ -3927,8 +4319,12 @@
- iconsBuilt++;
- if (DEBUG)
- fprintf(stderr,"icon made:fname='%s' thfname='%s' %d,%d,%ld,%ld\n",
-- bf->name, thfname, s1,s2,filest.st_mtime,thumbst.st_mtime);
-+ bf->name, thfname, s1, s2,
-+ (long)filest.st_mtime, (long)thumbst.st_mtime);
- }
-+ } else if (filest.st_ctime > thumbst.st_ctime) {
-+ /* update protections */
-+ chmod(thfname, (mode_t) (filest.st_mode & 07777));
- }
- }
- statcount++;
-@@ -3963,7 +4359,11 @@
- sprintf(thfname, "%s/%s", THUMBDIR, dp->d_name);
- if (stat(thfname, &thumbst)==0) { /* success */
- int tmp;
-+#ifdef AUTO_EXPAND
-+ tmp = stat2bf((u_int) thumbst.st_mode , thfname);
-+#else
- tmp = stat2bf((u_int) thumbst.st_mode);
-+#endif
-
- if (tmp == BF_FILE) { /* a plain file */
- /* see if this thumbfile has an associated pic file */
-@@ -4042,6 +4442,15 @@
- static char *labels[] = { "\nOk", "\033Cancel" };
- struct stat st;
-
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(br->path)) {
-+ sprintf(buf,"Sorry, you can't rename file in the virtual directory, '%s'",
-+ br->path);
-+ ErrPopUp(buf, "\nBummer!");
-+ return;
-+ }
-+#endif
-+
- if (cdBrow(br)) return;
-
- /* find the selected file */
-@@ -4129,6 +4538,15 @@
- static char *labels[] = { "\nOk", "\033Cancel" };
- struct stat st;
-
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(br->path)) {
-+ sprintf(buf,"Sorry, you can't mkdir in the virtual directory, '%s'",
-+ br->path);
-+ ErrPopUp(buf, "\nBummer!");
-+ return;
-+ }
-+#endif
-+
- if (cdBrow(br)) return;
-
- buf[0] = '\0';
-@@ -4197,14 +4615,34 @@
- if (cdBrow(br)) return; /* prints its own error message */
- }
-
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(buf)) {
-+#else
- if (chdir(buf)) {
-+#endif
- sprintf(str,"Unable to cd to '%s'\n", buf);
- setBrowStr(br, str);
- XBell(theDisp, 50);
- }
- else {
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(buf)) {
-+ BTSetActive(&br->but[BR_DELETE], 0);
-+ br->cmdMB.dim[BR_DELETE] = 1;
-+
-+ BTSetActive(&br->but[BR_RENAME], 0);
-+ br->cmdMB.dim[BR_RENAME] = 1;
-+
-+ BTSetActive(&br->but[BR_MKDIR], 0);
-+ br->cmdMB.dim[BR_MKDIR] = 1;
-+ } else {
-+ BTSetActive(&br->but[BR_MKDIR], 1);
-+ br->cmdMB.dim[BR_MKDIR] = 0;
-+ }
-+#endif
- scanDir(br);
- SCSetVal(&(br->scrl), 0); /* reset to top on a chdir */
-+ restIconVisible(br);
- }
- }
-
-@@ -4229,6 +4667,15 @@
- char buf[512];
- static char *yesno[] = { "\004Delete", "\033Cancel" };
-
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(br->path)) {
-+ sprintf(buf,"Sorry, you can't delete file at the virtual directory, '%s'",
-+ br->path);
-+ ErrPopUp(buf, "\nBummer!");
-+ return;
-+ }
-+#endif
-+
- if (!br->bfLen || !br->bfList || !br->numlit) return;
-
- if (cdBrow(br)) return; /* can't cd to this directory. screw it! */
-@@ -4251,7 +4698,11 @@
- for (i=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
- if (bf->lit) {
- if (firstdel == -1) firstdel = i;
-- if (bf->ftype == BF_DIR) numdirs++;
-+ if (bf->ftype == BF_DIR
-+#ifdef AUTO_EXPAND
-+ && (!Isarchive(bf->name))
-+#endif
-+ ) numdirs++;
- else numfiles++;
- }
- }
-@@ -4265,7 +4716,12 @@
- slen = strlen(buf);
-
- for (i=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
-+#ifdef AUTO_EXPAND
-+ if (bf->lit && (bf->ftype != BF_DIR || Isarchive(bf->name))) {
-+#else
- if (bf->lit && bf->ftype != BF_DIR) {
-+#endif
-+
- if ( (slen + strlen(bf->name) + 1) > 256) {
- strcat(buf,"...");
- break;
-@@ -4277,7 +4733,7 @@
- }
- }
-
-- i = PopUp(buf, yesno, 2);
-+ i = PopUp(buf, yesno, COUNT(yesno));
- if (i) return; /* cancelled */
- }
-
-@@ -4290,7 +4746,11 @@
- slen = strlen(buf);
-
- for (i=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
-+#ifdef AUTO_EXPAND
-+ if (bf->lit && (bf->ftype == BF_DIR || !Isarchive(bf->name))) {
-+#else
- if (bf->lit && bf->ftype == BF_DIR) {
-+#endif
- if ( (slen + strlen(bf->name) + 1) > 256) {
- strcat(buf,"...");
- break;
-@@ -4302,7 +4762,7 @@
- }
- }
-
-- i = PopUp(buf, yesno, 2);
-+ i = PopUp(buf, yesno, COUNT(yesno));
- if (i) return; /* cancelled */
- }
-
-@@ -4311,7 +4771,11 @@
-
- for (i=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
- if (bf->lit) {
-- if (bf->ftype == BF_DIR) rm_dir (br, bf->name);
-+ if (bf->ftype == BF_DIR
-+#ifdef AUTO_EXPAND
-+ && !Isarchive(bf->name)
-+#endif
-+ ) rm_dir (br, bf->name);
- else rm_file(br, bf->name);
- }
- }
-@@ -4440,7 +4904,11 @@
- xv_getwd(orgDir, sizeof(orgDir));
-
- sprintf(curDir, "%s%s", br->path, subdir);
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(curDir)) {
-+#else
- if (chdir(curDir)) {
-+#endif
- char str[512];
- sprintf(str, "Unable to cd to '%s'\n", curDir);
- setBrowStr(br, str);
-@@ -4452,14 +4920,24 @@
- /* have we looped? */
- for (i=0; i<dirStackLen && strcmp(curDir, dirStack[i]); i++);
- if (i<dirStackLen) { /* YES */
-+#ifdef AUTO_EXPAND
-+ Chvdir(orgDir);
-+#else
- chdir(orgDir);
-+#endif
-+ restIconVisible(br);
- return;
- }
-
- sp = (char *) malloc((size_t) strlen(curDir) + 1);
- if (!sp) {
- setBrowStr(br, "malloc() error in recurseUpdate()\n");
-+#ifdef AUTO_EXPAND
-+ Chvdir(orgDir);
-+#else
- chdir(orgDir);
-+#endif
-+ restIconVisible(br);
- return;
- }
-
-@@ -4494,7 +4972,12 @@
-
- xv_getwd(curDir, sizeof(curDir));
- if (strcmp(orgDir, curDir)) { /* change back to orgdir */
-+#ifdef AUTO_EXPAND
-+ Chvdir(orgDir);
-+#else
- chdir(orgDir);
-+#endif
-+ restIconVisible(br);
- scanDir(br);
- }
- }
-@@ -4518,6 +5001,13 @@
- setBrowStr(br, buf);
- }
-
-+#ifdef AUTO_EXPAND
-+ if (Rmvdir(name)) {
-+ sprintf(buf, "fail to remove virturl directory: %s", name);
-+ setBrowStr(br, buf);
-+ }
-+#endif
-+
- /* try to delete a thumbnail file, as well. ignore errors */
- strcpy(buf1, name); /* tmp1 = leading path of name */
- tmp = (char *) rindex(buf1, '/');
-@@ -4586,7 +5076,14 @@
- goto done;
- }
-
-- if (stat2bf((u_int) st.st_mode) == BF_DIR) { /* skip, for now */
-+#ifdef AUTO_EXPAND
-+ if ((stat2bf((u_int) st.st_mode , rmdirPath) == BF_DIR)
-+ && !Isarchive(rmdirPath)) /* skip, for now */
-+#else
-+
-+ if (stat2bf((u_int) st.st_mode) == BF_DIR) /* skip, for now */
-+#endif
-+ {
- rmdirPath[oldpathlen] = '\0';
- continue; /* don't remove from list */
- }
-@@ -4639,9 +5136,9 @@
-
- static int overwrite;
- #define OWRT_ASK 0
--#define OWRT_NOASK 1
--#define OWRT_CANCEL 2
--
-+#define OWRT_ALWAYS 1
-+#define OWRT_NEVER 2
-+#define OWRT_CANCEL 3
-
- /*******************************************/
- static void dragFiles(srcBr, dstBr, srcpath, dstpath, dstdir,
-@@ -4676,11 +5173,26 @@
- }
- else if (strcmp(dstdir,".")!=0) sprintf(dstp, "%s%s/", dstpath, dstdir);
-
-+#ifdef AUTO_EXPAND
-+ if (Isvdir(dstp)) {
-+ sprintf(buf,"Sorry, you can't %s to the virtual directory, '%s'",
-+ cpymode ? "copy" : "move", dstp);
-+ ErrPopUp(buf, "\nBummer!");
-+ SetCursors(-1);
-+ return;
-+ }
-+ if (Isvdir(srcpath))
-+ cpymode = 1;
-+#endif
-+
-
-
- /* if there is a thumbnail directory in 'srcpath', make one for dstpath */
- sprintf(src,"%s%s", srcpath, THUMBDIR);
- dothumbs = 0;
-+#ifdef AUTO_EXPAND
-+ Dirtovd(src);
-+#endif
- if (stat(src, &st)==0) {
- sprintf(dst,"%s%s", dstp, THUMBDIR);
- mkdir(dst, st.st_mode & 07777);
-@@ -4711,6 +5223,14 @@
- if (overwrite == OWRT_CANCEL) break; /* abort move */
- if (j==1) fail++;
-
-+#ifdef AUTO_EXPAND
-+ if (!cpymode && j==0)
-+ if (Movevdir(src,dst)) {
-+ sprintf(buf, "fail to move virturl directory: %s", names[i]);
-+ setBrowStr(srcBr, buf);
-+ }
-+#endif
-+
- if (dothumbs && j==0) {
- sprintf(src,"%s%s/%s", srcpath, THUMBDIR, names[i]);
- sprintf(dst,"%s%s/%s", dstp, THUMBDIR, names[i]);
-@@ -4748,6 +5268,15 @@
- }
-
-
-+ if (!cpymode) {
-+ /* clear all lit files in the source folder (as they've been moved)
-+ note: this won't be the optimal behavior if any files failed to
-+ move, but screw it, that's not going to happen too often... */
-+ for (i=0; i<srcBr->bfLen; i++) srcBr->bfList[i].lit = 0;
-+ srcBr->numlit = 0;
-+ }
-+
-+
- /* clear all files in the destination folder */
- for (i=0; i<dstBr->bfLen; i++) {
- dstBr->bfList[i].lit = 0;
-@@ -4793,7 +5322,51 @@
- SetCursors(-1);
- }
-
-+static int recursive_remove(dir)
-+ char *dir;
-+{
-+ DIR *dp = NULL;
-+ struct dirent *di;
-+ char name[MAXPATHLEN+1];
-+
-+ strncpy(name, dir, MAXPATHLEN);
-+ name[MAXPATHLEN] = 0;
-+
-+ if (name[strlen(name) - 1] == '/')
-+ name[strlen(name) - 1] = 0;
-
-+ if ((dp = opendir(name)) == NULL)
-+ goto err;
-+
-+ while ((di = readdir(dp)) != NULL) {
-+ char buf[MAXPATHLEN+1];
-+ struct stat st;
-+
-+ if (!strcmp(di->d_name, ".") || !strcmp(di->d_name, ".."))
-+ continue;
-+
-+ snprintf(buf, MAXPATHLEN, "%s/%s", name, di->d_name);
-+
-+ if (stat(buf, &st) < 0)
-+ continue;
-+
-+ if (S_ISDIR(st.st_mode)) {
-+ if (recursive_remove(buf) < 0)
-+ goto err;
-+ } else
-+ unlink(buf);
-+ }
-+
-+ if (rmdir(name) < 0)
-+ goto err;
-+
-+ closedir(dp);
-+ return 0;
-+
-+err:
-+ if (dp) closedir(dp);
-+ return -1;
-+}
-
- /*************************************************/
- static int moveFile(src,dst)
-@@ -4811,31 +5384,45 @@
- int i, srcdir, dstdir;
- struct stat st;
- char buf[512];
-- static char *owbuts[4] = { "\nOk", "dDon't ask", "nNo", "\033Cancel" };
-+ static char *owbuts[] = { "\nOk", "aAlways", "nNo", "NNever", "\033Cancel" };
-
- if (DEBUG) fprintf(stderr,"moveFile %s %s\n", src, dst);
-
-+#ifdef AUTO_EXPAND
-+ Dirtosubst(src);
-+#endif
-+
- if (stat(src, &st)) return 0; /* src doesn't exist, it would seem */
-+#ifdef AUTO_EXPAND
-+ srcdir = (stat2bf((u_int) st.st_mode , src) == BF_DIR);
-+#else
- srcdir = (stat2bf((u_int) st.st_mode) == BF_DIR);
-+#endif
-
- /* see if destination exists */
-+
- if (stat(dst, &st)==0) {
-+ if (overwrite==OWRT_NEVER) return -1;
-+#ifdef AUTO_EXPAND
-+ dstdir = (stat2bf((u_int) st.st_mode , dst) == BF_DIR);
-+#else
- dstdir = (stat2bf((u_int) st.st_mode) == BF_DIR);
-+#endif
-
- if (overwrite==OWRT_ASK) {
-- sprintf(buf, "%s '%s' exists.\n\nOverwrite?",
-+ snprintf(buf, sizeof(buf), "%s '%s' exists.\n\nOverwrite?",
- dstdir ? "Directory" : "File", dst);
-- i = PopUp(buf, owbuts, 4);
--
-- if (i==1) overwrite = OWRT_NOASK;
-- else if (i==2) return -1;
-- else if (i==3) { overwrite = OWRT_CANCEL; return 1; }
-+ switch (PopUp(buf, owbuts, COUNT(owbuts))) {
-+ case 1: overwrite = OWRT_ALWAYS; break;
-+ case 2: return -1;
-+ case 3: overwrite = OWRT_NEVER; return -1;
-+ case 4: overwrite = OWRT_CANCEL; return 1;
-+ }
- }
-
- if (dstdir) {
- #ifndef VMS /* we don't delete directories in VMS */
-- sprintf(buf, "rm -rf %s", dst);
-- if (system(buf)) { /* okay, so it's cheating... */
-+ if (recursive_remove(dst)) { /* okay, so it's cheating... */
- SetISTR(ISTR_WARNING, "Unable to remove directory %s", dst);
- return 1;
- }
-@@ -4858,9 +5445,8 @@
- if (i == 0) { /* copied okay, kill the original */
- if (srcdir) {
- #ifndef VMS /* we don't delete directories in VMS */
-- sprintf(buf, "rm -rf %s", src);
-- if (system(buf)) { /* okay, so it's cheating... */
-- SetISTR(ISTR_WARNING, "Unable to remove directory %s", dst);
-+ if (recursive_remove(src)) { /* okay, so it's cheating... */
-+ SetISTR(ISTR_WARNING, "Unable to remove directory %s", src);
- return 1;
- }
- #endif /* VMS */
-@@ -4906,38 +5492,51 @@
- fall through: if dest doesn't exist, copy the directory, recurs */
-
-
-- int i, dstExists, srcdir, dstdir;
-+ int dstExists, srcdir, dstdir;
- struct stat srcSt, dstSt;
- char buf[1024];
-- static char *owdiff[3] = { "\nOk", "nNo", "\033Cancel" };
-- static char *owsame[4] = { "\nOk", "dDon't Ask", "nNo", "\033Cancel" };
-+ static char *owdiff[] = { "\nOk", "nNo", "\033Cancel" };
-+ static char *owsame[] = { "\nOk", "aAlways", "nNo", "NNever", "\033Cancel" };
-
- if (DEBUG) fprintf(stderr,"copyFile %s %s\n", src, dst);
-
-+#ifdef AUTO_EXPAND
-+ Dirtosubst(src);
-+#endif
-+
- if (stat(src,&srcSt)) return 0; /* source doesn't exist, it would seem */
-
- dstExists = (stat(dst, &dstSt)==0);
-
- if (dstExists) { /* ask about overwriting... */
-- srcdir = (stat2bf((u_int) srcSt.st_mode) == BF_DIR);
-- dstdir = (stat2bf((u_int) dstSt.st_mode) == BF_DIR);
-+#ifdef AUTO_EXPAND
-+ srcdir = (stat2bf((u_int) srcSt.st_mode , src) == BF_DIR);
-+ dstdir = (stat2bf((u_int) dstSt.st_mode , dst) == BF_DIR);
-+#else
-+ srcdir = (stat2bf((u_int) srcSt.st_mode) == BF_DIR);
-+ dstdir = (stat2bf((u_int) dstSt.st_mode) == BF_DIR);
-+#endif
-
- sprintf(buf, "%s '%s' already exists. Replace it with %s '%s'?",
- (dstdir) ? "Directory" : "File", dst,
- (srcdir) ? "contents of directory" : "file", src);
-
- if (srcdir == dstdir) {
-+ if (overwrite==OWRT_NEVER) return -1;
- if (overwrite==OWRT_ASK) {
-- i = PopUp(buf, owsame, 4);
-- if (i==1) overwrite = OWRT_NOASK;
-- if (i==2) return -1;
-- else if (i==3) { overwrite = OWRT_CANCEL; return 1; }
-+ switch (PopUp(buf, owsame, COUNT(owsame))) {
-+ case 1: overwrite = OWRT_ALWAYS; break;
-+ case 2: return -1;
-+ case 3: overwrite = OWRT_NEVER; return -1;
-+ case 4: overwrite = OWRT_CANCEL; return 1;
-+ }
- }
- }
- else { /* one's a dir, the other's a file. *ALWAYS* ask! */
-- i = PopUp(buf, owdiff, 3);
-- if (i==1) return -1;
-- else if (i==2) { overwrite = OWRT_CANCEL; return 1; }
-+ switch (PopUp(buf, owdiff, COUNT(owdiff))) {
-+ case 1: return -1;
-+ case 2: overwrite = OWRT_CANCEL; return 1;
-+ }
- }
-
-
-@@ -5035,8 +5634,11 @@
- havedst = 1;
- }
-
--
-+#ifdef AUTO_EXPAND
-+ switch(stat2bf((u_int) srcSt.st_mode , cpDstPath)) {
-+#else
- switch(stat2bf((u_int) srcSt.st_mode)) {
-+#endif
- /* determine how to copy, by filetype */
-
- /* NOTE: There is no S_IFLNK case here, since we're using 'stat()' and
-@@ -5052,7 +5654,11 @@
- }
- }
- else {
-+#ifdef AUTO_EXPAND
-+ if (stat2bf((u_int) dstSt.st_mode , cpDstPath) != BF_DIR) {
-+#else
- if (stat2bf((u_int) dstSt.st_mode) != BF_DIR) {
-+#endif
- SetISTR(ISTR_WARNING,"%s: not a directory", cpDstPath);
- copyerr++;
- return;
-@@ -5130,7 +5736,12 @@
- goto done;
- }
-
-- if (stat2bf((u_int) srcSt.st_mode) == BF_DIR) {
-+#ifdef AUTO_EXPAND
-+ if (stat2bf((u_int) srcSt.st_mode , cpSrcPath) == BF_DIR)
-+#else
-+ if (stat2bf((u_int) srcSt.st_mode) == BF_DIR)
-+#endif
-+ {
- cpSrcPath[oldsrclen] = '\0';
- continue; /* don't remove from list, just skip */
- }
-@@ -5189,9 +5800,9 @@
- int exists;
- /*****************************/
- {
-- register int srcFd, dstFd, rcount, wcount, i;
-+ register int srcFd, dstFd, rcount, wcount;
- char buf[8192];
-- static char *owbuts[4] = { "\nOk", "dDon't Ask", "nNo", "\033Cancel" };
-+ static char *owbuts[] = { "\nOk", "aAlways", "nNo", "NNever", "\033Cancel" };
-
- if (DEBUG) fprintf(stderr,"cp_file: src='%s', dst='%s'\n",
- cpSrcPath, cpDstPath);
-@@ -5203,13 +5814,15 @@
- }
-
- if (exists) {
-+ if (overwrite==OWRT_NEVER) return;
- if (overwrite==OWRT_ASK) {
- sprintf(buf, "File '%s' exists.\n\nOverwrite?", cpDstPath);
-- i = PopUp(buf, owbuts, 4);
--
-- if (i==1) overwrite = OWRT_NOASK;
-- else if (i==2) return;
-- else if (i==3) { overwrite = OWRT_CANCEL; return; }
-+ switch (PopUp(buf, owbuts, 4)) {
-+ case 1: overwrite = OWRT_ALWAYS; break;
-+ case 2: return;
-+ case 3: overwrite = OWRT_NEVER; return;
-+ case 4: overwrite = OWRT_CANCEL; return;
-+ }
- }
- dstFd = open(cpDstPath, O_WRONLY|O_TRUNC, 0);
- }
-@@ -5303,8 +5916,14 @@
-
-
- /*********************************/
-+#ifdef AUTO_EXPAND
-+static int stat2bf(uistmode, path)
-+ u_int uistmode;
-+ char *path;
-+#else
- static int stat2bf(uistmode)
- u_int uistmode;
-+#endif
- {
- /* given the 'st.st_mode' field from a successful stat(), returns
- BF_FILE, BF_DIR, BF_BLK, BF_CHR, BF_FIFO, or BF_SOCK. Does *NOT*
-@@ -5318,6 +5937,9 @@
- else if (S_ISBLK(stmode)) rv = BF_BLK;
- else if (S_ISFIFO(stmode)) rv = BF_FIFO;
- else if (S_ISSOCK(stmode)) rv = BF_SOCK;
-+#ifdef AUTO_EXPAND
-+ else if (Isarchive(path)) rv = BF_DIR;
-+#endif
- else rv = BF_FILE;
-
- return rv;
-@@ -5418,4 +6040,56 @@
- }
-
-
-+static IVIS *icon_vis_list = NULL;
-+
-+/***************************************************************/
-+static void recIconVisible(name, icon)
-+ char *name;
-+ int icon;
-+{
-+ IVIS *ptr, *prev = NULL;
-+
-+ for (ptr = icon_vis_list; ptr; prev = ptr, ptr = ptr->next) {
-+ if (!strcmp(ptr->name, name)) {
-+ ptr->icon = icon;
-+ return;
-+ }
-+ }
-+
-+ ptr = calloc(sizeof(IVIS), 1);
-+ if (!ptr)
-+ return;
-+
-+ ptr->name = strdup(name);
-
-+ if (!ptr->name) {
-+ free(ptr);
-+ return;
-+ }
-+
-+ if (!prev) {
-+ icon_vis_list = ptr;
-+ } else {
-+ prev->next = ptr;
-+ }
-+
-+ ptr->next = NULL;
-+ ptr->icon = icon;
-+}
-+
-+/***************************************************************/
-+static void restIconVisible(br)
-+ BROWINFO *br;
-+{
-+ IVIS *ptr;
-+
-+ for (ptr = icon_vis_list; ptr; ptr = ptr->next) {
-+ if (!strcmp(ptr->name, br->path)) {
-+ if (ptr->icon >= 0) {
-+ makeIconVisible(br, ptr->icon);
-+ updateSel(br, ptr->icon, 0, 0);
-+ }
-+ return;
-+ }
-+ }
-+}
-diff -ruN xv-3.10a-bugfixes/xvctrl.c xv-3.10a-enhancements/xvctrl.c
---- xv-3.10a-bugfixes/xvctrl.c 2004-05-23 11:56:37.000000000 -0700
-+++ xv-3.10a-enhancements/xvctrl.c 2004-05-23 12:15:18.000000000 -0700
-@@ -104,7 +104,8 @@
- "Root: centered, warp",
- "Root: centered, brick",
- "Root: symmetrical tiled",
-- "Root: symmetrical mirrored" };
-+ "Root: symmetrical mirrored",
-+ "Root: upper left corner" };
-
- static char *conv24MList[] = { "8-bit mode\t\2448",
- "24-bit mode\t\2448",
-diff -ruN xv-3.10a-bugfixes/xvdial.c xv-3.10a-enhancements/xvdial.c
---- xv-3.10a-bugfixes/xvdial.c 2004-05-16 18:01:57.000000000 -0700
-+++ xv-3.10a-enhancements/xvdial.c 2004-05-16 18:06:38.000000000 -0700
-@@ -41,20 +41,21 @@
-
-
- /* local functions */
--static int whereInDial PARM((DIAL *, int, int));
--static void drawArrow PARM((DIAL *));
--static void drawValStr PARM((DIAL *));
--static void drawButt PARM((DIAL *, int, int));
--static int computeDialVal PARM((DIAL *, int, int));
--static void dimDial PARM((DIAL *));
-+static int whereInDial PARM((DIAL *, int, int));
-+static void drawArrow PARM((DIAL *));
-+static void drawValStr PARM((DIAL *));
-+static void drawButt PARM((DIAL *, int, int));
-+static double computeDialVal PARM((DIAL *, int, int));
-+static void dimDial PARM((DIAL *));
-
-
- /***************************************************/
--void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page,
-+void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, inc, page,
- fg, bg, hi, lo, title, units)
- DIAL *dp;
- Window parent;
--int x,y,w,h,minv,maxv,curv,page;
-+int x,y,w,h;
-+double minv,maxv,curv,inc,page;
- unsigned long fg,bg,hi,lo;
- char *title, *units;
- {
-@@ -98,18 +99,18 @@
- 1,fg,bg);
- if (!dp->win) FatalError("can't create dial window");
-
-- DSetRange(dp, minv, maxv, curv, page);
-+ DSetRange(dp, minv, maxv, curv, inc, page);
- XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask);
- }
-
-
- /***************************************************/
--void DSetRange(dp, minv, maxv, curv, page)
--DIAL *dp;
--int minv, maxv, curv, page;
-+void DSetRange(dp, minv, maxv, curv, inc, page)
-+DIAL *dp;
-+double minv, maxv, curv, inc, page;
- {
- if (maxv<minv) maxv=minv;
-- dp->min = minv; dp->max = maxv; dp->page = page;
-+ dp->min = minv; dp->max = maxv; dp->inc = inc; dp->page = page;
- dp->active = (minv < maxv);
-
- DSetVal(dp, curv);
-@@ -118,8 +119,8 @@
-
- /***************************************************/
- void DSetVal(dp, curv)
--DIAL *dp;
--int curv;
-+DIAL *dp;
-+double curv;
- {
- RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */
-
-@@ -129,7 +130,7 @@
- XSetForeground(theDisp, theGC, dp->bg);
- drawArrow(dp);
-
-- dp->val = curv;
-+ dp->val = (double)((int)(curv / dp->inc + (curv > 0 ? 0.5 : -0.5))) * dp->inc;
-
- /* draw new arrow and string */
- XSetForeground(theDisp, theGC, dp->fg);
-@@ -202,7 +203,8 @@
- int mx,my;
- {
- Window rW,cW;
-- int rx,ry, x,y, ipos, pos, lit, i, origval;
-+ int rx, ry, x, y, ipos, pos, lit;
-+ double origval;
- unsigned int mask;
-
- lit = 0;
-@@ -224,9 +226,9 @@
- if (ipos != INDIAL) {
- drawButt(dp, ipos, 1);
- switch (ipos) {
-- case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); break;
-+ case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc); break;
- case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break;
-- case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break;
-+ case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc); break;
- case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break;
- }
- if (dp->drawobj != NULL) (dp->drawobj)();
-@@ -235,8 +237,9 @@
- }
-
- else {
-- i = computeDialVal(dp, mx, my);
-- DSetVal(dp, i);
-+ double v;
-+ v = computeDialVal(dp, mx, my);
-+ DSetVal(dp, v);
- if (dp->drawobj != NULL) (dp->drawobj)();
- }
-
-@@ -246,11 +249,11 @@
- if (!(mask & Button1Mask)) break; /* button released */
-
- if (ipos == INDIAL) {
-- int j;
-- i = computeDialVal(dp, x, y);
-- j = dp->val;
-- DSetVal(dp, i);
-- if (j != dp->val) {
-+ double v, w;
-+ v = computeDialVal(dp, x, y);
-+ w = dp->val;
-+ DSetVal(dp, v);
-+ if (w != dp->val) {
- /* track whatever dial controls */
- if (dp->drawobj != NULL) (dp->drawobj)();
- }
-@@ -266,11 +269,11 @@
-
- if (lit) {
- switch (ipos) {
-- case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1);
-+ case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc);
- break;
- case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page);
- break;
-- case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1);
-+ case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc);
- break;
- case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page);
- break;
-@@ -320,19 +323,20 @@
- static void drawArrow(dp)
- DIAL *dp;
- {
-- int i, rad, cx, cy;
-+ int rad, cx, cy;
-+ double v;
- XPoint arrow[4];
-
- rad = dp->rad; cx = dp->cx; cy = dp->cy;
-
- /* map pos (range minv..maxv) into degrees (range 240..-60) */
-- i = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
-- arrow[0].x = cx + (int) ((double) rad * .80 * cos(i * DEG2RAD));
-- arrow[0].y = cy - (int) ((double) rad * .80 * sin(i * DEG2RAD));
-- arrow[1].x = cx + (int) ((double) rad * .33 * cos((i+160) * DEG2RAD));
-- arrow[1].y = cy - (int) ((double) rad * .33 * sin((i+160) * DEG2RAD));
-- arrow[2].x = cx + (int) ((double) rad * .33 * cos((i-160) * DEG2RAD));
-- arrow[2].y = cy - (int) ((double) rad * .33 * sin((i-160) * DEG2RAD));
-+ v = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
-+ arrow[0].x = cx + (int) ((double) rad * .80 * cos(v * DEG2RAD));
-+ arrow[0].y = cy - (int) ((double) rad * .80 * sin(v * DEG2RAD));
-+ arrow[1].x = cx + (int) ((double) rad * .33 * cos((v+160) * DEG2RAD));
-+ arrow[1].y = cy - (int) ((double) rad * .33 * sin((v+160) * DEG2RAD));
-+ arrow[2].x = cx + (int) ((double) rad * .33 * cos((v-160) * DEG2RAD));
-+ arrow[2].y = cy - (int) ((double) rad * .33 * sin((v-160) * DEG2RAD));
- arrow[3].x = arrow[0].x;
- arrow[3].y = arrow[0].y;
- XDrawLines(theDisp, dp->win, theGC, arrow, 4, CoordModeOrigin);
-@@ -343,23 +347,37 @@
- static void drawValStr(dp)
- DIAL *dp;
- {
-- int i, x1, x2;
-+ int tot, i, x1, x2;
- char foo[60], foo1[60];
-
- /* compute longest string necessary so we can right-align this thing */
-- sprintf(foo,"%d",dp->min); x1 = strlen(foo);
-- sprintf(foo,"%d",dp->max); x2 = strlen(foo);
-+ sprintf(foo,"%d",(int)dp->min); x1 = strlen(foo);
-+ sprintf(foo,"%d",(int)dp->max); x2 = strlen(foo);
- if (dp->min < 0 && dp->max > 0) x2++; /* put '+' at beginning */
- i = x1; if (x2>x1) i = x2;
- if (dp->units) i += strlen(dp->units);
-
-- if (dp->min < 0 && dp->max > 0) sprintf(foo,"%+d", dp->val);
-- else sprintf(foo,"%d", dp->val);
-+ sprintf(foo,"%g",dp->inc); /* space for decimal values */
-+ tot = i + strlen(foo) - 1; /* Take away the 0 from the beginning */
-+
-+ if (dp->min < 0.0 && dp->max > 0.0) sprintf(foo,"%+g", dp->val);
-+ else sprintf(foo,"%g", dp->val);
-+
-+ if (dp->inc < 1.0)
-+ {
-+ int j;
-+
-+ if (dp->val == (double)((int)dp->val))
-+ strcat(foo,".");
-+
-+ for (j = strlen(foo); j < tot; j++)
-+ strcat(foo,"0");
-+ }
-
- if (dp->units) strcat(foo,dp->units);
- foo1[0] = '\0';
- if (strlen(foo) < (size_t) i) {
-- for (i = i - strlen(foo); i>0; i--) strcat(foo1," ");
-+ for (i-=strlen(foo);i>0;i--) strcat(foo1," ");
- }
- strcat(foo1, foo);
-
-@@ -411,12 +429,13 @@
-
-
- /***************************************************/
--static int computeDialVal(dp, x, y)
-+static double computeDialVal(dp, x, y)
- DIAL *dp;
- int x, y;
- {
-- int dx, dy, val;
-- double angle;
-+ int dx, dy;
-+
-+ double angle, val;
-
- /* compute dx, dy (distance from cx, cy). Note: +dy is *up* */
- dx = x - dp->cx; dy = dp->cy - y;
-@@ -436,8 +455,10 @@
- if (angle > 270.0) angle -= 360.0;
- if (angle < -90.0) angle += 360.0;
-
-- val = (int) ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
-+ val = ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
-
-+ /* round value to be an even multiple of dp->inc */
-+ val = (double)((int)(val / dp->inc + 0.5)) * dp->inc;
- return val;
- }
-
-diff -ruN xv-3.10a-bugfixes/xvdir.c xv-3.10a-enhancements/xvdir.c
---- xv-3.10a-bugfixes/xvdir.c 2005-03-20 18:38:30.000000000 -0800
-+++ xv-3.10a-enhancements/xvdir.c 2005-04-25 22:24:28.000000000 -0700
-@@ -62,6 +62,9 @@
- #ifdef HAVE_TIFF
- "TIFF",
- #endif
-+#ifdef HAVE_PNG
-+ "PNG",
-+#endif
- "PostScript",
- "PBM/PGM/PPM (raw)",
- "PBM/PGM/PPM (ascii)",
-@@ -73,9 +76,32 @@
- "Targa (24-bit)",
- "FITS",
- "PM",
-+ "Spectrum SCREEN$", /* [JCE] */
-+ "WBMP",
-+#ifdef HAVE_MAG
-+ "MAG",
-+#endif
-+#ifdef HAVE_PIC
-+ "PIC",
-+#endif
-+#ifdef HAVE_MAKI
-+ "MAKI (640x400 only)",
-+#endif
-+#ifdef HAVE_PI
-+ "PI",
-+#endif
-+#ifdef HAVE_PIC2
-+ "PIC2",
-+#endif
-+#ifdef HAVE_MGCSFX
-+ "MgcSfx",
-+#endif
- MBSEP,
- "Filename List"};
-
-+#ifdef HAVE_PIC2
-+extern int PIC2SaveParams PARM((char *, int));
-+#endif
-
- static void arrangeButts PARM((int));
- static void RedrawDList PARM((int, SCRL *));
-@@ -570,7 +596,11 @@
- }
- #endif
-
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(tmppath)) {
-+#else
- if (chdir(tmppath)) {
-+#endif
- char str[512];
- sprintf(str,"Unable to cd to '%s'\n", tmppath);
- *trunc_point = '/'; /* restore the path */
-@@ -635,7 +665,11 @@
- xv_getwd(path, sizeof(path));
- #endif
-
-+#ifdef AUTO_EXPAND
-+ if (Chvdir(path)) {
-+#else
- if (chdir(path)) {
-+#endif
- ErrPopUp("Current load/save directory seems to have gone away!",
- "\nYikes!");
- #ifdef apollo
-@@ -643,7 +677,11 @@
- #else
- strcpy(path,"/");
- #endif
-+#ifdef AUTO_EXPAND
-+ Chvdir(path);
-+#else
- chdir(path);
-+#endif
- }
-
- changedDir = strcmp(path, oldpath);
-@@ -748,6 +786,9 @@
- else if (S_ISFIFO(ftype)) fnames[i][0] = C_FIFO;
- else if (S_ISSOCK(ftype)) fnames[i][0] = C_SOCK;
- else if (fnames[i][0] == C_REG && (mode&0111)) fnames[i][0] = C_EXE;
-+#ifdef AUTO_EXPAND
-+ else if (Isarchive(fnames[i]+1)) fnames[i][0] = C_DIR;
-+#endif
- }
- else {
- /* fprintf(stderr,"problems 'stat-ing' files\n");*/
-@@ -847,7 +888,7 @@
- scrollToFileName();
- }
-
-- else if (c=='\010' || c=='\177') { /* BS or DEL */
-+ else if (c=='\010') { /* BS */
- if (curPos==0) return(-1); /* at beginning of str */
- xvbcopy(&filename[curPos], &filename[curPos-1], (size_t) (len-curPos+1));
- curPos--;
-@@ -872,7 +913,7 @@
- curPos = len;
- }
-
-- else if (c=='\004') { /* ^D: delete character at curPos */
-+ else if (c=='\004' || c=='\177') { /* ^D or DEL: delete character at curPos */
- if (curPos==len) return(-1);
- xvbcopy(&filename[curPos+1], &filename[curPos], (size_t) (len-curPos));
- }
-@@ -1055,6 +1096,25 @@
-
- fullname = GetDirFullName();
-
-+#ifdef AUTO_EXPAND
-+ {
-+ char path[MAXPATHLEN];
-+
-+ GetDirPath(path);
-+ Mkvdir(path);
-+ if ((i = Isvdir(fullname)) & 01) {
-+ char buf[128];
-+ sprintf(buf,
-+ "Sorry, you can't save file in the virtual directory, '%s'",
-+ path);
-+ ErrPopUp(buf, "\nBummer!");
-+ return -1;
-+ }
-+ if (i & 06)
-+ Rmvdir(fullname);
-+ }
-+#endif
-+
- fmt = MBWhich(&fmtMB);
- col = MBWhich(&colMB);
-
-@@ -1116,7 +1176,34 @@
- }
- #endif
-
-+#ifdef HAVE_PNG
-+ else if (fmt == F_PNG) { /* PNG */
-+ PNGSaveParams(fullname, col);
-+ PNGDialog(1); /* open PNG Dialog box */
-+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
-+ return 0; /* always 'succeeds' */
-+ }
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ else if (fmt == F_PIC2) { /* PIC2 */
-+ if (PIC2SaveParams(fullname, col) < 0)
-+ return 0;
-+ PIC2Dialog(1); /* open PIC2 Dialog box */
-+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
-+ return 0; /* always 'succeeds' */
-+ }
-+#endif /* HAVE_PIC2 */
-
-+#ifdef HAVE_MGCSFX
-+ else if (fmt == F_MGCSFX) { /* MGCSFX */
-+ if (MGCSFXSaveParams(fullname, col) < 0)
-+ return 0;
-+ MGCSFXDialog(1); /* open MGCSFX Dialog box */
-+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
-+ return 0; /* always 'succeeds' */
-+ }
-+#endif /* HAVE_MGCSFX */
-
-
- WaitCursor();
-@@ -1164,6 +1251,10 @@
- rv = WriteBMP (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
- break;
-
-+ case F_WBMP:
-+ rv = WriteWBMP (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
-+ break;
-+
- case F_IRIS:
- rv = WriteIRIS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
- break;
-@@ -1181,6 +1272,35 @@
- rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
- picComments);
- break;
-+
-+ case F_ZX: /* [JCE] Spectrum SCREEN$ */
-+ rv = WriteZX (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
-+ picComments);
-+ break;
-+#ifdef HAVE_MAG
-+ case F_MAG:
-+ rv = WriteMAG (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
-+ picComments);
-+ break;
-+#endif /* HAVE_MAG */
-+#ifdef HAVE_PIC
-+ case F_PIC:
-+ rv = WritePIC (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
-+ picComments);
-+ break;
-+#endif /* HAVE_PIC */
-+#ifdef HAVE_MAKI
-+ case F_MAKI:
-+ rv = WriteMAKI (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
-+ break;
-+#endif /* HAVE_MAKI */
-+
-+#ifdef HAVE_PI
-+ case F_PI:
-+ rv = WritePi (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
-+ picComments);
-+ break;
-+#endif /* HAVE_PI */
- }
-
-
-@@ -1310,7 +1430,8 @@
-
- else if (group == F_FORMAT) {
- MBSelect(&fmtMB, bnum);
-- if (MBWhich(&fmtMB) == F_XBM) { /* turn off all but B/W */
-+ if (MBWhich(&fmtMB) == F_XBM ||
-+ MBWhich(&fmtMB) == F_WBMP) { /* turn off all but B/W */
- colMB.dim[F_FULLCOLOR] = 1;
- colMB.dim[F_GREYSCALE] = 1;
- colMB.dim[F_BWDITHER] = 0;
-@@ -1389,14 +1510,29 @@
- (strcmp(lowsuf,"eps" )==0) ||
- (strcmp(lowsuf,"rgb" )==0) ||
- (strcmp(lowsuf,"tga" )==0) ||
-- (strcmp(lowsuf,"xpm" )==0) ||
- (strcmp(lowsuf,"fits")==0) ||
- (strcmp(lowsuf,"fts" )==0) ||
-+#ifdef HAVE_JPEG
- (strcmp(lowsuf,"jpg" )==0) ||
- (strcmp(lowsuf,"jpeg")==0) ||
- (strcmp(lowsuf,"jfif")==0) ||
-+#endif
-+#ifdef HAVE_TIFF
- (strcmp(lowsuf,"tif" )==0) ||
-- (strcmp(lowsuf,"tiff")==0)) {
-+ (strcmp(lowsuf,"tiff")==0) ||
-+#endif
-+#ifdef HAVE_PNG
-+ (strcmp(lowsuf,"png" )==0) ||
-+#endif
-+ (strcmp(lowsuf,"wbmp")==0) ||
-+ (strcmp(lowsuf,"xpm" )==0) ||
-+ (strcmp(lowsuf,"tiff")==0) ||
-+ (strcmp(lowsuf,"mag" )==0) ||
-+ (strcmp(lowsuf,"pic" )==0) ||
-+ (strcmp(lowsuf,"mki" )==0) ||
-+ (strcmp(lowsuf,"pi" )==0) ||
-+ (strcmp(lowsuf,"p2" )==0) ||
-+ (strcmp(lowsuf,"pcd" )==0)) {
-
- /* found one. set lowsuf = to the new suffix, and tack on to filename */
-
-@@ -1419,6 +1555,7 @@
- case F_XBM: strcpy(lowsuf,"xbm"); break;
- case F_SUNRAS: strcpy(lowsuf,"ras"); break;
- case F_BMP: strcpy(lowsuf,"bmp"); break;
-+ case F_WBMP: strcpy(lowsuf,"wbmp"); break;
- case F_PS: strcpy(lowsuf,"ps"); break;
- case F_IRIS: strcpy(lowsuf,"rgb"); break;
- case F_TARGA: strcpy(lowsuf,"tga"); break;
-@@ -1432,8 +1569,33 @@
- #ifdef HAVE_TIFF
- case F_TIFF: strcpy(lowsuf,"tif"); break;
- #endif
-+
-+#ifdef HAVE_PNG
-+ case F_PNG: strcpy(lowsuf,"png"); break;
-+#endif
-+
-+#ifdef HAVE_MAG
-+ case F_MAG: strcpy(lowsuf,"mag"); break;
-+#endif
-+
-+#ifdef HAVE_PIC
-+ case F_PIC: strcpy(lowsuf,"pic"); break;
-+#endif
-+
-+#ifdef HAVE_MAKI
-+ case F_MAKI: strcpy(lowsuf,"mki"); break;
-+#endif
-+
-+#ifdef HAVE_PI
-+ case F_PI: strcpy(lowsuf,"pi"); break;
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ case F_PIC2: strcpy(lowsuf,"p2"); break;
-+#endif
- }
-
-+
- if (allcaps) { /* upper-caseify lowsuf */
- for (sp=lowsuf; *sp; sp++)
- *sp = (islower(*sp)) ? toupper(*sp) : *sp;
-@@ -1499,6 +1661,11 @@
- }
- #endif
-
-+#ifdef AUTO_EXPAND
-+ Mkvdir(newpath);
-+ Dirtovd(newpath);
-+#endif
-+
- if (stat(newpath, &st)==0) {
- int isdir;
-
-@@ -1596,7 +1763,11 @@
- dopipe = 0;
-
- /* make sure we're in the correct directory */
-+#ifdef AUTO_EXPAND
-+ if (strlen(path)) Chvdir(path);
-+#else
- if (strlen(path)) chdir(path);
-+#endif
-
- if (ISPIPE(filename[0])) { /* do piping */
- /* make up some bogus temp file to put this in */
-@@ -2002,7 +2173,7 @@
- if (stat(namelist[curname], &origStat)==0) {
- haveStat = 1;
- if (DEBUG) fprintf(stderr," origStat.size=%ld, origStat.mtime=%ld\n",
-- origStat.st_size, origStat.st_mtime);
-+ (long)origStat.st_size, (long)origStat.st_mtime);
- }
- }
- }
-@@ -2027,7 +2198,7 @@
-
- if (stat(namelist[curname], &st)==0) {
- if (DEBUG) fprintf(stderr," st.size=%ld, st.mtime=%ld\n",
-- st.st_size, st.st_mtime);
-+ (long)st.st_size, (long)st.st_mtime);
-
- if ((st.st_size == origStat.st_size) &&
- (st.st_mtime == origStat.st_mtime)) return 0; /* no change */
-@@ -2080,3 +2251,164 @@
- }
-
-
-+#ifdef HAVE_PIC2
-+/**** Stuff for PIC2Dialog box ****/
-+FILE *pic2_OpenOutFile(filename, append)
-+char *filename;
-+int *append;
-+{
-+ /* opens file for output. does various error handling bits. Returns
-+ an open file pointer if success, NULL if failure */
-+
-+ FILE *fp = NULL;
-+ struct stat st;
-+
-+ if (!filename || filename[0] == '\0')
-+ return (NULL);
-+ strcpy(outFName, filename);
-+ dopipe = 0;
-+
-+ /* make sure we're in the correct directory */
-+#ifdef AUTO_EXPAND
-+ if (strlen(path)) Chvdir(path);
-+#else
-+ if (strlen(path)) chdir(path);
-+#endif
-+
-+ if (ISPIPE(filename[0])) { /* do piping */
-+ /* make up some bogus temp file to put this in */
-+#ifndef VMS
-+ sprintf(outFName, "%s/xvXXXXXX", tmpdir);
-+#else
-+ strcpy(outFName, "[]xvXXXXXX.lis");
-+#endif
-+#ifdef USE_MKSTEMP
-+ fp = fdopen(mkstemp(outFName), "w");
-+#else
-+ mktemp(outFName);
-+#endif
-+ dopipe = 1;
-+ }
-+
-+
-+ /* see if file exists (i.e., we're overwriting) */
-+ *append = 0;
-+#ifdef USE_MKSTEMP
-+ if (!dopipe)
-+#endif
-+ if (stat(outFName, &st)==0) { /* stat succeeded, file must exist */
-+ if (ReadFileType(outFName) != RFT_PIC2) {
-+ static char *foo[] = { "\nOk", "\033Cancel" };
-+ char str[512];
-+
-+ sprintf(str,"Overwrite existing file '%s'?", outFName);
-+ if (PopUp(str, foo, 2))
-+ return (NULL);
-+ } else {
-+ static char *foo[] = { "\nOk", "\033Cancel" };
-+ char str[512];
-+
-+ sprintf(str,"Append to existing file '%s'?", outFName);
-+ if (PopUp(str, foo, 2)) {
-+ sprintf(str,"Overwrite existing file '%s'?", outFName);
-+ if (PopUp(str, foo, 2))
-+ return (NULL);
-+ } else
-+ *append = 1;
-+ }
-+ }
-+
-+ /* Open file */
-+#ifdef USE_MKSTEMP
-+ if (!dopipe)
-+#endif
-+ fp = *append ? fopen(outFName, "r+") : fopen(outFName, "w");
-+ if (!fp) {
-+ char str[512];
-+ sprintf(str,"Can't write file '%s'\n\n %s.",outFName, ERRSTR(errno));
-+ ErrPopUp(str, "\nBummer");
-+ return (NULL);
-+ }
-+
-+ return (fp);
-+}
-+
-+
-+/***************************************/
-+void pic2_KillNullFile(fp)
-+FILE *fp;
-+{
-+ fseek(fp, (size_t) 0, SEEK_END);
-+ if (ftell(fp) > 0) {
-+ fclose(fp);
-+ return;
-+ } else {
-+ fclose(fp);
-+ unlink(outFName);
-+ return;
-+ }
-+}
-+#endif /* HAVE_PIC2 */
-+
-+
-+#ifdef HAVE_MGCSFX
-+/**** Stuff for MGCSFX Dialog box ****/
-+/***************************************/
-+int OpenOutFileDesc(filename)
-+ char *filename;
-+{
-+ /* opens file for output. does various error handling bits. Returns
-+ an open file pointer if success, NULL if failure */
-+
-+ int fd;
-+ struct stat st;
-+
-+ if (!filename || filename[0] == '\0') return -1;
-+ strcpy(outFName, filename);
-+ dopipe = 0;
-+
-+ /* make sure we're in the correct directory */
-+#ifdef AUTO_EXPAND
-+ if (strlen(path)) Chvdir(path);
-+#else
-+ if (strlen(path)) chdir(path);
-+#endif
-+
-+ if (ISPIPE(filename[0])) { /* do piping */
-+ /* make up some bogus temp file to put this in */
-+#ifndef VMS
-+ sprintf(outFName, "%s/xvXXXXXX", tmpdir);
-+#else
-+ strcpy(outFName, "[]xvXXXXXX.lis");
-+#endif
-+#ifdef USE_MKSTEMP
-+ close(mkstemp(outFName));
-+#else
-+ mktemp(outFName);
-+#endif
-+ dopipe = 1;
-+ }
-+
-+
-+ /* if didn't just create it, see if file exists (i.e., we're overwriting) */
-+ if (!dopipe && stat(outFName, &st)==0) { /* stat succeeded, file exists */
-+ static char *foo[] = { "\nOk", "\033Cancel" };
-+ char str[512];
-+
-+ sprintf(str,"Overwrite existing file '%s'?", outFName);
-+ if (PopUp(str, foo, 2)) return -1;
-+ }
-+
-+
-+ /* Open file */
-+ fd = open(outFName, O_WRONLY | O_CREAT | O_TRUNC, (0644));
-+ if (fd < 0) {
-+ char str[512];
-+ sprintf(str,"Can't write file '%s'\n\n %s.", outFName, ERRSTR(errno));
-+ ErrPopUp(str, "\nBummer");
-+ return -1;
-+ }
-+
-+ return fd;
-+}
-+#endif /* HAVE_MGCSFX */
-diff -ruN xv-3.10a-bugfixes/xvevent.c xv-3.10a-enhancements/xvevent.c
---- xv-3.10a-bugfixes/xvevent.c 2004-05-16 18:02:03.000000000 -0700
-+++ xv-3.10a-enhancements/xvevent.c 2005-05-01 09:33:38.000000000 -0700
-@@ -64,6 +64,8 @@
-
- static void annotatePic PARM((void));
-
-+static int debkludge_offx;
-+static int debkludge_offy;
-
- /****************/
- int EventLoop()
-@@ -71,13 +73,25 @@
- {
- XEvent event;
- int retval,done,waiting;
-- time_t orgtime, curtime;
-+#ifdef USE_TICKS
-+ clock_t waitsec_ticks=0L, orgtime_ticks=0L, curtime_ticks;
-+ clock_t elapsed_ticks=0L, remaining_interval;
-+#else
-+ time_t orgtime=0L, curtime;
-+#endif
-
-
- #ifndef NOSIGNAL
- signal(SIGQUIT, onInterrupt);
- #endif
-
-+ if (startGrab == 1) {
-+ startGrab = 2;
-+ FakeButtonPress(&but[BGRAB]);
-+ FakeKeyPress(ctrlW, XK_Return);
-+ return(1);
-+ }
-+
- /* note: there's no special event handling if we're using the root window.
- if we're using the root window, we will recieve NO events for mainW */
-
-@@ -100,18 +114,24 @@
-
- while (!done) {
-
-- if (waitsec > -1 && canstartwait && !waiting && XPending(theDisp)==0) {
-+ if (waitsec >= 0.0 && canstartwait && !waiting && XPending(theDisp)==0) {
- /* we wanna wait, we can wait, we haven't started waiting yet, and
- all pending events (ie, drawing the image the first time)
- have been dealt with: START WAITING */
-- time((time_t *) &orgtime);
-+#ifdef USE_TICKS
-+ waitsec_ticks = (clock_t)(waitsec * CLK_TCK);
-+ orgtime_ticks = times(NULL); /* unclear if NULL valid, but OK on Linux */
-+#else
-+ orgtime = time(NULL);
-+#endif
- waiting = 1;
- }
-
-
- /* if there's an XEvent pending *or* we're not doing anything
- in real-time (polling, flashing the selection, etc.) get next event */
-- if ((waitsec==-1 && !polling && !HaveSelection()) || XPending(theDisp)>0) {
-+ if ((waitsec<0.0 && !polling && !HaveSelection()) || XPending(theDisp)>0)
-+ {
- XNextEvent(theDisp, &event);
- retval = HandleEvent(&event,&done);
- }
-@@ -121,7 +141,7 @@
- DrawSelection(0);
- DrawSelection(1);
- XFlush(theDisp);
-- Timer(200);
-+ Timer(200); /* milliseconds */
- }
-
- if (polling) {
-@@ -129,13 +149,32 @@
- else if (!XPending(theDisp)) sleep(1);
- }
-
-- if (waitsec>-1 && waiting) {
-- time((time_t *) &curtime);
-- if (curtime - orgtime < waitsec) sleep(1);
-- else {
-- if (waitloop) return NEXTLOOP;
-- else return NEXTQUIT;
-- }
-+ if (waitsec>=0.0 && waiting) {
-+#ifdef USE_TICKS
-+ curtime_ticks = times(NULL); /* value in ticks */
-+ if (curtime_ticks < orgtime_ticks) {
-+ /* clock ticks rolled over: need to correct for that (i.e.,
-+ * curtime_ticks is presumably quite small, while orgtime_ticks
-+ * should be close to LONG_MAX, so do math accordingly--any way
-+ * to check whether clock_t is *not* a signed long?) */
-+ elapsed_ticks = curtime_ticks + (LONG_MAX - orgtime_ticks);
-+ } else
-+ elapsed_ticks = curtime_ticks - orgtime_ticks;
-+ remaining_interval = waitsec_ticks - elapsed_ticks;
-+ if (remaining_interval >= (clock_t)(1 * CLK_TCK))
-+ sleep(1);
-+ else {
-+ /* less than one second remaining: do delay in msec, then return */
-+ Timer((remaining_interval * 1000L) / CLK_TCK); /* can't overflow */
-+ return waitloop? NEXTLOOP : NEXTQUIT;
-+ }
-+#else
-+ curtime = time(NULL); /* value in seconds */
-+ if (curtime - orgtime < (time_t)waitsec)
-+ sleep(1);
-+ else
-+ return waitloop? NEXTLOOP : NEXTQUIT;
-+#endif
- }
- }
- } /* while (!done) */
-@@ -154,7 +193,24 @@
- int *donep;
- {
- static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0;
-- static int wasJpegUp=0, wasTiffUp=0;
-+#ifdef HAVE_JPEG
-+ static int wasJpegUp=0;
-+#endif
-+#ifdef HAVE_TIFF
-+ static int wasTiffUp=0;
-+#endif
-+#ifdef HAVE_PNG
-+ static int wasPngUp=0;
-+#endif
-+#ifdef HAVE_PCD
-+ static int wasPcdUp=0;
-+#endif
-+#ifdef HAVE_PIC2
-+ static int wasPic2Up=0;
-+#endif
-+#ifdef HAVE_MGCSFX
-+ static int wasMgcSfxUp=0;
-+#endif
-
- static int mainWKludge=0; /* force first mainW expose after a mainW config
- to redraw all of mainW */
-@@ -233,6 +289,28 @@
- if (TIFFCheckEvent(event)) break; /* event has been processed */
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break; /* event has been processed */
-+#endif
-+
-+ if (PCDCheckEvent(event)) break; /* event has been processed */
-+
-+#ifdef HAVE_PIC2
-+ if (PIC2CheckEvent(event)) break; /* event has been processed */
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (PCDCheckEvent (event)) break; /* event has been processed */
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ if (MGCSFXCheckEvent(event)) break; /* event has been processed */
-+#endif
-+
-+#ifdef TV_MULTILINGUAL
-+ if (CharsetCheckEvent(event)) break; /* event has been processed */
-+#endif
-+
- if (GamCheckEvent (event)) break; /* event has been processed */
- if (BrowseCheckEvent (event, &retval, &done)) break; /* event eaten */
- if (TextCheckEvent (event, &retval, &done)) break; /* event eaten */
-@@ -344,6 +422,9 @@
-
- if (BrowseDelWin(client_event->window)) break;
- if (TextDelWin(client_event->window)) break;
-+#ifdef TV_MULTILINGUAL
-+ if (CharsetDelWin(client_event->window)) break;
-+#endif
-
- if (client_event->window == infoW) InfoBox(0);
- else if (client_event->window == gamW) GamBox(0);
-@@ -359,6 +440,24 @@
- else if (client_event->window == tiffW) TIFFDialog(0);
- #endif
-
-+#ifdef HAVE_PNG
-+ else if (client_event->window == pngW) PNGDialog(0);
-+#endif
-+
-+ else if (client_event->window == pcdW) PCDDialog(0);
-+
-+#ifdef HAVE_PIC2
-+ else if (client_event->window == pic2W) PIC2Dialog(0);
-+#endif
-+
-+#ifdef HAVE_PCD
-+ else if (client_event->window == pcdW) PCDDialog(0);
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ else if (client_event->window == mgcsfxW) MGCSFXDialog(0);
-+#endif
-+
- else if (client_event->window == mainW) Quit(0);
- }
- }
-@@ -534,10 +633,21 @@
- #ifdef HAVE_JPEG
- if (wasJpegUp) { JPEGDialog(wasJpegUp); wasJpegUp=0; }
- #endif
--
- #ifdef HAVE_TIFF
- if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; }
- #endif
-+#ifdef HAVE_PNG
-+ if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; }
-+#endif
-+#ifdef HAVE_PCD
-+ if (wasPcdUp) { PCDDialog(wasPcdUp); wasPcdUp=0; }
-+#endif
-+#ifdef HAVE_PIC2
-+ if (wasPic2Up) { PIC2Dialog(wasPic2Up); wasPic2Up=0; }
-+#endif
-+#ifdef HAVE_MGCSFX
-+ if (wasMgcSfxUp) { MGCSFXDialog(wasMgcSfxUp); wasMgcSfxUp=0; }
-+#endif
- }
- }
- }
-@@ -572,10 +682,21 @@
- #ifdef HAVE_JPEG
- if (jpegUp) { wasJpegUp = jpegUp; JPEGDialog(0); }
- #endif
--
- #ifdef HAVE_TIFF
- if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); }
- #endif
-+#ifdef HAVE_PNG
-+ if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
-+#endif
-+#ifdef HAVE_PCD
-+ if (pcdUp) { wasPcdUp = pcdUp; PCDDialog(0); }
-+#endif
-+#ifdef HAVE_PIC2
-+ if (pic2Up) { wasPic2Up = pic2Up; PIC2Dialog(0); }
-+#endif
-+#ifdef HAVE_MGCSFX
-+ if (mgcsfxUp) { wasMgcSfxUp = mgcsfxUp; MGCSFXDialog(0); }
-+#endif
- }
- }
- }
-@@ -641,6 +762,30 @@
- p_offy = xwa.y;
- }
-
-+ /* Gather info to keep right border inside */
-+ {
-+ Window current;
-+ Window root_r;
-+ Window parent_r;
-+ Window *children_r;
-+ int nchildren_r;
-+ XWindowAttributes xwa;
-+
-+ parent_r=mainW;
-+ current=mainW;
-+ do {
-+ current=parent_r;
-+ XQueryTree(theDisp, current, &root_r, &parent_r,
-+ &children_r, &nchildren_r);
-+ if (children_r!=NULL) {
-+ XFree(children_r);
-+ }
-+ } while(parent_r!=root_r);
-+ XGetWindowAttributes(theDisp, current, &xwa);
-+ debkludge_offx=eWIDE-xwa.width+p_offx;
-+ debkludge_offy=eHIGH-xwa.height+p_offy;
-+ }
-+
-
- /* move window around a bit... */
- {
-@@ -997,7 +1142,8 @@
-
- int i;
- char txt[512], str[PRINTCMDLEN + 10];
-- static char *labels[] = { " Color", " Grayscale", " B/W", "\033Cancel" };
-+ static char *labels[] = { "\03Color", "\07Grayscale", " B/W", "\033Cancel" };
-+ /* ^B ("\02") already used for moving cursor back */
-
- strcpy(txt, "Print: Enter a command that will read a PostScript file ");
- strcat(txt, "from stdin and print it to the desired printer.\n\n");
-@@ -1147,6 +1293,26 @@
- if (TIFFCheckEvent(event)) break;
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break;
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (PCDCheckEvent (event)) break; /* event has been processed */
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ if (PIC2CheckEvent(event)) break;
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ if (MGCSFXCheckEvent(event)) break;
-+#endif
-+
-+#ifdef TV_MULTILINGUAL
-+ if (CharsetCheckEvent(event)) break;
-+#endif
-+
- if (GamCheckEvent (event)) break;
- if (BrowseCheckEvent (event, &retval, &done)) break;
- if (TextCheckEvent (event, &retval, &done)) break;
-@@ -1276,6 +1442,48 @@
- else if (shift) BlurPaint();
- break;
-
-+ case Button4: /* note min vs. max, + vs. - */
-+ if (win == ctrlW || win == nList.win || win == nList.scrl.win) {
-+ SCRL *sp=&nList.scrl;
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val > sp->min+halfpage)
-+ SCSetVal(sp,sp->val-halfpage);
-+ else
-+ SCSetVal(sp,sp->min);
-+ }
-+ else if (win == dirW || win == dList.win || win == dList.scrl.win) {
-+ SCRL *sp=&dList.scrl;
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val > sp->min+halfpage)
-+ SCSetVal(sp,sp->val-halfpage);
-+ else
-+ SCSetVal(sp,sp->min);
-+ }
-+ break;
-+
-+ case Button5: /* note max vs. min, - vs. + */
-+ if (win == ctrlW || win == nList.win || win == nList.scrl.win) {
-+ SCRL *sp=&nList.scrl;
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val < sp->max-halfpage)
-+ SCSetVal(sp,sp->val+halfpage);
-+ else
-+ SCSetVal(sp,sp->max);
-+ }
-+ else if (win == dirW || win == dList.win || win == dList.scrl.win) {
-+ SCRL *sp=&dList.scrl;
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val < sp->max-halfpage)
-+ SCSetVal(sp,sp->val+halfpage);
-+ else
-+ SCSetVal(sp,sp->max);
-+ }
-+ break;
-+
- default: break;
- }
- }
-@@ -1364,16 +1572,35 @@
- if (TIFFCheckEvent(event)) break;
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break;
-+#endif
-+
-+ if (PCDCheckEvent (event)) break;
-+
-+#ifdef HAVE_PIC2
-+ if (PIC2CheckEvent(event)) break;
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (PCDCheckEvent (event)) break;
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ if (MGCSFXCheckEvent(event)) break;
-+#endif
-+
- if (GamCheckEvent (event)) break;
- if (BrowseCheckEvent (event, &retval, &done)) break;
- if (TextCheckEvent (event, &retval, &done)) break;
-
-
-- /* check for pageup/pagedown, 'p' in main window
-- (you can use shift-up or shift-down if no crop rectangle drawn)
-- (for viewing multipage docs) */
-+ /* Support for multi-image files ("multipage docs"). Check for PgUp/PgDn
-+ or 'p' in any window but control or directory; PgUp/PgDn are already
-+ used to page through the file list in those windows. If no cropping
-+ rectangle is active, shift-Up and shift-Down also work. */
-
-- if (key_event->window == mainW) {
-+ if (key_event->window != ctrlW && key_event->window != dirW) {
- dealt = 1;
-
- ck = CursorKey(ks, shift, 0);
-@@ -1578,13 +1805,13 @@
- }
- break;
-
-- case '\010':
-- case '\177': FakeButtonPress(&but[BPREV]); break;
-+ case '\010': FakeButtonPress(&but[BPREV]); break;
-
-
- case '\014': FakeButtonPress(&but[BLOAD]); break; /* ^L */
- case '\023': FakeButtonPress(&but[BSAVE]); break; /* ^S */
- case '\020': FakeButtonPress(&but[BPRINT]); break; /* ^P */
-+ case '\177':
- case '\004': FakeButtonPress(&but[BDELETE]); break; /* ^D */
-
- /* BCOPY, BCUT, BPASTE, BCLEAR handled in 'meta' case */
-@@ -2025,6 +2252,16 @@
- if (xwa->width < dispWIDE && xwc.x < p_offx) xwc.x = p_offx;
- if (xwa->height < dispHIGH && xwc.y < p_offy) xwc.y = p_offy;
-
-+ /* Try to keep bottom right decorations inside */
-+ if (xwc.x+eWIDE-debkludge_offx>dispWIDE) {
-+ xwc.x=dispWIDE-eWIDE+debkludge_offx;
-+ if (xwc.x<0) xwc.x=0;
-+ }
-+ if (xwc.y+eHIGH-debkludge_offy>dispHIGH) {
-+ xwc.y=dispHIGH-eHIGH+debkludge_offy;
-+ if (xwc.y<0) xwc.y=0;
-+ }
-+
- xwc.width = xwa->width;
- xwc.height = xwa->height;
-
-@@ -2370,6 +2607,24 @@
- if (tiffUp) TIFFDialog(0); /* close tiff window */
- #endif
-
-+#ifdef HAVE_PNG
-+ if (pngUp) PNGDialog(0); /* close png window */
-+#endif
-+
-+ if (pcdUp) PCDDialog(0); /* close pcd window */
-+
-+#ifdef HAVE_PIC2
-+ if (pic2Up) PIC2Dialog(0); /* close pic2 window */
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (pcdUp) PCDDialog(0); /* close pcd window */
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ if (mgcsfxUp) MGCSFXDialog(0); /* close mgcsfx window */
-+#endif
-+
- ClosePopUp();
-
- /* make the interrupt signal look like a '\n' keypress in ctrlW */
-@@ -2574,26 +2829,43 @@
- static void paintLine(x,y,x1,y1)
- int x,y,x1,y1;
- {
-- int dx,dy,i,lx,ly,adx,ady;
-+ int t,dx,dy,d,dd;
-
-- dx = x1-x; dy = y1-y;
-- adx = abs(dx); ady = abs(dy);
-+ dx = abs(x1-x); dy = abs(y1-y);
-
-- if (dx == 0 && dy == 0) paintPixel(x,y);
--
-- else if (adx > ady) { /* X is major axis */
-- for (i=0; i<=adx; i++) {
-- lx = x + (i * dx + (adx/2)) / abs(dx);
-- ly = y + (i * dy + (adx/2)) / abs(dx);
-- paintPixel(lx,ly);
-+ if (dx >= dy) { /* X is major axis */
-+ if (x > x1) {
-+ t = x; x = x1; x1 = t;
-+ t = y; y = y1; y1 = t;
-+ }
-+ d = dy + dy - dx;
-+ dd = y < y1 ? 1 : -1;
-+ while (x <= x1) {
-+ paintPixel(x,y);
-+ if (d > 0) {
-+ y += dd;
-+ d -= dx + dx;
-+ }
-+ ++x;
-+ d += dy + dy;
- }
- }
-
- else { /* Y is major axis */
-- for (i=0; i<=ady; i++) {
-- lx = x + (i * dx + (ady/2)) / ady;
-- ly = y + (i * dy + (ady/2)) / ady;
-- paintPixel(lx,ly);
-+ if (y > y1) {
-+ t = x; x = x1; x1 = t;
-+ t = y; y = y1; y1 = t;
-+ }
-+ d = dx + dx - dy;
-+ dd = x < x1 ? 1 : -1;
-+ while (y <= y1) {
-+ paintPixel(x,y);
-+ if (d > 0) {
-+ x += dd;
-+ d -= dy + dy;
-+ }
-+ ++y;
-+ d += dx + dx;
- }
- }
-
-diff -ruN xv-3.10a-bugfixes/xvfits.c xv-3.10a-enhancements/xvfits.c
---- xv-3.10a-bugfixes/xvfits.c 2005-04-02 21:08:45.000000000 -0800
-+++ xv-3.10a-enhancements/xvfits.c 2005-04-17 14:45:28.000000000 -0700
-@@ -14,7 +14,7 @@
- * provided "as is" without express or implied warranty.
- */
-
--
-+#define NEEDSDIR /* for S_IRUSR|S_IWUSR */
- #include "xv.h"
-
- #define NCARDS (36)
-@@ -228,7 +228,7 @@
- * If there was a problem writing files, then a error message will be set.
- */
-
-- int i, npixels=nx * ny, nwrt;
-+ int i, npixels=nx * ny, nwrt, tmpfd;
- FILE *fp;
- char *error;
- char filename[70];
-@@ -254,7 +254,12 @@
-
- for (i=0; i < nz && !error; i++) {
- sprintf(filename, "%s%d", basename, i+1);
-- fp = xv_fopen(filename, "w");
-+ tmpfd = open(filename,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) {
-+ error = "Unable to open temporary file";
-+ break;
-+ }
-+ fp = fdopen(tmpfd, "w");
- if (!fp) {
- error = "Unable to open temporary file";
- break;
-@@ -262,13 +267,17 @@
-
- if (wrheader(fp, nx, ny, comment)) {
- error = "I/O error writing temporary file";
-+ fflush(fp);
- fclose(fp);
- unlink(filename);
-+ close(tmpfd);
- break;
- }
-
- nwrt = fwrite(image+i*npixels, sizeof(byte), (size_t) npixels, fp);
-+ fflush(fp);
- fclose(fp);
-+ close(tmpfd);
-
- if (nwrt == 0) { /* failed to write any data */
- error = "I/O error writing temporary file";
-diff -ruN xv-3.10a-bugfixes/xvgam.c xv-3.10a-enhancements/xvgam.c
---- xv-3.10a-bugfixes/xvgam.c 2004-05-16 18:02:11.000000000 -0700
-+++ xv-3.10a-enhancements/xvgam.c 2004-05-16 18:06:48.000000000 -0700
-@@ -265,11 +265,11 @@
- BTCreate(&gbut[G_BRNDCOL], cmapF, 5 + 66 + 67 + 2, 189, 66, BUTTH,
- "Random", infofg, infobg, hicol, locol);
-
-- DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0,360,180, 5,
-+ DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
- infofg, infobg, hicol, locol, "Hue", NULL);
-- DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0,360,180, 5,
-+ DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
- infofg, infobg, hicol, locol, "Sat.", NULL);
-- DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0,360,180, 5,
-+ DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
- infofg, infobg, hicol, locol, "Value", NULL);
-
- rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor;
-@@ -359,7 +359,7 @@
-
- srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial;
-
-- DCreate(&satDial, hsvF, 100, 199, 100, 121, -100, 100, 0, 5,
-+ DCreate(&satDial, hsvF, 100, 199, 100, 121, -100.0, 100.0, 0.0, 1.0, 5.0,
- infofg, infobg,hicol,locol, "Saturation", "%");
-
- hueRB = RBCreate(NULL, hsvF, 7, 153, "1",
-@@ -722,7 +722,7 @@
-
- if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++;
-
-- if (satDial.val != 0) hsvnonlinear++;
-+ if (satDial.val != 0.0) hsvnonlinear++;
-
- /* check intensity graf */
- for (i=0; i<256 && intGraf.func[i]==i; i++);
-@@ -1291,14 +1291,14 @@
- rgb2hsv(rcmap[editColor], gcmap[editColor], bcmap[editColor], &h, &s, &v);
- if (h<0) h = 0;
-
-- DSetVal(&rhDial, (int) h);
-- DSetVal(&gsDial, (int) (s*100));
-- DSetVal(&bvDial, (int) (v*100));
-+ DSetVal(&rhDial, h);
-+ DSetVal(&gsDial, s*100);
-+ DSetVal(&bvDial, v*100);
- }
- else {
-- DSetVal(&rhDial, rcmap[editColor]);
-- DSetVal(&gsDial, gcmap[editColor]);
-- DSetVal(&bvDial, bcmap[editColor]);
-+ DSetVal(&rhDial, (double)rcmap[editColor]);
-+ DSetVal(&gsDial, (double)gcmap[editColor]);
-+ DSetVal(&bvDial, (double)bcmap[editColor]);
- }
- }
-
-@@ -1310,16 +1310,15 @@
-
- if (hsvmode) {
- int rv, gv, bv;
-- hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0,
-- ((double) bvDial.val) / 100.0, &rv, &gv, &bv);
-+ hsv2rgb(rhDial.val, gsDial.val / 100.0, bvDial.val / 100.0, &rv, &gv, &bv);
- rcmap[editColor] = rv;
- gcmap[editColor] = gv;
- bcmap[editColor] = bv;
- }
- else {
-- rcmap[editColor] = rhDial.val;
-- gcmap[editColor] = gsDial.val;
-- bcmap[editColor] = bvDial.val;
-+ rcmap[editColor] = (int)rhDial.val;
-+ gcmap[editColor] = (int)gsDial.val;
-+ bcmap[editColor] = (int)bvDial.val;
- }
- }
-
-@@ -1561,9 +1560,9 @@
- gsDial.title = "Green";
- bvDial.title = "Blue";
-
-- DSetRange(&rhDial, 0, 255, rcmap[editColor], 16);
-- DSetRange(&gsDial, 0, 255, gcmap[editColor], 16);
-- DSetRange(&bvDial, 0, 255, bcmap[editColor], 16);
-+ DSetRange(&rhDial, 0.0, 255.0, (double)rcmap[editColor], 1.0, 16.0);
-+ DSetRange(&gsDial, 0.0, 255.0, (double)gcmap[editColor], 1.0, 16.0);
-+ DSetRange(&bvDial, 0.0, 255.0, (double)bcmap[editColor], 1.0, 16.0);
-
- XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
- XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
-@@ -1581,9 +1580,9 @@
- &h, &s, &v);
-
- if (h<0.0) h = 0.0;
-- DSetRange(&rhDial, 0, 360, (int) h, 5);
-- DSetRange(&gsDial, 0, 100, (int) (s*100), 5);
-- DSetRange(&bvDial, 0, 100, (int) (v*100), 5);
-+ DSetRange(&rhDial, 0.0, 360.0, h, 1.0, 5.0);
-+ DSetRange(&gsDial, 0.0, 100.0, s*100, 1.0, 5.0);
-+ DSetRange(&bvDial, 0.0, 100.0, v*100, 1.0, 5.0);
-
- XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
- XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
-@@ -1891,7 +1890,7 @@
- }
-
- /* apply satDial value to s */
-- s = s + ((double) satDial.val) / 100.0;
-+ s = s + satDial.val / 100.0;
- if (s<0.0) s = 0.0;
- if (s>1.0) s = 1.0;
-
-@@ -2007,7 +2006,7 @@
-
- gs->hueRBnum = RBWhich(hueRB);
-
-- gs->satval = satDial.val;
-+ gs->satval = (int)satDial.val;
- GetGrafState(&intGraf,&gs->istate);
- GetGrafState(&rGraf, &gs->rstate);
- GetGrafState(&gGraf, &gs->gstate);
-@@ -2064,8 +2063,8 @@
- changed++;
- }
-
-- if (gs->satval != satDial.val) {
-- DSetVal(&satDial,gs->satval);
-+ if (gs->satval != (int)satDial.val) {
-+ DSetVal(&satDial,(double)gs->satval);
- changed++;
- }
-
-@@ -3200,7 +3199,7 @@
-
- if (whtHD.enabCB.val && whtHD.satval) hsvmod++;
-
-- if (satDial.val != 0) hsvmod++;
-+ if (satDial.val != 0.0) hsvmod++;
-
- /* check intensity graf */
- for (i=0; i<256; i++) {
-@@ -3284,7 +3283,7 @@
- }
-
- /* apply satDial value to s */
-- s = s + satDial.val;
-+ s = s + (int)satDial.val;
- if (s< 0) s = 0;
- if (s>100) s = 100;
-
-diff -ruN xv-3.10a-bugfixes/xvgif.c xv-3.10a-enhancements/xvgif.c
---- xv-3.10a-bugfixes/xvgif.c 2005-04-03 11:53:13.000000000 -0700
-+++ xv-3.10a-enhancements/xvgif.c 2005-04-30 21:47:44.000000000 -0700
-@@ -50,6 +50,7 @@
- BytesPerScanline, /* bytes per scanline in output raster */
- ColorMapSize, /* number of colors */
- Background, /* background color */
-+ Transparent, /* transparent color (GRR 19980314) */
- CodeSize, /* Code size, read from GIF header */
- InitCodeSize, /* Starting code size, used during Clear */
- Code, /* Value returned by ReadCode */
-@@ -111,16 +112,20 @@
-
- register byte ch, *origptr;
- register int i, block;
-- int aspect, gotimage;
-+ int aspect;
-+ char tmpname[256];
-+ byte r[256], g[256], b[256];
-
- /* initialize variables */
-- BitOffset = XC = YC = OutCount = gotimage = 0;
-+ BitOffset = XC = YC = OutCount = 0;
- Pass = -1;
- RawGIF = Raster = pic8 = NULL;
- gif89 = 0;
-+ Transparent = -1;
-
- pinfo->pic = (byte *) NULL;
- pinfo->comment = (char *) NULL;
-+ pinfo->numpages= 0;
-
- bname = BaseName(fname);
- fp = xv_fopen(fname,"r");
-@@ -145,7 +150,7 @@
-
- if (fread(dataptr, (size_t) filesize, (size_t) 1, fp) != 1)
- return( gifError(pinfo, "GIF data read failed") );
--
-+ fclose(fp);
-
- origptr = dataptr;
-
-@@ -161,6 +166,7 @@
- RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */
- ch = NEXTBYTE;
- RHeight = ch + 0x100 * NEXTBYTE;
-+ if (DEBUG) fprintf(stderr,"GIF89 logical screen = %d x %d\n",RWidth,RHeight);
-
- ch = NEXTBYTE;
- HasColormap = ((ch & COLORMAPMASK) ? True : False);
-@@ -176,6 +182,8 @@
- if (!gif89) return(gifError(pinfo,"corrupt GIF file (screen descriptor)"));
- else normaspect = (float) (aspect + 15) / 64.0; /* gif89 aspect ratio */
- if (DEBUG) fprintf(stderr,"GIF89 aspect = %f\n", normaspect);
-+ /* FIXME: apparently this _should_ apply to all frames in a multi-image
-+ * GIF (i.e., PgUp/PgDn), but it doesn't */
- }
-
-
-@@ -183,20 +191,23 @@
-
- if (HasColormap)
- for (i=0; i<ColorMapSize; i++) {
-- pinfo->r[i] = NEXTBYTE;
-- pinfo->g[i] = NEXTBYTE;
-- pinfo->b[i] = NEXTBYTE;
-+ r[i] = NEXTBYTE;
-+ g[i] = NEXTBYTE;
-+ b[i] = NEXTBYTE;
- }
- else { /* no colormap in GIF file */
- /* put std EGA palette (repeated 16 times) into colormap, for lack of
- anything better to do */
-
- for (i=0; i<256; i++) {
-- pinfo->r[i] = EGApalette[i&15][0];
-- pinfo->g[i] = EGApalette[i&15][1];
-- pinfo->b[i] = EGApalette[i&15][2];
-+ r[i] = EGApalette[i&15][0];
-+ g[i] = EGApalette[i&15][1];
-+ b[i] = EGApalette[i&15][2];
- }
- }
-+ memcpy(pinfo->r, r, sizeof r);
-+ memcpy(pinfo->g, g, sizeof g);
-+ memcpy(pinfo->b, b, sizeof b);
-
- /* possible things at this point are:
- * an application extension block
-@@ -334,12 +345,28 @@
- if (DEBUG) fprintf(stderr,"Graphic Control extension\n\n");
-
- SetISTR(ISTR_INFO, "%s: %s", bname,
-- "Graphic Control Extension in GIF file. Ignored.");
-+ "Graphic Control Extension ignored.");
-
-- /* read (and ignore) data sub-blocks */
-+ /* read (and ignore) data sub-blocks, unless compositing with
-+ * user-defined background */
- do {
-- j = 0; sbsize = NEXTBYTE;
-- while (j<sbsize) { SKIPBYTE; j++; }
-+ j = 0;
-+ sbsize = NEXTBYTE;
-+ /* GRR 19980314: get transparent index out of block */
-+ if (have_imagebg && sbsize == 4 && Transparent < 0) {
-+ byte packed_fields = NEXTBYTE;
-+
-+ j++;
-+ SKIPBYTE; j++;
-+ SKIPBYTE; j++;
-+ if (packed_fields & 1) {
-+ Transparent = NEXTBYTE;
-+ j++;
-+ }
-+ }
-+ while (j<sbsize) {
-+ SKIPBYTE; j++;
-+ }
- } while (sbsize);
- }
-
-@@ -376,36 +403,42 @@
-
-
- else if (block == IMAGESEP) {
-- if (DEBUG) fprintf(stderr,"imagesep (got=%d) ",gotimage);
-+ if (DEBUG) fprintf(stderr,"imagesep (page=%d) ",pinfo->numpages+1);
- if (DEBUG) fprintf(stderr," at start: offset=0x%x\n",dataptr-RawGIF);
-
-- if (gotimage) { /* just skip over remaining images */
-- int i,misc,ch,ch1;
-+ BitOffset = XC = YC = Pass = OutCount = 0;
-
-- /* skip image header */
-- SKIPBYTE; SKIPBYTE; /* left position */
-- SKIPBYTE; SKIPBYTE; /* top position */
-- SKIPBYTE; SKIPBYTE; /* width */
-- SKIPBYTE; SKIPBYTE; /* height */
-- misc = NEXTBYTE; /* misc. bits */
--
-- if (misc & 0x80) { /* image has local colormap. skip it */
-- for (i=0; i< 1 << ((misc&7)+1); i++) {
-- SKIPBYTE; SKIPBYTE; SKIPBYTE;
-+ if (pinfo->numpages > 0) { /* do multipage stuff */
-+ if (pinfo->numpages == 1) { /* first time only... */
-+ xv_mktemp(pinfo->pagebname, "xvpgXXXXXX");
-+ if (pinfo->pagebname[0] == '\0') {
-+ ErrPopUp("LoadGIF: Unable to create temporary filename???",
-+ "\nHow unlikely!");
-+ return 0;
- }
- }
--
-- SKIPBYTE; /* minimum code size */
--
-- /* skip image data sub-blocks */
-- do {
-- ch = ch1 = NEXTBYTE;
-- while (ch--) SKIPBYTE;
-- if ((dataptr - RawGIF) > filesize) break; /* EOF */
-- } while(ch1);
-+ sprintf(tmpname, "%s%d", pinfo->pagebname, pinfo->numpages);
-+ fp = xv_fopen(tmpname, "w");
-+ if (!fp) {
-+ ErrPopUp("LoadGIF: Unable to open temp file", "\nDang!");
-+ return 0;
-+ }
-+ if (WriteGIF(fp, pinfo->pic, pinfo->type, pinfo->w, pinfo->h, pinfo->r,
-+ pinfo->g, pinfo->b, numcols, pinfo->colType, NULL)) {
-+ fclose(fp);
-+ ErrPopUp("LoadGIF: Error writing temp file", "\nBummer!");
-+ return 0;
-+ }
-+ fclose(fp);
-+ free(pinfo->pic);
-+ pinfo->pic = (byte *) NULL;
-+ if (HasColormap) {
-+ memcpy(pinfo->r, r, sizeof r);
-+ memcpy(pinfo->g, g, sizeof g);
-+ memcpy(pinfo->b, b, sizeof b);
-+ }
- }
--
-- else if (readImage(pinfo)) gotimage = 1;
-+ if (readImage(pinfo)) pinfo->numpages++;
- if (DEBUG) fprintf(stderr," at end: dataptr=0x%x\n",dataptr-RawGIF);
- }
-
-@@ -425,7 +458,7 @@
- sprintf(str, "Unknown block type (0x%02x) at offset 0x%x",
- block, (dataptr - origptr) - 1);
-
-- if (!gotimage) return gifError(pinfo, str);
-+ if (!pinfo->numpages) return gifError(pinfo, str);
- else gifWarning(str);
- }
-
-@@ -438,8 +471,34 @@
- free(RawGIF); RawGIF = NULL;
- free(Raster); Raster = NULL;
-
-- if (!gotimage)
-+ if (!pinfo->numpages)
- return( gifError(pinfo, "no image data found in GIF file") );
-+ if (pinfo->numpages > 1) {
-+ /* write the last page temp file */
-+ int numpages = pinfo->numpages;
-+ char *comment = pinfo->comment;
-+ sprintf(tmpname, "%s%d", pinfo->pagebname, pinfo->numpages);
-+ fp = xv_fopen(tmpname, "w");
-+ if (!fp) {
-+ ErrPopUp("LoadGIF: Unable to open temp file", "\nDang!");
-+ return 0;
-+ }
-+ if (WriteGIF(fp, pinfo->pic, pinfo->type, pinfo->w, pinfo->h, pinfo->r,
-+ pinfo->g, pinfo->b, numcols, pinfo->colType, NULL)) {
-+ fclose(fp);
-+ ErrPopUp("LoadGIF: Error writing temp file", "\nBummer!");
-+ return 0;
-+ }
-+ fclose(fp);
-+ free(pinfo->pic);
-+ pinfo->pic = (byte *) NULL;
-+
-+ /* load the first page temp file */
-+ sprintf(tmpname, "%s%d", pinfo->pagebname, 1);
-+ i = LoadGIF(tmpname, pinfo);
-+ pinfo->numpages = numpages;
-+ pinfo->comment = comment;
-+ }
-
- return 1;
- }
-@@ -484,6 +543,17 @@
- }
-
-
-+ /* GRR 19980314 */
-+ /* need not worry about size of EGA palette: full 256 colors */
-+ if (have_imagebg && Transparent >= 0 &&
-+ Transparent < ((Misc&0x80)? (1 << ((Misc&7)+1)) : ColorMapSize) )
-+ {
-+ pinfo->r[Transparent] = (imagebgR >> 8);
-+ pinfo->g[Transparent] = (imagebgG >> 8);
-+ pinfo->b[Transparent] = (imagebgB >> 8);
-+ }
-+
-+
-
- /* Start reading the raster data. First we get the intial code size
- * and compute decompressor constant values, based on this code size.
-@@ -540,7 +610,7 @@
- return( gifError(pinfo, "image dimensions out of range") );
- picptr = pic8 = (byte *) malloc((size_t) maxpixels);
- if (!pic8) FatalError("LoadGIF: couldn't malloc 'pic8'");
--
-+
-
-
- /* Decompress the file, continuing until you see the GIF EOF code.
-@@ -642,11 +712,10 @@
- SetISTR(ISTR_WARNING,"%s: %s", bname,
- "This GIF file seems to be truncated. Winging it.");
- if (!Interlace) /* clear->EOBuffer */
-- xvbzero((char *) pic8+npixels, (size_t) (maxpixels-npixels));
-+ xvbzero((char *) pic8+npixels,
-+ (size_t) (maxpixels-npixels<0 ? 0 : maxpixels-npixels));
- }
-
-- fclose(fp);
--
- /* fill in the PICINFO structure */
-
- pinfo->pic = pic8;
-diff -ruN xv-3.10a-bugfixes/xvgrab.c xv-3.10a-enhancements/xvgrab.c
---- xv-3.10a-bugfixes/xvgrab.c 2004-05-16 18:03:30.000000000 -0700
-+++ xv-3.10a-enhancements/xvgrab.c 2005-04-25 23:39:32.000000000 -0700
-@@ -14,6 +14,13 @@
- #define NEEDSTIME
- #include "xv.h"
-
-+/* Allow flexibility in use of buttons JPD */
-+#define WINDOWGRABMASK Button1Mask /* JPD prefers Button2Mask */
-+#define RECTGTRACKMASK Button2Mask /* JPD prefers Button1Mask*/
-+#define CANCELGRABMASK Button3Mask
-+
-+#define DO_GRABFLASH /* JPD prefers not to do that; just a loss of time ... */
-+
-
- union swapun {
- CARD32 l;
-@@ -69,12 +76,15 @@
- 0 if cancelled */
-
- int i, x, y, x1, y1, x2, y2, ix, iy, iw, ih, rv;
-- int rx, ry, pretendGotB1, autograb;
-+ int rx, ry, GotButton, autograb;
-+ int cancelled = 0;
- Window rW, cW, clickWin;
- unsigned int mask;
-+#ifdef RECOLOR_GRAB_CURSOR
- XColor fc, bc;
-+#endif
-
-- pretendGotB1 = 0;
-+ GotButton = 0;
-
- if (grabInProgress) return 0; /* avoid recursive grabs during delay */
-
-@@ -122,15 +132,23 @@
- free(grabPic); grabPic = (byte *) NULL;
- }
-
--
-+ /* recolor cursor to indicate that grabbing is active? */
-+ /* Instead, change cursor JPD */
-+#ifdef RECOLOR_GRAB_CURSOR
- fc.flags = bc.flags = DoRed | DoGreen | DoBlue;
- fc.red = fc.green = fc.blue = 0xffff;
- bc.red = bc.green = bc.blue = 0x0000;
- XRecolorCursor(theDisp, tcross, &fc, &bc);
-+#endif
-
-
- XBell(theDisp, 0); /* beep once at start of grab */
-
-+ /* Change cursor to top_left_corner JPD */
-+ XGrabPointer(theDisp, rootW, False,
-+ PointerMotionMask|ButtonPressMask|ButtonReleaseMask,
-+ GrabModeAsync, GrabModeAsync, None, tlcorner, CurrentTime);
-+
- if (!autograb) XGrabButton(theDisp, (u_int) AnyButton, 0, rootW, False, 0,
- GrabModeAsync, GrabModeSync, None, tcross);
-
-@@ -142,7 +160,7 @@
- rv = 0;
- goto exit;
- }
-- else { pretendGotB1 = 1; mask = Button1Mask; }
-+ else { GotButton = 1; mask = WINDOWGRABMASK; }
- }
-
- else { /* !autograb */
-@@ -170,16 +188,20 @@
- }
- }
-
-+ XUngrabPointer(theDisp, CurrentTime);
-+ /* Reset cursor to XC_tcross JPD */
-+ XGrabPointer(theDisp, rootW, False,
-+ PointerMotionMask|ButtonPressMask|ButtonReleaseMask,
-+ GrabModeAsync, GrabModeAsync, None, tcross, CurrentTime);
-
- /***
- *** got button click (or pretending we did, if autograb)
- ***/
-
--
-- if (mask & Button3Mask || rW!=rootW) { /* Button3: CANCEL GRAB */
-+ if (mask & CANCELGRABMASK || rW!=rootW) { /* CANCEL GRAB */
- while (1) { /* wait for button to be released */
- if (XQueryPointer(theDisp,rootW,&rW,&cW,&rx,&ry,&x1,&y1,&mask)) {
-- if (!(mask & Button3Mask)) break;
-+ if (!(mask & CANCELGRABMASK)) break;
- }
- }
-
-@@ -187,19 +209,21 @@
- XBell(theDisp, 0);
- XBell(theDisp, 0);
- rv = 0;
-+ cancelled = 1;
- goto exit;
- }
-
-
--
-- if (mask & Button1Mask) { /* Button1: GRAB WINDOW (& FRAME, maybe) */
-- while (!pretendGotB1) { /* wait for button to be released, if clicked */
-+ if (mask & WINDOWGRABMASK) { /* GRAB WINDOW (& FRAME, maybe) */
-+ while (!GotButton) { /* wait for button to be released, if clicked */
- int rx,ry,x1,y1; Window rW, cW;
- if (XQueryPointer(theDisp,rootW,&rW,&cW,&rx,&ry,&x1,&y1,&mask)) {
-- if (!(mask & Button1Mask)) break;
-+ if (!(mask & WINDOWGRABMASK)) break;
- }
- }
-
-+ grabwin:
-+
- clickWin = (cW) ? cW : rootW;
-
- if (clickWin == rootW) { /* grab entire screen */
-@@ -223,7 +247,6 @@
- }
- }
-
--
- /* range checking: keep rectangle fully on-screen */
- if (ix<0) { iw += ix; ix = 0; }
- if (iy<0) { ih += iy; iy = 0; }
-@@ -244,8 +267,7 @@
- endflash();
- }
-
--
-- else { /* Button2: TRACK A RECTANGLE */
-+ else { /* TRACK A RECTANGLE */
- int origrx, origry;
-
- clickWin = rootW;
-@@ -259,7 +281,7 @@
- /* Wait for button release while tracking rectangle on screen */
- while (1) {
- if (XQueryPointer(theDisp,rootW,&rW,&cW,&rx,&ry,&x,&y,&mask)) {
-- if (!(mask & Button2Mask)) break;
-+ if (!(mask & RECTGTRACKMASK)) break;
- }
-
- flashrect(ix, iy, iw, ih, 0); /* turn off rect */
-@@ -276,6 +298,7 @@
-
- flashrect(ix, iy, iw, ih, 0); /* turn off rect */
-
-+#ifdef DO_GRABFLASH
- /* flash the rectangle a bit... */
- for (i=0; i<5; i++) {
- flashrect(ix, iy, iw, ih, 1);
-@@ -283,13 +306,26 @@
- flashrect(ix, iy, iw, ih, 0);
- XFlush(theDisp); Timer(100);
- }
-+#endif
-+
- endflash();
-
-+ /* if rectangle has zero width or height, search for child window JPD */
-+ if (iw==0 && ih==0) {
-+ int xr, yr;
-+ Window childW = 0;
-+ if (rW && cW)
-+ XTranslateCoordinates(theDisp, rW, cW, rx, ry, &xr, &yr, &childW);
-+ if (childW)
-+ cW = childW;
-+ goto grabwin;
-+ }
-+
- XUngrabServer(theDisp);
- }
-
--
- /***
-+ *** now that clickWin,ix,iy,iw,ih are known, try to grab the bits :
- *** grab screen area (ix,iy,iw,ih)
- ***/
-
-@@ -303,9 +339,16 @@
-
- SetCursors(-1);
-
--
- exit:
-
-+ XUngrabPointer(theDisp, CurrentTime);
-+ XUngrabServer(theDisp);
-+
-+ if (startGrab) {
-+ startGrab = 0;
-+ if (cancelled) Quit(0);
-+ }
-+
- if (hidewins) { /* remap XV windows */
- autoclose += 2; /* force it on once */
- if (mainW && dispMode == RMB_WINDOW) {
-@@ -1217,7 +1260,3 @@
-
- return 1;
- }
--
--
--
--
-diff -ruN xv-3.10a-bugfixes/xvhips.c xv-3.10a-enhancements/xvhips.c
---- xv-3.10a-bugfixes/xvhips.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvhips.c 2005-04-30 23:49:14.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvhips.c xv-3.10a/xvhips.c
+--- xv-3.10a.orig/xvhips.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvhips.c 2005-05-01 01:49:14.000000000 -0500
@@ -0,0 +1,406 @@
+/*
+ * xvhips.c - load routine for 'HIPS' format pictures
@@ -8911,9 +1948,9 @@ diff -ruN xv-3.10a-bugfixes/xvhips.c xv-3.10a-enhancements/xvhips.c
+}
+
+#endif /* HAVE_HIPS */
-diff -ruN xv-3.10a-bugfixes/xvhips.h xv-3.10a-enhancements/xvhips.h
---- xv-3.10a-bugfixes/xvhips.h 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvhips.h 2005-04-25 08:34:14.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvhips.h xv-3.10a/xvhips.h
+--- xv-3.10a.orig/xvhips.h 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvhips.h 2005-04-25 10:34:14.000000000 -0500
@@ -0,0 +1,154 @@
+/*
+ * HIPL Picture Header Format Standard
@@ -9069,804 +2106,1339 @@ diff -ruN xv-3.10a-bugfixes/xvhips.h xv-3.10a-enhancements/xvhips.h
+#ifndef SIGN
+# define SIGN(A,B) (((B) > 0) ? (A) : (-(A)))
+#endif /* SIGN */
-diff -ruN xv-3.10a-bugfixes/xvimage.c xv-3.10a-enhancements/xvimage.c
---- xv-3.10a-bugfixes/xvimage.c 2005-03-31 07:23:39.000000000 -0800
-+++ xv-3.10a-enhancements/xvimage.c 2005-04-17 23:00:10.000000000 -0700
-@@ -21,6 +21,16 @@
- * int LoadPad(pinfo, fname);
- */
-
-+/* The following switch should better be provided at runtime for
-+ * comparison purposes.
-+ * At the moment it's only compile time, unfortunately.
-+ * Who can make adaptions for use as a runtime switch by a menu option?
-+ * [GRR 19980607: now via do_fixpix_smooth global; macro renamed to ENABLE_]
-+ * [see http://sylvana.net/fixpix/ for home page, further info]
-+ */
-+/* #define ENABLE_FIXPIX_SMOOTH */ /* GRR 19980607: moved into xv.h */
-+
-+#define NEEDSDIR /* for S_IRUSR|S_IWUSR */
- #include "copyright.h"
-
- #include "xv.h"
-@@ -36,7 +46,9 @@
- static int doAutoCrop24 PARM((void));
- static void floydDitherize1 PARM((XImage *, byte *, int, int, int,
- byte *, byte *,byte *));
-+#if 0 /* NOTUSED */
- static int highbit PARM((unsigned long));
-+#endif
-
- static int doPadSolid PARM((char *, int, int, int, int));
- static int doPadBggen PARM((char *, int, int, int, int));
-@@ -46,6 +58,267 @@
- static int ReadImageFile1 PARM((char *, PICINFO *));
-
-
-+/* The following array represents the pixel values for each shade
-+ * of the primary color components.
-+ * If 'p' is a pointer to a source image rgb-byte-triplet, we can
-+ * construct the output pixel value simply by 'oring' together
-+ * the corresponding components:
+diff -u -r --new-file xv-3.10a.orig/xvjp2k.c xv-3.10a/xvjp2k.c
+--- xv-3.10a.orig/xvjp2k.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvjp2k.c 2007-05-13 20:04:37.000000000 -0500
+@@ -0,0 +1,1326 @@
++/*
++ * xvjp2k.c - I/O subroutines for JPEG 2000 format pictures
+ *
-+ * unsigned char *p;
-+ * unsigned long pixval;
++ * This module is a "shim" between XV and a JPEG 2000 CODEC in the open-source
++ * JasPer Library created by Michael D. Adams; for more information, see the URL
++ * "http://www.ece.uvic.ca/~mdadams/jasper". We don't use most of the other
++ * facilities in this library, so it's better to link XV with a UNIX "archive"
++ * representation of it, not a DLL.
+ *
-+ * pixval = screen_rgb[0][*p++];
-+ * pixval |= screen_rgb[1][*p++];
-+ * pixval |= screen_rgb[2][*p++];
++ * JPEG 2000 files can be represented in either of two general ways: The
++ * simplest representation is a "code stream", which often has a ".jpc" file
++ * name suffix and is organized much like a classical JPEG file, except that
++ * unfortunately, JPEG 2000 code streams indicate the no. of colors in an image
++ * but no longer give any clues about its color space (e.g., RGB or YCbCr).
++ * Instead, there is now a semantically higher-level representation, which often
++ * has a ".jp2" file name suffix and encapsulates a "code stream" with (possibly
++ * a lot of) color-space information, optionally including things like ICC
++ * correction tables.
+ *
-+ * This is both efficient and generic, since the only assumption
-+ * is that the primary color components have separate bits.
-+ * The order and distribution of bits does not matter, and we
-+ * don't need additional variables and shifting/masking code.
-+ * The array size is 3 KBytes total and thus very reasonable.
-+ */
-+
-+static unsigned long screen_rgb[3][256];
-+
-+/* The following array holds the exact color representations
-+ * reported by the system.
-+ * This is useful for less than 24 bit deep displays as a base
-+ * for additional dithering to get smoother output.
-+ */
-+
-+static byte screen_set[3][256];
-+
-+/* The following routine initializes the screen_rgb and screen_set
-+ * arrays.
-+ * Since it is executed only once per program run, it does not need
-+ * to be super-efficient.
++ * Compared to the IJG JPEG Library used in file "xvjpeg.c", one must solve
++ * several problems for color images when marrying JasPer to XV.
++ *
++ * 1. JPEG 2000 files can represent a wide range of image sizes, resolutions,
++ * and color spaces, not all of which can be easily rendered "as is" on a
++ * normal "X Windows" display, so we must carefully check a decoded image's
++ * parameters in order to reject anything that we can't handle gracefully.
++ *
++ * 2. JasPer prefers to decode/encode images using color-plane "slices", instead
++ * of interleaved pixels needed by "X Windows", so we must (de)interleave
++ * copies of the image buffer here.
++ *
++ * XXX Things to do:
+ *
-+ * The method is to draw points in a pixmap with the specified shades
-+ * of primary colors and then get the corresponding XImage pixel
-+ * representation.
-+ * Thus we can get away with any Bit-order/Byte-order dependencies.
++ * 1. In "LoadJP{2,C}()" try to handle the "quick" option, which requests
++ * faster loading of a reduced-size image for the visual schnauzer. The
++ * schnauzer's icon size is currently 80x60, so the old "xvjpeg.c" module tries
++ * to produce a 2X (160x120) image. Can we do the same?
+ *
-+ * The routine uses some global X variables: theDisp, theScreen,
-+ * and dispDEEP. Adapt these to your application as necessary.
-+ * I've not passed them in as parameters, since for other platforms
-+ * than X these may be different (see vfixpix.c), and so the
-+ * screen_init() interface is unique.
++ * 2. In "StoreJP2K()", JasPer Library Version 1.701 apparently has no API to
++ * let the XV global "picComments" string be inserted in a JPEG 2000 comment
++ * record. If the library ever gets fixed, enhance our code accordingly.
+ *
-+ * BUG: I've read in the "Xlib Programming Manual" from O'Reilly &
-+ * Associates, that the DefaultColormap in TrueColor might not
-+ * provide the full shade representation in XAllocColor.
-+ * In this case one had to provide a 'best' colormap instead.
-+ * However, my tests with Xaccel on a Linux-Box with a Mach64
-+ * card were fully successful, so I leave that potential problem
-+ * to you at the moment and would appreciate any suggestions...
++ * --Scott Marovich <marovich@hpl.hp.com>, Hewlett-Packard Laboratories,
++ * January 2005.
+ */
++#include "copyright.h"
+
-+static void screen_init()
-+{
-+ static int init_flag; /* assume auto-init as 0 */
-+ Pixmap check_map;
-+ GC check_gc;
-+ XColor check_col;
-+ XImage *check_image;
-+ int ci, i;
-+
-+ if (init_flag) return;
-+ init_flag = 1;
-+
-+ check_map = XCreatePixmap(theDisp, RootWindow(theDisp,theScreen),
-+ 1, 1, dispDEEP);
-+ check_gc = XCreateGC(theDisp, check_map, 0, NULL);
-+ for (ci = 0; ci < 3; ci++) {
-+ for (i = 0; i < 256; i++) {
-+ check_col.red = 0;
-+ check_col.green = 0;
-+ check_col.blue = 0;
-+ /* Do proper upscaling from unsigned 8 bit (image data values)
-+ to unsigned 16 bit (X color representation). */
-+ ((unsigned short *)&check_col.red)[ci] = (unsigned short)((i << 8) | i);
-+ if (theVisual->class == TrueColor)
-+ XAllocColor(theDisp, theCmap, &check_col);
-+ else
-+ xvAllocColor(theDisp, theCmap, &check_col);
-+ screen_set[ci][i] =
-+ (((unsigned short *)&check_col.red)[ci] >> 8) & 0xff;
-+ XSetForeground(theDisp, check_gc, check_col.pixel);
-+ XDrawPoint(theDisp, check_map, check_gc, 0, 0);
-+ check_image = XGetImage(theDisp, check_map, 0, 0, 1, 1,
-+ AllPlanes, ZPixmap);
-+ if (check_image) {
-+ switch (check_image->bits_per_pixel) {
-+ case 8:
-+ screen_rgb[ci][i] = *(CARD8 *)check_image->data;
-+ break;
-+ case 16:
-+ screen_rgb[ci][i] = *(CARD16 *)check_image->data;
-+ break;
-+ case 24:
-+ screen_rgb[ci][i] =
-+ ((unsigned long)*(CARD8 *)check_image->data << 16) |
-+ ((unsigned long)*(CARD8 *)(check_image->data + 1) << 8) |
-+ (unsigned long)*(CARD8 *)(check_image->data + 2);
-+ break;
-+ case 32:
-+ screen_rgb[ci][i] = *(CARD32 *)check_image->data;
-+ break;
-+ }
-+ XDestroyImage(check_image);
-+ }
-+ }
-+ }
-+ XFreeGC(theDisp, check_gc);
-+ XFreePixmap(theDisp, check_map);
-+}
++#define NEEDSARGS
++#include "xv.h"
+
++#ifdef HAVE_JP2K
++
++#include <jasper/jasper.h>
++/* missing prototype in 1.701.0, sigh: */
++jas_stream_t *jas_stream_freopen PARM((const char *, const char *, FILE *));
++
++static const char *fbasename, /* File's base name, for error/warning msgs */
++ bad_samp[] = "%s: can't read %d-plane %s file!",
++ fmode[] = "rb",
++ full_msg[] = "%s %s. (%ld bytes)",
++ jp2_kind[] = "JP2",
++ jpc_kind[] = "JPEG 2000",
++ load_msg[] = "Loading %dx%d %s %s (%ld bytes)...",
++ no_mem[] = "%s: can't read %s file - out of memory",
++ pixel_size[] = "%s: can't display %d-bit pixels!",
++ shrt_msg[] = "%dx%d %s %s. ",
++ truncated[] = "%s: Unexpected end of %s file",
++ read_err[] = "%s: I/O error reading %s file",
++ bad_dims[] = "%s: error in JPEG-2000 header (bad image size)";
++
++/* We only want to override the JasPer Library's "jas_eprintf()" subroutine in
++ order to make it a "wrapper" around XV's own error-reporting subroutine, but
++ because of the way the former is currently packaged in JasPer Library Version
++ 1.701, we must override everything else packaged in the "jas_debug.o" module
++ with it, otherwise we get "duplicate definition" messages from the linker.
++*/
++int jas_getdbglevel(void) {return 0;}
++int jas_setdbglevel(int n) {return 0;}
++int jas_memdump(FILE *fp,void *data,size_t len) {return 0;}
++
++int jas_eprintf(const char *fmt,...) /* Handle JasPer Library message */
++{
++ static char error[] = "error: ", warning[]= "warning: ";
++ va_list ap;
++ int kind = ISTR_WARNING;
++ char buffer[512];
++ register char *p;
++
++ /* Unlike the IJG JPEG Library, the JasPer Library current has no graceful way
++ for an application (= us!) to intercept its diagnostic messages and output
++ them using our own subroutines, so this ugly replacement for its output
++ subroutine will have to suffice. At Version 1.701, lthough the library's
++ own "jas_eprintf()" is a varargs subroutine, all calls currently pass just
++ 1 string with a Line Feed at the end and no "printf(3C)" arguments. Most
++ strings begin with "error: " or "warning: ", although a few have neither.
++ We try to translate these into the format preferred by XV, trimming any
++ trailing Line Feed character (ugh!).
++ */
++ va_start(ap, fmt);
++ vsnprintf(p = buffer,512,fmt,ap);
++ va_end(ap);
++ while (*p++);
++ if (p[-2] == '\n') p[-2] = '\0';
++ p = buffer;
++ if (strncmp(p,error,sizeof error) == 0) /* "error: ... " */
++ {
++ kind = ISTR_WARNING;
++ p += sizeof error;
++ }
++ else /* "warning: ... " */
++ if (strncmp(p,warning,sizeof warning) == 0)
++ {
++ kind = ISTR_INFO;
++ p += sizeof warning;
++ };
++ SetISTR(kind,"%s: %s",fbasename,p);
++ return strlen(fmt);
++}
++
++static char *SetBuf(FILE *f)
++{
++ char *buf;
++ register char *p;
++
++ /* JPEG 2000 image files are apt to be large, but the buffer size allocated by
++ most implementations of the "C" Standard I/O Library is still ridiculously
++ small, typically 1 KB. We want to allocate a much larger buffer for higher
++ I/O efficiency, but the details are unfortunately a bit platform-specific.
++ Under UNIX systems with virtual memory, we want to encourage its internal
++ "physio()" subroutine by making the buffer an integral number of pages,
++ aligned on a page-multiple memory address boundary. Under HP-UX 11.1+ and
++ perhaps other operating-systems, a Standard I/O buffer is preceded by a
++ header whose size must also be taken into account.
++ */
++# ifndef IOBUFSIZ
++# define IOBUFSIZ 65536
++# endif /* IOBUFSIZ */
++# ifdef __hpux
++# define OVERHEAD sizeof(mbstate_t)
++# endif /* __hpux */
++# ifndef OVERHEAD
++# define OVERHEAD 0
++# endif /* OVERHEAD */
++
++# ifdef NBPG
++ if (!(buf = p = malloc(NBPG+OVERHEAD+IOBUFSIZ))) return 0;
++ p = (char *)((unsigned long)p+NBPG-1 & ~(NBPG-1));
++ p -= OVERHEAD;
++# else /* not NBPG */
++ if (!(buf = p = malloc(OVERHEAD+IOBUFSIZ))) return 0;
++ p += OVERHEAD;
++# endif /* NBPG */
++ setvbuf(f,p,_IOFBF,OVERHEAD+IOBUFSIZ);
++ return buf;
++# undef OVERHEAD
++# undef IOBUFSIZ
++}
++
++int LoadJPC(char *fname,register PICINFO *pinfo,int quick)
++{
++ jas_image_t *img;
++ jas_stream_t *str;
++ FILE *fp;
++ char *iobuf;
++ const char *s;
++ unsigned long filesize;
++ long w, h, npixels, bufsize;
++ int ok = 0, vstride;
++ register int i;
++
++ /* Load a JPEG 2000 "code stream" image file into a pixel buffer for XV.
++ Unlike classical JPEG files, they have no clue about the image's color
++ space, so we check for 8-bit data samples but make no effort to check or
++ convert color spaces, and "what you see is what you get". For now, ignore
++ the "quick" option to return a reduced-resolution or -size image. Return 1
++ on success, or 0 on failure.
++ */
++ if (!(fp = xv_fopen(fname,fmode))) return 0;
++ fbasename = BaseName(fname); /* Input file's base name, for message(s) */
++ if (!(iobuf = SetBuf(fp)))
++ {
++ (void)fclose(fp);
++ SetISTR(ISTR_WARNING,no_mem,fbasename,jpc_kind);
++ goto L3;
++ }
+
-+#ifdef ENABLE_FIXPIX_SMOOTH
++ /* Before telling the JasPer Library about this file, get its size for display
++ purposes. Non-UNIX systems don't necessarily simulate "stat(2)", so do it
++ crudely but portably by seeking to the end, then back to the beginning.
++ */
++ fseek(fp,0L,2);
++ filesize = ftell(fp);
++ fseek(fp,0L,0);
+
-+/* The following code is based in part on:
-+ *
-+ * jquant1.c
-+ *
-+ * Copyright (C) 1991-1996, Thomas G. Lane.
-+ * This file is part of the Independent JPEG Group's software.
-+ * For conditions of distribution and use, see the accompanying README file.
-+ *
-+ * This file contains 1-pass color quantization (color mapping) routines.
-+ * These routines provide mapping to a fixed color map using equally spaced
-+ * color values. Optional Floyd-Steinberg or ordered dithering is available.
++ /* "jas_stream_close()" will eventually close the input file, so only do it
++ explicitly if no stream can be created:
+ */
++ if (!(str = jas_stream_freopen(fname,fmode,fp))) /* nice if prototype... */
++ {
++ (void)fclose(fp);
++ goto L3;
++ }
+
-+/* Declarations for Floyd-Steinberg dithering.
-+ *
-+ * Errors are accumulated into the array fserrors[], at a resolution of
-+ * 1/16th of a pixel count. The error at a given pixel is propagated
-+ * to its not-yet-processed neighbors using the standard F-S fractions,
-+ * ... (here) 7/16
-+ * 3/16 5/16 1/16
-+ * We work left-to-right on even rows, right-to-left on odd rows.
-+ *
-+ * We can get away with a single array (holding one row's worth of errors)
-+ * by using it to store the current row's errors at pixel columns not yet
-+ * processed, but the next row's errors at columns already processed. We
-+ * need only a few extra variables to hold the errors immediately around the
-+ * current column. (If we are lucky, those variables are in registers, but
-+ * even if not, they're probably cheaper to access than array elements are.)
-+ *
-+ * We provide (#columns + 2) entries per component; the extra entry at each
-+ * end saves us from special-casing the first and last pixels.
++ /* It's not clear to me whether the following represents a JasPer Library "bug"
++ but it sure looks goofy: Unless a stream buffer is marked "read only",
++ which only happens when the stream's "fillbuf" method is called, even though
++ our buffers are always "read only", the library will try to flush out buffer
++ contents when the stream is destroyed, which makes it die a horrible death.
++ So, mark the stream buffer proactively:
+ */
++ str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */
++ if (!(img = jpc_decode(str,0))) goto L2;
++ if ((vstride = jas_image_numcmpts(img))) /* num. color planes */
++ {
+
-+typedef INT16 FSERROR; /* 16 bits should be enough */
-+typedef int LOCFSERROR; /* use 'int' for calculation temps */
++ /* After the image-component streams created, they are left in a "write"
++ state with the streams' cursors positioned at their ends, so "seek" in
++ order to "read" each stream from its beginning.
++ */
++ i = vstride;
++ while (--i >= 0)
++ if (jas_stream_seek(img->cmpts_[i]->stream_,0L,0))
++ {
++ SetISTR(ISTR_WARNING,read_err,fbasename,jpc_kind);
++ goto L1;
++ }
++ }
++ w = jas_image_width(img);
++ h = jas_image_height(img);
+
-+typedef struct { byte *colorset;
-+ FSERROR *fserrors;
-+ } FSBUF;
++ /* avoid buffer overflow */
++ npixels = w * h;
++ bufsize = vstride * npixels;
++ if (w <= 0 || h <= 0 || npixels/w != h || bufsize/vstride != npixels)
++ {
++ (void)fclose(fp);
++ SetISTR(ISTR_WARNING,bad_dims,fbasename);
++ goto L1;
++ }
++ pinfo->normw = pinfo->w = w;
++ pinfo->normh = pinfo->h = h;
+
-+/* Floyd-Steinberg initialization function.
-+ *
-+ * It is called 'fs2_init' since it's specialized for our purpose and
-+ * could be embedded in a more general FS-package.
-+ *
-+ * Returns a malloced FSBUF pointer which has to be passed as first
-+ * parameter to subsequent 'fs2_dither' calls.
-+ * The FSBUF structure does not need to be referenced by the calling
-+ * application, it can be treated from the app like a void pointer.
-+ *
-+ * The current implementation does only require to free() this returned
-+ * pointer after processing.
-+ *
-+ * Returns NULL if malloc fails.
-+ *
-+ * NOTE: The FSBUF structure is designed to allow the 'fs2_dither'
-+ * function to work with an *arbitrary* number of color components
-+ * at runtime! This is an enhancement over the IJG code base :-).
-+ * Only fs2_init() specifies the (maximum) number of components.
++ /* Sanity-check the image's color space and no. of colors. For now, accept
++ only "generic" color spaces, not files needing image-specific color
++ correction, but fix that someday...
+ */
++ switch (vstride)
++ {
++ default:
++ SetISTR(ISTR_WARNING,bad_samp,fbasename,vstride,jpc_kind);
++ goto L1;
++ case 1:
++ if ((i = jas_image_cmptprec(img,0)) != 8) /* not 8-bit pixels */
++ {
++ SetISTR(ISTR_WARNING,pixel_size,fbasename,i);
++ goto L1;
++ }
++ s = "Greyscale";
++ pinfo->type = PIC8;
++ pinfo->colType = F_GREYSCALE;
++ i = 256; /* Return fake indexed-color "map" */
++ while (--i >= 0) pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
++ break;
++ case 3:
++
++ /* BEWARE OF KLUDGE: If the image's color space is RGB, assume that the
++ data-sample precision for all color planes is the
++ same. If the color space is YCbCr, assume the luminance (Y = 0th)
++ component has the greatest precision, although the chrominance
++ (Cr = 1st, Cb = 2nd) components are usually sub-sampled.
++ */
++ if ((i = jas_image_cmptprec(img,0)) != 8) /* not 24-bit pixels */
++ {
++ SetISTR(ISTR_WARNING,pixel_size,fbasename,i*3);
++ goto L1;
++ }
++ s = "Color";
++ pinfo->type = PIC24;
++ pinfo->colType = F_FULLCOLOR;
++
++ /* XXX Unlike the IJG JPEG Library, the JasPer Library is apparently
++ unable to quantize colors or tell us whether the image's colors
++ were quantized by its creator, so it seems that we can't return a
++ color map for XV to potentially use 8-bit indexed color. If there
++ *is* an easy way to do it that escapes me, put the code here someday.
++ */
++ }
++ if (!(pinfo->pic = (byte *)malloc(bufsize))) /* image buffer for XV */
++ {
++ SetISTR(ISTR_WARNING,no_mem,fbasename,jpc_kind);
++ goto L1;
++ }
++ pinfo->frmType = F_JPC;
++ sprintf(pinfo->fullInfo,full_msg,s,jpc_kind,filesize);
++ sprintf(pinfo->shrtInfo,shrt_msg,pinfo->w,pinfo->h,s,jpc_kind);
++ SetISTR(ISTR_INFO,load_msg,pinfo->normw,pinfo->normh,s,jpc_kind,filesize);
++ if (vstride == 1) /* gray-scale image */
++ { register jas_stream_t *c = img->cmpts_[0]->stream_;
++ register byte *p = pinfo->pic;
++
++ /* Since this is a 1-plane image, avoid a lot of errant nonsense in the
++ JasPer Library by sequentially reading all of the data into our buffer
++ directly.
++ */
++ do if ((i = (*c->ops_->read_)(c->obj_,(char *)p,bufsize)) <= 0)
++ {
++ SetISTR(ISTR_WARNING,i < 0 ? read_err : truncated,fbasename,
++ jpc_kind);
++ goto L1;
++ }
++ while ((p += i),(bufsize -= i) > 0);
++ }
++ else /* RGB color image */
++ {
+
-+static FSBUF *fs2_init(width)
-+int width;
++ /* Reading color images is inefficient because JPEG 2000 wants to partition
++ file data into separate image planes (colors), while XV wants data
++ samples from each plane to be interleaved as 3-byte pixels. Apparently
++ the fastest method consists of 3 passes through the XV image buffer,
++ into which we insert the bytes of each component.
++ */
++ i = 0;
++ do /* each color component */
++ { long npix = npixels;
++ register jas_stream_t *c = img->cmpts_[i]->stream_;
++ register byte *p = pinfo->pic + i;
++
++ do /* each pixel */
++ { register int b;
++
++ if ((b = jas_stream_getc(c)) < 0)
++ {
++ SetISTR(ISTR_WARNING,
++ (c->flags_ & JAS_STREAM_EOF) ? truncated : read_err,
++ fbasename,jpc_kind);
++ goto L1;
++ }
++ *p = b;
++ }
++ while ((p += 3),--npix > 0);
++ }
++ while (++i <= 2);
++ }
++ ok = 1; /* Success! */
++L1: jas_image_destroy(img);
++L2: (void)jas_stream_close(str);
++ free(iobuf);
++L3: return ok;
++}
++
++int LoadJP2(char *fname,register PICINFO *pinfo,int quick)
+{
-+ FSBUF *fs;
-+ FSERROR *p;
++ jas_image_t *img;
++ jas_stream_t *str;
++ FILE *fp;
++ char *iobuf;
++ const char *s;
++ unsigned long filesize;
++ long w, h, npixels, bufsize;
++ int ok = 0, vstride;
++ register int i;
++
++ /* Load a JPEG 2000 JP2 image file into a pixel buffer for XV, doing any
++ necessary color-space conversion to end up with 8-bit gray scale or 24-bit
++ RGB. For now, ignore the "quick" option to return a reduced-resolution
++ or -size image. Return 1 on success, or 0 on failure.
++ */
++ if (!(fp = xv_fopen(fname,fmode))) return 0;
++ fbasename = BaseName(fname); /* Input file's base name, for message(s) */
++ if (!(iobuf = SetBuf(fp)))
++ {
++ (void)fclose(fp);
++ SetISTR(ISTR_WARNING,no_mem,fbasename,jpc_kind);
++ goto L3;
++ }
+
-+ fs = (FSBUF *)
-+ malloc(sizeof(FSBUF) * 3 + ((size_t)width + 2) * sizeof(FSERROR) * 3);
-+ if (fs == 0) return fs;
++ /* Before telling the JasPer Library about this file, get its size for display
++ purposes. Non-UNIX systems don't necessarily simulate "stat(2)", so do it
++ crudely but portably by seeking to the end, then back to the beginning.
++ */
++ fseek(fp,0L,2);
++ filesize = ftell(fp);
++ fseek(fp,0L,0);
+
-+ fs[0].colorset = screen_set[0];
-+ fs[1].colorset = screen_set[1];
-+ fs[2].colorset = screen_set[2];
++ /* "jas_stream_close()" will eventually close the input file, so only do it
++ explicitly if no stream can be created:
++ */
++ if (!(str = jas_stream_freopen(fname,fmode,fp)))
++ {
++ (void)fclose(fp);
++ goto L3;
++ }
+
-+ p = (FSERROR *)(fs + 3);
-+ memset(p, 0, ((size_t)width + 2) * sizeof(FSERROR) * 3);
++ /* It's not clear to me whether the following represents a JasPer Library "bug"
++ but it sure looks goofy: Unless a stream buffer is marked "read only",
++ which only happens when the stream's "fillbuf" method is called, even though
++ our buffers are always "read only", the library will try to flush out buffer
++ contents when the stream is destroyed, which makes it die a horrible death.
++ So, mark the stream buffer proactively:
++ */
++ str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */
++ if (!(img = jp2_decode(str,0))) goto L2;
++ if ((vstride = jas_image_numcmpts(img))) /* num. color planes */
++ {
+
-+ fs[0].fserrors = p;
-+ fs[1].fserrors = p + 1;
-+ fs[2].fserrors = p + 2;
++ /* After the image-component streams created, they are left in a "write"
++ state with the streams' cursors positioned at their ends, so "seek" in
++ order to "read" each stream from its beginning.
++ */
++ i = vstride;
++ while (--i >= 0)
++ if (jas_stream_seek(img->cmpts_[i]->stream_,0L,0))
++ {
++ SetISTR(ISTR_WARNING,read_err,fbasename,jp2_kind);
++ goto L1;
++ }
++ }
++ w = jas_image_width(img);
++ h = jas_image_height(img);
+
-+ return fs;
-+}
++ /* avoid buffer overflow */
++ npixels = w * h;
++ bufsize = vstride * npixels;
++ if (w <= 0 || h <= 0 || npixels/w != h || bufsize/vstride != npixels)
++ {
++ (void)fclose(fp);
++ SetISTR(ISTR_WARNING,bad_dims,fbasename);
++ goto L1;
++ }
++ pinfo->normw = pinfo->w = w;
++ pinfo->normh = pinfo->h = h;
+
-+/* Floyd-Steinberg dithering function.
-+ *
-+ * NOTE:
-+ * (1) The image data referenced by 'ptr' is *overwritten* (input *and*
-+ * output) to allow more efficient implementation.
-+ * (2) Alternate FS dithering is provided by the sign of 'nc'. Pass in
-+ * a negative value for right-to-left processing. The return value
-+ * provides the right-signed value for subsequent calls!
-+ * (3) This particular implementation assumes *no* padding between lines!
-+ * Adapt this if necessary.
++ /* Sanity-check the image's color space and no. of colors. For now, accept
++ only "generic" color spaces, not files needing image-specific color
++ correction, but fix that someday...
+ */
++ switch (vstride)
++ { static char color_space[]={"%s: invalid color space!"};
++
++ default:
++ SetISTR(ISTR_WARNING,bad_samp,fbasename,vstride,jp2_kind);
++ goto L1;
++ case 1:
++ if ( !jas_clrspc_isunknown(i = jas_image_clrspc(img))
++ && jas_clrspc_fam(i) != JAS_CLRSPC_FAM_GRAY
++ )
++ {
++ SetISTR(ISTR_WARNING,color_space,fbasename);
++ goto L1;
++ }
++ if ((i = jas_image_cmptprec(img,0)) != 8) /* not 8-bit pixels */
++ {
++ SetISTR(ISTR_WARNING,pixel_size,fbasename,i);
++ goto L1;
++ }
++ s = "Greyscale";
++ pinfo->type = PIC8;
++ pinfo->colType = F_GREYSCALE;
++ i = 256; /* Return fake indexed-color "map" */
++ while (--i >= 0) pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
++ break;
++ case 3:
++ if (jas_clrspc_isunknown(i = jas_image_clrspc(img)))
++ {
++ SetISTR(ISTR_WARNING,color_space,fbasename);
++ goto L1;
++ }
++ if (jas_clrspc_fam(i) != JAS_CLRSPC_FAM_RGB)
++ { jas_image_t *oimg;
++ jas_cmprof_t *profile;
++
++ /* Here's where the JasPer Library really shines. The only color
++ space that XV handles is RGB, so if that's not what our image
++ uses, then to quote Capt. Kirk: "Make it so!"
++ */
++ if (!(profile = jas_cmprof_createfromclrspc(JAS_CLRSPC_SRGB)))
++ {
++ SetISTR(ISTR_WARNING,"%s: can't create RGB profile",
++ fbasename);
++ goto L1;
++ }
++ img = jas_image_chclrspc( oimg = img
++ , profile
++ , JAS_CMXFORM_INTENT_PER
++ );
++ jas_cmprof_destroy(profile);
++ if (!img) /* Oops! We failed, so restore original image */
++ {
++ img = oimg;
++ SetISTR(ISTR_WARNING,"%s: can't convert to RGB",fbasename);
++ goto L1;
++ }
++ jas_image_destroy(oimg);
++ }
+
-+static int fs2_dither(fs, ptr, nc, num_rows, num_cols)
-+FSBUF *fs;
-+byte *ptr;
-+int nc, num_rows, num_cols;
-+{
-+ int abs_nc, ci, row, col;
-+ LOCFSERROR delta, cur, belowerr, bpreverr;
-+ byte *dataptr, *colsetptr;
-+ FSERROR *errorptr;
-+
-+ if ((abs_nc = nc) < 0) abs_nc = -abs_nc;
-+ for (row = 0; row < num_rows; row++) {
-+ for (ci = 0; ci < abs_nc; ci++, ptr++) {
-+ dataptr = ptr;
-+ colsetptr = fs[ci].colorset;
-+ errorptr = fs[ci].fserrors;
-+ if (nc < 0) {
-+ dataptr += (num_cols - 1) * abs_nc;
-+ errorptr += (num_cols + 1) * abs_nc;
++ /* BEWARE OF KLUDGE: If the image's color space is RGB, assume that the
++ data-sample precision for all color planes is the
++ same. If the color space is YCbCr, assume the luminance (Y = 0th)
++ component has the greatest precision, although the chrominance
++ (Cr = 1st, Cb = 2nd) components are usually sub-sampled.
++ */
++ if ((i = jas_image_cmptprec(img,0)) != 8) /* not 24-bit pixels */
++ {
++ SetISTR(ISTR_WARNING,pixel_size,fbasename,i*3);
++ goto L1;
++ }
++ s = "Color";
++ pinfo->type = PIC24;
++ pinfo->colType = F_FULLCOLOR;
++
++ /* XXX Unlike the IJG JPEG Library, the JasPer Library is apparently
++ unable to quantize colors or tell us whether the image's colors
++ were quantized by its creator, so it seems that we can't return a
++ color map for XV to potentially use 8-bit indexed color. If there
++ *is* an easy way to do it that escapes me, put the code here someday.
++ */
+ }
-+ cur = belowerr = bpreverr = 0;
-+ for (col = 0; col < num_cols; col++) {
-+ cur += errorptr[nc];
-+ cur += 8; cur >>= 4;
-+ if ((cur += *dataptr) < 0) cur = 0;
-+ else if (cur > 255) cur = 255;
-+ *dataptr = cur & 0xff;
-+ cur -= colsetptr[cur];
-+ delta = cur << 1; cur += delta;
-+ bpreverr += cur; cur += delta;
-+ belowerr += cur; cur += delta;
-+ errorptr[0] = (FSERROR)bpreverr;
-+ bpreverr = belowerr;
-+ belowerr = delta >> 1;
-+ dataptr += nc;
-+ errorptr += nc;
++ if (!(pinfo->pic = (byte *)malloc(bufsize))) /* image buffer for XV */
++ {
++ SetISTR(ISTR_WARNING,no_mem,fbasename,jp2_kind);
++ goto L1;
+ }
-+ errorptr[0] = (FSERROR)bpreverr;
-+ }
-+ ptr += (num_cols - 1) * abs_nc;
-+ nc = -nc;
-+ }
-+ return nc;
-+}
-+
-+#endif /* ENABLE_FIXPIX_SMOOTH */
-+
-
- #define DO_CROP 0
- #define DO_ZOOM 1
-@@ -1348,7 +1621,7 @@
- SetISTR(ISTR_WARNING, "Invalid image dimensions for dithering");
- return (byte *)NULL;
- }
--
-+
- outpic = (byte *) malloc((size_t) npixels);
- if (!outpic) return outpic;
-
-@@ -1838,7 +2111,7 @@
- unsigned int wide, high;
- {
- /*
-- * this has to do the none-to-simple bit of converting the data in 'pic24'
-+ * This has to do the none-too-simple bit of converting the data in 'pic24'
- * into something usable by X.
- *
- * There are two major approaches: if we're displaying on a TrueColor
-@@ -1852,7 +2125,7 @@
- * mode. (In that by this point, a 3/3/2 standard colormap has been
- * created for our use (though all 256 colors may not be unique...), and
- * we're just going to display the 24-bit picture by dithering with those
-- * colors
-+ * colors.)
- *
- */
-
-@@ -1890,33 +2163,17 @@
- /* Non-ColorMapped Visuals: TrueColor, DirectColor */
- /************************************************************************/
-
-- unsigned long r, g, b, rmask, gmask, bmask, xcol;
-- int rshift, gshift, bshift, bperpix, bperline, border, cshift;
-- int maplen;
-+ unsigned long xcol;
-+ int bperpix, bperline;
- byte *imagedata, *lip, *ip, *pp;
-
-
-- /* compute various shifting constants that we'll need... */
--
-- rmask = theVisual->red_mask;
-- gmask = theVisual->green_mask;
-- bmask = theVisual->blue_mask;
--
-- rshift = 7 - highbit(rmask);
-- gshift = 7 - highbit(gmask);
-- bshift = 7 - highbit(bmask);
--
-- maplen = theVisual->map_entries;
-- if (maplen>256) maplen=256;
-- cshift = 7 - highbit((u_long) (maplen-1));
--
- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
- wide, high, 32, 0);
- if (!xim) FatalError("couldn't create X image!");
-
- bperline = xim->bytes_per_line;
- bperpix = xim->bits_per_pixel;
-- border = xim->byte_order;
-
- imagedata = (byte *) malloc((size_t) (high * bperline));
- if (!imagedata) FatalError("couldn't malloc imagedata");
-@@ -1930,85 +2187,141 @@
- FatalError(buf);
- }
-
-+ screen_init();
-
-- lip = imagedata; pp = pic24;
-- for (i=0; i<high; i++, lip+=bperline) {
-- for (j=0, ip=lip; j<wide; j++) {
-- r = *pp++; g = *pp++; b = *pp++;
--
-- /* shift r,g,b so that high bit of 8-bit color specification is
-- * aligned with high bit of r,g,b-mask in visual,
-- * AND each component with its mask,
-- * and OR the three components together
-- */
--
-- if (theVisual->class == DirectColor) {
-- r = (u_long) directConv[(r>>cshift) & 0xff] << cshift;
-- g = (u_long) directConv[(g>>cshift) & 0xff] << cshift;
-- b = (u_long) directConv[(b>>cshift) & 0xff] << cshift;
-- }
--
--
-- /* shift the bits around */
-- if (rshift<0) r = r << (-rshift);
-- else r = r >> rshift;
--
-- if (gshift<0) g = g << (-gshift);
-- else g = g >> gshift;
--
-- if (bshift<0) b = b << (-bshift);
-- else b = b >> bshift;
--
-- r = r & rmask;
-- g = g & gmask;
-- b = b & bmask;
--
-- xcol = r | g | b;
--
-- if (bperpix == 32) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>24) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>24) & 0xff;
-- }
-- }
--
-- else if (bperpix == 24) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-- }
-- }
-+#ifdef ENABLE_FIXPIX_SMOOTH
-+ if (do_fixpix_smooth) {
-+#if 0
-+ /* If we wouldn't have to save the original pic24 image data,
-+ * the following code would do the dither job by overwriting
-+ * the image data, and the normal render code would then work
-+ * without any change on that data.
-+ * Unfortunately, this approach would hurt the xv assumptions...
-+ */
-+ if (bperpix < 24) {
-+ FSBUF *fs = fs2_init(wide);
-+ if (fs) {
-+ fs2_dither(fs, pic24, 3, high, wide);
-+ free(fs);
-+ }
++ pinfo->frmType = F_JP2;
++ sprintf(pinfo->fullInfo,full_msg,s,jp2_kind,filesize);
++ sprintf(pinfo->shrtInfo,shrt_msg,pinfo->w,pinfo->h,s,jp2_kind);
++ SetISTR(ISTR_INFO,load_msg,pinfo->normw,pinfo->normh,s,jp2_kind,filesize);
++ if (vstride == 1) /* gray-scale image */
++ { register jas_stream_t *c = img->cmpts_[0]->stream_;
++ register byte *p = pinfo->pic;
++
++ /* Since this is a 1-plane image, avoid a lot of errant nonsense in the
++ JasPer Library by sequentially reading all of the data into our buffer
++ directly.
++ */
++ do if ((i = (*c->ops_->read_)(c->obj_,(char *)p,bufsize)) <= 0)
++ {
++ SetISTR(ISTR_WARNING,i < 0 ? read_err : truncated,fbasename,
++ jp2_kind);
++ goto L1;
++ }
++ while ((p += i),(bufsize -= i) > 0);
+ }
-+#else
-+ /* ...so we have to take a different approach with linewise
-+ * dithering/rendering in a loop using a temporary line buffer.
-+ */
-+ if (bperpix < 24) {
-+ FSBUF *fs = fs2_init(wide);
-+ if (fs) {
-+ byte *row_buf = malloc((size_t)wide * 3);
-+ if (row_buf) {
-+ int nc = 3;
-+ byte *picp = pic24; lip = imagedata;
-+
-+ switch (bperpix) {
-+ case 8:
-+ for (i=0; i<high; i++, lip+=bperline, picp+=(size_t)wide*3) {
-+ memcpy(row_buf, picp, (size_t)wide * 3);
-+ nc = fs2_dither(fs, row_buf, nc, 1, wide);
-+ for (j=0, ip=lip, pp=row_buf; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+ *ip++ = xcol & 0xff;
-+ }
-+ }
-+ break;
++ else /* RGB color image */
++ {
+
-+ case 16:
-+ for (i=0; i<high; i++, lip+=bperline, picp+=(size_t)wide*3) {
-+ CARD16 *ip16 = (CARD16 *)lip;
-+ memcpy(row_buf, picp, (size_t)wide * 3);
-+ nc = fs2_dither(fs, row_buf, nc, 1, wide);
-+ for (j=0, pp=row_buf; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+ *ip16++ = (CARD16)xcol;
-+ }
-+ }
-+ break;
-+ } /* end switch */
-+
-+ free(row_buf);
-+ free(fs);
-
-- else if (bperpix == 16) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-+ return xim;
- }
-- }
--
-- else if (bperpix == 8) {
-- *ip++ = xcol & 0xff;
-- }
-+ free(fs);
-+ }
- }
-+#endif /* 0? */
- }
-+#endif /* ENABLE_FIXPIX_SMOOTH */
-+
-+ lip = imagedata; pp = pic24;
-+
-+ switch (bperpix) {
-+ case 8:
-+ for (i=0; i<high; i++, lip+=bperline) {
-+ for (j=0, ip=lip; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+ *ip++ = xcol & 0xff;
++ /* Reading color images is inefficient because JPEG 2000 wants to partition
++ file data into separate image planes (colors), while XV wants data
++ samples from each plane to be interleaved as 3-byte pixels. Apparently
++ the fastest method consists of 3 passes through the XV image buffer,
++ into which we insert the bytes of each component.
++ */
++ i = 0;
++ do /* each color component */
++ { long npix = npixels;
++ register jas_stream_t *c = img->cmpts_[i]->stream_;
++ register byte *p = pinfo->pic + i;
++
++ do /* each pixel */
++ { register int b;
++
++ if ((b = jas_stream_getc(c)) < 0)
++ {
++ SetISTR(ISTR_WARNING,
++ (c->flags_ & JAS_STREAM_EOF) ? truncated : read_err,
++ fbasename,jp2_kind);
++ goto L1;
++ }
++ *p = b;
++ }
++ while ((p += 3),--npix > 0);
+ }
-+ }
-+ break;
++ while (++i <= 2);
++ }
++ ok = 1; /* Success! */
++L1: jas_image_destroy(img);
++L2: (void)jas_stream_close(str);
++ free(iobuf);
++L3: return ok;
++}
++
++/* The following variables and subroutines are used when writing a JPEG 2000
++ file, which is done mainly using call-backs from "X Windows" widgets. The
++ most complicated part of this interface is: managing interactions with a
++ window to request the boat-loads of options that the JasPer Library supports.
++ Start by defining subwindow sizes, plus indices into several arrays of
++ corresponding widget-state variables.
++
++ IMPLEMENTATION NOTES: The following dimensions create a tall, thin window
++ which appears to have considerable empty space at the
++ bottom. Before you complain, click the Precinct Height menu button in order
++ to the tall pop-up subwindow that it generates. If the parent window is made
++ shorter, then this pop-up will be clipped, which is an ugly nuisance. I
++ don't know how to make the pop-up visible outside its parent's borders; do
++ you? If there's some way to make "X Windows" do this, then we might consider
++ making the parent shorter.
++
++ Note that there is currently no mechanism to program the no. of intermediate
++ layers used by the encoder, or their rates. This is potentially a large and
++ complicated data-entry problem, and perhaps someday we can invent a clever
++ solution using the rest of the parent window's space.
++*/
++# define JP2KW 275 /* Window width, in pixels */
++# define JP2KH 400 /* Window height, in pixels */
++# define BUTTW 51 /* Button width, in pixels (odd for half-toning) */
++# define BUTTH 20 /* Button height, in pixels */
++# define MENUW 75 /* Menu-button width, in pixels (odd for half-toning) */
++# define MENUH 24 /* Menu-button height, in pixels */
++# define RBUTH 20 /* Radio button height, in pixels */
++# define RBUTW 51 /* Radio button width, in pixels (odd for half-toning) */
++# define TEXTH (LINEHIGH+5) /* Text subwindow height, in pixels */
++# define TEXTW 75 /* Text subwindow width, in pixels */
++
++# define J_BOK 0 /* Boolean "Ok" button */
++# define J_BCANC 1 /* Boolean "Cancel" button */
++# define J_NBUTT 2 /* No. of regular button widgets */
++
++# define J_CSOP 0 /* Boolean encoding-style option buttons */
++# define J_CEPH 1
++# define J_CLAZY 2
++# define J_CTERM 3
++# define J_CSEGS 4
++# define J_CVCAU 5
++# define J_CPTRM 6
++# define J_CRSTP 7
++# define J_NCHKB 8 /* No. of check-box button widgets */
++
++# define J_MCBXW 0 /* 1-of-N menu-selection buttons */
++# define J_MCBXH 1
++# define J_MPREW 2
++# define J_MPREH 3
++# define J_MPROG 4
++# define J_NMENU 5 /* No. of menu-button widgets */
++
++# define J_TGBIT 0 /* (Unsigned numeric) string subwindows */
++# define J_TRES 1
++# define J_TRATE 2
++# define J_NTEXT 3 /* No. of text subwindows */
++
++static BUTT button[J_NBUTT];
++static CBUTT chkbut[J_NCHKB];
++static MBUTT menu[J_NMENU];
++static RBUTT *radio;
++static Window text[J_NTEXT];
++static int colorType, format, textval[J_NTEXT];
++static const char *ProgList[]={"lrcp","rlcp","rpcl","pcrl","cprl"};
++
++void CreateJP2KW(void)
++{
++ static const char EXP2_0[] ={ "1"}, /* Successive powers of 2 */
++ EXP2_1[] ={ "2"},
++ EXP2_2[] ={ "4"},
++ EXP2_3[] ={ "8"},
++ EXP2_4[] ={ "16"},
++ EXP2_5[] ={ "32"},
++ EXP2_6[] ={ "64"},
++ EXP2_7[] ={ "128"},
++ EXP2_8[] ={ "256"},
++ EXP2_9[] ={ "512"},
++ EXP2_10[]={ "1024"},
++ EXP2_11[]={ "2048"},
++ EXP2_12[]={ "4096"},
++ EXP2_13[]={ "8192"},
++ EXP2_14[]={"16384"},
++ EXP2_15[]={"32768"};
++ static const char *CBoxList[]=
++ {
++ EXP2_1 ,EXP2_2 ,EXP2_3 ,EXP2_4 ,EXP2_5,EXP2_6 ,EXP2_7 ,EXP2_8 ,EXP2_9,
++ EXP2_10,EXP2_11
++ };
++ static const char *PrecList[]=
++ {
++ EXP2_0,EXP2_1,EXP2_2 ,EXP2_3 ,EXP2_4 ,EXP2_5 ,EXP2_6 ,EXP2_7 ,
++ EXP2_8,EXP2_9,EXP2_10,EXP2_11,EXP2_12,EXP2_13,EXP2_14,EXP2_15
++ };
++ static const char hstr[]={"Height"}, wstr[]={"Width"};
++
++ if (!(jp2kW = CreateWindow( "xvjp2k"
++ , "XVjp2k"
++ , 0
++ , JP2KW
++ , JP2KH
++ , infofg
++ , infobg
++ , 0
++ )
++ )
++ ) FatalError("can't create JPEG 2000 window!");
++ XSelectInput(theDisp,jp2kW,ExposureMask|ButtonPressMask|KeyPressMask);
++
++ /* Create a row of 2 boolean-valued, regular buttons ("Ok" and "Cancel") in the
++ window's bottom right corner.
++ */
++ BTCreate(&button[J_BOK ],jp2kW,
++ JP2KW-2*BUTTW-20,JP2KH-10-BUTTH-1,BUTTW,BUTTH,
++ "Ok" ,infofg,infobg,hicol,locol);
++ BTCreate(&button[J_BCANC],jp2kW,
++ JP2KW- BUTTW-10,JP2KH-10-BUTTH-1,BUTTW,BUTTH,
++ "Cancel",infofg,infobg,hicol,locol);
++
++ /* Create a vertical column of 8 boolean-valued, check-box buttons (for
++ encoding-style options) down the window's left side.
++ */
++ CBCreate(&chkbut[J_CSOP] ,jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+0*BUTTH,
++ "sop" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CEPH] ,jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+1*BUTTH,
++ "eph" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CLAZY],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+2*BUTTH,
++ "lazy" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CTERM],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+3*BUTTH,
++ "termall" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CSEGS],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+4*BUTTH,
++ "segsym" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CVCAU],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+5*BUTTH,
++ "vcausal" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CPTRM],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+6*BUTTH,
++ "pterm" ,infofg,infobg,hicol,locol);
++ CBCreate(&chkbut[J_CRSTP],jp2kW,
++ 10,10+ASCENT+SPACING+2*LINEHIGH+7*BUTTH,
++ "resetprob",infofg,infobg,hicol,locol);
++ /* Create text subwindows for unsigned decimal integer values. */
++
++ text[J_TGBIT] = XCreateSimpleWindow(theDisp,jp2kW,
++ JP2KW-TEXTW-10,10+ASCENT+SPACING+2*LINEHIGH+3*MENUH+0*TEXTH,TEXTW,TEXTH,
++ 1,infofg,infobg);
++ XSelectInput(theDisp,text[J_TGBIT],ExposureMask|KeyPressMask);
++ text[J_TRES ] = XCreateSimpleWindow(theDisp,jp2kW,
++ JP2KW-TEXTW-10,10+ASCENT+SPACING+2*LINEHIGH+3*MENUH+1*TEXTH,TEXTW,TEXTH,
++ 1,infofg,infobg);
++ XSelectInput(theDisp,text[J_TRES ],ExposureMask|KeyPressMask);
++ text[J_TRATE] = XCreateSimpleWindow(theDisp,jp2kW,
++ JP2KW-TEXTW-10,10+ASCENT+SPACING+2*LINEHIGH+3*MENUH+2*TEXTH,TEXTW,TEXTH,
++ 1,infofg,infobg);
++ XSelectInput(theDisp,text[J_TRATE],ExposureMask|KeyPressMask);
++
++ /* Create a row of 2 boolean-valued radio buttons (for the "Rate" subwindow
++ value's unit of measure). The 1st button is "selected" by default.
++ */
++ radio = RBCreate(0,jp2kW,
++ JP2KW-19*RBUTW/8-10,10+ASCENT+SPACING+2*LINEHIGH+3*MENUH+3*TEXTH+4,
++ "Percent",infofg,infobg,hicol,locol);
++ (void)RBCreate(radio,jp2kW,
++ JP2KW-1*RBUTW-10 ,10+ASCENT+SPACING+2*LINEHIGH+3*MENUH+3*TEXTH+4,
++ "Bytes",infofg,infobg,hicol,locol);
++
++ /* Create pop-up menu-selection buttons after mapping the above subwindows,
++ since we don't want the pop-up menus mapped unless the corresponding button
++ is selected.
++ */
++ XMapSubwindows(theDisp,jp2kW);
++ MBCreate(&menu[J_MCBXW],jp2kW,
++ JP2KW-2*MENUW-10,10+ASCENT+SPACING+2*LINEHIGH+0*MENUH,MENUW,MENUH,
++ wstr ,CBoxList,sizeof CBoxList/sizeof *CBoxList,infofg,infobg,
++ hicol,locol);
++ MBCreate(&menu[J_MCBXH],jp2kW,
++ JP2KW-2*MENUW-10,10+ASCENT+SPACING+2*LINEHIGH+1*MENUH,MENUW,MENUH,
++ hstr ,CBoxList,sizeof CBoxList/sizeof *CBoxList,infofg,infobg,
++ hicol,locol);
++ MBCreate(&menu[J_MPREW],jp2kW,
++ JP2KW-1*MENUW-10,10+ASCENT+SPACING+2*LINEHIGH+0*MENUH,MENUW,MENUH,
++ wstr ,PrecList,sizeof PrecList/sizeof *PrecList,infofg,infobg,
++ hicol,locol);
++ MBCreate(&menu[J_MPREH],jp2kW,
++ JP2KW-1*MENUW-10,10+ASCENT+SPACING+2*LINEHIGH+1*MENUH,MENUW,MENUH,
++ hstr ,PrecList,sizeof PrecList/sizeof *PrecList,infofg,infobg,
++ hicol,locol);
++ MBCreate(&menu[J_MPROG],jp2kW,
++ JP2KW-1*MENUW-10,10+ASCENT+SPACING+2*LINEHIGH+2*MENUH,MENUW,MENUH,
++ "Order",ProgList,sizeof ProgList/sizeof *ProgList,infofg,infobg,
++ hicol,locol);
++
++ /* Initialize values represented by widgets, which should correspond to default
++ compiled into the JasPer Library. Unfortunately, as of Version 1.701 there
++ is no easy way for an application to extract these from the library, so the
++ following code might get out of sync over time:
++ */
++ menu[J_MCBXW].hascheck = 1; menu[J_MCBXW].flags[ 5] = 1;
++ menu[J_MCBXH].hascheck = 1; menu[J_MCBXH].flags[ 5] = 1;
++ menu[J_MPREW].hascheck = 1; menu[J_MPREW].flags[15] = 1;
++ menu[J_MPREH].hascheck = 1; menu[J_MPREH].flags[15] = 1;
++ menu[J_MPROG].hascheck = 1; menu[J_MPROG].flags[ 0] = 1;
++ textval[J_TGBIT] = 2; /* No. of guard bits */
++ textval[J_TRES ] = 6; /* Max. no. of resolution levels */
++ textval[J_TRATE] = 100; /* Rate = 100% */
++}
++
++void JP2KSaveParams(int fmt,char *fname,int col) /* Save output-file parms */
++{
++ format = fmt; /* Desired file format: F_JPC|F_JP2 */
++ fbasename = fname; /* ->Output file path */
++ colorType = col; /* Desired color space: F_GREYSCALE|... */
++}
++
++static void StoreJP2K(char *options)
++{
++ static jas_image_cmptparm_t parm[3]= /* Image parameters */
++ {{0,0,1,1,0,0,8,0},{0,0,1,1,0,0,8,0},{0,0,1,1,0,0,8,0}};
++ static char nomem[]={"StoreJP2K: out of memory\n"},
++ write[]={"w"};
++ jas_image_t *img;
++ jas_stream_t *str;
++ FILE *fp, *fp2;
++ byte *pic, *r, *g, *b;
++ const char *filename;
++ char *iobuf = 0;
++ unsigned long imagesize;
++ jas_clrspc_t color_space;
++ int nc, w, h, pfree, ptype, error = 1;
++ register int i;
++
++ /* This is a generic subroutine for writing JPEG 2000 image files using the
++ JasPer Library. Our argument is an ASCII string, containing a Space (" ")-
++ separated sequence of encoder options that currently aren't well documented.
++ Most of the work is identical for both ".jpc" and ".jp2" files. Start by
++ verifying that the output file can be opened, then get an image buffer from
++ XV and begin crunching it into a suitable form for the JasPer Library.
++ */
++ if (!(fp = OpenOutFile(filename = fbasename))) return; /* Oops! */
++ setbuf(fp,0); /* We don't really use this file pointer for I/O; see below */
++ fbasename = BaseName(filename);
++ WaitCursor();
++ pic = GenSavePic(&ptype,&w,&h,&pfree,&nc,&r,&g,&b);
++ imagesize = w*h;
++ if (ptype == PIC24) imagesize *= 3;
+
-+ case 16:
-+ for (i=0; i<high; i++, lip+=bperline) {
-+ CARD16 *ip16 = (CARD16 *)lip;
-+ for (j=0; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+ *ip16++ = (CARD16)xcol;
++ /* As an optimization to save file space, even if our user didn't ask to store
++ a gray-scale image, check whether we could and, if so, do it anyway.
++ */
++ if (colorType != F_GREYSCALE) /* can we force a gray-scale image? */
++ {
++ if (ptype == PIC8)
++ {
++ i = nc;
++ while (--i >= 0 && r[i] == g[i] && r[i] == b[i]);
+ }
-+ }
-+ break;
++ else /* PIC24 */
++ { register byte *p = pic + imagesize;
+
-+ case 24:
-+ for (i=0; i<high; i++, lip+=bperline) {
-+ for (j=0, ip=lip; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+#ifdef USE_24BIT_ENDIAN_FIX
-+ if (border == MSBFirst) {
-+ *ip++ = (xcol>>16) & 0xff;
-+ *ip++ = (xcol>>8) & 0xff;
-+ *ip++ = xcol & 0xff;
-+ }
-+ else { /* LSBFirst */
-+ *ip++ = xcol & 0xff;
-+ *ip++ = (xcol>>8) & 0xff;
-+ *ip++ = (xcol>>16) & 0xff;
-+ }
-+#else /* GRR: this came with the FixPix patch, but I don't think it's right */
-+ *ip++ = (xcol >> 16) & 0xff; /* (no way to test, however, so */
-+ *ip++ = (xcol >> 8) & 0xff; /* it's left enabled by default) */
-+ *ip++ = xcol & 0xff;
-+#endif
-+ }
-+ }
-+ break;
++ while ((p -= 3) >= pic && p[0] == p[1] && p[0] == p[2]);
++ i = p-pic;
++ };
++ if (i < 0) colorType = F_GREYSCALE; /* We made it all the way through */
++ };
++
++ /* If XV is currently color-mapping the image, make a color-mapped copy so that
++ the map needn't be transmitted in the output file.
++ */
++ if ((i = (colorType != F_GREYSCALE) << 1 | (ptype != PIC8)) != 3)
++ { byte *tmp = pic, *last = pic + imagesize;
++ register byte *from = tmp, *to = pic;
++
++ if (!(pic = (byte *)malloc(imagesize))) FatalError(nomem);
++ switch (i)
++ {
+
-+ case 32:
-+ for (i=0; i<high; i++, lip+=bperline) {
-+ CARD32 *ip32 = (CARD32 *)lip;
-+ for (j=0; j<wide; j++) {
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+ *ip32++ = (CARD32)xcol;
++ /* Color-map 8->8 bit image. */
++
++ case 0: do
++ {
++ i = *from;
++ *to++ = MONO(r[i],g[i],b[i]);
++ }
++ while (++from < last);
++ break;
++
++ /* Color-map 24->8 bit image. */
++
++ case 1: do *to++ = MONO(from[0],from[1],from[2]);
++ while ((from += 3) < last);
++ break;
++
++ /* Color-map 8->24 bit image. */
++
++ case 2: do
++ {
++ i = *from;
++ *to++ = r[i]; *to++ = g[i]; *to++ = b[i];
++ }
++ while (++from < last);
++ break;
++ };
++ if (pfree) free(tmp); /* Release the original image buffer if we can */
++ pfree = 1; /* Let the modified buffer be released later */
++ };
++
++ /* Initialize various image-file parameter variables. */
++
++ parm[0].width = w;
++ parm[0].height = h;
++ if (colorType == F_GREYSCALE) /* gray-scale image */
++ {
++ ptype = 1; /* No. of color planes */
++ color_space = JAS_CLRSPC_SGRAY;
++ }
++ else /* RGB color image */
++ {
++ ptype = 3; /* No. of color planes */
++ color_space = JAS_CLRSPC_SRGB;
++ parm[2].width = parm[1].width = parm[0].width;
++ parm[2].height = parm[1].height = parm[0].height;
++ };
++
++ /* Now comes a egregious hack: The JasPer Library will eventually want to
++ close the output file that it writes, but since XV opened the file, XV also
++ thinks it has the right to close the file! In order to pacify them both,
++ we duplicate the file pointer and let the JasPer Library have it, while we
++ retain the original for XV.
++
++ XXX This code is very UNIX-specific; what's an equivalent hack for Windows?
++ */
++ if (!(fp2 = (i = dup(fileno(fp))) >= 0 ? fdopen(i,write) : 0))
++ FatalError("StoreJP2K: can't duplicate output file pointer\n");
++ if (!(iobuf = SetBuf(fp2)))
++ {
++ (void)fclose(fp2);
++ FatalError(nomem);
++ };
++
++ /* Hand our output file to the JasPer Library and create an image object.
++ "jas_stream_close()" will eventually close our output file, so only do it
++ explicitly if no stream can be created. If everything looks copacetic,
++ then write our buffer contents to the image components' streams.
++ */
++ if (!(str = jas_stream_freopen(filename,write,fp2)))
++ {
++ (void)fclose(fp2);
++ FatalError("StoreJP2K: can't open output stream\n");
++ };
++ if (!(img = jas_image_create(ptype,parm,color_space))) goto L2;
++ if (ptype == 1)
++ { register jas_stream_t *c = img->cmpts_[0]->stream_;
++ register byte *p = pic;
++
++ /* Since this is a 1-plane image, avoid a lot of errant nonsense in the
++ JasPer Library by sequentially writing all of the data directly from our
++ buffer.
++ */
++ jas_image_setcmpttype(img,0,JAS_IMAGE_CT_GRAY_Y);
++ img->cmpts_[0]->type_ = JAS_IMAGE_CT_GRAY_Y;
++ do if ((i = (*c->ops_->write_)(c->obj_,(char *)p,imagesize)) <= 0)
++ goto L1;
++ while ((p += i),(imagesize -= i) > 0);
++ if (jas_stream_flush(c) < 0) goto L1;
++ }
++ else /* RGB color image */
++ {
++
++ /* Writing color images is inefficient because JPEG 2000 wants to partition
++ file data into separate image planes (colors), while XV wants data
++ samples from each plane to be interleaved as 3-byte pixels. Apparently
++ the fastest method consists of 3 passes through the XV image buffer,
++ from which we extract the bytes of each component.
++ */
++ i = 0;
++ do /* each color component */
++ { long npix = imagesize/3;
++ register jas_stream_t *c = img->cmpts_[i]->stream_;
++ register byte *p = pic + i;
++
++ jas_image_setcmpttype(img,i,i+JAS_IMAGE_CT_RGB_R);
++ do if (jas_stream_putc(c,*p) < 0) goto L1;
++ while ((p += 3),--npix > 0);
++ if (jas_stream_flush(c) < 0) goto L1;
+ }
-+ }
-+ break;
-+ } /* end switch */
- }
-
- else {
-@@ -2458,6 +2771,7 @@
-
-
- /***********************/
-+#if 0 /* NOTUSED */
- static int highbit(ul)
- unsigned long ul;
- {
-@@ -2470,6 +2784,7 @@
- for (i=31; ((ul & hb) == 0) && i>=0; i--, ul<<=1);
- return i;
- }
-+#endif /* 0 - NOTUSED */
-
-
-
-@@ -2680,6 +2995,9 @@
- char *str;
- int wide, high, opaque,omode;
- {
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
- int i;
- byte *bgpic24;
- char syscmd[512], fname[128], errstr[512];
-@@ -2705,6 +3023,13 @@
- close(mkstemp(fname));
- #else
- mktemp(fname);
-+ tmpfd = open(fname, O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) {
-+ sprintf(errstr, "Error: can't create temporary file %s", fname);
-+ ErrPopUp(errstr, "\nDoh!");
-+ return 0;
-+ }
-+ close(tmpfd);
- #endif
-
- /* run bggen to generate the background */
-@@ -2978,7 +3303,7 @@
-
- ftype = ReadFileType(name);
-
-- if (ftype == RFT_COMPRESS) { /* handle compressed/gzipped files */
-+ if ((ftype == RFT_COMPRESS) || (ftype == RFT_BZIP2)) { /* handle .Z,gz,bz2 */
- #ifdef VMS
- basefname[0] = '\0';
- strcpy(basefname, name); /* remove trailing .Z */
-@@ -2988,7 +3313,7 @@
- uncName = name;
- #endif
-
-- if (UncompressFile(uncName, uncompname)) {
-+ if (UncompressFile(uncName, uncompname, ftype)) {
- ftype = ReadFileType(uncompname);
- readname = uncompname;
- }
-@@ -3029,9 +3354,3 @@
-
- return 1;
- }
--
--
--
--
--
--
-diff -ruN xv-3.10a-bugfixes/xvinfo.c xv-3.10a-enhancements/xvinfo.c
---- xv-3.10a-bugfixes/xvinfo.c 2004-05-16 18:03:43.000000000 -0700
-+++ xv-3.10a-enhancements/xvinfo.c 2005-05-01 00:05:53.000000000 -0700
-@@ -265,7 +265,7 @@
- if (stnum == ISTR_WARNING && !ctrlUp && !infoUp && !anyBrowUp &&
- strlen(istrs[stnum])) {
- OpenAlert(istrs[stnum]);
-- sleep(3);
-+ sleep(1); /* was 3, but _really_ slow for TIFFs with unknown tags... */
- CloseAlert();
- }
- }
-diff -ruN xv-3.10a-bugfixes/xvjpeg.c xv-3.10a-enhancements/xvjpeg.c
---- xv-3.10a-bugfixes/xvjpeg.c 2005-03-27 16:23:06.000000000 -0800
-+++ xv-3.10a-enhancements/xvjpeg.c 2005-04-17 14:45:28.000000000 -0700
-@@ -51,11 +51,21 @@
- static void clickJD PARM((int, int));
- static void doCmd PARM((int));
- static void writeJPEG PARM((void));
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(void) xv_error_exit PARM((j_common_ptr));
-+METHODDEF(void) xv_error_output PARM((j_common_ptr));
-+METHODDEF(void) xv_prog_meter PARM((j_common_ptr));
-+#else
- METHODDEF void xv_error_exit PARM((j_common_ptr));
- METHODDEF void xv_error_output PARM((j_common_ptr));
- METHODDEF void xv_prog_meter PARM((j_common_ptr));
-+#endif
- static unsigned int j_getc PARM((j_decompress_ptr));
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(boolean) xv_process_comment PARM((j_decompress_ptr));
-+#else
- METHODDEF boolean xv_process_comment PARM((j_decompress_ptr));
-+#endif
- static int writeJFIF PARM((FILE *, byte *, int,int,int));
-
-
-@@ -85,10 +95,10 @@
-
- XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask);
-
-- DCreate(&qDial, jpegW, 10, 10, 80, 100, 1, 100, 75, 5,
-+ DCreate(&qDial, jpegW, 10, 10, 80, 100, 1.0, 100.0, 75.0, 1.0, 5.0,
- infofg, infobg, hicol, locol, "Quality", "%");
-
-- DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5,
-+ DCreate(&smDial, jpegW, 120, 10, 80, 100, 0.0, 100.0, 0.0, 1.0, 5.0,
- infofg, infobg, hicol, locol, "Smoothing", "%");
-
- BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH,
-@@ -415,7 +425,11 @@
-
-
- /**************************************************/
--METHODDEF void xv_error_exit(cinfo)
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(void) xv_error_exit(cinfo)
-+#else
-+METHODDEF void xv_error_exit(cinfo)
-+#endif
- j_common_ptr cinfo;
- {
- my_error_ptr myerr;
-@@ -427,7 +441,11 @@
-
-
- /**************************************************/
--METHODDEF void xv_error_output(cinfo)
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(void) xv_error_output(cinfo)
-+#else
-+METHODDEF void xv_error_output(cinfo)
-+#endif
- j_common_ptr cinfo;
- {
- my_error_ptr myerr;
-@@ -441,7 +459,11 @@
-
-
- /**************************************************/
--METHODDEF void xv_prog_meter(cinfo)
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(void) xv_prog_meter(cinfo)
-+#else
-+METHODDEF void xv_prog_meter(cinfo)
-+#endif
- j_common_ptr cinfo;
- {
- struct jpeg_progress_mgr *prog;
-@@ -706,7 +728,11 @@
-
-
- /**************************************************/
--METHODDEF boolean xv_process_comment(cinfo)
-+#if JPEG_LIB_VERSION > 60
-+METHODDEF(boolean) xv_process_comment(cinfo)
-+#else
-+METHODDEF boolean xv_process_comment(cinfo)
-+#endif
- j_decompress_ptr cinfo;
- {
- int length, hasnull;
-@@ -794,8 +820,8 @@
-
-
- jpeg_set_defaults(&cinfo);
-- jpeg_set_quality(&cinfo, qDial.val, TRUE);
-- cinfo.smoothing_factor = smDial.val;
-+ jpeg_set_quality(&cinfo, (int)qDial.val, TRUE);
-+ cinfo.smoothing_factor = (int)smDial.val;
-
-
- jpeg_start_compress(&cinfo, TRUE);
-@@ -804,7 +830,7 @@
- /*** COMMENT HANDLING ***/
-
- sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n",
-- CREATOR_STR, REVDATE, qDial.val, smDial.val);
-+ CREATOR_STR, REVDATE, (int)qDial.val, (int)smDial.val);
-
- if (picComments) { /* append XV comment */
- char *sp, *sp1; int done;
-@@ -866,4 +892,27 @@
-
-
-
++ while (++i <= 2);
++ };
++ if ( (*(format == F_JPC ? jpc_encode : jp2_encode))(img,str,options) >= 0
++ && jas_stream_flush(str) >= 0
++ ) error = 0; /* Success! */
++L1: jas_image_destroy(img);
++L2: (void)jas_stream_close(str);
++ if (iobuf) free(iobuf);
++ if (pfree) free(pic);
++ if (!CloseOutFile(fp,filename,error)) DirBox(0);
++ SetCursors(-1);
++}
+
-+/*******************************************/
-+void
-+VersionInfoJPEG() /* GRR 19980605, 19980607 */
++void JP2KDialog(int vis)
+{
-+ int major = JPEG_LIB_VERSION / 10;
-+ int minor = JPEG_LIB_VERSION % 10;
-+ char minoralpha[2];
++ if ((jp2kUp = vis)) CenterMapWindow(jp2kW,0,0,JP2KW,JP2KH);
++ else XUnmapWindow(theDisp,jp2kW);
++}
++
++static void TWRedraw(Window w,unsigned int val)
++{
++ char buf[11];
++ register int i;
+
-+ if (minor) {
-+ minoralpha[0] = (char)(minor - 1 + 'a');
-+ minoralpha[1] = '\0';
-+ } else
-+ minoralpha[0] = '\0';
++ /* Draw a 1-line numeric text string in the specified window, representing the
++ argument value as a left-justified unsigned decimal integer, followed by a
++ "cursor" icon.
++ */
++ sprintf(buf,"%u",val);
++ if (ctrlColor) XClearArea(theDisp,w,2,2,TEXTW-4,TEXTH-4,False);
++ else XClearWindow(theDisp,w);
++ Draw3dRect(w,0,0,TEXTW-1,TEXTH-1,R3D_IN,2,hicol,locol,infobg);
++ XSetForeground(theDisp,theGC,infofg);
++ XDrawString(theDisp,w,theGC,3,ASCENT+3,buf,i = strlen(buf));
+
-+/* fprintf(stderr, " Compiled with libjpeg %d.%d.\n", major, minor); */
-+ fprintf(stderr, " Compiled with libjpeg %d%s.\n", major, minoralpha);
++ /* Draw a "cursor" icon after the numeric string. */
++
++ i = XTextWidth(mfinfo,buf,i);
++ XDrawLine(theDisp,w,theGC,i+3,2 ,i+3,2+CHIGH+1);
++ XDrawLine(theDisp,w,theGC,i+3,2+CHIGH+1,i+5,2+CHIGH+3);
++ XDrawLine(theDisp,w,theGC,i+3,2+CHIGH+1,i+1,2+CHIGH+3);
+}
+
++int JP2KCheckEvent(register XEvent *xev)
++{
++ int ok = 0;
++
++ /* Check whether the argument "X Windows" event is for one of our subwindows.
++ If it is, handle the event and return 1; otherwise, return 0.
++ */
++ if (!jp2kUp) return 0;
++ switch (xev->type)
++ { KeySym ks;
++ int len;
++ char buf[128];
++ register int i;
++
++ /* Throw away excess "expose" events for "dumb" windows. */
++
++ case Expose :
++# define E ((XExposeEvent *)xev)
++ if (E->window == jp2kW)
++ { XRectangle rect;
++
++ rect.x = E->x ; rect.y = E->y ;
++ rect.width = E->width; rect.height = E->height;
++ XSetClipRectangles(theDisp,theGC,0,0,&rect,1,Unsorted);
++ XSetForeground(theDisp,theGC,infofg);
++ XSetBackground(theDisp,theGC,infobg);
++ i = sizeof button/sizeof *button;
++ while (--i >= 0) BTRedraw(&button[i]);
++ i = sizeof chkbut/sizeof *chkbut;
++ while (--i >= 0) CBRedraw(&chkbut[i]);
++ i = sizeof menu/sizeof *menu;
++ while (--i >= 0) MBRedraw(&menu[i]);
++ RBRedraw(radio,-1);
++ DrawString(jp2kW,10,10+ASCENT,"Save JPEG 2000 File...");
++ DrawString(jp2kW,10,10+ASCENT+2*LINEHIGH,"Style options:");
++ DrawString(jp2kW,JP2KW-2*MENUW-10,10+ASCENT+2*LINEHIGH,
++ "Coding Blk");
++ DrawString(jp2kW,JP2KW-1*MENUW-10,10+ASCENT+2*LINEHIGH,
++ " Precinct");
++ DrawString(jp2kW,
++ JP2KW-2*MENUW-10,10+ASCENT+SPACING+3*LINEHIGH+2*MENUH,
++ "Progression:");
++ DrawString(jp2kW,
++ JP2KW-2*TEXTW-10,10+ASCENT+SPACING+3*LINEHIGH+3*MENUH+0*TEXTH,
++ "Guard bits:");
++ DrawString(jp2kW,
++ JP2KW-2*TEXTW-10,10+ASCENT+SPACING+3*LINEHIGH+3*MENUH+1*TEXTH,
++ "Res levels:");
++ DrawString(jp2kW,
++ JP2KW-2*TEXTW-10,10+ASCENT+SPACING+3*LINEHIGH+3*MENUH+2*TEXTH,
++ "Rate:");
++ XSetClipMask(theDisp,theGC,None);
++ ok = 1;
++ break;
++ };
++ i = sizeof text/sizeof *text;
++ while (--i >= 0 && E->window != text[i]);
++ if (i >= 0)
++ {
++ TWRedraw(E->window,textval[i]);
++ ok = 1;
++ };
++ break;
++# undef E
++
++ /* Check whether the user pressed one of our buttons. */
++
++ case ButtonPress:
++# define E ((XButtonEvent *)xev)
++ if (E->button == Button1 && E->window == jp2kW)
++ { register int j;
++
++ ok = 1; /* Check whether a regular button was pressed */
++ i = sizeof button/sizeof *button;
++ while ( --i >= 0
++ && !PTINRECT(E->x,E->y,button[i].x,button[i].y,button[i].w,button[i].h)
++ );
++ if (i >= 0) /* our button was pressed */
++ { char options[1024];
++ register char *p;
++ register const char *q;
++
++ if (!BTTrack(&button[i])) break; /* Ignore it */
++ if (i != J_BOK) /* must be "Cancel" button */
++ {
++ JP2KDialog(0);
++ break;
++ };
++
++ /* Our user hit the "Ok" button. At this point, we have an ugly
++ job to do: JasPer Library encoder options must be specified
++ as an ASCII string of Space (" ")-separated <tag>[=<value>]
++ entries, so we must collect the values of all of our widgets
++ and subwindows, determine whether our user has requested any
++ non-default values, then build the string only for the JasPer
++ Library to immediately tear it apart again. Yechh!
++ */
++ if ((unsigned)textval[J_TGBIT]-1 > 7)
++ {
++ OpenAlert("No. of guard bits must be 1-8");
++ sleep(3);
++ CloseAlert();
++ break;
++ };
++ if ((unsigned)textval[J_TRES ] <= 0)
++ {
++ OpenAlert("Maximum resolution levels must be >= 1");
++ sleep(3);
++ CloseAlert();
++ break;
++ };
++
++ /* XXX Should we check and complain if the rate is zero?
++ JasPer Library Version 1.701 apparently accepts that
++ value, even though it seems kinda weird.
++ */
++ p = options;
++ i = 0;
++ do if ((j = MBWhich(&menu[i])) != 5)
++ { static const char *parm[2] =
++ {"cblkwidth=%u", "cblkheight=%u"};
++
++ if (p > options) *p++ = ' ';
++ sprintf(p,parm[i-J_MCBXW],++j);
++ while (*++p);
++ }
++ while (++i <= J_MCBXH);
++ do if ((j = MBWhich(&menu[i])) < 15)
++ { static const char *parm[2] =
++ {"prcwidth=%u", "prcheight=%u"};
++
++ if (p > options) *p++ = ' ';
++ sprintf(p,parm[i-J_MPREW],j);
++ while (*++p);
++ }
++ while (++i <= J_MPREH);
++ if ((j = MBWhich(&menu[i])))
++ {
++ if (p > options) *p++ = ' ';
++ *p++ = 'p'; *p++ = 'r'; *p++ = 'g'; *p = '=';
++ q = ProgList[j];
++ while ((*++p = *q++));
++ };
++ if ((i = textval[J_TRES ]) != 6)
++ {
++ if (p > options) *p++ = ' ';
++ sprintf(p,"numrlvls=%u",i);
++ while (*++p);
++ };
++ i = 0;
++ do if (chkbut[i].val) /* append this encoding option */
++ {
++ if (p > options) *p++ = ' ';
++ q = chkbut[i].str;
++ while ((*p++ = *q++));
++ *--p = '\000';
++ }
++ while (++i < sizeof chkbut/sizeof *chkbut);
++ if ((i = textval[J_TGBIT]) != 2)
++ {
++ if (p > options) *p++ = ' ';
++ sprintf(p,"numgbits=%u",i);
++ while (*++p);
++ };
++ if ((i = textval[J_TRATE]) != 100)
++ {
++ if (p > options) *p++ = ' ';
++ *p++ = 'r'; *p++ = 'a'; *p++ = 't'; *p++ = 'e';
++ *p++ = '=';
++ if (i) /* non-zero rate */
++ {
++ if (RBWhich(radio)) sprintf(p,"%uB",i); /* # Bytes */
++ else /* the value is a percentage */
++ {
++ if (i > 100) i = 200; /* => Raw size + 1 */
++ sprintf(p,"%u.%.2u",i/100,i%100);
++ }
++ while (*++p);
++ }
++ else /* rate = 0 */
++ {
++
++ /* XXX This is apparently valid, since JasPer Library
++ Version 1.701 doesn't complain about it.
++ */
++ *p++ = '0';
++ *p = '\000';
++ }
++ };
++ StoreJP2K(options); /* Finally, do the *real* work! */
++ JP2KDialog(0);
++ p = GetDirFullName();
++ if (!ISPIPE(*p))
++ {
++ XVCreatedFile(p);
++ StickInCtrlList(0);
++ };
++ break;
++ };
++
++ /* See whether a check-box button was pressed. */
+
++ i = sizeof chkbut/sizeof *chkbut;
++ while (--i >= 0 && !CBClick(&chkbut[i],E->x,E->y));
++ if (i >= 0) /* our button was pressed */
++ {
++ (void)CBTrack(&chkbut[i]);
++ break;
++ };
++
++ /* See whether a menu button was pressed. */
++
++ i = sizeof menu/sizeof *menu;
++ while (--i >= 0 && !MBClick(&menu[i],E->x,E->y));
++ if (i >= 0) /* our button was pressed */
++ { register int j;
++
++ if ((j = MBTrack(&menu[i])) >= 0)
++ {
++ switch (i)
++ {
++
++ /* The JasPer Library constrains a coding box's area
++ (width x height) to be <= 4096 pixels, so if this
++ button-press would violate that condition, then
++ quietly limit the box's orthogonal dimension by just
++ enough to compensate.
++ */
++ case J_MCBXH:
++ case J_MCBXW: if (MBWhich(&menu[!i]) + j >= 10)
++ MBSelect(&menu[!i],10 - j);
++ };
++ MBSelect(&menu[i],j);
++ MBSetActive(&menu[i],1);
++ };
++ break;
++ };
++
++ /* See whether a radio button was pressed. */
++
++ if ( (i = RBClick(radio,E->x,E->y)) >= 0 /* button pressed */
++ && RBTrack(radio,i)
++ )
++ {
++ RBSelect(radio,i);
++ RBSetActive(radio,i,1);
++ };
++ break;
++ };
++ XBell(theDisp,50);
++ break;
++# undef E
++
++ /* Translate a few key-press events into simulated button events. */
++
++ case KeyPress :
++# define E ((XKeyEvent *)xev)
++ buf[len = XLookupString(E,buf,sizeof buf,&ks,0)] = '\000';
++ RemapKeyCheck(ks,buf,&len);
++ if (E->window == jp2kW)
++ {
++ ok = 1;
++ if (len > 0)
++ switch (buf[0])
++ {
++ case '\r' :
++ case '\n' : FakeButtonPress(&button[J_BOK ]);
++ break;
++ case '\033': FakeButtonPress(&button[J_BCANC]);
++ };
++ break;
++ };
++ i = sizeof text/sizeof *text;
++ while (--i >= 0 && E->window != text[i]);
++ if (i >= 0) /* a key was pressed in our text window */
++ { int oldval = textval[i]; /* Save this subwindow's old value */
++ register int c, j = 0;
++
++ /* This is a *very* simple text-input editing loop that assembles an
++ an unsigned integer from successive ASCII decimal digits, typed
++ into one of our 1-line subwindows. For convenience, the only
++ character recognized is Backspace.
++ */
++ ok = 1;
++ L: if (j >= len) break;
++ if ((unsigned)(c = buf[j++] - '0') <= 9)
++ {
++ TWRedraw(text[i],textval[i] = textval[i]*10 + c);
++ goto L;
++ };
++ if ((c += '0') == '\b')
++ {
++ TWRedraw(text[i],textval[i] = textval[i]/10);
++ goto L;
++ };
++ textval[i] = oldval;
++ };
++ XBell(theDisp,50);
++# undef E
++ };
++ return ok;
++}
+
+
++/*******************************************/
++void
++VersionInfoJP2K() /* GRR 20070304 */
++{
++ fprintf(stderr, " Compiled with libjasper %s; using libjasper %s.\n",
++ JAS_VERSION, jas_getversion());
++}
+
- #endif /* HAVE_JPEG */
-diff -ruN xv-3.10a-bugfixes/xvmag.c xv-3.10a-enhancements/xvmag.c
---- xv-3.10a-bugfixes/xvmag.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvmag.c 2005-04-17 22:56:58.000000000 -0700
++#endif /* HAVE_JP2K */
+diff -u -r --new-file xv-3.10a.orig/xvmag.c xv-3.10a/xvmag.c
+--- xv-3.10a.orig/xvmag.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvmag.c 2005-04-18 00:56:58.000000000 -0500
@@ -0,0 +1,866 @@
+/*
+ * xvmag.c - load routine for `MAG' format pictures.
@@ -10734,9 +4306,9 @@ diff -ruN xv-3.10a-bugfixes/xvmag.c xv-3.10a-enhancements/xvmag.c
+ return r;
+}
+#endif /* HAVE_MAG */
-diff -ruN xv-3.10a-bugfixes/xvmaki.c xv-3.10a-enhancements/xvmaki.c
---- xv-3.10a-bugfixes/xvmaki.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvmaki.c 2005-04-17 22:57:01.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvmaki.c xv-3.10a/xvmaki.c
+--- xv-3.10a.orig/xvmaki.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvmaki.c 2005-04-18 00:57:01.000000000 -0500
@@ -0,0 +1,794 @@
+/*
+ * xvmaki.c - load routine for `MAKI' format pictures.
@@ -11532,9 +5104,9 @@ diff -ruN xv-3.10a-bugfixes/xvmaki.c xv-3.10a-enhancements/xvmaki.c
+ return r;
+}
+#endif /* HAVE_MAKI */
-diff -ruN xv-3.10a-bugfixes/xvmgcsfx.c xv-3.10a-enhancements/xvmgcsfx.c
---- xv-3.10a-bugfixes/xvmgcsfx.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvmgcsfx.c 2005-05-01 10:20:12.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvmgcsfx.c xv-3.10a/xvmgcsfx.c
+--- xv-3.10a.orig/xvmgcsfx.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvmgcsfx.c 2007-04-15 17:02:32.000000000 -0500
@@ -0,0 +1,2276 @@
+/*
+ * $Id: xvmgcsfx.c,v 1.23 95/11/27 19:03:36 tin329 Exp Locker: tin329 $
@@ -13759,8 +7331,8 @@ diff -ruN xv-3.10a-bugfixes/xvmgcsfx.c xv-3.10a-enhancements/xvmgcsfx.c
+/*******************************************/
+int getInputCom()
+{
-+ static char *labels[] = { "\nOk", "\033Cancel" };
-+ int i;
++ static const char *labels[] = { "\nOk", "\033Cancel" };
++ int i;
+
+ strcpy(input_command_ex, MGCSFX_DEFAULT_INPUT_COMMAND);
+ i = GetStrPopUp("Input External Command (Input is PNM):", labels, 2,
@@ -13776,8 +7348,8 @@ diff -ruN xv-3.10a-bugfixes/xvmgcsfx.c xv-3.10a-enhancements/xvmgcsfx.c
+
+int getOutputCom()
+{
-+ static char *labels[] = { "\nOk", "\033Cancel" };
-+ int i;
++ static const char *labels[] = { "\nOk", "\033Cancel" };
++ int i;
+
+ strcpy(output_command_ex, MGCSFX_DEFAULT_OUTPUT_COMMAND);
+ i = GetStrPopUp("Input External Command (Output is PNM_RAW):", labels, 2,
@@ -13812,180 +7384,9 @@ diff -ruN xv-3.10a-bugfixes/xvmgcsfx.c xv-3.10a-enhancements/xvmgcsfx.c
+#endif
+
+#endif /* HAVE_MGCSFX */
-diff -ruN xv-3.10a-bugfixes/xvmisc.c xv-3.10a-enhancements/xvmisc.c
---- xv-3.10a-bugfixes/xvmisc.c 2005-03-20 22:47:06.000000000 -0800
-+++ xv-3.10a-enhancements/xvmisc.c 2005-04-17 14:45:28.000000000 -0700
-@@ -103,10 +103,18 @@
- if (!usesize || !(i&WidthValue)) w = defw;
- if (!usesize || !(i&HeightValue)) h = defh;
-
-- hints.flags |= USSize;
-+ hints.flags |= USSize | PWinGravity;
-
-- if (i&XValue && i&XNegative) x = dispWIDE - w - abs(x);
-- if (i&YValue && i&YNegative) y = dispHIGH - h - abs(y);
-+ hints.win_gravity = NorthWestGravity;
-+ if (i&XValue && i&XNegative) {
-+ hints.win_gravity = NorthEastGravity;
-+ x = dispWIDE - (w + 2 * bwidth) - abs(x);
-+ }
-+ if (i&YValue && i&YNegative) {
-+ hints.win_gravity = (hints.win_gravity == NorthWestGravity) ?
-+ SouthWestGravity : SouthEastGravity;
-+ y = dispHIGH - (h + 2 * bwidth) - abs(y);
-+ }
-
-
- #define VROOT_TRANS
-@@ -142,20 +150,19 @@
- if (!win) return(win); /* leave immediately if couldn't create */
-
-
-- XSetStandardProperties(theDisp, win, name, name, None, NULL, 0, &hints);
--
- xwmh.input = True;
- xwmh.flags = InputHint;
- if (iconPix) { xwmh.icon_pixmap = iconPix; xwmh.flags |= IconPixmapHint; }
-- XSetWMHints(theDisp, win, &xwmh);
-
- if (clname && strlen(clname)) {
- classh.res_name = "xv";
- classh.res_class = clname;
-- XSetClassHint(theDisp, win, &classh);
- StoreDeleteWindowProp(win);
- }
-
-+ XmbSetWMProperties(theDisp, win, name, name, NULL, 0, &hints, &xwmh,
-+ clname ? &classh : NULL);
-+
- return(win);
- }
-
-@@ -232,28 +239,28 @@
- int i = CK_NONE;
-
- if (ks==XK_Up || ks==XK_KP_Up ||
-- ks==XK_KP_8 || ks==XK_F28) i=CK_UP;
-+ ks==XK_F28) i=CK_UP;
-
- else if (ks==XK_Down || ks==XK_KP_Down ||
-- ks==XK_KP_2 || ks==XK_F34) i=CK_DOWN;
-+ ks==XK_F34) i=CK_DOWN;
-
- else if (ks==XK_Left || ks==XK_KP_Left ||
-- ks==XK_KP_4 || ks==XK_F30) i=CK_LEFT;
-+ ks==XK_F30) i=CK_LEFT;
-
- else if (ks==XK_Right || ks==XK_KP_Right ||
-- ks==XK_KP_6 || ks==XK_F32) i=CK_RIGHT;
-+ ks==XK_F32) i=CK_RIGHT;
-
- else if (ks==XK_Prior || ks==XK_KP_Prior ||
-- ks==XK_KP_9 || ks==XK_F29) i=CK_PAGEUP;
-+ ks==XK_F29) i=CK_PAGEUP;
-
- else if (ks==XK_Next || ks==XK_KP_Next ||
-- ks==XK_KP_3 || ks==XK_F35) i=CK_PAGEDOWN;
-+ ks==XK_F35) i=CK_PAGEDOWN;
-
- else if (ks==XK_Home || ks==XK_KP_Home ||
-- ks==XK_KP_7 || ks==XK_F27) i=CK_HOME;
-+ ks==XK_F27) i=CK_HOME;
-
- else if (ks==XK_End || ks==XK_KP_End ||
-- ks==XK_KP_1 || ks==XK_F33) i=CK_END;
-+ ks==XK_F33) i=CK_END;
-
- else i = CK_NONE;
-
-@@ -503,6 +510,11 @@
- as we have to keep the alloc'd colors around, but we don't want anything
- else to stay */
-
-+#ifdef AUTO_EXPAND
-+ chdir(initdir);
-+ Vdsettle();
-+#endif
-+
- if (!theDisp) exit(i); /* called before connection opened */
-
- if (useroot && i==0) { /* save the root info */
-@@ -526,6 +538,26 @@
- if (tiffW) XDestroyWindow(theDisp, tiffW);
- #endif
-
-+#ifdef HAVE_PNG
-+ if (pngW) XDestroyWindow(theDisp, pngW);
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (pcdW) XDestroyWindow(theDisp, pcdW);
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ if (pic2W) XDestroyWindow(theDisp, pic2W);
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ 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;
-@@ -722,6 +754,26 @@
- #ifdef HAVE_TIFF
- if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
- #endif
-+
-+#ifdef HAVE_PNG
-+ if (pngW) XDefineCursor(theDisp, pngW, otherc);
-+#endif
-+
-+#ifdef HAVE_PNG
-+ if (pngW) XDefineCursor(theDisp, pngW, otherc);
-+#endif
-+
-+#ifdef HAVE_PCD
-+ if (pcdW) XDefineCursor(theDisp, pcdW, otherc);
-+#endif
-+
-+#ifdef HAVE_PIC2
-+ if (pic2W) XDefineCursor(theDisp, pic2W, otherc);
-+#endif
-+
-+#ifdef HAVE_MGCSFX
-+ if (mgcsfxW) XDefineCursor(theDisp, mgcsfxW, otherc);
-+#endif
- }
-
-
-@@ -921,7 +973,7 @@
- void XVCreatedFile(fullname)
- char *fullname;
- {
-- /* called whenever a file has been deleted. Updates browser & dir windows,
-+ /* called whenever a file has been created. Updates browser & dir windows,
- if necessary */
-
- BRCreatedFile(fullname);
-@@ -1006,6 +1058,9 @@
- ((rv=(char *) getenv("cwd"))==NULL)) rv = "./";
- strcpy(buf, rv);
- }
-+#ifdef AUTO_EXPAND
-+ Vdtodir(buf);
-+#endif
- }
-
-
-diff -ruN xv-3.10a-bugfixes/xvml.c xv-3.10a-enhancements/xvml.c
---- xv-3.10a-bugfixes/xvml.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvml.c 2005-04-17 22:57:34.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvml.c xv-3.10a/xvml.c
+--- xv-3.10a.orig/xvml.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvml.c 2005-04-18 00:57:34.000000000 -0500
@@ -0,0 +1,989 @@
+/*
+ * xvml.c - makes text item structure for multi-lingual textviewer.
@@ -14976,9 +8377,9 @@ diff -ruN xv-3.10a-bugfixes/xvml.c xv-3.10a-enhancements/xvml.c
+}
+
+#endif /* TV_MULTILINGUAL */
-diff -ruN xv-3.10a-bugfixes/xvml.h xv-3.10a-enhancements/xvml.h
---- xv-3.10a-bugfixes/xvml.h 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvml.h 2005-04-17 22:57:45.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvml.h xv-3.10a/xvml.h
+--- xv-3.10a.orig/xvml.h 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvml.h 2005-04-18 00:57:45.000000000 -0500
@@ -0,0 +1,96 @@
+#ifndef MLVIEW_H
+#define MLVIEW_H
@@ -15076,346 +8477,10 @@ diff -ruN xv-3.10a-bugfixes/xvml.h xv-3.10a-enhancements/xvml.h
+struct design lookup_design PARM((char *, int));
+
+#endif
-diff -ruN xv-3.10a-bugfixes/xvpbm.c xv-3.10a-enhancements/xvpbm.c
---- xv-3.10a-bugfixes/xvpbm.c 2005-04-03 14:25:28.000000000 -0700
-+++ xv-3.10a-enhancements/xvpbm.c 2005-04-17 14:04:22.000000000 -0700
-@@ -23,6 +23,15 @@
- */
-
-
-+typedef unsigned short ush;
-+typedef unsigned char uch;
-+
-+#define alpha_composite(composite, fg, alpha, bg) { \
-+ ush temp = ((ush)(fg)*(ush)(alpha) + \
-+ (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
-+ (composite) = (uch)((temp + (temp >> 8)) >> 8); \
-+}
-+
- #define TRUNCSTR "File appears to be truncated."
-
- static int garbage;
-@@ -31,6 +40,7 @@
- static int loadpbm PARM((FILE *, PICINFO *, int));
- static int loadpgm PARM((FILE *, PICINFO *, int, int));
- static int loadppm PARM((FILE *, PICINFO *, int, int));
-+static int loadpam PARM((FILE *, PICINFO *, int, int));
- static int getint PARM((FILE *, PICINFO *));
- static int getbit PARM((FILE *, PICINFO *));
- static int getshort PARM((FILE *));
-@@ -38,10 +48,83 @@
-
- static char *bname;
-
-+
-+#ifdef HAVE_MGCSFX
-+/*
-+ * When file read or file write is fail, probably it's caused by
-+ * reading from pipe which has no data yet, or writing to pipe
-+ * which is not ready yet.
-+ * Then we can use system call select() on descriptor of pipe and wait.
-+ * If you want, change 'undef' to 'define' in the following line.
-+ * This feature is performance-killer.
-+ */
-+#undef FIX_PIPE_ERROR
-+
-+#ifdef __osf__
-+# ifdef __alpha
-+# define FIX_PIPE_ERROR
-+# endif
-+#endif
-+
-+#endif /* HAVE_MGCSFX */
-+
-+
-+#ifdef FIX_PIPE_ERROR
-+
-+int pipefdr;
-+
-+struct timeval timeout;
-+int width;
-+fd_set fds;
-+
-+static void ready_read()
-+{
-+ if(pipefdr < 0) return; /* if file descriptor is not pipe, OK */
-+ WaitCursor();
-+
-+reselect:
-+ /* setting of timeout */
-+ timeout.tv_sec = 1; /* 1 sec */
-+ timeout.tv_usec = 0; /* 0 usec */
-+
-+ FD_ZERO(&fds); /* clear bits */
-+ FD_SET(pipefdr, &fds); /* set bit of fd in fds */
-+
-+ /* number of file descriptor to want check (0 $B!A(B width-1) */
-+ width = pipefdr + 1;
-+
-+ /* select returns number of file descriptors */
-+ if (select(width, &fds, NULL, NULL, &timeout) < 0){
-+ if(DEBUG){
-+ fprintf(stderr, "No file descriptors can't selected, waiting...\n");
-+ }
-+ goto reselect;
-+ }
-+
-+ if (FD_ISSET(pipefdr, &fds)){
-+ /* Now, descriptor of pipe is ready to read */
-+ return;
-+ }else{
-+ if(DEBUG){
-+ fprintf(stderr, "Can't read from pipe yet, waiting...\n");
-+ }
-+ goto reselect;
-+ }
-+
-+}
-+#endif /* FIX_PIPE_ERROR */
-+
- /*******************************************/
-+#ifdef HAVE_MGCSFX
-+int LoadPBM(fname, pinfo, fd)
-+ char *fname;
-+ PICINFO *pinfo;
-+ int fd;
-+#else
- int LoadPBM(fname, pinfo)
- char *fname;
- PICINFO *pinfo;
-+#endif /* HAVE_MGCSFX */
- /*******************************************/
- {
- /* returns '1' on success */
-@@ -50,6 +133,10 @@
- int c, c1;
- int maxv, rv;
-
-+#ifdef FIX_PIPE_ERROR
-+ pipefdr = fd;
-+#endif
-+
- garbage = maxv = rv = 0;
- bname = BaseName(fname);
-
-@@ -57,6 +144,22 @@
- pinfo->comment = (char *) NULL;
-
-
-+#ifdef HAVE_MGCSFX
-+ if(fd < 0){
-+ /* open the file */
-+ fp = xv_fopen(fname,"r");
-+ if (!fp) return (pbmError(bname, "can't open file"));
-+
-+ /* compute file length */
-+ fseek(fp, 0L, 2);
-+ filesize = ftell(fp);
-+ fseek(fp, 0L, 0);
-+ }else{
-+ fp = fdopen(fd, "r");
-+ if (!fp) return (pbmError(bname, "can't open file"));
-+ filesize = 0; /* dummy */
-+ }
-+#else
- /* open the file */
- fp = xv_fopen(fname,"r");
- if (!fp) return (pbmError(bname, "can't open file"));
-@@ -65,6 +168,7 @@
- fseek(fp, 0L, 2);
- filesize = ftell(fp);
- fseek(fp, 0L, 0);
-+#endif /* HAVE_MGCSFX */
-
-
- /* read the first two bytes of the file to determine which format
-@@ -73,7 +177,8 @@
- "P6" = raw pixmap */
-
- c = getc(fp); c1 = getc(fp);
-- if (c!='P' || c1<'1' || c1>'6') return(pbmError(bname, "unknown format"));
-+ if (c!='P' || c1<'1' || (c1>'6' && c1!='8')) /* GRR alpha */
-+ return(pbmError(bname, "unknown format"));
-
- /* read in header information */
- pinfo->w = getint(fp, pinfo); pinfo->h = getint(fp, pinfo);
-@@ -104,6 +209,7 @@
- if (c1=='1' || c1=='4') rv = loadpbm(fp, pinfo, c1=='4' ? 1 : 0);
- else if (c1=='2' || c1=='5') rv = loadpgm(fp, pinfo, c1=='5' ? 1 : 0, maxv);
- else if (c1=='3' || c1=='6') rv = loadppm(fp, pinfo, c1=='6' ? 1 : 0, maxv);
-+ else if (c1=='8') rv = loadpam(fp, pinfo, 1 , maxv);
-
- fclose(fp);
-
-@@ -248,7 +354,20 @@
- }
- }
- else {
-+#ifdef FIX_PIPE_ERROR
-+ reread:
-+ numgot += fread(pic8 + numgot, (size_t) 1, (size_t) w*h - numgot, fp); /* read raw data */
-+ if(errno == EINTR){
-+ if(DEBUG){
-+ fprintf(stderr,
-+ "Can't read all data from pipe, call select and waiting...\n");
-+ }
-+ ready_read();
-+ goto reread;
-+ }
-+#else
- numgot = fread(pic8, (size_t)1, (size_t)npixels, fp); /* read raw data */
-+#endif
- }
- }
-
-@@ -315,7 +434,20 @@
- }
- }
- else {
-+#ifdef FIX_PIPE_ERROR
-+ reread:
-+ numgot += fread(pic24 + numgot, (size_t) 1, (size_t) w*h*3 - numgot, fp); /* read data */
-+ if(errno == EINTR){
-+ if(DEBUG){
-+ fprintf(stderr,
-+ "Can't read all data from pipe, call select and waiting...\n");
-+ }
-+ ready_read();
-+ goto reread;
-+ }
-+#else
- numgot = fread(pic24, (size_t) 1, (size_t) bufsize, fp); /* read data */
-+#endif
- }
- }
-
-@@ -341,6 +473,122 @@
- }
-
-
-+/*******************************************/
-+static int loadpam(fp, pinfo, raw, maxv) /* unofficial RGBA extension */
-+ FILE *fp;
-+ PICINFO *pinfo;
-+ int raw, maxv;
-+{
-+ byte *p, *pix, *pic24, *linebuf, scale[256], bgR, bgG, bgB, r, g, b, a;
-+ int i, j, bitshift, w, h, npixels, bufsize, linebufsize, holdmaxv;
-+
-+ w = pinfo->w;
-+ h = pinfo->h;
-+
-+ npixels = w * h;
-+ bufsize = 3*npixels;
-+ linebufsize = 4*w;
-+ if (w <= 0 || h <= 0 || npixels/w != h || bufsize/3 != npixels ||
-+ linebufsize/4 != w)
-+ return pbmError(bname, "image dimensions too large");
-+
-+ /* allocate 24-bit image */
-+ pic24 = (byte *) calloc((size_t) bufsize, (size_t) 1);
-+ if (!pic24) FatalError("couldn't malloc 'pic24' for PAM");
-+
-+ /* allocate line buffer for pre-composited RGBA data */
-+ linebuf = (byte *) malloc((size_t) linebufsize);
-+ if (!linebuf) {
-+ free(pic24);
-+ FatalError("couldn't malloc 'linebuf' for PAM");
-+ }
-+
-+ pinfo->pic = pic24;
-+ pinfo->type = PIC24;
-+ sprintf(pinfo->fullInfo, "PAM, %s format. (%ld bytes)",
-+ (raw) ? "raw" : "ascii", filesize);
-+ sprintf(pinfo->shrtInfo, "%dx%d PAM.", w, h);
-+ pinfo->colType = F_FULLCOLOR;
-+
-+
-+ /* if maxv>255, keep dropping bits until it's reasonable */
-+ holdmaxv = maxv;
-+ bitshift = 0;
-+ while (maxv>255) { maxv = maxv>>1; bitshift++; }
-+
-+
-+ numgot = 0;
-+
-+ if (!raw) { /* GRR: not alpha-ready */
-+ return pbmError(bname, "can't handle non-raw PAM image");
-+/*
-+ for (i=0, pix=pic24; i<h; i++) {
-+ if ((i&0x3f)==0) WaitCursor();
-+ for (j=0; j<w*3; j++, pix++)
-+ *pix = (byte) (getint(fp, pinfo) >> bitshift);
-+ }
-+ */
-+ }
-+ else { /* raw */
-+ if (holdmaxv>255) { /* GRR: not alpha-ready */
-+ return pbmError(bname, "can't handle PAM image with maxval > 255");
-+/*
-+ for (i=0, pix=pic24; i<h; i++) {
-+ if ((i&0x3f)==0) WaitCursor();
-+ for (j=0; j<w*3; j++,pix++)
-+ *pix = (byte) (getshort(fp) >> bitshift);
-+ }
-+ */
-+ }
-+ else {
-+ if (have_imagebg) { /* GRR: alpha-ready */
-+ bgR = (imagebgR >> 8);
-+ bgG = (imagebgG >> 8);
-+ bgB = (imagebgB >> 8);
-+ } else {
-+ bgR = bgG = bgB = 0;
-+ }
-+ for (i=0, pix=pic24; i<h; i++) {
-+ numgot += fread(linebuf, (size_t) 1, (size_t) linebufsize, fp); /* read data */
-+ if ((i&0x3f)==0) WaitCursor();
-+ for (j=0, p=linebuf; j<w; j++) {
-+ r = *p++;
-+ g = *p++;
-+ b = *p++;
-+ a = *p++;
-+ alpha_composite(*pix++, r, a, bgR)
-+ alpha_composite(*pix++, g, a, bgG)
-+ alpha_composite(*pix++, b, a, bgB)
-+ }
-+ }
-+ }
-+ }
-+
-+ free(linebuf);
-+
-+ /* in principle this could overflow, but not critical */
-+ if (numgot != w*h*4) pbmError(bname, TRUNCSTR);
-+
-+ if (garbage)
-+ return(pbmError(bname, "Garbage characters in image data."));
-+
-+
-+ /* have to scale up all RGB values (Conv24to8 expects RGB values to
-+ range from 0-255) */
-+
-+ if (maxv<255) {
-+ for (i=0; i<=maxv; i++) scale[i] = (i * 255) / maxv;
-+
-+ for (i=0, pix=pic24; i<h; i++) {
-+ if ((i&0x3f)==0) WaitCursor();
-+ for (j=0; j<w*3; j++, pix++) *pix = scale[*pix];
-+ }
-+ }
-+
-+ return 1;
-+}
-+
-+
-
- /*******************************************/
- static int getint(fp, pinfo)
-diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
---- xv-3.10a-bugfixes/xvpcd.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvpcd.c 2005-04-26 00:25:13.000000000 -0700
-@@ -0,0 +1,1307 @@
+diff -u -r --new-file xv-3.10a.orig/xvpcd.c xv-3.10a/xvpcd.c
+--- xv-3.10a.orig/xvpcd.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvpcd.c 2007-05-13 20:02:13.000000000 -0500
+@@ -0,0 +1,1311 @@
+/*
+ * xvpcd.c - load routine for 'PhotoCD' format pictures
+ *
@@ -15444,11 +8509,15 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ */
+
+#include "xv.h"
-+#include <memory.h>
+
+#ifdef HAVE_PCD
+
-+#define TRACE 0
++#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
+# define trace(x) fprintf x
+#else
@@ -15464,7 +8533,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+
+#ifdef __STDC__
+static void magnify(int, int, int, int, int, byte *);
-+static int pcdError(char *, char *);
++static int pcdError(const char *, const char *);
+static int gethuffdata(byte *, byte *, byte *, int, int);
+#else
+static void magnify();
@@ -15472,12 +8541,12 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+static int gethuffdata();
+#endif
+
-+#define wcurfactor 16 /* Call WaitCursor() every n rows */
++#define wcurfactor 16 /* Call WaitCursor() every n rows */
+
-+static int size; /* Set by window routines */
-+static int leaveitup;/* Cleared by docmd() when OK or CANCEL pressed */
-+static int goforit; /* Set to 1 if OK or 0 if CANCEL */
-+static FILE *fp;
++static int size; /* Set by window routines */
++static int leaveitup;/* Cleared by docmd() when OK or CANCEL pressed */
++static int goforit; /* Set to 1 if OK or 0 if CANCEL */
++static FILE *fp;
+static CBUTT lutCB;
+
+/*
@@ -15485,47 +8554,47 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ * Why there are 351 entries and not 346 as per Kodak documentation
+ * is a mystery.
+ */
-+static double rscale = 1.00,
-+ gscale = 1.00,
-+ bscale = 1.00;
-+
-+static byte Y[351] = {
-+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
-+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
-+ 30, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-+ 41, 42, 43, 45, 46, 47, 48, 49, 50, 51,
-+ 52, 53, 54, 56, 57, 58, 59, 60, 61, 62,
-+ 63, 64, 66, 67, 68, 69, 70, 71, 72, 73,
-+ 74, 76, 77, 78, 79, 80, 81, 82, 83, 84,
-+ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
-+ 107, 108, 110, 111, 112, 113, 114, 115, 116, 117,
-+ 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-+ 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
-+ 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
-+ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
-+ 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
-+ 169, 170, 171, 172, 173, 174, 175, 176, 176, 177,
-+ 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
-+ 188, 189, 190, 191, 192, 193, 193, 194, 195, 196,
-+ 197, 198, 199, 200, 201, 201, 202, 203, 204, 205,
-+ 206, 207, 207, 208, 209, 210, 211, 211, 212, 213,
-+ 214, 215, 215, 216, 217, 218, 218, 219, 220, 221,
-+ 221, 222, 223, 224, 224, 225, 226, 226, 227, 228,
-+ 228, 229, 230, 230, 231, 232, 232, 233, 234, 234,
-+ 235, 236, 236, 237, 237, 238, 238, 239, 240, 240,
-+ 241, 241, 242, 242, 243, 243, 244, 244, 245, 245,
-+ 245, 246, 246, 247, 247, 247, 248, 248, 248, 249,
-+ 249, 249, 249, 250, 250, 250, 250, 251, 251, 251,
-+ 251, 251, 252, 252, 252, 252, 252, 253, 253, 253,
-+ 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
-+ 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-+ 254, 254, 254, 254, 254, 254, 254, 254, 254, 255,
-+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-+ 255
++static double rscale = 1.00,
++ gscale = 1.00,
++ bscale = 1.00;
++
++static byte Y[351] = {
++ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
++ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
++ 30, 32, 33, 34, 35, 36, 37, 38, 39, 40,
++ 41, 42, 43, 45, 46, 47, 48, 49, 50, 51,
++ 52, 53, 54, 56, 57, 58, 59, 60, 61, 62,
++ 63, 64, 66, 67, 68, 69, 70, 71, 72, 73,
++ 74, 76, 77, 78, 79, 80, 81, 82, 83, 84,
++ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
++ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
++ 107, 108, 110, 111, 112, 113, 114, 115, 116, 117,
++ 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
++ 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
++ 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
++ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
++ 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
++ 169, 170, 171, 172, 173, 174, 175, 176, 176, 177,
++ 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
++ 188, 189, 190, 191, 192, 193, 193, 194, 195, 196,
++ 197, 198, 199, 200, 201, 201, 202, 203, 204, 205,
++ 206, 207, 207, 208, 209, 210, 211, 211, 212, 213,
++ 214, 215, 215, 216, 217, 218, 218, 219, 220, 221,
++ 221, 222, 223, 224, 224, 225, 226, 226, 227, 228,
++ 228, 229, 230, 230, 231, 232, 232, 233, 234, 234,
++ 235, 236, 236, 237, 237, 238, 238, 239, 240, 240,
++ 241, 241, 242, 242, 243, 243, 244, 244, 245, 245,
++ 245, 246, 246, 247, 247, 247, 248, 248, 248, 249,
++ 249, 249, 249, 250, 250, 250, 250, 251, 251, 251,
++ 251, 251, 252, 252, 252, 252, 252, 253, 253, 253,
++ 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
++ 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
++ 254, 254, 254, 254, 254, 254, 254, 254, 254, 255,
++ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
++ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
++ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
++ 255
+};
+
+/*******************************************/
@@ -15537,128 +8606,128 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+{
+ long offset;
+ int mag;
-+ int rotate;
-+ byte header[3*0x800];
-+ byte *pic24, *luma, *chroma1, *chroma2, *ptr, *lptr, *c1ptr, *c2ptr;
++ int rotate;
++ byte header[3*0x800];
++ byte *pic24, *luma, *chroma1, *chroma2, *ptr, *lptr, *c1ptr, *c2ptr;
+ int w, h, npixels, bufsize;
+ int row, col;
-+ int huffplanes;
-+ char *bname;
++ int huffplanes;
++ const char *bname;
+
-+ bname = BaseName(fname);
-+ pinfo->pic = NULL;
-+ pinfo->comment = NULL;
++ bname = BaseName(fname);
++ pinfo->pic = NULL;
++ pinfo->comment = NULL;
+
+
-+ /*
-+ * open the file
-+ */
-+ if((fp=fopen(fname,"r")) == NULL)
-+ return pcdError(bname, "can't open file");
++ /*
++ * open the file
++ */
++ if((fp=fopen(fname,"r")) == NULL)
++ return pcdError(bname, "can't open file");
+
-+ /*
-+ * inspect the header
-+ */
-+ if(fread(&header[0], 1, sizeof(header), fp) != sizeof(header))
-+ return pcdError(bname, "could not load PCD header");
-+ if(strncmp(&header[0x800], "PCD_", 4) != 0)
-+ return pcdError(bname, "not a PCD file");
-+ rotate = header[0x0E02] & 0x03;
++ /*
++ * inspect the header
++ */
++ if(fread(&header[0], 1, sizeof(header), fp) != sizeof(header))
++ return pcdError(bname, "could not load PCD header");
++ if(strncmp((char *)&header[0x800], "PCD_", 4) != 0)
++ return pcdError(bname, "not a PCD file");
++ rotate = header[0x0E02] & 0x03;
+
+/* base/16
-+ - plain data starts at sector 1+2+1=4
-+ (numbered from 0, ie. the 5th sector)
-+ - luma 192*128 = 24576 bytes (12 sectors)
-+ + chroma1 96*64 = 6144 bytes (3 sectors)
-+ + chroma2 96*64 = 6144 bytes (3 sectors)
-+ = total 18 sectors
++ - plain data starts at sector 1+2+1=4
++ (numbered from 0, ie. the 5th sector)
++ - luma 192*128 = 24576 bytes (12 sectors)
++ + chroma1 96*64 = 6144 bytes (3 sectors)
++ + chroma2 96*64 = 6144 bytes (3 sectors)
++ = total 18 sectors
+
-+ - NB. "Plain" data is interleaved - 2 luma rows 192 wide,
-+ then 1 of each of the chroma rows 96 wide !
++ - NB. "Plain" data is interleaved - 2 luma rows 192 wide,
++ then 1 of each of the chroma rows 96 wide !
+
+ base/4
-+ - plain data starts at sector 1+2+1+18+1=23
-+ - luma 384*256 = 98304 bytes (48 sectors)
-+ + chroma1 192*128 = 24576 bytes (12 sectors)
-+ + chroma2 192*128 = 24576 bytes (12 sectors)
-+ = total 72 sectors
++ - plain data starts at sector 1+2+1+18+1=23
++ - luma 384*256 = 98304 bytes (48 sectors)
++ + chroma1 192*128 = 24576 bytes (12 sectors)
++ + chroma2 192*128 = 24576 bytes (12 sectors)
++ = total 72 sectors
+
-+ - NB. "Plain" data is interleaved - 2 luma rows 384 wide,
-+ then 1 of each of the chroma rows 192 wide !
++ - NB. "Plain" data is interleaved - 2 luma rows 384 wide,
++ then 1 of each of the chroma rows 192 wide !
+
+ base
-+ - plain data starts at sector 1+2+1+18+1+72+1=96
++ - plain data starts at sector 1+2+1+18+1+72+1=96
+
-+ - luma 768*512 = 393216 bytes (192 sectors)
-+ + chroma1 384*256 = 98304 bytes (48 sectors)
-+ + chroma2 384*256 = 98304 bytes (48 sectors)
-+ = total 288 sectors
++ - luma 768*512 = 393216 bytes (192 sectors)
++ + chroma1 384*256 = 98304 bytes (48 sectors)
++ + chroma2 384*256 = 98304 bytes (48 sectors)
++ = total 288 sectors
+
-+ - NB. "Plain" data is interleaved - 2 luma rows 768 wide,
-+ then 1 of each of the chroma rows 384 wide !
++ - NB. "Plain" data is interleaved - 2 luma rows 768 wide,
++ then 1 of each of the chroma rows 384 wide !
+
+ 4base
-+ - plain data for base is read
-+ - luma data interpolated *2
-+ - chroma data interpolated *4
++ - plain data for base is read
++ - luma data interpolated *2
++ - chroma data interpolated *4
+
-+ - cd_offset is 1+2+1+18+1+72+1+288=384
-+ - at cd_offset+4 (388) is huffman table
-+ - at cd_offset+5 (389) is 4base luma plane
++ - cd_offset is 1+2+1+18+1+72+1+288=384
++ - at cd_offset+4 (388) is huffman table
++ - at cd_offset+5 (389) is 4base luma plane
+
-+ (the sector at cd_offset+3 seems to contain 256 words each of
-+ which is an offset presumably to the sector containing certain
-+ rows ? rows/4 given 1024 possible rows. The rest of this sector
-+ is filled with zeroes)
++ (the sector at cd_offset+3 seems to contain 256 words each of
++ which is an offset presumably to the sector containing certain
++ rows ? rows/4 given 1024 possible rows. The rest of this sector
++ is filled with zeroes)
+
+
+ 16base
-+ - plain data for base is read
-+ - luma data interpolated *2
-+ - chroma data interpolated *4
-+
-+ - cd_offset is 1+2+1+18+1+72+1+288=384
-+ - at cd_offset+4 (388) is huffman table for 4 base
-+ - at cd_offset+5 (389) is 4base luma plane
-+ - luma plane interpolated *2
-+
-+ - cd_offset is set to current position (should be start of sector)
-+ - at cd_offset+12 is huffman table for 16 base
-+ - at cd_offset+14 is 16 base luma & 2 chroma planes which are read
++ - plain data for base is read
++ - luma data interpolated *2
++ - chroma data interpolated *4
++
++ - cd_offset is 1+2+1+18+1+72+1+288=384
++ - at cd_offset+4 (388) is huffman table for 4 base
++ - at cd_offset+5 (389) is 4base luma plane
++ - luma plane interpolated *2
++
++ - cd_offset is set to current position (should be start of sector)
++ - at cd_offset+12 is huffman table for 16 base
++ - at cd_offset+14 is 16 base luma & 2 chroma planes which are read
+ (note that the luma plane comes first, with a sync pattern
+ announcing each row from 0 to 2047, then the two chroma planes
+ are interleaved by row, the row # being even from 0 to 2046, with
+ each row containing 1536 values, the chroma1 row coming first,
+ finally followed by a sync pattern with a row of 2048 announcing
+ the end (its plane seems to be set to 3, ie. chroma2)
-+ - chroma planes interpolated *2
++ - chroma planes interpolated *2
+
-+ (the sector at cd_offset+10 & 11 seem to contain 1024 pairs of words
++ (the sector at cd_offset+10 & 11 seem to contain 1024 pairs of words
+ the first for luma and the second for chroma, each of
-+ which is an offset presumably to the sector containing certain
-+ rows ? rows/2 given 2048 possible rows)
++ which is an offset presumably to the sector containing certain
++ rows ? rows/2 given 2048 possible rows)
+
+Not yet implemented:
+
+In order to do overskip for base and 4base, one has to reach the chroma
+data for 16 base:
+
-+ - for 4base, after reading the 4base luma plane (and presumably
-+ skipping the chroma planes) one sets cd_offset to the start of
-+ the "current" sector
++ - for 4base, after reading the 4base luma plane (and presumably
++ skipping the chroma planes) one sets cd_offset to the start of
++ the "current" sector
+
-+ - for base, one has to skip the 4base data first:
-+ - cd_offset is set to 384
-+ - at (cd_offset+3 sectors)[510] is a 16 bit word high byte 1st
-+ containing an offset to the beginning of the 16base stuff
-+ though there is then a loop until >30 0xff's start a sector !
++ - for base, one has to skip the 4base data first:
++ - cd_offset is set to 384
++ - at (cd_offset+3 sectors)[510] is a 16 bit word high byte 1st
++ containing an offset to the beginning of the 16base stuff
++ though there is then a loop until >30 0xff's start a sector !
+
-+ - being now positioned after the end of the 4base stuff,
-+ - at (cd_offset+10 sectors)[2] is a 16 bit word high byte 1st
-+ containing an offset to the chroma planes.
-+ - at cd_offset+12 is the set of huffman tables
++ - being now positioned after the end of the 4base stuff,
++ - at (cd_offset+10 sectors)[2] is a 16 bit word high byte 1st
++ containing an offset to the chroma planes.
++ - at cd_offset+12 is the set of huffman tables
+
-+ - for base, the 16base chroma planes are then halved
++ - for base, the 16base chroma planes are then halved
+*/
+
+ PCDSetParamOptions(bname);
@@ -15668,7 +8737,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ SetCursors(-1); /* Somebody has already set it to wait :( */
+ leaveitup=1;
+ goforit=0;
-+ size = 1;
++ size = 1;
+ /* block until the popup window gets closed */
+ while (leaveitup) {
+ int i;
@@ -15689,268 +8758,268 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ goforit = 1;
+ }
+
-+ if(lutCB.val)
-+ rscale = gscale = bscale = 255.0/346.0;
-+ else
-+ rscale = gscale = bscale = 1.0;
++ if(lutCB.val)
++ rscale = gscale = bscale = 255.0/346.0;
++ else
++ rscale = gscale = bscale = 1.0;
++
++ switch (size) {
++ case 0:
++ pinfo->w = 192;
++ pinfo->h = 128;
++ offset=4*0x800;
++ mag=1;
++ huffplanes=0;
++ sprintf(pinfo->fullInfo, "PhotoCD, base/16 resolution");
++ break;
+
-+ switch (size) {
-+ case 0:
-+ pinfo->w = 192;
-+ pinfo->h = 128;
-+ offset=4*0x800;
-+ mag=1;
-+ huffplanes=0;
-+ sprintf(pinfo->fullInfo, "PhotoCD, base/16 resolution");
-+ break;
++ case 1:
++ pinfo->w = 384;
++ pinfo->h = 256;
++ offset=23*0x800;
++ mag=1;
++ huffplanes=0;
++ sprintf(pinfo->fullInfo, "PhotoCD, base/4 resolution");
++ break;
+
-+ case 1:
-+ pinfo->w = 384;
-+ pinfo->h = 256;
-+ offset=23*0x800;
-+ mag=1;
-+ huffplanes=0;
-+ sprintf(pinfo->fullInfo, "PhotoCD, base/4 resolution");
-+ break;
++ case 2:
++ default:
++ pinfo->w = 768;
++ pinfo->h = 512;
++ offset=96*0x800;
++ mag=1;
++ huffplanes=0;
++ sprintf(pinfo->fullInfo, "PhotoCD, base resolution");
++ break;
+
-+ case 2:
-+ default:
-+ pinfo->w = 768;
-+ pinfo->h = 512;
-+ offset=96*0x800;
-+ mag=1;
-+ huffplanes=0;
-+ sprintf(pinfo->fullInfo, "PhotoCD, base resolution");
-+ break;
++ case 3:
++ pinfo->w = 1536;
++ pinfo->h = 1024;
++ offset=96*0x800;
++ mag=2;
++ huffplanes=1;
++ sprintf(pinfo->fullInfo, "PhotoCD, 4base resolution");
++ break;
+
-+ case 3:
-+ pinfo->w = 1536;
-+ pinfo->h = 1024;
-+ offset=96*0x800;
-+ mag=2;
-+ huffplanes=1;
-+ sprintf(pinfo->fullInfo, "PhotoCD, 4base resolution");
-+ break;
++ case 4:
++ pinfo->w=3072;
++ pinfo->h=2048;
++ offset=96*0x800;
++ mag=4;
++ huffplanes=2;
++ sprintf(pinfo->fullInfo, "PhotoCD, 16base resolution");
++ break;
++ }
+
-+ case 4:
-+ pinfo->w=3072;
-+ pinfo->h=2048;
-+ offset=96*0x800;
-+ mag=4;
-+ huffplanes=2;
-+ sprintf(pinfo->fullInfo, "PhotoCD, 16base resolution");
-+ break;
-+ }
++ /*
++ * rotate?
++ */
++ w = pinfo->w;
++ h = pinfo->h;
++ switch(rotate) {
++ case 0:
++ break;
+
-+ /*
-+ * rotate?
-+ */
-+ w = pinfo->w;
-+ h = pinfo->h;
-+ switch(rotate) {
-+ case 0:
-+ break;
++ case 1:
++ case 3:
++ pinfo->w = h;
++ pinfo->h = w;
++ break;
+
-+ case 1:
-+ case 3:
-+ pinfo->w = h;
-+ pinfo->h = w;
-+ break;
++ default:
++ fprintf(stderr, "unknown image rotate %d; assuming none\n",
++ rotate);
++ rotate = 0;
++ }
+
-+ default:
-+ fprintf(stderr, "unknown image rotate %d; assuming none\n",
-+ rotate);
-+ rotate = 0;
-+ }
++ /*
++ * allocate 24-bit image
++ */
++ npixels = pinfo->w * pinfo->h;
++ bufsize = 3 * npixels;
++ if (pinfo->w <= 0 || pinfo->h <= 0 || npixels/pinfo->w != pinfo->h ||
++ bufsize/3 != npixels)
++ FatalError("image dimensions out of range");
+
-+ /*
-+ * allocate 24-bit image
-+ */
-+ npixels = pinfo->w * pinfo->h;
-+ bufsize = 3 * npixels;
-+ if (pinfo->w <= 0 || pinfo->h <= 0 || npixels/pinfo->w != pinfo->h ||
-+ bufsize/3 != npixels)
-+ FatalError("image dimensions out of range");
++ pinfo->pic = (byte *)malloc((size_t) bufsize);
++ if(!pinfo->pic)
++ FatalError("couldn't malloc '24-bit RGB plane'");
+
-+ pinfo->pic = (byte *)malloc((size_t) bufsize);
-+ if(!pinfo->pic)
-+ FatalError("couldn't malloc '24-bit RGB plane'");
++ pinfo->type = PIC24;
++ sprintf(pinfo->shrtInfo, "%dx%d PhotoCD.", pinfo->w, pinfo->h);
++ pinfo->colType = F_FULLCOLOR;
++ pinfo->frmType = -1;
+
-+ pinfo->type = PIC24;
-+ sprintf(pinfo->shrtInfo, "%dx%d PhotoCD.", pinfo->w, pinfo->h);
-+ pinfo->colType = F_FULLCOLOR;
-+ pinfo->frmType = -1;
++ if(fseek(fp, offset, SEEK_SET) == -1) {
++ free(pinfo->pic);
++ return pcdError(bname,"Can't find start of data.");
++ }
+
-+ if(fseek(fp, offset, SEEK_SET) == -1) {
-+ free(pinfo->pic);
-+ return pcdError(bname,"Can't find start of data.");
-+ }
++ pic24 = pinfo->pic;
+
-+ pic24 = pinfo->pic;
++ luma=(byte *)calloc(npixels,1);
++ if(!luma) {
++ free(pinfo->pic);
++ FatalError("couldn't malloc 'luma plane'");
++ }
+
-+ luma=(byte *)calloc(npixels,1);
-+ if(!luma) {
-+ free(pinfo->pic);
-+ FatalError("couldn't malloc 'luma plane'");
-+ }
++ chroma1=(byte *)calloc(npixels/4,1);
++ if(!chroma1) {
++ free(pinfo->pic);
++ free(luma);
++ FatalError("couldn't malloc 'chroma1 plane'");
++ }
+
-+ chroma1=(byte *)calloc(npixels/4,1);
-+ if(!chroma1) {
-+ free(pinfo->pic);
-+ free(luma);
-+ FatalError("couldn't malloc 'chroma1 plane'");
-+ }
++ chroma2=(byte *)calloc(npixels/4,1);
++ if(!chroma2) {
++ free(pinfo->pic);
++ free(luma);
++ free(chroma1);
++ FatalError("couldn't malloc 'chroma2 plane'");
++ }
+
-+ chroma2=(byte *)calloc(npixels/4,1);
-+ if(!chroma2) {
-+ free(pinfo->pic);
-+ free(luma);
-+ free(chroma1);
-+ FatalError("couldn't malloc 'chroma2 plane'");
-+ }
++ /* Read 2 luma rows length w, then one of each chroma rows w/2 */
++ /* If a mag factor is active, the small image is read into the */
++ /* top right hand corner of the larger allocated image */
+
-+ /* Read 2 luma rows length w, then one of each chroma rows w/2 */
-+ /* If a mag factor is active, the small image is read into the */
-+ /* top right hand corner of the larger allocated image */
++ trace((stderr, "base image: start @ 0x%08lx (sector %ld.%ld)\n",
++ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
++ for(row=0,lptr=luma,c1ptr=chroma1,c2ptr=chroma2; row <h/mag;
++ row+=2,lptr+=w*2,c1ptr+=w/2,c2ptr+=w/2) {
++ if(fread(lptr, 1, w/mag, fp) != w/mag) {
++ pcdError(bname, "Luma plane too short.");
++ break;
++ }
++ if(fread(lptr+w, 1, w/mag, fp) != w/mag) {
++ pcdError(bname, "Luma plane too short.");
++ break;
++ }
++ if(fread(c1ptr, 1, w/2/mag, fp) != w/2/mag) {
++ pcdError(bname, "Chroma1 plane too short.");
++ break;
++ }
++ if(fread(c2ptr, 1, w/2/mag, fp) != w/2/mag) {
++ pcdError(bname, "Chroma2 plane too short.");
++ break;
++ }
++ if(row%wcurfactor == 0)
++ WaitCursor();
++ }
++ trace((stderr, "base image: done @ 0x%08lx (sector %ld.%ld)\n",
++ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
+
-+ trace((stderr, "base image: start @ 0x%08lx (sector %ld.%ld)\n",
-+ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
-+ for(row=0,lptr=luma,c1ptr=chroma1,c2ptr=chroma2; row <h/mag;
-+ row+=2,lptr+=w*2,c1ptr+=w/2,c2ptr+=w/2) {
-+ if(fread(lptr, 1, w/mag, fp) != w/mag) {
-+ pcdError(bname, "Luma plane too short.");
-+ break;
-+ }
-+ if(fread(lptr+w, 1, w/mag, fp) != w/mag) {
-+ pcdError(bname, "Luma plane too short.");
-+ break;
-+ }
-+ if(fread(c1ptr, 1, w/2/mag, fp) != w/2/mag) {
-+ pcdError(bname, "Chroma1 plane too short.");
-+ break;
-+ }
-+ if(fread(c2ptr, 1, w/2/mag, fp) != w/2/mag) {
-+ pcdError(bname, "Chroma2 plane too short.");
-+ break;
-+ }
-+ if(row%wcurfactor == 0)
-+ WaitCursor();
-+ }
-+ trace((stderr, "base image: done @ 0x%08lx (sector %ld.%ld)\n",
-+ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
-+
-+ if(huffplanes) {
-+ if(fseek(fp, 388*0x800, SEEK_SET) == -1)
-+ return pcdError(bname,
-+ "Can't find start of huffman tables.");
-+
-+ magnify(2, h/mag, w/mag, h, w, luma);
-+ magnify(2, h/2/mag, w/2/mag, h/2, w/2, chroma1);
-+ magnify(2, h/2/mag, w/2/mag, h/2, w/2, chroma2);
-+
-+ /*
-+ * doesn't really touch the chroma planes which aren't
-+ * present in 4base
-+ */
-+ gethuffdata(luma, chroma1, chroma2, w, h/mag*2);
-+
-+ /*
-+ * if only doing 4base should probably fetch 16bases
-+ * chroma planes here
-+ */
-+ if(huffplanes == 2) {
-+ /*
-+ * This depends on gethuffdata() having grabbed
-+ * things in 0x800 sectors AND still being
-+ * positioned in the "last" sector of the data
-+ * (cf. Hadmut's code which is positioned at start
-+ * of the next sector)
-+ */
-+ long offset = ftell(fp)/0x800+12;
-+
-+ if(fseek(fp, offset*0x800, SEEK_SET) == 0) {
-+ magnify(2,h/2,w/2,h,w,luma);
-+ magnify(2,h/4,w/4,h/2,w/2,chroma1);
-+ magnify(2,h/4,w/4,h/2,w/2,chroma2);
-+ gethuffdata(luma,chroma1,chroma2,w,h);
-+ } else
-+ fprintf(stderr, "can't seek to 2nd huffman tables\n");
-+ }
-+ }
-+ fclose(fp);
++ if(huffplanes) {
++ if(fseek(fp, 388*0x800, SEEK_SET) == -1)
++ return pcdError(bname,
++ "Can't find start of huffman tables.");
+
-+ /*
-+ * YCC -> R'G'B' and image rotate
-+ */
-+ ptr=pic24;
-+ lptr=luma; c1ptr=chroma1; c2ptr=chroma2;
-+ for(row = 0; row < h; ++row) {
-+ byte *rowc1ptr = c1ptr,
-+ *rowc2ptr = c2ptr;
-+ int k = 0;
-+
-+ switch(rotate) {
-+ case 1:
-+ ptr = &pic24[row*3 + (w - 1)*h*3];
-+ k = -3*(h + 1);
-+ break;
++ magnify(2, h/mag, w/mag, h, w, luma);
++ magnify(2, h/2/mag, w/2/mag, h/2, w/2, chroma1);
++ magnify(2, h/2/mag, w/2/mag, h/2, w/2, chroma2);
+
-+ case 3:
-+ ptr = &pic24[(h - 1 - row)*3];
-+ k = 3*(h - 1);
-+ break;
++ /*
++ * doesn't really touch the chroma planes which aren't
++ * present in 4base
++ */
++ gethuffdata(luma, chroma1, chroma2, w, h/mag*2);
+
-+ default:
-+ ptr = &pic24[row*w*3];
-+ k = 0;
-+ break;
-+ }
-+ for(col = 0; col < w; ++col) {
-+ double L = 1.3584*(double) *lptr++,
-+ C1 = 2.2179*(double) (*c1ptr - 156),
-+ C2 = 1.8215*(double) (*c2ptr - 137);
-+ int r = rscale*(L + C2),
-+ g = gscale*(L - 0.194*C1 - 0.509*C2),
-+ b = bscale*(L + C1);
-+
-+ if(lutCB.val) {
-+ if(r < 0) r = 0; else if(r >= 255) r = 255;
-+ if(g < 0) g = 0; else if(g >= 255) g = 255;
-+ if(b < 0) b = 0; else if(b >= 255) b = 255;
-+ } else {
-+ if(r < 0) r = 0; else if(r >= 351) r = 350;
-+ if(g < 0) g = 0; else if(g >= 351) g = 350;
-+ if(b < 0) b = 0; else if(b >= 351) b = 350;
-+ r = Y[r]; g = Y[g]; b = Y[b];
-+ }
-+ *ptr++ = r;
-+ *ptr++ = g;
-+ *ptr++ = b;
-+ ptr += k;
-+ if(col & 1) {
-+ ++c1ptr;
-+ ++c2ptr;
-+ }
-+ }
-+ if((row & 1) == 0) {
-+ c1ptr = rowc1ptr;
-+ c2ptr = rowc2ptr;
-+ }
-+ if(row%wcurfactor == 0)
-+ WaitCursor();
-+ }
-+ free(luma); free(chroma1); free(chroma2);
-+ return 1;
++ /*
++ * if only doing 4base should probably fetch 16bases
++ * chroma planes here
++ */
++ if(huffplanes == 2) {
++ /*
++ * This depends on gethuffdata() having grabbed
++ * things in 0x800 sectors AND still being
++ * positioned in the "last" sector of the data
++ * (cf. Hadmut's code which is positioned at start
++ * of the next sector)
++ */
++ long offset = ftell(fp)/0x800+12;
++
++ if(fseek(fp, offset*0x800, SEEK_SET) == 0) {
++ magnify(2,h/2,w/2,h,w,luma);
++ magnify(2,h/4,w/4,h/2,w/2,chroma1);
++ magnify(2,h/4,w/4,h/2,w/2,chroma2);
++ gethuffdata(luma,chroma1,chroma2,w,h);
++ } else
++ fprintf(stderr, "can't seek to 2nd huffman tables\n");
++ }
++ }
++ fclose(fp);
++
++ /*
++ * YCC -> R'G'B' and image rotate
++ */
++ ptr=pic24;
++ lptr=luma; c1ptr=chroma1; c2ptr=chroma2;
++ for(row = 0; row < h; ++row) {
++ byte *rowc1ptr = c1ptr,
++ *rowc2ptr = c2ptr;
++ int k = 0;
++
++ switch(rotate) {
++ case 1:
++ ptr = &pic24[row*3 + (w - 1)*h*3];
++ k = -3*(h + 1);
++ break;
++
++ case 3:
++ ptr = &pic24[(h - 1 - row)*3];
++ k = 3*(h - 1);
++ break;
++
++ default:
++ ptr = &pic24[row*w*3];
++ k = 0;
++ break;
++ }
++ for(col = 0; col < w; ++col) {
++ double L = 1.3584*(double) *lptr++,
++ C1 = 2.2179*(double) (*c1ptr - 156),
++ C2 = 1.8215*(double) (*c2ptr - 137);
++ int r = rscale*(L + C2),
++ g = gscale*(L - 0.194*C1 - 0.509*C2),
++ b = bscale*(L + C1);
++
++ if(lutCB.val) {
++ if(r < 0) r = 0; else if(r >= 255) r = 255;
++ if(g < 0) g = 0; else if(g >= 255) g = 255;
++ if(b < 0) b = 0; else if(b >= 255) b = 255;
++ } else {
++ if(r < 0) r = 0; else if(r >= 351) r = 350;
++ if(g < 0) g = 0; else if(g >= 351) g = 350;
++ if(b < 0) b = 0; else if(b >= 351) b = 350;
++ r = Y[r]; g = Y[g]; b = Y[b];
++ }
++ *ptr++ = r;
++ *ptr++ = g;
++ *ptr++ = b;
++ ptr += k;
++ if(col & 1) {
++ ++c1ptr;
++ ++c2ptr;
++ }
++ }
++ if((row & 1) == 0) {
++ c1ptr = rowc1ptr;
++ c2ptr = rowc2ptr;
++ }
++ if(row%wcurfactor == 0)
++ WaitCursor();
++ }
++ free(luma); free(chroma1); free(chroma2);
++ return 1;
+}
+
+/*
+ * derived from Hadmut Danisch's interpolate()
+ */
+static void
-+magnify(int mag, /* power of 2 by which to magnify in place */
-+ int h, int w, /* the "start" unmag'd dimensions of the array */
-+ int mh, int mw, /* the real (maximum) dimensions of the array */
-+ byte *p) /* pointer to the data */
++magnify(int mag, /* power of 2 by which to magnify in place */
++ int h, int w, /* the "start" unmag'd dimensions of the array */
++ int mh, int mw, /* the real (maximum) dimensions of the array */
++ byte *p) /* pointer to the data */
+{
+ int x,y,yi;
+ byte *optr,*nptr,*uptr; /* MUST be unsigned, else averaging fails */
@@ -15964,7 +9033,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+
+ for(y=0;y<h;y++) {
+ yi=h-1-y;
-+ optr=p+ yi*mw + (w-1); /* last pixel of an old row */
++ optr=p+ yi*mw + (w-1); /* last pixel of an old row */
+ nptr=p+2*yi*mw + (2*w - 2); /* last pixel of a new row */
+
+ nptr[0]=nptr[1]=optr[0]; /* special cases */
@@ -16000,18 +9069,18 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ ((int)*(uptr++))+1)>>1; /* last pixel */
+ }
+
-+ xvbcopy(p + (2*h-2)*mw, /* 2nd last row */
-+ p + (2*h-1)*mw, /* the last row */
-+ 2*w); /* length of a new row */
++ xvbcopy((char *)(p + (2*h-2)*mw), /* 2nd last row */
++ (char *)(p + (2*h-1)*mw), /* the last row */
++ 2*w); /* length of a new row */
+
+ h*=2; w*=2;
-+ mag>>=1; /* Obviously mag must be a power of 2 ! */
++ mag>>=1; /* Obviously mag must be a power of 2 ! */
+ }
+}
+
+/*******************************************/
+static int
-+pcdError(char *fname, char *st)
++pcdError(const char *fname, const char *st)
+{
+ SetISTR(ISTR_WARNING,"%s: %s", fname, st);
+ return 0;
@@ -16041,19 +9110,19 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+/***************************************************/
+void CreatePCDW()
+{
-+ int y;
++ int y;
+
+ pcdW = CreateWindow("xv pcd", "XVpcd", NULL,
-+ TWIDE, THIGH, infofg, infobg, 0);
++ TWIDE, THIGH, infofg, infobg, 0);
+ if (!pcdW) FatalError("can't create pcd window!");
+
+ XSelectInput(theDisp, pcdW, ExposureMask | ButtonPressMask | KeyPressMask);
+
+ BTCreate(&tbut[T_BOK], pcdW, TWIDE-140-1, THIGH-10-BUTTH-1, 60, BUTTH,
-+ "Ok", infofg, infobg, hicol, locol);
++ "Ok", infofg, infobg, hicol, locol);
+
+ BTCreate(&tbut[T_BCANC], pcdW, TWIDE-70-1, THIGH-10-BUTTH-1, 60, BUTTH,
-+ "Cancel", infofg, infobg, hicol, locol);
++ "Cancel", infofg, infobg, hicol, locol);
+
+ y = 55;
+ resnRB = RBCreate(NULL, pcdW, 36, y, "192*128 Base/16",
@@ -16082,7 +9151,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+{
+ if (vis) {
+ CenterMapWindow(pcdW, tbut[T_BOK].x + tbut[T_BOK].w/2,
-+ tbut[T_BOK].y + tbut[T_BOK].h/2, TWIDE, THIGH);
++ tbut[T_BOK].y + tbut[T_BOK].h/2, TWIDE, THIGH);
+ }
+ else XUnmapWindow(theDisp, pcdW);
+ pcdUp = vis;
@@ -16135,12 +9204,12 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+
+ if (e->window == pcdW) {
+ if (stlen) {
-+ if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
-+ FakeButtonPress(&tbut[T_BOK]);
-+ }
-+ else if (buf[0] == '\033') { /* ESC */
-+ FakeButtonPress(&tbut[T_BCANC]);
-+ }
++ if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
++ FakeButtonPress(&tbut[T_BOK]);
++ }
++ else if (buf[0] == '\033') { /* ESC */
++ FakeButtonPress(&tbut[T_BCANC]);
++ }
+ }
+ }
+ else rv = 0;
@@ -16158,7 +9227,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+
+/***************************************************/
+void
-+PCDSetParamOptions(char *fname)
++PCDSetParamOptions(const char *fname)
+{
+ int cur;
+ cur = RBWhich(resnRB);
@@ -16176,9 +9245,9 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+static void
+drawTD(int x, int y, int w, int h)
+{
-+ char *title = "Load PhotoCD file...";
-+ int i;
-+ XRectangle xr;
++ const char *title = "Load PhotoCD file...";
++ int i;
++ XRectangle xr;
+
+ xr.x = x; xr.y = y; xr.width = w; xr.height = h;
+ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
@@ -16237,12 +9306,12 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ leaveitup=0;
+ goforit=0;
+ switch (cmd) {
-+ case T_BOK: PCDSetParams();
++ case T_BOK: PCDSetParams();
+ goforit=1;
-+ case T_BCANC: PCDDialog(0);
++ case T_BCANC: PCDDialog(0);
+ break;
+
-+ default: break;
++ default: break;
+ }
+}
+
@@ -16268,7 +9337,7 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+ *
+ * Store the huffman table into tree type structure:
+ *
-+ * int int[n of entries*2]
++ * int int[n of entries*2]
+ *
+ * Each entry consists of two words (the 1st for zero and the 2nd for one).
+ *
@@ -16283,171 +9352,171 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+static void
+dumphufftab(int n, const byte *h, int m, const int *t)
+{
-+ int j;
++ int j;
+
-+ for(j = 0; j < n || j < m; ++j) {
-+ if(j < m)
-+ fprintf(stderr, "%04x %04x ::", 0xffff & t[2*j + 0],
-+ 0xffff & t[2*j + 1]);
-+ else
-+ fprintf(stderr, "%s %s ::", " ", " ");
-+ if(j < n) {
-+ int k;
-+ unsigned l = (h[4*j + 1] << 8) | h[4*j + 2];
-+
-+ fprintf(stderr, " %02x %2d ", h[4*j + 3], h[4*j + 0]);
-+ for(k = 0; k <= h[4*j + 0]; ++k, l *= 2)
-+ fprintf(stderr, "%c", '0'+((l & 0x8000) != 0));
-+ }
-+ fprintf(stderr, "\n");
-+ }
++ for(j = 0; j < n || j < m; ++j) {
++ if(j < m)
++ fprintf(stderr, "%04x %04x ::", 0xffff & t[2*j + 0],
++ 0xffff & t[2*j + 1]);
++ else
++ fprintf(stderr, "%s %s ::", " ", " ");
++ if(j < n) {
++ int k;
++ unsigned l = (h[4*j + 1] << 8) | h[4*j + 2];
++
++ fprintf(stderr, " %02x %2d ", h[4*j + 3], h[4*j + 0]);
++ for(k = 0; k <= h[4*j + 0]; ++k, l *= 2)
++ fprintf(stderr, "%c", '0'+((l & 0x8000) != 0));
++ }
++ fprintf(stderr, "\n");
++ }
+}
+
+static int *
+gethufftable(void)
+{
-+ int *hufftab, *h, i, j, N, num, bufsize, huffptr, hufftop;
-+ byte *huf;
-+
-+ /*
-+ * absorb the entirety of the table in one chunk (for better
-+ * dumps in case of error)
-+ */
-+ trace((stderr, "hufftab 0x%08lx ", ftell(fp)));
-+ num = 1 + fgetc(fp); /* 256 max */
-+ huf = (byte *)alloca(4*num*sizeof(byte));
-+ if((i = fread(huf, 1, 4*num, fp)) != 4*num) {
-+ fprintf(stderr, "unexpected EOF: got %d bytes, wanted %d\n",
-+ i, 4*num);
-+ return NULL;
-+ }
++ int *hufftab, *h, i, j, N, num, bufsize, huffptr, hufftop;
++ byte *huf;
+
-+ /*
-+ * guess an initial size and prepare the initial entry
-+ */
-+ trace((stderr, "length %u\n", num));
-+ N = 2*num; /* 512 max */
-+ bufsize = N * sizeof(int);
-+/* this case can't happen, but added for symmetry with loop below
-+ if (N/2 != num || bufsize/N != sizeof(int)) {
-+ SetISTR(ISTR_WARNING, "Huffman table size out of range");
-+ return NULL;
-+ }
++ /*
++ * absorb the entirety of the table in one chunk (for better
++ * dumps in case of error)
++ */
++ trace((stderr, "hufftab 0x%08lx ", ftell(fp)));
++ num = 1 + fgetc(fp); /* 256 max */
++ huf = (byte *)alloca(4*num*sizeof(byte));
++ if((i = fread(huf, 1, 4*num, fp)) != 4*num) {
++ fprintf(stderr, "unexpected EOF: got %d bytes, wanted %d\n",
++ i, 4*num);
++ return NULL;
++ }
++
++ /*
++ * guess an initial size and prepare the initial entry
++ */
++ trace((stderr, "length %u\n", num));
++ N = 2*num; /* 512 max */
++ bufsize = N * sizeof(int);
++/* this case can't happen, but added for symmetry with loop below
++ if (N/2 != num || bufsize/N != sizeof(int)) {
++ SetISTR(ISTR_WARNING, "Huffman table size out of range");
++ return NULL;
++ }
+ */
-+ if((hufftab = (int *)malloc(bufsize)) == NULL)
-+ FatalError("couldn't malloc initial Huffman table");
-+ hufftab[0] = hufftab[1] = 0;
-+
-+ /*
-+ * we check the table for reasonableness; there is a lack of detailed
-+ * documentation on this format. in particular, for the base16,
-+ * the position of the huffman tables is uncertain to within one
-+ * "sector", and we have to detect his before trying to read
-+ * bogusness.
-+ */
-+ hufftop = 0;
-+ for(i = 0; i < num; ++i) {
-+ unsigned length = huf[4*i + 0],
-+ codeword = (huf[4*i + 1] << 8) | huf[4*i + 2];
-+
-+ /*
-+ * some sanity checks
-+ */
-+ if(length >= 16) {
-+ fprintf(stderr,
-+ "gethufftable: improbable length @ %d/%d\n",
-+ i, num);
-+ dumphufftab(num, huf, hufftop/2, hufftab);
-+ free(hufftab);
-+ return NULL;
-+ }
++ if((hufftab = (int *)malloc(bufsize)) == NULL)
++ FatalError("couldn't malloc initial Huffman table");
++ hufftab[0] = hufftab[1] = 0;
+
-+ /*
-+ * walk the whole set of codes
-+ */
-+ huffptr = 0;
-+ for(j = 0; j < 16; ++j, codeword *= 2) {
-+ /*
-+ * choose the child node
-+ */
-+ if(codeword & 0x8000)
-+ ++huffptr;
-+
-+ /*
-+ * store value at end-of-code
-+ */
-+ if(j == length) {
-+ /*
-+ * more sanity
-+ */
-+ if((codeword *= 2) & 0xffff) {
-+ fprintf(stderr,
-+ "gethufftable: "
-+ ":probable invalid code @ %d\n",
-+ i);
-+ dumphufftab(num, huf,
-+ hufftop/2, hufftab);
-+ free(hufftab);
-+ return NULL;
-+ }
-+ hufftab[huffptr] = 1 + (int) huf[4*i + 3];
-+ break;
-+ }
++ /*
++ * we check the table for reasonableness; there is a lack of detailed
++ * documentation on this format. in particular, for the base16,
++ * the position of the huffman tables is uncertain to within one
++ * "sector", and we have to detect his before trying to read
++ * bogusness.
++ */
++ hufftop = 0;
++ for(i = 0; i < num; ++i) {
++ unsigned length = huf[4*i + 0],
++ codeword = (huf[4*i + 1] << 8) | huf[4*i + 2];
+
-+ /*
-+ * otherwise, follow the tree to date
-+ */
-+ if(hufftab[huffptr] < 0) {
-+ huffptr -= hufftab[huffptr];
-+ continue;
-+ } else if(hufftab[huffptr] > 0) {
-+ fprintf(stderr, "duplicate code %d %d/%d\n",
-+ huffptr, i, num);
-+ dumphufftab(num, huf, hufftop/2, hufftab);
-+ free(hufftab);
-+ return NULL;
-+ }
++ /*
++ * some sanity checks
++ */
++ if(length >= 16) {
++ fprintf(stderr,
++ "gethufftable: improbable length @ %d/%d\n",
++ i, num);
++ dumphufftab(num, huf, hufftop/2, hufftab);
++ free(hufftab);
++ return NULL;
++ }
++
++ /*
++ * walk the whole set of codes
++ */
++ huffptr = 0;
++ for(j = 0; j < 16; ++j, codeword *= 2) {
++ /*
++ * choose the child node
++ */
++ if(codeword & 0x8000)
++ ++huffptr;
++
++ /*
++ * store value at end-of-code
++ */
++ if(j == length) {
++ /*
++ * more sanity
++ */
++ if((codeword *= 2) & 0xffff) {
++ fprintf(stderr,
++ "gethufftable: "
++ ":probable invalid code @ %d\n",
++ i);
++ dumphufftab(num, huf,
++ hufftop/2, hufftab);
++ free(hufftab);
++ return NULL;
++ }
++ hufftab[huffptr] = 1 + (int) huf[4*i + 3];
++ break;
++ }
++
++ /*
++ * otherwise, follow the tree to date
++ */
++ if(hufftab[huffptr] < 0) {
++ huffptr -= hufftab[huffptr];
++ continue;
++ } else if(hufftab[huffptr] > 0) {
++ fprintf(stderr, "duplicate code %d %d/%d\n",
++ huffptr, i, num);
++ dumphufftab(num, huf, hufftop/2, hufftab);
++ free(hufftab);
++ return NULL;
++ }
+
-+ /*
-+ * and if necessary, make the tree bigger
-+ */
-+ if((hufftop += 2) >= N) {
-+ int oldN = N;
++ /*
++ * and if necessary, make the tree bigger
++ */
++ if((hufftop += 2) >= N) {
++ int oldN = N;
+#if TRACE
-+ dumphufftab(num, huf, hufftop/2, hufftab);
-+#endif
-+ N *= 2;
-+ bufsize = N*sizeof(int);
-+ if (N/2 != oldN || bufsize/N != sizeof(int)) {
-+ SetISTR(ISTR_WARNING,
-+ "new Huffman table is too large");
-+ free(hufftab);
-+ return NULL;
-+ }
-+ h = (int *)realloc(hufftab, bufsize);
-+ if(h == NULL) {
-+ fprintf(stderr,
-+ "Table overflow %d/%d\n",
-+ i, num);
-+ dumphufftab(num, huf,
-+ hufftop/2, hufftab);
-+ free(hufftab);
-+ FatalError(
-+ "couldn't realloc Huffman table");
-+ }
-+ hufftab = h;
-+ }
++ dumphufftab(num, huf, hufftop/2, hufftab);
++#endif
++ N *= 2;
++ bufsize = N*sizeof(int);
++ if (N/2 != oldN || bufsize/N != sizeof(int)) {
++ SetISTR(ISTR_WARNING,
++ "new Huffman table is too large");
++ free(hufftab);
++ return NULL;
++ }
++ h = (int *)realloc(hufftab, bufsize);
++ if(h == NULL) {
++ fprintf(stderr,
++ "Table overflow %d/%d\n",
++ i, num);
++ dumphufftab(num, huf,
++ hufftop/2, hufftab);
++ free(hufftab);
++ FatalError(
++ "couldn't realloc Huffman table");
++ }
++ hufftab = h;
++ }
+
-+ /*
-+ * then add new ptr
-+ */
-+ hufftab[huffptr] = huffptr - hufftop;
-+ huffptr = hufftop;
-+ hufftab[huffptr + 0] =
-+ hufftab[huffptr + 1] = 0;
-+ }
-+ }
-+ return hufftab;
++ /*
++ * then add new ptr
++ */
++ hufftab[huffptr] = huffptr - hufftop;
++ huffptr = hufftop;
++ hufftab[huffptr + 0] =
++ hufftab[huffptr + 1] = 0;
++ }
++ }
++ return hufftab;
+}
+
+/* WORDTYPE & char buffer must be unsigned else */
@@ -16559,501 +9628,173 @@ diff -ruN xv-3.10a-bugfixes/xvpcd.c xv-3.10a-enhancements/xvpcd.c
+#define skip24() (skipnn(24))
+
+static int
-+gethuffdata( byte *luma,
-+ byte *chroma1,
-+ byte *chroma2,
-+ int realrowwidth,
-+ int maxrownumber)
-+{
-+static byte clip[3*256];
-+ int *hufftable[3], *huffstart = NULL, *huffptr = NULL;
-+ int row, col, plane, i, result = 1;
++gethuffdata( byte *luma,
++ byte *chroma1,
++ byte *chroma2,
++ int realrowwidth,
++ int maxrownumber)
++{
++static byte clip[3*256];
++ int *hufftable[3], *huffstart = NULL, *huffptr = NULL;
++ int row, col, plane, i, result = 1;
+#if TRACE
-+ int uflow = 0, oflow = 0;
++ int uflow = 0, oflow = 0;
+#endif
-+ byte *pixelptr = NULL;
-+
-+ trace((stderr,"gethuffdata: start @ 0x%08lx (sector %ld.%ld)\n",
-+ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
-+
-+ /*
-+ * correction clipping
-+ */
-+ if(clip[256+255] == 0) {
-+ for(i = 0; i < 256; ++i)
-+ clip[i + 0] = 0x00,
-+ clip[i + 256] = (byte) i,
-+ clip[i + 512] = 0xff;
-+ }
++ byte *pixelptr = NULL;
+
-+ /*
-+ * should really only look for luma plane for 4base, but the
-+ * there are zeroes in the rest of the sector that give both
-+ * chroma tables 0 length
-+ */
-+ for(i = 0; i < 3; ++i)
-+ hufftable[i] = NULL;
-+ for(i = 0; i < 3; ++i) {
-+ if((hufftable[i] = gethufftable()) == NULL) {
-+ result = 0;
-+ break;
-+ }
-+ }
-+ if(result == 0)
-+ goto oops;
-+
-+ /*
-+ * skip remainder of current sector
-+ */
-+ i = (ftell(fp) | 0x7ff) + 1;
-+ if(fseek(fp, i, SEEK_SET) < 0) {
-+ fprintf(stderr, "gethuffdata: sector skip failed\n");
-+ return 0;
-+ }
++ trace((stderr,"gethuffdata: start @ 0x%08lx (sector %ld.%ld)\n",
++ ftell(fp), ftell(fp)/0x800, ftell(fp) % 0x800));
+
-+ /*
-+ * skip remainder of "sector"
-+ */
-+ i = 0;
-+ while (is24() != 0xfffffe) {
-+ (void)get24();
-+ if(++i == 1)
-+ trace((stderr,"gethuffdata: skipping for sync ..."));
-+ }
-+ if(i != 0)
-+ trace((stderr, " %d times\n", i));
-+
-+ while(result) {
-+ if(is24() == 0xfffffe) {
-+ skip24();
-+ plane = get2();
-+ row = get13(); col = 0;
-+ skip1();
-+ if(row >= maxrownumber) {
-+ trace((stderr,
-+ "gethuffdata: stopping at row %d\n",
-+ row));
-+ break;
-+ }
-+ switch (plane) {
-+ case 0:
-+ huffstart = hufftable[0];
-+ pixelptr = luma + row*realrowwidth;
-+ break;
++ /*
++ * correction clipping
++ */
++ if(clip[256+255] == 0) {
++ for(i = 0; i < 256; ++i)
++ clip[i + 0] = 0x00,
++ clip[i + 256] = (byte) i,
++ clip[i + 512] = 0xff;
++ }
+
-+ case 2:
-+ huffstart = hufftable[1];
-+ pixelptr = chroma1 + row/2*realrowwidth/2;
-+ break;
++ /*
++ * should really only look for luma plane for 4base, but the
++ * there are zeroes in the rest of the sector that give both
++ * chroma tables 0 length
++ */
++ for(i = 0; i < 3; ++i)
++ hufftable[i] = NULL;
++ for(i = 0; i < 3; ++i) {
++ if((hufftable[i] = gethufftable()) == NULL) {
++ result = 0;
++ break;
++ }
++ }
++ if(result == 0)
++ goto oops;
+
-+ case 3:
-+ huffstart = hufftable[2];
-+ pixelptr = chroma2 + row/2*realrowwidth/2;
-+ break;
++ /*
++ * skip remainder of current sector
++ */
++ i = (ftell(fp) | 0x7ff) + 1;
++ if(fseek(fp, i, SEEK_SET) < 0) {
++ fprintf(stderr, "gethuffdata: sector skip failed\n");
++ return 0;
++ }
+
-+ default:
-+ fprintf(stderr, "gethuffdata: bad plane %d\n",
-+ plane);
-+ result = 0;
-+ break;
-+ }
-+ WaitCursor();
-+ continue;
-+ }
++ /*
++ * skip remainder of "sector"
++ */
++ i = 0;
++ while (is24() != 0xfffffe) {
++ (void)get24();
++ if(++i == 1)
++ trace((stderr,"gethuffdata: skipping for sync ..."));
++ }
++ if(i != 0)
++ trace((stderr, " %d times\n", i));
++
++ while(result) {
++ if(is24() == 0xfffffe) {
++ skip24();
++ plane = get2();
++ row = get13(); col = 0;
++ skip1();
++ if(row >= maxrownumber) {
++ trace((stderr,
++ "gethuffdata: stopping at row %d\n",
++ row));
++ break;
++ }
++ switch (plane) {
++ case 0:
++ huffstart = hufftable[0];
++ pixelptr = luma + row*realrowwidth;
++ break;
+
-+ /*
-+ * locate correction in huffman tree
-+ */
-+ for(huffptr = huffstart;;) {
-+ huffptr += get1();
-+ if(*huffptr < 0) {
-+ huffptr -= *huffptr;
-+ } else if(*huffptr == 0) {
-+ fprintf(stderr,
-+ "gethuffdata: invalid code: "
-+ "image quality reduced\n");
-+ result = 0;
-+ break;
-+ } else
-+ break;
-+ }
-+ if(!result)
-+ break;
++ case 2:
++ huffstart = hufftable[1];
++ pixelptr = chroma1 + row/2*realrowwidth/2;
++ break;
++
++ case 3:
++ huffstart = hufftable[2];
++ pixelptr = chroma2 + row/2*realrowwidth/2;
++ break;
++
++ default:
++ fprintf(stderr, "gethuffdata: bad plane %d\n",
++ plane);
++ result = 0;
++ break;
++ }
++ WaitCursor();
++ continue;
++ }
++
++ /*
++ * locate correction in huffman tree
++ */
++ for(huffptr = huffstart;;) {
++ huffptr += get1();
++ if(*huffptr < 0) {
++ huffptr -= *huffptr;
++ } else if(*huffptr == 0) {
++ fprintf(stderr,
++ "gethuffdata: invalid code: "
++ "image quality reduced\n");
++ result = 0;
++ break;
++ } else
++ break;
++ }
++ if(!result)
++ break;
+
-+ /*
-+ * apply correction to the pixel
-+ *
-+ * eeeek!! the corrections can sometimes over or underflow!
-+ * this strongly suggested that the 'magnify' method was in
-+ * some way wrong. however, experiments showed that the
-+ * over/under flows even occured for the pixels that are
-+ * copied through magnify without change (ie, the even
-+ * row/even column case). curiously, though, the odd
-+ * column and odd row cases were about 3x more likely to have
-+ * the over/underflow, and the odd row/odd column case was
-+ * about 5x higher, so maybe the use of a bi-linear
-+ * interpolation is not correct -- just *close*?
-+ *
-+ * the other clue in this area is that the overflows are
-+ * by far most frequenct along edges of very bright
-+ * areas -- rarely in the interior of such regions.
-+ */
-+ i = (int) *pixelptr + (signed char) (*huffptr - 1);
++ /*
++ * apply correction to the pixel
++ *
++ * eeeek!! the corrections can sometimes over or underflow!
++ * this strongly suggested that the 'magnify' method was in
++ * some way wrong. however, experiments showed that the
++ * over/under flows even occured for the pixels that are
++ * copied through magnify without change (ie, the even
++ * row/even column case). curiously, though, the odd
++ * column and odd row cases were about 3x more likely to have
++ * the over/underflow, and the odd row/odd column case was
++ * about 5x higher, so maybe the use of a bi-linear
++ * interpolation is not correct -- just *close*?
++ *
++ * the other clue in this area is that the overflows are
++ * by far most frequenct along edges of very bright
++ * areas -- rarely in the interior of such regions.
++ */
++ i = (int) *pixelptr + (signed char) (*huffptr - 1);
+#if TRACE
-+ if(i > 255)
-+ ++oflow;
-+/* trace((stderr,
-+ "gethuffdata: oflow %d %d %d\n", row, col, i));*/
-+ else if(i < 0)
-+ ++uflow;
-+/* trace((stderr,
-+ "gethuffdata: uflow %d %d %d\n", row, col, i));*/
-+ ++col;
-+#endif
-+ *pixelptr++ = clip[i + 256];
-+ }
++ if(i > 255)
++ ++oflow;
++/* trace((stderr,
++ "gethuffdata: oflow %d %d %d\n", row, col, i));*/
++ else if(i < 0)
++ ++uflow;
++/* trace((stderr,
++ "gethuffdata: uflow %d %d %d\n", row, col, i));*/
++ ++col;
++#endif
++ *pixelptr++ = clip[i + 256];
++ }
+
+oops:
-+ for(i = 0; i < 3; ++i)
-+ free(hufftable[i]);
-+ trace((stderr, "gethuffdata: uflow=%d oflow=%d\n", uflow, oflow));
-+ trace((stderr, "gethuffdata: done @ 0x%08lx (sector %ld.%d)\n",
-+ ftell(fp), ftell(fp)/0x800, 0x800 - bytesleft));
-+ return result;
++ for(i = 0; i < 3; ++i)
++ free(hufftable[i]);
++ trace((stderr, "gethuffdata: uflow=%d oflow=%d\n", uflow, oflow));
++ trace((stderr, "gethuffdata: done @ 0x%08lx (sector %ld.%d)\n",
++ ftell(fp), ftell(fp)/0x800, 0x800 - bytesleft));
++ return result;
+}
+
+#endif /* HAVE_PCD */
-diff -ruN xv-3.10a-bugfixes/xvpds.c xv-3.10a-enhancements/xvpds.c
---- xv-3.10a-bugfixes/xvpds.c 2005-04-03 11:31:30.000000000 -0700
-+++ xv-3.10a-enhancements/xvpds.c 2005-04-17 21:40:40.000000000 -0700
-@@ -77,8 +77,7 @@
- * Huffman-encoded, and the encoding histogram follows the ASCII headers.
- * To decode these, we use a slightly modified version of "vdcomp.c" from the
- * NASA Viking CD-ROMS. For xv to work, you need to have vdcomp compiled
-- * and in your search path. vdcomp.c should be included with this
--distribution.
-+ * and in your search path. vdcomp.c should be included with this distribution.
- *
- * I've heard that newer discs have FITS images on them. If they do, support
- * for them will be added when I get one. Until then, you can use fitstopgm.
-@@ -102,7 +101,7 @@
- * This software is provided "as is" without any express or implied warranty.
- */
-
--
-+#define NEEDSDIR /* for S_IRUSR|S_IWUSR */
- #include "xv.h"
-
- #ifdef HAVE_PDS
-@@ -129,27 +128,32 @@
-
- /* This is arbitrary. Everything I've seen so far fits in 50 chars */
- #define COMMENTSIZE 50
-+#define INOTESIZE 1000
-
-
- static int lastwasinote = FALSE;
--static char scanbuff [MAX_SIZE],
-- rtbuff [RTBUFFSIZE],
-- inote [20*COMMENTSIZE],
-- infobuff [COMMENTSIZE],
-- spacecraft [COMMENTSIZE],
-- target [COMMENTSIZE],
-- filtname [COMMENTSIZE],
-- gainmode [COMMENTSIZE],
-- editmode [COMMENTSIZE],
-- scanmode [COMMENTSIZE],
-- exposure [COMMENTSIZE],
-- shuttermode [COMMENTSIZE],
-- mphase [COMMENTSIZE],
-- iname [COMMENTSIZE],
-- itime [COMMENTSIZE],
-- garbage [1020],
-+static char scanbuff [MAX_SIZE+1],
-+ rtbuff [RTBUFFSIZE+1],
-+ inote [INOTESIZE+1],
-+ infobuff [COMMENTSIZE+1],
-+ spacecraft [COMMENTSIZE+1],
-+ target [COMMENTSIZE+1],
-+ filtname [COMMENTSIZE+1],
-+ gainmode [COMMENTSIZE+1],
-+ editmode [COMMENTSIZE+1],
-+ scanmode [COMMENTSIZE+1],
-+ exposure [COMMENTSIZE+1],
-+ shuttermode [COMMENTSIZE+1],
-+ mphase [COMMENTSIZE+1],
-+ iname [COMMENTSIZE+1],
-+ itime [COMMENTSIZE+1],
-+ garbage [1024],
- *tmptmp,
- pdsuncompfname[FNAMESIZE];
-+
-+#define SSTR(l) "%" #l "s"
-+#define S(l) SSTR(l)
-+
- byte *image;
- static int elaphe;
-
-@@ -251,6 +255,9 @@
- /* returns '1' on success, '0' on failure */
-
- int tempnum, bytewidth, bufsize;
-+#ifndef USE_MKSTEMP
-+ int tmpfd;
-+#endif
- FILE *zf;
- static int isfixed,teco,i,j,itype,vaxbyte,
- recsize,hrecsize,irecsize,isimage,labelrecs,labelsofar,
-@@ -397,7 +404,7 @@
-
- if (strcmp(scanbuff,"END") == 0) {
- break;
-- } else if (sscanf(scanbuff," RECORD_TYPE = %s",rtbuff) == 1) {
-+ } else if (sscanf(scanbuff, " RECORD_TYPE = " S(RTBUFFSIZE), rtbuff) == 1) {
- if (strncmp(rtbuff,"VARIABLE_LENGTH", (size_t) 15) == 0) {
- /* itype=PDSVARIABLE; */
- } else if (strncmp(rtbuff,"FIXED_LENGTH", (size_t) 12) == 0) {
-@@ -416,7 +423,7 @@
- if (irecsize == 0) irecsize=recsize;
- lastwasinote=FALSE;
- continue;
-- } else if (sscanf(scanbuff," FILE_TYPE = %s", rtbuff) != 0) {
-+ } else if (sscanf(scanbuff, " FILE_TYPE = " S(RTBUFFSIZE), rtbuff) != 0) {
- lastwasinote=FALSE;
- if (strncmp(rtbuff,"IMAGE", (size_t) 5) == 0) {
- isimage=TRUE;
-@@ -445,74 +452,74 @@
- lastwasinote=FALSE; continue;
- } else if (sscanf(scanbuff," SAMPLE_BITS = %d", &samplesize) == 1) {
- lastwasinote=FALSE; continue;
-- } else if (sscanf(scanbuff," SAMPLE_TYPE = %s", sampletype) == 1) {
-+ } else if (sscanf(scanbuff, " SAMPLE_TYPE = " S(64), sampletype) == 1) {
- lastwasinote=FALSE; continue;
-- } else if (sscanf(scanbuff," SPACECRAFT_NAME = %s %s",
-+ } else if (sscanf(scanbuff," SPACECRAFT_NAME = " S(COMMENTSIZE) " " S(1023),
- spacecraft,garbage) == 2 ) {
-- strcat(spacecraft,xv_strstr(scanbuff, spacecraft)+strlen(spacecraft));
-+ const char *tmp = xv_strstr(scanbuff, spacecraft) + strlen(spacecraft);
-+ strncat(spacecraft, tmp, COMMENTSIZE - strlen(spacecraft));
- lastwasinote=FALSE; continue;
-- } else if (sscanf(scanbuff," SPACECRAFT_NAME = %s", spacecraft) == 1) {
-+ } else if (sscanf(scanbuff, " SPACECRAFT_NAME = " S(COMMENTSIZE), spacecraft) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," TARGET_NAME = %s", target) == 1) {
-+ } else if (sscanf(scanbuff, " TARGET_NAME = " S(COMMENTSIZE), target) == 1) {
- lastwasinote=FALSE; continue;
-- } else if (sscanf(scanbuff," TARGET_BODY = %s", target) == 1) {
-+ } else if (sscanf(scanbuff, " TARGET_BODY = " S(COMMENTSIZE), target) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," MISSION_PHASE_NAME = %s", mphase) == 1) {
-+ } else if (sscanf(scanbuff, " MISSION_PHASE_NAME = " S(COMMENTSIZE), mphase) == 1) {
- lastwasinote=FALSE; continue;
-- } else if (sscanf(scanbuff," MISSION_PHASE = %s", mphase) == 1) {
-+ } else if (sscanf(scanbuff, " MISSION_PHASE = " S(COMMENTSIZE), mphase) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_NAME = %s", iname) == 1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_NAME = " S(COMMENTSIZE), iname) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," GAIN_MODE_ID = %s", gainmode) == 1) {
-+ } else if (sscanf(scanbuff, " GAIN_MODE_ID = " S(COMMENTSIZE), gainmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_GAIN_STATE = %s",gainmode)==1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_GAIN_STATE = " S(COMMENTSIZE), gainmode) ==1 ) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," EDIT_MODE_ID = %s", editmode) == 1) {
-+ } else if (sscanf(scanbuff, " EDIT_MODE_ID = " S(COMMENTSIZE), editmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_EDIT_MODE = %s", editmode)==1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_EDIT_MODE = " S(COMMENTSIZE), editmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," SCAN_MODE_ID = %s", scanmode) == 1) {
-+ } else if (sscanf(scanbuff, " SCAN_MODE_ID = " S(COMMENTSIZE), scanmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %s", scanmode)==1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_SCAN_RATE = " S(COMMENTSIZE), scanmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," SHUTTER_MODE_ID = %s", shuttermode) == 1) {
-+ } else if (sscanf(scanbuff, " SHUTTER_MODE_ID = " S(COMMENTSIZE), shuttermode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_SHUTTER_MODE = %s",
-- shuttermode) == 1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_SHUTTER_MODE = " S(COMMENTSIZE), shuttermode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," SCAN_MODE_ID = %s", scanmode) == 1) {
-+ } else if (sscanf(scanbuff, " SCAN_MODE_ID = " S(COMMENTSIZE), scanmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %s", scanmode)==1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_SCAN_RATE = " S(COMMENTSIZE), scanmode) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," SPACECRAFT_EVENT_TIME = %s", itime) == 1) {
-+ } else if (sscanf(scanbuff, " SPACECRAFT_EVENT_TIME = " S(COMMENTSIZE), itime) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," IMAGE_TIME = %s", itime) == 1) {
-+ } else if (sscanf(scanbuff, " IMAGE_TIME = " S(COMMENTSIZE), itime) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," FILTER_NAME = %s", filtname) == 1) {
-+ } else if (sscanf(scanbuff, " FILTER_NAME = " S(COMMENTSIZE), filtname) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff," INSTRUMENT_FILTER_NAME = %s",filtname)==1) {
-+ } else if (sscanf(scanbuff, " INSTRUMENT_FILTER_NAME = " S(COMMENTSIZE), filtname) == 1) {
- lastwasinote=FALSE; continue;
-
-- } else if ((sscanf(scanbuff," EXPOSURE_DURATION = %s", exposure) == 1)
-- || (sscanf(scanbuff," INSTRUMENT_EXPOSURE_DURATION = %s",
-- exposure) == 1)) {
-+ } else if ((sscanf(scanbuff, " EXPOSURE_DURATION = " S(COMMENTSIZE), exposure) == 1)
-+ || (sscanf(scanbuff, " INSTRUMENT_EXPOSURE_DURATION = " S(COMMENTSIZE),
-+ exposure)) == 1) {
- tmptmp = (char *) index(scanbuff,'=');
- tmptmp++;
- while((*tmptmp) == ' ')
-@@ -520,10 +527,10 @@
- strcpy(exposure,tmptmp);
- lastwasinote=FALSE; continue;
-
-- } else if (sscanf(scanbuff, "NOTE = %s", inote) == 1) {
-+ } else if (sscanf(scanbuff, "NOTE = " S(INOTESIZE), inote) == 1) {
- tmptmp = (char *) index(scanbuff,'='); tmptmp++;
- while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++;
-- strcpy(inote,tmptmp);
-+ strncpy(inote, tmptmp, INOTESIZE - 1);
- strcat(inote," ");
-
- /* evil and somewhat risky: A "note" (really, any textual
-@@ -548,7 +555,7 @@
- } else if (lastwasinote) {
- tmptmp=scanbuff;
- while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++;
-- strcat(inote,tmptmp);
-+ strncat(inote, tmptmp, INOTESIZE - strlen(inote) - 1);
- strcat(inote," ");
- if (index(tmptmp,'"') != NULL)
- lastwasinote=FALSE;
-@@ -647,27 +654,27 @@
-
- *infobuff='\0';
- if (*spacecraft) {
-- strcat(infobuff,spacecraft);
-+ strncat(infobuff, spacecraft, sizeof(infobuff) - 1);
- }
-
- if (*target) {
-- strcat(infobuff,", ");
-- strcat(infobuff,target);
-+ strncat(infobuff, ", ", sizeof(infobuff) - strlen(infobuff) - 1);
-+ strncat(infobuff, target, sizeof(infobuff) - strlen(infobuff) - 1);
- }
-
- if (*filtname) {
-- strcat(infobuff,", ");
-- strcat(infobuff,filtname);
-+ strncat(infobuff, ", ", sizeof(infobuff) - strlen(infobuff) - 1);
-+ strncat(infobuff, filtname, sizeof(infobuff) - strlen(infobuff) - 1);
- }
-
- if (*itime) {
-- strcat(infobuff,", ");
-- strcat(infobuff,itime);
-+ strncat(infobuff, ", ", sizeof(infobuff) - strlen(infobuff) - 1);
-+ strncat(infobuff, itime, sizeof(infobuff) - strlen(infobuff) - 1);
- }
-
-- SetISTR(ISTR_WARNING,infobuff);
-+ SetISTR(ISTR_WARNING, "%s", infobuff);
-
-- strcpy(pdsuncompfname,fname);
-+ strncpy(pdsuncompfname,fname,sizeof(pdsuncompfname) - 1);
- ftypstr = "";
-
- switch (itype) {
-@@ -695,7 +702,7 @@
- fclose(zf);
-
- #ifndef VMS
-- sprintf(pdsuncompfname,"%s/xvhuffXXXXXX", tmpdir);
-+ snprintf(pdsuncompfname, sizeof(pdsuncompfname) - 1, "%s/xvhuffXXXXXX", tmpdir);
- #else
- strcpy(pdsuncompfname,"sys$disk:[]xvhuffXXXXXX");
- #endif
-@@ -704,10 +711,16 @@
- close(mkstemp(pdsuncompfname));
- #else
- mktemp(pdsuncompfname);
-+ tmpfd = open(pdsuncompfname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
-+ if (tmpfd < 0) {
-+ SetISTR(ISTR_WARNING,"Unable to create temporary file.");
-+ return 0;
-+ }
-+ close(tmpfd);
- #endif
-
- #ifndef VMS
-- sprintf(scanbuff,"%s %s - 4 >%s",PDSUNCOMP,fname,pdsuncompfname);
-+ sprintf(scanbuff,"%s '%s' - 4 > %s", PDSUNCOMP, fname, pdsuncompfname);
- #else
- sprintf(scanbuff,"%s %s %s 4",PDSUNCOMP,fname,pdsuncompfname);
- #endif
-@@ -823,26 +836,26 @@
- char tmp[256];
- *(pinfo->comment) = '\0';
-
-- sprintf(tmp, "Spacecraft: %-28sTarget: %-32s\n", spacecraft, target);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Spacecraft: %-28.28sTarget: %-32.32s\n", spacecraft, target);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Filter: %-32sMission phase: %-24s\n", filtname, mphase);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Filter: %-32.32sMission phase: %-24.24s\n", filtname, mphase);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Image time: %-28sGain mode: %-29s\n", itime, gainmode);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Image time: %-28.28sGain mode: %-29.29s\n", itime, gainmode);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Edit mode: %-29sScan mode: %-29s\n", editmode, scanmode);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Edit mode: %-29.29sScan mode: %-29.29s\n", editmode, scanmode);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Exposure: %-30sShutter mode: %-25s\n", exposure,shuttermode);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Exposure: %-30.30sShutter mode: %-25.25s\n", exposure,shuttermode);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Instrument: %-28sImage time: %-28s\n", iname, itime);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Instrument: %-28.28sImage time: %-28.28s\n", iname, itime);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
-
-- sprintf(tmp, "Image Note: %-28s", inote);
-- strcat(pinfo->comment, tmp);
-+ sprintf(tmp, "Image Note: %-28.28s", inote);
-+ strncat(pinfo->comment, tmp, 2000 - strlen(pinfo->comment) - 1);
- }
-
- if (LoadPDSPalette(fname, pinfo)) return 1;
-diff -ruN xv-3.10a-bugfixes/xvpi.c xv-3.10a-enhancements/xvpi.c
---- xv-3.10a-bugfixes/xvpi.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvpi.c 2005-04-17 22:57:04.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvpi.c xv-3.10a/xvpi.c
+--- xv-3.10a.orig/xvpi.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvpi.c 2005-04-18 00:57:04.000000000 -0500
@@ -0,0 +1,1060 @@
+/*
+ * xvpi.c - load routine for `Pi' format pictures.
@@ -18115,9 +10856,9 @@ diff -ruN xv-3.10a-bugfixes/xvpi.c xv-3.10a-enhancements/xvpi.c
+ return r;
+}
+#endif /* HAVE_PI */
-diff -ruN xv-3.10a-bugfixes/xvpic.c xv-3.10a-enhancements/xvpic.c
---- xv-3.10a-bugfixes/xvpic.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvpic.c 2005-04-17 22:57:08.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvpic.c xv-3.10a/xvpic.c
+--- xv-3.10a.orig/xvpic.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvpic.c 2005-04-18 00:57:08.000000000 -0500
@@ -0,0 +1,1285 @@
+/*
+ * xvpic.c - load routine for `PIC' format pictures.
@@ -19404,9 +12145,9 @@ diff -ruN xv-3.10a-bugfixes/xvpic.c xv-3.10a-enhancements/xvpic.c
+ return r;
+}
+#endif /* HAVE_PIC */
-diff -ruN xv-3.10a-bugfixes/xvpic2.c xv-3.10a-enhancements/xvpic2.c
---- xv-3.10a-bugfixes/xvpic2.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvpic2.c 2005-04-17 22:56:07.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvpic2.c xv-3.10a/xvpic2.c
+--- xv-3.10a.orig/xvpic2.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvpic2.c 2007-04-15 17:02:32.000000000 -0500
@@ -0,0 +1,3608 @@
+/*
+ * $Id: xvpic2.c,v 2.9.1.14 1995/04/24 15:34:15 ikeyan Exp $
@@ -22926,11 +15667,11 @@ diff -ruN xv-3.10a-bugfixes/xvpic2.c xv-3.10a-enhancements/xvpic2.c
+{
+ switch (cmd) {
+ case T_BOK: {
-+ char *fullname;
-+ char buf[64], *x_offsetp, *y_offsetp;
-+ static char *labels[] = { "\nOk", "\033Cancel" };
-+ XEvent event;
-+ int i;
++ char *fullname;
++ char buf[64], *x_offsetp, *y_offsetp;
++ static const char *labels[] = { "\nOk", "\033Cancel" };
++ XEvent event;
++ int i;
+
+ strcpy(buf, "0,0");
+ i = GetStrPopUp("Enter offset (x,y):", labels, 2, buf, 64,
@@ -23016,10 +15757,10 @@ diff -ruN xv-3.10a-bugfixes/xvpic2.c xv-3.10a-enhancements/xvpic2.c
+ free(inpix);
+}
+#endif /* HAVE_PIC2 */
-diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
---- xv-3.10a-bugfixes/xvpng.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvpng.c 2005-04-17 15:00:08.000000000 -0700
-@@ -0,0 +1,1081 @@
+diff -u -r --new-file xv-3.10a.orig/xvpng.c xv-3.10a/xvpng.c
+--- xv-3.10a.orig/xvpng.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvpng.c 2007-05-13 19:53:28.000000000 -0500
+@@ -0,0 +1,1173 @@
+/*
+ * xvpng.c - load and write routines for 'PNG' format pictures
+ *
@@ -23034,16 +15775,19 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ */
+
+/*#include "copyright.h"*/
++
+/* (c) 1995 by Alexander Lehmann <lehmann@mathematik.th-darmstadt.de>
+ * This file is a suplement to xv and is supplied under the same copying
+ * conditions (except the shareware part).
++ * The copyright will be passed on to JB at some future point if he
++ * so desires.
++ *
+ * Modified by Andreas Dilger <adilger@enel.ucalgary.ca> to fix
+ * error handling for bad PNGs, add dialogs for interlacing and
+ * compression selection, and upgrade to libpng-0.89.
++ *
+ * Modified by Greg Roelofs, TenThumbs and others to fix bugs and add
-+ * features.
-+ * The copyright will be passed on to JB at some future point if he
-+ * so desires.
++ * features. See README.jumbo for details.
+ */
+
+#include "xv.h"
@@ -23060,13 +15804,13 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+#define COMPRESSION 6 /* default zlib compression level, not max
+ (Z_BEST_COMPRESSION) */
+
-+#define HAVE_tRNS (info_ptr->valid & PNG_INFO_tRNS)
++#define HAVE_tRNS (info_ptr->valid & PNG_INFO_tRNS)
+
-+#define DWIDE 86
++#define DWIDE 86
+#define DHIGH 104
-+#define PFX PWIDE-93
-+#define PFY 44
-+#define PFH 20
++#define PFX (PWIDE-93)
++#define PFY 44
++#define PFH 20
+
+#define P_BOK 0
+#define P_BCANC 1
@@ -23092,7 +15836,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+/*** local variables ***/
+static char *filename;
-+static char *fbasename;
++static const char *fbasename;
+static int colorType;
+static int read_anything;
+static double Display_Gamma = DISPLAY_GAMMA;
@@ -23102,6 +15846,35 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+static CBUTT interCB;
+static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB;
+
++
++#ifdef PNG_NO_STDIO
++/* NOTE: Some sites configure their version of the PNG Library without
++ * Standard I/O Library interfaces in order to avoid unnecessary inter-
++ * library dependencies at link time for applications that don't need Standard
++ * I/O. If your site is one of these, the following skeletal stubs, copied
++ * from libpng code, should be enough for this module. --Scott B. Marovich,
++ * Hewlett-Packard Laboratories, March 2001.
++ */
++static void
++png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
++{
++
++ /* fread() returns 0 on error, so it is OK to store this in a png_size_t
++ * instead of an int, which is what fread() actually returns.
++ */
++ if (fread(data,1,length,(FILE *)png_ptr->io_ptr) != length)
++ png_error(png_ptr, "Read Error");
++}
++
++static void
++png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
++{
++ if (fwrite(data, 1, length, (FILE *)png_ptr->io_ptr) != length)
++ png_error(png_ptr, "Write Error");
++}
++#endif /* PNG_NO_STDIO */
++
++
+/**************************************************************************/
+/* PNG SAVE DIALOG ROUTINES ***********************************************/
+/**************************************************************************/
@@ -23258,14 +16031,14 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+static void drawPD(x, y, w, h)
+ int x, y, w, h;
+{
-+ char *title = "Save PNG file...";
++ const char *title = "Save PNG file...";
+
+ char ctitle1[20];
-+ char *ctitle2 = "Useful range";
-+ char *ctitle3 = "is 2 - 7.";
-+ char *ctitle4 = "Uncompressed = 0";
++ const char *ctitle2 = "Useful range";
++ const char *ctitle3 = "is 2 - 7.";
++ const char *ctitle4 = "Uncompressed = 0";
+
-+ char *ftitle = "Row Filters:";
++ const char *ftitle = "Row Filters:";
+
+ char gtitle[20];
+
@@ -23421,21 +16194,23 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ int ptype, w, h;
+ byte *rmap, *gmap, *bmap;
+ int numcols;
++ /* FIXME? what's diff between picComments and WriteGIF's comment arg? */
+{
+ png_struct *png_ptr;
+ png_info *info_ptr;
+ png_color palette[256];
+ png_textp text;
-+ byte remap[256];
-+ int i, filter, linesize, pass;
++ byte r1[256], g1[256], b1[256]; /* storage for deduped palette */
++ byte pc2nc[256]; /* for duplicated-color remapping (1st level) */
++ byte remap[256]; /* for bw/grayscale remapping (2nd level) */
++ int i, j, numuniqcols=0, filter, linesize, pass;
+ byte *p, *png_line;
+ char software[256];
+ char *savecmnt;
+
+ if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
+ png_xv_error, png_xv_warning)) == NULL) {
-+ sprintf(software, "png_create_write_struct() failure in WritePNG (ver. %s)",
-+ PNG_LIBPNG_VER_STRING);
++ sprintf(software, "png_create_write_struct() failure in WritePNG");
+ FatalError(software);
+ }
+
@@ -23451,7 +16226,12 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ return -1;
+ }
+
++#ifdef PNG_NO_STDIO
++ png_set_write_fn(png_ptr, fp, png_default_write_data, NULL);
++ png_set_error_fn(png_ptr, NULL, png_xv_error, png_xv_warning);
++#else
+ png_init_io(png_ptr, fp);
++#endif
+
+ png_set_compression_level(png_ptr, (int)cDial.val);
+
@@ -23485,8 +16265,39 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ linesize = 0; /* quiet a compiler warning */
+
++
++ /* GRR 20070331: remap palette to eliminate duplicated colors (as in
++ * xvgifwr.c) */
++ if (ptype == PIC8) {
++ for (i=0; i<256; ++i) {
++ pc2nc[i] = r1[i] = g1[i] = b1[i] = 0;
++ }
++
++ /* compute number of unique colors */
++ numuniqcols = 0;
++
++ for (i=0; i<numcols; ++i) {
++ /* see if color #i is already used */
++ for (j=0; j<i; ++j) {
++ if (rmap[i] == rmap[j] && gmap[i] == gmap[j] && bmap[i] == bmap[j])
++ break;
++ }
++
++ if (j==i) { /* wasn't found */
++ pc2nc[i] = numuniqcols;
++ r1[numuniqcols] = rmap[i]; /* i.e., r1[pc2nc[i]] == rmap[i] */
++ g1[numuniqcols] = gmap[i];
++ b1[numuniqcols] = bmap[i];
++ ++numuniqcols;
++ }
++ else pc2nc[i] = pc2nc[j];
++ }
++ }
++
++
++ /* Appendix G.2 of user manual claims colorType will never be F_REDUCED... */
+ if (colorType == F_FULLCOLOR || colorType == F_REDUCED) {
-+ if(ptype == PIC24) {
++ if (ptype == PIC24) {
+ linesize = 3*w;
+ if (linesize/3 < w) {
+ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
@@ -23496,39 +16307,39 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ }
+ info_ptr->color_type = PNG_COLOR_TYPE_RGB;
+ info_ptr->bit_depth = 8;
-+ } else {
++ } else /* ptype == PIC8 */ {
+ linesize = w;
+ info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
-+ if(numcols <= 2)
++ if (numuniqcols <= 2)
+ info_ptr->bit_depth = 1;
+ else
-+ if(numcols <= 4)
++ if (numuniqcols <= 4)
+ info_ptr->bit_depth = 2;
+ else
-+ if(numcols <= 16)
++ if (numuniqcols <= 16)
+ info_ptr->bit_depth = 4;
+ else
+ info_ptr->bit_depth = 8;
+
-+ for(i = 0; i < numcols; i++) {
-+ palette[i].red = rmap[i];
-+ palette[i].green = gmap[i];
-+ palette[i].blue = bmap[i];
++ 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 = numcols;
++ info_ptr->num_palette = numuniqcols;
+ info_ptr->palette = palette;
+ info_ptr->valid |= PNG_INFO_PLTE;
+ }
+ }
+
-+ else if(colorType == F_GREYSCALE || colorType == F_BWDITHER) {
++ else if (colorType == F_GREYSCALE || colorType == F_BWDITHER) {
+ info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
-+ if(colorType == F_BWDITHER) {
++ if (colorType == F_BWDITHER) {
+ /* shouldn't happen */
+ if (ptype == PIC24) FatalError("PIC24 and B/W Stipple in WritePNG()");
+
+ info_ptr->bit_depth = 1;
-+ if(MONO(rmap[0], gmap[0], bmap[0]) > MONO(rmap[1], gmap[1], bmap[1])) {
++ if (MONO(r1[0], g1[0], b1[0]) > MONO(r1[1], g1[1], b1[1])) {
+ remap[0] = 1;
+ remap[1] = 0;
+ }
@@ -23538,8 +16349,8 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ }
+ linesize = w;
+ }
-+ else {
-+ if(ptype == PIC24) {
++ else /* F_GREYSCALE */ {
++ if (ptype == PIC24) {
+ linesize = 3*w;
+ if (linesize/3 < w) {
+ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
@@ -23549,65 +16360,75 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ }
+ info_ptr->bit_depth = 8;
+ }
-+ else {
++ else /* ptype == PIC8 */ {
+ int low_precision;
+
+ linesize = w;
+
-+ for(i = 0; i < numcols; i++)
-+ remap[i] = MONO(rmap[i], gmap[i], bmap[i]);
-+
-+ for(; i < 256; i++)
-+ remap[i]=0;
++ /* NOTE: currently remap[] is the _secondary_ remapping of "palette"
++ * colors; its values are the final color/grayscale values, and,
++ * like r1/g1/b1[], it is _indexed_ by pc2nc[] (which is why its
++ * values come from r1/g1/b1[] and not from rmap/gmap/bmap[]).
++ *
++ * FIXME (probably): MONO() will create new duplicates; ideally should
++ * do extra round of dup-detection (and preferably collapse all
++ * remapping levels into single LUT). This stuff is a tad confusing.
++ */
++ for (i = 0; i < numuniqcols; i++)
++ remap[i] = MONO(r1[i], g1[i], b1[i]);
++
++ for (; i < 256; i++)
++ remap[i]=0; /* shouldn't be necessary, but... */
+
+ info_ptr->bit_depth = 8;
+
+ /* Note that this fails most of the time because of gamma */
++ /* (and that would be a bug: GRR FIXME) */
+ /* try to adjust to 4-bit precision grayscale */
+
+ low_precision=1;
+
-+ for(i = 0; i < numcols; i++) {
-+ if((remap[i] & 0x0f) * 0x11 != remap[i]) {
++ for (i = 0; i < numuniqcols; i++) {
++ if ((remap[i] & 0x0f) * 0x11 != remap[i]) {
+ low_precision = 0;
+ break;
+ }
+ }
+
-+ if(low_precision) {
-+ for(i = 0; i < numcols; i++) {
++ if (low_precision) {
++ for (i = 0; i < numuniqcols; i++) {
+ remap[i] &= 0xf;
+ }
+ info_ptr->bit_depth = 4;
+
+ /* try to adjust to 2-bit precision grayscale */
+
-+ for(i = 0; i < numcols; i++) {
-+ if((remap[i] & 0x03) * 0x05 != remap[i]) {
++ for (i = 0; i < numuniqcols; i++) {
++ if ((remap[i] & 0x03) * 0x05 != remap[i]) {
+ low_precision = 0;
+ break;
+ }
+ }
+ }
+
-+ if(low_precision) {
-+ for(i = 0; i < numcols; i++) {
++ if (low_precision) {
++ for (i = 0; i < numuniqcols; i++) {
+ remap[i] &= 3;
+ }
+ info_ptr->bit_depth = 2;
+
+ /* try to adjust to 1-bit precision grayscale */
+
-+ for(i = 0; i < numcols; i++) {
-+ if((remap[i] & 0x01) * 0x03 != remap[i]) {
++ for (i = 0; i < numuniqcols; i++) {
++ if ((remap[i] & 0x01) * 0x03 != remap[i]) {
+ low_precision = 0;
+ break;
+ }
+ }
+ }
+
-+ if(low_precision) {
-+ for(i = 0; i < numcols; i++) {
++ if (low_precision) {
++ for (i = 0; i < numuniqcols; i++) {
+ remap[i] &= 1;
+ }
+ info_ptr->bit_depth = 1;
@@ -23634,32 +16455,40 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ 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;
+
+ png_write_info(png_ptr, info_ptr);
+
-+ if(info_ptr->bit_depth < 8)
++ if (info_ptr->bit_depth < 8)
+ png_set_packing(png_ptr);
+
+ pass=png_set_interlace_handling(png_ptr);
+
-+ if((png_line = malloc(linesize)) == NULL)
++ if ((png_line = malloc(linesize)) == NULL)
+ png_error(png_ptr, "cannot allocate temp image line");
++ /* FIXME: should be FatalError() */
+
-+ for(i = 0; i < pass; i++) {
++ for (i = 0; i < pass; ++i) {
+ int j;
+ p = pic;
-+ for(j = 0; j < h; j++) {
-+ if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
++ for (j = 0; j < h; ++j) {
++ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
+ int k;
-+ for(k = 0; k < w; 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[p[k]];
++ remap[pc2nc[p[k]]];
++ png_write_row(png_ptr, png_line);
++ } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
++ int k;
++ for (k = 0; k < w; ++k)
++ png_line[k] = pc2nc[p[k]];
+ png_write_row(png_ptr, png_line);
-+ } else /* RGB or palette */
++ } else { /* PNG_COLOR_TYPE_RGB */
+ png_write_row(png_ptr, p);
-+ if((j & 0x1f) == 0) WaitCursor();
++ }
++ if ((j & 0x1f) == 0) WaitCursor();
+ p += linesize;
+ }
+ }
@@ -23668,8 +16497,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ savecmnt = NULL; /* quiet a compiler warning */
+
-+ if (text)
-+ {
++ if (text) {
+ if (picComments && strlen(picComments) &&
+ (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) {
+ png_textp tp;
@@ -23701,7 +16529,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ /* See if it looks like a PNG keyword from LoadPNG */
+ /* GRR: should test for strictly < 80, right? (key = 1-79 chars only) */
-+ if(comment && comment[1] == ':' && comment - key <= 80) {
++ if (comment && comment[1] == ':' && comment - key <= 80) {
+ *(comment++) = '\0';
+ *(comment++) = '\0';
+
@@ -23709,7 +16537,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ since we have already stored one */
+ if (strcmp(key, "Software") == 0 && strncmp(comment, "XV", 2) == 0) {
+ key = strchr(comment, '\n');
-+ if(key)
++ if (key)
+ key++; /* skip \n */
+ comment = strchr(key, ':');
+ }
@@ -23726,7 +16554,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ /* It looks like another keyword, go backward to the beginning */
+ if (key) {
-+ while(key > tp->text && *key != '\n')
++ while (key > tp->text && *key != '\n')
+ key--;
+
+ if (key > tp->text && comment - key <= 80) {
@@ -23774,8 +16602,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ }
+ } while (key && *key);
+ }
-+ else
-+ {
++ else {
+ info_ptr->num_text = 0;
+ }
+ }
@@ -23787,8 +16614,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ png_write_end(png_ptr, info_ptr);
+ fflush(fp); /* just in case we core-dump before finishing... */
+
-+ if (text)
-+ {
++ if (text) {
+ free(text);
+ /* must do this or png_destroy_write_struct() 0.97+ will free text again: */
+ info_ptr->text = (png_textp)NULL;
@@ -23845,28 +16671,28 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
+ png_xv_error, png_xv_warning);
-+ if(!png_ptr) {
++ if (!png_ptr) {
+ fclose(fp);
+ FatalError("malloc failure in LoadPNG");
+ }
+
+ info_ptr = png_create_info_struct(png_ptr);
+
-+ if(!info_ptr) {
++ if (!info_ptr) {
+ fclose(fp);
+ png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ FatalError("malloc failure in LoadPNG");
+ }
+
-+ if(setjmp(png_ptr->jmpbuf)) {
++ if (setjmp(png_ptr->jmpbuf)) {
+ fclose(fp);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
-+ if(!read_anything) {
-+ if(pinfo->pic) {
++ if (!read_anything) {
++ if (pinfo->pic) {
+ free(pinfo->pic);
+ pinfo->pic = NULL;
+ }
-+ if(pinfo->comment) {
++ if (pinfo->comment) {
+ free(pinfo->comment);
+ pinfo->comment = NULL;
+ }
@@ -23874,7 +16700,12 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ return read_anything;
+ }
+
++#ifdef PNG_NO_STDIO
++ png_set_read_fn(png_ptr, fp, png_default_read_data);
++ png_set_error_fn(png_ptr, NULL, png_xv_error, png_xv_warning);
++#else
+ png_init_io(png_ptr, fp);
++#endif
+ png_read_info(png_ptr, info_ptr);
+
+ pinfo->w = pinfo->normw = info_ptr->width;
@@ -23924,8 +16755,10 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ if (info_ptr->valid & PNG_INFO_gAMA)
+ png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma);
-+ else
-+ png_set_gamma(png_ptr, Display_Gamma, 0.45);
++/*
++ *else
++ * png_set_gamma(png_ptr, Display_Gamma, 0.45);
++ */
+
+ gray_to_rgb = 0; /* quiet a compiler warning */
+
@@ -23934,7 +16767,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ my_background.red = imagebgR;
+ my_background.green = imagebgG;
+ my_background.blue = imagebgB;
-+ my_background.gray = imagebgG; /* only used if all three equal... */
++ my_background.gray = imagebgG; /* used only if all three equal... */
+ } else {
+ my_background.red = (imagebgR >> 8);
+ my_background.green = (imagebgG >> 8);
@@ -23980,7 +16813,7 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+
+ png_read_update_info(png_ptr, info_ptr);
+
-+ if(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
++ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
+ info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || gray_to_rgb)
+ {
+ linesize = 3 * pinfo->w;
@@ -23995,13 +16828,13 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ } else {
+ linesize = pinfo->w;
+ pinfo->type = PIC8;
-+ if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
++ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
+ info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
-+ for(i = 0; i < 256; i++)
++ for (i = 0; i < 256; i++)
+ pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+ } else {
+ pinfo->colType = F_FULLCOLOR;
-+ for(i = 0; i < info_ptr->num_palette; i++) {
++ 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;
@@ -24018,37 +16851,37 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+ }
+ pinfo->pic = calloc((size_t)bufsize, (size_t)1);
+
-+ if(!pinfo->pic) {
++ if (!pinfo->pic) {
+ png_error(png_ptr, "can't allocate space for PNG image");
+ }
+
+ png_start_read_image(png_ptr);
+
-+ for(i = 0; i < pass; i++) {
++ for (i = 0; i < pass; i++) {
+ byte *p = pinfo->pic;
-+ for(j = 0; j < pinfo->h; j++) {
++ for (j = 0; j < pinfo->h; j++) {
+ png_read_row(png_ptr, p, NULL);
+ read_anything = 1;
-+ if((j & 0x1f) == 0) WaitCursor();
++ if ((j & 0x1f) == 0) WaitCursor();
+ p += linesize;
+ }
+ }
+
+ png_read_end(png_ptr, info_ptr);
+
-+ if(info_ptr->num_text > 0) {
++ if (info_ptr->num_text > 0) {
+ commentsize = 1;
+
-+ for(i = 0; i < info_ptr->num_text; i++)
++ for (i = 0; i < info_ptr->num_text; i++)
+ commentsize += strlen(info_ptr->text[i].key) + 1 +
+ info_ptr->text[i].text_length + 2;
+
-+ if((pinfo->comment = malloc(commentsize)) == NULL) {
++ 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++) {
++ for (i = 0; i < info_ptr->num_text; i++) {
+ strcat(pinfo->comment, info_ptr->text[i].key);
+ strcat(pinfo->comment, "::");
+ strcat(pinfo->comment, info_ptr->text[i].text);
@@ -24101,2240 +16934,9 @@ diff -ruN xv-3.10a-bugfixes/xvpng.c xv-3.10a-enhancements/xvpng.c
+}
+
+#endif /* HAVE_PNG */
-diff -ruN xv-3.10a-bugfixes/xvpopup.c xv-3.10a-enhancements/xvpopup.c
---- xv-3.10a-bugfixes/xvpopup.c 2004-05-16 18:04:13.000000000 -0700
-+++ xv-3.10a-enhancements/xvpopup.c 2005-04-25 08:21:34.000000000 -0700
-@@ -23,7 +23,7 @@
- #define OMIT_ICON_BITS
- #include "bits/icon" /* icon_bits[] not used, but icon_width/height are */
-
--#define PUWIDE 400
-+#define PUWIDE 480
- #define PUHIGH 170
-
- #define PAD_PUWIDE 480
-@@ -201,14 +201,14 @@
-
- if (!padHaveDooDads) {
- DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100,
-- 1, 2048, pWIDE, 10,
-+ 1.0, 2048.0, (double)pWIDE, 1.0, 10.0,
- infofg, infobg, hicol, locol, "Width", NULL);
- DCreate(&padHDial, popW, 16+1+75, puhigh-16-100-1,75,100,
-- 1, 2048, pHIGH, 10,
-+ 1.0, 2048.0, (double)pHIGH, 1.0, 10.0,
- infofg, infobg, hicol, locol, "Height", NULL);
-
- DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100,
-- 0, 100, 100, 10,
-+ 0.0, 100.0, 100.0, 1.0, 10.0,
- infofg, infobg, hicol, locol, "Opaque", NULL);
-
- MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL,
-@@ -259,9 +259,9 @@
- else if (poptyp == ISPAD) {
- BTSetActive(&bts[0], (int) strlen(gsBuf));
- i = pWIDE * 3; RANGE(i,2048,9999);
-- DSetRange(&padWDial, 1, i, padWDial.val, 10);
-+ DSetRange(&padWDial, 1.0, (double)i, padWDial.val, 1.0, 10.0);
- i = pHIGH * 3; RANGE(i,2048,9999);
-- DSetRange(&padHDial, 1, i, padHDial.val, 10);
-+ DSetRange(&padHDial, 1.0, (double)i, padHDial.val, 1.0, 10.0);
-
- DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */
- DSetActive(&padHDial, (padMode!=PAD_LOAD));
-@@ -287,15 +287,19 @@
- /* center first button in window around mouse position, with constraint that
- window be fully on the screen */
-
-- CenterMapWindow(popW, 40 + bts[0].x, BUTTH/2 + bts[0].y, puwide, puhigh);
- popUp = poptyp;
-+ if (startGrab == 2)
-+ startGrab = 4;
-+ else {
-+ CenterMapWindow(popW, 40 + bts[0].x, BUTTH/2 + bts[0].y, puwide, puhigh);
-
-- /* MUST wait for VisibilityNotify event to come in, else we run the risk
-- of UnMapping the window *before* the Map request completed. This
-- appears to be bad, (It leaves an empty window frame up.) though it
-- generally only happens on slow servers. Better safe than screwed... */
-+ /* MUST wait for VisibilityNotify event to come in, else we run the risk
-+ of UnMapping the window *before* the Map request completed. This
-+ appears to be bad, (It leaves an empty window frame up.) though it
-+ generally only happens on slow servers. Better safe than screwed... */
-
-- XWindowEvent(theDisp, popW, VisibilityChangeMask, &event);
-+ XWindowEvent(theDisp, popW, VisibilityChangeMask, &event);
-+ }
-
- /* block until this window gets closed */
- while (popUp) {
-@@ -466,9 +470,9 @@
- changedGSBuf(); /* careful! popW doesn't exist yet! */
-
- if (padHaveDooDads) {
-- oldW = padWDial.val;
-- oldH = padHDial.val;
-- oldO = padODial.val;
-+ oldW = (int)padWDial.val;
-+ oldH = (int)padHDial.val;
-+ oldO = (int)padODial.val;
- }
- else { oldW = pWIDE; oldH = pHIGH; oldO = 100; }
-
-@@ -487,9 +491,9 @@
- }
-
- if (rv == 1) { /* cancelled: restore normal values */
-- DSetVal(&padWDial, oldW);
-- DSetVal(&padHDial, oldH);
-- DSetVal(&padODial, oldO);
-+ DSetVal(&padWDial, (double)oldW);
-+ DSetVal(&padHDial, (double)oldH);
-+ DSetVal(&padODial, (double)oldO);
- }
-
- XUnmapWindow(theDisp, padWDial.win);
-@@ -499,9 +503,9 @@
- /* load up return values */
- *pMode = padMode;
- *pStr = padBuf;
-- *pWide = padWDial.val;
-- *pHigh = padHDial.val;
-- *pOpaque = padODial.val;
-+ *pWide = (int)padWDial.val;
-+ *pHigh = (int)padHDial.val;
-+ *pOpaque = (int)padODial.val;
- *pOmode = padOMode;
-
- return rv;
-@@ -956,14 +960,14 @@
- int x,y;
- {
- int i;
-- BUTT *bp;
-+ BUTT *bp = NULL;
-
- for (i=0; i<nbts; i++) {
- bp = &bts[i];
- if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
- }
-
-- if (i<nbts && BTTrack(bp)) {
-+ if (i<nbts && bp && BTTrack(bp)) {
- popUp = 0; selected = i; return;
- }
-
-@@ -972,8 +976,8 @@
- else if (popUp == ISPAD) {
- if (PTINRECT(x, y, padDButt.x, padDButt.y, padDButt.w, padDButt.h)) {
- if (BTTrack(&padDButt)) {
-- DSetVal(&padWDial, pWIDE);
-- DSetVal(&padHDial, pHIGH);
-+ DSetVal(&padWDial, (double)pWIDE);
-+ DSetVal(&padHDial, (double)pHIGH);
- }
- }
-
-@@ -1105,7 +1109,7 @@
- }
-
-
-- else if (c=='\010' || c=='\177') { /* BS or DEL */
-+ else if (c=='\010') { /* BS */
- if (gsCurPos==0) return 1; /* at beginning of str */
- xvbcopy(&gsBuf[gsCurPos], &gsBuf[gsCurPos-1], (size_t) len-gsCurPos+1);
- gsCurPos--;
-@@ -1128,7 +1132,7 @@
- gsCurPos = len;
- }
-
-- else if (c=='\004') { /* ^D: delete character at gsCurPos */
-+ else if (c=='\004' || c=='\177') { /* ^D or DEL: delete character at gsCurPos */
- if (gsCurPos==len) return 1;
- xvbcopy(&gsBuf[gsCurPos+1], &gsBuf[gsCurPos], (size_t) len-gsCurPos);
- }
-diff -ruN xv-3.10a-bugfixes/xvps.c xv-3.10a-enhancements/xvps.c
---- xv-3.10a-bugfixes/xvps.c 2005-03-30 08:18:17.000000000 -0800
-+++ xv-3.10a-enhancements/xvps.c 2005-04-17 14:45:28.000000000 -0700
-@@ -142,9 +142,9 @@
- CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol);
- CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol);
-
-- DCreate(&xsDial, psW, 240, 30, 80, 100, 10, 800, 100, 5,
-+ DCreate(&xsDial, psW, 240, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0,
- infofg, infobg, hicol, locol, "Width", "%");
-- DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5,
-+ DCreate(&ysDial, psW, 331, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0,
- infofg, infobg, hicol, locol, "Height", "%");
- xsDial.drawobj = changedScale;
- ysDial.drawobj = changedScale;
-@@ -239,10 +239,10 @@
-
- if (rd_int("psres")) { /* xv.psres: default paper resolution */
- if (def_int >= 10 && def_int <= 720) {
-- int i = (int) ((PIX2INCH * 100) / def_int);
-+ double v = (PIX2INCH * 100) / def_int;
-
-- DSetVal(&xsDial, i);
-- DSetVal(&ysDial, i);
-+ DSetVal(&xsDial, v);
-+ DSetVal(&ysDial, v);
- }
- }
-
-@@ -839,7 +839,7 @@
- if (scx < scy) { sz_iny = h * scx; }
- else { sz_inx = w * scy; }
-
-- DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5));
-+ DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w);
- DSetVal(&ysDial, xsDial.val);
-
- sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
-@@ -1561,9 +1561,9 @@
- the first one is loaded (but not deleted) */
-
- #ifdef GS_PATH
-- char tmp[512], gscmd[512], cmdstr[512], tmpname[64];
-+ #define CMDSIZE 1024
-+ char tmp[512], gscmd[512], cmdstr[CMDSIZE], tmpname[64];
- int gsresult, nump, i, filetype, doalert, epsf;
-- char *rld;
- #endif
-
- pinfo->pic = (byte *) NULL;
-@@ -1596,7 +1596,7 @@
- /* build 'gscmd' string */
-
- #ifndef VMS /* VMS needs quotes around mixed case command lines */
-- sprintf(gscmd, "%s -sDEVICE=%s -r%d -q -dNOPAUSE -sOutputFile=%s%%d ",
-+ sprintf(gscmd, "%s -sDEVICE=%s -r%d -q -dSAFER -dNOPAUSE -sOutputFile=%s%%d ",
- GS_PATH, gsDev, gsRes, tmpname);
- #else
- sprintf(gscmd,
-@@ -1734,32 +1734,48 @@
-
- /******************************************************************/
- #ifdef GS_PATH
--void buildCmdStr(str, gscmd, fname, quick, epsf)
-- char *str, *gscmd, *fname;
-+void buildCmdStr(str, gscmd, xname, quick, epsf)
-+ char *str, *gscmd, *xname;
- int quick, epsf;
- {
- /* note 'epsf' set only on files that don't have a showpage cmd */
-+ char *x, *y, *fname;
-+
-+ x = (char *) malloc((5 * strlen(xname))+3);
-+ if (!x)
-+ FatalError("malloc failure in xvps.c buildCmdStr");
-+ fname = x;
-+ *x++ = 0x27;
-+
-+ for (y = xname; *y; ++y) {
-+ if (0x27 == *y) {
-+ strcpy(x, "'\"'\"'");
-+ x += strlen(x);
-+ } else *x++ = *y;
-+ }
-+ strcpy (x, "'");
-
- #ifndef VMS
-
-- if (epsf) sprintf(str, "echo '\n showpage ' | cat '%s' - | %s -",
-+ if (epsf) snprintf(str, CMDSIZE, "echo '\n showpage ' | cat %s - | %s -",
- fname, gscmd);
-
-- else if (quick) sprintf(str, "echo '%s' | cat - '%s' | %s -",
-+ else if (quick) snprintf(str, CMDSIZE, "echo %s | cat - %s | %s -",
- "/showpage { showpage quit } bind def",
- fname, gscmd);
-
-- else sprintf(str, "%s -- %s", gscmd, fname);
-+ else snprintf(str, CMDSIZE, "%s -- %s", gscmd, fname);
-
- #else /* VMS */
- /* VMS doesn't have pipes or an 'echo' command and GS doesn't like
-- Unix-style file names as input files in the VMS version */
-+ Unix-style filenames as input files in the VMS version */
- strcat(tmp, " -- ");
- rld = strrchr(fname, '/'); /* Pointer to last '/' */
- if (rld) rld++; /* Pointer to filename */
- else rld = fname; /* No path - use original string */
- strcat(tmp, rld);
- #endif /* VMS */
-+ free(fname);
- }
- #endif /* GS_PATH */
-
-diff -ruN xv-3.10a-bugfixes/xvrle.c xv-3.10a-enhancements/xvrle.c
---- xv-3.10a-bugfixes/xvrle.c 2005-03-29 23:29:14.000000000 -0800
-+++ xv-3.10a-enhancements/xvrle.c 2004-05-16 18:07:46.000000000 -0700
-@@ -43,7 +43,7 @@
- byte bgcol[256];
- byte maps[3][256];
- int xpos, ypos, w, h, flags, ncolors, pixelbits, ncmap, cmaplen;
-- int cmtlen, npixels, bufsize=0;
-+ int cmtlen;
- byte *img;
- long filesize;
- char *bname, *errstr;
-@@ -176,44 +176,32 @@
-
- errstr = NULL;
- if (ncolors == 0 || ncolors == 2)
-- errstr = "Unsupported number of channels in RLE file";
-+ errstr = "Unsupt. # of channels in RLE file.\n";
-
- if (pixelbits != 8)
-- errstr = "Only 8-bit pixels supported in RLE files";
-+ errstr = "Only 8-bit pixels supported in RLE files.\n";
-
- if (ncmap==0 || ncmap==1 || ncmap == 3 || ncmap == ncolors) { /* ok */ }
-- else errstr = "Invalid number of colormap channels in RLE file";
-+ else errstr = "Invalid # of colormap channels in RLE file.\n";
-
-- npixels = w * h;
-- if (w <= 0 || h <= 0 || npixels/w != h)
-- errstr = "RLE image dimensions out of range";
-+ if (w<1 || h<1)
-+ errstr = "Bogus size in RLE header.\n";
-
-
- if (errstr) {
- fclose(fp);
-- if (pinfo->comment)
-- free(pinfo->comment);
-- pinfo->comment = (char *) NULL;
-+ if (pinfo->comment) free(pinfo->comment); pinfo->comment = (char *) NULL;
- return rleError(bname, errstr);
- }
-
-
- /* allocate image memory */
-- if (ncolors == 1)
-- img = (byte *) calloc((size_t) npixels, (size_t) 1);
-- else {
-- bufsize = 3*npixels;
-- if (bufsize/3 != npixels)
-- return rleError(bname, "RLE image dimensions out of range");
-- img = (byte *) calloc((size_t) bufsize, (size_t) 1);
-- }
--
-+ if (ncolors == 1) img = (byte *) calloc((size_t) w * h, (size_t) 1);
-+ else img = (byte *) calloc((size_t) w * h * 3, (size_t) 1);
- if (!img) {
- fclose(fp);
-- if (pinfo->comment)
-- free(pinfo->comment);
-- pinfo->comment = (char *) NULL;
-- return rleError(bname, "Unable to allocate RLE image data");
-+ if (pinfo->comment) free(pinfo->comment); pinfo->comment = (char *) NULL;
-+ return rleError(bname, "unable to allocate image data.\n");
- }
-
-
-@@ -221,10 +209,10 @@
- if ((flags & H_CLEARFIRST) && !(flags & H_NO_BACKGROUND)) {
- byte *ip;
- if (ncolors == 1) {
-- for (i=0, ip=img; i<npixels; i++, ip++) *ip = bgcol[0];
-+ for (i=0, ip=img; i<w*h; i++, ip++) *ip = bgcol[0];
- }
- else {
-- for (i=0, ip=img; i<npixels; i++)
-+ for (i=0, ip=img; i<w*h; i++)
- for (j=0; j<3; j++, ip++) *ip = bgcol[j];
- }
- }
-@@ -242,7 +230,7 @@
- if (ncmap) {
- byte *ip;
- int imagelen, cmask;
-- imagelen = (ncolors==1) ? npixels : bufsize;
-+ imagelen = (ncolors==1) ? w*h : w*h*3;
- cmask = (cmaplen-1);
-
- if (ncmap == 1) { /* single gamma curve */
-@@ -250,7 +238,7 @@
- }
-
- else if (ncmap >= 3 && ncolors >=3) { /* one curve per band */
-- for (i=0, ip=img; i<npixels; i++) {
-+ for (i=0, ip=img; i<w*h; i++) {
- *ip = maps[0][*ip & cmask]; ip++;
- *ip = maps[1][*ip & cmask]; ip++;
- *ip = maps[2][*ip & cmask]; ip++;
-diff -ruN xv-3.10a-bugfixes/xvroot.c xv-3.10a-enhancements/xvroot.c
---- xv-3.10a-bugfixes/xvroot.c 2004-05-16 18:04:21.000000000 -0700
-+++ xv-3.10a-enhancements/xvroot.c 2004-05-16 18:07:52.000000000 -0700
-@@ -44,6 +44,7 @@
- case RM_MIRROR:
- case RM_IMIRROR: rpixw = 2*eWIDE; rpixh = 2*eHIGH; break;
- case RM_CSOLID:
-+ case RM_UPLEFT:
- case RM_CWARP:
- case RM_CBRICK: rpixw = dispWIDE; rpixh = dispHIGH; break;
-
-@@ -101,7 +102,7 @@
-
-
- else if (rmode == RM_CENTER || rmode == RM_CENTILE || rmode == RM_CSOLID ||
-- rmode == RM_CWARP || rmode == RM_CBRICK) {
-+ rmode == RM_CWARP || rmode == RM_CBRICK || rmode == RM_UPLEFT) {
- /* do some stuff to set up the border around the picture */
-
- if (rmode != RM_CENTILE) {
-@@ -138,6 +139,12 @@
-
- else if (rmode == RM_CSOLID) { }
-
-+ else if (rmode == RM_UPLEFT) {
-+
-+ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0,
-+ (u_int) eWIDE, (u_int) eHIGH);
-+ }
-+
- else if (rmode == RM_CWARP) { /* warp effect */
- XSetForeground(theDisp, theGC, rootfg);
- for (i=0; i<=dispWIDE; i+=8)
-@@ -157,7 +164,7 @@
-
-
- /* draw the image centered on top of the background */
-- if (rmode != RM_CENTILE)
-+ if ((rmode != RM_CENTILE) && (rmode != RM_UPLEFT))
- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0,
- ((int) dispWIDE-eWIDE)/2, ((int) dispHIGH-eHIGH)/2,
- (u_int) eWIDE, (u_int) eHIGH);
-diff -ruN xv-3.10a-bugfixes/xvsmooth.c xv-3.10a-enhancements/xvsmooth.c
---- xv-3.10a-bugfixes/xvsmooth.c 2004-05-16 18:04:28.000000000 -0700
-+++ xv-3.10a-enhancements/xvsmooth.c 2004-05-16 18:07:59.000000000 -0700
-@@ -105,7 +105,7 @@
- /* we can save a lot of time by precomputing cxtab[] and pxtab[], both
- dwide arrays of ints that contain values for the equations:
- cx = (ex * swide) / dwide;
-- px = ((ex * swide * 100) / dwide) - (cx * 100) - 50; */
-+ px = ((ex * swide * 128) / dwide) - (cx * 128) - 64; */
-
- cxtab = (int *) malloc(dwide * sizeof(int));
- if (!cxtab) { free(pic24); return NULL; }
-@@ -115,8 +115,8 @@
-
- for (ex=0; ex<dwide; ex++) {
- cxtab[ex] = (ex * swide) / dwide;
-- pxtab[ex] = (((ex * swide)* 100) / dwide)
-- - (cxtab[ex] * 100) - 50;
-+ pxtab[ex] = (((ex * swide)* 128) / dwide)
-+ - (cxtab[ex] * 128) - 64;
- }
-
- for (ey=0; ey<dhigh; ey++) {
-@@ -125,7 +125,7 @@
- ProgressMeter(0, (dhigh)-1, ey, "Smooth");
-
- cy = (ey * shigh) / dhigh;
-- py = (((ey * shigh) * 100) / dhigh) - (cy * 100) - 50;
-+ py = (((ey * shigh) * 128) / dhigh) - (cy * 128) - 64;
- if (py<0) { y1 = cy-1; if (y1<0) y1=0; }
- else { y1 = cy+1; if (y1>shigh-1) y1=shigh-1; }
-
-@@ -172,30 +172,30 @@
- else {
- /* compute weighting factors */
- apx = abs(px); apy = abs(py);
-- pA = (apx * apy) / 100;
-- pB = (apy * (100 - apx)) / 100;
-- pC = (apx * (100 - apy)) / 100;
-- pD = 100 - (pA + pB + pC);
-+ pA = (apx * apy) >> 7; /* div 128 */
-+ pB = (apy * (128 - apx)) >> 7; /* div 128 */
-+ pC = (apx * (128 - apy)) >> 7; /* div 128 */
-+ pD = 128 - (pA + pB + pC);
-
- if (is24) {
-- *pp++ = ((int) (pA * rA))/100 + ((int) (pB * rB))/100 +
-- ((int) (pC * rC))/100 + ((int) (pD * rD))/100;
-+ *pp++ = (((int) (pA * rA))>>7) + (((int) (pB * rB))>>7) +
-+ (((int) (pC * rC))>>7) + (((int) (pD * rD))>>7);
-
-- *pp++ = ((int) (pA * gA))/100 + ((int) (pB * gB))/100 +
-- ((int) (pC * gC))/100 + ((int) (pD * gD))/100;
-+ *pp++ = (((int) (pA * gA))>>7) + (((int) (pB * gB))>>7) +
-+ (((int) (pC * gC))>>7) + (((int) (pD * gD))>>7);
-
-- *pp++ = ((int) (pA * bA))/100 + ((int) (pB * bB))/100 +
-- ((int) (pC * bC))/100 + ((int) (pD * bD))/100;
-+ *pp++ = (((int) (pA * bA))>>7) + (((int) (pB * bB))>>7) +
-+ (((int) (pC * bC))>>7) + (((int) (pD * bD))>>7);
- }
- else { /* 8-bit pic */
-- *pp++ = ((int) (pA * rmap[cA]))/100 + ((int)(pB * rmap[cB]))/100 +
-- ((int) (pC * rmap[cC]))/100 + ((int)(pD * rmap[cD]))/100;
-+ *pp++ = (((int)(pA * rmap[cA]))>>7) + (((int)(pB * rmap[cB]))>>7) +
-+ (((int)(pC * rmap[cC]))>>7) + (((int)(pD * rmap[cD]))>>7);
-
-- *pp++ = ((int) (pA * gmap[cA]))/100 + ((int)(pB * gmap[cB]))/100 +
-- ((int) (pC * gmap[cC]))/100 + ((int)(pD * gmap[cD]))/100;
-+ *pp++ = (((int)(pA * gmap[cA]))>>7) + (((int)(pB * gmap[cB]))>>7) +
-+ (((int)(pC * gmap[cC]))>>7) + (((int)(pD * gmap[cD]))>>7);
-
-- *pp++ = ((int)(pA * bmap[cA]))/100 + ((int)(pB * bmap[cB]))/100 +
-- ((int)(pC * bmap[cC]))/100 + ((int)(pD * bmap[cD]))/100;
-+ *pp++ = (((int)(pA * bmap[cA]))>>7) + (((int)(pB * bmap[cB]))>>7) +
-+ (((int)(pC * bmap[cC]))>>7) + (((int)(pD * bmap[cD]))>>7);
- }
- }
- }
-diff -ruN xv-3.10a-bugfixes/xvtext.c xv-3.10a-enhancements/xvtext.c
---- xv-3.10a-bugfixes/xvtext.c 2004-05-16 18:04:38.000000000 -0700
-+++ xv-3.10a-enhancements/xvtext.c 2005-05-01 13:04:23.000000000 -0700
-@@ -19,9 +19,13 @@
- #include "copyright.h"
-
- #include "xv.h"
-+#ifdef TV_MULTILINGUAL
-+#include "xvml.h"
-+#endif
-
--
--#define BUTTW 80
-+#define BUTTW1 80
-+#define BUTTW2 60
-+#define BUTTW3 110
- #define BUTTH 24
-
- #define TOPMARGIN 30 /* from top of window to top of text window */
-@@ -36,11 +40,28 @@
- #define TV_ASCII 0
- #define TV_HEX 1
- #define TV_CLOSE 2
--#define TV_NBUTTS 3
-
-+#define TV_E_NBUTTS 3
-+
-+#ifdef TV_L10N
-+# define TV_RESCAN 3
-+# define TV_USASCII 4
-+# define TV_JIS 5
-+# define TV_EUCJ 6
-+# define TV_MSCODE 7
-+
-+# define TV_J_NBUTTS 8
-+#endif
-
- #define TITLELEN 128
-
-+#ifdef TV_MULTILINGUAL
-+struct coding_spec {
-+ struct coding_system coding_system;
-+ char *(*converter)PARM((char *, int, int *));
-+};
-+#endif
-+
- /* data needed per text window */
- typedef struct { Window win, textW;
- int vis, wasvis;
-@@ -57,16 +78,89 @@
- int chwide, chhigh; /* size of textW, in chars */
- int hexmode; /* true if disp Hex, else Ascii */
- SCRL vscrl, hscrl;
-- BUTT but[TV_NBUTTS], nopBut;
-+#ifdef TV_L10N
-+ int code; /* current character code */
-+ BUTT but[TV_J_NBUTTS], nopBut;
-+#else
-+ BUTT but[TV_E_NBUTTS], nopBut;
-+#endif
-+#ifdef TV_MULTILINGUAL
-+/* int codeset; */
-+ struct coding_spec ccs; /* current coding_spec */
-+ BUTT csbut;
-+ char *cv_text;
-+ int cv_len;
-+ struct context *ctx;
-+ struct ml_text *txt;
-+ struct csinfo_t *cs;
-+#endif
- } TVINFO;
-
-
- static TVINFO tinfo[MAXTVWIN];
- static int hasBeenSized = 0;
- static int haveWindows = 0;
-+static int nbutts; /* # of buttons */
- static int mfwide, mfhigh, mfascent; /* size of chars in mono font */
- static int *event_retP, *event_doneP; /* used in tvChkEvent() */
--
-+#ifdef TV_MULTILINGUAL
-+# define TV_PLAIN 0
-+# define TV_ISO_8859_1 1
-+# define TV_ISO_2022_JP 2
-+# define TV_EUC_JAPAN 3
-+# define TV_ISO_2022_INT_1 4
-+# define TV_ISO_2022_KR 5
-+# define TV_EUC_KOREA 6
-+# define TV_ISO_2022_SS2_8 7
-+# define TV_ISO_2022_SS2_7 8
-+# define TV_SHIFT_JIS 9
-+# define TV_NCSS 10
-+static char *codeSetNames[TV_NCSS] = {
-+ "plain",
-+ "iso-8859-1",
-+ "iso-2022-jp",
-+ "euc-japan",
-+ "iso-2022-int-1",
-+ "iso-2022-kr",
-+ "euc-korea",
-+ "iso-2022-ss2-8",
-+ "iso-2022-ss2-7",
-+ "Shift JIS",
-+};
-+static struct coding_spec coding_spec[TV_NCSS] = {
-+ /* --- G0 --- --- G1 --- --- G2 --- --- G3 --- GL GR EOL SF LS */
-+ /* plain */
-+ {{{{ 1,94,'B'}, { 1,94,'B'}, { 1,94,'B'}, { 1,94,'B'}}, 0, 0, 0, 1, 1},
-+ NULL},
-+ /* iso-8859-1 */
-+ {{{{ 1,94,'B'}, { 1,96,'A'}, {-1,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 0, 0},
-+ NULL},
-+ /* iso-2022-jp */
-+ {{{{ 1,94,'B'}, {-1,94,'B'}, {-1,94,'B'}, {-1,94,'B'}}, 0, 0, 0, 1, 0},
-+ NULL},
-+ /* euc-japan */
-+ {{{{ 1,94,'B'}, { 2,94,'B'}, { 1,94,'J'}, { 2,94,'D'}}, 0, 1, 0, 1, 0},
-+ NULL},
-+ /* iso-2022-int-1 */
-+ {{{{ 1,94,'B'}, { 2,94,'C'}, {-1,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 1, 1},
-+ NULL},
-+ /* iso-2022-kr */
-+ {{{{ 1,94,'B'}, { 2,94,'C'}, {-1,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 0, 1},
-+ NULL},
-+ /* euc-korea */
-+ {{{{ 1,94,'B'}, { 2,94,'C'}, {-1,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 0, 0},
-+ NULL},
-+ /* iso-2022-ss2-8 */
-+ {{{{ 1,94,'B'}, {-1,94,'C'}, { 0,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 0, 0},
-+ NULL},
-+ /* iso-2022-ss2-7 */
-+ {{{{ 1,94,'B'}, {-1,94,'C'}, { 0,94,'B'}, {-1,94,'B'}}, 0, 1, 0, 1, 0},
-+ NULL},
-+ /* shift jis */
-+ {{{{ 1,94,'B'}, { 2,94,'B'}, { 1,94,'J'}, { 2,94,'D'}}, 0, 1, 1, 1, 0},
-+ sjis_to_jis},
-+};
-+#endif
-
- static void closeText PARM((TVINFO *));
- static int tvChkEvent PARM((TVINFO *, XEvent *));
-@@ -82,7 +176,15 @@
- static void textKey PARM((TVINFO *, int));
- static void doHexAsciiCmd PARM((TVINFO *, int));
- static void computeText PARM((TVINFO *));
--
-+#ifdef TV_L10N
-+static int selectCodeset PARM((TVINFO *));
-+#endif
-+#ifdef TV_MULTILINGUAL
-+static void setCodingSpec PARM((TVINFO *, struct coding_spec *));
-+static void createCsWins PARM((char *));
-+static void openCsWin PARM((TVINFO *));
-+static void closeCsWin PARM((TVINFO *));
-+#endif
-
- /* HEXMODE output looks like this:
- 0x00000000: 00 11 22 33 44 55 66 77 - 88 99 aa bb cc dd ee ff 0123456789abcdef
-@@ -98,12 +200,51 @@
- XSizeHints hints;
- XSetWindowAttributes xswa;
- TVINFO *tv;
-+#ifdef TV_MULTILINGUAL
-+ int default_codeset;
-+#endif
-
-+#ifdef TV_L10N
-+ if (!xlocale) {
-+#endif
-+ mfwide = monofinfo->max_bounds.width;
-+ mfhigh = monofinfo->ascent + monofinfo->descent;
-+ mfascent = monofinfo->ascent;
-
-- mfwide = monofinfo->max_bounds.width;
-- mfhigh = monofinfo->ascent + monofinfo->descent;
-- mfascent = monofinfo->ascent;
-+ nbutts = TV_E_NBUTTS; /* # of buttons */
-+#ifdef TV_L10N
-+ }
-+ else {
-+ mfwide = monofsetinfo->max_logical_extent.width / 2; /* shit! */
-+ mfhigh = monofsetinfo->max_logical_extent.height + 1;
-+ mfascent = mfhigh;
-+
-+ nbutts = TV_J_NBUTTS; /* # of buttons */
-+ }
-+#endif
-
-+#ifdef TV_MULTILINGUAL
-+ {
-+ char *dc = XGetDefault(theDisp, "xv", "codeSet");
-+ if (dc == NULL)
-+ default_codeset = TV_DEFAULT_CODESET;
-+ else {
-+ for (i = 0; i < TV_NCSS; i++) {
-+ if (strcmp(dc, codeSetNames[i]) == 0)
-+ break;
-+ }
-+ if (i >= TV_NCSS) {
-+ if (strcmp(dc, "iso-2022") == 0)
-+ default_codeset = TV_PLAIN;
-+ else {
-+ SetISTR(ISTR_WARNING, "%s: unknown codeset.", dc);
-+ default_codeset = TV_PLAIN;
-+ }
-+ } else
-+ default_codeset = i;
-+ }
-+ }
-+#endif
- /* compute default size of textview windows. should be big enough to
- hold an 80x24 text window */
-
-@@ -118,6 +259,14 @@
- for (i=0; i<MAXTVWIN; i++) {
- tv = &tinfo[i];
-
-+#ifdef TV_MULTILINGUAL
-+ tv->ctx = ml_create_context(ScreenOfDisplay(theDisp, theScreen));
-+ tv->txt = NULL;
-+ tv->cv_text = NULL;
-+ tv->cv_len = 0;
-+ ml_set_charsets(tv->ctx, &coding_spec[TV_PLAIN].coding_system);
-+#endif
-+
- tv->win = CreateWindow((i<CMTWIN) ? "xv text viewer" : "xv image comments",
- "XVtextview",
- (i<CMTWIN) ? geom : cmtgeom,
-@@ -162,24 +311,56 @@
- XSelectInput(theDisp, tv->textW, ExposureMask | ButtonPressMask);
-
-
-- BTCreate(&(tv->but[TV_ASCII]), tv->win, 0,0,BUTTW,BUTTH,
-+ BTCreate(&(tv->but[TV_ASCII]), tv->win, 0,0,BUTTW1,BUTTH,
- "Ascii",infofg,infobg,hicol,locol);
-- BTCreate(&(tv->but[TV_HEX]), tv->win, 0,0,BUTTW,BUTTH,
-+ BTCreate(&(tv->but[TV_HEX]), tv->win, 0,0,BUTTW1,BUTTH,
- "Hex",infofg,infobg,hicol,locol);
-- BTCreate(&(tv->but[TV_CLOSE]), tv->win, 0,0,BUTTW,BUTTH,
-+ BTCreate(&(tv->but[TV_CLOSE]), tv->win, 0,0,BUTTW1,BUTTH,
- "Close",infofg,infobg,hicol,locol);
-
-+#ifdef TV_L10N
-+ if (xlocale) {
-+ BTCreate(&(tv->but[TV_RESCAN]), tv->win, 0,0,BUTTW2,BUTTH,
-+ "RESCAN",infofg,infobg,hicol,locol);
-+ BTCreate(&(tv->but[TV_USASCII]), tv->win, 0,0,BUTTW2,BUTTH,
-+ "ASCII",infofg,infobg,hicol,locol);
-+ BTCreate(&(tv->but[TV_JIS]), tv->win, 0,0,BUTTW2,BUTTH,
-+ "JIS",infofg,infobg,hicol,locol);
-+ BTCreate(&(tv->but[TV_EUCJ]), tv->win, 0,0,BUTTW2,BUTTH,
-+ "EUC-j",infofg,infobg,hicol,locol);
-+ BTCreate(&(tv->but[TV_MSCODE]), tv->win, 0,0,BUTTW2,BUTTH,
-+ "MS Kanji",infofg,infobg,hicol,locol);
-+ }
-+#endif
-+
- BTCreate(&(tv->nopBut), tv->win, 0,0, (u_int) tv->vscrl.tsize+1,
- (u_int) tv->vscrl.tsize+1, "", infofg, infobg, hicol, locol);
- tv->nopBut.active = 0;
-
- XMapSubwindows(theDisp, tv->win);
-
-+#ifdef TV_MULTILINGUAL
-+ BTCreate(&tv->csbut, tv->win, 0, 0, BUTTW1, BUTTH, "Code Sets",
-+ infofg, infobg, hicol, locol);
-+#endif
-+
- tv->text = (char *) NULL;
- tv->textlen = 0;
- tv->title[0] = '\0';
-+#ifdef TV_L10N
-+ tv->code = (xlocale ? LOCALE_DEFAULT : 0);
-+#endif
-+#ifdef TV_MULTILINGUAL
-+ tv->ccs = coding_spec[default_codeset];
-+#endif
- }
--
-+#ifdef TV_MULTILINGUAL
-+ get_monofont_size(&mfwide, &mfhigh);
-+ /* recalculate sizes. */
-+ defwide = 80 * mfwide + 2*LRMARGINS + 8 + 20; /* -ish */
-+ defhigh = 24 * mfhigh + TOPMARGIN + BOTMARGIN + 8 + 20; /* ish */
-+ cmthigh = 6 * mfhigh + TOPMARGIN + BOTMARGIN + 8 + 20; /* ish */
-+#endif
-
- for (i=0; i<MAXTVWIN; i++) {
- resizeText(&tinfo[i], defwide, (i<CMTWIN) ? defhigh : cmthigh);
-@@ -190,44 +371,54 @@
-
- hasBeenSized = 1; /* we can now start looking at textview events */
-
-+#ifdef TV_MULTILINGUAL
-+ createCsWins("+100+100");
-+#endif
- }
-
-
- /***************************************************************/
--void TextView(fname)
-+int TextView(fname)
- char *fname;
- {
- /* given a filename, attempts to read in the file and open a textview win */
-
-+ int filetype;
- long textlen;
- char *text, buf[512], title[128], rfname[MAXPATHLEN+1];
- char *basefname[128]; /* just current fname, no path */
- FILE *fp;
-+ char filename[MAXPATHLEN+1];
-+
-+ strncpy(filename, fname, sizeof(filename) - 1);
-+#ifdef AUTO_EXPAND
-+ Mkvdir(filename);
-+ Dirtovd(filename);
-+#endif
-
- basefname[0] = '\0';
-- strcpy(rfname, fname);
-+ strncpy(rfname, filename, sizeof(rfname) - 1);
-
- /* see if this file is compressed. if it is, uncompress it, and view
- the uncompressed version */
-
-- if (ReadFileType(fname) == RFT_COMPRESS) {
-+ filetype = ReadFileType(filename);
-+ if ((filetype == RFT_COMPRESS) || (filetype == RFT_BZIP2)) {
- #ifndef VMS
-- if (!UncompressFile(fname, rfname)) return; /* failed to uncompress */
-+ if (!UncompressFile(filename, rfname, filetype)) return FALSE;
- #else
- /* chop off trailing '.Z' from friendly displayed basefname, if any */
-- strcpy (basefname, fname);
-+ strncpy (basefname, filename, 128 - 1);
- *rindex (basefname, '.') = '\0';
-- if (!UncompressFile(basefname, rfname)) return;/* failed to uncompress */
-+ if (!UncompressFile(basefname, rfname, filetype)) return FALSE;
- #endif
- }
-
--
--
- fp = fopen(rfname, "r");
- if (!fp) {
- sprintf(buf,"Couldn't open '%s': %s", rfname, ERRSTR(errno));
- ErrPopUp(buf,"\nOh well");
-- return;
-+ return FALSE;
- }
-
-
-@@ -239,16 +430,16 @@
- sprintf(buf, "File '%s' contains no data. (Zero length file.)", rfname);
- ErrPopUp(buf, "\nOk");
- fclose(fp);
-- return;
-+ return FALSE;
- }
-
-- text = (char *) malloc((size_t) textlen);
-+ text = (char *) malloc((size_t) textlen + 1);
- if (!text) {
- sprintf(buf, "Couldn't malloc %ld bytes to read file '%s'",
- textlen, rfname);
- ErrPopUp(buf, "\nSo what!");
- fclose(fp);
-- return;
-+ return FALSE;
- }
-
- if (fread(text, (size_t) 1, (size_t) textlen, fp) != textlen) {
-@@ -256,6 +447,9 @@
- rfname);
- ErrPopUp(buf, "\nHmm...");
- }
-+#ifdef TV_MULTILINGUAL
-+ text[textlen] = '\0';
-+#endif
-
- fclose(fp);
-
-@@ -263,6 +457,7 @@
- OpenTextView(text, (int) textlen, title, 1);
-
- /* note: text gets freed when window gets closed */
-+ return TRUE;
- }
-
-
-@@ -504,6 +699,10 @@
- tv->text = (char *) NULL;
- tv->lines = (char **) NULL;
- tv->numlines = tv->textlen = tv->hexmode = 0;
-+
-+#ifdef TV_MULTILINGUAL
-+ closeCsWin(tv);
-+#endif
- }
-
-
-@@ -591,6 +790,40 @@
- else if (e->window == tv->textW) { }
- else rv = 0;
- }
-+ else if (e->button == Button4) { /* note min vs. max, + vs. - */
-+ /* scroll regardless of where we are in the text window */
-+ if (e->window == tv->win ||
-+ e->window == tv->vscrl.win ||
-+ e->window == tv->hscrl.win ||
-+ e->window == tv->textW)
-+ {
-+ SCRL *sp=&(tv->vscrl);
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val > sp->min+halfpage)
-+ SCSetVal(sp,sp->val-halfpage);
-+ else
-+ SCSetVal(sp,sp->min);
-+ }
-+ else rv = 0;
-+ }
-+ else if (e->button == Button5) { /* note max vs. min, - vs. + */
-+ /* scroll regardless of where we are in the text window */
-+ if (e->window == tv->win ||
-+ e->window == tv->vscrl.win ||
-+ e->window == tv->hscrl.win ||
-+ e->window == tv->textW)
-+ {
-+ SCRL *sp=&(tv->vscrl);
-+ int halfpage=sp->page/2;
-+
-+ if (sp->val < sp->max-halfpage)
-+ SCSetVal(sp,sp->val+halfpage);
-+ else
-+ SCSetVal(sp,sp->max);
-+ }
-+ else rv = 0;
-+ }
- else rv = 0;
- }
-
-@@ -633,7 +866,9 @@
- int i, maxw, maxh;
- XSizeHints hints;
-
-+#ifndef TV_MULTILINGUAL
- if (tv->wide == w && tv->high == h) return; /* no change in size */
-+#endif
-
- if (XGetNormalHints(theDisp, tv->win, &hints)) {
- hints.width = w;
-@@ -657,10 +892,23 @@
- XMoveResizeWindow(theDisp, tv->textW, LRMARGINS, TOPMARGIN,
- (u_int) tv->twWide, (u_int) tv->twHigh);
-
-- for (i=0; i<TV_NBUTTS; i++) {
-- tv->but[i].x = tv->wide - (TV_NBUTTS-i) * (BUTTW+5);
-+ for (i=0; i<TV_E_NBUTTS; i++) {
-+ tv->but[i].x = tv->wide - (TV_E_NBUTTS-i) * (BUTTW1+5);
- tv->but[i].y = tv->high - BUTTH - 5;
- }
-+#ifdef TV_MULTILINGUAL
-+ tv->csbut.x = 5;
-+ tv->csbut.y = tv->high - BUTTH - 5;
-+#endif
-+
-+#ifdef TV_L10N
-+ if (xlocale) {
-+ for (; i<TV_J_NBUTTS; i++) {
-+ tv->but[i].x = 5 + (i-TV_E_NBUTTS) * (BUTTW2+5);
-+ tv->but[i].y = tv->high - BUTTH - 5;
-+ }
-+ }
-+#endif
-
- computeScrlVals(tv);
-
-@@ -711,6 +959,29 @@
- case TV_CLOSE: if (tv == &tinfo[CMTWIN]) CloseCommentText();
- else closeText(tv);
- break;
-+
-+#ifdef TV_L10N
-+ case TV_RESCAN:
-+ tv->code = selectCodeset(tv);
-+ drawTextW(0, &tv->vscrl);
-+ break;
-+ case TV_USASCII:
-+ tv->code = LOCALE_USASCII;
-+ drawTextW(0, &tv->vscrl);
-+ break;
-+ case TV_JIS:
-+ tv->code = LOCALE_JIS;
-+ drawTextW(0, &tv->vscrl);
-+ break;
-+ case TV_EUCJ:
-+ tv->code = LOCALE_EUCJ;
-+ drawTextW(0, &tv->vscrl);
-+ break;
-+ case TV_MSCODE:
-+ tv->code = LOCALE_MSCODE;
-+ drawTextW(0, &tv->vscrl);
-+ break;
-+#endif /* TV_L10N */
- }
- }
-
-@@ -745,8 +1016,10 @@
- drawNumLines(tv);
-
- /* draw the buttons */
-- for (i=0; i<TV_NBUTTS; i++) BTRedraw(&(tv->but[i]));
--
-+ for (i=0; i<nbutts; i++) BTRedraw(&(tv->but[i]));
-+#ifdef TV_MULTILINGUAL
-+ BTRedraw(&tv->csbut);
-+#endif
- BTRedraw(&tv->nopBut);
- }
-
-@@ -816,7 +1089,14 @@
- int delta;
- SCRL *sptr;
- {
-- int i, j, lnum, hpos, cpos, extrach, lwide;
-+ int i, j, lnum, hpos, vpos, cpos, lwide;
-+#ifndef TV_MULTILINGUAL
-+ int extrach;
-+#endif
-+#ifdef TV_L10N
-+ int desig_stat; /* for ISO 2022-JP */
-+ /* 0: ASCII, 1: JIS X 0208, 2: GL is JIS X 0201 kana */
-+#endif
- TVINFO *tv;
- char linestr[512];
- u_char *sp, *ep, *lp;
-@@ -839,12 +1119,38 @@
- XSetFont(theDisp, theGC, monofont);
-
- hpos = tv->hscrl.val;
-+ vpos = tv->vscrl.val;
- lwide = (tv->chwide < 500) ? tv->chwide : 500;
-
- /* draw text */
- if (!tv->hexmode) { /* ASCII mode */
-+#ifdef TV_MULTILINGUAL
-+ XClearArea(theDisp, tv->textW, 0, 0,
-+ (u_int) tv->twWide, (u_int) tv->twHigh, False);
-+ if(tv->txt == NULL)
-+ return;
-+ else {
-+ int i;
-+ int y;
-+ struct ml_text *tp = tv->txt;
-+ struct ml_line *lp;
-+
-+ XSetFunction(theDisp, theGC, GXcopy);
-+ XSetClipMask(theDisp, theGC, None);
-+ y = 3;
-+ for (lp = &tp->lines[vpos], i = tp->nlines - vpos;
-+ i > 0; lp++, i--) {
-+ XDrawText16(theDisp, tv->textW, theGC,
-+ -mfwide * hpos + 3, y + lp->ascent,
-+ lp->items, lp->nitems);
-+ y += lp->ascent + lp->descent;
-+ if (y > tv->twHigh)
-+ break;
-+ }
-+ }
-+#else
- for (i=0; i<tv->chhigh; i++) { /* draw each line */
-- lnum = i + tv->vscrl.val;
-+ lnum = i + vpos;
- if (lnum < tv->numlines-1) {
-
- /* find start of displayed portion of line. This is *wildly*
-@@ -865,7 +1171,13 @@
- cpos--; sp++;
- }
- else if (*sp < 32) extrach = 1;
-+
-+#ifdef TV_L10N
-+ else if (!tv->code && *sp > 127) extrach = 3;
-+#else
- else if (*sp > 127) extrach = 3;
-+#endif
-+
- else sp++;
- }
- else {
-@@ -881,6 +1193,10 @@
-
- /* build up the linestr buffer, which is the current line, padded
- with blanks to a width of exactly tv->chwide chars */
-+#ifdef TV_L10N
-+ desig_stat = 0; /* for ISO 2022-JP */
-+ /* 0: ASCII, 1: JIS X 0208, 2: GL is JIS X 0201 kana */
-+#endif
- for (cpos=0, lp=(byte *) linestr; cpos<lwide; cpos++, lp++) {
- if (sp>=ep) *lp = ' ';
- else {
-@@ -894,13 +1210,117 @@
- cpos--; lp--; sp++;
- }
-
-+#ifdef TV_L10N
-+ else if (*sp < 32 && !(tv->code == LOCALE_JIS && *sp == 0x1b)) {
-+#else
- else if (*sp < 32) {
-+#endif
- if (!extrach) extrach = 2;
- if (extrach == 2) *lp = '^';
- else if (extrach == 1) *lp = *sp + 64;
- }
-
-+#ifdef TV_L10N
-+ /* convert to EUC-Japan */
-+ else if (tv->code == LOCALE_JIS) {
-+ if (*sp == 0x1b) { /* ESC */
-+ if (*(sp+1) == '$') {
-+ if (*(sp+2) == 'B' || *(sp+2) == 'A' || *(sp+2) == '@') {
-+ /* ESC $ B, ESC $ A, ESC $ @ */
-+ desig_stat = 1;
-+ sp += 3; cpos--; lp--;
-+ }
-+ else if (*(sp+2) == '(' && *(sp+3) == 'B') {
-+ /* ESC $ ( B */
-+ desig_stat = 1;
-+ sp += 4; cpos--; lp--;
-+ }
-+ }
-+ else if (*(sp+1) == '(') {
-+ if (*(sp+2) == 'B' || *(sp+2) == 'J' || *(sp+2) == 'H') {
-+ /* ESC ( B, ESC ( J, ESC ( H */
-+ desig_stat = 0;
-+ sp += 3; cpos--; lp--;
-+ }
-+ else if (*(sp+2) == 'I') {
-+ /* ESC ( I */
-+ desig_stat = 2;
-+ sp += 3; cpos--; lp--;
-+ }
-+ }
-+ else if (*(sp+1) == ')' && *(sp+2) == 'I') {
-+ /* ESC ) I */
-+ desig_stat = 2;
-+ sp += 3; cpos--; lp--;
-+ }
-+ else { /* error */
-+ *lp = ' '; sp++;
-+ }
-+ }
-+
-+ else {
-+ switch (desig_stat) {
-+ case 0: /* ASCII */
-+ *lp = *sp++;
-+ break;
-+ case 1: /* JIS X 0208 */
-+ *lp++ = *sp++ | 0x80;
-+ *lp = *sp++ | 0x80;
-+ cpos++;
-+ break;
-+ case 2: /* JIS X 0201 kana */
-+#if defined(__osf__) && !defined(X_LOCALE)
-+ *lp = '='; sp++;
-+#else
-+ *lp++ = 0x8e; /* ^N | 0x80 */
-+ *lp = *sp++ | 0x80;
-+#endif
-+ break;
-+ default: /* error */
-+ *lp = *sp++;
-+ break;
-+ }
-+ }
-+ }
-+
-+ else if (tv->code == LOCALE_MSCODE) {
-+ if ((*sp >= 0x81 && *sp <= 0x9f)
-+ || (*sp >= 0xe0 && *sp <= 0xef)) {
-+ static u_char c1, c2;
-+
-+/*fprintf(stderr, "(%x,%x)->", *sp, *(sp+1));*/
-+ c1 = ((*sp - ((*sp>=0xe0) ? 0xb0 : 0x70)) << 1)
-+ - ((*(sp+1)<=0x9e) ? 1 : 0);
-+ c2 = *(sp+1);
-+ if (c2 >= 0x9f) c2 -= 0x7e; /* 0x9F - 0xFC */
-+ else if (c2 >= 0x80) c2 -= 0x20; /* 0x80 - 0x9E */
-+ else c2 -= 0x1f; /* 0x40 - 0x7E */
-+
-+ *lp++ = c1 | 0x80;
-+ *lp = c2 | 0x80;
-+ sp += 2;
-+/*fprintf(stderr, "(%x %x) ", c1 | 0x80, c2 | 0x80);*/
-+ cpos++;
-+ }
-+
-+ else if (*sp >= 0xa1 && *sp <= 0xdf) { /* JIS X 0201 kana */
-+#if defined(__osf__) && !defined(X_LOCALE)
-+ *lp = '='; sp++;
-+#else
-+ *lp++ = 0x8e; /* ^N | 0x80 */
-+ *lp = *sp++;
-+#endif
-+ }
-+
-+ else *lp = *sp++;
-+ }
-+#endif /* TV_L10N */
-+
-+#ifdef TV_L10N
-+ else if (!tv->code && *sp > 127) {
-+#else
- else if (*sp > 127) {
-+#endif
- if (!extrach) extrach = 4;
- if (extrach == 4) *lp = '\\';
- else if (extrach == 3) *lp = ((u_char)(*sp & 0700) >> 6) + '0';
-@@ -916,6 +1336,9 @@
- }
- }
- }
-+#ifdef TV_L10N
-+ *lp = '\0'; /* terminate linestr */
-+#endif
- }
-
- else { /* below bottom of file. Just build a blank str */
-@@ -923,15 +1346,22 @@
- }
-
- /* draw the line */
-- XDrawImageString(theDisp, tv->textW, theGC,
-- 3, i*mfhigh + 3 + mfascent, linestr, lwide);
-+#ifdef TV_L10N
-+ if (xlocale)
-+ XmbDrawImageString(theDisp, tv->textW, monofset, theGC,
-+ 3, i*mfhigh + 1 + mfascent, linestr, strlen(linestr));
-+ else
-+#endif
-+ XDrawImageString(theDisp, tv->textW, theGC,
-+ 3, i*mfhigh + 3 + mfascent, linestr, lwide);
- } /* for i ... */
-+#endif /* TV_MULTILINGUAL */
- } /* if hexmode */
-
-
- else { /* HEX MODE */
- for (i=0; i<tv->chhigh; i++) { /* draw each line */
-- lnum = i + tv->vscrl.val;
-+ lnum = i + vpos;
- if (lnum < tv->hexlines) {
-
- char hexstr[80], tmpstr[16];
-@@ -957,7 +1387,11 @@
-
- for (j=0; j<16; j++) {
- if (sp+j < ep) {
-+#ifdef TV_L10N
-+ if (sp[j] >= 32 && (sp[j] <= 127 || tv->code)) *lp++ = sp[j];
-+#else
- if (sp[j] >= 32 && sp[j] <= 127) *lp++ = sp[j];
-+#endif
- else *lp++ = '.';
- }
- else *lp++ = ' ';
-@@ -1005,14 +1439,21 @@
- int i;
- BUTT *bp;
-
-- for (i=0, bp=tv->but; i<TV_NBUTTS; i++, bp++) {
-+ for (i=0, bp=tv->but; i<nbutts; i++, bp++) {
- if (PTINRECT(x,y,bp->x,bp->y,bp->w,bp->h)) break;
- }
-
-- if (i<TV_NBUTTS) {
-+ if (i<nbutts) {
- if (BTTrack(bp)) doCmd(tv, i);
- return;
- }
-+
-+#ifdef TV_MULTILINGUAL
-+ if (PTINRECT(x, y, tv->csbut.x, tv->csbut.y, tv->csbut.w, tv->csbut.h)) {
-+ if (BTTrack(&tv->csbut))
-+ openCsWin(tv);
-+ }
-+#endif
- }
-
-
-@@ -1042,13 +1483,38 @@
-
- /* keyboard equivalents */
- switch (buf[0]) {
-- case '\001': doCmd(tv, TV_ASCII); break; /* ^A = Ascii */
-- case '\010': doCmd(tv, TV_HEX); break; /* ^H = Hex */
--
-- case '\033': doCmd(tv, TV_CLOSE); break; /* ESC = Close window */
-+ case '\001': case 'a': case 'A':
-+ doCmd(tv, TV_ASCII); break; /* ^A = Ascii */
-+ case '\010': case 'h': case 'H':
-+ doCmd(tv, TV_HEX); break; /* ^H = Hex */
-+
-+ case '\021': case 'q': case 'Q':
-+ case '\003': case 'c': case 'C':
-+ case '\033':
-+ doCmd(tv, TV_CLOSE); break; /* ESC = Close window */
-
- default: break;
- }
-+
-+#ifdef TV_L10N
-+ if (xlocale) {
-+ switch (buf[0]) {
-+ case '\022': case 'r': case 'R':
-+ doCmd(tv, TV_RESCAN); break;
-+ case '\012': case 'j': case 'J':
-+ doCmd(tv, TV_JIS); break;
-+ case '\005': case 'e': case 'E':
-+ case '\025': case 'u': case 'U':
-+ doCmd(tv, TV_EUCJ); break;
-+ case '\015': case 'm': case 'M':
-+ case '\023': case 's': case 'S':
-+ doCmd(tv, TV_MSCODE); break;
-+
-+ default: break;
-+ }
-+ }
-+#endif /* TV_L10N */
-+
- }
-
-
-@@ -1109,7 +1575,20 @@
- if (i<tv->numlines-1) SCSetVal(&tv->vscrl, i);
- }
-
-+#ifdef TV_L10N
-+ /* redraw text */
-+ if (xlocale) {
-+ XClearArea(theDisp, tv->textW, 0, 0,
-+ (u_int) tv->twWide, (u_int) tv->twHigh, False);
-+
-+ drawTextW(0, &tv->vscrl);
-+ }
-+#endif
-+#ifdef TV_MULTILINGUAL
-+ XClearArea(theDisp, tv->textW, 0, 0,
-+ (u_int) tv->twWide, (u_int) tv->twHigh, False);
- drawTextW(0, &tv->vscrl);
-+#endif
- }
-
-
-@@ -1122,9 +1601,22 @@
- int i,j,wide,maxwide,space;
- byte *sp;
-
-+#ifdef TV_L10N
-+ /* select code-set */
-+ if (xlocale)
-+ tv->code = selectCodeset(tv);
-+#endif /* TV_L10N */
-+
- if (!tv->text) {
- tv->numlines = tv->hexlines = 0;
- tv->lines = (char **) NULL;
-+#ifdef TV_MULTILINGUAL
-+ if (tv->cv_text != NULL) {
-+ free(tv->cv_text);
-+ tv->cv_text = NULL;
-+ }
-+ tv->txt = NULL;
-+#endif
- return;
- }
-
-@@ -1172,17 +1664,129 @@
- wide += space;
- }
- else if (*sp < 32) wide += 2;
-+#ifdef TV_L10N
-+ else if (*sp > 127 && !tv->code) wide += 4;
-+#else
- else if (*sp > 127) wide += 4;
-+#endif
- else wide++;
- }
- if (wide > maxwide) maxwide = wide;
- }
- tv->maxwide = maxwide;
-
-+#ifdef TV_MULTILINGUAL
-+ ml_set_charsets(tv->ctx, &tv->ccs.coding_system);
-+ if (tv->cv_text != NULL) {
-+ free(tv->cv_text);
-+ tv->cv_text = NULL;
-+ }
-+ if (tv->ccs.converter == NULL) {
-+ tv->txt = ml_draw_text(tv->ctx, tv->text, tv->textlen);
-+ } else {
-+ tv->cv_text = (*tv->ccs.converter)(tv->text, tv->textlen, &tv->cv_len);
-+ tv->txt = ml_draw_text(tv->ctx, tv->cv_text, tv->cv_len);
-+ }
-+ tv->maxwide = tv->txt->width / mfwide;
-+ tv->numlines = tv->txt->height / mfhigh + 1;
-+#endif
-+
- tv->hexlines = (tv->textlen + 15) / 16;
- }
-
-
-+/***************************************************/
-+#ifdef TV_L10N
-+static int selectCodeset(tv)
-+ TVINFO *tv;
-+{
-+ u_char *sp;
-+ int i, len;
-+ int code = LOCALE_USASCII; /* == 0 */
-+
-+
-+ len = tv->textlen;
-+
-+ /* select code-set */
-+ if (xlocale) {
-+ sp = (u_char *) tv->text; i = 0;
-+ while (i < len - 1) {
-+ if (*sp == 0x1b &&
-+ (*(sp+1) == '$' || *(sp+1) == '(' || *(sp+1) == ')')) {
-+ code = LOCALE_JIS;
-+ break;
-+ }
-+
-+ else if (*sp >= 0xa1 && *sp <= 0xdf) {
-+ if (*(sp+1) >= 0xf0 && *(sp+1) <= 0xfe) {
-+ code = LOCALE_EUCJ;
-+ break;
-+ }
-+# if (LOCALE_DEFAULT == LOCALE_EUCJ)
-+ else {
-+ sp++; i++;
-+ }
-+# endif
-+ }
-+
-+ else if ((*sp >= 0x81 && *sp <= 0x9f) || (*sp >= 0xe0 && *sp <= 0xef)) {
-+ if ((*(sp+1) >= 0x40 && *(sp+1) <= 0x7e) || *(sp+1) == 0x80) {
-+ code = LOCALE_MSCODE;
-+ break;
-+ }
-+ else if (*(sp+1) == 0xfd || *(sp+1) == 0xfe) {
-+ code = LOCALE_EUCJ;
-+ break;
-+ }
-+ else {
-+ sp++; i++;
-+ }
-+ }
-+
-+ else if (*sp >= 0xf0 && *sp <= 0xfe) {
-+ code = LOCALE_EUCJ;
-+ break;
-+ }
-+
-+ sp++; i++;
-+ }
-+ if (!code) code = LOCALE_DEFAULT;
-+ }
-+
-+ return code;
-+}
-+#endif /* TV_L10N */
-+
-+#ifdef TV_MULTILINGUAL
-+static void setCodingSpec(tv, cs)
-+ TVINFO *tv;
-+ struct coding_spec *cs;
-+{
-+ if (xvbcmp((char *) &tv->ccs, (char *) cs, sizeof *cs) == 0)
-+ return;
-+
-+ tv->ccs = *cs;
-+#if 0
-+ ml_set_charsets(tv->ctx, &tv->ccs.coding_system);
-+ if (tv->cv_text != NULL) {
-+ free(tv->cv_text);
-+ tv->cv_text = NULL;
-+ }
-+ if (tv->ccs.converter == NULL) {
-+ tv->txt = ml_draw_text(tv->ctx, tv->text, tv->textlen);
-+ } else {
-+ tv->cv_text = (*tv->ccs.converter)(tv->text, tv->textlen, &tv->cv_len);
-+ tv->txt = ml_draw_text(tv->ctx, tv->cv_text, tv->cv_len);
-+ }
-+#else
-+ computeText(tv);
-+ computeScrlVals(tv);
-+#endif
-+ /* drawTextW(0, &tv->vscrl); */
-+}
-+#endif
-+
-+
- /**********************************************************************/
- /* BUILT-IN TEXT FILES ************************************************/
- /**********************************************************************/
-@@ -1555,8 +2159,509 @@
- OpenTextView(keyhelp, (int) strlen(keyhelp), "XV Help", 0);
- }
-
-+#ifdef TV_MULTILINGUAL
-+
-+#define TV_ML_ACCEPT TV_NCSS
-+#define TV_ML_CLOSE (TV_ML_ACCEPT + 1)
-+#define TV_ML_NBUTTS (TV_ML_CLOSE + 1)
-+
-+#define TV_ML_RETCODE 0
-+# define TV_ML_RET_LF 0
-+# define TV_ML_RET_CRLF 1
-+# define TV_ML_RET_CR 2
-+# define TV_ML_RET_ANY 3
-+#define TV_ML_GL 1
-+#define TV_ML_GR 2
-+#define TV_ML_CVTR 3
-+#define TV_ML_NRBUTTS 4
-+
-+#define TV_ML_SHORT 0
-+#define TV_ML_LOCK 1
-+#define TV_ML_NCBUTTS 2
-+
-+#define TV_ML_NLISTS 4
-+
-+#define CSWIDE (BUTTW3 * 5 + 5 * 6)
-+#define CSHIGH 450
-+
-+typedef struct csinfo_t {
-+ TVINFO *tv;
-+ RBUTT *rbt[TV_ML_NRBUTTS];
-+ CBUTT cbt[TV_ML_NCBUTTS];
-+ LIST ls[TV_ML_NLISTS];
-+ BUTT bt[TV_ML_NBUTTS];
-+ int up;
-+ Window win;
-+ struct coding_spec tcs; /* temporary coding_spec */
-+} CSINFO;
-+CSINFO csinfo[MAXTVWIN];
-+static char **regs;
-+static int nregs;
-+
-+static int csCheckEvent PARM((CSINFO *, XEvent *));
-+static void csReflect PARM((CSINFO *));
-+static void csRedraw PARM((CSINFO *));
-+static void csListRedraw PARM((LIST *));
-+static void csLsRedraw PARM((int, SCRL *));
-+static void create_registry_list PARM((void));
-+
-+static char *(*cvtrtab[])PARM((char *, int, int *)) = {
-+ NULL,
-+ sjis_to_jis,
-+};
-+
-+static void createCsWins(geom)
-+ char *geom;
-+{
-+ XSetWindowAttributes xswa;
-+ int i, j;
-+
-+ create_registry_list();
-+
-+ xswa.backing_store = WhenMapped;
-+ for (i = 0; i < MAXTVWIN; i++) {
-+ char nam[8];
-+ TVINFO *tv = &tinfo[i];
-+ CSINFO *cs = &csinfo[i];
-+ tv->cs = cs;
-+ cs->tv = tv;
-+ sprintf(nam, "XVcs%d", i);
-+ cs->win = CreateWindow("xv codeset", nam, geom,
-+ CSWIDE, CSHIGH, infofg, infobg, 0);
-+ if (!cs->win) FatalError("couldn't create 'charset' window!");
-+#ifdef BACKING_STORE
-+ XChangeWindowAttributes(theDisp, cs->win, CWBackingStore, &xswa);
-+#endif
-+ XSelectInput(theDisp, cs->win, ExposureMask | ButtonPressMask);
-+
-+ DrawString(cs->win, 5, 5 + ASCENT, "Initial States");
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ int x, y;
-+ char buf[80];
-+
-+ if (i / 2 == 0)
-+ x = 15;
-+ else
-+ x = 280;
-+ if (i % 2 == 0)
-+ y = 5 + LINEHIGH * 1;
-+ else
-+ y = 5 + LINEHIGH * 7 + SPACING * 3;
-+
-+ sprintf(buf, "Designation for G%d:", i + 1);
-+ DrawString(cs->win, x, y + ASCENT, buf);
-+
-+ LSCreate(&cs->ls[i], cs->win, x + 15, y + LINEHIGH,
-+ 200, LINEHIGH * 5, 5,
-+ regs, nregs + 2,
-+ infofg, infobg, hicol, locol, csLsRedraw, 0, 0);
-+ cs->ls[i].selected = 0;
-+ }
-+
-+ for (i = 0; i < 2; i++) {
-+ char *p;
-+ int n;
-+ int x, y;
-+
-+ if ((p = (char *) malloc(3 * 4)) == NULL)
-+ FatalError("out of memory in createCsWins().");
-+ strcpy(p, "G1 G2 G3 G4");
-+ p[2] = p[5] = p[8] = '\0';
-+ n = (i == 0 ? TV_ML_GL : TV_ML_GR);
-+ x = (i == 0 ? 15 : 280);
-+ y = 235;
-+ DrawString(cs->win, x, y + ASCENT, "Assignment for GL:");
-+ x += 15;
-+ y += LINEHIGH;
-+ cs->rbt[n] = RBCreate(NULL, cs->win,
-+ x, y, p, infofg, infobg, hicol, locol);
-+ for (j = 1; j < 4; j++) {
-+ p += 3;
-+ x += 50;
-+ RBCreate(cs->rbt[n], cs->win,
-+ x, y, p, infofg, infobg, hicol, locol);
-+ }
-+ }
-+
-+ DrawString(cs->win, 5, 280 + ASCENT, "Ret Code:");
-+ cs->rbt[TV_ML_RETCODE] =
-+ RBCreate(NULL, cs->win, 20, 300, "LF", infofg,infobg, hicol,locol);
-+ RBCreate(cs->rbt[TV_ML_RETCODE], cs->win, 20, 300 + 20, "CR+LF",
-+ infofg, infobg, hicol, locol);
-+ RBCreate(cs->rbt[TV_ML_RETCODE], cs->win, 90, 300, "CR",
-+ infofg, infobg, hicol, locol);
-+ RBCreate(cs->rbt[TV_ML_RETCODE], cs->win, 90, 300 + 20, "Any",
-+ infofg, infobg, hicol, locol);
-+
-+ DrawString(cs->win, 350, 280 + ASCENT, "Converter:");
-+ cs->rbt[TV_ML_CVTR] =
-+ RBCreate(NULL, cs->win, 365, 300, "Nothing",
-+ infofg, infobg, hicol, locol);
-+ RBCreate(cs->rbt[TV_ML_CVTR], cs->win, 365, 300 + 20, "Shift JIS",
-+ infofg, infobg, hicol, locol);
-+
-+ CBCreate(&cs->cbt[TV_ML_SHORT], cs->win, 200, 300, "Short Form",
-+ infofg, infobg, hicol, locol);
-+ CBCreate(&cs->cbt[TV_ML_LOCK], cs->win, 200, 320, "Locking Shift",
-+ infofg, infobg, hicol, locol);
-+
-+ for (j = 0; j < TV_NCSS; j++) {
-+ BTCreate(&cs->bt[j], cs->win,
-+ 5 + (BUTTW3 + 5) * (j % 5),
-+ 350 + 5 + (BUTTH + 5) * (j / 5),
-+ BUTTW3, BUTTH, codeSetNames[j],
-+ infofg, infobg, hicol, locol);
-+ }
-+ BTCreate(&cs->bt[TV_ML_ACCEPT], cs->win,
-+ CSWIDE - 10 - BUTTW3 * 2, CSHIGH - 5 - BUTTH, BUTTW3, BUTTH,
-+ "Accept", infofg, infobg, hicol, locol);
-+ BTCreate(&cs->bt[TV_ML_CLOSE], cs->win,
-+ CSWIDE - 5 - BUTTW3, CSHIGH - 5 - BUTTH, BUTTW3, BUTTH,
-+ "Close", infofg, infobg, hicol, locol);
-
-+ XMapSubwindows(theDisp, cs->win);
-+ cs->up = 0;
-+ }
-+}
-
-+static void openCsWin(tv)
-+ TVINFO *tv;
-+{
-+ CSINFO *cs = tv->cs;
-+ if (cs->up)
-+ return;
-
-+ XMapRaised(theDisp, cs->win);
-+ cs->up = 1;
-+ cs->tcs = cs->tv->ccs;
-+ csReflect(cs);
-+}
-
-+static void closeCsWin(tv)
-+ TVINFO *tv;
-+{
-+ CSINFO *cs = tv->cs;
-+ if (!cs->up)
-+ return;
-+ cs->up = 0;
-+ XUnmapWindow(theDisp, cs->win);
-+}
-+
-+int CharsetCheckEvent(xev)
-+ XEvent *xev;
-+{
-+ int i;
-+ CSINFO *cs;
-+
-+ for (cs = csinfo, i = 0; i < MAXTVWIN; cs++, i++) {
-+ if (!cs->up)
-+ continue;
-+ if (csCheckEvent(cs, xev))
-+ break;
-+ }
-+ if (i < MAXTVWIN)
-+ return 1;
-+ return 0;
-+}
-+
-+static int csCheckEvent(cs, xev)
-+ CSINFO *cs;
-+ XEvent *xev;
-+{
-+ RBUTT **rbp;
-+ CBUTT *cbp;
-+ LIST *ls;
-+ BUTT *bp;
-+ int i, n;
-+
-+ if (xev->type == Expose) {
-+ int x, y, w, h;
-+ XExposeEvent *e = (XExposeEvent *) xev;
-+ x = e->x; y = e->y; w = e->width; h = e->height;
-+
-+ if (cs->win == e->window){
-+ csRedraw(cs);
-+ return 1;
-+ } else {
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ if (cs->ls[i].win == e->window) {
-+ LSRedraw(&cs->ls[i], 0);
-+ return 1;
-+ }
-+ }
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ if (cs->ls[i].scrl.win == e->window) {
-+ SCRedraw(&cs->ls[i].scrl);
-+ return 1;
-+ }
-+ }
-+ }
-+ } else if (xev->type == ButtonPress) {
-+ int x, y;
-+ XButtonEvent *e = (XButtonEvent *) xev;
-+ x = e->x; y = e->y;
-+ if (cs->win == e->window) {
-+ for (bp = cs->bt, i = 0; i < TV_ML_NBUTTS; bp++, i++) {
-+ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h))
-+ break;
-+ }
-+ if (i < TV_ML_NBUTTS) {
-+ if (BTTrack(bp)) {
-+ if (i < TV_NCSS) {
-+ cs->tcs = coding_spec[i];
-+ csReflect(cs);
-+ } else {
-+ switch (i) {
-+ case TV_ML_ACCEPT:
-+ setCodingSpec(cs->tv, &cs->tcs);
-+ break;
-+ case TV_ML_CLOSE:
-+ closeCsWin(cs->tv);
-+ break;
-+ }
-+ }
-+ }
-+ return 1;
-+ }
-+ for (cbp = cs->cbt, i = 0; i < TV_ML_NCBUTTS; cbp++, i++) {
-+ if (CBClick(cbp, x, y) && CBTrack(cbp))
-+ break;
-+ }
-+ if (i < TV_ML_NCBUTTS) {
-+ switch (i) {
-+ case TV_ML_SHORT:
-+ cs->tcs.coding_system.short_form = cbp->val;
-+ break;
-+ case TV_ML_LOCK:
-+ cs->tcs.coding_system.lock_shift = cbp->val;
-+ break;
-+ }
-+ return 1;
-+ }
-+ for (rbp = cs->rbt, i = 0; i < TV_ML_NRBUTTS; rbp++, i++) {
-+ if ((n = RBClick(*rbp, x, y)) >= 0 && RBTrack(*rbp, n)) {
-+ break;
-+ }
-+ }
-+ if (i < TV_ML_NRBUTTS) {
-+ switch (i) {
-+ case TV_ML_RETCODE:
-+ cs->tcs.coding_system.eol = n;
-+ break;
-+ case TV_ML_GL:
-+ cs->tcs.coding_system.gl = n;
-+ break;
-+ case TV_ML_GR:
-+ cs->tcs.coding_system.gr = n;
-+ break;
-+ case TV_ML_CVTR:
-+ cs->tcs.converter = cvtrtab[n];
-+ break;
-+ }
-+ return 1;
-+ }
-+ } else {
-+ for (ls = cs->ls, i = 0; i < TV_ML_NLISTS; ls++, i++) {
-+ if (ls->win == e->window) {
-+ LSClick(ls, e);
-+ n = ls->selected;
-+ if (n < nregs) {
-+ char r[32], *p = r;
-+ int b7;
-+ strcpy(r, regs[n]);
-+ if ((p = strrchr(r, '/')) != NULL) {
-+ *p = '\0';
-+ b7 = (*(p + 1) == 'R' ? 1 : 0);
-+ } else
-+ b7 = 0; /* shouldn't occur */
-+ cs->tcs.coding_system.design[i] = lookup_design(r, b7);
-+ } else if (n == nregs) /* initially none is designed. */
-+ cs->tcs.coding_system.design[i].bpc = 0;
-+ else
-+ cs->tcs.coding_system.design[i].bpc = -1;
-+ return 1;
-+ }
-+ }
-+ for (ls = cs->ls, i = 0; i < TV_ML_NLISTS; ls++, i++) {
-+ if (ls->scrl.win == e->window) {
-+ SCTrack(&ls->scrl, x, y);
-+ return 1;
-+ }
-+ }
-+ }
-+ }
-+ return 0;
-+}
-+
-+static void csReflect(cs)
-+ CSINFO *cs;
-+{
-+ int i;
-+
-+ RBSelect(cs->rbt[TV_ML_RETCODE], cs->tcs.coding_system.eol);
-+ RBSelect(cs->rbt[TV_ML_GL], cs->tcs.coding_system.gl);
-+ RBSelect(cs->rbt[TV_ML_GR], cs->tcs.coding_system.gr);
-+ for (i = 0; i < sizeof cvtrtab / sizeof cvtrtab[0]; i++) {
-+ if (cs->tcs.converter == cvtrtab[i])
-+ break;
-+ }
-+ if (i >= sizeof cvtrtab / sizeof cvtrtab[0])
-+ FatalError("program error in csReflect().");
-+ RBSelect(cs->rbt[TV_ML_CVTR], i);
-+
-+ cs->cbt[TV_ML_SHORT].val = cs->tcs.coding_system.short_form;
-+ cs->cbt[TV_ML_LOCK].val = cs->tcs.coding_system.lock_shift;
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ struct design design = cs->tcs.coding_system.design[i];
-+ char *reg, r[32];
-+ int b7;
-+ int n = 0;
-+ switch (design.bpc) {
-+ case -1:
-+ n = nregs + 1;
-+ break;
-+ case 0:
-+ n = nregs;
-+ break;
-+ case 1:
-+ case 2:
-+ if ((reg = lookup_registry(design, &b7)) == NULL)
-+ FatalError("internal error in csReflect.");
-+ sprintf(r, "%s/%s", reg, b7 ? "Right" : "Left");
-+ for (n = 0; n < nregs; n++) {
-+ if (strcmp(regs[n], r) == 0)
-+ break;
-+ }
-+ }
-+ cs->ls[i].selected = n;
-+ ScrollToCurrent(&cs->ls[i]);
-+ }
-+ csRedraw(cs);
-+ for (i = 0; i < TV_ML_NLISTS; i++)
-+ csListRedraw(&cs->ls[i]);
-+}
-+
-+static void csRedraw(cs)
-+ CSINFO *cs;
-+{
-+ int i;
-+
-+ XSetForeground(theDisp, theGC, infofg);
-+ DrawString(cs->win, 5,5 + ASCENT, "Initial States");
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ int x, y;
-+ char buf[80];
-+
-+ if (i / 2 == 0)
-+ x = 15;
-+ else
-+ x = 280;
-+ if (i % 2 == 0)
-+ y = 5 + LINEHIGH * 1;
-+ else
-+ y = 5 + LINEHIGH * 7 + SPACING * 3;
-+
-+ sprintf(buf, "Designation for G%d:", i);
-+ DrawString(cs->win, x, y + ASCENT, buf);
-+ }
-+
-+ DrawString(cs->win, 15, 235 + ASCENT, "Invocation for GL:");
-+ DrawString(cs->win, 280, 235 + ASCENT, "Invocation for GR:");
-+ DrawString(cs->win, 5, 280 + ASCENT, "Ret Code:");
-+ DrawString(cs->win, 350, 280 + ASCENT, "Converter:");
-+
-+ for (i = 0; i < TV_ML_NBUTTS; i++)
-+ BTRedraw(&cs->bt[i]);
-+ for (i = 0; i < TV_ML_NCBUTTS; i++)
-+ CBRedraw(&cs->cbt[i]);
-+ for (i = 0; i < TV_ML_NRBUTTS; i++)
-+ RBRedraw(cs->rbt[i], -1);
-+}
-+
-+static void csListRedraw(ls)
-+ LIST *ls;
-+{
-+ int i;
-+ for (i = 0; i < TV_ML_NLISTS; i++) {
-+ LSRedraw(ls, 0);
-+ SCRedraw(&ls->scrl);
-+ }
-+}
-+
-+static void csLsRedraw(delta, sptr)
-+ int delta;
-+ SCRL *sptr;
-+{
-+ int i, j;
-+ for (i = 0; i < MAXTVWIN; i++) {
-+ for (j = 0; j < TV_ML_NLISTS; j++) {
-+ if (sptr == &csinfo[i].ls[j].scrl) {
-+ LSRedraw(&csinfo[i].ls[j], delta);
-+ return;
-+ }
-+ }
-+ }
-+}
-+
-+int CharsetDelWin(win)
-+ Window win;
-+{
-+ CSINFO *cs;
-+ int i;
-+
-+ for (cs = csinfo, i = 0; i < TV_NCSS; cs++, i++) {
-+ if (cs->win == win) {
-+ if (cs->up) {
-+ XUnmapWindow(theDisp, cs->win);
-+ cs->up = 0;
-+ }
-+ return 1;
-+ }
-+ }
-+ return 0;
-+}
-+
-+static int reg_comp PARM((const void *, const void *));
-+static void create_registry_list()
-+{
-+ struct design d;
-+ char *names, *p;
-+ int i;
-+
-+ if ((p = names = (char *) malloc(32 * 0x80 * 2 * 2)) == NULL)
-+ FatalError("out of memory in create_name_list#1.");
-+ nregs = 0;
-+ for (d.bpc = 1; d.bpc <=2; d.bpc++) {
-+ for (d.noc = 94; d.noc <= 96; d.noc += 2) {
-+ for (d.des = ' '; (unsigned char) d.des < 0x80; d.des++) {
-+ int b7;
-+ char *r;
-+ if ((r = lookup_registry(d, &b7)) != NULL) {
-+ sprintf(p, "%s/%s", r, b7 ? "Right" : "Left");
-+ p += strlen(p) + 1;
-+ nregs++;
-+ }
-+ }
-+ }
-+ }
-+ if ((names = (char *) realloc(names, (size_t) (p - names))) == NULL)
-+ FatalError("out of memory in create_name_list#2.");
-+ if ((regs = (char **) malloc(sizeof(char *) * (nregs + 3))) == NULL)
-+ FatalError("out of memory in create_name_list#3.");
-+ p = names;
-+ for (i = 0; i < nregs; i++) {
-+ regs[i] = p;
-+ p += strlen(p) + 1;
-+ }
-+ qsort(regs, (size_t) nregs, sizeof(char *), reg_comp);
-+ regs[i++] = "nothing";
-+ regs[i++] = "unused";
-+ regs[i++] = NULL;
-+}
-+static int reg_comp(dst, src)
-+ const void *dst, *src;
-+{
-+ return strcmp(*(char **) dst, *(char **) src);
-+}
-
-+#endif /* TV_MULTILINGUAL */
-diff -ruN xv-3.10a-bugfixes/xvtiff.c xv-3.10a-enhancements/xvtiff.c
---- xv-3.10a-bugfixes/xvtiff.c 2005-03-27 17:25:31.000000000 -0800
-+++ xv-3.10a-enhancements/xvtiff.c 2005-04-17 14:11:55.000000000 -0700
-@@ -512,7 +512,7 @@
- vsprintf(cp, fmt, ap);
- strcat(cp, ".");
-
-- SetISTR(ISTR_WARNING,buf);
-+ SetISTR(ISTR_WARNING, "%s", buf);
-
- error_occurred = 1;
- }
-@@ -536,7 +536,7 @@
- vsprintf(cp, fmt, ap);
- strcat(cp, ".");
-
-- SetISTR(ISTR_WARNING,buf);
-+ SetISTR(ISTR_WARNING, "%s", buf);
- }
-
-
-@@ -564,6 +564,10 @@
- static byte **BWmap;
- static byte **PALmap;
-
-+/* XXXX Work around some collisions with the new library. */
-+#define tileContigRoutine _tileContigRoutine
-+#define tileSeparateRoutine _tileSeparateRoutine
-+
- typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
- uint32, uint32, int, int));
-
-@@ -603,7 +607,7 @@
- uint32, uint32, int, int));
- static void put4bitbwtile PARM((byte *, u_char *, RGBvalue *,
- uint32, uint32, int, int));
--static void put16bitbwtile PARM((byte *, u_char *, RGBvalue *,
-+static void put16bitbwtile PARM((byte *, u_short *, RGBvalue *,
- uint32, uint32, int, int));
-
- static void putRGBcontig8bittile PARM((byte *, u_char *, RGBvalue *,
-@@ -653,7 +657,7 @@
-
- default:
- TIFFError(TIFFFileName(tif),
-- "Sorry, can not handle %d-bit pictures", bitspersample);
-+ "Sorry, cannot handle %d-bit pictures", bitspersample);
- return (0);
- }
-
-@@ -666,7 +670,7 @@
-
- default:
- TIFFError(TIFFFileName(tif),
-- "Sorry, can not handle %d-channel images", samplesperpixel);
-+ "Sorry, cannot handle %d-channel images", samplesperpixel);
- return (0);
- }
-
-@@ -1157,7 +1161,7 @@
- b = g + stripsize;
- put = pickTileSeparateCase(Map);
- if (put == 0) {
-- TIFFError(filename, "Can not handle format");
-+ TIFFError(filename, "Cannot handle format");
- return (0);
- }
- y = setorientation(tif, h);
-@@ -1197,7 +1201,7 @@
- /*
- * Greyscale images with less than 8 bits/sample are handled
- * with a table to avoid lots of shifts and masks. The table
-- * is setup so that put*bwtile (below) can retrieve 8/bitspersample
-+ * is set up so that put*bwtile (below) can retrieve 8/bitspersample
- * pixel values simply by indexing into the table with one
- * number.
- */
-@@ -1249,11 +1253,11 @@
-
-
- /*
-- * Palette images with <= 8 bits/sample are handled
-- * with a table to avoid lots of shifts and masks. The table
-- * is setup so that put*cmaptile (below) can retrieve 8/bitspersample
-- * pixel values simply by indexing into the table with one
-- * number.
-+ * Palette images with <= 8 bits/sample are handled with
-+ * a table to avoid lots of shifts and masks. The table
-+ * is set up so that put*cmaptile (below) can retrieve
-+ * (8/bitspersample) pixel-values simply by indexing into
-+ * the table with one number.
- */
- static int makecmap()
- {
-@@ -1305,7 +1309,7 @@
- /*
- * The following routines move decoded data returned
- * from the TIFF library into rasters filled with packed
-- * ABGR pixels (i.e. suitable for passing to lrecwrite.)
-+ * ABGR pixels (i.e., suitable for passing to lrecwrite.)
- *
- * The routines have been created according to the most
- * important cases and optimized. pickTileContigCase and
-@@ -1376,7 +1380,7 @@
- int fromskew, toskew;
- {
- while (h-- > 0) {
-- UNROLL8(w, , *cp++ = PALmap[*pp++][0])
-+ UNROLL8(w, , *cp++ = PALmap[*pp++][0]);
- cp += toskew;
- pp += fromskew;
- }
-@@ -1529,7 +1533,7 @@
- */
- static void put16bitbwtile(cp, pp, Map, w, h, fromskew, toskew)
- byte *cp;
-- u_char *pp;
-+ u_short *pp;
- RGBvalue *Map;
- uint32 w, h;
- int fromskew, toskew;
-@@ -1538,8 +1542,7 @@
-
- while (h-- > 0) {
- for (x=w; x>0; x--) {
-- *cp++ = Map[(pp[0] << 8) + pp[1]];
-- pp += 2;
-+ *cp++ = Map[*pp++];
- }
- cp += toskew;
- pp += fromskew;
-@@ -1577,7 +1580,7 @@
- *cp++ = pp[0];
- *cp++ = pp[1];
- *cp++ = pp[2];
-- pp += samplesperpixel)
-+ pp += samplesperpixel);
- cp += toskew;
- pp += fromskew;
- }
-@@ -1650,7 +1653,7 @@
- *cp++ = *r++;
- *cp++ = *g++;
- *cp++ = *b++;
-- )
-+ );
- SKEW(r, g, b, fromskew);
- cp += toskew;
- }
-@@ -1857,7 +1860,7 @@
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- switch (bitspersample) {
-- case 16: put = put16bitbwtile; break;
-+ case 16: put = (tileContigRoutine) put16bitbwtile; break;
- case 8: put = putgreytile; break;
- case 4: put = put4bitbwtile; break;
- case 2: put = put2bitbwtile; break;
-@@ -1872,7 +1875,7 @@
- break;
- }
-
-- if (put==0) TIFFError(filename, "Can not handle format");
-+ if (put==0) TIFFError(filename, "Cannot handle format");
- return (put);
- }
-
-@@ -1880,8 +1883,8 @@
- /*
- * Select the appropriate conversion routine for unpacked data.
- *
-- * NB: we assume that unpacked single channel data is directed
-- * to the "packed routines.
-+ * NB: we assume that unpacked single-channel data is directed
-+ * to the "packed" routines.
- */
- static tileSeparateRoutine pickTileSeparateCase(Map)
- RGBvalue* Map;
-@@ -1897,10 +1900,32 @@
- break;
- }
-
-- if (put==0) TIFFError(filename, "Can not handle format");
-+ if (put==0) TIFFError(filename, "Cannot handle format");
- return (put);
- }
-
-
-
-+/*******************************************/
-+void
-+VersionInfoTIFF() /* GRR 19980605 */
-+{
-+ char temp[1024], *p, *q;
-+
-+ strcpy(temp, TIFFGetVersion());
-+ p = temp;
-+ while (!isdigit(*p))
-+ ++p;
-+ if ((q = strchr(p, '\n')) != NULL)
-+ *q = '\0';
-+
-+ fprintf(stderr, " Compiled with libtiff %s", p);
-+#ifdef TIFFLIB_VERSION
-+ fprintf(stderr, " of %d", TIFFLIB_VERSION); /* e.g., 19960307 */
-+#endif
-+ fprintf(stderr, ".\n");
-+}
-+
-+
-+
- #endif /* HAVE_TIFF */
-diff -ruN xv-3.10a-bugfixes/xvtiffwr.c xv-3.10a-enhancements/xvtiffwr.c
---- xv-3.10a-bugfixes/xvtiffwr.c 2005-03-28 08:39:52.000000000 -0800
-+++ xv-3.10a-enhancements/xvtiffwr.c 2005-04-17 14:45:28.000000000 -0700
-@@ -86,6 +86,9 @@
- TIFFSetField(tif, TIFFTAG_GROUP3OPTIONS,
- GROUP3OPT_2DENCODING+GROUP3OPT_FILLBITS);
-
-+ if (comp == COMPRESSION_LZW)
-+ TIFFSetField(tif, TIFFTAG_PREDICTOR, 2);
-+
- TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
- TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-diff -ruN xv-3.10a-bugfixes/xvvd.c xv-3.10a-enhancements/xvvd.c
---- xv-3.10a-bugfixes/xvvd.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvvd.c 2005-04-17 22:56:02.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvvd.c xv-3.10a/xvvd.c
+--- xv-3.10a.orig/xvvd.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvvd.c 2007-04-15 23:30:19.000000000 -0500
@@ -0,0 +1,1101 @@
+
+/*
@@ -27437,10 +18039,10 @@ diff -ruN xv-3.10a-bugfixes/xvvd.c xv-3.10a-enhancements/xvvd.c
+ (void)XSetIOErrorHandler(vd_XIOhandler);
+}
+#endif /* AUTO_EXPAND */
-diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
---- xv-3.10a-bugfixes/xvwbmp.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvwbmp.c 2005-04-03 14:02:18.000000000 -0700
-@@ -0,0 +1,323 @@
+diff -u -r --new-file xv-3.10a.orig/xvwbmp.c xv-3.10a/xvwbmp.c
+--- xv-3.10a.orig/xvwbmp.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvwbmp.c 2007-04-15 23:38:05.000000000 -0500
+@@ -0,0 +1,345 @@
+/*
+ * xvwbmp.c - i/o routings for WBMP files
+ * defined by OMA (http://www.openmobilealliance.com)
@@ -27470,9 +18072,8 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+#endif
+
+#define MUST(a) if (!(a)) {\
-+ return fail(st_fname, st_err);\
+ close(fd); \
-+ }
++ return fail(st_fname, st_err); }
+#define READU8(fd,u) if ((read(fd, &u, 1)<1)) {\
+ myfree(); \
+ close(fd); \
@@ -27491,26 +18092,29 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ return 0; \
+ }
+
-+static char * err_ueof = "Unexpected EOF";
-+static char * err_unst = "Unsupported image type";
-+static char * err_extf = "Extensions are forbidden";
-+static char * err_inmb = "Invalid multibyte integer";
++static const char err_ueof[] = "Unexpected EOF";
++static const char err_unst[] = "Unsupported image type";
++static const char err_extf[] = "Extensions are forbidden";
++static const char err_inmb[] = "Invalid multibyte integer";
+
-+static char * st_fname;
-+static char * st_err;
++static const char *st_fname;
++static const char *st_err;
+
-+static int fail PARM((char *, char *));
-+static int read_mb PARM((int *, int));
-+static void write_mb PARM((uint32, FILE *));
-+static int read_ext PARM((int, uint8));
-+static void * mymalloc PARM((int));
-+static void myfree PARM((void));
-+static uint8 * render1 PARM((uint8 *, int, int));
++static int fail PARM((const char *, const char *));
++static int read_mb PARM((int *, int));
++static void write_mb PARM((uint32, FILE *));
++static int read_ext PARM((int, uint8));
++static void *mymalloc PARM((int));
++static void myfree PARM((void));
++static uint8 *render1 PARM((uint8 *, int, int));
+
-+void ** mymem = NULL;
-+int mymems = 0;
++static void **mymem = NULL;
++static int mymems = 0;
+
-+int LoadWBMP(char * fname, PICINFO * pinfo)
++
++int LoadWBMP(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
+{
+ int fd;
+ int im_type; /* image type (only type 0 supported) */
@@ -27582,9 +18186,13 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ return 1;
+}
+
-+int WriteWBMP(FILE * fp, byte * pic, int ptype, int w, int h,
-+ byte * rmap, byte *gmap, byte *bmap,
-+ int numcols, int colorstyle)
++
++int WriteWBMP(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle)
++ FILE *fp;
++ byte *pic;
++ int ptype, w, h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
+{
+ int count = 0;
+ uint8 bit = 0;
@@ -27612,13 +18220,18 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ return 0;
+}
+
-+int fail(char * name, char * msg)
++
++static int fail(name, msg)
++ const char *name, *msg;
+{
+ SetISTR(ISTR_WARNING, "%s : %s", name, msg);
+ return 0;
+}
+
-+void write_mb(uint32 data, FILE * f)
++
++static void write_mb(data, f)
++ uint32 data;
++ FILE *f;
+{
+ int i = 32;
+ uint32 aux = data;
@@ -27650,7 +18263,9 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+
+}
+
-+int read_mb(int * dst, int fd)
++
++static int read_mb(dst, fd)
++ int *dst, fd;
+{
+ int ac = 0;
+ int ct = 0;
@@ -27674,7 +18289,10 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ return 1;
+}
+
-+int read_ext(int fd, uint8 fixed)
++
++static int read_ext(fd, fixed)
++ int fd;
++ uint8 fixed;
+{
+ if (!(fixed&0x7f)) { /* no extensions */
+ return 1;
@@ -27712,15 +18330,18 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ */
+}
+
-+void * mymalloc(int l)
++
++static void *mymalloc(numbytes)
++ int numbytes;
+{
+ mymem = (void**)realloc(mymem, mymems+1);
+ if (!mymem)
+ FatalError("LoadWBMP: can't realloc buffer");
-+ return (mymem[mymems++] = malloc(l));
++ return (mymem[mymems++] = malloc(numbytes));
+}
+
-+void myfree()
++
++static void myfree()
+{
+ int i;
+
@@ -27735,7 +18356,10 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ mymems = 0;
+}
+
-+uint8 * render1(uint8 * data, int size, int npixels)
++
++static uint8 *render1(data, size, npixels)
++ uint8 *data;
++ int size, npixels;
+{
+ byte * pic;
+ int i;
@@ -27764,57 +18388,9 @@ diff -ruN xv-3.10a-bugfixes/xvwbmp.c xv-3.10a-enhancements/xvwbmp.c
+ }
+ return pic;
+}
-diff -ruN xv-3.10a-bugfixes/xvxpm.c xv-3.10a-enhancements/xvxpm.c
---- xv-3.10a-bugfixes/xvxpm.c 2005-03-28 22:22:50.000000000 -0800
-+++ xv-3.10a-enhancements/xvxpm.c 2005-04-17 14:45:28.000000000 -0700
-@@ -175,7 +175,15 @@
-
- do {
- char key[3];
-- char color[40]; /* Need to figure a good size for this... */
-+ char color[80]; /* Need to figure a good size for this... */
-+
-+/*
-+ * Problem with spaces in color names
-+ *
-+ * X s Color Name m Other Name c Last Name
-+ *
-+ * ... this parser doesn't find `Any Name'
-+ */
-
- for (j=0; j<2 && (c != ' ') && (c != '\t') && (c != EOF); j++) {
- key[j] = c;
-@@ -187,7 +195,7 @@
- if (c == EOF) /* The failure condition of getc() */
- return (XpmLoadError(bname, "Error parsing colormap line"));
-
-- for (j=0; j<39 && (c!=' ') && (c!='\t') && (c!='"') && c!=EOF; j++) {
-+ for (j=0; j<79 && (c!=' ') && (c!='\t') && (c!='"') && c!=EOF; j++) {
- color[j] = c;
- c = XpmGetc(fp);
- }
-@@ -248,7 +256,7 @@
- else { /* 'None' or unrecognized color spec */
- int rgb;
-
-- if (strcmp(color, "None") == 0) rgb = 0xb2c0dc; /* infobg */
-+ if (strcasecmp(color, "None") == 0) rgb = 0xb2c0dc; /* infobg */
- else {
- SetISTR(ISTR_INFO, "%s: unknown color spec '%s'", bname, color);
- Timer(1000);
-@@ -321,7 +329,8 @@
- *i_sptr++ = mapentry->cv_rgb[2];
- }
- } /* for ( j < w ) */
-- (void)XpmGetc(fp); /* Throw away the close " */
-+ while (((c = XpmGetc(fp))!=EOF) && /* Throw away the close " and */
-+ (c != '"')); /* erase all remaining pixels */
-
- if (!(i%7)) WaitCursor();
- } /* for ( i < h ) */
-diff -ruN xv-3.10a-bugfixes/xvzx.c xv-3.10a-enhancements/xvzx.c
---- xv-3.10a-bugfixes/xvzx.c 1969-12-31 16:00:00.000000000 -0800
-+++ xv-3.10a-enhancements/xvzx.c 2004-05-16 18:08:33.000000000 -0700
+diff -u -r --new-file xv-3.10a.orig/xvzx.c xv-3.10a/xvzx.c
+--- xv-3.10a.orig/xvzx.c 1969-12-31 18:00:00.000000000 -0600
++++ xv-3.10a/xvzx.c 2007-05-13 19:53:46.000000000 -0500
@@ -0,0 +1,349 @@
+/*
+ * xvzx.c - load routine for Spectrum screen$
@@ -27842,9 +18418,9 @@ diff -ruN xv-3.10a-bugfixes/xvzx.c xv-3.10a-enhancements/xvzx.c
+
+#define TRUNCSTR "File appears to be truncated."
+
-+static int zxError PARM((char *, char *));
++static int zxError PARM((const char *, const char *));
+
-+static char *bname;
++static const char *bname;
+
+/*******************************************/
+int LoadZX(fname, pinfo)
@@ -27971,7 +18547,7 @@ diff -ruN xv-3.10a-bugfixes/xvzx.c xv-3.10a-enhancements/xvzx.c
+
+/*******************************************/
+static int zxError(fname, st)
-+ char *fname, *st;
++ const char *fname, *st;
+{
+ SetISTR(ISTR_WARNING,"%s: %s", fname, st);
+ return 0;
@@ -27983,12 +18559,12 @@ diff -ruN xv-3.10a-bugfixes/xvzx.c xv-3.10a-enhancements/xvzx.c
+
+byte ZXheader[128] =
+{
-+ 'P', 'L', 'U', 'S', '3', 'D', 'O', 'S', 26, /* Spectrum +3DOS file */
-+ 1, 0, /* Header type 1.0 */
-+ 128, 27, 0, 0, /* 7040 bytes */
-+ 3, /* Binary format */
-+ 0, 27, /* 6912 data bytes */
-+ 0, 64 /* load address 0x4000 */
++ 'P', 'L', 'U', 'S', '3', 'D', 'O', 'S', 26, /* Spectrum +3DOS file */
++ 1, 0, /* Header type 1.0 */
++ 128, 27, 0, 0, /* 7040 bytes */
++ 3, /* Binary format */
++ 0, 27, /* 6912 data bytes */
++ 0, 64 /* load address 0x4000 */
+};
+
+