summaryrefslogtreecommitdiff
path: root/source/xap
diff options
context:
space:
mode:
Diffstat (limited to 'source/xap')
-rwxr-xr-xsource/xap/MPlayer/MPlayer.SlackBuild407
-rw-r--r--source/xap/MPlayer/slack-desc19
-rw-r--r--source/xap/audacious-plugins/amidi-plug.fix-drct.diff11
-rwxr-xr-xsource/xap/audacious-plugins/audacious-plugins.SlackBuild128
-rw-r--r--source/xap/audacious-plugins/audacious-plugins.libmtp8.diff16
-rw-r--r--source/xap/audacious-plugins/slack-desc19
-rwxr-xr-xsource/xap/audacious/audacious.SlackBuild132
-rw-r--r--source/xap/audacious/audacious.handle_cmd_line_options.diff38
-rw-r--r--source/xap/audacious/slack-desc19
-rwxr-xr-xsource/xap/blackbox/blackbox.SlackBuild143
-rw-r--r--source/xap/blackbox/blackbox_0.65.0-5.diff12462
-rw-r--r--source/xap/blackbox/slack-desc19
-rw-r--r--source/xap/blackbox/xinitrc.blackbox28
-rw-r--r--source/xap/electricsheep/README.slackware29
-rwxr-xr-xsource/xap/electricsheep/electricsheep.SlackBuild266
-rw-r--r--source/xap/electricsheep/electricsheep.mplayer.diff12
-rw-r--r--source/xap/electricsheep/electricsheep_gnome-open.patch13
-rw-r--r--source/xap/electricsheep/slack-desc19
-rwxr-xr-xsource/xap/fluxbox/fluxbox.SlackBuild90
-rw-r--r--source/xap/fluxbox/slack-desc19
-rw-r--r--source/xap/fluxbox/xinitrc.fluxbox28
-rw-r--r--source/xap/fvwm/doinst.sh13
-rwxr-xr-xsource/xap/fvwm/fvwm.SlackBuild127
-rw-r--r--source/xap/fvwm/fvwm.colormap.diff20
-rw-r--r--source/xap/fvwm/slack-desc19
-rw-r--r--source/xap/fvwm/system.fvwm2rc822
-rw-r--r--source/xap/fvwm/xinitrc.fvwm230
-rwxr-xr-xsource/xap/gftp/gftp.SlackBuild94
-rw-r--r--source/xap/gftp/gftp.desktop16
-rw-r--r--source/xap/gftp/slack-desc19
-rwxr-xr-xsource/xap/gimp/gimp.SlackBuild105
-rw-r--r--source/xap/gimp/slack-desc19
-rwxr-xr-xsource/xap/gkrellm/gkrellm.SlackBuild117
-rw-r--r--source/xap/gkrellm/gkrellm.theme.defaults.diff11
-rw-r--r--source/xap/gkrellm/slack-desc19
-rw-r--r--source/xap/gnuchess/chess.pngbin0 -> 652 bytes
-rw-r--r--source/xap/gnuchess/eboard.desktop10
-rwxr-xr-xsource/xap/gnuchess/gnuchess.SlackBuild176
-rw-r--r--source/xap/gnuchess/gnuchess.SlackBuild.diff89
-rw-r--r--source/xap/gnuchess/gnuchess.gcc4_fix.diff11
-rw-r--r--source/xap/gnuchess/slack-desc19
-rw-r--r--source/xap/gnuchess/xboard.buffer_overflow_fix.diff95
-rw-r--r--source/xap/gnuchess/xboard.desktop10
-rw-r--r--source/xap/gnuchess/xboard.infodir.diff11
-rwxr-xr-xsource/xap/gnuplot/gnuplot.SlackBuild115
-rw-r--r--source/xap/gnuplot/slack-desc19
-rw-r--r--source/xap/gqview/doinst.sh7
-rwxr-xr-xsource/xap/gqview/gqview.SlackBuild103
-rw-r--r--source/xap/gqview/slack-desc19
-rw-r--r--source/xap/gucharmap/doinst.sh4
-rwxr-xr-xsource/xap/gucharmap/gucharmap.SlackBuild92
-rw-r--r--source/xap/gucharmap/slack-desc19
-rwxr-xr-xsource/xap/gv/gv.SlackBuild113
-rw-r--r--source/xap/gv/slack-desc19
-rwxr-xr-xsource/xap/gxine/gxine.SlackBuild99
-rw-r--r--source/xap/gxine/gxine.desktop14
-rw-r--r--source/xap/gxine/slack-desc19
-rwxr-xr-xsource/xap/imagemagick/imagemagick.SlackBuild140
-rw-r--r--source/xap/imagemagick/slack-desc19
-rw-r--r--source/xap/mozilla-firefox/firefox.moz_plugin_path.diff17
-rw-r--r--source/xap/mozilla-firefox/firefox.pngbin0 -> 24263 bytes
-rw-r--r--source/xap/mozilla-firefox/mimeTypes.rdf28
-rw-r--r--source/xap/mozilla-firefox/mozilla-firefox-mimeTypes-fix.diff45
-rwxr-xr-xsource/xap/mozilla-firefox/mozilla-firefox.SlackBuild184
-rw-r--r--source/xap/mozilla-firefox/mozilla-firefox.desktop80
-rw-r--r--source/xap/mozilla-firefox/slack-desc19
-rw-r--r--source/xap/mozilla-thunderbird/mozilla-thunderbird-firefox.diff11
-rwxr-xr-xsource/xap/mozilla-thunderbird/mozilla-thunderbird.SlackBuild141
-rw-r--r--source/xap/mozilla-thunderbird/mozilla-thunderbird.desktop84
-rw-r--r--source/xap/mozilla-thunderbird/slack-desc19
-rw-r--r--source/xap/mozilla-thunderbird/thunderbird.pngbin0 -> 2980 bytes
-rwxr-xr-xsource/xap/pan/pan.SlackBuild113
-rw-r--r--source/xap/pan/slack-desc19
-rwxr-xr-xsource/xap/pidgin/pidgin.SlackBuild192
-rw-r--r--source/xap/pidgin/purple-allow-sign-rsa-md5.patch12
-rw-r--r--source/xap/pidgin/slack-desc19
-rwxr-xr-xsource/xap/rdesktop/rdesktop.SlackBuild106
-rw-r--r--source/xap/rdesktop/slack-desc19
-rwxr-xr-xsource/xap/rxvt/rxvt.SlackBuild101
-rw-r--r--source/xap/rxvt/rxvt.utempter.diff277
-rw-r--r--source/xap/rxvt/slack-desc19
-rw-r--r--source/xap/sane/dll.conf.additions3
-rw-r--r--source/xap/sane/doinst.sh15
-rwxr-xr-xsource/xap/sane/sane.SlackBuild145
-rw-r--r--source/xap/sane/slack-desc19
-rw-r--r--source/xap/seamonkey/doinst.sh11
-rw-r--r--source/xap/seamonkey/seamonkey-icon.pngbin0 -> 12796 bytes
-rw-r--r--source/xap/seamonkey/seamonkey-mail-icon.pngbin0 -> 185 bytes
-rw-r--r--source/xap/seamonkey/seamonkey-mail.desktop8
-rwxr-xr-xsource/xap/seamonkey/seamonkey.SlackBuild233
-rw-r--r--source/xap/seamonkey/seamonkey.desktop8
-rw-r--r--source/xap/seamonkey/seamonkey.moz_plugin_path.diff16
-rw-r--r--source/xap/seamonkey/slack-desc19
-rw-r--r--source/xap/seyon/seyon-2.20c.lsm16
-rwxr-xr-xsource/xap/seyon/seyon.SlackBuild112
-rw-r--r--source/xap/seyon/seyon_2.20c-16.diff5031
-rw-r--r--source/xap/seyon/slack-desc19
-rw-r--r--source/xap/thunar-volman/slack-desc19
-rwxr-xr-xsource/xap/thunar-volman/thunar-volman.SlackBuild84
l---------source/xap/vim-gvim1
-rw-r--r--source/xap/windowmaker/slack-desc19
-rwxr-xr-xsource/xap/windowmaker/windowmaker.SlackBuild120
-rw-r--r--source/xap/windowmaker/windowmaker.no-mmx.diff19
-rw-r--r--source/xap/windowmaker/wmaker.inst.diff45
-rw-r--r--source/xap/windowmaker/xinitrc.wmaker38
-rw-r--r--source/xap/x11-ssh-askpass/README10
-rw-r--r--source/xap/x11-ssh-askpass/slack-desc19
-rwxr-xr-xsource/xap/x11-ssh-askpass/x11-ssh-askpass.SlackBuild67
-rw-r--r--source/xap/x11-ssh-askpass/x11-ssh-askpass.info10
-rw-r--r--source/xap/x11-ssh-askpass/xprofile.sample14
-rw-r--r--source/xap/x3270/doinst.sh24
-rw-r--r--source/xap/x3270/slack-desc19
-rwxr-xr-xsource/xap/x3270/x3270.SlackBuild89
-rw-r--r--source/xap/xchat/patches/patches.url1
-rw-r--r--source/xap/xchat/patches/xc286-smallfixes.diff68
-rw-r--r--source/xap/xchat/patches/xchat.gtk_2_14.diff191
-rw-r--r--source/xap/xchat/slack-desc19
-rwxr-xr-xsource/xap/xchat/xchat.SlackBuild114
-rw-r--r--source/xap/xfce/patches/exo_quoting_fix.diff66
-rw-r--r--source/xap/xfce/patches/launcher-plugin-migrate-icon-cat.diff48
-rw-r--r--source/xap/xfce/patches/migrate-itheme-smartly.diff92
-rw-r--r--source/xap/xfce/patches/terminal-0.4.0-fixup_docdir.diff132
-rw-r--r--source/xap/xfce/patches/thunar-1.0.1-fixup_docdir.diff360
-rw-r--r--source/xap/xfce/patches/xfcalendar.desktop.in.diff9
-rw-r--r--source/xap/xfce/patches/xfdesktop-fix_education_icon.diff11
-rwxr-xr-xsource/xap/xfce/profile.d/xfce.csh6
-rwxr-xr-xsource/xap/xfce/profile.d/xfce.sh7
-rw-r--r--source/xap/xfce/slack-desc19
-rwxr-xr-xsource/xap/xfce/xfce.SlackBuild201
-rw-r--r--source/xap/xfce4-power-manager/doinst.sh10
-rw-r--r--source/xap/xfce4-power-manager/slack-desc19
-rwxr-xr-xsource/xap/xfce4-power-manager/xfce4-power-manager.SlackBuild91
-rw-r--r--source/xap/xfractint/slack-desc19
-rwxr-xr-xsource/xap/xfractint/xfractint.SlackBuild109
-rw-r--r--source/xap/xgames/maze.diff22
-rw-r--r--source/xap/xgames/slack-desc19
-rw-r--r--source/xap/xgames/spider.diff121
-rw-r--r--source/xap/xgames/xcolormap.diff22
-rw-r--r--source/xap/xgames/xcuckoo.diff12
-rwxr-xr-xsource/xap/xgames/xgames.SlackBuild154
-rw-r--r--source/xap/xgames/xlander-2009-07-18.diff86
-rw-r--r--source/xap/xgames/xlander.fixes.diff228
-rw-r--r--source/xap/xine-lib/slack-desc19
-rwxr-xr-xsource/xap/xine-lib/xine-lib.SlackBuild98
-rw-r--r--source/xap/xine-ui/slack-desc19
-rwxr-xr-xsource/xap/xine-ui/xine-ui.SlackBuild87
-rw-r--r--source/xap/xine-ui/xine.desktop14
-rw-r--r--source/xap/xlockmore/l-bob.README5
-rw-r--r--source/xap/xlockmore/l-bob.xbm364
-rw-r--r--source/xap/xlockmore/l-linux.xbm205
-rw-r--r--source/xap/xlockmore/s-bob.xbm94
-rw-r--r--source/xap/xlockmore/slack-desc19
-rwxr-xr-xsource/xap/xlockmore/xlockmore.SlackBuild108
-rw-r--r--source/xap/xlockmore/xlockmore.bitmap.diff20
-rw-r--r--source/xap/xmms/slack-desc19
-rwxr-xr-xsource/xap/xmms/xmms.SlackBuild98
-rw-r--r--source/xap/xmms/xmms.desktop13
-rw-r--r--source/xap/xmms/xmms.gtk.doublesize.diff11
-rw-r--r--source/xap/xmms/xmms.wmxmms_vis_depth_workaround.diff11
-rw-r--r--source/xap/xpaint/slack-desc19
-rwxr-xr-xsource/xap/xpaint/xpaint.SlackBuild120
-rw-r--r--source/xap/xpaint/xpaint_2.7.8.1-1.2.diff47
-rw-r--r--source/xap/xpaint/xpaint_xaw3d_no_scroll_mode.diff11
-rw-r--r--source/xap/xpdf/VendorP.h.buggy.diff19
-rw-r--r--source/xap/xpdf/slack-desc19
-rw-r--r--source/xap/xpdf/xpdf-3.02pl1.patch33
-rw-r--r--source/xap/xpdf/xpdf-3.02pl2.patch823
-rw-r--r--source/xap/xpdf/xpdf-3.02pl3.patch1145
-rw-r--r--source/xap/xpdf/xpdf-arabic.diff7
-rw-r--r--source/xap/xpdf/xpdf-chinese-simplified.diff19
-rw-r--r--source/xap/xpdf/xpdf-chinese-traditional.diff17
-rw-r--r--source/xap/xpdf/xpdf-cyrillic.diff9
-rw-r--r--source/xap/xpdf/xpdf-greek.diff9
-rw-r--r--source/xap/xpdf/xpdf-hebrew.diff9
-rw-r--r--source/xap/xpdf/xpdf-japanese.diff57
-rw-r--r--source/xap/xpdf/xpdf-korean.diff15
-rw-r--r--source/xap/xpdf/xpdf-latin2.diff7
-rw-r--r--source/xap/xpdf/xpdf-resizefix.diff34
-rw-r--r--source/xap/xpdf/xpdf-thai.diff9
-rw-r--r--source/xap/xpdf/xpdf-turkish.diff7
-rwxr-xr-xsource/xap/xpdf/xpdf.SlackBuild143
-rw-r--r--source/xap/xpdf/xpdf.desktop100
-rw-r--r--source/xap/xpdf/xpdf_3.02-1.3.diff4470
-rw-r--r--source/xap/xpdf/xpdfrc.diff43
-rw-r--r--source/xap/xsane/slack-desc19
-rwxr-xr-xsource/xap/xsane/xsane.SlackBuild96
-rw-r--r--source/xap/xscreensaver/setuid.c274
-rw-r--r--source/xap/xscreensaver/slack-desc19
-rwxr-xr-xsource/xap/xscreensaver/xscreensaver.SlackBuild103
-rw-r--r--source/xap/xscreensaver/xscreensaver.electricsheep.diff20
-rw-r--r--source/xap/xscreensaver/xscreensaver.setuid.diff179
-rw-r--r--source/xap/xv/slack-desc19
-rw-r--r--source/xap/xv/xv-3.10a-jumbo-README.txt442
-rw-r--r--source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt28167
-rw-r--r--source/xap/xv/xv-3.10a-jumbo-fix-patch-20050410.txt28743
-rw-r--r--source/xap/xv/xv-3.10a.patch2745
-rwxr-xr-xsource/xap/xv/xv.SlackBuild74
-rw-r--r--source/xap/xv/xv.prefix.diff11
-rw-r--r--source/xap/xv/xv.prefix_x86_64.diff20
-rw-r--r--source/xap/xxgdb/slack-desc19
-rwxr-xr-xsource/xap/xxgdb/xxgdb.SlackBuild101
-rw-r--r--source/xap/xxgdb/xxgdb.fix_glibc_and_gcc.diff45
202 files changed, 96074 insertions, 0 deletions
diff --git a/source/xap/MPlayer/MPlayer.SlackBuild b/source/xap/MPlayer/MPlayer.SlackBuild
new file mode 100755
index 00000000..20b94741
--- /dev/null
+++ b/source/xap/MPlayer/MPlayer.SlackBuild
@@ -0,0 +1,407 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Eric Hameleers, Eindhoven, NL
+# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Permission to use, copy, modify, and distribute this software for
+# any purpose with or without fee is hereby granted, provided that
+# the above copyright notice and this permission notice appear in all
+# copies.
+#
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+# -----------------------------------------------------------------------------
+#
+# Slackware SlackBuild script
+# ===========================
+# By: Eric Hameleers <alien@slackware.com>
+# For: MPlayer
+# Descr: a movie player for LINUX
+# URL: http://www.mplayerhq.hu/
+# -----------------------------------------------------------------------------
+
+PRGNAM=MPlayer
+VERSION=${VERSION:-r29390}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+TAG=${TAG:-}
+
+DOCS="AUTHORS Changelog Copyright LICENSE README DOCS/HTML-single DOCS/tech"
+
+DEFSKIN=${DEFSKIN:-"Blue"} # Download more skins at the following url:
+SKINVER=${SKINVER:-"1.7"} # http://www.mplayerhq.hu/design7/dload.html
+
+# Available languages: all bg cs de dk el en es fr hu it ja
+# ko mk nb nl pl ro ru sk sv tr uk pt_BR zh_CN zh_TW
+LANGUAGES="en nl fr de es" # The default is to just add "en" documentation
+
+if [ "$ARCH" = "x86_64" ]; then
+ LIBDIRSUFFIX="64"
+ # --enable-runtime-cpudetection is supported only for x86, x86_64, and PPC
+ EXTRACONFIGUREOPTIONS="--enable-runtime-cpudetection"
+elif [ "$ARCH" = "i486" -o \
+ "$ARCH" = "i586" -o \
+ "$ARCH" = "i686" ]; then
+ LIBDIRSUFFIX=""
+ EXTRACONFIGUREOPTIONS="--enable-runtime-cpudetection"
+else
+ LIBDIRSUFFIX=""
+ EXTRACONFIGUREOPTIONS=""
+fi
+
+CODECSDIR=/usr/lib${LIBDIRSUFFIX}/codecs # Where the WIN32 codecs are expected for instance
+
+# ---------------------------------------------------------------------------
+# -- PATENT ALERT! --
+# MPlayer source contains an internal copy of 'libdvdcss' for reading DVD's.
+# This is considered illegal software in some countries.
+# Also, MPLayer can be built with MP3 (lame) and AMR audio encoders
+# (needed for FLV and .3GP videos) but these libraries are 'contaminated'
+# with patents from Fraunhofer and GGP.
+# Also, the AAC encoder has patent issues.
+# The Slackware package is built with "USE_PATENTS=NO" i.e. without using
+# the lame mp3, faac, AMR and dvdcss libraries.
+# This also means that this creates a version of MPlayer that is unable
+# to play encrypted DVD's (which is most DVD's on the market). If it is
+# allowed in your country to use libdvdcss, this is not a big problem though.
+# Install a libdvdcss package and it will be picked up automatically by
+# MPlayer's internal libdvdread library, so that MPlayer will again be able
+# to play encrypted DVD's.
+#
+# If you have licenses to use the code, and/or the patents do not apply in
+# your region, and you take all legal responsibility, you may wish to build
+# MPlayer with the option USE_PATENTS=YES which will include potentially
+# patent-encumbered code.
+# ---------------------------------------------------------------------------
+USE_PATENTS=${USE_PATENTS:-"NO"}
+
+# MPlayer will try to use one of the TrueType fonts present on the target
+# system for it's On Screen Display (OSD) font.
+# Slackware 11.0 ships with the Vera and DejaVu fonts, you may want to add
+# more fonts to this list. The first font found will be used by creating a
+# symbolic link "/usr/share/mplayer/subfont.ttf" to it.
+# The use of bitmapped fonts is considered deprecated, but you can still use
+# those if you want. Read http://www.mplayerhq.hu/DOCS/HTML/en/fonts-osd.html
+# if you want to know more about OSD font configuration.
+OSDFONTS="LiberationSans-Regular.ttf \
+ Arialuni.ttf arial.ttf \
+ DejaVuSans.ttf Vera.ttf"
+
+# We will work with a stripped-down source tarball, not containing libdvdcss:
+[ "$USE_PATENTS" != "YES" ] && EXTRA="_nolibdvdcss" || EXTRA=""
+
+# Where do we look for sources?
+SRCDIR=$(cd $(dirname $0); pwd)
+
+SOURCE[0]="$SRCDIR/${PRGNAM}${EXTRA}-${VERSION}.tar.xz"
+SRCURL[0]=""
+
+# The default skin to use (we need to add at least one)
+SOURCE[1]="$SRCDIR/${DEFSKIN}-${SKINVER}.tar.bz2"
+SRCURL[1]="http://www.mplayerhq.hu/MPlayer/skins/${DEFSKIN}-${SKINVER}.tar.bz2"
+
+# Use the src_checkout() function if no downloadable tarball exists.
+# This function checks out sources from SVN/CVS and creates a tarball of them.
+src_checkout() {
+ # Param #1 : index in the SOURCE[] array.
+ # Param #2 : full path to where SOURCE[$1] tarball should be created.
+ # Determine the tarball extension:
+ PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
+ case "$PEXT" in
+ "tar.xz") TARCOMP="J" ;;
+ "tar.gz") TARCOMP="z" ;;
+ "tgz") TARCOMP="z" ;;
+ "tar.bz2") TARCOMP="j" ;;
+ *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
+ esac
+ case ${1} in
+ 0) # mplayer
+ if [ "$(echo ${VERSION}|cut -c1)" == 'r' ]; then # revision instead of date
+ REV=$(echo ${VERSION} | cut -c2-)
+ else
+ REV="{${VERSION}}"
+ fi
+ mkdir MPlayer-${VERSION} \
+ && cd MPlayer-${VERSION} \
+ && svn checkout --revision $REV svn://svn.mplayerhq.hu/mplayer/trunk . \
+ && find . -type d -name '.svn' -depth | xargs rm -rf \
+ && ([ "$USE_PATENTS" != "YES" ] && rm -rf libdvdcss || true) \
+ && chown -R root:root . \
+ && cd .. \
+ && tar -${TARCOMP}cf ${2} MPlayer-${VERSION}
+ rm -rf MPlayer-${VERSION}
+ ;;
+ *) # Do nothing
+ ;;
+ esac
+}
+
+# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
+TMP=${TMP:-/tmp/build}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+##
+## --- with a little luck, you won't have to edit below this point --- ##
+##
+
+# Exit the script on errors:
+set -e
+trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
+# Catch unitialized variables:
+set -u
+P1=${1:-1}
+
+# Create working directories:
+mkdir -p $TMP/tmp-$PRGNAM # location to build the source
+rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
+mkdir -p $PKG # place for the package to be built
+rm -rf $PKG/* # erase old package's contents
+mkdir -p $OUTPUT # place for the package to be saved
+
+# Source file availability:
+for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
+ if ! [ -f ${SOURCE[$i]} ]; then
+ echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
+ # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
+ [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
+ if ! [ "x${SRCURL[$i]}" == "x" ]; then
+ echo "Will download file to $(dirname $SOURCE[$i])"
+ wget -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}" || true
+ if [ $? -ne 0 -o ! -s "${SOURCE[$i]}" ]; then
+ echo "Downloading '$(basename ${SOURCE[$i]})' failed.. aborting the build."
+ mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
+ exit 1
+ fi
+ else
+ # Try if we have a SVN/CVS download routine for ${SOURCE[$i]}
+ echo "Will checkout sources to $(dirname $SOURCE[$i])"
+ src_checkout $i "${SOURCE[$i]}" 2>&1 > $OUTPUT/checkout-$(basename ${SOURCE[$i]}).log
+ fi
+ if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
+ echo "File '$(basename ${SOURCE[$i]})' not available.. aborting the build."
+ exit 1
+ fi
+ fi
+done
+
+if [ "$P1" == "--download" ]; then
+ echo "Download complete."
+ exit 0
+fi
+
+# --- PACKAGE BUILDING ---
+
+echo "++"
+echo "|| $PRGNAM-$VERSION"
+echo "++"
+
+# Warn about libdvdread requirement:
+if [ "$USE_PATENTS" != "YES" ]; then
+ cat <<"EOT"
+**
+** Removing internal DeCSS library.
+** If you want to play encrypted DVD's you need to install libdvdcss separately.
+** You take full legal responsibility for any use of DeCSS. We neither supply
+** DeCSS code nor endorse any illegal use of it.
+**
+** If you are unaffected by patent concerns because you hold the required
+** licenses and permission to use the patented code, or reside in a
+** location where this is not a concern, and wish to include the patented
+** and restricted code (you take all legal responsibility for doing so),
+** then edit this SlackBuild script and change the line:
+** USE_PATENTS=${USE_PATENTS:-"NO"}
+** to:
+** USE_PATENTS="YES"
+**
+EOT
+ sleep 5
+fi
+
+cd $TMP/tmp-$PRGNAM
+echo "Extracting the source archive(s) for $PRGNAM..."
+tar -xvf ${SOURCE[0]}
+[ "$USE_PATENTS" != "YES" ] && rm -rf libdvdcss
+chown -R root:root *
+chmod -R u+w,go+r-w,a-s *
+cd ${PRGNAM}-${VERSION}
+
+# Determine what X we're running (the modular X returns the prefix
+# in the next command, while older versions stay silent):
+XPREF=$(pkg-config --variable=prefix x11) || true
+[ "$XPREF" == "" ] && XPREF='/usr/X11R6'
+
+# Remove support for patent encumbered and possibly illegal code:
+if [ "$USE_PATENTS" != "YES" ]; then
+ DO_PATENTED="--disable-libdvdcss-internal \
+ --disable-mp3lame --disable-mp3lame-lavc \
+ --disable-faac --disable-faac-lavc \
+ --disable-libamr_nb --disable-libamr_wb"
+else
+ DO_PATENTED=""
+fi
+
+echo Building ...
+# MPlayer wants to automatically determine compiler flags,
+# so we don't provide CFLAGS:
+./configure --prefix=/usr \
+ --mandir=/usr/man \
+ --confdir=/etc/mplayer \
+ --enable-gui \
+ --enable-menu \
+ --enable-largefiles \
+ --disable-arts \
+ --codecsdir=${CODECSDIR} \
+ --win32codecsdir=${CODECSDIR} \
+ --realcodecsdir=${CODECSDIR} \
+ --language="${LANGUAGES}" \
+ ${EXTRACONFIGUREOPTIONS} \
+ ${DO_PATENTED} \
+ 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log
+# So that MPlayer does not report "UNKNOWN" as it's version:
+echo $VERSION > VERSION
+make 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
+make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
+
+# Build the html documentation (not all languages are available):
+( cd DOCS/xml
+ for i in $(echo $LANGUAGES | tr , ' ') ; do
+ [ -d $i ] && make html-single-$i ;
+ done
+)
+
+# Prepare the configfile:
+mkdir -p $PKG/etc/mplayer
+cp etc/example.conf $PKG/etc/mplayer/mplayer.conf.new
+
+# Install our default skin:
+cd $PKG/usr/share/mplayer/skins
+tar -xvf ${SOURCE[1]}
+chown -R root:root *
+chmod -R u+w,go+r-w,a-s *
+ln -s ${DEFSKIN} default
+cd -
+
+# Add this to the doinst.sh:
+! [ -d $PKG/install ] && mkdir -p $PKG/install
+cat <<EOINS >> $PKG/install/doinst.sh
+# Handle the incoming configuration files:
+config() {
+ for infile in \$1; do
+ NEW="\$infile"
+ OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r \$OLD ]; then
+ mv \$NEW \$OLD
+ elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then
+ # toss the redundant copy
+ rm \$NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+ done
+}
+
+# Installing a bitmap font is considered deprecated; use a TTF font instead.
+# We try to link to an installed TTF font at install time.
+# Configure a default TrueType font to use for the OSD :
+if [ ! -f usr/share/mplayer/subfont.ttf ]; then
+ for font in ${OSDFONTS}; do
+ if [ -f .${XPREF}/lib${LIBDIRSUFFIX}/X11/fonts/TTF/\${font} ]; then
+ ( cd usr/share/mplayer/
+ ln -sf ${XPREF}/lib${LIBDIRSUFFIX}/X11/fonts/TTF/\${font} subfont.ttf
+ )
+ break
+ fi
+ done
+fi
+
+# Prepare the new configuration file
+config etc/mplayer/mplayer.conf.new
+
+if [ -x /usr/bin/update-desktop-database ]; then
+ chroot . /usr/bin/update-desktop-database -q usr/share/applications
+fi
+
+if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
+ if [ -x usr/bin/gtk-update-icon-cache ]; then
+ chroot . /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
+ fi
+fi
+
+EOINS
+
+# Add documentation:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
+cp -a $SRCDIR/$(basename $0) $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+mv $PKG/usr/doc/$PRGNAM-$VERSION/HTML-single $PKG/usr/doc/$PRGNAM-$VERSION/html
+# Save a sample of all configuration files:
+for i in etc/*.conf ; do
+ cp $i $PKG/usr/doc/$PRGNAM-$VERSION/$(basename $i)-sample
+done
+# Save a transcript of all configured options for this specific build:
+if [ -n $OUTPUT/configure-${PRGNAM}.log ]; then
+ cat $OUTPUT/configure-${PRGNAM}.log \
+ | sed -n "/^Config files successfully generated/,/^'config.h' and 'config.mak' contain your configuration options./p" \
+ > $PKG/usr/doc/$PRGNAM-$VERSION/${PRGNAM}.configuration
+fi
+find $PKG/usr/doc -type f -exec chmod 644 {} \;
+
+# Compress the man page(s):
+if [ -d $PKG/usr/man ]; then
+ find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
+ for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+fi
+
+# Strip binaries:
+( find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )
+
+# Add a package description:
+mkdir -p $PKG/install
+cat $SRCDIR/slack-desc > $PKG/install/slack-desc
+if [ -f $SRCDIR/doinst.sh ]; then
+ cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
+fi
+
+# Build the package:
+cd $PKG
+makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
+cd $OUTPUT
+md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz.md5
+cd -
+cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
+
+# Warn about libdvdcss requirement (again):
+if [ "$USE_PATENTS" != "YES" ]; then
+ cat <<"EOT"
+**
+** Internal DECSS library was not built.
+** If you want to play encrypted DVD's you need to install libdvdcss separately.
+** You take full legal responsibility for any use of DeCSS. We neither supply
+** DeCSS code nor endorse any illegal use of it.
+**
+** If you are unaffected by patent concerns because you hold the required
+** licenses and permission to use the patented code, or reside in a
+** location where this is not a concern, and wish to include the patented
+** and restricted code (you take all legal responsibility for doing so),
+** then edit this SlackBuild script and change the line:
+** USE_PATENTS=${USE_PATENTS:-"NO"}
+** to:
+** USE_PATENTS="YES"
+**
+EOT
+
+fi
+
diff --git a/source/xap/MPlayer/slack-desc b/source/xap/MPlayer/slack-desc
new file mode 100644
index 00000000..a73feb27
--- /dev/null
+++ b/source/xap/MPlayer/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+MPlayer: MPlayer (media player)
+MPlayer:
+MPlayer: MPlayer is a movie player. It plays most MPEG/VOB, AVI, Ogg/OGM,
+MPlayer: VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, NUT, NuppelVideo,
+MPlayer: FLI, YUV4MPEG, FILM, RoQ, PVA files, supported by many native, XAnim,
+MPlayer: and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx,
+MPlayer: DivX 3/4/5, WMV and even H.264 movies.
+MPlayer:
+MPlayer: Homepage for MPlayer is http://www.mplayerhq.hu/
+MPlayer:
+MPlayer:
diff --git a/source/xap/audacious-plugins/amidi-plug.fix-drct.diff b/source/xap/audacious-plugins/amidi-plug.fix-drct.diff
new file mode 100644
index 00000000..432b955d
--- /dev/null
+++ b/source/xap/audacious-plugins/amidi-plug.fix-drct.diff
@@ -0,0 +1,11 @@
+diff -ur ./src/amidi-plug/i_configure.c ../audacious-plugins-1.5.1/src/amidi-plug/i_configure.c
+--- ./src/amidi-plug/i_configure.c 2008-05-24 00:44:19.000000000 +0200
++++ ./src/amidi-plug/i_configure.c 2008-11-13 15:08:57.000000000 +0100
+@@ -28,6 +28,7 @@
+ #include "i_configure-fluidsynth.h"
+ #include "i_configure-dummy.h"
+ #include "i_utils.h"
++#include <audacious/plugin.h>
+ #include <audacious/auddrct.h>
+
+
diff --git a/source/xap/audacious-plugins/audacious-plugins.SlackBuild b/source/xap/audacious-plugins/audacious-plugins.SlackBuild
new file mode 100755
index 00000000..47bc40f9
--- /dev/null
+++ b/source/xap/audacious-plugins/audacious-plugins.SlackBuild
@@ -0,0 +1,128 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=audacious-plugins
+VERSION=${VERSION:-1.5.1}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-4}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+ ARCHOPTS="--disable-sse2"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+ ARCHOPTS="--disable-sse2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX="64"
+ ARCHOPTS=""
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+zcat $CWD/audacious-plugins.libmtp8.diff.gz | patch -p1 || exit 1
+zcat $CWD/amidi-plug.fix-drct.diff.gz | patch -p1 || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --enable-chardet \
+ --enable-amidiplug \
+ --enable-timidity \
+ --disable-altivec \
+ --program-prefix= \
+ --program-suffix= \
+ ${ARCHOPTS} \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS COPYING INSTALL Mercurial-Access \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+#zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/audacious-plugins/audacious-plugins.libmtp8.diff b/source/xap/audacious-plugins/audacious-plugins.libmtp8.diff
new file mode 100644
index 00000000..6c224fa5
--- /dev/null
+++ b/source/xap/audacious-plugins/audacious-plugins.libmtp8.diff
@@ -0,0 +1,16 @@
+--- ./src/mtp_up/mtp.c.orig 2008-05-23 17:44:20.000000000 -0500
++++ ./src/mtp_up/mtp.c 2008-09-14 14:28:44.000000000 -0500
+@@ -193,11 +193,12 @@
+ g_free(from_path);
+ g_free(tmp);
+ parent_id = mtp_device->default_music_folder;
++ gentrack->parent_id = parent_id;
+
+ #if DEBUG
+ g_print("Uploading track '%s'\n",filename);
+ #endif
+- ret = LIBMTP_Send_Track_From_File(mtp_device, filename , gentrack, NULL , NULL, parent_id);
++ ret = LIBMTP_Send_Track_From_File(mtp_device, filename , gentrack, NULL , NULL);
+ LIBMTP_destroy_track_t(gentrack);
+ if (ret == 0)
+ g_print("Track upload finished!\n");
diff --git a/source/xap/audacious-plugins/slack-desc b/source/xap/audacious-plugins/slack-desc
new file mode 100644
index 00000000..2c822733
--- /dev/null
+++ b/source/xap/audacious-plugins/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+audacious-plugins: audacious-plugins (Plugins used by the Audacious media player)
+audacious-plugins:
+audacious-plugins: This is a collection of plugins for Audacious to support additional
+audacious-plugins: media formats.
+audacious-plugins:
+audacious-plugins: The webpage for Audacious is: http://www.audacious-media-player.org.
+audacious-plugins:
+audacious-plugins:
+audacious-plugins:
+audacious-plugins:
+audacious-plugins:
diff --git a/source/xap/audacious/audacious.SlackBuild b/source/xap/audacious/audacious.SlackBuild
new file mode 100755
index 00000000..b18a0670
--- /dev/null
+++ b/source/xap/audacious/audacious.SlackBuild
@@ -0,0 +1,132 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=audacious
+VERSION=${VERSION:-1.5.1}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-3}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+ ARCHOPTS="--disable-sse2"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+ ARCHOPTS="--disable-sse2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+ ARCHOPTS=""
+elif [ "$ARCH" = "arm" ]; then
+ SLKCFLAGS="-O2 -march=armv4 -mtune=xscale"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "armel" ]; then
+ SLKCFLAGS="-O2 -march=armv4t"
+ LIBDIRSUFFIX=""
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Fix command line options handling:
+zcat $CWD/audacious.handle_cmd_line_options.diff.gz | patch -p1 || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --enable-ipv6 \
+ --enable-chardet \
+ --disable-altivec \
+ --program-prefix= \
+ --program-suffix= \
+ ${ARCHOPTS} \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ ABOUT-NLS AUTHORS COPYING INSTALL Mercurial-Access NEWS README \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+#zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/audacious/audacious.handle_cmd_line_options.diff b/source/xap/audacious/audacious.handle_cmd_line_options.diff
new file mode 100644
index 00000000..6ccb2243
--- /dev/null
+++ b/source/xap/audacious/audacious.handle_cmd_line_options.diff
@@ -0,0 +1,38 @@
+--- ./src/audacious/main.c.orig 2008-05-23 17:00:34.000000000 -0500
++++ ./src/audacious/main.c 2009-04-10 17:03:00.000000000 -0500
+@@ -315,7 +315,7 @@
+ }
+
+ static void
+-handle_cmd_line_options()
++handle_cmd_line_options(gboolean skip)
+ {
+ gchar **filenames = options.filenames;
+ #ifdef USE_DBUS
+@@ -430,7 +430,7 @@
+ } /* is_running */
+ else
+ #endif
+- { /* !is_running */
++ if (!skip) { /* !is_running */
+ if (filenames != NULL)
+ {
+ gint pos = 0;
+@@ -715,7 +715,7 @@
+
+ signal_handlers_init();
+
+- handle_cmd_line_options();
++ handle_cmd_line_options(TRUE);
+
+ if (options.headless == FALSE)
+ {
+@@ -735,6 +735,8 @@
+ plugin_system_init();
+ playlist_system_init();
+
++ handle_cmd_line_options(FALSE);
++
+ #ifdef USE_DBUS
+ init_dbus();
+ #endif
diff --git a/source/xap/audacious/slack-desc b/source/xap/audacious/slack-desc
new file mode 100644
index 00000000..6574e805
--- /dev/null
+++ b/source/xap/audacious/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+audacious: audacious (A relatively powerful media player)
+audacious:
+audacious: Audacious is a media player, based on Beep Media Player, which is in
+audacious: turn based on the X Multimedia System (XMMS). It is used to play
+audacious: audio and other kinds of media files. By default Audacious can play
+audacious: MPEG audio, Ogg Vorbis, RIFF wav, most module formats, and a few
+audacious: other formats. Audacious can be extended through plugins to play a
+audacious: number of other audio and video formats.
+audacious:
+audacious: The webpage for Audacious is: http://www.audacious-media-player.org.
+audacious:
diff --git a/source/xap/blackbox/blackbox.SlackBuild b/source/xap/blackbox/blackbox.SlackBuild
new file mode 100755
index 00000000..4505d06e
--- /dev/null
+++ b/source/xap/blackbox/blackbox.SlackBuild
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=blackbox
+VERSION=${VERSION:-0.65.0}
+BBVER=${BBVER:-0.8.6}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-4}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.gz || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Thanks for the gcc-4.1.1 patch, Debian. :-)
+zcat $CWD/blackbox_0.65.0-5.diff.gz | patch -p1 --verbose || exit 1
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --enable-shape \
+ --enable-slit \
+ --enable-interlace \
+ --enable-nls \
+ --enable-timed-cache \
+ $ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/etc/X11/xinit
+zcat $CWD/xinitrc.blackbox.gz > $PKG/etc/X11/xinit/xinitrc.blackbox
+chmod 755 $PKG/etc/X11/xinit/xinitrc.blackbox
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS INSTALL LICENSE README* TODO \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+######################################
+# Compile bbkeys program for blackbox:
+cd $TMP
+rm -rf bbkeys-${BBVER}
+tar xvf $CWD/bbkeys-${BBVER}.tar.gz || exit 1
+cd bbkeys-${BBVER} || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --enable-interlace \
+ $ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p /usr/doc/bbkeys-$BBKEYS
+cp -a \
+ AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README* TODO \
+ /usr/doc/bbkeys-$BBKEYS
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/blackbox/blackbox_0.65.0-5.diff b/source/xap/blackbox/blackbox_0.65.0-5.diff
new file mode 100644
index 00000000..4b6959d8
--- /dev/null
+++ b/source/xap/blackbox/blackbox_0.65.0-5.diff
@@ -0,0 +1,12462 @@
+--- blackbox-0.65.0.orig/Makefile.in
++++ blackbox-0.65.0/Makefile.in
+@@ -68,6 +68,7 @@
+ ORDEREDPSEUDO = @ORDEREDPSEUDO@
+ PACKAGE = @PACKAGE@
+ SHAPE = @SHAPE@
++XINERAMA = @XINERAMA@
+ TIMEDCACHE = @TIMEDCACHE@
+ VERSION = @VERSION@
+ gencat_cmd = @gencat_cmd@
+--- blackbox-0.65.0.orig/configure
++++ blackbox-0.65.0/configure
+@@ -1,42 +1,325 @@
+ #! /bin/sh
+-
+ # Guess values for system-dependent variables and create Makefiles.
+-# Generated automatically using autoconf version 2.13
+-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
++# Generated by GNU Autoconf 2.59.
+ #
++# Copyright (C) 2003 Free Software Foundation, Inc.
+ # This configure script is free software; the Free Software Foundation
+ # gives unlimited permission to copy, distribute and modify it.
++## --------------------- ##
++## M4sh Initialization. ##
++## --------------------- ##
++
++# Be Bourne compatible
++if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
++ emulate sh
++ NULLCMD=:
++ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
++ # is contrary to our usage. Disable this feature.
++ alias -g '${1+"$@"}'='"$@"'
++elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
++ set -o posix
++fi
++DUALCASE=1; export DUALCASE # for MKS sh
++
++# Support unset when possible.
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ as_unset=unset
++else
++ as_unset=false
++fi
++
++
++# Work around bugs in pre-3.0 UWIN ksh.
++$as_unset ENV MAIL MAILPATH
++PS1='$ '
++PS2='> '
++PS4='+ '
++
++# NLS nuisances.
++for as_var in \
++ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
++ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
++ LC_TELEPHONE LC_TIME
++do
++ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
++ eval $as_var=C; export $as_var
++ else
++ $as_unset $as_var
++ fi
++done
++
++# Required to use basename.
++if expr a : '\(a\)' >/dev/null 2>&1; then
++ as_expr=expr
++else
++ as_expr=false
++fi
++
++if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
++ as_basename=basename
++else
++ as_basename=false
++fi
++
++
++# Name of the executable.
++as_me=`$as_basename "$0" ||
++$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
++ X"$0" : 'X\(//\)$' \| \
++ X"$0" : 'X\(/\)$' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X/"$0" |
++ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
++ /^X\/\(\/\/\)$/{ s//\1/; q; }
++ /^X\/\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++
++
++# PATH needs CR, and LINENO needs CR and PATH.
++# Avoid depending upon Character Ranges.
++as_cr_letters='abcdefghijklmnopqrstuvwxyz'
++as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
++as_cr_Letters=$as_cr_letters$as_cr_LETTERS
++as_cr_digits='0123456789'
++as_cr_alnum=$as_cr_Letters$as_cr_digits
++
++# The user is always right.
++if test "${PATH_SEPARATOR+set}" != set; then
++ echo "#! /bin/sh" >conf$$.sh
++ echo "exit 0" >>conf$$.sh
++ chmod +x conf$$.sh
++ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
++ PATH_SEPARATOR=';'
++ else
++ PATH_SEPARATOR=:
++ fi
++ rm -f conf$$.sh
++fi
++
++
++ as_lineno_1=$LINENO
++ as_lineno_2=$LINENO
++ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
++ test "x$as_lineno_1" != "x$as_lineno_2" &&
++ test "x$as_lineno_3" = "x$as_lineno_2" || {
++ # Find who we are. Look in the path if we contain no path at all
++ # relative or not.
++ case $0 in
++ *[\\/]* ) as_myself=$0 ;;
++ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
++done
++
++ ;;
++ esac
++ # We did not find ourselves, most probably we were run as `sh COMMAND'
++ # in which case we are not to be found in the path.
++ if test "x$as_myself" = x; then
++ as_myself=$0
++ fi
++ if test ! -f "$as_myself"; then
++ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
++ { (exit 1); exit 1; }; }
++ fi
++ case $CONFIG_SHELL in
++ '')
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for as_base in sh bash ksh sh5; do
++ case $as_dir in
++ /*)
++ if ("$as_dir/$as_base" -c '
++ as_lineno_1=$LINENO
++ as_lineno_2=$LINENO
++ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
++ test "x$as_lineno_1" != "x$as_lineno_2" &&
++ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
++ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
++ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
++ CONFIG_SHELL=$as_dir/$as_base
++ export CONFIG_SHELL
++ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
++ fi;;
++ esac
++ done
++done
++;;
++ esac
++
++ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
++ # uniformly replaced by the line number. The first 'sed' inserts a
++ # line-number line before each line; the second 'sed' does the real
++ # work. The second script uses 'N' to pair each line-number line
++ # with the numbered line, and appends trailing '-' during
++ # substitution so that $LINENO is not a special case at line end.
++ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
++ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
++ sed '=' <$as_myself |
++ sed '
++ N
++ s,$,-,
++ : loop
++ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
++ t loop
++ s,-$,,
++ s,^['$as_cr_digits']*\n,,
++ ' >$as_me.lineno &&
++ chmod +x $as_me.lineno ||
++ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
++ { (exit 1); exit 1; }; }
++
++ # Don't try to exec as it changes $[0], causing all sort of problems
++ # (the dirname of $[0] is not the place where we might find the
++ # original and so on. Autoconf is especially sensible to this).
++ . ./$as_me.lineno
++ # Exit status is that of the last command.
++ exit
++}
++
++
++case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
++ *c*,-n*) ECHO_N= ECHO_C='
++' ECHO_T=' ' ;;
++ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
++ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
++esac
++
++if expr a : '\(a\)' >/dev/null 2>&1; then
++ as_expr=expr
++else
++ as_expr=false
++fi
++
++rm -f conf$$ conf$$.exe conf$$.file
++echo >conf$$.file
++if ln -s conf$$.file conf$$ 2>/dev/null; then
++ # We could just check for DJGPP; but this test a) works b) is more generic
++ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
++ if test -f conf$$.exe; then
++ # Don't use ln at all; we don't have any links
++ as_ln_s='cp -p'
++ else
++ as_ln_s='ln -s'
++ fi
++elif ln conf$$.file conf$$ 2>/dev/null; then
++ as_ln_s=ln
++else
++ as_ln_s='cp -p'
++fi
++rm -f conf$$ conf$$.exe conf$$.file
++
++if mkdir -p . 2>/dev/null; then
++ as_mkdir_p=:
++else
++ test -d ./-p && rmdir ./-p
++ as_mkdir_p=false
++fi
++
++as_executable_p="test -f"
++
++# Sed expression to map a string onto a valid CPP name.
++as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
++
++# Sed expression to map a string onto a valid variable name.
++as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
++
+
+-# Defaults:
+-ac_help=
++# IFS
++# We need space, tab and new line, in precisely that order.
++as_nl='
++'
++IFS=" $as_nl"
++
++# CDPATH.
++$as_unset CDPATH
++
++
++# Name of the host.
++# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
++# so uname gets run too.
++ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
++
++exec 6>&1
++
++#
++# Initializations.
++#
+ ac_default_prefix=/usr/local
+-# Any additions from configure.in:
+-ac_help="$ac_help
+- --with-x use the X Window System"
+-ac_help="$ac_help
+- --enable-shape enable support of the XShape extension [default=yes]"
+-ac_help="$ac_help
+- --enable-ordered-pseudo include code for ordered pseudocolor (8bpp)
+- dithering [default=no]"
+-ac_help="$ac_help
+- --enable-debug include verbose debugging code [default=no]"
+-ac_help="$ac_help
+- --enable-nls include natural language support [default=yes]"
+-ac_help="$ac_help
+- --enable-timed-cache use new timed pixmap cache [default=yes]"
+-ac_help="$ac_help
+- --enable-maintainer-mode enable make rules and dependencies not useful
+- (and sometimes confusing) to the casual installer"
++ac_config_libobj_dir=.
++cross_compiling=no
++subdirs=
++MFLAGS=
++MAKEFLAGS=
++SHELL=${CONFIG_SHELL-/bin/sh}
++
++# Maximum number of lines to put in a shell here document.
++# This variable seems obsolete. It should probably be removed, and
++# only ac_max_sed_lines should be used.
++: ${ac_max_here_lines=38}
++
++# Identity of this package.
++PACKAGE_NAME=
++PACKAGE_TARNAME=
++PACKAGE_VERSION=
++PACKAGE_STRING=
++PACKAGE_BUGREPORT=
++
++ac_unique_file="src/blackbox.cc"
++# Factoring default headers for most tests.
++ac_includes_default="\
++#include <stdio.h>
++#if HAVE_SYS_TYPES_H
++# include <sys/types.h>
++#endif
++#if HAVE_SYS_STAT_H
++# include <sys/stat.h>
++#endif
++#if STDC_HEADERS
++# include <stdlib.h>
++# include <stddef.h>
++#else
++# if HAVE_STDLIB_H
++# include <stdlib.h>
++# endif
++#endif
++#if HAVE_STRING_H
++# if !STDC_HEADERS && HAVE_MEMORY_H
++# include <memory.h>
++# endif
++# include <string.h>
++#endif
++#if HAVE_STRINGS_H
++# include <strings.h>
++#endif
++#if HAVE_INTTYPES_H
++# include <inttypes.h>
++#else
++# if HAVE_STDINT_H
++# include <stdint.h>
++# endif
++#endif
++#if HAVE_UNISTD_H
++# include <unistd.h>
++#endif"
++
++ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX regex_cmd CPP EGREP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS SHAPE XINERAMA ORDEREDPSEUDO DEBUG NLS gencat_cmd TIMEDCACHE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBOBJS LTLIBOBJS'
++ac_subst_files=''
+
+ # Initialize some variables set by options.
++ac_init_help=
++ac_init_version=false
+ # The variables have the same names as the options, with
+ # dashes changed to underlines.
+-build=NONE
+-cache_file=./config.cache
++cache_file=/dev/null
+ exec_prefix=NONE
+-host=NONE
+ no_create=
+-nonopt=NONE
+ no_recursion=
+ prefix=NONE
+ program_prefix=NONE
+@@ -45,10 +328,15 @@
+ silent=
+ site=
+ srcdir=
+-target=NONE
+ verbose=
+ x_includes=NONE
+ x_libraries=NONE
++
++# Installation directory options.
++# These are left unexpanded so users can "make install exec_prefix=/foo"
++# and all the variables that are supposed to be based on exec_prefix
++# by default will actually change.
++# Use braces instead of parens because sh, perl, etc. also accept them.
+ bindir='${exec_prefix}/bin'
+ sbindir='${exec_prefix}/sbin'
+ libexecdir='${exec_prefix}/libexec'
+@@ -62,17 +350,9 @@
+ infodir='${prefix}/info'
+ mandir='${prefix}/man'
+
+-# Initialize some other variables.
+-subdirs=
+-MFLAGS= MAKEFLAGS=
+-SHELL=${CONFIG_SHELL-/bin/sh}
+-# Maximum number of lines to put in a shell here document.
+-ac_max_here_lines=12
+-
+ ac_prev=
+ for ac_option
+ do
+-
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+@@ -80,59 +360,59 @@
+ continue
+ fi
+
+- case "$ac_option" in
+- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+- *) ac_optarg= ;;
+- esac
++ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+- case "$ac_option" in
++ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+- bindir="$ac_optarg" ;;
++ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+- ac_prev=build ;;
++ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+- build="$ac_optarg" ;;
++ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+- cache_file="$ac_optarg" ;;
++ cache_file=$ac_optarg ;;
++
++ --config-cache | -C)
++ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+- datadir="$ac_optarg" ;;
++ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
++ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+- fi
+- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+- eval "enable_${ac_feature}=no" ;;
++ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
++ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
++ { (exit 1); exit 1; }; }
++ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
++ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
++ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+- fi
+- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+- case "$ac_option" in
+- *=*) ;;
++ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
++ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
++ { (exit 1); exit 1; }; }
++ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
++ case $ac_option in
++ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+- eval "enable_${ac_feature}='$ac_optarg'" ;;
++ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+@@ -141,95 +421,47 @@
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+- exec_prefix="$ac_optarg" ;;
++ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+- -help | --help | --hel | --he)
+- # Omit some internal or obsolete options to make the list less imposing.
+- # This message is too long to be a string in the A/UX 3.1 sh.
+- cat << EOF
+-Usage: configure [options] [host]
+-Options: [defaults in brackets after descriptions]
+-Configuration:
+- --cache-file=FILE cache test results in FILE
+- --help print this message
+- --no-create do not create output files
+- --quiet, --silent do not print \`checking...' messages
+- --version print the version of autoconf that created configure
+-Directory and file names:
+- --prefix=PREFIX install architecture-independent files in PREFIX
+- [$ac_default_prefix]
+- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+- [same as prefix]
+- --bindir=DIR user executables in DIR [EPREFIX/bin]
+- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+- --datadir=DIR read-only architecture-independent data in DIR
+- [PREFIX/share]
+- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+- --sharedstatedir=DIR modifiable architecture-independent data in DIR
+- [PREFIX/com]
+- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+- --includedir=DIR C header files in DIR [PREFIX/include]
+- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+- --infodir=DIR info documentation in DIR [PREFIX/info]
+- --mandir=DIR man documentation in DIR [PREFIX/man]
+- --srcdir=DIR find the sources in DIR [configure dir or ..]
+- --program-prefix=PREFIX prepend PREFIX to installed program names
+- --program-suffix=SUFFIX append SUFFIX to installed program names
+- --program-transform-name=PROGRAM
+- run sed PROGRAM on installed program names
+-EOF
+- cat << EOF
+-Host type:
+- --build=BUILD configure for building on BUILD [BUILD=HOST]
+- --host=HOST configure for HOST [guessed]
+- --target=TARGET configure for TARGET [TARGET=HOST]
+-Features and packages:
+- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+- --x-includes=DIR X include files are in DIR
+- --x-libraries=DIR X library files are in DIR
+-EOF
+- if test -n "$ac_help"; then
+- echo "--enable and --with options recognized:$ac_help"
+- fi
+- exit 0 ;;
++ -help | --help | --hel | --he | -h)
++ ac_init_help=long ;;
++ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
++ ac_init_help=recursive ;;
++ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
++ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+- ac_prev=host ;;
++ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+- host="$ac_optarg" ;;
++ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+- includedir="$ac_optarg" ;;
++ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+- infodir="$ac_optarg" ;;
++ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+- libdir="$ac_optarg" ;;
++ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+- libexecdir="$ac_optarg" ;;
++ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+@@ -238,19 +470,19 @@
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+- localstatedir="$ac_optarg" ;;
++ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+- mandir="$ac_optarg" ;;
++ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+- | --no-cr | --no-c)
++ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+@@ -264,26 +496,26 @@
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+- oldincludedir="$ac_optarg" ;;
++ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+- prefix="$ac_optarg" ;;
++ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+- program_prefix="$ac_optarg" ;;
++ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+- program_suffix="$ac_optarg" ;;
++ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+@@ -300,7 +532,7 @@
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+- program_transform_name="$ac_optarg" ;;
++ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+@@ -310,7 +542,7 @@
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+- sbindir="$ac_optarg" ;;
++ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+@@ -321,58 +553,57 @@
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+- sharedstatedir="$ac_optarg" ;;
++ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+- site="$ac_optarg" ;;
++ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+- srcdir="$ac_optarg" ;;
++ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+- sysconfdir="$ac_optarg" ;;
++ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+- ac_prev=target ;;
++ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+- target="$ac_optarg" ;;
++ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+- -version | --version | --versio | --versi | --vers)
+- echo "configure generated by autoconf version 2.13"
+- exit 0 ;;
++ -version | --version | --versio | --versi | --vers | -V)
++ ac_init_version=: ;;
+
+ -with-* | --with-*)
+- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
++ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+- fi
++ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
++ { echo "$as_me: error: invalid package name: $ac_package" >&2
++ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+- case "$ac_option" in
+- *=*) ;;
++ case $ac_option in
++ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+- eval "with_${ac_package}='$ac_optarg'" ;;
++ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
++ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+- fi
+- ac_package=`echo $ac_package| sed 's/-/_/g'`
+- eval "with_${ac_package}=no" ;;
++ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
++ { echo "$as_me: error: invalid package name: $ac_package" >&2
++ { (exit 1); exit 1; }; }
++ ac_package=`echo $ac_package | sed 's/-/_/g'`
++ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+@@ -383,99 +614,110 @@
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+- x_includes="$ac_optarg" ;;
++ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+- x_libraries="$ac_optarg" ;;
++ x_libraries=$ac_optarg ;;
+
+- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
++ -*) { echo "$as_me: error: unrecognized option: $ac_option
++Try \`$0 --help' for more information." >&2
++ { (exit 1); exit 1; }; }
+ ;;
+
++ *=*)
++ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
++ # Reject names that are not valid shell variable names.
++ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
++ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
++ { (exit 1); exit 1; }; }
++ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
++ eval "$ac_envvar='$ac_optarg'"
++ export $ac_envvar ;;
++
+ *)
+- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+- echo "configure: warning: $ac_option: invalid host type" 1>&2
+- fi
+- if test "x$nonopt" != xNONE; then
+- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+- fi
+- nonopt="$ac_option"
++ # FIXME: should be removed in autoconf 3.0.
++ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
++ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
++ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
++ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+ done
+
+ if test -n "$ac_prev"; then
+- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+-fi
+-
+-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+-
+-# File descriptor usage:
+-# 0 standard input
+-# 1 file creation
+-# 2 errors and warnings
+-# 3 some systems may open it to /dev/tty
+-# 4 used on the Kubota Titan
+-# 6 checking for... messages and results
+-# 5 compiler messages saved in config.log
+-if test "$silent" = yes; then
+- exec 6>/dev/null
+-else
+- exec 6>&1
++ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
++ { echo "$as_me: error: missing argument to $ac_option" >&2
++ { (exit 1); exit 1; }; }
+ fi
+-exec 5>./config.log
+
+-echo "\
+-This file contains any messages produced by compilers while
+-running configure, to aid debugging if configure makes a mistake.
+-" 1>&5
++# Be sure to have absolute paths.
++for ac_var in exec_prefix prefix
++do
++ eval ac_val=$`echo $ac_var`
++ case $ac_val in
++ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
++ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
++ { (exit 1); exit 1; }; };;
++ esac
++done
+
+-# Strip out --no-create and --no-recursion so they do not pile up.
+-# Also quote any args containing shell metacharacters.
+-ac_configure_args=
+-for ac_arg
++# Be sure to have absolute paths.
++for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
++ localstatedir libdir includedir oldincludedir infodir mandir
+ do
+- case "$ac_arg" in
+- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+- | --no-cr | --no-c) ;;
+- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
++ eval ac_val=$`echo $ac_var`
++ case $ac_val in
++ [\\/$]* | ?:[\\/]* ) ;;
++ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
++ { (exit 1); exit 1; }; };;
+ esac
+ done
+
+-# NLS nuisances.
+-# Only set these to C if already set. These must not be set unconditionally
+-# because not all systems understand e.g. LANG=C (notably SCO).
+-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+-# Non-C LC_CTYPE values break the ctype check.
+-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
++# There might be people who depend on the old broken behavior: `$host'
++# used to hold the argument of --host etc.
++# FIXME: To remove some day.
++build=$build_alias
++host=$host_alias
++target=$target_alias
++
++# FIXME: To remove some day.
++if test "x$host_alias" != x; then
++ if test "x$build_alias" = x; then
++ cross_compiling=maybe
++ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
++ If a cross compiler is detected then cross compile mode will be used." >&2
++ elif test "x$build_alias" != "x$host_alias"; then
++ cross_compiling=yes
++ fi
++fi
+
+-# confdefs.h avoids OS command line length limits that DEFS can exceed.
+-rm -rf conftest* confdefs.h
+-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+-echo > confdefs.h
++ac_tool_prefix=
++test -n "$host_alias" && ac_tool_prefix=$host_alias-
++
++test "$silent" = yes && exec 6>/dev/null
+
+-# A filename unique to this package, relative to the directory that
+-# configure is in, which we can look for to find out if srcdir is correct.
+-ac_unique_file=src/blackbox.cc
+
+ # Find the source files, if location was not specified.
+ if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+- ac_prog=$0
+- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
++ ac_confdir=`(dirname "$0") 2>/dev/null ||
++$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$0" : 'X\(//\)[^/]' \| \
++ X"$0" : 'X\(//\)$' \| \
++ X"$0" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$0" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+@@ -485,13 +727,491 @@
+ fi
+ if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
++ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
++ { (exit 1); exit 1; }; }
+ else
+- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
++ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
++ { (exit 1); exit 1; }; }
+ fi
+ fi
+-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
++(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
++ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
++ { (exit 1); exit 1; }; }
++srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
++ac_env_build_alias_set=${build_alias+set}
++ac_env_build_alias_value=$build_alias
++ac_cv_env_build_alias_set=${build_alias+set}
++ac_cv_env_build_alias_value=$build_alias
++ac_env_host_alias_set=${host_alias+set}
++ac_env_host_alias_value=$host_alias
++ac_cv_env_host_alias_set=${host_alias+set}
++ac_cv_env_host_alias_value=$host_alias
++ac_env_target_alias_set=${target_alias+set}
++ac_env_target_alias_value=$target_alias
++ac_cv_env_target_alias_set=${target_alias+set}
++ac_cv_env_target_alias_value=$target_alias
++ac_env_CC_set=${CC+set}
++ac_env_CC_value=$CC
++ac_cv_env_CC_set=${CC+set}
++ac_cv_env_CC_value=$CC
++ac_env_CFLAGS_set=${CFLAGS+set}
++ac_env_CFLAGS_value=$CFLAGS
++ac_cv_env_CFLAGS_set=${CFLAGS+set}
++ac_cv_env_CFLAGS_value=$CFLAGS
++ac_env_LDFLAGS_set=${LDFLAGS+set}
++ac_env_LDFLAGS_value=$LDFLAGS
++ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
++ac_cv_env_LDFLAGS_value=$LDFLAGS
++ac_env_CPPFLAGS_set=${CPPFLAGS+set}
++ac_env_CPPFLAGS_value=$CPPFLAGS
++ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
++ac_cv_env_CPPFLAGS_value=$CPPFLAGS
++ac_env_CXX_set=${CXX+set}
++ac_env_CXX_value=$CXX
++ac_cv_env_CXX_set=${CXX+set}
++ac_cv_env_CXX_value=$CXX
++ac_env_CXXFLAGS_set=${CXXFLAGS+set}
++ac_env_CXXFLAGS_value=$CXXFLAGS
++ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
++ac_cv_env_CXXFLAGS_value=$CXXFLAGS
++ac_env_CPP_set=${CPP+set}
++ac_env_CPP_value=$CPP
++ac_cv_env_CPP_set=${CPP+set}
++ac_cv_env_CPP_value=$CPP
++
++#
++# Report the --help message.
++#
++if test "$ac_init_help" = "long"; then
++ # Omit some internal or obsolete options to make the list less imposing.
++ # This message is too long to be a string in the A/UX 3.1 sh.
++ cat <<_ACEOF
++\`configure' configures this package to adapt to many kinds of systems.
++
++Usage: $0 [OPTION]... [VAR=VALUE]...
++
++To assign environment variables (e.g., CC, CFLAGS...), specify them as
++VAR=VALUE. See below for descriptions of some of the useful variables.
++
++Defaults for the options are specified in brackets.
++
++Configuration:
++ -h, --help display this help and exit
++ --help=short display options specific to this package
++ --help=recursive display the short help of all the included packages
++ -V, --version display version information and exit
++ -q, --quiet, --silent do not print \`checking...' messages
++ --cache-file=FILE cache test results in FILE [disabled]
++ -C, --config-cache alias for \`--cache-file=config.cache'
++ -n, --no-create do not create output files
++ --srcdir=DIR find the sources in DIR [configure dir or \`..']
++
++_ACEOF
++
++ cat <<_ACEOF
++Installation directories:
++ --prefix=PREFIX install architecture-independent files in PREFIX
++ [$ac_default_prefix]
++ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
++ [PREFIX]
++
++By default, \`make install' will install all the files in
++\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
++an installation prefix other than \`$ac_default_prefix' using \`--prefix',
++for instance \`--prefix=\$HOME'.
++
++For better control, use the options below.
++
++Fine tuning of the installation directories:
++ --bindir=DIR user executables [EPREFIX/bin]
++ --sbindir=DIR system admin executables [EPREFIX/sbin]
++ --libexecdir=DIR program executables [EPREFIX/libexec]
++ --datadir=DIR read-only architecture-independent data [PREFIX/share]
++ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
++ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
++ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
++ --libdir=DIR object code libraries [EPREFIX/lib]
++ --includedir=DIR C header files [PREFIX/include]
++ --oldincludedir=DIR C header files for non-gcc [/usr/include]
++ --infodir=DIR info documentation [PREFIX/info]
++ --mandir=DIR man documentation [PREFIX/man]
++_ACEOF
++
++ cat <<\_ACEOF
++
++Program names:
++ --program-prefix=PREFIX prepend PREFIX to installed program names
++ --program-suffix=SUFFIX append SUFFIX to installed program names
++ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
++
++X features:
++ --x-includes=DIR X include files are in DIR
++ --x-libraries=DIR X library files are in DIR
++_ACEOF
++fi
++
++if test -n "$ac_init_help"; then
++
++ cat <<\_ACEOF
++
++Optional Features:
++ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
++ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
++ --enable-shape enable support of the XShape extension default=yes
++ --enable-xinerama enable support of the xinerama extension default=yes
++ --enable-ordered-pseudo include code for ordered pseudocolor (8bpp)
++ dithering default=no
++ --enable-debug include verbose debugging code default=no
++ --enable-nls include natural language support default=yes
++ --enable-timed-cache use new timed pixmap cache default=yes
++ --enable-maintainer-mode enable make rules and dependencies not useful
++ (and sometimes confusing) to the casual installer
++
++Optional Packages:
++ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
++ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
++ --with-x use the X Window System
++
++Some influential environment variables:
++ CC C compiler command
++ CFLAGS C compiler flags
++ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
++ nonstandard directory <lib dir>
++ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
++ headers in a nonstandard directory <include dir>
++ CXX C++ compiler command
++ CXXFLAGS C++ compiler flags
++ CPP C preprocessor
++
++Use these variables to override the choices made by `configure' or to help
++it to find libraries and programs with nonstandard names/locations.
++
++_ACEOF
++fi
++
++if test "$ac_init_help" = "recursive"; then
++ # If there are subdirs, report their specific --help.
++ ac_popdir=`pwd`
++ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
++ test -d $ac_dir || continue
++ ac_builddir=.
++
++if test "$ac_dir" != .; then
++ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
++ # A "../" for each directory in $ac_dir_suffix.
++ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
++else
++ ac_dir_suffix= ac_top_builddir=
++fi
++
++case $srcdir in
++ .) # No --srcdir option. We are building in place.
++ ac_srcdir=.
++ if test -z "$ac_top_builddir"; then
++ ac_top_srcdir=.
++ else
++ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
++ fi ;;
++ [\\/]* | ?:[\\/]* ) # Absolute path.
++ ac_srcdir=$srcdir$ac_dir_suffix;
++ ac_top_srcdir=$srcdir ;;
++ *) # Relative path.
++ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
++ ac_top_srcdir=$ac_top_builddir$srcdir ;;
++esac
++
++# Do not use `cd foo && pwd` to compute absolute paths, because
++# the directories may not exist.
++case `pwd` in
++.) ac_abs_builddir="$ac_dir";;
++*)
++ case "$ac_dir" in
++ .) ac_abs_builddir=`pwd`;;
++ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
++ *) ac_abs_builddir=`pwd`/"$ac_dir";;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_builddir=${ac_top_builddir}.;;
++*)
++ case ${ac_top_builddir}. in
++ .) ac_abs_top_builddir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
++ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_srcdir=$ac_srcdir;;
++*)
++ case $ac_srcdir in
++ .) ac_abs_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
++ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_srcdir=$ac_top_srcdir;;
++*)
++ case $ac_top_srcdir in
++ .) ac_abs_top_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
++ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
++ esac;;
++esac
++
++ cd $ac_dir
++ # Check for guested configure; otherwise get Cygnus style configure.
++ if test -f $ac_srcdir/configure.gnu; then
++ echo
++ $SHELL $ac_srcdir/configure.gnu --help=recursive
++ elif test -f $ac_srcdir/configure; then
++ echo
++ $SHELL $ac_srcdir/configure --help=recursive
++ elif test -f $ac_srcdir/configure.ac ||
++ test -f $ac_srcdir/configure.in; then
++ echo
++ $ac_configure --help
++ else
++ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
++ fi
++ cd "$ac_popdir"
++ done
++fi
++
++test -n "$ac_init_help" && exit 0
++if $ac_init_version; then
++ cat <<\_ACEOF
++
++Copyright (C) 2003 Free Software Foundation, Inc.
++This configure script is free software; the Free Software Foundation
++gives unlimited permission to copy, distribute and modify it.
++_ACEOF
++ exit 0
++fi
++exec 5>config.log
++cat >&5 <<_ACEOF
++This file contains any messages produced by compilers while
++running configure, to aid debugging if configure makes a mistake.
++
++It was created by $as_me, which was
++generated by GNU Autoconf 2.59. Invocation command line was
++
++ $ $0 $@
++
++_ACEOF
++{
++cat <<_ASUNAME
++## --------- ##
++## Platform. ##
++## --------- ##
++
++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
++uname -m = `(uname -m) 2>/dev/null || echo unknown`
++uname -r = `(uname -r) 2>/dev/null || echo unknown`
++uname -s = `(uname -s) 2>/dev/null || echo unknown`
++uname -v = `(uname -v) 2>/dev/null || echo unknown`
++
++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
++/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
++
++/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
++/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
++/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
++hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
++/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
++/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
++/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
++
++_ASUNAME
++
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ echo "PATH: $as_dir"
++done
++
++} >&5
++
++cat >&5 <<_ACEOF
++
++
++## ----------- ##
++## Core tests. ##
++## ----------- ##
++
++_ACEOF
++
++
++# Keep a trace of the command line.
++# Strip out --no-create and --no-recursion so they do not pile up.
++# Strip out --silent because we don't want to record it for future runs.
++# Also quote any args containing shell meta-characters.
++# Make two passes to allow for proper duplicate-argument suppression.
++ac_configure_args=
++ac_configure_args0=
++ac_configure_args1=
++ac_sep=
++ac_must_keep_next=false
++for ac_pass in 1 2
++do
++ for ac_arg
++ do
++ case $ac_arg in
++ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
++ | -silent | --silent | --silen | --sile | --sil)
++ continue ;;
++ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
++ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
++ esac
++ case $ac_pass in
++ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
++ 2)
++ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
++ if test $ac_must_keep_next = true; then
++ ac_must_keep_next=false # Got value, back to normal.
++ else
++ case $ac_arg in
++ *=* | --config-cache | -C | -disable-* | --disable-* \
++ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
++ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
++ | -with-* | --with-* | -without-* | --without-* | --x)
++ case "$ac_configure_args0 " in
++ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
++ esac
++ ;;
++ -* ) ac_must_keep_next=true ;;
++ esac
++ fi
++ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
++ # Get rid of the leading space.
++ ac_sep=" "
++ ;;
++ esac
++ done
++done
++$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
++$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
++
++# When interrupted or exit'd, cleanup temporary files, and complete
++# config.log. We remove comments because anyway the quotes in there
++# would cause problems or look ugly.
++# WARNING: Be sure not to use single quotes in there, as some shells,
++# such as our DU 5.0 friend, will then `close' the trap.
++trap 'exit_status=$?
++ # Save into config.log some information that might help in debugging.
++ {
++ echo
++
++ cat <<\_ASBOX
++## ---------------- ##
++## Cache variables. ##
++## ---------------- ##
++_ASBOX
++ echo
++ # The following way of writing the cache mishandles newlines in values,
++{
++ (set) 2>&1 |
++ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
++ *ac_space=\ *)
++ sed -n \
++ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
++ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
++ ;;
++ *)
++ sed -n \
++ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
++ ;;
++ esac;
++}
++ echo
++
++ cat <<\_ASBOX
++## ----------------- ##
++## Output variables. ##
++## ----------------- ##
++_ASBOX
++ echo
++ for ac_var in $ac_subst_vars
++ do
++ eval ac_val=$`echo $ac_var`
++ echo "$ac_var='"'"'$ac_val'"'"'"
++ done | sort
++ echo
++
++ if test -n "$ac_subst_files"; then
++ cat <<\_ASBOX
++## ------------- ##
++## Output files. ##
++## ------------- ##
++_ASBOX
++ echo
++ for ac_var in $ac_subst_files
++ do
++ eval ac_val=$`echo $ac_var`
++ echo "$ac_var='"'"'$ac_val'"'"'"
++ done | sort
++ echo
++ fi
++
++ if test -s confdefs.h; then
++ cat <<\_ASBOX
++## ----------- ##
++## confdefs.h. ##
++## ----------- ##
++_ASBOX
++ echo
++ sed "/^$/d" confdefs.h | sort
++ echo
++ fi
++ test "$ac_signal" != 0 &&
++ echo "$as_me: caught signal $ac_signal"
++ echo "$as_me: exit $exit_status"
++ } >&5
++ rm -f core *.core &&
++ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
++ exit $exit_status
++ ' 0
++for ac_signal in 1 2 13 15; do
++ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
++done
++ac_signal=0
+
++# confdefs.h avoids OS command line length limits that DEFS can exceed.
++rm -rf conftest* confdefs.h
++# AIX cpp loses on an empty file, so make sure it contains at least a newline.
++echo >confdefs.h
++
++# Predefined preprocessor variables.
++
++cat >>confdefs.h <<_ACEOF
++#define PACKAGE_NAME "$PACKAGE_NAME"
++_ACEOF
++
++
++cat >>confdefs.h <<_ACEOF
++#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
++_ACEOF
++
++
++cat >>confdefs.h <<_ACEOF
++#define PACKAGE_VERSION "$PACKAGE_VERSION"
++_ACEOF
++
++
++cat >>confdefs.h <<_ACEOF
++#define PACKAGE_STRING "$PACKAGE_STRING"
++_ACEOF
++
++
++cat >>confdefs.h <<_ACEOF
++#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
++_ACEOF
++
++
++# Let the site file select an alternate cache file if it wants to.
+ # Prefer explicitly selected file to automatically selected ones.
+ if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+@@ -502,39 +1222,103 @@
+ fi
+ for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+- echo "loading site script $ac_site_file"
++ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
++echo "$as_me: loading site script $ac_site_file" >&6;}
++ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+ done
+
+ if test -r "$cache_file"; then
+- echo "loading cache $cache_file"
+- . $cache_file
++ # Some versions of bash will fail to source /dev/null (special
++ # files actually), so we avoid doing that.
++ if test -f "$cache_file"; then
++ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
++echo "$as_me: loading cache $cache_file" >&6;}
++ case $cache_file in
++ [\\/]* | ?:[\\/]* ) . $cache_file;;
++ *) . ./$cache_file;;
++ esac
++ fi
+ else
+- echo "creating cache $cache_file"
+- > $cache_file
++ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
++echo "$as_me: creating cache $cache_file" >&6;}
++ >$cache_file
++fi
++
++# Check that the precious variables saved in the cache have kept the same
++# value.
++ac_cache_corrupted=false
++for ac_var in `(set) 2>&1 |
++ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
++ eval ac_old_set=\$ac_cv_env_${ac_var}_set
++ eval ac_new_set=\$ac_env_${ac_var}_set
++ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
++ eval ac_new_val="\$ac_env_${ac_var}_value"
++ case $ac_old_set,$ac_new_set in
++ set,)
++ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
++echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
++ ac_cache_corrupted=: ;;
++ ,set)
++ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
++echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
++ ac_cache_corrupted=: ;;
++ ,);;
++ *)
++ if test "x$ac_old_val" != "x$ac_new_val"; then
++ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
++echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
++ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
++echo "$as_me: former value: $ac_old_val" >&2;}
++ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
++echo "$as_me: current value: $ac_new_val" >&2;}
++ ac_cache_corrupted=:
++ fi;;
++ esac
++ # Pass precious variables to config.status.
++ if test "$ac_new_set" = set; then
++ case $ac_new_val in
++ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
++ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
++ *) ac_arg=$ac_var=$ac_new_val ;;
++ esac
++ case " $ac_configure_args " in
++ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
++ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
++ esac
++ fi
++done
++if $ac_cache_corrupted; then
++ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
++echo "$as_me: error: changes in the environment can compromise the build" >&2;}
++ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
++echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
++ { (exit 1); exit 1; }; }
+ fi
+
+ ac_ext=c
+-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+-cross_compiling=$ac_cv_prog_cc_cross
+-
+-ac_exeext=
+-ac_objext=o
+-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+- ac_n= ac_c='
+-' ac_t=' '
+- else
+- ac_n=-n ac_c= ac_t=
+- fi
+-else
+- ac_n= ac_c='\c' ac_t=
+-fi
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
+
+ ac_aux_dir=
+@@ -547,14 +1331,20 @@
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
++ elif test -f $ac_dir/shtool; then
++ ac_aux_dir=$ac_dir
++ ac_install_sh="$ac_aux_dir/shtool install -c"
++ break
+ fi
+ done
+ if test -z "$ac_aux_dir"; then
+- { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+-fi
+-ac_config_guess=$ac_aux_dir/config.guess
+-ac_config_sub=$ac_aux_dir/config.sub
+-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
++ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
++echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
++ { (exit 1); exit 1; }; }
++fi
++ac_config_guess="$SHELL $ac_aux_dir/config.guess"
++ac_config_sub="$SHELL $ac_aux_dir/config.sub"
++ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+ # Find a good install program. We prefer a C program (faster),
+ # so one script is as good as another. But avoid the broken or
+@@ -563,65 +1353,80 @@
+ # SunOS /usr/etc/install
+ # IRIX /sbin/install
+ # AIX /bin/install
++# AmigaOS /C/install, which installs bootblocks on floppy discs
+ # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+ # AFS /usr/afsws/bin/install, which mishandles nonexistent args
+ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
++# OS/2's system install, which has a completely different semantic
+ # ./install, which can be erroneously created by make from ./install.sh.
+-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+-echo "configure:572: checking for a BSD compatible install" >&5
++echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
++echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+ if test -z "$INSTALL"; then
+-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++if test "${ac_cv_path_install+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+- for ac_dir in $PATH; do
+- # Account for people who put trailing slashes in PATH elements.
+- case "$ac_dir/" in
+- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+- *)
+- # OSF1 and SCO ODT 3.0 have their own names for install.
+- # Don't use installbsd from OSF since it installs stuff as root
+- # by default.
+- for ac_prog in ginstall scoinst install; do
+- if test -f $ac_dir/$ac_prog; then
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ # Account for people who put trailing slashes in PATH elements.
++case $as_dir/ in
++ ./ | .// | /cC/* | \
++ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
++ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
++ /usr/ucb/* ) ;;
++ *)
++ # OSF1 and SCO ODT 3.0 have their own names for install.
++ # Don't use installbsd from OSF since it installs stuff as root
++ # by default.
++ for ac_prog in ginstall scoinst install; do
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
++ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
++ elif test $ac_prog = install &&
++ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
++ # program-specific install script used by HP pwplus--don't use.
++ :
+ else
+- ac_cv_path_install="$ac_dir/$ac_prog -c"
+- break 2
++ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
++ break 3
+ fi
+ fi
+ done
+- ;;
+- esac
+- done
+- IFS="$ac_save_IFS"
++ done
++ ;;
++esac
++done
++
+
+ fi
+ if test "${ac_cv_path_install+set}" = set; then
+- INSTALL="$ac_cv_path_install"
++ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+- INSTALL="$ac_install_sh"
++ INSTALL=$ac_install_sh
+ fi
+ fi
+-echo "$ac_t""$INSTALL" 1>&6
++echo "$as_me:$LINENO: result: $INSTALL" >&5
++echo "${ECHO_T}$INSTALL" >&6
+
+ # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+ # It thinks the first close brace ends the variable substitution.
+ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
++test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+-echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+-echo "configure:625: checking whether build environment is sane" >&5
++echo "$as_me:$LINENO: checking whether build environment is sane" >&5
++echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
+ # Just in case
+ sleep 1
+ echo timestamp > conftestfile
+@@ -643,8 +1448,11 @@
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+- { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+-alias in your environment" 1>&2; exit 1; }
++ { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
++alias in your environment" >&5
++echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
++alias in your environment" >&2;}
++ { (exit 1); exit 1; }; }
+ fi
+
+ test "$2" = conftestfile
+@@ -653,54 +1461,54 @@
+ # Ok.
+ :
+ else
+- { echo "configure: error: newly created file is older than distributed files!
+-Check your system clock" 1>&2; exit 1; }
++ { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
++Check your system clock" >&5
++echo "$as_me: error: newly created file is older than distributed files!
++Check your system clock" >&2;}
++ { (exit 1); exit 1; }; }
+ fi
+ rm -f conftest*
+-echo "$ac_t""yes" 1>&6
+-if test "$program_transform_name" = s,x,x,; then
+- program_transform_name=
+-else
+- # Double any \ or $. echo might interpret backslashes.
+- cat <<\EOF_SED > conftestsed
+-s,\\,\\\\,g; s,\$,$$,g
+-EOF_SED
+- program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+- rm -f conftestsed
+-fi
++echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ test "$program_prefix" != NONE &&
+- program_transform_name="s,^,${program_prefix},; $program_transform_name"
++ program_transform_name="s,^,$program_prefix,;$program_transform_name"
+ # Use a double $ so make ignores it.
+ test "$program_suffix" != NONE &&
+- program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+-
+-# sed with no file args requires a program.
+-test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+-
+-echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+-echo "configure:682: checking whether ${MAKE-make} sets \${MAKE}" >&5
+-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ program_transform_name="s,\$,$program_suffix,;$program_transform_name"
++# Double any \ or $. echo might interpret backslashes.
++# By default was `s,x,x', remove it if useless.
++cat <<\_ACEOF >conftest.sed
++s/[\\$]/&&/g;s/;s,x,x,$//
++_ACEOF
++program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
++rm conftest.sed
++
++echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
++echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
++set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
++if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- cat > conftestmake <<\EOF
++ cat >conftest.make <<\_ACEOF
+ all:
+- @echo 'ac_maketemp="${MAKE}"'
+-EOF
++ @echo 'ac_maketemp="$(MAKE)"'
++_ACEOF
+ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+-eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
++eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+ if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+ else
+ eval ac_cv_prog_make_${ac_make}_set=no
+ fi
+-rm -f conftestmake
++rm -f conftest.make
+ fi
+ if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+ fi
+
+@@ -710,75 +1518,87 @@
+ VERSION=0.65.0
+
+ if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+- { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
++ { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
++echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
++ { (exit 1); exit 1; }; }
+ fi
+
+
+
+ missing_dir=`cd $ac_aux_dir && pwd`
+-echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
+-echo "configure:721: checking for working aclocal" >&5
++echo "$as_me:$LINENO: checking for working aclocal" >&5
++echo $ECHO_N "checking for working aclocal... $ECHO_C" >&6
+ # Run test in a subshell; some versions of sh will print an error if
+ # an executable is not found, even if stderr is redirected.
+ # Redirect stdin to placate older versions of autoconf. Sigh.
+ if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+- echo "$ac_t""found" 1>&6
++ echo "$as_me:$LINENO: result: found" >&5
++echo "${ECHO_T}found" >&6
+ else
+ ACLOCAL="$missing_dir/missing aclocal"
+- echo "$ac_t""missing" 1>&6
++ echo "$as_me:$LINENO: result: missing" >&5
++echo "${ECHO_T}missing" >&6
+ fi
+
+-echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+-echo "configure:734: checking for working autoconf" >&5
++echo "$as_me:$LINENO: checking for working autoconf" >&5
++echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6
+ # Run test in a subshell; some versions of sh will print an error if
+ # an executable is not found, even if stderr is redirected.
+ # Redirect stdin to placate older versions of autoconf. Sigh.
+ if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+- echo "$ac_t""found" 1>&6
++ echo "$as_me:$LINENO: result: found" >&5
++echo "${ECHO_T}found" >&6
+ else
+ AUTOCONF="$missing_dir/missing autoconf"
+- echo "$ac_t""missing" 1>&6
++ echo "$as_me:$LINENO: result: missing" >&5
++echo "${ECHO_T}missing" >&6
+ fi
+
+-echo $ac_n "checking for working automake""... $ac_c" 1>&6
+-echo "configure:747: checking for working automake" >&5
++echo "$as_me:$LINENO: checking for working automake" >&5
++echo $ECHO_N "checking for working automake... $ECHO_C" >&6
+ # Run test in a subshell; some versions of sh will print an error if
+ # an executable is not found, even if stderr is redirected.
+ # Redirect stdin to placate older versions of autoconf. Sigh.
+ if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+- echo "$ac_t""found" 1>&6
++ echo "$as_me:$LINENO: result: found" >&5
++echo "${ECHO_T}found" >&6
+ else
+ AUTOMAKE="$missing_dir/missing automake"
+- echo "$ac_t""missing" 1>&6
++ echo "$as_me:$LINENO: result: missing" >&5
++echo "${ECHO_T}missing" >&6
+ fi
+
+-echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+-echo "configure:760: checking for working autoheader" >&5
++echo "$as_me:$LINENO: checking for working autoheader" >&5
++echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6
+ # Run test in a subshell; some versions of sh will print an error if
+ # an executable is not found, even if stderr is redirected.
+ # Redirect stdin to placate older versions of autoconf. Sigh.
+ if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+- echo "$ac_t""found" 1>&6
++ echo "$as_me:$LINENO: result: found" >&5
++echo "${ECHO_T}found" >&6
+ else
+ AUTOHEADER="$missing_dir/missing autoheader"
+- echo "$ac_t""missing" 1>&6
++ echo "$as_me:$LINENO: result: missing" >&5
++echo "${ECHO_T}missing" >&6
+ fi
+
+-echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+-echo "configure:773: checking for working makeinfo" >&5
++echo "$as_me:$LINENO: checking for working makeinfo" >&5
++echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6
+ # Run test in a subshell; some versions of sh will print an error if
+ # an executable is not found, even if stderr is redirected.
+ # Redirect stdin to placate older versions of autoconf. Sigh.
+ if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+- echo "$ac_t""found" 1>&6
++ echo "$as_me:$LINENO: result: found" >&5
++echo "${ECHO_T}found" >&6
+ else
+ MAKEINFO="$missing_dir/missing makeinfo"
+- echo "$ac_t""missing" 1>&6
++ echo "$as_me:$LINENO: result: missing" >&5
++echo "${ECHO_T}missing" >&6
+ fi
+
+
+@@ -786,214 +1606,657 @@
+ test x$prefix = "xNONE" && prefix="$ac_default_prefix"
+
+
+-# Extract the first word of "gcc", so it can be a program name with args.
+-set dummy gcc; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:793: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
++set dummy ${ac_tool_prefix}gcc; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+ else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- ac_cv_prog_CC="gcc"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_CC="${ac_tool_prefix}gcc"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ fi
+ fi
+-CC="$ac_cv_prog_CC"
++CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+- echo "$ac_t""$CC" 1>&6
++ echo "$as_me:$LINENO: result: $CC" >&5
++echo "${ECHO_T}$CC" >&6
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+-if test -z "$CC"; then
+- # Extract the first word of "cc", so it can be a program name with args.
+-set dummy cc; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:823: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++fi
++if test -z "$ac_cv_prog_CC"; then
++ ac_ct_CC=$CC
++ # Extract the first word of "gcc", so it can be a program name with args.
++set dummy gcc; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- if test -n "$CC"; then
+- ac_cv_prog_CC="$CC" # Let the user override the test.
++ if test -n "$ac_ct_CC"; then
++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+ else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_prog_rejected=no
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+- ac_prog_rejected=yes
+- continue
+- fi
+- ac_cv_prog_CC="cc"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_CC="gcc"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++fi
++fi
++ac_ct_CC=$ac_cv_prog_ac_ct_CC
++if test -n "$ac_ct_CC"; then
++ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
++echo "${ECHO_T}$ac_ct_CC" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ CC=$ac_ct_CC
++else
++ CC="$ac_cv_prog_CC"
++fi
++
++if test -z "$CC"; then
++ if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
++set dummy ${ac_tool_prefix}cc; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$CC"; then
++ ac_cv_prog_CC="$CC" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_CC="${ac_tool_prefix}cc"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++fi
++fi
++CC=$ac_cv_prog_CC
++if test -n "$CC"; then
++ echo "$as_me:$LINENO: result: $CC" >&5
++echo "${ECHO_T}$CC" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++fi
++if test -z "$ac_cv_prog_CC"; then
++ ac_ct_CC=$CC
++ # Extract the first word of "cc", so it can be a program name with args.
++set dummy cc; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$ac_ct_CC"; then
++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_CC="cc"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++fi
++fi
++ac_ct_CC=$ac_cv_prog_ac_ct_CC
++if test -n "$ac_ct_CC"; then
++ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
++echo "${ECHO_T}$ac_ct_CC" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ CC=$ac_ct_CC
++else
++ CC="$ac_cv_prog_CC"
++fi
++
++fi
++if test -z "$CC"; then
++ # Extract the first word of "cc", so it can be a program name with args.
++set dummy cc; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$CC"; then
++ ac_cv_prog_CC="$CC" # Let the user override the test.
++else
++ ac_prog_rejected=no
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
++ ac_prog_rejected=yes
++ continue
++ fi
++ ac_cv_prog_CC="cc"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+- if test $# -gt 0; then
++ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+- set dummy "$ac_dir/$ac_word" "$@"
+- shift
+- ac_cv_prog_CC="$@"
++ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+ fi
+ fi
+ fi
+-CC="$ac_cv_prog_CC"
++CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+- echo "$ac_t""$CC" 1>&6
++ echo "$as_me:$LINENO: result: $CC" >&5
++echo "${ECHO_T}$CC" >&6
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+- if test -z "$CC"; then
+- case "`uname -s`" in
+- *win32* | *WIN32*)
+- # Extract the first word of "cl", so it can be a program name with args.
+-set dummy cl; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:874: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++fi
++if test -z "$CC"; then
++ if test -n "$ac_tool_prefix"; then
++ for ac_prog in cl
++ do
++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
++set dummy $ac_tool_prefix$ac_prog; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+ else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- ac_cv_prog_CC="cl"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ fi
+ fi
+-CC="$ac_cv_prog_CC"
++CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+- echo "$ac_t""$CC" 1>&6
++ echo "$as_me:$LINENO: result: $CC" >&5
++echo "${ECHO_T}$CC" >&6
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+- ;;
+- esac
++
++ test -n "$CC" && break
++ done
++fi
++if test -z "$CC"; then
++ ac_ct_CC=$CC
++ for ac_prog in cl
++do
++ # Extract the first word of "$ac_prog", so it can be a program name with args.
++set dummy $ac_prog; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$ac_ct_CC"; then
++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_CC="$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
+ fi
+- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
++done
++done
++
++fi
++fi
++ac_ct_CC=$ac_cv_prog_ac_ct_CC
++if test -n "$ac_ct_CC"; then
++ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
++echo "${ECHO_T}$ac_ct_CC" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+-echo "configure:906: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
++ test -n "$ac_ct_CC" && break
++done
+
+-ac_ext=c
+-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+-ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+-cross_compiling=$ac_cv_prog_cc_cross
++ CC=$ac_ct_CC
++fi
+
+-cat > conftest.$ac_ext << EOF
++fi
+
+-#line 917 "configure"
+-#include "confdefs.h"
+
+-main(){return(0);}
+-EOF
+-if { (eval echo configure:922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- ac_cv_prog_cc_works=yes
+- # If we can't run a trivial program, we are probably using a cross compiler.
+- if (./conftest; exit) 2>/dev/null; then
+- ac_cv_prog_cc_cross=no
+- else
+- ac_cv_prog_cc_cross=yes
+- fi
++test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
++See \`config.log' for more details." >&5
++echo "$as_me: error: no acceptable C compiler found in \$PATH
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }
++
++# Provide some information about the compiler.
++echo "$as_me:$LINENO:" \
++ "checking for C compiler version" >&5
++ac_compiler=`set X $ac_compile; echo $2`
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
++ (eval $ac_compiler --version </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
++ (eval $ac_compiler -v </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
++ (eval $ac_compiler -V </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++ac_clean_files_save=$ac_clean_files
++ac_clean_files="$ac_clean_files a.out a.exe b.out"
++# Try to create an executable without -o first, disregard a.out.
++# It will help us diagnose broken compilers, and finding out an intuition
++# of exeext.
++echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
++echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
++ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
++if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
++ (eval $ac_link_default) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; then
++ # Find the output, starting from the most likely. This scheme is
++# not robust to junk in `.', hence go to wildcards (a.*) only as a last
++# resort.
++
++# Be careful to initialize this variable, since it used to be cached.
++# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
++ac_cv_exeext=
++# b.out is created by i960 compilers.
++for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
++do
++ test -f "$ac_file" || continue
++ case $ac_file in
++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
++ ;;
++ conftest.$ac_ext )
++ # This is the source file.
++ ;;
++ [ab].out )
++ # We found the default executable, but exeext='' is most
++ # certainly right.
++ break;;
++ *.* )
++ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
++ # FIXME: I believe we export ac_cv_exeext for Libtool,
++ # but it would be cool to find out if it's true. Does anybody
++ # maintain Libtool? --akim.
++ export ac_cv_exeext
++ break;;
++ * )
++ break;;
++ esac
++done
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- ac_cv_prog_cc_works=no
+-fi
+-rm -fr conftest*
+-ac_ext=c
+-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+-ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+-cross_compiling=$ac_cv_prog_cc_cross
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+-if test $ac_cv_prog_cc_works = no; then
+- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
++{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
++See \`config.log' for more details." >&5
++echo "$as_me: error: C compiler cannot create executables
++See \`config.log' for more details." >&2;}
++ { (exit 77); exit 77; }; }
++fi
++
++ac_exeext=$ac_cv_exeext
++echo "$as_me:$LINENO: result: $ac_file" >&5
++echo "${ECHO_T}$ac_file" >&6
++
++# Check the compiler produces executables we can run. If not, either
++# the compiler is broken, or we cross compile.
++echo "$as_me:$LINENO: checking whether the C compiler works" >&5
++echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
++# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
++# If not cross compiling, check that we can run a simple program.
++if test "$cross_compiling" != yes; then
++ if { ac_try='./$ac_file'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ cross_compiling=no
++ else
++ if test "$cross_compiling" = maybe; then
++ cross_compiling=yes
++ else
++ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
++If you meant to cross compile, use \`--host'.
++See \`config.log' for more details." >&5
++echo "$as_me: error: cannot run C compiled programs.
++If you meant to cross compile, use \`--host'.
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }
++ fi
++ fi
+ fi
+-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+-echo "configure:948: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+-cross_compiling=$ac_cv_prog_cc_cross
++echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+
+-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+-echo "configure:953: checking whether we are using GNU C" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++rm -f a.out a.exe conftest$ac_cv_exeext b.out
++ac_clean_files=$ac_clean_files_save
++# Check the compiler produces executables we can run. If not, either
++# the compiler is broken, or we cross compile.
++echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
++echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
++echo "$as_me:$LINENO: result: $cross_compiling" >&5
++echo "${ECHO_T}$cross_compiling" >&6
++
++echo "$as_me:$LINENO: checking for suffix of executables" >&5
++echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; then
++ # If both `conftest.exe' and `conftest' are `present' (well, observable)
++# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
++# work properly (i.e., refer to `conftest.exe'), while it won't with
++# `rm'.
++for ac_file in conftest.exe conftest conftest.*; do
++ test -f "$ac_file" || continue
++ case $ac_file in
++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
++ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
++ export ac_cv_exeext
++ break;;
++ * ) break;;
++ esac
++done
+ else
+- cat > conftest.c <<EOF
+-#ifdef __GNUC__
+- yes;
+-#endif
+-EOF
+-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+- ac_cv_prog_gcc=yes
++ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
++See \`config.log' for more details." >&5
++echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }
++fi
++
++rm -f conftest$ac_cv_exeext
++echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
++echo "${ECHO_T}$ac_cv_exeext" >&6
++
++rm -f conftest.$ac_ext
++EXEEXT=$ac_cv_exeext
++ac_exeext=$EXEEXT
++echo "$as_me:$LINENO: checking for suffix of object files" >&5
++echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
++if test "${ac_cv_objext+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.o conftest.obj
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; then
++ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
++ case $ac_file in
++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
++ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
++ break;;
++ esac
++done
+ else
+- ac_cv_prog_gcc=no
+-fi
+-fi
+-
+-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-if test $ac_cv_prog_gcc = yes; then
+- GCC=yes
+-else
+- GCC=
+-fi
++{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
++See \`config.log' for more details." >&5
++echo "$as_me: error: cannot compute suffix of object files: cannot compile
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }
++fi
++
++rm -f conftest.$ac_cv_objext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
++echo "${ECHO_T}$ac_cv_objext" >&6
++OBJEXT=$ac_cv_objext
++ac_objext=$OBJEXT
++echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
++echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
++if test "${ac_cv_c_compiler_gnu+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++#ifndef __GNUC__
++ choke me
++#endif
+
+-ac_test_CFLAGS="${CFLAGS+set}"
+-ac_save_CFLAGS="$CFLAGS"
+-CFLAGS=
+-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+-echo "configure:981: checking whether ${CC-cc} accepts -g" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- echo 'void f(){}' > conftest.c
+-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_compiler_gnu=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_compiler_gnu=no
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++ac_cv_c_compiler_gnu=$ac_compiler_gnu
++
++fi
++echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
++echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
++GCC=`test $ac_compiler_gnu = yes && echo yes`
++ac_test_CFLAGS=${CFLAGS+set}
++ac_save_CFLAGS=$CFLAGS
++CFLAGS="-g"
++echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
++echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
++if test "${ac_cv_prog_cc_g+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+ else
+- ac_cv_prog_cc_g=no
+-fi
+-rm -f conftest*
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
++ac_cv_prog_cc_g=no
+ fi
+-
+-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
++echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+ if test "$ac_test_CFLAGS" = set; then
+- CFLAGS="$ac_save_CFLAGS"
++ CFLAGS=$ac_save_CFLAGS
+ elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+@@ -1007,136 +2270,494 @@
+ CFLAGS=
+ fi
+ fi
+-
+-for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
++echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
++echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
++if test "${ac_cv_prog_cc_stdc+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_cv_prog_cc_stdc=no
++ac_save_CC=$CC
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <stdarg.h>
++#include <stdio.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
++struct buf { int x; };
++FILE * (*rcsopen) (struct buf *, struct stat *, int);
++static char *e (p, i)
++ char **p;
++ int i;
++{
++ return p[i];
++}
++static char *f (char * (*g) (char **, int), char **p, ...)
++{
++ char *s;
++ va_list v;
++ va_start (v,p);
++ s = g (p, va_arg (v,int));
++ va_end (v);
++ return s;
++}
++
++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
++ function prototypes and stuff, but not '\xHH' hex character constants.
++ These don't provoke an error unfortunately, instead are silently treated
++ as 'x'. The following induces an error, until -std1 is added to get
++ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
++ array size at least. It's necessary to write '\x00'==0 to get something
++ that's true only with -std1. */
++int osf4_cc_array ['\x00' == 0 ? 1 : -1];
++
++int test (int i, double x);
++struct s1 {int (*f) (int a);};
++struct s2 {int (*f) (double a);};
++int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
++int argc;
++char **argv;
++int
++main ()
++{
++return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
++ ;
++ return 0;
++}
++_ACEOF
++# Don't try gcc -ansi; that turns off useful extensions and
++# breaks some systems' header files.
++# AIX -qlanglvl=ansi
++# Ultrix and OSF/1 -std1
++# HP-UX 10.20 and later -Ae
++# HP-UX older versions -Aa -D_HPUX_SOURCE
++# SVR4 -Xc -D__EXTENSIONS__
++for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+ do
+-# Extract the first word of "$ac_prog", so it can be a program name with args.
+-set dummy $ac_prog; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1017: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ CC="$ac_save_CC $ac_arg"
++ rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_prog_cc_stdc=$ac_arg
++break
+ else
+- if test -n "$CXX"; then
+- ac_cv_prog_CXX="$CXX" # Let the user override the test.
+-else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- ac_cv_prog_CXX="$ac_prog"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
+ fi
++rm -f conftest.err conftest.$ac_objext
++done
++rm -f conftest.$ac_ext conftest.$ac_objext
++CC=$ac_save_CC
++
+ fi
+-CXX="$ac_cv_prog_CXX"
+-if test -n "$CXX"; then
+- echo "$ac_t""$CXX" 1>&6
++
++case "x$ac_cv_prog_cc_stdc" in
++ x|xno)
++ echo "$as_me:$LINENO: result: none needed" >&5
++echo "${ECHO_T}none needed" >&6 ;;
++ *)
++ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
++echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
++ CC="$CC $ac_cv_prog_cc_stdc" ;;
++esac
++
++# Some people use a C++ compiler to compile C. Since we use `exit',
++# in C++ we need to declare it. In case someone uses the same compiler
++# for both compiling C and C++ we need to have the C++ compiler decide
++# the declaration of exit, since it's the most demanding environment.
++cat >conftest.$ac_ext <<_ACEOF
++#ifndef __cplusplus
++ choke me
++#endif
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ for ac_declaration in \
++ '' \
++ 'extern "C" void std::exit (int) throw (); using std::exit;' \
++ 'extern "C" void std::exit (int); using std::exit;' \
++ 'extern "C" void exit (int) throw ();' \
++ 'extern "C" void exit (int);' \
++ 'void exit (int);'
++do
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_declaration
++#include <stdlib.h>
++int
++main ()
++{
++exit (42);
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ :
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++continue
+ fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_declaration
++int
++main ()
++{
++exit (42);
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ break
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-test -n "$CXX" && break
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+-test -n "$CXX" || CXX="gcc"
++rm -f conftest*
++if test -n "$ac_declaration"; then
++ echo '#ifdef __cplusplus' >>confdefs.h
++ echo $ac_declaration >>confdefs.h
++ echo '#endif' >>confdefs.h
++fi
+
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+-echo "configure:1049: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+-ac_ext=C
+-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
++ac_ext=cc
+ ac_cpp='$CXXCPP $CPPFLAGS'
+-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+-cross_compiling=$ac_cv_prog_cxx_cross
+-
+-cat > conftest.$ac_ext << EOF
+-
+-#line 1060 "configure"
+-#include "confdefs.h"
+-
+-int main(){return(0);}
+-EOF
+-if { (eval echo configure:1065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- ac_cv_prog_cxx_works=yes
+- # If we can't run a trivial program, we are probably using a cross compiler.
+- if (./conftest; exit) 2>/dev/null; then
+- ac_cv_prog_cxx_cross=no
+- else
+- ac_cv_prog_cxx_cross=yes
++ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
++if test -n "$ac_tool_prefix"; then
++ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
++ do
++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
++set dummy $ac_tool_prefix$ac_prog; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_CXX+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$CXX"; then
++ ac_cv_prog_CXX="$CXX" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
+ fi
++done
++done
++
++fi
++fi
++CXX=$ac_cv_prog_CXX
++if test -n "$CXX"; then
++ echo "$as_me:$LINENO: result: $CXX" >&5
++echo "${ECHO_T}$CXX" >&6
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- ac_cv_prog_cxx_works=no
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+-rm -fr conftest*
+-ac_ext=c
+-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+-ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+-cross_compiling=$ac_cv_prog_cc_cross
+
+-echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
+-if test $ac_cv_prog_cxx_works = no; then
+- { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
++ test -n "$CXX" && break
++ done
+ fi
+-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+-echo "configure:1091: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+-echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
+-cross_compiling=$ac_cv_prog_cxx_cross
+-
+-echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+-echo "configure:1096: checking whether we are using GNU C++" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++if test -z "$CXX"; then
++ ac_ct_CXX=$CXX
++ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
++do
++ # Extract the first word of "$ac_prog", so it can be a program name with args.
++set dummy $ac_prog; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- cat > conftest.C <<EOF
+-#ifdef __GNUC__
+- yes;
+-#endif
+-EOF
+-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+- ac_cv_prog_gxx=yes
++ if test -n "$ac_ct_CXX"; then
++ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+ else
+- ac_cv_prog_gxx=no
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_CXX="$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ fi
+ fi
++ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
++if test -n "$ac_ct_CXX"; then
++ echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
++echo "${ECHO_T}$ac_ct_CXX" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
+
+-echo "$ac_t""$ac_cv_prog_gxx" 1>&6
++ test -n "$ac_ct_CXX" && break
++done
++test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
+
+-if test $ac_cv_prog_gxx = yes; then
+- GXX=yes
+-else
+- GXX=
++ CXX=$ac_ct_CXX
+ fi
+
+-ac_test_CXXFLAGS="${CXXFLAGS+set}"
+-ac_save_CXXFLAGS="$CXXFLAGS"
+-CXXFLAGS=
+-echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+-echo "configure:1124: checking whether ${CXX-g++} accepts -g" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- echo 'void f(){}' > conftest.cc
+-if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
++
++# Provide some information about the compiler.
++echo "$as_me:$LINENO:" \
++ "checking for C++ compiler version" >&5
++ac_compiler=`set X $ac_compile; echo $2`
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
++ (eval $ac_compiler --version </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
++ (eval $ac_compiler -v </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
++ (eval $ac_compiler -V </dev/null >&5) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }
++
++echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
++echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
++if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++#ifndef __GNUC__
++ choke me
++#endif
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_compiler_gnu=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_compiler_gnu=no
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
++
++fi
++echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
++echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
++GXX=`test $ac_compiler_gnu = yes && echo yes`
++ac_test_CXXFLAGS=${CXXFLAGS+set}
++ac_save_CXXFLAGS=$CXXFLAGS
++CXXFLAGS="-g"
++echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
++echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
++if test "${ac_cv_prog_cxx_g+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_cv_prog_cxx_g=yes
+ else
+- ac_cv_prog_cxx_g=no
+-fi
+-rm -f conftest*
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
++ac_cv_prog_cxx_g=no
+ fi
+-
+-echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
++echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
+ if test "$ac_test_CXXFLAGS" = set; then
+- CXXFLAGS="$ac_save_CXXFLAGS"
++ CXXFLAGS=$ac_save_CXXFLAGS
+ elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+@@ -1150,6 +2771,115 @@
+ CXXFLAGS=
+ fi
+ fi
++for ac_declaration in \
++ '' \
++ 'extern "C" void std::exit (int) throw (); using std::exit;' \
++ 'extern "C" void std::exit (int); using std::exit;' \
++ 'extern "C" void exit (int) throw ();' \
++ 'extern "C" void exit (int);' \
++ 'void exit (int);'
++do
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_declaration
++#include <stdlib.h>
++int
++main ()
++{
++exit (42);
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ :
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++continue
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_declaration
++int
++main ()
++{
++exit (42);
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ break
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++done
++rm -f conftest*
++if test -n "$ac_declaration"; then
++ echo '#ifdef __cplusplus' >>confdefs.h
++ echo $ac_declaration >>confdefs.h
++ echo '#endif' >>confdefs.h
++fi
++
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ # Find a good install program. We prefer a C program (faster),
+ # so one script is as good as another. But avoid the broken or
+@@ -1158,505 +2888,1513 @@
+ # SunOS /usr/etc/install
+ # IRIX /sbin/install
+ # AIX /bin/install
++# AmigaOS /C/install, which installs bootblocks on floppy discs
+ # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+ # AFS /usr/afsws/bin/install, which mishandles nonexistent args
+ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
++# OS/2's system install, which has a completely different semantic
+ # ./install, which can be erroneously created by make from ./install.sh.
+-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+-echo "configure:1167: checking for a BSD compatible install" >&5
++echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
++echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+ if test -z "$INSTALL"; then
+-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++if test "${ac_cv_path_install+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+- for ac_dir in $PATH; do
+- # Account for people who put trailing slashes in PATH elements.
+- case "$ac_dir/" in
+- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+- *)
+- # OSF1 and SCO ODT 3.0 have their own names for install.
+- # Don't use installbsd from OSF since it installs stuff as root
+- # by default.
+- for ac_prog in ginstall scoinst install; do
+- if test -f $ac_dir/$ac_prog; then
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ # Account for people who put trailing slashes in PATH elements.
++case $as_dir/ in
++ ./ | .// | /cC/* | \
++ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
++ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
++ /usr/ucb/* ) ;;
++ *)
++ # OSF1 and SCO ODT 3.0 have their own names for install.
++ # Don't use installbsd from OSF since it installs stuff as root
++ # by default.
++ for ac_prog in ginstall scoinst install; do
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
++ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
++ elif test $ac_prog = install &&
++ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
++ # program-specific install script used by HP pwplus--don't use.
++ :
+ else
+- ac_cv_path_install="$ac_dir/$ac_prog -c"
+- break 2
++ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
++ break 3
+ fi
+ fi
+ done
+- ;;
+- esac
+- done
+- IFS="$ac_save_IFS"
++ done
++ ;;
++esac
++done
++
+
+ fi
+ if test "${ac_cv_path_install+set}" = set; then
+- INSTALL="$ac_cv_path_install"
++ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+- INSTALL="$ac_install_sh"
++ INSTALL=$ac_install_sh
+ fi
+ fi
+-echo "$ac_t""$INSTALL" 1>&6
++echo "$as_me:$LINENO: result: $INSTALL" >&5
++echo "${ECHO_T}$INSTALL" >&6
+
+ # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+ # It thinks the first close brace ends the variable substitution.
+ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
++test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+ for ac_prog in sed
+ do
+-# Extract the first word of "$ac_prog", so it can be a program name with args.
++ # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1225: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_regex_cmd'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_regex_cmd+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ if test -n "$regex_cmd"; then
+ ac_cv_prog_regex_cmd="$regex_cmd" # Let the user override the test.
+ else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- ac_cv_prog_regex_cmd="$ac_prog"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_regex_cmd="$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ fi
+ fi
+-regex_cmd="$ac_cv_prog_regex_cmd"
++regex_cmd=$ac_cv_prog_regex_cmd
+ if test -n "$regex_cmd"; then
+- echo "$ac_t""$regex_cmd" 1>&6
++ echo "$as_me:$LINENO: result: $regex_cmd" >&5
++echo "${ECHO_T}$regex_cmd" >&6
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+-test -n "$regex_cmd" && break
++ test -n "$regex_cmd" && break
+ done
+
+ if test x$regex_cmd = "x"; then
+- { echo "configure: error: error. sed is required to build the default menu file." 1>&2; exit 1; }
++ { { echo "$as_me:$LINENO: error: error. sed is required to build the default menu file." >&5
++echo "$as_me: error: error. sed is required to build the default menu file." >&2;}
++ { (exit 1); exit 1; }; }
+ fi
+
+-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+-echo "configure:1259: checking how to run the C preprocessor" >&5
++
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
++echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+ # On Suns, sometimes $CPP names a directory.
+ if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+ fi
+ if test -z "$CPP"; then
+-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ if test "${ac_cv_prog_CPP+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- # This must be in double quotes, not single quotes, because CPP may get
+- # substituted into the Makefile and "${CC-cc}" will confuse make.
+- CPP="${CC-cc} -E"
++ # Double quotes because CPP needs to be expanded
++ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
++ do
++ ac_preproc_ok=false
++for ac_c_preproc_warn_flag in '' yes
++do
++ # Use a header file that comes with gcc, so configuring glibc
++ # with a fresh cross-compiler works.
++ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+- # not just through cpp.
+- cat > conftest.$ac_ext <<EOF
+-#line 1274 "configure"
+-#include "confdefs.h"
+-#include <assert.h>
+-Syntax Error
+-EOF
+-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1280: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+-if test -z "$ac_err"; then
++ # not just through cpp. "Syntax error" is here to catch this case.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
++ Syntax error
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
+ :
+ else
+- echo "$ac_err" >&5
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- CPP="${CC-cc} -E -traditional-cpp"
+- cat > conftest.$ac_ext <<EOF
+-#line 1291 "configure"
+-#include "confdefs.h"
+-#include <assert.h>
+-Syntax Error
+-EOF
+-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+-if test -z "$ac_err"; then
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ # Broken: fails on valid input.
++continue
++fi
++rm -f conftest.err conftest.$ac_ext
++
++ # OK, works on sane cases. Now check whether non-existent headers
++ # can be detected and how.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <ac_nonexistent.h>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++ # Broken: success on invalid input.
++continue
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ # Passes both tests.
++ac_preproc_ok=:
++break
++fi
++rm -f conftest.err conftest.$ac_ext
++
++done
++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
++rm -f conftest.err conftest.$ac_ext
++if $ac_preproc_ok; then
++ break
++fi
++
++ done
++ ac_cv_prog_CPP=$CPP
++
++fi
++ CPP=$ac_cv_prog_CPP
++else
++ ac_cv_prog_CPP=$CPP
++fi
++echo "$as_me:$LINENO: result: $CPP" >&5
++echo "${ECHO_T}$CPP" >&6
++ac_preproc_ok=false
++for ac_c_preproc_warn_flag in '' yes
++do
++ # Use a header file that comes with gcc, so configuring glibc
++ # with a fresh cross-compiler works.
++ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ # <limits.h> exists even on freestanding compilers.
++ # On the NeXT, cc -E runs the code through the compiler's parser,
++ # not just through cpp. "Syntax error" is here to catch this case.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
++ Syntax error
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++ :
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ # Broken: fails on valid input.
++continue
++fi
++rm -f conftest.err conftest.$ac_ext
++
++ # OK, works on sane cases. Now check whether non-existent headers
++ # can be detected and how.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <ac_nonexistent.h>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++ # Broken: success on invalid input.
++continue
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ # Passes both tests.
++ac_preproc_ok=:
++break
++fi
++rm -f conftest.err conftest.$ac_ext
++
++done
++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
++rm -f conftest.err conftest.$ac_ext
++if $ac_preproc_ok; then
+ :
+ else
+- echo "$ac_err" >&5
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- CPP="${CC-cc} -nologo -E"
+- cat > conftest.$ac_ext <<EOF
+-#line 1308 "configure"
+-#include "confdefs.h"
+-#include <assert.h>
+-Syntax Error
+-EOF
+-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1314: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+-if test -z "$ac_err"; then
++ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
++See \`config.log' for more details." >&5
++echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }
++fi
++
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++
++
++echo "$as_me:$LINENO: checking for egrep" >&5
++echo $ECHO_N "checking for egrep... $ECHO_C" >&6
++if test "${ac_cv_prog_egrep+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
++ then ac_cv_prog_egrep='grep -E'
++ else ac_cv_prog_egrep='egrep'
++ fi
++fi
++echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
++echo "${ECHO_T}$ac_cv_prog_egrep" >&6
++ EGREP=$ac_cv_prog_egrep
++
++
++echo "$as_me:$LINENO: checking for ANSI C header files" >&5
++echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
++if test "${ac_cv_header_stdc+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <stdlib.h>
++#include <stdarg.h>
++#include <string.h>
++#include <float.h>
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_header_stdc=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_header_stdc=no
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++
++if test $ac_cv_header_stdc = yes; then
++ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <string.h>
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+ else
+- echo "$ac_err" >&5
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- CPP=/lib/cpp
++ ac_cv_header_stdc=no
+ fi
+ rm -f conftest*
++
+ fi
+-rm -f conftest*
++
++if test $ac_cv_header_stdc = yes; then
++ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <stdlib.h>
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "free" >/dev/null 2>&1; then
++ :
++else
++ ac_cv_header_stdc=no
+ fi
+ rm -f conftest*
+- ac_cv_prog_CPP="$CPP"
++
+ fi
+- CPP="$ac_cv_prog_CPP"
++
++if test $ac_cv_header_stdc = yes; then
++ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
++ if test "$cross_compiling" = yes; then
++ :
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <ctype.h>
++#if ((' ' & 0x0FF) == 0x020)
++# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
++# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
++#else
++# define ISLOWER(c) \
++ (('a' <= (c) && (c) <= 'i') \
++ || ('j' <= (c) && (c) <= 'r') \
++ || ('s' <= (c) && (c) <= 'z'))
++# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
++#endif
++
++#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
++int
++main ()
++{
++ int i;
++ for (i = 0; i < 256; i++)
++ if (XOR (islower (i), ISLOWER (i))
++ || toupper (i) != TOUPPER (i))
++ exit(2);
++ exit (0);
++}
++_ACEOF
++rm -f conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ :
+ else
+- ac_cv_prog_CPP="$CPP"
++ echo "$as_me: program exited with status $ac_status" >&5
++echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++( exit $ac_status )
++ac_cv_header_stdc=no
++fi
++rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
++fi
++fi
+ fi
+-echo "$ac_t""$CPP" 1>&6
++echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
++echo "${ECHO_T}$ac_cv_header_stdc" >&6
++if test $ac_cv_header_stdc = yes; then
++
++cat >>confdefs.h <<\_ACEOF
++#define STDC_HEADERS 1
++_ACEOF
+
+-for ac_hdr in ctype.h dirent.h fcntl.h libgen.h locale.h nl_types.h process.h signal.h stdarg.h stdio.h stdlib.h string.h time.h unistd.h sys/param.h sys/select.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/wait.h
+-do
+-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:1342: checking for $ac_hdr" >&5
+-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 1347 "configure"
+-#include "confdefs.h"
+-#include <$ac_hdr>
+-EOF
+-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1352: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+-if test -z "$ac_err"; then
+- rm -rf conftest*
+- eval "ac_cv_header_$ac_safe=yes"
+-else
+- echo "$ac_err" >&5
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_header_$ac_safe=no"
+ fi
+-rm -f conftest*
++
++# On IRIX 5.3, sys/types and inttypes.h are conflicting.
++
++
++
++
++
++
++
++
++
++for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
++ inttypes.h stdint.h unistd.h
++do
++as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
++echo "$as_me:$LINENO: checking for $ac_header" >&5
++echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
++if eval "test \"\${$as_ac_Header+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++
++#include <$ac_header>
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ eval "$as_ac_Header=yes"
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++eval "$as_ac_Header=no"
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
++if test `eval echo '${'$as_ac_Header'}'` = yes; then
++ cat >>confdefs.h <<_ACEOF
++#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
++_ACEOF
++
++fi
++
++done
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++for ac_header in ctype.h dirent.h fcntl.h libgen.h locale.h nl_types.h process.h signal.h stdarg.h stdio.h stdlib.h string.h time.h unistd.h sys/param.h sys/select.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/wait.h
++do
++as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
++if eval "test \"\${$as_ac_Header+set}\" = set"; then
++ echo "$as_me:$LINENO: checking for $ac_header" >&5
++echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
++if eval "test \"\${$as_ac_Header+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++fi
++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
++else
++ # Is the header compilable?
++echo "$as_me:$LINENO: checking $ac_header usability" >&5
++echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++#include <$ac_header>
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_header_compiler=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_header_compiler=no
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
++echo "${ECHO_T}$ac_header_compiler" >&6
++
++# Is the header present?
++echo "$as_me:$LINENO: checking $ac_header presence" >&5
++echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <$ac_header>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
+ fi
+-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+- cat >> confdefs.h <<EOF
+-#define $ac_tr_hdr 1
+-EOF
+-
+-else
+- echo "$ac_t""no" 1>&6
++if test -z "$ac_cpp_err"; then
++ ac_header_preproc=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_header_preproc=no
++fi
++rm -f conftest.err conftest.$ac_ext
++echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
++echo "${ECHO_T}$ac_header_preproc" >&6
++
++# So? What about this header?
++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
++ yes:no: )
++ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
++echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
++echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
++ ac_header_preproc=yes
++ ;;
++ no:yes:* )
++ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
++echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
++echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
++echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
++echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
++echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
++ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
++echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
++ (
++ cat <<\_ASBOX
++## ------------------------------------------ ##
++## Report this to the AC_PACKAGE_NAME lists. ##
++## ------------------------------------------ ##
++_ASBOX
++ ) |
++ sed "s/^/$as_me: WARNING: /" >&2
++ ;;
++esac
++echo "$as_me:$LINENO: checking for $ac_header" >&5
++echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
++if eval "test \"\${$as_ac_Header+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ eval "$as_ac_Header=\$ac_header_preproc"
++fi
++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
++
++fi
++if test `eval echo '${'$as_ac_Header'}'` = yes; then
++ cat >>confdefs.h <<_ACEOF
++#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
++_ACEOF
++
+ fi
++
+ done
+
+-echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+-echo "configure:1379: checking whether time.h and sys/time.h may both be included" >&5
+-if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 1384 "configure"
+-#include "confdefs.h"
++echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
++echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
++if test "${ac_cv_header_time+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <time.h>
+-int main() {
+-struct tm *tp;
+-; return 0; }
+-EOF
+-if { (eval echo configure:1393: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+- rm -rf conftest*
++
++int
++main ()
++{
++if ((struct tm *) 0)
++return 0;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_cv_header_time=yes
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- ac_cv_header_time=no
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_header_time=no
+ fi
+-rm -f conftest*
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+-
+-echo "$ac_t""$ac_cv_header_time" 1>&6
++echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
++echo "${ECHO_T}$ac_cv_header_time" >&6
+ if test $ac_cv_header_time = yes; then
+- cat >> confdefs.h <<\EOF
++
++cat >>confdefs.h <<\_ACEOF
+ #define TIME_WITH_SYS_TIME 1
+-EOF
++_ACEOF
+
+ fi
+
+
++
+ for ac_func in basename
+ do
+-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+-echo "configure:1417: checking for $ac_func" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 1422 "configure"
+-#include "confdefs.h"
++as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
++echo "$as_me:$LINENO: checking for $ac_func" >&5
++echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
++if eval "test \"\${$as_ac_var+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define $ac_func innocuous_$ac_func
++
+ /* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char $ac_func(); below. */
+-#include <assert.h>
++ which can conflict with char $ac_func (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
++
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
++
++#undef $ac_func
++
+ /* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char $ac_func ();
++/* The GNU C library defines this for functions which it implements
++ to always fail with ENOSYS. Some functions are actually named
++ something starting with __ and the normal name is an alias. */
++#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++choke me
++#else
++char (*f) () = $ac_func;
++#endif
++#ifdef __cplusplus
++}
++#endif
++
++int
++main ()
++{
++return f != $ac_func;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ eval "$as_ac_var=yes"
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++eval "$as_ac_var=no"
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
++if test `eval echo '${'$as_ac_var'}'` = yes; then
++ cat >>confdefs.h <<_ACEOF
++#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
++_ACEOF
++
++else
++ echo "$as_me:$LINENO: checking for basename in -lgen" >&5
++echo $ECHO_N "checking for basename in -lgen... $ECHO_C" >&6
++if test "${ac_cv_lib_gen_basename+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lgen $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char basename ();
++int
++main ()
++{
++basename ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_gen_basename=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_gen_basename=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_gen_basename" >&5
++echo "${ECHO_T}$ac_cv_lib_gen_basename" >&6
++if test $ac_cv_lib_gen_basename = yes; then
++ cat >>confdefs.h <<\_ACEOF
++#define HAVE_BASENAME 1
++_ACEOF
++ LIBS="$LIBS -lgen"
++fi
++
++fi
++done
++
++
++
++
++
++
++
++
++
++
++
++for ac_func in getpid setlocale sigaction strftime strcasestr snprintf vsnprintf catopen catgets catclose
++do
++as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
++echo "$as_me:$LINENO: checking for $ac_func" >&5
++echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
++if eval "test \"\${$as_ac_var+set}\" = set"; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define $ac_func innocuous_$ac_func
++
++/* System header to define __stub macros and hopefully few prototypes,
++ which can conflict with char $ac_func (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
++
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
++
++#undef $ac_func
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
+ /* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char $ac_func();
++ builtin and then its argument prototype would still apply. */
++char $ac_func ();
++/* The GNU C library defines this for functions which it implements
++ to always fail with ENOSYS. Some functions are actually named
++ something starting with __ and the normal name is an alias. */
++#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++choke me
++#else
++char (*f) () = $ac_func;
++#endif
++#ifdef __cplusplus
++}
++#endif
+
+-int main() {
++int
++main ()
++{
++return f != $ac_func;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ eval "$as_ac_var=yes"
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++eval "$as_ac_var=no"
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
++if test `eval echo '${'$as_ac_var'}'` = yes; then
++ cat >>confdefs.h <<_ACEOF
++#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
++_ACEOF
++
++fi
++done
++
++echo "$as_me:$LINENO: checking for t_open in -lnsl" >&5
++echo $ECHO_N "checking for t_open in -lnsl... $ECHO_C" >&6
++if test "${ac_cv_lib_nsl_t_open+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lnsl $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char t_open ();
++int
++main ()
++{
++t_open ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_nsl_t_open=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_nsl_t_open=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_t_open" >&5
++echo "${ECHO_T}$ac_cv_lib_nsl_t_open" >&6
++if test $ac_cv_lib_nsl_t_open = yes; then
++ LIBS="$LIBS -lnsl"
++fi
++
++echo "$as_me:$LINENO: checking for socket in -lsocket" >&5
++echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6
++if test "${ac_cv_lib_socket_socket+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lsocket $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char socket ();
++int
++main ()
++{
++socket ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_socket_socket=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_socket_socket=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5
++echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6
++if test $ac_cv_lib_socket_socket = yes; then
++ LIBS="$LIBS -lsocket"
++fi
++
++
++echo "$as_me:$LINENO: checking for X" >&5
++echo $ECHO_N "checking for X... $ECHO_C" >&6
++
++ac_path_x_has_been_run=yes
++
++# Check whether --with-x or --without-x was given.
++if test "${with_x+set}" = set; then
++ withval="$with_x"
++
++fi;
++# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
++if test "x$with_x" = xno; then
++ # The user explicitly disabled X.
++ have_x=disabled
++else
++ if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
++ # Both variables are already set.
++ have_x=yes
++ else
++ if test "${ac_cv_have_x+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ # One or both of the vars are not set, and there is no cached value.
++ac_x_includes=no ac_x_libraries=no
++rm -fr conftest.dir
++if mkdir conftest.dir; then
++ cd conftest.dir
++ # Make sure to not put "make" in the Imakefile rules, since we grep it out.
++ cat >Imakefile <<'_ACEOF'
++acfindx:
++ @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
++_ACEOF
++ if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
++ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
++ eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
++ # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
++ for ac_extension in a so sl; do
++ if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
++ test -f $ac_im_libdir/libX11.$ac_extension; then
++ ac_im_usrlibdir=$ac_im_libdir; break
++ fi
++ done
++ # Screen out bogus values from the imake configuration. They are
++ # bogus both because they are the default anyway, and because
++ # using them would break gcc on systems where it needs fixed includes.
++ case $ac_im_incroot in
++ /usr/include) ;;
++ *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
++ esac
++ case $ac_im_usrlibdir in
++ /usr/lib | /lib) ;;
++ *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
++ esac
++ fi
++ cd ..
++ rm -fr conftest.dir
++fi
+
+-/* The GNU C library defines this for functions which it implements
+- to always fail with ENOSYS. Some functions are actually named
+- something starting with __ and the normal name is an alias. */
+-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+-choke me
+-#else
+-$ac_func();
+-#endif
++# Standard set of common directories for X headers.
++# Check X11 before X11Rn because it is often a symlink to the current release.
++ac_x_header_dirs='
++/usr/X11/include
++/usr/X11R6/include
++/usr/X11R5/include
++/usr/X11R4/include
++
++/usr/include/X11
++/usr/include/X11R6
++/usr/include/X11R5
++/usr/include/X11R4
++
++/usr/local/X11/include
++/usr/local/X11R6/include
++/usr/local/X11R5/include
++/usr/local/X11R4/include
++
++/usr/local/include/X11
++/usr/local/include/X11R6
++/usr/local/include/X11R5
++/usr/local/include/X11R4
++
++/usr/X386/include
++/usr/x386/include
++/usr/XFree86/include/X11
++
++/usr/include
++/usr/local/include
++/usr/unsupported/include
++/usr/athena/include
++/usr/local/x11r5/include
++/usr/lpp/Xamples/include
+
+-; return 0; }
+-EOF
+-if { (eval echo configure:1445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_$ac_func=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_$ac_func=no"
+-fi
+-rm -f conftest*
+-fi
++/usr/openwin/include
++/usr/openwin/share/include'
+
+-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+- cat >> confdefs.h <<EOF
+-#define $ac_tr_func 1
+-EOF
+-
+-else
+- echo "$ac_t""no" 1>&6
+-echo $ac_n "checking for basename in -lgen""... $ac_c" 1>&6
+-echo "configure:1467: checking for basename in -lgen" >&5
+-ac_lib_var=`echo gen'_'basename | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++if test "$ac_x_includes" = no; then
++ # Guess where to find include files, by looking for a specified header file.
++ # First, try using that file with no special directory specified.
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <X11/Intrinsic.h>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
+ else
+- ac_save_LIBS="$LIBS"
+-LIBS="-lgen $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 1475 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char basename();
+-
+-int main() {
+-basename()
+-; return 0; }
+-EOF
+-if { (eval echo configure:1486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
++ ac_cpp_err=yes
+ fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
+-
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- cat >> confdefs.h <<\EOF
+-#define HAVE_BASENAME 1
+-EOF
+- LIBS="$LIBS -lgen"
++if test -z "$ac_cpp_err"; then
++ # We can compile using X headers with no special include directory.
++ac_x_includes=
+ else
+- echo "$ac_t""no" 1>&6
+-fi
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-fi
++ for ac_dir in $ac_x_header_dirs; do
++ if test -r "$ac_dir/X11/Intrinsic.h"; then
++ ac_x_includes=$ac_dir
++ break
++ fi
+ done
+-
+-for ac_func in getpid setlocale sigaction strftime strcasestr snprintf vsnprintf catopen catgets catclose
+-do
+-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+-echo "configure:1515: checking for $ac_func" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 1520 "configure"
+-#include "confdefs.h"
+-/* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char $ac_func(); below. */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char $ac_func();
+-
+-int main() {
+-
+-/* The GNU C library defines this for functions which it implements
+- to always fail with ENOSYS. Some functions are actually named
+- something starting with __ and the normal name is an alias. */
+-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+-choke me
+-#else
+-$ac_func();
+-#endif
+-
+-; return 0; }
+-EOF
+-if { (eval echo configure:1543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_$ac_func=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_$ac_func=no"
+-fi
+-rm -f conftest*
+ fi
++rm -f conftest.err conftest.$ac_ext
++fi # $ac_x_includes = no
+
+-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+- cat >> confdefs.h <<EOF
+-#define $ac_tr_func 1
+-EOF
+-
++if test "$ac_x_libraries" = no; then
++ # Check for the libraries.
++ # See if we find them without any special options.
++ # Don't add to $LIBS permanently.
++ ac_save_LIBS=$LIBS
++ LIBS="-lXt $LIBS"
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <X11/Intrinsic.h>
++int
++main ()
++{
++XtMalloc (0)
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ LIBS=$ac_save_LIBS
++# We can link X programs with no special library path.
++ac_x_libraries=
+ else
+- echo "$ac_t""no" 1>&6
+-fi
+-done
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-echo $ac_n "checking for t_open in -lnsl""... $ac_c" 1>&6
+-echo "configure:1568: checking for t_open in -lnsl" >&5
+-ac_lib_var=`echo nsl'_'t_open | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- ac_save_LIBS="$LIBS"
+-LIBS="-lnsl $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 1576 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char t_open();
+-
+-int main() {
+-t_open()
+-; return 0; }
+-EOF
+-if { (eval echo configure:1587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
++LIBS=$ac_save_LIBS
++for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
++do
++ # Don't even attempt the hair of trying to link an X program!
++ for ac_extension in a so sl; do
++ if test -r $ac_dir/libXt.$ac_extension; then
++ ac_x_libraries=$ac_dir
++ break 2
++ fi
++ done
++done
+ fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi # $ac_x_libraries = no
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- LIBS="$LIBS -lnsl"
++if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
++ # Didn't find X anywhere. Cache the known absence of X.
++ ac_cv_have_x="have_x=no"
+ else
+- echo "$ac_t""no" 1>&6
++ # Record where we found X for the cache.
++ ac_cv_have_x="have_x=yes \
++ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+ fi
+-
+-echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+-echo "configure:1608: checking for socket in -lsocket" >&5
+-ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- ac_save_LIBS="$LIBS"
+-LIBS="-lsocket $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 1616 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char socket();
+-
+-int main() {
+-socket()
+-; return 0; }
+-EOF
+-if { (eval echo configure:1627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+ fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- LIBS="$LIBS -lsocket"
++ fi
++ eval "$ac_cv_have_x"
++fi # $with_x != no
++
++if test "$have_x" != yes; then
++ echo "$as_me:$LINENO: result: $have_x" >&5
++echo "${ECHO_T}$have_x" >&6
++ no_x=yes
+ else
+- echo "$ac_t""no" 1>&6
++ # If each of the values was on the command line, it overrides each guess.
++ test "x$x_includes" = xNONE && x_includes=$ac_x_includes
++ test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
++ # Update the cache value to reflect the command line values.
++ ac_cv_have_x="have_x=yes \
++ ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
++ # It might be that x_includes is empty (headers are found in the
++ # standard search path. Then output the corresponding message
++ ac_out_x_includes=$x_includes
++ test "x$x_includes" = x && ac_out_x_includes="in standard search path"
++ echo "$as_me:$LINENO: result: libraries $x_libraries, headers $ac_out_x_includes" >&5
++echo "${ECHO_T}libraries $x_libraries, headers $ac_out_x_includes" >&6
+ fi
+
+
+-# If we find X, set shell vars x_includes and x_libraries to the
+-# paths, otherwise set no_x=yes.
+-# Uses ac_ vars as temps to allow command line to override cache and checks.
+-# --without-x overrides everything else, but does not touch the cache.
+-echo $ac_n "checking for X""... $ac_c" 1>&6
+-echo "configure:1653: checking for X" >&5
++if test "x$ac_path_x_has_been_run" != xyes; then
++ echo "$as_me:$LINENO: checking for X" >&5
++echo $ECHO_N "checking for X... $ECHO_C" >&6
++
++ac_path_x_has_been_run=yes
+
+ # Check whether --with-x or --without-x was given.
+ if test "${with_x+set}" = set; then
+ withval="$with_x"
+- :
+-fi
+
++fi;
+ # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+ if test "x$with_x" = xno; then
+ # The user explicitly disabled X.
+@@ -1666,207 +4404,209 @@
+ # Both variables are already set.
+ have_x=yes
+ else
+-if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ if test "${ac_cv_have_x+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ # One or both of the vars are not set, and there is no cached value.
+-ac_x_includes=NO ac_x_libraries=NO
+-rm -fr conftestdir
+-if mkdir conftestdir; then
+- cd conftestdir
++ac_x_includes=no ac_x_libraries=no
++rm -fr conftest.dir
++if mkdir conftest.dir; then
++ cd conftest.dir
+ # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+- cat > Imakefile <<'EOF'
++ cat >Imakefile <<'_ACEOF'
+ acfindx:
+ @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+-EOF
++_ACEOF
+ if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+ eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+ # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+ for ac_extension in a so sl; do
+ if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
+- test -f $ac_im_libdir/libX11.$ac_extension; then
+- ac_im_usrlibdir=$ac_im_libdir; break
++ test -f $ac_im_libdir/libX11.$ac_extension; then
++ ac_im_usrlibdir=$ac_im_libdir; break
+ fi
+ done
+ # Screen out bogus values from the imake configuration. They are
+ # bogus both because they are the default anyway, and because
+ # using them would break gcc on systems where it needs fixed includes.
+- case "$ac_im_incroot" in
++ case $ac_im_incroot in
+ /usr/include) ;;
+- *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
++ *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+ esac
+- case "$ac_im_usrlibdir" in
++ case $ac_im_usrlibdir in
+ /usr/lib | /lib) ;;
+- *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
++ *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+ esac
+ fi
+ cd ..
+- rm -fr conftestdir
++ rm -fr conftest.dir
+ fi
+
+-if test "$ac_x_includes" = NO; then
+- # Guess where to find include files, by looking for this one X11 .h file.
+- test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
++# Standard set of common directories for X headers.
++# Check X11 before X11Rn because it is often a symlink to the current release.
++ac_x_header_dirs='
++/usr/X11/include
++/usr/X11R6/include
++/usr/X11R5/include
++/usr/X11R4/include
++
++/usr/include/X11
++/usr/include/X11R6
++/usr/include/X11R5
++/usr/include/X11R4
++
++/usr/local/X11/include
++/usr/local/X11R6/include
++/usr/local/X11R5/include
++/usr/local/X11R4/include
++
++/usr/local/include/X11
++/usr/local/include/X11R6
++/usr/local/include/X11R5
++/usr/local/include/X11R4
++
++/usr/X386/include
++/usr/x386/include
++/usr/XFree86/include/X11
++
++/usr/include
++/usr/local/include
++/usr/unsupported/include
++/usr/athena/include
++/usr/local/x11r5/include
++/usr/lpp/Xamples/include
++
++/usr/openwin/include
++/usr/openwin/share/include'
+
++if test "$ac_x_includes" = no; then
++ # Guess where to find include files, by looking for a specified header file.
+ # First, try using that file with no special directory specified.
+-cat > conftest.$ac_ext <<EOF
+-#line 1715 "configure"
+-#include "confdefs.h"
+-#include <$x_direct_test_include>
+-EOF
+-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+-if test -z "$ac_err"; then
+- rm -rf conftest*
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <X11/Intrinsic.h>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
+ # We can compile using X headers with no special include directory.
+ ac_x_includes=
+ else
+- echo "$ac_err" >&5
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- # Look for the header file in a standard set of common directories.
+-# Check X11 before X11Rn because it is often a symlink to the current release.
+- for ac_dir in \
+- /usr/X11/include \
+- /usr/X11R6/include \
+- /usr/X11R5/include \
+- /usr/X11R4/include \
+- \
+- /usr/include/X11 \
+- /usr/include/X11R6 \
+- /usr/include/X11R5 \
+- /usr/include/X11R4 \
+- \
+- /usr/local/X11/include \
+- /usr/local/X11R6/include \
+- /usr/local/X11R5/include \
+- /usr/local/X11R4/include \
+- \
+- /usr/local/include/X11 \
+- /usr/local/include/X11R6 \
+- /usr/local/include/X11R5 \
+- /usr/local/include/X11R4 \
+- \
+- /usr/X386/include \
+- /usr/x386/include \
+- /usr/XFree86/include/X11 \
+- \
+- /usr/include \
+- /usr/local/include \
+- /usr/unsupported/include \
+- /usr/athena/include \
+- /usr/local/x11r5/include \
+- /usr/lpp/Xamples/include \
+- \
+- /usr/openwin/include \
+- /usr/openwin/share/include \
+- ; \
+- do
+- if test -r "$ac_dir/$x_direct_test_include"; then
+- ac_x_includes=$ac_dir
+- break
+- fi
+- done
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ for ac_dir in $ac_x_header_dirs; do
++ if test -r "$ac_dir/X11/Intrinsic.h"; then
++ ac_x_includes=$ac_dir
++ break
++ fi
++done
+ fi
+-rm -f conftest*
+-fi # $ac_x_includes = NO
++rm -f conftest.err conftest.$ac_ext
++fi # $ac_x_includes = no
+
+-if test "$ac_x_libraries" = NO; then
++if test "$ac_x_libraries" = no; then
+ # Check for the libraries.
+-
+- test -z "$x_direct_test_library" && x_direct_test_library=Xt
+- test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
+-
+ # See if we find them without any special options.
+ # Don't add to $LIBS permanently.
+- ac_save_LIBS="$LIBS"
+- LIBS="-l$x_direct_test_library $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 1789 "configure"
+-#include "confdefs.h"
+-
+-int main() {
+-${x_direct_test_function}()
+-; return 0; }
+-EOF
+-if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- LIBS="$ac_save_LIBS"
++ ac_save_LIBS=$LIBS
++ LIBS="-lXt $LIBS"
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <X11/Intrinsic.h>
++int
++main ()
++{
++XtMalloc (0)
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ LIBS=$ac_save_LIBS
+ # We can link X programs with no special library path.
+ ac_x_libraries=
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- LIBS="$ac_save_LIBS"
+-# First see if replacing the include by lib works.
+-# Check X11 before X11Rn because it is often a symlink to the current release.
+-for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
+- /usr/X11/lib \
+- /usr/X11R6/lib \
+- /usr/X11R5/lib \
+- /usr/X11R4/lib \
+- \
+- /usr/lib/X11 \
+- /usr/lib/X11R6 \
+- /usr/lib/X11R5 \
+- /usr/lib/X11R4 \
+- \
+- /usr/local/X11/lib \
+- /usr/local/X11R6/lib \
+- /usr/local/X11R5/lib \
+- /usr/local/X11R4/lib \
+- \
+- /usr/local/lib/X11 \
+- /usr/local/lib/X11R6 \
+- /usr/local/lib/X11R5 \
+- /usr/local/lib/X11R4 \
+- \
+- /usr/X386/lib \
+- /usr/x386/lib \
+- /usr/XFree86/lib/X11 \
+- \
+- /usr/lib \
+- /usr/local/lib \
+- /usr/unsupported/lib \
+- /usr/athena/lib \
+- /usr/local/x11r5/lib \
+- /usr/lpp/Xamples/lib \
+- /lib/usr/lib/X11 \
+- \
+- /usr/openwin/lib \
+- /usr/openwin/share/lib \
+- ; \
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++LIBS=$ac_save_LIBS
++for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+ do
++ # Don't even attempt the hair of trying to link an X program!
+ for ac_extension in a so sl; do
+- if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
++ if test -r $ac_dir/libXt.$ac_extension; then
+ ac_x_libraries=$ac_dir
+ break 2
+ fi
+ done
+ done
+ fi
+-rm -f conftest*
+-fi # $ac_x_libraries = NO
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi # $ac_x_libraries = no
+
+-if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
++if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+ # Didn't find X anywhere. Cache the known absence of X.
+ ac_cv_have_x="have_x=no"
+ else
+ # Record where we found X for the cache.
+ ac_cv_have_x="have_x=yes \
+- ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
++ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+ fi
+ fi
++
+ fi
+ eval "$ac_cv_have_x"
+ fi # $with_x != no
+
+ if test "$have_x" != yes; then
+- echo "$ac_t""$have_x" 1>&6
++ echo "$as_me:$LINENO: result: $have_x" >&5
++echo "${ECHO_T}$have_x" >&6
+ no_x=yes
+ else
+ # If each of the values was on the command line, it overrides each guess.
+@@ -1875,14 +4615,21 @@
+ # Update the cache value to reflect the command line values.
+ ac_cv_have_x="have_x=yes \
+ ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
+- echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6
++ # It might be that x_includes is empty (headers are found in the
++ # standard search path. Then output the corresponding message
++ ac_out_x_includes=$x_includes
++ test "x$x_includes" = x && ac_out_x_includes="in standard search path"
++ echo "$as_me:$LINENO: result: libraries $x_libraries, headers $ac_out_x_includes" >&5
++echo "${ECHO_T}libraries $x_libraries, headers $ac_out_x_includes" >&6
+ fi
+
++fi
+ if test "$no_x" = yes; then
+ # Not all programs may use this symbol, but it does not hurt to define it.
+- cat >> confdefs.h <<\EOF
++
++cat >>confdefs.h <<\_ACEOF
+ #define X_DISPLAY_MISSING 1
+-EOF
++_ACEOF
+
+ X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
+ else
+@@ -1895,60 +4642,117 @@
+ X_LIBS="$X_LIBS -L$x_libraries"
+ # For Solaris; some versions of Sun CC require a space after -R and
+ # others require no space. Words are not sufficient . . . .
+- case "`(uname -sr) 2>/dev/null`" in
++ case `(uname -sr) 2>/dev/null` in
+ "SunOS 5"*)
+- echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
+-echo "configure:1902: checking whether -R must be followed by a space" >&5
+- ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
+- cat > conftest.$ac_ext <<EOF
+-#line 1905 "configure"
+-#include "confdefs.h"
+-
+-int main() {
+-
+-; return 0; }
+-EOF
+-if { (eval echo configure:1912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
++ echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5
++echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
++ ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_R_nospace=yes
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- ac_R_nospace=no
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_R_nospace=no
+ fi
+-rm -f conftest*
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
+ if test $ac_R_nospace = yes; then
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ X_LIBS="$X_LIBS -R$x_libraries"
+ else
+ LIBS="$ac_xsave_LIBS -R $x_libraries"
+- cat > conftest.$ac_ext <<EOF
+-#line 1928 "configure"
+-#include "confdefs.h"
+-
+-int main() {
+-
+-; return 0; }
+-EOF
+-if { (eval echo configure:1935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_R_space=yes
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- ac_R_space=no
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_R_space=no
+ fi
+-rm -f conftest*
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
+ if test $ac_R_space = yes; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ X_LIBS="$X_LIBS -R $x_libraries"
+ else
+- echo "$ac_t""neither works" 1>&6
++ echo "$as_me:$LINENO: result: neither works" >&5
++echo "${ECHO_T}neither works" >&6
+ fi
+ fi
+- LIBS="$ac_xsave_LIBS"
++ LIBS=$ac_xsave_LIBS
+ esac
+ fi
+
+@@ -1959,527 +4763,1010 @@
+ if test "$ISC" = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
+ else
+- # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
+- # libraries were built with DECnet support. And karl@cs.umb.edu says
++ # Martyn Johnson says this is needed for Ultrix, if the X
++ # libraries were built with DECnet support. And Karl Berry says
+ # the Alpha needs dnet_stub (dnet does not exist).
+- echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
+-echo "configure:1967: checking for dnet_ntoa in -ldnet" >&5
+-ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char XOpenDisplay ();
++int
++main ()
++{
++XOpenDisplay ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ :
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5
++echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
++if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-ldnet $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 1975 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char dnet_ntoa();
+-
+-int main() {
+-dnet_ntoa()
+-; return 0; }
+-EOF
+-if { (eval echo configure:1986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char dnet_ntoa ();
++int
++main ()
++{
++dnet_ntoa ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_dnet_dnet_ntoa=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_dnet_dnet_ntoa=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
++echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
++if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+ if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+- echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
+-echo "configure:2008: checking for dnet_ntoa in -ldnet_stub" >&5
+-ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
++echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
++if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-ldnet_stub $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2016 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char dnet_ntoa();
+-
+-int main() {
+-dnet_ntoa()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char dnet_ntoa ();
++int
++main ()
++{
++dnet_ntoa ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_dnet_stub_dnet_ntoa=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_dnet_stub_dnet_ntoa=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
++echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
++if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+ fi
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++ LIBS="$ac_xsave_LIBS"
+
+ # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
+ # to get the SysV transport functions.
+- # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
++ # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
+ # needs -lnsl.
+ # The nsl library prevents programs from opening the X display
+- # on Irix 5.2, according to dickey@clark.net.
+- echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
+-echo "configure:2056: checking for gethostbyname" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 2061 "configure"
+-#include "confdefs.h"
++ # on Irix 5.2, according to T.E. Dickey.
++ # The functions gethostbyname, getservbyname, and inet_addr are
++ # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
++ echo "$as_me:$LINENO: checking for gethostbyname" >&5
++echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
++if test "${ac_cv_func_gethostbyname+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define gethostbyname to an innocuous variant, in case <limits.h> declares gethostbyname.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define gethostbyname innocuous_gethostbyname
++
+ /* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char gethostbyname(); below. */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char gethostbyname();
++ which can conflict with char gethostbyname (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
+
+-int main() {
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
+
++#undef gethostbyname
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char gethostbyname ();
+ /* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
+ choke me
+ #else
+-gethostbyname();
++char (*f) () = gethostbyname;
++#endif
++#ifdef __cplusplus
++}
+ #endif
+
+-; return 0; }
+-EOF
+-if { (eval echo configure:2084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_gethostbyname=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_gethostbyname=no"
+-fi
+-rm -f conftest*
+-fi
++int
++main ()
++{
++return f != gethostbyname;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_func_gethostbyname=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- :
+-else
+- echo "$ac_t""no" 1>&6
++ac_cv_func_gethostbyname=no
+ fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
++echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+
+ if test $ac_cv_func_gethostbyname = no; then
+- echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
+-echo "configure:2105: checking for gethostbyname in -lnsl" >&5
+-ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
++echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
++if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lnsl $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2113 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char gethostbyname();
+-
+-int main() {
+-gethostbyname()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char gethostbyname ();
++int
++main ()
++{
++gethostbyname ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_nsl_gethostbyname=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_nsl_gethostbyname=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
++echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
++if test $ac_cv_lib_nsl_gethostbyname = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
++ if test $ac_cv_lib_nsl_gethostbyname = no; then
++ echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
++echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
++if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lbsd $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char gethostbyname ();
++int
++main ()
++{
++gethostbyname ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_bsd_gethostbyname=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_bsd_gethostbyname=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5
++echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
++if test $ac_cv_lib_bsd_gethostbyname = yes; then
++ X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
++fi
++
++ fi
+ fi
+
+ # lieder@skyler.mavd.honeywell.com says without -lsocket,
+ # socket/setsockopt and other routines are undefined under SCO ODT
+ # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
+- # on later versions), says simon@lia.di.epfl.ch: it contains
+- # gethostby* variants that don't use the nameserver (or something).
+- # -lsocket must be given before -lnsl if both are needed.
+- # We assume that if connect needs -lnsl, so does gethostbyname.
+- echo $ac_n "checking for connect""... $ac_c" 1>&6
+-echo "configure:2154: checking for connect" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 2159 "configure"
+-#include "confdefs.h"
++ # on later versions), says Simon Leinen: it contains gethostby*
++ # variants that don't use the name server (or something). -lsocket
++ # must be given before -lnsl if both are needed. We assume that
++ # if connect needs -lnsl, so does gethostbyname.
++ echo "$as_me:$LINENO: checking for connect" >&5
++echo $ECHO_N "checking for connect... $ECHO_C" >&6
++if test "${ac_cv_func_connect+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define connect to an innocuous variant, in case <limits.h> declares connect.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define connect innocuous_connect
++
+ /* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char connect(); below. */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char connect();
++ which can conflict with char connect (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
++
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
+
+-int main() {
++#undef connect
+
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char connect ();
+ /* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+ #if defined (__stub_connect) || defined (__stub___connect)
+ choke me
+ #else
+-connect();
++char (*f) () = connect;
++#endif
++#ifdef __cplusplus
++}
+ #endif
+
+-; return 0; }
+-EOF
+-if { (eval echo configure:2182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_connect=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_connect=no"
+-fi
+-rm -f conftest*
+-fi
++int
++main ()
++{
++return f != connect;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_func_connect=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- :
+-else
+- echo "$ac_t""no" 1>&6
++ac_cv_func_connect=no
+ fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5
++echo "${ECHO_T}$ac_cv_func_connect" >&6
+
+ if test $ac_cv_func_connect = no; then
+- echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
+-echo "configure:2203: checking for connect in -lsocket" >&5
+-ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: checking for connect in -lsocket" >&5
++echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
++if test "${ac_cv_lib_socket_connect+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2211 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char connect();
+-
+-int main() {
+-connect()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char connect ();
++int
++main ()
++{
++connect ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_socket_connect=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_socket_connect=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5
++echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
++if test $ac_cv_lib_socket_connect = yes; then
+ X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+ fi
+
+- # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
+- echo $ac_n "checking for remove""... $ac_c" 1>&6
+-echo "configure:2246: checking for remove" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 2251 "configure"
+-#include "confdefs.h"
++ # Guillermo Gomez says -lposix is necessary on A/UX.
++ echo "$as_me:$LINENO: checking for remove" >&5
++echo $ECHO_N "checking for remove... $ECHO_C" >&6
++if test "${ac_cv_func_remove+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define remove to an innocuous variant, in case <limits.h> declares remove.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define remove innocuous_remove
++
+ /* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char remove(); below. */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char remove();
++ which can conflict with char remove (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
+
+-int main() {
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
+
++#undef remove
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char remove ();
+ /* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+ #if defined (__stub_remove) || defined (__stub___remove)
+ choke me
+ #else
+-remove();
++char (*f) () = remove;
++#endif
++#ifdef __cplusplus
++}
+ #endif
+
+-; return 0; }
+-EOF
+-if { (eval echo configure:2274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_remove=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_remove=no"
+-fi
+-rm -f conftest*
+-fi
++int
++main ()
++{
++return f != remove;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_func_remove=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- :
+-else
+- echo "$ac_t""no" 1>&6
++ac_cv_func_remove=no
+ fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5
++echo "${ECHO_T}$ac_cv_func_remove" >&6
+
+ if test $ac_cv_func_remove = no; then
+- echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
+-echo "configure:2295: checking for remove in -lposix" >&5
+-ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: checking for remove in -lposix" >&5
++echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
++if test "${ac_cv_lib_posix_remove+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lposix $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2303 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char remove();
+-
+-int main() {
+-remove()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char remove ();
++int
++main ()
++{
++remove ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_posix_remove=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_posix_remove=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5
++echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
++if test $ac_cv_lib_posix_remove = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+ fi
+
+ # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+- echo $ac_n "checking for shmat""... $ac_c" 1>&6
+-echo "configure:2338: checking for shmat" >&5
+-if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 2343 "configure"
+-#include "confdefs.h"
++ echo "$as_me:$LINENO: checking for shmat" >&5
++echo $ECHO_N "checking for shmat... $ECHO_C" >&6
++if test "${ac_cv_func_shmat+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++/* Define shmat to an innocuous variant, in case <limits.h> declares shmat.
++ For example, HP-UX 11i <limits.h> declares gettimeofday. */
++#define shmat innocuous_shmat
++
+ /* System header to define __stub macros and hopefully few prototypes,
+- which can conflict with char shmat(); below. */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char shmat();
++ which can conflict with char shmat (); below.
++ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++ <limits.h> exists even on freestanding compilers. */
++
++#ifdef __STDC__
++# include <limits.h>
++#else
++# include <assert.h>
++#endif
+
+-int main() {
++#undef shmat
+
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char shmat ();
+ /* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+ #if defined (__stub_shmat) || defined (__stub___shmat)
+ choke me
+ #else
+-shmat();
++char (*f) () = shmat;
++#endif
++#ifdef __cplusplus
++}
+ #endif
+
+-; return 0; }
+-EOF
+-if { (eval echo configure:2366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_func_shmat=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_func_shmat=no"
+-fi
+-rm -f conftest*
+-fi
++int
++main ()
++{
++return f != shmat;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_func_shmat=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
+
+-if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- :
+-else
+- echo "$ac_t""no" 1>&6
++ac_cv_func_shmat=no
+ fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5
++echo "${ECHO_T}$ac_cv_func_shmat" >&6
+
+ if test $ac_cv_func_shmat = no; then
+- echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
+-echo "configure:2387: checking for shmat in -lipc" >&5
+-ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: checking for shmat in -lipc" >&5
++echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
++if test "${ac_cv_lib_ipc_shmat+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lipc $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2395 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char shmat();
+-
+-int main() {
+-shmat()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char shmat ();
++int
++main ()
++{
++shmat ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_ipc_shmat=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_ipc_shmat=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5
++echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
++if test $ac_cv_lib_ipc_shmat = yes; then
+ X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+ fi
+ fi
+
+ # Check for libraries that X11R6 Xt/Xaw programs need.
+- ac_save_LDFLAGS="$LDFLAGS"
++ ac_save_LDFLAGS=$LDFLAGS
+ test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
+ # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
+ # check for ICE first), but we must link in the order -lSM -lICE or
+ # we get undefined symbols. So assume we have SM if we have ICE.
+ # These have to be linked with before -lX11, unlike the other
+ # libraries we check for below, so use a different variable.
+- # --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
+- echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
+-echo "configure:2439: checking for IceConnectionNumber in -lICE" >&5
+-ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ # John Interrante, Karl Berry
++ echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5
++echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
++if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
+-LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2447 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char IceConnectionNumber();
+-
+-int main() {
+-IceConnectionNumber()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lICE $X_EXTRA_LIBS $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char IceConnectionNumber ();
++int
++main ()
++{
++IceConnectionNumber ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_ICE_IceConnectionNumber=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_ICE_IceConnectionNumber=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
++echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
++if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+ X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+- LDFLAGS="$ac_save_LDFLAGS"
++ LDFLAGS=$ac_save_LDFLAGS
+
+ fi
+
+
+-test x$no_x = "xyes" && { echo "configure: error: Blackbox requires the X Window System libraries and headers." 1>&2; exit 1; }
++test x$no_x = "xyes" && { { echo "$as_me:$LINENO: error: Blackbox requires the X Window System libraries and headers." >&5
++echo "$as_me: error: Blackbox requires the X Window System libraries and headers." >&2;}
++ { (exit 1); exit 1; }; }
+
+ test x$x_includes = "x" && x_includes="/usr/include"
+ test x$x_libraries = "x" && x_libraries="/usr/lib"
+@@ -2489,71 +5776,107 @@
+ LIBS="$LIBS $X_LIBS"
+ LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS"
+
+-echo $ac_n "checking for GCC""... $ac_c" 1>&6
+-echo "configure:2494: checking for GCC" >&5
++echo "$as_me:$LINENO: checking for GCC" >&5
++echo $ECHO_N "checking for GCC... $ECHO_C" >&6
+ if test x$GCC = "xyes"; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ CXXFLAGS="${CXXFLAGS} -Wall -W -pedantic"
+ else
+- echo "$ac_t""no, trying other compilers" 1>&6
+- echo $ac_n "checking for MIPSpro""... $ac_c" 1>&6
+-echo "configure:2501: checking for MIPSpro" >&5
++ echo "$as_me:$LINENO: result: no, trying other compilers" >&5
++echo "${ECHO_T}no, trying other compilers" >&6
++ echo "$as_me:$LINENO: checking for MIPSpro" >&5
++echo $ECHO_N "checking for MIPSpro... $ECHO_C" >&6
+ mips_pro_ver=`$CC -version 2>&1 | grep -i mipspro | cut -f4 -d ' '`
+ if test "x$mips_pro_ver" = "x"; then
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ else
+- echo "$ac_t""yes, version $mips_pro_ver." 1>&6
+- echo $ac_n "checking for -LANG:std in CXXFLAGS""... $ac_c" 1>&6
+-echo "configure:2508: checking for -LANG:std in CXXFLAGS" >&5
++ echo "$as_me:$LINENO: result: yes, version $mips_pro_ver." >&5
++echo "${ECHO_T}yes, version $mips_pro_ver." >&6
++ echo "$as_me:$LINENO: checking for -LANG:std in CXXFLAGS" >&5
++echo $ECHO_N "checking for -LANG:std in CXXFLAGS... $ECHO_C" >&6
+ lang_std_not_set=`echo $CXXFLAGS | grep "\-LANG:std"`
+ if test "x$lang_std_not_set" = "x"; then
+- echo "$ac_t""not set, setting." 1>&6
++ echo "$as_me:$LINENO: result: not set, setting." >&5
++echo "${ECHO_T}not set, setting." >&6
+ CXXFLAGS="${CXXFLAGS} -LANG:std"
+ else
+- echo "$ac_t""already set." 1>&6
++ echo "$as_me:$LINENO: result: already set." >&5
++echo "${ECHO_T}already set." >&6
+ fi
+- fi
++ fi
+ fi
+
+-echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
+-echo "configure:2520: checking for XOpenDisplay in -lX11" >&5
+-ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++echo "$as_me:$LINENO: checking for XOpenDisplay in -lX11" >&5
++echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
++if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lX11 $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2528 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char XOpenDisplay();
+-
+-int main() {
+-XOpenDisplay()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char XOpenDisplay ();
++int
++main ()
++{
++XOpenDisplay ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_X11_XOpenDisplay=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_X11_XOpenDisplay=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_X11_XOpenDisplay" >&5
++echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
++if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+ LIBS="$LIBS -lX11"
+ else
+- echo "$ac_t""no" 1>&6
+-{ echo "configure: error: Could not find XOpenDisplay in -lX11." 1>&2; exit 1; }
++ { { echo "$as_me:$LINENO: error: Could not find XOpenDisplay in -lX11." >&5
++echo "$as_me: error: Could not find XOpenDisplay in -lX11." >&2;}
++ { (exit 1); exit 1; }; }
+
+ fi
+
+@@ -2563,227 +5886,469 @@
+ Xext_lib=""
+
+ SHAPE=""
+-echo $ac_n "checking whether to build support for the XShape extension""... $ac_c" 1>&6
+-echo "configure:2568: checking whether to build support for the XShape extension" >&5
++echo "$as_me:$LINENO: checking whether to build support for the XShape extension" >&5
++echo $ECHO_N "checking whether to build support for the XShape extension... $ECHO_C" >&6
+ # Check whether --enable-shape or --disable-shape was given.
+ if test "${enable_shape+set}" = set; then
+ enableval="$enable_shape"
+- :
+-fi
+
++fi;
+
+ : ${enableval="yes"}
+ if test x$enableval = "xyes"; then
+- echo "$ac_t""yes" 1>&6
+- echo $ac_n "checking for XShapeCombineShape in -lXext""... $ac_c" 1>&6
+-echo "configure:2580: checking for XShapeCombineShape in -lXext" >&5
+-ac_lib_var=`echo Xext'_'XShapeCombineShape | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++ echo "$as_me:$LINENO: checking for XShapeCombineShape in -lXext" >&5
++echo $ECHO_N "checking for XShapeCombineShape in -lXext... $ECHO_C" >&6
++if test "${ac_cv_lib_Xext_XShapeCombineShape+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lXext $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2588 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char XShapeCombineShape();
+-
+-int main() {
+-XShapeCombineShape()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
+- echo $ac_n "checking for X11/extensions/shape.h""... $ac_c" 1>&6
+-echo "configure:2615: checking for X11/extensions/shape.h" >&5
+- cat > conftest.$ac_ext <<EOF
+-#line 2617 "configure"
+-#include "confdefs.h"
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char XShapeCombineShape ();
++int
++main ()
++{
++XShapeCombineShape ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_Xext_XShapeCombineShape=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_Xext_XShapeCombineShape=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_Xext_XShapeCombineShape" >&5
++echo "${ECHO_T}$ac_cv_lib_Xext_XShapeCombineShape" >&6
++if test $ac_cv_lib_Xext_XShapeCombineShape = yes; then
++ echo "$as_me:$LINENO: checking for X11/extensions/shape.h" >&5
++echo $ECHO_N "checking for X11/extensions/shape.h... $ECHO_C" >&6
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
+ #include <X11/extensions/shape.h>
+
+-int main() {
++int
++main ()
++{
+ long foo = ShapeSet
+-; return 0; }
+-EOF
+-if { (eval echo configure:2627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- echo "$ac_t""yes" 1>&6
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ SHAPE="-DSHAPE"; Xext_lib="-lXext"
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- echo "$ac_t""no" 1>&6
+-
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++
+ fi
+-rm -f conftest*
+-
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++
++fi
++
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++
++LIBS="$LIBS $Xext_lib"
++
++LIBS="$LIBS $X_EXTRA_LIBS"
++
++Xext_lib=""
++
++XINERAMA=""
++echo "$as_me:$LINENO: checking whether to build support for the Xinerama extension" >&5
++echo $ECHO_N "checking whether to build support for the Xinerama extension... $ECHO_C" >&6
++# Check whether --enable-xinerama or --disable-xinerama was given.
++if test "${enable_xinerama+set}" = set; then
++ enableval="$enable_xinerama"
++
++fi;
++
++: ${enableval="yes"}
++if test x$enableval = "xyes"; then
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++ echo "$as_me:$LINENO: checking for XineramaQueryScreens in -lXinerama" >&5
++echo $ECHO_N "checking for XineramaQueryScreens in -lXinerama... $ECHO_C" >&6
++if test "${ac_cv_lib_Xinerama_XineramaQueryScreens+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lXinerama $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char XineramaQueryScreens ();
++int
++main ()
++{
++XineramaQueryScreens ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_Xinerama_XineramaQueryScreens=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_Xinerama_XineramaQueryScreens=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_Xinerama_XineramaQueryScreens" >&5
++echo "${ECHO_T}$ac_cv_lib_Xinerama_XineramaQueryScreens" >&6
++if test $ac_cv_lib_Xinerama_XineramaQueryScreens = yes; then
++ echo "$as_me:$LINENO: checking for X11/extensions/Xinerama.h" >&5
++echo $ECHO_N "checking for X11/extensions/Xinerama.h... $ECHO_C" >&6
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <X11/Xlib.h>
++#include <X11/Xutil.h>
++#include <X11/extensions/Xinerama.h>
++
++int
++main ()
++{
++XineramaScreenInfo* s = 0
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++ XINERAMA="-DXINERAMA"; Xext_lib="-lXext -lXinerama"
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++
+ fi
+
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+
+ LIBS="$LIBS $Xext_lib"
+
+ ORDEREDPSEUDO=""
+-echo $ac_n "checking whether to include Pseudocolor ordered dithering code""... $ac_c" 1>&6
+-echo "configure:2653: checking whether to include Pseudocolor ordered dithering code" >&5
++echo "$as_me:$LINENO: checking whether to include Pseudocolor ordered dithering code" >&5
++echo $ECHO_N "checking whether to include Pseudocolor ordered dithering code... $ECHO_C" >&6
+ # Check whether --enable-ordered-pseudo or --disable-ordered-pseudo was given.
+ if test "${enable_ordered_pseudo+set}" = set; then
+ enableval="$enable_ordered_pseudo"
+ if test x$enableval = "xyes"; then
+- echo "$ac_t""yes" 1>&6
+- ORDEREDPSEUDO="-DORDEREDPSEUDO"
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++ ORDEREDPSEUDO="-DORDEREDPSEUDO"
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+ else
+- echo "$ac_t""no" 1>&6
+-
+-fi
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+
++fi;
+
+
+ DEBUG=""
+-echo $ac_n "checking whether to include verbose debugging code""... $ac_c" 1>&6
+-echo "configure:2672: checking whether to include verbose debugging code" >&5
++echo "$as_me:$LINENO: checking whether to include verbose debugging code" >&5
++echo $ECHO_N "checking whether to include verbose debugging code... $ECHO_C" >&6
+ # Check whether --enable-debug or --disable-debug was given.
+ if test "${enable_debug+set}" = set; then
+ enableval="$enable_debug"
+ if test x$enableval = "xyes"; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ if test x$GCC = "xyes"; then
+ DEBUG="-DDEBUG -fno-inline -g"
+ else
+ DEBUG="-DDEBUG"
+ fi
+ else
+- echo "$ac_t""no" 1>&6
+- DEBUG="-DNDEBUG"
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++ DEBUG="-DNDEBUG"
+ fi
+ else
+- echo "$ac_t""no" 1>&6
+- DEBUG="-DNDEBUG"
+-
+-fi
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++ DEBUG="-DNDEBUG"
+
++fi;
+
+
+ NLS=""
+-echo $ac_n "checking whether to include NLS support""... $ac_c" 1>&6
+-echo "configure:2697: checking whether to include NLS support" >&5
++echo "$as_me:$LINENO: checking whether to include NLS support" >&5
++echo $ECHO_N "checking whether to include NLS support... $ECHO_C" >&6
+ # Check whether --enable-nls or --disable-nls was given.
+ if test "${enable_nls+set}" = set; then
+ enableval="$enable_nls"
+ if test x$enableval = "xyes"; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ NLS="-DNLS"
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+ else
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ NLS="-DNLS"
+
+-fi
+-
++fi;
+
+
+-echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6
+-echo "configure:2716: checking for setlocale in -lxpg4" >&5
+-ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'`
+-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++echo "$as_me:$LINENO: checking for setlocale in -lxpg4" >&5
++echo $ECHO_N "checking for setlocale in -lxpg4... $ECHO_C" >&6
++if test "${ac_cv_lib_xpg4_setlocale+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+- ac_save_LIBS="$LIBS"
++ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lxpg4 $LIBS"
+-cat > conftest.$ac_ext <<EOF
+-#line 2724 "configure"
+-#include "confdefs.h"
+-/* Override any gcc2 internal prototype to avoid an error. */
+-/* We use char because int might match the return type of a gcc2
+- builtin and then its argument prototype would still apply. */
+-char setlocale();
+-
+-int main() {
+-setlocale()
+-; return 0; }
+-EOF
+-if { (eval echo configure:2735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=yes"
+-else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- eval "ac_cv_lib_$ac_lib_var=no"
+-fi
+-rm -f conftest*
+-LIBS="$ac_save_LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+
+-fi
+-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+- echo "$ac_t""yes" 1>&6
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char setlocale ();
++int
++main ()
++{
++setlocale ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_xpg4_setlocale=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_xpg4_setlocale=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_xpg4_setlocale" >&5
++echo "${ECHO_T}$ac_cv_lib_xpg4_setlocale" >&6
++if test $ac_cv_lib_xpg4_setlocale = yes; then
+ LIBS="$LIBS -lxpg4"
+-else
+- echo "$ac_t""no" 1>&6
+ fi
+
+
+ for ac_prog in gencat
+ do
+-# Extract the first word of "$ac_prog", so it can be a program name with args.
++ # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:2761: checking for $ac_word" >&5
+-if eval "test \"`echo '$''{'ac_cv_prog_gencat_cmd'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_gencat_cmd+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ if test -n "$gencat_cmd"; then
+ ac_cv_prog_gencat_cmd="$gencat_cmd" # Let the user override the test.
+ else
+- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+- ac_dummy="$PATH"
+- for ac_dir in $ac_dummy; do
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$ac_word; then
+- ac_cv_prog_gencat_cmd="$ac_prog"
+- break
+- fi
+- done
+- IFS="$ac_save_ifs"
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_gencat_cmd="$ac_prog"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
+ fi
+ fi
+-gencat_cmd="$ac_cv_prog_gencat_cmd"
++gencat_cmd=$ac_cv_prog_gencat_cmd
+ if test -n "$gencat_cmd"; then
+- echo "$ac_t""$gencat_cmd" 1>&6
++ echo "$as_me:$LINENO: result: $gencat_cmd" >&5
++echo "${ECHO_T}$gencat_cmd" >&6
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+
+-test -n "$gencat_cmd" && break
++ test -n "$gencat_cmd" && break
+ done
+
+ if test x$gencat_cmd = "x"; then
+@@ -2792,37 +6357,42 @@
+
+
+ TIMEDCACHE=""
+-echo $ac_n "checking whether to use the new timed pixmap cache""... $ac_c" 1>&6
+-echo "configure:2797: checking whether to use the new timed pixmap cache" >&5
++echo "$as_me:$LINENO: checking whether to use the new timed pixmap cache" >&5
++echo $ECHO_N "checking whether to use the new timed pixmap cache... $ECHO_C" >&6
+ # Check whether --enable-timed-cache or --disable-timed-cache was given.
+ if test "${enable_timed_cache+set}" = set; then
+ enableval="$enable_timed_cache"
+ if test x$enableval = "xyes"; then
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ TIMEDCACHE="-DTIMEDCACHE"
+ else
+- echo "$ac_t""no" 1>&6
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
+ fi
+ else
+- echo "$ac_t""yes" 1>&6
++ echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6
+ TIMEDCACHE="-DTIMEDCACHE"
+
+-fi
+-
++fi;
+
+
+-echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+-echo "configure:2816: checking return type of signal handlers" >&5
+-if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+- echo $ac_n "(cached) $ac_c" 1>&6
+-else
+- cat > conftest.$ac_ext <<EOF
+-#line 2821 "configure"
+-#include "confdefs.h"
++echo "$as_me:$LINENO: checking return type of signal handlers" >&5
++echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
++if test "${ac_cv_type_signal+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
+ #include <sys/types.h>
+ #include <signal.h>
+ #ifdef signal
+-#undef signal
++# undef signal
+ #endif
+ #ifdef __cplusplus
+ extern "C" void (*signal (int, void (*)(int)))(int);
+@@ -2830,41 +6400,65 @@
+ void (*signal ()) ();
+ #endif
+
+-int main() {
++int
++main ()
++{
+ int i;
+-; return 0; }
+-EOF
+-if { (eval echo configure:2838: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+- rm -rf conftest*
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
+ ac_cv_type_signal=void
+ else
+- echo "configure: failed program was:" >&5
+- cat conftest.$ac_ext >&5
+- rm -rf conftest*
+- ac_cv_type_signal=int
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_type_signal=int
+ fi
+-rm -f conftest*
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
++echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
++echo "${ECHO_T}$ac_cv_type_signal" >&6
+
+-echo "$ac_t""$ac_cv_type_signal" 1>&6
+-cat >> confdefs.h <<EOF
++cat >>confdefs.h <<_ACEOF
+ #define RETSIGTYPE $ac_cv_type_signal
+-EOF
++_ACEOF
+
+
+
+-echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+-echo "configure:2858: checking whether to enable maintainer-specific portions of Makefiles" >&5
++echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
++echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+ if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+ else
+ USE_MAINTAINER_MODE=no
+-fi
++fi;
++ echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
++echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6
+
+- echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6
+-
+
+ if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+@@ -2874,460 +6468,1332 @@
+ MAINTAINER_MODE_FALSE=
+ fi
+ MAINT=$MAINTAINER_MODE_TRUE
+-
+
+
+-echo "$ac_t""" 1>&6
+-echo "$ac_t"" $PACKAGE version $VERSION configured successfully." 1>&6
+-echo "$ac_t""" 1>&6
+-echo "$ac_t""Using '$prefix' for installation." 1>&6
+-echo "$ac_t""Using '$CXX' for C++ compiler." 1>&6
+-echo "$ac_t""Building with '$CXXFLAGS' for C++ compiler flags." 1>&6
+-echo "$ac_t""Building with '$LIBS' for linker flags." 1>&6
+-echo "$ac_t""" 1>&6
+
++echo "$as_me:$LINENO: result: " >&5
++echo "${ECHO_T}" >&6
++echo "$as_me:$LINENO: result: $PACKAGE version $VERSION configured successfully." >&5
++echo "${ECHO_T} $PACKAGE version $VERSION configured successfully." >&6
++echo "$as_me:$LINENO: result: " >&5
++echo "${ECHO_T}" >&6
++echo "$as_me:$LINENO: result: Using '$prefix' for installation." >&5
++echo "${ECHO_T}Using '$prefix' for installation." >&6
++echo "$as_me:$LINENO: result: Using '$CXX' for C++ compiler." >&5
++echo "${ECHO_T}Using '$CXX' for C++ compiler." >&6
++echo "$as_me:$LINENO: result: Building with '$CXXFLAGS' for C++ compiler flags." >&5
++echo "${ECHO_T}Building with '$CXXFLAGS' for C++ compiler flags." >&6
++echo "$as_me:$LINENO: result: Building with '$LIBS' for linker flags." >&5
++echo "${ECHO_T}Building with '$LIBS' for linker flags." >&6
++echo "$as_me:$LINENO: result: " >&5
++echo "${ECHO_T}" >&6
+
+
++ ac_config_headers="$ac_config_headers config.h"
+
+-trap '' 1 2 15
+-cat > confcache <<\EOF
++ ac_config_commands="$ac_config_commands default-1"
++
++ ac_config_files="$ac_config_files Makefile src/Makefile util/Makefile data/Makefile data/styles/Makefile doc/Makefile nls/Makefile nls/C/Makefile nls/da_DK/Makefile nls/de_DE/Makefile nls/es_AR/Makefile nls/es_ES/Makefile nls/fr_FR/Makefile nls/hu_HU/Makefile nls/it_IT/Makefile nls/ja_JP/Makefile nls/ko_KR/Makefile nls/lv_LV/Makefile nls/nl_NL/Makefile nls/no_NO/Makefile nls/pl_PL/Makefile nls/pt_BR/Makefile nls/ro_RO/Makefile nls/ru_RU/Makefile nls/sk_SK/Makefile nls/sl_SI/Makefile nls/sv_SE/Makefile nls/uk_UA/Makefile nls/zh_CN/Makefile nls/zh_TW/Makefile version.h"
++cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+ # tests run on this system so they can be shared between configure
+-# scripts and configure runs. It is not useful on other systems.
+-# If it contains results you don't want to keep, you may remove or edit it.
++# scripts and configure runs, see configure's option --config-cache.
++# It is not useful on other systems. If it contains results you don't
++# want to keep, you may remove or edit it.
+ #
+-# By default, configure uses ./config.cache as the cache file,
+-# creating it if it does not exist already. You can give configure
+-# the --cache-file=FILE option to use a different cache file; that is
+-# what configure does when it calls configure scripts in
+-# subdirectories, so they share the cache.
+-# Giving --cache-file=/dev/null disables caching, for debugging configure.
+-# config.status only pays attention to the cache file if you give it the
+-# --recheck option to rerun configure.
++# config.status only pays attention to the cache file if you give it
++# the --recheck option to rerun configure.
+ #
+-EOF
++# `ac_cv_env_foo' variables (set or unset) will be overridden when
++# loading this file, other *unset* `ac_cv_foo' will be assigned the
++# following values.
++
++_ACEOF
++
+ # The following way of writing the cache mishandles newlines in values,
+ # but we know of no workaround that is simple, portable, and efficient.
+ # So, don't put newlines in cache variables' values.
+ # Ultrix sh set writes to stderr and can't be redirected directly,
+ # and sets the high bit in the cache file unless we assign to the vars.
+-(set) 2>&1 |
+- case `(ac_space=' '; set | grep ac_space) 2>&1` in
+- *ac_space=\ *)
+- # `set' does not quote correctly, so add quotes (double-quote substitution
+- # turns \\\\ into \\, and sed turns \\ into \).
+- sed -n \
+- -e "s/'/'\\\\''/g" \
+- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+- ;;
+- *)
+- # `set' quotes correctly as required by POSIX, so do not add quotes.
+- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+- ;;
+- esac >> confcache
+-if cmp -s $cache_file confcache; then
+- :
+-else
++{
++ (set) 2>&1 |
++ case `(ac_space=' '; set | grep ac_space) 2>&1` in
++ *ac_space=\ *)
++ # `set' does not quote correctly, so add quotes (double-quote
++ # substitution turns \\\\ into \\, and sed turns \\ into \).
++ sed -n \
++ "s/'/'\\\\''/g;
++ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
++ ;;
++ *)
++ # `set' quotes correctly as required by POSIX, so do not add quotes.
++ sed -n \
++ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
++ ;;
++ esac;
++} |
++ sed '
++ t clear
++ : clear
++ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
++ t end
++ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
++ : end' >>confcache
++if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+- echo "updating cache $cache_file"
+- cat confcache > $cache_file
++ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
++ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+ fi
+ rm -f confcache
+
+-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+-
+ test "x$prefix" = xNONE && prefix=$ac_default_prefix
+ # Let make expand exec_prefix.
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+-# Any assignment to VPATH causes Sun make to only execute
+-# the first set of double-colon rules, so remove it if not needed.
+-# If there is a colon in the path, we need to keep it.
++# VPATH may cause trouble with some makes, so we remove $(srcdir),
++# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
++# trailing colons and then remove the whole line if VPATH becomes empty
++# (actually we leave an empty line to preserve line numbers).
+ if test "x$srcdir" = x.; then
+- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
++ ac_vpsub='/^[ ]*VPATH[ ]*=/{
++s/:*\$(srcdir):*/:/;
++s/:*\${srcdir}:*/:/;
++s/:*@srcdir@:*/:/;
++s/^\([^=]*=[ ]*\):*/\1/;
++s/:*$//;
++s/^[^=]*=[ ]*$//;
++}'
+ fi
+
+-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+-
+ DEFS=-DHAVE_CONFIG_H
+
+-# Without the "./", some shells look in PATH for config.status.
+-: ${CONFIG_STATUS=./config.status}
++ac_libobjs=
++ac_ltlibobjs=
++for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
++ # 1. Remove the extension, and $U if already installed.
++ ac_i=`echo "$ac_i" |
++ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
++ # 2. Add them.
++ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
++ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
++done
++LIBOBJS=$ac_libobjs
+
+-echo creating $CONFIG_STATUS
+-rm -f $CONFIG_STATUS
+-cat > $CONFIG_STATUS <<EOF
+-#! /bin/sh
+-# Generated automatically by configure.
++LTLIBOBJS=$ac_ltlibobjs
++
++
++
++: ${CONFIG_STATUS=./config.status}
++ac_clean_files_save=$ac_clean_files
++ac_clean_files="$ac_clean_files $CONFIG_STATUS"
++{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
++echo "$as_me: creating $CONFIG_STATUS" >&6;}
++cat >$CONFIG_STATUS <<_ACEOF
++#! $SHELL
++# Generated by $as_me.
+ # Run this file to recreate the current configuration.
+-# This directory was configured as follows,
+-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+-#
+-# $0 $ac_configure_args
+-#
+ # Compiler output produced by configure, useful for debugging
+-# configure, is in ./config.log if it exists.
++# configure, is in config.log if it exists.
+
+-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+-for ac_option
++debug=false
++ac_cs_recheck=false
++ac_cs_silent=false
++SHELL=\${CONFIG_SHELL-$SHELL}
++_ACEOF
++
++cat >>$CONFIG_STATUS <<\_ACEOF
++## --------------------- ##
++## M4sh Initialization. ##
++## --------------------- ##
++
++# Be Bourne compatible
++if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
++ emulate sh
++ NULLCMD=:
++ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
++ # is contrary to our usage. Disable this feature.
++ alias -g '${1+"$@"}'='"$@"'
++elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
++ set -o posix
++fi
++DUALCASE=1; export DUALCASE # for MKS sh
++
++# Support unset when possible.
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ as_unset=unset
++else
++ as_unset=false
++fi
++
++
++# Work around bugs in pre-3.0 UWIN ksh.
++$as_unset ENV MAIL MAILPATH
++PS1='$ '
++PS2='> '
++PS4='+ '
++
++# NLS nuisances.
++for as_var in \
++ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
++ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
++ LC_TELEPHONE LC_TIME
++do
++ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
++ eval $as_var=C; export $as_var
++ else
++ $as_unset $as_var
++ fi
++done
++
++# Required to use basename.
++if expr a : '\(a\)' >/dev/null 2>&1; then
++ as_expr=expr
++else
++ as_expr=false
++fi
++
++if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
++ as_basename=basename
++else
++ as_basename=false
++fi
++
++
++# Name of the executable.
++as_me=`$as_basename "$0" ||
++$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
++ X"$0" : 'X\(//\)$' \| \
++ X"$0" : 'X\(/\)$' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X/"$0" |
++ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
++ /^X\/\(\/\/\)$/{ s//\1/; q; }
++ /^X\/\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++
++
++# PATH needs CR, and LINENO needs CR and PATH.
++# Avoid depending upon Character Ranges.
++as_cr_letters='abcdefghijklmnopqrstuvwxyz'
++as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
++as_cr_Letters=$as_cr_letters$as_cr_LETTERS
++as_cr_digits='0123456789'
++as_cr_alnum=$as_cr_Letters$as_cr_digits
++
++# The user is always right.
++if test "${PATH_SEPARATOR+set}" != set; then
++ echo "#! /bin/sh" >conf$$.sh
++ echo "exit 0" >>conf$$.sh
++ chmod +x conf$$.sh
++ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
++ PATH_SEPARATOR=';'
++ else
++ PATH_SEPARATOR=:
++ fi
++ rm -f conf$$.sh
++fi
++
++
++ as_lineno_1=$LINENO
++ as_lineno_2=$LINENO
++ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
++ test "x$as_lineno_1" != "x$as_lineno_2" &&
++ test "x$as_lineno_3" = "x$as_lineno_2" || {
++ # Find who we are. Look in the path if we contain no path at all
++ # relative or not.
++ case $0 in
++ *[\\/]* ) as_myself=$0 ;;
++ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
++done
++
++ ;;
++ esac
++ # We did not find ourselves, most probably we were run as `sh COMMAND'
++ # in which case we are not to be found in the path.
++ if test "x$as_myself" = x; then
++ as_myself=$0
++ fi
++ if test ! -f "$as_myself"; then
++ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
++echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
++ { (exit 1); exit 1; }; }
++ fi
++ case $CONFIG_SHELL in
++ '')
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for as_base in sh bash ksh sh5; do
++ case $as_dir in
++ /*)
++ if ("$as_dir/$as_base" -c '
++ as_lineno_1=$LINENO
++ as_lineno_2=$LINENO
++ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
++ test "x$as_lineno_1" != "x$as_lineno_2" &&
++ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
++ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
++ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
++ CONFIG_SHELL=$as_dir/$as_base
++ export CONFIG_SHELL
++ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
++ fi;;
++ esac
++ done
++done
++;;
++ esac
++
++ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
++ # uniformly replaced by the line number. The first 'sed' inserts a
++ # line-number line before each line; the second 'sed' does the real
++ # work. The second script uses 'N' to pair each line-number line
++ # with the numbered line, and appends trailing '-' during
++ # substitution so that $LINENO is not a special case at line end.
++ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
++ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
++ sed '=' <$as_myself |
++ sed '
++ N
++ s,$,-,
++ : loop
++ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
++ t loop
++ s,-$,,
++ s,^['$as_cr_digits']*\n,,
++ ' >$as_me.lineno &&
++ chmod +x $as_me.lineno ||
++ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
++echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
++ { (exit 1); exit 1; }; }
++
++ # Don't try to exec as it changes $[0], causing all sort of problems
++ # (the dirname of $[0] is not the place where we might find the
++ # original and so on. Autoconf is especially sensible to this).
++ . ./$as_me.lineno
++ # Exit status is that of the last command.
++ exit
++}
++
++
++case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
++ *c*,-n*) ECHO_N= ECHO_C='
++' ECHO_T=' ' ;;
++ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
++ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
++esac
++
++if expr a : '\(a\)' >/dev/null 2>&1; then
++ as_expr=expr
++else
++ as_expr=false
++fi
++
++rm -f conf$$ conf$$.exe conf$$.file
++echo >conf$$.file
++if ln -s conf$$.file conf$$ 2>/dev/null; then
++ # We could just check for DJGPP; but this test a) works b) is more generic
++ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
++ if test -f conf$$.exe; then
++ # Don't use ln at all; we don't have any links
++ as_ln_s='cp -p'
++ else
++ as_ln_s='ln -s'
++ fi
++elif ln conf$$.file conf$$ 2>/dev/null; then
++ as_ln_s=ln
++else
++ as_ln_s='cp -p'
++fi
++rm -f conf$$ conf$$.exe conf$$.file
++
++if mkdir -p . 2>/dev/null; then
++ as_mkdir_p=:
++else
++ test -d ./-p && rmdir ./-p
++ as_mkdir_p=false
++fi
++
++as_executable_p="test -f"
++
++# Sed expression to map a string onto a valid CPP name.
++as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
++
++# Sed expression to map a string onto a valid variable name.
++as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
++
++
++# IFS
++# We need space, tab and new line, in precisely that order.
++as_nl='
++'
++IFS=" $as_nl"
++
++# CDPATH.
++$as_unset CDPATH
++
++exec 6>&1
++
++# Open the log real soon, to keep \$[0] and so on meaningful, and to
++# report actual input values of CONFIG_FILES etc. instead of their
++# values after options handling. Logging --version etc. is OK.
++exec 5>>config.log
++{
++ echo
++ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
++## Running $as_me. ##
++_ASBOX
++} >&5
++cat >&5 <<_CSEOF
++
++This file was extended by $as_me, which was
++generated by GNU Autoconf 2.59. Invocation command line was
++
++ CONFIG_FILES = $CONFIG_FILES
++ CONFIG_HEADERS = $CONFIG_HEADERS
++ CONFIG_LINKS = $CONFIG_LINKS
++ CONFIG_COMMANDS = $CONFIG_COMMANDS
++ $ $0 $@
++
++_CSEOF
++echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
++echo >&5
++_ACEOF
++
++# Files that config.status was made for.
++if test -n "$ac_config_files"; then
++ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
++fi
++
++if test -n "$ac_config_headers"; then
++ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
++fi
++
++if test -n "$ac_config_links"; then
++ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
++fi
++
++if test -n "$ac_config_commands"; then
++ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
++fi
++
++cat >>$CONFIG_STATUS <<\_ACEOF
++
++ac_cs_usage="\
++\`$as_me' instantiates files from templates according to the
++current configuration.
++
++Usage: $0 [OPTIONS] [FILE]...
++
++ -h, --help print this help, then exit
++ -V, --version print version number, then exit
++ -q, --quiet do not print progress messages
++ -d, --debug don't remove temporary files
++ --recheck update $as_me by reconfiguring in the same conditions
++ --file=FILE[:TEMPLATE]
++ instantiate the configuration file FILE
++ --header=FILE[:TEMPLATE]
++ instantiate the configuration header FILE
++
++Configuration files:
++$config_files
++
++Configuration headers:
++$config_headers
++
++Configuration commands:
++$config_commands
++
++Report bugs to <bug-autoconf@gnu.org>."
++_ACEOF
++
++cat >>$CONFIG_STATUS <<_ACEOF
++ac_cs_version="\\
++config.status
++configured by $0, generated by GNU Autoconf 2.59,
++ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
++
++Copyright (C) 2003 Free Software Foundation, Inc.
++This config.status script is free software; the Free Software Foundation
++gives unlimited permission to copy, distribute and modify it."
++srcdir=$srcdir
++INSTALL="$INSTALL"
++_ACEOF
++
++cat >>$CONFIG_STATUS <<\_ACEOF
++# If no file are specified by the user, then we need to provide default
++# value. By we need to know if files were specified by the user.
++ac_need_defaults=:
++while test $# != 0
+ do
+- case "\$ac_option" in
++ case $1 in
++ --*=*)
++ ac_option=`expr "x$1" : 'x\([^=]*\)='`
++ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
++ ac_shift=:
++ ;;
++ -*)
++ ac_option=$1
++ ac_optarg=$2
++ ac_shift=shift
++ ;;
++ *) # This is not an option, so the user has probably given explicit
++ # arguments.
++ ac_option=$1
++ ac_need_defaults=false;;
++ esac
++
++ case $ac_option in
++ # Handling of the options.
++_ACEOF
++cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+- echo "$CONFIG_STATUS generated by autoconf version 2.13"
+- exit 0 ;;
+- -help | --help | --hel | --he | --h)
+- echo "\$ac_cs_usage"; exit 0 ;;
+- *) echo "\$ac_cs_usage"; exit 1 ;;
++ ac_cs_recheck=: ;;
++ --version | --vers* | -V )
++ echo "$ac_cs_version"; exit 0 ;;
++ --he | --h)
++ # Conflict between --help and --header
++ { { echo "$as_me:$LINENO: error: ambiguous option: $1
++Try \`$0 --help' for more information." >&5
++echo "$as_me: error: ambiguous option: $1
++Try \`$0 --help' for more information." >&2;}
++ { (exit 1); exit 1; }; };;
++ --help | --hel | -h )
++ echo "$ac_cs_usage"; exit 0 ;;
++ --debug | --d* | -d )
++ debug=: ;;
++ --file | --fil | --fi | --f )
++ $ac_shift
++ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
++ ac_need_defaults=false;;
++ --header | --heade | --head | --hea )
++ $ac_shift
++ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
++ ac_need_defaults=false;;
++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
++ | -silent | --silent | --silen | --sile | --sil | --si | --s)
++ ac_cs_silent=: ;;
++
++ # This is an error.
++ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
++Try \`$0 --help' for more information." >&5
++echo "$as_me: error: unrecognized option: $1
++Try \`$0 --help' for more information." >&2;}
++ { (exit 1); exit 1; }; } ;;
++
++ *) ac_config_targets="$ac_config_targets $1" ;;
++
+ esac
++ shift
+ done
+
+-ac_given_srcdir=$srcdir
+-ac_given_INSTALL="$INSTALL"
++ac_configure_extra_args=
+
+-trap 'rm -fr `echo "Makefile
+-src/Makefile
+-util/Makefile
+-data/Makefile
+-data/styles/Makefile
+-doc/Makefile
+-nls/Makefile
+-nls/C/Makefile
+-nls/da_DK/Makefile
+-nls/de_DE/Makefile
+-nls/es_AR/Makefile
+-nls/es_ES/Makefile
+-nls/fr_FR/Makefile
+-nls/hu_HU/Makefile
+-nls/it_IT/Makefile
+-nls/ja_JP/Makefile
+-nls/ko_KR/Makefile
+-nls/lv_LV/Makefile
+-nls/nl_NL/Makefile
+-nls/no_NO/Makefile
+-nls/pl_PL/Makefile
+-nls/pt_BR/Makefile
+-nls/ro_RO/Makefile
+-nls/ru_RU/Makefile
+-nls/sk_SK/Makefile
+-nls/sl_SI/Makefile
+-nls/sv_SE/Makefile
+-nls/uk_UA/Makefile
+-nls/zh_CN/Makefile
+-nls/zh_TW/Makefile
+-version.h config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+-EOF
+-cat >> $CONFIG_STATUS <<EOF
+-
+-# Protect against being on the right side of a sed subst in config.status.
+-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+-$ac_vpsub
+-$extrasub
+-s%@SHELL@%$SHELL%g
+-s%@CFLAGS@%$CFLAGS%g
+-s%@CPPFLAGS@%$CPPFLAGS%g
+-s%@CXXFLAGS@%$CXXFLAGS%g
+-s%@FFLAGS@%$FFLAGS%g
+-s%@DEFS@%$DEFS%g
+-s%@LDFLAGS@%$LDFLAGS%g
+-s%@LIBS@%$LIBS%g
+-s%@exec_prefix@%$exec_prefix%g
+-s%@prefix@%$prefix%g
+-s%@program_transform_name@%$program_transform_name%g
+-s%@bindir@%$bindir%g
+-s%@sbindir@%$sbindir%g
+-s%@libexecdir@%$libexecdir%g
+-s%@datadir@%$datadir%g
+-s%@sysconfdir@%$sysconfdir%g
+-s%@sharedstatedir@%$sharedstatedir%g
+-s%@localstatedir@%$localstatedir%g
+-s%@libdir@%$libdir%g
+-s%@includedir@%$includedir%g
+-s%@oldincludedir@%$oldincludedir%g
+-s%@infodir@%$infodir%g
+-s%@mandir@%$mandir%g
+-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+-s%@INSTALL_DATA@%$INSTALL_DATA%g
+-s%@PACKAGE@%$PACKAGE%g
+-s%@VERSION@%$VERSION%g
+-s%@ACLOCAL@%$ACLOCAL%g
+-s%@AUTOCONF@%$AUTOCONF%g
+-s%@AUTOMAKE@%$AUTOMAKE%g
+-s%@AUTOHEADER@%$AUTOHEADER%g
+-s%@MAKEINFO@%$MAKEINFO%g
+-s%@SET_MAKE@%$SET_MAKE%g
+-s%@CC@%$CC%g
+-s%@CXX@%$CXX%g
+-s%@regex_cmd@%$regex_cmd%g
+-s%@CPP@%$CPP%g
+-s%@X_CFLAGS@%$X_CFLAGS%g
+-s%@X_PRE_LIBS@%$X_PRE_LIBS%g
+-s%@X_LIBS@%$X_LIBS%g
+-s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
+-s%@SHAPE@%$SHAPE%g
+-s%@ORDEREDPSEUDO@%$ORDEREDPSEUDO%g
+-s%@DEBUG@%$DEBUG%g
+-s%@NLS@%$NLS%g
+-s%@gencat_cmd@%$gencat_cmd%g
+-s%@TIMEDCACHE@%$TIMEDCACHE%g
+-s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g
+-s%@MAINTAINER_MODE_FALSE@%$MAINTAINER_MODE_FALSE%g
+-s%@MAINT@%$MAINT%g
++if $ac_cs_silent; then
++ exec 6>/dev/null
++ ac_configure_extra_args="$ac_configure_extra_args --silent"
++fi
++
++_ACEOF
++cat >>$CONFIG_STATUS <<_ACEOF
++if \$ac_cs_recheck; then
++ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
++ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
++fi
++
++_ACEOF
++
++cat >>$CONFIG_STATUS <<_ACEOF
++#
++# INIT-COMMANDS section.
++#
++
++
++
++_ACEOF
++
++
++
++cat >>$CONFIG_STATUS <<\_ACEOF
++for ac_config_target in $ac_config_targets
++do
++ case "$ac_config_target" in
++ # Handling of arguments.
++ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
++ "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
++ "util/Makefile" ) CONFIG_FILES="$CONFIG_FILES util/Makefile" ;;
++ "data/Makefile" ) CONFIG_FILES="$CONFIG_FILES data/Makefile" ;;
++ "data/styles/Makefile" ) CONFIG_FILES="$CONFIG_FILES data/styles/Makefile" ;;
++ "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
++ "nls/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/Makefile" ;;
++ "nls/C/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/C/Makefile" ;;
++ "nls/da_DK/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/da_DK/Makefile" ;;
++ "nls/de_DE/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/de_DE/Makefile" ;;
++ "nls/es_AR/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/es_AR/Makefile" ;;
++ "nls/es_ES/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/es_ES/Makefile" ;;
++ "nls/fr_FR/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/fr_FR/Makefile" ;;
++ "nls/hu_HU/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/hu_HU/Makefile" ;;
++ "nls/it_IT/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/it_IT/Makefile" ;;
++ "nls/ja_JP/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/ja_JP/Makefile" ;;
++ "nls/ko_KR/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/ko_KR/Makefile" ;;
++ "nls/lv_LV/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/lv_LV/Makefile" ;;
++ "nls/nl_NL/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/nl_NL/Makefile" ;;
++ "nls/no_NO/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/no_NO/Makefile" ;;
++ "nls/pl_PL/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/pl_PL/Makefile" ;;
++ "nls/pt_BR/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/pt_BR/Makefile" ;;
++ "nls/ro_RO/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/ro_RO/Makefile" ;;
++ "nls/ru_RU/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/ru_RU/Makefile" ;;
++ "nls/sk_SK/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/sk_SK/Makefile" ;;
++ "nls/sl_SI/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/sl_SI/Makefile" ;;
++ "nls/sv_SE/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/sv_SE/Makefile" ;;
++ "nls/uk_UA/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/uk_UA/Makefile" ;;
++ "nls/zh_CN/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/zh_CN/Makefile" ;;
++ "nls/zh_TW/Makefile" ) CONFIG_FILES="$CONFIG_FILES nls/zh_TW/Makefile" ;;
++ "version.h" ) CONFIG_FILES="$CONFIG_FILES version.h" ;;
++ "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
++ "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
++ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
++echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
++ { (exit 1); exit 1; }; };;
++ esac
++done
++
++# If the user did not use the arguments to specify the items to instantiate,
++# then the envvar interface is used. Set only those that are not.
++# We use the long form for the default assignment because of an extremely
++# bizarre bug on SunOS 4.1.3.
++if $ac_need_defaults; then
++ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
++ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
++ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
++fi
++
++# Have a temporary directory for convenience. Make it in the build tree
++# simply because there is no reason to put it here, and in addition,
++# creating and moving files from /tmp can sometimes cause problems.
++# Create a temporary directory, and hook for its removal unless debugging.
++$debug ||
++{
++ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
++ trap '{ (exit 1); exit 1; }' 1 2 13 15
++}
++
++# Create a (secure) tmp directory for tmp files.
++
++{
++ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
++ test -n "$tmp" && test -d "$tmp"
++} ||
++{
++ tmp=./confstat$$-$RANDOM
++ (umask 077 && mkdir $tmp)
++} ||
++{
++ echo "$me: cannot create a temporary directory in ." >&2
++ { (exit 1); exit 1; }
++}
++
++_ACEOF
++
++cat >>$CONFIG_STATUS <<_ACEOF
++
++#
++# CONFIG_FILES section.
++#
+
++# No need to generate the scripts if there are no CONFIG_FILES.
++# This happens for instance when ./config.status config.h
++if test -n "\$CONFIG_FILES"; then
++ # Protect against being on the right side of a sed subst in config.status.
++ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
++ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
++s,@SHELL@,$SHELL,;t t
++s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
++s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
++s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
++s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
++s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
++s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
++s,@exec_prefix@,$exec_prefix,;t t
++s,@prefix@,$prefix,;t t
++s,@program_transform_name@,$program_transform_name,;t t
++s,@bindir@,$bindir,;t t
++s,@sbindir@,$sbindir,;t t
++s,@libexecdir@,$libexecdir,;t t
++s,@datadir@,$datadir,;t t
++s,@sysconfdir@,$sysconfdir,;t t
++s,@sharedstatedir@,$sharedstatedir,;t t
++s,@localstatedir@,$localstatedir,;t t
++s,@libdir@,$libdir,;t t
++s,@includedir@,$includedir,;t t
++s,@oldincludedir@,$oldincludedir,;t t
++s,@infodir@,$infodir,;t t
++s,@mandir@,$mandir,;t t
++s,@build_alias@,$build_alias,;t t
++s,@host_alias@,$host_alias,;t t
++s,@target_alias@,$target_alias,;t t
++s,@DEFS@,$DEFS,;t t
++s,@ECHO_C@,$ECHO_C,;t t
++s,@ECHO_N@,$ECHO_N,;t t
++s,@ECHO_T@,$ECHO_T,;t t
++s,@LIBS@,$LIBS,;t t
++s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
++s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
++s,@INSTALL_DATA@,$INSTALL_DATA,;t t
++s,@PACKAGE@,$PACKAGE,;t t
++s,@VERSION@,$VERSION,;t t
++s,@ACLOCAL@,$ACLOCAL,;t t
++s,@AUTOCONF@,$AUTOCONF,;t t
++s,@AUTOMAKE@,$AUTOMAKE,;t t
++s,@AUTOHEADER@,$AUTOHEADER,;t t
++s,@MAKEINFO@,$MAKEINFO,;t t
++s,@SET_MAKE@,$SET_MAKE,;t t
++s,@CC@,$CC,;t t
++s,@CFLAGS@,$CFLAGS,;t t
++s,@LDFLAGS@,$LDFLAGS,;t t
++s,@CPPFLAGS@,$CPPFLAGS,;t t
++s,@ac_ct_CC@,$ac_ct_CC,;t t
++s,@EXEEXT@,$EXEEXT,;t t
++s,@OBJEXT@,$OBJEXT,;t t
++s,@CXX@,$CXX,;t t
++s,@CXXFLAGS@,$CXXFLAGS,;t t
++s,@ac_ct_CXX@,$ac_ct_CXX,;t t
++s,@regex_cmd@,$regex_cmd,;t t
++s,@CPP@,$CPP,;t t
++s,@EGREP@,$EGREP,;t t
++s,@X_CFLAGS@,$X_CFLAGS,;t t
++s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
++s,@X_LIBS@,$X_LIBS,;t t
++s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
++s,@SHAPE@,$SHAPE,;t t
++s,@XINERAMA@,$XINERAMA,;t t
++s,@ORDEREDPSEUDO@,$ORDEREDPSEUDO,;t t
++s,@DEBUG@,$DEBUG,;t t
++s,@NLS@,$NLS,;t t
++s,@gencat_cmd@,$gencat_cmd,;t t
++s,@TIMEDCACHE@,$TIMEDCACHE,;t t
++s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
++s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
++s,@MAINT@,$MAINT,;t t
++s,@LIBOBJS@,$LIBOBJS,;t t
++s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+ CEOF
+-EOF
+
+-cat >> $CONFIG_STATUS <<\EOF
++_ACEOF
+
+-# Split the substitutions into bite-sized pieces for seds with
+-# small command number limits, like on Digital OSF/1 and HP-UX.
+-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+-ac_file=1 # Number of current file.
+-ac_beg=1 # First line for current file.
+-ac_end=$ac_max_sed_cmds # Line after last line for current file.
+-ac_more_lines=:
+-ac_sed_cmds=""
+-while $ac_more_lines; do
+- if test $ac_beg -gt 1; then
+- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+- else
+- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+- fi
+- if test ! -s conftest.s$ac_file; then
+- ac_more_lines=false
+- rm -f conftest.s$ac_file
+- else
+- if test -z "$ac_sed_cmds"; then
+- ac_sed_cmds="sed -f conftest.s$ac_file"
++ cat >>$CONFIG_STATUS <<\_ACEOF
++ # Split the substitutions into bite-sized pieces for seds with
++ # small command number limits, like on Digital OSF/1 and HP-UX.
++ ac_max_sed_lines=48
++ ac_sed_frag=1 # Number of current file.
++ ac_beg=1 # First line for current file.
++ ac_end=$ac_max_sed_lines # Line after last line for current file.
++ ac_more_lines=:
++ ac_sed_cmds=
++ while $ac_more_lines; do
++ if test $ac_beg -gt 1; then
++ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
++ else
++ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
++ fi
++ if test ! -s $tmp/subs.frag; then
++ ac_more_lines=false
+ else
+- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
++ # The purpose of the label and of the branching condition is to
++ # speed up the sed processing (if there are no `@' at all, there
++ # is no need to browse any of the substitutions).
++ # These are the two extra sed commands mentioned above.
++ (echo ':t
++ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
++ if test -z "$ac_sed_cmds"; then
++ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
++ else
++ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
++ fi
++ ac_sed_frag=`expr $ac_sed_frag + 1`
++ ac_beg=$ac_end
++ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+- ac_file=`expr $ac_file + 1`
+- ac_beg=$ac_end
+- ac_end=`expr $ac_end + $ac_max_sed_cmds`
+- fi
+-done
+-if test -z "$ac_sed_cmds"; then
+- ac_sed_cmds=cat
+-fi
+-EOF
+-
+-cat >> $CONFIG_STATUS <<EOF
+-
+-CONFIG_FILES=\${CONFIG_FILES-"Makefile
+-src/Makefile
+-util/Makefile
+-data/Makefile
+-data/styles/Makefile
+-doc/Makefile
+-nls/Makefile
+-nls/C/Makefile
+-nls/da_DK/Makefile
+-nls/de_DE/Makefile
+-nls/es_AR/Makefile
+-nls/es_ES/Makefile
+-nls/fr_FR/Makefile
+-nls/hu_HU/Makefile
+-nls/it_IT/Makefile
+-nls/ja_JP/Makefile
+-nls/ko_KR/Makefile
+-nls/lv_LV/Makefile
+-nls/nl_NL/Makefile
+-nls/no_NO/Makefile
+-nls/pl_PL/Makefile
+-nls/pt_BR/Makefile
+-nls/ro_RO/Makefile
+-nls/ru_RU/Makefile
+-nls/sk_SK/Makefile
+-nls/sl_SI/Makefile
+-nls/sv_SE/Makefile
+-nls/uk_UA/Makefile
+-nls/zh_CN/Makefile
+-nls/zh_TW/Makefile
+-version.h"}
+-EOF
+-cat >> $CONFIG_STATUS <<\EOF
+-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
++ done
++ if test -z "$ac_sed_cmds"; then
++ ac_sed_cmds=cat
++ fi
++fi # test -n "$CONFIG_FILES"
++
++_ACEOF
++cat >>$CONFIG_STATUS <<\_ACEOF
++for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+- case "$ac_file" in
+- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+- *) ac_file_in="${ac_file}.in" ;;
++ case $ac_file in
++ - | *:- | *:-:* ) # input from stdin
++ cat >$tmp/stdin
++ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
++ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
++ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
++ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
++ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+-
+- # Remove last slash and all that follows it. Not all systems have dirname.
+- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+- # The file is in a subdirectory.
+- test ! -d "$ac_dir" && mkdir "$ac_dir"
+- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+- # A "../" for each directory in $ac_dir_suffix.
+- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+- else
+- ac_dir_suffix= ac_dots=
+- fi
+-
+- case "$ac_given_srcdir" in
+- .) srcdir=.
+- if test -z "$ac_dots"; then top_srcdir=.
+- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
++ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
++ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
++$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$ac_file" : 'X\(//\)[^/]' \| \
++ X"$ac_file" : 'X\(//\)$' \| \
++ X"$ac_file" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$ac_file" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ { if $as_mkdir_p; then
++ mkdir -p "$ac_dir"
++ else
++ as_dir="$ac_dir"
++ as_dirs=
++ while test ! -d "$as_dir"; do
++ as_dirs="$as_dir $as_dirs"
++ as_dir=`(dirname "$as_dir") 2>/dev/null ||
++$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$as_dir" : 'X\(//\)[^/]' \| \
++ X"$as_dir" : 'X\(//\)$' \| \
++ X"$as_dir" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$as_dir" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ done
++ test ! -n "$as_dirs" || mkdir $as_dirs
++ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
++echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
++ { (exit 1); exit 1; }; }; }
++
++ ac_builddir=.
++
++if test "$ac_dir" != .; then
++ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
++ # A "../" for each directory in $ac_dir_suffix.
++ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
++else
++ ac_dir_suffix= ac_top_builddir=
++fi
++
++case $srcdir in
++ .) # No --srcdir option. We are building in place.
++ ac_srcdir=.
++ if test -z "$ac_top_builddir"; then
++ ac_top_srcdir=.
++ else
++ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
++ fi ;;
++ [\\/]* | ?:[\\/]* ) # Absolute path.
++ ac_srcdir=$srcdir$ac_dir_suffix;
++ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+- top_srcdir="$ac_dots$ac_given_srcdir" ;;
++ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
++ ac_top_srcdir=$ac_top_builddir$srcdir ;;
++esac
++
++# Do not use `cd foo && pwd` to compute absolute paths, because
++# the directories may not exist.
++case `pwd` in
++.) ac_abs_builddir="$ac_dir";;
++*)
++ case "$ac_dir" in
++ .) ac_abs_builddir=`pwd`;;
++ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
++ *) ac_abs_builddir=`pwd`/"$ac_dir";;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_builddir=${ac_top_builddir}.;;
++*)
++ case ${ac_top_builddir}. in
++ .) ac_abs_top_builddir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
++ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_srcdir=$ac_srcdir;;
++*)
++ case $ac_srcdir in
++ .) ac_abs_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
++ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_srcdir=$ac_top_srcdir;;
++*)
++ case $ac_top_srcdir in
++ .) ac_abs_top_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
++ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
++ esac;;
++esac
++
++
++ case $INSTALL in
++ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
++ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+- case "$ac_given_INSTALL" in
+- [/$]*) INSTALL="$ac_given_INSTALL" ;;
+- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+- esac
++ # Let's still pretend it is `configure' which instantiates (i.e., don't
++ # use $as_me), people would be surprised to read:
++ # /* config.h. Generated by config.status. */
++ if test x"$ac_file" = x-; then
++ configure_input=
++ else
++ configure_input="$ac_file. "
++ fi
++ configure_input=$configure_input"Generated from `echo $ac_file_in |
++ sed 's,.*/,,'` by configure."
+
+- echo creating "$ac_file"
+- rm -f "$ac_file"
+- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+- case "$ac_file" in
+- *Makefile*) ac_comsub="1i\\
+-# $configure_input" ;;
+- *) ac_comsub= ;;
+- esac
++ # First look for the input files in the build tree, otherwise in the
++ # src tree.
++ ac_file_inputs=`IFS=:
++ for f in $ac_file_in; do
++ case $f in
++ -) echo $tmp/stdin ;;
++ [\\/$]*)
++ # Absolute (can't be DOS-style, as IFS=:)
++ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
++echo "$as_me: error: cannot find input file: $f" >&2;}
++ { (exit 1); exit 1; }; }
++ echo "$f";;
++ *) # Relative
++ if test -f "$f"; then
++ # Build tree
++ echo "$f"
++ elif test -f "$srcdir/$f"; then
++ # Source tree
++ echo "$srcdir/$f"
++ else
++ # /dev/null tree
++ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
++echo "$as_me: error: cannot find input file: $f" >&2;}
++ { (exit 1); exit 1; }; }
++ fi;;
++ esac
++ done` || { (exit 1); exit 1; }
++
++ if test x"$ac_file" != x-; then
++ { echo "$as_me:$LINENO: creating $ac_file" >&5
++echo "$as_me: creating $ac_file" >&6;}
++ rm -f "$ac_file"
++ fi
++_ACEOF
++cat >>$CONFIG_STATUS <<_ACEOF
++ sed "$ac_vpsub
++$extrasub
++_ACEOF
++cat >>$CONFIG_STATUS <<\_ACEOF
++:t
++/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
++s,@configure_input@,$configure_input,;t t
++s,@srcdir@,$ac_srcdir,;t t
++s,@abs_srcdir@,$ac_abs_srcdir,;t t
++s,@top_srcdir@,$ac_top_srcdir,;t t
++s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
++s,@builddir@,$ac_builddir,;t t
++s,@abs_builddir@,$ac_abs_builddir,;t t
++s,@top_builddir@,$ac_top_builddir,;t t
++s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
++s,@INSTALL@,$ac_INSTALL,;t t
++" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
++ rm -f $tmp/stdin
++ if test x"$ac_file" != x-; then
++ mv $tmp/out $ac_file
++ else
++ cat $tmp/out
++ rm -f $tmp/out
++ fi
++
++done
++_ACEOF
++cat >>$CONFIG_STATUS <<\_ACEOF
+
+- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+- sed -e "$ac_comsub
+-s%@configure_input@%$configure_input%g
+-s%@srcdir@%$srcdir%g
+-s%@top_srcdir@%$top_srcdir%g
+-s%@INSTALL@%$INSTALL%g
+-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+-fi; done
+-rm -f conftest.s*
++#
++# CONFIG_HEADER section.
++#
+
+ # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+ # NAME is the cpp macro being defined and VALUE is the value it is being given.
+ #
+ # ac_d sets the value in "#define NAME VALUE" lines.
+-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+-ac_dC='\3'
+-ac_dD='%g'
+-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+-ac_uB='\([ ]\)%\1#\2define\3'
++ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
++ac_dB='[ ].*$,\1#\2'
++ac_dC=' '
++ac_dD=',;t'
++# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
++ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
++ac_uB='$,\1#\2define\3'
+ ac_uC=' '
+-ac_uD='\4%g'
+-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+-ac_eB='$%\1#\2define\3'
+-ac_eC=' '
+-ac_eD='%g'
+-
+-if test "${CONFIG_HEADERS+set}" != set; then
+-EOF
+-cat >> $CONFIG_STATUS <<EOF
+- CONFIG_HEADERS="config.h"
+-EOF
+-cat >> $CONFIG_STATUS <<\EOF
+-fi
+-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
++ac_uD=',;t'
++
++for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+- case "$ac_file" in
+- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+- *) ac_file_in="${ac_file}.in" ;;
++ case $ac_file in
++ - | *:- | *:-:* ) # input from stdin
++ cat >$tmp/stdin
++ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
++ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
++ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
++ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
++ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+- echo creating $ac_file
++ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
++echo "$as_me: creating $ac_file" >&6;}
+
+- rm -f conftest.frag conftest.in conftest.out
+- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+- cat $ac_file_inputs > conftest.in
+-
+-EOF
+-
+-# Transform confdefs.h into a sed script conftest.vals that substitutes
+-# the proper values into config.h.in to produce config.h. And first:
+-# Protect against being on the right side of a sed subst in config.status.
+-# Protect against being in an unquoted here document in config.status.
+-rm -f conftest.vals
+-cat > conftest.hdr <<\EOF
+-s/[\\&%]/\\&/g
+-s%[\\$`]%\\&%g
+-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+-s%ac_d%ac_u%gp
+-s%ac_u%ac_e%gp
+-EOF
+-sed -n -f conftest.hdr confdefs.h > conftest.vals
+-rm -f conftest.hdr
++ # First look for the input files in the build tree, otherwise in the
++ # src tree.
++ ac_file_inputs=`IFS=:
++ for f in $ac_file_in; do
++ case $f in
++ -) echo $tmp/stdin ;;
++ [\\/$]*)
++ # Absolute (can't be DOS-style, as IFS=:)
++ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
++echo "$as_me: error: cannot find input file: $f" >&2;}
++ { (exit 1); exit 1; }; }
++ # Do quote $f, to prevent DOS paths from being IFS'd.
++ echo "$f";;
++ *) # Relative
++ if test -f "$f"; then
++ # Build tree
++ echo "$f"
++ elif test -f "$srcdir/$f"; then
++ # Source tree
++ echo "$srcdir/$f"
++ else
++ # /dev/null tree
++ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
++echo "$as_me: error: cannot find input file: $f" >&2;}
++ { (exit 1); exit 1; }; }
++ fi;;
++ esac
++ done` || { (exit 1); exit 1; }
++ # Remove the trailing spaces.
++ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
++
++_ACEOF
++
++# Transform confdefs.h into two sed scripts, `conftest.defines' and
++# `conftest.undefs', that substitutes the proper values into
++# config.h.in to produce config.h. The first handles `#define'
++# templates, and the second `#undef' templates.
++# And first: Protect against being on the right side of a sed subst in
++# config.status. Protect against being in an unquoted here document
++# in config.status.
++rm -f conftest.defines conftest.undefs
++# Using a here document instead of a string reduces the quoting nightmare.
++# Putting comments in sed scripts is not portable.
++#
++# `end' is used to avoid that the second main sed command (meant for
++# 0-ary CPP macros) applies to n-ary macro definitions.
++# See the Autoconf documentation for `clear'.
++cat >confdef2sed.sed <<\_ACEOF
++s/[\\&,]/\\&/g
++s,[\\$`],\\&,g
++t clear
++: clear
++s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
++t end
++s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
++: end
++_ACEOF
++# If some macros were called several times there might be several times
++# the same #defines, which is useless. Nevertheless, we may not want to
++# sort them, since we want the *last* AC-DEFINE to be honored.
++uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
++sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
++rm -f confdef2sed.sed
+
+ # This sed command replaces #undef with comments. This is necessary, for
+ # example, in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+-cat >> conftest.vals <<\EOF
+-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+-EOF
+-
+-# Break up conftest.vals because some shells have a limit on
+-# the size of here documents, and old seds have small limits too.
+-
++cat >>conftest.undefs <<\_ACEOF
++s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
++_ACEOF
++
++# Break up conftest.defines because some shells have a limit on the size
++# of here documents, and old seds have small limits too (100 cmds).
++echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
++echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
++echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
++echo ' :' >>$CONFIG_STATUS
+ rm -f conftest.tail
+-while :
++while grep . conftest.defines >/dev/null
+ do
+- ac_lines=`grep -c . conftest.vals`
+- # grep -c gives empty output for an empty file on some AIX systems.
+- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+- # Write a limited-size here document to conftest.frag.
+- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
++ # Write a limited-size here document to $tmp/defines.sed.
++ echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
++ # Speed up: don't consider the non `#define' lines.
++ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
++ # Work around the forget-to-reset-the-flag bug.
++ echo 't clr' >>$CONFIG_STATUS
++ echo ': clr' >>$CONFIG_STATUS
++ sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+- sed -f conftest.frag conftest.in > conftest.out
+- rm -f conftest.in
+- mv conftest.out conftest.in
+-' >> $CONFIG_STATUS
+- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+- rm -f conftest.vals
+- mv conftest.tail conftest.vals
+-done
+-rm -f conftest.vals
+-
+-cat >> $CONFIG_STATUS <<\EOF
+- rm -f conftest.frag conftest.h
+- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+- cat conftest.in >> conftest.h
+- rm -f conftest.in
+- if cmp -s $ac_file conftest.h 2>/dev/null; then
+- echo "$ac_file is unchanged"
+- rm -f conftest.h
+- else
+- # Remove last slash and all that follows it. Not all systems have dirname.
+- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+- # The file is in a subdirectory.
+- test ! -d "$ac_dir" && mkdir "$ac_dir"
+- fi
+- rm -f $ac_file
+- mv conftest.h $ac_file
++ sed -f $tmp/defines.sed $tmp/in >$tmp/out
++ rm -f $tmp/in
++ mv $tmp/out $tmp/in
++' >>$CONFIG_STATUS
++ sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
++ rm -f conftest.defines
++ mv conftest.tail conftest.defines
++done
++rm -f conftest.defines
++echo ' fi # grep' >>$CONFIG_STATUS
++echo >>$CONFIG_STATUS
++
++# Break up conftest.undefs because some shells have a limit on the size
++# of here documents, and old seds have small limits too (100 cmds).
++echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
++rm -f conftest.tail
++while grep . conftest.undefs >/dev/null
++do
++ # Write a limited-size here document to $tmp/undefs.sed.
++ echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
++ # Speed up: don't consider the non `#undef'
++ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
++ # Work around the forget-to-reset-the-flag bug.
++ echo 't clr' >>$CONFIG_STATUS
++ echo ': clr' >>$CONFIG_STATUS
++ sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
++ echo 'CEOF
++ sed -f $tmp/undefs.sed $tmp/in >$tmp/out
++ rm -f $tmp/in
++ mv $tmp/out $tmp/in
++' >>$CONFIG_STATUS
++ sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
++ rm -f conftest.undefs
++ mv conftest.tail conftest.undefs
++done
++rm -f conftest.undefs
++
++cat >>$CONFIG_STATUS <<\_ACEOF
++ # Let's still pretend it is `configure' which instantiates (i.e., don't
++ # use $as_me), people would be surprised to read:
++ # /* config.h. Generated by config.status. */
++ if test x"$ac_file" = x-; then
++ echo "/* Generated by configure. */" >$tmp/config.h
++ else
++ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
+ fi
+-fi; done
++ cat $tmp/in >>$tmp/config.h
++ rm -f $tmp/in
++ if test x"$ac_file" != x-; then
++ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
++ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
++echo "$as_me: $ac_file is unchanged" >&6;}
++ else
++ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
++$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$ac_file" : 'X\(//\)[^/]' \| \
++ X"$ac_file" : 'X\(//\)$' \| \
++ X"$ac_file" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$ac_file" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ { if $as_mkdir_p; then
++ mkdir -p "$ac_dir"
++ else
++ as_dir="$ac_dir"
++ as_dirs=
++ while test ! -d "$as_dir"; do
++ as_dirs="$as_dir $as_dirs"
++ as_dir=`(dirname "$as_dir") 2>/dev/null ||
++$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$as_dir" : 'X\(//\)[^/]' \| \
++ X"$as_dir" : 'X\(//\)$' \| \
++ X"$as_dir" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$as_dir" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ done
++ test ! -n "$as_dirs" || mkdir $as_dirs
++ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
++echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
++ { (exit 1); exit 1; }; }; }
+
+-EOF
+-cat >> $CONFIG_STATUS <<EOF
++ rm -f $ac_file
++ mv $tmp/config.h $ac_file
++ fi
++ else
++ cat $tmp/config.h
++ rm -f $tmp/config.h
++ fi
++done
++_ACEOF
++cat >>$CONFIG_STATUS <<\_ACEOF
+
++#
++# CONFIG_COMMANDS section.
++#
++for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
++ ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
++ ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
++ ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
++$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$ac_dest" : 'X\(//\)[^/]' \| \
++ X"$ac_dest" : 'X\(//\)$' \| \
++ X"$ac_dest" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$ac_dest" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ { if $as_mkdir_p; then
++ mkdir -p "$ac_dir"
++ else
++ as_dir="$ac_dir"
++ as_dirs=
++ while test ! -d "$as_dir"; do
++ as_dirs="$as_dir $as_dirs"
++ as_dir=`(dirname "$as_dir") 2>/dev/null ||
++$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
++ X"$as_dir" : 'X\(//\)[^/]' \| \
++ X"$as_dir" : 'X\(//\)$' \| \
++ X"$as_dir" : 'X\(/\)' \| \
++ . : '\(.\)' 2>/dev/null ||
++echo X"$as_dir" |
++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
++ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
++ /^X\(\/\/\)$/{ s//\1/; q; }
++ /^X\(\/\).*/{ s//\1/; q; }
++ s/.*/./; q'`
++ done
++ test ! -n "$as_dirs" || mkdir $as_dirs
++ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
++echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
++ { (exit 1); exit 1; }; }; }
++
++ ac_builddir=.
++
++if test "$ac_dir" != .; then
++ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
++ # A "../" for each directory in $ac_dir_suffix.
++ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
++else
++ ac_dir_suffix= ac_top_builddir=
++fi
++
++case $srcdir in
++ .) # No --srcdir option. We are building in place.
++ ac_srcdir=.
++ if test -z "$ac_top_builddir"; then
++ ac_top_srcdir=.
++ else
++ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
++ fi ;;
++ [\\/]* | ?:[\\/]* ) # Absolute path.
++ ac_srcdir=$srcdir$ac_dir_suffix;
++ ac_top_srcdir=$srcdir ;;
++ *) # Relative path.
++ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
++ ac_top_srcdir=$ac_top_builddir$srcdir ;;
++esac
++
++# Do not use `cd foo && pwd` to compute absolute paths, because
++# the directories may not exist.
++case `pwd` in
++.) ac_abs_builddir="$ac_dir";;
++*)
++ case "$ac_dir" in
++ .) ac_abs_builddir=`pwd`;;
++ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
++ *) ac_abs_builddir=`pwd`/"$ac_dir";;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_builddir=${ac_top_builddir}.;;
++*)
++ case ${ac_top_builddir}. in
++ .) ac_abs_top_builddir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
++ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_srcdir=$ac_srcdir;;
++*)
++ case $ac_srcdir in
++ .) ac_abs_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
++ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
++ esac;;
++esac
++case $ac_abs_builddir in
++.) ac_abs_top_srcdir=$ac_top_srcdir;;
++*)
++ case $ac_top_srcdir in
++ .) ac_abs_top_srcdir=$ac_abs_builddir;;
++ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
++ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
++ esac;;
++esac
++
++
++ { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
++echo "$as_me: executing $ac_dest commands" >&6;}
++ case $ac_dest in
++ default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h ;;
++ esac
++done
++_ACEOF
+
+-EOF
+-cat >> $CONFIG_STATUS <<\EOF
+-test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
++cat >>$CONFIG_STATUS <<\_ACEOF
+
+-exit 0
+-EOF
++{ (exit 0); exit 0; }
++_ACEOF
+ chmod +x $CONFIG_STATUS
+-rm -fr confdefs* $ac_clean_files
+-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
++ac_clean_files=$ac_clean_files_save
++
++
++# configure is writing to config.log, and then calls config.status.
++# config.status does its own redirection, appending to config.log.
++# Unfortunately, on DOS this fails, as config.log is still kept open
++# by configure, so config.status won't be able to write to it; its
++# output is simply discarded. So we exec the FD to /dev/null,
++# effectively closing config.log, so it can be properly (re)opened and
++# appended to by config.status. When coming back to configure, we
++# need to make the FD available again.
++if test "$no_create" != yes; then
++ ac_cs_success=:
++ ac_config_status_args=
++ test "$silent" = yes &&
++ ac_config_status_args="$ac_config_status_args --quiet"
++ exec 5>/dev/null
++ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
++ exec 5>>config.log
++ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
++ # would make configure fail if this is the last instruction.
++ $ac_cs_success || { (exit 1); exit 1; }
++fi
+
+--- blackbox-0.65.0.orig/configure.in
++++ blackbox-0.65.0/configure.in
+@@ -106,6 +106,38 @@
+
+ LIBS="$LIBS $Xext_lib"
+
++LIBS="$LIBS $X_EXTRA_LIBS"
++
++Xext_lib=""
++
++dnl Check for Xinerama extension support and proper library files.
++XINERAMA=""
++AC_MSG_CHECKING([whether to build support for the Xinerama extension])
++AC_ARG_ENABLE(
++ xinerama, [ --enable-xinerama enable support of the xinerama extension [default=yes]])
++
++: ${enableval="yes"}
++if test x$enableval = "xyes"; then
++ AC_MSG_RESULT([yes])
++ AC_CHECK_LIB(Xinerama, XineramaQueryScreens,
++ AC_MSG_CHECKING([for X11/extensions/Xinerama.h])
++ AC_TRY_LINK(
++#include <X11/Xlib.h>
++#include <X11/Xutil.h>
++#include <X11/extensions/Xinerama.h>
++, XineramaScreenInfo* s = 0,
++ AC_MSG_RESULT([yes])
++ XINERAMA="-DXINERAMA"; Xext_lib="-lXext -lXinerama",
++ AC_MSG_RESULT([no])
++ )
++ )
++else
++ AC_MSG_RESULT([no])
++fi
++AC_SUBST(XINERAMA)
++
++LIBS="$LIBS $Xext_lib"
++
+ dnl Check for ordered 8bpp dithering
+ ORDEREDPSEUDO=""
+ AC_MSG_CHECKING([whether to include Pseudocolor ordered dithering code])
+--- blackbox-0.65.0.orig/doc/blackbox.1.in
++++ blackbox-0.65.0/doc/blackbox.1.in
+@@ -786,6 +786,13 @@
+ .EX
+ .B Default is False.
+ .EE
++.TP 3
++.BI "session.screen<num>.slit.xineramaPlacement" " [True|False]"
++Determines whether Xinerama inforation should be used to
++avoid placing the slit in non-viewable regions of the display.
++.EX
++.B Default is True.
++.EE
+ .\"
+ .\" ***** MENU CONFIGURABLE FROM MAIN MENU *****
+ .\"
+@@ -845,6 +852,24 @@
+ .B Default is TopToBottom.
+ .EE
+ .TP 3
++.BI "session.screen<num>.xineramaPlacement" " [True|False]"
++Use Xinerama information when deciding where to place windows.
++.EX
++.B Default is True.
++.EE
++.TP 3
++.BI "session.screen<num>.xineramaMenus" " [True|False]"
++Use Xinerama information to avoid menus spanning screen boundaries.
++.EX
++.B Default is True.
++.EE
++.TP 3
++.BI "session.screen<num>.xineramaMaximize" " [True|False]"
++Maximize windows to fill one screen when Xineramam is in use.
++.EX
++.B Default is True.
++.EE
++.TP 3
+ .BI "session.imageDither" " [True|False]"
+ This setting is only used when running in low
+ color modes. Image Dithering helps to show an
+@@ -951,6 +976,19 @@
+ .EX
+ .B Default is False.
+ .EE
++.TP 3
++.BI "session.screen<num>.toolbar.xineramaPlacement" " [True|False]"
++Use Xinerama information to prevent toolbar from being split
++across screens.
++.EX
++.B Default is True.
++.EE
++.TP 3
++.BI "session.screen<num>.toolbar.xineramaScreen" " [integer]"
++Xinerama screen number in which to place the toolbar.
++.EX
++.B Default is -1 (auto).
++.EE
+ .\"
+ .\" ***** CONFIGURABLE IN BLACKBOXRC ONLY *****
+ .\"
+--- blackbox-0.65.0.orig/nls/C/Configmenu.m
++++ blackbox-0.65.0/nls/C/Configmenu.m
+@@ -40,3 +40,13 @@
+ # Top to Bottom
+ $ #BottomTop
+ # Bottom to Top
++$ #XineramaOptions
++# Xinerama Options
++$ #XineramaPlacement
++# Window Placement
++$ #XineramaMaximize
++# Window Maximizing
++$ #XineramaToolbar
++# Toolbar Placement
++$ #XineramaMenus
++# Menu Placement
+--- blackbox-0.65.0.orig/nls/C/Toolbar.m
++++ blackbox-0.65.0/nls/C/Toolbar.m
+@@ -20,3 +20,7 @@
+ # Edit current workspace name
+ $ #ToolbarPlacement
+ # Toolbar Placement
++$ #ScreenTop
++# Screen %d Top
++$ #ScreenBottom
++# Screen %d Bottom
+--- blackbox-0.65.0.orig/nls/convert.awk
++++ blackbox-0.65.0/nls/convert.awk
+@@ -4,6 +4,8 @@
+
+ if (major > 1)
+ printf "\n" > output
++ else if (codeset)
++ printf "$ codeset=%s\n", codeset > output
+ printf "$set %d %s\n", major, $3 > output
+
+ if (header) {
+--- blackbox-0.65.0.orig/nls/da_DK/Makefile.am
++++ blackbox-0.65.0/nls/da_DK/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/da_DK/Makefile.in
++++ blackbox-0.65.0/nls/da_DK/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/de_DE/Makefile.am
++++ blackbox-0.65.0/nls/de_DE/Makefile.am
+@@ -26,7 +26,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/de_DE/Makefile.in
++++ blackbox-0.65.0/nls/de_DE/Makefile.in
+@@ -200,7 +200,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/es_ES/Makefile.am
++++ blackbox-0.65.0/nls/es_ES/Makefile.am
+@@ -28,7 +28,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/es_ES/Makefile.in
++++ blackbox-0.65.0/nls/es_ES/Makefile.in
+@@ -202,7 +202,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/fr_FR/Makefile.am
++++ blackbox-0.65.0/nls/fr_FR/Makefile.am
+@@ -26,7 +26,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/fr_FR/Makefile.in
++++ blackbox-0.65.0/nls/fr_FR/Makefile.in
+@@ -200,7 +200,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/hu_HU/Makefile.am
++++ blackbox-0.65.0/nls/hu_HU/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/hu_HU/Makefile.in
++++ blackbox-0.65.0/nls/hu_HU/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/it_IT/Makefile.am
++++ blackbox-0.65.0/nls/it_IT/Makefile.am
+@@ -26,7 +26,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/it_IT/Makefile.in
++++ blackbox-0.65.0/nls/it_IT/Makefile.in
+@@ -200,7 +200,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ja_JP/Makefile.am
++++ blackbox-0.65.0/nls/ja_JP/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=eucJP output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ja_JP/Makefile.in
++++ blackbox-0.65.0/nls/ja_JP/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=eucJP output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ko_KR/Makefile.am
++++ blackbox-0.65.0/nls/ko_KR/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=eucKR output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ko_KR/Makefile.in
++++ blackbox-0.65.0/nls/ko_KR/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=eucKR output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/nl_NL/Makefile.am
++++ blackbox-0.65.0/nls/nl_NL/Makefile.am
+@@ -26,7 +26,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/nl_NL/Makefile.in
++++ blackbox-0.65.0/nls/nl_NL/Makefile.in
+@@ -200,7 +200,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/no_NO/Makefile.am
++++ blackbox-0.65.0/nls/no_NO/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/no_NO/Makefile.in
++++ blackbox-0.65.0/nls/no_NO/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/pt_BR/Makefile.am
++++ blackbox-0.65.0/nls/pt_BR/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/pt_BR/Makefile.in
++++ blackbox-0.65.0/nls/pt_BR/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ru_RU/Makefile.am
++++ blackbox-0.65.0/nls/ru_RU/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=KOI8-R output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/ru_RU/Makefile.in
++++ blackbox-0.65.0/nls/ru_RU/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=KOI8-R output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sl_SI/Makefile.am
++++ blackbox-0.65.0/nls/sl_SI/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sl_SI/Makefile.in
++++ blackbox-0.65.0/nls/sl_SI/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sv_SE/Makefile.am
++++ blackbox-0.65.0/nls/sv_SE/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sv_SE/Makefile.in
++++ blackbox-0.65.0/nls/sv_SE/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/uk_UA/Makefile.am
++++ blackbox-0.65.0/nls/uk_UA/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=KOI8-U output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/uk_UA/Makefile.in
++++ blackbox-0.65.0/nls/uk_UA/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=KOI8-U output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/zh_CN/Makefile.am
++++ blackbox-0.65.0/nls/zh_CN/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=GB2312 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/zh_CN/Makefile.in
++++ blackbox-0.65.0/nls/zh_CN/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=GB2312 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/zh_TW/Makefile.am
++++ blackbox-0.65.0/nls/zh_TW/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=BIG5 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/zh_TW/Makefile.in
++++ blackbox-0.65.0/nls/zh_TW/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=BIG5 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/es_AR/Makefile.am
++++ blackbox-0.65.0/nls/es_AR/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/es_AR/Makefile.in
++++ blackbox-0.65.0/nls/es_AR/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-1 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/pl_PL/Makefile.in
++++ blackbox-0.65.0/nls/pl_PL/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/pl_PL/Makefile.am
++++ blackbox-0.65.0/nls/pl_PL/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sk_SK/Makefile.am
++++ blackbox-0.65.0/nls/sk_SK/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk convert=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/sk_SK/Makefile.in
++++ blackbox-0.65.0/nls/sk_SK/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-2 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/lv_LV/Makefile.am
++++ blackbox-0.65.0/nls/lv_LV/Makefile.am
+@@ -23,7 +23,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-13 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/nls/lv_LV/Makefile.in
++++ blackbox-0.65.0/nls/lv_LV/Makefile.in
+@@ -197,7 +197,7 @@
+
+ Translation.m: $(MFILES)
+ @if test x$(NLSTEST) = "x-DNLS"; then \
+- awk -f @srcdir@/../convert.awk output=Translation.m $(MFILES); \
++ awk -f @srcdir@/../convert.awk codeset=ISO-8859-13 output=Translation.m $(MFILES); \
+ fi
+
+ blackbox.cat: Translation.m
+--- blackbox-0.65.0.orig/src/BaseDisplay.cc
++++ blackbox-0.65.0/src/BaseDisplay.cc
+@@ -86,6 +86,7 @@
+ #include "GCCache.hh"
+ #include "Timer.hh"
+ #include "Util.hh"
++#include "Xinerama.hh"
+
+
+ // X error handler to handle any and all X errors while the application is
+@@ -400,9 +401,8 @@
+ }
+
+
+-ScreenInfo::ScreenInfo(BaseDisplay *d, unsigned int num) {
+- basedisplay = d;
+- screen_number = num;
++ScreenInfo::ScreenInfo(BaseDisplay *d, unsigned int num)
++ : basedisplay(d), screen_number(num), xinerama_info(0) {
+
+ root_window = RootWindow(basedisplay->getXDisplay(), screen_number);
+
+@@ -465,4 +465,12 @@
+
+ display_string = string("DISPLAY=") + default_string + '.' +
+ itostring(static_cast<unsigned long>(screen_number));
++
++#ifdef XINERAMA
++ xinerama_info = new XineramaInfo(this);
++ if (! xinerama_info->haveXinerama()) {
++ delete xinerama_info;
++ xinerama_info = 0;
++ }
++#endif
+ }
+--- blackbox-0.65.0.orig/src/BaseDisplay.hh
++++ blackbox-0.65.0/src/BaseDisplay.hh
+@@ -35,6 +35,7 @@
+ // forward declaration
+ class BaseDisplay;
+ class BGCCache;
++class XineramaInfo;
+
+ #include "Timer.hh"
+ #include "Util.hh"
+@@ -51,11 +52,14 @@
+ std::string display_string;
+ Rect rect;
+
++ XineramaInfo* xinerama_info;
++
+ public:
+ ScreenInfo(BaseDisplay *d, unsigned int num);
+
+ inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; }
+ inline Visual *getVisual(void) const { return visual; }
++ inline XineramaInfo *getXineramaInfo(void) const { return xinerama_info; }
+ inline Window getRootWindow(void) const { return root_window; }
+ inline Colormap getColormap(void) const { return colormap; }
+ inline int getDepth(void) const { return depth; }
+--- blackbox-0.65.0.orig/src/Basemenu.cc
++++ blackbox-0.65.0/src/Basemenu.cc
+@@ -49,6 +49,7 @@
+ #include "Image.hh"
+ #include "Screen.hh"
+ #include "Util.hh"
++#include "Xinerama.hh"
+
+ using std::string;
+ using std::min;
+@@ -478,6 +479,29 @@
+ drawSubmenu(which_sub);
+ }
+
++void Basemenu::moveInScreen(int screen_x, int screen_y, int dx, int dy) {
++ int x = screen_x + dx;
++ int y = screen_y + dy;
++
++ Rect rect = screen->getRect();
++ if (screen->getXineramaInfo() && screen->doXineramaMenus()) {
++ XineramaScreen xinerama = screen->getXineramaInfo()->
++ screenContaining(screen_x, screen_y);
++ if (xinerama.isValid()) {
++ rect = xinerama.getRect();
++ }
++ }
++
++ if (x < rect.left()) x = rect.left();
++ if (y < rect.top()) y = rect.top();
++
++ if (x + static_cast<signed>(getWidth()) > rect.right())
++ x = rect.right() - getWidth() - screen->getBorderWidth();
++ if (y + static_cast<signed>(getHeight()) > rect.bottom())
++ y = rect.bottom() - getHeight() - screen->getBorderWidth();
++
++ move(x,y);
++}
+
+ void Basemenu::redrawTitle(void) {
+ const char *text = (! menu.label.empty()) ? getLabel() :
+@@ -559,16 +583,24 @@
+ y = (((shifted) ? menu.y_shift : menu.y) +
+ menu.height - submenu->menu.height);
+
+- if ((x + submenu->getWidth()) > screen->getWidth())
++ Rect rect = screen->getRect();
++ if (screen->getXineramaInfo() && screen->doXineramaMenus()) {
++ XineramaScreen scr =
++ screen->getXineramaInfo()->screenContaining(menu.x, menu.y);
++ if (scr.isValid())
++ rect = scr.getRect();
++ }
++
++ if ((x + static_cast<signed>(submenu->getWidth())) > rect.right())
+ x = ((shifted) ? menu.x_shift : menu.x) -
+ submenu->getWidth() - screen->getBorderWidth();
+
+- if (x < 0) x = 0;
++ if (x < rect.left()) x = rect.left();
+
+- if ((y + submenu->getHeight()) > screen->getHeight())
+- y = screen->getHeight() - submenu->getHeight() -
++ if ((y + static_cast<signed>(submenu->getHeight())) > rect.bottom())
++ y = rect.bottom() - submenu->getHeight() -
+ (screen->getBorderWidth() * 2);
+- if (y < 0) y = 0;
++ if (y < rect.top()) y = rect.top();
+
+ submenu->move(x, y);
+ if (! moving) drawItem(index, True);
+@@ -961,22 +993,32 @@
+
+ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
+ if (ce->window == menu.frame) {
++
++ Rect rect = screen->getRect();
++#if 0
++ if (screen->getXineramaInfo() && screen->doXineramaMenus()) {
++ XineramaScreen xin_scr =
++ screen->getXineramaInfo()->screenContaining(menu.x, menu.y);
++ if (xin_scr.isValid()) {
++ rect = xin_scr.getRect();
++ }
++ }
++#endif
++
+ menu.x_shift = menu.x, menu.y_shift = menu.y;
+- if (menu.x + menu.width > screen->getWidth()) {
+- menu.x_shift = screen->getWidth() - menu.width -
+- screen->getBorderWidth();
++ if (menu.x + static_cast<signed>(menu.width) > rect.right()) {
++ menu.x_shift = rect.right() - menu.width - screen->getBorderWidth();
+ shifted = True;
+- } else if (menu.x < 0) {
+- menu.x_shift = -screen->getBorderWidth();
++ } else if (menu.x < rect.left()) {
++ menu.x_shift = rect.left() - screen->getBorderWidth();
+ shifted = True;
+ }
+
+- if (menu.y + menu.height > screen->getHeight()) {
+- menu.y_shift = screen->getHeight() - menu.height -
+- screen->getBorderWidth();
++ if (menu.y + static_cast<signed>(menu.height) > rect.bottom()) {
++ menu.y_shift = rect.bottom() - menu.height - screen->getBorderWidth();
+ shifted = True;
+- } else if (menu.y + static_cast<signed>(menu.title_h) < 0) {
+- menu.y_shift = -screen->getBorderWidth();
++ } else if (menu.y + static_cast<signed>(menu.title_h) < rect.top()) {
++ menu.y_shift = rect.top() - screen->getBorderWidth();
+ shifted = True;
+ }
+
+--- blackbox-0.65.0.orig/src/Basemenu.hh
++++ blackbox-0.65.0/src/Basemenu.hh
+@@ -129,6 +129,7 @@
+ void reconfigure(void);
+ void setLabel(const std::string& label);
+ void move(int x, int y);
++ void moveInScreen(int screen_x, int screen_y, int dx = 0, int dy = 0);
+ void update(void);
+ void setItemSelected(int index, bool sel);
+ void setItemEnabled(int index, bool enable);
+--- blackbox-0.65.0.orig/src/Configmenu.cc
++++ blackbox-0.65.0/src/Configmenu.cc
+@@ -36,13 +36,21 @@
+ setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config options"));
+ setInternalMenu();
+
++ int position = 2;
+ focusmenu = new Focusmenu(this);
+ placementmenu = new Placementmenu(this);
++ xineramamenu = 0;
+
+ insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
+ "Focus Model"), focusmenu);
+ insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
+ "Window Placement"), placementmenu);
++ if (scr->getXineramaInfo()) {
++ xineramamenu = new XineramaMenu(this);
++ insert(i18n(ConfigmenuSet, ConfigmenuXineramaOptions,
++ "Xinerama Options"), xineramamenu);
++ position++;
++ }
+ insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
+ "Image Dithering"), 1);
+ insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove,
+@@ -57,18 +65,19 @@
+ "Disable Bindings with Scroll Lock"), 6);
+ update();
+
+- setItemSelected(2, getScreen()->getImageControl()->doDither());
+- setItemSelected(3, getScreen()->doOpaqueMove());
+- setItemSelected(4, getScreen()->doFullMax());
+- setItemSelected(5, getScreen()->doFocusNew());
+- setItemSelected(6, getScreen()->doFocusLast());
+- setItemSelected(7, getScreen()->allowScrollLock());
++ setItemSelected(position++, getScreen()->getImageControl()->doDither());
++ setItemSelected(position++, getScreen()->doOpaqueMove());
++ setItemSelected(position++, getScreen()->doFullMax());
++ setItemSelected(position++, getScreen()->doFocusNew());
++ setItemSelected(position++, getScreen()->doFocusLast());
++ setItemSelected(position++, getScreen()->allowScrollLock());
+ }
+
+
+ Configmenu::~Configmenu(void) {
+ delete focusmenu;
+ delete placementmenu;
++ delete xineramamenu;
+ }
+
+
+@@ -132,7 +141,8 @@
+ void Configmenu::reconfigure(void) {
+ focusmenu->reconfigure();
+ placementmenu->reconfigure();
+-
++ if (xineramamenu)
++ xineramamenu->reconfigure();
+ Basemenu::reconfigure();
+ }
+
+@@ -319,3 +329,59 @@
+
+ reconfigure();
+ }
++
++
++Configmenu::XineramaMenu::XineramaMenu(Configmenu* cm)
++ : Basemenu(cm->getScreen()) {
++ setLabel(i18n(ConfigmenuSet, ConfigmenuXineramaOptions, "Xinerama Options"));
++ setInternalMenu();
++
++ insert(i18n(ConfigmenuSet, ConfigmenuXineramaPlacement, "Window Placement"),
++ ConfigmenuXineramaPlacement);
++ insert(i18n(ConfigmenuSet, ConfigmenuXineramaMaximize, "Window Maximizing"),
++ ConfigmenuXineramaMaximize);
++ insert(i18n(ConfigmenuSet, ConfigmenuXineramaToolbar, "Toolbar Placement"),
++ ConfigmenuXineramaToolbar);
++ insert(i18n(ConfigmenuSet, ConfigmenuXineramaMenus, "Menu Placement"),
++ ConfigmenuXineramaMenus);
++ update();
++
++ setItemSelected(0, getScreen()->doXineramaPlacement());
++ setItemSelected(1, getScreen()->doXineramaMaximize());
++ setItemSelected(2, getScreen()->doXineramaToolbar());
++ setItemSelected(3, getScreen()->doXineramaMenus());
++}
++
++
++void Configmenu::XineramaMenu::itemSelected(int button, unsigned int index) {
++ if (button != 1)
++ return;
++
++ switch (find(index)->function()) {
++
++ case ConfigmenuXineramaPlacement : {
++ getScreen()->saveXineramaPlacement(! getScreen()->doXineramaPlacement());
++ setItemSelected(index, getScreen()->doXineramaPlacement());
++ break;
++ }
++
++ case ConfigmenuXineramaMaximize : {
++ getScreen()->saveXineramaMaximize(! getScreen()->doXineramaMaximize());
++ setItemSelected(index, getScreen()->doXineramaMaximize());
++ break;
++ }
++
++ case ConfigmenuXineramaToolbar : {
++ getScreen()->saveXineramaToolbar(! getScreen()->doXineramaToolbar());
++ setItemSelected(index, getScreen()->doXineramaToolbar());
++ getScreen()->getToolbar()->reconfigure();
++ break;
++ }
++
++ case ConfigmenuXineramaMenus : {
++ getScreen()->saveXineramaMenus(! getScreen()->doXineramaMenus());
++ setItemSelected(index, getScreen()->doXineramaMenus());
++ break;
++ }
++ }
++}
+--- blackbox-0.65.0.orig/src/Configmenu.hh
++++ blackbox-0.65.0/src/Configmenu.hh
+@@ -58,8 +58,21 @@
+ virtual void reconfigure(void);
+ };
+
++ class XineramaMenu : public Basemenu {
++ private:
++ XineramaMenu(const XineramaMenu&);
++ XineramaMenu& operator=(const XineramaMenu&);
++
++ protected:
++ virtual void itemSelected(int button, unsigned int index);
++
++ public:
++ XineramaMenu(Configmenu *cm);
++ };
++
+ Focusmenu *focusmenu;
+ Placementmenu *placementmenu;
++ XineramaMenu* xineramamenu;
+
+ friend class Focusmenu;
+ friend class Placementmenu;
+@@ -76,6 +89,7 @@
+
+ inline Basemenu *getFocusmenu(void) { return focusmenu; }
+ inline Basemenu *getPlacementmenu(void) { return placementmenu; }
++ inline Basemenu *getXineramamenu(void) { return xineramamenu; }
+
+ void reconfigure(void);
+ };
+--- blackbox-0.65.0.orig/src/Makefile.in
++++ blackbox-0.65.0/src/Makefile.in
+@@ -87,6 +87,7 @@
+ ORDEREDPSEUDO = @ORDEREDPSEUDO@
+ PACKAGE = @PACKAGE@
+ SHAPE = @SHAPE@
++XINERAMA = @XINERAMA@
+ TIMEDCACHE = @TIMEDCACHE@
+ VERSION = @VERSION@
+ gencat_cmd = @gencat_cmd@
+@@ -95,7 +96,7 @@
+ DEFAULT_MENU = $(pkgdatadir)/menu
+ DEFAULT_STYLE = $(pkgdatadir)/styles/Results
+
+-CPPFLAGS = @CPPFLAGS@ @SHAPE@ @ORDEREDPSEUDO@ @DEBUG@ @NLS@ @TIMEDCACHE@ -DLOCALEPATH=\"$(pkgdatadir)/nls\" -DDEFAULTMENU=\"$(DEFAULT_MENU)\" -DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\"
++CPPFLAGS = @CPPFLAGS@ @SHAPE@ @XINERAMA@ @ORDEREDPSEUDO@ @DEBUG@ @NLS@ @TIMEDCACHE@ -DLOCALEPATH=\"$(pkgdatadir)/nls\" -DDEFAULTMENU=\"$(DEFAULT_MENU)\" -DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\"
+
+
+ bin_PROGRAMS = blackbox
+@@ -119,7 +120,8 @@
+ blackbox_OBJECTS = BaseDisplay.o Basemenu.o Clientmenu.o Color.o \
+ Configmenu.o GCCache.o Iconmenu.o Image.o ImageControl.o Netizen.o \
+ Rootmenu.o Screen.o Slit.o Texture.o Timer.o Toolbar.o Util.o Window.o \
+-Windowmenu.o Workspace.o Workspacemenu.o blackbox.o i18n.o main.o
++Windowmenu.o Workspace.o Workspacemenu.o Xinerama.o \
++blackbox.o i18n.o main.o
+ blackbox_LDADD = $(LDADD)
+ blackbox_DEPENDENCIES =
+ blackbox_LDFLAGS =
+@@ -321,11 +323,11 @@
+
+ BaseDisplay.o: BaseDisplay.cc ../config.h i18n.hh \
+ ../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh \
+- Util.hh
++ Util.hh Xinerama.hh
+ Basemenu.o: Basemenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
+ blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh GCCache.hh Color.hh \
+ Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh Iconmenu.hh \
+- Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh
++ Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Xinerama.hh
+ Clientmenu.o: Clientmenu.cc ../config.h blackbox.hh i18n.hh \
+ ../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Clientmenu.hh \
+ Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \
+@@ -375,13 +377,13 @@
+ blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \
+ GCCache.hh Color.hh Iconmenu.hh Image.hh Rootmenu.hh Screen.hh \
+ Texture.hh Util.hh Configmenu.hh Netizen.hh Workspace.hh \
+- Workspacemenu.hh Toolbar.hh Window.hh Windowmenu.hh Slit.hh
++ Workspacemenu.hh Toolbar.hh Window.hh Windowmenu.hh Slit.hh Xinerama.hh
+ Util.o: Util.cc ../config.h Util.hh
+ Window.o: Window.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
+ blackbox.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh Iconmenu.hh \
+ Basemenu.hh Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh \
+ Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \
+- Window.hh Windowmenu.hh Slit.hh
++ Window.hh Windowmenu.hh Slit.hh Xinerama.hh
+ Windowmenu.o: Windowmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
+ blackbox.hh BaseDisplay.hh Timer.hh Screen.hh Color.hh Texture.hh \
+ Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \
+@@ -390,11 +392,12 @@
+ blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \
+ Netizen.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \
+ Iconmenu.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \
+- Window.hh Windowmenu.hh
++ Window.hh Windowmenu.hh Xinerama.hh
+ Workspacemenu.o: Workspacemenu.cc ../config.h i18n.hh \
+ ../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh Timer.hh Screen.hh \
+ Color.hh Texture.hh Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh \
+ Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh
++Xinerama.o: Xinerama.cc ../config.h Util.hh Xinerama.hh
+ blackbox.o: blackbox.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
+ blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh Clientmenu.hh \
+ GCCache.hh Color.hh Image.hh Rootmenu.hh Screen.hh Texture.hh Util.hh \
+--- blackbox-0.65.0.orig/src/Screen.cc
++++ blackbox-0.65.0/src/Screen.cc
+@@ -998,6 +998,9 @@
+
+ *(session_stack + i++) = configmenu->getFocusmenu()->getWindowID();
+ *(session_stack + i++) = configmenu->getPlacementmenu()->getWindowID();
++ if (configmenu->getXineramamenu())
++ *(session_stack + i++) = configmenu->getXineramamenu()->getWindowID();
++
+ *(session_stack + i++) = configmenu->getWindowID();
+
+ *(session_stack + i++) = slit->getMenu()->getDirectionmenu()->getWindowID();
+@@ -1704,38 +1707,18 @@
+ if (rootmenu->isVisible())
+ rootmenu->hide();
+ } else if (xbutton->button == 2) {
+- int mx = xbutton->x_root - (workspacemenu->getWidth() / 2);
+- int my = xbutton->y_root - (workspacemenu->getTitleHeight() / 2);
+-
+- if (mx < 0) mx = 0;
+- if (my < 0) my = 0;
+-
+- if (mx + workspacemenu->getWidth() > getWidth())
+- mx = getWidth() - workspacemenu->getWidth() - getBorderWidth();
+-
+- if (my + workspacemenu->getHeight() > getHeight())
+- my = getHeight() - workspacemenu->getHeight() - getBorderWidth();
+-
+- workspacemenu->move(mx, my);
++ workspacemenu->moveInScreen(xbutton->x_root, xbutton->y_root,
++ -static_cast<signed>(workspacemenu->getWidth()) / 2,
++ -static_cast<signed>(workspacemenu->getTitleHeight()) / 2);
+
+ if (! workspacemenu->isVisible()) {
+ workspacemenu->removeParent();
+ workspacemenu->show();
+ }
+ } else if (xbutton->button == 3) {
+- int mx = xbutton->x_root - (rootmenu->getWidth() / 2);
+- int my = xbutton->y_root - (rootmenu->getTitleHeight() / 2);
+-
+- if (mx < 0) mx = 0;
+- if (my < 0) my = 0;
+-
+- if (mx + rootmenu->getWidth() > getWidth())
+- mx = getWidth() - rootmenu->getWidth() - getBorderWidth();
+-
+- if (my + rootmenu->getHeight() > getHeight())
+- my = getHeight() - rootmenu->getHeight() - getBorderWidth();
+-
+- rootmenu->move(mx, my);
++ rootmenu->moveInScreen(xbutton->x_root, xbutton->y_root,
++ -static_cast<signed>(rootmenu->getWidth()) / 2,
++ -static_cast<signed>(rootmenu->getTitleHeight()) / 2);
+
+ if (! rootmenu->isVisible()) {
+ blackbox->checkMenu();
+--- blackbox-0.65.0.orig/src/Screen.hh
++++ blackbox-0.65.0/src/Screen.hh
+@@ -149,15 +149,16 @@
+
+ bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
+ auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
+- focus_new, focus_last, click_raise, allow_scroll_lock;
++ focus_new, focus_last, click_raise, allow_scroll_lock,
++ xinerama_placement, xinerama_maximize, xinerama_menus, xinerama_toolbar;
+ BColor border_color;
+ XrmDatabase stylerc;
+
+ unsigned int workspaces;
+ int toolbar_placement, toolbar_width_percent, placement_policy,
+- edge_snap_threshold, row_direction, col_direction;
++ edge_snap_threshold, row_direction, col_direction, toolbar_xin_screen;
+
+- bool slit_on_top, slit_auto_hide;
++ bool slit_on_top, slit_auto_hide, xinerama_slit;
+ int slit_placement, slit_direction;
+
+ unsigned int handle_width, bevel_width, frame_width, border_width;
+@@ -224,6 +225,16 @@
+ inline bool doFocusNew(void) const { return resource.focus_new; }
+ inline bool doFocusLast(void) const { return resource.focus_last; }
+ inline bool allowScrollLock(void) const { return resource.allow_scroll_lock;}
++ inline bool doXineramaPlacement(void) const
++ { return resource.xinerama_placement; }
++ inline bool doXineramaMaximize(void) const
++ { return resource.xinerama_maximize; }
++ inline bool doXineramaMenus(void) const
++ { return resource.xinerama_menus; }
++ inline bool doXineramaToolbar(void) const
++ { return resource.xinerama_toolbar; }
++ inline bool doXineramaSlit(void) const
++ { return resource.xinerama_slit; }
+
+ inline const GC &getOpGC(void) const { return opGC; }
+
+@@ -281,6 +292,8 @@
+ { return resource.row_direction; }
+ inline int getColPlacementDirection(void) const
+ { return resource.col_direction; }
++ inline int getXineramaToolbarScreen(void) const
++ { return resource.toolbar_xin_screen; }
+
+ inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
+ inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; }
+@@ -295,6 +308,8 @@
+ inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
+ inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
+ inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
++ inline void saveXineramaToolbarScreen(int s)
++ { resource.toolbar_xin_screen = s;}
+ inline void saveEdgeSnapThreshold(int t)
+ { resource.edge_snap_threshold = t; }
+ inline void saveImageDither(bool d) { resource.image_dither = d; }
+@@ -303,6 +318,13 @@
+ inline void saveFocusNew(bool f) { resource.focus_new = f; }
+ inline void saveFocusLast(bool f) { resource.focus_last = f; }
+ inline void saveAllowScrollLock(bool a) { resource.allow_scroll_lock = a; }
++ inline void saveXineramaPlacement(bool p) { resource.xinerama_placement = p; }
++ inline void saveXineramaMaximize(bool m) { resource.xinerama_maximize = m; }
++ inline void saveXineramaMenus(bool m) { resource.xinerama_menus = m; }
++ inline void saveXineramaToolbar(bool t) { resource.xinerama_toolbar = t; }
++ inline void saveXinaramaToolbarScreen(int s)
++ { resource.toolbar_xin_screen = s; }
++ inline void saveXineramaSlit(bool s) { resource.xinerama_slit = s; }
+
+ inline void iconUpdate(void) { iconmenu->update(); }
+
+--- blackbox-0.65.0.orig/src/Slit.cc
++++ blackbox-0.65.0/src/Slit.cc
+@@ -35,6 +35,7 @@
+ #include "Screen.hh"
+ #include "Slit.hh"
+ #include "Toolbar.hh"
++#include "Xinerama.hh"
+
+
+ Slit::Slit(BScreen *scr) {
+@@ -481,6 +482,29 @@
+
+ frame.rect.setPos(x, y);
+
++ if (screen->getXineramaInfo() && screen->doXineramaSlit()) {
++ XineramaScreen scr = screen->getXineramaInfo()->screenContaining(frame.rect);
++ if (!scr.isValid()) {
++ scr = screen->getXineramaInfo()->getClosestScreen(x,y);
++ }
++
++ if (scr.isValid() && (scr.getRect() & frame.rect) != frame.rect) {
++ int w = static_cast<signed>(frame.rect.width());
++ if (x < scr.getRect().left())
++ x = scr.getRect().left();
++ else if (x + w > scr.getRect().right())
++ x = scr.getRect().right() - w;
++
++ int h = static_cast<signed>(frame.rect.height());
++ if (y < scr.getRect().top())
++ y = scr.getRect().top();
++ else if (y + h > scr.getRect().bottom())
++ y = scr.getRect().bottom() - h;
++
++ frame.rect.setPos(x, y);
++ }
++ }
++
+ // we have to add the border to the rect as it is not accounted for
+ Rect tbar_rect = screen->getToolbar()->getRect();
+ tbar_rect.setSize(tbar_rect.width() + (screen->getBorderWidth() * 2),
+@@ -536,22 +560,9 @@
+ XLowerWindow(display, frame.window);
+ } else if (e->button == Button3) {
+ if (! slitmenu->isVisible()) {
+- int x, y;
+-
+- x = e->x_root - (slitmenu->getWidth() / 2);
+- y = e->y_root - (slitmenu->getHeight() / 2);
+-
+- if (x < 0)
+- x = 0;
+- else if (x + slitmenu->getWidth() > screen->getWidth())
+- x = screen->getWidth() - slitmenu->getWidth();
+-
+- if (y < 0)
+- y = 0;
+- else if (y + slitmenu->getHeight() > screen->getHeight())
+- y = screen->getHeight() - slitmenu->getHeight();
+-
+- slitmenu->move(x, y);
++ slitmenu->moveInScreen(e->x_root, e->y_root,
++ -static_cast<signed>(slitmenu->getWidth()) / 2,
++ -static_cast<signed>(slitmenu->getHeight()) / 2);
+ slitmenu->show();
+ } else {
+ slitmenu->hide();
+--- blackbox-0.65.0.orig/src/Timer.hh
++++ blackbox-0.65.0/src/Timer.hh
+@@ -98,9 +98,9 @@
+ ~_timer_queue(void) {}
+
+ void release(const _Tp& value) {
+- c.erase(std::remove(c.begin(), c.end(), value), c.end());
++ this->c.erase(std::remove(this->c.begin(), this->c.end(), value), this->c.end());
+ // after removing the item we need to make the heap again
+- std::make_heap(c.begin(), c.end(), comp);
++ std::make_heap(this->c.begin(), this->c.end(), this->comp);
+ }
+ bool empty(void) const { return _Base::empty(); }
+ size_t size(void) const { return _Base::size(); }
+--- blackbox-0.65.0.orig/src/Toolbar.cc
++++ blackbox-0.65.0/src/Toolbar.cc
+@@ -62,6 +62,7 @@
+ #include "Clientmenu.hh"
+ #include "Workspacemenu.hh"
+ #include "Slit.hh"
++#include "Xinerama.hh"
+
+
+ static long aMinuteFromNow(void) {
+@@ -198,8 +199,56 @@
+
+
+ void Toolbar::reconfigure(void) {
++ Rect rect = screen->getRect();
++
++ if (screen->getXineramaInfo() && screen->doXineramaToolbar()) {
++
++ XineramaScreen xinerama =
++ screen->getXineramaInfo()->getScreen(screen->getXineramaToolbarScreen());
++
++ if (! xinerama.isValid()) {
++
++ XineramaList list;
++ switch (screen->getToolbarPlacement()) {
++ case TopLeft:
++ case TopRight:
++ case TopCenter:
++ screen->getXineramaInfo()->getTopScreens(list);
++ break;
++ case BottomLeft:
++ case BottomRight:
++ case BottomCenter:
++ default:
++ screen->getXineramaInfo()->getBottomScreens(list);
++ break;
++ }
++
++ switch (screen->getToolbarPlacement()) {
++ case TopLeft:
++ case BottomLeft:
++ xinerama = *list.begin();
++ break;
++ case TopRight:
++ case BottomRight:
++ xinerama = *list.rbegin();
++ break;
++ case TopCenter:
++ case BottomCenter:
++ default: {
++ XineramaList::iterator itr = list.begin();
++ for (int count = list.size()/2; count--; ++itr);
++ xinerama = *itr;
++ break;
++ }
++ }
++ screen->saveXineramaToolbarScreen(xinerama.getScreenNumber());
++ } // end if (invalid xinerama screen)
++
++ rect = xinerama.getRect();
++ } // end if (xinerama)
++
+ unsigned int height = 0,
+- width = (screen->getWidth() * screen->getToolbarWidthPercent()) / 100;
++ width = (rect.width() * screen->getToolbarWidthPercent()) / 100;
+
+ if (i18n.multibyte())
+ height = screen->getToolbarStyle()->fontset_extents->max_ink_extent.height;
+@@ -218,18 +267,25 @@
+ int x, y;
+ switch (screen->getToolbarPlacement()) {
+ case TopLeft:
++ case BottomLeft:
++ x = rect.left();
++ break;
+ case TopRight:
+- case TopCenter:
+- if (screen->getToolbarPlacement() == TopLeft)
+- x = 0;
+- else if (screen->getToolbarPlacement() == TopRight)
+- x = screen->getWidth() - frame.rect.width()
++ case BottomRight:
++ x = rect.left() + rect.width() - frame.rect.width()
+ - (screen->getBorderWidth() * 2);
+- else
+- x = (screen->getWidth() - frame.rect.width()) / 2;
+-
+- y = 0;
+-
++ break;
++ case TopCenter:
++ case BottomCenter:
++ default:
++ x = rect.left() + (rect.width() - frame.rect.width()) / 2;
++ break;
++ }
++ switch (screen->getToolbarPlacement()) {
++ case TopLeft:
++ case TopRight:
++ case TopCenter:
++ y = rect.top();
+ frame.x_hidden = x;
+ frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth()
+ - frame.rect.height();
+@@ -239,19 +295,11 @@
+ case BottomRight:
+ case BottomCenter:
+ default:
+- if (screen->getToolbarPlacement() == BottomLeft)
+- x = 0;
+- else if (screen->getToolbarPlacement() == BottomRight)
+- x = screen->getWidth() - frame.rect.width()
+- - (screen->getBorderWidth() * 2);
+- else
+- x = (screen->getWidth() - frame.rect.width()) / 2;
+-
+- y = screen->getHeight() - frame.rect.height()
++ y = rect.bottom() - frame.rect.height()
+ - (screen->getBorderWidth() * 2);
+
+ frame.x_hidden = x;
+- frame.y_hidden = screen->getHeight() - screen->getBevelWidth()
++ frame.y_hidden = rect.bottom() - screen->getBevelWidth()
+ - screen->getBorderWidth();
+ break;
+ }
+@@ -758,22 +806,9 @@
+ if (toolbarmenu->isVisible()) {
+ toolbarmenu->hide();
+ } else {
+- int x, y;
+-
+- x = be->x_root - (toolbarmenu->getWidth() / 2);
+- y = be->y_root - (toolbarmenu->getHeight() / 2);
+-
+- if (x < 0)
+- x = 0;
+- else if (x + toolbarmenu->getWidth() > screen->getWidth())
+- x = screen->getWidth() - toolbarmenu->getWidth();
+-
+- if (y < 0)
+- y = 0;
+- else if (y + toolbarmenu->getHeight() > screen->getHeight())
+- y = screen->getHeight() - toolbarmenu->getHeight();
+-
+- toolbarmenu->move(x, y);
++ toolbarmenu->moveInScreen(be->x_root, be->y_root,
++ -static_cast<signed>(toolbarmenu->getWidth()) / 2,
++ -static_cast<signed>(toolbarmenu->getHeight()) / 2);
+ toolbarmenu->show();
+ }
+ }
+@@ -1069,21 +1104,88 @@
+ : Basemenu(tm->toolbar->screen) {
+ setLabel(i18n(ToolbarSet, ToolbarToolbarPlacement, "Toolbar Placement"));
+ setInternalMenu();
+- setMinimumSublevels(3);
++ reconfigure();
++}
+
+- insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"),
+- Toolbar::TopLeft);
+- insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
+- Toolbar::BottomLeft);
+- insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"),
+- Toolbar::TopCenter);
+- insert(i18n(CommonSet, CommonPlacementBottomCenter, "Bottom Center"),
+- Toolbar::BottomCenter);
+- insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"),
+- Toolbar::TopRight);
+- insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"),
+- Toolbar::BottomRight);
++void Toolbarmenu::Placementmenu::reconfigure(void)
++{
++ for (int count = getCount(); count > 0; count = remove(count-1));
++
++ if (getScreen()->getXineramaInfo() && getScreen()->doXineramaToolbar()) {
++ char buffer[256];
++ XineramaList top_list, bottom_list;
++ getScreen()->getXineramaInfo()->getTopScreens(top_list);
++ getScreen()->getXineramaInfo()->getBottomScreens(bottom_list);
++ int width = std::max(top_list.size(),bottom_list.size()) + 2;
++ setMinimumSublevels(width);
++
++ XineramaList::const_iterator top = top_list.begin();
++ XineramaList::const_iterator bottom = bottom_list.begin();
++
++ insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"),
++ handleFromPlacement(Toolbar::TopLeft, top->getScreenNumber()));
++ insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
++ handleFromPlacement(Toolbar::BottomLeft, bottom->getScreenNumber()));
++
++ for (int count = width - 2; count--; ) {
++ if (top != top_list.end()) {
++ sprintf(buffer,
++ i18n(ToolbarSet, ToolbarScreenTop, "Screen %d Top"),
++ top->getScreenNumber());
++ insert(buffer,
++ handleFromPlacement(Toolbar::TopCenter,top->getScreenNumber()));
++ ++top;
++ }
++ else {
++ insert("",-2);
++ }
++
++ if (bottom != bottom_list.end()) {
++ sprintf(buffer,
++ i18n(ToolbarSet, ToolbarScreenBottom, "Screen %d Bottom"),
++ bottom->getScreenNumber());
++ insert(buffer,
++ handleFromPlacement(Toolbar::BottomCenter,bottom->getScreenNumber()));
++ ++bottom;
++ }
++ else {
++ insert("",-2);
++ }
++ }
++
++ int last_scr = top_list.rbegin()->getScreenNumber();
++ insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"),
++ handleFromPlacement(Toolbar::TopRight, last_scr));
++ last_scr = bottom_list.rbegin()->getScreenNumber();
++ insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"),
++ handleFromPlacement(Toolbar::BottomRight, last_scr));
++
++ update();
++
++ for (int index = 0; index < static_cast<signed>(getCount()); index++) {
++ if (find(index)->function() == -2) {
++ setItemEnabled(index, false);
++ }
++ }
++ }
++ else {
++ setMinimumSublevels(3);
++
++ insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"),
++ Toolbar::TopLeft);
++ insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
++ Toolbar::BottomLeft);
++ insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"),
++ Toolbar::TopCenter);
++ insert(i18n(CommonSet, CommonPlacementBottomCenter, "Bottom Center"),
++ Toolbar::BottomCenter);
++ insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"),
++ Toolbar::TopRight);
++ insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"),
++ Toolbar::BottomRight);
++ }
+ update();
++ Basemenu::reconfigure();
+ }
+
+
+@@ -1094,7 +1196,14 @@
+ BasemenuItem *item = find(index);
+ if (! item) return;
+
+- getScreen()->saveToolbarPlacement(item->function());
++ int placement = Placementmenu::placementFromHandle(item->function());
++ getScreen()->saveToolbarPlacement(placement);
++
++ if (getScreen()->getXineramaInfo() && getScreen()->doXineramaToolbar()) {
++ int xinerama = Placementmenu::xineramaFromHandle(item->function());
++ getScreen()->saveXineramaToolbarScreen(xinerama);
++ }
++
+ hide();
+ getScreen()->getToolbar()->reconfigure();
+
+--- blackbox-0.65.0.orig/src/Toolbar.hh
++++ blackbox-0.65.0/src/Toolbar.hh
+@@ -47,6 +47,15 @@
+
+ public:
+ Placementmenu(Toolbarmenu *tm);
++
++ inline static int handleFromPlacement(int placement, int xinerama_screen)
++ { return ((xinerama_screen+1) << 3) | placement; }
++ inline static int placementFromHandle(int handle)
++ { return handle & 0x7; }
++ inline static int xineramaFromHandle(int handle)
++ { return (handle >> 3)-1; }
++
++ void reconfigure(void);
+ };
+
+ Toolbar *toolbar;
+--- blackbox-0.65.0.orig/src/Util.hh
++++ blackbox-0.65.0/src/Util.hh
+@@ -29,6 +29,14 @@
+
+ #include <string>
+
++struct Point {
++ inline Point(void) : x(0), y(0) {}
++ inline Point(int set_x, int set_y) : x(set_x), y(set_y) {}
++ inline void set(int set_x, int set_y)
++ { x = set_x; y = set_y; }
++ int x, y;
++};
++
+ class Rect {
+ public:
+ inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
+@@ -51,6 +59,7 @@
+
+ inline unsigned int width(void) const { return _x2 - _x1 + 1; }
+ inline unsigned int height(void) const { return _y2 - _y1 + 1; }
++ inline int area(void) const { return width() * height(); }
+ void setWidth(unsigned int __w);
+ void setHeight(unsigned int __h);
+ void setSize(unsigned int __w, unsigned int __h);
+@@ -71,6 +80,9 @@
+ inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; }
+
+ bool intersects(const Rect &a) const;
++
++ inline bool contains( int x, int y ) const
++ { return (x >= _x1) && (x <= _x2) && (y >= _y1) && (y <= _y2); }
+
+ private:
+ int _x1, _y1, _x2, _y2;
+--- blackbox-0.65.0.orig/src/Window.cc
++++ blackbox-0.65.0/src/Window.cc
+@@ -44,6 +44,8 @@
+ #endif // HAVE_STDLIB_H
+ }
+
++#include <cassert>
++
+ #include "i18n.hh"
+ #include "blackbox.hh"
+ #include "GCCache.hh"
+@@ -55,6 +57,7 @@
+ #include "Window.hh"
+ #include "Windowmenu.hh"
+ #include "Workspace.hh"
++#include "Xinerama.hh"
+
+
+ /*
+@@ -208,8 +211,16 @@
+ client.normal_hint_flags & (PPosition|USPosition)) {
+ applyGravity(frame.rect);
+
+- if (blackbox->isStartup() || client.rect.intersects(screen->getRect()))
++ if (blackbox->isStartup()) {
++ place_window = False;
++ }
++ else if (s->getXineramaInfo() && s->doXineramaPlacement()) {
++ if (s->getXineramaInfo()->screenContaining(client.rect).isValid())
++ place_window = False;
++ }
++ else if (client.rect.intersects(screen->getRect())) {
+ place_window = False;
++ }
+ }
+
+ /*
+@@ -1626,7 +1637,13 @@
+ blackbox_attrib.premax_h =
+ client.rect.height() + frame.margin.top + frame.margin.bottom;
+
+- const Rect &screen_area = screen->availableArea();
++ Rect screen_area = screen->availableArea();
++ if (screen->getXineramaInfo() && screen->doXineramaMaximize()) {
++ XineramaScreen xinerama
++ = screen->getXineramaInfo()->screenContaining(frame.rect);
++ if (xinerama.isValid())
++ screen_area &= xinerama.getRect();
++ }
+ frame.changing = screen_area;
+
+ switch(button) {
+@@ -3288,6 +3305,7 @@
+ do {
+ if (multibyte) {
+ XRectangle ink, logical;
++ if (text_len>100) text_len=100;
+ XmbTextExtents(fontset, text, text_len, &ink, &logical);
+ length = logical.width;
+ } else {
+--- blackbox-0.65.0.orig/src/Workspace.cc
++++ blackbox-0.65.0/src/Workspace.cc
+@@ -55,13 +55,12 @@
+ #include "Window.hh"
+ #include "Workspace.hh"
+ #include "Windowmenu.hh"
++#include "Xinerama.hh"
+
+
+ Workspace::Workspace(BScreen *scrn, unsigned int i) {
+ screen = scrn;
+
+- cascade_x = cascade_y = 32;
+-
+ id = i;
+
+ clientmenu = new Clientmenu(this);
+@@ -123,9 +122,6 @@
+ for (; it != end; ++it, ++i)
+ (*it)->setWindowNumber(i);
+
+- if (i == 0)
+- cascade_x = cascade_y = 32;
+-
+ return i;
+ }
+
+@@ -548,8 +544,19 @@
+
+ bool Workspace::smartPlacement(Rect& win, const Rect& availableArea) {
+ rectList spaces;
+- spaces.push_back(availableArea); //initially the entire screen is free
+
++ // If xinerama info, initialize spaces to available xinerama screens
++ if (screen->getXineramaInfo() && screen->doXineramaPlacement()) {
++ const XineramaList& list = screen->getXineramaInfo()->getScreens();
++ for (XineramaList::const_iterator itr = list.begin();
++ itr != list.end(); ++itr) {
++ spaces.push_back(availableArea & itr->getRect());
++ }
++ }
++ else {
++ spaces.push_back(availableArea); //initially the entire screen is free
++ }
++
+ //Find Free Spaces
+ BlackboxWindowList::const_iterator wit = windowList.begin(),
+ end = windowList.end();
+@@ -621,17 +628,45 @@
+ }
+
+
+-bool Workspace::cascadePlacement(Rect &win, const Rect &availableArea) {
+- if (cascade_x > (availableArea.width() / 2) ||
+- cascade_y > (availableArea.height() / 2))
+- cascade_x = cascade_y = 32;
+-
+- if (cascade_x == 32) {
+- cascade_x += availableArea.x();
+- cascade_y += availableArea.y();
+- }
+-
+- win.setPos(cascade_x, cascade_y);
++bool Workspace::cascadePlacement(Rect &win, Rect availableArea, int offset) {
++
++ // Place window in whichever xinerama screen contains the
++ // pointer.
++ int xinerama_screen = 0;
++ if (screen->getXineramaInfo() && screen->doXineramaPlacement()) {
++ int ptr_x, ptr_y, x, y;
++ Window c, r;
++ unsigned int m;
++ XQueryPointer(screen->getBaseDisplay()->getXDisplay(),
++ screen->getRootWindow(),
++ &r, &c, &ptr_x, &ptr_y, &x, &y, &m);
++ XineramaScreen xinerama =
++ screen->getXineramaInfo()->screenContaining(ptr_x, ptr_y);
++ if (! xinerama.isValid())
++ xinerama = *(screen->getXineramaInfo()->getScreens().begin());
++ xinerama_screen = xinerama.getScreenNumber();
++ availableArea &= xinerama.getRect();
++ }
++
++ if (cascade_points.count(xinerama_screen) == 0) {
++ cascade_points[xinerama_screen] = Point(32,32);
++ }
++ Point& pos = cascade_points[xinerama_screen];
++
++ if (pos.x < (availableArea.left() + 32) ||
++ pos.y < (availableArea.top() + 32) ||
++ pos.x > (availableArea.left() + (int)availableArea.width() / 2) ||
++ pos.y > (availableArea.top() + (int)availableArea.height() / 2))
++ pos.x = pos.y = 32;
++
++ if (pos.x == 32) {
++ pos.x += availableArea.x();
++ pos.y += availableArea.y();
++ }
++
++ win.setPos(pos.x, pos.y);
++ pos.x += offset;
++ pos.y += offset;
+
+ return True;
+ }
+@@ -653,9 +688,8 @@
+ } // switch
+
+ if (placed == False) {
+- cascadePlacement(new_win, availableArea);
+- cascade_x += win->getTitleHeight() + (screen->getBorderWidth() * 2);
+- cascade_y += win->getTitleHeight() + (screen->getBorderWidth() * 2);
++ cascadePlacement(new_win, availableArea,
++ win->getTitleHeight() + (screen->getBorderWidth() * 2));
+ }
+
+ if (new_win.right() > availableArea.right())
+--- blackbox-0.65.0.orig/src/Workspace.hh
++++ blackbox-0.65.0/src/Workspace.hh
+@@ -51,7 +51,7 @@
+
+ std::string name;
+ unsigned int id;
+- unsigned int cascade_x, cascade_y;
++ std::map<int,Point> cascade_points;
+
+ Workspace(const Workspace&);
+ Workspace& operator=(const Workspace&);
+@@ -62,7 +62,7 @@
+ StackVector::iterator &stack);
+
+ void placeWindow(BlackboxWindow *win);
+- bool cascadePlacement(Rect& win, const Rect& availableArea);
++ bool cascadePlacement(Rect& win, Rect availableArea, int offset);
+ bool smartPlacement(Rect& win, const Rect& availableArea);
+
+ public:
+--- blackbox-0.65.0.orig/src/blackbox.cc
++++ blackbox-0.65.0/src/blackbox.cc
+@@ -1094,6 +1094,26 @@
+ screen_number, placement);
+ XrmPutLineResource(&new_blackboxrc, rc_string);
+
++ // write out xinerama settings
++ sprintf(rc_string, "session.screen%d.xineramaPlacement: %s",
++ screen_number, screen->doXineramaPlacement() ? "True" : "False");
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++ sprintf(rc_string, "session.screen%d.xineramaMaximize: %s",
++ screen_number, screen->doXineramaMaximize() ? "True" : "False");
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++ sprintf(rc_string, "session.screen%d.xineramaMenuPlacement: %s",
++ screen_number, screen->doXineramaMenus() ? "True" : "False");
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++ sprintf(rc_string, "session.screen%d.slit.xineramaPlacement: %s",
++ screen_number, screen->doXineramaSlit() ? "True" : "False");
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++ sprintf(rc_string, "session.screen%d.toolbar.xineramaPlacement: %s",
++ screen_number, screen->doXineramaToolbar() ? "True" : "False");
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++ sprintf(rc_string, "session.screen%d.toolbar.xineramaScreen: %d",
++ screen_number, screen->getXineramaToolbarScreen());
++ XrmPutLineResource(&new_blackboxrc, rc_string);
++
+ load_rc(screen);
+
+ // these are static, but may not be saved in the users .blackboxrc,
+@@ -1215,7 +1235,6 @@
+ }
+ }
+
+-
+ void Blackbox::load_rc(BScreen *screen) {
+ XrmDatabase database = (XrmDatabase) 0;
+
+@@ -1492,6 +1511,50 @@
+ ! strncasecmp("true", value.addr, value.size)) {
+ screen->saveOpaqueMove(True);
+ }
++
++ // load xinerama settings
++ sprintf(name_lookup, "session.screen%d.xineramaPlacement", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.XineramaPlacement", screen_number);
++ screen->saveXineramaPlacement(true);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && ! strncasecmp("false", value.addr, value.size)) {
++ screen->saveXineramaPlacement(false);
++ }
++ sprintf(name_lookup, "session.screen%d.xineramaMaximize", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.XineramaMaximize", screen_number);
++ screen->saveXineramaMaximize(true);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && ! strncasecmp("false", value.addr, value.size)) {
++ screen->saveXineramaMaximize(false);
++ }
++ sprintf(name_lookup, "session.screen%d.xineramaMenuPlacement", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.XineramaMenuPlacement", screen_number);
++ screen->saveXineramaMenus(true);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && ! strncasecmp("false", value.addr, value.size)) {
++ screen->saveXineramaMenus(false);
++ }
++ sprintf(name_lookup, "session.screen%d.slit.xineramaPlacement", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.Slit.XineramaPlacement", screen_number);
++ screen->saveXineramaSlit(true);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && ! strncasecmp("false", value.addr, value.size)) {
++ screen->saveXineramaSlit(false);
++ }
++ sprintf(name_lookup, "session.screen%d.toolbar.xineramaPlacement", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.Toolbar.XineramaPlacement", screen_number);
++ screen->saveXineramaToolbar(true);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && ! strncasecmp("false", value.addr, value.size)) {
++ screen->saveXineramaToolbar(false);
++ }
++ sprintf(name_lookup, "session.screen%d.toolbar.xineramaScreen", screen_number);
++ sprintf(class_lookup, "Session.Screen%d.Toolbar.XineramaScreen", screen_number);
++ screen->saveXineramaToolbarScreen(-1);
++ if ((XrmGetResource(database,name_lookup,class_lookup,&value_type,&value))
++ && sscanf(value.addr, "%d", &int_value) == 1) {
++ screen->saveXineramaToolbarScreen(int_value);
++ }
+
+ XrmDestroyDatabase(database);
+ }
+--- blackbox-0.65.0.orig/src/Xinerama.cc
++++ blackbox-0.65.0/src/Xinerama.cc
+@@ -0,0 +1,153 @@
++// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
++// Xinerama.cc for Blackbox - an X11 Window manager
++// Copyright (c) 2002 Jason Kraftcheck <kraftche@cae.wisc.edu>
++//
++// Permission is hereby granted, free of charge, to any person obtaining a
++// copy of this software and associated documentation files (the "Software"),
++// to deal in the Software without restriction, including without limitation
++// the rights to use, copy, modify, merge, publish, distribute, sublicense,
++// and/or sell copies of the Software, and to permit persons to whom the
++// Software is furnished to do so, subject to the following conditions:
++//
++// The above copyright notice and this permission notice shall be included in
++// all copies or substantial portions of the Software.
++//
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
++// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++// DEALINGS IN THE SOFTWARE.
++
++
++extern "C" {
++#include <X11/Xlib.h>
++#ifdef XINERAMA
++# include <X11/extensions/Xinerama.h>
++#endif
++}
++
++#include "Xinerama.hh"
++#include "BaseDisplay.hh"
++
++bool XineramaInfo::update(void)
++{
++ screen_list.clear();
++
++#ifdef XINERAMA
++ int count;
++ XineramaScreenInfo* xinerama_list = XineramaQueryScreens(
++ screen_info->getBaseDisplay()->getXDisplay(), &count );
++ if (xinerama_list) {
++ if (count > 1) {
++ for( int i = 0; i < count; i++ ) {
++ const XineramaScreenInfo& scr = xinerama_list[i];
++ screen_list.push_back( XineramaScreen( scr.screen_number,
++ Rect( scr.x_org, scr.y_org, scr.width, scr.height ) ) );
++ }
++ }
++ XFree(xinerama_list);
++ }
++#endif
++
++ return haveXinerama();
++}
++
++XineramaScreen XineramaInfo::screenContaining( int x, int y ) const
++{
++ XineramaList::const_iterator itr = getScreens().begin(),
++ end = getScreens().end();
++
++ for ( ; itr != end; ++itr) {
++ if (itr->getRect().contains(x,y))
++ return *itr;
++ };
++
++ return XineramaScreen();
++}
++
++XineramaScreen XineramaInfo::screenContaining( const Rect& rect ) const
++{
++ XineramaScreen result;
++ int area = 0;
++ XineramaList::const_iterator itr = getScreens().begin(),
++ end = getScreens().end();
++ for ( ; itr != end; ++itr) {
++ if (itr->getRect().intersects(rect)) {
++ int a = (itr->getRect() & rect).area();
++ if (a > area) {
++ result = *itr;
++ area = a;
++ }
++ }
++ }
++ return result;
++}
++
++
++XineramaScreen XineramaInfo::getScreen( int x_screen_number ) const
++{
++ XineramaList::const_iterator itr = getScreens().begin(),
++ end = getScreens().end();
++ for ( ; itr != end; ++itr) {
++ if (itr->getScreenNumber() == x_screen_number)
++ return *itr;
++ }
++
++ return XineramaScreen();
++}
++
++
++void XineramaInfo::getTopBottom( XineramaList& result, bool top ) const
++{
++ for (XineramaList::const_iterator in_itr = screen_list.begin();
++ in_itr != screen_list.end(); ++in_itr) {
++
++ XineramaList::iterator out_itr = result.begin();
++ while (out_itr != result.end() &&
++ in_itr->getRect().left() >= out_itr->getRect().right())
++ ++out_itr;
++
++ if (out_itr == result.end()) {
++ result.push_back(*in_itr);
++ }
++ else if (in_itr->getRect().right() <= out_itr->getRect().left()) {
++ result.insert(out_itr,*in_itr);
++ }
++ else if ((!top && in_itr->getRect().bottom() > out_itr->getRect().bottom()) ||
++ ( top && in_itr->getRect().top() < out_itr->getRect().top())) {
++ *out_itr = *in_itr;
++ }
++ }
++}
++
++XineramaScreen XineramaInfo::getClosestScreen( int x, int y ) const
++{
++ if (getScreens().empty())
++ return XineramaScreen();
++
++ XineramaList::const_iterator itr = screen_list.begin();
++ XineramaScreen result(*itr);
++ unsigned long dist_sqr = distanceSquared(itr->getRect(),x,y);
++ ++itr;
++
++ for ( ; itr != screen_list.end(); ++itr) {
++ unsigned long ds = distanceSquared(itr->getRect(), x, y);
++ if (ds < dist_sqr) {
++ dist_sqr = ds;
++ result = *itr;
++ }
++ }
++
++ return result;
++}
++
++unsigned long XineramaInfo::distanceSquared(const Rect& rect,int x,int y)
++{
++ unsigned long x_dist = (x < rect.left() ) ? rect.left() - x :
++ (x > rect.right() ) ? x - rect.right() : 0;
++ unsigned long y_dist = (y < rect.top() ) ? rect.top() - y :
++ (y > rect.bottom()) ? y - rect.bottom() : 0;
++ return x_dist * x_dist + y_dist * y_dist;
++}
+--- blackbox-0.65.0.orig/src/Xinerama.hh
++++ blackbox-0.65.0/src/Xinerama.hh
+@@ -0,0 +1,93 @@
++// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
++// Xinerama.hh for Blackbox - an X11 Window manager
++// Copyright (c) 2002 Jason Kraftcheck <kraftche@cae.wisc.edu>
++//
++// Permission is hereby granted, free of charge, to any person obtaining a
++// copy of this software and associated documentation files (the "Software"),
++// to deal in the Software without restriction, including without limitation
++// the rights to use, copy, modify, merge, publish, distribute, sublicense,
++// and/or sell copies of the Software, and to permit persons to whom the
++// Software is furnished to do so, subject to the following conditions:
++//
++// The above copyright notice and this permission notice shall be included in
++// all copies or substantial portions of the Software.
++//
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
++// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++// DEALINGS IN THE SOFTWARE.
++
++#ifndef __Xinerama_hh
++#define __Xinerama_hh
++
++#include <list>
++
++#include "Util.hh"
++
++class XineramaScreen;
++class ScreenInfo;
++
++typedef std::list<XineramaScreen> XineramaList;
++
++class XineramaScreen {
++private:
++ int x_screen;
++ Rect rect;
++
++public:
++ inline XineramaScreen( int screen_number, const Rect& box )
++ : x_screen(screen_number), rect(box) { }
++
++ inline XineramaScreen(void)
++ : x_screen(-1) { }
++
++ inline const Rect& getRect(void) const { return rect; }
++ inline int getScreenNumber(void) const { return x_screen; }
++
++ inline bool operator==( const XineramaScreen& other ) const
++ { return x_screen == other.x_screen; }
++
++ inline bool operator!=( const XineramaScreen& other ) const
++ { return x_screen != other.x_screen; }
++
++ inline bool isValid(void) const { return x_screen >= 0; }
++};
++
++class XineramaInfo {
++private:
++ XineramaList screen_list;
++ ScreenInfo* screen_info;
++
++protected:
++ void getTopBottom( XineramaList& result_list, bool top ) const;
++
++ static unsigned long distanceSquared( const Rect& rect, int x, int y );
++
++public:
++ inline XineramaInfo( ScreenInfo* screen ) : screen_info(screen)
++ { update(); }
++
++ inline bool haveXinerama(void) const
++ { return !screen_list.empty(); }
++
++ inline const XineramaList& getScreens(void) const
++ { return screen_list; }
++
++ bool update(void);
++
++ XineramaScreen screenContaining( int x, int y ) const;
++ XineramaScreen screenContaining( const Rect& rect ) const;
++ XineramaScreen getScreen( int x_screen_number ) const;
++ XineramaScreen getClosestScreen( int x, int y ) const;
++
++ inline void getTopScreens( XineramaList& result_list ) const
++ { getTopBottom( result_list, true ); }
++
++ inline void getBottomScreens( XineramaList& result_list ) const
++ { getTopBottom( result_list, false ); }
++};
++
++#endif
+--- blackbox-0.65.0.orig/util/Makefile.in
++++ blackbox-0.65.0/util/Makefile.in
+@@ -79,7 +79,7 @@
+ bin_PROGRAMS = bsetroot
+
+ bsetroot_SOURCES = bsetroot.cc
+-bsetroot_LDADD = ../src/BaseDisplay.o ../src/Color.o ../src/GCCache.o ../src/Texture.o ../src/Timer.o ../src/Image.o ../src/ImageControl.o ../src/i18n.o ../src/Util.o
++bsetroot_LDADD = ../src/BaseDisplay.o ../src/Color.o ../src/GCCache.o ../src/Texture.o ../src/Timer.o ../src/Image.o ../src/ImageControl.o ../src/i18n.o ../src/Util.o ../src/Xinerama.o
+
+ MAINTAINERCLEANFILES = Makefile.in
+ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+--- blackbox-0.65.0.orig/debian/changelog
++++ blackbox-0.65.0/debian/changelog
+@@ -0,0 +1,188 @@
++blackbox (0.65.0-5) unstable; urgency=high
++
++ * Fixed FTBFS with the missing build dependency on autoconf.
++ (closes: #291133)
++
++ -- Bruno Barrera C. <bruno@debian.org> Tue, 18 Jan 2005 20:22:45 -0300
++
++blackbox (0.65.0-4) unstable; urgency=low
++
++ * Fixed the string length problem. (closes: #178001)
++ * Added Xinerama support. (closes: #277517)
++
++ -- Bruno Barrera C. <bruno@debian.org> Mon, 17 Jan 2005 23:27:56 -0300
++
++blackbox (0.65.0-3) unstable; urgency=low
++
++ * Fixed FTBFS with gcc-3.4 (closes: #266642)
++ * debian/postinst now checks for the correct files to be removed
++ (blackbox-menu instead Blackbox-menu)
++
++ -- Bruno Barrera C. <bruno.barrera@igloo.cl> Fri, 20 Aug 2004 21:44:55 -0400
++
++blackbox (0.65.0-2) unstable; urgency=low
++
++ * New Maintainer (closes: #259585)
++ * Corrected menu-method coding (closes: #251237)
++ * Added a blackbox.desktop file. (closes: #257423)
++ * Completed the debian/copyright file.
++
++ -- Bruno Barrera C. <bruno.barrera@igloo.cl> Fri, 16 Jul 2004 18:26:04 -0400
++
++blackbox (0.65.0-1.2) unstable; urgency=low
++
++ * Non Maintainer Upload
++ * Patch by Matt Kraai to solve FTBFS: Closes: #208814.
++
++ -- Jesus Climent <jesus.climent@hispalinux.es> Wed, 15 Oct 2003 15:38:53 +0300
++
++blackbox (0.65.0-1.1) unstable; urgency=low
++
++ * Non Maintainer Upload
++ * Include <cassert> in src/Window.cc (Closes: #196245)
++
++ -- David Pashley <david@davidpashley.com> Tue, 15 Jul 2003 16:36:04 +0200
++
++blackbox (0.65.0-1) unstable; urgency=low
++
++ * new upstream release
++ * now has man pages for all binaries, closes: #93427
++ * newer version of bsetbg behaves much better, closes: #109606
++ * tilde expansion in blackboxrc and menus is now supported, closes: #139330
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Wed, 18 Sep 2002 11:02:00 -0700
++
++blackbox (0.65.0-0.pre1) unstable; urgency=low
++
++ * temporary deb
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Fri, 6 Sep 2002 19:33:37 -0700
++
++blackbox (0.62.1-1) unstable; urgency=low
++
++ * new upstream release
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Wed, 30 Jan 2002 22:17:06 -0800
++
++blackbox (0.62.0-1) unstable; urgency=low
++
++ * new upstream
++ * I am now the upstream (-:
++ * upstream fixes these, Closes: #72254, #103909, #116767
++ * Documented update-menu and blackbox behaviour (closes: #117386)
++ * Added README.menu and .style (closes: #81008)
++ * removed empty dir (closes: #78777)
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Sat, 19 Jan 2002 11:22:06 -0800
++
++blackbox (0.61.1-1.1) unstable; urgency=low
++
++ * NMU
++ * Fix unsafe temp files in bsetbg. Closes: #102126
++ * Add class key as needed, printf is a macro as of gcc 3.0. Closes: #105452
++
++ -- LaMont Jones <lamont@smallone.fc.hp.com> Sun, 15 Jul 2001 23:29:46 -0600
++
++blackbox (0.61.1-1) unstable; urgency=low
++
++ * New upstream release
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Mon, 9 Oct 2000 10:10:31 -0700
++
++blackbox (0.61.0-3) unstable; urgency=low
++
++ * Changed menu-method to call x-terminal-emulator instead of xterm
++ * Closes: #71981
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Wed, 20 Sep 2000 11:41:45 -0700
++
++blackbox (0.61.0-2) unstable; urgency=low
++
++ * removed echo from the postinst
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Thu, 31 Aug 2000 11:35:39 -0700
++
++blackbox (0.61.0-1) unstable; urgency=low
++
++ * New upstream
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Fri, 18 Aug 2000 13:29:31 -0700
++
++blackbox (0.61.0.20000806-1) unstable; urgency=low
++
++ * New upstream
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Mon, 7 Aug 2000 10:19:22 -0700
++
++blackbox (0.61.0.20000726-2) unstable; urgency=low
++
++ * Oops, forgot to re-run autofriends
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Wed, 26 Jul 2000 16:39:15 -0700
++
++blackbox (0.61.0.20000726-1) unstable; urgency=low
++
++ * New upstream beta
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Wed, 26 Jul 2000 13:10:07 -0700
++
++blackbox (0.60.3-5) unstable; urgency=low
++
++ * Fix for improper quoting of rootCommand
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Thu, 20 Jul 2000 21:41:11 -0700
++
++blackbox (0.60.3-4) unstable; urgency=low
++
++ * Bug fix release
++ * added a CXXFLAGS setting to the rules file. This makes blackbox smaller
++ and faster.
++ * Closes: #45298, #55305, #61552, #64615, #64773, #64851, #64969
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Tue, 18 Jul 2000 13:01:43 -0700
++
++blackbox (0.60.3-3) unstable; urgency=low
++
++ * Oops, left the stylesmenu file
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Sat, 27 May 2000 19:40:41 -0700
++
++blackbox (0.60.3-2) unstable; urgency=low
++
++ * Oops, left a call to update-bbstyles
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Fri, 26 May 2000 16:12:27 -0700
++
++blackbox (0.60.3-1) unstable; urgency=low
++
++ * New upstream release
++ * Changed user style menu to look in ~/.blackbox/styles to match
++ current practice among style authors
++ * Cleaned up menu-method script and thus the resulting menu file it
++ generates
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Fri, 26 May 2000 12:08:34 -0700
++
++blackbox (0.60.2-2) unstable; urgency=low
++
++ * Removed update-styles
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Thu, 25 May 2000 14:02:15 -0700
++
++blackbox (0.60.2-1) unstable; urgency=low
++
++ * New upstream release
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Thu, 25 May 2000 12:55:42 -0700
++
++blackbox (0.60.0.alpha-2) unstable; urgency=low
++
++ * New maintainer
++
++ -- Sean 'Shaleh' Perry <shaleh@debian.org> Thu, 25 May 2000 11:50:49 -0700
++
++blackbox (0.60.0.alpha-1) unstable; urgency=low
++
++ * The Alpha release.
++
++ -- Brent A. Fulgham <bfulgham@debian.org> Sat, 22 April 2000 13:32:08 -0800
+--- blackbox-0.65.0.orig/debian/conffiles
++++ blackbox-0.65.0/debian/conffiles
+@@ -0,0 +1 @@
++/etc/menu-methods/blackbox
+--- blackbox-0.65.0.orig/debian/control
++++ blackbox-0.65.0/debian/control
+@@ -0,0 +1,26 @@
++Source: blackbox
++Section: x11
++Priority: optional
++Build-Depends: autoconf, xlibs-dev, debhelper
++Maintainer: Bruno Barrera C. <bruno@debian.org>
++Standards-Version: 3.5.0
++
++Package: blackbox
++Architecture: any
++Depends: ${shlibs:Depends}
++Provides: x-window-manager
++Suggests: menu (>=1.5)
++Description: Window manager for X
++ This is a window manager for X. It is similar in many respects to
++ such popular packages as Window Maker, Enlightenment, and FVWM2. You
++ might be interested in this package if you are tired of window managers
++ that are a heavy drain on your system resources, but you still want
++ an attractive and modern-looking interface.
++ .
++ The best part of all is that this program is coded in C++, so it
++ is even more attractive "under the hood" than it is in service -- no
++ small feat.
++ .
++ If none of this sounds familiar to you, or you want your computer to
++ look like Microsoft Windows or Apple's OS X, you probably don't want
++ this package.
+--- blackbox-0.65.0.orig/debian/copyright
++++ blackbox-0.65.0/debian/copyright
+@@ -0,0 +1,37 @@
++This package was debianized by Brent A. Fulgham bfulgham@debian.org on
++Thu, 15 Oct 1998 18:17:09 -0700.
++
++It was downloaded from http://sf.net/projects/blackboxwm
++
++Upstream Authors: Sean 'Shaleh' Perry <shaleh@debian.org>
++ Brad Hughes <bhughes@trolltech.com>
++ Jeff Raven <jraven@psu.edu>
++
++Copyright:
++
++The Regents of the University of California.
++All rights reserved.
++
++Redistribution and use in source and binary forms, with or without
++modification, are permitted provided that the following conditions
++are met:
++1. Redistributions of source code must retain the above copyright
++ notice, this list of conditions and the following disclaimer.
++2. Redistributions in binary form must reproduce the above copyright
++ notice, this list of conditions and the following disclaimer in the
++ documentation and/or other materials provided with the distribution.
++3. Neither the name of the University nor the names of its contributors
++ may be used to endorse or promote products derived from this software
++ without specific prior written permission.
++
++THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS'' AND
++ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++SUCH DAMAGE.
+--- blackbox-0.65.0.orig/debian/dirs
++++ blackbox-0.65.0/debian/dirs
+@@ -0,0 +1,10 @@
++etc/menu-methods
++etc/X11/blackbox
++usr/bin
++usr/share/man/man1
++usr/share/doc
++usr/share/doc/blackbox
++usr/share/blackbox
++usr/share/blackbox/styles
++usr/share/blackbox/nls
++usr/share/xsessions
+--- blackbox-0.65.0.orig/debian/docs
++++ blackbox-0.65.0/debian/docs
+@@ -0,0 +1 @@
++AUTHORS README README.bsetbg data/README.menu data/README.style
+--- blackbox-0.65.0.orig/debian/menu
++++ blackbox-0.65.0/debian/menu
+@@ -0,0 +1,24 @@
++?package(blackbox):needs="wm" \
++ section="WindowManagers" title="Blackbox" \
++ command="/usr/bin/blackbox"
++?package(blackbox):needs="blackbox" \
++ section="WindowManagers" title="Exit" \
++ command="exit"
++?package(blackbox):needs="blackbox" \
++ section="WindowManagers" title="Reconfigure" \
++ command="reconfig"
++?package(blackbox):needs="blackbox" \
++ section="WindowManagers" title="Restart" \
++ command="restart"
++?package(blackbox):needs="blackbox" \
++ section="Blackbox/Styles" title="/usr/share/blackbox/styles" \
++ command="stylesdir"
++?package(blackbox):needs="blackbox" \
++ section="Blackbox/Styles" title="~/.blackbox/styles" \
++ command="stylesdir"
++?package(blackbox):needs="blackbox" \
++ section="Blackbox" title="Workspaces" \
++ command="workspaces"
++?package(blackbox):needs="blackbox" \
++ section="Blackbox" title="Configuration" \
++ command="config"
+--- blackbox-0.65.0.orig/debian/menu-method
++++ blackbox-0.65.0/debian/menu-method
+@@ -0,0 +1,27 @@
++#!/usr/sbin/install-menu
++#
++# Generates blackbox menus for all registered applications.
++
++!include menu.h
++compat="menu-1"
++outputencoding="LOCALE"
++
++genmenu="blackbox-menu"
++rootprefix="/etc/X11/blackbox/"
++userprefix=".blackbox/"
++treewalk="M)"
++
++supported
++ x11= nstring(level(), " ") "[exec] (" esc(title(), "()") ") {" esc($command, "()") "}\n"
++ wm= nstring(level(), " ") "[restart] (" esc(title(), "()") ") {" esc($command, "()") "}\n"
++ text= nstring(level(), " ") "[exec] (" esc(title(), "()") ") {" esc(term(), "()") "}\n"
++blackbox= nstring(level(), " ") "[" esc($command, "()") "] (" esc(title(), "()") ")\n"
++endsupported
++
++preoutput= \
++ "# Automatically generated file. Do not edit (see /usr/share/doc/menu/README)\n\n[begin] (Debian)\n"
++
++startmenu= ""
++submenutitle= nstring(level(), " ") "[submenu] (" esc(title(),"()") ") {" esc($longtitle,"()") "}\n"
++endmenu= nstring(level(), " ") "[end]\n"
++
+--- blackbox-0.65.0.orig/debian/postinst
++++ blackbox-0.65.0/debian/postinst
+@@ -0,0 +1,49 @@
++#!/bin/sh
++#
++# Blackbox postinst
++#
++# Shamelessly ripped off of Marcelo Magallon's script
++# by Brent Fulgham <bfulgham@debian.org>
++#
++set -e
++
++WMentry="/usr/bin/blackbox"
++
++add_wm_entry ()
++{
++ update-alternatives --install /usr/bin/x-window-manager x-window-manager $WMentry 50 \
++ --slave /usr/share/man/man1/x-window-manager.1.gz x-window-manager.1.gz /usr/share/man/man1/blackbox.1.gz
++}
++
++case "$1" in
++ configure)
++ if [ "$2" ] && dpkg --compare-versions $2 le 0.51.3-12; then
++ update-alternatives --remove x-window-manager /etc/X11/window-managers
++ fi
++
++ add_wm_entry
++
++ # clean up after eaarlier debs
++ if [ -f /usr/share/blackbox/styles/stylesmenu ]; then
++ rm /usr/share/blackbox/styles/stylesmenu
++ fi
++
++ if [ -f /etc/X11/blackbox/blackbox-menu ]; then
++ rm /etc/X11/blackbox/blackbox-menu
++ fi
++
++ if [ -x /usr/sbin/wm-menu-config ]; then
++ wm-menu-config blackbox on;
++ fi
++ ;;
++
++ abort-upgrade|abort-deconfigure|abort-remove)
++ # how did we get here? Force a non-zero exit code
++ exit 1
++ ;;
++
++ *)
++ ;;
++esac
++
++#DEBHELPER#
+--- blackbox-0.65.0.orig/debian/postrm
++++ blackbox-0.65.0/debian/postrm
+@@ -0,0 +1,24 @@
++#!/bin/sh
++set -e
++
++Blackbox_entry="/usr/bin/blackbox"
++
++case "$1" in
++ purge)
++ rm -rf /etc/X11/blackbox
++ ;;
++ remove)
++ if [ -x /usr/sbin/wm-menu-config ]; then
++ wm-menu-config blackbox off
++ fi
++
++ if [ -x /usr/sbin/register-window-manager ] ; then
++ register-window-manager --remove $Blackbox_entry
++ fi
++
++ ;;
++ *)
++ ;;
++esac
++
++#DEBHELPER#
+--- blackbox-0.65.0.orig/debian/rules
++++ blackbox-0.65.0/debian/rules
+@@ -0,0 +1,71 @@
++#!/usr/bin/make -f
++# MAde with the aid of dh_make, by Craig Small
++# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
++# Some lines taken from debmake, by Cristoph Lameter.
++
++# Uncomment this to turn on verbose mode.
++#export DH_VERBOSE=1
++
++PACKAGE=blackbox
++
++build: build-stamp
++build-stamp:
++ dh_testdir
++ autoconf
++ CXXFLAGS="-O2 -fno-rtti -fno-exceptions -fno-check-new" ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc/X11/blackbox
++
++ # Add here commands to compile the package.
++ $(MAKE) DEFAULT_MENU=/etc/X11/blackbox/blackbox-menu
++
++ touch build-stamp
++
++clean:
++ dh_testdir
++ dh_testroot
++ rm -f build-stamp install-stamp config.log
++
++ # Add here commands to clean up after the build process.
++ -$(MAKE) distclean
++
++ dh_clean
++
++
++install: install-stamp
++install-stamp: build-stamp
++ dh_testdir
++ dh_testroot
++ dh_clean -k
++ dh_installdirs
++
++ # Add here commands to install the package into debian/tmp.
++ $(MAKE) install DESTDIR=`pwd`/debian/tmp
++ # make install places a menu here, but we don't want it
++ rm -f `pwd`/debian/tmp/usr/share/blackbox/menu
++ cp debian/blackbox.desktop `pwd`/debian/tmp/usr/share/xsessions/
++ touch install-stamp
++
++# Build architecture-independent files here.
++binary-indep: build install
++# We have nothing to do by default.
++
++# Build architecture-dependent files here.
++binary-arch: build install
++ dh_testdir
++ dh_testroot
++ dh_installdocs
++ dh_installmenu
++ dh_installchangelogs ChangeLog
++ dh_strip
++ dh_compress
++ dh_fixperms
++ dh_installdeb
++ dh_shlibdeps
++ dh_gencontrol
++ dh_md5sums
++ dh_builddeb
++
++source diff:
++ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
++
++binary: binary-indep binary-arch
++.PHONY: build clean binary-indep binary-arch binary
+--- blackbox-0.65.0.orig/debian/prerm
++++ blackbox-0.65.0/debian/prerm
+@@ -0,0 +1,13 @@
++#!/bin/sh
++set -e
++
++case "$1" in
++ remove)
++ update-alternatives --remove x-window-manager /usr/bin/blackbox
++ ;;
++ *)
++ ;;
++esac
++
++#DEBHELPER#
++
+--- blackbox-0.65.0.orig/debian/README.debian
++++ blackbox-0.65.0/debian/README.debian
+@@ -0,0 +1,9 @@
++User menus:
++
++When update-menus is run as a user it will create ~/.blackbox-menu. You then
++need to exit blackbox if it is running and edit ~/.blackboxrc. Change the
++line:
++
++session.menuFile: /etc/X11/blackbox/blackbox-menu
++
++to point to the new file.
+--- blackbox-0.65.0.orig/debian/blackbox.desktop
++++ blackbox-0.65.0/debian/blackbox.desktop
+@@ -0,0 +1,12 @@
++[Desktop Entry]
++Encoding=UTF-8
++Name=Blackbox
++Comment=Highly configurable and low resource X11 Window manager
++Exec=blackbox
++Terminal=False
++TryExec=blackbox
++Type=Application
++
++[Window Manager]
++SessionManaged=true
++
diff --git a/source/xap/blackbox/slack-desc b/source/xap/blackbox/slack-desc
new file mode 100644
index 00000000..a459e577
--- /dev/null
+++ b/source/xap/blackbox/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+blackbox: blackbox (Blackbox window manager)
+blackbox:
+blackbox: Blackbox is that fast, light window manager you have been looking for
+blackbox: without all those annoying library dependencies.
+blackbox:
+blackbox: Also included in this package is the bbkeys utility for controlling
+blackbox: keyboard shortcut commands from within Blackbox.
+blackbox:
+blackbox: The Blackbox home page is http://blackboxwm.sourceforge.net
+blackbox:
+blackbox:
diff --git a/source/xap/blackbox/xinitrc.blackbox b/source/xap/blackbox/xinitrc.blackbox
new file mode 100644
index 00000000..e5822118
--- /dev/null
+++ b/source/xap/blackbox/xinitrc.blackbox
@@ -0,0 +1,28 @@
+#!/bin/sh
+# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
+
+userresources=$HOME/.Xresources
+usermodmap=$HOME/.Xmodmap
+sysresources=/usr/lib/X11/xinit/.Xresources
+sysmodmap=/usr/lib/X11/xinit/.Xmodmap
+
+# merge in defaults and keymaps
+
+if [ -f $sysresources ]; then
+ xrdb -merge $sysresources
+fi
+
+if [ -f $sysmodmap ]; then
+ xmodmap $sysmodmap
+fi
+
+if [ -f $userresources ]; then
+ xrdb -merge $userresources
+fi
+
+if [ -f $usermodmap ]; then
+ xmodmap $usermodmap
+fi
+
+# Start the window manager:
+exec /usr/bin/blackbox
diff --git a/source/xap/electricsheep/README.slackware b/source/xap/electricsheep/README.slackware
new file mode 100644
index 00000000..3476cb67
--- /dev/null
+++ b/source/xap/electricsheep/README.slackware
@@ -0,0 +1,29 @@
+ElectricSheep 2.6.9
+===================
+
+Electricsheep can no longer be configured from within the KDE4 screensaver
+preferences dialog. Instead, a separate "electricsheep-preferences"
+should be used now. The KDE4 screensaver file has been updated to reflect
+this change.
+
+The configuration application, "electricsheep-preferences", will now
+display when you push the "setup" button in the screensaver settings in
+KDE4 System Settings. The sheep also play in the small preview window
+within the System Settings dialog window.
+
+The "test" button does not work correctly. If you press it, the sheep
+will play, but the window in which the animation runs will not stretch
+to fullscreen.
+
+The sheep will play in full screen as expected when the real screensaver
+activates after the configured period of idle time. Shake the mouse and
+it stops.
+
+Electricsheep requires MPlayer to display your sheep! In some cases,
+the mplayer window may not close after stopping the screensaver. This will
+prevent electricsheep to play new sheep when the screensaver activates again.
+The solution (it is not a real solution I know) is to kill mplayer with
+ksysguard or the commandline "kill".
+
+=============================================================================
+Eric Hameleers <alien@slackware.com> :: 07jan2009
diff --git a/source/xap/electricsheep/electricsheep.SlackBuild b/source/xap/electricsheep/electricsheep.SlackBuild
new file mode 100755
index 00000000..1ed540cd
--- /dev/null
+++ b/source/xap/electricsheep/electricsheep.SlackBuild
@@ -0,0 +1,266 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Eric Hameleers, Eindhoven, Netherlands
+# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Permission to use, copy, modify, and distribute this software for
+# any purpose with or without fee is hereby granted, provided that
+# the above copyright notice and this permission notice appear in all
+# copies.
+#
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+# -----------------------------------------------------------------------------
+#
+# Slackware SlackBuild script
+# ===========================
+# By: Eric Hameleers <alien@slackware.com>
+# For: electricsheep
+# Descr: distributed screensaver
+# URL: http://electricsheep.org/
+# Needs: MPlayer (to display the sheep)
+# -----------------------------------------------------------------------------
+
+PRGNAM=electricsheep
+VERSION=${VERSION:-20090306}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+# Where do we look for sources?
+SRCDIR=$(cd $(dirname $0); pwd)
+
+DOCS="COPYING README $SRCDIR/README.slackware"
+DOCS_FLAM3="COPYING* README*"
+DOCS_FFMPEG="COPYING* CREDITS Changelog MAINTAINERS README"
+
+SOURCE="$SRCDIR/${PRGNAM}-${VERSION}.tar.xz"
+SRCURL=""
+
+# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
+TMP=${TMP:-/tmp/build}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+# Use the src_checkout() function if no downloadable tarball exists.
+# This function checks out sources from SVN/CVS and creates a tarball of them.
+src_checkout() {
+ # Param #1 : index in the SOURCE[] array.
+ # Param #2 : full path to where SOURCE[$1] tarball should be created.
+ # Determine the tarball extension:
+ PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
+ case "$PEXT" in
+ "tar.xz") TARCOMP="J" ;;
+ "tar.gz") TARCOMP="z" ;;
+ "tgz") TARCOMP="z" ;;
+ "tar.bz2") TARCOMP="j" ;;
+ *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
+ esac
+ case ${1} in
+ 0) # electricsheep-$VERSION
+ REV="{${VERSION}}"
+ mkdir electricsheep-${VERSION} \
+ && cd electricsheep-${VERSION} \
+ && svn checkout --revision $REV http://electricsheep.svn.sourceforge.net/svnroot/electricsheep/trunk/client client \
+ && svn checkout --revision $REV http://flam3.svn.sourceforge.net/svnroot/flam3/trunk/src flam3 \
+ && find . -type d -name '.svn' -depth | xargs rm -rf \
+ && chown -R root:root . \
+ && ( cd ..; tar -${TARCOMP}cf ${2} electricsheep-${VERSION} )
+ cd ..
+ rm -rf electricsheep-${VERSION}
+ ;;
+ *) # do nothing
+ ;;
+ esac
+}
+##
+## --- with a little luck, you won't have to edit below this point --- ##
+##
+
+# Exit the script on errors:
+set -e
+trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
+# Catch unitialized variables:
+set -u
+P1=${1:-1}
+
+case "$ARCH" in
+ i486) SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ s390) SLKCFLAGS="-O2"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ powerpc) SLKCFLAGS="-O2"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ x86_64) SLKCFLAGS="-O2 -fPIC"
+ SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
+ ;;
+ athlon-xp) SLKCFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ arm) SLKCFLAGS="-O2 -march=armv4 -mtune=xscale"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ armel) SLKCFLAGS="-O2 -march=armv4t"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+esac
+
+# Create working directories:
+mkdir -p $OUTPUT # place for the package to be saved
+mkdir -p $TMP/tmp-$PRGNAM # location to build the source
+mkdir -p $PKG # place for the package to be built
+rm -rf $PKG/* # always erase old package's contents
+rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
+rm -rf $OUTPUT/{configure,make,install,error,makepkg}-$PRGNAM.log
+ # remove old log files
+
+# Source file availability:
+if ! [ -f ${SOURCE} ]; then
+ echo "Source '$(basename ${SOURCE})' not available yet..."
+ # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
+ [ -w "$SRCDIR" ] || SOURCE="$OUTPUT/$(basename ${SOURCE})"
+ if ! [ "x${SRCURL}" == "x" ]; then
+ echo "Will download file to $(dirname $SOURCE)"
+ wget -nv -T 20 -O "${SOURCE}" "${SRCURL}" || true
+ if [ $? -ne 0 -o ! -s "${SOURCE}" ]; then
+ echo "Downloading '$(basename ${SOURCE})' failed.. aborting the build."
+ mv -f "${SOURCE}" "${SOURCE}".FAIL
+ exit 1
+ fi
+ else
+ # Try if we have a SVN/CVS download routine for ${SOURCE}
+ echo "Will checkout sources to $(dirname $SOURCE)"
+ src_checkout 0 "${SOURCE}" 2>&1 > $OUTPUT/checkout-$(basename ${SOURCE}).log
+ fi
+ if [ ! -f "${SOURCE}" -o ! -s "${SOURCE}" ]; then
+ echo "File '$(basename ${SOURCE})' not available.. aborting the build."
+ exit 1
+ fi
+fi
+
+if [ "$P1" == "--download" ]; then
+ echo "Download complete."
+ exit 0
+fi
+
+# --- PACKAGE BUILDING ---
+
+echo "++"
+echo "|| $PRGNAM-$VERSION"
+echo "++"
+
+cd $TMP/tmp-$PRGNAM
+echo "Extracting the source archive(s) for $PRGNAM..."
+tar -xvf ${SOURCE}
+cd ${PRGNAM}-${VERSION}
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+echo Building ...
+# First the client:
+cd client
+ # mplayer needs a buffer when reading from a pipe:
+ zcat $SRCDIR/electricsheep.mplayer.diff.gz | patch -p2 --verbose || exit 1
+ # To prevent an error later on:
+ chmod +x ffmpeg/doc/texi2pod.pl
+ # We do not use gnome:
+ cat $SRCDIR/electricsheep_gnome-open.patch | patch -p1 --verbose \
+ 2>&1 | tee $OUTPUT/patch-$PRGNAM.log
+ # Prevent install errors due to missing gnome
+ sed -i -e "/^install-data-local:/,/^$/d" Makefile.in
+ LDFLAGS="$SLKLDFLAGS" \
+ CXXFLAGS="$SLKCFLAGS" \
+ CFLAGS="$SLKCFLAGS" \
+ ./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --build=$ARCH-slackware-linux \
+ 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log
+ make 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
+ make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
+cd ..
+# Then the flam3 (fractal flames) renderer:
+cd flam3
+ LDFLAGS="$SLKLDFLAGS" \
+ CXXFLAGS="$SLKCFLAGS" \
+ CFLAGS="$SLKCFLAGS" \
+ ./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --build=$ARCH-slackware-linux \
+ 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log
+ make 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
+ make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
+cd ..
+
+# Add documentation:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/{flam3,ffmpeg}
+( cd client
+ cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
+)
+( cd client/ffmpeg
+ cp -a $DOCS_FFMPEG $PKG/usr/doc/$PRGNAM-$VERSION/ffmpeg
+)
+( cd flam3
+ cp -a $DOCS_FLAM3 $PKG/usr/doc/$PRGNAM-$VERSION/flam3
+)
+chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
+find $PKG/usr/doc -type f -exec chmod 644 {} \;
+
+cd client
+ # Add xscreensaver module:
+ mkdir -p $PKG/usr/share/xscreensaver/config
+ install -m644 electricsheep.xml \
+ $PKG/usr/share/xscreensaver/config/electricsheep.xml
+
+ # Add the KDE4 screensaver file:
+ install -D -m644 electricsheep.desktop.kde \
+ ${PKG}/usr/share/kde4/services/ScreenSavers/electricsheep.desktop
+ sed -i -e 's/^X-KDE-Category=.*$/X-KDE-Category=Fractals/' \
+ ${PKG}/usr/share/kde4/services/ScreenSavers/electricsheep.desktop
+
+ # Add icons:
+ mkdir -p $PKG/usr/share/electricsheep
+ cp -a electricsheep-{smile,frown}.png $PKG/usr/share/electricsheep/
+cd ..
+
+# Compress the man page(s)
+if [ -d $PKG/usr/man ]; then
+ find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
+ for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+fi
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Add a package description:
+mkdir -p $PKG/install
+cat $SRCDIR/slack-desc > $PKG/install/slack-desc
+
+# Build the package:
+cd $PKG
+makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
+cd $OUTPUT
+md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txz.md5
+cd -
+cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt
diff --git a/source/xap/electricsheep/electricsheep.mplayer.diff b/source/xap/electricsheep/electricsheep.mplayer.diff
new file mode 100644
index 00000000..6fe7c4ce
--- /dev/null
+++ b/source/xap/electricsheep/electricsheep.mplayer.diff
@@ -0,0 +1,12 @@
+diff -uar electricsheep-20090306.orig/client/electricsheep.c electricsheep-20090306/client/electricsheep.c
+--- electricsheep-20090306.orig/client/electricsheep.c 2009-03-06 01:30:18.000000000 +0100
++++ electricsheep-20090306/client/electricsheep.c 2009-07-01 21:53:21.000000000 +0200
+@@ -1946,6 +1946,8 @@
+ }
+ argv[c++] = "mplayer";
+ argv[c++] = "-really-quiet";
++ argv[c++] = "-cache";
++ argv[c++] = "8192";
+ if (window_id) {
+ argv[c++] = "-monitoraspect";
+ argv[c++] = monitoraspect;
diff --git a/source/xap/electricsheep/electricsheep_gnome-open.patch b/source/xap/electricsheep/electricsheep_gnome-open.patch
new file mode 100644
index 00000000..e86ec495
--- /dev/null
+++ b/source/xap/electricsheep/electricsheep_gnome-open.patch
@@ -0,0 +1,13 @@
+--- electricsheep-20090107/electricsheep-preferences.c.orig 2009-01-07 14:36:30.000000000 +0100
++++ electricsheep-20090107/electricsheep-preferences.c 2009-01-07 17:27:34.000000000 +0100
+@@ -115,8 +115,8 @@
+ }
+
+ void on_helpButton_clicked(GtkWidget *widget, gpointer user_data) {
+- if (system("gnome-open http://electricsheep.org/client/LNX_" VERSION ".html &"))
+- perror("gnome-open");
++ if (system("xdg-open http://electricsheep.org/client/LNX_" VERSION ".html &"))
++ perror("xdg-open");
+ }
+
+ static void tick() {
diff --git a/source/xap/electricsheep/slack-desc b/source/xap/electricsheep/slack-desc
new file mode 100644
index 00000000..d82ddf45
--- /dev/null
+++ b/source/xap/electricsheep/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+electricsheep: electricsheep (distributed screensaver)
+electricsheep:
+electricsheep: Electric Sheep is an xscreensaver module that displays mpeg video
+electricsheep: of an animated fractal flame. In the background it contributes
+electricsheep: render cycles to the next animation. Periodically it uploades
+electricsheep: completed frames to the server, where they are compressed for
+electricsheep: distribution to all clients.
+electricsheep: This program is recommended only if you have a high bandwidth
+electricsheep: connection to the internet such as DSL or cable modem.
+electricsheep:
+electricsheep: electricsheep home: http://electricsheep.org/
diff --git a/source/xap/fluxbox/fluxbox.SlackBuild b/source/xap/fluxbox/fluxbox.SlackBuild
new file mode 100755
index 00000000..bb0f0363
--- /dev/null
+++ b/source/xap/fluxbox/fluxbox.SlackBuild
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=1.1.1
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-fluxbox
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+tar xvf $CWD/fluxbox-$VERSION.tar.?z* || exit 1
+cd fluxbox-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/fluxbox-$VERSION \
+ --enable-xinerama \
+ --enable-shape \
+ --enable-slit \
+ --enable-interlace \
+ --enable-nls \
+ --enable-timed-cache \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+gzip -9 $PKG/usr/man/man?/*
+
+mkdir -p $PKG/etc/X11/xinit
+zcat $CWD/xinitrc.fluxbox.gz > $PKG/etc/X11/xinit/xinitrc.fluxbox
+chmod 755 $PKG/etc/X11/xinit/xinitrc.fluxbox
+
+mkdir -p $PKG/usr/doc/fluxbox-$VERSION
+cp -a AUTHORS COPYING* INSTALL NEWS README* TODO \
+ $PKG/usr/doc/fluxbox-$VERSION
+chmod 644 $PKG/usr/doc/fluxbox-$VERSION/*
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/fluxbox-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/fluxbox/slack-desc b/source/xap/fluxbox/slack-desc
new file mode 100644
index 00000000..e1bb595c
--- /dev/null
+++ b/source/xap/fluxbox/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+fluxbox: fluxbox (Fluxbox window manager)
+fluxbox:
+fluxbox: Fluxbox is yet another windowmanager for X that is based on blackbox
+fluxbox: but with many new features.
+fluxbox:
+fluxbox:
+fluxbox:
+fluxbox:
+fluxbox:
+fluxbox:
+fluxbox:
diff --git a/source/xap/fluxbox/xinitrc.fluxbox b/source/xap/fluxbox/xinitrc.fluxbox
new file mode 100644
index 00000000..d04675a9
--- /dev/null
+++ b/source/xap/fluxbox/xinitrc.fluxbox
@@ -0,0 +1,28 @@
+#!/bin/sh
+# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
+
+userresources=$HOME/.Xresources
+usermodmap=$HOME/.Xmodmap
+sysresources=/usr/lib/X11/xinit/.Xresources
+sysmodmap=/usr/lib/X11/xinit/.Xmodmap
+
+# merge in defaults and keymaps
+
+if [ -f $sysresources ]; then
+ xrdb -merge $sysresources
+fi
+
+if [ -f $sysmodmap ]; then
+ xmodmap $sysmodmap
+fi
+
+if [ -f $userresources ]; then
+ xrdb -merge $userresources
+fi
+
+if [ -f $usermodmap ]; then
+ xmodmap $usermodmap
+fi
+
+# Start the window manager:
+exec /usr/bin/startfluxbox
diff --git a/source/xap/fvwm/doinst.sh b/source/xap/fvwm/doinst.sh
new file mode 100644
index 00000000..57a23d6f
--- /dev/null
+++ b/source/xap/fvwm/doinst.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+config() {
+ NEW="$1"
+ OLD="`dirname $NEW`/`basename $NEW .new`"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+config etc/X11/fvwm2/system.fvwm2rc.new
diff --git a/source/xap/fvwm/fvwm.SlackBuild b/source/xap/fvwm/fvwm.SlackBuild
new file mode 100755
index 00000000..c990f1a0
--- /dev/null
+++ b/source/xap/fvwm/fvwm.SlackBuild
@@ -0,0 +1,127 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=fvwm
+VERSION=${VERSION:-2.4.20}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/X11/fvwm2 \
+ --mandir=/usr/man \
+ --enable-multibyte \
+ --program-prefix= \
+ --program-suffix= \
+ --enable-extras \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Add some ancient icons:
+( cd $PKG ; tar xzf $CWD/ancient-icons.tar.gz )
+
+# Add a few more things:
+mkdir -p $PKG/etc/X11/xinit
+zcat $CWD/xinitrc.fvwm2.gz > $PKG/etc/X11/xinit/xinitrc.fvwm2
+chmod 755 $PKG/etc/X11/xinit/xinitrc.fvwm2
+mkdir -p $PKG/etc/X11/fvwm2
+zcat $CWD/system.fvwm2rc.gz > $PKG/etc/X11/fvwm2/system.fvwm2rc.new
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/X11
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/X11 && rm -rf fvwm2 )
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/X11 && ln -sf ../../../etc/X11/fvwm2 fvwm2 )
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS COPYING INSTALL INSTALL.fvwm NEWS README \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+( cd docs
+ cp -a \
+ ANNOUNCE BUGS DEVELOPERS FAQ TODO color_combos error_codes fvwm.lsm m4_hacks \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+)
+
+mkdir -p $PKG/install
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/fvwm/fvwm.colormap.diff b/source/xap/fvwm/fvwm.colormap.diff
new file mode 100644
index 00000000..2d2eac94
--- /dev/null
+++ b/source/xap/fvwm/fvwm.colormap.diff
@@ -0,0 +1,20 @@
+--- ./fvwm/colormaps.c.orig Mon Sep 13 14:10:25 1999
++++ ./fvwm/colormaps.c Mon Sep 13 14:12:03 1999
+@@ -90,10 +90,13 @@
+ /* Reinstall the colormap that we think should be installed,
+ * UNLESS and unrecognized window has the focus - it might be
+ * an override-redirect window that has its own colormap. */
+- if((ReInstall)&&(Scr.UnknownWinFocused == None))
+- {
+- XInstallColormap(dpy,last_cmap);
+- }
++ /* Commented out, since although this behavior is an X standard, it breaks
++ * xlockmore and some other nifty programs, and having it this way doesn't
++ * cause any problems that I'm aware of. */
++ /* if((ReInstall)&&(Scr.UnknownWinFocused == None)) */
++ /* { */
++ /* XInstallColormap(dpy,last_cmap); */
++ /* } */
+ }
+
+ /************************************************************************
diff --git a/source/xap/fvwm/slack-desc b/source/xap/fvwm/slack-desc
new file mode 100644
index 00000000..77995d92
--- /dev/null
+++ b/source/xap/fvwm/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+fvwm: fvwm (a small and fast virtual window manager for X)
+fvwm:
+fvwm: Fvwm is the classic highly-configurable virtual window manager for
+fvwm: X11. It is a derivative of twm, redesigned to minimize memory
+fvwm: consumption, provide a 3-D look to window frames, and provide a simple
+fvwm: virtual desktop.
+fvwm:
+fvwm:
+fvwm:
+fvwm:
+fvwm:
diff --git a/source/xap/fvwm/system.fvwm2rc b/source/xap/fvwm/system.fvwm2rc
new file mode 100644
index 00000000..863643a4
--- /dev/null
+++ b/source/xap/fvwm/system.fvwm2rc
@@ -0,0 +1,822 @@
+#
+# Default system.fvwm2rc for Slackware Linux, adapted from the version
+# for fvwm95 (i.e. beware of non-functional commented-out options)
+#
+
+#========================================================================#
+
+#
+# Fonts - one for window titles, another for icons, and another for the menus
+#
+WindowFont -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
+IconFont fixed
+MenuStyle black grey76 grey30 -adobe-helvetica-medium-r-*-*-*-120-*-*-*-*-*-* fvwm
+
+#
+# Set the default window colors. The syntax is:
+# DefaultColors winforecolor winbackcolor titleforecolor titlebackcolor
+# where:
+# winbackcolor is the background (border) color of all windows,
+# including the menu windows
+# winforecolor is used for the menu text
+# titlebackcolor is the background color used for title bars of
+# non selected windows
+# titleforecolor is the color of the title text of non selected windows
+#
+#DefaultColors Black #c3c3c3 #c3c3c3 grey51
+
+#
+# Text and background color for the title bar of the active (selected) window
+#
+#HilightColors White #000080
+
+#
+# Text and background color for the title bar of sticky windows
+#
+#StickyColors grey51 #60c080
+
+# You can also use the Style command to set the colors of individual
+# title bars of some non-selected windows
+
+#Style "*" ForeColor #c3c3c3
+#Style "*" BackColor grey51
+
+#========================================================================#
+
+#
+# Set up the major operating modes
+#
+
+# Let's comment this out and be more UNIX-like :^)
+# Style "*" ClickToFocus
+# If we use the FvwmTaskBar we don't need the icons :-)
+# Style "..." Icon is also commented below.
+Style "*" NoIcon
+Style "*" MWMFunctions
+Style "*" HintOverride
+Style "*" MWMDecor
+
+OpaqueMoveSize 100
+EdgeScroll 100 100
+EdgeResistance 10000 0
+
+#
+# RandomPlacement prevents user interaction while placing windows:
+#
+Style "*" RandomPlacement
+
+#
+# NoPPosition instructs fvwm to ignore the PPosition field in window
+# geometry hints. Emacs annoyingly sets PPosition to (0,0)!
+#
+Style "*" NoPPosition
+
+#========================================================================#
+
+#
+# Set the desk top size in units of physical screen size
+#
+DeskTopSize 3x2
+
+#========================================================================#
+
+# Set the decoration styles and window options
+# Order is important!!!!
+# If compatible styles are set for a single window in multiple Style
+# commands, then the styles are ORed together. If conflicting styles
+# are set, the last one specified is used.
+
+# These commands should command before any menus or functions are defined,
+# and before the internal pager is started.
+
+#
+# Default border and handle widths
+#
+Style "*" BorderWidth 5, HandleWidth 5
+
+Style "Fvwm*" NoTitle, Sticky, WindowListSkip
+Style "Fvwm Pager" StaysOnTop, NoHandles
+Style "FvwmBanner" StaysOnTop
+Style "FvwmButtons" NoTitle, NoHandles, Sticky, WindowListSkip,BorderWidth 5
+Style "*lock" NoTitle, NoHandles, Sticky, WindowListSkip
+Style "xbiff" NoTitle, Sticky, WindowListSkip
+
+#
+# Some mini-icons for the title bar
+#
+#Style "*" TitleIcon mini-x2.xpm
+#Style "*xterm*" TitleIcon mini-term.xpm
+#Style "rxvt" TitleIcon mini-term.xpm
+#Style "xcalc" TitleIcon mini-calc.xpm
+#Style "xsession" TitleIcon mini-bx2.xpm
+#Style "xv" TitleIcon mini-xv.xpm
+#Style "SeaMonkey" TitleIcon mini-nscape.xpm
+#Style "xmag" TitleIcon mini-zoom.xpm
+#Style "textedit" TitleIcon mini-edit.xpm
+#Style "tkps" TitleIcon mini-run.xpm
+#Style "Ghostview" TitleIcon mini-gv.xpm
+#Style "Xcolorsel" TitleIcon mini-colors.xpm
+#Style "IDL*" TitleIcon mini-zoom.xpm
+#Style "xeyes" TitleIcon mini-eyes.xpm
+#Style "*fm*" TitleIcon mini-filemgr.xpm
+# xman resource names
+#Style "topBox" TitleIcon mini-book1.xpm
+#Style "help" TitleIcon mini-book2.xpm
+#Style "manualBrowser" TitleIcon mini-book2.xpm
+# xpaint resource names
+#Style "xpaint" TitleIcon mini-paint.xpm
+#Style "Canvas" TitleIcon mini-paint.xpm
+#Style "fatbits" TitleIcon mini-paint.xpm
+#Style "filebrowser" TitleIcon mini-paint.xpm
+
+#Style "rxvt" Icon term.xpm
+#Style "xterm" Icon xterm.xpm
+#Style "Appointment" Icon datebook.xpm
+#Style "xcalc" Icon rcalc.xpm
+#Style "xbiff" Icon mail1.xpm
+#Style "xmh" Icon mail1.xpm, StartsOnDesk 2
+#Style "xman" Icon xman.xpm
+#Style "xvgr" Icon graphs.xpm
+#Style "matlab" Icon math4.xpm
+#Style "xmag" Icon mag_glass.xpm
+#Style "xgraph" Icon graphs.xpm
+#Style "xv" Icon xview.xpm
+#Style "FvwmButtons" Icon toolbox.xpm
+#Style "xconsole" Icon koala.xpm
+#Style "xsession" Icon koala.xpm
+#Style "textedit" Icon textedit.xpm
+#Style "gv" Icon gv.xpm
+
+#========================================================================#
+
+#
+# Stuff to do at start-up
+#
+
+AddToFunc "InitFunction"
+#+ "I" Module FvwmButtons
++ "I" Module FvwmButtons MiniButtons
++ "I" Module FvwmPager 0 0
+
+AddToFunc "RestartFunction"
+#+ "I" Module FvwmButtons
++ "I" Module FvwmButtons MiniButtons
++ "I" Module FvwmPager 0 0
+
+#========================================================================#
+
+# Now define some handy complex functions
+
+#
+# This one moves and then raises the window if you drag the mouse,
+# only raises the window if you click, or does a full maximize if
+# you double click
+#
+AddToFunc "Move-or-Raise" "M" Move
++ "M" Raise
++ "C" Raise
++ "D" Maximize 100 100
+
+#
+# This one moves and then lowers the window if you drag the mouse,
+# only lowers the window if you click, or does a RaiseLower if you double
+# click
+#
+AddToFunc "Move-or-Lower" "M" Move
++ "M" Lower
++ "C" Lower
++ "D" RaiseLower
+
+#
+# This one moves or (de)iconifies:
+#
+AddToFunc "Move-or-Iconify" "M" Move
++ "D" Iconify
+
+#
+# This one resizes and then raises the window if you drag the mouse,
+# only raises the window if you click, or does a RaiseLower if you double
+# click
+#
+AddToFunc "Resize-or-Raise" "M" Resize
++ "M" Raise
++ "C" Raise
++ "D" RaiseLower
+
+
+#========================================================================#
+
+#
+# Now define the menus - defer bindings until later
+#
+
+# This is for the Start menu of the FvwmTaskBar
+
+DestroyMenu "StartMenu"
+AddToMenu "StartMenu"
++ "Manual Pages %mini-book1.xpm%" Exec xman &
++ "Magnifying Glass %mini-zoom.xpm%" Exec xmag &
++ "" Nop
++ "Accessories%mini-hammer.xpm%" Popup Accessories
++ "Applications %mini-x2.xpm%" Popup Applications
++ "File Managers %mini-filemgr.xpm%" Popup Filemanagers
++ "Games %mini-happy.xpm%" Popup Games
++ "Shells %mini-term.xpm" Popup Shells
++ "" Nop
++ "Lock Screen %mini-lock.xpm%" Popup Screenlock
++ "Screensaver %mini-display.xpm%" Popup Screensaver
++ "" Nop
++ "Refresh Screen %mini-ray.xpm%" Refresh
++ "" Nop
++ "Exit Fvwm2 %mini-stop.xpm%" Popup Quit-Verify
+
+DestroyMenu "Shells"
+AddToMenu "Shells"
++ "Xterm (7x14 font)%mini-term.xpm%" Exec xterm -sb -sl 500 -j -ls -fn 7x14 -fb 7x14bold &
++ "Large Xterm (10x20 font)%mini-term.xpm%" Exec xterm -sb -sl 500 -j -ls -fn 10x20 &
++ "" Nop
++ "Rxvt (7x14 font)%mini-term.xpm%" Exec rxvt -font 7x14 -ls &
++ "Large Rxvt (10x20 font)%mini-term.xpm%" Exec rxvt -font 10x20 -ls &
+
+DestroyMenu "Screensaver"
+AddToMenu "Screensaver"
++ "Blank%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode blank &
++ "Random%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode random &
++ "" Nop
++ "Ant%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode ant &
++ "Ball%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode ball &
++ "Bat%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bat &
++ "Blot%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode blot &
++ "Bomb%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bomb &
++ "Bouboule%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bouboule &
+#+ "Bob%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode image -bitmap /usr/include/X11/bitmaps/l-bob.xbm -batchcount 7 &
+#+ "Bounce%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bounce &
++ "\"Bob\"%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bounce &
++ "Braid%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode braid &
++ "Bug%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bug &
++ "Bubble%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode bubble &
++ "Clock%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode clock &
++ "Coral%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode coral &
++ "Crystal%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode crystal &
++ "Daisy%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode daisy &
++ "Dclock%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode dclock &
++ "Deco%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode deco &
++ "Demon%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode demon &
++ "Dilemma%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode dilemma &
++ "Drift%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode drift &
++ "More" PopUp ScreenSaver2
+
+DestroyMenu "Screensaver2"
+AddToMenu "Screensaver2"
++ "Eyes%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode eyes &
++ "Fadeplot%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode fadeplot &
++ "Flag%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode flag &
++ "Flame%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode flame &
++ "Forest%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode forest &
++ "Galaxy%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode galaxy &
++ "Geometry%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode geometry &
++ "Grav%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode grav &
++ "Helix%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode helix &
++ "Hop%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode hop &
++ "Hyper%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode hyper &
++ "Ico%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode ico &
++ "Ifs%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode ifs &
++ "Julia%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode julia &
++ "Kaleid%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode kaleid &
++ "Laser%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode laser &
++ "Life%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode life &
++ "Life1d%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode life1d &
++ "Life3d%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode life3d &
++ "Lightning%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode lightning &
++ "Lisa%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode lisa &
++ "Lissie%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode lissie &
++ "Loop%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode loop &
++ "More" PopUp ScreenSaver3
+
+DestroyMenu "Screensaver3"
+AddToMenu "Screensaver3"
++ "Mandelbrot%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode mandelbrot &
++ "Marquee%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode marquee &
++ "Maze%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode maze &
++ "Mountain%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode mountain &
++ "Munch%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode munch &
++ "Nose%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode nose &
++ "Pacman%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode pacman &
++ "Penguin%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode image -bitmap /usr/include/X11/bitmaps/l-linux.xbm -batchcount 7 &
++ "Penrose%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode penrose &
++ "Petal%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode petal &
++ "Puzzle%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode puzzle &
++ "Pyro%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode pyro &
++ "Qix%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode qix &
++ "Roll%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode roll &
++ "Rotor%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode rotor &
++ "Shape%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode shape &
++ "Sierpinski%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode sierpinski &
++ "Slip%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode slip &
++ "Sphere%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode sphere &
++ "Spiral%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode spiral &
++ "Spline%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode spline &
++ "Star%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode star &
++ "Strange%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode strange &
++ "More" PopUp ScreenSaver4
+
+DestroyMenu "Screensaver4"
+AddToMenu "Screensaver4"
++ "Swarm%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode swarm &
++ "Swirl%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode swirl &
++ "Triangle%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode triangle &
++ "Tube%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode tube &
++ "Turtle%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode turtle &
++ "Vines%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode vines &
++ "Voters%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode voters &
++ "Wator%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode wator &
++ "Wire%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode wire &
++ "World%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode world &
++ "Worm%mini-bball.xpm%" Exec xlock -nolock -nice 0 -mode worm &
+
+DestroyMenu "Screenlock"
+AddToMenu "Screenlock"
++ "Blank%mini-bball.xpm%" Exec xlock -nice 0 -mode blank &
++ "Random%mini-bball.xpm%" Exec xlock -nice 0 -mode random &
++ "" Nop
++ "Ant%mini-bball.xpm%" Exec xlock -nice 0 -mode ant &
++ "Ball%mini-bball.xpm%" Exec xlock -nice 0 -mode ball &
++ "Bat%mini-bball.xpm%" Exec xlock -nice 0 -mode bat &
++ "Blot%mini-bball.xpm%" Exec xlock -nice 0 -mode blot &
++ "Bomb%mini-bball.xpm%" Exec xlock -nice 0 -mode bomb &
++ "Bouboule%mini-bball.xpm%" Exec xlock -nice 0 -mode bouboule &
+#+ "Bob%mini-bball.xpm%" Exec xlock -nice 0 -mode image -bitmap /usr/include/X11/bitmaps/l-bob.xbm -batchcount 7 &
+#+ "Bounce%mini-bball.xpm%" Exec xlock -nice 0 -mode bounce &
++ "\"Bob\"%mini-bball.xpm%" Exec xlock -nice 0 -mode bounce &
++ "Braid%mini-bball.xpm%" Exec xlock -nice 0 -mode braid &
++ "Bug%mini-bball.xpm%" Exec xlock -nice 0 -mode bug &
++ "Bubble%mini-bball.xpm%" Exec xlock -nice 0 -mode bubble &
++ "Clock%mini-bball.xpm%" Exec xlock -nice 0 -mode clock &
++ "Coral%mini-bball.xpm%" Exec xlock -nice 0 -mode coral &
++ "Crystal%mini-bball.xpm%" Exec xlock -nice 0 -mode crystal &
++ "Daisy%mini-bball.xpm%" Exec xlock -nice 0 -mode daisy &
++ "Dclock%mini-bball.xpm%" Exec xlock -nice 0 -mode dclock &
++ "Deco%mini-bball.xpm%" Exec xlock -nice 0 -mode deco &
++ "Demon%mini-bball.xpm%" Exec xlock -nice 0 -mode demon &
++ "Dilemma%mini-bball.xpm%" Exec xlock -nice 0 -mode dilemma &
++ "Drift%mini-bball.xpm%" Exec xlock -nice 0 -mode drift &
++ "More" PopUp Screenlock2
+
+DestroyMenu "Screenlock2"
+AddToMenu "Screenlock2"
++ "Eyes%mini-bball.xpm%" Exec xlock -nice 0 -mode eyes &
++ "Fadeplot%mini-bball.xpm%" Exec xlock -nice 0 -mode fadeplot &
++ "Flag%mini-bball.xpm%" Exec xlock -nice 0 -mode flag &
++ "Flame%mini-bball.xpm%" Exec xlock -nice 0 -mode flame &
++ "Forest%mini-bball.xpm%" Exec xlock -nice 0 -mode forest &
++ "Galaxy%mini-bball.xpm%" Exec xlock -nice 0 -mode galaxy &
++ "Geometry%mini-bball.xpm%" Exec xlock -nice 0 -mode geometry &
++ "Grav%mini-bball.xpm%" Exec xlock -nice 0 -mode grav &
++ "Helix%mini-bball.xpm%" Exec xlock -nice 0 -mode helix &
++ "Hop%mini-bball.xpm%" Exec xlock -nice 0 -mode hop &
++ "Hyper%mini-bball.xpm%" Exec xlock -nice 0 -mode hyper &
++ "Ico%mini-bball.xpm%" Exec xlock -nice 0 -mode ico &
++ "Ifs%mini-bball.xpm%" Exec xlock -nice 0 -mode ifs &
++ "Julia%mini-bball.xpm%" Exec xlock -nice 0 -mode julia &
++ "Kaleid%mini-bball.xpm%" Exec xlock -nice 0 -mode kaleid &
++ "Laser%mini-bball.xpm%" Exec xlock -nice 0 -mode laser &
++ "Life%mini-bball.xpm%" Exec xlock -nice 0 -mode life &
++ "Life1d%mini-bball.xpm%" Exec xlock -nice 0 -mode life1d &
++ "Life3d%mini-bball.xpm%" Exec xlock -nice 0 -mode life3d &
++ "Lightning%mini-bball.xpm%" Exec xlock -nice 0 -mode lightning &
++ "Lisa%mini-bball.xpm%" Exec xlock -nice 0 -mode lisa &
++ "Lissie%mini-bball.xpm%" Exec xlock -nice 0 -mode lissie &
++ "Loop%mini-bball.xpm%" Exec xlock -nice 0 -mode loop &
++ "More" PopUp Screenlock3
+
+DestroyMenu "Screenlock3"
+AddToMenu "Screenlock3"
++ "Mandelbrot%mini-bball.xpm%" Exec xlock -nice 0 -mode mandelbrot &
++ "Marquee%mini-bball.xpm%" Exec xlock -nice 0 -mode marquee &
++ "Maze%mini-bball.xpm%" Exec xlock -nice 0 -mode maze &
++ "Mountain%mini-bball.xpm%" Exec xlock -nice 0 -mode mountain &
++ "Munch%mini-bball.xpm%" Exec xlock -nice 0 -mode munch &
++ "Nose%mini-bball.xpm%" Exec xlock -nice 0 -mode nose &
++ "Pacman%mini-bball.xpm%" Exec xlock -nice 0 -mode pacman &
++ "Penguin%mini-bball.xpm%" Exec xlock -nice 0 -mode image -bitmap /usr/include/X11/bitmaps/l-linux.xbm -batchcount 7 &
++ "Penrose%mini-bball.xpm%" Exec xlock -nice 0 -mode penrose &
++ "Petal%mini-bball.xpm%" Exec xlock -nice 0 -mode petal &
++ "Puzzle%mini-bball.xpm%" Exec xlock -nice 0 -mode puzzle &
++ "Pyro%mini-bball.xpm%" Exec xlock -nice 0 -mode pyro &
++ "Qix%mini-bball.xpm%" Exec xlock -nice 0 -mode qix &
++ "Roll%mini-bball.xpm%" Exec xlock -nice 0 -mode roll &
++ "Rotor%mini-bball.xpm%" Exec xlock -nice 0 -mode rotor &
++ "Shape%mini-bball.xpm%" Exec xlock -nice 0 -mode shape &
++ "Sierpinski%mini-bball.xpm%" Exec xlock -nice 0 -mode sierpinski &
++ "Slip%mini-bball.xpm%" Exec xlock -nice 0 -mode slip &
++ "Sphere%mini-bball.xpm%" Exec xlock -nice 0 -mode sphere &
++ "Spiral%mini-bball.xpm%" Exec xlock -nice 0 -mode spiral &
++ "Spline%mini-bball.xpm%" Exec xlock -nice 0 -mode spline &
++ "Star%mini-bball.xpm%" Exec xlock -nice 0 -mode star &
++ "Strange%mini-bball.xpm%" Exec xlock -nice 0 -mode strange &
++ "More" PopUp Screenlock4
+
+DestroyMenu "Screenlock4"
+AddToMenu "Screenlock4"
++ "Swarm%mini-bball.xpm%" Exec xlock -nice 0 -mode swarm &
++ "Swirl%mini-bball.xpm%" Exec xlock -nice 0 -mode swirl &
++ "Triangle%mini-bball.xpm%" Exec xlock -nice 0 -mode triangle &
++ "Tube%mini-bball.xpm%" Exec xlock -nice 0 -mode tube &
++ "Turtle%mini-bball.xpm%" Exec xlock -nice 0 -mode turtle &
++ "Vines%mini-bball.xpm%" Exec xlock -nice 0 -mode vines &
++ "Voters%mini-bball.xpm%" Exec xlock -nice 0 -mode voters &
++ "Wator%mini-bball.xpm%" Exec xlock -nice 0 -mode wator &
++ "Wire%mini-bball.xpm%" Exec xlock -nice 0 -mode wire &
++ "World%mini-bball.xpm%" Exec xlock -nice 0 -mode world &
++ "Worm%mini-bball.xpm%" Exec xlock -nice 0 -mode worm &
+
+DestroyMenu "Games"
+AddToMenu "Games"
++ "Maze%mini-maze.xpm%" Exec maze &
++ "Spider%mini-espada.xpm%" Exec spider &
++ "Chess%mini-slon.xpm%" Exec xboard &
++ "Xlander%mini-xlander.xpm%" Exec xlander &
+#+ "Xmahjongg%mini-xmahjongg.xpm%" Exec xmahjongg &
++ "Workman%mini-cdlabel.xpm%" Exec workman &
++ "" Nop
++ "Amusements" Popup Amusements
+
+DestroyMenu "Amusements"
+AddToMenu "Amusements"
+#+ "Xcat%mini-cat.xpm%" Exec xcat &
++ "Xeyes%mini-eyes.xpm%" Exec xeyes &
++ "Xlogo%mini-bx2.xpm%" Exec xlogo &
++ "Xroach%mini-roach.xpm%" Exec xroach &
++ "Xsnow%mini-xsnow.xpm%" Exec xsnow &
++ "Stop Xsnow%mini-stop.xpm%" Exec killall xsnow &
+
+DestroyMenu "Accessories"
+AddToMenu "Accessories"
++ "Font viewer (xfontsel)%mini-font.xpm%" Exec xfontsel &
++ "Manual pages%mini-book1.xpm%" Exec xman &
++ "Magnifying glass%mini-zoom.xpm%" Exec xmag &
++ "Oclock%mini-clock.xpm%" Exec oclock &
++ "Running Processes (Top)%mini-run.xpm%" Exec xterm -font 7x14 -T Top -n Top -e top &
++ "System load%mini-perf.xpm%" Exec xload &
++ "Xclipboard%mini-clipboard.xpm%" Exec xclipboard &
++ "Xclock%mini-clock.xpm%" Exec xclock &
+
+DestroyMenu "Applications"
+AddToMenu "Applications"
++ "Emacs%mini-edit.xpm%" Exec emacs &
++ "NcFTP%mini-ftp.xpm%" Exec xterm -name NcFtp -T FTP -ls -fn 7x14 -e ncftp &
++ "GIMP%mini-camera.xpm%" Exec gimp &
++ "Gv%mini-gv.xpm%" Exec gv &
++ "Gnuplot%mini-zoom.xpm%" Exec xterm -T "Gnuplot" -name Gnuplot -fn 7x14 -e gnuplot &
++ "SeaMonkey%mini-nscape.xpm%" Exec seamonkey &
++ "Pine%mini-mail.xpm%" Exec xterm -name Mail -T Mail -ls -fn 7x14 -e pine -i &
++ "Xv%mini-xv.xpm%" Exec xv &
++ "Xedit%mini-edit.xpm%" Exec xedit &
++ "Xfig%mini-xfig.xpm%" Exec xfig &
++ "Xfractint%mini-fractal.xpm%" Exec xterm -font 7x14 -e xfractint &
++ "Xpaint%mini-paint.xpm%" Exec xpaint &
++ "Xpdf%mini-pdf.xpm%" Exec xpdf &
++ "Xxgdb%mini-bug2.xpm%" Exec xxgdb &
+
+DestroyMenu "Filemanagers"
+AddToMenu "Filemanagers"
+#+ "TkDesk%mini-desktop.xpm%" Exec tkdesk &
++ "Xfm%mini-filemgr.xpm%" Exec xfm &
+
+#
+# This menu is invoked as a sub-menu - it allows you to quit,
+# restart, or switch to another WM.
+#
+DestroyMenu "Quit-Verify"
+AddToMenu "Quit-Verify"
++ "Quit fvwm2%mini-exclam.xpm%" Quit
++ "" Nop
++ "Restart Fvwm2%mini-turn.xpm%" Restart fvwm2
++ "" Nop
++ "Start fvwm95%mini-exp.xpm%" Restart fvwm95
++ "Start mwm%mini-mwm.xpm%" Restart mwm
++ "Start olvwm%mini-olwm.xpm%" Restart /usr/openwin/bin/olvwm
++ "Start olwm%mini-olwm.xpm%" Restart /usr/openwin/bin/olwm
++ "Start twm%mini-twm.xpm%" Restart twm
+
+#
+# Provides a list of modules to fire off
+#
+#DestroyMenu "Module-Popup"
+#AddToMenu "Module-Popup"
+##+ "Audio" Module FvwmAudio
+#+ "Banner%mini.fvwm.xpm%" Module FvwmBanner
+#+ "Button Bar%mini-ball.xpm%" Module FvwmButtons
+#+ "Button Bar (Mini)%mini-ball.xpm%" Module FvwmButtons MiniButtons
+##+ "Clean-Up%mini-pencil.xpm%" Module FvwmClean
+##+ "Configure%mini-hammer.xpm%" Module FvwmConfig
+#+ "Debug%mini-bug2.xpm%" Module FvwmDebug
+##+ "Task bar%mini-exp.xpm%" Module FvwmTaskBar
+#+ "Identify%mini-question.xpm%" Module FvwmIdent
+#+ "Save Desktop%mini-desktop.xpm%" Module FvwmSaveDesk
+#+ "Pager%mini-pager.xpm%" Module FvwmPager 0 0
+#+ "Window List%mini-windows.xpm%" Module FvwmWinList
+#+ "Talk%mini-exclam.xpm%" Module FvwmTalk
+
+AddToMenu Module-Popup "FvwmModules" Title
++ "Identify" Module FvwmIdent
++ "Talk" Module FvwmTalk
++ "" Nop
++ "Button-Bar" Module FvwmButtons
++ "Pager" Module FvwmPager 0 0
++ "Pager (2 desks)" Module FvwmPager 0 1
++ "WinList" Module FvwmWinList
++ "" Nop
++ "Banner" Module FvwmBanner
++ "ScrollBar" Module FvwmScroll 50 50
++ "Background" Module FvwmBacker
++ "AutoRaise" Module FvwmAuto 200 Raise Nop
++ "Stop AutoRaise" KillModule FvwmAuto
++ "" Nop
++ "IconBox" Module FvwmIconBox
++ "IconMan" Module FvwmIconMan
++ "" Nop
++ "Form - Rlogin" Module FvwmForm Rlogin
++ "Form - MyFvwmTalk" Module FvwmForm MyFvwmTalk
++ "Form - QuitVerify" Module FvwmForm QuitVerify
+
+#
+# This menu will fire up some very common utilities
+#
+DestroyMenu "Utilities"
+AddToMenu "Utilities"
++ "" Nop
++ "Xterm%mini-term.xpm%" Exec xterm -sb -sl 500 -j -ls -fn 7x14 -fb 7x14bold &
++ "Running Processes (Top)%mini-run.xpm%" Exec xterm -font 7x14 -T Top -n Top -e top &
++ "Calculator%mini-calc.xpm%" Exec xcalc &
++ "Manual pages%mini-book1.xpm%" Exec xman &
++ "Magnifying glass%mini-zoom.xpm%" Exec xmag &
++ "Oclock%mini-clock.xpm%" Exec oclock &
++ "" Nop
++ "Applications%mini-x2.xpm%" Popup Applications
++ "File Managers%mini-filemgr.xpm%" Popup Filemanagers
++ "Games%mini-happy.xpm%" Popup Games
++ "Shells%mini-term.xpm" Popup Shells
++ "" Nop
++ "Screensaver%mini-display.xpm%" Popup Screensaver
++ "Lock Screen%mini-lock.xpm%" Popup Screenlock
++ "" Nop
++ "Modules%mini-modules.xpm%" Popup Module-Popup
++ "" Nop
++ "Refresh Screen%mini-ray.xpm%" Refresh
++ "" Nop
++ "Exit Fvwm2%mini-stop.xpm%" Popup Quit-Verify
+
+#
+# This defines the most common window operations
+#
+DestroyMenu "Window Ops"
+AddToMenu "Window Ops" Title
++ "&Move%mini-move.xpm%" Function Move-or-Raise
++ "&Resize%mini-resize.xpm%" Function Resize-or-Raise
++ "R&aise%mini-raise.xpm%" Raise
++ "&Lower%mini-lower.xpm%" Lower
++ "(De)Iconify" Iconify
++ "(Un)Stick" Stick
++ "(Un)Maximize%mini-max1.xpm%" Function maximize_func
++ "" Nop
++ "Kill%mini-bomb.xpm%" Destroy
++ "&Close%mini-cross.xpm%" Delete
++ "" Nop
++ "Switch to..." WindowList
++ "Refresh Screen%mini-ray.xpm%" Refresh
+
+#
+# A trimmed down version of "Window Ops", good for binding to decorations
+#
+AddToMenu "Window-Ops2" "&Restore" Iconify -1
++ "&Move" Move-or-Raise
++ "&Size" Resize-or-Raise
++ "Mi&nimize" Iconify 1
++ "Ma&ximize" Maximize 100 100
++ "" Nop
++ "&Kill" Destroy
++ "&Close Alt+F4" Delete
+
+#========================================================================#
+
+#
+# One more complex function - couldn't be defined earlier because it used
+# pop-up menus
+#
+# This creates the "system" menu for the title-bar window-ops
+# pop-up
+#
+AddToFunc "window_ops_func" "C" PopUp Window-Ops2
++ "M" PopUp Window-Ops2
++ "D" Delete
+
+
+#========================================================================#
+
+#
+# Mouse bindings
+#
+
+# First, for the mouse in the root window
+# Button 1 gives the Utilities menu
+# Button 2 gives the Window Ops menu
+# Button 3 gives the WindowList (like TwmWindows)
+# I use the AnyModifier (A) option for the modifier field, so you can hold down
+# any shift-control-whatever combination you want!
+
+# Button Context Modifi Function
+Mouse 1 R A Menu "Utilities" Nop
+Mouse 2 R A Menu "Window Ops" Nop
+Mouse 3 R A WindowList
+#Mouse 3 R A Module "winlist" FvwmWinList transient
+
+# Now the title bar buttons
+# Any button in the left title-bar button gives the window ops menu
+# Any button in the first right title-bar button Iconifies the window
+# Any button in the second title-bar button full-maximizes
+# Note the use of "Mouse 0" for AnyButton.
+
+# Button Context Modif Function
+Mouse 0 1 A Function "window_ops_func"
+Mouse 0 2 A Maximize 100 100
+Mouse 0 4 A Iconify
+
+# Now the rest of the frame
+# Here I invoke my complex functions for Move-or-lower, Move-or-raise,
+# and Resize-or-Raise.
+#
+# Button 1 in the corner pieces, with any modifiers, gives resize or raise
+Mouse 1 F A Function "Resize-or-Raise"
+# Button 1 in the title, sides, or icon, w/ any modifiers, gives move or raise
+Mouse 1 TS A Function "Move-or-Raise"
+
+# Button 1 in an icons gives move for a drag, de-iconify for a double-click,
+# nothing for a single click
+# Button 2 in an icon, w/ any modifiers, gives de-iconify
+Mouse 1 I A Function "Move-or-Iconify"
+Mouse 2 I A Iconify
+
+# Button 2 in the corners, sides, or title-bar gives the window ops menu
+Mouse 2 FST A Function "window_ops_func"
+
+# Button 3 anywhere in the decoration (except the title-bar buttons)
+# does a raise-lower
+Mouse 3 TSIF A RaiseLower
+
+# Button 3 in the window, with the Modifier-1 key (usually alt or diamond)
+# gives Raise-Lower. Used to use control here, but that interferes with xterm
+Mouse 3 W M RaiseLower
+
+#========================================================================#
+
+# Now some keyboard shortcuts.
+
+# Arrow Keys
+# press arrow + control anywhere, and scroll by 1 page
+Key Left A C Scroll -100 0
+Key Right A C Scroll +100 +0
+Key Up A C Scroll +0 -100
+Key Down A C Scroll +0 +100
+
+# press arrow + meta key, and scroll by 1/10 of a page
+Key Left A M Scroll -10 +0
+Key Right A M Scroll +10 +0
+Key Up A M Scroll +0 -10
+Key Down A M Scroll +0 +10
+
+# press shift arrow + control anywhere, and move the pointer by 1% of a page
+Key Left A SC CursorMove -1 0
+Key Right A SC CursorMove +1 +0
+Key Up A SC CursorMove +0 -1
+Key Down A SC CursorMove +0 +1
+
+# press shift arrow + meta key, and move the pointer by 1/10 of a page
+Key Left A SM CursorMove -10 +0
+Key Right A SM CursorMove +10 +0
+Key Up A SM CursorMove +0 -10
+Key Down A SM CursorMove +0 +10
+
+# Keyboard accelerators
+Key F1 A M Popup "Utilities"
+Key F1 A M Popup "Utilities"
+Key F2 A M Popup "Window Ops"
+Key F3 A M Module "WindowList" FvwmWinList
+Key F4 A M Iconify
+Key F5 A M Move
+Key F6 A M Resize
+Key F7 A M CirculateUp
+Key F8 A M CirculateDown
+
+#Page Up/Dapge Down keys are used to scroll by one desktop page
+# in any context, press page up/down + control
+# in root context, just pressing page up/down is OK
+#
+# I prefer the non-wrapping scroll. These are for example purposes only
+#Key Next A C Scroll 100000 0
+#Key Next R N Scroll 100000 0
+#Key Prior A C Scroll -100000 0
+#Key Prior R N Scroll -100000 0
+
+Key Tab A M Prev Focus
+Key Tab A MS Next Focus
+
+Key Escape A C WindowList
+
+#========================================================================#
+
+# Definitions used by the modules
+
+#------------------ Pager
+*FvwmPagerBack grey60
+*FvwmPagerFore black
+*FvwmPagerFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
+*FvwmPagerHilight #c3c3c3
+*FvwmPagerGeometry -3-27
+*FvwmPagerLabel 0 Desktop
+*FvwmPagerSmallFont 5x8
+
+#------------------ FvwmButtons
+*FvwmButtonsFore Black
+*FvwmButtonsBack #c3c3c3
+*FvwmButtonsFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
+# Geometry - really likes to pick its own size, but giving a position is OK
+*FvwmButtonsGeometry -5-5
+# Layout: specify rows or columns, not both
+*FvwmButtonsRows 1
+
+# Define the buttons to use.....
+*FvwmButtons xclock clock.xpm Swallow "xclock" Exec xclock -bg \#c3c3c3 -geometry -1500-1500 -padding 0 &
+#*GoodStuff xcmap NULL Swallow "xcmap" xcmap -geometry -1500-1500
+*FvwmButtons (2x1) load NULL Swallow "xload" Exec nice -16 xload -nolabel -bg grey60 -update 5 -geometry -1500-1500
+*FvwmButtons SeaMonkey nscape.xpm Exec "SeaMonkey" seamonkey &
+*FvwmButtons xterm rterm.xpm Exec "xterm" xterm -ls -sb -fn 7x14 &
+*FvwmButtons xfm Xfm.xpm Exec "Xfm" xfm &
+#*FvwmButtons textedit textedit.xpm Exec "Textedit" textedit &
+*FvwmButtons xcalc rcalc.xpm Exec "Calculator" xcalc &
+*FvwmButtons xv xv.xpm Exec "xv" xv &
+#*FvwmButtons gv gv.xpm Exec "gv" gv &
+#*FvwmButtons seamonkey nscape.xpm Exec "SeaMonkey" seamonkey -geometry 920x650+90+5
+*FvwmButtons kill rbomb.xpm Destroy
+#*FvwmButtons (2x1) - whatever SwallowModule Exec "Desktop" FvwmPager 0 0
+*FvwmButtons (2x1, Swallow(UseOld) "Desktop" 'FvwmPager 0 0')
+
+#------------------ MiniButtons
+
+Style "MiniButtons" NoTitle,NoHandles,Sticky,StaysOnTop,WindowListSkip,BorderWidth 0
+
+*MiniButtonsFore Black
+*MiniButtonsBack #c0c0c0
+*MiniButtonsFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
+*MiniButtonsGeometry -5-5
+*MiniButtonsRows 1
+*MiniButtonsPadding 1 1
+
+*MiniButtons - mini-nscape.xpm Exec "SeaMonkey" seamonkey -geometry 790x543+0+0 &
+*MiniButtons - mini-term.xpm Exec "XTerm" xterm -ls -sb -fn 7x14 &
+*MiniButtons - mini-filemgr.xpm Exec "Xfm" xfm &
+*MiniButtons - mini-calc.xpm Exec "Calculator" xcalc &
+#*MiniButtons - mini-gv.xpm Exec "gv" gv &
+*MiniButtons - mini-xv.xpm Exec "xv" xv &
+*MiniButtons - mini-bomb.xpm Destroy
+
+#------------------ Identify
+*FvwmIdentBack #000080
+*FvwmIdentFore Yellow
+*FvwmIdentFont -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
+
+#------------------ FvwmWinList
+*FvwmWinListBack #c3c3c3
+*FvwmWinListFore Black
+*FvwmWinListFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
+*FvwmWinListAction Click1 Iconify -1,Focus
+*FvwmWinListAction Click2 Iconify
+*FvwmWinListAction Click3 Module "FvwmIdent" FvwmIdent
+*FvwmWinListUseSkipList
+*FvwmWinListGeometry +0-1
+
+#------------------ FvwmTaskBar
+#Style "FvwmTaskBar" NoTitle,BorderWidth 4,HandleWidth 4,Sticky,StaysOnTop,WindowListSkip,CirculateSkip
+# I don't like the taskbar to stay to top, since it covers the bottom
+# part of SeaMonkey in full-screen mode:
+#Style "FvwmTaskBar" NoTitle,BorderWidth 4,HandleWidth 4,Sticky,WindowListSkip,CirculateSkip
+
+*FvwmTaskBarGeometry +0-0
+*FvwmTaskBarFore Black
+*FvwmTaskBarBack #c3c3c3
+*FvwmTaskBarTipsFore black
+*FvwmTaskBarTipsBack bisque
+*FvwmTaskBarFont -adobe-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*
+*FvwmTaskBarSelFont -adobe-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*
+*FvwmTaskBarAction Click1 Iconify -1,Raise,Focus
+*FvwmTaskBarAction Click2 Iconify
+*FvwmTaskBarAction Click3 Module "FvwmIdent" FvwmIdent
+*FvwmTaskBarUseSkipList
+*FvwmTaskBarAutoStick
+*FvwmTaskBarStartName Start
+*FvwmTaskBarStartMenu StartMenu
+# Just for fun, let's use the Linux penguin for the Start button:
+*FvwmTaskBarStartIcon mini-penguin.xpm
+#*FvwmTaskBarStartIcon mini-exp.xpm
+*FvwmTaskBarShowTips
+*FvwmTaskBarMailProg xterm -e mail
diff --git a/source/xap/fvwm/xinitrc.fvwm2 b/source/xap/fvwm/xinitrc.fvwm2
new file mode 100644
index 00000000..955629fc
--- /dev/null
+++ b/source/xap/fvwm/xinitrc.fvwm2
@@ -0,0 +1,30 @@
+#!/bin/sh
+# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
+
+userresources=$HOME/.Xresources
+usermodmap=$HOME/.Xmodmap
+sysresources=/etc/X11/xinit/.Xresources
+sysmodmap=/etc/X11/xinit/.Xmodmap
+
+# merge in defaults and keymaps
+
+if [ -f $sysresources ]; then
+ xrdb -merge $sysresources
+fi
+
+if [ -f $sysmodmap ]; then
+ xmodmap $sysmodmap
+fi
+
+if [ -f $userresources ]; then
+ xrdb -merge $userresources
+fi
+
+if [ -f $usermodmap ]; then
+ xmodmap $usermodmap
+fi
+
+# start some nice programs
+
+xsetroot -solid SteelBlue
+fvwm2
diff --git a/source/xap/gftp/gftp.SlackBuild b/source/xap/gftp/gftp.SlackBuild
new file mode 100755
index 00000000..ba93205e
--- /dev/null
+++ b/source/xap/gftp/gftp.SlackBuild
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=2.0.19
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gftp
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf gftp-$VERSION
+tar xvf $CWD/gftp-$VERSION.tar.bz2 || exit 1
+cd gftp-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var/lib \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/gftp-$VERSION \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Put symlinks to the themable icons in place
+mkdir -p $PKG/usr/share/icons/hicolor/{scalable,16x16,22x22,24x24,32x32,48x48}/apps
+ln -s /usr/share/gftp/gftp-scalable.svg \
+ $PKG/usr/share/icons/hicolor/scalable/apps/gftp.svg
+for i in 16x16 22x22 24x24 32x32 48x48 ; do
+ ln -s /usr/share/gftp/gftp-${i}.png \
+ $PKG/usr/share/icons/hicolor/${i}/apps/gftp.png
+done
+
+mkdir -p $PKG/usr/doc/gftp-$VERSION
+cp -a \
+ AUTHORS COPYING NEWS README README.html THANKS TODO docs/USERS-GUIDE \
+ $PKG/usr/doc/gftp-$VERSION
+
+( cd $PKG/usr/man
+ find . -type f -exec gzip -9 {} \;
+ for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
+)
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gftp-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gftp/gftp.desktop b/source/xap/gftp/gftp.desktop
new file mode 100644
index 00000000..0beaf5bc
--- /dev/null
+++ b/source/xap/gftp/gftp.desktop
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=gFTP
+Comment=Download and upload files using multiple file transfer protocols
+Comment[fr]=Télécharge des fichiers en utilisant le protocole FTP
+GenericName=gFTP
+Exec=gftp %u
+Terminal=false
+X-MultipleArgs=false
+Type=Application
+Icon=gftp
+Categories=Network;
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gftp
+X-GNOME-Bugzilla-Component=general
+X-GNOME-Bugzilla-Version=2.0.19
diff --git a/source/xap/gftp/slack-desc b/source/xap/gftp/slack-desc
new file mode 100644
index 00000000..693fb4d2
--- /dev/null
+++ b/source/xap/gftp/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gftp: gftp (FTP client for X)
+gftp:
+gftp: gFTP is a multithreaded FTP client for X written using GTK+. It
+gftp: features simultaneous downloads, resuming of interrupted file
+gftp: transfers, file transfer queues, downloading of entire directories,
+gftp: ftp proxy support, remote directory caching, passive and non-passive
+gftp: file transfers, drag-n-drop support, bookmarks menu, stop button,
+gftp: and many more features.
+gftp:
+gftp:
+gftp:
diff --git a/source/xap/gimp/gimp.SlackBuild b/source/xap/gimp/gimp.SlackBuild
new file mode 100755
index 00000000..ef001a68
--- /dev/null
+++ b/source/xap/gimp/gimp.SlackBuild
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=2.6.6
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gimp
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+cd $TMP
+rm -rf gimp-$VERSION
+tar xvf $CWD/gimp-$VERSION.tar.bz2 || exit 1
+cd gimp-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --localstatedir=/var/lib \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ --docdir=/usr/doc/gimp-$VERSION \
+ --disable-static \
+ --enable-gimp-remote \
+ --without-gvfs \
+ --with-libcurl \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+mkdir -p $PKG/usr/share/applications $PKG/usr/share/application-registry
+make install DESTDIR=$PKG || exit 1
+
+# Add a manpage symlink for POLA-compliance
+( cd $PKG/usr/man/man1 ; ln -sf gimptool-2.?.1 gimptool.1 )
+
+( cd $PKG/usr/man
+ find . -type f -exec gzip -9 {} \;
+ for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
+)
+
+mkdir -p $PKG/usr/doc/gimp-$VERSION
+cp -a \
+ AUTHORS COPYING HACKING INSTALL LICENSE NEWS README* docs/Wilber* \
+ $PKG/usr/doc/gimp-$VERSION
+( cd $PKG/usr/doc/gimp-$VERSION
+ for i in \
+ libgimp libgimpbase libgimpcolor libgimpconfig libgimpmath \
+ libgimpmodule libgimpthumb libgimpwidgets ; do \
+ ln -s /usr/share/gtk-doc/html/$i $i-html ;
+ done
+)
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gimp-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gimp/slack-desc b/source/xap/gimp/slack-desc
new file mode 100644
index 00000000..9f9aca38
--- /dev/null
+++ b/source/xap/gimp/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gimp: gimp (The GNU Image Manipulation Program)
+gimp:
+gimp: The GIMP is a powerful tool for the preparation and manipulation of
+gimp: digital images. The GIMP provides the user with a wide variety of
+gimp: image manipulation, painting, processing, and rendering tools. The
+gimp: GIMP's open design and extensible architecture make for a very
+gimp: powerful end product for photo and image retouching, web graphics
+gimp: design, or digital illustration.
+gimp:
+gimp:
+gimp:
diff --git a/source/xap/gkrellm/gkrellm.SlackBuild b/source/xap/gkrellm/gkrellm.SlackBuild
new file mode 100755
index 00000000..222f2567
--- /dev/null
+++ b/source/xap/gkrellm/gkrellm.SlackBuild
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=2.3.2
+PKGVER=2.3.2
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+if [ "$ARCH" = "x86_64" ]; then
+ LIBDIRSUFFIX="64"
+else
+ LIBDIRSUFFIX=""
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gkrellm
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf gkrellm-$VERSION
+tar xvf $CWD/gkrellm-$VERSION.tar.bz2 || exit 1
+cd gkrellm-$VERSION || exit 1
+# Fix library paths (works for all ARCHs):
+sed -i -e "s#lib/gkrellm2#lib${LIBDIRSUFFIX}/gkrellm2#g" $(grep -lr 'lib/gkrellm2' *)
+# Increase the default width slightly, and don't use the text
+# shadow effect by default (this seems better with Pango font
+# rendering):
+zcat $CWD/gkrellm.theme.defaults.diff.gz | patch -p1 --verbose || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+make \
+ INSTALLROOT=/usr \
+ INSTALLDIR=/usr/bin \
+ INCLUDEDIR=/usr/include \
+ MANDIR=/usr/man/man1 \
+ LOCALEDIR=/usr/share/locale \
+ PKGCONFIGDIR=/usr/lib${LIBDIRSUFFIX}/pkgconfig
+
+# We will need this installed to build plugins, so...
+make install
+
+# Install to the $PKG dir:
+make install \
+ INSTALLROOT=$PKG/usr \
+ INSTALLDIR=$PKG/usr/bin \
+ INCLUDEDIR=$PKG/usr/include \
+ MANDIR=$PKG/usr/man/man1 \
+ LOCALEDIR=$PKG/usr/share/locale \
+ PKGCONFIGDIR=$PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig
+
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/gkrellm2/plugins
+
+mkdir -p $PKG/usr/doc/gkrellm-$VERSION
+cp -a \
+ COPYRIGHT CREDITS INSTALL README Themes.html \
+ $PKG/usr/doc/gkrellm-$VERSION
+
+gzip -9 $PKG/usr/man/man?/*.?
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# Add optional plugin(s):
+# The countdown plugin is needed to track X-Day. ;-)
+COUNTDOWN=0.1.1
+cd $TMP
+rm -rf gkrellm-countdown
+tar xf $CWD/gkrellm-countdown-$COUNTDOWN.tar.gz || exit 1
+cd gkrellm-countdown || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+make
+cp gkrellm-countdown.so $PKG/usr/lib${LIBDIRSUFFIX}/gkrellm2/plugins
+
+mkdir -p $PKG/usr/doc/gkrellm-countdown-$COUNTDOWN
+cp -a \
+ COPYING ChangeLog README \
+ $PKG/usr/doc/gkrellm-countdown-$COUNTDOWN
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gkrellm-$PKGVER-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gkrellm/gkrellm.theme.defaults.diff b/source/xap/gkrellm/gkrellm.theme.defaults.diff
new file mode 100644
index 00000000..aff6a9fb
--- /dev/null
+++ b/source/xap/gkrellm/gkrellm.theme.defaults.diff
@@ -0,0 +1,11 @@
+--- ./src/config.c.orig 2008-10-03 19:33:37.000000000 -0500
++++ ./src/config.c 2008-10-25 20:33:56.000000000 -0500
+@@ -1883,7 +1883,7 @@
+
+ _GK.chart_height_min = 5;
+ _GK.chart_height_max = 200;
+- _GK.chart_width_ref = 60;
++ _GK.chart_width_ref = 75;
+ _GK.chart_text_no_fill = FALSE;
+ _GK.bg_separator_height = 2;
+ _GK.allow_scaling = FALSE;
diff --git a/source/xap/gkrellm/slack-desc b/source/xap/gkrellm/slack-desc
new file mode 100644
index 00000000..3540eb6a
--- /dev/null
+++ b/source/xap/gkrellm/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gkrellm: gkrellm (GNU Krell Monitors)
+gkrellm:
+gkrellm: GKrellM charts SMP CPU, load, Disk, and all active net interfaces
+gkrellm: automatically. An on/off button and online timer for the PPP interface
+gkrellm: is provided. Monitors for memory and swap usage, file system, internet
+gkrellm: connections, APM laptop battery, mbox style mailboxes, and cpu temps.
+gkrellm: Also includes an uptime monitor, hostname label, and clock/calendar.
+gkrellm:
+gkrellm: Bill Wilson is the author of GKrellM.
+gkrellm:
+gkrellm:
diff --git a/source/xap/gnuchess/chess.png b/source/xap/gnuchess/chess.png
new file mode 100644
index 00000000..6e4a1bff
--- /dev/null
+++ b/source/xap/gnuchess/chess.png
Binary files differ
diff --git a/source/xap/gnuchess/eboard.desktop b/source/xap/gnuchess/eboard.desktop
new file mode 100644
index 00000000..f467664a
--- /dev/null
+++ b/source/xap/gnuchess/eboard.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=eboard
+GenericName=Chess Game
+Comment=A graphical chess engine frontend
+Exec=eboard
+Icon=/usr/share/pixmaps/chess.png
+Terminal=false
+Type=Application
+Categories=Application;Game;BoardGame
diff --git a/source/xap/gnuchess/gnuchess.SlackBuild b/source/xap/gnuchess/gnuchess.SlackBuild
new file mode 100755
index 00000000..2b236ae4
--- /dev/null
+++ b/source/xap/gnuchess/gnuchess.SlackBuild
@@ -0,0 +1,176 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERGNUCHESS=5.07
+VERSJENG=11.2
+VEREBOARD=1.0.3
+VERXBOARD=4.2.7
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-4}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=/tmp/package-gnuchess
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+### gnuchess
+cd $TMP
+rm -rf gnuchess-$VERGNUCHESS
+tar xvf $CWD/gnuchess-$VERGNUCHESS.tar.bz2 || exit 1
+cd gnuchess-$VERGNUCHESS || exit 1
+# make gnuchess compile with gcc4
+zcat $CWD/gnuchess.gcc4_fix.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ $ARCH-slackware-linux
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/doc/gnuchess-$VERGNUCHESS
+cp -a \
+ doc/README \
+ AUTHORS COPYING INSTALL NEWS TODO \
+ $PKG/usr/doc/gnuchess-$VERGNUCHESS
+
+### Sjeng
+cd $TMP
+rm -rf Sjeng-Free-$VERSJENG
+tar xvf $CWD/Sjeng-Free-$VERSJENG.tar.bz2 || exit 1
+cd Sjeng-Free-$VERSJENG || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ $ARCH-slackware-linux
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/doc/Sjeng-Free-$VERSJENG
+cp -a \
+ AUTHORS BUGS COPYING NEWS README THANKS TODO \
+ $PKG/usr/doc/Sjeng-Free-$VERSJENG
+
+### eboard
+cd $TMP
+rm -rf eboard-$VEREBOARD
+tar xvf $CWD/eboard-$VEREBOARD.tar.bz2 || exit 1
+cd eboard-$VEREBOARD || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+./configure \
+ --prefix=/usr \
+ --extra-flags=$(echo $SLKCFLAGS | sed -e "y/ /:/")
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/doc/eboard-$VEREBOARD
+cp -a \
+ AUTHORS COPYING README TODO Documentation/*.txt \
+ $PKG/usr/doc/eboard-$VEREBOARD
+
+### XBoard
+cd $TMP
+rm -rf xboard-$VERXBOARD
+tar xvf $CWD/xboard-$VERXBOARD.tar.bz2 || exit 1
+cd xboard-$VERXBOARD || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# --infodir is fubar.
+zcat $CWD/xboard.infodir.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+# Taken from Debian to fix CVE-2004-2552
+# FOR WHICH THERE IS NO ATTACK VECTOR!!!
+zcat $CWD/xboard.buffer_overflow_fix.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --infodir=/usr/info \
+ --enable-zippy \
+ --build=$ARCH-slackware-linux
+make $NUMJOBS || make || exit 1
+install -c -s xboard $PKG/usr/bin/xboard
+install -c -s zic2xpm $PKG/usr/bin/zic2xpm
+install -c cmail $PKG/usr/bin/cmail
+install -c ./pxboard $PKG/usr/bin/pxboard
+install -c -m 644 ./xboard.man $PKG/usr/man/man6/xboard.6
+install -c -m 644 ./zic2xpm.man $PKG/usr/man/man6/zic2xpm.6
+mkdir -p $PKG/usr/info
+install -c -m 644 xboard.info $PKG/usr/info/xboard.info
+mkdir -p $PKG/usr/doc/xboard-$VERXBOARD
+cp -a \
+ AUTHORS COPYING COPYRIGHT FAQ FAQ.html NEWS READ_ME \
+ $PKG/usr/doc/xboard-$VERXBOARD
+
+### Finish up...
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+gzip -9 $PKG/usr/man/man?/*.?
+gzip -9 $PKG/usr/info/*.info
+mkdir -p $PKG/usr/share/pixmaps
+cat $CWD/chess.png > $PKG/usr/share/pixmaps/chess.png
+mkdir -p $PKG/usr/share/applications
+cat $CWD/eboard.desktop > $PKG/usr/share/applications/eboard.desktop
+cat $CWD/xboard.desktop > $PKG/usr/share/applications/xboard.desktop
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gnuchess-$VERGNUCHESS-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gnuchess/gnuchess.SlackBuild.diff b/source/xap/gnuchess/gnuchess.SlackBuild.diff
new file mode 100644
index 00000000..0112a9d2
--- /dev/null
+++ b/source/xap/gnuchess/gnuchess.SlackBuild.diff
@@ -0,0 +1,89 @@
+--- gnuchess.SlackBuild 2006-04-04 03:47:10.000000000 +0300
++++ gnuchess.SlackBuild 2007-05-08 17:06:11.000000000 +0300
+@@ -4,10 +4,10 @@
+
+ VERGNUCHESS=5.07
+ VERSJENG=11.2
+-VEREBOARD=0.9.5
++VEREBOARD=1.0.3
+ VERXBOARD=4.2.7
+ ARCH=${ARCH:-i486}
+-BUILD=${BUILD:-2}
++BUILD=${BUILD:-3}
+
+ if [ "$ARCH" = "i386" ]; then
+ SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
+@@ -27,6 +27,8 @@
+ rm -rf gnuchess-$VERGNUCHESS
+ tar xjvf $CWD/gnuchess-$VERGNUCHESS.tar.bz2
+ cd gnuchess-$VERGNUCHESS
++# make gnuchess compile with gcc4
++zcat $CWD/gnuchess.gcc4_fix.diff.gz | patch -p1 --verbose --backup --suffix=.orig
+ chown -R root:root .
+ find . -perm 664 -exec chmod 644 {} \;
+ find . -perm 600 -exec chmod 644 {} \;
+@@ -93,33 +95,13 @@
+ find . -perm 511 -exec chmod 755 {} \;
+ find . -perm 711 -exec chmod 755 {} \;
+ find . -perm 555 -exec chmod 755 {} \;
+-CFLAGS="$SLKCFLAGS" \
+ ./configure \
+- --prefix=/usr
++ --prefix=/usr --extra-flags=`echo $SLKCFLAGS | sed -e "y/ /:/"`
+ make -j3
+-#make install DESTDIR=$PKG
+-install -d $PKG/usr/bin
+-install -m 0755 eboard $PKG/usr/bin/eboard
+-install -m 0755 eboard-config $PKG/usr/bin/eboard-config
+-install -m 0755 eboard-addtheme $PKG/usr/bin/eboard-addtheme
+-install -d $PKG/usr/man/man1
+-install -d $PKG/usr/man/man6
+-install -m 0644 eboard.6 $PKG/usr/man/man6
+-install -m 0644 eboard-addtheme.1 $PKG/usr/man/man1
+-install -m 0644 eboard-config.1 $PKG/usr/man/man1
+-install -d $PKG/usr/share/eboard
+-install -m 0644 classic.png $PKG/usr/share/eboard/classic.png
+-install -m 0644 ghouls.png $PKG/usr/share/eboard/ghouls.png
+-install -m 0644 plastic.png $PKG/usr/share/eboard/plastic.png
+-install -m 0644 eboard_themes.conf $PKG/usr/share/eboard/eboard_themes.conf
+-install -m 0644 NAG.en.txt $PKG/usr/share/eboard/NAG.en.txt
+-( cd multilang
+- install -d $PKG/usr/share/eboard
+- install -m 0644 eboard.cs.dict eboard.de.dict eboard.es.dict eboard.it.dict eboard.pt_BR.dict $PKG/usr/share/eboard
+-)
++make install DESTDIR=$PKG
+ mkdir -p $PKG/usr/doc/eboard-$VEREBOARD
+ cp -a \
+- AUTHORS COPYING README TODO \
++ AUTHORS COPYING README TODO Documentation/*.txt \
+ $PKG/usr/doc/eboard-$VEREBOARD
+
+ ### XBoard
+@@ -140,6 +122,8 @@
+ find . -perm 555 -exec chmod 755 {} \;
+ # --infodir is fubar.
+ zcat $CWD/xboard.infodir.diff.gz | patch -p1 --verbose --backup --suffix=.orig
++# Taken from Debian to fix CVE-2004-2552
++zcat $CWD/xboard.buffer_overflow_fix.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+ CFLAGS="$SLKCFLAGS" \
+ ./configure \
+ --prefix=/usr \
+@@ -153,6 +137,7 @@
+ install -c ./pxboard $PKG/usr/bin/pxboard
+ install -c -m 644 ./xboard.man $PKG/usr/man/man6/xboard.6
+ install -c -m 644 ./zic2xpm.man $PKG/usr/man/man6/zic2xpm.6
++mkdir -p $PKG/usr/info
+ install -c -m 644 xboard.info $PKG/usr/info/xboard.info
+ mkdir -p $PKG/usr/doc/xboard-$VERXBOARD
+ cp -a \
+@@ -165,8 +150,9 @@
+ find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+ )
+ gzip -9 $PKG/usr/man/man?/*.?
++gzip -9 $PKG/usr/info/*.info
+ mkdir -p $PKG/usr/share/pixmaps
+-cat $CWD/chess.png > $PKG/usr/share/pixmaps/chess.png
++cp $CWD/chess.png $PKG/usr/share/pixmaps/chess.png
+ mkdir -p $PKG/usr/share/applications
+ cat $CWD/eboard.desktop > $PKG/usr/share/applications/eboard.desktop
+ cat $CWD/xboard.desktop > $PKG/usr/share/applications/xboard.desktop
diff --git a/source/xap/gnuchess/gnuchess.gcc4_fix.diff b/source/xap/gnuchess/gnuchess.gcc4_fix.diff
new file mode 100644
index 00000000..a6835194
--- /dev/null
+++ b/source/xap/gnuchess/gnuchess.gcc4_fix.diff
@@ -0,0 +1,11 @@
+--- gnuchess-5.07/src/input.c 2007-05-08 15:55:16.688003280 +0300
++++ gnuchess-5.07/src/input.c 2007-05-08 15:55:29.238088685 +0300
+@@ -92,7 +92,7 @@
+ fgets(inputstr, MAXSTR, stdin);
+ }
+
+-static pthread_t input_thread;
++pthread_t input_thread;
+
+ /* Mutex and condition variable for thread communication */
+
diff --git a/source/xap/gnuchess/slack-desc b/source/xap/gnuchess/slack-desc
new file mode 100644
index 00000000..96776653
--- /dev/null
+++ b/source/xap/gnuchess/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gnuchess: gnuchess (GPL licensed chess engines and graphical frontends)
+gnuchess:
+gnuchess: This is a package of programs for playing chess. It includes the
+gnuchess: gnuchess and Sjeng chess engines, and the eboard and XBoard
+gnuchess: graphical interfaces to these engines.
+gnuchess:
+gnuchess:
+gnuchess:
+gnuchess:
+gnuchess:
+gnuchess:
diff --git a/source/xap/gnuchess/xboard.buffer_overflow_fix.diff b/source/xap/gnuchess/xboard.buffer_overflow_fix.diff
new file mode 100644
index 00000000..f36d36ba
--- /dev/null
+++ b/source/xap/gnuchess/xboard.buffer_overflow_fix.diff
@@ -0,0 +1,95 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 09_fix_-icshost_buffer_overflow.dpatch by Florian Ernst <florian@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Of minor importance, though, as there is probably no attack vector
+## DP: See bug#343560
+
+@DPATCH@
+diff -urNad xboard-4.2.7~/backend.c xboard-4.2.7/backend.c
+--- xboard-4.2.7~/backend.c 2003-11-28 10:37:36.000000000 +0100
++++ xboard-4.2.7/backend.c 2005-12-16 22:19:16.000000000 +0100
+@@ -692,7 +692,7 @@
+ sprintf(buf, "Could not open comm port %s",
+ appData.icsCommPort);
+ } else {
+- sprintf(buf, "Could not connect to host %s, port %s",
++ snprintf(buf, sizeof(buf), "Could not connect to host %s, port %s",
+ appData.icsHost, appData.icsPort);
+ }
+ DisplayFatalError(buf, err, 1);
+@@ -869,18 +869,18 @@
+ } else if (*appData.gateway != NULLCHAR) {
+ if (*appData.remoteShell == NULLCHAR) {
+ /* Use the rcmd protocol to run telnet program on a gateway host */
+- sprintf(buf, "%s %s %s",
++ snprintf(buf, sizeof(buf), "%s %s %s",
+ appData.telnetProgram, appData.icsHost, appData.icsPort);
+ return OpenRcmd(appData.gateway, appData.remoteUser, buf, &icsPR);
+
+ } else {
+ /* Use the rsh program to run telnet program on a gateway host */
+ if (*appData.remoteUser == NULLCHAR) {
+- sprintf(buf, "%s %s %s %s %s", appData.remoteShell,
++ snprintf(buf, sizeof(buf), "%s %s %s %s %s", appData.remoteShell,
+ appData.gateway, appData.telnetProgram,
+ appData.icsHost, appData.icsPort);
+ } else {
+- sprintf(buf, "%s %s -l %s %s %s %s",
++ snprintf(buf, sizeof(buf), "%s %s -l %s %s %s %s",
+ appData.remoteShell, appData.gateway,
+ appData.remoteUser, appData.telnetProgram,
+ appData.icsHost, appData.icsPort);
+@@ -1684,7 +1684,7 @@
+
+ if (loggedOn && !have_set_title && ics_handle[0] != NULLCHAR) {
+ char buf[MSG_SIZ];
+- sprintf(buf, "%s@%s", ics_handle, appData.icsHost);
++ snprintf(buf, sizeof(buf), "%s@%s", ics_handle, appData.icsHost);
+ DisplayIcsInteractionTitle(buf);
+ have_set_title = TRUE;
+ }
+@@ -4882,7 +4882,7 @@
+ SendToProgram(buf, cps);
+ }
+ if (cps->sendICS) {
+- sprintf(buf, "ics %s\n", appData.icsActive ? appData.icsHost : "-");
++ snprintf(buf, sizeof(buf), "ics %s\n", appData.icsActive ? appData.icsHost : "-");
+ SendToProgram(buf, cps);
+ }
+ cps->maybeThinking = FALSE;
+diff -urNad xboard-4.2.7~/xboard.c xboard-4.2.7/xboard.c
+--- xboard-4.2.7~/xboard.c 2003-11-19 09:42:18.000000000 +0100
++++ xboard-4.2.7/xboard.c 2005-12-16 22:19:16.000000000 +0100
+@@ -6734,8 +6734,8 @@
+ strcpy(icon, text);
+ strcpy(title, text);
+ } else if (appData.icsActive) {
+- sprintf(icon, "%s", appData.icsHost);
+- sprintf(title, "%s: %s", programName, appData.icsHost);
++ snprintf(icon, sizeof(icon), "%s", appData.icsHost);
++ snprintf(title, sizeof(title), "%s: %s", programName, appData.icsHost);
+ } else if (appData.cmailGameName[0] != NULLCHAR) {
+ sprintf(icon, "%s", "CMail");
+ sprintf(title, "%s: %s", programName, "CMail");
+@@ -6804,7 +6804,7 @@
+ } else {
+ fprintf(stderr, "%s: %s: %s\n",
+ programName, message, strerror(error));
+- sprintf(buf, "%s: %s", message, strerror(error));
++ snprintf(buf, sizeof(buf), "%s: %s", message, strerror(error));
+ message = buf;
+ }
+ if (appData.popupExitMessage && boardWidget && XtIsRealized(boardWidget)) {
+@@ -7488,9 +7488,9 @@
+ char cmdLine[MSG_SIZ];
+
+ if (port[0] == NULLCHAR) {
+- sprintf(cmdLine, "%s %s", appData.telnetProgram, host);
++ snprintf(cmdLine, sizeof(cmdLine), "%s %s", appData.telnetProgram, host);
+ } else {
+- sprintf(cmdLine, "%s %s %s", appData.telnetProgram, host, port);
++ snprintf(cmdLine, sizeof(cmdLine), "%s %s %s", appData.telnetProgram, host, port);
+ }
+ return StartChildProcess(cmdLine, "", pr);
+ }
diff --git a/source/xap/gnuchess/xboard.desktop b/source/xap/gnuchess/xboard.desktop
new file mode 100644
index 00000000..6336cb63
--- /dev/null
+++ b/source/xap/gnuchess/xboard.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=XBoard
+GenericName=Chess Game
+Comment=A graphical chess engine frontend
+Exec=xboard
+Icon=/usr/share/pixmaps/chess.png
+Terminal=false
+Type=Application
+Categories=Application;Game;BoardGame
diff --git a/source/xap/gnuchess/xboard.infodir.diff b/source/xap/gnuchess/xboard.infodir.diff
new file mode 100644
index 00000000..5c18bb02
--- /dev/null
+++ b/source/xap/gnuchess/xboard.infodir.diff
@@ -0,0 +1,11 @@
+--- ./Makefile.in.orig 2003-11-28 13:12:57.000000000 -0800
++++ ./Makefile.in 2004-06-26 15:47:07.000000000 -0700
+@@ -21,7 +21,7 @@
+ # Yuck; the autoconf generated configure script sets an infodir variable
+ # and provides a command-line flag to change it, but the default is
+ # /usr/info instead of /usr/share/info.
+-infodir = $(prefix)/share/info
++infodir = /usr/info
+
+ CC = @CC@
+ CFLAGS = @CFLAGS@ @CPPFLAGS@ -DINFODIR=\"$(infodir)\"
diff --git a/source/xap/gnuplot/gnuplot.SlackBuild b/source/xap/gnuplot/gnuplot.SlackBuild
new file mode 100755
index 00000000..f154e16d
--- /dev/null
+++ b/source/xap/gnuplot/gnuplot.SlackBuild
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=4.2.5
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-1}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gnuplot
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP
+rm -rf gnuplot-$VERSION
+tar xvf $CWD/gnuplot-$VERSION.tar.?z* || exit 1
+cd gnuplot-$VERSION || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# To distribute gnuplot binaries, you can not use GNU readline, as
+# gnuplot does not use a GPL compatible free license.
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --with-png \
+ --with-gd \
+ --datadir=/usr/share/gnuplot \
+ --with-readline=builtin \
+ --build=${ARCH}-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+# Compress info pages and purge "dir" file from the package:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+mkdir -p $PKG/usr/doc/gnuplot-$VERSION
+cp -a \
+ BUGS CodeStyle Copyright FAQ INSTALL NEWS PATCHLEVEL PGPKEYS PORTING \
+ README* TODO VERSION \
+ $PKG/usr/doc/gnuplot-$VERSION
+cp -a demo $PKG/usr/doc/gnuplot-$VERSION
+rm -f $PKG/usr/doc/gnuplot-$VERSION/demo/Make*
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# Make the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gnuplot-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gnuplot/slack-desc b/source/xap/gnuplot/slack-desc
new file mode 100644
index 00000000..f0007b4a
--- /dev/null
+++ b/source/xap/gnuplot/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gnuplot: gnuplot (plotting utility)
+gnuplot:
+gnuplot: Gnuplot is a command-line driven interactive function plotting utility
+gnuplot: for UNIX, MSDOS, and VMS platforms. The software is copyrighted but
+gnuplot: freely distributed (i.e., you don't have to pay for it). It was
+gnuplot: originally intended as graphical program which would allow scientists
+gnuplot: and students to visualize mathematical functions and data. Gnuplot
+gnuplot: supports many different types of terminals, plotters, and printers
+gnuplot: (including many color devices, and pseudo-devices like LaTeX) and is
+gnuplot: easily extensible to include new devices.
+gnuplot:
diff --git a/source/xap/gqview/doinst.sh b/source/xap/gqview/doinst.sh
new file mode 100644
index 00000000..31da2264
--- /dev/null
+++ b/source/xap/gqview/doinst.sh
@@ -0,0 +1,7 @@
+if [ -x /usr/bin/update-desktop-database ]; then
+ /usr/bin/update-desktop-database usr/share/applications >/dev/null 2>&1
+fi
+if [ -x /usr/bin/gtk-update-icon-cache ]; then
+ /usr/bin/gtk-update-icon-cache -f -t usr/share/icons/hicolor > /dev/null 2>&1
+fi
+
diff --git a/source/xap/gqview/gqview.SlackBuild b/source/xap/gqview/gqview.SlackBuild
new file mode 100755
index 00000000..74e0a3a9
--- /dev/null
+++ b/source/xap/gqview/gqview.SlackBuild
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+# Copyright 2006 Robby Workman (http://rlworkman.net)
+# Copyright 2007, 2009 Patrick Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Modified by the SlackBuilds.org project
+
+
+PRGNAM=gqview
+VERSION=2.1.5
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-2}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-$PRGNAM
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || exit 1
+cd $PRGNAM-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --program-prefix="" \
+ --program-suffix="" \
+ --build=i486-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install-strip DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a \
+ AUTHORS COPYING ChangeLog INSTALL NEWS README TODO \
+ $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+mv $PKG/usr/share/doc/$PRGNAM-$VERSION/* $PKG/usr/doc/$PRGNAM-$VERSION
+rm -r $PKG/usr/share/doc
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gqview/slack-desc b/source/xap/gqview/slack-desc
new file mode 100644
index 00000000..d6a6ceab
--- /dev/null
+++ b/source/xap/gqview/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gqview: gqview (GQview Image Browser)
+gqview:
+gqview: GQview is an image browser that features single-click access to view
+gqview: images and move around the directory tree.
+gqview:
+gqview: Homepage: http://gqview.sourceforge.net/
+gqview:
+gqview:
+gqview:
+gqview:
+gqview:
diff --git a/source/xap/gucharmap/doinst.sh b/source/xap/gucharmap/doinst.sh
new file mode 100644
index 00000000..4e8ba707
--- /dev/null
+++ b/source/xap/gucharmap/doinst.sh
@@ -0,0 +1,4 @@
+if [ -x /usr/bin/update-desktop-database ]; then
+ /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
+fi
+
diff --git a/source/xap/gucharmap/gucharmap.SlackBuild b/source/xap/gucharmap/gucharmap.SlackBuild
new file mode 100755
index 00000000..36f52614
--- /dev/null
+++ b/source/xap/gucharmap/gucharmap.SlackBuild
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=${VERSION:-2.26.2}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gucharmap
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf gucharmap-$VERSION
+tar xvf $CWD/gucharmap-$VERSION.tar.?z* || exit 1
+cd gucharmap-$VERSION || exit 1
+#zcat $CWD/gucharmap.noscrollkeeper.diff.gz | patch -p1 --verbose || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --localstatedir=/var/lib \
+ --docdir=/usr/doc/gucharmap-$VERSION \
+ --enable-static=no \
+ --enable-python-bindings \
+ --disable-gconf \
+ --disable-schemas-install \
+ --disable-scrollkeeper \
+ --build=$ARCH-slackware-linux
+
+make -i $NUMJOBS || make || exit 1
+make -i install DESTDIR=$PKG || exit 1
+
+# We don't want the gconf stuff
+rm -rf $PKG/etc
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/gucharmap-$VERSION
+cp -a \
+ COPYING* NEWS README TODO \
+ $PKG/usr/doc/gucharmap-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gucharmap-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gucharmap/slack-desc b/source/xap/gucharmap/slack-desc
new file mode 100644
index 00000000..798e123b
--- /dev/null
+++ b/source/xap/gucharmap/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gucharmap: gucharmap (character map utility)
+gucharmap:
+gucharmap: gucharmap is a Unicode character map and font viewer.
+gucharmap:
+gucharmap:
+gucharmap:
+gucharmap:
+gucharmap:
+gucharmap:
+gucharmap:
+gucharmap:
diff --git a/source/xap/gv/gv.SlackBuild b/source/xap/gv/gv.SlackBuild
new file mode 100755
index 00000000..d28abd8e
--- /dev/null
+++ b/source/xap/gv/gv.SlackBuild
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=gv
+VERSION=${VERSION:-3.6.7}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.?z* || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --libdir=/etc/X11 \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ --program-prefix= \
+ --program-suffix= \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS COPYING INSTALL NEWS README \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+#zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gv/slack-desc b/source/xap/gv/slack-desc
new file mode 100644
index 00000000..00626777
--- /dev/null
+++ b/source/xap/gv/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gv: gv (PS/PDF file viewer)
+gv:
+gv: gv is a PostScript and PDF previewer. It allows users to view and
+gv: navigate through PostScript and PDF documents on an X display by
+gv: providing a user interface for the ghostscript interpreter.
+gv:
+gv: gv was written by Johannes Plass, using the source code for Tim
+gv: Theisen's ghostview 1.5 as a starting point.
+gv:
+gv:
+gv:
diff --git a/source/xap/gxine/gxine.SlackBuild b/source/xap/gxine/gxine.SlackBuild
new file mode 100755
index 00000000..d9b75d0b
--- /dev/null
+++ b/source/xap/gxine/gxine.SlackBuild
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=0.5.903
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-gxine
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf gxine-$VERSION
+tar xvf $CWD/gxine-$VERSION.tar.bz2 || exit 1
+cd gxine-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --localstatedir=/var/lib \
+ --mandir=/usr/man \
+ --disable-static \
+ --with-browser-plugin \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+#zcat $CWD/gxine.desktop.gz > $PKG/usr/share/applications/gxine.desktop
+#if [ ! -r $PKG/usr/share/pixmaps/gxine.png ]; then
+# exit 1
+#fi
+
+# I'm sorry, but making this link was the worst suggestion I ever
+# went along with. I'll continue to include it (for now), but having
+# (buggy) gxine pop up without prompting all the time is ANNOYING!!!
+#mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
+#( cd $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
+# ln -sf /usr/lib${LIBDIRSUFFIX}/gxine/gxineplugin.so .
+#)
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+find $PKG/usr/man -type f -exec gzip -9 {} \;
+
+mkdir -p $PKG/usr/doc/gxine-$VERSION
+cp -a \
+ ABOUT-NLS AUTHORS COPYING* INSTALL NEWS README TODO \
+ $PKG/usr/doc/gxine-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/gxine-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/gxine/gxine.desktop b/source/xap/gxine/gxine.desktop
new file mode 100644
index 00000000..54e5e6c2
--- /dev/null
+++ b/source/xap/gxine/gxine.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=gxine
+GenericName=Video Player
+Comment=Play films and songs, or watch digital TV
+Exec=gxine
+MultipleArgs=true
+Icon=/usr/share/pixmaps/gxine.png
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GTK;Application;AudioVideo;
+MimeType=video/mpeg;video/msvideo;video/quicktime;video/x-avi;video/x-ms-asf;video/x-ms-wmv;video/x-msvideo;application/x-ogg;application/ogg;audio/x-mp3;audio/x-mpeg;video/x-mpeg;video/x-fli;audio/x-wav;audio/x-mpegurl;audio/x-scpls;audio/x-ms-asx;application/vnd.rn-realmedia;audio/x-real-audio;audio/x-pn-realaudio;application/x-flac;audio/x-flac;application/x-shockwave-flash;audio/mpeg;audio/x-ms-asf;audio/x-m4a;audio/x-ms-wax;video/dv;video/x-anim;video/x-flc;misc/ultravox;application/x-matroska;audio/vnd.rn-realaudio;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;image/vnd.rn-realpix;video/vnd.rn-realvideo
diff --git a/source/xap/gxine/slack-desc b/source/xap/gxine/slack-desc
new file mode 100644
index 00000000..18f7cef4
--- /dev/null
+++ b/source/xap/gxine/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+gxine: gxine (GTK+ media player based on Xine)
+gxine:
+gxine: Xine is a free multimedia player. It plays back CDs, DVDs, and VCDs,
+gxine: multimedia files, and multimedia streamed over a network.
+gxine:
+gxine: The gxine package contains a GTK+ graphical user interface for the
+gxine: Xine multimedia player.
+gxine:
+gxine:
+gxine:
+gxine:
diff --git a/source/xap/imagemagick/imagemagick.SlackBuild b/source/xap/imagemagick/imagemagick.SlackBuild
new file mode 100755
index 00000000..cfa07497
--- /dev/null
+++ b/source/xap/imagemagick/imagemagick.SlackBuild
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-1}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-imagemagick
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+# NOTE: This is to cope with ImageMagick version numbers such as 5.4.7-4,
+# which occur fairly often (but not always). If these numbers are all the same,
+# then this is not one of those versions.
+
+# This is a bit messy, so we'll explain it well. :-)
+
+# This is the base version number, which is needed to cd into the source tree
+BASEVER=6.5.3-3
+
+# This is the version number used in the source tarball filename
+FILEVER=6.5.3-3
+
+# This is the version number used in the package, where a version number cannot
+# contain a '-'
+PKGVER=6.5.3_3
+
+# --with-x or not --with-x, that is the question. It seems many other
+# distributions don't compile with X support, but it's been traditional
+# here. I am moving the prefix to /usr (instead of /usr/X11R6) though,
+# because many X-linked things are put into /usr now (like GNOME), and
+# I've heard a few reports of compile failures when this isn't in /usr.
+# Everyone else does it -- time to follow the path of least resistance.
+
+cd $TMP
+rm -rf ImageMagick-$BASEVER
+tar xvf $CWD/ImageMagick-$FILEVER.tar.?z* || exit 1
+cd ImageMagick-$BASEVER || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# --without-modules seems to avoid a segfault when identifying
+# or converting ps or eps files...
+
+# --disable-openmp seems to keep the perl Image::Magick from
+# eating up all RAM, and may help other script bindings.
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --program-prefix= \
+ --with-x \
+ --with-frozenpaths=no \
+ --without-modules \
+ --disable-openmp \
+ --enable-static=no \
+ --enable-shared \
+ --with-perl \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS INSTALLDIRS=vendor || make INSTALLDIRS=vendor || exit 1
+make install INSTALLDIRS=vendor DESTDIR=$PKG || exit 1
+
+# Lately ImageMagick has been smoking crack:
+rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libltdl.*
+
+( cd $PKG
+ # Nothing but a perl upgrade should replace this (and maybe not even that)
+ find . -name perllocal.pod | xargs rm -f
+)
+
+# DESTDIR is still broken about this, but works well enough otherwise:
+chmod 644 $PKG/usr/share/man/man3/*
+mv $PKG/usr/share/man/man3 $PKG/usr/man
+rmdir $PKG/usr/share/man
+
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/perl5
+ # Ditch empty dirs:
+ rmdir */* 2> /dev/null
+ rmdir * 2> /dev/null
+)
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+gzip -9 $PKG/usr/man/man?/*.?
+
+mkdir -p $PKG/usr
+mv $PKG/usr/share/doc $PKG/usr
+cp -a \
+ AUTHORS LICENSE NEWS NOTICE Platforms.txt QuickStart.txt README.txt \
+ $PKG/usr/doc/Imag*
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/imagemagick-$PKGVER-$ARCH-$BUILD.txz
+
diff --git a/source/xap/imagemagick/slack-desc b/source/xap/imagemagick/slack-desc
new file mode 100644
index 00000000..80ac9a67
--- /dev/null
+++ b/source/xap/imagemagick/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+imagemagick: imagemagick (a robust collection of image processing tools)
+imagemagick:
+imagemagick: ImageMagick is a collection of tools for manipulating and displaying
+imagemagick: digital images. It can merge images, transform image dimensions,
+imagemagick: do screen captures, create animation sequences, and convert between
+imagemagick: many different image formats.
+imagemagick:
+imagemagick: ImageMagick was written by John Cristy of ImageMagick Studio.
+imagemagick:
+imagemagick: Home page: http://www.imagemagick.org/
+imagemagick:
diff --git a/source/xap/mozilla-firefox/firefox.moz_plugin_path.diff b/source/xap/mozilla-firefox/firefox.moz_plugin_path.diff
new file mode 100644
index 00000000..761f295a
--- /dev/null
+++ b/source/xap/mozilla-firefox/firefox.moz_plugin_path.diff
@@ -0,0 +1,17 @@
+--- ./firefox.orig 2008-05-29 15:21:18.000000000 -0500
++++ ./firefox 2008-06-17 12:19:26.000000000 -0500
+@@ -54,6 +54,14 @@
+
+ moz_libdir=/usr/local/lib/firefox-3.0
+
++# Include /usr/lib/mozilla/plugins in the plugin path:
++if [ "$MOZ_PLUGIN_PATH" ] ; then
++ MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:${moz_libdir}/plugins:/usr/lib/mozilla/plugins
++else
++ MOZ_PLUGIN_PATH=${moz_libdir}/plugins:/usr/lib/mozilla/plugins
++fi
++export MOZ_PLUGIN_PATH
++
+ # Use run-mozilla.sh in the current dir if it exists
+ # If not, then start resolving symlinks until we find run-mozilla.sh
+ found=0
diff --git a/source/xap/mozilla-firefox/firefox.png b/source/xap/mozilla-firefox/firefox.png
new file mode 100644
index 00000000..76204b5d
--- /dev/null
+++ b/source/xap/mozilla-firefox/firefox.png
Binary files differ
diff --git a/source/xap/mozilla-firefox/mimeTypes.rdf b/source/xap/mozilla-firefox/mimeTypes.rdf
new file mode 100644
index 00000000..f3bc7b40
--- /dev/null
+++ b/source/xap/mozilla-firefox/mimeTypes.rdf
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
+ xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <RDF:Seq RDF:about="urn:mimetypes:root">
+ </RDF:Seq>
+ <RDF:Description RDF:about="urn:mimetypes">
+ <NC:MIME-types RDF:resource="urn:mimetypes:root"/>
+ </RDF:Description>
+ <RDF:Description RDF:about="urn:scheme:mailto"
+ NC:value="mailto">
+ <NC:handlerProp RDF:resource="urn:scheme:handler:mailto"/>
+ </RDF:Description>
+ <RDF:Description RDF:about="urn:handler:web:http://compose.mail.yahoo.com/?To=%s"
+ NC:prettyName="Yahoo! Mail"
+ NC:uriTemplate="http://compose.mail.yahoo.com/?To=%s" />
+ <RDF:Description RDF:about="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"
+ NC:prettyName="GMail"
+ NC:uriTemplate="https://mail.google.com/mail/?extsrc=mailto&amp;url=%s" />
+ <RDF:Description RDF:about="urn:scheme:handler:mailto"
+ NC:alwaysAsk="true">
+ <NC:possibleApplication RDF:resource="urn:handler:web:http://compose.mail.yahoo.com/?To=%s"/>
+ <NC:possibleApplication RDF:resource="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"/>
+ <NC:possibleApplication RDF:resource="urn:handler:local:/usr/bin/thunderbird"/>
+ </RDF:Description>
+ <RDF:Description RDF:about="urn:handler:local:/usr/bin/thunderbird"
+ NC:prettyName="thunderbird"
+ NC:path="/usr/bin/thunderbird" />
+</RDF:RDF>
diff --git a/source/xap/mozilla-firefox/mozilla-firefox-mimeTypes-fix.diff b/source/xap/mozilla-firefox/mozilla-firefox-mimeTypes-fix.diff
new file mode 100644
index 00000000..22211304
--- /dev/null
+++ b/source/xap/mozilla-firefox/mozilla-firefox-mimeTypes-fix.diff
@@ -0,0 +1,45 @@
+diff -Nur mozilla-1.9.1.orig/browser/locales/generic/profile/mimeTypes.rdf mozilla-1.9.1/browser/locales/generic/profile/mimeTypes.rdf
+--- mozilla-1.9.1.orig/browser/locales/generic/profile/mimeTypes.rdf 2009-06-29 11:14:41.000000000 -0500
++++ mozilla-1.9.1/browser/locales/generic/profile/mimeTypes.rdf 2009-07-01 08:28:05.407353867 -0500
+@@ -1,13 +1,28 @@
+-<?xml version="1.0"?>
+-
+-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+- xmlns:NC="http://home.netscape.com/NC-rdf#"
+- xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+-
+- <Description about="urn:mimetypes">
+- <NC:MIME-types>
+- <Seq about="urn:mimetypes:root">
+- </Seq>
+- </NC:MIME-types>
+- </Description>
+-</RDF>
++<?xml version="1.0"?>
++<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
++ xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
++ <RDF:Seq RDF:about="urn:mimetypes:root">
++ </RDF:Seq>
++ <RDF:Description RDF:about="urn:mimetypes">
++ <NC:MIME-types RDF:resource="urn:mimetypes:root"/>
++ </RDF:Description>
++ <RDF:Description RDF:about="urn:scheme:mailto"
++ NC:value="mailto">
++ <NC:handlerProp RDF:resource="urn:scheme:handler:mailto"/>
++ </RDF:Description>
++ <RDF:Description RDF:about="urn:handler:web:http://compose.mail.yahoo.com/?To=%s"
++ NC:prettyName="Yahoo! Mail"
++ NC:uriTemplate="http://compose.mail.yahoo.com/?To=%s" />
++ <RDF:Description RDF:about="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"
++ NC:prettyName="GMail"
++ NC:uriTemplate="https://mail.google.com/mail/?extsrc=mailto&amp;url=%s" />
++ <RDF:Description RDF:about="urn:scheme:handler:mailto"
++ NC:alwaysAsk="true">
++ <NC:possibleApplication RDF:resource="urn:handler:web:http://compose.mail.yahoo.com/?To=%s"/>
++ <NC:possibleApplication RDF:resource="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"/>
++ <NC:possibleApplication RDF:resource="urn:handler:local:/usr/bin/thunderbird"/>
++ </RDF:Description>
++ <RDF:Description RDF:about="urn:handler:local:/usr/bin/thunderbird"
++ NC:prettyName="thunderbird"
++ NC:path="/usr/bin/thunderbird" />
++</RDF:RDF>
diff --git a/source/xap/mozilla-firefox/mozilla-firefox.SlackBuild b/source/xap/mozilla-firefox/mozilla-firefox.SlackBuild
new file mode 100755
index 00000000..22dfb33b
--- /dev/null
+++ b/source/xap/mozilla-firefox/mozilla-firefox.SlackBuild
@@ -0,0 +1,184 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Thanks to the folks at the Mozilla Foundation for permission to
+# distribute this, and for all the great work! :-)
+
+# This is a source build script. Unfortunately, there is no official
+# binary tarball available for x86_64
+
+VERSION=${VERSION:-3.5.2}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+MOZVERS=${MOZVERS:-1.9.1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+# Try to be gentle to the compiler, no optimizations:
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O -fPIC"
+ LIBDIRSUFFIX="64"
+elif [ "$ARCH" = "arm" ]; then
+ SLKCFLAGS="-O2 -march=armv4 -mtune=xscale"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "armel" ]; then
+ SLKCFLAGS="-O2 -march=armv4t"
+ LIBDIRSUFFIX=""
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-mozilla-firefox
+
+rm -rf $PKG
+mkdir -p $TMP $PKG/usr/lib${LIBDIRSUFFIX}
+
+cd $TMP
+rm -rf mozilla-$MOZVERS
+tar xvf $CWD/firefox-$VERSION-source.tar.bz2 || exit 1
+cd mozilla-$MOZVERS || exit 1
+
+# Fix a long standing bug that's prevented staying current on GTK+.
+# Thanks to the BLFS folks. :-)
+cat << EOF >> layout/build/Makefile.in
+
+ifdef MOZ_ENABLE_CANVAS
+EXTRA_DSO_LDOPTS += \$(XLDFLAGS) -lX11 -lXrender
+endif
+
+EOF
+
+# Patch mimeTypes.rdf
+# Uncomment this if you want to use the patch; otherwise, we overwrite the
+# mimeTypes.rdf inside the package directory later
+# zcat $CWD/mozilla-firefox-mimeTypes-fix.diff.gz | patch -p1 || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+export MOZILLA_OFFICIAL="1" &&
+export BUILD_OFFICIAL="1" &&
+export MOZ_PHOENIX="1" &&
+export CFLAGS="$SLKCFLAGS" &&
+export CXXFLAGS="$SLKCFLAGS" &&
+./configure \
+ --enable-official-branding \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --with-default-mozilla-five-home=/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION \
+ --with-system-zlib \
+ --enable-application=browser \
+ --enable-default-toolkit=cairo-gtk2 \
+ --enable-crypto \
+ --enable-svg \
+ --enable-canvas \
+ --enable-xft \
+ --enable-xinerama \
+ --enable-optimize \
+ --enable-reorder \
+ --enable-strip \
+ --enable-system-cairo \
+ --enable-cpp-rtti \
+ --enable-single-profile \
+ --disable-ldap \
+ --disable-accessibility \
+ --disable-debug \
+ --disable-tests \
+ --disable-logging \
+ --disable-pedantic \
+ --disable-installer \
+ --disable-mailnews \
+ --disable-composer \
+ --disable-profilesharing
+ # Complains about missing APNG support in Slackware's libpng:
+ #--with-system-png \
+
+#make -f client.mk build MOZ_MAKE_FLAGS="$NUMJOBS" || exit 1
+make MOZ_MAKE_FLAGS="$NUMJOBS" || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# We don't need these (just symlinks anyway):
+rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/firefox-devel-$VERSION
+
+# Nor these:
+rm -rf $PKG/usr/include
+
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION
+ #mv defaults/profile/mimeTypes.rdf defaults/profile/mimeTypes.rdf.orig || exit 1
+ zcat $CWD/mimeTypes.rdf > defaults/profile/mimeTypes.rdf || exit 1
+ zcat $CWD/firefox.moz_plugin_path.diff.gz \
+ | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" \
+ | patch -p1 --verbose --backup --suffix=.orig || exit 1
+ # Clean up if the above patch was successful:
+ rm -f firefox.orig
+) || exit
+
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
+mkdir -p $PKG/usr/share/applications
+cat $CWD/mozilla-firefox.desktop > $PKG/usr/share/applications/mozilla-firefox.desktop
+mkdir -p $PKG/usr/share/pixmaps
+cat $CWD/firefox.png > $PKG/usr/share/pixmaps/firefox.png
+
+# These files/directories are usually created if Firefox is run as root,
+# which on many systems might (and possibly should) be never. Therefore, if we
+# don't see them we'll put stubs in place to prevent startup errors.
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION
+ if [ -d extensions/talkback\@mozilla.org ]; then
+ if [ ! -r extensions/talkback\@mozilla.org/chrome.manifest ]; then
+ echo > extensions/talkback\@mozilla.org/chrome.manifest
+ fi
+ fi
+ if [ ! -d updates ]; then
+ mkdir -p updates/0
+ fi
+)
+
+# Need some default icons in the right place:
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION/chrome/icons/default
+install -m 644 other-licenses/branding/firefox/default16.png \
+ $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION/icons/
+install -m 644 other-licenses/branding/firefox/default16.png \
+ $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION/chrome/icons/default/
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION
+ install -m 644 icons/{default,mozicon50}.xpm chrome/icons/default/
+)
+
+# Copy over the LICENSE
+install -p -c -m 644 LICENSE $PKG/usr/lib${LIBDIRSUFFIX}/firefox-$VERSION/
+
+mkdir $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/mozilla-firefox-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/mozilla-firefox/mozilla-firefox.desktop b/source/xap/mozilla-firefox/mozilla-firefox.desktop
new file mode 100644
index 00000000..23be26f3
--- /dev/null
+++ b/source/xap/mozilla-firefox/mozilla-firefox.desktop
@@ -0,0 +1,80 @@
+[Desktop Entry]
+Exec=firefox %u
+Icon=firefox
+Type=Application
+Categories=Network;
+Name=Firefox
+Name[bn]=ফায়ারফকà§à¦¸
+Name[eo]=Mozilo Fajrovulpo
+Name[fi]=Mozilla Firefox
+Name[pa]=ਫਾਇਰਫੋਕਸ
+Name[tg]=Рӯбоҳи оташин
+GenericName=Web Browser
+GenericName[af]=Web Blaaier
+GenericName[ar]=متصÙØ­ ويب
+GenericName[az]=Veb Səyyahı
+GenericName[bg]=Браузър
+GenericName[bn]=ওয়েব বà§à¦°à¦¾à¦‰à¦œà¦¾à¦°
+GenericName[br]=Furcher ar Gwiad
+GenericName[bs]=WWW Preglednik
+GenericName[ca]=Fullejador web
+GenericName[cs]=WWW prohlížeÄ
+GenericName[cy]=Porydd Gwe
+GenericName[da]=Browser
+GenericName[de]=Web-Browser
+GenericName[el]=ΠεÏιηγητής ΙστοÏ
+GenericName[eo]=TTT-legilo
+GenericName[es]=Navegador web
+GenericName[et]=Veebilehitseja
+GenericName[eu]=Web arakatzailea
+GenericName[fa]=مرورگر وب
+GenericName[fi]=WWW-selain
+GenericName[fo]=Alnótsfar
+GenericName[fr]=Navigateur web
+GenericName[gl]=Navegador Web
+GenericName[he]=דפדפן ×ינטרנט
+GenericName[hi]=वेब बà¥à¤°à¤¾à¤‰à¤œà¤¼à¤°
+GenericName[hr]=Web preglednik
+GenericName[hu]=Webböngésző
+GenericName[is]=Vafri
+GenericName[it]=Browser Web
+GenericName[ja]=ウェブブラウザ
+GenericName[ko]=웹 브ë¼ìš°ì €
+GenericName[lo]=ເວັບບຣາວເຊີ
+GenericName[lt]=Žiniatinklio naršyklė
+GenericName[lv]=Web PÄrlÅ«ks
+GenericName[mk]=ПрелиÑтувач на Интернет
+GenericName[mn]=Веб-Хөтөч
+GenericName[nb]=Nettleser
+GenericName[nds]=Nettkieker
+GenericName[nl]=Webbrowser
+GenericName[nn]=Nettlesar
+GenericName[nso]=Seinyakisi sa Web
+GenericName[pa]=ਵੈਬ à¨à¨²à¨•à¨¾à¨°à¨¾
+GenericName[pl]=PrzeglÄ…darka WWW
+GenericName[pt]=Navegador Web
+GenericName[pt_BR]=Navegador Web
+GenericName[ro]=Navigator de web
+GenericName[ru]=Веб-браузер
+GenericName[se]=Fierpmádatlogan
+GenericName[sk]=Webový prehliadaÄ
+GenericName[sl]=Spletni brskalnik
+GenericName[sr]=Веб претраживач
+GenericName[sr@Latn]=Veb pretraživaÄ
+GenericName[ss]=Ibrawuza yeWeb
+GenericName[sv]=Webbläsare
+GenericName[ta]=வலை உலாவி
+GenericName[tg]=ТафÑиргари вÑб
+GenericName[th]=เว็บบราวเซอร์
+GenericName[tr]=Web Tarayıcı
+GenericName[uk]=Ðавігатор Тенет
+GenericName[uz]=Веб-браузер
+GenericName[ven]=Buronza ya Webu
+GenericName[vi]=Trình duyệt Web
+GenericName[wa]=Betchteu waibe
+GenericName[xh]=Umkhangeli zincwadi we Web
+GenericName[zh_CN]=网页æµè§ˆå™¨
+GenericName[zh_TW]=網é ç€è¦½å™¨
+GenericName[zu]=Umcingi we-Web
+MimeType=text/html;
+X-KDE-StartupNotify=true
diff --git a/source/xap/mozilla-firefox/slack-desc b/source/xap/mozilla-firefox/slack-desc
new file mode 100644
index 00000000..a54bac8f
--- /dev/null
+++ b/source/xap/mozilla-firefox/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+mozilla-firefox: mozilla-firefox (Mozilla Firefox Web browser)
+mozilla-firefox:
+mozilla-firefox: This project is a redesign of the Mozilla browser component written
+mozilla-firefox: using the XUL user interface language. Firefox empowers you to
+mozilla-firefox: browse faster, more safely and more efficiently than with any other
+mozilla-firefox: browser.
+mozilla-firefox:
+mozilla-firefox: Visit the Mozilla Firefox project online:
+mozilla-firefox: http://www.mozilla.org/projects/firefox/
+mozilla-firefox:
+mozilla-firefox:
diff --git a/source/xap/mozilla-thunderbird/mozilla-thunderbird-firefox.diff b/source/xap/mozilla-thunderbird/mozilla-thunderbird-firefox.diff
new file mode 100644
index 00000000..fdf20963
--- /dev/null
+++ b/source/xap/mozilla-thunderbird/mozilla-thunderbird-firefox.diff
@@ -0,0 +1,11 @@
+--- ./defaults/pref/all-thunderbird.js.orig 2005-10-25 22:03:39.000000000 -0500
++++ ./defaults/pref/all-thunderbird.js 2005-12-09 16:22:00.000000000 -0600
+@@ -440,3 +440,8 @@
+
+ // prevent status-bar spoofing even if people are foolish enough to turn on JS
+ pref("dom.disable_window_status_change", true);
++
++// Use Firefox as the default for http:// and https:// links
++pref("network.protocol-handler.app.http", "/usr/bin/firefox");
++pref("network.protocol-handler.app.https", "/usr/bin/firefox");
++
diff --git a/source/xap/mozilla-thunderbird/mozilla-thunderbird.SlackBuild b/source/xap/mozilla-thunderbird/mozilla-thunderbird.SlackBuild
new file mode 100755
index 00000000..9872927d
--- /dev/null
+++ b/source/xap/mozilla-thunderbird/mozilla-thunderbird.SlackBuild
@@ -0,0 +1,141 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Thanks to the folks at the Mozilla Foundation for permission to
+# distribute this, and for all the great work! :-)
+
+VERSION=2.0.0.23
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-Os -march=i486 -mcpu=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-Os"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-Os -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-mozilla-thunderbird
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf mozilla
+tar xvf $CWD/thunderbird-$VERSION-source.tar.bz2 || exit 1
+cd mozilla || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+export MOZILLA_OFFICIAL="1" &&
+export BUILD_OFFICIAL="1" &&
+export MOZ_CO_PROJECT="mail" &&
+export CFLAGS="$SLKCFLAGS" &&
+export CXXFLAGS="$SLKCFLAGS" &&
+./configure \
+ --enable-official-branding \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --with-default-mozilla-five-home=/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION \
+ --with-user-appdir=.thunderbird \
+ --with-system-zlib \
+ --with-system-png \
+ --enable-application=mail \
+ --enable-default-toolkit=gtk2 \
+ --enable-crypto \
+ --enable-xft \
+ --enable-pango \
+ --enable-xinerama \
+ --enable-optimize \
+ --enable-reorder \
+ --enable-strip \
+ --enable-cpp-rtti \
+ --enable-single-profile \
+ --enable-ldap \
+ --disable-freetype2 \
+ --disable-accessibility \
+ --disable-debug \
+ --disable-tests \
+ --disable-logging \
+ --disable-pedantic \
+ --disable-installer \
+ --disable-profilesharing \
+ --disable-gnomevfs \
+ --disable-gnomeui
+
+make MOZ_OPT_FLAGS="$SLKCFLAGS" MOZ_MAKE_FLAGS="$NUMJOBS" || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# We do not need 20+ MB of includes:
+rm -rf $PKG/usr/include
+
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION
+ echo "Applying firefox patch"
+ zcat $CWD/mozilla-thunderbird-firefox.diff.gz | patch -p0 --verbose || exit 1
+) || exit 1
+
+mkdir -p $PKG/usr/share/applications
+cat $CWD/mozilla-thunderbird.desktop > $PKG/usr/share/applications/mozilla-thunderbird.desktop
+mkdir -p $PKG/usr/share/pixmaps
+cat $CWD/thunderbird.png > $PKG/usr/share/pixmaps/thunderbird.png
+
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION/chrome/icons/default/
+install -m 644 other-licenses/branding/thunderbird/default.xpm \
+ $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION/chrome/icons/default/
+install -m 644 other-licenses/branding/thunderbird/default.xpm \
+ $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION/icons/
+
+# These files/directories are usually created if Thunderbird is run as root,
+# which on many systems might (and possibly should) be never. Therefore,
+# if we don't see them we'll put stubs in place to prevent startup errors.
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION
+ if [ -d chrome ]; then
+ if [ ! -r chrome/app-chrome.manifest ]; then
+ echo > chrome/app-chrome.manifest
+ fi
+ fi
+ if [ ! -d updates ]; then
+ mkdir -p updates/0
+ fi
+)
+
+# Copy over the LICENSE
+install -c -m 644 LICENSE $PKG/usr/lib${LIBDIRSUFFIX}/thunderbird-$VERSION
+
+mkdir $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/mozilla-thunderbird-$VERSION-${ARCH}-$BUILD.txz
+
diff --git a/source/xap/mozilla-thunderbird/mozilla-thunderbird.desktop b/source/xap/mozilla-thunderbird/mozilla-thunderbird.desktop
new file mode 100644
index 00000000..0f85ecbe
--- /dev/null
+++ b/source/xap/mozilla-thunderbird/mozilla-thunderbird.desktop
@@ -0,0 +1,84 @@
+[Desktop Entry]
+Encoding=UTF-8
+Exec=thunderbird
+Icon=/usr/share/pixmaps/thunderbird.png
+Type=Application
+Categories=Application;Network;
+Name=Thunderbird
+Name[bn]=থাণà§à¦¡à¦¾à¦°à¦¬à¦¾à¦°à§à¦¡
+Name[eo]=Mozilo Tondrobirdo
+Name[fi]=Mozilla Thunderbird
+Name[pa]=ਥੰਡਰਬਰਡ
+Name[tg]=Паррандаи бало
+GenericName=Mail Client
+GenericName[af]=Pos Kliënt
+GenericName[ar]=البريد الألكتروني
+GenericName[az]=Poçt Alıcısı
+GenericName[be]=Паштовы кліент
+GenericName[bg]=ПощенÑки клиент
+GenericName[bn]=ইমেইল কà§à¦²à¦¾à§Ÿà§‡à¦¨à§à¦Ÿ
+GenericName[br]=Arval postel
+GenericName[bs]=Program za Äitanje elektronske poÅ¡te
+GenericName[ca]=Client de correu electrònic
+GenericName[cs]=Klient pro Ätení elektronické poÅ¡ty
+GenericName[cy]=Dibynnydd Ebost
+GenericName[da]=E-mail-klient
+GenericName[de]=E-Mail-Programm
+GenericName[el]=Πελάτης mail
+GenericName[eo]=Legi kaj sendi retpoÅton
+GenericName[es]=Cliente de correo electrónico
+GenericName[et]=Meiliklient
+GenericName[eu]=Posta bezeroa
+GenericName[fa]=کارگیر پست الکترونیکی
+GenericName[fi]=Sähköpostiohjelma
+GenericName[fo]=Postforrit
+GenericName[fr]=Logiciel de messagerie électronique
+GenericName[ga]=Cliant Ríomhphoist
+GenericName[gl]=Cliente de correo
+GenericName[he]=תוכנית דו×ר
+GenericName[hi]=डाकिया
+GenericName[hr]=Program za Äitanje elektronske poÅ¡te
+GenericName[hu]=Levelezőprogram
+GenericName[id]=Klien Mail
+GenericName[is]=Póstforrit
+GenericName[it]=Programma di posta elettronica
+GenericName[ja]=メールクライアント
+GenericName[ko]=편지를 주고 받는 프로그램
+GenericName[lo]=ໄຄà»à»€àº­àº±àº™àºˆàº»àº”ຫມາàºà»€àº­à»€àº¥àº±àºà»‚ຕນິàº
+GenericName[lt]=Pašto klientas
+GenericName[lv]=Pasta Klients
+GenericName[mk]=Програма за електронÑка пошта
+GenericName[mn]=Э-Захиа-Програм
+GenericName[mt]=Klijent tal-imejl
+GenericName[nb]=E-postklient
+GenericName[nds]=Mailprogramm
+GenericName[nl]=E-mailclient
+GenericName[nn]=Lesing og sending av e-post
+GenericName[nso]=Moreki wa Poso
+GenericName[oc]=Programari de correu electrònic
+GenericName[pa]=ਪੱਤਰ ਕਲਾਂਇਟ
+GenericName[pl]=Program do wysyłania i odbierania poczty elektronicznej
+GenericName[pt]=Client de E-mail
+GenericName[pt_BR]=Cliente de E-mail
+GenericName[ro]=Program de poştă electronică
+GenericName[ru]=Клиент Ñлектронной почты
+GenericName[se]=Boastaprográmma
+GenericName[sk]=Klient elektronickej pošty
+GenericName[sl]=Program za e-pošto
+GenericName[sr]=Програм за e-пошту
+GenericName[sr@Latn]=Program za e-poštu
+GenericName[ss]=Likhasimende leliposi
+GenericName[sv]=E-postklient
+GenericName[ta]=அஞà¯à®šà®²à¯ உறà¯à®ªà¯à®ªà®¿à®©à®°à¯
+GenericName[tg]=Коргири почтаи Ñллектроникӣ
+GenericName[th]=ไคลเอนต์จดหมายอิเล็à¸à¸—รอนิà¸à¸ªà¹Œ
+GenericName[tr]=Posta Ä°stemcisi
+GenericName[uk]=Клієнт електронної пошти
+GenericName[uz]=Хат-хабар клиенти
+GenericName[ven]=Mushumisani na poso
+GenericName[wa]=Cliyint d' emilaedje
+GenericName[xh]=Umxhasi Weposi
+GenericName[zh_CN]=邮件程åº
+GenericName[zh_TW]=郵件處ç†ç¨‹å¼
+GenericName[zu]=Umxhasi weposi
+X-KDE-StartupNotify=true
diff --git a/source/xap/mozilla-thunderbird/slack-desc b/source/xap/mozilla-thunderbird/slack-desc
new file mode 100644
index 00000000..353b2225
--- /dev/null
+++ b/source/xap/mozilla-thunderbird/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+mozilla-thunderbird: mozilla-thunderbird (Mozilla Thunderbird mail application)
+mozilla-thunderbird:
+mozilla-thunderbird: Mozilla Thunderbird is a redesign of the Mozilla mail component
+mozilla-thunderbird: written using the XUL user interface language. Thunderbird makes
+mozilla-thunderbird: emailing safer, faster, and easier than ever before with the
+mozilla-thunderbird: industry's best implementations of features such as intelligent spam
+mozilla-thunderbird: filters, built-in RSS reader, quick search, and much more.
+mozilla-thunderbird:
+mozilla-thunderbird: Visit the Mozilla Thunderbird project online:
+mozilla-thunderbird: http://www.mozilla.org/projects/thunderbird/
+mozilla-thunderbird:
diff --git a/source/xap/mozilla-thunderbird/thunderbird.png b/source/xap/mozilla-thunderbird/thunderbird.png
new file mode 100644
index 00000000..a6172dcd
--- /dev/null
+++ b/source/xap/mozilla-thunderbird/thunderbird.png
Binary files differ
diff --git a/source/xap/pan/pan.SlackBuild b/source/xap/pan/pan.SlackBuild
new file mode 100755
index 00000000..288b34a7
--- /dev/null
+++ b/source/xap/pan/pan.SlackBuild
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=pan
+VERSION=${VERSION:-0.133}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --localstatedir=/var/lib \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --program-prefix= \
+ --program-suffix= \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS COPYING* INSTALL NEWS README TODO \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+#zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/pan/slack-desc b/source/xap/pan/slack-desc
new file mode 100644
index 00000000..c4336adb
--- /dev/null
+++ b/source/xap/pan/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+pan: pan (USENET newsreader)
+pan:
+pan: This is PAN, a powerful and user-friendly USENET newsreader based on
+pan: GTK+2. Pan is the only Unix newsreader to score 100% on the Good
+pan: Net-Keeping Seal of Approval newsreader evaluations.
+pan:
+pan:
+pan:
+pan:
+pan:
+pan:
diff --git a/source/xap/pidgin/pidgin.SlackBuild b/source/xap/pidgin/pidgin.SlackBuild
new file mode 100755
index 00000000..fb7def08
--- /dev/null
+++ b/source/xap/pidgin/pidgin.SlackBuild
@@ -0,0 +1,192 @@
+#!/bin/sh
+
+# Copyright 2006, 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=pidgin
+VERSION=${VERSION:-2.5.9}
+PIDGINENC=${PIDGINENC:-3.0}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+elif [ "$ARCH" = "arm" ]; then
+ SLKCFLAGS="-O2 -march=armv4 -mtune=xscale"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "armel" ]; then
+ SLKCFLAGS="-O2 -march=armv4t"
+ LIBDIRSUFFIX=""
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.?z* || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Allow certificates signed with rsa-md5:
+zcat $CWD/purple-allow-sign-rsa-md5.patch.gz | patch -p0 --verbose || exit 1
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --enable-dot=no \
+ --disable-schemas-install \
+ --enable-dbus \
+ --enable-gnutls=yes \
+ --enable-nss=no \
+ --enable-gtkspell \
+ --enable-cyrus-sasl \
+ --with-perl-lib=vendor \
+ --disable-meanwhile \
+ --disable-avahi \
+ --disable-nm \
+ --program-prefix= \
+ --program-suffix= \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Fix misplaced items:
+eval $(perl '-V:archlib')
+eval $(perl '-V:privlib')
+VENDORPERL="$(echo $archlib | sed -e "s/perl5/perl5\/vendor_perl/")"
+
+find $PKG -type f -name perllocal.pod -exec mv {} $PKG/$VENDORPERL/Pidgin.pod \;
+mkdir -p $PKG/usr/man/man3
+find $PKG/usr/share/man -type f -name *.3 -exec mv {} $PKG/usr/man/man3 \;
+rm -rf $PKG/usr/share/man
+rm -r $PKG$privlib
+
+# This removes our DESTDIR from the packlist filenames, to keep perl's
+# internal inventories consistent and correct.
+find $PKG -name .packlist | while read plist ; do
+ sed -e "s%/share/man%/man%g" \
+ -e "s%$PKG%%g" \
+ -e "s%\.1$%\.1\.gz%g" \
+ -e "s%\.2$%\.2\.gz%g" \
+ -e "s%\.3$%\.3\.gz%g" \
+ -e "s%\.3pm$%\.3pm\.gz%g" \
+ -e "s%\.4$%\.4\.gz%g" \
+ -e "s%\.5$%\.5\.gz%g" \
+ -e "s%\.6$%\.6\.gz%g" \
+ -e "s%\.7$%\.7\.gz%g" \
+ -e "s%\.8$%\.8\.gz%g" \
+ ${plist} > ${plist}.new
+ mv -f ${plist}.new ${plist}
+done
+
+### add gaim-encryption
+( cd $TMP
+ rm -rf pidgin-encryption-$PIDGINENC
+ tar xvf $CWD/pidgin-encryption-$PIDGINENC.tar.gz || exit 1
+ cd pidgin-encryption-$PIDGINENC
+ PIDGIN_CFLAGS="-I${PKG}/usr/include/pidgin" \
+ PIDGIN_LIBS="-L${PKG}/usr/lib${LIBDIRSUFFIX}" \
+ PURPLE_CFLAGS="-I${PKG}/usr/include/libpurple" \
+ PURPLE_LIBS="-L${PKG}/usr/lib${LIBDIRSUFFIX}" \
+ ./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --disable-static \
+ --with-nss-includes=/usr/include/seamonkey/nss \
+ --with-nspr-includes=/usr/include/seamonkey/nspr \
+ --with-nss-libs=/usr/lib${LIBDIRSUFFIX}/seamonkey/ \
+ --with-nspr-libs=/usr/lib${LIBDIRSUFFIX}/seamonkey/ \
+ --program-prefix="" \
+ --program-suffix="" \
+ --build=$ARCH-slackware-linux
+ make $NUMJOBS || make || exit 1
+ make install DESTDIR=$PKG || exit 1
+) || exit 1
+### end add gaim-encryption
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ AUTHORS COPYING COPYRIGHT HACKING INSTALL NEWS PLUGIN_HOWTO README* doc \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+( cd $PKG/usr/doc/${PKGNAM}-$VERSION/doc
+ rm -f Makefile* *.dox *.1 *.in
+)
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/pidgin/purple-allow-sign-rsa-md5.patch b/source/xap/pidgin/purple-allow-sign-rsa-md5.patch
new file mode 100644
index 00000000..d882a6e8
--- /dev/null
+++ b/source/xap/pidgin/purple-allow-sign-rsa-md5.patch
@@ -0,0 +1,12 @@
+--- libpurple/plugins/ssl/ssl-gnutls.c.old 2008-10-17 18:58:31.000000000 +0200
++++ libpurple/plugins/ssl/ssl-gnutls.c 2008-10-17 18:53:03.000000000 +0200
+@@ -693,7 +693,8 @@
+ (Verisign and possibly others have
+ root certificates that predate the
+ current standard) */
+- GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT,
++ GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT
++ | GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5,
+ &verify);
+
+ if (ret != 0) {
diff --git a/source/xap/pidgin/slack-desc b/source/xap/pidgin/slack-desc
new file mode 100644
index 00000000..a9aabca1
--- /dev/null
+++ b/source/xap/pidgin/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+pidgin: pidgin (GTK+ instant messaging program)
+pidgin:
+pidgin: Pidgin allows you to talk to anyone using a variety of messaging
+pidgin: protocols, including AIM (Oscar and TOC), ICQ, IRC, Yahoo!, MSN
+pidgin: Messenger, Jabber, Gadu-Gadu, Napster, and Zephyr. These protocols
+pidgin: are implemented using a modular, easy to use design. To use a
+pidgin: protocol, just load the plugin for it.
+pidgin:
+pidgin: For more info, see: http://www.pidgin.im
+pidgin:
+pidgin:
diff --git a/source/xap/rdesktop/rdesktop.SlackBuild b/source/xap/rdesktop/rdesktop.SlackBuild
new file mode 100755
index 00000000..cbfc1498
--- /dev/null
+++ b/source/xap/rdesktop/rdesktop.SlackBuild
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+# Copyright 2006, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=rdesktop
+VERSION=${VERSION:-1.6.0}
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-1}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Configure:
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --with-sound=alsa \
+ --enable-smartcard \
+ --mandir=/usr/man \
+ --build=$ARCH-slackware-linux
+
+# Build and install:
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ COPYING README \
+ doc \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/rdesktop/slack-desc b/source/xap/rdesktop/slack-desc
new file mode 100644
index 00000000..283da1cd
--- /dev/null
+++ b/source/xap/rdesktop/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+rdesktop: rdesktop (Remote Desktop Protocol client)
+rdesktop:
+rdesktop: rdesktop is a client for Remote Desktop Protocol (RDP), used in a
+rdesktop: number of Microsoft products including Windows NT Terminal Server,
+rdesktop: Windows 2000 Server, Windows XP, and Windows 2003 Server.
+rdesktop:
+rdesktop: For more information, see: http://www.rdesktop.org
+rdesktop:
+rdesktop:
+rdesktop:
+rdesktop:
diff --git a/source/xap/rxvt/rxvt.SlackBuild b/source/xap/rxvt/rxvt.SlackBuild
new file mode 100755
index 00000000..81d39485
--- /dev/null
+++ b/source/xap/rxvt/rxvt.SlackBuild
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=2.7.10
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-4}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-rxvt
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf rxvt-$VERSION
+tar xvf $CWD/rxvt-$VERSION.tar.bz2 || exit 1
+cd rxvt-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+zcat $CWD/rxvt.utempter.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --enable-languages \
+ --enable-utmp \
+ --enable-wtmp \
+ --enable-xpm-background \
+ --enable-transparency \
+ --enable-menubar \
+ --enable-graphics \
+ --enable-rxvt-scroll \
+ --enable-next-scroll \
+ --enable-xterm-scroll \
+ --enable-xim \
+ --enable-frills \
+ --enable-linespace \
+ --enable-24bit \
+ --enable-keepscrolling \
+ --enable-mousewheel \
+ --enable-slipwheeling \
+ --enable-xgetdefault \
+ --enable-old-selection \
+ $ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+rmdir $PKG/usr/lib $PKG/usr/include
+rm $PKG/usr/bin/rxvt-$VERSION
+mkdir -p $PKG/usr/doc/rxvt-$VERSION
+cp -a \
+ rxvt-$VERSION.lsm doc rclock/rclock.html \
+ $PKG/usr/doc/rxvt-$VERSION
+rm -r $PKG/usr/doc/rxvt-$VERSION/doc/yodl
+
+gzip -9 $PKG/usr/man/man1/*
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/rxvt-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/rxvt/rxvt.utempter.diff b/source/xap/rxvt/rxvt.utempter.diff
new file mode 100644
index 00000000..54e06f7a
--- /dev/null
+++ b/source/xap/rxvt/rxvt.utempter.diff
@@ -0,0 +1,277 @@
+--- ./src/logging.c.orig 2002-12-15 16:33:04.000000000 -0800
++++ ./src/logging.c 2003-06-07 21:08:52.000000000 -0700
+@@ -60,157 +60,7 @@
+ void
+ rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname)
+ {
+-#ifdef HAVE_STRUCT_UTMP
+- struct utmp *ut = &(r->h->ut);
+-#endif
+-#ifdef HAVE_STRUCT_UTMPX
+- struct utmpx *utx = &(r->h->utx);
+-#endif
+-#ifdef HAVE_UTMP_PID
+- int i;
+-#endif
+- char ut_id[5];
+- struct passwd *pwent = getpwuid(getuid());
+-
+- if (!STRNCMP(pty, "/dev/", 5))
+- pty += 5; /* skip /dev/ prefix */
+-
+- if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) {
+- STRNCPY(ut_id, (pty + 3), sizeof(ut_id));
+- }
+-#ifdef HAVE_UTMP_PID
+- else if (sscanf(pty, "pts/%d", &i) == 1)
+- sprintf(ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
+-#endif
+- else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) {
+- rxvt_print_error("can't parse tty name \"%s\"", pty);
+- return;
+- }
+-
+-#ifdef HAVE_STRUCT_UTMP
+- MEMSET(ut, 0, sizeof(struct utmp));
+-# ifdef HAVE_UTMP_PID
+- setutent();
+- STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
+- ut->ut_type = DEAD_PROCESS;
+- getutid(ut); /* position to entry in utmp file */
+- STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
+-# endif
+-#endif
+-
+-#ifdef HAVE_STRUCT_UTMPX
+- MEMSET(utx, 0, sizeof(struct utmpx));
+- setutxent();
+- STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
+- utx->ut_type = DEAD_PROCESS;
+- getutxid(utx); /* position to entry in utmp file */
+- STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
+-#endif
+-
+-#ifdef HAVE_STRUCT_UTMP
+- STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
+- ut->ut_time = time(NULL);
+-# ifdef HAVE_UTMP_PID
+- STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+- sizeof(ut->ut_user));
+- STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
+- ut->ut_time = time(NULL);
+- ut->ut_pid = r->h->cmd_pid;
+-# ifdef HAVE_UTMP_HOST
+- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
+-# endif
+- ut->ut_type = USER_PROCESS;
+- pututline(ut);
+- endutent(); /* close the file */
+- r->h->utmp_pos = -1;
+-# else
+- STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+- sizeof(ut->ut_name));
+-# ifdef HAVE_UTMP_HOST
+- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
+-# endif
+-# endif
+-#endif
+-
+-#ifdef HAVE_STRUCT_UTMPX
+- STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line));
+- STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+- sizeof(utx->ut_user));
+- STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
+- utx->ut_session = getsid(0);
+- utx->ut_tv.tv_sec = time(NULL);
+- utx->ut_tv.tv_usec = 0;
+- utx->ut_pid = r->h->cmd_pid;
+-# ifdef HAVE_UTMPX_HOST
+- STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host));
+-# if 0
+- {
+- char *colon;
+-
+- if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
+- *colon = '\0';
+- }
+-# endif
+-# endif
+- utx->ut_type = USER_PROCESS;
+- pututxline(utx);
+- endutxent(); /* close the file */
+- r->h->utmp_pos = -1;
+-#endif
+-
+-#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
+- {
+- int i;
+-# ifdef HAVE_TTYSLOT
+- i = ttyslot();
+- if (rxvt_write_bsd_utmp(i, ut))
+- r->h->utmp_pos = i;
+-# else
+- FILE *fd0;
+-
+- if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
+- char buf[256], name[256];
+-
+- buf[sizeof(buf) - 1] = '\0';
+- for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
+- if (*buf == '#' || sscanf(buf, "%s", name) != 1)
+- continue;
+- if (!STRCMP(ut->ut_line, name)) {
+- if (!rxvt_write_bsd_utmp(i, ut))
+- i = 0;
+- r->h->utmp_pos = i;
+- fclose(fd0);
+- break;
+- }
+- i++;
+- }
+- fclose(fd0);
+- }
+-# endif
+- }
+-#endif
+-
+-#ifdef WTMP_SUPPORT
+-# ifdef WTMP_ONLY_ON_LOGIN
+- if (r->Options & Opt_loginShell)
+-# endif
+- {
+-# ifdef HAVE_STRUCT_UTMP
+-# ifdef HAVE_UPDWTMP
+- updwtmp(RXVT_WTMP_FILE, ut);
+-# else
+- rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
+-# endif
+-# endif
+-# ifdef HAVE_STRUCT_UTMPX
+- updwtmpx(RXVT_WTMPX_FILE, utx);
+-# endif
+- }
+-#endif
+-#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
+- if (r->Options & Opt_loginShell)
+- rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
+-#endif
++ addToUtmp(pty, NULL, r->cmd_fd);
+ }
+
+ /* ------------------------------------------------------------------------- */
+@@ -221,85 +71,7 @@
+ void
+ rxvt_cleanutent(rxvt_t *r)
+ {
+-#ifdef HAVE_STRUCT_UTMP
+- struct utmp *tmput, *ut = &(r->h->ut);
+-#endif
+-#ifdef HAVE_STRUCT_UTMPX
+- struct utmpx *tmputx, *utx = &(r->h->utx);
+-#endif
+-
+-#ifdef HAVE_STRUCT_UTMP
+-# ifdef HAVE_UTMP_PID
+- MEMSET(ut, 0, sizeof(struct utmp));
+- setutent();
+- STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
+- ut->ut_type = USER_PROCESS;
+- if ((tmput = getutid(ut))) /* position to entry in utmp file */
+- ut = tmput;
+- ut->ut_type = DEAD_PROCESS;
+-# else
+- MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
+-# ifdef HAVE_UTMP_HOST
+- MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
+-# endif
+-# endif
+- ut->ut_time = time(NULL);
+-#endif
+-
+-#ifdef HAVE_STRUCT_UTMPX
+- MEMSET(utx, 0, sizeof(struct utmpx));
+- setutxent();
+- STRNCPY(utx->ut_id, r->h->ut_id, sizeof(utx->ut_id));
+- utx->ut_type = USER_PROCESS;
+- if ((tmputx = getutxid(utx))) /* position to entry in utmp file */
+- utx = tmputx;
+- utx->ut_type = DEAD_PROCESS;
+- utx->ut_session = getsid(0);
+- utx->ut_tv.tv_sec = time(NULL);
+- utx->ut_tv.tv_usec = 0;
+-#endif
+-
+- /*
+- * Write ending wtmp entry
+- */
+-#ifdef WTMP_SUPPORT
+-# ifdef WTMP_ONLY_ON_LOGIN
+- if (r->Options & Opt_loginShell)
+-# endif
+- {
+-# ifdef HAVE_STRUCT_UTMP
+-# ifdef HAVE_UPDWTMP
+- updwtmp(RXVT_WTMP_FILE, ut);
+-# else
+- rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
+-# endif
+-# endif
+-# ifdef HAVE_STRUCT_UTMPX
+- updwtmpx(RXVT_WTMPX_FILE, utx);
+-# endif
+- }
+-#endif
+-
+- /*
+- * Write utmp entry
+- */
+-#ifdef HAVE_STRUCT_UTMP
+-# ifdef HAVE_UTMP_PID
+- if (ut->ut_pid == r->h->cmd_pid)
+- pututline(ut);
+- endutent();
+-# else
+- if (r->h->utmp_pos > 0) {
+- MEMSET(ut, 0, sizeof(struct utmp));
+- rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
+- }
+-# endif
+-#endif
+-#ifdef HAVE_STRUCT_UTMPX
+- if (utx->ut_pid == r->h->cmd_pid)
+- pututxline(utx);
+- endutxent();
+-#endif
++ removeFromUtmp();
+ }
+
+ /* ------------------------------------------------------------------------- */
+--- ./src/init.c.orig 2002-12-03 21:21:39.000000000 -0800
++++ ./src/init.c 2003-06-07 21:09:26.000000000 -0700
+@@ -858,6 +858,7 @@
+ rxvt_print_error("aborting");
+ exit(EXIT_FAILURE);
+ }
++ rxvt_privileged_utmp(r, SAVE);
+ }
+
+ /*----------------------------------------------------------------------*/
+@@ -1364,7 +1365,6 @@
+ #endif
+ r->num_fds++; /* counts from 0 */
+
+- rxvt_privileged_utmp(r, SAVE);
+ return cfd;
+ }
+
+--- ./autoconf/Make.common.in.orig 2001-11-29 19:22:56.000000000 -0800
++++ ./autoconf/Make.common.in 2003-06-07 21:08:52.000000000 -0700
+@@ -68,7 +68,7 @@
+
+ LIBTOOL = @LIBTOOL@
+ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(DEBUG) $(DINCLUDE) $(XINC) -I$(basedir) -I$(srcdir) -I.
+-LINK = $(CC) $(CFLAGS) $(LDFLAGS)
++LINK = $(CC) $(CFLAGS) $(LDFLAGS) -lutempter -lutil
+
+ # End of common section of the Makefile
+ #-------------------------------------------------------------------------
diff --git a/source/xap/rxvt/slack-desc b/source/xap/rxvt/slack-desc
new file mode 100644
index 00000000..5f278d61
--- /dev/null
+++ b/source/xap/rxvt/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+rxvt: rxvt (terminal emulator)
+rxvt:
+rxvt: rxvt is a color vt102 terminal emulator intended as an xterm
+rxvt: replacement for users who do not require features such as Tektronix
+rxvt: 4014 emulation and toolkit-style configurability. As a result, rxvt
+rxvt: uses much less memory -- a significant advantage on a machine serving
+rxvt: many X sessions. Also included is rclock, an analog clock for X.
+rxvt:
+rxvt:
+rxvt:
+rxvt:
diff --git a/source/xap/sane/dll.conf.additions b/source/xap/sane/dll.conf.additions
new file mode 100644
index 00000000..3e06e04d
--- /dev/null
+++ b/source/xap/sane/dll.conf.additions
@@ -0,0 +1,3 @@
+# HPLIP backend homepage: http://hplip.sf.net/
+# Uncomment the following line if hplip is installed:
+hpaio
diff --git a/source/xap/sane/doinst.sh b/source/xap/sane/doinst.sh
new file mode 100644
index 00000000..99841064
--- /dev/null
+++ b/source/xap/sane/doinst.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+for file in etc/sane.d/*.new ; do
+ config $file
+done
diff --git a/source/xap/sane/sane.SlackBuild b/source/xap/sane/sane.SlackBuild
new file mode 100755
index 00000000..2d82f09e
--- /dev/null
+++ b/source/xap/sane/sane.SlackBuild
@@ -0,0 +1,145 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=1.0.19
+BACKVER=1.0.19
+FRONTVER=1.0.14
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-4}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-sane
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+# First, we'll build the backends
+cd $TMP
+rm -rf sane-backends-$BACKVER
+tar xvf $CWD/sane-backends-$BACKVER.tar.bz2 || exit 1
+cd sane-backends-$BACKVER
+chown -R root:root .
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --with-docdir=/usr/doc/sane-$VERSION \
+ --localstatedir=/var/lib \
+ --enable-locking \
+ --with-lockdir=/var/lock/sane \
+ --with-group=scanner \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Add the default udev rules, and until it's handled upstream,
+# fix their syntax work with recent versions of udev
+mkdir -p $PKG/lib/udev/rules.d
+sed s/SYSFS/ATTRS/g tools/udev/libsane.rules \
+ > $PKG/lib/udev/rules.d/80-libsane.rules
+# Add the hal fdi file
+mkdir -p $PKG/usr/share/hal/fdi/policy/10osvendor/
+cat tools/hal/libsane.fdi \
+ > $PKG/usr/share/hal/fdi/policy/10osvendor/10-libsane.fdi
+
+# Now let's build the frontends
+cd $TMP
+rm -rf sane-frontends-$FRONTVER
+tar xvf $CWD/sane-frontends-$FRONTVER.tar.bz2 || exit 1
+cd sane-frontends-$FRONTVER
+chown -R root:root .
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --mandir=/usr/man \
+ --with-docdir=/usr/doc/sane-$VERSION \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Fix stupid permissions:
+chown -R root:root $PKG/var
+chmod 755 $PKG/var
+chmod 1777 $PKG/var/lock
+chown root:scanner $PKG/var/lock/sane
+chmod 775 $PKG/var/lock/sane
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# List additional backends in /etc/sane.d/dll.conf.
+# I don't think it will hurt anything to do this, even
+# if these backends turn out not to be available:
+zcat $CWD/dll.conf.additions.gz >> $PKG/etc/sane.d/dll.conf
+
+# Move config files:
+( cd $PKG/etc/sane.d
+ for file in *.conf ; do
+ mv $file ${file}.new
+ done
+)
+rm -f /etc/sane.d/*.conf
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/sane-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/sane/slack-desc b/source/xap/sane/slack-desc
new file mode 100644
index 00000000..787dbd6f
--- /dev/null
+++ b/source/xap/sane/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+sane: sane (Scanner Access Now Easy)
+sane:
+sane: SANE is a universal scanner interface that provides standardized
+sane: access to any raster image scanner hardware, such as flatbed scanners,
+sane: hand-held scanners, video and still cameras, frame-grabbers, and other
+sane: similar devices.
+sane:
+sane:
+sane:
+sane:
+sane:
diff --git a/source/xap/seamonkey/doinst.sh b/source/xap/seamonkey/doinst.sh
new file mode 100644
index 00000000..c236bea5
--- /dev/null
+++ b/source/xap/seamonkey/doinst.sh
@@ -0,0 +1,11 @@
+# If there's no mozilla here, then take over:
+if [ ! -r usr/bin/mozilla ]; then
+ ( cd usr/bin ; ln -sf seamonkey mozilla )
+fi
+# Hopefully this won't break everything. ;-)
+if ! grep /usr/lib/seamonkey etc/ld.so.conf 1> /dev/null 2> /dev/null ; then
+ echo "/usr/lib/seamonkey" >> etc/ld.so.conf
+fi
+if [ -x /sbin/ldconfig ]; then
+ /sbin/ldconfig 2> /dev/null
+fi
diff --git a/source/xap/seamonkey/seamonkey-icon.png b/source/xap/seamonkey/seamonkey-icon.png
new file mode 100644
index 00000000..824ab7a5
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey-icon.png
Binary files differ
diff --git a/source/xap/seamonkey/seamonkey-mail-icon.png b/source/xap/seamonkey/seamonkey-mail-icon.png
new file mode 100644
index 00000000..123b077b
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey-mail-icon.png
Binary files differ
diff --git a/source/xap/seamonkey/seamonkey-mail.desktop b/source/xap/seamonkey/seamonkey-mail.desktop
new file mode 100644
index 00000000..1e0b62b1
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey-mail.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=SeaMonkey Mail
+Comment=Read Mail with SeaMonkey
+Exec=/usr/bin/seamonkey -mail
+Icon=/usr/share/pixmaps/seamonkey-mail-icon.png
+Terminal=0
+Type=Application
+Categories=Application;Network;
diff --git a/source/xap/seamonkey/seamonkey.SlackBuild b/source/xap/seamonkey/seamonkey.SlackBuild
new file mode 100755
index 00000000..a0869558
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey.SlackBuild
@@ -0,0 +1,233 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=${VERSION:-1.1.17}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+elif [ "$ARCH" = "arm" ]; then
+ SLKCFLAGS="-O2 -march=armv4 -mtune=xscale"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "armel" ]; then
+ SLKCFLAGS="-O2 -march=armv4t"
+ LIBDIRSUFFIX=""
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-seamonkey
+rm -rf $PKG
+mkdir -p $TMP $PKG/usr
+
+cd $TMP
+rm -rf mozilla
+tar xvf $CWD/seamonkey-${VERSION}.source.tar.xz || exit 1
+cd mozilla || exit 1
+
+# Add /usr/lib/mozilla/plugins to MOZ_PLUGINS_PATH:
+zcat $CWD/seamonkey.moz_plugin_path.diff.gz \
+ | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" \
+ | patch -p1 --verbose || exit 1
+rm -f xpfe/bootstrap/mozilla.in.orig
+
+# Make sure the perms/ownerships are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# Fix a long standing bug that's prevented staying current on GTK+.
+# Thanks to the BLFS folks. :-)
+cat >> layout/build/Makefile.in << EOF
+
+ifdef MOZ_ENABLE_CANVAS
+EXTRA_DSO_LDOPTS += \$(XLDFLAGS) -lX11 -lXrender
+endif
+
+EOF
+
+chown -R root:root .
+BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 \
+./configure --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --enable-optimize="$CFLAGS" \
+ --disable-debug \
+ --with-default-mozilla-five-home=/usr/lib${LIBDIRSUFFIX}/seamonkey-${VERSION} \
+ --enable-strip \
+ --disable-tests \
+ --enable-svg \
+ --enable-system-cairo \
+ --enable-canvas \
+ --disable-short-wchar \
+ --enable-nspr-autoconf \
+ --enable-extensions=default,irc \
+ --enable-crypto \
+ --disable-xprint \
+ --without-system-nspr \
+ --with-system-zlib \
+ --with-system-jpeg \
+ --with-system-png \
+ --with-system-mng \
+ --enable-application=suite \
+ --enable-xft \
+ --host=$ARCH-slackware-linux \
+ --target=$ARCH-slackware-linux \
+ --build=$ARCH-slackware-linux
+
+BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 make $NUMJOBS -s export || exit 1
+BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 make $NUMJOBS -s libs || exit 1
+BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 DESTDIR=$PKG make install || exit 1
+
+# Install nss headers.
+mkdir -p $PKG/usr/include/seamonkey-${VERSION}/nss
+find security/nss/lib -name "*.h" -type f -exec cp -a {} $PKG/usr/include/seamonkey-${VERSION}/nss \;
+chown -R root:root $PKG/usr/include/seamonkey-${VERSION}/nss
+chmod 644 $PKG/usr/include/seamonkey-${VERSION}/nss/*
+# Create a more generic include files symlink:
+( cd $PKG/usr/include
+ if [ ! -e seamonkey ]; then
+ ln -sf seamonkey-${VERSION} seamonkey
+ fi
+)
+
+# Let the nspr be found by gxine:
+( cd $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig; ln -s seamonkey-nspr.pc nspr.pc )
+
+# A Better Way to handle the problem below is simply to add /usr/lib/seamonkey
+# to /etc/ld.so.conf. After all, the various Mozilla offshoots all set an
+# LD_LIBRARY_PATH to make sure *they* use the right libraries anyway, and as
+# far as I know seamonkey has the only set of Mozilla development libraries
+# right now. Plus, doing it this way doesn't stomp all over efforts by people
+# who would like to use seamonkey-nss-solibs.
+
+## Link some libraries into /usr/lib. Unless this is done, some things (like gxine)
+## will be unable to load them, even if they linked with them successfully.
+#( cd $PKG/usr/lib${LIBDIRSUFFIX} && ( for somelib in libmozjs.so libnspr4.so libnss3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so ; do
+# # Link to it:
+# ln -sf seamonkey-${VERSION}/$somelib .
+# done )
+#)
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+# Strip files:
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# This remains the standard plugin directory for all browsers.
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
+
+# Some software won't compile without this symlink:
+( cd $PKG/usr/lib${LIBDIRSUFFIX}
+ if [ ! -e seamonkey ]; then
+ ln -sf seamonkey-${VERSION} seamonkey
+ fi
+)
+
+mkdir -p $PKG/usr/share/applications
+cp -a $CWD/*.desktop $PKG/usr/share/applications
+chown -R root:root $PKG/usr/share/applications
+chmod 644 $PKG/usr/share/applications/*
+mkdir -p $PKG/usr/share/pixmaps
+cp -a $CWD/*.png $PKG/usr/share/pixmaps
+chown -R root:root $PKG/usr/share/pixmaps
+chmod 644 $PKG/usr/share/pixmaps/*
+
+mkdir -p $PKG/usr/doc/seamonkey-$VERSION
+cp -a \
+ LEGAL LICENSE README.txt \
+ $PKG/usr/doc/seamonkey-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+zcat $CWD/doinst.sh.gz | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" \
+ > $PKG/install/doinst.sh
+
+cd $TMP/package-seamonkey
+/sbin/makepkg -l y -c n -p $TMP/seamonkey-$VERSION-$ARCH-$BUILD.txz
+
+# Create a standalone seamonkey-solibs package for RPM, gxine, etc.
+rm -r $TMP/package-seamonkey-solibs
+mkdir -p $TMP/package-seamonkey-solibs/usr/doc
+cp -a $PKG/usr/doc/seamonkey-$VERSION $TMP/package-seamonkey-solibs/usr/doc
+mkdir -p $TMP/package-seamonkey-solibs/usr/lib${LIBDIRSUFFIX}/seamonkey-${VERSION}
+for file in libfreebl3.chk libfreebl3.so libmozjs.so libnspr4.so libnss3.so \
+ libnssckbi.so libplc4.so libplds4.so libsmime3.so libsoftokn3.chk \
+ libsoftokn3.so libssl3.so ; do
+ cp -a $PKG/usr/lib${LIBDIRSUFFIX}/seamonkey-${VERSION}/$file \
+ $TMP/package-seamonkey-solibs/usr/lib${LIBDIRSUFFIX}/seamonkey-${VERSION}
+done
+mkdir $TMP/package-seamonkey-solibs/install
+cat << EOF | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" > $TMP/package-seamonkey-solibs/install/doinst.sh
+( cd usr/lib ; rm -rf seamonkey )
+( cd usr/lib ; ln -sf seamonkey-$VERSION seamonkey )
+if ! grep /usr/lib/seamonkey etc/ld.so.conf 1> /dev/null 2> /dev/null ; then
+ echo "/usr/lib/seamonkey" >> etc/ld.so.conf
+fi
+if [ -x /sbin/ldconfig ]; then
+ /sbin/ldconfig 2> /dev/null
+fi
+EOF
+cat << EOF > $TMP/package-seamonkey-solibs/install/slack-desc
+ |-----handy-ruler------------------------------------------------------|
+seamonkey-solibs: seamonkey-solibs (Shared libraries from Seamonkey)
+seamonkey-solibs:
+seamonkey-solibs: This package contains a subset of the shared libraries from Seamonkey
+seamonkey-solibs: to provide runtime support for programs that require nss, nspr, and
+seamonkey-solibs: js. These libraries are used in programs like RPM and gxine, and can
+seamonkey-solibs: be used in others. This package is built from the Seamonkey sources
+seamonkey-solibs: and is provided as a standalone runtime package for people who do not
+seamonkey-solibs: want to install the entire seamonkey package (as for server use).
+seamonkey-solibs:
+seamonkey-solibs: This package is runtime only. The include files and other files for
+seamonkey-solibs: development can be found in the seamonkey package.
+EOF
+cd $TMP/package-seamonkey-solibs
+/sbin/makepkg -l y -c n -p $TMP/seamonkey-solibs-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/seamonkey/seamonkey.desktop b/source/xap/seamonkey/seamonkey.desktop
new file mode 100644
index 00000000..7c988a76
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=SeaMonkey
+Comment=Web Browser
+Exec=/usr/bin/seamonkey
+Icon=/usr/share/pixmaps/seamonkey-icon.png
+Terminal=0
+Type=Application
+Categories=Application;Network;
diff --git a/source/xap/seamonkey/seamonkey.moz_plugin_path.diff b/source/xap/seamonkey/seamonkey.moz_plugin_path.diff
new file mode 100644
index 00000000..f967580b
--- /dev/null
+++ b/source/xap/seamonkey/seamonkey.moz_plugin_path.diff
@@ -0,0 +1,16 @@
+--- ./xpfe/bootstrap/mozilla.in.orig 2006-08-20 17:44:28.000000000 -0500
++++ ./xpfe/bootstrap/mozilla.in 2007-02-19 21:25:32.000000000 -0600
+@@ -60,6 +60,13 @@
+ MOZ_PIS_SESSION_PID="$$"
+ MOZ_PIS_USER_DIR="${MOZ_USER_DIR}"
+ export MOZ_PIS_API MOZ_PIS_MOZBINDIR MOZ_PIS_SESSION_PID MOZ_PIS_USER_DIR
++ # Include /usr/lib/mozilla/plugins in the plugin path:
++ if [ "$MOZ_PLUGIN_PATH" ] ; then
++ MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:${moz_libdir}/plugins:/usr/lib/mozilla/plugins
++ else
++ MOZ_PLUGIN_PATH=${moz_libdir}/plugins:/usr/lib/mozilla/plugins
++ fi
++ export MOZ_PLUGIN_PATH
+
+ case "${1}" in
+ "start")
diff --git a/source/xap/seamonkey/slack-desc b/source/xap/seamonkey/slack-desc
new file mode 100644
index 00000000..978c1d09
--- /dev/null
+++ b/source/xap/seamonkey/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+seamonkey: SeaMonkey (an open-source web browser suite)
+seamonkey:
+seamonkey: The SeaMonkey browser suite. SeaMonkey features a state-of-the-art
+seamonkey: web browser and powerful email client, as well as a WYSIWYG web page
+seamonkey: composer and a feature-rich IRC chat client. For web developers,
+seamonkey: mozilla.org's DOM inspector and JavaScript debugger tools are
+seamonkey: included as well.
+seamonkey:
+seamonkey: Visit the SeaMonkey project at this URL:
+seamonkey: http://www.mozilla.org/projects/seamonkey/
+seamonkey:
diff --git a/source/xap/seyon/seyon-2.20c.lsm b/source/xap/seyon/seyon-2.20c.lsm
new file mode 100644
index 00000000..7eb9dbb9
--- /dev/null
+++ b/source/xap/seyon/seyon-2.20c.lsm
@@ -0,0 +1,16 @@
+Begin3
+Title: Seyon
+Version: 2.20c
+Entered-date: 09MAY99
+Description: Seyon is a complete full-featured telecommunications package
+ for the X Window System. Some of its features are: dialing
+ directory, scripting language, external file transfer protocol
+ support, zmodem auto-download, configurable keyboard
+ translation modes.
+Keywords: communication seyon x11 rs232 serial
+Author: msaggaf@erl.mit.edu (M. Saggaf)
+Maintained-by: stevem@chiark.greenend.org.uk (Steve McIntyre)
+Primary-site: sunsite.unc.edu /pub/Linux/apps/serialcomm/dialout
+ 165 KB seyon-2.20c.tar.gz
+Copying-policy: GNU GPL
+End
diff --git a/source/xap/seyon/seyon.SlackBuild b/source/xap/seyon/seyon.SlackBuild
new file mode 100755
index 00000000..656d2ff9
--- /dev/null
+++ b/source/xap/seyon/seyon.SlackBuild
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+# Copyright 2002-2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=2.20c
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-3}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-seyon
+
+rm -rf $PKG
+mkdir -p $PKG $PKG
+cd $TMP
+rm -rf seyon-$VERSION
+tar xvf $CWD/seyon-$VERSION.tar.gz || exit 1
+cd seyon-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+zcat $CWD/seyon_2.20c-16.diff.gz | patch -p1 --verbose || exit 1
+
+chmod 755 makever.sh
+xmkmf
+make || exit 1
+
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/X11
+make install DESTDIR=$PKG LIBDIR=/usr/lib${LIBDIRSUFFIX}/X11 || exit 1
+
+mkdir -p $PKG/etc/X11/seyon
+touch $PKG/etc/X11/seyon/Seyon-modem.new
+mkdir -p $PKG/etc/X11/app-defaults
+cp Seyon-co.ad $PKG/etc/X11/app-defaults/Seyon-color.new
+cp Seyon.ad $PKG/etc/X11/app-defaults/Seyon.new
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/seyon-$VERSION/.seyon
+cp -a \
+ 1-* COPYING $PKG/usr/doc/seyon-$VERSION
+cp -a \
+ phonelist protocols script.CIS script.PCBoard script.QWK script.unix startup \
+ $PKG/usr/doc/seyon-$VERSION/.seyon
+find $PKG/usr/doc/seyon-$VERSION -type f -exec chmod 644 {} \;
+find $PKG/usr/doc/seyon-$VERSION -type d -exec chmod 755 {} \;
+( cd $PKG/usr/doc/seyon-$VERSION ; ln -sf .seyon HOME.seyon.directory.example )
+
+mkdir -p $PKG/usr/man/man1
+cat seyon.man | gzip -9c > $PKG/usr/man/man1/seyon.1.gz
+
+mkdir -p $PKG/install
+cat << EOF > $PKG/install/doinst.sh
+#!/bin/sh
+config() {
+ NEW="\$1"
+ OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r \$OLD ]; then
+ mv \$NEW \$OLD
+ elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy
+ rm \$NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+config etc/X11/seyon/Seyon-modem.new
+config etc/X11/app-defaults/Seyon.new
+config etc/X11/app-defaults/Seyon-color.new
+
+EOF
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/seyon-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/seyon/seyon_2.20c-16.diff b/source/xap/seyon/seyon_2.20c-16.diff
new file mode 100644
index 00000000..536e69cb
--- /dev/null
+++ b/source/xap/seyon/seyon_2.20c-16.diff
@@ -0,0 +1,5031 @@
+--- seyon-2.20c.orig/Seyon.ad
++++ seyon-2.20c/Seyon.ad
+@@ -7,6 +7,8 @@
+ ! * statement of rights and permissions for this program.
+ ! *
+
++#include "/etc/X11/seyon/Seyon-modem"
++
+ *.title: Seyon Command Center
+ *.iconName: Seyon
+
+@@ -259,31 +261,6 @@
+ *statusBox.rng.label: RNG
+
+ !
+-! Quick Keys
+-!
+-
+-*quickKeyBox.Command.font: 6x10
+-
+-*quickKey1.visible: on
+-*quickKey2.visible: on
+-*quickKey3.visible: on
+-*quickKey4.visible: on
+-*quickKey5.visible: on
+-
+-!*quickKey1.action: DialEntries(1);
+-!*quickKey2.action: DialEntries(3);
+-!*quickKey3.action: FileTransfer(2, ou*);
+-!*quickKey4.action: DivertFile(/tmp/lo);
+-!*quickKey5.action: Hangup(); Beep();
+-!RunScript(test1); Echo(ll);
+-
+-*quickKey1.label: Athena
+-*quickKey2.label: Ch1
+-*quickKey3.label: UpMail
+-*quickKey4.label: DivMsg
+-*quickKey5.label: Local
+-
+-!
+ ! Fun messages. Send me more please.
+ !
+
+@@ -302,6 +279,7 @@
+ "Have something funny? send it!" \
+ "I've fallen and I can't get up!"
+
+++*showFunMessages: off
+ *notImplemented*title: Seyon Feature
+ *notImplemented.dialog.label: \
+ This feature is not yet implemented\n\
+--- seyon-2.20c.orig/SeDecl.h
++++ seyon-2.20c/SeDecl.h
+@@ -66,7 +66,6 @@
+ extern FILE *open_file(),
+ *open_file_va();
+ extern void send_break(),
+- usleep(),
+ show(),
+ showf(),
+ SeyonMessage(),
+--- seyon-2.20c.orig/1-CHANGES
++++ seyon-2.20c/1-CHANGES
+@@ -12,7 +12,6 @@
+ Rolled in some obvious bug fixes from the Debian version of 2.14c:
+ * Fixed typo in Seyon.ad: s/replcae/replace
+ * Added #include <linux/serial.h> to SePort.c for Linux
+- * Minor changes to ExecShellCommand; used to crash, should no more.
+ * Now under GPL (see 1-COPYING for details), new maintainer.
+
+ Versions up to 2.20b:
+--- seyon-2.20c.orig/SeTerm.c
++++ seyon-2.20c/SeTerm.c
+@@ -10,7 +10,7 @@
+ * This file contains routines for Seyon's terminal. The main routine is
+ * terminal(), which reads characters from the terminal and sends them to the
+ * port. That routine also forks a child process that reads characters from
+- * the port and writes them to the temrinal. Once the parent receives SIGTERM
++ * the port and writes them to the terminal. Once the parent receives SIGTERM
+ * (which should be sent by the grand parent), it kills the child and exits.
+ */
+
+--- seyon-2.20c.orig/MultiList.c
++++ seyon-2.20c/MultiList.c
+@@ -1031,8 +1031,8 @@
+ XfwfMultiListWidget mlw;
+ int row,column;
+ {
+- GC bg_gc,fg_gc;
+- XfwfMultiListItem *item;
++ GC bg_gc,fg_gc = 0;
++ XfwfMultiListItem *item = NULL;
+ int ul_x,ul_y,str_x,str_y,w,h,item_index,has_item,text_h;
+
+ if (!XtIsRealized((Widget)mlw)) return;
+--- seyon-2.20c.orig/SeInit.c
++++ seyon-2.20c/SeInit.c
+@@ -34,30 +34,30 @@
+ #endif
+
+ extern void TopAbout(),
+- TopHelp(),
+- TopSet(),
+- TopTransfer(),
+- TopMisc(),
+- SetNewlineTrMode(),
+- FunMessage();
++ TopHelp(),
++ TopSet(),
++ TopTransfer(),
++ TopMisc(),
++ SetNewlineTrMode(),
++ FunMessage();
+
+ extern void upload_acc_ok(),
+- setVal_action_ok(),
+- manual_dial_action_ok(),
+- divert_action_ok();
++ setVal_action_ok(),
++ manual_dial_action_ok(),
++ divert_action_ok();
+
+ extern Boolean CvtStringToStringArray();
+
+ void HangupConfirm(),
+- ExecHangup(),
+- ExitConfirm(),
+- ExitAction(),
+- test();
++ ExecHangup(),
++ ExitConfirm(),
++ ExitAction(),
++ test();
+
+ Boolean inhibit_child = False;
+ Widget w_exit,
+- w_kill,
+- statusMessage;
++ w_kill,
++ statusMessage;
+ Widget dialWidget, genericWidget;
+ pid_t w_child_pid = 0;
+ Pixmap progIcon;
+@@ -66,194 +66,202 @@
+
+ void
+ InitVariables(topLevel)
+- Widget topLevel;
++ Widget topLevel;
+ {
+- char buffer[REG_BUF];
++ char buffer[REG_BUF];
+
+- sprintf(captureFile, "%s/%s", expand_fname(qres.defaultDirectory, buffer),
+- qres.captureFile);
++ expand_fname(qres.defaultDirectory, buffer, REG_BUF);
+
+- SetNewlineTrMode(qres.newlineTranslation);
++ if(REG_BUF > (1 + strlen(buffer) + strlen(qres.captureFile)))
++ sprintf(captureFile, "%s/%s", buffer, qres.captureFile);
++ else
++ {
++ printf("Buffer overflow in InitVariables: %s/%s\nExit\n",buffer, qres.captureFile);
++ exit(1);
++ }
++
++ SetNewlineTrMode(qres.newlineTranslation);
+ }
+
+ void
+ SetIcon(topLevelWidget)
+- Widget topLevelWidget;
++ Widget topLevelWidget;
+ {
+- progIcon =
+- XCreateBitmapFromData(XtDisplay(topLevelWidget),
+- DefaultRootWindow(XtDisplay(topLevelWidget)),
+- progIcon_bits, progIcon_width,
+- progIcon_height);
+- XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL);
++ progIcon =
++ XCreateBitmapFromData(XtDisplay(topLevelWidget),
++ DefaultRootWindow(XtDisplay(topLevelWidget)),
++ progIcon_bits, progIcon_width,
++ progIcon_height);
++ XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL);
+ }
+
+ void
+ CreateCommandCenter()
+ {
+- void GetQuickKeyResources(),
+- GetValueByPopupOKAction(),
+- DispatchActionsCallback();
+- void TopShell();
+- void KillChildProc();
+-
+- Widget mainBox,
+- menuBox,
+- statusBox,
+- messageBox,
+- quickKeyBox;
+- static Widget status[NUM_MDM_STAT];
+- static Atom wm_delete_window;
+- Dimension menuBoxWidth;
+-
+- struct _quickKeyRes quickKeyRes;
+- Widget quickKeyW;
+- char qKBuf[REG_BUF];
+- int i, n = 0;
+-
+- static XtActionsRec actionTable[] = {
+- {"UploadOk", upload_acc_ok},
+- {"SetValOk", setVal_action_ok},
+- {"ManualDialOk", manual_dial_action_ok},
+- {"DivertOk", divert_action_ok},
+- {"Exit", ExitAction},
+- {"GetValueByPopupOK", GetValueByPopupOKAction},
+- };
+-
+- XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable,
+- XtNumber(actionTable));
+-
+- mainBox = SeAddPaned("mainBox", topLevel);
+- statusBox = AddBox("statusBox", mainBox);
+- messageBox = SeAddForm("messageBox", mainBox);
+- quickKeyBox = AddBox("quickKeyBox", mainBox);
+- menuBox = AddBox("menuBox", mainBox);
+-
+- status[0] = SeAddToggle("dcd", statusBox, NULL);
+- status[1] = SeAddToggle("dtr", statusBox, NULL);
+- status[2] = SeAddToggle("dsr", statusBox, NULL);
+- status[3] = SeAddToggle("rts", statusBox, NULL);
+- status[4] = SeAddToggle("cts", statusBox, NULL);
+- status[5] = SeAddToggle("rng", statusBox, NULL);
+-
+- statusMessage = SeAddLabel("message", messageBox);
+-
+- AddButton("about", menuBox, TopAbout, NULL);
+- AddButton("help", menuBox, TopHelp, NULL);
+- AddButton("set", menuBox, TopSet, NULL);
+- genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL);
+- AddButton("transfer", menuBox, TopTransfer, NULL);
+- AddButton("shellCommand", menuBox, TopShell, NULL);
+- AddButton("misc", menuBox, TopMisc, NULL);
+- AddButton("hangup", menuBox, HangupConfirm, NULL);
+- w_exit = AddButton("exit", menuBox, ExitConfirm, NULL);
+- w_kill = AddButton("kill", menuBox, KillChildProc, NULL);
+-
+- for (i = 0; i < MAX_SEQUICKKEYS; i++) {
+- sprintf(qKBuf, "quickKey%d", i+1);
+- GetQuickKeyResources(qKBuf, &quickKeyRes);
+- if (quickKeyRes.visible) {
+- n++;
++ void GetQuickKeyResources(),
++ GetValueByPopupOKAction(),
++ DispatchActionsCallback();
++ void TopShell();
++ void KillChildProc();
++
++ Widget mainBox,
++ menuBox,
++ statusBox,
++ messageBox,
++ quickKeyBox;
++ static Widget status[NUM_MDM_STAT];
++ static Atom wm_delete_window;
++ Dimension menuBoxWidth;
++
++ struct _quickKeyRes quickKeyRes;
++ Widget quickKeyW;
++ char qKBuf[LRG_BUF];
++ int i, n = 0;
++
++ static XtActionsRec actionTable[] = {
++ {"UploadOk", upload_acc_ok},
++ {"SetValOk", setVal_action_ok},
++ {"ManualDialOk", manual_dial_action_ok},
++ {"DivertOk", divert_action_ok},
++ {"Exit", ExitAction},
++ {"GetValueByPopupOK", GetValueByPopupOKAction},
++ };
++
++ XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable,
++ XtNumber(actionTable));
++
++ mainBox = SeAddPaned("mainBox", topLevel);
++ statusBox = AddBox("statusBox", mainBox);
++ messageBox = SeAddForm("messageBox", mainBox);
++ quickKeyBox = AddBox("quickKeyBox", mainBox);
++ menuBox = AddBox("menuBox", mainBox);
++
++ status[0] = SeAddToggle("dcd", statusBox, NULL);
++ status[1] = SeAddToggle("dtr", statusBox, NULL);
++ status[2] = SeAddToggle("dsr", statusBox, NULL);
++ status[3] = SeAddToggle("rts", statusBox, NULL);
++ status[4] = SeAddToggle("cts", statusBox, NULL);
++ status[5] = SeAddToggle("rng", statusBox, NULL);
++
++ statusMessage = SeAddLabel("message", messageBox);
++
++ AddButton("about", menuBox, TopAbout, NULL);
++ AddButton("help", menuBox, TopHelp, NULL);
++ AddButton("set", menuBox, TopSet, NULL);
++ genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL);
++ AddButton("transfer", menuBox, TopTransfer, NULL);
++ AddButton("shellCommand", menuBox, TopShell, NULL);
++ AddButton("misc", menuBox, TopMisc, NULL);
++ AddButton("hangup", menuBox, HangupConfirm, NULL);
++ w_exit = AddButton("exit", menuBox, ExitConfirm, NULL);
++ w_kill = AddButton("kill", menuBox, KillChildProc, NULL);
++
++ for (i = 0; i < MAX_SEQUICKKEYS; i++) {
++ sprintf(qKBuf, "quickKey%d", i+1); /* qKBuf is large enough here... */
++ GetQuickKeyResources(qKBuf, &quickKeyRes);
++ if (quickKeyRes.visible) {
++ n++;
+ quickKeyW =
+- AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL);
+- }
+- }
+- if (n == 0) XtDestroyWidget(quickKeyBox);
+-
+- XtOverrideTranslations(topLevel,
+- XtParseTranslationTable("<Message>WM_PROTOCOLS: Exit()"));
+-
+- /* Call UpdateStatusBox() before realizing the top-level widget so that
+- the status widget array in that function would be properly initialized
+- before the user is able to call hangup(), since the latter passes NULL
+- to UpdateStatusBox() */
+- UpdateStatusBox((XtPointer)status);
+-
+- XtSetMappedWhenManaged(topLevel, False);
+- XtRealizeWidget(topLevel);
+- XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL);
+- XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL);
+- if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL);
+-
+- /*
+- * (ideally one should not assume any fixed numbers, but this will do
+- * for now).
+- *
+- * width of message box = label width
+- * + 2*border width (2*1)
+- * + defaultDistance (right) (1)
+- * + horizDistance (left) (4)
+- *
+- * desired width of label = width of menu box
+- * - hSpace of menu box (2*4) (to align with buttons)
+- * - border with of label (2*1)
+- * = width of menu box - 10
+- *
+- * => width of message box = width of menu box - 10 + 7
+- * => width of message box < width of menu box
+- * => menu box width is the controlling factor in deciding the widnow
+- * width, as desired.
+- */
+- XtVaSetValues(statusMessage, XtNresizable, True, NULL);
+- XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL);
+- XtVaSetValues(statusMessage, XtNresizable, False, NULL);
+-
+- wm_delete_window = XInternAtom(XtDisplay(topLevel),
+- "WM_DELETE_WINDOW", False);
+- XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel),
+- &wm_delete_window, 1);
++ AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL);
++ }
++ }
++ if (n == 0) XtDestroyWidget(quickKeyBox);
++
++ XtOverrideTranslations(topLevel,
++ XtParseTranslationTable("<Message>WM_PROTOCOLS: Exit()"));
++
++ /* Call UpdateStatusBox() before realizing the top-level widget so that
++ the status widget array in that function would be properly initialized
++ before the user is able to call hangup(), since the latter passes NULL
++ to UpdateStatusBox() */
++ UpdateStatusBox((XtPointer)status);
++
++ XtSetMappedWhenManaged(topLevel, False);
++ XtRealizeWidget(topLevel);
++ XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL);
++ XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL);
++ if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL);
++
++ /*
++ * (ideally one should not assume any fixed numbers, but this will do
++ * for now).
++ *
++ * width of message box = label width
++ * + 2*border width (2*1)
++ * + defaultDistance (right) (1)
++ * + horizDistance (left) (4)
++ *
++ * desired width of label = width of menu box
++ * - hSpace of menu box (2*4) (to align with buttons)
++ * - border with of label (2*1)
++ * = width of menu box - 10
++ *
++ * => width of message box = width of menu box - 10 + 7
++ * => width of message box < width of menu box
++ * => menu box width is the controlling factor in deciding the widnow
++ * width, as desired.
++ */
++ XtVaSetValues(statusMessage, XtNresizable, True, NULL);
++ XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL);
++ XtVaSetValues(statusMessage, XtNresizable, False, NULL);
++
++ wm_delete_window = XInternAtom(XtDisplay(topLevel),
++ "WM_DELETE_WINDOW", False);
++ XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel),
++ &wm_delete_window, 1);
+ }
+
+ void
+ TopAbout(parent)
+- Widget parent;
++ Widget parent;
+ {
+- Widget popup,
+- mBox,
+- uBox,
+- lBox,
+- pic,
+- msg,
+- caption;
+- Pixmap pix;
+- Dimension width1,
+- width2;
+- char msgStr[LRG_BUF];
++ Widget popup,
++ mBox,
++ uBox,
++ lBox,
++ pic,
++ msg,
++ caption;
++ Pixmap pix;
++ Dimension width1,
++ width2;
++ char msgStr[LRG_BUF];
+ #include "authPic.h"
+
+- popup = SeAddPopup("about", parent);
+- mBox = SeAddPaned("mBox", popup);
+- uBox = SeAddBox("uBox", mBox);
+- lBox = SeAddBox("lBox", mBox);
+-
+- msg = SeAddLabel("msg", uBox);
+- pic = SeAddLabel("pic", uBox);
+- caption = SeAddLabel("caption", uBox);
++ popup = SeAddPopup("about", parent);
++ mBox = SeAddPaned("mBox", popup);
++ uBox = SeAddBox("uBox", mBox);
++ lBox = SeAddBox("lBox", mBox);
++
++ msg = SeAddLabel("msg", uBox);
++ pic = SeAddLabel("pic", uBox);
++ caption = SeAddLabel("caption", uBox);
+
+- sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION,
++ /* msgStr is big enough here */
++ sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION,
+ REVISION, "Copyright 1992-1993", "(c) Muhammad M. Saggaf",
+ "All rights reserved");
+- XtVaSetValues(msg, XtNlabel, msgStr, NULL);
++ XtVaSetValues(msg, XtNlabel, msgStr, NULL);
+
+- pix = XCreateBitmapFromData(XtDisplay(pic),
+- DefaultRootWindow(XtDisplay(pic)),
+- authPic_bits, authPic_width,
+- authPic_height);
+- XtVaSetValues(pic, XtNbitmap, pix, NULL);
+-
+- width1 = SeWidgetWidth(msg);
+- width2 = SeWidgetWidth(pic);
+- width1 = width1 > width2 ? width1 : width2;
+- width2 = SeWidgetWidth(caption);
+- width1 = width1 > width2 ? width1 : width2;
+-
+- XtVaSetValues(msg, XtNwidth, width1, NULL);
+- XtVaSetValues(pic, XtNwidth, width1, NULL);
+- XtVaSetValues(caption, XtNwidth, width1, NULL);
++ pix = XCreateBitmapFromData(XtDisplay(pic),
++ DefaultRootWindow(XtDisplay(pic)),
++ authPic_bits, authPic_width,
++ authPic_height);
++ XtVaSetValues(pic, XtNbitmap, pix, NULL);
++
++ width1 = SeWidgetWidth(msg);
++ width2 = SeWidgetWidth(pic);
++ width1 = width1 > width2 ? width1 : width2;
++ width2 = SeWidgetWidth(caption);
++ width1 = width1 > width2 ? width1 : width2;
++
++ XtVaSetValues(msg, XtNwidth, width1, NULL);
++ XtVaSetValues(pic, XtNwidth, width1, NULL);
++ XtVaSetValues(caption, XtNwidth, width1, NULL);
+
+- SeAddButton("dismiss", lBox, DestroyShell);
++ SeAddButton("dismiss", lBox, DestroyShell);
+
+- XtPopupSpringLoaded(popup);
++ XtPopupSpringLoaded(popup);
+ }
+
+ /*
+@@ -262,151 +270,151 @@
+
+ void
+ TopHelp(widget)
+- Widget widget;
++ Widget widget;
+ {
+- Widget DoDisplayFile();
+- Widget displayPopup;
++ Widget DoDisplayFile();
++ Widget displayPopup;
+
+- XtVaSetValues(widget, XtNsensitive, False, NULL);
+- displayPopup = DoDisplayFile(widget, qres.helpFile);
+- XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget);
++ XtVaSetValues(widget, XtNsensitive, False, NULL);
++ displayPopup = DoDisplayFile(widget, qres.helpFile);
++ XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget);
+
+- PositionShell(displayPopup, widget, SHELLPOS_HWFH);
+- XtPopup(displayPopup, XtGrabNone);
++ PositionShell(displayPopup, widget, SHELLPOS_HWFH);
++ XtPopup(displayPopup, XtGrabNone);
+ }
+
+ void
+ ExecHangup()
+ {
+- MdmHangup();
+- SeyonMessage("Line Disconnected");
++ MdmHangup();
++ SeyonMessage("Line Disconnected");
+ }
+
+ void
+ DoHangup(widget)
+- Widget widget;
++ Widget widget;
+ {
+- DestroyShell(widget);
+- ExecHangup();
++ DestroyShell(widget);
++ ExecHangup();
+ }
+
+ void
+ HangupConfirm(widget)
+- Widget widget;
++ Widget widget;
+ {
+- Widget popup,
+- dialog;
++ Widget popup,
++ dialog;
+
+- ErrorIfBusy()
++ ErrorIfBusy()
+
+- if (qres.hangupConfirm) {
+- popup = AddSimplePopup("hangup", widget);
+- dialog = SeAddDialog("dialog", popup);
++ if (qres.hangupConfirm) {
++ popup = AddSimplePopup("hangup", widget);
++ dialog = SeAddDialog("dialog", popup);
+
+- XawDialogAddButton(dialog, "yes", DoHangup, (XtPointer) dialog);
+- XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
++ XawDialogAddButton(dialog, "yes", DoHangup, (XtPointer) dialog);
++ XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
+
+- PopupCentered(popup, widget);
+- }
+- else
+- ExecHangup();
++ PopupCentered(popup, widget);
++ }
++ else
++ ExecHangup();
+ }
+
+ void
+ ExitNoHangup(widget)
+- Widget widget;
++ Widget widget;
+ {
+- DestroyShell(widget);
+- s_exit(widget);
++ DestroyShell(widget);
++ s_exit(widget);
+ }
+
+ void
+ ExitHangup(widget)
+- Widget widget;
++ Widget widget;
+ {
+- ExecHangup();
+- ExitNoHangup(widget);
++ ExecHangup();
++ ExitNoHangup(widget);
+ }
+
+ void
+ ExitConfirm(widget)
+- Widget widget;
++ Widget widget;
+ {
+- Widget popup,
+- dialog;
++ Widget popup,
++ dialog;
+
+- if (qres.exitConfirm && !qres.ignoreModemDCD && Online()) {
+- popup = AddSimplePopup("exit", widget);
+- dialog = SeAddDialog("dialog", popup);
++ if (qres.exitConfirm && !qres.ignoreModemDCD && Online()) {
++ popup = AddSimplePopup("exit", widget);
++ dialog = SeAddDialog("dialog", popup);
+
+- XawDialogAddButton(dialog, "yes", ExitHangup, NULL);
+- XawDialogAddButton(dialog, "no", ExitNoHangup, NULL);
+- XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
++ XawDialogAddButton(dialog, "yes", ExitHangup, NULL);
++ XawDialogAddButton(dialog, "no", ExitNoHangup, NULL);
++ XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
+
+- PopupCentered(popup, widget);
+- }
+- else
+- s_exit();
++ PopupCentered(popup, widget);
++ }
++ else
++ s_exit();
+ }
+
+ void
+ ExitAction(widget)
+- Widget widget;
++ Widget widget;
+ {
+- Boolean wExitButtonStatus;
++ Boolean wExitButtonStatus;
+
+- /* Prevent the user from exiting the program by f.delete if exiting
+- is not permitted */
+- XtVaGetValues(w_exit, XtNsensitive, &wExitButtonStatus, NULL);
+- ReturnIfTrue(!wExitButtonStatus);
+- s_exit();
++ /* Prevent the user from exiting the program by f.delete if exiting
++ is not permitted */
++ XtVaGetValues(w_exit, XtNsensitive, &wExitButtonStatus, NULL);
++ ReturnIfTrue(!wExitButtonStatus);
++ s_exit();
+ }
+
+ void
+ w_exit_up(w_exit_status)
+- Boolean w_exit_status;
++ Boolean w_exit_status;
+ {
+- XtVaSetValues(w_exit, XtNsensitive, w_exit_status, NULL);
++ XtVaSetValues(w_exit, XtNsensitive, w_exit_status, NULL);
+ }
+
+ void
+ SetKillButtonSens(killWidgetStatus)
+- Boolean killWidgetStatus;
++ Boolean killWidgetStatus;
+ {
+- XtVaSetValues(w_kill, XtNsensitive, killWidgetStatus, NULL);
+- w_exit_up(!killWidgetStatus);
++ XtVaSetValues(w_kill, XtNsensitive, killWidgetStatus, NULL);
++ w_exit_up(!killWidgetStatus);
+ }
+
+ void
+ w_kill_up(w_kill_status)
+- Boolean w_kill_status;
++ Boolean w_kill_status;
+ {
+- SetKillButtonSens(w_kill_status);
++ SetKillButtonSens(w_kill_status);
+ }
+
+ void
+ KillChildProc()
+ {
+- if (w_child_pid == 0) return;
+- if (kill(w_child_pid, SIGTERM) == 0) w_child_pid = 0;
++ if (w_child_pid == 0) return;
++ if (kill(w_child_pid, SIGTERM) == 0) w_child_pid = 0;
+ }
+
+ void
+ GetQuickKeyResources(quickKeyName, quickKeyRes)
+- String quickKeyName;
+- struct _quickKeyRes *quickKeyRes;
++ String quickKeyName;
++ struct _quickKeyRes *quickKeyRes;
+ {
+ #define offset(field) XtOffsetOf(struct _quickKeyRes, field)
+- static XtResource resources[] = {
+- {"visible", "Visible", XtRBoolean, sizeof(Boolean),
+- offset(visible), XtRImmediate, (XtPointer)False},
+- {"action", "Action", XtRString, sizeof(String),
+- offset(action), XtRString, (XtPointer)""},
+- };
++ static XtResource resources[] = {
++ {"visible", "Visible", XtRBoolean, sizeof(Boolean),
++ offset(visible), XtRImmediate, (XtPointer)False},
++ {"action", "Action", XtRString, sizeof(String),
++ offset(action), XtRString, (XtPointer)""},
++ };
+ #undef offset
+
+- XtGetSubresources(topLevel, (XtPointer)quickKeyRes, quickKeyName, "Command",
+- resources, XtNumber(resources), NULL, 0);
++ XtGetSubresources(topLevel, (XtPointer)quickKeyRes, quickKeyName, "Command",
++ resources, XtNumber(resources), NULL, 0);
+ }
+
+ void
+@@ -414,140 +422,140 @@
+ {
+ #define offset(field) XtOffsetOf(struct QueryResources, field)
+
+- static XtResource resources[] = {
+- {"modems", "Modems", XtRString, sizeof(String),
+- offset(modems), XtRString, (XtPointer)""},
+- {"script", "Script", XtRString, sizeof(String),
+- offset(script), XtRString, (XtPointer) NULL},
++ static XtResource resources[] = {
++ {"modems", "Modems", XtRString, sizeof(String),
++ offset(modems), XtRString, (XtPointer)""},
++ {"script", "Script", XtRString, sizeof(String),
++ offset(script), XtRString, (XtPointer) NULL},
+
+- {"defaultBPS", "DefaultBPS", XtRString, sizeof(String),
+- offset(defaultBPS), XtRString, (XtPointer) "9600"},
+- {"defaultBits", "DefaultBits", XtRInt, sizeof(int),
+- offset(defaultBits), XtRImmediate, (XtPointer) 8},
+- {"defaultParity", "DefaultParity", XtRInt, sizeof(int),
+- offset(defaultParity), XtRImmediate, (XtPointer) 0},
+- {"defaultStopBits", "DefaultStopBits", XtRInt, sizeof(int),
+- offset(defaultStopBits), XtRImmediate, (XtPointer) 1},
+- {"stripHighBit", "StripHighBit", XtRBoolean, sizeof(Boolean),
+- offset(stripHighBit), XtRImmediate, (XtPointer) False},
+- {"backspaceTranslation", "BackspaceTranslation", XtRBoolean,
+- sizeof(Boolean), offset(backspaceTranslation), XtRImmediate,
+- (XtPointer) False},
+- {"metaKeyTranslation", "MetaKeyTranslation", XtRBoolean,
+- sizeof(Boolean), offset(metaKeyTranslation), XtRImmediate,
+- (XtPointer) True},
+- {"xonxoffFlowControl", "XonxoffFlowControl", XtRBoolean,
+- sizeof(Boolean), offset(xonxoffFlowControl), XtRImmediate,
+- (XtPointer) False},
+- {"rtsctsFlowControl", "RtsctsFlowControl", XtRBoolean,
+- sizeof(Boolean), offset(rtsctsFlowControl), XtRImmediate,
+- (XtPointer) False},
+- {"newlineTranslation", "NewlineTranslation", XtRString,
+- sizeof(String), offset(newlineTranslation), XtRImmediate,
+- (XtPointer) "cr"},
+-
+- {"dialPrefix", "DialPrefix", XtRString, sizeof(String),
+- offset(dialPrefix), XtRString, (XtPointer) "ATDT"},
+- {"dialSuffix", "DialSuffix", XtRString, sizeof(String),
+- offset(dialSuffix), XtRString, (XtPointer) "^M"},
+- {"dialCancelString", "DialCancelString", XtRString, sizeof(String),
+- offset(dialCancelString), XtRString, (XtPointer) "^M"},
+-
+- {"dialTimeOut", "DialTimeOut", XtRInt, sizeof(int),
+- offset(dialTimeOut), XtRImmediate, (XtPointer) 45},
+- {"dialDelay", "DialDelay", XtRInt, sizeof(int),
+- offset(dialDelay), XtRImmediate, (XtPointer) 10},
+- {"dialRepeat", "DialRepeat", XtRInt, sizeof(int),
+- offset(dialRepeat), XtRImmediate, (XtPointer) 5},
+-
+- {"connectString", "ConnectString", XtRString, sizeof(String),
+- offset(connectString), XtRString, (XtPointer) "CONNECT"},
+- {"noConnectString1", "NoConnectString1", XtRString, sizeof(String),
+- offset(noConnectString[0]), XtRString, (XtPointer) "NO CARRIER"},
+- {"noConnectString2", "NoConnectString2", XtRString, sizeof(String),
+- offset(noConnectString[1]), XtRString, (XtPointer) "NO DIALTONE"},
+- {"noConnectString3", "NoConnectString3", XtRString, sizeof(String),
+- offset(noConnectString[2]), XtRString, (XtPointer) "BUSY"},
+- {"noConnectString4", "NoConnectString4", XtRString, sizeof(String),
+- offset(noConnectString[3]), XtRString, (XtPointer) "VOICE"},
+-
+- {"hangupBeforeDial", "HangupBeforeDial", XtRBoolean, sizeof(Boolean),
+- offset(hangupBeforeDial), XtRImmediate, (XtPointer)True},
+- {"dialAutoStart", "DialAutoStart", XtRBoolean, sizeof(Boolean),
+- offset(dialAutoStart), XtRImmediate, (XtPointer)False},
+- {"dialDirFormat", "DialDirFormat", XtRString, sizeof(String),
+- offset(dialDirFormat), XtRString,
+- (XtPointer)"%-15s %-15s %6s %1c%1c%1c %1c%1c %s"},
+- {"defaultPhoneEntries", "DefaultPhoneEntries", XtRString, sizeof(String),
+- offset(defaultPhoneEntries), XtRString, (XtPointer)NULL},
+-
+- {"startupAction", "StartupAction", XtRString, sizeof(String),
+- offset(startupAction), XtRString,
+- (XtPointer)"RunScript(startup);"},
+- {"postConnectAction", "PostConnectAction", XtRString, sizeof(String),
+- offset(postConnectAction), XtRString, (XtPointer)"Beep();"},
+-
+- {"autoZmodem", "AutoZmodem", XtRBoolean, sizeof(Boolean),
+- offset(autoZmodem), XtRImmediate, (XtPointer)True},
+- {"autoZmodemAction", "AutoZmodemAction", XtRString, sizeof(String),
+- offset(autoZmodemAction), XtRString,
+- (XtPointer)"ShellCommand($rz);"},
+-
+- {"modemVMin", "ModemVMin", XtRInt, sizeof(int),
+- offset(modemVMin), XtRImmediate, (XtPointer) 1},
+- {"ignoreModemDCD", "IgnoreModemDCD", XtRBoolean, sizeof(Boolean),
+- offset(ignoreModemDCD), XtRImmediate, (XtPointer) False},
+- {"hangupViaDTR", "HangupViaDTR", XtRBoolean, sizeof(Boolean),
+- offset(hangupViaDTR), XtRImmediate, (XtPointer)False},
+- {"modemAttentionString", "ModemAttentionString", XtRString, sizeof(String),
+- offset(modemAttentionString), XtRString, (XtPointer)"+++"},
+- {"modemHangupString", "ModemHangupString", XtRString, sizeof(String),
+- offset(modemHangupString), XtRString, (XtPointer)"ATH^M"},
+- {"hangupConfirm", "HangupConfirm", XtRBoolean, sizeof(Boolean),
+- offset(hangupConfirm), XtRImmediate, (XtPointer) True},
+- {"exitConfirm", "ExitConfirm", XtRBoolean, sizeof(Boolean),
+- offset(exitConfirm), XtRImmediate, (XtPointer) True},
+- {"neverBeep", "NeverBeep", XtRBoolean, sizeof(Boolean),
+- offset(neverBeep), XtRImmediate, (XtPointer)False},
+-
+- {"defaultDirectory", "DefaultDirectory", XtRString, sizeof(String),
+- offset(defaultDirectory), XtRString, (XtPointer) "~/.seyon"},
+- {"scriptDirectory", "scriptDirectory", XtRString, sizeof(String),
+- offset(scriptDirectory), XtRString, (XtPointer) NULL},
+- {"startupFile", "StartupFile", XtRString, sizeof(String),
+- offset(startupFile), XtRString, (XtPointer) "startup"},
+- {"phoneFile", "PhoneFile", XtRString, sizeof(String),
+- offset(phoneFile), XtRString, (XtPointer) "phonelist"},
+- {"protocolsFile", "ProtocolsFile", XtRString, sizeof(String),
+- offset(protocolsFile), XtRString, (XtPointer) "protocols"},
+- {"captureFile", "CaptureFile", XtRString, sizeof(String),
+- offset(captureFile), XtRString, (XtPointer) "capture"},
+- {"helpFile", "HelpFile", XtRString, sizeof(String),
+- offset(helpFile), XtRString, (XtPointer) HELPFILE},
+-
+- {"modemStatusInterval", "ModemStatusInterval", XtRInt, sizeof(int),
+- offset(modemStatusInterval), XtRImmediate, (XtPointer) 5},
+-
+- {"idleGuard", "IdleGuard", XtRBoolean, sizeof(Boolean),
+- offset(idleGuard), XtRImmediate, (XtPointer) False},
+- {"idleGuardInterval", "IdleGuardInterval", XtRInt, sizeof(int),
+- offset(idleGuardInterval), XtRImmediate, (XtPointer) 300},
+- {"idleGuardString", "IdleGuardString", XtRString, sizeof(String),
+- offset(idleGuardString), XtRImmediate, (XtPointer) " ^H"},
+-
+- {"showFunMessages", "ShowFunMessages", XtRBoolean, sizeof(Boolean),
+- offset(showFunMessages), XtRImmediate, (XtPointer) True},
+- {"funMessagesInterval", "FunMessagesInterval", XtRInt, sizeof(int),
+- offset(funMessagesInterval), XtRImmediate, (XtPointer) 15},
+- {"funMessages", "FunMessages", XtRStringArray, sizeof(String*),
+- offset(funMessages), XtRStringArray, (XtPointer) NULL},
+- };
++ {"defaultBPS", "DefaultBPS", XtRString, sizeof(String),
++ offset(defaultBPS), XtRString, (XtPointer) "9600"},
++ {"defaultBits", "DefaultBits", XtRInt, sizeof(int),
++ offset(defaultBits), XtRImmediate, (XtPointer) 8},
++ {"defaultParity", "DefaultParity", XtRInt, sizeof(int),
++ offset(defaultParity), XtRImmediate, (XtPointer) 0},
++ {"defaultStopBits", "DefaultStopBits", XtRInt, sizeof(int),
++ offset(defaultStopBits), XtRImmediate, (XtPointer) 1},
++ {"stripHighBit", "StripHighBit", XtRBoolean, sizeof(Boolean),
++ offset(stripHighBit), XtRImmediate, (XtPointer) False},
++ {"backspaceTranslation", "BackspaceTranslation", XtRBoolean,
++ sizeof(Boolean), offset(backspaceTranslation), XtRImmediate,
++ (XtPointer) False},
++ {"metaKeyTranslation", "MetaKeyTranslation", XtRBoolean,
++ sizeof(Boolean), offset(metaKeyTranslation), XtRImmediate,
++ (XtPointer) True},
++ {"xonxoffFlowControl", "XonxoffFlowControl", XtRBoolean,
++ sizeof(Boolean), offset(xonxoffFlowControl), XtRImmediate,
++ (XtPointer) False},
++ {"rtsctsFlowControl", "RtsctsFlowControl", XtRBoolean,
++ sizeof(Boolean), offset(rtsctsFlowControl), XtRImmediate,
++ (XtPointer) False},
++ {"newlineTranslation", "NewlineTranslation", XtRString,
++ sizeof(String), offset(newlineTranslation), XtRImmediate,
++ (XtPointer) "cr"},
++
++ {"dialPrefix", "DialPrefix", XtRString, sizeof(String),
++ offset(dialPrefix), XtRString, (XtPointer) "ATDT"},
++ {"dialSuffix", "DialSuffix", XtRString, sizeof(String),
++ offset(dialSuffix), XtRString, (XtPointer) "^M"},
++ {"dialCancelString", "DialCancelString", XtRString, sizeof(String),
++ offset(dialCancelString), XtRString, (XtPointer) "^M"},
++
++ {"dialTimeOut", "DialTimeOut", XtRInt, sizeof(int),
++ offset(dialTimeOut), XtRImmediate, (XtPointer) 45},
++ {"dialDelay", "DialDelay", XtRInt, sizeof(int),
++ offset(dialDelay), XtRImmediate, (XtPointer) 10},
++ {"dialRepeat", "DialRepeat", XtRInt, sizeof(int),
++ offset(dialRepeat), XtRImmediate, (XtPointer) 5},
++
++ {"connectString", "ConnectString", XtRString, sizeof(String),
++ offset(connectString), XtRString, (XtPointer) "CONNECT"},
++ {"noConnectString1", "NoConnectString1", XtRString, sizeof(String),
++ offset(noConnectString[0]), XtRString, (XtPointer) "NO CARRIER"},
++ {"noConnectString2", "NoConnectString2", XtRString, sizeof(String),
++ offset(noConnectString[1]), XtRString, (XtPointer) "NO DIALTONE"},
++ {"noConnectString3", "NoConnectString3", XtRString, sizeof(String),
++ offset(noConnectString[2]), XtRString, (XtPointer) "BUSY"},
++ {"noConnectString4", "NoConnectString4", XtRString, sizeof(String),
++ offset(noConnectString[3]), XtRString, (XtPointer) "VOICE"},
++
++ {"hangupBeforeDial", "HangupBeforeDial", XtRBoolean, sizeof(Boolean),
++ offset(hangupBeforeDial), XtRImmediate, (XtPointer)True},
++ {"dialAutoStart", "DialAutoStart", XtRBoolean, sizeof(Boolean),
++ offset(dialAutoStart), XtRImmediate, (XtPointer)False},
++ {"dialDirFormat", "DialDirFormat", XtRString, sizeof(String),
++ offset(dialDirFormat), XtRString,
++ (XtPointer)"%-15s %-15s %6s %1c%1c%1c %1c%1c %s"},
++ {"defaultPhoneEntries", "DefaultPhoneEntries", XtRString, sizeof(String),
++ offset(defaultPhoneEntries), XtRString, (XtPointer)NULL},
++
++ {"startupAction", "StartupAction", XtRString, sizeof(String),
++ offset(startupAction), XtRString,
++ (XtPointer)"RunScript(startup);"},
++ {"postConnectAction", "PostConnectAction", XtRString, sizeof(String),
++ offset(postConnectAction), XtRString, (XtPointer)"Beep();"},
++
++ {"autoZmodem", "AutoZmodem", XtRBoolean, sizeof(Boolean),
++ offset(autoZmodem), XtRImmediate, (XtPointer)True},
++ {"autoZmodemAction", "AutoZmodemAction", XtRString, sizeof(String),
++ offset(autoZmodemAction), XtRString,
++ (XtPointer)"ShellCommand($rz);"},
++
++ {"modemVMin", "ModemVMin", XtRInt, sizeof(int),
++ offset(modemVMin), XtRImmediate, (XtPointer) 1},
++ {"ignoreModemDCD", "IgnoreModemDCD", XtRBoolean, sizeof(Boolean),
++ offset(ignoreModemDCD), XtRImmediate, (XtPointer) False},
++ {"hangupViaDTR", "HangupViaDTR", XtRBoolean, sizeof(Boolean),
++ offset(hangupViaDTR), XtRImmediate, (XtPointer)False},
++ {"modemAttentionString", "ModemAttentionString", XtRString, sizeof(String),
++ offset(modemAttentionString), XtRString, (XtPointer)"+++"},
++ {"modemHangupString", "ModemHangupString", XtRString, sizeof(String),
++ offset(modemHangupString), XtRString, (XtPointer)"ATH^M"},
++ {"hangupConfirm", "HangupConfirm", XtRBoolean, sizeof(Boolean),
++ offset(hangupConfirm), XtRImmediate, (XtPointer) True},
++ {"exitConfirm", "ExitConfirm", XtRBoolean, sizeof(Boolean),
++ offset(exitConfirm), XtRImmediate, (XtPointer) True},
++ {"neverBeep", "NeverBeep", XtRBoolean, sizeof(Boolean),
++ offset(neverBeep), XtRImmediate, (XtPointer)False},
++
++ {"defaultDirectory", "DefaultDirectory", XtRString, sizeof(String),
++ offset(defaultDirectory), XtRString, (XtPointer) "~/.seyon"},
++ {"scriptDirectory", "scriptDirectory", XtRString, sizeof(String),
++ offset(scriptDirectory), XtRString, (XtPointer) NULL},
++ {"startupFile", "StartupFile", XtRString, sizeof(String),
++ offset(startupFile), XtRString, (XtPointer) "startup"},
++ {"phoneFile", "PhoneFile", XtRString, sizeof(String),
++ offset(phoneFile), XtRString, (XtPointer) "phonelist"},
++ {"protocolsFile", "ProtocolsFile", XtRString, sizeof(String),
++ offset(protocolsFile), XtRString, (XtPointer) "protocols"},
++ {"captureFile", "CaptureFile", XtRString, sizeof(String),
++ offset(captureFile), XtRString, (XtPointer) "capture"},
++ {"helpFile", "HelpFile", XtRString, sizeof(String),
++ offset(helpFile), XtRString, (XtPointer) HELPFILE},
++
++ {"modemStatusInterval", "ModemStatusInterval", XtRInt, sizeof(int),
++ offset(modemStatusInterval), XtRImmediate, (XtPointer) 5},
++
++ {"idleGuard", "IdleGuard", XtRBoolean, sizeof(Boolean),
++ offset(idleGuard), XtRImmediate, (XtPointer) False},
++ {"idleGuardInterval", "IdleGuardInterval", XtRInt, sizeof(int),
++ offset(idleGuardInterval), XtRImmediate, (XtPointer) 300},
++ {"idleGuardString", "IdleGuardString", XtRString, sizeof(String),
++ offset(idleGuardString), XtRImmediate, (XtPointer) " ^H"},
++
++ {"showFunMessages", "ShowFunMessages", XtRBoolean, sizeof(Boolean),
++ offset(showFunMessages), XtRImmediate, (XtPointer) True},
++ {"funMessagesInterval", "FunMessagesInterval", XtRInt, sizeof(int),
++ offset(funMessagesInterval), XtRImmediate, (XtPointer) 15},
++ {"funMessages", "FunMessages", XtRStringArray, sizeof(String*),
++ offset(funMessages), XtRStringArray, (XtPointer) NULL},
++ };
+
+ #undef offset
+
+- XtSetTypeConverter(XtRString, XtRStringArray, CvtStringToStringArray,
+- NULL, 0, XtCacheNone, NULL);
++ XtSetTypeConverter(XtRString, XtRStringArray, CvtStringToStringArray,
++ NULL, 0, XtCacheNone, NULL);
+
+- XtGetApplicationResources(topLevel, (XtPointer)&qres, resources,
+- XtNumber(resources), NULL, 0);
++ XtGetApplicationResources(topLevel, (XtPointer)&qres, resources,
++ XtNumber(resources), NULL, 0);
+ }
+--- seyon-2.20c.orig/SeDial.c
++++ seyon-2.20c/SeDial.c
+@@ -89,7 +89,7 @@
+ {XMapRaised(XtDisplay(widget), XtWindow(popup)); return;}
+
+ if (disItems[0] == NULL) {
+- strcpy(phoneFile, qres.phoneFile);
++ strncpy(phoneFile, qres.phoneFile, REG_BUF);
+ if (ReadParsePhoneFile(phoneFile, disItems) < 0) return;
+
+ form = XtParent(widget);
+@@ -328,7 +328,7 @@
+ Widget dialog = XtParent(widget);
+ char phoneNumber[SM_BUF];
+
+- strcpy(phoneNumber, XawDialogGetValueString(dialog));
++ strncpy(phoneNumber, XawDialogGetValueString(dialog), SM_BUF);
+ DestroyShell(dialog);
+ ExecManualDial(XtParent(GetShell(widget)), phoneNumber);
+ }
+@@ -341,7 +341,7 @@
+ inhibit_child = True;
+ manualDial = True;
+
+- strcpy(phone_number, phoneNumber);
++ strncpy(phone_number, phoneNumber, SM_BUF);
+
+ dialTry = 1;
+ PreProcessPrep();
+@@ -442,15 +442,15 @@
+ if ((ptr = (char*)strstr(raw, keyword)) != NULL) {
+ ptr += strlen(keyword);
+ if (strncmp(ptr, "CURRENT", 3)) {
+- strcpy(buf, ptr);
++ strncpy(buf, ptr, REG_BUF);
+ GetWord(buf, wrd);
+- strcpy(var, wrd);
++ strncpy(var, wrd, sizeof(*var));
+ }
+ else
+- strcpy(var, "CURRENT");
++ strncpy(var, "CURRENT", sizeof(*var));
+ }
+ else
+- strcpy(var, def);
++ strncpy(var, def, sizeof(*var));
+ }
+
+ void
+@@ -463,8 +463,8 @@
+ char svar[TIN_BUF],
+ sdef[TIN_BUF];
+
+- sprintf(svar, "%d", *var);
+- sprintf(sdef, "%d", def);
++ sprintf(svar, "%d", *var); /* safe */
++ sprintf(sdef, "%d", def); /* safe */
+
+ GetStrField(raw, keyword, svar, sdef);
+
+@@ -496,7 +496,7 @@
+ else {
+ signal(SIGALRM, SIG_DFL);
+ alarm(0);
+- strcpy(dialMsg, "TIMEOUT");
++ strncpy(dialMsg, "TIMEOUT", SM_BUF);
+ longjmp(dial_env, 1);
+ }
+ }
+@@ -514,6 +514,8 @@
+ *bufPtr,
+ dialString[REG_BUF];
+ int i,
++/* length, */
++ length_remaining,
+ k;
+
+ if (setjmp(dial_env) != 0) {
+@@ -534,8 +536,8 @@
+ if (!manualDial) {
+
+ itemName = ddItems[k]->name;
+- sprintf(dialString, "\r%s %s%s", ddItems[k]->prefix, ddItems[k]->number,
+- ddItems[k]->suffix);
++ strncpy(dialString, FmtString("\r%s %s%s", ddItems[k]->prefix,
++ ddItems[k]->number, ddItems[k]->suffix), REG_BUF);
+
+ if (mbaud(ddItems[k]->baud) < 0)
+ se_warningf("invalid BPS value in dialing directory: %s",
+@@ -552,14 +554,23 @@
+ }
+ else {
+ itemName = phone_number;
+- sprintf(dialString, "\r%s %s%s", qres.dialPrefix, phone_number,
+- qres.dialSuffix);
++ strncpy(dialString, FmtString("\r%s %s%s", qres.dialPrefix, phone_number,
++ qres.dialSuffix), REG_BUF);
+ }
+
++ length_remaining = SM_BUF;
+ if (dialTry == 1)
+- sprintf(dialMsg, "Dialing %s", itemName);
++ {
++ strncpy(dialMsg, "Dialing ", length_remaining);
++ length_remaining -= strlen("Dialing ");
++ strncat(dialMsg, itemName, length_remaining);
++ }
+ else
+- sprintf(dialMsg, "Redialing:%d %s", dialTry, itemName);
++ strncpy(dialMsg, "Redialing ", length_remaining);
++ length_remaining -= strlen("Redialing ");
++ sprintf(dialMsg, "%1.1d ", dialTry);
++ length_remaining -= 2;
++ strncat(dialMsg, itemName, length_remaining);
+
+ ProcRequest(SET_MESSAGE, "Setting Up...", "");
+
+@@ -589,7 +600,7 @@
+ for (i = 0; i < 3; i++)
+ if (*(bufPtr = StripSpace(qres.noConnectString[i])) &&
+ strncmp(modemResponse, bufPtr, strlen(bufPtr)) == 0) {
+- strcpy(dialMsg, modemResponse);
++ strncpy(dialMsg, modemResponse, SM_BUF);
+ longjmp(dial_env, 1);
+ }
+ } /* while(1)... */
+@@ -601,15 +612,20 @@
+ String disItems[];
+ {
+ FILE *fp;
++ FILE *devnull;
+ String rawItems[MAX_ENT + 1];
+ char *buf,
+ *sHold,
+ disItemsBuf[REG_BUF];
++ char filename[LRG_BUF];
+ int i,
+ n,
++ length,
+ iHold;
+
+- if ((fp = open_file(fname, qres.defaultDirectory)) == NULL)
++ strncpy(filename, fname, REG_BUF);
++
++ if ((fp = open_file(filename, REG_BUF, qres.defaultDirectory)) == NULL)
+ return -1;
+
+ ReadCommentedFile(fp, rawItems);
+@@ -623,11 +639,9 @@
+
+ /* Find the number */
+ GetWord(buf, ddItems[i]->number);
+-/* strcpy(ddItems[i]->number, GetFirstWord(buf));*/
+
+ /* Find the name */
+ GetWord((buf = lptr), ddItems[i]->name);
+-/* strcpy(ddItems[i]->name, GetNextWord());*/
+
+ /* Find other stuff */
+ GetStrField(buf, "BPS=", ddItems[i]->baud, qres.defaultBPS);
+@@ -643,8 +657,20 @@
+ FreeList(rawItems);
+ FreeList(disItems);
+
++ /* Ick... This is horrible - using a user-provided format string
++ means we have no easy way of limiting string length. HACK HACK
++ HACK Use fprintf to output to /dev/null and count the number of
++ bytes... It would be nice if we could rely on having snprintf() */
++
++ devnull = fopen("/dev/null", "r+");
++ if(NULL == devnull)
++ {
++ printf("Open /dev/null failed!?!\n");
++ return 1;
++ }
++
+ for (n = 0; n < i; n++) {
+- sprintf(disItemsBuf, qres.dialDirFormat,
++ length = fprintf(devnull, qres.dialDirFormat,
+ ddItems[n]->name,
+ ddItems[n]->number,
+ strncmp((sHold = ddItems[n]->baud), "CUR", 3) ? sHold : "????",
+@@ -658,10 +684,33 @@
+ strcmp(sHold, qres.dialSuffix) ? 'S' : 'D' : '?',
+ ddItems[n]->script);
+
+- disItemsBuf[SM_BUF - 1] = '\0';
+- disItems[n] = XtNewString(disItemsBuf);
++ if(REG_BUF >= length)
++ {
++ sprintf(disItemsBuf, qres.dialDirFormat,
++ ddItems[n]->name,
++ ddItems[n]->number,
++ strncmp((sHold = ddItems[n]->baud), "CUR", 3) ? sHold : "????",
++ (iHold = ddItems[n]->bits) == 100 ? '?' : itoa(iHold),
++ (iHold = ddItems[n]->parity) ? (iHold == 1 ? 'O' :
++ (iHold == 2 ? 'E' : '?')) : 'N',
++ (iHold = ddItems[n]->stopBits) == 100 ? '?' : itoa(iHold),
++ strncmp((sHold = ddItems[n]->prefix), "CUR", 3) ?
++ strcmp(sHold, qres.dialPrefix) ? 'P' : 'D' : '?',
++ strncmp((sHold = ddItems[n]->suffix), "CUR", 3) ?
++ strcmp(sHold, qres.dialSuffix) ? 'S' : 'D' : '?',
++ ddItems[n]->script);
++ disItemsBuf[SM_BUF - 1] = '\0';
++ disItems[n] = XtNewString(disItemsBuf);
++ }
++ else
++ {
++ printf("ReadParsePhoneFile: attempted overrun: %s\n",ddItems[n]->name);
++ fclose(devnull);
++ return 1;
++ }
+ }
+ disItems[n] = NULL;
++ fclose(devnull);
+
+ return 0;
+ }
+--- seyon-2.20c.orig/SePort.c
++++ seyon-2.20c/SePort.c
+@@ -51,7 +51,7 @@
+ #ifdef linux
+ #include <linux/serial.h>
+ #include <sys/ioctl.h>
+-#include <linux/fs.h>
++/* #include <linux/fs.h> */
+ #include <linux/tty.h>
+ #endif
+ #endif
+@@ -127,20 +127,30 @@
+
+ void
+ MdmPutString(s)
+- char *s;
++ char *s;
+ {
+- char c;
+-
+- usleep(MDELAY);
+- for (; (c = *s); s++) {
+- if (*s == '^' && *(s + 1))
+- if (*(++s) == '^') c = *s;
+- else c = *s & 0x1f;
++ char c;
+
+- if (c == '~') sleep(1);
+- else send_tbyte(c);
+ usleep(MDELAY);
+- }
++ for (; (c = *s); s++)
++ {
++ if (*s == '^' && *(s + 1))
++ {
++ if (*(++s) == '^')
++ {
++ c = *s;
++ }
++ else
++ {
++ c = *s & 0x1f;
++ }
++ }
++ if (c == '~')
++ sleep(1);
++ else
++ send_tbyte(c);
++ usleep(MDELAY);
++ }
+ }
+
+ void
+@@ -150,10 +160,7 @@
+ *b,
+ *c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- MdmPutString(buf);
++ MdmPutString(FmtString(fmt,a,b,c));
+ }
+
+ void
+@@ -224,7 +231,7 @@
+ int newModem;
+ {
+ static Boolean useModemControl = True;
+- int retStat;
++ int retStat = 0;
+
+ if (newModem) useModemControl = True;
+
+@@ -350,11 +357,11 @@
+
+ char *
+ mport(s) /* get/set port string */
+- char *s;
++ char *s;
+ {
+- if (s != NULL)
+- strcpy(modem_port, s);
+- return (modem_port);
++ if (s != NULL)
++ strncpy(modem_port, s, sizeof(modem_port));
++ return (modem_port);
+ }
+
+ int
+@@ -650,6 +657,17 @@
+ ser_io.flags |= ASYNC_SPD_VHI;
+ break;
+ #endif
++#else
++#ifdef B57600
++ case 57600:
++ baudrate = B57600;
++ break;
++#endif
++#ifdef B115200
++ case 115200:
++ baudrate = B115200;
++ break;
++#endif
+ #endif
+ default:
+ return (-1);
+@@ -702,6 +720,14 @@
+ #endif
+ #endif
+ return 38400;
++#ifdef B57600
++ case B57600:
++ return 57600;
++#endif
++#ifdef B115200
++ case B115200:
++ return 115200;
++#endif
+ }
+
+ SeError("Consistency error in baud rate");
+@@ -822,7 +848,7 @@
+ modemName, "", ""));
+ break;
+ default:
+- SeError(FmtString("Unknown Error While Openeong Modem ``%s''",
++ SeError(FmtString("Unknown Error While Opening Modem ``%s''",
+ modemName, "", ""));
+ break;
+ }
+@@ -946,16 +972,13 @@
+ }
+
+ void
+-sendf_slowly(format, a, b, c)
+- char *format,
++sendf_slowly(fmt, a, b, c)
++ char *fmt,
+ *a,
+ *b,
+ *c;
+ {
+- char buffer[SM_BUF];
+-
+- sprintf(buffer, format, a, b, c);
+- send_slowly(buffer);
++ send_slowly(FmtString(fmt,a,b,c));
+ }
+
+ void
+@@ -989,7 +1012,7 @@
+ LockModem(modem)
+ String modem;
+ {
+- strcpy(modem_port, modem);
++ strncpy(modem_port, modem, REG_BUF);
+ return lock_tty();
+ }
+
+@@ -1004,50 +1027,82 @@
+ int
+ lock_tty()
+ {
+- int lfd;
+- pid_t pid,
+- lckpid;
+- char *modemname;
++ int lfd;
++ pid_t pid,
++ lckpid;
++ char *modemname;
+ #if LF_USE_ASCII_PID
+- char pidstr[20],
+- lckpidstr[20];
+- int nb;
++ char pidstr[20],
++ lckpidstr[20];
++ int nb;
+ #endif
+ #if LF_USE_DEV_NUMBERS
+- struct stat mbuf;
++ struct stat mbuf;
+ #endif
+
+- /* Get our PID, and initialize the filename strings */
+- pid = getpid();
++ /* Get our PID, and initialize the filename strings */
++ pid = getpid();
+
+ #if !LF_USE_DEV_NUMBERS
+- modemname = strrchr(modem_port, '/');
+- sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX,
+- (modemname ? (modemname + 1) : modem_port));
++ modemname = strrchr(modem_port, '/');
++ if(modemname)
++ {
++ if( SM_BUF > (1 + strlen(LF_PATH) + strlen(LF_PREFIX) + strlen(modemname)))
++ sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX, (modemname + 1));
++ else
++ {
++ SePErrorF("Buffer too small for lock filename in lock_tty(): %s", modemname, "", "");
++ return -1;
++ }
++ }
++ else
++ {
++ if( SM_BUF > (1 + strlen(LF_PATH) + strlen(LF_PREFIX) + strlen(modem_port)))
++ sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX, (modem_port));
++ else
++ {
++ SePErrorF("Buffer too small for lock filename in lock_tty(): %s", modem_port, "", "");
++ return -1;
++ }
++ }
++
+ #else
+- if(stat(modem_port, &mbuf) < 0) {
+- SePErrorF("could not stat modem port %s", modem_port, "", "");
+- return -1;
+- }
+- sprintf(lckf,"%s/%s%03u.%03u.%03u", LF_PATH, LF_PREFIX, major(mbuf.st_dev),
+- major(mbuf.st_rdev), minor(mbuf.st_rdev));
++ if(stat(modem_port, &mbuf) < 0) {
++ SePErrorF("could not stat modem port %s", modem_port, "", "");
++ return -1;
++ }
++ if( SM_BUF > (10 + strlen(LF_PATH) + strlen(LF_PREFIX)))
++ sprintf(lckf,"%s/%s%03u.%03u.%03u", LF_PATH, LF_PREFIX, major(mbuf.st_dev),
++ major(mbuf.st_rdev), minor(mbuf.st_rdev));
++ else
++ {
++ SePErrorF("Buffer too small for lock filename in lock_tty():", "", "", "");
++ return -1;
++ }
+ #endif /* LF_USE_DEV_NUMBERS */
+
+- sprintf(ltmp, "%s/%s%d", LF_PATH, "LTMP.", pid);
+- /* Create the LTMP.<pid> file and scribble our PID in it */
+- unlink(ltmp);
+- if ((lfd = creat(ltmp, 0644)) == -1) {
+- SePErrorF("Could not create temporary lock file %s", ltmp, "", "");
+- return -1;
+- }
++ if( SM_BUF > (11 + strlen(LF_PATH)))
++ sprintf(ltmp, "%s/%s%d", LF_PATH, "LTMP.", pid);
++ else
++ {
++ SePErrorF("Buffer too small for ltmp filename in lock_tty():", "", "", "");
++ return -1;
++ }
++ /* Create the LTMP.<pid> file and scribble our PID in it */
++ unlink(ltmp);
++ if ((lfd = creat(ltmp, 0644)) == -1) {
++ SePErrorF("Could not create temporary lock file %s", ltmp, "", "");
++ return -1;
++ }
+
+ #if LF_USE_ASCII_PID
+- sprintf(pidstr, "%10d\n", pid);
+- write(lfd, pidstr, 11);
++ /* pidstr is easily large enough */
++ sprintf(pidstr, "%10d\n", pid);
++ write(lfd, pidstr, 11);
+ #else
+- write(lfd, (char*)&pid, sizeof(pid));
++ write(lfd, (char*)&pid, sizeof(pid));
+ #endif
+- close(lfd);
++ close(lfd);
+
+ /*
+ * Attempt to link directly - if it works, we're done.
+--- seyon-2.20c.orig/protocols
++++ seyon-2.20c/protocols
+@@ -6,7 +6,7 @@
+ # you have to use the resources
+ # zmodemAutoDownload and
+ # zmodemAutoDownloadCommand for that.
+-# see the manula page for more details.
++# see the manual page for more details.
+
+ # the format is simple.
+
+@@ -24,9 +24,9 @@
+
+ # you can put comments on a single line
+ # or at the end of a line
+-
+-regular_zmodem_dl "$ cd /usr/dl; rz -vv" n # like in here
+-
++#
++#regular_zmodem_dl "$ cd /usr/dl; rz -vv" n # like in here
++#
+ # blank lines are OK too, for readability.
+
+ # the title has to be either a single word, like the above
+@@ -34,21 +34,29 @@
+
+ # you put anything instead of y as long as it starts
+ # with y: y, Y, yes, yep ..etc.
+-
+-"regular zmodem ul" "$ cd /usr/src; sz -vv" y
+-
++#
++#"regular zmodem ul" "$ cd /usr/src; sz -vv" y
++#
+ # anything that doesn't start with a y is a no
+ # e.g. n, N, NO, Not, nope, nien, nono ..etc.
+ # even hello, but the use of words that doesn't start
+ # with n is highly discouraged
+-
+-graphic_zmodem_dl "cd /usr/dl; grz No
+-xrz3D "$cd /usr/dl; xrz" NO
+-
++#
++#graphic_zmodem_dl "cd /usr/dl; grz No
++#xrz3D "$cd /usr/dl; xrz" NO
++#
+ # here is my own protocols file
+ # notice how I make it clear to myself
+ # whether I'm uploading or downloading
+-
+-"SEND - Zmodem" "$cd /usr/src; sz -vv" y
+-"RECEIVE - Reg. Zmodem" "$cd /usr/dl; rz -vv" n
+-"RECEIVE - Xrz3D" "$cd /usr/dl; xrz" n
++#
++#"SEND - Zmodem" "$cd /usr/src; sz -vv" y
++#"RECEIVE - Reg. Zmodem" "$cd /usr/dl; rz -vv" n
++#"RECEIVE - Xrz3D" "$cd /usr/dl; xrz" n
++
++"Zmodem - RECEIVE" "$lrz" n
++"Ymodem - RECEIVE" "$lrb" n
++"Xmodem - RECEIVE" "$lrx" y
++
++"Zmodem - SEND" "$lsz" y
++"Ymodem - SEND" "$lsb" y
++"Xmodem - SEND" "$lsx" y
+--- seyon-2.20c.orig/SeErr.c
++++ seyon-2.20c/SeErr.c
+@@ -107,28 +107,26 @@
+
+ #ifdef notdef
+ void
+-SePopupWarningF(parent, fmt, a, b, c, d)
++SePopupWarningF(parent, fmt, a, b, c)
+ Widget parent;
+ String fmt,
+ a,
+ b,
+- c,
+- d;
++ c;
+ {
+ SePopupNoticeF(parent, 0, "Seyon Warning", DestroyParentPopup,
+- fmt, a, b, c, d);
++ fmt, a, b, c);
+ }
+
+ void
+-SePopupInitWarningF(parent, fmt, a, b, c, d)
++SePopupInitWarningF(parent, fmt, a, b, c)
+ Widget parent;
+ String fmt,
+ a,
+ b,
+- c,
+- d;
++ c;
+ {
+ SePopupNoticeF(parent, 0, "Seyon Initialization Warning",
+- DestroyParentPopup, fmt, a, b, c, d);
++ DestroyParentPopup, fmt, a, b, c);
+ }
+ #endif
+--- seyon-2.20c.orig/SeSubs.c
++++ seyon-2.20c/SeSubs.c
+@@ -45,9 +45,9 @@
+
+ void
+ toggle_flag(flag)
+- Boolean *flag;
++ Boolean *flag;
+ {
+- *flag = !*flag;
++ *flag = !*flag;
+ }
+
+ /*
+@@ -56,10 +56,10 @@
+
+ void
+ show(msg)
+- char *msg;
++ char *msg;
+ {
+- fprintf(tfp, "%s\r\n", msg);
+- fflush(tfp);
++ fprintf(tfp, "%s\r\n", msg);
++ fflush(tfp);
+ }
+
+ /*
+@@ -68,105 +68,96 @@
+
+ void
+ showf(fmt, a, b, c)
+- char *fmt,
+- *a,
+- *b,
+- *c;
++ char *fmt,
++ *a,
++ *b,
++ *c;
+ {
+- fprintf(tfp, fmt, a, b, c);
+- fprintf(tfp, "\r\n");
++ fprintf(tfp, fmt, a, b, c);
++ fprintf(tfp, "\r\n");
+ }
+
+ void
+ SeError(msg)
+- char *msg;
++ char *msg;
+ {
+- char buf[REG_BUF];
++ char buf[REG_BUF];
+
+- sprintf(buf, "\r>> Error: %s.", msg);
+- show(buf);
++ strncpy(buf, "\r>> Error: ",REG_BUF);
++ strncat(buf, msg, REG_BUF-12);
++ buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */
++ show(buf);
+ }
+
+ void
+ SeErrorF(fmt, a, b, c)
+- char *fmt,
+- *a,
+- *b,
+- *c;
++ char *fmt,
++ *a,
++ *b,
++ *c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SeError(buf);
++ SeError(FmtString(fmt, a, b, c));
+ }
+
+ void
+ se_warning(msg)
+- char *msg;
++ char *msg;
+ {
+- char buf[REG_BUF];
++ char buf[REG_BUF];
+
+- sprintf(buf, "\r>> Warning: %s.", msg);
+- show(buf);
++ strncpy(buf, "\r>> Warning: ",REG_BUF);
++ strncat(buf, msg, REG_BUF-14);
++ buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */
++ show(buf);
+ }
+
+ void
+ se_warningf(fmt, a, b, c)
+- char *fmt,
+- *a,
+- *b,
+- *c;
++ char *fmt,
++ *a,
++ *b,
++ *c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- se_warning(buf);
++ se_warning(FmtString(fmt, a, b, c));
+ }
+
+ void
+ SeNotice(msg)
+- char *msg;
++ char *msg;
+ {
+- char buf[REG_BUF];
++ char buf[REG_BUF];
+
+- sprintf(buf, "\r>> Notice: %s.", msg);
+- show(buf);
++ strncpy(buf, "\r>> Notice: ",REG_BUF);
++ strncat(buf, msg, REG_BUF-13);
++ buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */
++ show(buf);
+ }
+
+ void
+ SeNoticeF(fmt, a, b, c)
+- char *fmt,
+- *a,
+- *b,
+- *c;
++ char *fmt,
++ *a,
++ *b,
++ *c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SeNotice(buf);
++ SeNotice(FmtString(fmt, a, b, c));
+ }
+
+ void
+ SePError(msg)
+- char *msg;
++ char *msg;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, "%s: %s", msg, strerror(errno));
+- SeError(buf);
++ SeError(FmtString("%s: %s",msg,strerror(errno)));
+ }
+
+ void
+ SePErrorF(fmt, a, b, c)
+- char *fmt,
+- *a,
+- *b,
+- *c;
++ char *fmt,
++ *a,
++ *b,
++ *c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SePError(buf);
++ SePError(FmtString(fmt,a,b,c));
+ }
+
+ /* ------------------------------------------------------------
+@@ -180,12 +171,12 @@
+ int
+ SeFork()
+ {
+- pid_t pid;
++ pid_t pid;
+
+- if ((pid = fork()) < 0)
+- SePError("Faild to fork process");
++ if ((pid = fork()) < 0)
++ SePError("Faild to fork process");
+
+- return pid;
++ return pid;
+ }
+
+ /*
+@@ -194,119 +185,119 @@
+
+ void
+ ShellCommandHandler(sig, fio_p)
+- int sig;
+- XtPointer fio_p;
++ int sig;
++ XtPointer fio_p;
+ {
+- void PostExecPrep();
++ void PostExecPrep();
+
+- if (wait((int*)0) < 0) SePError("ShellCommand wait failed");
+- XoAppIgnoreSignal(app_con, SIGCHLD);
++ if (wait((int*)0) < 0) SePError("ShellCommand wait failed");
++ XoAppIgnoreSignal(app_con, SIGCHLD);
+
+- set_tty_mode();
+- set_modem_fio(*(int *)fio_p);
++ set_tty_mode();
++ set_modem_fio(*(int *)fio_p);
+
+- SeyonMessage("Shell Command Completed");
+- PostExecPrep();
+- inhibit_child = False;
++ SeyonMessage("Shell Command Completed");
++ PostExecPrep();
++ inhibit_child = False;
+ }
+
+ void
+ ShellCommand(command)
+- char *command;
++ char *command;
+ {
+- ExecShellCommand(command, 1);
++ ExecShellCommand(command, 1);
+ }
+
+ void
+ ExecShellCommand(command, top)
+- char *command;
+- int top;
++ char *command;
++ int top;
+ {
+- static char *shell = NULL;
+- char cmd[REG_BUF],
+- *scmd;
+- static int fio=0;
+- pid_t forkRes;
+-
+- if (command == NULL) return;
+-
+- if (shell == NULL) {
+- shell = (char*)getenv("SHELL");
+- if (!shell) shell = "/bin/sh";
+- }
+-
+- if (top) PreExecPrep();
+-
+- io_set_attr(tfd, &oldmode);
+- fio = get_modem_fio();
+-
+- if (top)
+- XoAppAddSignal(app_con, SIGCHLD, ShellCommandHandler, (XtPointer)&fio);
+- else signal(SIGCHLD, SIG_IGN);
+-
+- forkRes = SeFork();
+- if (forkRes == 0) {
+- scmd = str_stripspc_copy(cmd, command);
+-
+- show("");
+-
+- if (*scmd == '$') {
+- SeNotice("Redirecting stdin/stdout");
+- mattach(); /* Attach modem to stdin/stdout */
+- scmd++;
++ static char *shell = NULL;
++ char cmd[REG_BUF],
++ *scmd;
++ static int fio=0;
++ pid_t forkRes;
++
++ if (command == NULL) return;
++
++ if (shell == NULL) {
++ shell = (char*)getenv("SHELL");
++ if (!shell) shell = "/bin/sh";
+ }
+
+- if (setuid(getuid()) < 0)
+- SePError("Failed to set effective uid");
++ if (top) PreExecPrep();
+
+- if (*scmd == CNULL) {
+- SeNotice(FmtString1("Executing the shell `%s'", shell));
+- execl(shell, shell, (char*)NULL);
+- SeError(FmtString1("Execution of the shell `%s' failed", shell));
+- exit(1);
+- }
++ io_set_attr(tfd, &oldmode);
++ fio = get_modem_fio();
++
++ if (top)
++ XoAppAddSignal(app_con, SIGCHLD, ShellCommandHandler, (XtPointer)&fio);
++ else signal(SIGCHLD, SIG_IGN);
++
++ forkRes = SeFork();
++ if (forkRes == 0) {
++ scmd = str_stripspc_copy(cmd, command);
++
++ show("");
++
++ if (*scmd == '$') {
++ SeNotice("Redirecting stdin/stdout");
++ mattach(); /* Attach modem to stdin/stdout */
++ scmd++;
++ }
++
++ if (setuid(getuid()) < 0)
++ SePError("Failed to set effective uid");
++
++ if (*scmd == CNULL) {
++ SeNotice(FmtString1("Executing the shell `%s'", shell));
++ execl(shell, shell, (char*)NULL);
++ SeError(FmtString1("Execution of the shell `%s' failed", shell));
++ exit(1);
++ }
+
+- SeNotice(FmtString1("Executing the command `%s'", scmd));
+- execl(shell, shell, "-c", scmd, (char*)NULL);
+- SePError(FmtString1("Execution of the command `%s' failed", scmd));
+- exit(1);
+- }
+- else if (forkRes > 0) {
+- if (top) inhibit_child = True;
+- else {
++ SeNotice(FmtString1("Executing the command `%s'", scmd));
++ execl(shell, shell, "-c", scmd, (char*)NULL);
++ SePError(FmtString1("Execution of the command `%s' failed", scmd));
++ exit(1);
++ }
++ else if (forkRes > 0) {
++ if (top) inhibit_child = True;
++ else {
+ wait((int*)0); /* Wait for the child process to terminate */
+ set_tty_mode();
+ set_modem_fio(fio);
+- }
+- } /* if (forkRes == 0)... */
++ }
++ } /* if (forkRes == 0)... */
+ }
+
+ void
+ PreProcessPrep()
+ {
+- SuspContTerminal(TERM_SUSPEND);
+- SetKillButtonSens(True);
++ SuspContTerminal(TERM_SUSPEND);
++ SetKillButtonSens(True);
+ }
+
+ void
+ PostProcessPrep()
+ {
+- SuspContTerminal(TERM_CONTINUE);
+- SetKillButtonSens(False);
++ SuspContTerminal(TERM_CONTINUE);
++ SetKillButtonSens(False);
+ }
+
+ void
+ PreExecPrep()
+ {
+- SuspContTerminal(0);
+- w_exit_up(False);
++ SuspContTerminal(0);
++ w_exit_up(False);
+ }
+
+ void
+ PostExecPrep()
+ {
+- SuspContTerminal(1);
+- w_exit_up(True);
++ SuspContTerminal(1);
++ w_exit_up(True);
+ }
+
+ /*
+@@ -318,33 +309,34 @@
+ */
+
+ char *
+-expand_fname(fname, buffer)
+- char *fname,
+- *buffer;
+-{
+- char *home,
+- *buf,
+- name[REG_BUF];
+- int i;
+-
+- str_stripspc_copy(name, fname);
+- buf = buffer;
+-
+- for (i = 0; name[i]; i++) {
+- if (name[i] == '~') {
+- if ((home = (char *) getenv("HOME")) == NULL)
+- return NULL;
+- strcpy(buf, home);
+- buf += strlen(home);
++expand_fname(fname, buffer, size)
++ char *fname,
++ *buffer;
++ int size;
++{
++ char *home,
++ *buf,
++ name[REG_BUF];
++ int i;
++
++ str_stripspc_copy(name, fname);
++ buf = buffer;
++
++ for (i = 0; (name[i] && (buffer+REG_BUF > buf)); i++) {
++ if (name[i] == '~') {
++ if ((home = (char *) getenv("HOME")) == NULL)
++ return NULL;
++ strncpy(buf, home, size);
++ buf += strlen(home);
++ }
++ else {
++ *buf = name[i];
++ buf++;
++ }
+ }
+- else {
+- *buf = name[i];
+- buf++;
+- }
+- }
+- *buf = '\0';
++ *buf = '\0';
+
+- return buffer;
++ return buffer;
+ }
+
+ /*
+@@ -353,11 +345,12 @@
+ */
+
+ FILE*
+-open_file(fname, directory)
+- char *fname,
+- *directory;
++open_file(fname, size, directory)
++ char *fname;
++ int size;
++ char *directory;
+ {
+- return open_file_va(fname, directory, NULL);
++ return open_file_va(fname, size, directory, NULL);
+ }
+
+ /*
+@@ -365,120 +358,79 @@
+ */
+
+ FILE*
+-open_file_va(fname, dir1, dir2)
+- char *fname,
+- *dir1,
+- *dir2;
+-{
+- FILE *fp;
+- char name[REG_BUF],
+- fullname[REG_BUF],
+- buffer[REG_BUF];
+-
+- str_stripspc_copy(name, fname);
+-
+- if (dir1) {
+- sprintf(fullname, "%s/%s", expand_fname(dir1, buffer), name);
+-
+- if ((fp = fopen(fullname, "r")) != NULL) {
+- strcpy(fname, fullname);
+- return fp;
+- }
+-
+- if (dir2) {
+- sprintf(fullname, "%s/%s", expand_fname(dir2, buffer), name);
++open_file_va(fname, size, dir1, dir2)
++ char *fname;
++ int size;
++ char *dir1,
++ *dir2;
++{
++ FILE *fp;
++ char *fullname,
++ name[REG_BUF],
++ buffer[REG_BUF];
++
++ str_stripspc_copy(name, fname);
++
++ if (dir1) {
++ fullname = FmtString("%s/%s", expand_fname(dir1, buffer, REG_BUF), name, "");
++ if ((fp = fopen(fullname, "r")) != NULL) {
++ strncpy(fname, fullname, size);
++ return fp;
++ }
+
+- if ((fp = fopen(fullname, "r")) != NULL) {
+- strcpy(fname, fullname);
+- return fp;
+- }
++ if (dir2) {
++ fullname = FmtString("%s/%s", expand_fname(dir2, buffer, REG_BUF), name, "");
++ if ((fp = fopen(fullname, "r")) != NULL) {
++ strncpy(fname, fullname, size);
++ return fp;
++ }
++ }
++ } /* if (dir1)... */
++
++ if ((fp = fopen(name, "r")) != NULL) {
++ strncpy(fname, name, REG_BUF);
++ return fp;
+ }
+- } /* if (dir1)... */
+-
+- if ((fp = fopen(name, "r")) != NULL) {
+- strcpy(fname, name);
+- return fp;
+- }
+
+- SeErrorF("/OFV/ Could not open the file `%s'", name, "", "");
+- if (dir1) {
+- SeNoticeF("Tried the default directory `%s'", dir1, "", "");
+- if (dir2)
+- SeNoticeF("Tried the default directory `%s'", dir2, "", "");
+- }
+- SeNotice("Tried the current directory");
++ SeErrorF("/OFV/ Could not open the file `%s'", name, "", "");
++ if (dir1) {
++ SeNoticeF("Tried the default directory `%s'", dir1, "", "");
++ if (dir2)
++ SeNoticeF("Tried the default directory `%s'", dir2, "", "");
++ }
++ SeNotice("Tried the current directory");
+
+- return NULL;
++ return NULL;
+ }
+
+ /*
+- * another implementation of the above using varargs, currently not used
+- */
+-
+-/*FILE *open_file_va(args)
+- va_list args;
+- va_decl
+-{
+- FILE *fp;
+- char *name, *dir, fullname[REG_BUF];
+- char buffer[REG_BUF];
+-
+- va_start(args);
+- name = va_arg(args, char *);
+-
+- if (fp = fopen(name, "r"))
+- return fp;
+-
+- while(dir = va_arg(args, char *))
+- {
+- sprintf(fullname, "%s/%s", expand_fname(SSpc(dir), buffer), name);
+-
+- if (fp = fopen(fullname, "r"))
+- return fp;
+- }
+-
+- va_end(args);
+-
+- if (dir = (char *) getenv("HOME")) {
+- sprintf(fullname, "%s/%s", dir, name);
+-
+- if (fp = fopen(fullname, "r"))
+- return fp;
+- }
+-
+- showf("<< Seyon: file '%s' not in current, default, or home directory >>",
+- name, "", "");
+- return NULL;
+-}*/
+-
+-/*
+ * read a file into a buffer
+ */
+
+ void
+ read_file(fp, line)
+- FILE *fp;
+- char *line[];
++ FILE *fp;
++ char *line[];
+ {
+- char buffer[REG_BUF + 1];
+- int i;
++ char buffer[REG_BUF + 1];
++ int i;
+
+- for (i = 0; i < MAX_ENT && fgets(buffer, REG_BUF, fp) != NULL; i++)
+- line[i] = strcpy((char *)malloc(sizeof(buffer)), SSpc(buffer));
+- line[i] = NULL;
++ for (i = 0; i < MAX_ENT && fgets(buffer, REG_BUF, fp) != NULL; i++)
++ line[i] = strcpy((char *)malloc(sizeof(buffer)), SSpc(buffer));
++ line[i] = NULL;
+ }
+
+ /*
+- * similar to the above, but closes the file after readsing it
++ * similar to the above, but closes the file after reading it
+ */
+
+ void
+ read_close_file(fp, line)
+- FILE *fp;
+- char *line[];
++ FILE *fp;
++ char *line[];
+ {
+- read_file(fp, line);
+- fclose(fp);
++ read_file(fp, line);
++ fclose(fp);
+ }
+
+ /*
+@@ -487,12 +439,12 @@
+
+ void
+ write_pipe_data(pd, data, size)
+- int *pd;
+- char *data;
+- int size;
++ int *pd;
++ char *data;
++ int size;
+ {
+- if (write(pd[1], data, size) < 0)
+- show("<< Could not write to pipe >>");
++ if (write(pd[1], data, size) < 0)
++ show("<< Could not write to pipe >>");
+ }
+
+ /*
+@@ -501,11 +453,11 @@
+
+ void
+ read_pipe_data(pd, data, size)
+- int *pd;
+- char *data;
+- int size;
++ int *pd;
++ char *data;
++ int size;
+ {
+- read(pd[0], data, size);
++ read(pd[0], data, size);
+ }
+
+ /*
+@@ -515,30 +467,30 @@
+ void
+ IdleGuard()
+ {
+- struct stat statBuf;
+- time_t idleTime;
+- static time_t totalIdleTime;
+- int timeToNextCall;
+-
+- if (qres.idleGuard && !inhibit_child) {
+- if (fstat(tfd, &statBuf) < 0) {
+- SePError("/IG/ Could not stat the tty");
+- return;
+- }
++ struct stat statBuf;
++ time_t idleTime;
++ static time_t totalIdleTime;
++ int timeToNextCall;
++
++ if (qres.idleGuard && !inhibit_child) {
++ if (fstat(tfd, &statBuf) < 0) {
++ SePError("/IG/ Could not stat the tty");
++ return;
++ }
++
++ if ((idleTime = time((time_t *) 0) - statBuf.st_mtime) >=
++ qres.idleGuardInterval * 0.99) {
++ MdmPutString(qres.idleGuardString);
++ timeToNextCall = qres.idleGuardInterval;
++ totalIdleTime += idleTime;
++ SeyonMessagef("Idle for %d minutes", (totalIdleTime + 30) / 60);
++ }
++ else {
++ timeToNextCall = qres.idleGuardInterval - (int)idleTime;
++ totalIdleTime = 0;
++ }
+
+- if ((idleTime = time((time_t *) 0) - statBuf.st_mtime) >=
+- qres.idleGuardInterval * 0.99) {
+- MdmPutString(qres.idleGuardString);
+- timeToNextCall = qres.idleGuardInterval;
+- totalIdleTime += idleTime;
+- SeyonMessagef("Idle for %d minutes", (totalIdleTime + 30) / 60);
+- }
+- else {
+- timeToNextCall = qres.idleGuardInterval - (int)idleTime;
+- totalIdleTime = 0;
+- }
+-
+- XtAppAddTimeOut(app_con, timeToNextCall * 1000,
++ XtAppAddTimeOut(app_con, timeToNextCall * 1000,
+ (XtTimerCallbackProc) IdleGuard, (XtPointer) app_con);
+- }
++ }
+ }
+--- seyon-2.20c.orig/Seyon.c
++++ seyon-2.20c/Seyon.c
+@@ -72,314 +72,365 @@
+ pid_t mainPid;
+
+ int
+-main(argc, argv)
+- int argc;
+- char *argv[];
++main(int argc, char *argv[])
+ {
+- int OpenModem();
+- void DispatchActions(),
+- GetParameters(),
+- ShowOpenModemErrMsg();
+-
+- char *arg[REG_BUF], termEmu[REG_BUF];
+- int sepIndex, i, n, retStatus;
++ int OpenModem();
++ void DispatchActions(),
++ GetParameters(),
++ ShowOpenModemErrMsg();
++
++ char *arg[REG_BUF],
++ termEmu[REG_BUF];
++ int sepIndex,
++ i,
++ n,
++ length,
++ retStatus;
+ #ifdef HAVE_FAS
+- char large_string[1024];
++ char large_string[LRG_BUF];
+ #endif
+
+- XtAppContext appContext;
+- char modemList[LRG_BUF],
+- *curModem,
+- *startupAction = modemList;
++ int length_remaining;
++ XtAppContext appContext;
++ char modemList[LRG_BUF],
++ *curModem,
++ *startupAction = modemList;
+
+- static char *fallbackResources[] = {
++ static char *fallbackResources[] = {
+ #include "Seyon.ad.h"
+- NULL,
+- };
++ NULL,
++ };
+
+- static XrmOptionDescRec optionList[] = {
+- {"-modems", "modems", XrmoptionSepArg, NULL},
+- {"-script", "script", XrmoptionSepArg, NULL},
+- {"-entries", "defaultPhoneEntries", XrmoptionSepArg, NULL},
+- {"-dial", "dialAutoStart", XrmoptionNoArg, "True"},
+- {"-nodial", "dialAutoStart", XrmoptionNoArg, "False"},
+- {"-emulator", "emulator", XrmoptionSepArg, ""},
+- {"-noemulator", "noemulator", XrmoptionNoArg, ""},
+- {"-nodefargs", "nodefargs", XrmoptionNoArg, ""},
+- };
++ static XrmOptionDescRec optionList[] = {
++ {"-modems", "modems", XrmoptionSepArg, NULL},
++ {"-script", "script", XrmoptionSepArg, NULL},
++ {"-entries", "defaultPhoneEntries", XrmoptionSepArg, NULL},
++ {"-dial", "dialAutoStart", XrmoptionNoArg, "True"},
++ {"-nodial", "dialAutoStart", XrmoptionNoArg, "False"},
++ {"-emulator", "emulator", XrmoptionSepArg, ""},
++ {"-noemulator", "noemulator", XrmoptionNoArg, ""},
++ {"-nodefargs", "nodefargs", XrmoptionNoArg, ""},
++ };
+
+- for (i = 1; i < argc && strcmp(argv[i], "--"); i++);
+- sepIndex = i;
++ for (i = 1; i < argc && strcmp(argv[i], "--"); i++);
++ sepIndex = i;
+
+- /* Find if the -noemulator switch is given */
+- for (i = 1; i < sepIndex &&
++ /* Find if the -noemulator switch is given */
++ for (i = 1; i < sepIndex &&
+ strncmp(argv[i], "-noemulator", max(4, strlen(argv[i]))); i++);
+
+- /* If no, launch Seyon via the emulator */
+- if (i >= sepIndex) {
++ /* If no, launch Seyon via the emulator */
++ if (i >= sepIndex) {
+
+- for (i = 1; i < sepIndex &&
+- strncmp(argv[i], "-emulator", max(3, strlen(argv[i]))); i++);
+- if (i < sepIndex - 1)
+- strcpy(termEmu, argv[i+1]);
+- else
+- strcpy(termEmu, SEYON_EMU_NAME);
+-
+- /* Find if the -nodefargs switch is given */
+- for (i = 1; i < sepIndex &&
+- strncmp(argv[i], "-nodefargs", max(5, strlen(argv[i]))); i++);
++ for (i = 1; i < sepIndex &&
++ strncmp(argv[i], "-emulator", max(3, strlen(argv[i]))); i++);
++ if (i < sepIndex - 1)
++ strncpy(termEmu, argv[i+1], REG_BUF);
++ else
++ strncpy(termEmu, SEYON_EMU_NAME, REG_BUF);
++
++ /* Find if the -nodefargs switch is given */
++ for (i = 1; i < sepIndex &&
++ strncmp(argv[i], "-nodefargs", max(5, strlen(argv[i]))); i++);
+
+- n = 1;
++ n = 1;
+
+- /* If no, use the default emulator arguments */
+- if (i >= sepIndex) {
++ /* If no, use the default emulator arguments */
++ if (i >= sepIndex) {
+ arg[n] = "-name"; n++;
+ arg[n] = "Seyon"; n++;
+ arg[n] = "-T"; n++;
+ arg[n] = "Seyon Terminal Emulator"; n++;
+ arg[n] = "-n"; n++;
+ arg[n] = "Terminal"; n++;
+- }
++ }
+
+- /* Pass all switches aftetr '--' to the emulator */
+- for (i = sepIndex + 1; i < argc; i++, n++)
++ /* Pass all switches aftetr '--' to the emulator */
++ for (i = sepIndex + 1; i < argc; i++, n++)
+ arg[n] = argv[i];
+
+- arg[n] = "-e"; n++;
++ arg[n] = "-e"; n++;
+
+ #ifndef HAVE_FAS
+- arg[n] = argv[0]; n++;
+- arg[n] = "-noemulator"; n++;
++ arg[n] = argv[0]; n++;
++ arg[n] = "-noemulator"; n++;
+
+- /* Pass all switches before '--' to Seyon */
+- for (i = 1; i < sepIndex; i++, n++)
++ /* Pass all switches before '--' to Seyon */
++ for (i = 1; i < sepIndex; i++, n++)
+ arg[n] = argv[i];
+ #else
+- arg[n] = "/bin/sh"; n++;
+- arg[n] = "-c"; n++;
+- arg[n] = large_string;
+- strcpy(arg[n], argv[0]);
+- strcat(arg[n], " -noemulator");
+- for (i = 1; i < sepIndex; i++) {
+- strcat(arg[n]," ");
+- strcat(arg[n],argv[i]);
+- }
+- n++;
++ arg[n] = "/bin/sh"; n++;
++ arg[n] = "-c"; n++;
++ arg[n] = large_string;
++ length_remaining = LRG_BUF;
++ strncpy(arg[n], argv[0], LRG_BUF);
++ length_remaining -= strlen(argv[0]);
++ length = strlen(" -noemulator");
++ if(length_remaining > length)
++ {
++ strncat(arg[n], " -noemulator", length_remaining);
++ length_remaining -= length;
++ }
++ else
++ {
++ printf("String overflow in parsing options\n");
++ exit (1);
++ }
++ for (i = 1; i < sepIndex; i++) {
++ length = strlen(argv[i]) + 1;
++ if(length_remaining > length)
++ {
++ strncat(arg[n]," ", 1);
++ strncat(arg[n],argv[i], length_remaining);
++ }
++ else
++ {
++ printf("String overflow in parsing options\n");
++ exit (1);
++ }
++ }
++ n++;
+ #endif
+
+- arg[n] = NULL; n++;
++ arg[n] = NULL; n++;
+
+- arg[0] = termEmu;
+- execvp(arg[0], arg);
++ arg[0] = termEmu;
++ execvp(arg[0], arg);
+
+- fprintf(stderr, "%s `%s.\n%s\n", ">> Warning: Could not execute",
+- termEmu, ">> Notice: Falling to `xterm'.");
++ fprintf(stderr, "%s `%s.\n%s\n", ">> Warning: Could not execute",
++ termEmu, ">> Notice: Falling to `xterm'.");
+
+- arg[0] = "xterm";
+- execvp(arg[0], arg);
++ arg[0] = "xterm";
++ execvp(arg[0], arg);
+
+- fprintf(stderr, "%s\n%s\n", ">> Error: Could not execute `xterm'.",
+- ">> Notice: Giving up.");
+- exit(1);
+- } /* if (i >= sepIndex)... */
+-
+- /* ---------------------------------------------------------------------- */
+- /* ---------------------------------------------------------------------- */
+-
+- /* The real program begins here */
+-
+- topLevel = XtAppInitialize(&appContext, "Seyon", optionList,
+- XtNumber(optionList), &argc, argv,
+- fallbackResources, NULL, 0);
+- app_con = appContext;
+- GetResources(topLevel);
+-
+- mainPid = getpid();
+- setup_signal_handlers();
+- SetIcon(topLevel);
+-
+- printf("\r\n%s %s\r\n", "Seyon Copyright (c) 1992-1993 Muhammad M. Saggaf.",
+- "All rights reserved.");
+- printf("\rVersion %s rev. %s %s-%s %s@%s %s %s.\r\n\n", VERSION, REVISION,
+- COMPILE_HOSTTYPE, COMPILE_OSNAME, COMPILE_BY, COMPILE_HOST,
+- COMPILE_DATE, COMPILE_TIME);
+-
+- if ((tfp = fopen("/dev/tty", "r+")) == NULL) {
+- PopupInitError("errTtyAccess", exit);
+- goto MainLoop;
+- }
++ fprintf(stderr, "%s\n%s\n", ">> Error: Could not execute `xterm'.",
++ ">> Notice: Giving up.");
++ exit(1);
++ } /* if (i >= sepIndex)... */
++
++ /* ------------------------------------------------------------------ */
++ /* ------------------------------------------------------------------ */
++
++ /* The real program begins here */
++
++ topLevel = XtAppInitialize(&appContext, "Seyon", optionList,
++ XtNumber(optionList), &argc, argv,
++ fallbackResources, NULL, 0);
++ app_con = appContext;
++ GetResources(topLevel);
++
++ mainPid = getpid();
++ setup_signal_handlers();
++ SetIcon(topLevel);
++
++ printf("\r\n%s %s\r\n", "Seyon Copyright (c) 1992-1993 Muhammad M. Saggaf.",
++ "All rights reserved.");
++ printf("\rVersion %s rev. %s %s-%s %s@%s %s %s.\r\n\n", VERSION, REVISION,
++ COMPILE_HOSTTYPE, COMPILE_OSNAME, COMPILE_BY, COMPILE_HOST,
++ COMPILE_DATE, COMPILE_TIME);
++
++ if ((tfp = fopen("/dev/tty", "r+")) == NULL) {
++ PopupInitError("errTtyAccess", exit);
++ goto MainLoop;
++ }
+
+- tfd = fileno(tfp);
++ tfd = fileno(tfp);
+
+- io_get_attr(tfd, &oldmode); /* get current console tty mode */
+- newmode = oldmode; /* copy (structure) to newmode */
++ io_get_attr(tfd, &oldmode); /* get current console tty mode */
++ newmode = oldmode; /* copy (structure) to newmode */
+
+ #if HAVE_TERMIOS || HAVE_TERMIO
+- newmode.c_oflag &= ~OPOST;
+- newmode.c_iflag |= (IGNBRK | IGNPAR);
+- newmode.c_iflag &= ~(IXON | IXOFF | ISTRIP | BRKINT);
+- newmode.c_lflag &= ~(ICANON | ISIG | ECHO);
+- newmode.c_cflag |= CREAD;
+- newmode.c_cc[VMIN] = 1;
+- newmode.c_cc[VTIME] = 1;
++ newmode.c_oflag &= ~OPOST;
++ newmode.c_iflag |= (IGNBRK | IGNPAR);
++ newmode.c_iflag &= ~(IXON | IXOFF | ISTRIP | BRKINT);
++ newmode.c_lflag &= ~(ICANON | ISIG | ECHO);
++ newmode.c_cflag |= CREAD;
++ newmode.c_cc[VMIN] = 1;
++ newmode.c_cc[VTIME] = 1;
+ #else
+ #if HAVE_SGTTYB
+- newmode.sg_flags = CBREAK;
++ newmode.sg_flags = CBREAK;
+ #endif
+ #endif
+
+- set_tty_mode();
++ set_tty_mode();
+
+- InitVariables(topLevel);
++ InitVariables(topLevel);
+
+- if (argc > 1 && strcmp(argv[1], "--")) {
+- SeErrorF("Unknown or incomplete command-line switch: `%s'", argv[1],
+- "", "");
+- PopupInitError("errSwitches", do_exit);
+- goto MainLoop;
+- }
++ if (argc > 1 && strcmp(argv[1], "--")) {
++ SeErrorF("Unknown or incomplete command-line switch: `%s'", argv[1],
++ "", "");
++ PopupInitError("errSwitches", do_exit);
++ goto MainLoop;
++ }
+
+- /* ---------------------------------------------------------------------- */
++ /* ------------------------------------------------------------------- */
+
+- /* Open modem port and configure it */
++ /* Open modem port and configure it */
+
+- strcpy(modemList, qres.modems);
+- curModem = GetFirstWord(modemList);
++ strncpy(modemList, qres.modems, LRG_BUF);
++ curModem = GetFirstWord(modemList);
+
+- show("Locating Modems...");
++ show("Locating Modems...");
+
+- do {
+- if ((retStatus = OpenModem(curModem)) >= 0) break;
++ do {
++ if ((retStatus = OpenModem(curModem)) >= 0) break;
+
+- ShowOpenModemErrMsg(curModem, retStatus);
+- if (retStatus != ERR_MDM_NOMODEM)
++ ShowOpenModemErrMsg(curModem, retStatus);
++ if (retStatus != ERR_MDM_NOMODEM)
+ show(FmtString("Modem `%s' is Unavailable.\n", curModem, "", ""));
+- curModem = GetNextWord();
+- } while (curModem[0] != '\0');
+-
+- if (retStatus < 0) {
+- SeError("No Modems Available");
+- PopupInitError("errModemInit", do_exit);
+- goto MainLoop;
+- }
+-
+- show(FmtString("Modem `%s' is Available.\n", curModem, "", ""));
+-
+- /* ---------------------------------------------------------------------- */
+-
+- CreateCommandCenter();
+-
+- /* ---------------------------------------------------------------------- */
++ curModem = GetNextWord();
++ } while (curModem[0] != '\0');
+
+- pipe(child_pipe);
+- pipe(scriptToMainPipe);
+- pipe(mainToTermPipe);
+- XtAppAddInput(appContext, child_pipe[0], (XtPointer)XtInputReadMask,
+- ExecProcRequest, NULL);
+- XtAppAddInput(appContext, scriptToMainPipe[0], (XtPointer)XtInputReadMask,
+- GetParameters, NULL);
++ if (retStatus < 0) {
++ SeError("No Modems Available");
++ PopupInitError("errModemInit", do_exit);
++ goto MainLoop;
++ }
++
++ show(FmtString("Modem `%s' is Available.\n", curModem, "", ""));
++
++ /* ------------------------------------------------------------------- */
++
++ CreateCommandCenter();
++
++ /* ------------------------------------------------------------------- */
++
++ pipe(child_pipe);
++ pipe(scriptToMainPipe);
++ pipe(mainToTermPipe);
++ XtAppAddInput(appContext, child_pipe[0], (XtPointer)XtInputReadMask,
++ ExecProcRequest, NULL);
++ XtAppAddInput(appContext, scriptToMainPipe[0], (XtPointer)XtInputReadMask,
++ GetParameters, NULL);
++
++ IdleGuard();
++ if (qres.showFunMessages)
++ XtAppAddTimeOut(appContext, qres.funMessagesInterval*1000,
++ FunMessage, NULL);
++
++ /* ------------------------------------------------------------------- */
++
++ length_remaining = LRG_BUF;
++ strncpy(startupAction, qres.startupAction, LRG_BUF);
++ length_remaining -= strlen(startupAction);
++ if (qres.script)
++ {
++ length = strlen(" RunScript();") + strlen(qres.script);
++ if (length_remaining > length)
++ {
++ sprintf(startupAction + strlen(startupAction),
++ " RunScript(%s);", qres.script);
++ length_remaining -= length;
++ }
++ else
++ {
++ printf("String overflow in parsing options\n");
++ exit (1);
++ }
++ }
++ if (qres.dialAutoStart)
++ {
++ length = strlen(" DialEntries(Default);");
++ if(length_remaining > length)
++ {
++ strncat(startupAction, " DialEntries(Default);", length);
++ length -= length;
++ }
++ else
++ {
++ printf("String overflow in parsing options\n");
++ exit (1);
++ }
++ }
++
++ /* ------------------------------------------------------------------- */
+
+- IdleGuard();
+- if (qres.showFunMessages) XtAppAddTimeOut(appContext,
+- qres.funMessagesInterval*1000, FunMessage, NULL);
++ linkflag = 2;
++ ProcRequest(DISPATCH_ACTION, "", startupAction);
+
+- /* ---------------------------------------------------------------------- */
++ /* ------------------------------------------------------------------- */
+
+- strcpy(startupAction, qres.startupAction);
+- if (qres.script) sprintf(startupAction + strlen(startupAction),
+- " RunScript(%s);", qres.script);
+- if (qres.dialAutoStart) strcat(startupAction, " DialEntries(Default);");
+-
+- /* ---------------------------------------------------------------------- */
+-
+- linkflag = 2;
+- ProcRequest(DISPATCH_ACTION, "", startupAction);
+-
+- /* ---------------------------------------------------------------------- */
+-
+- XtSetMappedWhenManaged(topLevel, True);
+- XtMapWidget(topLevel); /* I don't know why I need this, but I do */
++ XtSetMappedWhenManaged(topLevel, True);
++ XtMapWidget(topLevel); /* I don't know why I need this, but I do */
+
+ MainLoop:
+- XtAppMainLoop(app_con);
+- return 0;
++ XtAppMainLoop(app_con);
++ return 0;
+ }
+
+ void
+-setup_signal_handlers()
++setup_signal_handlers(void)
+ {
+- signal(SIGINT, SIG_IGN);
+- signal(SIGQUIT, SIG_IGN);
++ signal(SIGINT, SIG_IGN);
++ signal(SIGQUIT, SIG_IGN);
+
+ #ifdef SIGBUS
+- signal(SIGBUS, die);
++ signal(SIGBUS, die);
+ #endif
+- signal(SIGFPE, die);
+- signal(SIGILL, die);
+- signal(SIGIOT, die);
+- signal(SIGSEGV, die);
+- signal(SIGTERM, die);
+- signal(SIGTRAP, die);
++ signal(SIGFPE, die);
++ signal(SIGILL, die);
++ signal(SIGIOT, die);
++ signal(SIGSEGV, die);
++ signal(SIGTERM, die);
++ signal(SIGTRAP, die);
+ }
+
+ void
+-die(sig)
+- int sig;
++die(int sig)
+ {
+- void KillChildProc();
+- signal(sig, SIG_IGN);
++ void KillChildProc();
++ signal(sig, SIG_IGN);
+
+- SeErrorF("Killed by signal %d", sig, "", "");
+- SeNoticeF("Debugging info: pid=%d.", getpid(), "", "");
++ SeErrorF("Killed by signal %d", sig, "", "");
++ SeNoticeF("Debugging info: pid=%d.", getpid(), "", "");
+
+- if (getpid() == mainPid) {
+- KillTerminal();
+- KillChildProc();
++ if (getpid() == mainPid) {
++ KillTerminal();
++ KillChildProc();
+
+- SeNotice("Press any key to exit");
+- getchar();
+- cleanup_exit(1);
+- }
+- else {
+- write_child_info(child_pipe, KILL_TERM, "Terminal Proc Exited");
+- exit(1);
+- }
++ SeNotice("Press any key to exit");
++ getchar();
++ cleanup_exit(1);
++ }
++ else {
++ write_child_info(child_pipe, KILL_TERM, "Terminal Proc Exited");
++ exit(1);
++ }
+ }
+
+ void
+-do_exit(rc)
+- int rc;
++do_exit(int rc)
+ {
+- void KillChildProc();
++ void KillChildProc();
+
+- XtUnmapWidget(topLevel);
+- KillTerminal();
+- KillChildProc();
++ XtUnmapWidget(topLevel);
++ KillTerminal();
++ KillChildProc();
+
+- unlock_tty();
++ unlock_tty();
+
+- fflush(tfp);
+- restore_orig_mode();
+- fclose(tfp);
++ fflush(tfp);
++ restore_orig_mode();
++ fclose(tfp);
+
+- CloseModem();
++ CloseModem();
+
+- XtDestroyApplicationContext(XtWidgetToApplicationContext(topLevel));
++ XtDestroyApplicationContext(XtWidgetToApplicationContext(topLevel));
+ /* XCloseDisplay(XtDisplay(topLevel));*/
+- exit(rc);
++ exit(rc);
+ }
+
+ void
+-cleanup_exit(status)
+- int status;
++cleanup_exit(int status)
+ {
+- SeNotice("cleaning up..");
+- do_exit(status);
++ SeNotice("cleaning up..");
++ do_exit(status);
+ }
+
+ void
+ s_exit()
+ {
+- show("I'm rated PG-34!!");
+- do_exit(0);
++ show("I'm rated PG-34!!");
++ do_exit(0);
+ }
+--- seyon-2.20c.orig/SeTrans.c
++++ seyon-2.20c/SeTrans.c
+@@ -51,7 +51,7 @@
+ ErrorIfBusy();
+
+ if (disItems[0] == NULL) {
+- strcpy(protocolsFile, qres.protocolsFile);
++ strncpy(protocolsFile, qres.protocolsFile, REG_BUF);
+ if (ReadParseProtFile(protocolsFile, disItems) < 0)
+ return;
+ }
+@@ -81,39 +81,47 @@
+
+ void
+ DoTransfer(widget, clientData, callData)
+- Widget widget;
+- XtPointer clientData,
+- callData;
+-{
+- XfwfMultiListReturnStruct *item;
+- Widget popup;
+- String* actionData = (String*)clientData;
+- char fullCommand[LRG_BUF];
+-
+- if (clientData)
+- {if ((transCurItemIndex = atoi(actionData[0]) - 1) < 0 ||
+- transCurItemIndex > MAX_ENT - 1)
+- SimpleError("Invalid Entry Number");}
+- else {
+- if ((item = XfwfMultiListGetHighlighted(mlw))->num_selected == 0)
++ Widget widget;
++ XtPointer clientData,
++ callData;
++{
++ XfwfMultiListReturnStruct *item;
++ Widget popup;
++ String* actionData = (String*)clientData;
++ char fullCommand[LRG_BUF];
++ int length_remaining;
++
++ if (clientData)
++ {if ((transCurItemIndex = atoi(actionData[0]) - 1) < 0 ||
++ transCurItemIndex > MAX_ENT - 1)
++ SimpleError("Invalid Entry Number");}
++ else {
++ if ((item = XfwfMultiListGetHighlighted(mlw))->num_selected == 0)
+ SimpleError("No Item Selected");
+- transCurItemIndex = item->selected_items[0];
+- }
++ transCurItemIndex = item->selected_items[0];
++ }
+
+- strcpy(fullCommand, protItems[transCurItemIndex]->command);
++ strncpy(fullCommand, protItems[transCurItemIndex]->command, LRG_BUF);
+
+- if (protItems[transCurItemIndex]->reqName)
+- if (actionData == NULL || actionData[1] == NULL) {
++ if (protItems[transCurItemIndex]->reqName)
++ {
++ if (actionData == NULL || actionData[1] == NULL)
++ {
+ popup = GetShell(PopupDialogGetValue("upload", widget, exec_upload,
+- NULL, lastUploadFile));
++ NULL, lastUploadFile));
+ PopupCentered(popup, (clientData) ? XtParent(GetShell(widget)) : widget);
+ return;
+- }
+- else
+- strcat(strcat(fullCommand, " "), actionData[1]);
+-
+- DestroyShell(widget);
+- ShellCommand(fullCommand);
++ }
++ else
++ {
++ length_remaining = LRG_BUF - strlen(fullCommand);
++ strncat(fullCommand, " ", length_remaining);
++ length_remaining -= 1;
++ strncat(fullCommand, actionData[1], length_remaining);
++ }
++ }
++ DestroyShell(widget);
++ ShellCommand(fullCommand);
+ }
+
+ void
+@@ -133,11 +141,11 @@
+ Widget widget;
+ {
+ Widget dialog = XtParent(widget);
+- static char cmd[REG_BUF];
++ static char *cmd;
+
+- strcpy(lastUploadFile, XawDialogGetValueString(dialog));
+- sprintf(cmd, "%s %s", protItems[transCurItemIndex]->command,
+- lastUploadFile);
++ strncpy(lastUploadFile, XawDialogGetValueString(dialog), REG_BUF);
++ cmd = FmtString("%s %s", protItems[transCurItemIndex]->command,
++ lastUploadFile, "");
+
+ DestroyShell(XtParent(GetShell(widget)));
+ ShellCommand(cmd);
+--- seyon-2.20c.orig/Seyon-co.ad
++++ seyon-2.20c/Seyon-co.ad
+@@ -13,26 +13,30 @@
+ *foreground: black
+ *borderColor: white
+
++*background: blue
++*foreground: black
++*borderColor: lightBlue
++
+ *Command.background: lightBlue
+-*Scrollbar.background: darkSeaGreen
+-*Toggle.background: darkOliveGreen
+-*Toggle.foreground: darkTurquoise
+-*List.background: grey
+-*XfwfMultiList.background: grey
+-*Text*background: grey
+-*Text*Scrollbar.background: darkSeaGreen
++*Scrollbar.background: cyan
++*Toggle.background: cyan
++*Toggle.foreground: black
++*List.background: tan
++*XfwfMultiList.background: tan
++*Text*background: tan
++*Text*Scrollbar.background: cyan
+
+ *ok.background: green
+-*cancel.background: tomato
++*cancel.background: red
+ *dismiss.background: orange
+-*hangup.background: orange
+-*exit.background: tomato
+-*kill.background: tomato
++*hangup.background: red
++*exit.background: red
++*kill.background: red
+
+-*about*msg.background: grey
+-*about*pic.background: grey
++*about*msg.background: tan
++*about*pic.background: tan
+
+-*messageBox.message.background: grey
++*messageBox.message.background: tan
+
+-*quickKeyBox.Command.background: darkOliveGreen
+-*quickKeyBox.Command.foreground: darkTurquoise
++*quickKeyBox.Command.background: orange
++*quickKeyBox.Command.foreground: black
+--- seyon-2.20c.orig/config.h
++++ seyon-2.20c/config.h
+@@ -302,7 +302,7 @@
+ * HDB uucp does) rather than in binary form as other uucp prgrams do
+ */
+ #ifndef LF_USE_ASCII_PID
+-#define LF_USE_ASCII_PID NO
++#define LF_USE_ASCII_PID YES
+ #endif
+
+ /*
+@@ -319,7 +319,7 @@
+ */
+
+ #ifndef LF_PATH
+-#define LF_PATH "/usr/spool/uucp"
++#define LF_PATH "/var/lock"
+ #endif
+
+ /*
+--- seyon-2.20c.orig/Imakefile
++++ seyon-2.20c/Imakefile
+@@ -48,14 +48,16 @@
+ InstallNonExecFile(seyon.help,$(LIBDIR))
+
+ install::
++/*
+ @if [ ! -d $(HOME)/.seyon ]; then mkdir $(HOME)/.seyon; fi; \
+ echo "=== Copying example files (no overwrite) to $(HOME)/.seyon ..."; \
+ for i in phonelist protocols startup script.*; do \
+ if [ ! -f $(HOME)/.seyon/$$i ]; then cp $$i $(HOME)/.seyon; fi;\
+ done;
++*/
+
+ clean::
+- rm -f version.h y.tab.* SeParse.c
++ rm -f version.h y.tab.* SeParse.c Seyon.ad.h
+
+ Seyon.c: Seyon.ad.h version.h
+
+@@ -66,7 +68,7 @@
+ rm -f version.h
+
+ version.h:
+- ./makever.sh
++ sh ./makever.sh
+
+ SeScan.o: y.tab.h
+
+--- seyon-2.20c.orig/makever.sh
++++ seyon-2.20c/makever.sh
+@@ -48,9 +48,9 @@
+ echo "#define VERSION \"$VERSION\"" >> version.h
+ echo "#define REVISION \"$REVISION\"" >> version.h
+
+-echo "#ifdef IS_MAIN" >> version.h
+-echo "static char version[] = \"\$Revision: $VERSION.$REVISION \$\";"\
+- >> version.h
+-echo "#endif" >> version.h
++#echo "#ifdef IS_MAIN" >> version.h
++#echo "static char version[] = \"\$Revision: $VERSION.$REVISION \$\";"\
++# >> version.h
++#echo "#endif" >> version.h
+
+ echo "Machine type is $machine, OS name is $system"
+--- seyon-2.20c.orig/SeScan.c
++++ seyon-2.20c/SeScan.c
+@@ -95,8 +95,8 @@
+ SC_OUTSIDE,
+ };
+
+-static ScanState = SC_OUTSIDE;
+-static ScanDelim = 0; /* Current string delimiter */
++static int ScanState = SC_OUTSIDE;
++static int ScanDelim = 0; /* Current string delimiter */
+
+ void NEW_STATE(st)
+ int st;
+@@ -290,8 +290,8 @@
+ #ifdef TEST
+ main()
+ {
+- scSetInputBuf("Just to see if we'\\'re \\n\\033 able to distinguish' words and strings
+-\"Also 'quotes' inside strings\" and 'strs \"inside quotes\"'
++ scSetInputBuf("Just to see if we'\\'re \\n\\033 able to distinguish' words and strings\n\
++\"Also 'quotes' inside strings\" and 'strs \"inside quotes\"'\n\
+ Not to forget ^S and ^q control ^ chars");
+
+ while (lGetWord() != 0);
+--- seyon-2.20c.orig/SeSubsX.c
++++ seyon-2.20c/SeSubsX.c
+@@ -70,7 +70,8 @@
+
+ if (onlineTime != oldOnlineTime) {
+ oldOnlineTime = onlineTime;
+- sprintf(buf, "%02d:%02d", onlineTime / 60, onlineTime % 60);
++ /* Buffer is easily big enough */
++ sprintf(buf, "%02ld:%02ld", onlineTime / 60, onlineTime % 60);
+ SeSetLabel(statusWidget[0], buf);
+ }
+
+@@ -91,6 +92,7 @@
+ msg = qres.funMessages[msg_index++];
+ if (msg == NULL) {
+ msg_index = 0;
++ /* Buffer is easily big enough */
+ sprintf(vermsg, "Welcome to Seyon version %s.%s", VERSION, REVISION);
+ msg = vermsg;
+ }
+@@ -171,7 +173,8 @@
+
+ procRequest.action = action;
+
+- if (msg) strcpy(procRequest.msg, msg);
++ if (msg)
++ strncpy(procRequest.msg, msg, 80);
+ else *procRequest.msg = '\0';
+
+ write_pipe_data(pd, &procRequest, sizeof(procRequest));
+@@ -186,8 +189,8 @@
+ struct _procRequest procRequest;
+
+ procRequest.action = action;
+- strcpy(procRequest.msg, msg);
+- strcpy(procRequest.arg, arg);
++ strncpy(procRequest.msg, msg, 80);
++ strncpy(procRequest.arg, arg, 90);
+
+ write_pipe_data(child_pipe, &procRequest, sizeof(procRequest));
+ }
+@@ -201,10 +204,7 @@
+ *b,
+ *c;
+ {
+- char buffer[SM_BUF];
+-
+- sprintf(buffer, fmt, a, b, c);
+- write_child_info(pd, action, buffer);
++ write_child_info(pd, action, FmtString(fmt,a,b,c));
+ }
+
+ void
+@@ -222,10 +222,7 @@
+ b,
+ c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SeyonMessage(buf);
++ SeyonMessage(FmtString(fmt,a,b,c));
+ }
+
+ Boolean
+--- seyon-2.20c.orig/SeActions.c
++++ seyon-2.20c/SeActions.c
+@@ -28,6 +28,7 @@
+ /* SeDecl.h includes stdio.h */
+ #include "SeDecl.h"
+ #include "version.h"
++#include "config.h"
+
+ #define CheckNumParam(num) {if (*numParam != num) \
+ SimpleError("Wrong Number of Parameters");}
+@@ -234,7 +235,7 @@
+ Cardinal* numParam;
+ {
+ int IconifyShell();
+- Widget dirWidget;
++/* Widget dirWidget; */
+ static String termWindowId = NULL;
+ int i;
+
+@@ -312,10 +313,18 @@
+ Cardinal* numParam;
+ {
+ void s_set();
++ int length;
++ int length_remaining;
+
+ ErrorIfBusy();
+ CheckNumParam(2);
+- sprintf((lptr = line), "%s %s", param[0], param[1]);
++
++ length_remaining = WBSIZE;
++ length = 1 + strlen(param[0]) + strlen(param[1]);
++ if(length_remaining > length)
++ sprintf((lptr = line), "%s %s", param[0], param[1]);
++ else
++ printf("SetAction: string buffer would have overrun: %s %s\n",param[0], param[1]);
+ eof_flag = 0;
+ s_set();
+ }
+@@ -372,7 +381,7 @@
+ prevActionAsync = False,
+ startup = True;
+ static Widget actionWidget;
+- static String actionStack;
++ static String actionStack = "";
+
+ void (*actionProc)();
+ static char actionName[SM_BUF],
+@@ -387,6 +396,9 @@
+ Boolean async;
+ };
+
++ /* A string containing a script of actions to perform at startup. */
++ String startScript;
++
+ static struct _actionTable actionTable[] = {
+ {"Beep", BeepAction, False},
+ {"CloseWindow", CloseWindowAction, False},
+@@ -413,12 +425,12 @@
+ switch (intData) {
+
+ case ACTION_NEW_ACTION:
+- strcpy(actionName, stringData);
++ strncpy(actionName, stringData, sizeof(actionName));
+ numArgs = 0;
+ return;
+
+ case ACTION_NEW_ARG:
+- strcpy((argsArray[numArgs] = args[numArgs]), stringData);
++ strncpy((argsArray[numArgs] = args[numArgs]), stringData, SM_BUF);
+ numArgs++;
+ return;
+
+@@ -461,10 +473,12 @@
+ XtFree(actionStack);
+
+ if (startup) {
+- startup = False;
+- ParseThis(FmtString("Message(\"Welcome to Seyon version %s.%s\"); %s",
+- VERSION, REVISION, "RestartTerminal();"),
+- DispatchActions);
++ startup = False;
++ startScript
++ = XtNewString( FmtString("Message(\"Welcome to Seyon version %s.%s\"); %s",
++ VERSION, REVISION, "RestartTerminal();"));
++ ParseThis(startScript, DispatchActions);
++ XtFree(startScript);
+ }
+
+ return;
+--- seyon-2.20c.orig/SeScript.c
++++ seyon-2.20c/SeScript.c
+@@ -100,8 +100,8 @@
+ if (qres.scriptDirectory) scriptDir = qres.scriptDirectory;
+ else scriptDir = qres.defaultDirectory;
+
+- strcpy(buf, scriptFileName);
+- if ((scriptFP = open_file(buf, scriptDir)) == NULL)
++ strncpy(buf, scriptFileName, REG_BUF);
++ if ((scriptFP = open_file(buf, REG_BUF, scriptDir)) == NULL)
+ return False;
+
+ exec_close_script(scriptFP);
+@@ -110,31 +110,33 @@
+
+ void
+ exec_close_script(script_fp)
+- FILE *script_fp;
++ FILE *script_fp;
+ {
+- if_flag = 0;
+- echo_flag = False;
+- captflag = False;
+- tty_flag = True;
+- eof_flag = 0;
++ if_flag = 0;
++ echo_flag = False;
++ captflag = False;
++ tty_flag = True;
++ eof_flag = 0;
+
+- if (linkflag == 2)
+- linkflag = 0;
++ if (linkflag == 2)
++ linkflag = 0;
+
+- while (!eof_flag)
+- get_line(script_fp);
++ while (!eof_flag)
++ get_line(script_fp);
+
+- fclose(script_fp);
+- if (captflag)
+- fclose(cf);
++ fclose(script_fp);
++ if (captflag)
++ fclose(cf);
+
+- eof_flag = 0;
+- lptr = strcpy(line, "");
+- k_when();
++ eof_flag = 0;
++ /* No buffer length problem here! */
++ /* But why do this??? */
++ lptr = strcpy(line, "");
++ k_when();
+
+- linkflag = 0;
++ linkflag = 0;
+
+- return;
++ return;
+ }
+
+ static char wf[MAX_LINE];
+@@ -202,7 +204,7 @@
+
+
+ GETTEST_ARG("waitfor");
+- strcpy(wf, word);
++ strncpy(wf, word, MAX_LINE);
+
+ GET_ARG();
+
+@@ -331,7 +333,7 @@
+ return;
+ }
+
+- strcpy(label, word);
++ strncpy(label, word, WBSIZE);
+
+ rewind(script_fp);
+ while (!found) {
+@@ -360,7 +362,7 @@
+ if_flag = 0; /* reset IF flag */
+ }
+
+-static if_negate = 0;
++static int if_negate = 0;
+
+ static int
+ if_test(cond)
+--- seyon-2.20c.orig/SeWin.c
++++ seyon-2.20c/SeWin.c
+@@ -377,7 +377,7 @@
+ {
+ Widget dialog = XtParent(valueWidget);
+
+- strcpy(getValueDefValue, XawDialogGetValueString(dialog));
++ strncpy(getValueDefValue, XawDialogGetValueString(dialog), REG_BUF);
+ DestroyShell(dialog);
+
+ (*getValueExecProc)(XtParent(GetShell(valueWidget)), getValueDefValue);
+@@ -745,10 +745,7 @@
+ b,
+ c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SePopupMsg(parent, buf);
++ SePopupMsg(parent, FmtString(fmt,a,b,c));
+ }
+
+ Widget
+@@ -773,20 +770,16 @@
+ }
+
+ void
+-SePopupNoticeF(parent, title, call_back, fmt, a, b, c, d)
++SePopupNoticeF(parent, title, call_back, fmt, a, b, c)
+ Widget parent;
+ String title;
+ void (*call_back) ();
+ String fmt,
+ a,
+ b,
+- c,
+- d;
++ c;
+ {
+- char buf[REG_BUF];
+-
+- sprintf(buf, fmt, a, b, c);
+- SePopupNotice(parent, title, call_back, buf);
++ SePopupNotice(parent, title, call_back, FmtString(fmt,a,b,c));
+ }
+
+ /*
+@@ -918,10 +911,7 @@
+ b,
+ c;
+ {
+- char buffer[REG_BUF];
+-
+- sprintf(buffer, fmt, a, b, c);
+- SetStatusMessage(buffer);
++ SetStatusMessage(FmtString(fmt,a,b,c));
+ }
+
+ /*---------------------------------------------------------------------------+
+--- seyon-2.20c.orig/SeString.c
++++ seyon-2.20c/SeString.c
+@@ -22,12 +22,13 @@
+
+ char
+ itoa(num)
+- int num;
++ int num;
+ {
+- char buf[TIN_BUF];
++ char buf[TIN_BUF];
+
+- sprintf(buf, "%d", num);
+- return buf[0];
++ /* Buffer is safely big enough */
++ sprintf(buf, "%d", num);
++ return buf[0];
+ }
+
+ /*
+@@ -100,8 +101,15 @@
+ char buffer[REG_BUF],
+ *bufptr;
+
+- strcpy(buffer, source);
++ strncpy(buffer, source, REG_BUF);
++
++ /* Null-terminate, as expected by str_strip_lead_end_space(). */
++ buffer[REG_BUF] = '\0';
++
+ bufptr = str_strip_lead_end_space(buffer);
++
++ /* Must fit, as we can only have removed things from the original
++ string */
+ return strcpy(dest, bufptr);
+ }
+
+@@ -128,14 +136,43 @@
+ return strBuf;
+ }
+
++/* Note that the the (char *) data structure returned by FmtString()
++ is invalidated on subsequent calls, and that the function is not
++ re-entrant. Take care that the pointer returned is not held for
++ use across calls. */
+ char*
+ FmtString(fmt, a, b, c)
+- char *fmt, *a, *b, *c;
++ char *fmt, *a, *b, *c;
+ {
+- static char strBuf[LRG_BUF];
++ static char strBuf[LRG_BUF];
++ static FILE *devnull=NULL;
++ int length = 0;
++
++ /* Clear the buffer as it highlights errors elsewhere, such as
++ simultaneous use of the static string or re-entry into this
++ function. */
++ memset(strBuf, 0, LRG_BUF);
++
++ /* Ick... This is horrible - using a user-provided format string
++ means we have no easy way of limiting string length. HACK HACK
++ HACK Use fprintf to output to /dev/null and count the number of
++ bytes... It would be nice if we could rely on having snprintf() */
++
++ if(NULL == devnull)
++ {
++ devnull = fopen("/dev/null", "r+");
++ if(NULL == devnull)
++ {
++ printf("Open /dev/null failed!?!\n");
++ return strBuf;
++ }
++ length = fprintf(devnull, fmt, a, b, c);
++ }
++
++ if(LRG_BUF >= length)
++ sprintf(strBuf, fmt, a, b, c);
+
+- sprintf(strBuf, fmt, a, b, c);
+- return strBuf;
++ return strBuf;
+ }
+
+ /*
+@@ -189,6 +226,7 @@
+ if (*line == '\0')
+ return NULL;
+ else if (*line == '\"')
++
+ for (wrd = ++line; *line != '\"' && *line; line++);
+ else
+ for (wrd = line; !isspace(*line) && *line; line++);
+@@ -246,38 +284,38 @@
+ * this routine is not currently used, and I'm not if it works
+ */
+
+-char *
+-get_word(str, word)
+- char *str,
+- *word;
+-{
+- char *wrd,
+- c;
+-
+- while (isspace(*str) && *str)
+- str++;
+-
+- if (!(*str))
+- word[0] = '\0';
+-
+- else if (*str == '\"') {
+- for (wrd = ++str; *str != '\"' && *str; str++);
+- *str = '\0';
+- strcpy(word, wrd);
+- *str = '\"';
+- str++;
+- }
++/* char * */
++/* get_word(str, word) */
++/* char *str, */
++/* *word; */
++/* { */
++/* char *wrd, */
++/* c; */
++
++/* while (isspace(*str) && *str) */
++/* str++; */
++
++/* if (!(*str)) */
++/* word[0] = '\0'; */
++
++/* else if (*str == '\"') { */
++/* for (wrd = ++str; *str != '\"' && *str; str++); */
++/* *str = '\0'; */
++/* strcpy(word, wrd); */
++/* *str = '\"'; */
++/* str++; */
++/* } */
++
++/* else { */
++/* for (wrd = str; !isspace(*str) && *str; str++); */
++/* c = *str; */
++/* *str = '\0'; */
++/* strcpy(word, wrd); */
++/* *str = c; */
++/* } */
+
+- else {
+- for (wrd = str; !isspace(*str) && *str; str++);
+- c = *str;
+- *str = '\0';
+- strcpy(word, wrd);
+- *str = c;
+- }
+-
+- return str;
+-}
++/* return str; */
++/* } */
+
+ #if !HAVE_STRERROR
+
+--- seyon-2.20c.orig/SeParse.y
++++ seyon-2.20c/SeParse.y
+@@ -1,8 +1,11 @@
+ %{
+ #include <stdio.h>
+ #include <ctype.h>
++#include <stdlib.h>
+ #include "SeParse.h"
+
++int yylex(void);
++
+ void (*callbackProc)();
+ %}
+
+@@ -81,19 +84,19 @@
+ {
+ char long_line[1000];
+
+- char input_str[] = "This(is, a, real, funky); script();
+- Scripts(); Can(be); Multi(Line, \"Can't they?\");
+- Commas(are, no, longer, optional, inside, arglists);
+- Scripts(); Can(); contain(\"tabs \\t and backspaces \\b\");
+- As(\"Well\\ as Quoted Strings\", and, '\"Quoted Strings inside
+- quoted strings\"');
+- esc(can, appear, outside, strings, ^z, \\012\\015\\n);
+- But(parenthesis, should, match);
+- We(\"have a funny way of specifying \\012 chars and even)\");
+- backslashes( \" \\\\ \");
+- new(\"in this version are ^m and ^A ctr-escapes, as in ^S^Q\");
+- The(next, line, will, give, a, syntax, error, because, it, has, two, adj, functions,
+- without, a, separating, semicolon);
++ char input_str[] = "This(is, a, real, funky); script();\n\
++ Scripts(); Can(be); Multi(Line, \"Can't they?\");\n\
++ Commas(are, no, longer, optional, inside, arglists);\n\
++ Scripts(); Can(); contain(\"tabs \\t and backspaces \\b\");\n\
++ As(\"Well\\ as Quoted Strings\", and, '\"Quoted Strings inside\n\
++ quoted strings\"');\n\
++ esc(can, appear, outside, strings, ^z, \\012\\015\\n)\n\
++ But(parenthesis, should, match);\n\
++ We(\"have a funny way of specifying \\012 chars and even)\"); \n\
++ backslashes( \" \\\\ \");\n\
++ new(\"in this version are ^m and ^A ctr-escapes, as in ^S^Q\");\n\
++ The(next, line, will, give, a, syntax, error, because, it, has, two, adj, functions,\n\
++ without, a, separating, semicolon);\n\
+ End() script()";
+
+ printf("------ String to parse: \n%s\n\n---- Parsing begins:\n", input_str);
+--- seyon-2.20c.orig/SeSet.c
++++ seyon-2.20c/SeSet.c
+@@ -18,6 +18,9 @@
+
+ #include "seyon.h"
+ #include "SeDecl.h"
++#if HAVE_TERMIOS
++#include <termios.h>
++#endif
+
+ extern int param_pipe[2];
+
+@@ -84,6 +87,13 @@
+ {"baud", {"300", "1200", "2400", "4800", "9600", "19200", "38400",
+ #if USE_NONSTD_BAUD
+ "57600", "115200",
++#else
++#ifdef B57600
++ "57600",
++#endif
++#ifdef B115200
++ "115200",
++#endif
+ #endif
+ NULL}, 1, MenuSetGetBaud},
+ {"bits", {"5", "6", "7", "8", NULL}, 1, MenuSetGetCSize},
+@@ -191,7 +201,7 @@
+ struct _setValue *vptr;
+
+ vptr = set_value;
+- strcpy(vptr->value, modem_port);
++ strncpy(vptr->value, modem_port, SM_BUF);
+ vptr++;
+
+ curValObjPtr = (vptr = (struct _setValue *)client_data);
+--- seyon-2.20c.orig/startup
++++ seyon-2.20c/startup
+@@ -4,30 +4,30 @@
+ # see the manual page for a complete listing of the keywords
+ # that can be used with 'set'.
+
+-# set baud 9600
++set baud 57600
+
+ # can be 5, 6, 7, or 8
+-# set bits 8
++set bits 8
+
+ # can be 0 (= no parity), 1 (= odd parity), or 2 (= even parity)
+ # set parity 0
+
+ # can be 1 or 2
+-# set stopBits 1
++set stopBits 1
+
+ # can be nl, cr, or cr/lf
+ # set newlineTranslation cr
+
+-# set del on
+-# set meta_tr on
+-# set xoff off
+-# set rtscts on
+-# set autozm on
++set del on
++set meta_tr on
++set xoff off
++set rtscts on
++set autozm on
+ # set idleGuard on
+
+ # put the modem initialization string here if you like one.
+ # most modern modems do not need it since they store their setup in
+ # non-volatile memory.
+
+-# echo "Initializing modem..."
+-# transmit "ATZ^M"
++echo "Initializing modem..."
++transmit "ATM0^M"
+--- seyon-2.20c.orig/debian/po/POTFILES.in
++++ seyon-2.20c/debian/po/POTFILES.in
+@@ -0,0 +1 @@
++[type: gettext/rfc822deb] templates
+--- seyon-2.20c.orig/debian/po/fr.po
++++ seyon-2.20c/debian/po/fr.po
+@@ -0,0 +1,49 @@
++#
++# Translators, if you are not familiar with the PO format, gettext
++# documentation is worth reading, especially sections dedicated to
++# this format, e.g. by running:
++# info -n '(gettext)PO Files'
++# info -n '(gettext)Header Entry'
++#
++# Some information specific to po-debconf are available at
++# /usr/share/doc/po-debconf/README-trans
++# or http://www.debian.org/intl/l10n/po-debconf/README-trans
++#
++# Developers do not need to manually edit POT or PO files.
++#
++msgid ""
++msgstr ""
++"Project-Id-Version: seyon 2.20c-12\n"
++"POT-Creation-Date: 2003-10-13 02:02+0100\n"
++"PO-Revision-Date: 2003-10-16 23:41+0100\n"
++"Last-Translator: Christian Perrier <bubulle@debian.org>\n"
++"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
++"MIME-Version: 1.0\n"
++"Content-Type: text/plain; charset=iso-8859-15\n"
++"Content-Transfer-Encoding: 8bit\n"
++
++#. Description
++#: ../templates:4
++msgid "Modem device"
++msgstr "Périphérique du modem"
++
++#. Description
++#: ../templates:4
++msgid ""
++"Please choose the device file corresponding to the port the modem is "
++"connected to. This may be /dev/ttyS1 or any other device file."
++msgstr ""
++"Veuillez choisir le fichier de périphérique correspondant au port où est "
++"connecté le modem. Cela peut être /dev/ttyS1 ou tout autre fichier de "
++"périphérique."
++
++#. Description
++#: ../templates:4
++msgid ""
++"/dev/modem is usually a symbolic link to the appropriate device file. This "
++"configuration program will not setup this link. If you choose \"/dev/modem"
++"\", the link should already exist."
++msgstr ""
++"/dev/modem est généralement un lien symbolique vers le fichier de "
++"périphérique correct. Ce programme de configuration n'établira pas ce lien. "
++"Si vous indiquez « /dev/modem », il faudrait que le lien existe au préalable."
+--- seyon-2.20c.orig/debian/po/nl.po
++++ seyon-2.20c/debian/po/nl.po
+@@ -0,0 +1,50 @@
++#
++# Translators, if you are not familiar with the PO format, gettext
++# documentation is worth reading, especially sections dedicated to
++# this format, e.g. by running:
++# info -n '(gettext)PO Files'
++# info -n '(gettext)Header Entry'
++#
++# Some information specific to po-debconf are available at
++# /usr/share/doc/po-debconf/README-trans
++# or http://www.debian.org/intl/l10n/po-debconf/README-trans
++#
++# Developers do not need to manually edit POT or PO files.
++#
++#, fuzzy
++msgid ""
++msgstr ""
++"Project-Id-Version: seyon2.20c-12 \n"
++"Report-Msgid-Bugs-To: \n"
++"POT-Creation-Date: 2003-07-21 16:50+0200\n"
++"PO-Revision-Date: 2003-09-07 17:46+0100\n"
++"Last-Translator: Tim Vandermeersch <qber66@skolelinux.no>\n"
++"Language-Team: dutch <debian-l10n-dutch@lists.debian.org>\n"
++"MIME-Version: 1.0\n"
++"Content-Type: text/plain; charset=iso-8859-1\n"
++"Content-Transfer-Encoding: 8bit\n"
++
++#. Description
++#: ../templates:4
++msgid "Modem device"
++msgstr "Modem apparaat"
++
++#. Description
++#: ../templates:4
++msgid ""
++"Please choose the device file corresponding to the port the modem is "
++"connected to. This may be /dev/ttyS1 or any other device file."
++msgstr ""
++"Gelieve het overeenkomstige apparaat bestand te kiezen van de poort waar de "
++"modem met verbonden is. Dit kan /dev/ttyS1 of een ander apparaat bestand zijn."
++
++#. Description
++#: ../templates:4
++msgid ""
++"/dev/modem is usually a symbolic link to the appropriate device file. This "
++"configuration program will not setup this link. If you choose \"/dev/modem"
++"\", the link should already exist."
++msgstr ""
++"/dev/modem is meestal een symbolische link naar het correcte apparaat bestand."
++"Dit configuratie programma zal deze link niet creëren. Als u \"/dev/modem\""
++"kiest, dient deze link al te bestaan."
+--- seyon-2.20c.orig/debian/po/templates.pot
++++ seyon-2.20c/debian/po/templates.pot
+@@ -0,0 +1,45 @@
++#
++# Translators, if you are not familiar with the PO format, gettext
++# documentation is worth reading, especially sections dedicated to
++# this format, e.g. by running:
++# info -n '(gettext)PO Files'
++# info -n '(gettext)Header Entry'
++#
++# Some information specific to po-debconf are available at
++# /usr/share/doc/po-debconf/README-trans
++# or http://www.debian.org/intl/l10n/po-debconf/README-trans
++#
++# Developers do not need to manually edit POT or PO files.
++#
++#, fuzzy
++msgid ""
++msgstr ""
++"Project-Id-Version: PACKAGE VERSION\n"
++"Report-Msgid-Bugs-To: \n"
++"POT-Creation-Date: 2003-10-13 02:02+0100\n"
++"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
++"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
++"Language-Team: LANGUAGE <LL@li.org>\n"
++"MIME-Version: 1.0\n"
++"Content-Type: text/plain; charset=CHARSET\n"
++"Content-Transfer-Encoding: 8bit\n"
++
++#. Description
++#: ../templates:4
++msgid "Modem device"
++msgstr ""
++
++#. Description
++#: ../templates:4
++msgid ""
++"Please choose the device file corresponding to the port the modem is "
++"connected to. This may be /dev/ttyS1 or any other device file."
++msgstr ""
++
++#. Description
++#: ../templates:4
++msgid ""
++"/dev/modem is usually a symbolic link to the appropriate device file. This "
++"configuration program will not setup this link. If you choose \"/dev/modem"
++"\", the link should already exist."
++msgstr ""
+--- seyon-2.20c.orig/debian/po/cs.po
++++ seyon-2.20c/debian/po/cs.po
+@@ -0,0 +1,49 @@
++#
++# Translators, if you are not familiar with the PO format, gettext
++# documentation is worth reading, especially sections dedicated to
++# this format, e.g. by running:
++# info -n '(gettext)PO Files'
++# info -n '(gettext)Header Entry'
++#
++# Some information specific to po-debconf are available at
++# /usr/share/doc/po-debconf/README-trans
++# or http://www.debian.org/intl/l10n/po-debconf/README-trans
++#
++# Developers do not need to manually edit POT or PO files.
++#
++msgid ""
++msgstr ""
++"Project-Id-Version: seyon\n"
++"Report-Msgid-Bugs-To: \n"
++"POT-Creation-Date: 2003-10-13 02:02+0100\n"
++"PO-Revision-Date: 2004-12-31 11:57+0100\n"
++"Last-Translator: Miroslav Kure <kurem@debian.cz>\n"
++"Language-Team: Czech <provoz@debian.cz>\n"
++"MIME-Version: 1.0\n"
++"Content-Type: text/plain; charset=ISO-8859-2\n"
++"Content-Transfer-Encoding: 8bit\n"
++
++#. Description
++#: ../templates:4
++msgid "Modem device"
++msgstr "Zaøízení modemu"
++
++#. Description
++#: ../templates:4
++msgid ""
++"Please choose the device file corresponding to the port the modem is "
++"connected to. This may be /dev/ttyS1 or any other device file."
++msgstr ""
++"Vyberte soubor zaøízení, který odpovídá portu, ke kterému je modem pøipojen. "
++"Mù¾e to být /dev/ttyS1, nebo nìjaký jiný soubor zaøízení."
++
++#. Description
++#: ../templates:4
++msgid ""
++"/dev/modem is usually a symbolic link to the appropriate device file. This "
++"configuration program will not setup this link. If you choose \"/dev/modem"
++"\", the link should already exist."
++msgstr ""
++"/dev/modem èasto bývá symbolickým odkazem na pøíslu¹ný soubor zaøízení. "
++"Tento konfiguraèní program zmínìný odkaz nevytváøí. Zadáte-li tedy \"/dev/"
++"modem\", mìl by odkaz ji¾ existovat."
+--- seyon-2.20c.orig/debian/conffiles
++++ seyon-2.20c/debian/conffiles
+@@ -0,0 +1,2 @@
++/etc/X11/app-defaults/Seyon
++/etc/X11/app-defaults/Seyon-color
+--- seyon-2.20c.orig/debian/config.include
++++ seyon-2.20c/debian/config.include
+@@ -0,0 +1,84 @@
++# Edit this file to configure debian/rules to build a package.
++# No modification of debian/rules should be neccessary. (Famous last words!)
++#
++# File by Joey Hess <joeyh@master.debian.org>
++
++# What is the name of the primary package in this sourcepackage?
++package=seyon
++
++# Parameters to pass to rules file. This can include doc files, or
++# command-line switches.
++docs=1-{BUGREPORT,FAQ,HISTORY,README,SURVEY,TODO}
++examples=phonelist protocols startup
++binfiles=$(package)
++copyright=debian/copyright
++
++# What file must exist in the current directory if the package is
++# properly unpacked here?
++test_file=$(package).h
++
++# Does this package build from an Imakefile?
++# If so, uncomment the line below.
++use_imakefile=y
++
++# Does this package build from a Configure script?
++# If so, uncomment the line below and enter the command to run to run the
++# Configure script (ie: "./Configure")
++#use_configure=./Configure
++
++# What commands to run to build the package?
++define build_command
++ $(MAKE)
++endef
++
++# What commands to run to clean up after a build?
++define clean_command
++ -$(MAKE) -i clean
++endef
++
++# List here any files that must be removed during "debian/rules clean"
++# that clean_command doesn't take care of.
++clean_files=
++
++# List here any temporary directories that are used to build multiple-
++# binary packages. These are automatically created and removed.
++tmp_dirs=
++
++# List here any files that should be preserved during a build, and restored
++# to their original state during a clean. For example, if the package comes
++# with both an Imakefile and a Makefile, and xmkmf is run, list the original
++# Makefile here so it will be backed up before it is overwritten my xmkmf.
++preserve_files=Makefile
++
++# What command to run to install the package into debian/tmp?
++# You might want to edit the package's Makefile and add $(PREFIX)
++# to all the paths it installs files to. or, you can just write
++# your own install commands here instead.
++#
++# Note that debian/* and the files in /usr/share/doc will be installed
++# properly for you, you don't need to do that here.
++#
++define install_command
++ $(MAKE) DESTDIR=debian/tmp install
++ install -d debian/tmp/etc/X11/seyon
++ ln -sf /etc/X11/seyon/seyon-emu debian/tmp/usr/X11R6/bin/seyon-emu
++ install -d debian/tmp/usr/X11R6/man/man1
++ install -m 644 seyon.man debian/tmp/usr/X11R6/man/man1/seyon.1x
++ install -m 644 debian/seyon-emu.man debian/tmp/usr/X11R6/man/man1/seyon-emu.1x
++ # Install 1-CHANGES as upstream changelog.
++ install -d debian/tmp/usr/share/doc/$(package)
++ cp 1-CHANGES debian/tmp/usr/share/doc/$(package)/changelog
++ strip --remove-section=.comment --remove-section=.note debian/tmp/usr/X11R6/bin/seyon
++ install -d debian/tmp/usr/lib/menu
++ install -m 644 debian/menu debian/tmp/usr/lib/menu/seyon
++endef
++
++# After being installed in debian/tmp, everything is chowned to root.root,
++# and chmod g-ws is run on everything. Enter below any chmod commands you
++# need to run to set files to the proper permissions. This is where you
++# can make programs be suid, etc.
++# (Note that these commands will be run as root.)
++define ch_commands
++ chmod 644 debian/tmp/etc/X11/app-defaults/*
++ chmod 644 debian/tmp/usr/X11R6/lib/X11/seyon.help
++endef
+--- seyon-2.20c.orig/debian/copyright
++++ seyon-2.20c/debian/copyright
+@@ -0,0 +1,46 @@
++This is a Debian prepackaged version of seyon.
++
++This package was originally put together by Joey Hess
++<joeyh@master.debian.org>, using sources from:
++
++ftp://sunsite.unc.edu/pub/Linux/apps/serialcomm/dialout/Seyon-2.14c-tar.gz
++
++The following copyright applied to the old package:
++
++======================================================================
++
++ Seyon is Copyright (c) 1992 of Muhammad M. Saggaf. Seyon is not
++ public domain. Permission is granted to use and distribute Seyon
++ freely for any use and to sell it at any price without reference to
++ the copyright owner provided that in all above cases Seyon is intact
++ and is not made part of any program either in whole or in part and
++ that this copyright notice is included with Seyon. Permission is
++ also granted to modify the source as long as the modified source is
++ not distributed.
++
++======================================================================
++
++As of May 1999, Muhammad M. Saggaf has given permission for seyon to
++be released and maintained under GPL (see
++/usr/share/common-licenses/GPL):
++
++Dear Steve:
++
++I received your letter today (yes, I know it took a long time, it took a
++trip half-way around the world and then back to my current address in the
++U.S.). I share your view about license for Seyon, I think it is too
++restrictive, especially that I'm not actively maintaining it. The purpose
++behind that restriction was to prevent incompatible versions, really, but I
++don't think it was the correct way of doing that. You have my permission to
++modify the license (e.g. the GPL is just fine) and distribute the package
++with the new license.
++
++My very best wishes,
++
++-- M. Saggaf
++ msaggaf@erl.mit.edu
++
++For now I am the new upstream maintainer as well as the Debian
++maintainer for the seyon package. Upstream sources without the Debian
++patches will be made available shortly from sunsite.unc.edu (now
++better known as metalab.unc.edu), as above.
+--- seyon-2.20c.orig/debian/examples
++++ seyon-2.20c/debian/examples
+@@ -0,0 +1,7 @@
++script.QWK
++script.unix
++script.CIS
++script.PCBoard
++startup
++protocols
++phonelist
+--- seyon-2.20c.orig/debian/postinst
++++ seyon-2.20c/debian/postinst
+@@ -0,0 +1,27 @@
++#!/bin/sh -e
++
++case "$1" in
++ abort-upgrade|abort-remove|abort-deconfigure)
++ exit 0;; # Don't prompt for configuration if something went wrong...
++esac
++
++if test -x /usr/bin/update-menus; then update-menus; fi
++
++EMU=/etc/X11/seyon/seyon-emu
++COLORDEFAULTS=/etc/X11/seyon/Seyon
++MODEMDEFAULTS=/etc/X11/seyon/Seyon-modem
++
++. /usr/share/debconf/confmodule
++db_version 2.0
++
++if [ ! -f $COLORDEFAULTS -o ! -f $MODEMDEFAULTS ]; then
++
++ # No longer need to worry about colour/mono app-defaults any more; the
++ # system will get it right...
++
++ ln -sf /usr/bin/x-terminal-emulator $EMU
++
++fi
++exit 0
++
++#DEBHELPER#
+--- seyon-2.20c.orig/debian/postrm
++++ seyon-2.20c/debian/postrm
+@@ -0,0 +1,21 @@
++#!/bin/sh -e
++
++if test -x /usr/bin/update-menus; then update-menus; fi
++
++XTERM=/etc/X11/seyon/seyon-emu
++COLORDEFAULTS=/etc/X11/seyon/Seyon
++MODEMDEFAULTS=/etc/X11/seyon/Seyon-modem
++
++if [ "$1" = "purge" ]
++then
++ rm -f $XTERM $COLORDEFAULTS $MODEMDEFAULTS
++ rmdir /etc/X11/seyon /etc/X11 2>/dev/null || true
++
++ . /usr/share/debconf/confmodule
++
++ db_purge
++
++
++fi
++
++#DEBHELPER#
+--- seyon-2.20c.orig/debian/postrm.debhelper
++++ seyon-2.20c/debian/postrm.debhelper
+@@ -0,0 +1,78 @@
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
++# Automatically added by dh_installdebconf
++if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
++ . /usr/share/debconf/confmodule
++ db_purge
++fi
++# End automatically added section
+--- seyon-2.20c.orig/debian/preinst
++++ seyon-2.20c/debian/preinst
+@@ -0,0 +1,15 @@
++#! /bin/sh
++# see: dh_installdeb(1)
++
++set -e
++
++# Source debconf library
++. /usr/share/debconf/confmodule
++
++# dh_installdeb will replace this with shell code automatically
++# generated by other debhelper scripts.
++
++#DEBHELPER#
++
++
++
+--- seyon-2.20c.orig/debian/rules
++++ seyon-2.20c/debian/rules
+@@ -0,0 +1,143 @@
++#!/usr/bin/make -f
++##############################################################################
++# Generic debian/rules file. Based on:
++#
++#> Sample debian.rules file - for GNU Hello (1.3).
++#> Copyright 1994,1995 by Ian Jackson.
++#> I hereby give you perpetual unlimited permission to copy,
++#> modify and relicense this file, provided that you do not remove
++#> my name from the file itself. (I assert my moral right of
++#> paternity under the Copyright, Designs and Patents Act 1988.)
++#
++# Heavily modified by Joey Hess <jeh22@cornell.edu>
++#
++##############################################################################
++#
++# NOTE: You shouldn't have to edit this file. Edit debian/config.include instead.
++# If you must edit this file to get your package to build properly, then
++# I have failed. Let me know; mail jeh22@cornell.edu.
++#
++# (Currently not handled: multiple binary packages from 1 source package,
++# and binary-indep rule.)
++#
++# NOTE: This file is designed so it doesn't need to be run as root. For
++# actions that require that the user be root, the root password will be
++# prompted for, if you're not already root.
++#
++##############################################################################
++
++# Include config file.
++include debian/config.include
++
++# Generate a makefile (via configure scriopt or xmkmf).
++makefile-stamp:
++ ifeq ($(strip $(use_imakefile)),y)
++ xmkmf -a
++ endif
++ $(use_configure)
++ touch makefile-stamp
++
++# Preserve some files that may get deleted/overwritten/modified otherwise.
++preserve-stamp:
++ ifneq ($(strip $(preserve_files)),)
++ $(foreach file,$(preserve_files),-cp $(file) $(file).preserved)
++ endif
++ touch preserve-stamp
++
++build: preserve-stamp makefile-stamp
++ $(checkdir)
++ $(build_command)
++ touch build
++
++clean: preserve-stamp makefile-stamp
++ $(checkdir)
++ # Do actual cleaning up here.
++ -rm -f build
++ $(clean_command)
++ -rm -rf *~ debian/*~ debian/files* $(clean_files)
++ $(clean_tmp)
++ # Remove Makefile that xmkmf creates.
++ ifeq ($(strip $(use_imakefile)),y)
++ -rm -f Makefile
++ endif
++ # If we preserved some files, we need to restore them now.
++ ifneq ($(strip $(preserve_files)),)
++ $(foreach file,$(preserve_files),-mv -f $(file).preserved $(file))
++ endif
++ -rm -f preserve-stamp makefile-stamp
++
++# Build architecture-independent files here.
++# (not yet set up to be used)
++binary-indep: build
++ $(checkdir)
++
++# Build architecture-dependent files here.
++binary-arch: build
++ $(checkdir)
++ $(clean_tmp)
++ install -d debian/tmp debian/tmp/DEBIAN debian/tmp/usr/share/doc/$(package)
++ $(install_command)
++ # Compress manpages
++ -gzip -9v -r debian/tmp/usr/man/ debian/tmp/usr/X11R6/man/
++ # Install documentation files, compressed.
++ ifneq ($(strip $(docs)),)
++ cp $(docs) debian/tmp/usr/share/doc/$(package)
++ gzip -9v debian/tmp/usr/share/doc/$(package)/*
++ endif
++ # Install copyright file, don't compress.
++ ifneq ($(strip $(copyright)),)
++ cp $(copyright) debian/tmp/usr/share/doc/$(package)/copyright
++ endif
++ # Install examples, compressed.
++ ifneq ($(strip $(examples)),)
++ install -d debian/tmp/usr/share/doc/$(package)/examples
++ cp $(examples) debian/tmp/usr/share/doc/$(package)/examples
++ gzip -9v debian/tmp/usr/share/doc/$(package)/examples/*
++ endif
++ # Install other debian files if they exist.
++ -install -m 644 debian/changelog debian/tmp/usr/share/doc/$(package)/changelog.Debian
++ -gzip -9v debian/tmp/usr/share/doc/$(package)/changelog.Debian
++ -install -m 644 debian/conffiles debian/tmp/DEBIAN/conffiles
++ -install -m 755 debian/preinst debian/tmp/DEBIAN/preinst
++ -install -m 755 debian/postinst debian/tmp/DEBIAN/postinst
++ -install -m 755 debian/prerm debian/tmp/DEBIAN/prerm
++ -install -m 755 debian/postrm debian/tmp/DEBIAN/postrm
++ # Generate control file.
++ dpkg-shlibdeps $(binfiles)
++ dpkg-gencontrol -isp
++ # Set permissions.
++ @[ "`whoami`" != root ] && \
++ echo -e "\n ** Enter root password to set file permissions."; \
++ debian/rules setperms
++ # C. Perrier. Well, debhelper helps a lot for all this..:-)
++ # Install debconf templates (with debhelper)
++ dh_installdebconf
++ # Actually build the .deb file.
++ dpkg --build debian/tmp ..
++
++# This must be run suid root, it sets the file permissions in debian/tmp
++setperms:
++ chown -R root.root debian/tmp
++ chmod -R g-ws debian/tmp
++ -$(ch_commands)
++
++define checkdir
++ @test -f $(test_file) -a -f debian/rules || (echo -e "\n\
++ ** \"$(test_file)\" or \"debian/rules\" does not exist.\n\
++ ** Either \"$(package)\" is not unpacked in this directory, or\n\
++ ** an incorrect test_file is specified in debian/config.\n" && false)
++endef
++
++# This rm's the debian/tmp directory.
++define clean_tmp
++ -rm -rf debian/tmp >/dev/null 2>&1
++ @if [ -d debian/tmp ]; then \
++ if [ "`whoami`" != root ]; then \
++ echo -e "\n ** Enter root password to remove debian/tmp."; \
++ fi; \
++ rm -rf debian/tmp; \
++ fi
++endef
++
++binary: binary-indep binary-arch
++.PHONY: clean setperms binary
+--- seyon-2.20c.orig/debian/rules.old
++++ seyon-2.20c/debian/rules.old
+@@ -0,0 +1,136 @@
++#!/usr/bin/make -f
++##############################################################################
++# Generic debian/rules file. Based on:
++#
++#> Sample debian.rules file - for GNU Hello (1.3).
++#> Copyright 1994,1995 by Ian Jackson.
++#> I hereby give you perpetual unlimited permission to copy,
++#> modify and relicense this file, provided that you do not remove
++#> my name from the file itself. (I assert my moral right of
++#> paternity under the Copyright, Designs and Patents Act 1988.)
++#
++# Heavily modified by Joey Hess <joeyh@master.debian.org>
++#
++##############################################################################
++#
++# NOTE: You shouldn't have to edit this file. Edit debian/config instead.
++# If you must edit this file to get your package to build properly, then
++# I have failed. Let me know; mail me.
++#
++# (Currently not handled: multiple binary packages from 1 source package,
++# and binary-indep rule.)
++#
++# NOTE: This file is designed so it doesn't need to be run as root. For
++# actions that require that the user be root, the root password will be
++# prompted for, if you're not already root.
++#
++##############################################################################
++#
++# Changelog:
++# * Fakeroot and sudo fixes.
++# * Run dpkg-gencontrol after debstd, and delete substvars during clean.
++# * Clean up junk files in subdirs.
++# * Modifications for multiple binary package support.
++# * Call debstd after fixing file perms.
++# * Don't pass package name to debstd + fixes for multi binary packages.
++# * Use build-stamp instead of build.
++# * New email address.
++# * Added changelog.
++#
++##############################################################################
++
++# Include config file.
++include debian/config
++
++# Generate a makefile (via configure scriopt or xmkmf).
++makefile-stamp:
++ ifeq ($(strip $(use_imakefile)),y)
++ xmkmf -a
++ endif
++ $(use_configure)
++ touch makefile-stamp
++
++# Preserve some files that may get deleted/overwritten/modified otherwise.
++preserve-stamp:
++ ifneq ($(strip $(preserve_files)),)
++ $(foreach file,$(preserve_files),cp $(file) $(file).preserved ;)
++ endif
++ touch preserve-stamp
++
++build-stamp: preserve-stamp makefile-stamp
++ $(checkdir)
++ $(build_command)
++ touch build-stamp
++
++build: build-stamp
++
++clean: preserve-stamp makefile-stamp
++ $(checkdir)
++ # Do actual cleaning up here.
++ -rm -f build-stamp
++ $(clean_command)
++ -find . -name '\#*\#' -o -name '*~' -o -name 'DEADJOE' -exec rm -f {} \;
++ -rm -f debian/files* debian/substvars debian/*.substvars $(clean_files)
++ $(clean_tmp)
++ # Remove Makefile that xmkmf creates.
++ ifeq ($(strip $(use_imakefile)),y)
++ -rm -f Makefile
++ endif
++ # If we preserved some files, we need to restore them now.
++ ifneq ($(strip $(preserve_files)),)
++ $(foreach file,$(preserve_files),mv -f $(file).preserved $(file); )
++ endif
++ -rm -f preserve-stamp makefile-stamp
++
++# Build architecture-independent files here.
++# (not yet set up to be used)
++binary-indep: build
++ $(checkdir)
++
++# Build architecture-dependent files here.
++binary-arch: build
++ $(checkdir)
++ $(clean_tmp)
++ $(install_command)
++ # Set permissions and check package for problems, then build package.
++ @if [ "`whoami`" != root ]; then \
++ echo -e "\n ** Enter root password to set file permissions."; \
++ sudo debian/rules setperms; \
++ else \
++ debian/rules setperms; \
++ fi
++
++# This must be run suid root, it sets the file permissions in debian/tmp
++setperms:
++ chown -R root.root debian/tmp
++ chmod -R g-ws debian/tmp
++ # Debstd handles lots of nasty details. This requires that the debmake
++ # package is installed.
++ -debstd $(debstd) $(docs)
++ dpkg-gencontrol -p$(package)
++ $(ch_commands)
++ dpkg --build debian/tmp ..
++
++define checkdir
++ @test -e $(test_file) -a -f debian/rules || (echo -e "\n\
++ ** \"$(test_file)\" or \"debian/rules\" does not exist.\n\
++ ** Either the package is not unpacked in this directory, or\n\
++ ** an incorrect test_file is specified in debian/config.\n" && false)
++endef
++
++# This rm's the debian/tmp directory, and any other directories specified in
++# tmpdirs
++define clean_tmp
++ -rm -rf debian/tmp >/dev/null 2>&1
++ @if [ -d debian/tmp -o -n "$(tmp_dirs)" ]; then \
++ if [ "`whoami`" != root ]; then \
++ echo -e "\n ** Enter root password to remove temporary directories $(tmp_dirs)"; \
++ sudo rm -rf debian/tmp $(tmp_dirs); \
++ else \
++ rm -rf debian/tmp $(tmp_dirs); \
++ fi; \
++ fi
++endef
++
++binary: binary-indep binary-arch
++.PHONY: clean setperms binary
+--- seyon-2.20c.orig/debian/seyon-emu.man
++++ seyon-2.20c/debian/seyon-emu.man
+@@ -0,0 +1,23 @@
++.TH SEYON 1 \" -*- nroff -*-
++
++.SH NAME
++Seyon \- X11 Telecommunications Package.
++
++.SH SYNOPSIS
++.B seyon-emu
++
++.SH DESCRIPTION
++
++.P
++
++\fISeyon-emu\fP is the name of the terminal-emulator program called by
++\fIseyon\fP. This will normally simply be a symbolic link to another
++program (such as \fIxterm\fP or \fIrxvt\fP). Therefore read the manual
++page of the appropriate program for its options.
++
++.SH SEE ALSO
++rxvt(1), xterm(1), seyon(1)
++
++This manual page added by Steve McIntyre <stevem@chiark.greenend.org.uk>,
++Debian maintainer of seyon, 14th March 1998.
++
+--- seyon-2.20c.orig/debian/substvars
++++ seyon-2.20c/debian/substvars
+@@ -0,0 +1,2 @@
++shlibs:Depends=libc6 (>= 2.3.2.ds1-4), libice6 | xlibs (>> 4.1.0), libsm6 | xlibs (>> 4.1.0), libx11-6 | xlibs (>> 4.1.0), libxaw7 (>> 4.1.0), libxext6 | xlibs (>> 4.1.0), libxmu6 | xlibs (>> 4.1.0), libxpm4 | xlibs (>> 4.1.0), libxt6 | xlibs (>> 4.1.0)
++misc:Depends=debconf (>= 0.5) | debconf-2.0, debconf (>= 0.5)
+--- seyon-2.20c.orig/debian/templates
++++ seyon-2.20c/debian/templates
+@@ -0,0 +1,10 @@
++Template: seyon/device
++Type: string
++Default: /dev/modem
++_Description: Modem device
++ Please choose the device file corresponding to the port the modem is
++ connected to. This may be /dev/ttyS1 or any other device file.
++ .
++ /dev/modem is usually a symbolic link to the appropriate device file.
++ This configuration program will not setup this link. If you choose
++ "/dev/modem", the link should already exist.
+--- seyon-2.20c.orig/debian/config
++++ seyon-2.20c/debian/config
+@@ -0,0 +1,92 @@
++#!/bin/sh -e
++
++# Some ideas stolen from the cvs package
++
++# Config script for seyon using debconf
++. /usr/share/debconf/confmodule
++db_version 2.0 || [ $? -lt 30 ]
++
++db_title "Seyon communication software"
++
++# Defaults
++MODEMDEFAULTS=/etc/X11/seyon/Seyon-modem
++DEFAULTPORT=/dev/modem
++PORT=$DEFAULTPORT
++
++read_rcfile() {
++ # Default values
++ if [ -f $MODEMDEFAULTS ]; then
++ PORT=`cat $MODEMDEFAULTS | grep -m1 "^seyon\*modems:" | cut -f2 -d: 2>/dev/null`
++ fi
++ if [ -z $PORT ] ; then
++ PORT=$DEFAULTPORT
++ fi
++}
++
++write_rcfile() {
++ TEMPFILE=`tempfile`
++ if [ -f $MODEMDEFAULTS ]; then
++ ESCAPEDPORT=`echo $PORT | sed 's/\//\\\\\//g'`
++ sed "s/^seyon\*modems:.*$/seyon\*modems: ${ESCAPEDPORT}/" $MODEMDEFAULTS > $TEMPFILE
++ chmod --reference=$MODEMDEFAULTS $TEMPFILE
++ chown --reference=$MODEMDEFAULTS $TEMPFILE
++ else
++ echo "seyon*modems: $PORT" > $TEMPFILE
++ chmod 640 $TEMPFILE
++ chown root.dialout $TEMPFILE
++ fi
++ if [ ! -d /etc/X11/seyon ] ; then
++ mkdir -p /etc/X11/seyon
++ fi
++ mv $TEMPFILE $MODEMDEFAULTS
++}
++
++set_debconf() {
++ if [ "$PORT" ]; then
++ db_set seyon/device "$PORT" || true
++ fi
++}
++
++get_debconf() {
++ db_get seyon/device
++ PORT=$RET
++ # If not present, use default
++ if [ "$PORT" = "" ]
++ then
++ PORT=$DEFAULTPORT
++ fi
++}
++
++
++input_settings() {
++ db_input low seyon/device || true
++ db_go
++ db_get seyon/device
++ PORT=$RET
++ # If not present, use default
++ if [ "$PORT" = "" ]
++ then
++ PORT=$DEFAULTPORT
++ fi
++}
++
++
++## Main program
++# We first read the settings file
++# in order to get admin-modified settings
++read_rcfile
++# Debconf-stored values are updated accordingly
++set_debconf
++# They are re-read from Debconf
++get_debconf
++# In case the package has never been configured, the settings
++# are asked through debconf
++input_settings
++# They are re-re-read from debconf
++# for updating variables
++get_debconf
++# The settings file is written
++write_rcfile
++# Then we do some other stuff, which could sometimes lead to
++# debconf showing screens
++# This is why they are here and not in the postinst script
+--- seyon-2.20c.orig/debian/control
++++ seyon-2.20c/debian/control
+@@ -0,0 +1,18 @@
++Source: seyon
++Section: comm
++Priority: extra
++Maintainer: Steve McIntyre <93sam@debian.org>
++Standards-Version: 3.6.1.1
++Build-Depends: xlibs-dev, xutils, libxaw7-dev | libxaw-dev, bison, debhelper (>= 4.1.16)
++
++Package: seyon
++Architecture: any
++Depends: ${shlibs:Depends}, xterm | x-terminal-emulator, debconf (>= 1.2.9)
++Suggests: lrzsz, ckermit
++Description: Full-featured native X11 communications program
++ Seyon is a complete full-featured modem communications package
++ for the X Window System. Some of its features are:
++ - dialing directory
++ - terminal emulation (DEC VT02, Tektronix 4014 and ANSI)
++ - script language
++ - Zmodem
+--- seyon-2.20c.orig/debian/menu
++++ seyon-2.20c/debian/menu
+@@ -0,0 +1,3 @@
++?package(seyon):needs="X11" section="Apps/Net" hints="Terminal" \
++ title="Seyon" longtitle="Seyon communications program" \
++ command="seyon"
+--- seyon-2.20c.orig/debian/prerm
++++ seyon-2.20c/debian/prerm
+@@ -0,0 +1,10 @@
++#!/bin/sh
++
++
++PACKAGE=seyon
++
++if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/$PACKAGE ]; then
++ rm -f /usr/doc/$PACKAGE
++fi
++
++#DEBHELPER#
+--- seyon-2.20c.orig/debian/changelog
++++ seyon-2.20c/debian/changelog
+@@ -0,0 +1,267 @@
++seyon (2.20c-16) unstable; urgency=low
++
++ * Added Czech debconf template. Thanks to Miroslav Kure for the
++ patch. Closes: #288019.
++
++ -- Steve McIntyre <93sam@debian.org> Mon, 03 Jan 2005 21:49:33 +0000
++
++seyon (2.20c-15) unstable; urgency=low
++
++ * Fix handling of /etc/X11/seyon/Seyon-modem on new
++ installations. Closes: #275167. Thanks to Rob Epping for the patch.
++ * Updated Standards-version and fixed some lintian warnings.
++
++ -- Steve McIntyre <93sam@debian.org> Mon, 25 Oct 2004 22:58:45 +0100
++
++seyon (2.20c-14) unstable; urgency=low
++
++ * Updated French debconf template. Thanks to Christian
++ Perrier. Closes: #216159.
++ * Added Dutch debconf template. Thanks to Tim Vandermeersch. Closes:
++ #209081.
++
++ -- Steve McIntyre <93sam@debian.org> Sun, 02 Nov 2003 16:10:08 +0000
++
++seyon (2.20c-13) unstable; urgency=low
++
++ * Fixed typo in debian/templates. Closes: #209080
++ * Update to use new serial speed interface for Linux. Closes: #206321.
++ Thanks to Elrik Fuller for the patch.
++
++ -- Steve McIntyre <93sam@debian.org> Mon, 13 Oct 2003 02:00:51 +0100
++
++seyon (2.20c-12) unstable; urgency=low
++
++ * Patch by Christian Perrier <bubulle@debian.org> :
++ - rename debian/config to debian/config.include (avoid confusion
++ with the config file needed by debconf)
++ - Now uses debconf :
++ - Depends on debconf (>= 1.2.9 for gettext)
++ - new config script (should properly handle admin-modified settings
++ -->debconf is not a registry)
++ - rewrote postint
++ - new templates file (gettext-based)
++ This should make the installation uninteractive. Closes: #147269
++ This should also remember the serial port on upgrade; Closes: #92414
++ - Any value may be entered for the modem device. Closes: #87564
++ * Make sure that the new Seyon-modem config file has the same
++ permissions as the old one.
++
++ -- Steve McIntyre <93sam@debian.org> Mon, 21 Jul 2003 20:31:27 +0100
++
++seyon (2.20c-11) unstable; urgency=high
++
++ * Real fix for the string-handling bug in FmtString(). Many thanks
++ to Barry Kitson for a _huge_ amount of work on this one.
++ * Several other less major string cleanups, again thanks to Barry.
++
++ -- Steve McIntyre <93sam@debian.org> Wed, 16 Jul 2003 01:39:22 +0100
++
++seyon (2.20c-10) unstable; urgency=low
++
++ * Fix for a nasty string-handling bug. Thanks to Barry Kitson for
++ the inspiration. Closes: #90613, #132484.
++ * Make sure we delete the generated Seyon.ad.h file on a "make clean".
++
++ -- Steve McIntyre <93sam@debian.org> Mon, 14 Jul 2003 02:49:49 +0100
++
++seyon (2.20c-9) unstable; urgency=low
++
++ * Fix multi-line strings so will build again with gcc 3.3. Closes: #196280
++ Thanks to Joshua Kwan for the patch.
++ * Finally get around to replacing the NMU version. Closes: #133890
++ Thanks Junichi...
++ * Fixed some lintian warnings
++
++ -- Steve McIntyre <93sam@debian.org> Sat, 07 Jun 2003 19:08:02 +0100
++
++seyon (2.20c-8.1) unstable; urgency=low
++
++ * NMU
++ * Do not write to $(HOME) when building. (closes: #133890)
++ * Fix build-deps to depend on libxaw7-dev | libxaw-dev instead of
++ libxaw-dev only.
++
++ -- Junichi Uekawa <dancer@debian.org> Fri, 17 May 2002 21:12:50 +0900
++
++seyon (2.20c-8) unstable; urgency=medium
++
++ * Added Build-Depends on bison. Closes: #123699.
++ * Turned app-defaults files into conffiles after lintian warning.
++
++ -- Steve McIntyre <93sam@debian.org> Wed, 19 Dec 2001 17:24:13 +0000
++
++seyon (2.20c-7) unstable; urgency=low
++
++ * Added Build-Depends on libxaw-dev. Closes: #89742.
++
++ -- Steve McIntyre <93sam@debian.org> Thu, 15 Mar 2001 15:55:19 +0000
++
++seyon (2.20c-6) unstable; urgency=low
++
++ * Properly added menu entry. Sorry! Closes: #80160.
++
++ -- Steve McIntyre <93sam@debian.org> Wed, 14 Mar 2001 00:03:32 +0000
++
++seyon (2.20c-5) unstable; urgency=low
++
++ * Added xutils to Build-Depends. Closes: #89134.
++ * Changed dependency on x-terminal-emulator to xterm | x-terminal-emulator to fix lintian warning.
++ * Added menu hint. Closes: #80160.
++ * I still think there's no better place in the menu structure than Apps/Net. Closes: #15080.
++
++ -- Steve McIntyre <93sam@debian.org> Sat, 10 Mar 2001 11:12:39 +0000
++
++seyon (2.20c-4) unstable; urgency=low
++
++ * New maintainer address.
++ * Renamed Build-Depends-Indep to Build-Depends.
++
++ -- Steve McIntyre <93sam@debian.org> Wed, 07 Mar 2001 22:53:31 +0000
++
++seyon (2.20c-3) unstable; urgency=medium
++
++ * Removed a broken usleep() declaration from SeDecl.h. Closes: #87532
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sun, 25 Feb 2001 11:31:56 +0000
++
++seyon (2.20c-2) unstable; urgency=medium
++
++ * Move app-defaults file to /etc/X11/app-defaults. Closes: #86289
++ * Now explicitly depends on x-terminal-emulator instead of imlicitly on xterm. Closes: #75343
++ * Fixed includes from SePort.c, so it now builds again. Closes: 84487
++ * Updated Standards-Version, added Build-Depends.
++ * Fixed lots of lintian warnings.
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sat, 24 Feb 2001 11:01:56 +0000
++
++seyon (2.20c-1) unstable; urgency=low
++
++ * Call makever.sh with sh, so it doesn't need to be executable. Fixes Bug#38037
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sun, 23 May 1999 20:19:56 +0100
++
++seyon (2.20c-0) unstable; urgency=low
++
++ * Hurrah! Seyon is now free! Check the copyright file for more info.
++ Fixes Bug#20914.
++ * New upstream version, new upstream maintainer (me!)
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sun, 09 May 1999 21:18:01 +0100
++
++seyon (2.14c-12) frozen unstable; urgency=low
++
++ * Removed obsolete dependency on xbase. Would be important bug if we weren'y non-free...
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sat, 06 Feb 1999 13:32:15 +0000
++
++seyon (2.14c-11) frozen unstable; urgency=low
++
++ * Replaced Suggests: for now non-existent kermit package with ckermit.
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Thu, 14 Jan 1999 23:54:15 +0000
++
++seyon (2.14c-10) frozen unstable; urgency=low
++
++ * Integrated non-maintainer diff (9.1)
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Wed, 30 Dec 1998 01:48:53 +0000
++
++seyon (2.14c-9.1) frozen unstable; urgency=low
++
++ * non-maintainer (binary-only) upload for Alpha
++ * ignore error from $(ch_commands) as chmodding the Seyon symlink fails if
++ seyon isn't installed yet (and hence no /etc/X11/seyon/Seyon file).
++
++ -- Paul Slootman <paul@debian.org> Tue, 29 Dec 1998 20:11:10 +0100
++
++seyon (2.14c-9) frozen unstable; urgency=low
++
++ * Fixed typo in mono app-default file; s/replcae/replace; thanks to Remo Badii <Remo.Badii@psi.ch> for pointing this one out.
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sun, 24 Oct 1998 20:15:08 +0100
++
++seyon (2.14c-8) unstable; urgency=low
++
++ * Fixed script-handling code so it no longer seg-faults after running a "shell" command. Fixes Bug#27015.
++ * Include examples for phonelist, protocols and startup. Fixes Bug#23268.
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sat, 17 Oct 1998 22:03:16 +0100
++
++seyon (2.14c-7) frozen unstable; urgency=low
++
++ * Added missing sunsite reference to copyright file. Fixes bug #19870
++ * Added error-checking to postinst - don't ask questions if something went wrong. Fizes bug #12608.
++ * Restores X beep after use; fixes bug #17231.
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Thu, 26 Mar 1998 22:54:54 -0000
++
++seyon (2.14c-6) unstable; urgency=low
++
++ * New maintainer
++ * Added simple man page for seyon-emu.
++ * Other packaging fixes to close bug #19402.
++ * Uses correct devices (fixes bug #15061)
++ * Postinst fixed (fixes bug #16226)
++
++ -- Steve McIntyre <stevem@chiark.greenend.org.uk> Sat, 14 Mar 1998 20:31:43 -0000
++
++seyon (2.14c-5.3) unstable; urgency=low
++
++ * Fixed postint to not fail if enter is pressed in response to the first
++ question with no 'y' or 'n'.
++ * Postinst and postrm do not use bashisms, changes them to use /bin/sh.
++
++ -- Joey Hess <joeyh@master.debian.org> Sun, 16 Nov 1997 00:42:06 -0500
++
++seyon (2.14c-5.2) unstable; urgency=low
++
++ * Libc6 release.
++
++ -- Joey Hess <joeyh@master.debian.org> Sun, 16 Nov 1997 00:42:06 -0500
++
++seyon (2.14c-5.1) unstable; urgency=low
++
++ * Changed maintainer to Debian QA Group; seyon is orphaned.
++ * Updated to use new source format (#9561).
++ * Use pristine sources.
++ * Register with menu system.
++ * Depend on xbase for xterm.
++ * Use ttyS instead of cua (#4922).
++ * If upgrading, and we used cua before, update the conffiles to use ttyS
++ instead.
++ * Include phonelist in the examples directory (#6475).
++
++ -- Joey Hess <joeyh@master.debian.org> Mon, 1 Sep 1997 13:13:24 -0400
++
++Wed Jul 24 23:18:23 1996 Sven Rudolph <sr1@inf.tu-dresden.de>
++
++ * debian.control: added exetended description (Bug#3689)
++
++ * debian.rules: corrected multiarchitecture support
++
++ * debian.control: added Section: and Priority:
++
++Thu Apr 4 19:38:36 1996 Sven Rudolph <sr1@inf.tu-dresden.de>
++
++ * releasing 2.14c-3
++
++ * rebuilt for ELF
++
++ * debian.postinst: fixed creytion of seyon-emu symlink
++
++ * debian.control: removed Package_Revision field
++ added Architecture field
++
++Thu Sep 21 23:23:52 1995 Sven Rudolph <sr1@inf.tu-dresden.de>
++
++ * moved config data to /etc/X11/seyon
++
++ * debian.postinst: postinst doesn't modify
++ /etc/X11/xinit/Xresources and
++ /etc/X11/xdm/Xresources now
++
++ * debian.control: fixed entries for DEPENDS and OPTIONAL
++ (Bug#1409, Bug#1177)
++
++ * debian.control: corrected location of manpage (Bug#490)
+--- seyon-2.20c.orig/typescript
++++ seyon-2.20c/typescript
+@@ -0,0 +1,37 @@
++Script started on Thu Feb 24 23:08:45 2000
++hammer:~/debian/seyon/seyon-2.20c$ make clean && make
++rm -f seyon
++rm -f version.h y.tab.* SeParse.c
++rm -f *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"*
++rm -f version.h
++sh ./makever.sh
++Machine type is i686, OS name is Linux
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o Seyon.o Seyon.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeActions.o SeActions.c
++bison -y -d SeParse.y
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeScan.o SeScan.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeDial.o SeDial.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeErr.o SeErr.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeGeneric.o SeGeneric.c
++rm -f SeInit.o
++gcc -c -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -DHELPFILE=\"/usr/X11R6/lib/X11/seyon.help\" SeInit.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeIo.o SeIo.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeMisc.o SeMisc.c
++mv -f y.tab.c SeParse.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeParse.o SeParse.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SePort.o SePort.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeScript.o SeScript.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeSet.o SeSet.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeSig.o SeSig.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeString.o SeString.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeSubs.o SeSubs.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeSubsX.o SeSubsX.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeSupp.o SeSupp.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeTerm.o SeTerm.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeTrans.o SeTrans.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o SeWin.o SeWin.c
++gcc -O2 -g -Wall -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -c -o MultiList.o MultiList.c
++rm -f seyon
++gcc -o seyon -O2 -g -Wall -L/usr/X11R6/lib Seyon.o SeActions.o SeScan.o SeDial.o SeErr.o SeGeneric.o SeInit.o SeIo.o SeMisc.o SeParse.o SePort.o SeScript.o SeSet.o SeSig.o SeString.o SeSubs.o SeSubsX.o SeSupp.o SeTerm.o SeTrans.o SeWin.o MultiList.o -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11
++hammer:~/debian/seyon/seyon-2.20c$
++Script done on Thu Feb 24 23:09:17 2000
diff --git a/source/xap/seyon/slack-desc b/source/xap/seyon/slack-desc
new file mode 100644
index 00000000..70c0d089
--- /dev/null
+++ b/source/xap/seyon/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+seyon: seyon (telecommunications package)
+seyon:
+seyon: Seyon is a complete full-featured telecommunications package for the
+seyon: X Window System. Some of its features are: Dialing directory that
+seyon: supports an unlimited number of entries. Terminal emulation window
+seyon: supporting DEC VT02, Tektronix 4014, and ANSI. Script language to
+seyon: automate tedious tasks such as logging into remote hosts. Unlimited
+seyon: number of slots for external file transfer protocols. Support for
+seyon: zmodem auto-download. Seyon is intended to be both simple and
+seyon: extensively configurable.
+seyon:
diff --git a/source/xap/thunar-volman/slack-desc b/source/xap/thunar-volman/slack-desc
new file mode 100644
index 00000000..a5fdf60b
--- /dev/null
+++ b/source/xap/thunar-volman/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------|
+thunar-volman: thunar-volman (Thunar Volume Manager Plugin)
+thunar-volman:
+thunar-volman: thunar-volman is an extension for the Thunar File Manager,
+thunar-volman: which enables automatic management of removable drives and
+thunar-volman: media.
+thunar-volman:
+thunar-volman: It was designed to look and act similar to gnome-volume-manager
+thunar-volman: to get consistent removable drive and media management in both
+thunar-volman: Xfce and GNOME.
+thunar-volman:
+thunar-volman:
diff --git a/source/xap/thunar-volman/thunar-volman.SlackBuild b/source/xap/thunar-volman/thunar-volman.SlackBuild
new file mode 100755
index 00000000..bf14ff9e
--- /dev/null
+++ b/source/xap/thunar-volman/thunar-volman.SlackBuild
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# Slackware build script for thunar-volman
+# http://goodies.xfce.org/releases/thunar-volman/
+
+# Copyright 2007-2009 Robby Workman, Northport, Alabama, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PRGNAM=thunar-volman
+VERSION=0.3.80
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-$PRGNAM
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || exit 1
+cd $PRGNAM-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --enable-debug=no \
+ --build=$ARCH-slackware-linux
+
+make || exit 1
+make install DESTDIR=$PKG
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a \
+ AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS \
+ $PKG/usr/doc/$PRGNAM-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/vim-gvim b/source/xap/vim-gvim
new file mode 120000
index 00000000..1a147f49
--- /dev/null
+++ b/source/xap/vim-gvim
@@ -0,0 +1 @@
+../ap/vim \ No newline at end of file
diff --git a/source/xap/windowmaker/slack-desc b/source/xap/windowmaker/slack-desc
new file mode 100644
index 00000000..ef3edbe7
--- /dev/null
+++ b/source/xap/windowmaker/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+windowmaker: windowmaker (a fast and elegant window manager)
+windowmaker:
+windowmaker: Window Maker is a window manager for the X Window System that is
+windowmaker: relatively fast and small, feature rich, easy to use, with a simple
+windowmaker: and elegant appearance reminiscent of the NeXTSTEP(tm) graphical
+windowmaker: user interface.
+windowmaker:
+windowmaker: Window Maker is part of the official GNU project.
+windowmaker:
+windowmaker:
+windowmaker:
diff --git a/source/xap/windowmaker/windowmaker.SlackBuild b/source/xap/windowmaker/windowmaker.SlackBuild
new file mode 100755
index 00000000..8736f058
--- /dev/null
+++ b/source/xap/windowmaker/windowmaker.SlackBuild
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=20060427cvs
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-windowmaker
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf WindowMaker-$VERSION
+tar xvf $CWD/WindowMaker-$VERSION.tar.bz2 || exit 1
+cd WindowMaker-$VERSION || exit 1
+
+zcat $CWD/windowmaker.no-mmx.diff.gz | patch -p1 --verbose -F 3 || exit 1
+sh autogen.sh
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+# This should be non-interactive where possible.
+zcat $CWD/wmaker.inst.diff.gz | patch -p1 --verbose || exit
+
+LINGUAS="$(cd po ; /bin/ls *.po | sed 's/.po//g')" \
+GNUSTEP_LOCAL_ROOT=/usr/lib${LIBDIRSUFFIX}/GNUstep \
+CFLAGS="$SLKCFLAGS" \
+NLSDIR=/usr/share/locale \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --sysconfdir=/etc/X11 \
+ --enable-gnome \
+ --enable-kde \
+ --enable-usermenu \
+ --with-appspath=/usr/lib${LIBDIRSUFFIX}/GNUstep/Applications \
+ --build=$ARCH-slackware-linux
+
+# NLS bugs like -i
+make $NUMJOBS || make -i || exit 1
+
+# Change /usr/local/GNUstep to /usr/lib/GNUstep in the WMRootMenu:
+sed -i -e "s#/usr/local/GNUstep/Applications/WPrefs.app/#/usr/lib${LIBDIRSUFFIX}/GNUstep/Applications/WPrefs.app/#" \
+ $(grep -lr '/usr/local/GNUstep/Applications/WPrefs.app/' *)
+
+make -i install DESTDIR=$PKG
+mkdir -p $PKG/usr/doc/WindowMaker-$VERSION
+cp -a \
+ AUTHORS BUGFORM BUGS COPYING COPYING.WTFPL FAQ FAQ.I18N FAQ.I18N.cs FAQ.I18N.sk INSTALL INSTALL.cs INSTALL.es INSTALL.fr INSTALL.pt INSTALL.sk MIRRORS NEWS README README.definable-cursor README.pt TODO \
+ $PKG/usr/doc/WindowMaker-$VERSION
+cd $TMP
+rm -rf WindowMaker-extra-0.1
+tar xvf $CWD/WindowMaker-extra-0.1.tar.gz || exit 1
+cd WindowMaker-extra-0.1 || exit 1
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --with-iconsdir=/usr/share/pixmaps \
+ $ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/etc/X11/xinit
+cat $CWD/xinitrc.wmaker > $PKG/etc/X11/xinit/xinitrc.wmaker
+chmod 755 $PKG/etc/X11/xinit/xinitrc.wmaker
+
+gzip -9 $PKG/usr/man/man1/* $PKG/usr/man/sk/man1/*
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/windowmaker-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/windowmaker/windowmaker.no-mmx.diff b/source/xap/windowmaker/windowmaker.no-mmx.diff
new file mode 100644
index 00000000..277cc79e
--- /dev/null
+++ b/source/xap/windowmaker/windowmaker.no-mmx.diff
@@ -0,0 +1,19 @@
+--- ./configure.ac.01 2008-06-02 08:42:30.000000000 +0200
++++ ./configure.ac 2008-06-02 08:46:49.000000000 +0200
+@@ -190,7 +190,15 @@
+ # until we fix it, leave it disabled
+ asm_support=no
+ mmx_support=no
+-if test "$ac_cv_prog_gcc" = yes; then
++
++check_for_mmx_support=yes
++AC_ARG_ENABLE(mmx,
++ [ --disable-mmx disable compilation of MMX inline assembly ],
++ [if test x$enableval != xyes; then
++ check_for_mmx_support=no
++ fi])
++
++if test "$ac_cv_prog_gcc" = yes -a "$check_for_mmx_support" = yes; then
+ case $host_cpu in
+ *i?86*)
+ # gcc-3.3 or newer complains about some of our stuff without this
diff --git a/source/xap/windowmaker/wmaker.inst.diff b/source/xap/windowmaker/wmaker.inst.diff
new file mode 100644
index 00000000..c80edd34
--- /dev/null
+++ b/source/xap/windowmaker/wmaker.inst.diff
@@ -0,0 +1,45 @@
+--- ./util/wmaker.inst.in.orig 2002-05-30 13:13:46.000000000 -0700
++++ ./util/wmaker.inst.in 2002-05-30 13:16:37.000000000 -0700
+@@ -37,19 +37,7 @@
+ make_script() {
+ ISCRIPT=$1
+
+- cat << EOF >> $ISCRIPT
+-# Window Maker default X session startup script
+-
+-PATH="\$PATH:$BINDIR"
+-
+-# If you login from xdm, uncomment this to make error messages appear
+-# in the console window.
+-#
+-# tail -f $HOME/.xsession-errors > /dev/console &
+-
+-exec wmaker
+-
+-EOF
++ cat /etc/X11/xinit/xinitrc.wmaker >> $ISCRIPT
+ chmod +rx $ISCRIPT
+ }
+
+@@ -329,20 +317,7 @@
+
+ trap "show_end_message;exit" 2
+
+-echo
+-echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
+-echo "it calls wmaker when you start an X session."
+-echo "Type the name of the file that must be changed (normally .xinitrc)."
+-echo "If the file already exists, it will be backed up with a .old.$DATE "
+-echo "extension"
+-echo "If you want to edit it by hand, hit <Control>-C now."
+-read file
+-
+-if test "x$file" = "x"; then
+- echo "Using .xinitrc as a default value"
+- file=.xinitrc
+-fi
+-
++file=.xinitrc
+ if [ -f $USERDIR/$file ]; then
+ mv $USERDIR/$file $USERDIR/$file.old.$DATE
+ fi
diff --git a/source/xap/windowmaker/xinitrc.wmaker b/source/xap/windowmaker/xinitrc.wmaker
new file mode 100644
index 00000000..4e28503b
--- /dev/null
+++ b/source/xap/windowmaker/xinitrc.wmaker
@@ -0,0 +1,38 @@
+#!/bin/sh
+# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
+
+userresources=$HOME/.Xresources
+usermodmap=$HOME/.Xmodmap
+sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
+sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
+
+# merge in defaults and keymaps
+
+if [ -f $sysresources ]; then
+ xrdb -merge $sysresources
+fi
+
+if [ -f $sysmodmap ]; then
+ xmodmap $sysmodmap
+fi
+
+if [ -f $userresources ]; then
+ xrdb -merge $userresources
+fi
+
+if [ -f $usermodmap ]; then
+ xmodmap $usermodmap
+fi
+
+# If the user lacks $HOME/GNUstep, install it:
+if [ ! -f $HOME/GNUstep/Defaults/WindowMaker ]; then
+ wmaker.inst
+fi
+
+# Test for cpp, which wmaker uses to process config files:
+if [ ! -x /usr/bin/cpp ]; then
+ NOCPP="--no-cpp"
+fi
+
+# Start the window manager:
+exec /usr/bin/wmaker $NOCPP
diff --git a/source/xap/x11-ssh-askpass/README b/source/xap/x11-ssh-askpass/README
new file mode 100644
index 00000000..e1247b38
--- /dev/null
+++ b/source/xap/x11-ssh-askpass/README
@@ -0,0 +1,10 @@
+x11-ssh-askpass is an X11-based passphrase dialog for use with OpenSSH.
+
+To utilize this service, you will need a private SSH key in ~/.ssh/
+If you log on using kdm, then just create a ~/.xprofile with the
+contents of /usr/doc/x11-ssh-askpass-1.2.4.1/xprofile.sample
+
+If you are launching X from console (with startx), then you can edit your
+~/.xinitrc to source ~/.xprofile or just add the contents of ~/.xprofile
+to ~/.xinitrc to it. Of course, there are other acceptable ways to do
+the same thing - gurus can roll their own.
diff --git a/source/xap/x11-ssh-askpass/slack-desc b/source/xap/x11-ssh-askpass/slack-desc
new file mode 100644
index 00000000..d467253f
--- /dev/null
+++ b/source/xap/x11-ssh-askpass/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler---------------------------------------------|
+x11-ssh-askpass: x11-ssh-askpass (an X11-based passphrase dialog)
+x11-ssh-askpass:
+x11-ssh-askpass: x11-ssh-askpass is an X11-based passphrase dialog for use
+x11-ssh-askpass: with OpenSSH.
+x11-ssh-askpass:
+x11-ssh-askpass:
+x11-ssh-askpass:
+x11-ssh-askpass:
+x11-ssh-askpass:
+x11-ssh-askpass:
+x11-ssh-askpass:
diff --git a/source/xap/x11-ssh-askpass/x11-ssh-askpass.SlackBuild b/source/xap/x11-ssh-askpass/x11-ssh-askpass.SlackBuild
new file mode 100755
index 00000000..837b7f8a
--- /dev/null
+++ b/source/xap/x11-ssh-askpass/x11-ssh-askpass.SlackBuild
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# Slackware build script for x11-ssh-askpass
+# Written by "Vincent Batts <vbatts@batts.mine.nu>"
+
+# Modified by Robby Workman <rworkman@slackbuilds.org>
+
+VERSION=1.2.4.1
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+TAG=${TAG:-}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-x11-ssh-askpass
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf x11-ssh-askpass-$VERSION
+tar xvf $CWD/x11-ssh-askpass-$VERSION.tar.gz
+cd x11-ssh-askpass-$VERSION
+chown -R root:root .
+chmod -R a-s,u+rw,go+r-w .
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --with-app-defaults-dir=/etc/X11/app-defaults
+
+xmkmf || exit 1
+make includes || exit 1
+make || exit 1
+make install DESTDIR=$PKG || exit 1
+make install.man DESTDIR=$PKG || exit 1
+
+( cd $PKG
+ find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \
+ xargs strip --strip-unneeded 2> /dev/null || true
+ find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \
+ xargs strip --strip-unneeded 2> /dev/null
+)
+
+gzip -9 $PKG/usr/man/man1/x11-ssh-askpass.1x
+
+mkdir -p $PKG/usr/doc/x11-ssh-askpass-$VERSION
+cp README $CWD/xprofile.sample $PKG/usr/doc/x11-ssh-askpass-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/x11-ssh-askpass-$VERSION-$ARCH-$BUILD$TAG.txz
diff --git a/source/xap/x11-ssh-askpass/x11-ssh-askpass.info b/source/xap/x11-ssh-askpass/x11-ssh-askpass.info
new file mode 100644
index 00000000..3a94bf36
--- /dev/null
+++ b/source/xap/x11-ssh-askpass/x11-ssh-askpass.info
@@ -0,0 +1,10 @@
+PRGNAM="x11-ssh-askpass"
+VERSION="1.2.4.1"
+HOMEPAGE="http://www.jmknoble.net/software/x11-ssh-askpass/"
+DOWNLOAD="http://www.jmknoble.net/software/x11-ssh-askpass/x11-ssh-askpass-1.2.4.1.tar.gz"
+MD5SUM="8f2e41f3f7eaa8543a2440454637f3c3"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+MAINTAINER="Vincent Batts"
+EMAIL="vbatts@batts.mine.nu"
+APPROVED="rworkman"
diff --git a/source/xap/x11-ssh-askpass/xprofile.sample b/source/xap/x11-ssh-askpass/xprofile.sample
new file mode 100644
index 00000000..dce0eae0
--- /dev/null
+++ b/source/xap/x11-ssh-askpass/xprofile.sample
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+usessh=${usessh:-yes}
+
+if test "$usessh" = "yes" -a -d $HOME/.ssh ; then
+ SSH_ASKPASS="/usr/libexec/x11-ssh-askpass"
+ if [ -x $SSH_ASKPASS ] ; then
+ export SSH_ASKPASS
+ ssh-agent > $HOME/.ssh/agent
+ . $HOME/.ssh/agent
+ ssh-add
+ fi
+fi
+
diff --git a/source/xap/x3270/doinst.sh b/source/xap/x3270/doinst.sh
new file mode 100644
index 00000000..049c91e4
--- /dev/null
+++ b/source/xap/x3270/doinst.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+config() {
+ NEW="$1"
+ OLD="`dirname $NEW`/`basename $NEW .new`"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+config etc/X11/x3270/ibm_hosts.new
+
+# Update the X font indexes:
+if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
+ ( cd /usr/share/fonts/misc
+ mkfontscale .
+ mkfontdir -e /usr/share/fonts/encodings -e /usr/share/fonts/encodings/large .
+ )
+fi
+if [ -x /usr/bin/fc-cache ]; then
+ /usr/bin/fc-cache -f
+fi
diff --git a/source/xap/x3270/slack-desc b/source/xap/x3270/slack-desc
new file mode 100644
index 00000000..15eff71d
--- /dev/null
+++ b/source/xap/x3270/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+x3270: x3270 (IBM host access tool for X)
+x3270:
+x3270: x3270 opens a telnet connection to an IBM host in an X window. Since
+x3270: the window created by x3270 can use its own font for displaying
+x3270: characters, is a fairly accurate representation of an IBM 3278.
+x3270:
+x3270:
+x3270:
+x3270:
+x3270:
+x3270:
diff --git a/source/xap/x3270/x3270.SlackBuild b/source/xap/x3270/x3270.SlackBuild
new file mode 100755
index 00000000..225142a2
--- /dev/null
+++ b/source/xap/x3270/x3270.SlackBuild
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+TARBVER=3.3.7p8
+VERSION=3.3.7p8
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-x3270
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP
+rm -rf x3270-$VERSION
+tar xvf $CWD/x3270-$TARBVER.tar.bz2 || exit 1
+cd x3270-3.3 || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/X11 \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG
+
+mv $PKG/etc/X11/x3270/ibm_hosts $PKG/etc/X11/x3270/ibm_hosts.new
+find $PKG -name fonts.dir -exec rm {} \;
+if [ -d $PKG/usr/lib/X11/fonts/misc ]; then
+ mkdir -p $PKG/usr/share/fonts
+ mv $PKG/usr/lib/X11/fonts/misc $PKG/usr/share/fonts
+ rmdir $PKG/usr/lib/X11/fonts/misc 2> /dev/null
+ rmdir $PKG/usr/lib/X11/fonts 2> /dev/null
+ rmdir $PKG/usr/lib/X11 2> /dev/null
+ rmdir $PKG/usr/lib 2> /dev/null
+fi
+
+mkdir -p $PKG/etc/X11/app-defaults
+cat X3270.xad > $PKG/etc/X11/app-defaults/X3270
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/man/man{1,5}
+for file in x3270-script.man x3270.man x3270if.man ; do
+ cat $file | gzip -9c > $PKG/usr/man/man1/`basename $file .man`.1.gz
+done
+cat ibm_hosts.man | gzip -9c > $PKG/usr/man/man5/ibm_hosts.5.gz
+
+mkdir -p $PKG/usr/doc/x3270-$VERSION
+cp -a \
+ LICENSE README* Examples html \
+ $PKG/usr/doc/x3270-$VERSION
+
+mkdir -p $PKG/install
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/x3270-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xchat/patches/patches.url b/source/xap/xchat/patches/patches.url
new file mode 100644
index 00000000..33531f7c
--- /dev/null
+++ b/source/xap/xchat/patches/patches.url
@@ -0,0 +1 @@
+http://xchat.org/files/source/2.8/patches/
diff --git a/source/xap/xchat/patches/xc286-smallfixes.diff b/source/xap/xchat/patches/xc286-smallfixes.diff
new file mode 100644
index 00000000..da900152
--- /dev/null
+++ b/source/xap/xchat/patches/xc286-smallfixes.diff
@@ -0,0 +1,68 @@
+#
+# Various small fixes from CVS that are considered safe to apply to 2.8.6.
+#
+--- xchat-2.8.6/src/common/cfgfiles.c 2008-02-05 21:02:47.000000000 +1100
++++ xchat-2.8.6p1/src/common/cfgfiles.c 2008-06-15 13:45:43.000000000 +1000
+@@ -886,7 +886,6 @@
+ set_showval (session *sess, const struct prefs *var, char *tbuf)
+ {
+ int len, dots, j;
+- static const char *offon[] = { "OFF", "ON" };
+
+ len = strlen (var->name);
+ memcpy (tbuf, var->name, len);
+@@ -909,8 +908,10 @@
+ *((int *) &prefs + var->offset));
+ break;
+ case TYPE_BOOL:
+- sprintf (tbuf + len, "\0033:\017 %s\n", offon[
+- *((int *) &prefs + var->offset)]);
++ if (*((int *) &prefs + var->offset))
++ sprintf (tbuf + len, "\0033:\017 %s\n", "ON");
++ else
++ sprintf (tbuf + len, "\0033:\017 %s\n", "OFF");
+ break;
+ }
+ PrintText (sess, tbuf);
+--- xchat-2.8.6/src/common/chanopt.c 2008-06-10 22:00:55.000000000 +1000
++++ xchat-2.8.6p1/src/common/chanopt.c 2008-06-15 13:48:04.000000000 +1000
+@@ -32,7 +32,7 @@
+
+ #define S_F(xx) STRUCT_OFFSET_STR(struct session,xx)
+
+-channel_options chanopt[] =
++static const channel_options chanopt[] =
+ {
+ {"alert_beep", "BEEP", S_F(alert_beep)},
+ {"alert_taskbar", NULL, S_F(alert_taskbar)},
+--- xchat-2.8.6/src/common/servlist.c 2008-04-01 19:22:34.000000000 +1100
++++ xchat-2.8.6p1/src/common/servlist.c 2008-06-15 13:57:41.000000000 +1000
+@@ -509,6 +509,8 @@
+ list = g_slist_nth (net->servlist, net->selected);
+ if (!list)
+ list = net->servlist;
++ if (!list)
++ return;
+ ircserv = list->data;
+
+ /* incase a protocol switch is added to the servlist gui */
+--- xchat-2.8.6/src/common/text.c 2008-03-28 13:20:04.000000000 +1100
++++ xchat-2.8.6p1/src/common/text.c 2008-06-15 13:59:59.000000000 +1000
+@@ -216,7 +216,7 @@
+ static void
+ scrollback_save (session *sess, char *text)
+ {
+- char buf[1024];
++ char buf[512 * 4];
+ time_t stamp;
+ int len;
+
+@@ -266,7 +266,7 @@
+ scrollback_load (session *sess)
+ {
+ int fh;
+- char buf[1024];
++ char buf[512 * 4];
+ char *text;
+ time_t stamp;
+ int lines;
diff --git a/source/xap/xchat/patches/xchat.gtk_2_14.diff b/source/xap/xchat/patches/xchat.gtk_2_14.diff
new file mode 100644
index 00000000..f0a42a1c
--- /dev/null
+++ b/source/xap/xchat/patches/xchat.gtk_2_14.diff
@@ -0,0 +1,191 @@
+diff -ur xchat-2.8.6.orig/src/fe-gtk/about.c xchat-2.8.6/src/fe-gtk/about.c
+--- xchat-2.8.6.orig/src/fe-gtk/about.c 2008-04-01 10:58:38.000000000 +0200
++++ xchat-2.8.6/src/fe-gtk/about.c 2008-10-12 14:12:59.329706289 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/ascii.c xchat-2.8.6/src/fe-gtk/ascii.c
+--- xchat-2.8.6.orig/src/fe-gtk/ascii.c 2008-02-05 11:02:50.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/ascii.c 2008-10-12 14:12:59.329706289 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/banlist.c xchat-2.8.6/src/fe-gtk/banlist.c
+--- xchat-2.8.6.orig/src/fe-gtk/banlist.c 2008-02-05 11:02:50.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/banlist.c 2008-10-12 14:12:59.329706289 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/fe-gtk.c xchat-2.8.6/src/fe-gtk/fe-gtk.c
+--- xchat-2.8.6.orig/src/fe-gtk/fe-gtk.c 2008-02-24 09:39:44.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/fe-gtk.c 2008-10-12 14:12:59.339702951 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/ignoregui.c xchat-2.8.6/src/fe-gtk/ignoregui.c
+--- xchat-2.8.6.orig/src/fe-gtk/ignoregui.c 2008-02-05 11:02:52.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/ignoregui.c 2008-10-12 14:12:59.343034799 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/maingui.c xchat-2.8.6/src/fe-gtk/maingui.c
+--- xchat-2.8.6.orig/src/fe-gtk/maingui.c 2008-04-01 10:53:41.000000000 +0200
++++ xchat-2.8.6/src/fe-gtk/maingui.c 2008-10-12 14:12:59.349699891 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdlib.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/menu.c xchat-2.8.6/src/fe-gtk/menu.c
+--- xchat-2.8.6.orig/src/fe-gtk/menu.c 2008-06-08 09:59:37.000000000 +0200
++++ xchat-2.8.6/src/fe-gtk/menu.c 2008-10-12 14:12:59.349699891 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/notifygui.c xchat-2.8.6/src/fe-gtk/notifygui.c
+--- xchat-2.8.6.orig/src/fe-gtk/notifygui.c 2008-02-05 11:03:34.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/notifygui.c 2008-10-12 14:12:59.363033500 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/palette.c xchat-2.8.6/src/fe-gtk/palette.c
+--- xchat-2.8.6.orig/src/fe-gtk/palette.c 2008-02-05 11:02:52.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/palette.c 2008-10-12 14:12:59.363033500 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <stdlib.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/pixmaps.c xchat-2.8.6/src/fe-gtk/pixmaps.c
+--- xchat-2.8.6.orig/src/fe-gtk/pixmaps.c 2008-02-05 11:02:52.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/pixmaps.c 2008-10-12 14:12:59.363033500 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/plugingui.c xchat-2.8.6/src/fe-gtk/plugingui.c
+--- xchat-2.8.6.orig/src/fe-gtk/plugingui.c 2008-02-05 11:02:52.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/plugingui.c 2008-10-12 14:12:59.363033500 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <string.h>
+ #include <stdio.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/rawlog.c xchat-2.8.6/src/fe-gtk/rawlog.c
+--- xchat-2.8.6.orig/src/fe-gtk/rawlog.c 2008-02-24 05:49:37.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/rawlog.c 2008-10-12 14:12:59.366369608 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/search.c xchat-2.8.6/src/fe-gtk/search.c
+--- xchat-2.8.6.orig/src/fe-gtk/search.c 2008-02-05 11:02:53.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/search.c 2008-10-12 14:12:59.369703062 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/urlgrab.c xchat-2.8.6/src/fe-gtk/urlgrab.c
+--- xchat-2.8.6.orig/src/fe-gtk/urlgrab.c 2008-02-05 11:02:53.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/urlgrab.c 2008-10-12 14:12:59.376368714 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/userlistgui.c xchat-2.8.6/src/fe-gtk/userlistgui.c
+--- xchat-2.8.6.orig/src/fe-gtk/userlistgui.c 2008-02-05 11:02:53.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/userlistgui.c 2008-10-12 14:12:59.379703216 +0200
+@@ -16,7 +16,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+-#define GTK_DISABLE_DEPRECATED
++/* #define GTK_DISABLE_DEPRECATED */
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur xchat-2.8.6.orig/src/fe-gtk/xtext.h xchat-2.8.6/src/fe-gtk/xtext.h
+--- xchat-2.8.6.orig/src/fe-gtk/xtext.h 2008-02-24 05:48:02.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/xtext.h 2008-10-12 14:10:49.203049619 +0200
+@@ -1,6 +1,7 @@
+ #ifndef __XTEXT_H__
+ #define __XTEXT_H__
+
++#include <gtk/gtktypeutils.h>
+ #include <gtk/gtkadjustment.h>
+ #ifdef USE_XFT
+ #include <X11/Xft/Xft.h>
diff --git a/source/xap/xchat/slack-desc b/source/xap/xchat/slack-desc
new file mode 100644
index 00000000..70c75e67
--- /dev/null
+++ b/source/xap/xchat/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xchat: xchat (GTK+-based IRC client)
+xchat:
+xchat: X-Chat is a GTK+-based IRC (Internet Relay Chat) client.
+xchat:
+xchat:
+xchat:
+xchat:
+xchat:
+xchat:
+xchat:
+xchat:
diff --git a/source/xap/xchat/xchat.SlackBuild b/source/xap/xchat/xchat.SlackBuild
new file mode 100755
index 00000000..1f05472b
--- /dev/null
+++ b/source/xap/xchat/xchat.SlackBuild
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=2.8.6
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-3}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xchat
+rm -rf $PKG
+mkdir -p $TMP $PKG/usr
+
+cd $TMP
+rm -rf xchat-$VERSION
+tar xvf $CWD/xchat-$VERSION.tar.bz2 || exit 1
+cd xchat-$VERSION || exit 1
+if [ -d $CWD/patches ]; then
+ for file in $CWD/patches/*.diff.gz ; do
+ zcat $file | patch -p1 --verbose || exit 1
+ done
+fi
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --localstatedir=/var/lib \
+ --enable-tcl=/usr/lib${LIBDIRSUFFIX} \
+ --enable-ipv6 \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/xchat-$VERSION
+cp -a \
+ AUTHORS COPYING HACKING INSTALL README \
+ $PKG/usr/doc/xchat-$VERSION
+
+# In case they ever add this stuff:
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+# Compress info pages and purge "dir" file from the package:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $TMP/package-xchat
+/sbin/makepkg -l y -c n $TMP/xchat-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xfce/patches/exo_quoting_fix.diff b/source/xap/xfce/patches/exo_quoting_fix.diff
new file mode 100644
index 00000000..ac654457
--- /dev/null
+++ b/source/xap/xfce/patches/exo_quoting_fix.diff
@@ -0,0 +1,66 @@
+Index: exo-open/main.c
+===================================================================
+--- exo-open/main.c (revision 30250)
++++ exo-open/main.c (revision 30251)
+@@ -36,7 +36,17 @@
+ #include <exo/exo.h>
+
+
++/**
++ * For testing this code the following commands should work:
++ *
++ * exo-open --launch WebBrowser http://xfce.org (bug #5461).
++ * exo-open http://xfce.org
++ * exo-open --launch TerminalEmulator ./script.sh 'something with a space' 'nospace' (bug #5132).
++ * exo-open --launch TerminalEmulator ssh -l username some.host.com
++ **/
+
++
++
+ static gboolean opt_help = FALSE;
+ static gboolean opt_version = FALSE;
+ static gchar *opt_launch = NULL;
+@@ -143,6 +153,8 @@
+ {
+ if (argc > 1)
+ {
++ /* NOTE: see the comment at the top of this document! */
++
+ /* combine all specified parameters to one parameter string */
+ join = g_string_new (NULL);
+ for (i = 1; argv[i] != NULL; i++)
+@@ -150,11 +162,18 @@
+ /* separate the arguments */
+ if (i > 1)
+ join = g_string_append_c (join, ' ');
+-
+- /* append the quoted argument */
+- quoted = g_shell_quote (argv[i]);
+- join = g_string_append (join, quoted);
+- g_free (quoted);
++
++ /* only quote arguments with spaces */
++ if (strchr (argv[i], ' ') != NULL)
++ {
++ quoted = g_shell_quote (argv[i]);
++ join = g_string_append (join, quoted);
++ g_free (quoted);
++ }
++ else
++ {
++ join = g_string_append (join, argv[i]);
++ }
+ }
+ parameter = g_string_free (join, FALSE);
+ }
+@@ -163,6 +182,10 @@
+ parameter = NULL;
+ }
+
++#ifndef NDEBUG
++ g_message ("launch=%s, wd=%s, parameters (%d)=%s", opt_launch, opt_working_directory, argc, parameter);
++#endif
++
+ /* run the preferred application */
+ if (!exo_execute_preferred_application (opt_launch, parameter, opt_working_directory, NULL, &err))
+ {
diff --git a/source/xap/xfce/patches/launcher-plugin-migrate-icon-cat.diff b/source/xap/xfce/patches/launcher-plugin-migrate-icon-cat.diff
new file mode 100644
index 00000000..4370281a
--- /dev/null
+++ b/source/xap/xfce/patches/launcher-plugin-migrate-icon-cat.diff
@@ -0,0 +1,48 @@
+diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
+index 8edc66c..1e370c4 100644
+--- a/plugins/launcher/launcher.c
++++ b/plugins/launcher/launcher.c
+@@ -37,6 +37,30 @@
+ #include "launcher-exec.h"
+ #include "launcher-dialog.h"
+
++/* for 4.4 settings migration */
++static const gchar *icon_category_map[] = {
++ "applications-other",
++ "accessories-text-editor",
++ "system-file-manager",
++ "applications-accessories",
++ "applications-games",
++ "help-browser",
++ "applications-multimedia",
++ "applications-internet",
++ "applications-graphics",
++ "printer",
++ "office-calendar",
++ "applications-office",
++ "audio-card",
++ "utilities-terminal",
++ "applications-development",
++ "preferences-desktop",
++ "applications-system",
++ "applications-other",
++ "applications-accessories",
++};
++#define ICON_CATEGORY_MAP_MAX (G_N_ELEMENTS (icon_category_map) - 1)
++
+ /* prototypes */
+ static void launcher_utility_icon_theme_changed (GtkIconTheme *icon_theme,
+ LauncherPlugin *launcher);
+@@ -1216,6 +1240,12 @@ launcher_plugin_read (LauncherPlugin *launcher)
+ entry->name = launcher_plugin_read_entry (rc, "Name");
+ entry->comment = launcher_plugin_read_entry (rc, "Comment");
+ entry->icon = launcher_plugin_read_entry (rc, "Icon");
++ if (G_UNLIKELY (!entry->icon))
++ {
++ gint icon_category = xfce_rc_read_int_entry (rc, "X-XFCE-IconCategory", -1);
++ if (G_LIKELY (icon_category >= 0 && icon_category <= ICON_CATEGORY_MAP_MAX))
++ entry->icon = g_strdup (icon_category_map[icon_category]);
++ }
+ entry->exec = launcher_plugin_read_entry (rc, "Exec");
+ entry->path = launcher_plugin_read_entry (rc, "Path");
+
diff --git a/source/xap/xfce/patches/migrate-itheme-smartly.diff b/source/xap/xfce/patches/migrate-itheme-smartly.diff
new file mode 100644
index 00000000..e9c66ed2
--- /dev/null
+++ b/source/xap/xfce/patches/migrate-itheme-smartly.diff
@@ -0,0 +1,92 @@
+Index: scripts/xfconf-migration-4.6.pl.in
+===================================================================
+--- a/scripts/xfconf-migration-4.6.pl.in (revision 29645)
++++ b/scripts/xfconf-migration-4.6.pl.in (working copy)
+@@ -256,6 +256,77 @@
+ return $mcs.'.xml';
+ }
+
++sub icon_theme_exists
++{
++ my ($dirref,$themename) = @_;
++ my @dirs = @{$dirref};
++
++ foreach my $d (@dirs) {
++ return 1 if(-f "$d/$themename/index.theme");
++ }
++
++ return 0;
++}
++
++sub migrate_icon_theme
++{
++ my ($ref,$chan) = @_;
++ my %opts = %{$ref};
++ my $opt = 'Net/IconThemeName';
++
++ return if(!defined($opts{$opt}));
++ my $val = $opts{$opt}->{'value'};
++
++ if(lc($val) eq 'rodent') {
++ # we don't ship rodent anymore, so try to find something suitable
++ my @icondirs;
++ if(defined($ENV{'XDG_DATA_HOME'})) {
++ @icondirs = ( $ENV{'XDG_DATA_HOME'} . '/icons' );
++ } else {
++ @icondirs = ( $ENV{'HOME'} . '/.local/share/icons' );
++ }
++
++ if(defined($ENV{'XDG_DATA_DIRS'})) {
++ push(@icondirs, split(/:/, $ENV{'XDG_DATA_DIRS'}));
++ } else {
++ push(@icondirs, ( '/usr/share/icons', '/usr/local/share/icons' ));
++ }
++
++ $val = undef;
++ foreach my $itheme (('Tango', 'gnome', 'crystalsvg')) {
++ if(icon_theme_exists(\@icondirs, $itheme)) {
++ $val = $itheme;
++ last;
++ }
++ }
++
++ if(!defined($val)) {
++ # pick the first one that is not 'hicolor'
++ foreach my $d (@icondirs) {
++ opendir(DIR, $d) and do {
++ my @subdirs = grep { $_ ne 'hicolor' && -d "$d/$_" } readdir(DIR);
++ foreach my $sd (@subdirs) {
++ if(-f "$d/$sd/index.theme") {
++ $val = $sd;
++ last;
++ }
++ }
++ closedir(DIR);
++ };
++ last if(defined($val));
++ }
++
++ if(!defined($val)) {
++ # ok, their system is kinda b0rked; not much we can do
++ warn("Couldn't find a suitable icon theme to migrate to");
++ return;
++ }
++ }
++ }
++
++ xfconf_set($chan, 'string', '/Net/IconThemeName', $val);
++}
++
+ sub migrate_xsettings
+ {
+ my $mcs = 'gtk';
+@@ -283,8 +354,7 @@
+ '/Net/CursorBlinkTime', 'int');
+ save_xfconf_prop($ref, $chan, 'Net/DndDragThreshold',
+ '/Net/DndDragThreshold', 'int');
+- save_xfconf_prop($ref, $chan, 'Net/IconThemeName',
+- '/Net/IconThemeName', 'string');
++ migrate_icon_theme($ref, $chan);
+ save_xfconf_prop($ref, $chan, 'Net/ThemeName',
+ '/Net/ThemeName', 'string');
+
diff --git a/source/xap/xfce/patches/terminal-0.4.0-fixup_docdir.diff b/source/xap/xfce/patches/terminal-0.4.0-fixup_docdir.diff
new file mode 100644
index 00000000..d9608470
--- /dev/null
+++ b/source/xap/xfce/patches/terminal-0.4.0-fixup_docdir.diff
@@ -0,0 +1,132 @@
+diff -Nur Terminal-0.4.0.orig/Makefile.in Terminal-0.4.0/Makefile.in
+--- Terminal-0.4.0.orig/Makefile.in 2009-07-20 13:04:04.000000000 -0500
++++ Terminal-0.4.0/Makefile.in 2009-07-20 13:50:20.529864039 -0500
+@@ -986,7 +986,7 @@
+
+ TerminalHelp: TerminalHelp.in Makefile
+ rm -f TerminalHelp.gen TerminalHelp
+- sed -e "s,\@datadir\@,$(datadir),g" \
++ sed -e "s,\@docdir\@,$(docdir),g" \
+ < $(srcdir)/TerminalHelp.in \
+ > TerminalHelp.gen
+ mv TerminalHelp.gen TerminalHelp
+diff -Nur Terminal-0.4.0.orig/TerminalHelp.in Terminal-0.4.0/TerminalHelp.in
+--- Terminal-0.4.0.orig/TerminalHelp.in 2009-07-20 13:03:50.000000000 -0500
++++ Terminal-0.4.0/TerminalHelp.in 2009-07-20 13:50:20.529864039 -0500
+@@ -19,7 +19,7 @@
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #
+
+-HELPDIR="@datadir@/doc/Terminal/"
++HELPDIR="@docdir@/"
+
+ if test -n "$LC_ALL"; then
+ LC=$LC_ALL
+diff -Nur Terminal-0.4.0.orig/doc/C/Makefile.in Terminal-0.4.0/doc/C/Makefile.in
+--- Terminal-0.4.0.orig/doc/C/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/C/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -260,7 +260,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Terminal/C
++TARGET_DIR = $(docdir)/C
+ STYLESHEET = ../terminal.xsl
+ DOCUMENT = Terminal.xml
+
+diff -Nur Terminal-0.4.0.orig/doc/C/images/Makefile.in Terminal-0.4.0/doc/C/images/Makefile.in
+--- Terminal-0.4.0.orig/doc/C/images/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/C/images/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -240,7 +240,7 @@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-imagesdir = $(datadir)/doc/Terminal/C/images
++imagesdir = $(docdir)/C/images
+ images_DATA = \
+ terminal-compose-shortcut.png \
+ terminal-edit-preferences.png \
+diff -Nur Terminal-0.4.0.orig/doc/Makefile.in Terminal-0.4.0/doc/Makefile.in
+--- Terminal-0.4.0.orig/doc/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/Makefile.in 2009-07-20 13:51:00.229192942 -0500
+@@ -286,7 +286,7 @@
+ fr \
+ ja
+
+-cssdir = $(datadir)/doc/Terminal
++cssdir = $(docdir)/
+ css_DATA = \
+ terminal.css
+
+diff -Nur Terminal-0.4.0.orig/doc/da/Makefile.in Terminal-0.4.0/doc/da/Makefile.in
+--- Terminal-0.4.0.orig/doc/da/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/da/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -260,7 +260,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Terminal/da
++TARGET_DIR = $(docdir)/da
+ STYLESHEET = ../terminal.xsl
+ DOCUMENT = Terminal.xml
+
+diff -Nur Terminal-0.4.0.orig/doc/da/images/Makefile.in Terminal-0.4.0/doc/da/images/Makefile.in
+--- Terminal-0.4.0.orig/doc/da/images/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/da/images/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -240,7 +240,7 @@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-imagesdir = $(datadir)/doc/Terminal/da/images
++imagesdir = $(docdir)/da/images
+ images_DATA = \
+ terminal-compose-shortcut.png \
+ terminal-edit-preferences.png \
+diff -Nur Terminal-0.4.0.orig/doc/fr/Makefile.in Terminal-0.4.0/doc/fr/Makefile.in
+--- Terminal-0.4.0.orig/doc/fr/Makefile.in 2009-07-20 13:04:02.000000000 -0500
++++ Terminal-0.4.0/doc/fr/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -260,7 +260,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Terminal/fr
++TARGET_DIR = $(docdir)/fr
+ STYLESHEET = ../terminal.xsl
+ DOCUMENT = Terminal.xml
+
+diff -Nur Terminal-0.4.0.orig/doc/fr/images/Makefile.in Terminal-0.4.0/doc/fr/images/Makefile.in
+--- Terminal-0.4.0.orig/doc/fr/images/Makefile.in 2009-07-20 13:04:03.000000000 -0500
++++ Terminal-0.4.0/doc/fr/images/Makefile.in 2009-07-20 13:50:20.533867320 -0500
+@@ -240,7 +240,7 @@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-imagesdir = $(datadir)/doc/Terminal/fr/images
++imagesdir = $(docdir)/fr/images
+ images_DATA = \
+ terminal-compose-shortcut.png \
+ terminal-edit-preferences.png \
+diff -Nur Terminal-0.4.0.orig/doc/ja/Makefile.in Terminal-0.4.0/doc/ja/Makefile.in
+--- Terminal-0.4.0.orig/doc/ja/Makefile.in 2009-07-20 13:04:03.000000000 -0500
++++ Terminal-0.4.0/doc/ja/Makefile.in 2009-07-20 13:50:20.537889876 -0500
+@@ -260,7 +260,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Terminal/ja
++TARGET_DIR = $(docdir)/ja
+ STYLESHEET = ../terminal.xsl
+ DOCUMENT = Terminal.xml
+
+diff -Nur Terminal-0.4.0.orig/doc/ja/images/Makefile.in Terminal-0.4.0/doc/ja/images/Makefile.in
+--- Terminal-0.4.0.orig/doc/ja/images/Makefile.in 2009-07-20 13:04:03.000000000 -0500
++++ Terminal-0.4.0/doc/ja/images/Makefile.in 2009-07-20 13:50:20.537889876 -0500
+@@ -240,7 +240,7 @@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-imagesdir = $(datadir)/doc/Terminal/ja/images
++imagesdir = $(docdir)/ja/images
+ images_DATA = \
+ terminal-compose-shortcut.png \
+ terminal-edit-preferences.png \
diff --git a/source/xap/xfce/patches/thunar-1.0.1-fixup_docdir.diff b/source/xap/xfce/patches/thunar-1.0.1-fixup_docdir.diff
new file mode 100644
index 00000000..52d076d9
--- /dev/null
+++ b/source/xap/xfce/patches/thunar-1.0.1-fixup_docdir.diff
@@ -0,0 +1,360 @@
+diff -Nur Thunar-1.0.1.orig/Makefile.in Thunar-1.0.1/Makefile.in
+--- Thunar-1.0.1.orig/Makefile.in 2009-04-18 09:41:09.000000000 -0500
++++ Thunar-1.0.1/Makefile.in 2009-07-20 19:36:55.895440657 -0500
+@@ -932,7 +932,7 @@
+
+ ThunarHelp: ThunarHelp.in Makefile
+ rm -f ThunarHelp.gen ThunarHelp
+- sed -e "s,\@datadir\@,$(datadir),g" \
++ sed -e "s,\@htmldir\@,$(htmldir),g" \
+ < $(srcdir)/ThunarHelp.in \
+ > ThunarHelp.gen
+ mv ThunarHelp.gen ThunarHelp
+diff -Nur Thunar-1.0.1.orig/ThunarHelp.in Thunar-1.0.1/ThunarHelp.in
+--- Thunar-1.0.1.orig/ThunarHelp.in 2008-10-22 01:43:23.000000000 -0500
++++ Thunar-1.0.1/ThunarHelp.in 2009-07-20 19:36:38.235721255 -0500
+@@ -19,7 +19,7 @@
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #
+
+-HELPDIR="@datadir@/doc/Thunar/html/"
++HELPDIR="@htmldir@/"
+
+ if test -n "$LC_ALL"; then
+ LC=$LC_ALL
+diff -Nur Thunar-1.0.1.orig/docs/Makefile.in Thunar-1.0.1/docs/Makefile.in
+--- Thunar-1.0.1.orig/docs/Makefile.in 2009-04-18 09:40:14.000000000 -0500
++++ Thunar-1.0.1/docs/Makefile.in 2009-07-20 19:36:38.235721255 -0500
+@@ -292,7 +292,7 @@
+ builddir = @builddir@
+ datadir = @datadir@
+ datarootdir = @datarootdir@
+-docdir = $(datadir)/doc/Thunar
++docdir = @docdir@
+ dvidir = @dvidir@
+ exec_prefix = @exec_prefix@
+ host = @host@
+diff -Nur Thunar-1.0.1.orig/docs/manual/C/Makefile.in Thunar-1.0.1/docs/manual/C/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/C/Makefile.in 2009-04-18 09:40:19.000000000 -0500
++++ Thunar-1.0.1/docs/manual/C/Makefile.in 2009-07-20 19:36:38.235721255 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/C
++TARGET_DIR = $(htmldir)/C
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/C/images/Makefile.in Thunar-1.0.1/docs/manual/C/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/C/images/Makefile.in 2009-04-18 09:40:21.000000000 -0500
++++ Thunar-1.0.1/docs/manual/C/images/Makefile.in 2009-07-20 19:36:38.235721255 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/C/images
++imagesdir = $(htmldir)/C/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/Makefile.in Thunar-1.0.1/docs/manual/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/Makefile.in 2009-04-18 09:40:22.000000000 -0500
++++ Thunar-1.0.1/docs/manual/Makefile.in 2009-07-20 19:36:38.235721255 -0500
+@@ -338,7 +338,7 @@
+ tr \
+ zh_TW
+
+-cssdir = $(datadir)/doc/Thunar/html
++cssdir = $(htmldir)
+ css_DATA = \
+ thunar.css
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/da/Makefile.in Thunar-1.0.1/docs/manual/da/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/da/Makefile.in 2009-04-18 09:40:22.000000000 -0500
++++ Thunar-1.0.1/docs/manual/da/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -317,7 +317,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/da
++TARGET_DIR = $(htmldir)/da
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/da/images/Makefile.in Thunar-1.0.1/docs/manual/da/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/da/images/Makefile.in 2009-04-18 09:40:24.000000000 -0500
++++ Thunar-1.0.1/docs/manual/da/images/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -311,7 +311,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/da/images
++imagesdir = $(htmldir)/da/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/es/Makefile.in Thunar-1.0.1/docs/manual/es/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/es/Makefile.in 2009-04-18 09:40:24.000000000 -0500
++++ Thunar-1.0.1/docs/manual/es/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/es
++TARGET_DIR = $(htmldir)/es
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/es/images/Makefile.in Thunar-1.0.1/docs/manual/es/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/es/images/Makefile.in 2009-04-18 09:40:25.000000000 -0500
++++ Thunar-1.0.1/docs/manual/es/images/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/es/images
++imagesdir = $(htmldir)/es/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/eu/Makefile.in Thunar-1.0.1/docs/manual/eu/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/eu/Makefile.in 2009-04-18 09:40:25.000000000 -0500
++++ Thunar-1.0.1/docs/manual/eu/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/eu
++TARGET_DIR = $(htmldir)/eu
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/eu/images/Makefile.in Thunar-1.0.1/docs/manual/eu/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/eu/images/Makefile.in 2009-04-18 09:40:26.000000000 -0500
++++ Thunar-1.0.1/docs/manual/eu/images/Makefile.in 2009-07-20 19:36:38.239694094 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/eu/images
++imagesdir = $(htmldir)/eu/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/fr/Makefile.in Thunar-1.0.1/docs/manual/fr/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/fr/Makefile.in 2009-04-18 09:40:26.000000000 -0500
++++ Thunar-1.0.1/docs/manual/fr/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/fr
++TARGET_DIR = $(htmldir)/fr
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/fr/images/Makefile.in Thunar-1.0.1/docs/manual/fr/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/fr/images/Makefile.in 2009-04-18 09:40:27.000000000 -0500
++++ Thunar-1.0.1/docs/manual/fr/images/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/fr/images
++imagesdir = $(htmldir)/fr/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/gl/Makefile.in Thunar-1.0.1/docs/manual/gl/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/gl/Makefile.in 2009-04-18 09:40:27.000000000 -0500
++++ Thunar-1.0.1/docs/manual/gl/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/gl
++TARGET_DIR = $(htmldir)/gl
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/gl/images/Makefile.in Thunar-1.0.1/docs/manual/gl/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/gl/images/Makefile.in 2009-04-18 09:40:29.000000000 -0500
++++ Thunar-1.0.1/docs/manual/gl/images/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/C/images
++imagesdir = $(htmldir)/C/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/it/Makefile.in Thunar-1.0.1/docs/manual/it/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/it/Makefile.in 2009-04-18 09:40:30.000000000 -0500
++++ Thunar-1.0.1/docs/manual/it/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -317,7 +317,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/it
++TARGET_DIR = $(htmldir)/it
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/it/images/Makefile.in Thunar-1.0.1/docs/manual/it/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/it/images/Makefile.in 2009-04-18 09:40:31.000000000 -0500
++++ Thunar-1.0.1/docs/manual/it/images/Makefile.in 2009-07-20 19:36:38.243692845 -0500
+@@ -311,7 +311,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/it/images
++imagesdir = $(htmldir)/it/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/ja/Makefile.in Thunar-1.0.1/docs/manual/ja/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/ja/Makefile.in 2009-04-18 09:40:32.000000000 -0500
++++ Thunar-1.0.1/docs/manual/ja/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/ja
++TARGET_DIR = $(htmldir)/ja
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/ja/images/Makefile.in Thunar-1.0.1/docs/manual/ja/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/ja/images/Makefile.in 2009-04-18 09:40:33.000000000 -0500
++++ Thunar-1.0.1/docs/manual/ja/images/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/ja/images
++imagesdir = $(htmldir)/ja/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/nl/Makefile.in Thunar-1.0.1/docs/manual/nl/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/nl/Makefile.in 2009-04-18 09:40:34.000000000 -0500
++++ Thunar-1.0.1/docs/manual/nl/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/nl
++TARGET_DIR = $(htmldir)/nl
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/nl/images/Makefile.in Thunar-1.0.1/docs/manual/nl/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/nl/images/Makefile.in 2009-04-18 09:40:34.000000000 -0500
++++ Thunar-1.0.1/docs/manual/nl/images/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/nl/images
++imagesdir = $(htmldir)/nl/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/pl/Makefile.in Thunar-1.0.1/docs/manual/pl/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/pl/Makefile.in 2009-04-18 09:40:34.000000000 -0500
++++ Thunar-1.0.1/docs/manual/pl/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/pl
++TARGET_DIR = $(htmldir)/pl
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/pl/images/Makefile.in Thunar-1.0.1/docs/manual/pl/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/pl/images/Makefile.in 2009-04-18 09:40:34.000000000 -0500
++++ Thunar-1.0.1/docs/manual/pl/images/Makefile.in 2009-07-20 19:36:38.247717296 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/pl/images
++imagesdir = $(htmldir)/pl/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/ru/Makefile.in Thunar-1.0.1/docs/manual/ru/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/ru/Makefile.in 2009-04-18 09:40:35.000000000 -0500
++++ Thunar-1.0.1/docs/manual/ru/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/ru
++TARGET_DIR = $(htmldir)/ru
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/ru/images/Makefile.in Thunar-1.0.1/docs/manual/ru/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/ru/images/Makefile.in 2009-04-18 09:40:35.000000000 -0500
++++ Thunar-1.0.1/docs/manual/ru/images/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/ru/images
++imagesdir = $(htmldir)/ru/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/tr/Makefile.in Thunar-1.0.1/docs/manual/tr/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/tr/Makefile.in 2009-04-18 09:40:35.000000000 -0500
++++ Thunar-1.0.1/docs/manual/tr/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -317,7 +317,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/tr
++TARGET_DIR = $(htmldir)/tr
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/tr/images/Makefile.in Thunar-1.0.1/docs/manual/tr/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/tr/images/Makefile.in 2009-04-18 09:40:36.000000000 -0500
++++ Thunar-1.0.1/docs/manual/tr/images/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -311,7 +311,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/tr/images
++imagesdir = $(htmldir)/tr/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
+diff -Nur Thunar-1.0.1.orig/docs/manual/zh_TW/Makefile.in Thunar-1.0.1/docs/manual/zh_TW/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/zh_TW/Makefile.in 2009-04-18 09:40:36.000000000 -0500
++++ Thunar-1.0.1/docs/manual/zh_TW/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -319,7 +319,7 @@
+ SUBDIRS = \
+ images
+
+-TARGET_DIR = $(datadir)/doc/Thunar/html/zh_TW
++TARGET_DIR = $(htmldir)/zh_TW
+ STYLESHEET = ../thunar.xsl
+ DOCUMENT = Thunar.xml
+
+diff -Nur Thunar-1.0.1.orig/docs/manual/zh_TW/images/Makefile.in Thunar-1.0.1/docs/manual/zh_TW/images/Makefile.in
+--- Thunar-1.0.1.orig/docs/manual/zh_TW/images/Makefile.in 2009-04-18 09:40:36.000000000 -0500
++++ Thunar-1.0.1/docs/manual/zh_TW/images/Makefile.in 2009-07-20 19:36:38.251717303 -0500
+@@ -313,7 +313,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ xfconf_query_found = @xfconf_query_found@
+-imagesdir = $(datadir)/doc/Thunar/html/zh_TW/images
++imagesdir = $(htmldir)/zh_TW/images
+ images_DATA = \
+ bulk-rename.png \
+ file-manager-window.png \
diff --git a/source/xap/xfce/patches/xfcalendar.desktop.in.diff b/source/xap/xfce/patches/xfcalendar.desktop.in.diff
new file mode 100644
index 00000000..d8826781
--- /dev/null
+++ b/source/xap/xfce/patches/xfcalendar.desktop.in.diff
@@ -0,0 +1,9 @@
+--- a/xfcalendar.desktop.in 2009-03-01 10:13:10.349305702 -0600
++++ b/xfcalendar.desktop.in 2009-03-01 10:13:29.564307721 -0600
+@@ -10,4 +10,5 @@
+ Terminal=false
+ Type=Application
+ Categories=X-XFCE;Office;Calendar;GTK;
++OnlyShowIn=XFCE;
+ _GenericName=Calendar
+
diff --git a/source/xap/xfce/patches/xfdesktop-fix_education_icon.diff b/source/xap/xfce/patches/xfdesktop-fix_education_icon.diff
new file mode 100644
index 00000000..56a34060
--- /dev/null
+++ b/source/xap/xfce/patches/xfdesktop-fix_education_icon.diff
@@ -0,0 +1,11 @@
+diff -Nur xfdesktop-4.6.1.orig/modules/menu/directory-data/xfce-education.directory.in xfdesktop-4.6.1/modules/menu/directory-data/xfce-education.directory.in
+--- xfdesktop-4.6.1.orig/modules/menu/directory-data/xfce-education.directory.in 2009-01-12 16:03:19.000000000 -0600
++++ xfdesktop-4.6.1/modules/menu/directory-data/xfce-education.directory.in 2009-07-31 01:04:29.029467762 -0500
+@@ -2,6 +2,6 @@
+ Version=1.0
+ Encoding=UTF-8
+ Type=Directory
+-Icon=
++Icon=applications-education
+ _Name=Education
+ _Comment=Educational software
diff --git a/source/xap/xfce/profile.d/xfce.csh b/source/xap/xfce/profile.d/xfce.csh
new file mode 100755
index 00000000..ccc2b8f1
--- /dev/null
+++ b/source/xap/xfce/profile.d/xfce.csh
@@ -0,0 +1,6 @@
+#!/bin/csh
+if ( $?XDG_CONFIG_DIRS ) then
+ setenv XDG_CONFIG_DIRS ${XDG_CONFIG_DIRS}:/etc/xfce/xdg
+else
+ setenv XDG_CONFIG_DIRS /etc/xdg:/etc/xfce/xdg
+endif
diff --git a/source/xap/xfce/profile.d/xfce.sh b/source/xap/xfce/profile.d/xfce.sh
new file mode 100755
index 00000000..adb187c1
--- /dev/null
+++ b/source/xap/xfce/profile.d/xfce.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+if [ ! "$XDG_CONFIG_DIRS" = "" ]; then
+ XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/xfce/xdg
+else
+ XDG_CONFIG_DIRS=/etc/xdg:/etc/xfce/xdg
+fi
+export XDG_CONFIG_DIRS
diff --git a/source/xap/xfce/slack-desc b/source/xap/xfce/slack-desc
new file mode 100644
index 00000000..ecedf010
--- /dev/null
+++ b/source/xap/xfce/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xfce: xfce (a fast and lightweight desktop environment for X)
+xfce:
+xfce: Xfce is a fast and lightweight desktop environment that is both
+xfce: visually appealing and easy to use.
+xfce:
+xfce: For more information, see: http://www.xfce.org
+xfce:
+xfce: Xfce was developed by Olivier Fourdan.
+xfce:
+xfce:
+xfce:
diff --git a/source/xap/xfce/xfce.SlackBuild b/source/xap/xfce/xfce.SlackBuild
new file mode 100755
index 00000000..2ed8042e
--- /dev/null
+++ b/source/xap/xfce/xfce.SlackBuild
@@ -0,0 +1,201 @@
+#!/bin/sh
+
+# Copyright 2003 Slackware Linux, Inc., Concord, CA, USA
+# Copyright 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=4.6.1
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-5}
+
+# A few tarballs have different versions; handle them here
+XDT_VERS=4.6.0 # xfce4-dev-tools version
+EXO_VERS=0.3.101 # exo version
+THUNAR_VERS=1.0.1 # thunar version
+GXE_VERS=2.6.0 # gtk-xfce-engine version
+TERM_VERS=0.4.0 # terminal version
+MPAD_VERS=0.2.16 # mousepad version
+XFWMTHEME_VERS=4.6.0 # xfwm4-themes version
+
+NUMJOBS=${NUMJOBS:--j6}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/xfce-build-dir}
+PKG=$TMP/package-xfce
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP || exit 1
+
+COMPRESSION=xz
+COMPRESSUTIL=xz
+
+# The Rodent theme isn't xdg-compliant, so they're not shipping it
+# xfce4-icon-theme-$VERSION.tar.$COMPRESSION
+# We'll set Tango as the system default instead...
+
+for file in \
+ xfce4-dev-tools-$XDT_VERS.tar.$COMPRESSION \
+ libxfce4util-$VERSION.tar.$COMPRESSION \
+ xfconf-$VERSION.tar.$COMPRESSION \
+ libxfcegui4-$VERSION.tar.$COMPRESSION \
+ libxfce4menu-$VERSION.tar.$COMPRESSION \
+ exo-$EXO_VERS.tar.$COMPRESSION \
+ xfce4-panel-$VERSION.tar.$COMPRESSION \
+ Thunar-$THUNAR_VERS.tar.$COMPRESSION \
+ xfce4-settings-$VERSION.tar.$COMPRESSION \
+ xfce4-session-$VERSION.tar.$COMPRESSION \
+ xfdesktop-$VERSION.tar.$COMPRESSION \
+ xfwm4-$VERSION.tar.$COMPRESSION \
+ xfce-utils-$VERSION.tar.$COMPRESSION \
+ xfce4-mixer-$VERSION.tar.$COMPRESSION \
+ xfprint-$VERSION.tar.$COMPRESSION \
+ xfce4-appfinder-$VERSION.tar.$COMPRESSION \
+ gtk-xfce-engine-$GXE_VERS.tar.$COMPRESSION \
+ Terminal-$TERM_VERS.tar.$COMPRESSION \
+ xfwm4-themes-$XFWMTHEME_VERS.tar.$COMPRESSION \
+ mousepad-$MPAD_VERS.tar.$COMPRESSION \
+ orage-$VERSION.tar.$COMPRESSION ;
+do
+ $COMPRESSUTIL -dc $CWD/src/$file | tar xvf - || exit 1
+ cd $(basename $file .tar.$COMPRESSION) || exit 1
+ chown -R root:root .
+ find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+ # Here's where we patch or set up any other package-specific stuff:
+ # Patch to only show xfcalendar in XFce (otherwise it shows up in
+ # KDE's Lost & Found and does not work):
+ if [ "$file" = "orage-$VERSION.tar.$COMPRESSION" ]; then
+ zcat $CWD/patches/xfcalendar.desktop.in.diff.gz | patch -p1 || exit 1
+ fi
+ # Fix http://bugzilla.xfce.org/show_bug.cgi?id=5461
+ # and enable python bindings in libexo
+ if [ "$file" = "exo-$EXO_VERS.tar.$COMPRESSION" ]; then
+ zcat $CWD/patches/exo_fix_quoting.diff.gz | patch -p0 || exit 1
+ PACKAGE_SPECIFIC_OPTIONS="--enable-python"
+ fi
+ # Make Terminal respect --docdir
+ if [ "$file" = "Terminal-$TERM_VERS.tar.$COMPRESSION" ]; then
+ zcat $CWD/patches/terminal-0.4.0-fixup_docdir.diff.gz | patch -p1 || exit 1
+ fi
+ # Make Thunar respect --docdir
+ if [ "$file" = "Thunar-$THUNAR_VERS.tar.$COMPRESSION" ]; then
+ zcat $CWD/patches/thunar-1.0.1-fixup_docdir.diff.gz | patch -p1 || exit 1
+ fi
+ # Fix the missing education icon in the desktop menu
+ if [ "$file" = "xfdesktop-$VERSION.tar.$COMPRESSION" ]; then
+ zcat $CWD/patches/xfdesktop-fix_education_icon.diff.gz | patch -p1 || exit 1
+ fi
+ # End patches/package-specific stuff
+
+ CFLAGS="$SLKCFLAGS" \
+ CXXFLAGS="$SLKCFLAGS" \
+ ./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc/xfce \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/xfce-$VERSION/$(basename $file .tar.$COMPRESSION) \
+ --htmldir=/usr/doc/xfce-$VERSION/$(basename $file .tar.$COMPRESSION)/html \
+ --disable-static \
+ --build=$ARCH-slackware-linux \
+ $PACKAGE_SPECIFIC_OPTIONS
+
+ # Unset this now -- we're done with it
+ unset PACKAGE_SPECIFIC_OPTIONS
+
+ make $NUMJOBS || make || exit 1
+ make install || exit 1
+ make install DESTDIR=$PKG
+
+ mkdir -p $PKG/usr/doc/xfce-$VERSION/$(basename $file .tar.$COMPRESSION)
+ # This will cause errors, but won't miss any docs:
+ cp -a \
+ AUTHORS BUGS COMPOSITOR COPYING* FAQ HACKING INSTALL \
+ NEWS NOTES README* THANKS TODO example.gtkrc-2.0 \
+ $PKG/usr/doc/xfce-$VERSION/$(basename $file .tar.$COMPRESSION) \
+ 2> /dev/null || true
+
+ cd - ;
+done
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# The Rodent icon theme isn't xdg compliant, so it spews errors quite often
+# and just flat breaks some things here and there, so the Xfce team elected
+# not to ship it with 4.6.0. In the meantime, we'll default to Tango.
+sed -i s/Rodent/Tango/ \
+ $PKG/etc/xfce/xdg/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml
+
+# We're going to borrow the "applications-education" icons (six of them)
+# from kde's oxygen icon theme (it's LGPL)
+tar xf $CWD/icons.tar.xz -C $PKG/usr/share
+
+# We don't want any of those icon caches
+find $PKG/usr/share/icons -type f -name "index-theme.cache" -exec rm -f {} \;
+
+# Compress and if needed symlink the man pages:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+mkdir -p $PKG/etc/profile.d
+cp -a $CWD/profile.d/* $PKG/etc/profile.d
+chown root:root $PKG/etc/profile.d/*
+chmod 755 $PKG/etc/profile.d/*
+
+mkdir -p $PKG/etc/X11/xinit
+( cd $PKG/etc/X11/xinit
+ ln -sf ../../xfce/xdg/xfce4/xinitrc xinitrc.xfce
+ chmod 755 ../../xfce/xdg/xfce4/xinitrc
+)
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xfce-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xfce4-power-manager/doinst.sh b/source/xap/xfce4-power-manager/doinst.sh
new file mode 100644
index 00000000..1f8ff67d
--- /dev/null
+++ b/source/xap/xfce4-power-manager/doinst.sh
@@ -0,0 +1,10 @@
+if [ -x /usr/bin/update-desktop-database ]; then
+ /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
+fi
+
+if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
+ if [ -x /usr/bin/gtk-update-icon-cache ]; then
+ /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
+ fi
+fi
+
diff --git a/source/xap/xfce4-power-manager/slack-desc b/source/xap/xfce4-power-manager/slack-desc
new file mode 100644
index 00000000..d1dd7ec1
--- /dev/null
+++ b/source/xap/xfce4-power-manager/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------|
+xfce4-power-manager: xfce4-power-manager (Power Management Daemon for Xfce)
+xfce4-power-manager:
+xfce4-power-manager: xfce4-power-manager makes power management functions (such as
+xfce4-power-manager: suspend and hibernate) easy inside the Xfce Desktop Environment
+xfce4-power-manager: (but it should also work in any other desktop environment).
+xfce4-power-manager:
+xfce4-power-manager:
+xfce4-power-manager:
+xfce4-power-manager:
+xfce4-power-manager:
+xfce4-power-manager:
diff --git a/source/xap/xfce4-power-manager/xfce4-power-manager.SlackBuild b/source/xap/xfce4-power-manager/xfce4-power-manager.SlackBuild
new file mode 100755
index 00000000..1487b2d0
--- /dev/null
+++ b/source/xap/xfce4-power-manager/xfce4-power-manager.SlackBuild
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+# Slackware build script for xfce4-power-manager
+
+# Copyright 2008-2009 Robby Workman Northport, Alabama, USA
+# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PRGNAM=xfce4-power-manager
+VERSION=0.6.6
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-$PRGNAM
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP || exit 1
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || exit 1
+cd $PRGNAM-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/xfce \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/$PRGNAM-$VERSION \
+ --enable-debug=no \
+ --build=$ARCH-slackware-linux
+
+make || exit 1
+make install DESTDIR=$PKG
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/html
+cp -a \
+ AUTHORS COPYING ChangeLog INSTALL NEWS README TODO \
+ $PKG/usr/doc/$PRGNAM-$VERSION
+( cd $PKG/usr/doc/$PRGNAM-$VERSION/html
+ ln -s /usr/share/xfce4/doc/C/xfce4-power-manager.html index.html
+ ln -s /usr/share/xfce4/doc/C/images .
+)
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xfractint/slack-desc b/source/xap/xfractint/slack-desc
new file mode 100644
index 00000000..0b8614fa
--- /dev/null
+++ b/source/xap/xfractint/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xfractint: xfractint (fractal generation program)
+xfractint:
+xfractint: Xfractint draws a wide variety of fractals. Xfractint is a port of the
+xfractint: DOS program Fractint.
+xfractint:
+xfractint: The primary original authors of Fractint are Bert Tyler, Timothy
+xfractint: Wegner, Mark Peterson, and Pieter Branderhorst. Fractint was ported
+xfractint: to X by Ken Shirriff.
+xfractint:
+xfractint:
+xfractint:
diff --git a/source/xap/xfractint/xfractint.SlackBuild b/source/xap/xfractint/xfractint.SlackBuild
new file mode 100755
index 00000000..1ae5e6fe
--- /dev/null
+++ b/source/xap/xfractint/xfractint.SlackBuild
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+# Copyright 2007, 2008, 2009 Patrick Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=xfractint
+VERSION=${VERSION:-20.04p09}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/xfractint-${VERSION}.tar.bz2 || exit 1
+cd ${PKGNAM}-${VERSION} || exit 1
+
+rm -f unix/calmanfx.o # contains i386 code
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+make OPT="$SLKCFLAGS" SRCDIR=/usr/share/xfractint SHRDIR=/usr/share/xfractint BINDIR=/usr/bin MANDIR=/usr/man/man1 || exit 1
+
+mkdir -p $PKG/usr/{bin,man/man1,share/xfractint}
+make install SRCDIR=$PKG/usr/share/xfractint SHRDIR=$PKG/usr/share/xfractint BINDIR=$PKG/usr/bin MANDIR=$PKG/usr/man/man1 || exit 1
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add palette maps missing from latest sources:
+( cd $PKG/usr/share/${PKGNAM}/maps ; tar xf $CWD/palette.maps.tar.gz )
+
+# Fix all wrong permissions in /usr/share/xfractint
+( cd $PKG/usr/share
+ find . -perm 777 -exec chmod 755 {} \;
+ find . -perm 666 -exec chmod 644 {} \;
+)
+
+# Add a documentation directory:
+mkdir -p ${PKG}/usr/doc/${PKGNAM}-$VERSION
+cp -a *.txt read.me $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# Build the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xgames/maze.diff b/source/xap/xgames/maze.diff
new file mode 100644
index 00000000..77ec739c
--- /dev/null
+++ b/source/xap/xgames/maze.diff
@@ -0,0 +1,22 @@
+--- ./getopt.c.orig Wed Aug 4 14:48:46 1999
++++ ./getopt.c Wed Aug 4 14:48:55 1999
+@@ -22,7 +22,7 @@
+ char *optarg;
+
+ int
+-getopt(argc, argv, opts)
++maze_getopt(argc, argv, opts)
+ int argc;
+ char **argv, *opts;
+ {
+--- ./maze.c.orig Wed Aug 4 14:48:59 1999
++++ ./maze.c Wed Aug 4 14:49:10 1999
+@@ -136,7 +136,7 @@
+ int flags;
+
+ cmd = argv[0];
+- while ((c = getopt(argc, argv, "rSd:g:")) != EOF)
++ while ((c = maze_getopt(argc, argv, "rSd:g:")) != EOF)
+ switch(c) {
+
+ case 'S':
diff --git a/source/xap/xgames/slack-desc b/source/xap/xgames/slack-desc
new file mode 100644
index 00000000..a81a038c
--- /dev/null
+++ b/source/xap/xgames/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xgames: xgames (small X games collection)
+xgames:
+xgames: A few small and historic games and toys for X.
+xgames:
+xgames: Includes maze, spider, xcolormap, xlander, xminesweep, xroach, xsnow.
+xgames:
+xgames:
+xgames:
+xgames:
+xgames:
+xgames:
diff --git a/source/xap/xgames/spider.diff b/source/xap/xgames/spider.diff
new file mode 100644
index 00000000..b0704f14
--- /dev/null
+++ b/source/xap/xgames/spider.diff
@@ -0,0 +1,121 @@
+--- ./globals.h.orig 1991-09-28 12:46:20.000000000 -0500
++++ ./globals.h 2007-02-21 20:14:54.000000000 -0600
+@@ -96,6 +96,6 @@
+ Bool can_get_help_files();
+ #endif
+
+-extern char *malloc();
+-extern char *calloc();
+-extern char *realloc();
++extern void *malloc();
++extern void *calloc();
++extern void *realloc();
+--- ./movelog.c.orig 1991-09-28 12:46:17.000000000 -0500
++++ ./movelog.c 2007-02-21 20:17:21.000000000 -0600
+@@ -22,6 +22,7 @@
+ #ifdef SVR4
+ #include <unistd.h>
+ #endif
++#include <stdlib.h>
+
+ #define CACHE_SIZE 50
+ static int move_index = 0;
+@@ -33,6 +34,21 @@
+
+ extern int cheat_count;
+
++Rank flip_ranks[NUM_RANKS] = {
++ King, Queen, Jack, Ten, Nine, Eight, Seven,
++ Six, Five, Four, Three, Deuce, Ace
++};
++
++static int
++card_to_int(card)
++CardPtr card;
++{
++int val;
++
++ val = card->suit * 13 + flip_ranks[card->rank];
++ return (val);
++}
++
+ make_deck_cache()
+ {
+ CardPtr tmp;
+@@ -280,11 +296,6 @@
+ }
+ }
+
+-Rank flip_ranks[NUM_RANKS] = {
+- King, Queen, Jack, Ten, Nine, Eight, Seven,
+- Six, Five, Four, Three, Deuce, Ace
+-};
+-
+ static void
+ int_to_card(val, suit, rank)
+ int val;
+@@ -298,16 +309,6 @@
+ assert (*rank >= Ace && *suit <= King);
+ }
+
+-static int
+-card_to_int(card)
+-CardPtr card;
+-{
+-int val;
+-
+- val = card->suit * 13 + flip_ranks[card->rank];
+- return (val);
+-}
+-
+ static CardPtr
+ find_card(cache, suit, rank)
+ CardPtr *cache;
+@@ -709,6 +710,23 @@
+ }
+ }
+
++static int
++restore_game(str, str2)
++char *str, *str2;
++{
++
++ if (read_position(str) != 0) {
++ return (-1);
++ }
++
++ init_cache(); /* clear out the move cache */
++
++ if (str2)
++ read_moves(str2);
++
++ return (0);
++}
++
+ read_selection(buf)
+ char *buf;
+ {
+@@ -786,23 +804,6 @@
+ show_message(buf);
+ }
+
+-static int
+-restore_game(str, str2)
+-char *str, *str2;
+-{
+-
+- if (read_position(str) != 0) {
+- return (-1);
+- }
+-
+- init_cache(); /* clear out the move cache */
+-
+- if (str2)
+- read_moves(str2);
+-
+- return (0);
+-}
+-
+ /*
+ * play the same deck again
+ */
diff --git a/source/xap/xgames/xcolormap.diff b/source/xap/xgames/xcolormap.diff
new file mode 100644
index 00000000..57a0bee7
--- /dev/null
+++ b/source/xap/xgames/xcolormap.diff
@@ -0,0 +1,22 @@
+--- ./Makefile.orig Wed Aug 4 14:53:55 1999
++++ ./Makefile Wed Aug 4 14:54:07 1999
+@@ -3,7 +3,7 @@
+ PROGRAM = xcolormap
+ OBJS = xcolormap.o
+
+-LIBS = -lm -lXt -lX11
++LIBS = -lm -L /usr/X11R6/lib -lXt -lX11
+
+ all: $(PROGRAM)
+
+--- ./xcolormap.c.orig Wed Aug 4 14:53:23 1999
++++ ./xcolormap.c Wed Aug 4 14:53:49 1999
+@@ -113,7 +113,7 @@
+
+ if (!TheDisplay)
+ {
+- XtWarning ("%s: can't open display, exiting...", APPNAME);
++ XtWarning ("%s: can't open display, exiting...");
+ exit (0);
+ }
+
diff --git a/source/xap/xgames/xcuckoo.diff b/source/xap/xgames/xcuckoo.diff
new file mode 100644
index 00000000..00c014cb
--- /dev/null
+++ b/source/xap/xgames/xcuckoo.diff
@@ -0,0 +1,12 @@
+diff -u xcuckoo.orig/xcuckoo.c xcuckoo/xcuckoo.c
+--- xcuckoo.orig/xcuckoo.c 1992-05-05 02:38:34.000000000 -0500
++++ xcuckoo/xcuckoo.c 2007-02-28 13:10:37.000000000 -0600
+@@ -37,7 +37,7 @@
+ #include "version.h"
+ #include "patchlevel.h"
+
+-extern char *malloc();
++extern void *malloc();
+
+ /* R4 concession */
+ #ifndef XPointer
diff --git a/source/xap/xgames/xgames.SlackBuild b/source/xap/xgames/xgames.SlackBuild
new file mode 100755
index 00000000..e2514f81
--- /dev/null
+++ b/source/xap/xgames/xgames.SlackBuild
@@ -0,0 +1,154 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=0.3
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xgames
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+# Build spider:
+cd $TMP
+tar xvf $CWD/spider.tar.gz || exit 1
+cd spider || exit 1
+zcat $CWD/spider.diff.gz | patch -p1 --verbose || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+mkdir -p $PKG/usr/bin
+cat spider > $PKG/usr/bin/spider
+mkdir -p $PKG/usr/man/man6
+cat spider.man | gzip -9c > $PKG/usr/man/man6/spider.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/spider
+cp -a README* $PKG/usr/doc/xgames-$VERSION/spider
+
+# Build maze:
+cd $TMP
+tar xvf $CWD/maze.tar.gz || exit 1
+cd maze || exit 1
+zcat $CWD/maze.diff.gz | patch -p1 || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat maze > $PKG/usr/bin/maze
+cat maze.man | gzip -9c > $PKG/usr/man/man6/maze.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/maze
+cp -a README $PKG/usr/doc/xgames-$VERSION/maze
+
+# Build xcolormap:
+cd $TMP
+tar xvf $CWD/xcolormap.tar.gz || exit 1
+cd xcolormap || exit 1
+zcat $CWD/xcolormap.diff.gz | patch -p1 || exit 1
+make $NUMJOBS || make || exit 1
+cat xcolormap > $PKG/usr/bin/xcolormap
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xcolormap
+cp -a README $PKG/usr/doc/xgames-$VERSION/xcolormap
+
+# Build xcuckoo:
+cd $TMP
+tar xvf $CWD/xcuckoo-1.1.tar.gz || exit 1
+cd xcuckoo || exit 1
+zcat $CWD/xcuckoo.diff.gz | patch -p1 --verbose || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xcuckoo > $PKG/usr/bin/xcuckoo
+cat xcuckoo.man | gzip -9c > $PKG/usr/man/man6/xcuckoo.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xcuckoo
+cp -a CHANGES $PKG/usr/doc/xgames-$VERSION/xcuckoo
+
+# Build xlander:
+cd $TMP
+tar xvf $CWD/xlander.tar.gz || exit 1
+cd xlander || exit 1
+zcat $CWD/xlander.fixes.diff.gz | patch -p1 || exit 1
+zcat $CWD/xlander-2009-07-18.diff.gz | patch -p1 || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xlander > $PKG/usr/bin/xlander
+cat xlander.man | gzip -9c > $PKG/usr/man/man6/xlander.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xlander
+cp -a README $PKG/usr/doc/xgames-$VERSION/xlander
+
+# Build xminesweep:
+cd $TMP
+tar xvf $CWD/xminesweep3.0.tar.gz || exit 1
+cd xminesweep3.0 || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xminesweep > $PKG/usr/bin/xminesweep
+cat xminesweep.man | gzip -9c > $PKG/usr/man/man6/xminesweep.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xminesweep
+cp -a README $PKG/usr/doc/xgames-$VERSION/xminesweep
+
+# Build xneko:
+cd $TMP
+tar xvf $CWD/xneko.tar.gz || exit 1
+cd xneko || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xneko > $PKG/usr/bin/xneko
+cat xneko.man | gzip -9c > $PKG/usr/man/man6/xneko.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xneko
+cp -a README $PKG/usr/doc/xgames-$VERSION/xneko
+
+# Build xroach:
+cd $TMP
+tar xvf $CWD/xroach.tar.gz || exit 1
+cd xroach || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xroach > $PKG/usr/bin/xroach
+cat xroach.man | gzip -9c > $PKG/usr/man/man6/xroach.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xroach
+cp -a README.linux $PKG/usr/doc/xgames-$VERSION/xroach
+
+# Build xsnow:
+cd $TMP
+tar xvf $CWD/xsnow-1.40.tar.gz || exit 1
+cd xsnow-1.40 || exit 1
+xmkmf
+make $NUMJOBS || make || exit 1
+cat xsnow > $PKG/usr/bin/xsnow
+cat xsnow.man | gzip -9c > $PKG/usr/man/man6/xsnow.6.gz
+mkdir -p $PKG/usr/doc/xgames-$VERSION/xsnow
+cp -a README $PKG/usr/doc/xgames-$VERSION/xsnow
+
+# Fix everything up:
+chmod 755 $PKG/usr/bin/*
+strip $PKG/usr/bin/*
+
+( cd $PKG/usr/doc
+ find . -type f -exec chown root.root {} \;
+ find . -type f -exec chmod 644 {} \;
+)
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xgames-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xgames/xlander-2009-07-18.diff b/source/xap/xgames/xlander-2009-07-18.diff
new file mode 100644
index 00000000..21402ea4
--- /dev/null
+++ b/source/xap/xgames/xlander-2009-07-18.diff
@@ -0,0 +1,86 @@
+diff --git a/game.c b/game.c
+index e6f3a53..b789081 100644
+--- a/game.c
++++ b/game.c
+@@ -93,7 +93,7 @@ void RateLanding (db, lander)
+ extern LINE landingpad[];
+ int x_distance, z_distance; /* Distance from center of pad */
+ int abs ();
+- void InitializeLander (), DisplayAcceleration ();
++ void InitFrameRate (), InitializeLander (), DisplayAcceleration ();
+
+ x_distance =
+ abs ((int) (db->off_x - (landingpad[0].x1 + (PAD_WIDTH >> 1))));
+@@ -108,6 +108,7 @@ void RateLanding (db, lander)
+ }
+ XDrawImageString (d, instrBuffer, gcInstr, 381, 84, buf, strlen (buf));
+ Pause ("Press mouse button to continue");
++ InitFrameRate ();
+ InitializeLander (db, lander);
+
+ /*
+diff --git a/initialize.c b/initialize.c
+index 99a81c5..279e3f2 100644
+--- a/initialize.c
++++ b/initialize.c
+@@ -60,7 +60,7 @@ void InitializeLander (craft, lander)
+ lander->retro_thruster = 0;
+ lander->vert_speed = 0.0;
+ lander->heading = 1.36;
+- lander->lat_veloc = 100.0;
++ lander->lat_veloc = 300.0;
+ lander->fuel = FULL_TANK;
+ lander->alt = craft->off_y / PIXELS_PER_FOOT;
+ }
+diff --git a/patchlevel.h b/patchlevel.h
+index 9625f98..be79bb8 100644
+--- a/patchlevel.h
++++ b/patchlevel.h
+@@ -1,2 +1,2 @@
+-#define PATCHLEVEL 3
++#define PATCHLEVEL 4
+
+diff --git a/xlander.c b/xlander.c
+index 2b2c103..318e5df 100644
+--- a/xlander.c
++++ b/xlander.c
+@@ -101,9 +101,17 @@ void DisplayWorld ()
+ }
+
+
++void InitFrameRate ()
++{
++ gettimeofday(&frame_time, NULL);
++ gettimeofday(&prev_frame_time, NULL);
++ fps = 1000000.0; /* Avoid initial spike */
++}
++
++
+ void UpdateFrameRate ()
+ {
+- unsigned long sec, usec, diff;
++ long sec, usec, diff;
+
+ gettimeofday(&frame_time, NULL);
+ sec = frame_time.tv_sec - prev_frame_time.tv_sec;
+@@ -164,6 +172,7 @@ int main (argc, argv)
+ */
+ mask = sigblock (sigmask (SIGINT));
+ Pause ("Press any mouse button to begin");
++ InitFrameRate ();
+ DisplayAcceleration ();
+ for (;;) {
+ UpdateOrientation (world, craft, &lander);
+diff --git a/xlander.h b/xlander.h
+index ea157f7..ea072d3 100644
+--- a/xlander.h
++++ b/xlander.h
+@@ -44,7 +44,7 @@
+ #define PIXELS_PER_FOOT 6 /* Number of pixels per foot */
+ #define ACCELERATION -5.310 /* Acceleration of gravity (ft/sec^2) */
+ #define RETRO 35.0 /* Acceleration due to retroactive thruster */
+-#define LATERAL_THRUST 5.0 /* Acceleration due to lateral thruster */
++#define LATERAL_THRUST 1.0 /* Acceleration due to lateral thruster */
+ #define PI 3.1415926535897932384
+ #define HALFPI 1.5707963 /* pi/2 */
+ #define TWOPI100 628
diff --git a/source/xap/xgames/xlander.fixes.diff b/source/xap/xgames/xlander.fixes.diff
new file mode 100644
index 00000000..7212e183
--- /dev/null
+++ b/source/xap/xgames/xlander.fixes.diff
@@ -0,0 +1,228 @@
+diff -ru a-slackware-1995-06-17/game.c b-gary/game.c
+--- a-slackware-1995-06-17/game.c 1995-06-17 21:23:00.000000000 -0400
++++ b-gary/game.c 2007-03-01 04:08:49.000000000 -0500
+@@ -165,7 +165,7 @@
+ switch (event.type) {
+ case KeyPress:
+ if (lander->fuel > 0.0) {
+- XLookupString (&event, &ch, 1, &keysym, (XComposeStatus *) 0);
++ XLookupString ((XKeyEvent *) &event, &ch, 1, &keysym, (XComposeStatus *) 0);
+ if (ch == lander->controls[0] || keysym == XK_Up)
+ lander->rear_thruster = lander->lateral_thrust;
+ else if (ch == lander->controls[1] || keysym == XK_Down)
+@@ -179,7 +179,7 @@
+ }
+ break;
+ case KeyRelease:
+- XLookupString (&event, &ch, 1, &keysym, (XComposeStatus *) 0);
++ XLookupString ((XKeyEvent *) &event, &ch, 1, &keysym, (XComposeStatus *) 0);
+ if (ch == lander->controls[0] || keysym == XK_Up)
+ lander->rear_thruster = 0;
+ else if (ch == lander->controls[1] || keysym == XK_Down)
+@@ -197,24 +197,26 @@
+ }
+
+ if (lander->retro_thruster > 0)
+- lander->fuel -= RETRO_BURN;
++ lander->fuel -= RETRO_BURN / fps;
+ if (lander->front_thruster > 0)
+- lander->fuel -= LATERAL_BURN;
++ lander->fuel -= LATERAL_BURN / fps;
+ if (lander->rear_thruster > 0)
+- lander->fuel -= LATERAL_BURN;
++ lander->fuel -= LATERAL_BURN / fps;
+ if (lander->left_thruster > 0)
+- lander->fuel -= LATERAL_BURN;
++ lander->fuel -= LATERAL_BURN / fps;
+ if (lander->right_thruster > 0)
+- lander->fuel -= LATERAL_BURN;
++ lander->fuel -= LATERAL_BURN / fps;
++ if (lander->fuel < 0.0)
++ lander->fuel = 0.0; /* Prevents gas gauge from going negative */
+ lander->vert_speed +=
+- (lander->retro_thruster + acceleration) / TICKS_PER_SECOND;
+- lander->alt += lander->vert_speed / TICKS_PER_SECOND;
++ (lander->retro_thruster + acceleration) / fps;
++ lander->alt += lander->vert_speed / fps;
+ lat_accel_x = lander->right_thruster - lander->left_thruster;
+ lat_accel_y = lander->rear_thruster - lander->front_thruster;
+ lat_veloc_x = lander->lat_veloc * cos (lander->heading) + lat_accel_x;
+ lat_veloc_y = lander->lat_veloc * sin (lander->heading) + lat_accel_y;
+- craft->off_x += (lat_veloc_x / TICKS_PER_SECOND) * PIXELS_PER_FOOT;
+- craft->off_z += (lat_veloc_y / TICKS_PER_SECOND) * PIXELS_PER_FOOT;
++ craft->off_x += (lat_veloc_x / fps) * PIXELS_PER_FOOT;
++ craft->off_z += (lat_veloc_y / fps) * PIXELS_PER_FOOT;
+ lander->lat_veloc =
+ sqrt (lat_veloc_x * lat_veloc_x + lat_veloc_y * lat_veloc_y);
+
+diff -ru a-slackware-1995-06-17/globals.c b-gary/globals.c
+--- a-slackware-1995-06-17/globals.c 1995-06-17 21:22:36.000000000 -0400
++++ b-gary/globals.c 2007-03-01 04:08:49.000000000 -0500
+@@ -27,3 +27,4 @@
+ XrmDatabase resources = (XrmDatabase) 0;
+ /* X Resource database */
+ float acceleration = 0.0; /* Acceleration due to gravity */
++float fps; /* Current frames per second */
+diff -ru a-slackware-1995-06-17/globals.h b-gary/globals.h
+--- a-slackware-1995-06-17/globals.h 1995-06-17 21:22:41.000000000 -0400
++++ b-gary/globals.h 2007-03-01 04:08:49.000000000 -0500
+@@ -30,5 +30,6 @@
+ extern int px, py, pz;
+ extern int roll, pitch, yaw;
+ extern float acceleration;
++extern float fps;
+
+-#endif _globals_h_
++#endif /* _globals_h_ */
+diff -ru a-slackware-1995-06-17/initialize.c b-gary/initialize.c
+--- a-slackware-1995-06-17/initialize.c 1995-06-17 21:23:00.000000000 -0400
++++ b-gary/initialize.c 2007-03-01 04:08:49.000000000 -0500
+@@ -61,7 +61,7 @@
+ lander->vert_speed = 0.0;
+ lander->heading = 1.36;
+ lander->lat_veloc = 100.0;
+- lander->fuel = 320.0;
++ lander->fuel = FULL_TANK;
+ lander->alt = craft->off_y / PIXELS_PER_FOOT;
+ }
+
+@@ -293,7 +293,7 @@
+
+ world->min_x = world->min_y = -HALF_WORLD_LENGTH;
+ world->max_x = world->max_y = HALF_WORLD_WIDTH;
+- srandom ((long) time ((int *) 0));
++ srandom ((long) time ((time_t *) 0));
+ for (x = -HALF_WORLD_WIDTH; x < HALF_WORLD_WIDTH;
+ r ^= 1, x += EDGE_LENGTH + (int) x_offset)
+ for (y = r * (int) y_offset - HALF_WORLD_LENGTH; y < HALF_WORLD_LENGTH;
+diff -ru a-slackware-1995-06-17/instrument.c b-gary/instrument.c
+--- a-slackware-1995-06-17/instrument.c 1995-06-17 21:22:39.000000000 -0400
++++ b-gary/instrument.c 2007-03-01 04:08:49.000000000 -0500
+@@ -48,7 +48,7 @@
+ {
+ static int heading_x = 50, heading_y = 15;
+ static int fuel_level = 80, old_x = 290, old_y = 10;
+- int new_fuel_level = (int) fuel / 4;
++ int new_fuel_level = (int) (fuel / (float) FULL_TANK * 80.0);
+ char buf[32];
+
+ /*
+diff -ru a-slackware-1995-06-17/patchlevel.h b-gary/patchlevel.h
+--- a-slackware-1995-06-17/patchlevel.h 1995-06-17 21:23:00.000000000 -0400
++++ b-gary/patchlevel.h 2007-03-01 04:08:49.000000000 -0500
+@@ -1,2 +1,2 @@
+-#define PATCHLEVEL 2
++#define PATCHLEVEL 3
+
+diff -ru a-slackware-1995-06-17/xlander.c b-gary/xlander.c
+--- a-slackware-1995-06-17/xlander.c 1995-06-17 21:22:36.000000000 -0400
++++ b-gary/xlander.c 2007-03-01 04:08:49.000000000 -0500
+@@ -14,6 +14,7 @@
+
+ #include "xlander.h"
+ #include "globals.h"
++#include <sys/time.h>
+
+ /*
+ * A lander
+@@ -68,6 +69,7 @@
+ static DATABASE *world, *craft, *thrust, *shadow;
+ static LANDER lander;
+ int mask;
++struct timeval frame_time, prev_frame_time;
+
+ /******************************************************************************
+ ** DisplayWorld
+@@ -98,7 +100,26 @@
+ XSync (d,False);
+ }
+
+-void main (argc, argv)
++
++void UpdateFrameRate ()
++{
++ unsigned long sec, usec, diff;
++
++ gettimeofday(&frame_time, NULL);
++ sec = frame_time.tv_sec - prev_frame_time.tv_sec;
++ usec = frame_time.tv_usec - prev_frame_time.tv_usec;
++ if(usec < 0) {
++ usec += 1000000;
++ sec--;
++ }
++ diff = sec * 1000000 + usec;
++ fps = 1000000.0 / (float) diff;
++ prev_frame_time.tv_sec = frame_time.tv_sec;
++ prev_frame_time.tv_usec = frame_time.tv_usec;
++}
++
++
++int main (argc, argv)
+ int argc;
+ char *argv[];
+ {
+@@ -113,6 +134,10 @@
+ thrust = DBInitFromData (thrust_data, THRUSTSIZE);
+ shadow = DBInitFromData (shadow_data, SHADOWSIZE);
+
++ gettimeofday(&frame_time, NULL);
++ gettimeofday(&prev_frame_time, NULL);
++ fps = 1000000.0; /* Prevent startup pulse */
++
+ /*
+ * Initial coordinates of the lander...
+ */
+@@ -143,7 +168,9 @@
+ for (;;) {
+ UpdateOrientation (world, craft, &lander);
+ DisplayWorld ();
++ UpdateFrameRate ();
+ (void) sigsetmask (mask);
+ mask = sigblock (sigmask (SIGINT));
+ }
++ return 0;
+ }
+diff -ru a-slackware-1995-06-17/xlander.h b-gary/xlander.h
+--- a-slackware-1995-06-17/xlander.h 1995-06-17 21:23:00.000000000 -0400
++++ b-gary/xlander.h 2007-03-01 04:08:49.000000000 -0500
+@@ -20,6 +20,7 @@
+ #ifndef _xlander_h_
+ #define _xlander_h_
+
++#include <stdlib.h>
+ #include <stdio.h>
+ #include <math.h>
+ #include <signal.h>
+@@ -41,7 +42,6 @@
+ #define HALF_WORLD_LENGTH (WORLD_LENGTH >> 1)
+ #define HALF_WORLD_WIDTH (WORLD_WIDTH >> 1)
+ #define PIXELS_PER_FOOT 6 /* Number of pixels per foot */
+-#define TICKS_PER_SECOND 3 /* Number of frames per second */
+ #define ACCELERATION -5.310 /* Acceleration of gravity (ft/sec^2) */
+ #define RETRO 35.0 /* Acceleration due to retroactive thruster */
+ #define LATERAL_THRUST 5.0 /* Acceleration due to lateral thruster */
+@@ -53,7 +53,7 @@
+ #define LAT_SPEED 30.0 /* Maximum lateral speed without crashing */
+ #define RETRO_BURN 1.6 /* Retroactive thruster fuel consumption */
+ #define LATERAL_BURN 0.4 /* Lateral thruster fuel consumption */
+-#define FULL_TANK 320 /* Full tank of fuel */
++#define FULL_TANK 15 /* Full tank of fuel */
+ #define MAX_VELOC 640.0 /* Maximum velocity */
+
+ #define LANDER_WIDTH 600
+@@ -107,9 +107,6 @@
+
+ DATABASE *DBInit (), *DBInitFromData (), *LoadDataBase ();
+ void DBInsert (), DBFinish (), DBPlot (), SwapBuffers (), exit ();
+-#ifndef _AIX
+-char *malloc ();
+-#endif
+ double atof ();
+ #ifdef sun
+ int printf (), fprintf (), time ();
+@@ -122,4 +119,4 @@
+ #define WorldToRadarX(x) (290 + (((int) (x) + (WORLD_WIDTH >> 1)) / 250))
+ #define WorldToRadarY(y) (90 - (((int) (y) + (WORLD_LENGTH >> 1)) / 250))
+
+-#endif _xlander_h_
++#endif /* _xlander_h_ */
diff --git a/source/xap/xine-lib/slack-desc b/source/xap/xine-lib/slack-desc
new file mode 100644
index 00000000..27673668
--- /dev/null
+++ b/source/xap/xine-lib/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xine-lib: xine-lib (xine multimedia playback engine libraries)
+xine-lib:
+xine-lib: xine-lib is a free (GPL licensed) high-performance multimedia
+xine-lib: playback engine. The xine shared libraries are used by xine-ui (and
+xine-lib: other media players and multimedia applications) for smooth video
+xine-lib: processing and playback of multimedia streams such as movies, radio
+xine-lib: and TV network streams, DVDs, and VCDs.
+xine-lib:
+xine-lib:
+xine-lib:
+xine-lib:
diff --git a/source/xap/xine-lib/xine-lib.SlackBuild b/source/xap/xine-lib/xine-lib.SlackBuild
new file mode 100755
index 00000000..84c6703f
--- /dev/null
+++ b/source/xap/xine-lib/xine-lib.SlackBuild
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+# Version on the tarball
+VERSION=1.1.16.3
+# Version used in the source directory to cd into
+DIRVER=1.1.16.3
+# Version used for the Slackware package
+PKGVER=1.1.16.3
+
+# I would use "-march=i486 -mtune=i686" here as usual, but with XINE it's all or nothing.
+# I'd rather have it work well for the i686/Athlon crowd than suck for everyone.
+ARCH=${ARCH:-x86_64}
+TARGET=${TARGET:-$ARCH-pc-linux-gnu}
+BUILD=${BUILD:-6}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+if [ "$ARCH" = "x86_64" ]; then
+ LIBDIRSUFFIX="64"
+else
+ LIBDIRSUFFIX=""
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xine-lib
+rm -rf $PKG
+mkdir -p $TMP $PKG/usr
+
+cd $TMP
+rm -rf xine-lib-$VERSION
+tar xvf $CWD/xine-lib-$VERSION.tar.bz2 || exit 1
+cd xine-lib-$DIRVER || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+XINE_BUILD=$TARGET \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --docdir=/usr/doc/xine-lib-$VERSION \
+ --mandir=/usr/man \
+ --with-w32-path=/usr/lib${LIBDIRSUFFIX}/codecs \
+ --with-arts \
+ --disable-nosefart \
+ --without-speex
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/codecs
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+( cd $PKG/usr/man
+ find . -type f -exec gzip -9 {} \;
+ for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
+)
+
+# Copy a few missed docs, and remove the redundant html FAQ (we have a txt)
+cp -a \
+ ABOUT-NLS AUTHORS NEWS \
+ $PKG/usr/doc/xine-lib-$VERSION
+rm -f $PKG/usr/doc/xine-lib-$VERSION/faq.html
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xine-lib-$PKGVER-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xine-ui/slack-desc b/source/xap/xine-ui/slack-desc
new file mode 100644
index 00000000..f4e39279
--- /dev/null
+++ b/source/xap/xine-ui/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xine-ui: xine-ui (xine multimedia playback engine user interface)
+xine-ui:
+xine-ui: Xine is a free multimedia player. It plays back CDs, DVDs, and VCDs,
+xine-ui: multimedia files, and multimedia streamed over a network.
+xine-ui:
+xine-ui: The xine-ui package contains the graphical user interface for the
+xine-ui: xine multimedia player.
+xine-ui:
+xine-ui:
+xine-ui:
+xine-ui:
diff --git a/source/xap/xine-ui/xine-ui.SlackBuild b/source/xap/xine-ui/xine-ui.SlackBuild
new file mode 100755
index 00000000..1dd61f1f
--- /dev/null
+++ b/source/xap/xine-ui/xine-ui.SlackBuild
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=0.99.5
+# I would use "-march=i486 -mcpu=i686" here as usual, but with XINE it's all or nothing.
+# I'd rather have it work well for the i686/Athlon crowd than suck for everyone.
+ARCH=${ARCH:-x86_64}
+TARGET=${TARGET:-$ARCH-pc-linux-gnu}
+BUILD=${BUILD:-2}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xine-ui
+rm -rf $PKG
+mkdir -p $TMP $PKG/usr
+
+cd $TMP
+rm -rf xine-ui-$VERSION
+tar xvf $CWD/xine-ui-$VERSION.tar.bz2 || exit 1
+cd xine-ui-$VERSION || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+XINE_BUILD=$TARGET \
+./configure \
+ --prefix=/usr \
+ --with-aalib \
+ --with-caca \
+ --build=$TARGET
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/usr/share/applications
+zcat $CWD/xine.desktop.gz > $PKG/usr/share/applications/xine.desktop
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+( cd $PKG/usr/man
+ find . -name "*.?" | xargs gzip -9
+)
+
+mkdir -p $PKG/usr/doc/xine-ui-$VERSION
+cp -a \
+ ABOUT-NLS AUTHORS COPYING NEWS README \
+ doc/README* \
+ $PKG/usr/doc/xine-ui-$VERSION
+cp -a \
+ src/xitk/xine-toolkit/README \
+ $PKG/usr/doc/xine-ui-$VERSION/README.xitk
+# redundant
+rm -rf $PKG/usr/share/doc
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xine-ui-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xine-ui/xine.desktop b/source/xap/xine-ui/xine.desktop
new file mode 100644
index 00000000..0936a4e9
--- /dev/null
+++ b/source/xap/xine-ui/xine.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Xine
+Name[pl]=Odtwarzacz xine
+GenericName=Media Player
+Comment=Xine Media Player
+Comment[pl]=Odtwarzacz filmów
+Icon=xine.xpm
+Exec=xine
+Terminal=0
+Type=Application
+Categories=Application;AudioVideo;Player;
+MimeType=video/mpeg;video/quicktime;video/x-msvideo;video/x-anim;audio/x-mp3;audio/x-mp2;
+# vi: encoding=utf-8
diff --git a/source/xap/xlockmore/l-bob.README b/source/xap/xlockmore/l-bob.README
new file mode 100644
index 00000000..8e868f88
--- /dev/null
+++ b/source/xap/xlockmore/l-bob.README
@@ -0,0 +1,5 @@
+
+The image of J. R. "Bob" Dobbs found in the file l-bob.xbm, and used as the
+"bob" (xlockmore) screensaver in Slackware, is a registered trademark of
+The Subgenius Foundation (http://www.subgenius.com). Used by permission.
+
diff --git a/source/xap/xlockmore/l-bob.xbm b/source/xap/xlockmore/l-bob.xbm
new file mode 100644
index 00000000..ceea6daf
--- /dev/null
+++ b/source/xap/xlockmore/l-bob.xbm
@@ -0,0 +1,364 @@
+#define image_width 172
+#define image_height 246
+static unsigned char image_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3a,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xdf,0xff,0xf3,0xff,0x1f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xdf,0xff,0xff,0x9f,0xff,0xe3,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x9f,0xff,
+ 0xff,0x3f,0xff,0xc7,0xff,0x3f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0x1f,0xf2,0x7f,0x7f,0xfe,0xc3,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x3f,0xc0,0x7f,
+ 0x7e,0xfc,0xc1,0xff,0xff,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xcf,0x7f,0x00,0xff,0x7c,0xfc,0xc1,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x0f,0xff,0x00,0xff,0x78,
+ 0xf0,0xc1,0xff,0xff,0x03,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xfc,0x1f,0xfe,0x00,0xff,0x30,0xe0,0x81,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0x7f,0x38,0x1f,0xfc,0x01,0xfe,0x01,0xe0,
+ 0x83,0xff,0xf9,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xff,0xff,0x3f,
+ 0x38,0x1e,0xf8,0x01,0xfc,0x01,0xe0,0x87,0xff,0xfb,0x07,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0x7f,0x00,0x3c,0xf0,0x01,0xf8,0x01,0xe0,0x8f,
+ 0xff,0xf3,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xc0,0xff,0xff,0x7f,0x00,
+ 0x3c,0xf0,0x03,0xf8,0x01,0xc0,0xff,0xff,0xf3,0x0f,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0x00,0x7c,0xe0,0x03,0xf0,0x01,0xc0,0xff,0xff,
+ 0xf3,0x3f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x81,0x7f,
+ 0xe0,0x03,0xf0,0x03,0xc0,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0x83,0xff,0xe0,0x03,0xe0,0x03,0xc0,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0xf0,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x97,0xff,0xc0,
+ 0x07,0xe0,0x03,0x80,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xc1,0x07,0xc0,0x07,0x80,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0xf0,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xc1,0x07,
+ 0xc0,0x03,0x80,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xf0,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x83,0x0f,0xc0,0x07,0xc0,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xc7,0x0f,0xc0,
+ 0x1f,0xe0,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0xf0,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xcf,0x1f,0xc0,0x7f,0xfc,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xc0,0x7f,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf0,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xc3,0x7f,0xfe,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0xf0,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc7,0x7f,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0xf0,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xf0,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0xf0,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0xff,0x0f,0xff,0xff,0x1f,0x00,0xf0,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfe,0xff,0xff,
+ 0x07,0xff,0xff,0x1f,0x00,0xf0,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0xff,0xff,0xbf,0x00,0xff,0xff,0x1f,0x00,0xf0,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,0x0f,0x00,
+ 0xff,0xff,0x1f,0x00,0xf0,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0xfe,0xff,0x3f,0x00,0xf0,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xfe,
+ 0xff,0x3f,0x00,0xf0,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0xfe,0xff,0x3f,0x00,0xf0,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xfc,0xff,
+ 0x3f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x7f,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0xfc,0xff,0x3f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,
+ 0x7f,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0xff,0x3f,
+ 0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,0xf0,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0x3f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,
+ 0xe0,0xff,0xff,0xe7,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xf8,0xff,0x7f,0x00,
+ 0xf0,0x00,0x00,0xf0,0xff,0xff,0x01,0x00,0x00,0x80,0xc3,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0xf0,
+ 0x00,0x00,0xf8,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0xf8,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0xf0,0x00,
+ 0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x7f,0x00,0xf0,0x00,0x00,
+ 0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,
+ 0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,
+ 0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x7f,0x00,0xf0,
+ 0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xc0,0xff,0x7f,0x00,0xf0,0x00,
+ 0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x70,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xc0,0xff,0x7f,0x00,0xf0,0x00,0x00,
+ 0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xc1,
+ 0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xc1,0xff,
+ 0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xc1,0xff,0x7f,
+ 0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xc1,0xff,0x7f,0x00,
+ 0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xc1,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xc1,0xff,0x7f,0x00,0xf0,
+ 0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xc3,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x03,0x40,0x91,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0xe0,0xc3,0xff,0x7f,0x00,0xf0,0x00,
+ 0x00,0xf0,0xff,0xff,0x03,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xf0,0xff,0x0f,
+ 0xe0,0xc3,0xff,0x7f,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0xc3,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xf3,0xc3,0xff,0x7f,0x00,0xf0,0x00,0x00,
+ 0xfc,0xff,0xff,0xe3,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xf7,
+ 0x83,0xff,0xff,0x00,0xf0,0x00,0x00,0xfc,0xff,0xff,0xf3,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x83,0xff,0xff,0x00,0xf0,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x03,
+ 0xff,0xff,0x00,0xf0,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0x07,0xff,0xff,0x00,0xf0,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0x01,0xfc,0xff,0x01,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x07,0xff,
+ 0xff,0x00,0xf0,0x00,0x00,0xfc,0xff,0xff,0x5f,0x00,0xf8,0xff,0x03,0x00,0x00,
+ 0xc0,0xff,0x3f,0x00,0xff,0x0f,0xff,0xff,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,
+ 0x1f,0x00,0xe0,0xff,0x07,0x00,0x00,0xe0,0xff,0x03,0x00,0xfc,0x0f,0xfe,0x7f,
+ 0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x1f,0x00,0xc0,0xff,0x0f,0x00,0x00,0xf0,
+ 0xff,0x00,0x00,0xf0,0x0f,0xfe,0x7f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0x1f,
+ 0xf0,0xff,0xff,0x1f,0x00,0x00,0xf8,0xff,0x23,0x00,0xe0,0x1f,0xfe,0x3f,0x00,
+ 0xf0,0x00,0x00,0xf8,0xff,0xff,0x1f,0xfe,0xff,0xff,0x3f,0x00,0x00,0xfc,0xff,
+ 0xff,0x07,0xe0,0x1f,0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0xfe,0xff,0xff,0x3f,0xc0,0x1f,0xfe,0x3f,0x00,0xf0,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,
+ 0x7f,0xc0,0x1f,0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x3f,0xfe,0xff,0xff,
+ 0xff,0xff,0x01,0x80,0xff,0xff,0xff,0xff,0x81,0x1f,0xfc,0x3f,0x00,0xf0,0x00,
+ 0x00,0xf8,0xff,0x3f,0xfc,0xff,0xff,0xff,0xff,0x01,0xc0,0xff,0xff,0xff,0xff,
+ 0x83,0x1f,0xfc,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x1f,0xf8,0xff,0xff,0xff,
+ 0xff,0x01,0xe0,0xff,0xff,0xff,0xff,0x83,0x1f,0xfc,0x3f,0x00,0xf0,0x00,0x00,
+ 0xf8,0xff,0x1f,0xf8,0xf7,0xff,0xf9,0xff,0x01,0xe0,0xff,0xff,0xff,0xfb,0x03,
+ 0x1f,0xfc,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x0f,0xf8,0xc1,0xff,0xe0,0xff,
+ 0x03,0xf0,0xff,0x83,0xff,0xe1,0x07,0x1e,0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,
+ 0xff,0x0f,0xf8,0xc1,0xff,0xe0,0xff,0x03,0xf0,0xff,0x83,0xff,0xe1,0x07,0x1e,
+ 0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x0f,0xf8,0xc0,0xff,0xe0,0xff,0x03,
+ 0xe0,0xff,0x81,0xff,0xe1,0x07,0x1f,0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,
+ 0x0f,0xf8,0xc0,0xff,0xe0,0xff,0x03,0xc0,0xff,0x80,0xff,0xe1,0x03,0x1e,0xfe,
+ 0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x1f,0x70,0xc0,0x7f,0xf0,0xff,0x03,0x00,
+ 0x00,0x80,0xff,0xe1,0x01,0x1e,0xfe,0x3f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x1f,
+ 0x20,0x00,0x07,0xf8,0xff,0x03,0x00,0x00,0xf8,0xff,0xc0,0x00,0x1e,0xfe,0x1f,
+ 0x00,0xf0,0x00,0x00,0xf8,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0x03,0x00,0x00,
+ 0xfe,0x07,0x00,0x00,0x1e,0xfe,0x1f,0x00,0xf0,0x00,0x00,0xf8,0xff,0x0f,0x00,
+ 0x00,0x80,0xff,0xfc,0x03,0x00,0x00,0xfe,0x03,0x00,0x00,0x1e,0xfe,0x1f,0x00,
+ 0xf0,0x00,0x00,0xf8,0xbf,0x0f,0x00,0x00,0xe0,0xff,0xfc,0x03,0x00,0x00,0xfe,
+ 0x03,0x00,0x00,0x08,0xfe,0x1f,0x00,0xf0,0x00,0x00,0xf0,0xbf,0x0f,0x00,0x00,
+ 0xf8,0x7f,0xfc,0x03,0x00,0x00,0xfc,0x0f,0x00,0x00,0x00,0xfe,0x1f,0x00,0xf0,
+ 0x00,0x00,0xf0,0x3f,0x0f,0x00,0xfc,0xff,0x3f,0xf8,0x03,0x00,0x00,0xf8,0xff,
+ 0x00,0x00,0x00,0xfe,0x0f,0x00,0xf0,0x00,0x00,0xf0,0x3f,0x0e,0x00,0xfc,0xff,
+ 0x0f,0xf8,0x01,0x00,0x00,0xf0,0xff,0x01,0x00,0x00,0xfe,0x1f,0x00,0xf0,0x00,
+ 0x00,0xf0,0x3f,0x0f,0x00,0xfc,0xff,0x07,0xf8,0x01,0x00,0x00,0xc0,0xff,0x01,
+ 0x00,0x00,0xfe,0x0f,0x00,0xf0,0x00,0x00,0xf0,0x7f,0x06,0x00,0xfc,0xff,0x01,
+ 0xf8,0x01,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0xfe,0x0f,0x00,0xf0,0x00,0x00,
+ 0xf0,0x7f,0x06,0x00,0xe0,0x3f,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0x0f,0x00,0xf0,0x00,0x00,0xf0,0x7f,0x06,0x00,0x00,0x07,0x00,0xf8,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x07,0x00,0xf0,0x00,0x00,0xe0,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x07,0x00,0xf0,0x00,0x00,0xe0,0x7f,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x07,0x00,0xf0,0x00,0x00,0xf0,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0x07,0x00,0xf0,0x00,0x00,0xe0,0x7f,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x0f,0x00,0xf0,0x00,0x00,0xe0,0x7f,0x1c,
+ 0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x0f,
+ 0x00,0xf0,0x00,0x00,0xe0,0x7f,0x3c,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x9e,0x0f,0x00,0xf0,0x00,0x00,0xe0,0xff,0x3c,0x00,
+ 0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9e,0x0f,0x00,
+ 0xf0,0x00,0x00,0xc0,0xfd,0x7c,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x9e,0x0f,0x00,0xf0,0x00,0x00,0x80,0xfd,0x7c,0x00,0x00,
+ 0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x07,0x00,0xf0,
+ 0x00,0x00,0x00,0xfc,0x7c,0x00,0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x9f,0x07,0x00,0xf0,0x00,0x00,0x00,0xfc,0xfc,0x00,0x00,0x00,
+ 0x80,0x3f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x07,0x00,0xf0,0x00,
+ 0x00,0x80,0xff,0xfc,0x00,0x00,0x00,0xe0,0x3f,0x00,0x38,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0x03,0x00,0xf0,0x00,0x00,0x80,0xff,0xf8,0x01,0x00,0x00,0xf0,
+ 0x3f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0x00,0xf0,0x00,0x00,
+ 0x00,0xff,0xf8,0x03,0x00,0x00,0xf8,0x3f,0x00,0x20,0x00,0x1e,0x00,0x00,0x00,
+ 0x04,0xef,0x01,0x00,0xf0,0x00,0x00,0x00,0xff,0xf8,0x03,0x00,0x00,0xff,0x1f,
+ 0x00,0x20,0xc0,0x7f,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x7c,0xf8,0x07,0x00,0x80,0xff,0x1f,0x00,0x00,0xe0,0xff,0x01,0x00,0x00,0x0f,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x07,0x00,0xe0,0xff,0x1f,0x00,
+ 0x00,0xe0,0xff,0x03,0x00,0xc0,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0xf8,0x07,0x00,0xf0,0xff,0x1f,0x00,0x00,0xf0,0xff,0x07,0x00,0xc0,0x1f,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0xf8,0xfe,0x1f,0x00,0x00,
+ 0xfc,0xf3,0x0f,0x00,0xf0,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,
+ 0x0f,0x00,0x7c,0xfc,0x3f,0x00,0x80,0xff,0xe1,0x3f,0x00,0xf8,0x0f,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x1f,0x00,0x3e,0xfc,0xbf,0x00,0xe0,0xff,
+ 0xc0,0x3f,0x00,0xfe,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x1f,
+ 0x00,0x1f,0xfc,0xff,0x03,0xf0,0x7f,0x80,0x7f,0x80,0xff,0x0f,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0xf8,0x1f,0x80,0x0f,0xfe,0xff,0x07,0xfe,0x3f,0x00,
+ 0x7f,0xf8,0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x7f,0xe0,
+ 0x07,0xff,0xff,0xff,0xff,0x1f,0x00,0xff,0xf9,0xff,0x0f,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xf0,0x83,0xff,0xff,0xff,0xff,0x03,0x00,0xfe,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x83,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0xfe,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0x80,0xff,0xff,0xff,0x7f,0x00,0x00,0xfc,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xe0,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0x7f,0xe0,0xff,0xff,0xff,0x1f,0x00,0x00,0xf8,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0x3f,0xf0,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0xf0,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0x1f,0xfc,0xff,0xff,0xff,0x07,0x00,0x00,0xf8,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0x07,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0x83,0xff,0xff,0xff,0xff,0x01,0x00,0xff,0xff,0x1f,0xff,0x1f,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0x81,0xff,0xff,0xff,0xff,0x00,
+ 0xe0,0xff,0xff,0x07,0xf8,0x1f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0x01,0xff,0xff,0xff,0x3f,0x80,0xff,0xff,0xff,0x01,0xf8,0x3f,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xff,0x01,0xfe,0xff,0xff,0x1f,0xc0,0xff,
+ 0xff,0xff,0x00,0xf8,0x1f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0x01,0xf8,0xff,0xff,0x1f,0xf8,0xff,0xff,0x7f,0x00,0xf8,0x1f,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0xf8,0xff,0x01,0xf8,0x8f,0xfc,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0xfc,0x1f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0xff,0x01,
+ 0xf8,0x0f,0xe0,0xff,0xff,0x07,0xf8,0x0f,0x00,0xfc,0x1f,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0xf8,0xe7,0x03,0xf8,0x0f,0x00,0x04,0x00,0x00,0xf8,0x0f,
+ 0x00,0xfc,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf0,0xef,0x03,0xfc,
+ 0x0f,0x00,0x00,0x00,0x00,0xfe,0x07,0x00,0xfc,0x0f,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0xf0,0xef,0x07,0xfc,0x1f,0x00,0x00,0x00,0x00,0xff,0x03,0x00,
+ 0xfc,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf0,0xc7,0x07,0xf8,0x3f,
+ 0x00,0x00,0x00,0x00,0xff,0x01,0x00,0xfe,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0xe0,0xc7,0x07,0xf8,0xff,0x01,0x00,0x00,0x00,0xff,0x00,0x00,0xfe,
+ 0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xe0,0xc7,0x07,0xf0,0xff,0x0f,
+ 0x00,0x00,0x00,0xff,0x00,0x00,0xff,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x00,0xe0,0xc7,0x07,0xf0,0xff,0x1f,0x00,0x00,0x80,0xff,0x00,0x00,0xff,0x03,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xc0,0xcf,0x07,0xf0,0xff,0x3f,0x00,
+ 0x00,0xc0,0x7f,0x00,0x00,0xff,0x03,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0xc0,0xdf,0x07,0xe0,0xff,0x3f,0x00,0x00,0xe0,0x07,0x00,0x80,0xff,0x01,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x80,0x9f,0x0f,0xe0,0xff,0x7f,0x00,0x00,
+ 0xc6,0x00,0x00,0x80,0xff,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x80,
+ 0xbf,0x0f,0xe0,0xff,0x7f,0x00,0xfc,0x0f,0x00,0x00,0x80,0xff,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xff,0x0f,0xc0,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0xc0,0xff,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0x0f,0x80,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xc0,0x7f,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0x00,0xfe,0x0f,0x80,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0xc0,0x7f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xfe,0x0f,
+ 0x80,0xff,0xff,0xf0,0x3f,0x00,0x00,0x00,0xe0,0x7f,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x1f,0xc0,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0x3f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xfc,0x1f,0xe0,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0x3c,0xf0,0xff,0x7f,0x00,0x00,0x10,0x00,0x00,0xf0,
+ 0x1f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xf8,0x3c,0xf0,0xff,
+ 0xff,0x00,0xf0,0x7f,0x00,0x00,0xf8,0x1f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0x18,0xfc,0xff,0xff,0x07,0xfe,0xff,0x00,0x00,0xf8,0x1f,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0xf8,0x0f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0x00,0xff,0xcf,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x0f,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x40,0xc0,0xff,0x87,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0xfc,0x07,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0x83,0xff,0xff,0xff,0xff,0x00,0x00,0xfc,0x03,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x81,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0x81,0xff,0xff,0xff,0x1f,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xc1,0xff,0xcf,0xff,0x0f,
+ 0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xf0,0xff,0x03,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xf0,0xff,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0x7f,0xf0,0x3f,0x00,0x00,0x00,0x00,0xc0,0xff,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x3f,0xf0,0x3f,0x00,0x00,0x00,0x00,0xc0,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xc0,0x00,0x00,0x00,0xff,0x3f,
+ 0xfc,0x1f,0x00,0x00,0x00,0x00,0xe0,0x3f,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0xf0,0x03,0x03,0xc0,0xff,0x1f,0xfc,0x0f,0x00,0x00,0x00,0x00,0xf0,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xfc,0x83,0x07,0xe0,0xff,0x3f,0xfc,
+ 0x07,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0xfe,0x87,0x07,0xf0,0xff,0x3f,0xfe,0x07,0x00,0x00,0x00,0x00,0xfc,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xfe,0xc3,0x0f,0xf8,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0xfe,0x0f,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x80,0xff,
+ 0xc3,0x1f,0xfc,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0x80,0xff,0xe3,0x1f,0xfe,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xe0,0xff,0xf1,
+ 0x3f,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x80,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0xe0,0x1f,0xfc,0xff,0xff,0x3f,0xfc,0xff,0x03,0x00,0x00,
+ 0x00,0xe0,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xe0,0x1f,0xfc,0xff,
+ 0xff,0x3f,0xfc,0xff,0x03,0x00,0x00,0x00,0xe0,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0xe0,0x0f,0xfc,0xff,0xff,0x1f,0xfc,0xff,0x03,0x00,0x00,0x00,
+ 0xf0,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xc0,0x01,0xfe,0xff,0xff,
+ 0x1f,0xf8,0xff,0x07,0x00,0x00,0x00,0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0xfe,0xff,0xff,0x0f,0xf8,0xff,0x0f,0x00,0x00,0x80,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
+ 0xf0,0xff,0xff,0x0f,0x08,0xfc,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x0f,0x1c,0xfc,0xff,0xff,0x07,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x80,0xff,0x1f,0xf8,0xff,0xff,0x03,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0xff,0x3f,0xf8,0xff,0xff,0x01,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xff,0x3f,0xf0,0xff,0xff,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xff,
+ 0x7f,0xf0,0xff,0xff,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0xff,0xff,0xe0,0xff,0x7f,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xff,0xff,
+ 0xe0,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0xfe,0xff,0xc0,0xff,0x3f,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xfc,0xff,0xc1,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0xfc,0xff,0xc1,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xfc,0xff,0xc1,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0xfc,0xff,0xc1,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xf8,0xff,0xc3,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0xf8,0xff,0xc3,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xf0,0xff,0xc3,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0xf0,0xff,0xc7,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xe0,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0xe0,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xc0,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x80,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xfe,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0x00,0x00,0xfc,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0xf8,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0x00,0x00,0xe0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0};
diff --git a/source/xap/xlockmore/l-linux.xbm b/source/xap/xlockmore/l-linux.xbm
new file mode 100644
index 00000000..7ceeaf90
--- /dev/null
+++ b/source/xap/xlockmore/l-linux.xbm
@@ -0,0 +1,205 @@
+#define image_width 128
+#define image_height 151
+static unsigned char image_bits[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
+ 0x00, 0x09, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x00, 0x00, 0x00, 0x02, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x50, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x14, 0x00,
+ 0xe8, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x03, 0x2e, 0x00, 0x5c, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x5f, 0x00, 0xf7, 0x0b, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0x7d, 0x00,
+ 0xfe, 0x0f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x83, 0x7f, 0x80, 0xff, 0x0b, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xf1, 0x80, 0x0f, 0x1f, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe0, 0x80,
+ 0x87, 0x1e, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc7, 0xc8, 0x81, 0x87, 0x1c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xd0, 0x80, 0x03, 0x3c, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xd0, 0x81,
+ 0x03, 0x3c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc7, 0xc0, 0x00, 0x03, 0x3c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x87, 0xc0, 0x2a, 0x03, 0x3c, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x87, 0x41, 0xff,
+ 0x01, 0x3c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x87, 0xa1, 0x2b, 0x0f, 0x1e, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xeb, 0xfe, 0x9f, 0x0f, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf7, 0xfb,
+ 0x76, 0x0d, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x07, 0xba, 0xdf, 0xff, 0x07, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xea, 0xfd, 0xdb, 0x1e, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x7d, 0x6f,
+ 0xff, 0x1b, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x87, 0xd6, 0xfd, 0x6d, 0x1b, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0xfb, 0xef, 0xf7, 0x15, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x6d, 0xff,
+ 0x3e, 0x1d, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x87, 0xde, 0xbb, 0xcf, 0x16, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xfa, 0xef, 0xb3, 0x0b, 0x04, 0xf8,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xd8, 0xbe,
+ 0xe8, 0x05, 0x08, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x87, 0xf2, 0x37, 0x55, 0x1d, 0x54, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0x01, 0x40, 0x7d, 0x3f, 0x28, 0xe0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xd7, 0xbf,
+ 0x8b, 0x3f, 0xa8, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x8f, 0x57, 0x65, 0xf5, 0x77, 0x50, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0x4e, 0x5b, 0x75, 0x5f, 0x40, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x87, 0x3f, 0x2a,
+ 0xfd, 0x7f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x83, 0x77, 0x89, 0xee, 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xdf, 0xf5, 0xff, 0xff, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0x7f, 0xff,
+ 0xfe, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc0, 0xff, 0xfd, 0xff, 0xff, 0x01, 0x00, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0xc0, 0xdf, 0xb7, 0xff, 0xff, 0x03, 0x00,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xe0, 0xff, 0xfe,
+ 0xff, 0xff, 0x03, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0xf0, 0xff, 0xfb, 0xff, 0xff, 0x07, 0x00, 0xf8, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0x07, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
+ 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xfe, 0xff, 0xff,
+ 0xff, 0xff, 0x0f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x80, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
+ 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x7f, 0x80,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff,
+ 0xff, 0xff, 0x3f, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x3f, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x1f, 0x80,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x07, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xc3, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xe3, 0xc3,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0x5f, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xf7, 0x8f, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x36, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xbb, 0x1d,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff,
+ 0xff, 0xff, 0xf7, 0x37, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x36,
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xda, 0x5e, 0xf8, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xbf, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x7f, 0xbd, 0xfb,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x2d, 0x00, 0x80, 0xfb, 0xff,
+ 0xff, 0xff, 0xeb, 0xbf, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f,
+ 0x00, 0x80, 0xfe, 0xff, 0xff, 0x7f, 0xfd, 0xf5, 0x81, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xbf, 0x15, 0x00, 0xc0, 0xf7, 0xff, 0xff, 0x5f, 0xb7, 0xde,
+ 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x6f, 0x00, 0xe0, 0xfe, 0xff,
+ 0xff, 0xaf, 0xfd, 0xff, 0x07, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, 0x3d,
+ 0x00, 0xb0, 0xf7, 0xff, 0xff, 0x6a, 0xd7, 0xb6, 0x05, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x57, 0x01, 0xd4, 0xfd, 0xff, 0x6f, 0xb5, 0xbf, 0xff,
+ 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xbb, 0x4a, 0x75, 0xff, 0xff,
+ 0xf3, 0xef, 0xf5, 0xb6, 0x06, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd6,
+ 0xaa, 0xda, 0xf7, 0xff, 0x5f, 0x7d, 0xef, 0xff, 0x1f, 0xc0, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0xbf, 0xaa, 0xf6, 0xfd, 0xff, 0xf5, 0xdf, 0x7f, 0xb7,
+ 0x2d, 0x00, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xd5, 0x55, 0xbb, 0xde, 0xff,
+ 0xdd, 0xf6, 0xd5, 0xfb, 0x3f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xbf, 0xbe,
+ 0xfe, 0xee, 0xf7, 0xff, 0xf7, 0x7b, 0x7f, 0x6f, 0x5b, 0x00, 0xfe, 0xff,
+ 0xff, 0xff, 0x7f, 0xd5, 0xab, 0xfd, 0xbd, 0xff, 0x7b, 0xef, 0xfd, 0xdf,
+ 0xbf, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xfd, 0xda, 0xb7, 0xef, 0xff,
+ 0xad, 0xbf, 0x57, 0xfb, 0xf6, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xbf, 0xaa,
+ 0xf7, 0xfe, 0xfd, 0xfe, 0xfb, 0xf5, 0xff, 0xb7, 0x7f, 0x01, 0xfe, 0xff,
+ 0xff, 0xff, 0x3f, 0xfd, 0x5e, 0xb7, 0xb7, 0xfb, 0x6d, 0x5f, 0xbd, 0xee,
+ 0xeb, 0x02, 0xfe, 0xff, 0xff, 0xff, 0x5f, 0xab, 0xfb, 0xfd, 0xde, 0xff,
+ 0xf7, 0xff, 0xef, 0xbd, 0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfd,
+ 0xef, 0xdf, 0xbd, 0xed, 0xdb, 0xea, 0xfb, 0xfb, 0xbb, 0xc5, 0xff, 0xff,
+ 0xff, 0xff, 0x83, 0xb6, 0x7d, 0xf7, 0xf7, 0xff, 0xb5, 0xbf, 0x5e, 0xaf,
+ 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfb, 0xdf, 0xdf, 0xfe, 0xad,
+ 0xfb, 0xee, 0xf7, 0xff, 0xde, 0xea, 0xff, 0xff, 0xff, 0xff, 0x40, 0xad,
+ 0xfb, 0xfa, 0xd7, 0xfe, 0xd7, 0xbb, 0xde, 0xf6, 0xfb, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0x00, 0xfd, 0xee, 0xbf, 0xfd, 0xb7, 0xfb, 0xff, 0xfb, 0xbf,
+ 0xbf, 0xd6, 0xff, 0xff, 0xff, 0x1f, 0xc0, 0xee, 0xbf, 0xf7, 0x77, 0xdf,
+ 0x55, 0xdb, 0x5f, 0xed, 0xd6, 0xaf, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xbb,
+ 0xf6, 0x5e, 0xdf, 0xf6, 0xfb, 0xfe, 0xf6, 0xff, 0xff, 0xb5, 0xff, 0xff,
+ 0xff, 0x03, 0x40, 0xf5, 0xbf, 0xfb, 0xfb, 0xdf, 0xed, 0xab, 0xdf, 0x55,
+ 0x5b, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x80, 0xde, 0xfa, 0x5e, 0x6f, 0xf5,
+ 0xb7, 0xff, 0xf6, 0xfe, 0xff, 0x6b, 0xfc, 0xff, 0x1f, 0x00, 0x40, 0xf7,
+ 0xd7, 0xf7, 0xfb, 0xff, 0xdb, 0xed, 0xff, 0xbb, 0xed, 0x36, 0xe0, 0x7f,
+ 0x00, 0x00, 0x80, 0x7a, 0x7f, 0xdd, 0xae, 0xfe, 0xed, 0xde, 0xb6, 0xff,
+ 0x77, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x40, 0xdd, 0xed, 0xfb, 0xdf, 0xff,
+ 0x57, 0xbb, 0xfb, 0xdb, 0xde, 0xab, 0x00, 0x00, 0x00, 0x00, 0x40, 0xf7,
+ 0xf7, 0xdf, 0xea, 0xff, 0xbb, 0xed, 0xae, 0xbe, 0x7f, 0x5d, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xba, 0xbf, 0x76, 0xfb, 0xff, 0x4b, 0xb5, 0xf5, 0xf7,
+ 0xf6, 0x57, 0x00, 0x00, 0x00, 0x00, 0x40, 0x6d, 0xdb, 0xaf, 0xfc, 0xff,
+ 0xa7, 0xaa, 0x56, 0xdd, 0x5f, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5,
+ 0xf7, 0x5a, 0xff, 0xff, 0x1f, 0xa9, 0x5a, 0xf5, 0xf6, 0x2b, 0x00, 0x00,
+ 0x00, 0x00, 0xa0, 0x5a, 0x5d, 0x95, 0xff, 0xff, 0xff, 0xa7, 0x52, 0xab,
+ 0x5d, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x80, 0x6a, 0xd7, 0xca, 0xff, 0xff,
+ 0xff, 0x1f, 0xa4, 0x54, 0xab, 0x09, 0x00, 0xfc, 0xff, 0xff, 0x00, 0xaa,
+ 0xba, 0xf2, 0xff, 0xff, 0xff, 0xff, 0x41, 0xaa, 0x5a, 0x25, 0xf8, 0xff,
+ 0xff, 0xff, 0x0f, 0xd5, 0x4a, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xa4,
+ 0x4a, 0x02, 0xfc, 0xff, 0xff, 0xff, 0x4f, 0xa4, 0x2a, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x11, 0x29, 0x91, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x52,
+ 0x95, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0x44, 0xc4, 0xff, 0xff,
+ 0xff, 0xff, 0x1f, 0x90, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x12, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x08, 0x91, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff};
diff --git a/source/xap/xlockmore/s-bob.xbm b/source/xap/xlockmore/s-bob.xbm
new file mode 100644
index 00000000..47b24090
--- /dev/null
+++ b/source/xap/xlockmore/s-bob.xbm
@@ -0,0 +1,94 @@
+#define s-bob_width 86
+#define s-bob_height 123
+static char s-bob_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xfd,0x07,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0x7f,0xff,0xf7,0xfb,0x07,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0x7f,0xf8,0xee,0xf9,0x0f,0x00,0x00,0x00,0x00,0xfc,0xff,0xf3,0xf0,0xcc,
+ 0xf9,0x1f,0x00,0x00,0x00,0x00,0xfe,0x4f,0xe7,0xe1,0x81,0xf1,0x3d,0x00,0x00,
+ 0x00,0x00,0xff,0x0f,0xc6,0xc1,0x81,0xf3,0x3d,0x00,0x00,0x00,0x80,0xff,0x0f,
+ 0x8e,0xc1,0x81,0xff,0x7d,0x00,0x00,0x00,0x80,0xff,0x1f,0x8f,0x81,0x81,0xff,
+ 0xff,0x01,0x00,0x00,0xc0,0xff,0xff,0x9f,0x83,0x03,0xff,0xff,0x03,0x00,0x00,
+ 0xc0,0xff,0xff,0x1f,0x83,0x83,0xff,0xff,0x07,0x00,0x00,0xe0,0xff,0xff,0xbf,
+ 0x87,0xef,0xff,0xff,0x0f,0x00,0x00,0xf0,0xff,0xff,0xff,0x9f,0xef,0xff,0xff,
+ 0x1f,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0x3f,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xef,0xff,0xf3,0x7f,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xf7,0x7f,0xf0,0x7f,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x1f,0xe0,0x7f,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x07,0xe0,0x7f,0x00,0x00,0xfc,0xff,
+ 0xfc,0xff,0xff,0x3f,0x00,0xe0,0x7f,0x00,0x00,0xfc,0x1f,0xfc,0xff,0xff,0x0f,
+ 0x00,0xc0,0x7f,0x00,0x00,0xfc,0x1f,0x00,0x90,0xff,0x01,0x00,0xc0,0xff,0x00,
+ 0x00,0xfc,0x1f,0x00,0x00,0x3c,0x00,0x00,0xc0,0xff,0x00,0x00,0xfc,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0x00,
+ 0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0x00,0xfc,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x8c,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x9c,0xff,
+ 0x00,0x00,0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x9c,0xff,0x00,0x00,0xfc,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x9c,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x9c,0xff,0x00,0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x9c,0xff,0x00,
+ 0x00,0xfc,0x1f,0x00,0x00,0x00,0x00,0x00,0x98,0xff,0x00,0x00,0xfc,0x1f,0xff,
+ 0x03,0x00,0xc0,0x3f,0x98,0xff,0x00,0x00,0xfe,0x9f,0xff,0x07,0x00,0xe0,0xff,
+ 0x1f,0xff,0x00,0x00,0xfe,0xff,0xff,0x0f,0x00,0xf0,0xff,0x1f,0xff,0x00,0x00,
+ 0xfe,0xff,0xe1,0x1f,0x00,0xf0,0xff,0x3f,0xff,0x00,0x00,0xfc,0x7f,0x80,0x3f,
+ 0x00,0xf8,0x01,0x3e,0xfe,0x00,0x00,0xfc,0x7f,0xfc,0x7f,0x00,0xfc,0x01,0x78,
+ 0x7e,0x00,0x00,0xfc,0xff,0xff,0xff,0x00,0xfe,0x7f,0x78,0x7e,0x00,0x00,0xfc,
+ 0xe7,0xff,0xff,0x01,0xff,0xff,0x71,0x7e,0x00,0x00,0xfc,0xc7,0xff,0xff,0x81,
+ 0xff,0xff,0x71,0x7e,0x00,0x00,0xfc,0xc3,0xf9,0xf8,0xc1,0x1f,0x9f,0x63,0x7e,
+ 0x00,0x00,0xfc,0xc3,0xf8,0xf8,0x81,0x1f,0x9f,0x73,0x7e,0x00,0x00,0xfc,0xc7,
+ 0xf8,0xfc,0x01,0x00,0x9f,0x61,0x7e,0x00,0x00,0xfc,0x03,0x00,0xfe,0x01,0xe0,
+ 0x03,0x60,0x7e,0x00,0x00,0x7c,0x03,0x80,0xef,0x01,0xe0,0x01,0x00,0x7e,0x00,
+ 0x00,0x7c,0x03,0xfe,0xc7,0x01,0xc0,0x0f,0x00,0x3e,0x00,0x00,0x7c,0x03,0xfe,
+ 0xc3,0x01,0x80,0x1f,0x00,0x3e,0x00,0x00,0xfc,0x02,0x78,0xc0,0x01,0x00,0x00,
+ 0x00,0x3e,0x00,0x00,0xf8,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,
+ 0xfc,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0xf8,0x06,0x00,0xc0,
+ 0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0xf8,0x06,0x00,0xe0,0x00,0x00,0x00,0x00,
+ 0x36,0x00,0x00,0xf0,0x0e,0x00,0xf0,0x00,0x00,0x00,0x00,0x37,0x00,0x00,0xe0,
+ 0x0e,0x00,0x70,0x40,0x00,0x00,0x00,0x3f,0x00,0x00,0xf0,0x1c,0x00,0x7c,0x40,
+ 0x00,0x00,0x00,0x1f,0x00,0x00,0xf0,0x1c,0x00,0x7f,0x00,0xf8,0x00,0x20,0x00,
+ 0x00,0x00,0x00,0x3c,0x80,0x7f,0x00,0xf8,0x01,0x38,0x00,0x00,0x00,0x00,0x3c,
+ 0xc0,0x7e,0x00,0xde,0x03,0x3c,0x00,0x00,0x00,0x00,0x7c,0x60,0x7e,0x80,0x8f,
+ 0x07,0x3e,0x00,0x00,0x00,0x00,0x7c,0x30,0xfe,0xe3,0x07,0xcf,0x3f,0x00,0x00,
+ 0x00,0x00,0xfc,0x1c,0xff,0xff,0x01,0xfe,0x3f,0x00,0x00,0x00,0x00,0xfe,0x0f,
+ 0xff,0xff,0x00,0xfe,0x3f,0x00,0x00,0x00,0x00,0xfe,0x8f,0xff,0x7f,0x00,0xfc,
+ 0x3f,0x00,0x00,0x00,0x00,0xfe,0xe7,0xff,0x3f,0x00,0xfc,0x3f,0x00,0x00,0x00,
+ 0x00,0xfe,0xf1,0xff,0x1f,0xf0,0x7f,0x7f,0x00,0x00,0x00,0x00,0xfe,0xf1,0xff,
+ 0x07,0xff,0x1f,0x7c,0x00,0x00,0x00,0x00,0xfc,0xc1,0xff,0xc7,0xff,0x0f,0x7c,
+ 0x00,0x00,0x00,0x00,0xfc,0xc1,0x83,0xff,0xc3,0x03,0x7e,0x00,0x00,0x00,0x00,
+ 0xbc,0xe1,0x03,0x00,0xe0,0x03,0x3e,0x00,0x00,0x00,0x00,0xbc,0xc3,0x07,0x00,
+ 0xf0,0x01,0x3e,0x00,0x00,0x00,0x00,0xb8,0xc3,0x3f,0x00,0xf0,0x00,0x3f,0x00,
+ 0x00,0x00,0x00,0xb8,0xc3,0x7f,0x00,0xf8,0x00,0x1f,0x00,0x00,0x00,0x00,0x70,
+ 0x83,0xff,0x00,0x0a,0x00,0x0f,0x00,0x00,0x00,0x00,0xf0,0x83,0xff,0xff,0x03,
+ 0x80,0x0f,0x00,0x00,0x00,0x00,0xe0,0x03,0xff,0xff,0x00,0x80,0x0f,0x00,0x00,
+ 0x00,0x00,0xe0,0x87,0xff,0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0xc0,0xc6,
+ 0xff,0x00,0x04,0xc0,0x07,0x00,0x00,0x00,0x00,0xc0,0xe4,0xff,0xe3,0x0f,0xc0,
+ 0x07,0x00,0x00,0x00,0x00,0x80,0xf0,0xfb,0xff,0x1f,0xe0,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xf1,0xff,0x0f,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0xfc,0xf1,
+ 0xff,0x07,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0xfe,0xfc,0x01,0x00,0xf0,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0x7c,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x08,
+ 0x00,0x7f,0x7e,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x1e,0x83,0x7f,0x3e,0x00,
+ 0x00,0x3c,0x00,0x00,0x00,0x00,0x9e,0xc3,0xff,0x3f,0x00,0x00,0x3e,0x00,0x00,
+ 0x00,0x00,0x9f,0xe7,0xff,0x3f,0x00,0x00,0x1f,0x00,0x00,0x00,0x80,0xe7,0xff,
+ 0xe7,0x1f,0x00,0x80,0x0f,0x00,0x00,0x00,0x80,0xe3,0xff,0xe7,0x1f,0x00,0xc0,
+ 0x0f,0x00,0x00,0x00,0x00,0xe0,0xff,0xc3,0x3f,0x00,0xf0,0x07,0x00,0x00,0x00,
+ 0x30,0xe6,0xff,0x83,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xf0,0xc7,0xff,0x01,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf0,0xcf,0xff,0x00,0xfe,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0xf0,0x8f,0xff,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0x00,0xe0,
+ 0x9f,0x7f,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0xe0,0x9f,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x9f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0x9f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00};
diff --git a/source/xap/xlockmore/slack-desc b/source/xap/xlockmore/slack-desc
new file mode 100644
index 00000000..92ee2c41
--- /dev/null
+++ b/source/xap/xlockmore/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xlockmore: xlockmore (screen locker for X)
+xlockmore:
+xlockmore: Patrick J. Naughton's xlock screensaver/locker for X, with many
+xlockmore: more modes added by David A. Bagley.
+xlockmore:
+xlockmore: The 'Bob' bitmap has been included especially for Slackware, as well
+xlockmore: as a Linux penguin logo. (NOTE: the image of J. R. "Bob" Dobbs is a
+xlockmore: registered trademark of The Subgenius Foundation, used by permission)
+xlockmore:
+xlockmore:
+xlockmore:
diff --git a/source/xap/xlockmore/xlockmore.SlackBuild b/source/xap/xlockmore/xlockmore.SlackBuild
new file mode 100755
index 00000000..f25bf14e
--- /dev/null
+++ b/source/xap/xlockmore/xlockmore.SlackBuild
@@ -0,0 +1,108 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=5.28
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-1}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC -lcrypt"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xlockmore
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+## Explode the package framework:
+#cd $PKG
+#tar xzvf $CWD/_xlockmore.tar.gz
+
+cd $TMP
+rm -rf xlockmore-$VERSION
+tar xvf $CWD/xlockmore-$VERSION.tar.bz2 || exit 1
+cd xlockmore-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+zcat $CWD/xlockmore.bitmap.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+mkdir -p $PKG/usr/include/X11/bitmaps
+cp $CWD/l-bob.xbm $PKG/usr/include/X11/bitmaps
+cp $CWD/s-bob.xbm $PKG/usr/include/X11/bitmaps
+cp $CWD/l-linux.xbm $PKG/usr/include/X11/bitmaps
+mkdir -p $PKG/usr/doc/xlockmore-$VERSION
+cp -a README $PKG/usr/doc/xlockmore-$VERSION/README
+cp -a docs/* $PKG/usr/doc/xlockmore-$VERSION
+cp -a $CWD/l-bob.README $PKG/usr/doc/xlockmore-$VERSION
+## Normal compile:
+#./configure --prefix=/usr --without-opengl --without-mesagl \
+# --without-dtsaver --without-rplay --without-nas --disable-bomb
+# Use MesaGL/OpenGL:
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --without-dtsaver \
+ --without-ttf \
+ --without-gtk \
+ --without-rplay \
+ --without-nas \
+ --disable-bomb \
+ --without-motif \
+ --without-esound \
+ --without-gtk \
+ $ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+cd xlock
+
+mkdir -p $PKG/etc/X11/app-defaults
+cat XLock.ad > $PKG/etc/X11/app-defaults/XLock
+mkdir -p $PKG/usr/bin
+cat xlock > $PKG/usr/bin/xlock
+chown root.shadow $PKG/usr/bin/xlock
+chmod 2751 $PKG/usr/bin/xlock
+
+mkdir -p $PKG/usr/man/man1
+cat xlock.man | gzip -9c > $PKG/usr/man/man1/xlock.1.gz
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Build the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xlockmore-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xlockmore/xlockmore.bitmap.diff b/source/xap/xlockmore/xlockmore.bitmap.diff
new file mode 100644
index 00000000..f9d77758
--- /dev/null
+++ b/source/xap/xlockmore/xlockmore.bitmap.diff
@@ -0,0 +1,20 @@
+--- ./xlock/XLock.ad.orig 2002-05-13 09:51:34.000000000 -0700
++++ ./xlock/XLock.ad 2002-05-29 21:25:39.000000000 -0700
+@@ -75,6 +75,8 @@
+ !XLock.*.bitmap: bitmaps/m-xlock.xbm
+ !XLock.*.bitmap: pixmaps/m-xlock.xpm
+ !XLock.*.bitmap: /usr/lib/X11/xlock/bitmaps
++! It's best to have no default here, or it kills the bat mode:
++!XLock.*.bitmap: /usr/X11R6/include/X11/bitmaps/s-bob.xbm
+
+ ! For mailbox check application
+ !XLock.mailCmd: /usr/ucb/mail -e
+@@ -165,6 +167,8 @@
+ !XLock.bounce.cycles: 1
+ XLock.bounce.size: 0
+ XLock.bounce.saturation: 1.0
++! "Bob" is taking over the bounce mode by default:
++XLock.bounce.bitmap: /usr/X11R6/include/X11/bitmaps/s-bob.xbm
+ XLock.braid.delay: 1000
+ XLock.braid.count: 15
+ XLock.braid.cycles: 100
diff --git a/source/xap/xmms/slack-desc b/source/xap/xmms/slack-desc
new file mode 100644
index 00000000..6ea4362d
--- /dev/null
+++ b/source/xap/xmms/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xmms: xmms (X Multimedia System)
+xmms:
+xmms: XMMS is the X Multimedia System. It is used to play audio and other
+xmms: kinds of media files. By default XMMS can play MPEG audio, Ogg
+xmms: Vorbis, RIFF wav, most module formats, and a few other formats. XMMS
+xmms: can be extended through plugins to play a number of other audio and
+xmms: video formats.
+xmms:
+xmms:
+xmms:
+xmms:
diff --git a/source/xap/xmms/xmms.SlackBuild b/source/xap/xmms/xmms.SlackBuild
new file mode 100755
index 00000000..b11afde6
--- /dev/null
+++ b/source/xap/xmms/xmms.SlackBuild
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=1.2.11
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-3}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+ ARCHOPTS="--enable-simd"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+ ARCHOPTS=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+ ARCHOPTS=""
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xmms
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf xmms-$VERSION
+tar xvf $CWD/xmms-$VERSION.tar.bz2 || exit 1
+cd xmms-$VERSION || exit 1
+
+zcat $CWD/xmms.gtk.doublesize.diff.gz | patch -p1 || exit 1
+zcat $CWD/xmms.wmxmms_vis_depth_workaround.diff.gz | patch -p0 || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+ ./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --localstatedir=/var/lib \
+ --disable-static \
+ --with-ipv6 \
+ $ARCHOPTS \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+# Add a .desktop file for the menus:
+mkdir -p $PKG/usr/share/applications
+cat $CWD/xmms.desktop > $PKG/usr/share/applications/xmms.desktop
+
+mkdir -p $PKG/usr/doc/xmms-$VERSION
+cp -a \
+ ABOUT-NLS AUTHORS COPYING FAQ INSTALL NEWS README TODO \
+ $PKG/usr/doc/xmms-$VERSION
+
+# Finish up...
+gzip -9 $PKG/usr/man/*/*
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xmms-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xmms/xmms.desktop b/source/xap/xmms/xmms.desktop
new file mode 100644
index 00000000..49e4870b
--- /dev/null
+++ b/source/xap/xmms/xmms.desktop
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Name=XMMS
+GenericName=Audio Player
+Comment=Play music
+Comment[hu]=Zene lejátszása
+Comment[de]=Musik abspielen
+Exec=xmms %U
+Icon=xmms
+MimeType=application/x-ogg;audio/mp3;audio/mpeg;audio/mpegurl;audio/prs.sid;audio/x-flac;audio/x-it;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-s3m;audio/x-scpls;audio/x-stm;audio/x-wav;audio/x-xm;application/ogg;audio/x-vorbis+ogg
+Categories=Application;GTK;AudioVideo;Player;
+Terminal=false
+Type=Application
+Encoding=UTF-8
diff --git a/source/xap/xmms/xmms.gtk.doublesize.diff b/source/xap/xmms/xmms.gtk.doublesize.diff
new file mode 100644
index 00000000..226bb78a
--- /dev/null
+++ b/source/xap/xmms/xmms.gtk.doublesize.diff
@@ -0,0 +1,11 @@
+--- ./xmms/util.c.orig 2006-07-16 08:40:04.000000000 -0500
++++ ./xmms/util.c 2008-09-12 15:49:41.000000000 -0500
+@@ -175,7 +175,7 @@
+ * This needs to be optimized
+ */
+
+- dblimg = gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_best(), img->width << 1, img->height << 1);
++ dblimg = gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_best_with_depth(img->depth), img->width << 1, img->height << 1);
+ if (dblimg->bpp == 1)
+ {
+ char *srcptr, *ptr, *ptr2;
diff --git a/source/xap/xmms/xmms.wmxmms_vis_depth_workaround.diff b/source/xap/xmms/xmms.wmxmms_vis_depth_workaround.diff
new file mode 100644
index 00000000..8b940791
--- /dev/null
+++ b/source/xap/xmms/xmms.wmxmms_vis_depth_workaround.diff
@@ -0,0 +1,11 @@
+--- wmxmms/wmxmms.c.orig 2008-11-09 19:32:24.000000000 -0600
++++ wmxmms/wmxmms.c 2008-09-13 12:17:35.000000000 -0500
+@@ -650,7 +650,7 @@
+ dock_gc = gdk_gc_new(icon_win->window);
+
+ launch_pixmap = gdk_pixmap_new(window->window, 64, 64,
+- gdk_visual_get_best_depth());
++ -1);
+
+ launch_mask = gdk_pixmap_new(window->window, 64, 64, 1);
+ mask_gc = gdk_gc_new(launch_mask);
diff --git a/source/xap/xpaint/slack-desc b/source/xap/xpaint/slack-desc
new file mode 100644
index 00000000..93027a60
--- /dev/null
+++ b/source/xap/xpaint/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xpaint: xpaint (simple X paint program)
+xpaint:
+xpaint: XPaint is a versatile bitmap/pixmap editing tool with a feature set
+xpaint: similar to MacPaint.
+xpaint:
+xpaint: The short features list:
+xpaint: Brushes, Spray paint, Pencil, Lines, Arcs, Pattern Fill, Text,
+xpaint: Boxes, Circles, Polygons.
+xpaint: Works on multiple images simultaneously. Cut/Copy/Paste between all
+xpaint: active images. Fatbits/Zoom on the image windows.
+xpaint:
diff --git a/source/xap/xpaint/xpaint.SlackBuild b/source/xap/xpaint/xpaint.SlackBuild
new file mode 100755
index 00000000..c353c738
--- /dev/null
+++ b/source/xap/xpaint/xpaint.SlackBuild
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PKGNAM=xpaint
+VERSION=${VERSION:-2.7.8.1}
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-2}
+
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+if [ "$ARCH" = "x86_64" ]; then
+ # Make it detect Xaw3d:
+ sed -i -e "s#usr/lib/#usr/lib${LIBDIRSUFFIX}/#g" $( grep -lr 'usr/lib/' * )
+fi
+zcat ${CWD}/xpaint_xaw3d_no_scroll_mode.diff.gz | patch -p1 || exit 1
+#zcat ${CWD}/xpaint_2.7.8.1-1.2.diff.gz | patch -p1 || exit 1
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+./configure
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG
+make install.man DESTDIR=$PKG
+
+( cd bitmaps
+ mkdir -p ${PKG}/usr/include/X11/bitmaps
+ find . -name "*.xbm" -exec cp {} ${PKG}/usr/include/X11/bitmaps \;
+ mkdir -p ${PKG}/usr/include/X11/pixmaps
+ find . -name "*.xpm" -exec cp {} ${PKG}/usr/include/X11/pixmaps \;
+ mkdir -p /install
+)
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p ${PKG}/usr/doc/xpaint-$VERSION
+cp -a \
+ README README.PNG README.old TODO \
+ ${PKG}/usr/doc/xpaint-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > ${PKG}/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xpaint/xpaint_2.7.8.1-1.2.diff b/source/xap/xpaint/xpaint_2.7.8.1-1.2.diff
new file mode 100644
index 00000000..1f8cc82e
--- /dev/null
+++ b/source/xap/xpaint/xpaint_2.7.8.1-1.2.diff
@@ -0,0 +1,47 @@
+--- ./misc.h.orig 2005-08-15 14:50:05.000000000 -0500
++++ ./misc.h 2007-05-10 16:46:23.000000000 -0500
+@@ -24,7 +24,7 @@
+ long random(void);
+ #endif
+
+-#if !defined(__VMS) & !defined(linux) & !defined(__EMX__) & !defined(__FreeBSD__) & !defined(__CYGWIN__)
++#if !defined(__VMS) & !defined(linux) & !defined(__EMX__) & !defined(__FreeBSD__) & !defined(__CYGWIN__) & !defined(__GLIBC__)
+ #if defined(BSD4_4) || defined(HPArchitecture) || defined(SGIArchitecture) || defined(_AIX) || defined(_SCO_DS)
+ void srandom(unsigned int);
+ #else
+--- ./Local.config.orig 2005-04-30 16:33:14.000000000 -0500
++++ ./Local.config 2007-05-10 16:47:02.000000000 -0500
+@@ -132,11 +132,11 @@
+ XCOMM You must have the XPM library.
+ XCOMM Make sure the path name to the library is correct.
+
+-XPM_LIB = -L/usr/X11R6/lib -lXpm
++XPM_LIB = -lXpm
+
+ XCOMM Make sure this points to the location of the 'xpm.h' file.
+
+-XPM_INCLUDE = -I/usr/X11R6/include/X11
++XPM_INCLUDE = -I/usr/include/X11
+
+
+ DEPENDFLAGS = -I./bitmaps
+--- ./configure.orig 2005-06-03 07:26:11.000000000 -0500
++++ ./configure 2007-05-10 16:46:23.000000000 -0500
+@@ -7,7 +7,7 @@
+ echo "(looking for Xaw, Xaw3d, Xaw95, neXtaw)"
+ echo ""
+ else
+- WIDGETS=`echo $1 | tr [a:z] [A:Z]`
++ WIDGETS=`echo $1`
+ fi
+
+ if test "$WIDGETS" = "" ; then
+@@ -54,7 +54,7 @@
+ fi
+ fi
+
+-if test "$WIDGETS" = "XAW3DG" ; then
++if test "$WIDGETS" = "xaw3dg" ; then
+ ln -sf /usr/include/X11/Xaw3d xaw_incdir
+ echo "XAWLIB_DEFINES = -DXAW3D -DXAW3DG"
+ echo "XAWLIB_DEFINES = -DXAW3D -DXAW3DG" > Local.xawdefs
diff --git a/source/xap/xpaint/xpaint_xaw3d_no_scroll_mode.diff b/source/xap/xpaint/xpaint_xaw3d_no_scroll_mode.diff
new file mode 100644
index 00000000..f89b12c1
--- /dev/null
+++ b/source/xap/xpaint/xpaint_xaw3d_no_scroll_mode.diff
@@ -0,0 +1,11 @@
+--- xpaint-2.7.8.1/misc.c.orig 2005-04-24 11:57:52.000000000 +0000
++++ xpaint-2.7.8.1/misc.c 2008-11-06 21:43:46.000000000 +0000
+@@ -671,7 +671,7 @@
+ }
+ else return;
+ if (sb == None) return;
+-#ifdef XAW3DG
++#if defined(XAW3DG) && defined(XAW_ARROW_SCROLLBARS)
+ if (((ScrollbarWidget)sb)->scrollbar.scroll_mode == 2 /* if scroll continuous */
+ || LookAhead (sb, event))
+ return;
diff --git a/source/xap/xpdf/VendorP.h.buggy.diff b/source/xap/xpdf/VendorP.h.buggy.diff
new file mode 100644
index 00000000..a8c91ab4
--- /dev/null
+++ b/source/xap/xpdf/VendorP.h.buggy.diff
@@ -0,0 +1,19 @@
+--- ./VendorP.h.orig 2007-02-14 02:45:33.000000000 -0600
++++ ./VendorP.h 2007-08-08 14:22:17.000000000 -0500
+@@ -76,6 +76,8 @@
+ XtPointer extension; /* pointer to extension record */
+ } VendorShellClassPart;
+
++struct VendorShellClassRec;
++/*
+ typedef struct _VendorShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+@@ -85,6 +87,7 @@
+ } VendorShellClassRec;
+
+ externalref VendorShellClassRec vendorShellClassRec;
++*/
+
+ /* New fields for the vendor shell widget. */
+
diff --git a/source/xap/xpdf/slack-desc b/source/xap/xpdf/slack-desc
new file mode 100644
index 00000000..164302aa
--- /dev/null
+++ b/source/xap/xpdf/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xpdf: xpdf (PDF viewer for X)
+xpdf:
+xpdf: Xpdf is a viewer for Portable Document Format (PDF) files.
+xpdf:
+xpdf: xpdf was written by Derek B. Noonburg.
+xpdf:
+xpdf: The xpdf package requires the t1lib package to render Type 1 fonts.
+xpdf:
+xpdf:
+xpdf:
+xpdf:
diff --git a/source/xap/xpdf/xpdf-3.02pl1.patch b/source/xap/xpdf/xpdf-3.02pl1.patch
new file mode 100644
index 00000000..cd42fb96
--- /dev/null
+++ b/source/xap/xpdf/xpdf-3.02pl1.patch
@@ -0,0 +1,33 @@
+*** xpdf-3.02.orig/xpdf/Stream.cc Tue Feb 27 14:05:52 2007
+--- xpdf-3.02/xpdf/Stream.cc Thu Jul 26 14:44:43 2007
+***************
+*** 410,424 ****
+ ok = gFalse;
+
+ nVals = width * nComps;
+- if (width <= 0 || nComps <= 0 || nBits <= 0 ||
+- nComps >= INT_MAX / nBits ||
+- width >= INT_MAX / nComps / nBits ||
+- nVals * nBits + 7 < 0) {
+- return;
+- }
+ pixBytes = (nComps * nBits + 7) >> 3;
+ rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
+! if (rowBytes <= 0) {
+ return;
+ }
+ predLine = (Guchar *)gmalloc(rowBytes);
+--- 410,422 ----
+ ok = gFalse;
+
+ nVals = width * nComps;
+ pixBytes = (nComps * nBits + 7) >> 3;
+ rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
+! if (width <= 0 || nComps <= 0 || nBits <= 0 ||
+! nComps > gfxColorMaxComps ||
+! nBits > 16 ||
+! width >= INT_MAX / nComps || // check for overflow in nVals
+! nVals >= (INT_MAX - 7) / nBits) { // check for overflow in rowBytes
+ return;
+ }
+ predLine = (Guchar *)gmalloc(rowBytes);
diff --git a/source/xap/xpdf/xpdf-3.02pl2.patch b/source/xap/xpdf/xpdf-3.02pl2.patch
new file mode 100644
index 00000000..ab9e3c67
--- /dev/null
+++ b/source/xap/xpdf/xpdf-3.02pl2.patch
@@ -0,0 +1,823 @@
+diff -c -r xpdf-3.02pl1.orig/xpdf/Stream.cc xpdf-3.02/xpdf/Stream.cc
+*** xpdf-3.02pl1.orig/xpdf/Stream.cc Thu Oct 25 15:47:38 2007
+--- xpdf-3.02/xpdf/Stream.cc Thu Oct 25 15:48:19 2007
+***************
+*** 1243,1265 ****
+ columns = columnsA;
+ if (columns < 1) {
+ columns = 1;
+! }
+! if (columns + 4 <= 0) {
+! columns = INT_MAX - 4;
+ }
+ rows = rowsA;
+ endOfBlock = endOfBlockA;
+ black = blackA;
+! refLine = (short *)gmallocn(columns + 3, sizeof(short));
+! codingLine = (short *)gmallocn(columns + 2, sizeof(short));
+
+ eof = gFalse;
+ row = 0;
+ nextLine2D = encoding < 0;
+ inputBits = 0;
+! codingLine[0] = 0;
+! codingLine[1] = refLine[2] = columns;
+! a0 = 1;
+
+ buf = EOF;
+ }
+--- 1243,1268 ----
+ columns = columnsA;
+ if (columns < 1) {
+ columns = 1;
+! } else if (columns > INT_MAX - 2) {
+! columns = INT_MAX - 2;
+ }
+ rows = rowsA;
+ endOfBlock = endOfBlockA;
+ black = blackA;
+! // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = columns
+! // ---> max codingLine size = columns + 1
+! // refLine has one extra guard entry at the end
+! // ---> max refLine size = columns + 2
+! codingLine = (int *)gmallocn(columns + 1, sizeof(int));
+! refLine = (int *)gmallocn(columns + 2, sizeof(int));
+
+ eof = gFalse;
+ row = 0;
+ nextLine2D = encoding < 0;
+ inputBits = 0;
+! codingLine[0] = columns;
+! a0i = 0;
+! outputBits = 0;
+
+ buf = EOF;
+ }
+***************
+*** 1278,1286 ****
+ row = 0;
+ nextLine2D = encoding < 0;
+ inputBits = 0;
+! codingLine[0] = 0;
+! codingLine[1] = columns;
+! a0 = 1;
+ buf = EOF;
+
+ // skip any initial zero bits and end-of-line marker, and get the 2D
+--- 1281,1289 ----
+ row = 0;
+ nextLine2D = encoding < 0;
+ inputBits = 0;
+! codingLine[0] = columns;
+! a0i = 0;
+! outputBits = 0;
+ buf = EOF;
+
+ // skip any initial zero bits and end-of-line marker, and get the 2D
+***************
+*** 1297,1507 ****
+ }
+ }
+
+ int CCITTFaxStream::lookChar() {
+ short code1, code2, code3;
+! int a0New;
+! GBool err, gotEOL;
+! int ret;
+! int bits, i;
+
+! // if at eof just return EOF
+! if (eof && codingLine[a0] >= columns) {
+! return EOF;
+ }
+
+ // read the next row
+! err = gFalse;
+! if (codingLine[a0] >= columns) {
+
+ // 2-D encoding
+ if (nextLine2D) {
+- // state:
+- // a0New = current position in coding line (0 <= a0New <= columns)
+- // codingLine[a0] = last change in coding line
+- // (black-to-white if a0 is even,
+- // white-to-black if a0 is odd)
+- // refLine[b1] = next change in reference line of opposite color
+- // to a0
+- // invariants:
+- // 0 <= codingLine[a0] <= a0New
+- // <= refLine[b1] <= refLine[b1+1] <= columns
+- // 0 <= a0 <= columns+1
+- // refLine[0] = 0
+- // refLine[n] = refLine[n+1] = columns
+- // -- for some 1 <= n <= columns+1
+- // end condition:
+- // 0 = codingLine[0] <= codingLine[1] < codingLine[2] < ...
+- // < codingLine[n-1] < codingLine[n] = columns
+- // -- where 1 <= n <= columns+1
+ for (i = 0; codingLine[i] < columns; ++i) {
+ refLine[i] = codingLine[i];
+ }
+! refLine[i] = refLine[i + 1] = columns;
+! b1 = 1;
+! a0New = codingLine[a0 = 0] = 0;
+! do {
+ code1 = getTwoDimCode();
+ switch (code1) {
+ case twoDimPass:
+! if (refLine[b1] < columns) {
+! a0New = refLine[b1 + 1];
+! b1 += 2;
+ }
+ break;
+ case twoDimHoriz:
+! if ((a0 & 1) == 0) {
+! code1 = code2 = 0;
+ do {
+! code1 += code3 = getWhiteCode();
+ } while (code3 >= 64);
+ do {
+! code2 += code3 = getBlackCode();
+ } while (code3 >= 64);
+ } else {
+- code1 = code2 = 0;
+ do {
+! code1 += code3 = getBlackCode();
+ } while (code3 >= 64);
+ do {
+! code2 += code3 = getWhiteCode();
+ } while (code3 >= 64);
+ }
+! if (code1 > 0 || code2 > 0) {
+! if (a0New + code1 <= columns) {
+! codingLine[a0 + 1] = a0New + code1;
+! } else {
+! codingLine[a0 + 1] = columns;
+! }
+! ++a0;
+! if (codingLine[a0] + code2 <= columns) {
+! codingLine[a0 + 1] = codingLine[a0] + code2;
+! } else {
+! codingLine[a0 + 1] = columns;
+! }
+! ++a0;
+! a0New = codingLine[a0];
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+ }
+ break;
+! case twoDimVert0:
+! if (refLine[b1] < columns) {
+! a0New = codingLine[++a0] = refLine[b1];
+! ++b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+- } else {
+- a0New = codingLine[++a0] = columns;
+ }
+ break;
+ case twoDimVertR1:
+! if (refLine[b1] + 1 < columns) {
+! a0New = codingLine[++a0] = refLine[b1] + 1;
+! ++b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+- } else {
+- a0New = codingLine[++a0] = columns;
+ }
+ break;
+! case twoDimVertL1:
+! if (refLine[b1] - 1 > a0New || (a0 == 0 && refLine[b1] == 1)) {
+! a0New = codingLine[++a0] = refLine[b1] - 1;
+! --b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+ }
+ break;
+! case twoDimVertR2:
+! if (refLine[b1] + 2 < columns) {
+! a0New = codingLine[++a0] = refLine[b1] + 2;
+! ++b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+- } else {
+- a0New = codingLine[++a0] = columns;
+ }
+ break;
+ case twoDimVertL2:
+! if (refLine[b1] - 2 > a0New || (a0 == 0 && refLine[b1] == 2)) {
+! a0New = codingLine[++a0] = refLine[b1] - 2;
+! --b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+! }
+! break;
+! case twoDimVertR3:
+! if (refLine[b1] + 3 < columns) {
+! a0New = codingLine[++a0] = refLine[b1] + 3;
+! ++b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+- } else {
+- a0New = codingLine[++a0] = columns;
+ }
+ break;
+! case twoDimVertL3:
+! if (refLine[b1] - 3 > a0New || (a0 == 0 && refLine[b1] == 3)) {
+! a0New = codingLine[++a0] = refLine[b1] - 3;
+! --b1;
+! while (refLine[b1] <= a0New && refLine[b1] < columns) {
+! b1 += 2;
+ }
+ }
+ break;
+ case EOF:
+ eof = gTrue;
+! codingLine[a0 = 0] = columns;
+! return EOF;
+ default:
+ error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
+ err = gTrue;
+ break;
+ }
+! } while (codingLine[a0] < columns);
+
+ // 1-D encoding
+ } else {
+! codingLine[a0 = 0] = 0;
+! while (1) {
+ code1 = 0;
+! do {
+! code1 += code3 = getWhiteCode();
+! } while (code3 >= 64);
+! codingLine[a0+1] = codingLine[a0] + code1;
+! ++a0;
+! if (codingLine[a0] >= columns) {
+! break;
+! }
+! code2 = 0;
+! do {
+! code2 += code3 = getBlackCode();
+! } while (code3 >= 64);
+! codingLine[a0+1] = codingLine[a0] + code2;
+! ++a0;
+! if (codingLine[a0] >= columns) {
+! break;
+ }
+ }
+ }
+
+- if (codingLine[a0] != columns) {
+- error(getPos(), "CCITTFax row is wrong length (%d)", codingLine[a0]);
+- // force the row to be the correct length
+- while (codingLine[a0] > columns) {
+- --a0;
+- }
+- codingLine[++a0] = columns;
+- err = gTrue;
+- }
+-
+ // byte-align the row
+ if (byteAlign) {
+ inputBits &= ~7;
+--- 1300,1529 ----
+ }
+ }
+
++ inline void CCITTFaxStream::addPixels(int a1, int blackPixels) {
++ if (a1 > codingLine[a0i]) {
++ if (a1 > columns) {
++ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
++ err = gTrue;
++ a1 = columns;
++ }
++ if ((a0i & 1) ^ blackPixels) {
++ ++a0i;
++ }
++ codingLine[a0i] = a1;
++ }
++ }
++
++ inline void CCITTFaxStream::addPixelsNeg(int a1, int blackPixels) {
++ if (a1 > codingLine[a0i]) {
++ if (a1 > columns) {
++ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
++ err = gTrue;
++ a1 = columns;
++ }
++ if ((a0i & 1) ^ blackPixels) {
++ ++a0i;
++ }
++ codingLine[a0i] = a1;
++ } else if (a1 < codingLine[a0i]) {
++ if (a1 < 0) {
++ error(getPos(), "Invalid CCITTFax code");
++ err = gTrue;
++ a1 = 0;
++ }
++ while (a0i > 0 && a1 <= codingLine[a0i - 1]) {
++ --a0i;
++ }
++ codingLine[a0i] = a1;
++ }
++ }
++
+ int CCITTFaxStream::lookChar() {
+ short code1, code2, code3;
+! int b1i, blackPixels, i, bits;
+! GBool gotEOL;
+
+! if (buf != EOF) {
+! return buf;
+ }
+
+ // read the next row
+! if (outputBits == 0) {
+!
+! // if at eof just return EOF
+! if (eof) {
+! return EOF;
+! }
+!
+! err = gFalse;
+
+ // 2-D encoding
+ if (nextLine2D) {
+ for (i = 0; codingLine[i] < columns; ++i) {
+ refLine[i] = codingLine[i];
+ }
+! refLine[i++] = columns;
+! refLine[i] = columns;
+! codingLine[0] = 0;
+! a0i = 0;
+! b1i = 0;
+! blackPixels = 0;
+! // invariant:
+! // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1]
+! // <= columns
+! // exception at left edge:
+! // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
+! // exception at right edge:
+! // refLine[b1i] = refLine[b1i+1] = columns is possible
+! while (codingLine[a0i] < columns) {
+ code1 = getTwoDimCode();
+ switch (code1) {
+ case twoDimPass:
+! addPixels(refLine[b1i + 1], blackPixels);
+! if (refLine[b1i + 1] < columns) {
+! b1i += 2;
+ }
+ break;
+ case twoDimHoriz:
+! code1 = code2 = 0;
+! if (blackPixels) {
+ do {
+! code1 += code3 = getBlackCode();
+ } while (code3 >= 64);
+ do {
+! code2 += code3 = getWhiteCode();
+ } while (code3 >= 64);
+ } else {
+ do {
+! code1 += code3 = getWhiteCode();
+ } while (code3 >= 64);
+ do {
+! code2 += code3 = getBlackCode();
+ } while (code3 >= 64);
+ }
+! addPixels(codingLine[a0i] + code1, blackPixels);
+! if (codingLine[a0i] < columns) {
+! addPixels(codingLine[a0i] + code2, blackPixels ^ 1);
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+! }
+! break;
+! case twoDimVertR3:
+! addPixels(refLine[b1i] + 3, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+! case twoDimVertR2:
+! addPixels(refLine[b1i] + 2, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+ case twoDimVertR1:
+! addPixels(refLine[b1i] + 1, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+! case twoDimVert0:
+! addPixels(refLine[b1i], blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+! case twoDimVertL3:
+! addPixelsNeg(refLine[b1i] - 3, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+ case twoDimVertL2:
+! addPixelsNeg(refLine[b1i] - 2, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+ }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+! case twoDimVertL1:
+! addPixelsNeg(refLine[b1i] - 1, blackPixels);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < columns) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+! b1i += 2;
+ }
+ }
+ break;
+ case EOF:
++ addPixels(columns, 0);
+ eof = gTrue;
+! break;
+ default:
+ error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
++ addPixels(columns, 0);
+ err = gTrue;
+ break;
+ }
+! }
+
+ // 1-D encoding
+ } else {
+! codingLine[0] = 0;
+! a0i = 0;
+! blackPixels = 0;
+! while (codingLine[a0i] < columns) {
+ code1 = 0;
+! if (blackPixels) {
+! do {
+! code1 += code3 = getBlackCode();
+! } while (code3 >= 64);
+! } else {
+! do {
+! code1 += code3 = getWhiteCode();
+! } while (code3 >= 64);
+ }
++ addPixels(codingLine[a0i] + code1, blackPixels);
++ blackPixels ^= 1;
+ }
+ }
+
+ // byte-align the row
+ if (byteAlign) {
+ inputBits &= ~7;
+***************
+*** 1560,1573 ****
+ // this if we know the stream contains end-of-line markers because
+ // the "just plow on" technique tends to work better otherwise
+ } else if (err && endOfLine) {
+! do {
+ if (code1 == EOF) {
+ eof = gTrue;
+ return EOF;
+ }
+ eatBits(1);
+! code1 = lookBits(13);
+! } while ((code1 >> 1) != 0x001);
+ eatBits(12);
+ if (encoding > 0) {
+ eatBits(1);
+--- 1582,1598 ----
+ // this if we know the stream contains end-of-line markers because
+ // the "just plow on" technique tends to work better otherwise
+ } else if (err && endOfLine) {
+! while (1) {
+! code1 = lookBits(13);
+ if (code1 == EOF) {
+ eof = gTrue;
+ return EOF;
+ }
++ if ((code1 >> 1) == 0x001) {
++ break;
++ }
+ eatBits(1);
+! }
+ eatBits(12);
+ if (encoding > 0) {
+ eatBits(1);
+***************
+*** 1575,1585 ****
+ }
+ }
+
+! a0 = 0;
+! outputBits = codingLine[1] - codingLine[0];
+! if (outputBits == 0) {
+! a0 = 1;
+! outputBits = codingLine[2] - codingLine[1];
+ }
+
+ ++row;
+--- 1600,1610 ----
+ }
+ }
+
+! // set up for output
+! if (codingLine[0] > 0) {
+! outputBits = codingLine[a0i = 0];
+! } else {
+! outputBits = codingLine[a0i = 1];
+ }
+
+ ++row;
+***************
+*** 1587,1625 ****
+
+ // get a byte
+ if (outputBits >= 8) {
+! ret = ((a0 & 1) == 0) ? 0xff : 0x00;
+! if ((outputBits -= 8) == 0) {
+! ++a0;
+! if (codingLine[a0] < columns) {
+! outputBits = codingLine[a0 + 1] - codingLine[a0];
+! }
+ }
+ } else {
+ bits = 8;
+! ret = 0;
+ do {
+ if (outputBits > bits) {
+! i = bits;
+! bits = 0;
+! if ((a0 & 1) == 0) {
+! ret |= 0xff >> (8 - i);
+ }
+! outputBits -= i;
+ } else {
+! i = outputBits;
+! bits -= outputBits;
+! if ((a0 & 1) == 0) {
+! ret |= (0xff >> (8 - i)) << bits;
+ }
+ outputBits = 0;
+! ++a0;
+! if (codingLine[a0] < columns) {
+! outputBits = codingLine[a0 + 1] - codingLine[a0];
+ }
+ }
+! } while (bits > 0 && codingLine[a0] < columns);
+ }
+- buf = black ? (ret ^ 0xff) : ret;
+ return buf;
+ }
+
+--- 1612,1654 ----
+
+ // get a byte
+ if (outputBits >= 8) {
+! buf = (a0i & 1) ? 0x00 : 0xff;
+! outputBits -= 8;
+! if (outputBits == 0 && codingLine[a0i] < columns) {
+! ++a0i;
+! outputBits = codingLine[a0i] - codingLine[a0i - 1];
+ }
+ } else {
+ bits = 8;
+! buf = 0;
+ do {
+ if (outputBits > bits) {
+! buf <<= bits;
+! if (!(a0i & 1)) {
+! buf |= 0xff >> (8 - bits);
+ }
+! outputBits -= bits;
+! bits = 0;
+ } else {
+! buf <<= outputBits;
+! if (!(a0i & 1)) {
+! buf |= 0xff >> (8 - outputBits);
+ }
++ bits -= outputBits;
+ outputBits = 0;
+! if (codingLine[a0i] < columns) {
+! ++a0i;
+! outputBits = codingLine[a0i] - codingLine[a0i - 1];
+! } else if (bits > 0) {
+! buf <<= bits;
+! bits = 0;
+ }
+ }
+! } while (bits);
+! }
+! if (black) {
+! buf ^= 0xff;
+ }
+ return buf;
+ }
+
+***************
+*** 1661,1666 ****
+--- 1690,1698 ----
+ code = 0; // make gcc happy
+ if (endOfBlock) {
+ code = lookBits(12);
++ if (code == EOF) {
++ return 1;
++ }
+ if ((code >> 5) == 0) {
+ p = &whiteTab1[code];
+ } else {
+***************
+*** 1673,1678 ****
+--- 1705,1713 ----
+ } else {
+ for (n = 1; n <= 9; ++n) {
+ code = lookBits(n);
++ if (code == EOF) {
++ return 1;
++ }
+ if (n < 9) {
+ code <<= 9 - n;
+ }
+***************
+*** 1684,1689 ****
+--- 1719,1727 ----
+ }
+ for (n = 11; n <= 12; ++n) {
+ code = lookBits(n);
++ if (code == EOF) {
++ return 1;
++ }
+ if (n < 12) {
+ code <<= 12 - n;
+ }
+***************
+*** 1709,1717 ****
+ code = 0; // make gcc happy
+ if (endOfBlock) {
+ code = lookBits(13);
+ if ((code >> 7) == 0) {
+ p = &blackTab1[code];
+! } else if ((code >> 9) == 0) {
+ p = &blackTab2[(code >> 1) - 64];
+ } else {
+ p = &blackTab3[code >> 7];
+--- 1747,1758 ----
+ code = 0; // make gcc happy
+ if (endOfBlock) {
+ code = lookBits(13);
++ if (code == EOF) {
++ return 1;
++ }
+ if ((code >> 7) == 0) {
+ p = &blackTab1[code];
+! } else if ((code >> 9) == 0 && (code >> 7) != 0) {
+ p = &blackTab2[(code >> 1) - 64];
+ } else {
+ p = &blackTab3[code >> 7];
+***************
+*** 1723,1728 ****
+--- 1764,1772 ----
+ } else {
+ for (n = 2; n <= 6; ++n) {
+ code = lookBits(n);
++ if (code == EOF) {
++ return 1;
++ }
+ if (n < 6) {
+ code <<= 6 - n;
+ }
+***************
+*** 1734,1739 ****
+--- 1778,1786 ----
+ }
+ for (n = 7; n <= 12; ++n) {
+ code = lookBits(n);
++ if (code == EOF) {
++ return 1;
++ }
+ if (n < 12) {
+ code <<= 12 - n;
+ }
+***************
+*** 1747,1752 ****
+--- 1794,1802 ----
+ }
+ for (n = 10; n <= 13; ++n) {
+ code = lookBits(n);
++ if (code == EOF) {
++ return 1;
++ }
+ if (n < 13) {
+ code <<= 13 - n;
+ }
+***************
+*** 1961,1966 ****
+--- 2011,2022 ----
+ // allocate a buffer for the whole image
+ bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
+ bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
++ if (bufWidth <= 0 || bufHeight <= 0 ||
++ bufWidth > INT_MAX / bufWidth / (int)sizeof(int)) {
++ error(getPos(), "Invalid image size in DCT stream");
++ y = height;
++ return;
++ }
+ for (i = 0; i < numComps; ++i) {
+ frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
+ memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
+***************
+*** 3036,3041 ****
+--- 3092,3102 ----
+ }
+ scanInfo.firstCoeff = str->getChar();
+ scanInfo.lastCoeff = str->getChar();
++ if (scanInfo.firstCoeff < 0 || scanInfo.lastCoeff > 63 ||
++ scanInfo.firstCoeff > scanInfo.lastCoeff) {
++ error(getPos(), "Bad DCT coefficient numbers in scan info block");
++ return gFalse;
++ }
+ c = str->getChar();
+ scanInfo.ah = (c >> 4) & 0x0f;
+ scanInfo.al = c & 0x0f;
+diff -c -r xpdf-3.02pl1.orig/xpdf/Stream.h xpdf-3.02/xpdf/Stream.h
+*** xpdf-3.02pl1.orig/xpdf/Stream.h Tue Feb 27 14:05:52 2007
+--- xpdf-3.02/xpdf/Stream.h Thu Oct 25 15:48:15 2007
+***************
+*** 528,540 ****
+ int row; // current row
+ int inputBuf; // input buffer
+ int inputBits; // number of bits in input buffer
+! short *refLine; // reference line changing elements
+! int b1; // index into refLine
+! short *codingLine; // coding line changing elements
+! int a0; // index into codingLine
+ int outputBits; // remaining ouput bits
+ int buf; // character buffer
+
+ short getTwoDimCode();
+ short getWhiteCode();
+ short getBlackCode();
+--- 528,542 ----
+ int row; // current row
+ int inputBuf; // input buffer
+ int inputBits; // number of bits in input buffer
+! int *codingLine; // coding line changing elements
+! int *refLine; // reference line changing elements
+! int a0i; // index into codingLine
+! GBool err; // error on current line
+ int outputBits; // remaining ouput bits
+ int buf; // character buffer
+
++ void addPixels(int a1, int black);
++ void addPixelsNeg(int a1, int black);
+ short getTwoDimCode();
+ short getWhiteCode();
+ short getBlackCode();
diff --git a/source/xap/xpdf/xpdf-3.02pl3.patch b/source/xap/xpdf/xpdf-3.02pl3.patch
new file mode 100644
index 00000000..b5988805
--- /dev/null
+++ b/source/xap/xpdf/xpdf-3.02pl3.patch
@@ -0,0 +1,1145 @@
+diff -r -c xpdf-3.02.orig/goo/gmem.cc xpdf-3.02/goo/gmem.cc
+*** xpdf-3.02.orig/goo/gmem.cc Tue Feb 27 14:05:51 2007
+--- xpdf-3.02/goo/gmem.cc Thu Mar 19 15:47:25 2009
+***************
+*** 55,61 ****
+ void *data;
+ unsigned long *trl, *p;
+
+! if (size <= 0) {
+ return NULL;
+ }
+ size1 = gMemDataSize(size);
+--- 55,69 ----
+ void *data;
+ unsigned long *trl, *p;
+
+! if (size < 0) {
+! #if USE_EXCEPTIONS
+! throw GMemException();
+! #else
+! fprintf(stderr, "Invalid memory allocation size\n");
+! exit(1);
+! #endif
+! }
+! if (size == 0) {
+ return NULL;
+ }
+ size1 = gMemDataSize(size);
+***************
+*** 91,97 ****
+ #else
+ void *p;
+
+! if (size <= 0) {
+ return NULL;
+ }
+ if (!(p = malloc(size))) {
+--- 99,113 ----
+ #else
+ void *p;
+
+! if (size < 0) {
+! #if USE_EXCEPTIONS
+! throw GMemException();
+! #else
+! fprintf(stderr, "Invalid memory allocation size\n");
+! exit(1);
+! #endif
+! }
+! if (size == 0) {
+ return NULL;
+ }
+ if (!(p = malloc(size))) {
+***************
+*** 112,118 ****
+ void *q;
+ int oldSize;
+
+! if (size <= 0) {
+ if (p) {
+ gfree(p);
+ }
+--- 128,142 ----
+ void *q;
+ int oldSize;
+
+! if (size < 0) {
+! #if USE_EXCEPTIONS
+! throw GMemException();
+! #else
+! fprintf(stderr, "Invalid memory allocation size\n");
+! exit(1);
+! #endif
+! }
+! if (size == 0) {
+ if (p) {
+ gfree(p);
+ }
+***************
+*** 131,137 ****
+ #else
+ void *q;
+
+! if (size <= 0) {
+ if (p) {
+ free(p);
+ }
+--- 155,169 ----
+ #else
+ void *q;
+
+! if (size < 0) {
+! #if USE_EXCEPTIONS
+! throw GMemException();
+! #else
+! fprintf(stderr, "Invalid memory allocation size\n");
+! exit(1);
+! #endif
+! }
+! if (size == 0) {
+ if (p) {
+ free(p);
+ }
+diff -r -c xpdf-3.02.orig/xpdf/JBIG2Stream.cc xpdf-3.02/xpdf/JBIG2Stream.cc
+*** xpdf-3.02.orig/xpdf/JBIG2Stream.cc Tue Feb 27 14:05:52 2007
+--- xpdf-3.02/xpdf/JBIG2Stream.cc Tue Mar 31 10:55:23 2009
+***************
+*** 422,433 ****
+ table[i] = table[len];
+
+ // assign prefixes
+! i = 0;
+! prefix = 0;
+! table[i++].prefix = prefix++;
+! for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
+! prefix <<= table[i].prefixLen - table[i-1].prefixLen;
+! table[i].prefix = prefix++;
+ }
+ }
+
+--- 422,435 ----
+ table[i] = table[len];
+
+ // assign prefixes
+! if (table[0].rangeLen != jbig2HuffmanEOT) {
+! i = 0;
+! prefix = 0;
+! table[i++].prefix = prefix++;
+! for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
+! prefix <<= table[i].prefixLen - table[i-1].prefixLen;
+! table[i].prefix = prefix++;
+! }
+ }
+ }
+
+***************
+*** 491,497 ****
+ }
+ if (p->bits < 0) {
+ error(str->getPos(), "Bad two dim code in JBIG2 MMR stream");
+! return 0;
+ }
+ bufLen -= p->bits;
+ return p->n;
+--- 493,499 ----
+ }
+ if (p->bits < 0) {
+ error(str->getPos(), "Bad two dim code in JBIG2 MMR stream");
+! return EOF;
+ }
+ bufLen -= p->bits;
+ return p->n;
+***************
+*** 507,513 ****
+ ++nBytesRead;
+ }
+ while (1) {
+! if (bufLen >= 7 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
+ if (bufLen <= 12) {
+ code = buf << (12 - bufLen);
+ } else {
+--- 509,515 ----
+ ++nBytesRead;
+ }
+ while (1) {
+! if (bufLen >= 11 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
+ if (bufLen <= 12) {
+ code = buf << (12 - bufLen);
+ } else {
+***************
+*** 550,563 ****
+ ++nBytesRead;
+ }
+ while (1) {
+! if (bufLen >= 6 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
+ if (bufLen <= 13) {
+ code = buf << (13 - bufLen);
+ } else {
+ code = buf >> (bufLen - 13);
+ }
+ p = &blackTab1[code & 0x7f];
+! } else if (bufLen >= 4 && ((buf >> (bufLen - 4)) & 0x0f) == 0) {
+ if (bufLen <= 12) {
+ code = buf << (12 - bufLen);
+ } else {
+--- 552,566 ----
+ ++nBytesRead;
+ }
+ while (1) {
+! if (bufLen >= 10 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
+ if (bufLen <= 13) {
+ code = buf << (13 - bufLen);
+ } else {
+ code = buf >> (bufLen - 13);
+ }
+ p = &blackTab1[code & 0x7f];
+! } else if (bufLen >= 7 && ((buf >> (bufLen - 4)) & 0x0f) == 0 &&
+! ((buf >> (bufLen - 6)) & 0x03) != 0) {
+ if (bufLen <= 12) {
+ code = buf << (12 - bufLen);
+ } else {
+***************
+*** 683,690 ****
+ h = hA;
+ line = (wA + 7) >> 3;
+ if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+! data = NULL;
+! return;
+ }
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+--- 686,694 ----
+ h = hA;
+ line = (wA + 7) >> 3;
+ if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+! // force a call to gmalloc(-1), which will throw an exception
+! h = -1;
+! line = 2;
+ }
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+***************
+*** 698,705 ****
+ h = bitmap->h;
+ line = bitmap->line;
+ if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+! data = NULL;
+! return;
+ }
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+--- 702,710 ----
+ h = bitmap->h;
+ line = bitmap->line;
+ if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+! // force a call to gmalloc(-1), which will throw an exception
+! h = -1;
+! line = 2;
+ }
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+***************
+*** 754,759 ****
+--- 759,766 ----
+ inline void JBIG2Bitmap::getPixelPtr(int x, int y, JBIG2BitmapPtr *ptr) {
+ if (y < 0 || y >= h || x >= w) {
+ ptr->p = NULL;
++ ptr->shift = 0; // make gcc happy
++ ptr->x = 0; // make gcc happy
+ } else if (x < 0) {
+ ptr->p = &data[y * line];
+ ptr->shift = 7;
+***************
+*** 798,803 ****
+--- 805,814 ----
+ Guint src0, src1, src, dest, s1, s2, m1, m2, m3;
+ GBool oneByte;
+
++ // check for the pathological case where y = -2^31
++ if (y < -0x7fffffff) {
++ return;
++ }
+ if (y < 0) {
+ y0 = -y;
+ } else {
+***************
+*** 1011,1018 ****
+--- 1022,1034 ----
+ JBIG2SymbolDict::JBIG2SymbolDict(Guint segNumA, Guint sizeA):
+ JBIG2Segment(segNumA)
+ {
++ Guint i;
++
+ size = sizeA;
+ bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
++ for (i = 0; i < size; ++i) {
++ bitmaps[i] = NULL;
++ }
+ genericRegionStats = NULL;
+ refinementRegionStats = NULL;
+ }
+***************
+*** 1021,1027 ****
+ Guint i;
+
+ for (i = 0; i < size; ++i) {
+! delete bitmaps[i];
+ }
+ gfree(bitmaps);
+ if (genericRegionStats) {
+--- 1037,1045 ----
+ Guint i;
+
+ for (i = 0; i < size; ++i) {
+! if (bitmaps[i]) {
+! delete bitmaps[i];
+! }
+ }
+ gfree(bitmaps);
+ if (genericRegionStats) {
+***************
+*** 1296,1301 ****
+--- 1314,1326 ----
+ goto eofError2;
+ }
+
++ // check for missing page information segment
++ if (!pageBitmap && ((segType >= 4 && segType <= 7) ||
++ (segType >= 20 && segType <= 43))) {
++ error(getPos(), "First JBIG2 segment associated with a page must be a page information segment");
++ goto syntaxError;
++ }
++
+ // read the segment data
+ switch (segType) {
+ case 0:
+***************
+*** 1411,1416 ****
+--- 1436,1443 ----
+ Guint i, j, k;
+ Guchar *p;
+
++ symWidths = NULL;
++
+ // symbol dictionary flags
+ if (!readUWord(&flags)) {
+ goto eofError;
+***************
+*** 1466,1485 ****
+ codeTables = new GList();
+ numInputSyms = 0;
+ for (i = 0; i < nRefSegs; ++i) {
+! seg = findSegment(refSegs[i]);
+! if (seg->getType() == jbig2SegSymbolDict) {
+! numInputSyms += ((JBIG2SymbolDict *)seg)->getSize();
+! } else if (seg->getType() == jbig2SegCodeTable) {
+! codeTables->append(seg);
+ }
+ }
+
+ // compute symbol code length
+! symCodeLen = 0;
+! i = 1;
+! while (i < numInputSyms + numNewSyms) {
+ ++symCodeLen;
+! i <<= 1;
+ }
+
+ // get the input symbol bitmaps
+--- 1493,1524 ----
+ codeTables = new GList();
+ numInputSyms = 0;
+ for (i = 0; i < nRefSegs; ++i) {
+! if ((seg = findSegment(refSegs[i]))) {
+! if (seg->getType() == jbig2SegSymbolDict) {
+! j = ((JBIG2SymbolDict *)seg)->getSize();
+! if (numInputSyms > UINT_MAX - j) {
+! error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
+! delete codeTables;
+! goto eofError;
+! }
+! numInputSyms += j;
+! } else if (seg->getType() == jbig2SegCodeTable) {
+! codeTables->append(seg);
+! }
+ }
+ }
++ if (numInputSyms > UINT_MAX - numNewSyms) {
++ error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
++ delete codeTables;
++ goto eofError;
++ }
+
+ // compute symbol code length
+! symCodeLen = 1;
+! i = (numInputSyms + numNewSyms) >> 1;
+! while (i) {
+ ++symCodeLen;
+! i >>= 1;
+ }
+
+ // get the input symbol bitmaps
+***************
+*** 1491,1501 ****
+ k = 0;
+ inputSymbolDict = NULL;
+ for (i = 0; i < nRefSegs; ++i) {
+! seg = findSegment(refSegs[i]);
+! if (seg->getType() == jbig2SegSymbolDict) {
+! inputSymbolDict = (JBIG2SymbolDict *)seg;
+! for (j = 0; j < inputSymbolDict->getSize(); ++j) {
+! bitmaps[k++] = inputSymbolDict->getBitmap(j);
+ }
+ }
+ }
+--- 1530,1541 ----
+ k = 0;
+ inputSymbolDict = NULL;
+ for (i = 0; i < nRefSegs; ++i) {
+! if ((seg = findSegment(refSegs[i]))) {
+! if (seg->getType() == jbig2SegSymbolDict) {
+! inputSymbolDict = (JBIG2SymbolDict *)seg;
+! for (j = 0; j < inputSymbolDict->getSize(); ++j) {
+! bitmaps[k++] = inputSymbolDict->getBitmap(j);
+! }
+ }
+ }
+ }
+***************
+*** 1510,1515 ****
+--- 1550,1558 ----
+ } else if (huffDH == 1) {
+ huffDHTable = huffTableE;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffDW == 0) {
+***************
+*** 1517,1533 ****
+--- 1560,1585 ----
+ } else if (huffDW == 1) {
+ huffDWTable = huffTableC;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffBMSize == 0) {
+ huffBMSizeTable = huffTableA;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffBMSizeTable =
+ ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffAggInst == 0) {
+ huffAggInstTable = huffTableA;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffAggInstTable =
+ ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+***************
+*** 1560,1566 ****
+ }
+
+ // allocate symbol widths storage
+- symWidths = NULL;
+ if (huff && !refAgg) {
+ symWidths = (Guint *)gmallocn(numNewSyms, sizeof(Guint));
+ }
+--- 1612,1617 ----
+***************
+*** 1602,1607 ****
+--- 1653,1662 ----
+ goto syntaxError;
+ }
+ symWidth += dw;
++ if (i >= numNewSyms) {
++ error(getPos(), "Too many symbols in JBIG2 symbol dictionary");
++ goto syntaxError;
++ }
+
+ // using a collective bitmap, so don't read a bitmap here
+ if (huff && !refAgg) {
+***************
+*** 1638,1643 ****
+--- 1693,1702 ----
+ arithDecoder->decodeInt(&refDX, iardxStats);
+ arithDecoder->decodeInt(&refDY, iardyStats);
+ }
++ if (symID >= numInputSyms + i) {
++ error(getPos(), "Invalid symbol ID in JBIG2 symbol dictionary");
++ goto syntaxError;
++ }
+ refBitmap = bitmaps[symID];
+ bitmaps[numInputSyms + i] =
+ readGenericRefinementRegion(symWidth, symHeight,
+***************
+*** 1704,1709 ****
+--- 1763,1774 ----
+ } else {
+ arithDecoder->decodeInt(&run, iaexStats);
+ }
++ if (i + run > numInputSyms + numNewSyms ||
++ (ex && j + run > numExSyms)) {
++ error(getPos(), "Too many exported symbols in JBIG2 symbol dictionary");
++ delete symbolDict;
++ goto syntaxError;
++ }
+ if (ex) {
+ for (cnt = 0; cnt < run; ++cnt) {
+ symbolDict->setBitmap(j++, bitmaps[i++]->copy());
+***************
+*** 1713,1718 ****
+--- 1778,1788 ----
+ }
+ ex = !ex;
+ }
++ if (j != numExSyms) {
++ error(getPos(), "Too few symbols in JBIG2 symbol dictionary");
++ delete symbolDict;
++ goto syntaxError;
++ }
+
+ for (i = 0; i < numNewSyms; ++i) {
+ delete bitmaps[numInputSyms + i];
+***************
+*** 1735,1740 ****
+--- 1805,1814 ----
+
+ return gTrue;
+
++ codeTableError:
++ error(getPos(), "Missing code table in JBIG2 symbol dictionary");
++ delete codeTables;
++
+ syntaxError:
+ for (i = 0; i < numNewSyms; ++i) {
+ if (bitmaps[numInputSyms + i]) {
+***************
+*** 1837,1842 ****
+--- 1911,1918 ----
+ }
+ } else {
+ error(getPos(), "Invalid segment reference in JBIG2 text region");
++ delete codeTables;
++ return;
+ }
+ }
+ symCodeLen = 0;
+***************
+*** 1871,1876 ****
+--- 1947,1955 ----
+ } else if (huffFS == 1) {
+ huffFSTable = huffTableG;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffFSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffDS == 0) {
+***************
+*** 1880,1885 ****
+--- 1959,1967 ----
+ } else if (huffDS == 2) {
+ huffDSTable = huffTableJ;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffDSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffDT == 0) {
+***************
+*** 1889,1894 ****
+--- 1971,1979 ----
+ } else if (huffDT == 2) {
+ huffDTTable = huffTableM;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffDTTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffRDW == 0) {
+***************
+*** 1896,1901 ****
+--- 1981,1989 ----
+ } else if (huffRDW == 1) {
+ huffRDWTable = huffTableO;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffRDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffRDH == 0) {
+***************
+*** 1903,1908 ****
+--- 1991,1999 ----
+ } else if (huffRDH == 1) {
+ huffRDHTable = huffTableO;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffRDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffRDX == 0) {
+***************
+*** 1910,1915 ****
+--- 2001,2009 ----
+ } else if (huffRDX == 1) {
+ huffRDXTable = huffTableO;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffRDXTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffRDY == 0) {
+***************
+*** 1917,1927 ****
+--- 2011,2027 ----
+ } else if (huffRDY == 1) {
+ huffRDYTable = huffTableO;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffRDYTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+ if (huffRSize == 0) {
+ huffRSizeTable = huffTableA;
+ } else {
++ if (i >= (Guint)codeTables->getLength()) {
++ goto codeTableError;
++ }
+ huffRSizeTable =
+ ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
+ }
+***************
+*** 2016,2023 ****
+--- 2116,2130 ----
+
+ return;
+
++ codeTableError:
++ error(getPos(), "Missing code table in JBIG2 text region");
++ gfree(codeTables);
++ delete syms;
++ return;
++
+ eofError:
+ error(getPos(), "Unexpected EOF in JBIG2 stream");
++ return;
+ }
+
+ JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
+***************
+*** 2324,2331 ****
+ error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
+ return;
+ }
+! seg = findSegment(refSegs[0]);
+! if (seg->getType() != jbig2SegPatternDict) {
+ error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
+ return;
+ }
+--- 2431,2438 ----
+ error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
+ return;
+ }
+! if (!(seg = findSegment(refSegs[0])) ||
+! seg->getType() != jbig2SegPatternDict) {
+ error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
+ return;
+ }
+***************
+*** 2483,2489 ****
+
+ // read the bitmap
+ bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
+! NULL, atx, aty, mmr ? 0 : length - 18);
+
+ // combine the region bitmap into the page bitmap
+ if (imm) {
+--- 2590,2596 ----
+
+ // read the bitmap
+ bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
+! NULL, atx, aty, mmr ? length - 18 : 0);
+
+ // combine the region bitmap into the page bitmap
+ if (imm) {
+***************
+*** 2505,2510 ****
+--- 2612,2654 ----
+ error(getPos(), "Unexpected EOF in JBIG2 stream");
+ }
+
++ inline void JBIG2Stream::mmrAddPixels(int a1, int blackPixels,
++ int *codingLine, int *a0i, int w) {
++ if (a1 > codingLine[*a0i]) {
++ if (a1 > w) {
++ error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
++ a1 = w;
++ }
++ if ((*a0i & 1) ^ blackPixels) {
++ ++*a0i;
++ }
++ codingLine[*a0i] = a1;
++ }
++ }
++
++ inline void JBIG2Stream::mmrAddPixelsNeg(int a1, int blackPixels,
++ int *codingLine, int *a0i, int w) {
++ if (a1 > codingLine[*a0i]) {
++ if (a1 > w) {
++ error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
++ a1 = w;
++ }
++ if ((*a0i & 1) ^ blackPixels) {
++ ++*a0i;
++ }
++ codingLine[*a0i] = a1;
++ } else if (a1 < codingLine[*a0i]) {
++ if (a1 < 0) {
++ error(getPos(), "Invalid JBIG2 MMR code");
++ a1 = 0;
++ }
++ while (*a0i > 0 && a1 <= codingLine[*a0i - 1]) {
++ --*a0i;
++ }
++ codingLine[*a0i] = a1;
++ }
++ }
++
+ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
+ int templ, GBool tpgdOn,
+ GBool useSkip, JBIG2Bitmap *skip,
+***************
+*** 2517,2523 ****
+ JBIG2BitmapPtr atPtr0, atPtr1, atPtr2, atPtr3;
+ int *refLine, *codingLine;
+ int code1, code2, code3;
+! int x, y, a0, pix, i, refI, codingI;
+
+ bitmap = new JBIG2Bitmap(0, w, h);
+ bitmap->clearToZero();
+--- 2661,2667 ----
+ JBIG2BitmapPtr atPtr0, atPtr1, atPtr2, atPtr3;
+ int *refLine, *codingLine;
+ int code1, code2, code3;
+! int x, y, a0i, b1i, blackPixels, pix, i;
+
+ bitmap = new JBIG2Bitmap(0, w, h);
+ bitmap->clearToZero();
+***************
+*** 2527,2535 ****
+ if (mmr) {
+
+ mmrDecoder->reset();
+ refLine = (int *)gmallocn(w + 2, sizeof(int));
+! codingLine = (int *)gmallocn(w + 2, sizeof(int));
+! codingLine[0] = codingLine[1] = w;
+
+ for (y = 0; y < h; ++y) {
+
+--- 2671,2688 ----
+ if (mmr) {
+
+ mmrDecoder->reset();
++ if (w > INT_MAX - 2) {
++ error(getPos(), "Bad width in JBIG2 generic bitmap");
++ // force a call to gmalloc(-1), which will throw an exception
++ w = -3;
++ }
++ // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w
++ // ---> max codingLine size = w + 1
++ // refLine has one extra guard entry at the end
++ // ---> max refLine size = w + 2
++ codingLine = (int *)gmallocn(w + 1, sizeof(int));
+ refLine = (int *)gmallocn(w + 2, sizeof(int));
+! codingLine[0] = w;
+
+ for (y = 0; y < h; ++y) {
+
+***************
+*** 2537,2664 ****
+ for (i = 0; codingLine[i] < w; ++i) {
+ refLine[i] = codingLine[i];
+ }
+! refLine[i] = refLine[i + 1] = w;
+
+ // decode a line
+! refI = 0; // b1 = refLine[refI]
+! codingI = 0; // a1 = codingLine[codingI]
+! a0 = 0;
+! do {
+ code1 = mmrDecoder->get2DCode();
+ switch (code1) {
+ case twoDimPass:
+! if (refLine[refI] < w) {
+! a0 = refLine[refI + 1];
+! refI += 2;
+! }
+! break;
+ case twoDimHoriz:
+! if (codingI & 1) {
+! code1 = 0;
+! do {
+! code1 += code3 = mmrDecoder->getBlackCode();
+! } while (code3 >= 64);
+! code2 = 0;
+! do {
+! code2 += code3 = mmrDecoder->getWhiteCode();
+! } while (code3 >= 64);
+! } else {
+! code1 = 0;
+! do {
+! code1 += code3 = mmrDecoder->getWhiteCode();
+! } while (code3 >= 64);
+! code2 = 0;
+! do {
+! code2 += code3 = mmrDecoder->getBlackCode();
+! } while (code3 >= 64);
+! }
+! if (code1 > 0 || code2 > 0) {
+! a0 = codingLine[codingI++] = a0 + code1;
+! a0 = codingLine[codingI++] = a0 + code2;
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! }
+! break;
+! case twoDimVert0:
+! a0 = codingLine[codingI++] = refLine[refI];
+! if (refLine[refI] < w) {
+! ++refI;
+! }
+! break;
+! case twoDimVertR1:
+! a0 = codingLine[codingI++] = refLine[refI] + 1;
+! if (refLine[refI] < w) {
+! ++refI;
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! }
+! break;
+! case twoDimVertR2:
+! a0 = codingLine[codingI++] = refLine[refI] + 2;
+! if (refLine[refI] < w) {
+! ++refI;
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! }
+! break;
+ case twoDimVertR3:
+! a0 = codingLine[codingI++] = refLine[refI] + 3;
+! if (refLine[refI] < w) {
+! ++refI;
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! }
+! break;
+! case twoDimVertL1:
+! a0 = codingLine[codingI++] = refLine[refI] - 1;
+! if (refI > 0) {
+! --refI;
+! } else {
+! ++refI;
+! }
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! break;
+! case twoDimVertL2:
+! a0 = codingLine[codingI++] = refLine[refI] - 2;
+! if (refI > 0) {
+! --refI;
+! } else {
+! ++refI;
+! }
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! break;
+ case twoDimVertL3:
+! a0 = codingLine[codingI++] = refLine[refI] - 3;
+! if (refI > 0) {
+! --refI;
+! } else {
+! ++refI;
+! }
+! while (refLine[refI] <= a0 && refLine[refI] < w) {
+! refI += 2;
+! }
+! break;
+ default:
+ error(getPos(), "Illegal code in JBIG2 MMR bitmap data");
+ break;
+ }
+! } while (a0 < w);
+! codingLine[codingI++] = w;
+
+ // convert the run lengths to a bitmap line
+ i = 0;
+! while (codingLine[i] < w) {
+ for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
+ bitmap->setPixel(x, y);
+ }
+ i += 2;
+ }
+ }
+--- 2690,2846 ----
+ for (i = 0; codingLine[i] < w; ++i) {
+ refLine[i] = codingLine[i];
+ }
+! refLine[i++] = w;
+! refLine[i] = w;
+
+ // decode a line
+! codingLine[0] = 0;
+! a0i = 0;
+! b1i = 0;
+! blackPixels = 0;
+! // invariant:
+! // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1] <= w
+! // exception at left edge:
+! // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
+! // exception at right edge:
+! // refLine[b1i] = refLine[b1i+1] = w is possible
+! while (codingLine[a0i] < w) {
+ code1 = mmrDecoder->get2DCode();
+ switch (code1) {
+ case twoDimPass:
+! mmrAddPixels(refLine[b1i + 1], blackPixels, codingLine, &a0i, w);
+! if (refLine[b1i + 1] < w) {
+! b1i += 2;
+! }
+! break;
+ case twoDimHoriz:
+! code1 = code2 = 0;
+! if (blackPixels) {
+! do {
+! code1 += code3 = mmrDecoder->getBlackCode();
+! } while (code3 >= 64);
+! do {
+! code2 += code3 = mmrDecoder->getWhiteCode();
+! } while (code3 >= 64);
+! } else {
+! do {
+! code1 += code3 = mmrDecoder->getWhiteCode();
+! } while (code3 >= 64);
+! do {
+! code2 += code3 = mmrDecoder->getBlackCode();
+! } while (code3 >= 64);
+! }
+! mmrAddPixels(codingLine[a0i] + code1, blackPixels,
+! codingLine, &a0i, w);
+! if (codingLine[a0i] < w) {
+! mmrAddPixels(codingLine[a0i] + code2, blackPixels ^ 1,
+! codingLine, &a0i, w);
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! break;
+ case twoDimVertR3:
+! mmrAddPixels(refLine[b1i] + 3, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case twoDimVertR2:
+! mmrAddPixels(refLine[b1i] + 2, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case twoDimVertR1:
+! mmrAddPixels(refLine[b1i] + 1, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case twoDimVert0:
+! mmrAddPixels(refLine[b1i], blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! ++b1i;
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+ case twoDimVertL3:
+! mmrAddPixelsNeg(refLine[b1i] - 3, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case twoDimVertL2:
+! mmrAddPixelsNeg(refLine[b1i] - 2, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case twoDimVertL1:
+! mmrAddPixelsNeg(refLine[b1i] - 1, blackPixels, codingLine, &a0i, w);
+! blackPixels ^= 1;
+! if (codingLine[a0i] < w) {
+! if (b1i > 0) {
+! --b1i;
+! } else {
+! ++b1i;
+! }
+! while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
+! b1i += 2;
+! }
+! }
+! break;
+! case EOF:
+! mmrAddPixels(w, 0, codingLine, &a0i, w);
+! break;
+ default:
+ error(getPos(), "Illegal code in JBIG2 MMR bitmap data");
++ mmrAddPixels(w, 0, codingLine, &a0i, w);
+ break;
+ }
+! }
+
+ // convert the run lengths to a bitmap line
+ i = 0;
+! while (1) {
+ for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
+ bitmap->setPixel(x, y);
+ }
++ if (codingLine[i+1] >= w || codingLine[i+2] >= w) {
++ break;
++ }
+ i += 2;
+ }
+ }
+***************
+*** 2706,2712 ****
+ ltp = !ltp;
+ }
+ if (ltp) {
+! bitmap->duplicateRow(y, y-1);
+ continue;
+ }
+ }
+--- 2888,2896 ----
+ ltp = !ltp;
+ }
+ if (ltp) {
+! if (y > 0) {
+! bitmap->duplicateRow(y, y-1);
+! }
+ continue;
+ }
+ }
+***************
+*** 2909,2916 ****
+ return;
+ }
+ if (nRefSegs == 1) {
+! seg = findSegment(refSegs[0]);
+! if (seg->getType() != jbig2SegBitmap) {
+ error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment");
+ return;
+ }
+--- 3093,3100 ----
+ return;
+ }
+ if (nRefSegs == 1) {
+! if (!(seg = findSegment(refSegs[0])) ||
+! seg->getType() != jbig2SegBitmap) {
+ error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment");
+ return;
+ }
+***************
+*** 3004,3009 ****
+--- 3188,3197 ----
+ tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
+ tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
+ tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
++ } else {
++ tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
++ tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
++ tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
+ }
+
+ for (x = 0; x < w; ++x) {
+***************
+*** 3075,3080 ****
+--- 3263,3272 ----
+ tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
+ tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
+ tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
++ } else {
++ tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
++ tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
++ tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
+ }
+
+ for (x = 0; x < w; ++x) {
+diff -r -c xpdf-3.02.orig/xpdf/JBIG2Stream.h xpdf-3.02/xpdf/JBIG2Stream.h
+*** xpdf-3.02.orig/xpdf/JBIG2Stream.h Tue Feb 27 14:05:52 2007
+--- xpdf-3.02/xpdf/JBIG2Stream.h Tue Mar 31 10:50:07 2009
+***************
+*** 78,83 ****
+--- 78,87 ----
+ Guint *refSegs, Guint nRefSegs);
+ void readGenericRegionSeg(Guint segNum, GBool imm,
+ GBool lossless, Guint length);
++ void mmrAddPixels(int a1, int blackPixels,
++ int *codingLine, int *a0i, int w);
++ void mmrAddPixelsNeg(int a1, int blackPixels,
++ int *codingLine, int *a0i, int w);
+ JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
+ int templ, GBool tpgdOn,
+ GBool useSkip, JBIG2Bitmap *skip,
diff --git a/source/xap/xpdf/xpdf-arabic.diff b/source/xap/xpdf/xpdf-arabic.diff
new file mode 100644
index 00000000..a6dfcf1f
--- /dev/null
+++ b/source/xap/xpdf/xpdf-arabic.diff
@@ -0,0 +1,7 @@
+--- ./add-to-xpdfrc.orig 2003-02-16 16:54:40.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:24:14.000000000 -0600
+@@ -1,3 +1,3 @@
+ #----- begin Arabic support package (2003-feb-16)
+-unicodeMap ISO-8859-6 /usr/local/share/xpdf/arabic/ISO-8859-6.unicodeMap
++unicodeMap ISO-8859-6 /usr/share/xpdf/arabic/ISO-8859-6.unicodeMap
+ #----- end Arabic support package
diff --git a/source/xap/xpdf/xpdf-chinese-simplified.diff b/source/xap/xpdf/xpdf-chinese-simplified.diff
new file mode 100644
index 00000000..adb125a4
--- /dev/null
+++ b/source/xap/xpdf/xpdf-chinese-simplified.diff
@@ -0,0 +1,19 @@
+--- ./add-to-xpdfrc.orig 2004-07-27 17:28:08.000000000 -0500
++++ ./add-to-xpdfrc 2008-03-02 01:46:16.000000000 -0600
+@@ -1,9 +1,9 @@
+ #----- begin Chinese Simplified support package (2004-jul-27)
+-cidToUnicode Adobe-GB1 /usr/local/share/xpdf/chinese-simplified/Adobe-GB1.cidToUnicode
+-unicodeMap ISO-2022-CN /usr/local/share/xpdf/chinese-simplified/ISO-2022-CN.unicodeMap
+-unicodeMap EUC-CN /usr/local/share/xpdf/chinese-simplified/EUC-CN.unicodeMap
+-unicodeMap GBK /usr/local/share/xpdf/chinese-simplified/GBK.unicodeMap
+-cMapDir Adobe-GB1 /usr/local/share/xpdf/chinese-simplified/CMap
+-toUnicodeDir /usr/local/share/xpdf/chinese-simplified/CMap
+-#displayCIDFontTT Adobe-GB1 /usr/..../gkai00mp.ttf
++cidToUnicode Adobe-GB1 /usr/share/xpdf/chinese-simplified/Adobe-GB1.cidToUnicode
++unicodeMap ISO-2022-CN /usr/share/xpdf/chinese-simplified/ISO-2022-CN.unicodeMap
++unicodeMap EUC-CN /usr/share/xpdf/chinese-simplified/EUC-CN.unicodeMap
++unicodeMap GBK /usr/share/xpdf/chinese-simplified/GBK.unicodeMap
++cMapDir Adobe-GB1 /usr/share/xpdf/chinese-simplified/CMap
++toUnicodeDir /usr/share/xpdf/chinese-simplified/CMap
++displayCIDFontTT Adobe-GB1 /usr/share/fonts/TTF/wqy-zenhei.ttf
+ #----- end Chinese Simplified support package
diff --git a/source/xap/xpdf/xpdf-chinese-traditional.diff b/source/xap/xpdf/xpdf-chinese-traditional.diff
new file mode 100644
index 00000000..71d35ee5
--- /dev/null
+++ b/source/xap/xpdf/xpdf-chinese-traditional.diff
@@ -0,0 +1,17 @@
+--- ./add-to-xpdfrc.orig 2004-07-27 17:28:07.000000000 -0500
++++ ./add-to-xpdfrc 2008-03-02 01:45:16.000000000 -0600
+@@ -1,8 +1,8 @@
+ #----- begin Chinese Traditional support package (2004-jul-27)
+-cidToUnicode Adobe-CNS1 /usr/local/share/xpdf/chinese-traditional/Adobe-CNS1.cidToUnicode
+-unicodeMap Big5 /usr/local/share/xpdf/chinese-traditional/Big5.unicodeMap
+-unicodeMap Big5ascii /usr/local/share/xpdf/chinese-traditional/Big5ascii.unicodeMap
+-cMapDir Adobe-CNS1 /usr/local/share/xpdf/chinese-traditional/CMap
+-toUnicodeDir /usr/local/share/xpdf/chinese-traditional/CMap
+-#displayCIDFontTT Adobe-CNS1 /usr/..../bkai00mp.ttf
++cidToUnicode Adobe-CNS1 /usr/share/xpdf/chinese-traditional/Adobe-CNS1.cidToUnicode
++unicodeMap Big5 /usr/share/xpdf/chinese-traditional/Big5.unicodeMap
++unicodeMap Big5ascii /usr/share/xpdf/chinese-traditional/Big5ascii.unicodeMap
++cMapDir Adobe-CNS1 /usr/share/xpdf/chinese-traditional/CMap
++toUnicodeDir /usr/share/xpdf/chinese-traditional/CMap
++displayCIDFontTT Adobe-CNS1 /usr/share/fonts/TTF/wqy-zenhei.ttf
+ #----- end Chinese Traditional support package
diff --git a/source/xap/xpdf/xpdf-cyrillic.diff b/source/xap/xpdf/xpdf-cyrillic.diff
new file mode 100644
index 00000000..ec841961
--- /dev/null
+++ b/source/xap/xpdf/xpdf-cyrillic.diff
@@ -0,0 +1,9 @@
+--- ./add-to-xpdfrc.orig 2003-07-08 00:43:40.000000000 -0500
++++ ./add-to-xpdfrc 2008-03-02 01:27:17.000000000 -0600
+@@ -1,4 +1,4 @@
+ #----- begin Cyrillic support package (2003-jun-28)
+-nameToUnicode /usr/local/share/xpdf/cyrillic/Bulgarian.nameToUnicode
+-unicodeMap KOI8-R /usr/local/share/xpdf/cyrillic/KOI8-R.unicodeMap
++nameToUnicode /usr/share/xpdf/cyrillic/Bulgarian.nameToUnicode
++unicodeMap KOI8-R /usr/share/xpdf/cyrillic/KOI8-R.unicodeMap
+ #----- end Cyrillic support package
diff --git a/source/xap/xpdf/xpdf-greek.diff b/source/xap/xpdf/xpdf-greek.diff
new file mode 100644
index 00000000..fe47d443
--- /dev/null
+++ b/source/xap/xpdf/xpdf-greek.diff
@@ -0,0 +1,9 @@
+--- ./add-to-xpdfrc.orig 2003-07-08 00:43:40.000000000 -0500
++++ ./add-to-xpdfrc 2008-03-02 01:28:00.000000000 -0600
+@@ -1,4 +1,4 @@
+ #----- begin Greek support package (2003-jun-28)
+-nameToUnicode /usr/local/share/xpdf/greek/Greek.nameToUnicode
+-unicodeMap ISO-8859-7 /usr/local/share/xpdf/greek/ISO-8859-7.unicodeMap
++nameToUnicode /usr/share/xpdf/greek/Greek.nameToUnicode
++unicodeMap ISO-8859-7 /usr/share/xpdf/greek/ISO-8859-7.unicodeMap
+ #----- end Greek support package
diff --git a/source/xap/xpdf/xpdf-hebrew.diff b/source/xap/xpdf/xpdf-hebrew.diff
new file mode 100644
index 00000000..e7d091d0
--- /dev/null
+++ b/source/xap/xpdf/xpdf-hebrew.diff
@@ -0,0 +1,9 @@
+--- ./add-to-xpdfrc.orig 2008-03-02 01:28:33.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:28:45.000000000 -0600
+@@ -1,4 +1,4 @@
+ #----- begin Hebrew support package (2003-feb-16)
+-unicodeMap ISO-8859-8 /usr/local/share/xpdf/hebrew/ISO-8859-8.unicodeMap
+-unicodeMap Windows-1255 /usr/local/share/xpdf/hebrew/Windows-1255.unicodeMap
++unicodeMap ISO-8859-8 /usr/share/xpdf/hebrew/ISO-8859-8.unicodeMap
++unicodeMap Windows-1255 /usr/share/xpdf/hebrew/Windows-1255.unicodeMap
+ #----- end Hebrew support package
diff --git a/source/xap/xpdf/xpdf-japanese.diff b/source/xap/xpdf/xpdf-japanese.diff
new file mode 100644
index 00000000..5c1878fe
--- /dev/null
+++ b/source/xap/xpdf/xpdf-japanese.diff
@@ -0,0 +1,57 @@
+--- ./add-to-xpdfrc.orig 2008-03-02 01:31:08.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:31:32.000000000 -0600
+@@ -1,9 +1,47 @@
+ #----- begin Japanese support package (2004-jul-27)
+-cidToUnicode Adobe-Japan1 /usr/local/share/xpdf/japanese/Adobe-Japan1.cidToUnicode
+-unicodeMap ISO-2022-JP /usr/local/share/xpdf/japanese/ISO-2022-JP.unicodeMap
+-unicodeMap EUC-JP /usr/local/share/xpdf/japanese/EUC-JP.unicodeMap
+-unicodeMap Shift-JIS /usr/local/share/xpdf/japanese/Shift-JIS.unicodeMap
+-cMapDir Adobe-Japan1 /usr/local/share/xpdf/japanese/CMap
+-toUnicodeDir /usr/local/share/xpdf/japanese/CMap
+-#displayCIDFontTT Adobe-Japan1 /usr/..../kochi-mincho.ttf
++cidToUnicode Adobe-Japan1 /usr/share/xpdf/japanese/Adobe-Japan1.cidToUnicode
++unicodeMap ISO-2022-JP /usr/share/xpdf/japanese/ISO-2022-JP.unicodeMap
++unicodeMap EUC-JP /usr/share/xpdf/japanese/EUC-JP.unicodeMap
++unicodeMap Shift-JIS /usr/share/xpdf/japanese/Shift-JIS.unicodeMap
++cMapDir Adobe-Japan1 /usr/share/xpdf/japanese/CMap
++toUnicodeDir /usr/share/xpdf/japanese/CMap
++
++### use Sazanami by default
++displayCIDFontTT Adobe-Japan1 /usr/share/fonts/TTF/sazanami-mincho.ttf
++### use Sazanami (Sazanami Gothic) if gothic font is required
++displayNamedCIDFontTT ShinGo-Bold /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT ShinGo-regular /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT MidashiGo-MB31 /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT FutoGoB101-Bold /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT HeiseiKakuGo-W5 /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT HeiseiKakuGo-W9 /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT HeiseiMaruGo-W4 /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT MS-Gothic /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT HG-GothicB /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT Kochi-Gothic /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT GothicBBB-Medium-H /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT GothicBBB-Medium /usr/share/fonts/TTF/sazanami-gothic.ttf
++displayNamedCIDFontTT Ryumin-Light-H /usr/share/fonts/TTF/sazanami-mincho.ttf
++displayNamedCIDFontTT Ryumin-Light /usr/share/fonts/TTF/sazanami-mincho.ttf
++
++### make default font name to "Ryumin-Light" when converted to PostScript
++psFont16 Adobe-Japan1 H Ryumin-Light-H ISO-2022-JP
++psFont16 Adobe-Japan1 V Ryumin-Light-V ISO-2022-JP
++# use "Gothic-BBB-Medium" if gothic font is required
++psNamedFont16 MidashiGo-MB31 H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 MidashiGo-MB31 V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 FutoGoB101-Bold H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 FutoGoB101-Bold V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 HeiseiKakuGo-W5 H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 HeiseiKakuGo-W5 V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 HeiseiKakuGo-W9 H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 HeiseiKakuGo-W9 V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 HeiseiMaruGo-W4 H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 HeiseiMaruGo-W4 V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 MS-Gothic H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 MS-Gothic V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 HG-GothicB H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 HG-GothicB V GothicBBB-Medium-V ISO-2022-JP
++psNamedFont16 Kochi-Gothic H GothicBBB-Medium-H ISO-2022-JP
++psNamedFont16 Kochi-Gothic V GothicBBB-Medium-V ISO-2022-JP
+ #----- end Japanese support package
diff --git a/source/xap/xpdf/xpdf-korean.diff b/source/xap/xpdf/xpdf-korean.diff
new file mode 100644
index 00000000..632fc214
--- /dev/null
+++ b/source/xap/xpdf/xpdf-korean.diff
@@ -0,0 +1,15 @@
+--- ./add-to-xpdfrc.orig 2005-07-07 13:05:05.000000000 -0500
++++ ./add-to-xpdfrc 2008-03-02 01:33:52.000000000 -0600
+@@ -1,8 +1,8 @@
+ #----- begin Korean support package (2005-jul-07)
+-cidToUnicode Adobe-Korea1 /usr/local/share/xpdf/korean/Adobe-Korea1.cidToUnicode
+-unicodeMap ISO-2022-KR /usr/local/share/xpdf/korean/ISO-2022-KR.unicodeMap
+-cMapDir Adobe-Korea1 /usr/local/share/xpdf/korean/CMap
+-toUnicodeDir /usr/local/share/xpdf/korean/CMap
++cidToUnicode Adobe-Korea1 /usr/share/xpdf/korean/Adobe-Korea1.cidToUnicode
++unicodeMap ISO-2022-KR /usr/share/xpdf/korean/ISO-2022-KR.unicodeMap
++cMapDir Adobe-Korea1 /usr/share/xpdf/korean/CMap
++toUnicodeDir /usr/share/xpdf/korean/CMap
+ #displayCIDFontTT Adobe-Korea1 /usr/..../batang.ttf"
+ #displayCIDFontTT Unidocs-Korea1 /usr/..../batang.ttf"
+ #----- end Korean support package
diff --git a/source/xap/xpdf/xpdf-latin2.diff b/source/xap/xpdf/xpdf-latin2.diff
new file mode 100644
index 00000000..88ce2444
--- /dev/null
+++ b/source/xap/xpdf/xpdf-latin2.diff
@@ -0,0 +1,7 @@
+--- ./add-to-xpdfrc.orig 2002-11-03 17:49:15.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:35:51.000000000 -0600
+@@ -1,3 +1,3 @@
+ #----- begin Latin2 support package (2002-oct-22)
+-unicodeMap Latin2 /usr/local/share/xpdf/latin2/Latin2.unicodeMap
++unicodeMap Latin2 /usr/share/xpdf/latin2/Latin2.unicodeMap
+ #----- end Latin2 support package
diff --git a/source/xap/xpdf/xpdf-resizefix.diff b/source/xap/xpdf/xpdf-resizefix.diff
new file mode 100644
index 00000000..4be7feb0
--- /dev/null
+++ b/source/xap/xpdf/xpdf-resizefix.diff
@@ -0,0 +1,34 @@
+--- ./fofi/FoFiType1.cc.orig 2007-02-27 16:05:51.000000000 -0600
++++ ./fofi/FoFiType1.cc 2007-04-11 19:58:28.000000000 -0500
+@@ -235,9 +235,14 @@
+ }
+ }
+ } else {
+- if (strtok(buf, " \t") &&
+- (p = strtok(NULL, " \t\n\r")) && !strcmp(p, "def")) {
+- break;
++ p = strtok(buf, " \t\n\r");
++ if (p)
++ {
++ if (!strcmp(p, "def")) break;
++ if (!strcmp(p, "readonly")) break;
++ // the spec does not says this but i'm mantaining old xpdf behaviour that accepts "foo def" as end of the encoding array
++ p = strtok(buf, " \t\n\r");
++ if (p && !strcmp(p, "def")) break;
+ }
+ }
+ }
+--- ./splash/Splash.cc.orig 2007-02-27 16:05:52.000000000 -0600
++++ ./splash/Splash.cc 2007-04-11 19:58:35.000000000 -0500
+@@ -1501,6 +1501,11 @@
+ xPath->aaScale();
+ }
+ xPath->sort();
++ if (!&xPath->segs[0])
++ {
++ delete xPath;
++ return splashErrEmptyPath;
++ }
+ scanner = new SplashXPathScanner(xPath, eo);
+
+ // get the min and max x and y values
diff --git a/source/xap/xpdf/xpdf-thai.diff b/source/xap/xpdf/xpdf-thai.diff
new file mode 100644
index 00000000..75b9b1a2
--- /dev/null
+++ b/source/xap/xpdf/xpdf-thai.diff
@@ -0,0 +1,9 @@
+--- ./add-to-xpdfrc.orig 2002-11-03 17:49:15.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:36:36.000000000 -0600
+@@ -1,4 +1,4 @@
+ #----- begin Thai support package (2002-jan-16)
+-nameToUnicode /usr/local/share/xpdf/thai/Thai.nameToUnicode
+-unicodeMap TIS-620 /usr/local/share/xpdf/thai/TIS-620.unicodeMap
++nameToUnicode /usr/share/xpdf/thai/Thai.nameToUnicode
++unicodeMap TIS-620 /usr/share/xpdf/thai/TIS-620.unicodeMap
+ #----- end Thai support package
diff --git a/source/xap/xpdf/xpdf-turkish.diff b/source/xap/xpdf/xpdf-turkish.diff
new file mode 100644
index 00000000..ec7fe79f
--- /dev/null
+++ b/source/xap/xpdf/xpdf-turkish.diff
@@ -0,0 +1,7 @@
+--- ./add-to-xpdfrc.orig 2002-11-03 17:49:15.000000000 -0600
++++ ./add-to-xpdfrc 2008-03-02 01:37:33.000000000 -0600
+@@ -1,3 +1,3 @@
+ #----- begin Turkish support package (2002-apr-10)
+-unicodeMap ISO-8859-9 /usr/local/share/xpdf/turkish/ISO-8859-9.unicodeMap
++unicodeMap ISO-8859-9 /usr/share/xpdf/turkish/ISO-8859-9.unicodeMap
+ #----- end Turkish support package
diff --git a/source/xap/xpdf/xpdf.SlackBuild b/source/xap/xpdf/xpdf.SlackBuild
new file mode 100755
index 00000000..d07fb9aa
--- /dev/null
+++ b/source/xap/xpdf/xpdf.SlackBuild
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=3.02
+PATCHLEVEL=pl3
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=1
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xpdf
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf xpdf-$VERSION
+tar xvf $CWD/xpdf-$VERSION.tar.gz || exit 1
+cd xpdf-$VERSION || exit 1
+
+zcat $CWD/xpdf-resizefix.diff.gz | patch -p1 --verbose || exit 1
+cat $CWD/xpdf-3.02pl1.patch | patch -p1 --verbose || exit 1
+cat $CWD/xpdf-3.02pl2.patch | patch -p1 --verbose || exit 1
+cat $CWD/xpdf-3.02pl3.patch | patch -p1 --verbose || exit 1
+zcat $CWD/xpdf_3.02-1.3.diff.gz | patch -p1 --verbose || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+zcat $CWD/xpdfrc.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --sysconfdir=/etc \
+ --with-gzip \
+ --with-freetype2-includes=/usr/include/freetype2
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG || exit 1
+
+mkdir -p $PKG/etc
+cat doc/sample-xpdfrc > $PKG/etc/xpdfrc
+mkdir -p $PKG/usr/share/applications
+cat $CWD/xpdf.desktop > $PKG/usr/share/applications/xpdf.desktop
+mkdir -p $PKG/usr/share/icons
+cat xpdf/xpdfIcon.xpm > $PKG/usr/share/icons/xpdfIcon.xpm
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+chmod 755 $PKG/usr/bin/*
+gzip -9 $PKG/usr/man/man?/*
+
+mkdir -p $PKG/usr/doc/xpdf-$VERSION
+cp -a \
+ ANNOUNCE CHANGES COPYING INSTALL README \
+ $PKG/usr/doc/xpdf-$VERSION
+chmod 644 $PKG/usr/doc/xpdf-$VERSION/*
+
+# Add additional language support:
+for language in xpdf-arabic xpdf-chinese-simplified xpdf-chinese-traditional xpdf-cyrillic xpdf-greek xpdf-hebrew xpdf-japanese xpdf-korean xpdf-latin2 xpdf-thai xpdf-turkish ; do
+ rm -rf ${language}
+ tar xf $CWD/${language}.tar.gz
+ ( cd ${language}
+ zcat $CWD/${language}.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+ chown -R root:root .
+ find . -type f -exec chmod 644 {} \;
+ cat add-to-xpdfrc >> $PKG/etc/xpdfrc
+ mkdir -p $PKG/usr/share/xpdf/$(echo ${language} | cut -f2- -d -)
+ cp -a * $PKG/usr/share/xpdf/$(echo ${language} | cut -f2- -d -)
+ )
+done
+
+mkdir -p $PKG/install
+mv $PKG/etc/xpdfrc $PKG/etc/xpdfrc.new
+cat << EOF > $PKG/install/doinst.sh
+#!/bin/sh
+config() {
+ NEW="\$1"
+ OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r \$OLD ]; then
+ mv \$NEW \$OLD
+ elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy
+ rm \$NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+config etc/xpdfrc.new
+EOF
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# We'll use the versions of these from the poppler derived work (if they exist here):
+( cd $PKG/usr/bin
+ rm -f pdfinfo pdftops pdftoppm pdftohtml pdftotext pdfimages pdffonts
+ cd $PKG/usr/man/man1
+ for file in pdfinfo pdftops pdftoppm pdftohtml pdftotext pdfimages pdffonts ; do
+ rm -f ${file}.1.gz
+ done
+)
+
+# Build the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xpdf-${VERSION}${PATCHLEVEL}-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xpdf/xpdf.desktop b/source/xap/xpdf/xpdf.desktop
new file mode 100644
index 00000000..b8f4c9b1
--- /dev/null
+++ b/source/xap/xpdf/xpdf.desktop
@@ -0,0 +1,100 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=X PDF
+Name[bn]=à¦à¦•à§à¦¸ পি-ডি-à¦à¦«
+Name[de]=X-PDF
+Name[eo]=XPDF
+Name[es]=PDF para X
+Name[fr]=XPDF
+Name[hi]=à¤à¤•à¥à¤¸ पीडीà¤à¤«
+Name[ko]=Xìš© PDF
+Name[mn]=X-PDF
+Name[nds]=X-PDF
+Name[te]=à°Žà°•à±à°¸à± పిడిఎఫà±
+MimeType=application/pdf
+GenericName=PDF Viewer
+GenericName[af]=Pdf Aansig
+GenericName[ar]=عارض الملÙات PDF
+GenericName[az]=PDF Nümayişçisi
+GenericName[be]=ПраглÑдальнік PDF
+GenericName[bg]=Преглед на PDF документи
+GenericName[bn]=পি-ডি-à¦à¦« পà§à¦°à¦¦à¦°à§à¦¶à¦•
+GenericName[br]=Gweler PDF
+GenericName[bs]=Preglednik PDF dokumenata
+GenericName[ca]=Visor PDF
+GenericName[cs]=ProhlížeÄ PDF souborů
+GenericName[csb]=Przezérnik PDF
+GenericName[cy]=Gwelydd PDF
+GenericName[da]=PDF-fremviser
+GenericName[de]=PDF-Betrachter
+GenericName[el]=ΠÏοβολέας PDF
+GenericName[eo]=PDF-rigardilo
+GenericName[es]=Visor de documentos PDF
+GenericName[et]=PDF failide vaatamine
+GenericName[eu]=PDF ikustailua
+GenericName[fa]=مشاهده‌گر PDF
+GenericName[fi]=PDF-näytin
+GenericName[fo]=PDF-vísari
+GenericName[fr]=Afficheur PDF
+GenericName[fy]=PDF-werjefteprogramma
+GenericName[ga]=Amharcán PDF
+GenericName[gl]=Visualizador de PDF
+GenericName[he]=מציג קבצי PDF
+GenericName[hi]=पीडीà¤à¤« पà¥à¤°à¤¦à¤°à¥à¤¶à¤•
+GenericName[hr]=Preglednik PDF dokumenata
+GenericName[hu]=PDF-nézegető
+GenericName[id]=Viewer PDF
+GenericName[is]=PDF-sjá
+GenericName[it]=Visualizzatore PDF
+GenericName[ja]=PDF ビューア
+GenericName[kk]=PDF қарау құралы
+GenericName[km]=កម្មវិធី​មើល PDF
+GenericName[ko]=PDF 보기
+GenericName[lo]=ສະà»àº”ງຜົນPDF
+GenericName[lt]=PDF Žiūriklis
+GenericName[lv]=PDF SkatÄ«tÄjs
+GenericName[mk]=Прегледувач на PDF
+GenericName[mn]=PDF-Харагч
+GenericName[ms]=Pemapar PDF
+GenericName[mt]=Werrej PDF
+GenericName[nb]=PDF-leser
+GenericName[nds]=Kieker för PDF-Dateien
+GenericName[ne]=PDF दरà¥à¤¶à¤•
+GenericName[nl]=PDF-weergaveprogramma
+GenericName[nn]=PDF-lesar
+GenericName[nso]=Molebeledi wa PDF
+GenericName[oc]=Visualisor PDF
+GenericName[pa]=PDF ਦਰਸ਼ਕ
+GenericName[pl]=Przeglądarka plików PDF
+GenericName[pt]=Visualizador de PDFs
+GenericName[pt_BR]=Visualizador de arquivos PDF
+GenericName[ro]=Vizualizor de documente PDF
+GenericName[ru]=ПроÑмотр PDF
+GenericName[rw]=Mugaragaza PDF
+GenericName[se]=PDF-logan
+GenericName[sk]=PrehliadaÄ PDF súborov
+GenericName[sl]=Pregledovalnik datotek PDF
+GenericName[sr]=PDF приказивач
+GenericName[sr@Latn]=PDF prikazivaÄ
+GenericName[ss]=Sibuki se PDF
+GenericName[sv]=PDF-visare
+GenericName[ta]=PDF காடà¯à®šà®¿
+GenericName[tg]=Ðамоишгари PDF
+GenericName[th]=ตัวà¹à¸ªà¸”งผล PDF
+GenericName[tr]=PDF Görüntüleyici
+GenericName[tt]=PDF Kürsätkeç
+GenericName[uk]=ПереглÑдач PDF
+GenericName[uz]=PDF кўрувчи
+GenericName[ven]=Tshivhoni tsha PDF
+GenericName[vi]=Trình xem PDF
+GenericName[wa]=HÃ¥yneu di documints PDF
+GenericName[zh_CN]=PDF 查看器
+GenericName[zh_TW]=PDF 檢視程å¼
+GenericName[zu]=Umbukisi we-PDF
+Exec=xpdf
+Icon=xpdfIcon
+Path=
+Type=Application
+Terminal=false
+X-KDE-StartupNotify=false
+Categories=Graphics;PDFViewer;
diff --git a/source/xap/xpdf/xpdf_3.02-1.3.diff b/source/xap/xpdf/xpdf_3.02-1.3.diff
new file mode 100644
index 00000000..6a769e5c
--- /dev/null
+++ b/source/xap/xpdf/xpdf_3.02-1.3.diff
@@ -0,0 +1,4470 @@
+--- xpdf-3.02.orig/debian/README.Debian
++++ xpdf-3.02/debian/README.Debian
+@@ -0,0 +1,16 @@
++
++This package incorporates the following Xpdf language
++packages:
++
++xpdf-cyrillic 2002-jun-28
++xpdf-greek 2002-jun-28
++xpdf-hebrew 2003-feb-16
++xpdf-latin2 2002-oct-22
++xpdf-thai 2002-jan-16
++xpdf-turkish 2002-apr-10
++xpdf-arabic 2003-feb-16
++
++xpdf-chinese-simplified, xpdf-chinese-traditional, xpdf-korean
++and xpdf-japanese are separate Debian packages in the "non-free"
++section of the Debian archive.
++
+--- xpdf-3.02.orig/debian/xpdf-utils.files
++++ xpdf-3.02/debian/xpdf-utils.files
+@@ -0,0 +1,10 @@
++/usr/share/man/man1/pdftotext.1
++/usr/share/man/man1/pdfinfo.1
++/usr/share/man/man1/pdffonts.1
++/usr/share/man/man1/pdfimages.1
++/usr/share/man/man1/pdftops.1
++/usr/bin/pdftops
++/usr/bin/pdftotext
++/usr/bin/pdfinfo
++/usr/bin/pdffonts
++/usr/bin/pdfimages
+--- xpdf-3.02.orig/debian/patches-obselete/04_freetype-glyph.dpatch
++++ xpdf-3.02/debian/patches-obselete/04_freetype-glyph.dpatch
+@@ -0,0 +1,20 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 04_freetype-glyph.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Bug fix for Freetype glyph handling
++
++@DPATCH@
++
++--- xpdf-3.00.orig/splash/SplashFTFont.cc
+++++ xpdf-3.00/splash/SplashFTFont.cc
++@@ -238,6 +238,9 @@
++ if (FT_Get_Glyph(slot, &glyph)) {
++ return NULL;
++ }
+++ if (glyph->format != FT_GLYPH_FORMAT_OUTLINE) {
+++ return NULL;
+++ }
++ path.path = new SplashPath();
++ path.needClose = gFalse;
++ FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
+--- xpdf-3.02.orig/debian/patches-obselete/07_decrypt.dpatch
++++ xpdf-3.02/debian/patches-obselete/07_decrypt.dpatch
+@@ -0,0 +1,52 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 07_decrypt.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Avoid potential buffer overruns during decryption
++
++@DPATCH@
++diff -urNad --exclude=CVS --exclude=.svn ./xpdf/Decrypt.cc /tmp/dpep-work.wRRwAu/xpdf-3.01/xpdf/Decrypt.cc
++--- ./xpdf/Decrypt.cc 2005-08-17 15:34:31.000000000 +1000
+++++ /tmp/dpep-work.wRRwAu/xpdf-3.01/xpdf/Decrypt.cc 2005-08-19 18:47:09.000000000 +1000
++@@ -75,6 +75,11 @@
++ Guchar fx, fy;
++ int len, i, j;
++
+++ // check whether we have non-zero keyLength
+++ if ( !keyLength ) {
+++ return gFalse;
+++ }
+++
++ // try using the supplied owner password to generate the user password
++ *ownerPasswordOk = gFalse;
++ if (ownerPassword) {
++@@ -100,7 +105,7 @@
++ } else {
++ memcpy(test2, ownerKey->getCString(), 32);
++ for (i = 19; i >= 0; --i) {
++- for (j = 0; j < keyLength; ++j) {
+++ for (j = 0; j < keyLength && j < 16; ++j) {
++ tmpKey[j] = test[j] ^ i;
++ }
++ rc4InitKey(tmpKey, keyLength, fState);
++@@ -140,6 +145,11 @@
++ int len, i, j;
++ GBool ok;
++
+++ // check whether we have non-zero keyLength
+++ if ( !keyLength ) {
+++ return gFalse;
+++ }
+++
++ // generate file key
++ buf = (Guchar *)gmalloc(72 + fileID->getLength());
++ if (userPassword) {
++@@ -184,7 +194,7 @@
++ } else if (encRevision == 3) {
++ memcpy(test, userKey->getCString(), 32);
++ for (i = 19; i >= 0; --i) {
++- for (j = 0; j < keyLength; ++j) {
+++ for (j = 0; j < keyLength && j < 16; ++j) {
++ tmpKey[j] = fileKey[j] ^ i;
++ }
++ rc4InitKey(tmpKey, keyLength, fState);
+--- xpdf-3.02.orig/debian/patches-obselete/03_freetype-build.dpatch
++++ xpdf-3.02/debian/patches-obselete/03_freetype-build.dpatch
+@@ -0,0 +1,301 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 03_freetype-build.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Use pkg-config to locate FreeType build information
++
++@DPATCH@
++diff -urNad --exclude=CVS --exclude=.svn ./configure.in /tmp/dpep-work.9fnwEh/xpdf-3.01/configure.in
++--- ./configure.in 2005-08-19 17:06:04.000000000 +1000
+++++ /tmp/dpep-work.9fnwEh/xpdf-3.01/configure.in 2005-08-19 17:12:11.000000000 +1000
++@@ -301,10 +301,8 @@
++ AC_SUBST(t1_CFLAGS)
++
++ dnl ##### Check for FreeType 2.x.
++-dnl ##### (Note: FT_Get_Name_Index was added in FT 2.0.5, and is
++-dnl ##### the reason that Xpdf requires 2.0.5+.)
++-smr_CHECK_LIB(freetype2, freetype, [FreeType2 font rasterizer - version 2.0.5+],
++- FT_Get_Name_Index, ft2build.h, -lm)
+++PKG_CHECK_MODULES(freetype2, freetype2 >= 9.5.3, smr_have_freetype2_library="yes",
+++ smr_have_freetype2_library="no")
++ AC_SUBST(freetype2_LIBS)
++ AC_SUBST(freetype2_CFLAGS)
++ if test "x$smr_have_freetype2_library" = xyes; then
++diff -urNad --exclude=CVS --exclude=.svn ./smr.m4 /tmp/dpep-work.9fnwEh/xpdf-3.01/smr.m4
++--- ./smr.m4 1970-01-01 10:00:00.000000000 +1000
+++++ /tmp/dpep-work.9fnwEh/xpdf-3.01/smr.m4 2005-08-19 17:12:05.000000000 +1000
++@@ -0,0 +1,274 @@
+++# <<< smr.m4 from smr_macros 0.2.4 >>>
+++
+++dnl ####################### -*- Mode: M4 -*- ###########################
+++dnl smr.m4 --
+++dnl
+++dnl Copyright (C) 1999 Matthew D. Langston <langston at SLAC.Stanford.EDU>
+++dnl Copyright (C) 1998 Steve Robbins <stever at cs.mcgill.ca>
+++dnl
+++dnl This file is free software; you can redistribute it and/or modify it
+++dnl under the terms of the GNU General Public License as published by
+++dnl the Free Software Foundation; either version 2 of the License, or
+++dnl (at your option) any later version.
+++dnl
+++dnl This file is distributed in the hope that it will be useful, but
+++dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+++dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+++dnl General Public License for more details.
+++dnl
+++dnl You should have received a copy of the GNU General Public License
+++dnl along with this file; if not, write to:
+++dnl
+++dnl Free Software Foundation, Inc.
+++dnl Suite 330
+++dnl 59 Temple Place
+++dnl Boston, MA 02111-1307, USA.
+++dnl ####################################################################
+++
+++
+++dnl NOTE: The macros in this file are extensively documented in the
+++dnl accompanying `smr_macros.texi' Texinfo file. Please see the
+++dnl Texinfo documentation for the definitive specification of how
+++dnl these macros are supposed to work. If the macros work
+++dnl differently than the Texinfo documentation says they should,
+++dnl then the macros (and not the Texinfo documentation) has the
+++dnl bug(s).
+++
+++dnl This is a convenient macro which translates illegal characters for
+++dnl bourne shell variables into legal characters. It has the same
+++dnl functionality as sed 'y%./+-:%__p__%'.
+++AC_DEFUN([smr_safe_translation], [patsubst(patsubst([$1], [+], [p]), [./-:], [_])])
+++
+++AC_DEFUN(smr_SWITCH,
+++[
+++ dnl Define convenient aliases for the arguments since there are so
+++ dnl many of them and I keep confusing myself whenever I have to edit
+++ dnl this macro.
+++ pushdef([smr_name], $1)
+++ pushdef([smr_help_string], $2)
+++ pushdef([smr_default], $3)
+++ pushdef([smr_yes_define], $4)
+++ pushdef([smr_no_define], $5)
+++
+++ dnl Do some sanity checking of the arguments.
+++ ifelse([regexp(smr_default, [^\(yes\|no\)$])], -1, [AC_MSG_ERROR($0: third arg must be either yes or no)])
+++
+++ dnl Create the help string
+++ pushdef([smr_lhs], [--ifelse(smr_default, yes, disable, enable)-smr_name])dnl
+++ pushdef([smr_rhs], [ifelse(smr_default, yes, disable, enable) smr_help_string (default is smr_default)])dnl
+++
+++ dnl Add the option to `configure --help'. We don't need to supply the
+++ dnl 4th argument to AC_ARG_ENABLE (i.e. the code to set the default
+++ dnl value) because that is done below by AC_CACHE_CHECK.
+++ AC_ARG_ENABLE([smr_name],
+++ AC_HELP_STRING([smr_lhs], [smr_rhs]),
+++ smr_cv_enable_[]smr_name=$enableval)
+++
+++ dnl We cache the result so that the user doesn't have to remember
+++ dnl which flags they passed to `configure'.
+++ AC_CACHE_CHECK([whether to enable smr_help_string],
+++ smr_cv_enable_[]smr_name,
+++ smr_cv_enable_[]smr_name=smr_default)
+++
+++ ifelse(smr_yes_define, , , test x"[$]smr_cv_enable_[]smr_name" = xyes && AC_DEFINE(smr_yes_define))
+++ ifelse(smr_no_define, , , test x"[$]smr_cv_enable_[]smr_name" = xno && AC_DEFINE(smr_no_define))
+++
+++ dnl Sanity check the value assigned to smr_cv_enable_$1 to force it to
+++ dnl be either `yes' or `no'.
+++ if test ! x"[$]smr_cv_enable_[]smr_name" = xyes; then
+++ if test ! x"[$]smr_cv_enable_[]smr_name" = xno; then
+++ AC_MSG_ERROR([smr_lhs must be either yes or no])
+++ fi
+++ fi
+++
+++ popdef([smr_name])
+++ popdef([smr_help_string])
+++ popdef([smr_default])
+++ popdef([smr_yes_define])
+++ popdef([smr_no_define])
+++ popdef([smr_lhs])
+++ popdef([smr_rhs])
+++])
+++
+++
+++AC_DEFUN(smr_ARG_WITHLIB,
+++[
+++ dnl Define convenient aliases for the arguments since there are so
+++ dnl many of them and I keep confusing myself whenever I have to edit
+++ dnl this macro.
+++ pushdef([smr_name], $1)
+++ pushdef([smr_libname], ifelse($2, , smr_name, $2))
+++ pushdef([smr_help_string], $3)
+++ pushdef([smr_safe_name], smr_safe_translation(smr_name))
+++
+++ dnl Add the option to `configure --help'. We don't need to supply the
+++ dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
+++ dnl value) because that is done below by AC_CACHE_CHECK.
+++ AC_ARG_WITH(smr_safe_name-library,
+++ AC_HELP_STRING([--with-smr_safe_name-library[[=PATH]]],
+++ [use smr_name library ifelse(smr_help_string, , , (smr_help_string))]),
+++ smr_cv_with_[]smr_safe_name[]_library=$withval)
+++
+++ dnl We cache the result so that the user doesn't have to remember
+++ dnl which flags they passed to `configure'.
+++ AC_CACHE_CHECK([whether to use smr_name library],
+++ smr_cv_with_[]smr_safe_name[]_library,
+++ smr_cv_with_[]smr_safe_name[]_library=maybe)
+++
+++
+++ case x"[$]smr_cv_with_[]smr_safe_name[]_library" in
+++ xyes | xmaybe)
+++ smr_safe_name[]_LIBS="-l[]smr_libname"
+++ with_[]smr_safe_name=[$]smr_cv_with_[]smr_safe_name[]_library
+++ ;;
+++ xno)
+++ smr_safe_name[]_LIBS=
+++ with_[]smr_safe_name=no
+++ ;;
+++ *)
+++ if test -f "[$]smr_cv_with_[]smr_safe_name[]_library"; then
+++ smr_safe_name[]_LIBS=[$]smr_cv_with_[]smr_safe_name[]_library
+++ elif test -d "[$]smr_cv_with_[]smr_safe_name[]_library"; then
+++ smr_safe_name[]_LIBS="-L[$]smr_cv_with_[]smr_safe_name[]_library -l[]smr_libname"
+++ else
+++ AC_MSG_ERROR([argument must be boolean, file, or directory])
+++ fi
+++ with_[]smr_safe_name=yes
+++ ;;
+++ esac
+++
+++ popdef([smr_name])
+++ popdef([smr_libname])
+++ popdef([smr_help_string])
+++ popdef([smr_safe_name])
+++])
+++
+++
+++AC_DEFUN(smr_ARG_WITHINCLUDES,
+++[
+++ dnl Define convenient aliases for the arguments since there are so
+++ dnl many of them and I keep confusing myself whenever I have to edit
+++ dnl this macro.
+++ pushdef([smr_name], $1)
+++ pushdef([smr_header], $2)
+++ pushdef([smr_extra_flags], $3)
+++ pushdef([smr_safe_name], smr_safe_translation(smr_name))
+++
+++ dnl Add the option to `configure --help'. We don't need to supply the
+++ dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
+++ dnl value) because that is done below by AC_CACHE_CHECK.
+++ AC_ARG_WITH(smr_safe_name-includes,
+++ AC_HELP_STRING([--with-smr_safe_name-includes[[=DIR]]],
+++ [set directory for smr_name headers]),
+++ smr_cv_with_[]smr_safe_name[]_includes=$withval)
+++
+++ dnl We cache the result so that the user doesn't have to remember
+++ dnl which flags they passed to `configure'.
+++ AC_CACHE_CHECK([where to find the smr_name header files],
+++ smr_cv_with_[]smr_safe_name[]_includes,
+++ smr_cv_with_[]smr_safe_name[]_includes=)
+++
+++ if test ! x"[$]smr_cv_with_[]smr_safe_name[]_includes" = x; then
+++ if test -d "[$]smr_cv_with_[]smr_safe_name[]_includes"; then
+++ smr_safe_name[]_CFLAGS="-I[$]smr_cv_with_[]smr_safe_name[]_includes"
+++ else
+++ AC_MSG_ERROR([argument must be a directory])
+++ fi
+++ else
+++ smr_safe_name[]_CFLAGS=
+++ fi
+++
+++ dnl This bit of logic comes from the autoconf AC_PROG_CC macro. We
+++ dnl need to put the given include directory into CPPFLAGS temporarily,
+++ dnl but then restore CPPFLAGS to its old value.
+++ smr_test_CPPFLAGS="${CPPFLAGS+set}"
+++ smr_save_CPPFLAGS="$CPPFLAGS"
+++ CPPFLAGS="$CPPFLAGS [$]smr_safe_name[]_CFLAGS smr_extra_flags"
+++
+++ dnl If the header file smr_header exists, then define
+++ dnl HAVE_[]smr_header (in all capitals).
+++ AC_CHECK_HEADERS([smr_header],
+++ smr_have_[]smr_safe_name[]_header=yes,
+++ smr_have_[]smr_safe_name[]_header=no)
+++
+++ if test x"$smr_test_CPPFLAGS" = xset; then
+++ CPPFLAGS=$smr_save_CPPFLAGS
+++ else
+++ unset CPPFLAGS
+++ fi
+++
+++ popdef([smr_name])
+++ popdef([smr_header])
+++ popdef([smr_extra_flags])
+++ popdef([smr_safe_name])
+++])
+++
+++
+++AC_DEFUN(smr_CHECK_LIB,
+++[
+++ dnl Define convenient aliases for the arguments since there are so
+++ dnl many of them and I keep confusing myself whenever I have to edit
+++ dnl this macro.
+++ pushdef([smr_name], $1)
+++ pushdef([smr_libname], ifelse($2, , smr_name, $2))
+++ pushdef([smr_help_string], $3)
+++ pushdef([smr_function], $4)
+++ pushdef([smr_header], $5)
+++ pushdef([smr_extra_libs], $6)
+++ pushdef([smr_extra_flags], $7)
+++ pushdef([smr_prototype], $8)
+++ pushdef([smr_safe_name], smr_safe_translation(smr_name))
+++
+++ dnl Give the user (via "configure --help") an interface to specify
+++ dnl whether we should use the library or not, and possibly where we
+++ dnl should find it.
+++ smr_ARG_WITHLIB([smr_name], [smr_libname], [smr_help_string])
+++
+++ if test ! x"$with_[]smr_safe_name" = xno; then
+++
+++ # If we got this far, then the user didn't explicitly ask not to use
+++ # the library.
+++
+++ dnl If the caller of smr_CHECK_LIB specified a header file for this
+++ dnl library, then give the user (via "configure --help") an
+++ dnl interface to specify where this header file can be found (if it
+++ dnl isn't found by the compiler by default).
+++ ifelse(smr_header, , , [smr_ARG_WITHINCLUDES(smr_name, smr_header, smr_extra_flags)])
+++
+++ # We need only look for the library if the header has been found
+++ # (or no header is needed).
+++ if test [$]smr_have_[]smr_safe_name[]_header != no; then
+++
+++ AC_CHECK_LIB(smr_libname,
+++ smr_function,
+++ smr_have_[]smr_safe_name[]_library=yes,
+++ smr_have_[]smr_safe_name[]_library=no,
+++ [$]smr_safe_name[]_CFLAGS [smr_extra_flags] [$]smr_safe_name[]_LIBS [smr_extra_libs],
+++ [ifelse(smr_prototype, , , [[#]include <smr_header>])],
+++ smr_prototype)
+++ fi
+++
+++ if test x"[$]smr_have_[]smr_safe_name[]_library" = xyes; then
+++ AC_MSG_RESULT([using smr_name library])
+++ else
+++ smr_safe_name[]_LIBS=
+++ smr_safe_name[]_CFLAGS=
+++
+++ if test x"$with_[]smr_safe_name" = xmaybe; then
+++ AC_MSG_RESULT([not using smr_name library])
+++ else
+++ AC_MSG_WARN([requested smr_name library not found!])
+++ fi
+++ fi
+++ fi
+++
+++ popdef([smr_name])
+++ popdef([smr_libname])
+++ popdef([smr_help_string])
+++ popdef([smr_function])
+++ popdef([smr_header])
+++ popdef([smr_extra_libs])
+++ popdef([smr_extra_flags])
+++ popdef([smr_prototype])
+++ popdef([smr_safe_name])
+++])
+--- xpdf-3.02.orig/debian/patches-obselete/05_gmem.dpatch
++++ xpdf-3.02/debian/patches-obselete/05_gmem.dpatch
+@@ -0,0 +1,97 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 05_gmem.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Change all size parameters to size_t (why?)
++
++@DPATCH@
++diff -urNad --exclude=CVS --exclude=.svn ./goo/gmem.c /tmp/dpep-work.0qyf6L/xpdf-3.01/goo/gmem.c
++--- ./goo/gmem.c 2005-08-19 19:02:18.000000000 +1000
+++++ /tmp/dpep-work.0qyf6L/xpdf-3.01/goo/gmem.c 2005-08-19 19:05:34.000000000 +1000
++@@ -54,9 +54,9 @@
++
++ #endif /* DEBUG_MEM */
++
++-void *gmalloc(int size) {
+++void *gmalloc(size_t size) {
++ #ifdef DEBUG_MEM
++- int size1;
+++ size_t size1;
++ char *mem;
++ GMemHdr *hdr;
++ void *data;
++@@ -96,11 +96,11 @@
++ #endif
++ }
++
++-void *grealloc(void *p, int size) {
+++void *grealloc(void *p, size_t size) {
++ #ifdef DEBUG_MEM
++ GMemHdr *hdr;
++ void *q;
++- int oldSize;
+++ size_t oldSize;
++
++ if (size == 0) {
++ if (p)
++@@ -137,8 +137,8 @@
++ #endif
++ }
++
++-void *gmallocn(int nObjs, int objSize) {
++- int n;
+++void *gmallocn(int nObjs, size_t objSize) {
+++ size_t n;
++
++ n = nObjs * objSize;
++ if (objSize == 0 || n / objSize != nObjs) {
++@@ -148,8 +148,8 @@
++ return gmalloc(n);
++ }
++
++-void *greallocn(void *p, int nObjs, int objSize) {
++- int n;
+++void *greallocn(void *p, int nObjs, size_t objSize) {
+++ size_t n;
++
++ n = nObjs * objSize;
++ if (objSize == 0 || n / objSize != nObjs) {
++@@ -161,7 +161,7 @@
++
++ void gfree(void *p) {
++ #ifdef DEBUG_MEM
++- int size;
+++ size_t size;
++ GMemHdr *hdr;
++ GMemHdr *prevHdr, *q;
++ int lst;
++diff -urNad --exclude=CVS --exclude=.svn ./goo/gmem.h /tmp/dpep-work.0qyf6L/xpdf-3.01/goo/gmem.h
++--- ./goo/gmem.h 2005-08-19 19:02:18.000000000 +1000
+++++ /tmp/dpep-work.0qyf6L/xpdf-3.01/goo/gmem.h 2005-08-19 19:04:24.000000000 +1000
++@@ -19,13 +19,13 @@
++ * Same as malloc, but prints error message and exits if malloc()
++ * returns NULL.
++ */
++-extern void *gmalloc(int size);
+++extern void *gmalloc(size_t size);
++
++ /*
++ * Same as realloc, but prints error message and exits if realloc()
++ * returns NULL. If <p> is NULL, calls malloc instead of realloc().
++ */
++-extern void *grealloc(void *p, int size);
+++extern void *grealloc(void *p, size_t size);
++
++ /*
++ * These are similar to gmalloc and grealloc, but take an object count
++@@ -33,8 +33,8 @@
++ * bytes, but there is an additional error check that the total size
++ * doesn't overflow an int.
++ */
++-extern void *gmallocn(int nObjs, int objSize);
++-extern void *greallocn(void *p, int nObjs, int objSize);
+++extern void *gmallocn(int nObjs, size_t objSize);
+++extern void *greallocn(void *p, int nObjs, size_t objSize);
++
++ /*
++ * Same as free, but checks for and ignores NULL pointers.
+--- xpdf-3.02.orig/debian/patches-obselete/00list
++++ xpdf-3.02/debian/patches-obselete/00list
+@@ -0,0 +1,10 @@
++# Security fixes:
++04_freetype-glyph.dpatch
++05_gmem.dpatch
++06_splashpath.dpatch
++07_decrypt.dpatch
++08_core_action.dpatch
++23_security3.dpatch
++# Fix for full screen handling (bug#247602)
++31_fullscreen.patch
++32_vscroll.patch
+--- xpdf-3.02.orig/debian/patches-obselete/31_fullscreen.dpatch
++++ xpdf-3.02/debian/patches-obselete/31_fullscreen.dpatch
+@@ -0,0 +1,45 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 31_fullscreen.dpatch by Junichi Uekawa <dancer@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: NETWM support, rediff of 247602 by Eugeniy Meshcheryakov <eugen@univ.kiev.ua>
++
++@DPATCH@
++diff -urNad xpdf-3.01~/xpdf/XPDFViewer.cc xpdf-3.01/xpdf/XPDFViewer.cc
++--- xpdf-3.01~/xpdf/XPDFViewer.cc 2006-07-12 23:58:06.000000000 +0900
+++++ xpdf-3.01/xpdf/XPDFViewer.cc 2006-07-12 23:59:42.000000000 +0900
++@@ -1049,6 +1049,9 @@
++ #endif
++ int depth;
++ Pixel fg, bg, arm;
+++ Atom wmStateAtom;
+++ Atom wmStateFullscreenAtom;
+++ XClientMessageEvent event;
++
++ // show the window
++ XtPopup(win, XtGrabNone);
++@@ -1240,6 +1243,24 @@
++ about_height,
++ fg, arm, depth),
++ NULL);
+++ if (app->getFullScreen()) {
+++ XtUnmanageChild(toolBar);
+++ wmStateAtom = XInternAtom(display, "_NET_WM_STATE", False);
+++ wmStateFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
+++ event.type = ClientMessage;
+++ event.serial = 0;
+++ event.send_event = True;
+++ event.window = XtWindow(win);
+++ event.message_type = wmStateAtom;
+++ event.format = 32;
+++ event.data.l[0] = 1; /* _NET_WM_STATE_ADD */
+++ event.data.l[1] = wmStateFullscreenAtom;
+++ event.data.l[2] = 0;
+++ event.data.l[3] = 0;
+++ event.data.l[4] = 0;
+++ XSendEvent(display, RootWindow(display, screenNum), False,
+++ SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&event);
+++ }
++ }
++
++ void XPDFViewer::closeWindow() {
+--- xpdf-3.02.orig/debian/patches-obselete/08_core_action.dpatch
++++ xpdf-3.02/debian/patches-obselete/08_core_action.dpatch
+@@ -0,0 +1,20 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 08_core_action.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: No description.
++
++@DPATCH@
++diff -urNad --exclude=CVS --exclude=.svn ./xpdf/XPDFCore.cc /tmp/dpep-work.ujprcX/xpdf-3.01/xpdf/XPDFCore.cc
++--- ./xpdf/XPDFCore.cc 2005-08-19 18:27:53.000000000 +1000
+++++ /tmp/dpep-work.ujprcX/xpdf-3.01/xpdf/XPDFCore.cc 2005-08-19 18:52:50.000000000 +1000
++@@ -452,6 +452,9 @@
++ GString *msg;
++ int i;
++
+++ if (action == 0)
+++ return;
+++
++ switch (kind = action->getKind()) {
++
++ // GoTo / GoToR action
+--- xpdf-3.02.orig/debian/patches-obselete/32_vscroll.dpatch
++++ xpdf-3.02/debian/patches-obselete/32_vscroll.dpatch
+@@ -0,0 +1,98 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 32_vscroll.dpatch by Junichi Uekawa <dancer@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: remove scrollbar patch, updated from 247602 by Eugeniy Meshcheryakov <eugen@univ.kiev.ua>
++
++@DPATCH@
++diff -urNad xpdf-3.01~/xpdf/XPDFCore.cc xpdf-3.01/xpdf/XPDFCore.cc
++--- xpdf-3.01~/xpdf/XPDFCore.cc 2006-07-13 00:06:46.000000000 +0900
+++++ xpdf-3.01/xpdf/XPDFCore.cc 2006-07-13 00:08:17.000000000 +0900
++@@ -881,39 +881,40 @@
++ XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
++ scrolledWin = XmCreateScrolledWindow(parentWidget, "scroll", args, n);
++ XtManageChild(scrolledWin);
++- n = 0;
++- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); ++n;
++- XtSetArg(args[n], XmNminimum, 0); ++n;
++- XtSetArg(args[n], XmNmaximum, 1); ++n;
++- XtSetArg(args[n], XmNsliderSize, 1); ++n;
++- XtSetArg(args[n], XmNvalue, 0); ++n;
++- XtSetArg(args[n], XmNincrement, 1); ++n;
++- XtSetArg(args[n], XmNpageIncrement, 1); ++n;
++- hScrollBar = XmCreateScrollBar(scrolledWin, "hScrollBar", args, n);
++- XtManageChild(hScrollBar);
++- XtAddCallback(hScrollBar, XmNvalueChangedCallback,
++- &hScrollChangeCbk, (XtPointer)this);
+++ if (!fullScreen) {
+++ n = 0;
+++ XtSetArg(args[n], XmNorientation, XmHORIZONTAL); ++n;
+++ XtSetArg(args[n], XmNminimum, 0); ++n;
+++ XtSetArg(args[n], XmNmaximum, 1); ++n;
+++ XtSetArg(args[n], XmNsliderSize, 1); ++n;
+++ XtSetArg(args[n], XmNvalue, 0); ++n;
+++ XtSetArg(args[n], XmNincrement, 1); ++n;
+++ XtSetArg(args[n], XmNpageIncrement, 1); ++n;
+++ hScrollBar = XmCreateScrollBar(scrolledWin, "hScrollBar", args, n);
+++ XtManageChild(hScrollBar);
+++ XtAddCallback(hScrollBar, XmNvalueChangedCallback,
+++ &hScrollChangeCbk, (XtPointer)this);
++ #ifndef DISABLE_SMOOTH_SCROLL
++- XtAddCallback(hScrollBar, XmNdragCallback,
++- &hScrollDragCbk, (XtPointer)this);
+++ XtAddCallback(hScrollBar, XmNdragCallback,
+++ &hScrollDragCbk, (XtPointer)this);
++ #endif
++- n = 0;
++- XtSetArg(args[n], XmNorientation, XmVERTICAL); ++n;
++- XtSetArg(args[n], XmNminimum, 0); ++n;
++- XtSetArg(args[n], XmNmaximum, 1); ++n;
++- XtSetArg(args[n], XmNsliderSize, 1); ++n;
++- XtSetArg(args[n], XmNvalue, 0); ++n;
++- XtSetArg(args[n], XmNincrement, 1); ++n;
++- XtSetArg(args[n], XmNpageIncrement, 1); ++n;
++- vScrollBar = XmCreateScrollBar(scrolledWin, "vScrollBar", args, n);
++- XtManageChild(vScrollBar);
++- XtAddCallback(vScrollBar, XmNvalueChangedCallback,
++- &vScrollChangeCbk, (XtPointer)this);
+++ n = 0;
+++ XtSetArg(args[n], XmNorientation, XmVERTICAL); ++n;
+++ XtSetArg(args[n], XmNminimum, 0); ++n;
+++ XtSetArg(args[n], XmNmaximum, 1); ++n;
+++ XtSetArg(args[n], XmNsliderSize, 1); ++n;
+++ XtSetArg(args[n], XmNvalue, 0); ++n;
+++ XtSetArg(args[n], XmNincrement, 1); ++n;
+++ XtSetArg(args[n], XmNpageIncrement, 1); ++n;
+++ vScrollBar = XmCreateScrollBar(scrolledWin, "vScrollBar", args, n);
+++ XtManageChild(vScrollBar);
+++ XtAddCallback(vScrollBar, XmNvalueChangedCallback,
+++ &vScrollChangeCbk, (XtPointer)this);
++ #ifndef DISABLE_SMOOTH_SCROLL
++- XtAddCallback(vScrollBar, XmNdragCallback,
++- &vScrollDragCbk, (XtPointer)this);
+++ XtAddCallback(vScrollBar, XmNdragCallback,
+++ &vScrollDragCbk, (XtPointer)this);
++ #endif
++-
+++ }
++ // create the drawing area
++ n = 0;
++ XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); ++n;
++@@ -1459,7 +1460,7 @@
++ XtSetArg(args[n], XmNsliderSize, drawAreaWidth); ++n;
++ XtSetArg(args[n], XmNincrement, 16); ++n;
++ XtSetArg(args[n], XmNpageIncrement, drawAreaWidth); ++n;
++- XtSetValues(hScrollBar, args, n);
+++ if (hScrollBar) XtSetValues(hScrollBar, args, n);
++
++ if (pages->getLength() > 0) {
++ if (continuousMode) {
++@@ -1479,7 +1480,7 @@
++ XtSetArg(args[n], XmNsliderSize, drawAreaHeight); ++n;
++ XtSetArg(args[n], XmNincrement, 16); ++n;
++ XtSetArg(args[n], XmNpageIncrement, drawAreaHeight); ++n;
++- XtSetValues(vScrollBar, args, n);
+++ if (vScrollBar) XtSetValues(vScrollBar, args, n);
++ }
++
++ void XPDFCore::setCursor(Cursor cursor) {
+--- xpdf-3.02.orig/debian/patches-obselete/23_security3.dpatch
++++ xpdf-3.02/debian/patches-obselete/23_security3.dpatch
+@@ -0,0 +1,45 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 23_security3.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Red Hat-supplied patch for CAN-2006-0301
++
++@DPATCH@
++diff -urNad xpdf-3.01~/splash/Splash.cc xpdf-3.01/splash/Splash.cc
++--- xpdf-3.01~/splash/Splash.cc 2006-02-01 20:41:14.000000000 +1100
+++++ xpdf-3.01/splash/Splash.cc 2006-02-01 20:41:41.000000000 +1100
++@@ -931,6 +931,10 @@
++ int alpha2, ialpha2;
++ Guchar t;
++
+++ if ( (unsigned) x >= (unsigned) bitmap->getWidth() ||
+++ (unsigned) y >= (unsigned) bitmap->getHeight())
+++ return;
+++
++ if (noClip || state->clip->test(x, y)) {
++ if (alpha != 1 || softMask || state->blendFunc) {
++ blendFunc = state->blendFunc ? state->blendFunc : &blendNormal;
++@@ -1198,6 +1202,11 @@
++ updateModY(y);
++ }
++
+++ if ((unsigned) x0 >= (unsigned) bitmap->getWidth() ||
+++ (unsigned) x1 >= (unsigned) bitmap->getWidth() ||
+++ (unsigned) y >= (unsigned) bitmap->getHeight())
+++ return;
+++
++ if (alpha != 1 || softMask || state->blendFunc) {
++ blendFunc = state->blendFunc ? state->blendFunc : &blendNormal;
++ if (softMask) {
++@@ -1828,6 +1837,11 @@
++ updateModY(y);
++ }
++
+++ if ((unsigned) x0 >= (unsigned) bitmap->getWidth() ||
+++ (unsigned) x1 >= (unsigned) bitmap->getWidth() ||
+++ (unsigned) y >= (unsigned) bitmap->getHeight())
+++ return;
+++
++ switch (bitmap->mode) {
++ case splashModeMono1:
++ p = &bitmap->data[y * bitmap->rowSize + (x0 >> 3)];
+--- xpdf-3.02.orig/debian/patches-obselete/06_splashpath.dpatch
++++ xpdf-3.02/debian/patches-obselete/06_splashpath.dpatch
+@@ -0,0 +1,20 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 06_splashpath.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: No description.
++
++@DPATCH@
++diff -urNad --exclude=CVS --exclude=.svn ./splash/Splash.cc /tmp/dpep-work.Z6NPbI/xpdf-3.01/splash/Splash.cc
++--- ./splash/Splash.cc 2005-08-17 15:34:30.000000000 +1000
+++++ /tmp/dpep-work.Z6NPbI/xpdf-3.01/splash/Splash.cc 2005-08-19 18:36:11.000000000 +1000
++@@ -820,6 +820,9 @@
++ if (path->length == 0) {
++ return splashErrEmptyPath;
++ }
+++ if (path->length == 1) {
+++ return splashErrBogusPath;
+++ }
++ xPath = new SplashXPath(path, state->flatness, gTrue);
++ xPath->sort();
++ scanner = new SplashXPathScanner(xPath, eo);
+--- xpdf-3.02.orig/debian/xpdfrc
++++ xpdf-3.02/debian/xpdfrc
+@@ -0,0 +1,96 @@
++#========================================================================
++#
++# System-wide xpdfrc file
++#
++# The Xpdf tools look for a config file in two places:
++# 1. ~/.xpdfrc
++# 2. /etc/xpdf/xpdfrc
++#
++# Note that if ~/.xpdfrc exists, Xpdf will NOT read the system
++# configuration file /etc/xpdf/xpdfrc. You may wish to include it
++# from your ~/.xpdfrc using:
++# include /etc/xpdf/xpdfrc
++# and then add additional settings.
++#
++# For complete details on config file syntax and available options,
++# please see the xpdfrc(5) man page.
++#
++# http://www.foolabs.com/xpdf/
++#
++#========================================================================
++
++#----- display fonts
++
++# These map the Base-14 fonts to the Type 1 fonts that ship with
++# ghostscript (gsfonts package).
++
++displayFontT1 Times-Roman /usr/share/fonts/type1/gsfonts/n021003l.pfb
++displayFontT1 Times-Italic /usr/share/fonts/type1/gsfonts/n021023l.pfb
++displayFontT1 Times-Bold /usr/share/fonts/type1/gsfonts/n021004l.pfb
++displayFontT1 Times-BoldItalic /usr/share/fonts/type1/gsfonts/n021024l.pfb
++displayFontT1 Helvetica /usr/share/fonts/type1/gsfonts/n019003l.pfb
++displayFontT1 Helvetica-Oblique /usr/share/fonts/type1/gsfonts/n019023l.pfb
++displayFontT1 Helvetica-Bold /usr/share/fonts/type1/gsfonts/n019004l.pfb
++displayFontT1 Helvetica-BoldOblique /usr/share/fonts/type1/gsfonts/n019024l.pfb
++displayFontT1 Courier /usr/share/fonts/type1/gsfonts/n022003l.pfb
++displayFontT1 Courier-Oblique /usr/share/fonts/type1/gsfonts/n022023l.pfb
++displayFontT1 Courier-Bold /usr/share/fonts/type1/gsfonts/n022004l.pfb
++displayFontT1 Courier-BoldOblique /usr/share/fonts/type1/gsfonts/n022024l.pfb
++displayFontT1 Symbol /usr/share/fonts/type1/gsfonts/s050000l.pfb
++displayFontT1 ZapfDingbats /usr/share/fonts/type1/gsfonts/d050000l.pfb
++
++# If you need to display PDF files that refer to non-embedded fonts,
++# you should add one or more fontDir options to point to the
++# directories containing the font files. Xpdf will only look at .pfa,
++# .pfb, and .ttf files in those directories (other files will simply
++# be ignored).
++
++#fontDir /usr/local/fonts/bakoma
++
++#----- PostScript output control
++
++# Set the default PostScript file or command.
++
++psFile "|lpr"
++
++# Set the default PostScript paper size -- this can be letter, legal,
++# A4, or A3. You can also specify a paper size as width and height
++# (in points). Xpdf uses the paper size in /etc/papersize by default.
++
++#psPaperSize letter
++
++#----- text output control
++
++# Choose a text encoding for copy-and-paste and for pdftotext output.
++# The Latin1, ASCII7, and UTF-8 encodings are built into Xpdf. Other
++# encodings are available in the language support packages.
++
++#textEncoding UTF-8
++
++# Choose the end-of-line convention for multi-line copy-and-past and
++# for pdftotext output. The available options are unix, mac, and dos.
++
++#textEOL unix
++
++#----- misc settings
++
++# Enable Type 1 font rasterizing with t1lib. Default "yes".
++
++#enableT1lib no
++
++# Enable TrueType and Type 1 font rasterizing with FreeType. Default "yes".
++
++#enableFreeType no
++
++# Enable anti-aliasing of fonts. Default "yes".
++
++#antialias no
++
++# Set the command used to run a web browser when a URL hyperlink is
++# clicked.
++
++urlCommand "sensible-browser '%s'"
++
++# Include the language configuration file list generated by update-xpdfrc
++include /etc/xpdf/includes
++
+--- xpdf-3.02.orig/debian/xpdf-common.postinst
++++ xpdf-3.02/debian/xpdf-common.postinst
+@@ -0,0 +1,20 @@
++#!/bin/sh
++set -e
++
++if [ "$1" = "configure" ]; then
++ /usr/sbin/update-xpdfrc
++fi
++
++# Remove old /etc/xpdfrc if present
++rm -f /etc/xpdfrc
++
++# Move accidental /etc/xpdf/xpdf-* language files
++# to their proper names (bug in 2.01-1)
++for i in cyrillic greek hebrew latin2 thai turkish; do
++ if [ -e /etc/xpdf/xpdf-$i ]; then
++ mv /etc/xpdf/xpdf-$i /etc/xpdf/xpdfrc-$i
++ fi
++done
++
++#DEBHELPER#
++
+--- xpdf-3.02.orig/debian/control
++++ xpdf-3.02/debian/control
+@@ -0,0 +1,75 @@
++Source: xpdf
++Section: text
++Priority: optional
++Maintainer: Hamish Moffatt <hamish@debian.org>
++Standards-Version: 3.7.2
++Build-Depends: libt1-dev (>= 5.0.2-3), libxext-dev, libxp-dev, libxt-dev, libxpm-dev, libx11-dev, lesstif2-dev | libmotif-dev, x-dev, debhelper (>= 4.2.21), libfreetype6-dev (>= 2.1.2-1), libpaper-dev | libpaperg-dev, pkg-config, dpatch, automake1.9, autoconf
++Build-Conflicts: libttf-dev, libstroke0-dev, autoconf2.13
++
++Package: xpdf
++Architecture: all
++Depends: xpdf-reader, xpdf-utils, xpdf-common
++Conflicts: xpdf-i (<= 0.90-8)
++Replaces: xpdf-i (<= 0.90-8)
++Description: Portable Document Format (PDF) suite
++ xpdf is a suite of tools for Portable Document Format (PDF) files. (These are
++ sometimes called 'Acrobat' files after the name of Adobe's PDF software.)
++ .
++ The tools include xpdf, a PDF viewer (in the package xpdf-reader),
++ and PDF converters (including to/from PostScript) (in the package
++ xpdf-utils).
++ .
++ This package is intended for compatibility with previous versions of
++ this package only. You can safely remove it from your system.
++
++Package: xpdf-common
++Architecture: all
++Conflicts: xpdf (<= 0.93-6), xpdf-cyrillic, xpdf-greek, xpdf-hebrew, xpdf-latin2, xpdf-thai, xpdf-turkish
++Replaces: xpdf-cyrillic, xpdf-greek, xpdf-hebrew, xpdf-latin2, xpdf-thai, xpdf-turkish
++Suggests: xpdf-reader | xpdf-utils
++Recommends: gsfonts-x11
++Description: Portable Document Format (PDF) suite -- common files
++ xpdf is a suite of tools for Portable Document Format (PDF) files. (These are
++ sometimes called 'Acrobat' files after the name of Adobe's PDF software.)
++ .
++ This package contains common files needed by the other xpdf packages.
++
++Package: xpdf-reader
++Architecture: any
++Depends: ${shlibs:Depends}, gsfonts (>= 6.0-1), xpdf-common (>= ${source:Version}), xpdf-common (<< ${source:Version}.1~)
++Provides: pdf-viewer, postscript-preview
++Conflicts: xpdf-i (<= 0.90-8), xpdf (<= 0.93-6)
++Suggests: www-browser
++Description: Portable Document Format (PDF) suite -- viewer for X11
++ xpdf is a suite of tools for Portable Document Format (PDF) files. (These are
++ sometimes called 'Acrobat' files after the name of Adobe's PDF software.)
++ .
++ This package contains xpdf itself, a PDF viewer for X11.
++ xpdf is designed to be small and efficient. xpdf supports encrypted
++ PDF files. Standard X fonts, Truetype fonts and Type 1 fonts are supported.
++ .
++ This package also contains pdftoppm, a utility for converting
++ PDF files to PBM, PGM and PPM formats.
++ .
++ See also the xpdf-utils package for conversion utilities and the
++ other xpdf-* packages for additional language support.
++
++Package: xpdf-utils
++Architecture: any
++Depends: ${shlibs:Depends}, gsfonts (>= 6.0-1), xpdf-common (>= ${source:Version}), xpdf-common (<< ${source:Version}.1~)
++Provides: pdf-viewer, postscript-preview, poppler-utils
++Conflicts: xpdf-i (<= 0.90-8), xpdf (<= 0.93-6), poppler-utils
++Replaces: poppler-utils
++Suggests: pdftk
++Description: Portable Document Format (PDF) suite -- utilities
++ xpdf is a suite of tools for Portable Document Format (PDF) files. (These are
++ sometimes called 'Acrobat' files after the name of Adobe's PDF software.)
++ .
++ This package contains pdftops (PDF to PostScript converter),
++ pdfinfo (PDF document information extractor), pdfimages
++ (PDF image extractor), pdftotext (PDF to text converter), and
++ pdffonts (PDF font analyzer).
++ .
++ To view PDF files, see the xpdf-reader package. That package
++ also contains pdftoppm (PDF to Portable Bitmap converter).
++
+--- xpdf-3.02.orig/debian/xpdf-reader.mime
++++ xpdf-3.02/debian/xpdf-reader.mime
+@@ -0,0 +1,2 @@
++application/pdf; /usr/bin/xpdf %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf; priority=6
++application/x-pdf; /usr/bin/xpdf %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf; priority=6
+--- xpdf-3.02.orig/debian/xpdf-common.dirs
++++ xpdf-3.02/debian/xpdf-common.dirs
+@@ -0,0 +1,7 @@
++usr/share/doc/xpdf-common
++usr/share/doc/xpdf-common/examples
++usr/share/man/man5
++usr/share/man/man8
++usr/share/xpdf
++usr/sbin
++etc/xpdf
+--- xpdf-3.02.orig/debian/update-xpdfrc
++++ xpdf-3.02/debian/update-xpdfrc
+@@ -0,0 +1,22 @@
++#!/bin/sh
++set -e
++
++TARGET=/etc/xpdf/includes
++
++# Generate /etc/xpdf/includes from /etc/xpdf/*
++# This allows the xpdf-* language add-on packages
++# to supply configuration file snippets.
++
++echo \# DO NOT EDIT THIS FILE DIRECTLY. >> $TARGET
++echo \# This file was automatically generated by /usr/sbin/update-xpdfrc. > $TARGET
++echo \# Instead, add or remove files in /etc/xpdf/ then run >> $TARGET
++echo \# /usr/sbin/update-xpdfrc to regenerate this file. >> $TARGET
++echo >> $TARGET
++
++find /etc/xpdf \
++ -name xpdfrc-\* \
++ -and -not -name \*.dpkg\* \
++ -and -not -name \*~ \
++ -and -not -name \*,v \
++ -printf "include %p\n" >> $TARGET
++
+--- xpdf-3.02.orig/debian/xpdf-reader.files
++++ xpdf-3.02/debian/xpdf-reader.files
+@@ -0,0 +1,4 @@
++usr/share/man/man1/pdftoppm.1
++usr/share/man/man1/xpdf.1
++usr/bin/xpdf
++usr/bin/pdftoppm
+--- xpdf-3.02.orig/debian/update-xpdfrc.8
++++ xpdf-3.02/debian/update-xpdfrc.8
+@@ -0,0 +1,46 @@
++.\" Please adjust this date whenever revising the manpage.
++.\"
++.\" Some roff macros, for reference:
++.\" .nh disable hyphenation
++.\" .hy enable hyphenation
++.\" .ad l left justify
++.\" .ad b justify to both left and right margins
++.\" .nf disable filling
++.\" .fi enable filling
++.\" .br insert line break
++.\" .sp <n> insert n+1 empty lines
++.\" for manpage-specific macros, see man(7)
++.TH "update-xpdfrc" "8" "October 22, 2002" "Hamish Moffatt"
++.SH "NAME"
++update\-xpdfrc \- program to generate xpdf's configuration file
++.SH "SYNOPSIS"
++.B update\-xdfrc
++.SH "DESCRIPTION"
++.B \fBupdate\-xpdfrc\fR
++is a program used to generate part of the \fIxpdfrc(5)\fR file used
++by xpdf. The generated configuration file contains a list of the
++configuration snippets provided by the xpdf-* language packages.
++
++You may edit the file \fI/etc/xpdfrc\fR to configure xpdf.
++However, do not edit the generated file \fI/etc/xpdf/includes\fR.
++It is updated whenever a language package is added or removed.
++You must include the file /etc/xpdf/includes in your xpdfrc
++to make use of this functionality.
++
++The language support packages (xpdf-japanese etc) provide additional
++configuration files such as \fI/etc/xpdf/xpdfrc-japanese\fR, which will be
++listed in the generated \fI/etc/xpdf/includes\fR.
++
++.SH "FILES"
++.nf
++.ta \w'/etc/xpdf/xpdfrc\-* 'u
++/etc/xpdf/xpdfrc main configuration file
++.br
++/etc/xpdf/xpdf\-* additional configuration files
++.SH "SEE ALSO"
++.BR xpdfrc (5),
++.BR xpdf (1).
++.SH "AUTHOR"
++This manual page and the update-xpdfrc utility was written by Hamish Moffatt <hamish@debian.org>
++for the Debian GNU/Linux system (but may be used by others).
++.\" vim:syn=nroff
+--- xpdf-3.02.orig/debian/xpdf.postinst
++++ xpdf-3.02/debian/xpdf.postinst
+@@ -0,0 +1,18 @@
++#!/bin/sh
++set -e
++
++# Attempt to remove the /usr/share/doc/xpdf directory.
++# If it exists. dpkg won't replace it with the symbolic
++# link.
++
++if [ "$1" = "configure" ]; then
++
++ if [ -d /usr/share/doc/xpdf ]; then
++ rm -rf /usr/share/doc/xpdf
++ ln -sf xpdf-common /usr/share/doc/xpdf
++ fi
++
++fi
++
++#DEBHELPER#
++
+--- xpdf-3.02.orig/debian/xpdf-utils.dirs
++++ xpdf-3.02/debian/xpdf-utils.dirs
+@@ -0,0 +1,3 @@
++usr/share/doc
++usr/share/man/man1
++usr/bin
+--- xpdf-3.02.orig/debian/compat
++++ xpdf-3.02/debian/compat
+@@ -0,0 +1 @@
++4
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-cyrillic
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-cyrillic
+@@ -0,0 +1,4 @@
++#----- begin Cyrillic support package (2003-jun-28)
++nameToUnicode /usr/share/xpdf/cyrillic/Bulgarian.nameToUnicode
++unicodeMap KOI8-R /usr/share/xpdf/cyrillic/KOI8-R.unicodeMap
++#----- end Cyrillic support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-hebrew
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-hebrew
+@@ -0,0 +1,4 @@
++#----- begin Hebrew support package (2003-feb-16)
++unicodeMap ISO-8859-8 /usr/share/xpdf/hebrew/ISO-8859-8.unicodeMap
++unicodeMap Windows-1255 /usr/share/xpdf/hebrew/Windows-1255.unicodeMap
++#----- end Hebrew support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-latin2
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-latin2
+@@ -0,0 +1,3 @@
++#----- begin Latin2 support package (2002-oct-22)
++unicodeMap Latin2 /usr/share/xpdf/latin2/Latin2.unicodeMap
++#----- end Latin2 support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-turkish
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-turkish
+@@ -0,0 +1,3 @@
++#----- begin Turkish support package (2002-apr-10)
++unicodeMap ISO-8859-9 /usr/share/xpdf/turkish/ISO-8859-9.unicodeMap
++#----- end Turkish support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-greek
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-greek
+@@ -0,0 +1,4 @@
++#----- begin Greek support package (2002-feb-13)
++nameToUnicode /usr/share/xpdf/greek/Greek.nameToUnicode
++unicodeMap ISO-8859-7 /usr/share/xpdf/greek/ISO-8859-7.unicodeMap
++#----- end Greek support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-arabic
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-arabic
+@@ -0,0 +1,3 @@
++#----- begin Arabic support package (2003-feb-16)
++unicodeMap ISO-8859-6 /usr/share/xpdf/arabic/ISO-8859-6.unicodeMap
++#----- end Arabic support package
+--- xpdf-3.02.orig/debian/lang/etc/xpdf/xpdfrc-thai
++++ xpdf-3.02/debian/lang/etc/xpdf/xpdfrc-thai
+@@ -0,0 +1,4 @@
++#----- begin Thai support package (2002-jan-16)
++nameToUnicode /usr/share/xpdf/thai/Thai.nameToUnicode
++unicodeMap TIS-620 /usr/share/xpdf/thai/TIS-620.unicodeMap
++#----- end Thai support package
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/hebrew/Windows-1255.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/hebrew/Windows-1255.unicodeMap
+@@ -0,0 +1,66 @@
++000a 000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 00a3 a0
++00a5 00a9 a5
++00ab 00b9 ab
++00bb 00bf bb
++00d7 aa
++00f7 ba
++010c 43
++010d 63
++0131 69
++0141 4c
++0142 6c
++0152 4f45
++0153 6f65
++0160 53
++0161 73
++0178 59
++017d 5a
++017e 7a
++0192 83
++02c6 88
++02da b0
++02dc 98
++05b0 05b9 c0
++05bb 05c3 cb
++05f0 05f4 d4
++05d0 05ea e0
++200e 200f fd
++2013 2014 96
++2018 2019 91
++201a 82
++201c 201d 93
++201e 84
++2020 86
++2021 87
++2022 95
++2026 85
++2030 89
++2039 8b
++203a 9b
++2044 2f
++20aa a4
++20ac 80
++2122 99
++2212 2d
++f6f9 4c
++f6fa 4f45
++f6fc b0
++f6fd 53
++f6fe 7e
++f6ff 5a
++f721 21
++f724 24
++f726 26
++f730 f739 30
++f73f 3f
++f761 f77a 41
++f7a1 f7a2 a1
++f7bf bf
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/hebrew/ISO-8859-8.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/hebrew/ISO-8859-8.unicodeMap
+@@ -0,0 +1,63 @@
++000a 000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 00a0 20
++00a2 00a9 a2
++00ab 00b9 ab
++00bb 00be bb
++010c 43
++010d 63
++0131 69
++0141 4c
++0142 6c
++0152 4f45
++0153 6f65
++0160 53
++0161 73
++0178 59
++017d 5a
++017e 7a
++02c6 5e
++02da b0
++02dc 7e
++05d0 05ea e0
++05f0 e5e5
++05f1 e5e9
++05f2 e9e9
++2013 ad
++2014 2d2d
++2018 60
++2019 27
++201a 2c
++201c 22
++201d 22
++201e 2c2c
++2022 b7
++2026 2e2e2e
++2039 3c
++203a 3e
++2044 2f
++2122 544d
++2212 2d
++f6f9 4c
++f6fa 4f45
++f6fc b0
++f6fd 53
++f6fe 7e
++f6ff 5a
++f721 21
++f724 24
++f726 26
++f730 f739 30
++f73f 3f
++f761 f77a 41
++f7a1 f7a2 a1
++f7bf bf
++f7e0 f7f6 c0
++f7f8 f7fe d8
++f7ff 59
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/arabic/ISO-8859-6.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/arabic/ISO-8859-6.unicodeMap
+@@ -0,0 +1,40 @@
++000a 000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 00a0 20
++00a4 a4
++00ad ad
++02c6 5e
++02dc 7e
++060c 060c ac
++061b 061b bb
++061f 061f bf
++0621 063a c1
++0640 0652 e0
++2013 2013 ad
++2014 2014 2d2d
++2018 2018 60
++2019 2019 27
++201a 201a 2c
++201c 201c 22
++201d 201d 22
++201e 201e 2c2c
++2026 2026 2e2e2e
++2039 2039 3c
++203a 203a 3e
++2044 2044 2f
++2122 2122 544d
++2212 2212 2d
++f6f9 f6f9 4c
++f6fe f6fe 7e
++f721 f721 21
++f724 f724 24
++f726 f726 26
++f730 f739 30
++f73f f73f 3f
++f761 f77a 41
++fb00 fb00 6666
++fb01 fb01 6669
++fb02 fb02 666c
++fb03 fb03 666669
++fb04 fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/thai/Thai.nameToUnicode
++++ xpdf-3.02/debian/lang/usr/share/xpdf/thai/Thai.nameToUnicode
+@@ -0,0 +1,116 @@
++0e01 ThaiCharacterKoKai
++0e02 ThaiCharacterKhoKhai
++0e03 ThaiCharacterKhoKhuat
++0e04 ThaiCharacterKhoKhwai
++0e05 ThaiCharacterKhoKhon
++0e06 ThaiCharacterKhoRakhang
++0e07 ThaiCharacterNgoNgu
++0e08 ThaiCharacterChoChan
++0e09 ThaiCharacterChoChing
++0e0a ThaiCharacterChoChang
++0e0b ThaiCharacterSoSo
++0e0c ThaiCharacterChoChoe
++0e0d ThaiCharacterYoYing
++0e0e ThaiCharacterDoChada
++0e0f ThaiCharacterToPatak
++0e10 ThaiCharacterThoThan
++0e11 ThaiCharacterThoNangmontho
++0e12 ThaiCharacterThoPhuthao
++0e13 ThaiCharacterNoNen
++0e14 ThaiCharacterDoDek
++0e15 ThaiCharacterToTao
++0e16 ThaiCharacterThoThung
++0e17 ThaiCharacterThoThahan
++0e18 ThaiCharacterThoThong
++0e19 ThaiCharacterNoNu
++0e1a ThaiCharacterBoBaimai
++0e1b ThaiCharacterPoPla
++0e1c ThaiCharacterPhoPhung
++0e1d ThaiCharacterFoFa
++0e1e ThaiCharacterPhoPhan
++0e1f ThaiCharacterFoFan
++0e20 ThaiCharacterPhoSamphao
++0e21 ThaiCharacterMoMa
++0e22 ThaiCharacterYoYak
++0e23 ThaiCharacterRoRua
++0e24 ThaiCharacterRu
++0e25 ThaiCharacterLoLing
++0e26 ThaiCharacterLu
++0e27 ThaiCharacterWoWaen
++0e28 ThaiCharacterSoSala
++0e29 ThaiCharacterSoRusi
++0e2a ThaiCharacterSoSua
++0e2b ThaiCharacterHoHip
++0e2c ThaiCharacterLoChula
++0e2d ThaiCharacterOAng
++0e2e ThaiCharacterHoNokhuk
++0e2f ThaiCharacterPaiyannoi
++0e30 ThaiCharacterSaraA
++0e31 ThaiCharacterMaiHan-akat
++0e32 ThaiCharacterSaraAa
++0e33 ThaiCharacterSaraAm
++0e34 ThaiCharacterSaraI
++0e35 ThaiCharacterSaraIi
++0e36 ThaiCharacterSaraUe
++0e37 ThaiCharacterSaraUee
++0e38 ThaiCharacterSaraU
++0e39 ThaiCharacterSaraUu
++0e3a ThaiCharacterPhinthu
++0e3f ThaiCurrencySymbolBaht
++0e40 ThaiCharacterSaraE
++0e41 ThaiCharacterSaraAe
++0e42 ThaiCharacterSaraO
++0e43 ThaiCharacterSaraAiMaimuan
++0e44 ThaiCharacterSaraAiMaimalai
++0e45 ThaiCharacterLakkhangyao
++0e46 ThaiCharacterMaiyamok
++0e47 ThaiCharacterMaitaikhu
++0e48 ThaiCharacterMaiEk
++0e49 ThaiCharacterMaiTho
++0e4a ThaiCharacterMaiTri
++0e4b ThaiCharacterMaiChattawa
++0e4c ThaiCharacterThanthakhat
++0e4d ThaiCharacterNikhahit
++0e4e ThaiCharacterYamakkan
++0e4f ThaiCharacterFongman
++0e50 ThaiDigitZero
++0e51 ThaiDigitOne
++0e52 ThaiDigitTwo
++0e53 ThaiDigitThree
++0e54 ThaiDigitFour
++0e55 ThaiDigitFive
++0e56 ThaiDigitSix
++0e57 ThaiDigitSeven
++0e58 ThaiDigitEight
++0e59 ThaiDigitNine
++0e5a ThaiCharacterAngkhankhu
++0e5b ThaiCharacterKhomut
++0e4c ThaiCharacterThanthakhatLowLeft
++0e49 ThaiCharacterMaiThoLeft
++0e38 ThaiCharacterSaraULow
++0e31 ThaiCharacterMaiHanAkat
++0e4b ThaiCharacterMaiChattawaLeft
++0e37 ThaiCharacterSaraUeeLeft
++0e4a ThaiCharacterMaiTriLeft
++0e3a ThaiCharacterPhinthuLow
++0e48 ThaiCharacterMaiEkLeft
++0e49 ThaiCharacterMaiThoLow
++0e0d ThaiCharacterYoYingDescless
++0e4b ThaiCharacterMaiChattawaLow
++0e4a ThaiCharacterMaiTriLow
++0e48 ThaiCharacterMaiEkLow
++0e31 ThaiCharacterMaiHanAkatLeft
++0e4c ThaiCharacterThanthakhatLeft
++0e34 ThaiCharacterSaraILeft
++0e4d ThaiCharacterNikhahitLeft
++0e3f ThaiCharacterBaht
++0e49 ThaiCharacterMaiThoLowLeft
++0e4b ThaiCharacterMaiChattawaLowLeft
++0e4c ThaiCharacterThanthakhatLow
++0e39 ThaiCharacterSaraUuLow
++0e4a ThaiCharacterMaiTriLowLeft
++0e35 ThaiCharacterSaraIiLeft
++0e48 ThaiCharacterMaiEkLowLeft
++0e47 ThaiCharacterMaitaikhuLeft
++0e10 ThaiCharacterThoThanDescless
++0e36 ThaiCharacterSaraUeLeft
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/thai/TIS-620.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/thai/TIS-620.unicodeMap
+@@ -0,0 +1,47 @@
++000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 20
++0131 69
++0141 4c
++0142 6c
++0152 4f45
++0153 6f65
++0160 53
++0161 73
++0178 59
++017d 5a
++017e 7a
++02c6 5e
++02dc 7e
++0e01 0e3a a1
++0e3f 0e5b df
++2013 2d2d
++2014 2d2d
++2018 60
++2019 27
++201a 2c
++201c 22
++201d 22
++201e 2c2c
++2022 2a
++2026 2e2e2e
++2039 3c
++203a 3e
++2044 2f
++2122 544d
++2212 2d
++f700 b0
++f701 f704 d4
++f705 f709 e8
++f70a f70e e8
++f70f ad
++f710 d1
++f711 ed
++f712 f717 e7
++f718 f71a d8
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/greek/ISO-8859-7.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/greek/ISO-8859-7.unicodeMap
+@@ -0,0 +1,63 @@
++000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 a0
++00a3 a3
++00a6 00a9 a6
++00ab 00ad ab
++00b0 00b4 b0
++00b5 ec
++00b7 b7
++00bb bb
++00bd bd
++02c6 5e
++02da b0
++02dc 7e
++0374 b4
++037e 3b
++0384 038a b4
++038c bc
++038e 03a1 be
++03a3 03ce d3
++03d0 e2
++03d1 e8
++03d2 d5
++03d3 be
++03d4 db
++03d5 f6
++03d6 f0
++03d7 eae1e9
++03da d3d4
++03db f3f4
++03f0 ea
++03f1 f1
++03f2 63
++03f3 6a
++03f4 c8
++03f5 e5
++2013 ad
++2014 af
++2018 60
++2019 a2
++201a 2c
++201b a1
++201c 22
++201d 22
++201e 2c2c
++2022 b7
++2026 2e2e2e
++2039 3c
++203a 3e
++2044 2f
++20ac c5f5f1fe
++20af c4f1f7
++2122 544d
++2126 d9
++2206 c4
++2212 2d
++2219 b7
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/greek/Greek.nameToUnicode
++++ xpdf-3.02/debian/lang/usr/share/xpdf/greek/Greek.nameToUnicode
+@@ -0,0 +1,11 @@
++0396 Dzeta
++039e Ksi
++039f Omikron
++03a7 Khi
++03b2 betatwo
++03b6 dzeta
++03be ksi
++03bf omikron
++03c3 sigmafinal
++03c6 phitwo
++03c7 khi
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/cyrillic/KOI8-R.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/cyrillic/KOI8-R.unicodeMap
+@@ -0,0 +1,100 @@
++000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 9a
++00a9 bf
++00b0 9c
++00b2 9d
++00b7 9e
++00f7 9f
++02c6 5e
++02da 9c
++02dc 7e
++0401 b3
++0410 0411 e1
++0412 f7
++0413 e7
++0414 0415 e4
++0416 f6
++0417 fa
++0418 041f e9
++0420 0423 f2
++0424 e6
++0425 e8
++0426 e3
++0427 fe
++0428 fb
++0429 fd
++042a ff
++042b f9
++042c f8
++042d fc
++042e e0
++042f f1
++0430 0431 c1
++0432 d7
++0433 c7
++0434 0435 c4
++0436 d6
++0437 da
++0438 c9
++0439 043f ca
++0440 0443 d2
++0444 c6
++0445 c8
++0446 c3
++0447 de
++0448 db
++0449 dd
++044a df
++044b d9
++044c d8
++044d dc
++044e c0
++044f d1
++0451 a3
++2013 2d
++2014 2d2d
++2018 60
++2019 27
++201a 2c
++201c 22
++201d 22
++201e 2c2c
++2022 9e
++2026 2e2e2e
++2039 3c
++203a 3e
++2044 2f
++2122 544d
++2212 2d
++2219 221a 95
++2248 97
++2264 2265 98
++2320 93
++2321 9b
++2500 80
++2502 81
++250c 82
++2510 83
++2514 84
++2518 85
++251c 86
++2524 87
++252c 88
++2534 89
++253c 8a
++2550 2552 a0
++2553 2561 a4
++2562 256c b4
++2580 8b
++2584 8c
++2588 8d
++258c 8e
++2590 2593 8f
++25a0 94
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/cyrillic/Bulgarian.nameToUnicode
++++ xpdf-3.02/debian/lang/usr/share/xpdf/cyrillic/Bulgarian.nameToUnicode
+@@ -0,0 +1,58 @@
++0410 As
++0411 Buki
++0412 Wjedi
++0413 Glagol
++0414 Dobro
++0415 Jest
++0416 Schiwete
++0417 Selmja
++0418 Ische
++0419 Ischebreve
++041a Kako
++041b Ljudi
++041c Muislete
++041d Nasche
++041e On
++041f Pakoj
++0420 Rzui
++0421 Slovo
++0422 Twerdo
++0423 Uk
++0424 Fert
++0425 Cherr
++0426 Zui
++0427 Tscherw
++0428 Scha
++0429 Schtscha
++042a Jerr
++042e Ju
++042f Ja
++0430 as
++0431 buki
++0432 wjedi
++0433 glagol
++0434 dobro
++0435 jest
++0436 schiwete
++0437 selmja
++0438 ische
++0439 ischebreve
++043a kako
++043b ljudi
++043c muislete
++043d nasche
++043e on
++043f pakoj
++0440 rzui
++0441 slovo
++0442 twerdo
++0443 uk
++0444 fert
++0445 cherr
++0446 zui
++0447 tscherw
++0448 scha
++0449 schtscha
++044a jerr
++044e ju
++044f ja
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/latin2/Latin2.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/latin2/Latin2.unicodeMap
+@@ -0,0 +1,134 @@
++000a 000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 00a0 20
++00a4 a4
++00a7 00a8 a7
++00ad ad
++00b0 b0
++00b4 b4
++00b8 b8
++00c1 00c2 c1
++00c4 c4
++00c7 c7
++00c9 c9
++00cb cb
++00cd 00ce cd
++00d3 00d4 d3
++00d6 00d7 d6
++00da da
++00dc 00dd dc
++00df df
++00e1 00e2 e1
++00e4 e4
++00e7 e7
++00e9 e9
++00eb eb
++00ed 00ee ed
++00f3 00f4 f3
++00f6 00f7 f6
++00fa fa
++00fc 00fd fc
++0102 c3
++0103 e3
++0104 a1
++0105 b1
++0106 c6
++0107 e6
++010c c8
++010d e8
++010e cf
++010f ef
++0110 d0
++0111 f0
++0118 ca
++0119 ea
++011a cc
++011b ec
++0131 69
++0132 494a
++0133 696a
++0139 c5
++013a e5
++013d a5
++013e b5
++0141 a3
++0142 b3
++0143 d1
++0144 f1
++0147 d2
++0148 f2
++0150 d5
++0151 f5
++0152 4f45
++0153 6f65
++0154 c0
++0155 e0
++0158 d8
++0159 f8
++015a a6
++015b b6
++015e aa
++015f ba
++0160 a9
++0161 b9
++0162 de
++0163 fe
++0164 ab
++0165 bb
++016e d9
++016f f9
++0170 db
++0171 fb
++0178 59
++0179 ac
++017a bc
++017b af
++017c bf
++017d ae
++017e be
++02c6 5e
++02c7 b7
++02d8 a2
++02d9 ff
++02da b0
++02db b2
++02dc 7e
++02dd bd
++2013 2013 ad
++2014 2014 2d2d
++2018 2018 60
++2019 2019 27
++201a 201a 2c
++201c 201c 22
++201d 201d 22
++201e 201e 2c2c
++2022 2022 b7
++2026 2026 2e2e2e
++2039 2039 3c
++203a 203a 3e
++2044 2044 2f
++2122 2122 544d
++2212 2212 2d
++f6f9 f6f9 4c
++f6fa f6fa 4f45
++f6fc f6fc b0
++f6fd f6fd 53
++f6fe f6fe 7e
++f6ff f6ff 5a
++f721 f721 21
++f724 f724 24
++f726 f726 26
++f730 f739 30
++f73f f73f 3f
++f761 f77a 41
++f7a1 f7a2 a1
++f7bf f7bf bf
++f7e0 f7f6 c0
++f7f8 f7fe d8
++f7ff f7ff 59
++fb00 fb00 6666
++fb01 fb01 6669
++fb02 fb02 666c
++fb03 fb03 666669
++fb04 fb04 66666c
+--- xpdf-3.02.orig/debian/lang/usr/share/xpdf/turkish/ISO-8859-9.unicodeMap
++++ xpdf-3.02/debian/lang/usr/share/xpdf/turkish/ISO-8859-9.unicodeMap
+@@ -0,0 +1,67 @@
++000a 0a
++000c 000d 0c
++0020 007e 20
++00a0 20
++00a1 00ac a1
++00ae 00cf ae
++00d1 00dc d1
++00df 00ef df
++00f1 00fc f1
++00ff ff
++010c 43
++010d 63
++011e d0
++011f f0
++0130 dd
++0131 fd
++0141 4c
++0142 6c
++0152 4f45
++0153 6f65
++015e de
++015f fe
++0160 53
++0161 73
++0178 59
++017d 5a
++017e 7a
++02c6 5e
++02da b0
++02dc 7e
++2013 ad
++2014 2d2d
++2018 60
++2019 27
++201a 2c
++201c 22
++201d 22
++201e 2c2c
++2022 b7
++2026 2e2e2e
++2039 3c
++203a 3e
++2044 2f
++2122 544d
++2212 2d
++f6f9 4c
++f6fa 4f45
++f6fc b0
++f6fd 53
++f6fe 7e
++f6ff 5a
++f721 21
++f724 24
++f726 26
++f730 f739 30
++f73f 3f
++f761 f77a 41
++f7a1 f7a2 a1
++f7bf bf
++f7e0 f7f6 c0
++f7f8 f7fe d8
++f7ff 59
++fb00 6666
++fb01 6669
++fb02 666c
++fb03 666669
++fb04 66666c
+--- xpdf-3.02.orig/debian/changelog
++++ xpdf-3.02/debian/changelog
+@@ -0,0 +1,801 @@
++xpdf (3.02-1.3) unstable; urgency=high
++
++ * Non-maintainer upload by testing security team.
++ * Included fix-CVE-2007-5393_2007-5392_2007-4352.dpatch to address the
++ following security issues (Closes: #450629)
++ - CVE-2007-5393 buffer overflow in the CCITTFaxStream::lookChar leading
++ to arbitrary code execution via a crafted pdf file.
++ - CVE-2007-5392 integer overflow in the DCTStream::reset resulting in a
++ heap based buffer overflow allows code execution.
++ - CVE-2007-4352 array index error in DCTStream::readProgressiveDataUnit
++ leads to memory corruption and possibly arbitrary code execution.
++
++ -- Nico Golde <nion@debian.org> Fri, 09 Nov 2007 09:22:19 +0100
++
++xpdf (3.02-1.2) unstable; urgency=high
++
++ * Non-maintainer upload by testing security team.
++ * Removed post-3.5.7-kdegraphics-CVE-2007-3387.diff.dpatch and
++ created fix-CVE-2007-3387_CVE-2007-5049.dpatch to have a fix
++ for CVE-2007-3387 and a buffer overflow in GetNextLine()
++ (CVE-2007-5049) since they are related (Closes: #443906).
++
++ -- Nico Golde <nion@debian.org> Thu, 27 Sep 2007 12:05:46 +0200
++
++xpdf (3.02-1.1) unstable; urgency=high
++
++ * Non-maintainer upload with permission of the maintainer
++ * Fix integer overflow in the StreamPredictor::StreamPredictor
++ function by adding post-3.5.7-kdegraphics-CVE-2007-3387.diff.dpatch
++ (Closes: #435462) Fixes: CVE-2007-3387
++
++ -- Steffen Joeris <white@debian.org> Tue, 07 Aug 2007 14:00:34 +1000
++
++xpdf (3.02-1) unstable; urgency=low
++
++ * New upstream release (closes: #413611)
++ * Adds PDF 1.6 and 1.7 support (closes: #320509, #329372)
++ * Fixes segfault on Postscript conversion (in xpdf or pdftops)
++ with libc6 2.5-1, though probably also fixed in libc6 already
++ (closes: #419618)
++ * Improved rendering of some PDFs (closes: #409759, #242294, #280767)
++ * Improved full screen handling (obseletes patches incorporated
++ in 3.01-9; 31_fullscreen.dpatch, 32_vscroll.dpatch)
++ * Adds new options to the xpdfrc(5) (closes: #384024)
++ * Fixed handling of some broken PDFs (closes: #330711)
++ * On-the-fly switch to full screen is possible (closes: #281479)
++ * Adds configurable keybindings
++
++ * Patched Latin2 unicode map to include IJ sequences; thanks to
++ Petr Peringer for the patch (closes: #402757)
++ * Fix reference to /etc/xpdf/xpdf-* -> /etc/xpdf/xpdfrc-* in
++ update-xpdfrc(8) (closes: #402852)
++ * Added -title support to zxpdf (closes: #338096)
++ * Updated debian/copyright (closes: #407888)
++ * Modified xpdfrc(5) to note that options are case sensitive (closes:
++ #417979)
++ * Fix package relationships so that package is bin-NMU safe
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 25 Apr 2007 02:42:16 +1000
++
++xpdf (3.01-9) unstable; urgency=low
++
++ * Incorporate patches from Eugeniy Meshcheryakov and Junichi Uekawa to
++ fix fullscreen mode when using a NETWM-compliant window manager
++ (closes: #247602, #362496, #367845, #168970, #192397, #165047)
++ (31_fullscreen.dpatch, 32_vscroll.dpatch)
++ * Nasty, nasty patch to workaround FTBFS due to incompatility
++ between latest g++-4.1 and lesstif - bug#377230 (40_lesstif_copy.dpatch,
++ 41_lesstif_cpp.dpatch)
++ * Upgrade to standards-revision 3.7.2
++ * Made xpdf-common recommend gsfonts-x11 (closes: #329804)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 15 Jul 2006 16:01:16 +1000
++
++xpdf (3.01-8) unstable; urgency=low
++
++ * Add patch 05_freetype-2.2.dpatch: make splash/SplashFTFont.cc
++ compatible with FreeType 2.2 (ie don't use FreeType internals
++ directly any more). Fixes unreported FTBFS.
++ * Enable additional compile-time options: --enable-opi,
++ --enable-multithreaded, --enable-wordlist
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 27 May 2006 00:58:12 +1000
++
++xpdf (3.01-7) unstable; urgency=high
++
++ * SECURITY UPDATE: incorporated upstream patch revision 3.01pl2
++ (obseletes several patches collected from Red Hat, Ubuntu etc).
++ * References: CAN-2005-3191/3192/3193/3624/3625/2626/2627/3628,
++ CAN-2006-0301 (all included, some improved by this patch)
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 16 Feb 2006 00:22:13 +1100
++
++xpdf (3.01-6) unstable; urgency=high
++
++ * SECURITY UPDATE: fixed buffer overflow in splash image handling
++ (Splash/splash.cc) using patch supplied by Red Hat:
++ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=179046
++ (closes: #350785, #350783)
++ * References: CVE-2006-0301
++ * My first upload from the side of the road on borrowed wifi
++ in a foreign country...
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 1 Feb 2006 22:42:42 +1300
++
++xpdf (3.01-5) unstable; urgency=low
++
++ * Changed build-dep on libpaperg-dev to libpaper-dev (closes: #346397)
++ * Made xpdf-utils conflicts/replaces/provides poppler-utils
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 8 Jan 2006 13:25:57 +1100
++
++xpdf (3.01-4) unstable; urgency=high
++
++ * SECURITY UPDATE: added additional precautionary checks
++ supplied by Martin Pitt, Chris Evans and Ludwid Nussel
++ * Changed build-dep on xlibs-dev to individual lib*-dev packages
++
++ -- Hamish Moffatt <hamish@debian.org> Fri, 6 Jan 2006 18:55:24 +1100
++
++xpdf (3.01-3) unstable; urgency=high
++
++ * SECURITY UPDATE: fix several potential buffer overflows:
++ DCTStream Baseline Heap Overflow, DCTStream Progressive Heap Overflow,
++ StreamPredictor Heap Overflow, JPX Stream Reader Heap Overflow
++ (closes: #322462) (21_security.dpatch)
++ * References: CAN-2005-3193, CAN-2005-3191
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 6 Dec 2005 23:05:10 +0000
++
++xpdf (3.01-2) unstable; urgency=low
++
++ * Incorporate upstream patch to fix resize issues with some
++ window managers (20_resize.dpatch)
++ (closes: #325112, #326888, #327572, #329112, #324172)
++ * Fix incorrect escape sequences in xpdf.1 (closes: #320631)
++ Thanks to Erik Schanze for the patch. (01_manpage.dpatch)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 10 Oct 2005 23:34:46 +1000
++
++xpdf (3.01-1) unstable; urgency=low
++
++ * New upstream release (closes: #323715)
++ * Added initial transparency support (closes: #181958, #284504, #243533)
++ * Improved performance of pattern handling (closes: #220628)
++ * Rasterizer optimisations (closes: #229714, #283549)
++ * Handle negative font sizes (closes: #267790, #269495)
++ * Fixed bugs in the Type 1C font parser
++ (closes: #280291, #308547, #316895, #322906, #317708)
++ and TrueType (closes: #270086)
++ * Fix borders with some files (closes: #284307)
++ * Fixed copy/paste losing text (closes: #310042)
++ * Window is sized to fit the document page (closes: #249039, #254843)
++ * Background window is now gray to show page size (closes: #295696)
++ * Directories are not scanned until open dialog used (closes: #298742)
++ * Fixed other crashes (closes: #251057, #264298, #303710),
++ PostScript output bugs (closes: #295685)
++
++ * Added build-conflicts with libstroke0-dev, as it supplies
++ autoconf macros that conflict with xpdf's own
++ * Added category and generic name entries to the Desktop file
++ (closes: #302546); thanks to Alejandro Exojo for the patch
++ * Register for MIME type application/x-pdf in addition to
++ application/pdf (closes: #319057)
++ * Updated to standards-revision 3.6.2
++
++ -- Hamish Moffatt <hamish@debian.org> Fri, 19 Aug 2005 22:48:35 +1000
++
++xpdf (3.00-15) unstable; urgency=low
++
++ * SECURITY UPDATE: fix potiential DoS attack through hand-crafted
++ PDFs with corrupt loca tables (closes: #322462)
++ * References: CAN-2005-2097
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 17 Aug 2005 07:55:17 +1000
++
++xpdf (3.00-14) unstable; urgency=low
++
++ * Use dpatch for patch management; added build-dep on dpatch
++ * Fix FTBFS with gcc-4.0 (closes: #316836);
++ thanks to Daniel Schepler for the patch
++ * xpdf-utils now suggests: pdftk (closes: #306624)
++ * Fix page parameter handling in zxpdf (closes: #315458)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 17 Jul 2005 01:07:20 +1000
++
++xpdf (3.00-13) unstable; urgency=low
++
++ * SECURITY UPDATE: fix buffer overflow for PDF documents with an /Encrypt
++ /Length value > 16 (xpdf/XRef.cc) (upstream xpdf-3.00pl3.patch)
++ * References: CAN-2005-0064 (in addition to previous changes)
++
++ * Added desktop entry to xpdf-reader (adapted from Ubuntu with thanks)
++ (closes: #280812)
++ * Updated build-dependency on debhelper to 4.2.21 to get dh_desktop
++
++ * Fixed FTBFS on amd64 with gcc-4.0 resulting from cast from void*
++ to int in xpdf/XPDFViewer.cc (closes: #288727)
++ Thanks to Andreas Jochens for the patch.
++
++ * Added note to header of source files modified to remove PDF
++ permission checking as requested by upstream in bug#298584
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 22 Mar 2005 23:33:52 +1100
++
++xpdf (3.00-12) unstable; urgency=high
++
++ * SECURITY UPDATE: Fixed buffer overflow that could overwrite the stack
++ and hence cause the execution of arbitrary code as reported by
++ iDEFENSE (xpdf/Decrypt.cc)
++ * References: CAN-2005-0064
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 19 Jan 2005 23:48:56 +1100
++
++xpdf (3.00-11) unstable; urgency=high
++
++ * SECURITY UPDATE: fix potential buffer overflow
++ Applied patch to colour map handling in xpdf/Gfx.cc (closes: #286742)
++ * References: CAN-2004-1125
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 23 Dec 2004 08:16:24 +1100
++
++xpdf (3.00-10) unstable; urgency=high
++
++ * SECURITY UPDATE: fix potential buffer overflow
++ * goo/gmem.[ch]: change declarations of gmalloc and grealloc to use size_t
++ instead of int; int truncated sizes to 32 bits, which made xpdf still
++ vulnerable to integer (and eventually buffer) overflow attacks on 64 bit
++ platforms like amd64.
++ * Thanks to Marcus Meissner <meissner@suse.de> for providing the patch
++ and Martin Pitt <mpitt@debian.org> for providing the changes for
++ Debian in the form of 3.00-9ubuntu2
++ * References:
++ CAN-2004-0889 (incomplete fix in version 3.00-9)
++
++ * Incorporated patch from Arnaud Giersch to fix crashes with
++ certain PDFs (closes: #278693, #279292)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 8 Nov 2004 00:23:22 +1100
++
++xpdf (3.00-9) unstable; urgency=high
++
++ * Applied patch to fix vulnerability CAN-2004:0889: integer overflow
++ issues that could allow denial of service or possibly arbitrary
++ code execution
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 21 Oct 2004 23:49:32 +1000
++
++xpdf (3.00-8) unstable; urgency=low
++
++ * Final cleanup for sarge.
++ * Fixed handling of some PDFs causing crashes (Closes: #254864)
++ Modified splash/SplashFTFont.cc to prevent crash caused by calling
++ FreeType's FT_Decompose_Outline with a non-outline object
++ * Cleaned up dependency on libt1-5 to prevent duplicate depends
++ * Moved pixmaps to /usr/share/pixmaps
++ * Cleaned up lintian warnings
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 18 Aug 2004 23:32:07 +1000
++
++xpdf (3.00-7) unstable; urgency=low
++
++ * Changed wrapper script to use /bin/bash explicitly
++ (closes: #245943, #248090)
++ * Add /usr/share/bug/xpdf/control so that bugs submitted to 'xpdf'
++ go to 'xpdf-reader' instead
++ * Update supplied configuration file for new configuration options
++ (closes: #246351)
++ * Added menu icon (closes: #244504)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 9 May 2004 23:24:30 +1000
++
++xpdf (3.00-6) unstable; urgency=low
++
++ * Add dependency on libt1-5 >= 5.0.2 to fix several Xpdf crashes
++ (closes: #238946, #243847, #243879)
++ * Fixed wrapper script so that X resources are still located
++ correctly (closes: #242513)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 25 Apr 2004 21:48:25 +1000
++
++xpdf (3.00-5) unstable; urgency=low
++
++ * Fix crash when clicking bookmarks in some PDFs (closes: #236007)
++ * Not uploaded
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 30 Mar 2004 23:31:16 +1000
++
++xpdf (3.00-4) unstable; urgency=low
++
++ * Build with new libt1 rather than old t1lib (closes: #234273)
++ * Fixed repeated text in pdfimages(1) (closes: #202139)
++ * Fix crash on some PDFs due to empty paths (closes: #231709, #240187)
++ (thanks to Guillaume Morin for the patch)
++ * Applied upstream patch to add TrueType font collection (TTC) support
++ (closes: #232340)
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 30 Mar 2004 22:30:35 +1000
++
++xpdf (3.00-3) unstable; urgency=low
++
++ * Add upstream patch to fix handling of 16-bit TrueType fonts
++ * Added note to /etc/xpdf/xpdfrc file warning that user configuration
++ files (~/.xpdfrc) override the system-wide file, rather than supplement
++ it (closes: #230853)
++ * Updated /etc/xpdf/xpdfrc to remove obselete X font mappings
++ (no longer supported)
++ * Updated /usr/share/doc/xpdf-common/examples/sample-xpdfrc for 3.00
++ (closes: #229874) by supplying the debian package version instead
++ of upstream's
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 10 Feb 2004 23:00:02 +1100
++
++xpdf (3.00-2) unstable; urgency=low
++
++ * Added build-dep for pkg-config
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 28 Jan 2004 00:38:31 +1100
++
++xpdf (3.00-1) unstable; urgency=low
++
++ * New upstream release
++ * Enter now works in Find dialog to start searching (closes: #167975)
++ * Find dialog text input grows when window is resized (closes: #205208)
++ * Fixed crashes with some PDFs (closes: #223989, #224943, #225289, #229264)
++ * Fixed inverted horizontal mouse wheel behaviour (closes: #224849)
++ * Fixed slow rendering of some documents (closes: #222254)
++ * Corrected location of upstream sources in copyright file
++ (closes: #229670)
++ * Fixed location of configuration file in manual pages
++ (/etc/xpdfrc -> /etc/xpdf/xpdfrc)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 26 Jan 2004 14:39:30 +1100
++
++xpdf (2.03-2) unstable; urgency=low
++
++ * Applied upstream patch to fix reading of JBIG encoded files (closes:
++ #220450)
++ * Wrapper script will now use exec when calling xpdf.bin
++ (closes: #219736) and zxpdf will do the same when calling xpdf
++
++ -- Hamish Moffatt <hamish@debian.org> Fri, 14 Nov 2003 09:08:11 +1100
++
++xpdf (2.03-1) unstable; urgency=low
++
++ * New upstream release
++ * Fixes crashes with some documents (closes: #215867, #212990)
++ * Supports PDF outline (bookmarks) (closes: #166926)
++ * Supports clipping to text which makes some more PDF files
++ display correctly (closes: #184070)
++ * Fix PDF BitsPerComponent handling (closes: #185950)
++ * Handle PDFs with broken Unicode cmap table (closes: #188532)
++ * Handle PDFs with broken DCT streams (closes: #193718)
++ * Improved text extraction with right-to-left scripts (closes: #176745)
++ * If the print command is changed in the print dialog, it won't
++ be reset if another file is opened (closes: #200466)
++
++ * Updated Greek and Cyrillic language support to 2003-jun-28 versions
++ * Provided manual page for xpdf.bin (symlink to xpdf(1)) (closes: #211887)
++ * update-xpdfrc will now ignore backup (*~) and RCS files (closes: #194124)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 22 Oct 2003 22:43:47 +1000
++
++xpdf (2.02pl1-1) unstable; urgency=high
++
++ * Upstream patch release to fix security hole in URL handling
++ (closes: #198032)
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 19 Jun 2003 23:06:21 +1000
++
++xpdf (2.02-2) unstable; urgency=low
++
++ * Modified xpdf(1) to include information about zxpdf
++ (closes: #175535)
++ * Modified zxpdf to work with no command line parameters
++ * Modified zxpdf to recognise .PDF (upper case) file extension
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 23 Apr 2003 00:27:50 +1000
++
++xpdf (2.02-1) unstable; urgency=low
++
++ * New upstream release
++ * Incorporated new Arabic language package 2003-feb-16
++ * Updated Hebrew language support to 2003-feb-16
++ * Upstream: fixed display problems in some PDFs (closes: #181076,
++ #144047, #167827, #176856, #180829)
++ * Upstream: fixed crash on find-next before find (closes: #172973)
++ * Upstream: fixed color handling in buttons (closes: #171398)
++ * Upstream: fixed crash if Ctrl-W pressed while file open (closes: #177698)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 30 Mar 2003 14:06:43 +1000
++
++xpdf (2.01-3) unstable; urgency=low
++
++ * Fixed wrapper script bug: incorrect handling of command line
++ parameters (closes: #174965, #174851)
++ * Fixed wrapper script bug: should set $LC_ALL as well as $LANG
++ (closes: #174717)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 4 Jan 2003 15:59:01 +1100
++
++xpdf (2.01-2) unstable; urgency=low
++
++ * Applied patch to fix buffer overflow as reported by iDEFENSE
++ * Fixed name of language configuration files (/etc/xpdf/xpdf-* renamed
++ back to xpdfrc-*) (closes: #173046)
++ * Modified update-xpdfrc to ignore .dpkg* files in /etc/xpdf
++ (closes: #173268)
++ * Made xpdf a wrapper script which calls real xpdf binary to work
++ around locale problems (closes: #167956, #168717, #169339, #172009)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 28 Dec 2002 00:35:52 +1100
++
++xpdf (2.01-1) unstable; urgency=low
++
++ * New upstream release
++ * Merged in the small and free xpdf language packages xpdf-cyrillic,
++ xpdf-greek, xpdf-hebrew, xpdf-latin2, xpdf-thai and xpdf-turkish;
++ the others remain as seperate packages in non-free.
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 8 Dec 2002 00:02:37 +1100
++
++xpdf (2.00-2) unstable; urgency=low
++
++ * Recompile with lesstif2 (closes: #170624)
++ * Change the default urlCommand to sensible-browser, which will make it
++ honour the BROWSER variable, and run a good default browser that is
++ installed if that is not set. Sure beats hardcoding non-free netscape.
++ (closes: #170085)
++ * Suggest www-browser.
++ * Fixed incorrect resource names in xpdf(1) (closes: #168730)
++ * Set a default print command (closes: #168520)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 30 Nov 2002 13:08:38 +1100
++
++xpdf (2.00-1) unstable; urgency=low
++
++ * New upstream release - uses Lesstif instead of old Xpdf-specific toolkit
++ * Upstream: Control-P now brings up the print dialog (closes: #157225)
++ * Upstream: Worked around problems with fonts in some PDF files
++ (closes: #159778)
++ * Upstream: 'Save as' now uses the standard Motif save dialog, so any
++ filename can be entered (closes: #158423)
++ * Upstream: handles malformed PDFs with error messages rather than
++ silently as happened previously in some cases (closes: #151241)
++ * Upstream: fullscreen behaviour is working fine in this version
++ (closes: #156252)
++ * Upstream: Enter works in save dialog (closes: #166942)
++ * Upstream: now uses standard Motif file selector dialog (closes: #160255)
++ * No performance issues observed with resizing the window (closes: #165847)
++ * Tweaked configuration mechanism not to build /etc/xpdfrc now,
++ but an include file for the main configuration file instead.
++ No changes to the language packages are required to support this.
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 5 Nov 2002 11:49:24 +1100
++
++xpdf (1.01-3) unstable; urgency=low
++
++ * Recompile with more recent FreeType, updated dependencies to match
++ (closes: #155946)
++ * Made xpdf handle missing default paper name from libpaper
++ (eg if $PAPERSIZE is set to a non-existent file) (closes: #150360)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 4 Sep 2002 21:49:41 +1000
++
++xpdf (1.01-2) unstable; urgency=low
++
++ * Fixed dependencies to ensure that xpdf-common, xpdf-reader and
++ xpdf-utils versions are always synchronised (closes: #147897,
++ #151683)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 7 Jul 2002 01:24:00 +1000
++
++xpdf (1.01-1) unstable; urgency=low
++
++ * New upstream release (closes: #146286, #147428)
++ including support for Type 3 fonts (closes: #128686, #137378,
++ #137416, #143245, #145541, #147614)
++ * Removed empty examples directory (closes: #145057, #146336)
++ * Changed dependency on gsfonts to require the woody version
++ or newer (>= 6.0-1) (closes: #146398)
++ * Applied patch to allow copying and printing of protected
++ PDF files (closes: #145558)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 22 May 2002 23:16:47 +1000
++
++xpdf (1.00-4) unstable; urgency=low
++
++ * xpdf-reader: added zxpdf script contributed by Yann Dirson to allow
++ viewing of compressed PDF files (closes: #87316, #14227)
++ * xpdf-reader, xpdf-utils: corrected location of the configuration
++ files in the manual pages (closes: #139982)
++ * xpdf-common: added note to /etc/xpdf/xpdfrc describing configuration
++ file scheme (closes: #143372)
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 25 Apr 2002 10:57:47 +1000
++
++xpdf (1.00-3) unstable; urgency=low
++
++ * Fixed conflicts with xpdf-i (should conflict with versions
++ <= 0.90-8, not 0.90-7) (closes: #136385, #136157)
++ * Applied patch from the upstream author to fix the missing
++ initialZoom X resource (closes: #135712)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 9 Mar 2002 00:23:33 +1100
++
++xpdf (1.00-2) unstable; urgency=low
++
++ * Fixed problem with building the arch-specific packages when
++ xpdf-common was not installed (tried to overwrite /etc/xpdfrc)
++ (closes: #134336, #134338)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 18 Feb 2002 08:36:59 +1100
++
++xpdf (1.00-1) unstable; urgency=low
++
++ * New upstream release (closes: #131961)
++ * Split the xpdf package into xpdf-reader, xpdf-utils and a
++ metapackage, xpdf. This reduces the number of library packages
++ required if you just want pdf2ps, for example. (closes: #122786)
++ * The new upstream release has the language support split into
++ seperate packages. See xpdf-chinese-simplified,
++ xpdf-chinese-traditional, xpdf-korean, xpdf-japanese,
++ xpdf-thai and xpdf-cyrillic. NOTE: some of these are
++ non-free.
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 2 Feb 2002 23:44:20 +1100
++
++xpdf (0.93-6) unstable; urgency=low
++
++ * Applied patch from the upstream author Derek Noonburg
++ to fix an unitialized variable which causes xpdf
++ to sometimes crash on Alpha systems (closes: #124314)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 16 Jan 2002 21:30:53 +1100
++
++xpdf (0.93-5) unstable; urgency=low
++
++ * Applied patch from the upstream author Derek Noonburg
++ to fix TrueType font embedding bugs (closes: #123913)
++ * Added Build-Conflicts: with libttf-dev; the compile gets
++ mixed up between freetype1 and freetype2 when libttf-dev
++ is installed (closes: #123565)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 9 Jan 2002 22:46:49 +1100
++
++xpdf (0.93-4) unstable; urgency=low
++
++ * Added menu hint "Documents" (closes: #121029)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 25 Nov 2001 13:02:24 +1100
++
++xpdf (0.93-3) unstable; urgency=low
++
++ * Added app-defaults file mapping for Type 1 base-14 fonts (requires
++ gsfonts) (closes: #120649, #120994)
++ * Added libpaper support; xpdf now gets the default paper size from
++ X resources, $PAPERSIZE, /etc/papersize, or defaults to letter
++ (closes: #120645)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 25 Nov 2001 11:38:19 +1100
++
++xpdf (0.93-2) unstable; urgency=low
++
++ * Removed final references to install-mime (closes: #120423)
++ * Linked with libfreetype6 (closes: #116283)
++ * Configuration file moved to /etc/xpdfrc (was /usr/etc/xpdfrc by mistake)
++ * Also linked with t1lib
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 24 Nov 2001 16:20:23 +1100
++
++xpdf (0.93-1) unstable; urgency=low
++
++ * New upstream release (closes: #81911, #107448)
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 7 Nov 2001 23:54:52 +1100
++
++xpdf (0.92-5) unstable; urgency=low
++
++ * Fixed freetype file locations which caused the build to fail if
++ libfreetype6-dev wasn't installed (but isn't actually used)
++ (closes: #111745)
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 11 Sep 2001 20:21:47 +1000
++
++xpdf (0.92-4) unstable; urgency=low
++
++ * Added libttf-dev to build-deps so that xpdf will be built with
++ TrueType font support (closes: #108667)
++ * Increased xpdf's priority in mailcap from 4 to 6 to be above
++ gv and acroread (closes: #106858)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 2 Sep 2001 14:54:11 +1000
++
++xpdf (0.92-3) unstable; urgency=low
++
++ * Changed build-dep on xpm4g-dev to xlibs-dev (closes: #83814)
++ * Re-enabled Chinese language support (closes: #74974)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 29 Jan 2001 08:23:06 +1100
++
++xpdf (0.92-2) unstable; urgency=low
++
++ * Recompiled with latest X libraries
++
++ -- Hamish Moffatt <hamish@debian.org> Thu, 18 Jan 2001 08:21:23 +1100
++
++xpdf (0.92-1) unstable; urgency=low
++
++ * New upstream release
++ * Updated Standards-Version
++
++ -- Hamish Moffatt <hamish@debian.org> Wed, 6 Dec 2000 21:16:34 +1100
++
++xpdf (0.91-3) unstable; urgency=low
++
++ * Enabled Chinese language support (closes: #74974)
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 7 Nov 2000 15:52:41 +1100
++
++xpdf (0.91-2) unstable; urgency=low
++
++ * Changed replaces/conflicts with xpdf-i to allow installation
++ of xpdf-i 0.91-1 (dummy package) as well as xpdf >= 0.91
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 19 Sep 2000 22:55:44 +1100
++
++xpdf (0.91-1) unstable; urgency=low
++
++ * New upstream version (closes: #43604, #47391, #61055, #67591, #50170)
++ * Upstream source now includes decryption; xpdf-i is now obselete
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 20 Aug 2000 18:25:07 +1000
++
++xpdf (0.90-6) unstable; urgency=low
++
++ * Added build-depends for debhelper, xpm4g-dev and xlib6g-dev
++ (closes: #68464, #61585)
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 7 Aug 2000 19:29:08 +1000
++
++xpdf (0.90-5) unstable; urgency=low
++
++ * Added build-depends for t1lib-dev (closes: #55658)
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 1 Aug 2000 21:03:43 +1000
++
++xpdf (0.90-4) unstable; urgency=low
++
++ * Recompile for t1lib1
++
++ -- Hamish Moffatt <hamish@debian.org> Mon, 3 Jan 2000 09:45:45 +1100
++
++xpdf (0.90-3) unstable; urgency=low
++
++ * FHS compliant
++ * Converted to debhelper
++ * Moved xpdf binary from /usr/X11R6/bin to /usr/bin
++
++ -- Hamish Moffatt <hamish@debian.org> Fri, 1 Oct 1999 23:51:31 +1000
++
++xpdf (0.90-2) unstable; urgency=low
++
++ * Recompiled with t1lib 0.9.1-4 to get correct dependencies
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 11 Sep 1999 00:59:17 +1000
++
++xpdf (0.90-1) unstable; urgency=low
++
++ * New upstream version
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 14 Aug 1999 14:31:00 +1000
++
++xpdf (0.80-6) unstable; urgency=low
++
++ * Added code in postinst and postrm to remove old MIME entries
++ added using install-mime (fixes #37724, #31293)
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 23 May 1999 00:25:00 +1000
++
++xpdf (0.80-5) unstable; urgency=low
++
++ * Fixed error in /usr/lib/mime/packages/xpdf (fixes #37537)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 15 May 1999 22:35:00 +1000
++
++xpdf (0.80-4) unstable; urgency=low
++
++ * Fixed bug in postinst introduced in 0.80-3 (fixes #37009, #37026)
++ * xpdf now Conflicts with and Replaces xpdf-i
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 02 May 1999 18:20:00 +1000
++
++xpdf (0.80-3) unstable; urgency=low
++
++ * Fixed incorrect mime support handling with patch from David Rocher
++ (fixes bug#36901)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 01 May 1999 18:45:00 +1000
++
++xpdf (0.80-2) unstable; urgency=low
++
++ * Enabled support for 16-bit Japanese fonts (fixes bug#30671)
++
++ -- Hamish Moffatt <hamish@debian.org> Fri, 18 Dec 1998 00:18:00 +1100
++
++xpdf (0.80-1) unstable; urgency=low
++
++ * New upstream release
++
++ -- Hamish Moffatt <hamish@debian.org> Sun, 29 Nov 1998 01:03:00 +1100
++
++xpdf (0.7a-3) unstable; urgency=low
++
++ * Previous upload had wrong section and was rejected
++ * Change of license; xpdf is now GPL (see
++ http://www.debian.org/Lists-Archives/debian-devel-9809/msg00193.html)
++
++ -- Hamish Moffatt <hamish@debian.org> Sat, 10 Oct 1998 11:12:00 +1000
++
++xpdf (0.7a-2) unstable; urgency=low
++
++ * New maintainer
++ * Updated to use update-mime (fixes#26532)
++ * Removed dependency on mime-support, as instructed by update-mime(1)
++ * Rebuilt with new libstdc++
++
++ -- Hamish Moffatt <hamish@debian.org> Tue, 06 Oct 1998 19:43:00 +1000
++
++xpdf (0.7a-1) non-free; urgency=low
++
++ * Upgraded to new upstream release xpdf-0.7a
++
++ -- Dirk Eddelbuettel <edd@debian.org> Mon, 2 Mar 1998 19:24:35 -0500
++
++xpdf (0.7-3) non-free; urgency=low
++
++ * Moved to non-free as the copyright violated #3 of the DFSG (fixes #14360)
++
++ -- Dirk Eddelbuettel <edd@debian.org> Tue, 4 Nov 1997 20:44:26 -0500
++
++xpdf (0.7-2) unstable; urgency=low
++
++ * Compiled with GNU libc2 aka libc6
++ * Linked against xlib6g and xpm4g (fixes bug #12915)
++ * Uses pristine upstream sources as xpdf_0.7.orig.tar.gz
++ * Upgraded to Debian Policy 2.3.0.0
++ * Added menu file for xpdf
++
++ -- Dirk Eddelbuettel <edd@debian.org> Tue, 30 Sep 1997 20:34:09 -0400
++
++xpdf (0.7-1) unstable; urgency=low
++
++ * New upstream release xpdf-0.7
++
++ -- Dirk Eddelbuettel <edd@debian.org> Thu, 29 May 1997 21:22:38 -0400
++
++xpdf (0.6-1) unstable frozen; urgency=low
++
++ * New upstream release xpdf-0.6 (fixes bug #4476)
++
++ * Changed Priority: to optional as per override file on master
++
++ * Converted package management files to Debian Standard 2.1.1.0
++ * Changed maintainer email address to <edd@debian.org>
++
++ -- Dirk Eddelbuettel <edd@debian.org> Sun, 24 Nov 1996 16:50:23 -0500
++
++Sat Aug 10 16:22:28 1996 Dirk Eddelbuettel <edd@miles.econ.queensu.ca>
++
++ * xpdf-0.5-1 release: only changes to Debian package files
++
++ * debian.control: now Depends on mime-support, suitable postinst
++ and postrm scripts added (with thanks to Brian White);
++ also updated virtual package dependencies, now Provides: a
++ pdf-viewer as well as postscript-preview and Depends changed
++ to X11R6 from elf-x11r6lib
++
++ * debian.rules: install xpdf.1x, not xpdf.1
++
++Mon May 27 20:58:19 1996 Dirk Eddelbuettel <edd@miles.econ.queensu.ca>
++
++ * xpdf-0.5-0 release: upgraded to upstream version 0.5
++
++Sun Apr 28 09:51:02 1996 Dirk Eddelbuettel <edd@miles.econ.queensu.ca>
++
++ * xpdf-0.4-0 release: upgraded to upstream version 0.4
++
++ * debian.control: added Architecture:, changed Section: to text,
++ added note that xpdftops is now included
++
++Wed Feb 14 21:49:17 1996 Dirk Eddelbuettel <edd@miles.econ.queensu.ca>
++
++ * xpdf-0.3-1 release
++
++ * debian.rules: fix location of README to /usr/doc/xpdf (bug#2333)
++
++Sun Jan 28 17:36:31 1996 Dirk Eddelbuettel <edd@miles.econ.queensu.ca>
++
++ * xpdf-0.3-0: Initial Debian release
++
+--- xpdf-3.02.orig/debian/xpdf.dirs
++++ xpdf-3.02/debian/xpdf.dirs
+@@ -0,0 +1,2 @@
++usr/share/doc
++usr/share/bug/xpdf
+--- xpdf-3.02.orig/debian/xpdf-common.postrm
++++ xpdf-3.02/debian/xpdf-common.postrm
+@@ -0,0 +1,9 @@
++#!/bin/sh
++set -e
++
++if [ "$1" = "purge" ]; then
++ rm -f /etc/xpdf/includes
++fi
++
++#DEBHELPER#
++
+--- xpdf-3.02.orig/debian/xpdf.desktop
++++ xpdf-3.02/debian/xpdf.desktop
+@@ -0,0 +1,11 @@
++[Desktop Entry]
++Encoding=UTF-8
++Name=xpdf
++GenericName=PDF viewer
++Comment=View PDF files
++Exec=xpdf
++Icon=xpdf.xpm
++Terminal=false
++Type=Application
++MimeType=application/pdf;
++Categories=PDFViewer;Viewer;Graphics;
+--- xpdf-3.02.orig/debian/xpdf-reader.menu
++++ xpdf-3.02/debian/xpdf-reader.menu
+@@ -0,0 +1,8 @@
++?package(xpdf-reader):\
++ needs="x11" \
++ section="Apps/Viewers" \
++ command="/usr/bin/xpdf" \
++ title="Xpdf" \
++ hints="Documents" \
++ icon="/usr/share/pixmaps/xpdf.xpm" \
++ longtitle="Xpdf: Portable Document Format (PDF) file viewer for X"
+--- xpdf-3.02.orig/debian/xpdf-bug-control
++++ xpdf-3.02/debian/xpdf-bug-control
+@@ -0,0 +1 @@
++Submit-As: xpdf-reader
+--- xpdf-3.02.orig/debian/xpdf-reader.dirs
++++ xpdf-3.02/debian/xpdf-reader.dirs
+@@ -0,0 +1,7 @@
++usr/share/doc
++usr/share/applications
++usr/share/man/man1
++usr/lib/mime/packages
++usr/lib/menu
++usr/bin
++usr/share/pixmaps
+--- xpdf-3.02.orig/debian/patches/40_lesstif_copy.dpatch
++++ xpdf-3.02/debian/patches/40_lesstif_copy.dpatch
+@@ -0,0 +1,18 @@
++#! /bin/sh -e
++## DP: make local copy of lesstif headers for use in patch 41
++
++dpatch_patch ()
++{
++ mkdir lesstif
++ cp -a /usr/include/Xm lesstif/
++}
++
++dpatch_unpatch ()
++{
++ rm -rf lesstif
++}
++
++DPATCH_LIB_NO_DEFAULT=1
++
++. /usr/share/dpatch/dpatch.lib.sh
++
+--- xpdf-3.02.orig/debian/patches/01_manpage.dpatch
++++ xpdf-3.02/debian/patches/01_manpage.dpatch
+@@ -0,0 +1,258 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 01_manpage.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Manual page updates
++
++@DPATCH@
++diff -urNad xpdf-3.02~/doc/pdffonts.1 xpdf-3.02/doc/pdffonts.1
++--- xpdf-3.02~/doc/pdffonts.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdffonts.1 2007-04-25 01:26:55.000000000 +1000
++@@ -73,9 +73,7 @@
++ .SH CONFIGURATION FILE
++ Pdffonts reads a configuration file at startup. It first tries to
++ find the user's private config file, ~/.xpdfrc. If that doesn't
++-exist, it looks for a system-wide config file, typically
++-/usr/local/etc/xpdfrc (but this location can be changed when pdffonts
++-is built). See the
+++exist, it looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/pdfimages.1 xpdf-3.02/doc/pdfimages.1
++--- xpdf-3.02~/doc/pdfimages.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdfimages.1 2007-04-25 01:26:55.000000000 +1000
++@@ -12,9 +12,9 @@
++ saves images from a Portable Document Format (PDF) file as Portable
++ Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
++ .PP
++-Pdfimages reads the PDF file, scans one or more pages,
+++Pdfimages reads the PDF file
++ .IR PDF-file ,
++-and writes one PPM, PBM, or JPEG file for each image,
+++scans one or more pages, and writes one PPM, PBM, or JPEG file for each image,
++ .IR image-root - nnn . xxx ,
++ where
++ .I nnn
++@@ -28,9 +28,7 @@
++ .SH CONFIGURATION FILE
++ Pdfimages reads a configuration file at startup. It first tries to
++ find the user's private config file, ~/.xpdfrc. If that doesn't
++-exist, it looks for a system-wide config file, typically
++-/usr/local/etc/xpdfrc (but this location can be changed when pdfimages
++-is built). See the
+++exist, it looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/pdfinfo.1 xpdf-3.02/doc/pdfinfo.1
++--- xpdf-3.02~/doc/pdfinfo.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdfinfo.1 2007-04-25 01:26:55.000000000 +1000
++@@ -71,8 +71,7 @@
++ .SH CONFIGURATION FILE
++ Pdfinfo reads a configuration file at startup. It first tries to find
++ the user's private config file, ~/.xpdfrc. If that doesn't exist, it
++-looks for a system-wide config file, typically /usr/local/etc/xpdfrc
++-(but this location can be changed when pdfinfo is built). See the
+++looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/pdftoppm.1 xpdf-3.02/doc/pdftoppm.1
++--- xpdf-3.02~/doc/pdftoppm.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdftoppm.1 2007-04-25 01:26:55.000000000 +1000
++@@ -24,9 +24,7 @@
++ .SH CONFIGURATION FILE
++ Pdftoppm reads a configuration file at startup. It first tries to
++ find the user's private config file, ~/.xpdfrc. If that doesn't
++-exist, it looks for a system-wide config file, typically
++-/usr/local/etc/xpdfrc (but this location can be changed when pdftoppm
++-is built). See the
+++exist, it looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/pdftops.1 xpdf-3.02/doc/pdftops.1
++--- xpdf-3.02~/doc/pdftops.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdftops.1 2007-04-25 01:26:55.000000000 +1000
++@@ -31,8 +31,7 @@
++ .SH CONFIGURATION FILE
++ Pdftops reads a configuration file at startup. It first tries to find
++ the user's private config file, ~/.xpdfrc. If that doesn't exist, it
++-looks for a system-wide config file, typically /usr/local/etc/xpdfrc
++-(but this location can be changed when pdftops is built). See the
+++looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/pdftotext.1 xpdf-3.02/doc/pdftotext.1
++--- xpdf-3.02~/doc/pdftotext.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/pdftotext.1 2007-04-25 01:26:55.000000000 +1000
++@@ -28,9 +28,7 @@
++ .SH CONFIGURATION FILE
++ Pdftotext reads a configuration file at startup. It first tries to
++ find the user's private config file, ~/.xpdfrc. If that doesn't
++-exist, it looks for a system-wide config file, typically
++-/usr/local/etc/xpdfrc (but this location can be changed when pdftotext
++-is built). See the
+++exist, it looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++diff -urNad xpdf-3.02~/doc/xpdf.1 xpdf-3.02/doc/xpdf.1
++--- xpdf-3.02~/doc/xpdf.1 2007-04-25 01:26:52.000000000 +1000
+++++ xpdf-3.02/doc/xpdf.1 2007-04-25 01:26:55.000000000 +1000
++@@ -7,10 +7,15 @@
++ [options]
++ .RI [ PDF-file
++ .RI [ page " | +" dest ]]
+++.sp
+++.B zxpdf
+++[options]
+++.RI [ PDF-file
+++.RI [ page " | +" dest ]]
++ .SH DESCRIPTION
++ .B Xpdf
++ is a viewer for Portable Document Format (PDF) files. (These are also
++-sometimes also called \'Acrobat' files, from the name of Adobe's PDF
+++sometimes also called 'Acrobat' files, from the name of Adobe's PDF
++ software.) Xpdf runs under the X Window System on UNIX, VMS, and
++ OS/2.
++ .PP
++@@ -29,7 +34,7 @@
++ xpdf file.pdf 18
++ .RE
++ .PP
++-You can also give a named destination, prefixed with \'+' in place of
+++You can also give a named destination, prefixed with '+' in place of
++ the page number. (This is only useful with PDF files that provide
++ named destination targets.)
++ .PP
++@@ -38,11 +43,17 @@
++ .RS
++ xpdf
++ .RE
+++.PP
+++Compressed files (gz and bz2) may be viewed using the command:
+++.PP
+++.RS
+++zxpdf file.pdf.gz
+++.RE
+++.PP
++ .SH CONFIGURATION FILE
++ Xpdf reads a configuration file at startup. It first tries to find
++ the user's private config file, ~/.xpdfrc. If that doesn't exist, it
++-looks for a system-wide config file, typically /usr/local/etc/xpdfrc
++-(but this location can be changed when xpdf is built). See the
+++looks for a system-wide config file, /etc/xpdf/xpdfrc. See the
++ .BR xpdfrc (5)
++ man page for details.
++ .SH OPTIONS
++@@ -92,8 +103,8 @@
++ .TP
++ .BI \-z " zoom"
++ Set the initial zoom factor. A number specifies a zoom percentage,
++-where 100 means 72 dpi.You may also specify \'page', to fit the page
++-to the window size, or \'width', to fit the page width to the window
+++where 100 means 72 dpi.You may also specify 'page', to fit the page
+++to the window size, or 'width', to fit the page width to the window
++ width.
++ .RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ]
++ .TP
++@@ -123,7 +134,7 @@
++ .BI \-ps " PS-file"
++ Set the default file name for PostScript output (i.e., the name which
++ will appear in the print dialog). This can also be of the form
++-\'|command' to pipe the PostScript through a command.
+++'|command' to pipe the PostScript through a command.
++ .RB "[config file: " psFile ]
++ .TP
++ .BI \-paper " size"
++@@ -231,7 +242,7 @@
++ .RB "[X resource: " xpdf*fontList ]
++ .PP
++ The color and font options only affect the user interface elements,
++-not the PDF display (the \'paper').
+++not the PDF display (the 'paper').
++ .PP
++ The following X resources do not have command line option equivalents:
++ .TP
++@@ -254,7 +265,7 @@
++ .B "dashed left/right arrow buttons"
++ Move backward or forward along the history path.
++ .TP
++-.B "\'Page' entry box"
+++.B "'Page' entry box"
++ Move to a specific page number. Click in the box to activate it, type
++ the page number, then hit return.
++ .TP
++@@ -267,17 +278,17 @@
++ .B "print button"
++ Bring up a dialog for generating a PostScript file. The dialog has
++ options to set the pages to be printed and the PostScript file name.
++-The file name can be \'-' for stdout or \'|command' to pipe the
++-PostScript through a command, e.g., \'|lpr'.
+++The file name can be '-' for stdout or '|command' to pipe the
+++PostScript through a command, e.g., '|lpr'.
++ .TP
++-.B "\'?' button"
++-Bring up the \'about xpdf' window.
+++.B "'?' button"
+++Bring up the 'about xpdf' window.
++ .TP
++ .B "link info"
++-The space between the \'?' and \'Quit' buttons is used to show the URL
+++The space between the '?' and 'Quit' buttons is used to show the URL
++ or external file name when the mouse is over a link.
++ .TP
++-.B "\'Quit' button"
+++.B "'Quit' button"
++ Quit xpdf.
++ .PP
++ .SS Menu
++@@ -333,9 +344,9 @@
++ .PP
++ .SS Links
++ Clicking on a hyperlink will jump to the link's destination. A link
++-to another PDF document will make xpdf load that document. A
++-\'launch' link to an executable program will display a dialog, and if
++-you click \'ok', execute the program. URL links call an external
+++to another PDF document will make xpdf load that document. A 'launch'
+++link to an executable program will display a dialog, and if
+++you click 'ok', execute the program. URL links call an external
++ command (see the
++ .B WEB BROWSERS
++ section below).
++@@ -458,7 +469,7 @@
++ .PP
++ When you click on a URL link in a PDF file, xpdf will execute the
++ command specified by the urlCommand config file option, replacing an
++-occurrence of \'%s' with the URL. For example, to call netscape with
+++occurrence of '%s' with the URL. For example, to call netscape with
++ the URL, add this line to your config file:
++ .PP
++ .RS
++@@ -809,8 +820,8 @@
++ xpdf -remote myServer file.pdf
++ .RE
++ .PP
++-If there is currently no xpdf running in server mode with the name
++-\'myServer', a new xpdf window will be opened. If another command:
+++If there is currently no xpdf running in server mode with the name 'myServer',
+++a new xpdf window will be opened. If another command:
++ .PP
++ .RS
++ xpdf -remote myServer another.pdf 9
++diff -urNad xpdf-3.02~/doc/xpdfrc.5 xpdf-3.02/doc/xpdfrc.5
++--- xpdf-3.02~/doc/xpdfrc.5 2007-02-28 09:05:51.000000000 +1100
+++++ xpdf-3.02/doc/xpdfrc.5 2007-04-25 01:28:30.000000000 +1000
++@@ -19,6 +19,9 @@
++ .PP
++ The following sections list all of the configuration options, sorted
++ into functional groups. There is an examples section at the end.
+++.PP
+++Note that all settings are case-sensitive; in particular, boolean options
+++are "yes" and "no" (rather than "Yes" or "No").
++ .SH INCLUDE FILES
++ .TP
++ .BI include " config\-file"
+--- xpdf-3.02.orig/debian/patches/00list
++++ xpdf-3.02/debian/patches/00list
+@@ -0,0 +1,24 @@
++01_manpage.dpatch
++02_permissions.dpatch
++#10_add_accelerators.dpatch # doesn't work
++
++# Security fixes:
++#04_freetype-glyph.dpatch # Not obvious
++#05_gmem.dpatch # Not obvious
++#06_splashpath.dpatch # Not obvious
++#07_decrypt.dpatch # Not obvious
++#08_core_action.dpatch # Not obvious
++#23_security3.dpatch # Not obvious
++
++# Lesstif bug#377230 workaround:
++40_lesstif_copy.dpatch
++41_lesstif_cpp.dpatch
++
++# Final cleanup:
++99_autoconf.dpatch
++
++# Fix CVE-2007-3387 and CVE-2007-5049
++fix-CVE-2007-3387_CVE-2007-5049.dpatch
++
++# Fix CVE-2007-5393, CVE-2007-5392, CVE-2007-4352
++fix-CVE-2007-5393_2007-5392_2007-4352.dpatch
+--- xpdf-3.02.orig/debian/patches/02_permissions.dpatch
++++ xpdf-3.02/debian/patches/02_permissions.dpatch
+@@ -0,0 +1,176 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## permissions.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Remove PDF file permission checks
++
++@DPATCH@
++diff -urNad xpdf-3.02~/xpdf/PDFCore.cc xpdf-3.02/xpdf/PDFCore.cc
++--- xpdf-3.02~/xpdf/PDFCore.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/PDFCore.cc 2007-04-24 23:43:59.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 2004 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 18 August 2005.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -1563,9 +1565,11 @@
++ int x0, y0, x1, y1, t;
++ GString *s;
++
+++#ifdef ENFORCE_PERMISSIONS
++ if (!doc->okToCopy()) {
++ return NULL;
++ }
+++#endif
++ if ((page = findPage(pg))) {
++ cvtUserToDev(pg, xMin, yMin, &x0, &y0);
++ cvtUserToDev(pg, xMax, yMax, &x1, &y1);
++diff -urNad xpdf-3.02~/xpdf/XPDFCore.cc xpdf-3.02/xpdf/XPDFCore.cc
++--- xpdf-3.02~/xpdf/XPDFCore.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/XPDFCore.cc 2007-04-24 23:46:39.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 2002-2003 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 22 May 2002.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -384,11 +386,15 @@
++ #ifndef NO_TEXT_SELECT
++ if (selectULX != selectLRX &&
++ selectULY != selectLRY) {
+++#ifdef ENFORCE_PERMISSIONS
++ if (doc->okToCopy()) {
++ copySelection();
++ } else {
++ error(-1, "Copying of text from this document is not allowed.");
++ }
+++#else
+++ copySelection();
+++#endif
++ }
++ #endif
++ }
++@@ -407,9 +413,11 @@
++ int pg;
++ double ulx, uly, lrx, lry;
++
+++#ifdef ENFORCE_PERMISSIONS
++ if (!doc->okToCopy()) {
++ return;
++ }
+++#endif
++ if (getSelection(&pg, &ulx, &uly, &lrx, &lry)) {
++ //~ for multithreading: need a mutex here
++ if (currentSelection) {
++diff -urNad xpdf-3.02~/xpdf/XPDFViewer.cc xpdf-3.02/xpdf/XPDFViewer.cc
++--- xpdf-3.02~/xpdf/XPDFViewer.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/XPDFViewer.cc 2007-04-24 23:43:59.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 2002-2003 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 22 May 2002.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -3406,10 +3408,12 @@
++ PSOutputDev *psOut;
++
++ doc = viewer->core->getDoc();
+++#ifdef ENFORCE_PERMISSIONS
++ if (!doc->okToPrint()) {
++ error(-1, "Printing this document is not allowed.");
++ return;
++ }
+++#endif
++
++ viewer->core->setBusyCursor(gTrue);
++
++diff -urNad xpdf-3.02~/xpdf/pdfimages.cc xpdf-3.02/xpdf/pdfimages.cc
++--- xpdf-3.02~/xpdf/pdfimages.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/pdfimages.cc 2007-04-24 23:43:59.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 1998-2003 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 22 May 2002.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -119,11 +121,13 @@
++ }
++
++ // check for copy permission
+++#ifdef ENFORCE_PERMISSIONS
++ if (!doc->okToCopy()) {
++ error(-1, "Copying of images from this document is not allowed.");
++ exitCode = 3;
++ goto err1;
++ }
+++#endif
++
++ // get page range
++ if (firstPage < 1)
++diff -urNad xpdf-3.02~/xpdf/pdftops.cc xpdf-3.02/xpdf/pdftops.cc
++--- xpdf-3.02~/xpdf/pdftops.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/pdftops.cc 2007-04-24 23:43:59.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 1996-2003 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 22 May 2002.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -278,12 +280,14 @@
++ goto err1;
++ }
++
+++#ifdef ENFORCE_PERMISSIONS
++ // check for print permission
++ if (!doc->okToPrint()) {
++ error(-1, "Printing this document is not allowed.");
++ exitCode = 3;
++ goto err1;
++ }
+++#endif
++
++ // construct PostScript file name
++ if (argc == 3) {
++diff -urNad xpdf-3.02~/xpdf/pdftotext.cc xpdf-3.02/xpdf/pdftotext.cc
++--- xpdf-3.02~/xpdf/pdftotext.cc 2007-02-28 09:05:52.000000000 +1100
+++++ xpdf-3.02/xpdf/pdftotext.cc 2007-04-24 23:43:59.000000000 +1000
++@@ -4,6 +4,8 @@
++ //
++ // Copyright 1997-2003 Glyph & Cog, LLC
++ //
+++// Modified for Debian by Hamish Moffatt, 22 May 2002.
+++//
++ //========================================================================
++
++ #include <aconf.h>
++@@ -160,12 +162,14 @@
++ goto err2;
++ }
++
+++#ifdef ENFORCE_PERMISSIONS
++ // check for copy permission
++ if (!doc->okToCopy()) {
++ error(-1, "Copying of text from this document is not allowed.");
++ exitCode = 3;
++ goto err2;
++ }
+++#endif
++
++ // construct text file name
++ if (argc == 3) {
+--- xpdf-3.02.orig/debian/patches/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch
++++ xpdf-3.02/debian/patches/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch
+@@ -0,0 +1,652 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## fix-CVE-2007-5393_2007-5392_2007-4352.dpatch by Nico Golde <nion@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: No description.
++
++@DPATCH@
++diff -urNad xpdf-3.02~/xpdf/Stream.cc xpdf-3.02/xpdf/Stream.cc
++--- xpdf-3.02~/xpdf/Stream.cc 2007-02-27 23:05:52.000000000 +0100
+++++ xpdf-3.02/xpdf/Stream.cc 2007-11-09 09:20:09.000000000 +0100
++@@ -1245,23 +1245,26 @@
++ columns = columnsA;
++ if (columns < 1) {
++ columns = 1;
++- }
++- if (columns + 4 <= 0) {
++- columns = INT_MAX - 4;
+++ } else if (columns > INT_MAX - 2) {
+++ columns = INT_MAX - 2;
++ }
++ rows = rowsA;
++ endOfBlock = endOfBlockA;
++ black = blackA;
++- refLine = (short *)gmallocn(columns + 3, sizeof(short));
++- codingLine = (short *)gmallocn(columns + 2, sizeof(short));
+++ // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = columns
+++ // ---> max codingLine size = columns + 1
+++ // refLine has one extra guard entry at the end
+++ // ---> max refLine size = columns + 2
+++ codingLine = (int *)gmallocn(columns + 1, sizeof(int));
+++ refLine = (int *)gmallocn(columns + 2, sizeof(int));
++
++ eof = gFalse;
++ row = 0;
++ nextLine2D = encoding < 0;
++ inputBits = 0;
++- codingLine[0] = 0;
++- codingLine[1] = refLine[2] = columns;
++- a0 = 1;
+++ codingLine[0] = columns;
+++ a0i = 0;
+++ outputBits = 0;
++
++ buf = EOF;
++ }
++@@ -1280,9 +1283,9 @@
++ row = 0;
++ nextLine2D = encoding < 0;
++ inputBits = 0;
++- codingLine[0] = 0;
++- codingLine[1] = columns;
++- a0 = 1;
+++ codingLine[0] = columns;
+++ a0i = 0;
+++ outputBits = 0;
++ buf = EOF;
++
++ // skip any initial zero bits and end-of-line marker, and get the 2D
++@@ -1299,211 +1302,230 @@
++ }
++ }
++
+++inline void CCITTFaxStream::addPixels(int a1, int blackPixels) {
+++ if (a1 > codingLine[a0i]) {
+++ if (a1 > columns) {
+++ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
+++ err = gTrue;
+++ a1 = columns;
+++ }
+++ if ((a0i & 1) ^ blackPixels) {
+++ ++a0i;
+++ }
+++ codingLine[a0i] = a1;
+++ }
+++}
+++
+++inline void CCITTFaxStream::addPixelsNeg(int a1, int blackPixels) {
+++ if (a1 > codingLine[a0i]) {
+++ if (a1 > columns) {
+++ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
+++ err = gTrue;
+++ a1 = columns;
+++ }
+++ if ((a0i & 1) ^ blackPixels) {
+++ ++a0i;
+++ }
+++ codingLine[a0i] = a1;
+++ } else if (a1 < codingLine[a0i]) {
+++ if (a1 < 0) {
+++ error(getPos(), "Invalid CCITTFax code");
+++ err = gTrue;
+++ a1 = 0;
+++ }
+++ while (a0i > 0 && a1 <= codingLine[a0i - 1]) {
+++ --a0i;
+++ }
+++ codingLine[a0i] = a1;
+++ }
+++}
+++
++ int CCITTFaxStream::lookChar() {
++ short code1, code2, code3;
++- int a0New;
++- GBool err, gotEOL;
++- int ret;
++- int bits, i;
+++ int b1i, blackPixels, i, bits;
+++ GBool gotEOL;
++
++- // if at eof just return EOF
++- if (eof && codingLine[a0] >= columns) {
++- return EOF;
+++ if (buf != EOF) {
+++ return buf;
++ }
++
++ // read the next row
++- err = gFalse;
++- if (codingLine[a0] >= columns) {
+++ if (outputBits == 0) {
+++
+++ // if at eof just return EOF
+++ if (eof) {
+++ return EOF;
+++ }
+++
+++ err = gFalse;
++
++ // 2-D encoding
++ if (nextLine2D) {
++- // state:
++- // a0New = current position in coding line (0 <= a0New <= columns)
++- // codingLine[a0] = last change in coding line
++- // (black-to-white if a0 is even,
++- // white-to-black if a0 is odd)
++- // refLine[b1] = next change in reference line of opposite color
++- // to a0
++- // invariants:
++- // 0 <= codingLine[a0] <= a0New
++- // <= refLine[b1] <= refLine[b1+1] <= columns
++- // 0 <= a0 <= columns+1
++- // refLine[0] = 0
++- // refLine[n] = refLine[n+1] = columns
++- // -- for some 1 <= n <= columns+1
++- // end condition:
++- // 0 = codingLine[0] <= codingLine[1] < codingLine[2] < ...
++- // < codingLine[n-1] < codingLine[n] = columns
++- // -- where 1 <= n <= columns+1
++ for (i = 0; codingLine[i] < columns; ++i) {
++ refLine[i] = codingLine[i];
++ }
++- refLine[i] = refLine[i + 1] = columns;
++- b1 = 1;
++- a0New = codingLine[a0 = 0] = 0;
++- do {
+++ refLine[i++] = columns;
+++ refLine[i] = columns;
+++ codingLine[0] = 0;
+++ a0i = 0;
+++ b1i = 0;
+++ blackPixels = 0;
+++ // invariant:
+++ // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1]
+++ // <= columns
+++ // exception at left edge:
+++ // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
+++ // exception at right edge:
+++ // refLine[b1i] = refLine[b1i+1] = columns is possible
+++ while (codingLine[a0i] < columns) {
++ code1 = getTwoDimCode();
++ switch (code1) {
++ case twoDimPass:
++- if (refLine[b1] < columns) {
++- a0New = refLine[b1 + 1];
++- b1 += 2;
+++ addPixels(refLine[b1i + 1], blackPixels);
+++ if (refLine[b1i + 1] < columns) {
+++ b1i += 2;
++ }
++ break;
++ case twoDimHoriz:
++- if ((a0 & 1) == 0) {
++- code1 = code2 = 0;
+++ code1 = code2 = 0;
+++ if (blackPixels) {
++ do {
++- code1 += code3 = getWhiteCode();
+++ code1 += code3 = getBlackCode();
++ } while (code3 >= 64);
++ do {
++- code2 += code3 = getBlackCode();
+++ code2 += code3 = getWhiteCode();
++ } while (code3 >= 64);
++ } else {
++- code1 = code2 = 0;
++ do {
++- code1 += code3 = getBlackCode();
+++ code1 += code3 = getWhiteCode();
++ } while (code3 >= 64);
++ do {
++- code2 += code3 = getWhiteCode();
+++ code2 += code3 = getBlackCode();
++ } while (code3 >= 64);
++ }
++- if (code1 > 0 || code2 > 0) {
++- if (a0New + code1 <= columns) {
++- codingLine[a0 + 1] = a0New + code1;
++- } else {
++- codingLine[a0 + 1] = columns;
++- }
++- ++a0;
++- if (codingLine[a0] + code2 <= columns) {
++- codingLine[a0 + 1] = codingLine[a0] + code2;
++- } else {
++- codingLine[a0 + 1] = columns;
++- }
++- ++a0;
++- a0New = codingLine[a0];
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ addPixels(codingLine[a0i] + code1, blackPixels);
+++ if (codingLine[a0i] < columns) {
+++ addPixels(codingLine[a0i] + code2, blackPixels ^ 1);
+++ }
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
+++ }
+++ break;
+++ case twoDimVertR3:
+++ addPixels(refLine[b1i] + 3, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ ++b1i;
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++ }
++ break;
++- case twoDimVert0:
++- if (refLine[b1] < columns) {
++- a0New = codingLine[++a0] = refLine[b1];
++- ++b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ case twoDimVertR2:
+++ addPixels(refLine[b1i] + 2, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ ++b1i;
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++- } else {
++- a0New = codingLine[++a0] = columns;
++ }
++ break;
++ case twoDimVertR1:
++- if (refLine[b1] + 1 < columns) {
++- a0New = codingLine[++a0] = refLine[b1] + 1;
++- ++b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ addPixels(refLine[b1i] + 1, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ ++b1i;
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++- } else {
++- a0New = codingLine[++a0] = columns;
++ }
++ break;
++- case twoDimVertL1:
++- if (refLine[b1] - 1 > a0New || (a0 == 0 && refLine[b1] == 1)) {
++- a0New = codingLine[++a0] = refLine[b1] - 1;
++- --b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ case twoDimVert0:
+++ addPixels(refLine[b1i], blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ ++b1i;
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++ }
++ break;
++- case twoDimVertR2:
++- if (refLine[b1] + 2 < columns) {
++- a0New = codingLine[++a0] = refLine[b1] + 2;
++- ++b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ case twoDimVertL3:
+++ addPixelsNeg(refLine[b1i] - 3, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ if (b1i > 0) {
+++ --b1i;
+++ } else {
+++ ++b1i;
+++ }
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++- } else {
++- a0New = codingLine[++a0] = columns;
++ }
++ break;
++ case twoDimVertL2:
++- if (refLine[b1] - 2 > a0New || (a0 == 0 && refLine[b1] == 2)) {
++- a0New = codingLine[++a0] = refLine[b1] - 2;
++- --b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ addPixelsNeg(refLine[b1i] - 2, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ if (b1i > 0) {
+++ --b1i;
+++ } else {
+++ ++b1i;
++ }
++- }
++- break;
++- case twoDimVertR3:
++- if (refLine[b1] + 3 < columns) {
++- a0New = codingLine[++a0] = refLine[b1] + 3;
++- ++b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++- } else {
++- a0New = codingLine[++a0] = columns;
++ }
++ break;
++- case twoDimVertL3:
++- if (refLine[b1] - 3 > a0New || (a0 == 0 && refLine[b1] == 3)) {
++- a0New = codingLine[++a0] = refLine[b1] - 3;
++- --b1;
++- while (refLine[b1] <= a0New && refLine[b1] < columns) {
++- b1 += 2;
+++ case twoDimVertL1:
+++ addPixelsNeg(refLine[b1i] - 1, blackPixels);
+++ blackPixels ^= 1;
+++ if (codingLine[a0i] < columns) {
+++ if (b1i > 0) {
+++ --b1i;
+++ } else {
+++ ++b1i;
+++ }
+++ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
+++ b1i += 2;
++ }
++ }
++ break;
++ case EOF:
+++ addPixels(columns, 0);
++ eof = gTrue;
++- codingLine[a0 = 0] = columns;
++- return EOF;
+++ break;
++ default:
++ error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
+++ addPixels(columns, 0);
++ err = gTrue;
++ break;
++ }
++- } while (codingLine[a0] < columns);
+++ }
++
++ // 1-D encoding
++ } else {
++- codingLine[a0 = 0] = 0;
++- while (1) {
+++ codingLine[0] = 0;
+++ a0i = 0;
+++ blackPixels = 0;
+++ while (codingLine[a0i] < columns) {
++ code1 = 0;
++- do {
++- code1 += code3 = getWhiteCode();
++- } while (code3 >= 64);
++- codingLine[a0+1] = codingLine[a0] + code1;
++- ++a0;
++- if (codingLine[a0] >= columns) {
++- break;
++- }
++- code2 = 0;
++- do {
++- code2 += code3 = getBlackCode();
++- } while (code3 >= 64);
++- codingLine[a0+1] = codingLine[a0] + code2;
++- ++a0;
++- if (codingLine[a0] >= columns) {
++- break;
+++ if (blackPixels) {
+++ do {
+++ code1 += code3 = getBlackCode();
+++ } while (code3 >= 64);
+++ } else {
+++ do {
+++ code1 += code3 = getWhiteCode();
+++ } while (code3 >= 64);
++ }
+++ addPixels(codingLine[a0i] + code1, blackPixels);
+++ blackPixels ^= 1;
++ }
++ }
++
++- if (codingLine[a0] != columns) {
++- error(getPos(), "CCITTFax row is wrong length (%d)", codingLine[a0]);
++- // force the row to be the correct length
++- while (codingLine[a0] > columns) {
++- --a0;
++- }
++- codingLine[++a0] = columns;
++- err = gTrue;
++- }
++-
++ // byte-align the row
++ if (byteAlign) {
++ inputBits &= ~7;
++@@ -1562,14 +1584,17 @@
++ // this if we know the stream contains end-of-line markers because
++ // the "just plow on" technique tends to work better otherwise
++ } else if (err && endOfLine) {
++- do {
+++ while (1) {
+++ code1 = lookBits(13);
++ if (code1 == EOF) {
++ eof = gTrue;
++ return EOF;
++ }
+++ if ((code1 >> 1) == 0x001) {
+++ break;
+++ }
++ eatBits(1);
++- code1 = lookBits(13);
++- } while ((code1 >> 1) != 0x001);
+++ }
++ eatBits(12);
++ if (encoding > 0) {
++ eatBits(1);
++@@ -1577,11 +1602,11 @@
++ }
++ }
++
++- a0 = 0;
++- outputBits = codingLine[1] - codingLine[0];
++- if (outputBits == 0) {
++- a0 = 1;
++- outputBits = codingLine[2] - codingLine[1];
+++ // set up for output
+++ if (codingLine[0] > 0) {
+++ outputBits = codingLine[a0i = 0];
+++ } else {
+++ outputBits = codingLine[a0i = 1];
++ }
++
++ ++row;
++@@ -1589,39 +1614,43 @@
++
++ // get a byte
++ if (outputBits >= 8) {
++- ret = ((a0 & 1) == 0) ? 0xff : 0x00;
++- if ((outputBits -= 8) == 0) {
++- ++a0;
++- if (codingLine[a0] < columns) {
++- outputBits = codingLine[a0 + 1] - codingLine[a0];
++- }
+++ buf = (a0i & 1) ? 0x00 : 0xff;
+++ outputBits -= 8;
+++ if (outputBits == 0 && codingLine[a0i] < columns) {
+++ ++a0i;
+++ outputBits = codingLine[a0i] - codingLine[a0i - 1];
++ }
++ } else {
++ bits = 8;
++- ret = 0;
+++ buf = 0;
++ do {
++ if (outputBits > bits) {
++- i = bits;
++- bits = 0;
++- if ((a0 & 1) == 0) {
++- ret |= 0xff >> (8 - i);
+++ buf <<= bits;
+++ if (!(a0i & 1)) {
+++ buf |= 0xff >> (8 - bits);
++ }
++- outputBits -= i;
+++ outputBits -= bits;
+++ bits = 0;
++ } else {
++- i = outputBits;
++- bits -= outputBits;
++- if ((a0 & 1) == 0) {
++- ret |= (0xff >> (8 - i)) << bits;
+++ buf <<= outputBits;
+++ if (!(a0i & 1)) {
+++ buf |= 0xff >> (8 - outputBits);
++ }
+++ bits -= outputBits;
++ outputBits = 0;
++- ++a0;
++- if (codingLine[a0] < columns) {
++- outputBits = codingLine[a0 + 1] - codingLine[a0];
+++ if (codingLine[a0i] < columns) {
+++ ++a0i;
+++ outputBits = codingLine[a0i] - codingLine[a0i - 1];
+++ } else if (bits > 0) {
+++ buf <<= bits;
+++ bits = 0;
++ }
++ }
++- } while (bits > 0 && codingLine[a0] < columns);
+++ } while (bits);
+++ }
+++ if (black) {
+++ buf ^= 0xff;
++ }
++- buf = black ? (ret ^ 0xff) : ret;
++ return buf;
++ }
++
++@@ -1663,6 +1692,9 @@
++ code = 0; // make gcc happy
++ if (endOfBlock) {
++ code = lookBits(12);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if ((code >> 5) == 0) {
++ p = &whiteTab1[code];
++ } else {
++@@ -1675,6 +1707,9 @@
++ } else {
++ for (n = 1; n <= 9; ++n) {
++ code = lookBits(n);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if (n < 9) {
++ code <<= 9 - n;
++ }
++@@ -1686,6 +1721,9 @@
++ }
++ for (n = 11; n <= 12; ++n) {
++ code = lookBits(n);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if (n < 12) {
++ code <<= 12 - n;
++ }
++@@ -1711,9 +1749,12 @@
++ code = 0; // make gcc happy
++ if (endOfBlock) {
++ code = lookBits(13);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if ((code >> 7) == 0) {
++ p = &blackTab1[code];
++- } else if ((code >> 9) == 0) {
+++ } else if ((code >> 9) == 0 && (code >> 7) != 0) {
++ p = &blackTab2[(code >> 1) - 64];
++ } else {
++ p = &blackTab3[code >> 7];
++@@ -1725,6 +1766,9 @@
++ } else {
++ for (n = 2; n <= 6; ++n) {
++ code = lookBits(n);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if (n < 6) {
++ code <<= 6 - n;
++ }
++@@ -1736,6 +1780,9 @@
++ }
++ for (n = 7; n <= 12; ++n) {
++ code = lookBits(n);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if (n < 12) {
++ code <<= 12 - n;
++ }
++@@ -1749,6 +1796,9 @@
++ }
++ for (n = 10; n <= 13; ++n) {
++ code = lookBits(n);
+++ if (code == EOF) {
+++ return 1;
+++ }
++ if (n < 13) {
++ code <<= 13 - n;
++ }
++@@ -1963,6 +2013,12 @@
++ // allocate a buffer for the whole image
++ bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
++ bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
+++ if (bufWidth <= 0 || bufHeight <= 0 ||
+++ bufWidth > INT_MAX / bufWidth / (int)sizeof(int)) {
+++ error(getPos(), "Invalid image size in DCT stream");
+++ y = height;
+++ return;
+++ }
++ for (i = 0; i < numComps; ++i) {
++ frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
++ memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
++@@ -3038,6 +3094,11 @@
++ }
++ scanInfo.firstCoeff = str->getChar();
++ scanInfo.lastCoeff = str->getChar();
+++ if (scanInfo.firstCoeff < 0 || scanInfo.lastCoeff > 63 ||
+++ scanInfo.firstCoeff > scanInfo.lastCoeff) {
+++ error(getPos(), "Bad DCT coefficient numbers in scan info block");
+++ return gFalse;
+++ }
++ c = str->getChar();
++ scanInfo.ah = (c >> 4) & 0x0f;
++ scanInfo.al = c & 0x0f;
++diff -urNad xpdf-3.02~/xpdf/Stream.h xpdf-3.02/xpdf/Stream.h
++--- xpdf-3.02~/xpdf/Stream.h 2007-02-27 23:05:52.000000000 +0100
+++++ xpdf-3.02/xpdf/Stream.h 2007-11-09 09:20:09.000000000 +0100
++@@ -528,13 +528,15 @@
++ int row; // current row
++ int inputBuf; // input buffer
++ int inputBits; // number of bits in input buffer
++- short *refLine; // reference line changing elements
++- int b1; // index into refLine
++- short *codingLine; // coding line changing elements
++- int a0; // index into codingLine
+++ int *codingLine; // coding line changing elements
+++ int *refLine; // reference line changing elements
+++ int a0i; // index into codingLine
+++ GBool err; // error on current line
++ int outputBits; // remaining ouput bits
++ int buf; // character buffer
++
+++ void addPixels(int a1, int black);
+++ void addPixelsNeg(int a1, int black);
++ short getTwoDimCode();
++ short getWhiteCode();
++ short getBlackCode();
+--- xpdf-3.02.orig/debian/patches/10_add_accelerators.dpatch
++++ xpdf-3.02/debian/patches/10_add_accelerators.dpatch
+@@ -0,0 +1,33 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 10_add_accelerators.dpatch by <hamish@noddy.cloud.net.au>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Add keyboard accelerators for rotate (#385962)
++
++@DPATCH@
++diff -urNad xpdf-3.02~/xpdf/XPDFViewer.cc xpdf-3.02/xpdf/XPDFViewer.cc
++--- xpdf-3.02~/xpdf/XPDFViewer.cc 2007-04-25 01:40:50.000000000 +1000
+++++ xpdf-3.02/xpdf/XPDFViewer.cc 2007-04-25 01:42:13.000000000 +1000
++@@ -1958,16 +1958,22 @@
++ n = 0;
++ s = XmStringCreateLocalized("Rotate counterclockwise");
++ XtSetArg(args[n], XmNlabelString, s); ++n;
+++ s2 = XmStringCreateLocalized("[");
+++ XtSetArg(args[n], XmNacceleratorText, s2); ++n;
++ btn = XmCreatePushButton(popupMenu, "rotateCCW", args, n);
++ XmStringFree(s);
+++ XmStringFree(s2);
++ XtManageChild(btn);
++ XtAddCallback(btn, XmNactivateCallback,
++ &rotateCCWCbk, (XtPointer)this);
++ n = 0;
++ s = XmStringCreateLocalized("Rotate clockwise");
++ XtSetArg(args[n], XmNlabelString, s); ++n;
+++ s2 = XmStringCreateLocalized("]");
+++ XtSetArg(args[n], XmNacceleratorText, s2); ++n;
++ btn = XmCreatePushButton(popupMenu, "rotateCW", args, n);
++ XmStringFree(s);
+++ XmStringFree(s2);
++ XtManageChild(btn);
++ XtAddCallback(btn, XmNactivateCallback,
++ &rotateCWCbk, (XtPointer)this);
+--- xpdf-3.02.orig/debian/patches/fix-CVE-2007-3387_CVE-2007-5049.dpatch
++++ xpdf-3.02/debian/patches/fix-CVE-2007-3387_CVE-2007-5049.dpatch
+@@ -0,0 +1,31 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## fix-CVE-2007-3387_CVE-2007-5049.dpatch by Nico Golde <nion@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: No description.
++
++@DPATCH@
++diff -urNad xpdf-3.02~/xpdf/Stream.cc xpdf-3.02/xpdf/Stream.cc
++--- xpdf-3.02~/xpdf/Stream.cc 2007-02-27 23:05:52.000000000 +0100
+++++ xpdf-3.02/xpdf/Stream.cc 2007-09-27 12:04:52.000000000 +0200
++@@ -410,15 +410,13 @@
++ ok = gFalse;
++
++ nVals = width * nComps;
++- if (width <= 0 || nComps <= 0 || nBits <= 0 ||
++- nComps >= INT_MAX / nBits ||
++- width >= INT_MAX / nComps / nBits ||
++- nVals * nBits + 7 < 0) {
++- return;
++- }
++ pixBytes = (nComps * nBits + 7) >> 3;
++ rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
++- if (rowBytes <= 0) {
+++ if (width <= 0 || nComps <= 0 || nBits <= 0 ||
+++ nComps > gfxColorMaxComps ||
+++ nBits > 16 ||
+++ width >= INT_MAX / nComps || // check for overflow in nVals
+++ nVals >= (INT_MAX - 7) / nBits) { // check for overflow in rowBytes
++ return;
++ }
++ predLine = (Guchar *)gmalloc(rowBytes);
+--- xpdf-3.02.orig/debian/patches/99_autoconf.dpatch
++++ xpdf-3.02/debian/patches/99_autoconf.dpatch
+@@ -0,0 +1,19 @@
++#! /bin/sh -e
++## DP: run aclocal and autoconf
++
++dpatch_patch ()
++{
++ tar cf debian/patched/autoconf.tar configure aclocal.m4
++ aclocal-1.9 -I .
++ autoconf
++}
++
++dpatch_unpatch ()
++{
++ tar xf debian/patched/autoconf.tar
++}
++
++DPATCH_LIB_NO_DEFAULT=1
++
++. /usr/share/dpatch/dpatch.lib.sh
++
+--- xpdf-3.02.orig/debian/patches/41_lesstif_cpp.dpatch
++++ xpdf-3.02/debian/patches/41_lesstif_cpp.dpatch
+@@ -0,0 +1,30 @@
++#! /bin/sh /usr/share/dpatch/dpatch-run
++## 41_lesstif_cpp.dpatch by <hamish@debian.org>
++##
++## All lines beginning with `## DP:' are a description of the patch.
++## DP: Work around mixed C/C++ linkages in lesstif - #377230
++
++@DPATCH@
++diff -urNad xpdf-3.01~/lesstif/Xm/VendorSP.h xpdf-3.01/lesstif/Xm/VendorSP.h
++--- xpdf-3.01~/lesstif/Xm/VendorSP.h 2006-05-28 08:30:56.000000000 +1000
+++++ xpdf-3.01/lesstif/Xm/VendorSP.h 2006-07-15 14:42:38.000000000 +1000
++@@ -30,10 +30,6 @@
++ #include <Xm/VendorS.h>
++ #include <X11/ShellP.h>
++
++-#ifdef __cplusplus
++-extern "C" {
++-#endif
++-
++ XMLIBEXPORT extern Cardinal _XmFilterResources(XtResource *resources,
++ Cardinal numResources,
++ WidgetClass filterClass,
++@@ -58,8 +54,5 @@
++ XMLIBEXPORT extern VendorShellClassRec vendorShellClassRec;
++
++
++-#ifdef __cplusplus
++-}
++-#endif
++
++ #endif /* _XM_VENDORSP_H */
+--- xpdf-3.02.orig/debian/zxpdf
++++ xpdf-3.02/debian/zxpdf
+@@ -0,0 +1,52 @@
++#!/bin/bash
++
++# Copyright (c) 2001 Alcove - http://www.alcove.com/
++# Please distribute under the terms of the GNU GPL, version 2
++
++# Author: Yann Dirson <yann.dirson@fr.alcove.com>
++# $Id: zxpdf,v 1.1 2001/09/28 10:23:35 ydirson Exp $
++
++set -e
++
++file=
++flags=
++title="zxpdf"
++while [ $# -gt 0 ]
++do
++ case "$1" in
++ -z|-g|-geometry|-remote|-rgb|-papercolor|-eucjp|-t1lib|-ps|-paperw|-paperh)
++ flags="$flags $1 $2"; shift ;;
++ -title) title="$2"; shift ;;
++ -*) flags="$flags $1" ;;
++ *.pdf|*.PDF) file="$1"; shift; pages="$@"; cat=; break ;;
++ *.gz|*.Z) file="$1"; shift; pages="$@"; cat=zcat; break ;;
++ *.bz2) file="$1"; shift; pages="$@"; cat=bzcat; break ;;
++ *) echo >&2 "ERROR: unknown suffix in file \`$1'"; exit 1 ;;
++ esac
++ shift
++done
++
++if [ $# -ge 1 ] # optional page argument
++then
++ echo >&2 "ERROR: Too many arguments"
++fi
++
++if [ x"$title" == x -a x"$tmp" != x ]
++then
++ title="zxpdf: $file"
++fi
++
++if [ -z "$cat" ]
++then
++ tmp="$file"
++else
++ tmp=$(basename "$file")
++ tmp=$(tempfile -p "${tmp%.pdf*}" -s .pdf)
++ $cat "$file" >"$tmp"
++fi
++
++if [ "$tmp" == "" ]; then
++ exec xpdf -title $title $flags
++else
++ exec xpdf -title $title $flags "$tmp" $pages
++fi
+--- xpdf-3.02.orig/debian/copyright
++++ xpdf-3.02/debian/copyright
+@@ -0,0 +1,42 @@
++
++This is Debian GNU/Linux's prepackaged version of the 'xpdf' viewer written
++by Derek B. Noonburg. This package was original built by
++Dirk Eddelbuettel <edd@qed.econ.queensu.ca> and since 1998 has been
++maintained by Hamish Moffatt <hamish@debian.org>. Current sources are found
++at
++ http://www.foolabs.com/xpdf
++
++
++The upstream author's email address is: derekn@foolabs.com
++
++Copyright:
++
++Xpdf is copyright 1996-2007 Derek B. Noonburg.
++
++Xpdf is licensed under the GNU General Public License (GPL), version
++2. In my opinion, the GPL is a convoluted, confusing, ambiguous mess.
++But it's also pervasive, and I'm sick of arguing. And even if it is
++confusing, the basic idea is good.
++
++In order to cut down on the confusion a little bit, here are some
++informal clarifications:
++
++- I don't mind if you redistribute xpdf in source and/or binary form,
++ as long as you include all of the documentation: README, man pages
++ (or help files), and COPYING. (Note that the README file contains a
++ pointer to a web page with the source code.)
++
++- Selling a CD-ROM that contains xpdf is fine with me, as long as it
++ includes the documentation. I wouldn't mind receiving a sample
++ copy, but it's not necessary.
++
++- If you make useful changes to xpdf, please make the source code
++ available -- post it on a web site, email it to me, whatever.
++
++For information on commercial licensing and consulting, please see the
++Glyph & Cog web site:
++
++ http://www.glyphandcog.com/
++
++The full text of the GPL can be found in /usr/share/common-licenses/GPL.
++
+--- xpdf-3.02.orig/debian/xpdf.xpm
++++ xpdf-3.02/debian/xpdf.xpm
+@@ -0,0 +1,177 @@
++/* XPM */
++static char *xpdf[] = {
++/* columns rows colors chars-per-pixel */
++"32 32 139 2",
++" c #003D000F000F",
++". c #0CE40CE00CE0",
++"X c #1E7600000000",
++"o c #138D13B413B4",
++"O c #19E816001600",
++"+ c #1B021CF31CF3",
++"@ c #26B900000000",
++"# c #2D20004E004E",
++"$ c #2DCD0F260F26",
++"% c #342B0C290C29",
++"& c #39F700000000",
++"* c #35BB16E016E0",
++"= c #3F3D10DC10DC",
++"- c #23C023C023C0",
++"; c #2DB72DF22DF2",
++": c #32B02C2C2C2C",
++"> c #331533153315",
++", c #3D4F3DAB3DAB",
++"< c #412900000000",
++"1 c #4E4400000000",
++"2 c #438A16751675",
++"3 c #552E00090009",
++"4 c #589D00000000",
++"5 c #553814381438",
++"6 c #466A40084008",
++"7 c #578D29C429C4",
++"8 c #63DD00000000",
++"9 c #706515B015B0",
++"0 c #708517F717F7",
++"q c #71D819011901",
++"w c #42B142B242B2",
++"e c #4AB94AB64AB6",
++"r c #5F30420C420C",
++"t c #52F852745274",
++"y c #553A59885988",
++"u c #5C0B535A535A",
++"i c #599959D559D5",
++"p c #618059D459D4",
++"a c #7FA2562B562B",
++"s c #63F465206520",
++"d c #699169916991",
++"f c #7B317B717B71",
++"g c #AE2F00880088",
++"h c #B26E00000000",
++"j c #B8C604F204F2",
++"k c #B90308810881",
++"l c #B13817391739",
++"z c #BFF611DD11DD",
++"x c #A7343C313C31",
++"c c #B6A136E436E4",
++"v c #B14F39523952",
++"b c #A7CA44514451",
++"n c #AC7B5BE65BE6",
++"m c #ABF678C378C3",
++"M c #C79F00000000",
++"N c #CD5500170017",
++"B c #C4B212E112E1",
++"V c #CED416B516B5",
++"C c #DD5300000000",
++"Z c #DCAC0C610C61",
++"A c #D83D139D139D",
++"S c #DCCB13C113C1",
++"D c #D90D194E194E",
++"F c #D87234623462",
++"G c #D84A3CFC3CFC",
++"H c #DED13D643D64",
++"J c #E229000B000B",
++"K c #E2CE09930993",
++"L c #E45115631563",
++"P c #E54D19161916",
++"I c #E2BC21232123",
++"U c #CE1D46944694",
++"Y c #CD8C53CB53CB",
++"T c #D70F42BB42BB",
++"R c #DA5454E754E7",
++"E c #D9295CAA5CAA",
++"W c #CAFD63A163A1",
++"Q c #C9846E7E6E7E",
++"! c #DEBA65C865C8",
++"~ c #DD2D7F957F95",
++"^ c #E4DA44214421",
++"/ c #E3A452AE52AE",
++"( c #ED3959C459C4",
++") c #E22F650D650D",
++"_ c #845284888488",
++"` c #86F188C288C2",
++"' c #8DE18DEE8DEE",
++"] c #935A941B941B",
++"[ c #9CE89CF49CF4",
++"{ c #A7A8850E850E",
++"} c #AA8084FC84FC",
++"| c #AFF888F088F0",
++" . c #B29381928192",
++".. c #B6EE8A448A44",
++"X. c #A3FDA3EBA3EB",
++"o. c #AB35AC0CAC0C",
++"O. c #B246B246B246",
++"+. c #B969B4DDB4DD",
++"@. c #BB90BB8FBB8F",
++"#. c #CD068F7A8F7A",
++"$. c #CDC0936A936A",
++"%. c #D20085B385B3",
++"&. c #D6699ED29ED2",
++"*. c #DC829C599C59",
++"=. c #CD42A62FA62F",
++"-. c #CE21ABF7ABF7",
++";. c #CD9AB2CBB2CB",
++":. c #CD0CC08AC08A",
++">. c #D8C2A77BA77B",
++",. c #EAE89F659F65",
++"<. c #EC71BE37BE37",
++"1. c #F4BBA0EAA0EA",
++"2. c #F5C9AB37AB37",
++"3. c #FB7DAD09AD09",
++"4. c #C526C505C505",
++"5. c #CD07CC65CC65",
++"6. c #D032D33DD33D",
++"7. c #D630C522C522",
++"8. c #DA43C538C538",
++"9. c #DFD0CAA7CAA7",
++"0. c #D260D3EFD3EF",
++"q. c #D4D9D990D990",
++"w. c #DB0BDBC3DBC3",
++"e. c #E08DE8F0E8F0",
++"r. c #E76CC6A0C6A0",
++"t. c #E78BD27BD27B",
++"y. c #EFD9D5B1D5B1",
++"u. c #EAC6DCDCDCDC",
++"i. c #E5DCE474E474",
++"p. c #E7BFEA2AEA2A",
++"a. c #ED83E7CCE7CC",
++"s. c #EBD0EBC8EBC8",
++"d. c #EE64F2ADF2AD",
++"f. c #F714E461E461",
++"g. c #F915E48FE48F",
++"h. c #FD3EEA64EA64",
++"j. c #F276F27AF27A",
++"k. c #FCA4F400F400",
++"l. c #FFF3FFF3FFF3",
++/* pixels */
++" ",
++" ",
++"< 1 1 3 3 & @ 1 1 @ ",
++"8 N J J J N 4 # g J h # ",
++" 4 N J J J N 4 O w w o o 6 b A h # ",
++" 4 N J C J N 4 , w.5.> O X.4.7.>.% ",
++" 4 N J J J N 4 O.O. ` y.F ! q.O ",
++" 4 N J J J N 4 - 0.o. # ;.2.h 2 , ",
++" 4 N J J J N 4 w s.] @ x p.| # ",
++" 4 N J J J N 4 w p.} g T p._ ",
++" 3 N J J J N 4 e d.%.C U s.f ",
++" . . 3 M J J J N 4 X i k.H g a s.> ",
++" ; @.f t n / D J J B 6 y u .h.l 7 ] j.d t . ",
++" > @.l.w.] s 6.*.K A #.8.W ! u.a.* ; [ d.d t ",
++" o _ 4.l.d d h.A Q e.R C A r.6.o . +.5.o ",
++" + _ j.e i s.0 &.<.A J A 8.4.. . 4.4.o ",
++" _ s.w i p.O o.3.C J S t.4.. o 5.@.. ",
++" ] s.w . ] 6.= -.2.C J P h.~ 4 O i.f ",
++" X.j.w w w...j ,.r.c N ^ k.( N 0 s.i ",
++" o.s.] ' o...z J c 4.5.$.=.f.1.K ) g.X.. ",
++" O 4.O.O + 2 k J g # o + + 5 V P K L D q ",
++" w s.] # g J h # 4 N J J C N 4 ",
++" w p._ @ h J g # 4 N J J J N 4 ",
++" e d.} g J h # 4 N J J J N 4 ",
++" i k.Y J g # 4 N J J J N 4 ",
++" s h.I g # 4 N J J J N 4 ",
++" $ +.s.m # 4 N J J J N 4 ",
++" # g T b : 4 N J J J N 4 ",
++" # h J g # 4 N J J J N < ",
++" @ 1 1 @ & 1 3 1 3 X ",
++" ",
++" "
++};
+--- xpdf-3.02.orig/debian/xpdf-wrapper
++++ xpdf-3.02/debian/xpdf-wrapper
+@@ -0,0 +1,5 @@
++#!/bin/bash
++LANG=C
++LC_ALL=C
++export LANG LC_ALL
++exec -a xpdf xpdf.bin "$@"
+--- xpdf-3.02.orig/debian/rules
++++ xpdf-3.02/debian/rules
+@@ -0,0 +1,110 @@
++#!/usr/bin/make -f
++# -*- makefile -*-
++# debian.rules file for the Debian GNU/Linux xpdf package
++# Copyright 1996,1997,1998 by Dirk Eddelbuettel <edd@debian.org>
++# Copyright 1998-2006 by Hamish Moffatt <hamish@debian.org>
++
++build: build-stamp
++build-stamp: patch
++ dh_testdir
++ #CC=gcc-4.0 CXX=g++-4.0 ./configure
++ ./configure \
++ --prefix=/usr \
++ --sysconfdir=/etc/xpdf \
++ --mandir=/usr/share/man \
++ --with-x \
++ --enable-freetype2 \
++ --enable-opi \
++ --enable-wordlist \
++ --enable-multithreaded \
++ --with-Xm-includes=$(shell pwd)/lesstif \
++ --with-freetype2-includes=/usr/include/freetype2 \
++ --with-t1-includes=/usr/include
++ $(MAKE)
++ touch build-stamp
++
++clean: clean1 unpatch
++clean1:
++ dh_testdir
++ -$(MAKE) -i distclean
++ rm -rf *~ debian/*~ debian/files* build-stamp aconf.h
++ rm -rf fofi/Makefile splash/Makefile
++ dh_clean
++
++binary-indep: # Nothing to build
++ dh_testdir
++ dh_installdirs -i
++ ln -sf xpdf-common debian/xpdf/usr/share/doc/xpdf
++
++ cp doc/xpdfrc.5 debian/xpdf-common/usr/share/man/man5
++ cp debian/xpdfrc debian/xpdf-common/usr/share/doc/xpdf-common/examples/sample-xpdfrc
++ cp debian/update-xpdfrc debian/xpdf-common/usr/sbin
++ chmod +x debian/xpdf-common/usr/sbin/update-xpdfrc
++ cp debian/xpdfrc debian/xpdf-common/etc/xpdf
++ cp debian/xpdf-bug-control debian/xpdf/usr/share/bug/xpdf/control
++
++ dh_installdocs -pxpdf-common README debian/README.Debian
++ dh_installchangelogs -pxpdf-common CHANGES
++ cp debian/update-xpdfrc.8 debian/xpdf-common/usr/share/man/man8
++
++ cp -a debian/lang/* debian/xpdf-common/
++
++ dh_compress -i
++ dh_fixperms -i
++ dh_installdeb -i
++ dh_shlibdeps -i
++ dh_gencontrol -i
++ dh_md5sums -i
++ dh_builddeb -i
++
++binary-arch: build
++ dh_testdir
++
++ dh_installdirs -a
++ mkdir -p debian/tmp
++ mkdir -p debian/tmp/usr/share
++ $(MAKE) install DESTDIR=`pwd`/debian/tmp
++
++ ln -sf xpdf-common debian/xpdf-reader/usr/share/doc/xpdf-reader
++ ln -sf xpdf-common debian/xpdf-utils/usr/share/doc/xpdf-utils
++
++ cp debian/zxpdf debian/xpdf-reader/usr/bin
++ chmod +x debian/xpdf-reader/usr/bin/zxpdf
++ ln -sf xpdf.1.gz debian/xpdf-reader/usr/share/man/man1/zxpdf.1.gz
++ ln -sf xpdf.1.gz debian/xpdf-reader/usr/share/man/man1/xpdf.bin.1.gz
++
++ cp debian/xpdf.xpm debian/xpdf-reader/usr/share/pixmaps
++
++ dh_installdocs -a
++ dh_movefiles -a
++ rm -rf debian/tmp
++
++ # rename xpdf binary and install wrapper script
++ mv debian/xpdf-reader/usr/bin/xpdf debian/xpdf-reader/usr/bin/xpdf.bin
++ cp debian/xpdf-wrapper debian/xpdf-reader/usr/bin/xpdf
++ chmod +x debian/xpdf-reader/usr/bin/xpdf
++ cp debian/xpdf.desktop debian/xpdf-reader/usr/share/applications/
++
++ dh_installmime -pxpdf-reader
++ dh_installmenu -pxpdf-reader
++ dh_strip -a
++ dh_desktop -a
++ dh_compress -a
++ dh_fixperms -a
++ dh_installdeb -a
++ dh_shlibdeps -a
++ dh_gencontrol -a
++ dh_md5sums -a
++ dh_builddeb -a
++
++patch: patch-stamp
++patch-stamp:
++ dpatch apply-all
++ #dpatch call-all -a=pkg-info >patch-stamp
++ touch patch-stamp
++
++unpatch:
++ dpatch deapply-all
++ rm -rf patch-stamp debian/patched
++
++binary: binary-indep binary-arch
diff --git a/source/xap/xpdf/xpdfrc.diff b/source/xap/xpdf/xpdfrc.diff
new file mode 100644
index 00000000..f005414e
--- /dev/null
+++ b/source/xap/xpdf/xpdfrc.diff
@@ -0,0 +1,43 @@
+--- ./doc/sample-xpdfrc.orig 2005-08-17 00:34:30.000000000 -0500
++++ ./doc/sample-xpdfrc 2007-02-17 21:26:12.000000000 -0600
+@@ -29,20 +29,20 @@
+ # installed in a "standard" location, xpdf will find them
+ # automatically.)
+
+-#displayFontT1 Times-Roman /usr/local/share/ghostscript/fonts/n021003l.pfb
+-#displayFontT1 Times-Italic /usr/local/share/ghostscript/fonts/n021023l.pfb
+-#displayFontT1 Times-Bold /usr/local/share/ghostscript/fonts/n021004l.pfb
+-#displayFontT1 Times-BoldItalic /usr/local/share/ghostscript/fonts/n021024l.pfb
+-#displayFontT1 Helvetica /usr/local/share/ghostscript/fonts/n019003l.pfb
+-#displayFontT1 Helvetica-Oblique /usr/local/share/ghostscript/fonts/n019023l.pfb
+-#displayFontT1 Helvetica-Bold /usr/local/share/ghostscript/fonts/n019004l.pfb
+-#displayFontT1 Helvetica-BoldOblique /usr/local/share/ghostscript/fonts/n019024l.pfb
+-#displayFontT1 Courier /usr/local/share/ghostscript/fonts/n022003l.pfb
+-#displayFontT1 Courier-Oblique /usr/local/share/ghostscript/fonts/n022023l.pfb
+-#displayFontT1 Courier-Bold /usr/local/share/ghostscript/fonts/n022004l.pfb
+-#displayFontT1 Courier-BoldOblique /usr/local/share/ghostscript/fonts/n022024l.pfb
+-#displayFontT1 Symbol /usr/local/share/ghostscript/fonts/s050000l.pfb
+-#displayFontT1 ZapfDingbats /usr/local/share/ghostscript/fonts/d050000l.pfb
++displayFontT1 Times-Roman /usr/share/ghostscript/fonts/n021003l.pfb
++displayFontT1 Times-Italic /usr/share/ghostscript/fonts/n021023l.pfb
++displayFontT1 Times-Bold /usr/share/ghostscript/fonts/n021004l.pfb
++displayFontT1 Times-BoldItalic /usr/share/ghostscript/fonts/n021024l.pfb
++displayFontT1 Helvetica /usr/share/ghostscript/fonts/n019003l.pfb
++displayFontT1 Helvetica-Oblique /usr/share/ghostscript/fonts/n019023l.pfb
++displayFontT1 Helvetica-Bold /usr/share/ghostscript/fonts/n019004l.pfb
++displayFontT1 Helvetica-BoldOblique /usr/share/ghostscript/fonts/n019024l.pfb
++displayFontT1 Courier /usr/share/ghostscript/fonts/n022003l.pfb
++displayFontT1 Courier-Oblique /usr/share/ghostscript/fonts/n022023l.pfb
++displayFontT1 Courier-Bold /usr/share/ghostscript/fonts/n022004l.pfb
++displayFontT1 Courier-BoldOblique /usr/share/ghostscript/fonts/n022024l.pfb
++displayFontT1 Symbol /usr/share/ghostscript/fonts/s050000l.pfb
++displayFontT1 ZapfDingbats /usr/share/ghostscript/fonts/d050000l.pfb
+
+ # If you need to display PDF files that refer to non-embedded fonts,
+ # you should add one or more fontDir options to point to the
+@@ -88,4 +88,4 @@
+ # Set the command used to run a web browser when a URL hyperlink is
+ # clicked.
+
+-#urlCommand "netscape -remote 'openURL(%s)'"
++#urlCommand "firefox -remote 'openURL(%s)'"
diff --git a/source/xap/xsane/slack-desc b/source/xap/xsane/slack-desc
new file mode 100644
index 00000000..330a2e56
--- /dev/null
+++ b/source/xap/xsane/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xsane: xsane (Graphical frontend to SANE, Scanner Access Now Easy)
+xsane:
+xsane: xsane provides a graphical user-interface to control an image
+xsane: acquisition device such as a flatbed scanner. It allows previewing
+xsane: and scanning individual images and can be invoked either directly
+xsane: from the command-line or through the GIMP image manipulation program.
+xsane:
+xsane: xsane accesses image acquisition devices through the SANE (Scanner
+xsane: Access Now Easy) interface.
+xsane:
+xsane:
diff --git a/source/xap/xsane/xsane.SlackBuild b/source/xap/xsane/xsane.SlackBuild
new file mode 100755
index 00000000..f8d73012
--- /dev/null
+++ b/source/xap/xsane/xsane.SlackBuild
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=0.996
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-1}
+
+NUMJOBS=${NUMJOBS:-" -j7 "}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xsane
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP
+rm -rf xsane-$VERSION
+tar xvf $CWD/xsane-$VERSION.tar.bz2 || exit 1
+cd xsane-$VERSION || exit 1
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --mandir=/usr/man \
+ --build=$ARCH-slackware-linux
+
+make $NUMJOBS || make || exit 1
+make install DESTDIR=$PKG
+
+rmdir $PKG/usr/sbin
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/usr/doc/xsane-$VERSION
+cp -a \
+ xsane.* \
+ $PKG/usr/doc/xsane-$VERSION
+rm -f $PKG/usr/doc/xsane-$VERSION/xsane.spec*
+( cd $PKG/usr/doc/xsane-$VERSION ; ln -s /usr/share/sane/xsane/doc html )
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.?
+ )
+ done
+ )
+fi
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xsane-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xscreensaver/setuid.c b/source/xap/xscreensaver/setuid.c
new file mode 100644
index 00000000..343dcf09
--- /dev/null
+++ b/source/xap/xscreensaver/setuid.c
@@ -0,0 +1,274 @@
+/* setuid.c --- management of runtime privileges.
+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <X11/Xlib.h> /* not used for much... */
+
+/* This file doesn't need the Xt headers, so stub these types out... */
+#undef XtPointer
+#define XtAppContext void*
+#define XrmDatabase void*
+#define XtIntervalId void*
+#define XtPointer void*
+#define Widget void*
+
+#include "xscreensaver.h"
+
+#ifndef EPERM
+#include <errno.h>
+#endif
+
+#include <pwd.h> /* for getpwnam() and struct passwd */
+#include <grp.h> /* for getgrgid() and struct group */
+
+static const char *
+uid_gid_string (uid_t uid, gid_t gid)
+{
+ static char buf[255];
+ struct passwd *p = 0;
+ struct group *g = 0;
+ p = getpwuid (uid);
+ g = getgrgid (gid);
+ sprintf (buf, "%s/%s (%ld/%ld)",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
+ return buf;
+}
+
+
+void
+describe_uids (saver_info *si, FILE *out)
+{
+ uid_t uid = getuid();
+ gid_t gid = getgid();
+ uid_t euid = geteuid();
+ gid_t egid = getegid();
+ char *s1 = strdup (uid_gid_string (uid, gid));
+ char *s2 = strdup (uid_gid_string (euid, egid));
+
+ if (si->orig_uid && *si->orig_uid &&
+ (!!strcmp (si->orig_uid, s1) ||
+ !!strcmp (si->orig_uid, s2)))
+ fprintf (out, "%s: initial effective uid/gid was %s\n", blurb(),
+ si->orig_uid);
+
+ fprintf (out, "%s: running as %s", blurb(), s1);
+ if (uid != euid || gid != egid)
+ fprintf (out, "; effectively %s", s2);
+ fprintf(out, "\n");
+ free(s1);
+ free(s2);
+}
+
+
+static int
+set_ids_by_number (uid_t uid, gid_t gid, char **message_ret)
+{
+ int uid_errno = 0;
+ int gid_errno = 0;
+ struct passwd *p = getpwuid (uid);
+ struct group *g = getgrgid (gid);
+
+ if (message_ret)
+ *message_ret = 0;
+
+ /* Rumor has it that some implementations of of setuid() do nothing
+ when called with -1; therefore, if the "nobody" user has a uid of
+ -1, then that would be Really Bad. Rumor further has it that such
+ systems really ought to be using -2 for "nobody", since that works.
+ So, if we get a uid (or gid, for good measure) of -1, switch to -2
+ instead. Note that this must be done after we've looked up the
+ user/group names with getpwuid(-1) and/or getgrgid(-1).
+ */
+ if (gid == (gid_t) -1) gid = (gid_t) -2;
+ if (uid == (uid_t) -1) uid = (uid_t) -2;
+
+ errno = 0;
+ if (setgid (gid) != 0)
+ gid_errno = errno ? errno : -1;
+
+ errno = 0;
+ if (setuid (uid) != 0)
+ uid_errno = errno ? errno : -1;
+
+ if (uid_errno == 0 && gid_errno == 0)
+ {
+ static char buf [1024];
+ sprintf (buf, "changed uid/gid to %s/%s (%ld/%ld).",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
+ if (message_ret)
+ *message_ret = buf;
+ return 0;
+ }
+ else
+ {
+ char buf [1024];
+ if (gid_errno)
+ {
+ sprintf (buf, "%s: couldn't set gid to %s (%ld)",
+ blurb(),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) gid);
+ if (gid_errno == -1)
+ fprintf(stderr, "%s: unknown error\n", buf);
+ else
+ perror(buf);
+ }
+
+ if (uid_errno)
+ {
+ sprintf (buf, "%s: couldn't set uid to %s (%ld)",
+ blurb(),
+ (p && p->pw_name ? p->pw_name : "???"),
+ (long) uid);
+ if (uid_errno == -1)
+ fprintf(stderr, "%s: unknown error\n", buf);
+ else
+ perror(buf);
+ }
+
+ return -1;
+ }
+}
+
+
+/* If we've been run as setuid or setgid to someone else (most likely root)
+ turn off the extra permissions so that random user-specified programs
+ don't get special privileges. (On some systems it is necessary to install
+ this program as setuid root in order to read the passwd file to implement
+ lock-mode.)
+
+ *** WARNING: DO NOT DISABLE ANY OF THE FOLLOWING CODE!
+ If you do so, you will open a security hole. See the sections
+ of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+ and "USING XDM".
+ */
+void
+hack_uid (saver_info *si)
+{
+
+ /* Discard privileges, and set the effective user/group ids to the
+ real user/group ids. That is, give up our "chmod +s" rights.
+ */
+ {
+ uid_t euid = geteuid();
+ gid_t egid = getegid();
+ uid_t uid = getuid();
+ gid_t gid = getgid();
+
+ si->orig_uid = strdup (uid_gid_string (euid, egid));
+
+ if (uid != euid || gid != egid)
+ if (set_ids_by_number (uid, gid, &si->uid_message) != 0)
+ saver_exit (si, 1, 0);
+ }
+
+
+ /* Locking can't work when running as root, because we have no way of
+ knowing what the user id of the logged in user is (so we don't know
+ whose password to prompt for.)
+
+ *** WARNING: DO NOT DISABLE THIS CODE!
+ If you do so, you will open a security hole. See the sections
+ of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+ and "USING XDM".
+ */
+ if (getuid() == (uid_t) 0)
+ {
+ si->locking_disabled_p = True;
+ si->nolock_reason = "running as root";
+ }
+
+
+ /* If we're running as root, switch to a safer user. This is above and
+ beyond the fact that we've disabling locking, above -- the theory is
+ that running graphics demos as root is just always a stupid thing
+ to do, since they have probably never been security reviewed and are
+ more likely to be buggy than just about any other kind of program.
+ (And that assumes non-malicious code. There are also attacks here.)
+
+ *** WARNING: DO NOT DISABLE THIS CODE!
+ If you do so, you will open a security hole. See the sections
+ of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+ and "USING XDM".
+ */
+ if (getuid() == (uid_t) 0)
+ {
+ struct passwd *p;
+
+ p = getpwnam ("nobody");
+ if (! p) p = getpwnam ("noaccess");
+ if (! p) p = getpwnam ("daemon");
+ if (! p)
+ {
+ fprintf (stderr,
+ "%s: running as root, and couldn't find a safer uid.\n",
+ blurb());
+ saver_exit(si, 1, 0);
+ }
+
+ if (set_ids_by_number (p->pw_uid, p->pw_gid, &si->uid_message) != 0)
+ saver_exit (si, -1, 0);
+ }
+
+
+ /* If there's anything even remotely funny looking about the passwd struct,
+ or if we're running as some other user from the list below (a
+ non-comprehensive selection of users known to be privileged in some way,
+ and not normal end-users) then disable locking. If it was possible,
+ switching to "nobody" would be the thing to do, but only root itself has
+ the privs to do that.
+
+ *** WARNING: DO NOT DISABLE THIS CODE!
+ If you do so, you will open a security hole. See the sections
+ of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+ and "USING XDM".
+ */
+ {
+ uid_t uid = getuid (); /* get it again */
+ struct passwd *p = getpwuid (uid); /* get it again */
+
+ if (!p ||
+ uid == (uid_t) 0 ||
+ uid == (uid_t) -1 ||
+ uid == (uid_t) -2 ||
+ p->pw_uid == (uid_t) 0 ||
+ p->pw_uid == (uid_t) -1 ||
+ p->pw_uid == (uid_t) -2 ||
+ !p->pw_name ||
+ !*p->pw_name ||
+ !strcmp (p->pw_name, "root") ||
+ !strcmp (p->pw_name, "nobody") ||
+ !strcmp (p->pw_name, "noaccess") ||
+ !strcmp (p->pw_name, "operator") ||
+ !strcmp (p->pw_name, "daemon") ||
+ !strcmp (p->pw_name, "bin") ||
+ !strcmp (p->pw_name, "adm") ||
+ !strcmp (p->pw_name, "sys") ||
+ !strcmp (p->pw_name, "games"))
+ {
+ static char buf [1024];
+ sprintf (buf, "running as %s",
+ (p && p->pw_name && *p->pw_name
+ ? p->pw_name : "<unknown>"));
+ si->nolock_reason = buf;
+ si->locking_disabled_p = True;
+ si->dangerous_uid_p = True;
+ }
+ }
+}
diff --git a/source/xap/xscreensaver/slack-desc b/source/xap/xscreensaver/slack-desc
new file mode 100644
index 00000000..85e2b909
--- /dev/null
+++ b/source/xap/xscreensaver/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xscreensaver: xscreensaver (a screen saver and locker for X)
+xscreensaver:
+xscreensaver: A modular screen saver and locker for the X Window System. Highly
+xscreensaver: customizable: allows the use of any program that can draw on the
+xscreensaver: root window as a display mode. More than 100 display modes are
+xscreensaver: included in this package.
+xscreensaver:
+xscreensaver:
+xscreensaver:
+xscreensaver:
+xscreensaver:
diff --git a/source/xap/xscreensaver/xscreensaver.SlackBuild b/source/xap/xscreensaver/xscreensaver.SlackBuild
new file mode 100755
index 00000000..4eb2fdfd
--- /dev/null
+++ b/source/xap/xscreensaver/xscreensaver.SlackBuild
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=5.08
+ARCH=${ARCH:-x86_64}
+NUMJOBS=${NUMJOBS:-" -j7 "}
+BUILD=${BUILD:-2}
+
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xscreensaver
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf xscreensaver-$VERSION
+tar xvf $CWD/xscreensaver-$VERSION.tar.?z* || exit 1
+cd xscreensaver-$VERSION
+
+# Allow xscreensaver to work setgid shadow. I'd rather avoid requiring
+# setuid root on this if at all possible...
+zcat $CWD/xscreensaver.setuid.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+
+# Add support for the electricsheep distributed screensaver:
+zcat $CWD/xscreensaver.electricsheep.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+xml_config=/usr/bin/xml-config xml2_config=/usr/bin/xml2-config \
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --with-x-app-defaults=/etc/X11/app-defaults \
+ --with-shadow \
+ --with-jpeg \
+ --with-gl \
+ --build=$ARCH-slackware-linux
+
+# We use '-i' because xscreensaver's NLS support has always been horribly broken
+make -i $NUMJOBS || make -i
+make -i install_prefix=$PKG install-strip
+
+gzip -9 $PKG/usr/man/man?/*
+
+chown root:shadow $PKG/usr/bin/xscreensaver
+chmod 2751 $PKG/usr/bin/xscreensaver
+
+# This is needed for the menus:
+mkdir -p $PKG/usr/share/pixmaps
+mkdir -p $PKG/etc
+mkdir -p $PKG/usr/doc/xscreensaver-$VERSION
+cp -a \
+ README* \
+ $PKG/usr/doc/xscreensaver-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xscreensaver-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xscreensaver/xscreensaver.electricsheep.diff b/source/xap/xscreensaver/xscreensaver.electricsheep.diff
new file mode 100644
index 00000000..27b11961
--- /dev/null
+++ b/source/xap/xscreensaver/xscreensaver.electricsheep.diff
@@ -0,0 +1,20 @@
+--- ./driver/XScreenSaver_ad.h.orig 2008-12-28 01:59:19.000000000 -0600
++++ ./driver/XScreenSaver_ad.h 2009-05-15 16:22:44.000000000 -0500
+@@ -138,6 +138,7 @@
+ squiral -root \\n\
+ wander -root \\n\
+ - webcollage -root \\n\
++ electricsheep --root 1 \\n\
+ xflame -root \\n\
+ xmatrix -root \\n\
+ GL: gflux -root \\n\
+--- ./driver/XScreenSaver.ad.in.orig 2008-12-28 01:33:15.000000000 -0600
++++ ./driver/XScreenSaver.ad.in 2009-05-15 16:22:04.000000000 -0500
+@@ -239,6 +239,7 @@
+ squiral -root \n\
+ wander -root \n\
+ - webcollage -root \n\
++ electricsheep --root 1 \n\
+ xflame -root \n\
+ xmatrix -root \n\
+ @GL_KLUDGE@ GL: gflux -root \n\
diff --git a/source/xap/xscreensaver/xscreensaver.setuid.diff b/source/xap/xscreensaver/xscreensaver.setuid.diff
new file mode 100644
index 00000000..c6810af5
--- /dev/null
+++ b/source/xap/xscreensaver/xscreensaver.setuid.diff
@@ -0,0 +1,179 @@
+--- ./driver/setuid.c.orig 2006-02-08 20:28:38.000000000 -0600
++++ ./driver/setuid.c 2006-04-04 16:48:08.000000000 -0500
+@@ -1,5 +1,5 @@
+ /* setuid.c --- management of runtime privileges.
+- * xscreensaver, Copyright (c) 1993-1998, 2005 Jamie Zawinski <jwz@jwz.org>
++ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+@@ -41,7 +41,7 @@
+ struct group *g = 0;
+ p = getpwuid (uid);
+ g = getgrgid (gid);
+- sprintf (buf, "%.100s/%.100s (%ld/%ld)",
++ sprintf (buf, "%s/%s (%ld/%ld)",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
+@@ -74,50 +74,11 @@
+ }
+
+
+-/* Returns true if we need to call setgroups().
+-
+- Without calling setgroups(), the process will retain any supplementary
+- gids associated with the uid, e.g.:
+-
+- % groups root
+- root : root bin daemon sys adm disk wheel
+-
+- However, setgroups() can only be called by root, and returns EPERM
+- for other users even if the call would be a no-op (e.g., setting the
+- group list to the current list.) So, to avoid that spurious error,
+- before calling setgroups() we first check whether the current list
+- of groups contains only one element, our target group. If so, we
+- don't need to call setgroups().
+- */
+-static int
+-setgroups_needed_p (uid_t target_group)
+-{
+- gid_t groups[1024];
+- int n, size;
+- size = sizeof(groups) / sizeof(gid_t);
+- n = getgroups (size - 1, groups);
+- if (n < 0)
+- {
+- char buf [1024];
+- sprintf (buf, "%s: getgroups(%ld, ...)", blurb(), (long int)(size - 1));
+- perror (buf);
+- return 1;
+- }
+- else if (n == 0) /* an empty list means only egid is in effect. */
+- return 0;
+- else if (n == 1 && groups[0] == target_group) /* one element, the target */
+- return 0;
+- else /* more than one, or the wrong one. */
+- return 1;
+-}
+-
+-
+ static int
+ set_ids_by_number (uid_t uid, gid_t gid, char **message_ret)
+ {
+ int uid_errno = 0;
+ int gid_errno = 0;
+- int sgs_errno = 0;
+ struct passwd *p = getpwuid (uid);
+ struct group *g = getgrgid (gid);
+
+@@ -136,11 +97,6 @@
+ if (uid == (uid_t) -1) uid = (uid_t) -2;
+
+ errno = 0;
+- if (setgroups_needed_p (gid) &&
+- setgroups (1, &gid) < 0)
+- sgs_errno = errno ? errno : -1;
+-
+- errno = 0;
+ if (setgid (gid) != 0)
+ gid_errno = errno ? errno : -1;
+
+@@ -148,10 +104,10 @@
+ if (setuid (uid) != 0)
+ uid_errno = errno ? errno : -1;
+
+- if (uid_errno == 0 && gid_errno == 0 && sgs_errno == 0)
++ if (uid_errno == 0 && gid_errno == 0)
+ {
+ static char buf [1024];
+- sprintf (buf, "changed uid/gid to %.100s/%.100s (%ld/%ld).",
++ sprintf (buf, "changed uid/gid to %s/%s (%ld/%ld).",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
+@@ -162,71 +118,28 @@
+ else
+ {
+ char buf [1024];
+- gid_t groups[1024];
+- int n, size;
+-
+- if (sgs_errno)
+- {
+- sprintf (buf, "%s: couldn't setgroups to %.100s (%ld)",
+- blurb(),
+- (g && g->gr_name ? g->gr_name : "???"),
+- (long) gid);
+- if (sgs_errno == -1)
+- fprintf(stderr, "%s: unknown error\n", buf);
+- else
+- {
+- errno = sgs_errno;
+- perror(buf);
+- }
+-
+- fprintf (stderr, "%s: effective group list: ", blurb());
+- size = sizeof(groups) / sizeof(gid_t);
+- n = getgroups (size - 1, groups);
+- if (n < 0)
+- fprintf (stderr, "unknown!\n");
+- else
+- {
+- int i;
+- fprintf (stderr, "[");
+- for (i = 0; i < n; i++)
+- {
+- g = getgrgid (groups[i]);
+- if (i > 0) fprintf (stderr, ", ");
+- if (g && g->gr_name) fprintf (stderr, "%s", g->gr_name);
+- else fprintf (stderr, "%ld", (long) groups[i]);
+- }
+- fprintf (stderr, "]\n");
+- }
+- }
+-
+ if (gid_errno)
+ {
+- sprintf (buf, "%s: couldn't set gid to %.100s (%ld)",
++ sprintf (buf, "%s: couldn't set gid to %s (%ld)",
+ blurb(),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) gid);
+ if (gid_errno == -1)
+ fprintf(stderr, "%s: unknown error\n", buf);
+ else
+- {
+- errno = gid_errno;
+- perror(buf);
+- }
++ perror(buf);
+ }
+
+ if (uid_errno)
+ {
+- sprintf (buf, "%s: couldn't set uid to %.100s (%ld)",
++ sprintf (buf, "%s: couldn't set uid to %s (%ld)",
+ blurb(),
+ (p && p->pw_name ? p->pw_name : "???"),
+ (long) uid);
+ if (uid_errno == -1)
+ fprintf(stderr, "%s: unknown error\n", buf);
+ else
+- {
+- errno = uid_errno;
+- perror(buf);
+- }
++ perror(buf);
+ }
+
+ return -1;
+@@ -350,7 +263,7 @@
+ !strcmp (p->pw_name, "games"))
+ {
+ static char buf [1024];
+- sprintf (buf, "running as %.100s",
++ sprintf (buf, "running as %s",
+ (p && p->pw_name && *p->pw_name
+ ? p->pw_name : "<unknown>"));
+ si->nolock_reason = buf;
diff --git a/source/xap/xv/slack-desc b/source/xap/xv/slack-desc
new file mode 100644
index 00000000..2fc48166
--- /dev/null
+++ b/source/xap/xv/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xv: xv (John Bradley's interactive image viewer)
+xv:
+xv: xv is an interactive image manipulation program.
+xv:
+xv: NOTICE: This program is unregistered shareware. Please read the
+xv: license information included.
+xv:
+xv:
+xv:
+xv:
+xv:
diff --git a/source/xap/xv/xv-3.10a-jumbo-README.txt b/source/xap/xv/xv-3.10a-jumbo-README.txt
new file mode 100644
index 00000000..63627ddf
--- /dev/null
+++ b/source/xap/xv/xv-3.10a-jumbo-README.txt
@@ -0,0 +1,442 @@
+These are the latest versions 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 two 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, plus quite a few from other people--though not all of the
+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.)
+
+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/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.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 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.
+
+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)
+ 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)
+ GRR = Greg Roelofs (http://pobox.com/~newt/)
+ 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/)
+ KS = Kyoichiro Suda (http://www.coara.or.jp/~sudakyo/XV_jp.html)
+ 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)
+ TA = Tim Adye (http://hepwww.rl.ac.uk/Adye/xv-psnewstyle.html)
+ 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
+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 20050501
+
+
+How to build
+------------
+
+The following assumes you, the user, already have the libtiff,[1]
+libjpeg,[2] libpng,[3] and zlib[4] libraries downloaded, patched (if
+necessary), compiled, and installed, not to mention a C compiler and
+the bzip2,[5] tar,[6] patch,[7] and make[8] utilities. You should also
+have downloaded the original XV 3.10a source distribution from the XV
+Downloads page[9] and be able to edit its Makefile and config.h files
+as indicated in the INSTALL file. 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://sources.redhat.com/bzip2/
+ [6] http://www.gnu.org/directory/devel/specific/tar.html
+ [7] http://www.gnu.org/directory/devel/specific/patch.html
+ [8] http://www.gnu.org/directory/devel/specific/make.html
+ [9] http://www.trilon.com/xv/downloads.html#src-distrib
+
++-------------------------------------------------------------------------+
+| |
+| BIG SCARY WARNING |
+| |
+| These patches work for Greg (and parts of them apparently 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 that |
+| 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:
+
+ 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
+
+ cd xv-3.10a
+
+ patch -p1 < ../xv-3.10a-jumbo-fix-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)
+
+ 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
+
+That wasn't so hard, was it?
+
+
+Summary of incorporated and unincorporated 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)
+ - 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)
+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"
+ detection/conversion; MacBinary prefixes; archives as virtual filesystems;
+ multilingual text viewer [though not Unicode]; etc.)
+ - xv-3.10a-yaos.dif (WF, TO) [*SECURITY*]
+ (fixes a number of format-string issues and system() calls)
+ - xv-3.10a.dif (WF) [*SECURITY*]
+ (fixes more format-string issues, mktemp() and open() calls, and compilation
+ warnings [mostly from jp-extension patch])
+ - xv-3.10a-jumbo-jpd_startgrab-patch-20050420.txt (JPD)
+ - PATCH.alwaysnever (LJ)
+ - PATCH.bsd (LJ)
+ - PATCH.linedraw (LJ)
+ - PATCH.multipage (LJ)
+ - PATCH.multipageGIF (LJ)
+ - PATCH.random (LJ)
+ - PATCH.stat (LJ)
+ - PATCH.thumbs (LJ)
+ - xv-startgrab-imake-hips.patch (JPD)
+ ("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)
+ - xv-3.10a-printkey.patch (KS)
+ - xv-3.10a-sysconfdir.patch (KS)
+ - added PREFIX and DESTDIR support to Makefile (KS, GRR)
+ - 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
+ 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:
+
+ - 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-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?]
+
+ - 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)
+ - fix for spacebar-for-next-image getting stuck at first text file
+ - 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
+---------
+
+ 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
+ (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
+ additional *SECURITY* issues (format-string vulnerabilities, system()
+ and mktemp() calls, etc., but NOT heap overflows in new decoders) both
+ in existing code and in jp-extension additions (enh)
+
+ 20050425
+ added support for -startgrab option (enh); added support for a "Never"
+ button to file-overwrite popups (enh); added NetBSD and BSDI to list of
+ mkstemp()-supporting systems (enh); improved line-drawing code to set the
+ correct pixels for lines of all slopes (enh); added "Page n of m" to Info
+ window for multipage images (enh); added support for multipage (animated)
+ GIFs (enh); fixed -random support so randomized file list can be traversed
+ normally in forward or backward direction (enh); added typecasts to stat()
+ printfs for portability (enh); fixed erroneous use of "creation" time and
+ forced unlink prior to overwrite in schnauzer thumbnail code (enh); added
+ HIPS support (enh/HAVE_HIPS option)
+
+ 20050501
+ extended multipage keyboard support (PgUp/PgDn) to all windows except
+ control ("console") and directory (enh); fixed minor (non-security)
+ format-string issue in xv.c (enh); shortened delay on popup error windows
+ from 3 seconds to 1 second (enh); tweaked text-viewer localization support
+ (TV_L10N) for Linux (enh); added keyboard short cuts for Color and
+ Grayscale buttons in print dialog (enh); added support for separate "magic
+ 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 --git a/source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt b/source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt
new file mode 100644
index 00000000..d78b601a
--- /dev/null
+++ b/source/xap/xv/xv-3.10a-jumbo-enh-patch-20050501.txt
@@ -0,0 +1,28167 @@
+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>
++ - 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>
++ - 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>
++ - 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>
++ - 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>
++ - 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)
++ 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)
++ EK = Egmont Koblinger (egmont users.sourceforge.net)
+ GRR = Greg Roelofs (http://pobox.com/~newt/)
+ 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/)
++ KS = Kyoichiro Suda (http://www.coara.or.jp/~sudakyo/XV_jp.html)
+ 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)
++ SJT = TenThumbs (tenthumbs cybernex.net)
+ TA = Tim Adye (http://hepwww.rl.ac.uk/Adye/xv-psnewstyle.html)
++ 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]
++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)
++ - 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)
++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"
++ detection/conversion; MacBinary prefixes; archives as virtual filesystems;
++ multilingual text viewer [though not Unicode]; etc.)
++ - xv-3.10a-yaos.dif (WF, TO) [*SECURITY*]
++ (fixes a number of format-string issues and system() calls)
++ - xv-3.10a.dif (WF) [*SECURITY*]
++ (fixes more format-string issues, mktemp() and open() calls, and compilation
++ warnings [mostly from jp-extension patch])
++ - xv-3.10a-jumbo-jpd_startgrab-patch-20050420.txt (JPD)
++ - PATCH.alwaysnever (LJ)
++ - PATCH.bsd (LJ)
++ - PATCH.linedraw (LJ)
++ - PATCH.multipage (LJ)
++ - PATCH.multipageGIF (LJ)
++ - PATCH.random (LJ)
++ - PATCH.stat (LJ)
++ - PATCH.thumbs (LJ)
++ - xv-startgrab-imake-hips.patch (JPD)
++ ("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)
++ - xv-3.10a-printkey.patch (KS)
++ - xv-3.10a-sysconfdir.patch (KS)
++ - added PREFIX and DESTDIR support to Makefile (KS, GRR)
++ - 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
++ 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 [??]
++ - 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)
++ - (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
++ - 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);
++ (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)
++
++ 20050417
++ incorporated "Japanese extension" patches, revision 5.3.3 (enh); fixed
++ additional *SECURITY* issues (format-string vulnerabilities, system()
++ and mktemp() calls, etc., but NOT heap overflows in new decoders) both
++ in existing code and in jp-extension additions (enh)
++
++ 20050425
++ added support for -startgrab option (enh); added support for a "Never"
++ button to file-overwrite popups (enh); added NetBSD and BSDI to list of
++ mkstemp()-supporting systems (enh); improved line-drawing code to set the
++ correct pixels for lines of all slopes (enh); added "Page n of m" to Info
++ window for multipage images (enh); added support for multipage (animated)
++ GIFs (enh); fixed -random support so randomized file list can be traversed
++ normally in forward or backward direction (enh); added typecasts to stat()
++ printfs for portability (enh); fixed erroneous use of "creation" time and
++ forced unlink prior to overwrite in schnauzer thumbnail code (enh); added
++ HIPS support (enh/HAVE_HIPS option)
++
++ 20050501
++ extended multipage keyboard support (PgUp/PgDn) to all windows except
++ control ("console") and directory (enh); fixed minor (non-security)
++ format-string issue in xv.c (enh); shortened delay on popup error windows
++ from 3 seconds to 1 second (enh); tweaked text-viewer localization support
++ (TV_L10N) for Linux (enh); added keyboard short cuts for Color and
++ Grayscale buttons in print dialog (enh); added support for separate "magic
++ 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
+@@ -0,0 +1,159 @@
++Copyright 1993-2001 David Clunie.
++
++PCD patch for XV 3.10a Release Notes 2001/07/08.
++
++See also the progress notes at the end of this file. Thanks to all those
++contributors who have substantially improved this patch.
++
++These patches allow xv to read Kodak photocd files and choose which of the
++5 available resolutions one wants to view.
++
++When a photocd file is loaded, a dialog box asks which resolution you
++would like. The visual schnauzer builds thumbnails by reading the lowest
++resolution image. The selected resolution can be selected from the
++command line with the -pcd option:
++
++ [-pcd 0|1|2|3|4]
++
++where:
++
++ 0=192*128, base/16 resolution
++ 1=384*256, base/4 resolution
++ 2=768*512, base resolution
++ 3=1536*1024, 4base resolution
++ 4=3072*2048 16base resolution.
++
++Note that the Pro format is not supported.
++
++The command line option allows loops without the dialog box popping up, eg.:
++
++ xv -pcd 1 -wloop -wait 10 *.pcd
++
++The code is pretty crude and was written quickly for a specific purpose and
++has not really been cleaned up. It is poorly structured, full of debugging
++codes and verbose comments, and there is very little attempt at optimizing
++things. No profiling has been done.
++
++There is not yet support for overview files, nor is there a facility to
++use the higher resolution chroma planes from when viewing lower resolution
++images.
++
++It's only claim to fame is that it works and produces reasonable looking
++images.
++
++The outline of this is shamelessly derived from xvpbm.c to read the
++file, and xvtiffwr.c to handle the popup window and X stuff (X never
++has been my forte !), and the PhotoCD format information (though not
++the code) was found in Hadmut Danisch's (danisch@ira.uka.de) hpcdtoppm
++program in which he has reverse engineered the format by studying
++hex dumps of PhotoCDs ! The color stuff and Huffman decding were
++extensively revised by Matthew Francey.
++
++Feel free to send me comments or improvements, or even better, more
++information about the photo CD format ... hopefully someone who really
++knows what they are doing will tidy it up or do a neater job.
++
++david (dclunie@dclunie.com)
++
++---------
++
++The trace #define in xvpcd.c is now in the right place, and the ansi
++prototype for the magnify function has been fixed. Colin made me switch to
++xvbcopy() which seems like a good idea for System V victims.
++
++---------
++
++Date: Wed, 22 Dec 1993 16:09:52 --1000
++From: colinc@fitmail.fit.qut.edu.au (Colin Canfield )
++
++I have done some more work using your patch I thought you might be intested in.
++The major change was adding a size parameter to the LoadPCD; either -1 to mean
++the popup or else the size you desired. This allows batch mode processing,
++specifically xv -pcd <size> <filename>, and the visual schnauzer can work in
++quick mode (ie. you don't have to select each image size when it is building
++the icons)
++
++I have added an xbm file for the file type but haven't drawn an icon for it,
++this is in bitmaps/br_pcd.xbm. I will just send you the new files.
++
++---------
++
++From: andrew@andrew.triumf.ca (Andrew Daviel)
++Date: 16 Feb 1995 23:32:21 GMT
++
++This is David Clunie's patch for xv-3.00 tuned a bit to work
++on xv-3.10. The code's all the same except for replacing
++"trace" with "fprintf" in xvpcd.c and adding an "unsigned" qualifier to
++keep my compiler (gcc) happy. Oh yes, changed RFT_PCD to 20 as
++John Bradley has now used 15 through 19.
++
++---------
++
++From: dclunie@flash.us.com (David A. Clunie)
++Date: Thu Jun 15 14:43:46 GMT+0300 1995
++
++Andrew's patch didn't include Colin's browser changes, so I redid the
++xv-3.10 update from scratch ... it seems pretty much the same as
++Andrew's changes. I also edited the Imakefile and Makefiles in order
++to support the PCD changes, as well as make the install process a
++little more flexible, with options to strip and set modes and so on.
++Also made RFT_PCD 25 so as not to conflict with magpic patch from Japan
++by Ikemoto Masahiro <ikeyan@airlab.cs.ritsumei.ac.jp>, and used his
++bitmap icon for pcd files.
++
++Now there are two versions of the patch, one which should be applied
++to the xv-3.10 distribution.
++
++The other should be applied to xv-3.10 AFTER Ikemoto Masahiro's
++Patch.magpic2.PhotoCD.XV319a, in order to add the browser features to
++the latter, as well as fixing a Makefile typo (was xcpcd.c not xvpcd.c)
++and including unistd.h for the SEEK_xxx constants in the magicpic
++stuff.
++
++---------
++
++Subject: Re: photo-cd patch for xv
++From: Matthew Francey <mdf@angoss.com>
++Date: Mon, 26 Mar 2001 15:37:55 +0000
++
++Attached is a revised version of xvpcd.c; the areas that I have
++re-written or changed are in a different coding style so you can tell
++what has changed. The GNU 'indent' program can be run against the file
++to enforce a consistent style ..
++
++Here is what I've done though:
++
++a) huffman table reader re-written, because it would fail on some
++ photocd files with "unusual" huffman codes.
++
++b) the huffman-coded corrections are now properly applied
++
++c) the corrections can sometimes over or underflow; clipping has been
++ introduced and effectively fixes the problem, but I suspect that
++ there is something deeper going on.
++
++d) the "official" YCC->sRGB transform is done. a "beyond 100% white"
++ mapping table was snarfed from ImageMagick. an option for using a
++ flat linear LUT was added -- this can make somewhat over-exposed images
++ look alot nicer.
++
++e) there were strange problems where the code wouldn't be able to find
++ the huffman tables and data for the 16base image (the bit-buffering
++ code was starting mid-sector, instead of at a sector boundary). Looking
++ at a pcd file with a hex editor suggests to me that it is possible to
++ just skip directly to these huffman tables -- no special "+12" and such
++ constants necessary. But I haven't tried this yet.
++
++The results: I've been able to read about 50 or 60 .pcd files [scattered
++in age from 6 years old to scans done last week] with this code without
++incident. Image quality at the high resolution is excellent. Even the
++trivial amount of LUT control is useful when dealing with over-exposed
++images.
++
++If I get around to it: finer LUT control to take advantage of the
++slightly extended dynamic range of PhotoCD scans, especially in regards to
++dark or somewhat underexposed scenes.
++
++
++
++
+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
+@@ -0,0 +1,27 @@
++#define br_bzip2_width 48
++#define br_bzip2_height 48
++static unsigned char br_bzip2_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, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x7c, 0xbe, 0x3d, 0x0e, 0x02, 0x20, 0xfc, 0xbe, 0x7d, 0x1f, 0x02,
++ 0x20, 0xcc, 0xb0, 0x6d, 0x1b, 0x02, 0x20, 0xcc, 0x98, 0x6d, 0x1b, 0x02,
++ 0x20, 0xfc, 0x98, 0x6d, 0x18, 0x02, 0x20, 0x7c, 0x8c, 0x7d, 0x0c, 0x02,
++ 0x20, 0xcc, 0x8c, 0x3d, 0x0e, 0x02, 0x20, 0xcc, 0x84, 0x0d, 0x06, 0x02,
++ 0x20, 0xcc, 0x86, 0x0d, 0x03, 0x02, 0x20, 0xfc, 0xbe, 0x0d, 0x1f, 0x02,
++ 0x20, 0x7c, 0xbe, 0x0d, 0x1f, 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, 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 -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
+@@ -0,0 +1,27 @@
++#define br_mag_width 48
++#define br_mag_height 48
++static unsigned char br_mag_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, 0x0c, 0x86, 0xc1, 0x0f, 0x02,
++ 0x20, 0x0c, 0xc6, 0xe3, 0x1f, 0x02, 0x20, 0x1c, 0xe7, 0x67, 0x18, 0x02,
++ 0x20, 0x1c, 0x77, 0x6e, 0x18, 0x02, 0x20, 0xbc, 0x37, 0x6c, 0x00, 0x02,
++ 0x20, 0xbc, 0x37, 0x6c, 0x00, 0x02, 0x20, 0xec, 0x36, 0x6c, 0x1e, 0x02,
++ 0x20, 0xec, 0xf6, 0x6f, 0x1e, 0x02, 0x20, 0x4c, 0xf6, 0x6f, 0x18, 0x02,
++ 0x20, 0x4c, 0x36, 0x6c, 0x18, 0x02, 0x20, 0x0c, 0x36, 0x6c, 0x18, 0x02,
++ 0x20, 0x0c, 0x36, 0xec, 0x1f, 0x02, 0x20, 0x0c, 0x36, 0xcc, 0x0f, 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 -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
+@@ -0,0 +1,27 @@
++#define br_maki_width 48
++#define br_maki_height 48
++static unsigned char br_maki_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, 0x83, 0x61, 0x18, 0x33, 0x02,
++ 0x20, 0x83, 0xf1, 0x98, 0x33, 0x02, 0x20, 0xc7, 0xf9, 0x99, 0x31, 0x02,
++ 0x20, 0xc7, 0x9d, 0xdb, 0x30, 0x02, 0x20, 0xef, 0x0d, 0xfb, 0x30, 0x02,
++ 0x20, 0xef, 0x0d, 0x7b, 0x30, 0x02, 0x20, 0xbb, 0x0d, 0x7b, 0x30, 0x02,
++ 0x20, 0xbb, 0xfd, 0xdb, 0x30, 0x02, 0x20, 0x93, 0xfd, 0xdb, 0x30, 0x02,
++ 0x20, 0x93, 0x0d, 0x9b, 0x31, 0x02, 0x20, 0x83, 0x0d, 0x9b, 0x31, 0x02,
++ 0x20, 0x83, 0x0d, 0x1b, 0x33, 0x02, 0x20, 0x83, 0x0d, 0x1b, 0x33, 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 -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
+@@ -0,0 +1,27 @@
++#define br_mgcsfx_width 48
++#define br_mgcsfx_height 48
++static unsigned char br_mgcsfx_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, 0x3c, 0xcf, 0x71, 0x00, 0x02,
++ 0x20, 0x6c, 0x61, 0xda, 0x00, 0x02, 0x20, 0x6c, 0x67, 0xd8, 0x1e, 0x02,
++ 0x20, 0x3c, 0x61, 0xd8, 0x1e, 0x02, 0x20, 0x6c, 0x61, 0xda, 0x00, 0x02,
++ 0x20, 0x6c, 0xcf, 0x71, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x4e, 0x7a, 0xef, 0x3d, 0x02, 0x20, 0xd3, 0x32, 0x68, 0x6c, 0x02,
++ 0x20, 0xc3, 0x32, 0xe4, 0x6c, 0x02, 0x20, 0x5b, 0x33, 0x62, 0x6c, 0x02,
++ 0x20, 0x53, 0x33, 0x61, 0x6c, 0x02, 0x20, 0x4e, 0x7a, 0xef, 0x3d, 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 -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
+@@ -0,0 +1,27 @@
++#define br_pcd_width 48
++#define br_pcd_height 48
++static unsigned char br_pcd_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, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x67, 0x00, 0xe0, 0x1c, 0x02,
++ 0x20, 0x6f, 0x00, 0xf0, 0x3d, 0x02, 0x20, 0x6b, 0x00, 0xb0, 0x2d, 0x02,
++ 0x20, 0x6b, 0x00, 0x33, 0x2c, 0x02, 0x20, 0x6b, 0x00, 0x33, 0x2c, 0x02,
++ 0x20, 0xeb, 0x98, 0x37, 0x2c, 0x02, 0x20, 0xef, 0xbd, 0x37, 0x2c, 0x02,
++ 0x20, 0x67, 0x2d, 0x33, 0x2c, 0x02, 0x20, 0x63, 0x2d, 0x33, 0x2c, 0x02,
++ 0x20, 0x63, 0x2d, 0x33, 0x2c, 0x02, 0x20, 0x63, 0x2d, 0xb3, 0x2d, 0x02,
++ 0x20, 0x63, 0x3d, 0xf7, 0x3d, 0x02, 0x20, 0x63, 0x19, 0xe6, 0x1c, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 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 -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
+@@ -0,0 +1,27 @@
++#define br_pi_width 48
++#define br_pi_height 48
++static unsigned char br_pi_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, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x80, 0x1f, 0x7e, 0x00, 0x02,
++ 0x20, 0x80, 0x3f, 0x7e, 0x00, 0x02, 0x20, 0x80, 0x31, 0x18, 0x00, 0x02,
++ 0x20, 0x80, 0x31, 0x18, 0x00, 0x02, 0x20, 0x80, 0x31, 0x18, 0x00, 0x02,
++ 0x20, 0x80, 0x39, 0x18, 0x00, 0x02, 0x20, 0x80, 0x1f, 0x18, 0x00, 0x02,
++ 0x20, 0x80, 0x0f, 0x18, 0x00, 0x02, 0x20, 0x80, 0x01, 0x18, 0x00, 0x02,
++ 0x20, 0x80, 0x01, 0x18, 0x00, 0x02, 0x20, 0x80, 0x01, 0x18, 0x00, 0x02,
++ 0x20, 0x80, 0x01, 0x7e, 0x00, 0x02, 0x20, 0x80, 0x01, 0x7e, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 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 -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
+@@ -0,0 +1,27 @@
++#define br_pic_width 48
++#define br_pic_height 48
++static unsigned char br_pic_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, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xf0, 0xf3, 0xf3, 0x01, 0x02,
++ 0x20, 0xf0, 0xf7, 0xfb, 0x03, 0x02, 0x20, 0x30, 0xc6, 0x18, 0x03, 0x02,
++ 0x20, 0x30, 0xc6, 0x18, 0x00, 0x02, 0x20, 0x30, 0xc6, 0x18, 0x00, 0x02,
++ 0x20, 0x30, 0xc7, 0x18, 0x00, 0x02, 0x20, 0xf0, 0xc3, 0x18, 0x00, 0x02,
++ 0x20, 0xf0, 0xc1, 0x18, 0x00, 0x02, 0x20, 0x30, 0xc0, 0x18, 0x00, 0x02,
++ 0x20, 0x30, 0xc0, 0x18, 0x00, 0x02, 0x20, 0x30, 0xc0, 0x18, 0x03, 0x02,
++ 0x20, 0x30, 0xf0, 0xfb, 0x03, 0x02, 0x20, 0x30, 0xf0, 0xf3, 0x01, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 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 -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
+@@ -0,0 +1,27 @@
++#define br_pic2_width 48
++#define br_pic2_height 48
++static unsigned char br_pic2_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, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x3f, 0x3f, 0x1f, 0x1f, 0x02,
++ 0x20, 0x7f, 0xbf, 0xbf, 0x3f, 0x02, 0x20, 0x63, 0x8c, 0xb1, 0x31, 0x02,
++ 0x20, 0x63, 0x8c, 0x01, 0x30, 0x02, 0x20, 0x63, 0x8c, 0x01, 0x30, 0x02,
++ 0x20, 0x73, 0x8c, 0x01, 0x30, 0x02, 0x20, 0x3f, 0x8c, 0x01, 0x18, 0x02,
++ 0x20, 0x1f, 0x8c, 0x01, 0x0c, 0x02, 0x20, 0x03, 0x8c, 0x01, 0x06, 0x02,
++ 0x20, 0x03, 0x8c, 0x01, 0x03, 0x02, 0x20, 0x03, 0x8c, 0xb1, 0x01, 0x02,
++ 0x20, 0x03, 0xbf, 0xbf, 0x3f, 0x02, 0x20, 0x03, 0x3f, 0x9f, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 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 -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
+@@ -0,0 +1,28 @@
++#define br_png_width 48
++#define br_png_height 48
++static unsigned char br_png_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, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0xf8, 0x19, 0xc3, 0x07, 0x02, 0x20, 0x18, 0x3b, 0x63, 0x0c, 0x02,
++ 0x20, 0x18, 0x3b, 0x33, 0x00, 0x02, 0x20, 0x18, 0x5b, 0x33, 0x00, 0x02,
++ 0x20, 0xf8, 0x59, 0x33, 0x0f, 0x02, 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02,
++ 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02, 0x20, 0x18, 0x18, 0x63, 0x0c, 0x02,
++ 0x20, 0x18, 0x18, 0xc3, 0x0b, 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, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 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 -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
+@@ -0,0 +1,28 @@
++#define br_zx_width 48
++#define br_zx_height 48
++static unsigned char br_zx_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, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x7f, 0xce, 0x01, 0x0e, 0x02, 0x20, 0x61, 0x84, 0x00, 0x11, 0x02,
++ 0x20, 0x30, 0x48, 0x00, 0x10, 0x02, 0x20, 0x18, 0x38, 0x10, 0x08, 0x02,
++ 0x20, 0x0c, 0x30, 0x10, 0x0e, 0x02, 0x20, 0x06, 0x68, 0x7c, 0x10, 0x02,
++ 0x20, 0x03, 0x48, 0x10, 0x10, 0x02, 0x20, 0x41, 0x84, 0x10, 0x11, 0x02,
++ 0x20, 0x7f, 0xce, 0x01, 0x0e, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x03, 0x20, 0xff, 0xff, 0xff, 0xff, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x40, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
++ 0x20, 0x00, 0x00, 0x00, 0x10, 0x02, 0x20, 0x00, 0x00, 0x00, 0x08, 0x03,
++ 0x20, 0x00, 0x00, 0x00, 0x84, 0x03, 0x20, 0x00, 0x00, 0x00, 0xc2, 0x03,
++ 0x20, 0x00, 0x00, 0x00, 0xe1, 0x03, 0x20, 0x00, 0x00, 0x80, 0xf0, 0x02,
++ 0x20, 0x00, 0x00, 0x40, 0x78, 0x02, 0x20, 0x00, 0x00, 0x20, 0x3c, 0x02,
++ 0x20, 0x00, 0x00, 0x10, 0x1e, 0x02, 0x20, 0x00, 0x00, 0x08, 0x0f, 0x03,
++ 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;
++ }
++ }
++
++ 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;
++ }
++
++ i++;
++ } /* while (mfontsize[i]) */
++
++# 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;
++
++ 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
++
++#ifdef HAVE_PCD
++ CreatePCDW();
++ XSetTransientForHint(theDisp, pcdW, dirW);
++#endif
++
++#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];
++ }
++#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
++
++#ifdef HAVE_PI
++# define F_PAIINC 1
++#else
++# define F_PAIINC 0
++#endif
++
++#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
++
++
++#ifdef ENABLE_FIXPIX_SMOOTH
++WHERE int do_fixpix_smooth; /* GRR 19980607: runtime FS dithering */
++#endif
++
++#ifdef HAVE_PIC2
++/* stuff used for 'pic2' box */
++WHERE Window pic2W;
++WHERE int pic2Up; /* is pic2W mapped, or what? */
++#endif /* HAVE_PIC2 */
++
++#ifdef HAVE_PCD
++/* stuff used for 'pcd' box */
++WHERE Window pcdW;
++WHERE int pcdUp; /* is pcdW mapped, or what? */
++#endif /* HAVE_PCD */
++
++#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 */
++
++#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));
++
++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
+@@ -0,0 +1,125 @@
++#/*
++# Configuration file for XV with recognition of 'Magic and Suffix'
++#
++#
++# $Id: xv_mgcsfx.sample,v 1.11 95/10/03 17:00:05 tin329 Exp Locker: tin329 $
++#
++# Author: Tetsuya INOUE <tin329@chino.it.okayama-u.ac.jp>
++#
++#
++# MgcSfx definition should write in one line.
++# Format:
++# <desc>:<ms type>:<ofs>:<magic>:<suffix>:<in it>:<in c>:<out it>:<out c>
++# If you decide to not use preprocessor, comment style is allowed.
++# # <comment>
++#
++# <desc> Description of your recognized image format.
++# <ms type> Type ID for recognition. (You should use 'magic'.)
++# * magic Data of string style.
++# `\' escape for special characters:
++# \b \f \n \r \t \v \\ \' \" \a \?
++# \0 ...\377 octal value
++# \x0 ...\xff hexadecimal value
++# * suffix Suffix of file name.
++# This type check <suffix> instead
++# of <magic>.
++# * [b|l]eint16 2 byte integer of [big|little] endian.
++# * [b|l]eint32 4 byte integer of [big|little] endian.
++# <ofs> Offset of magic number in the target image file.
++# <magic> Data(magic number) of <ms type> to match at <ofs>.
++# <suffix> Suffix of filename with '.'start.
++#
++# <in it> Input image format type (output from <in c>).
++# * PNM (PPM, PGM, PBM)
++# * AUTO Recognized by xv management, and load.
++# This is different from others, because
++# this write file to temporary.
++# <out it> Output image format type (input to <out c>).
++# * PNM_RAW (PPM_RAW, PGM_RAW, PBM_RAW)
++# * PNM_ASCII (PPM_ASCII, PGM_ASCII, PBM_ASCII)
++#
++# <in c> Command to get the input image.
++# * Command mast read stdin or file(specified by
++# argument), and write to stdout.
++# * Use %s to represent the file name. Without %s,
++# get file on stdin.
++# <out c> Command to put the output image.
++# * Command mast read stdin and write to stdout.
++#
++# <comment> Any message.
++#*/
++
++#/*############################################################################
++#
++# definition of the rule with Magic and Suffix
++#
++#*/
++
++# /* Canon View Station Image Format */
++ViewStation(std):magic:0:VsStdImf V0.2:.vs:PNM:VStopnm %s:PNM_RAW:pnmtoVS
++ViewStation(obj):magic:0:VsObjFormat V1.0:.vs:PNM:VSobjtopnm -:PNM_RAW:pnmtoVSobj
++
++# /* CERN httpd cache */
++# /* unchc skip header of CERN httpd cache file, and write data to stdout. */
++CERN httpd cache:magic:0:HTTP/1.0::AUTO:unchc %s::
++
++# /* XLD4(Q4) image format */
++XLD(Q4):magic:11:MAJYO:.q4:PNM:q4toppm::
++
++# /* ML1 image format */
++ML1:magic:0:\1\0\0\x1a:.ml1:PNM:ml1toppm %s::
++
++# /* Pict image format, 256 color only */
++PICT:suffix:::.pict:PNM:picttoppm:PNM_RAW:ppmquant 256 | ppmtopict
++PICT(gzip):suffix:::.pict.gz:PNM:gzip -dc | picttoppm:PNM_RAW:ppmquant 256 | ppmtopict | gzip
++PICT(compress):suffix:::.pict.Z:PNM:compress -dc | picttoppm:PNM_RAW:ppmquant 256 | ppmtopict | compress
++
++# /* Tim image format(used by SONY PlayStation) */
++TIM:magic:0:\x10\x00\x00\x00:.tim:PNM:timtoppm::
++
++# /* Cam image format(used by CASIO QV-10) */
++# /* CAM:magic:0:\x07\x20\x4d\x4d:.cam:AUTO:camtoppm -j:PNM_RAW */
++CAM:magic:0:\x07\x20\x4d\x4d:.cam:PNM:camtoppm::
++
++# /* Portable Network Graphics (PNG) format : magic is "0x89 PNG" */
++PNG:magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng
++# /* PNG(interlace):magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng -interlace */
++
++# /* DB-Z, SAURUS Freehand Memo, PV-F1 Action Board, Wiz Quick Memo format */
++# /* Use xbm2free-1.10 or later. Old version is NOT a filter. */
++# /* To show version of xbm2free, type "xbm2free" (with no argument). */
++ZAURUS:magic:19:IMG1:.zau:PBM_ASCII:free2pbm:PBM:pbmtoxbm|xbm2free -s -
++DBZ:magic:19:IMG1:.dbz:::PBM:pbmtoxbm|xbm2free -d -
++PVF1:magic:12:IMG1:.pvf1:PBM_ASCII:free2pbm:PBM:pbmtoxbm|xbm2free -v -
++# /* WIZ:magic:19:IMG1:.wiz:::PBM:pbmtoxbm|xbm2free -w - */
++
++
++
++# /* Compress:magic:0:\037\235:.Z:AUTO:uncompress %s:: */
++# /* Gzip:magic:0:\037\213:.gz:AUTO:gunzip %s:: */
++# /* Gzip(old):magic:0:\037\236:.z:AUTO:gunzip %s:: */
++
++# /* MAKI:magic:0:MAKI01A\040:.mki:::: */
++# /* MAKI:magic:0:MAKI01B\040:.mki:::: */
++# /* MAG:magic:0:MAKI02\040\040:.mag:::: */
++# /* Pi:magic:0:Pi:.pi:::: */
++# /* PIC:magic:0:PIC:.pic:::: */
++# /* PIC2:magic:0:P2DT:.p2:::: */
++# /* PhotoCD:magic:0:\xff\xff\xff\xff:.pcd:::: */
++
++# /* PBM(ascii):magic:0:P1:.pbm:::: */
++# /* PGM(ascii):magic:0:P2:.pgm:::: */
++# /* PPM(ascii):magic:0:P3:.ppm:::: */
++# /* PBM(raw):magic:0:P4:.pbm:::: */
++# /* PGM(raw):magic:0:P5:.pgm:::: */
++# /* PPM(raw):magic:0:P6:.ppm:::: */
++
++# /* Sun raster:magic:0:\131\246\152\225:.sun:::: */
++# /* JFIF(JPEG):magic:0:\xff\xd8\xff:.jpg:::: */
++# /* TIFF big-endian:magic:0:\115\115:.tif:::: */
++# /* TIFF little-endian:magic:0:\111\111:.tif:::: */
++# /* GIF(87):magic:0:GIF87a:.gif:::: */
++# /* GIF(89):magic:0:GIF89a:.gif:::: */
++# /* 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
+@@ -0,0 +1,406 @@
++/*
++ * xvhips.c - load routine for 'HIPS' format pictures
++ *
++ * LoadHIPS(fname, numcols)
++ */
++
++/*
++ * Copyright 1989, 1990 by the University of Pennsylvania
++ *
++ * Permission to use, copy, and distribute for non-commercial purposes,
++ * is hereby granted without fee, providing that the above copyright
++ * notice appear in all copies and that both the copyright notice and this
++ * permission notice appear in supporting documentation.
++ *
++ * The software may be modified for your own purposes, but modified versions
++ * may not be distributed.
++ *
++ * This software is provided "as is" without any express or implied warranty.
++ */
++
++#include "xv.h"
++
++#ifdef HAVE_HIPS
++
++#define Boolean FREDDIE
++#include "xvhips.h"
++#undef Boolean
++
++#include <alloca.h>
++
++#define LINES 100
++#define LINELENGTH 132
++
++static int fread_header(int fd, struct header *hd);
++static char *getline(int fd, char **s, int *l);
++static int dfscanf(int fd);
++static void make_grayscale(char *r, char *g, char *b);
++static float hls_value (float n1, float n2, float hue);
++static void hls_to_rgb(float h, float l, float s,
++ float *r, float *g, float *b);
++static void make_huescale(char *r, char *g, char *b);
++static void make_heatscale(char *r, char *g, char *b);
++static int load_colourmap(char *filestem, int max_colours,
++ char *r, char *g, char *b);
++
++/************************************************************************
++ *
++ * Read Header routines
++ *
++ ************************************************************************/
++
++static char *ssave[LINES];
++static int slmax[LINES];
++static int lalloc = 0;
++//extern char *calloc();
++
++
++
++static int fread_header(fd, hd)
++ int fd;
++ struct header *hd;
++{
++ int lineno, len, i;
++ char *s;
++
++/*fprintf(stderr,"fread_header: entered\n");*/
++ if(lalloc<1) {
++ ssave[0] = calloc(LINELENGTH, sizeof (char));
++ slmax[0] = LINELENGTH;
++ lalloc = 1;
++ }
++/*fprintf(stderr,"fread_header: ssave allocated\n");*/
++ getline(fd,&ssave[0],&slmax[0]);
++ hd->orig_name = calloc(strlen(ssave[0])+1, sizeof (char));
++ strcpy(hd->orig_name,ssave[0]);
++ getline(fd,&ssave[0],&slmax[0]);
++ hd->seq_name = calloc(strlen(ssave[0])+1, sizeof (char));
++ strcpy(hd->seq_name,ssave[0]);
++ hd->num_frame = dfscanf(fd);
++ getline(fd,&ssave[0],&slmax[0]);
++ hd->orig_date = calloc(strlen(ssave[0])+1, sizeof (char));
++ strcpy(hd->orig_date,ssave[0]);
++ hd->rows = dfscanf(fd);
++ hd->cols = dfscanf(fd);
++ hd->bits_per_pixel = dfscanf(fd);
++ hd->bit_packing = dfscanf(fd);
++ hd->pixel_format = dfscanf(fd);
++ lineno = 0;
++ len = 1;
++ getline(fd,&ssave[0],&slmax[0]);
++ s = ssave[0];
++ while(*(s += strlen(s)-3) == '|') {
++ len += strlen(ssave[lineno]);
++ lineno++;
++ if (lineno >= LINES)
++ fprintf(stderr, "Too many lines in header history");
++ if(lineno >= lalloc) {
++ ssave[lineno] = calloc(LINELENGTH, sizeof (char));
++ slmax[lineno] = LINELENGTH;
++ lalloc++;
++ }
++ getline(fd,&ssave[lineno],&slmax[lineno]);
++ s = ssave[lineno];
++ }
++ len += strlen(ssave[lineno]);
++ hd->seq_history = calloc(len, sizeof (char));
++ hd->seq_history[0] = '\0';
++ for (i=0;i<=lineno;i++)
++ strcat(hd->seq_history,ssave[i]);
++ lineno = 0;
++ len = 1;
++ while(strcmp(getline(fd,&ssave[lineno],&slmax[lineno]),".\n")) {
++ len += strlen(ssave[lineno]);
++ lineno++;
++ if (lineno >= LINES)
++ fprintf(stderr, "Too many lines in header desc.");
++ if(lineno >= lalloc) {
++ ssave[lineno] = calloc(LINELENGTH, sizeof (char));
++ slmax[lineno] = LINELENGTH;
++ lalloc++;
++ }
++ }
++ hd->seq_desc = calloc(len, sizeof (char));
++ *hd->seq_desc = '\0';
++ for (i=0;i<lineno;i++)
++ strcat(hd->seq_desc,ssave[i]);
++/*fprintf(stderr,"fread_header: exiting\n");*/
++ return 0;
++}
++
++
++
++static char *getline(fd,s,l)
++ int fd;
++ char **s;
++ int *l;
++{
++ int i,m;
++ char c,*s1,*s2;
++
++ i = 0;
++ s1 = *s;
++ m = *l;
++ while(read(fd,&c,1) == 1 && c != '\n') {
++ if (m-- <= 2) {
++ s2 = calloc(LINELENGTH+*l,sizeof (char));
++ strcpy(s2,*s);
++ *s = s2;
++ *l += LINELENGTH;
++ m = LINELENGTH;
++ s1 = s2 + strlen(s2);
++ }
++ *s1++ = c;
++ }
++ if (c == '\n') {
++ *s1++ = '\n';
++ *s1 = '\0';
++ return *s;
++ }
++ fprintf(stderr, "Unexpected EOF while reading header.");
++ return NULL;
++}
++
++
++
++static int dfscanf(fd)
++ int fd;
++{
++ int i;
++
++ getline(fd,&ssave[0],&slmax[0]);
++ sscanf(ssave[0],"%d",&i);
++ return(i);
++}
++
++
++
++/*******************************************/
++int LoadHIPS(fname,pinfo)
++ char *fname;
++ PICINFO * pinfo;
++/*******************************************/
++{
++ FILE *fp;
++ struct header h;
++ char * pic;
++
++ /* open the stream, if necesary */
++ fp=fopen(fname,"r");
++ if (!fp) return 0;
++
++ if (!fread_header(fileno(fp), &h)) {
++ SetISTR(ISTR_WARNING,"Can't read HIPS header");
++ return 0;
++ }
++
++ pinfo->w = h.cols;
++ pinfo->h = h.rows;
++ pic = pinfo->pic = (byte *) malloc(h.rows * h.cols); // GRR POSSIBLE OVERFLOW / FIXME
++ if (!pic) FatalError("couldn't malloc HIPS file");
++
++ if (!fread(pic, 1, h.cols*h.rows, fp)) {
++ SetISTR(ISTR_WARNING,"Error reading HIPS data.\n");
++ return 0;
++ }
++ fclose (fp);
++
++ pinfo->frmType = F_SUNRAS;
++ pinfo->colType = F_FULLCOLOR;
++ sprintf(pinfo->fullInfo, "HIPS file (%d bytes)", h.cols*h.rows);
++ sprintf(pinfo->shrtInfo, "HIPS file.");
++ pinfo->comment = (char *) NULL;
++
++ {
++ char cmapname[256];
++ /* Check header for colormap spec */
++ char * s = h.seq_desc - 1;
++ char * cmaptag = "+COLORMAP";
++ int sl = strlen(cmaptag);
++ cmapname[0] = 0;
++ while (*++s)
++ if (*s == '+')
++ if (strncmp(s, cmaptag, sl) == 0) {
++ char * p = s + sl;
++ while (*p && (*p == ' ' || *p == '\n' || *p == '\t')) p++;
++ sscanf(p, "%s", cmapname);
++ SetISTR(ISTR_INFO, cmapname);
++ fprintf(stderr, "Colormap = [%s]\n", cmapname);
++ }
++
++ if (strcmp(cmapname, "gray") == 0 || strcmp(cmapname, "grey") == 0)
++ make_grayscale(pinfo->r, pinfo->g, pinfo->b);
++ else if (strcmp(cmapname, "heat") == 0)
++ make_heatscale(pinfo->r, pinfo->g, pinfo->b);
++ else if (strcmp(cmapname, "hues") == 0)
++ make_huescale(pinfo->r, pinfo->g, pinfo->b);
++ else if (!cmapname[0] || !load_colourmap(cmapname, 256, pinfo->r, pinfo->g, pinfo->b))
++ make_grayscale(pinfo->r, pinfo->g, pinfo->b);
++ sprintf(pinfo->fullInfo, "HIPS file (%d x %d), Colormap = [%s]", h.cols, h.rows, cmapname);
++ }
++
++ return 1;
++}
++
++
++
++static void make_grayscale(char * r, char * g, char * b)
++{
++ int i;
++ /* default grayscale colors */
++ r[0] = 40; g[0] = 150; b[0] = 100; /* "green4" background */
++ for(i = 1; i < 256; i++)
++ r[i] = g[i] = b[i] = i;
++}
++
++
++
++static float hls_value (n1, n2, hue)
++ float n1,n2,hue;
++{
++ if (hue>360.0)
++ hue-=360.0 ;
++ else if (hue<0.0)
++ hue+=360.0 ;
++
++ if (hue<60.0)
++ return( n1+(n2-n1)*hue/60.0 ) ;
++ else if (hue<180.0)
++ return ( n2 ) ;
++ else if (hue<240.0)
++ return ( n1+(n2-n1)*(240.0-hue)/60.0 ) ;
++ else
++ return (n1) ;
++}
++
++
++
++static void hls_to_rgb(h,l,s, r,g,b)
++ float h, l, s;
++ float *r, *g, *b;
++{
++ static float m1, m2 ;
++
++ if (l<=0.5)
++ m2=l*(1+s) ;
++ else
++ m2=l+s-l*s ;
++ m1=2.0*l-m2 ;
++ if (s==0.0) *r=*g=*b=l ;
++ else {
++ *r=hls_value(m1,m2,h+120.0) ;
++ *g=hls_value(m1,m2,h) ;
++ *b=hls_value(m1,m2,h-120.0) ;
++ }
++
++}
++
++
++
++static void make_huescale(char * r, char * g, char * b)
++{
++ int j;
++ r[0] = g[0] = b[0] = 0;
++ for (j = 1; j<256; j++)
++ {
++ float fr, fg, fb;
++ hls_to_rgb((double)(256.0-j)*360.0/256.0, 0.5, 1.0, &fr, &fg, &fb);
++ r[j] = rint(255*fr);
++ g[j] = rint(255*fg);
++ b[j] = rint(255*fb);
++ }
++}
++
++
++
++static void make_heatscale(char * r, char * g, char * b)
++{
++ int j;
++ r[0] = g[0] = b[0] = 0;
++ for (j = 1; j<256; j++)
++ {
++ if(j<255/2)
++ r[j] = j*255/(255/2-1);
++ else
++ r[j]=255;
++ if (j>=255/2+255/3)
++ g[j] = 255;
++ else if (j>255/3)
++ g[j] = (j-255/3)*255/(255/2-1);
++ else
++ g[j] = 0;
++ if (j>255/2)
++ b[j] = (j-255/2)*255/(255-255/2-1);
++ else
++ b[j] = 0;
++ }
++}
++
++
++
++static int load_colourmap(char *filestem, int max_colours,
++ char *r, char *g, char *b)
++{
++ FILE * fp;
++ int numread=0;
++ char * filename;
++ char str[200];
++ int num_colors;
++ /*
++ * Look for palette file in local directory
++ */
++
++ filename = (char*)alloca(strlen(filestem) + 5);
++ strcpy(filename, filestem);
++ strcat(filename, ".PAL"); /* Add the PAL suffix to the name specified */
++ fp = fopen(filename,"r");
++ if (!fp) {
++ /*
++ * If not found, try in $IM2HOME/etc/palettes
++ */
++ char * im2home = (char*)getenv("IM2HOME");
++ char * palette_subdirectory = "etc/palettes";
++ char * fullfilename;
++ if (!im2home)
++ {
++ im2home = "/home/jewel/imagine2";
++ fprintf(stderr,"IM2HOME environment variable not set -- using [%s]\n",im2home);
++ }
++ fullfilename = alloca(strlen(im2home)+strlen(palette_subdirectory)+strlen(filename)+5);
++ sprintf(fullfilename, "%s/%s/%s",im2home,palette_subdirectory,filename);
++ fp = fopen(fullfilename,"r");
++ if (!fp)
++ {
++ fprintf(stderr,"Couldn't find any palette file -- looked for [%s] and [%s].\n",
++ filename,fullfilename);
++ perror("Last system error message was");
++ return 0;
++ }
++ }
++
++ strcpy(str,"(null)");
++ if (!fscanf(fp,"%s\n",str) || strncmp(str,"Palette",7) != 0) {
++ fprintf(stderr,"error: First line of palette file should be `Palette', not [%s]\n", str);
++ return 0;
++ }
++
++ fscanf(fp,"%[^\n]",str) ; /* Scan to end of line */
++ fscanf (fp,"%d",&num_colors);/* Read the number of colours in the file */
++ fgets(str,120,fp) ; /* Skip the text description, and general info lines */
++ fgets(str,120,fp) ;
++
++ while ((numread<max_colours)&&(numread<num_colors)) {
++ int rc, gc, bc;
++ fscanf (fp,"%d %d %d -", &rc, &gc, &bc) ; /* Get the (r,g,b) tuples */
++ r[numread] = rc;
++ g[numread] = gc;
++ b[numread] = bc;
++ numread++;
++ fgets(str,120,fp) ; /* Skip the description, if present */
++ }
++
++ SetISTR(ISTR_INFO,"Read %d colors from palette file [%s]", numread, filename);
++ return (numread) ; /* Return the number of colours ACTUALLY READ */
++}
++
++#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
+@@ -0,0 +1,154 @@
++/*
++ * HIPL Picture Header Format Standard
++ *
++ * Michael Landy - 2/1/82
++ */
++
++#define XHEADER
++#ifdef XHEADER
++struct extended {
++ char *name;
++ char *vals;
++ };
++#endif
++
++struct header {
++ char *orig_name; /* The originator of this sequence */
++ char *seq_name; /* The name of this sequence */
++ int num_frame; /* The number of frames in this sequence */
++ char *orig_date; /* The date the sequence was originated */
++ int rows; /* The number of rows in each image */
++ int cols; /* The number of columns in each image */
++ int bits_per_pixel; /* The number of significant bits per pixel */
++ int bit_packing; /* Nonzero if bits were packed contiguously */
++ int pixel_format; /* The format of each pixel, see below */
++ char *seq_history; /* The sequence's history of transformations */
++ char *seq_desc; /* Descriptive information */
++#ifdef XHEADER
++ struct extended *xheader;
++#endif
++};
++
++/*
++ * Pixel Format Codes
++ */
++
++#define PFBYTE 0 /* Bytes interpreted as integers (8 bits) */
++#define PFSHORT 1 /* Short integers (2 bytes) */
++#define PFINT 2 /* Integers (4 bytes) */
++#define PFFLOAT 3 /* Float's (4 bytes)*/
++#define PFCOMPLEX 4 /* 2 Float's interpreted as (real,imaginary) */
++#define PFASCII 5 /* ASCII rep, with linefeeds after each row */
++#define PFDOUBLE 6 /* Double's (8 byte floats) */
++#define PFDBLCOM 7 /* Double complex's (2 Double's) */
++#define PFQUAD 10 /* quad-tree encoding (Mimaging) */
++#define PFQUAD1 11 /* quad-tree encoding */
++#define PFBHIST 12 /* histogram of byte image (using ints) */
++#define PFSPAN 13 /* spanning tree format */
++#define PLOT3D 24 /* plot-3d format */
++#define PFINTPYR 50 /* integer pyramid */
++#define PFFLOATPYR 51 /* float pyramid */
++#define PFPOLYLINE 100 /* 2D points */
++#define PFCOLVEC 101 /* Set of RGB triplets defining colours */
++#define PFUKOOA 102 /* Data in standard UKOOA format */
++#define PFTRAINING 104 /* Set of colour vector training examples */
++#define PFTOSPACE 105 /* TOspace world model data structure */
++#define PFSTEREO 106 /* Stereo sequence (l, r, l, r, ...) */
++#define PFRGPLINE 107 /* 2D points with regions */
++#define PFRGISPLINE 108 /* 2D points with regions and interfaces */
++#define PFCHAIN 200 /* Chain code encoding (Mimaging) */
++#define PFLUT 300 /* LUT format (uses Ints) (Mimaging) */
++#define PFAHC 400 /* adaptive hierarchical encoding */
++#define PFOCT 401 /* oct-tree encoding */
++#define PFBT 402 /* binary tree encoding */
++#define PFAHC3 403 /* 3-d adaptive hierarchical encoding */
++#define PFBQ 404 /* binquad encoding */
++#define PFRLED 500 /* run-length encoding */
++#define PFRLEB 501 /* run-length encoding, line begins black */
++#define PFRLEW 502 /* run-length encoding, line begins white */
++#define PFPOLAR 600 /* rho-theta format (Mimaging) */
++
++/*
++ * Bit packing formats
++ */
++
++#define MSBFIRST 1 /* bit packing - most significant bit first */
++#define LSBFIRST 2 /* bit packing - least significant bit first */
++
++#define FBUFLIMIT 30000 /* increase this if you use large PLOT3D
++ files */
++
++/*
++ * For general readability
++ */
++
++#ifndef TRUE
++# define TRUE 1
++#endif
++
++#ifndef FALSE
++# define FALSE 0
++#endif
++
++typedef long Boolean;
++extern char *strsave(), *memalloc();
++
++/*
++ * image and pyramid type declarations for the pyramid routines.
++ *
++ * The pyramid utilities are derived from code originally written by
++ * Raj Hingorani at SRI/David Sarnoff Research Institute. The original
++ * Gaussian and Laplacian pyramid algorithms were designed by Peter Burt (also
++ * currently at SRI/DSRC). See: Computer Graphics and Image Processing,
++ * Volume 16, pp. 20-51, 1981, and IEEE Transactions on Communications,
++ * Volume COM-31, pp. 532-540, 1983.
++ */
++
++#define MAXLEV 12
++
++
++typedef struct {
++ float **ptr;
++ int nr;
++ int nc;
++} FIMAGE;
++
++typedef struct {
++ int **ptr;
++ int nr;
++ int nc;
++} IIMAGE;
++
++typedef FIMAGE FPYR[MAXLEV];
++typedef IIMAGE IPYR[MAXLEV];
++
++typedef struct {
++ float *k;
++ int taps2; /* the number of taps from the center rightward,
++ total number is 2*taps2-1 */
++} FILTER;
++
++/* function definitions */
++
++float **_read_fimgstr();
++int **_read_iimgstr();
++float **_alloc_fimage();
++int **_alloc_iimage();
++
++/* image macros */
++
++#ifndef MAX
++# define MAX(A,B) ((A) > (B) ? (A) : (B))
++#endif /* MAX */
++#ifndef MIN
++# define MIN(A,B) ((A) < (B) ? (A) : (B))
++#endif /* MIN */
++#ifndef ABS
++# define ABS(A) ((A) > 0 ? (A) : (-(A)))
++#endif /* ABS */
++#ifndef BETWEEN
++# define BETWEEN(A,B,C) (((A) < (B)) ? (B) : (((A) > (C)) ? (C) : (A)))
++#endif /* BETWEEN */
++#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:
++ *
++ * unsigned char *p;
++ * unsigned long pixval;
++ *
++ * pixval = screen_rgb[0][*p++];
++ * pixval |= screen_rgb[1][*p++];
++ * pixval |= screen_rgb[2][*p++];
++ *
++ * 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.
++ *
++ * 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.
++ *
++ * 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.
++ *
++ * 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...
++ */
++
++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);
++}
++
++
++#ifdef ENABLE_FIXPIX_SMOOTH
++
++/* 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.
++ */
++
++/* 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.
++ */
++
++typedef INT16 FSERROR; /* 16 bits should be enough */
++typedef int LOCFSERROR; /* use 'int' for calculation temps */
++
++typedef struct { byte *colorset;
++ FSERROR *fserrors;
++ } FSBUF;
++
++/* 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.
++ */
++
++static FSBUF *fs2_init(width)
++int width;
++{
++ FSBUF *fs;
++ FSERROR *p;
++
++ fs = (FSBUF *)
++ malloc(sizeof(FSBUF) * 3 + ((size_t)width + 2) * sizeof(FSERROR) * 3);
++ if (fs == 0) return fs;
++
++ fs[0].colorset = screen_set[0];
++ fs[1].colorset = screen_set[1];
++ fs[2].colorset = screen_set[2];
++
++ p = (FSERROR *)(fs + 3);
++ memset(p, 0, ((size_t)width + 2) * sizeof(FSERROR) * 3);
++
++ fs[0].fserrors = p;
++ fs[1].fserrors = p + 1;
++ fs[2].fserrors = p + 2;
++
++ return fs;
++}
++
++/* 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.
++ */
++
++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;
++ }
++ 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;
++ }
++ 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);
++ }
++ }
++#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;
++
++ 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;
++ }
++ }
++ break;
++
++ 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;
++ }
++ }
++ break;
++
++ 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;
++
++ 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;
++ }
++ }
++ 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 @@
+
+
+
++
++/*******************************************/
++void
++VersionInfoJPEG() /* GRR 19980605, 19980607 */
++{
++ int major = JPEG_LIB_VERSION / 10;
++ int minor = JPEG_LIB_VERSION % 10;
++ char minoralpha[2];
++
++ if (minor) {
++ minoralpha[0] = (char)(minor - 1 + 'a');
++ minoralpha[1] = '\0';
++ } else
++ minoralpha[0] = '\0';
++
++/* fprintf(stderr, " Compiled with libjpeg %d.%d.\n", major, minor); */
++ fprintf(stderr, " Compiled with libjpeg %d%s.\n", major, minoralpha);
++}
++
++
++
++
++
+ #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
+@@ -0,0 +1,866 @@
++/*
++ * xvmag.c - load routine for `MAG' format pictures.
++ *
++ * The `MAG' format is used by many Japanese personal computer users.
++ * This program is based on MAGBIBLE.DOC which is the specification
++ * for `MAG' format written by Woody RINN. It is written in Japanese,
++ * and exists in some anon-ftp sites.
++ */
++
++#include "xv.h"
++#include <setjmp.h>
++
++#ifdef HAVE_MAG
++
++typedef unsigned short data16;
++
++struct mag {
++ jmp_buf jmp;
++ FILE *fp;
++ long fsize;
++ int m_256, m_dig, m_8, m_200;
++ int x1, y1, x2, y2, left_pad, right_pad;
++ int p_width, p_height, width, height;
++ long h_off, a_off, a_size, b_off, b_size, p_off, p_size;
++ byte *a, *b, *p;
++};
++
++static void mag_open_file PARM((struct mag*, char*));
++static void mag_read_check_data PARM((struct mag*));
++static void mag_read_comment PARM((struct mag*, char**));
++static void mag_read_header PARM((struct mag*));
++static void mag_read_palette PARM((struct mag*, byte*, byte*, byte*));
++static void mag_read_flags PARM((struct mag*));
++static void mag_read_pixel_data PARM((struct mag*));
++static void mag_expand_body PARM((struct mag*, byte**));
++
++static void mag_compress_data PARM((struct mag*, byte*));
++static void mag_write_check_data PARM((struct mag*));
++static void mag_write_comment PARM((struct mag*, char *));
++static void mag_write_palette PARM((struct mag*, int,
++ byte*, byte*, byte*, int));
++static void mag_write_flags PARM((struct mag*));
++static void mag_write_pixel_data PARM((struct mag*));
++static void mag_write_header PARM((struct mag*));
++static void mag_set_double_word PARM((long, byte *));
++
++static void mag_init_info PARM((struct mag*));
++static void mag_cleanup_mag_info PARM((struct mag*, int));
++static void mag_cleanup_pinfo PARM((PICINFO*));
++static void mag_memory_error PARM((char*, char*));
++static void mag_error PARM((struct mag*, int));
++static void mag_file_error PARM((struct mag*, int));
++static void mag_file_warning PARM((struct mag*, int));
++static void mag_show_struct PARM((struct mag*));
++static void *mag_malloc PARM((size_t, char*));
++static void *mag_realloc PARM((void*, size_t, char*));
++
++
++static char *mag_id = "MAKI02 ";
++static struct{
++ int dx, dy;
++}points[16] = {
++ { 0, 0}, { 1, 0}, { 2, 0}, { 4, 0},
++ { 0, 1}, { 1, 1},
++ { 0, 2}, { 1, 2}, { 2, 2},
++ { 0, 4}, { 1, 4}, { 2, 4},
++ { 0, 8}, { 1, 8}, { 2, 8},
++ { 0, 16},
++};
++static int try[15] = {1, 4, 5, 6, 7, 9, 10, 2, 8, 11, 12, 13, 14, 3, 15};
++
++static char *mag_msgs[] = {
++ NULL,
++#define MAG_OPEN 1
++ "can't open file",
++#define MAG_CORRUPT 2
++ "file currupted.",
++#define MAG_FORMAT 3
++ "not MAG format.",
++#define MAG_WRITE 4
++ "write failed.",
++};
++
++
++#define H4(x) (((int) (x) >> 4) & 0x0f) /* operates on a byte */
++#define L4(x) ((x) & 0x0f)
++#define H8(x) (((x) >> 8) & 0xff) /* operates on a data16 */
++#define L8(x) ((x) & 0xff)
++
++#define error(msgnum) longjmp(mi->jmp, msgnum)
++
++
++/* The main routine to load a MAG file. */
++int LoadMAG(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++{
++ struct mag mag;
++ int e;
++
++ if(DEBUG) fputs("LoadMAG:\n", stderr);
++
++ pinfo->comment = NULL;
++ mag_init_info(&mag);
++ if((e = setjmp(mag.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ mag_cleanup_mag_info(&mag, 0);
++ mag_cleanup_pinfo(pinfo);
++ return 0;
++ }
++
++ mag_open_file(&mag, fname);
++ mag_read_check_data(&mag);
++ mag_read_comment(&mag, &pinfo->comment);
++ mag_read_header(&mag);
++ mag_read_palette(&mag, pinfo->r, pinfo->g, pinfo->b);
++ mag_read_flags(&mag);
++ mag_read_pixel_data(&mag);
++ mag_expand_body(&mag, &pinfo->pic);
++
++ pinfo->w = pinfo->normw = mag.width;
++ pinfo->h = pinfo->normh = mag.height;
++ pinfo->type = PIC8;
++ pinfo->frmType = F_MAG;
++ pinfo->colType = F_FULLCOLOR;
++ sprintf(pinfo->fullInfo, "MAG, %d colors%s (%ld bytes)",
++ mag.m_256 ? 256 : (mag.m_8 ? 8 : 16),
++ mag.m_200 ? ", aspect 0.5" : "", mag.fsize);
++ sprintf(pinfo->shrtInfo, "%dx%d MAG", mag.width, mag.height);
++ if(mag.m_200)
++ normaspect = 0.5;
++
++ mag_cleanup_mag_info(&mag, 0);
++ return 1;
++}
++
++static void mag_open_file(mi, fname)
++ struct mag *mi;
++ char *fname;
++{
++ if((mi->fp = fopen(fname, "rb")) == NULL)
++ mag_file_error(mi, MAG_OPEN);
++ fseek(mi->fp, (size_t) 0, SEEK_END);
++ mi->fsize = ftell(mi->fp);
++ fseek(mi->fp, (size_t) 0, SEEK_SET);
++}
++
++static void mag_read_check_data(mi)
++ struct mag *mi;
++{
++ char buffer[8];
++
++ if(fread(buffer, (size_t) 8, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_CORRUPT);
++ if(strncmp(buffer, mag_id, (size_t) 8) != 0)
++ mag_error(mi, MAG_FORMAT);
++}
++
++static void mag_read_comment(mi, p)
++ struct mag *mi;
++ char **p;
++{
++ int max = -1, i = 0;
++ int c;
++
++ while((c = fgetc(mi->fp)) != EOF){
++ if(c == 0x1a)
++ break;
++ if(max < i){
++ max += 16;
++ *p = mag_realloc(*p, (size_t) max + 1, "mag_read_comment#1");
++ }
++ (*p)[i++] = c;
++ }
++
++ if(c == EOF)
++ mag_file_error(mi, MAG_CORRUPT);
++
++ if(max < i){
++ *p = mag_realloc(*p, (size_t) max + 2, "mag_read_comment#2");
++ }
++ if(i > 24){
++ (*p)[i] = '\0';
++ strcpy(*p, &(*p)[24]);
++ }else{
++ (*p)[0] = '\0';
++ }
++}
++
++static void mag_read_header(mi)
++ struct mag *mi;
++{
++ byte buf[32];
++
++ mi->h_off = ftell(mi->fp);
++
++ if(fread(buf, (size_t) 32, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_CORRUPT);
++
++ mi->m_256 = buf[3] & 0x80;
++ mi->m_dig = buf[3] & 0x04;
++ mi->m_8 = buf[3] & 0x02;
++ mi->m_200 = buf[3] & 0x01;
++
++ mi->x1 = buf[ 4] + buf[ 5] * 256;
++ mi->y1 = buf[ 6] + buf[ 7] * 256;
++ mi->x2 = buf[ 8] + buf[ 9] * 256;
++ mi->y2 = buf[10] + buf[11] * 256;
++
++#define get_dword(a, b, c, d) \
++ ((long)(a) << 24 | (long)(b) << 16 | (long)(c) << 8 | (long)(d))
++
++ mi->a_off = get_dword(buf[15], buf[14], buf[13], buf[12]);
++ mi->b_off = get_dword(buf[19], buf[18], buf[17], buf[16]);
++ mi->b_size = get_dword(buf[23], buf[22], buf[21], buf[20]);
++ mi->p_off = get_dword(buf[27], buf[26], buf[25], buf[24]);
++ mi->p_size = get_dword(buf[31], buf[30], buf[29], buf[28]);
++#undef get_dword
++
++ mi->a_size = mi->b_off - mi->a_off;
++ mi->a_off += mi->h_off;
++ mi->b_off += mi->h_off;
++ mi->p_off += mi->h_off;
++
++ mi->width = mi->x2 - mi->x1 + 1;
++ mi->height = mi->y2 - mi->y1 + 1;
++ mi->left_pad = mi->x1 & 07;
++ mi->right_pad = 07 - (mi->x2 & 07);
++ mi->x1 -= mi->left_pad; /* x1 = 8m */
++ mi->x2 += mi->right_pad; /* x2 = 8n+7 */
++ mi->p_width = ((mi->x2 + 1) - mi->x1) / (mi->m_256 ? 2 : 4);
++ mi->p_height = (mi->y2 + 1) - mi->y1;
++
++ if(DEBUG) mag_show_struct(mi);
++}
++
++static void mag_read_palette(mi, r, g, b)
++ struct mag *mi;
++ byte *r, *g, *b;
++{
++ int num_palettes;
++ byte *buf;
++
++ if(mi->m_256)
++ num_palettes = 256;
++ else
++ num_palettes = 16;
++
++ buf = mag_malloc((size_t)num_palettes * 3, "mag_read_palette");
++
++ if(fread(buf, (size_t) 3, (size_t) num_palettes, mi->fp) != num_palettes){
++ free(buf);
++ mag_file_error(mi, MAG_CORRUPT);
++ }
++
++ for(num_palettes--; num_palettes >= 0; num_palettes--){
++ g[num_palettes] = buf[num_palettes * 3 ];
++ r[num_palettes] = buf[num_palettes * 3 + 1];
++ b[num_palettes] = buf[num_palettes * 3 + 2];
++ }
++
++ free(buf);
++}
++
++static void mag_read_flags(mi)
++ struct mag *mi;
++{
++ mi->a = mag_malloc((size_t) mi->a_size, "mag_read_flags#1");
++ mi->b = mag_malloc((size_t) mi->b_size, "mag_read_flags#2");
++
++ fseek(mi->fp, mi->a_off, SEEK_SET);
++ if(fread(mi->a, (size_t) mi->a_size, (size_t) 1, mi->fp) != 1)
++ mag_file_warning(mi, MAG_CORRUPT);
++ if(fread(mi->b, (size_t) mi->b_size, (size_t) 1, mi->fp) != 1)
++ mag_file_warning(mi, MAG_CORRUPT);
++}
++
++static void mag_read_pixel_data(mi)
++ struct mag *mi;
++{
++ mi->p = mag_malloc((size_t) mi->p_size, "mag_read_pixel_data");
++
++ fseek(mi->fp, mi->p_off, SEEK_SET);
++ if(fread(mi->p, (size_t) mi->p_size, (size_t) 1, mi->fp) != 1)
++ mag_file_warning(mi, MAG_CORRUPT);
++}
++
++/* MAG expanding routine */
++static void mag_expand_body(mi, pic0)
++ struct mag *mi;
++ byte **pic0;
++{
++ int ai, bi, fi, pi;
++ int px, py, x, y;
++ byte *flag;
++ byte mask;
++ data16 *pixel0;
++
++ flag = mag_malloc((size_t) mi->p_width / 2, "mag_expand_body#1");
++ *pic0 = mag_malloc((size_t) mi->width * mi->height, "mag_expand_body#2"); // GRR POSSIBLE OVERFLOW / FIXME
++ pixel0 = mag_malloc((size_t) 2 * mi->p_width * 17, "mag_expand_body#3"); // GRR POSSIBLE OVERFLOW / FIXME
++
++#define pixel(x, y) pixel0[(y) % 17 * mi->p_width + (x)]
++
++ ai = bi = pi = 0;
++ mask = 0x80;
++ for(y = py = 0; py < mi->p_height; py++){
++ for(fi = 0; fi < mi->p_width / 2; fi++){
++ if(py == 0){
++ if(mi->a[ai] & mask)
++ flag[fi] = mi->b[bi++];
++ else
++ flag[fi] = 0;
++ }else{
++ if(mi->a[ai] & mask)
++ flag[fi] ^= mi->b[bi++];
++ }
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ ai++;
++ }
++ }
++
++ for(px = fi = 0; fi < mi->p_width / 2; fi++){
++ int f = H4(flag[fi]);
++ if(f == 0){
++ pixel(px, py) = mi->p[pi] + mi->p[pi + 1] * 256;
++ px++;
++ pi+=2;
++ }else{
++ int dx = points[f].dx, dy = points[f].dy;
++ pixel(px, py) = pixel(px - dx, py - dy);
++ px++;
++ }
++
++ f = L4(flag[fi]);
++ if(f == 0){
++ pixel(px, py) = mi->p[pi] + mi->p[pi + 1] * 256;
++ px++;
++ pi+=2;
++ }else{
++ int dx = points[f].dx, dy = points[f].dy;
++ pixel(px, py) = pixel(px - dx, py - dy);
++ px++;
++ }
++ }
++
++#define inside(x) ((unsigned int)(x) < mi->width)
++#define pic(x, y) (*pic0)[(y) * mi->width + (x)]
++ for(x = -mi->left_pad, px = 0; px < mi->p_width; px++){
++ data16 p = pixel(px, py);
++ if(mi->m_256){
++ if(inside(x))
++ pic(x, y) = L8(p);
++ x++;
++ if(inside(x))
++ pic(x, y) = H8(p);
++ x++;
++ }else{
++ if(inside(x))
++ pic(x, y) = H4(L8(p));
++ x++;
++ if(inside(x))
++ pic(x, y) = L4(L8(p));
++ x++;
++ if(inside(x))
++ pic(x, y) = H4(H8(p));
++ x++;
++ if(inside(x))
++ pic(x, y) = L4(H8(p));
++ x++;
++ }
++ }
++ y++;
++ }
++#undef pic
++#undef inside
++#undef pixel
++
++ free(flag);
++ free(pixel0);
++}
++
++
++/* The main routine to write a MAG file. */
++int WriteMAG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle,
++ comment)
++ FILE *fp;
++ byte *pic;
++ int ptype, w, h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
++ char *comment;
++{
++ byte rtemp[256], gtemp[256], btemp[256];
++ struct mag mag;
++ int e;
++
++ if(DEBUG) fputs("WriteMag\n", stderr);
++
++ mag_init_info(&mag);
++ mag.fp = fp;
++
++ if(ptype == PIC24){
++ if(!(pic = Conv24to8(pic, w, h, 256, rtemp, gtemp, btemp)))
++ mag_memory_error("Conv24to8", "WriteMAG");
++ rmap = rtemp;
++ gmap = gtemp;
++ bmap = btemp;
++ numcols = 256;
++ mag.m_256 = 1;
++ }else{
++ if(numcols > 16)
++ mag.m_256 = 1;
++ }
++
++ if((e = setjmp(mag.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ mag_cleanup_mag_info(&mag, 1);
++ return -1;
++ }
++
++ mag.x2 = w - 1;
++ mag.y2 = h - 1;
++ mag.right_pad = 07 - (mag.x2 & 07);
++ mag.p_width = (w + mag.right_pad) / (mag.m_256 ? 2 : 4);
++ mag.p_height = h;
++ mag.width = w;
++ mag.height = h;
++ mag.a_size = (mag.p_width * mag.p_height + 15) / 16; /* x/2/8 */ // GRR POSSIBLE OVERFLOW / FIXME
++ if(mag.a_size % 2)
++ mag.a_size++;
++
++ mag_compress_data(&mag, pic);
++ mag_write_check_data(&mag);
++ mag_write_comment(&mag, comment);
++
++ mag.h_off = ftell(mag.fp);
++
++ mag_write_palette(&mag, numcols, rmap, gmap, bmap,
++ colorstyle == F_GREYSCALE);
++ mag_write_flags(&mag);
++ mag_write_pixel_data(&mag);
++ mag_write_header(&mag);
++
++ mag_cleanup_mag_info(&mag, 1);
++ return 0;
++}
++
++/* MAG compressing routine */
++static void mag_compress_data(mi, pic0)
++ struct mag *mi;
++ byte *pic0;
++{
++ int ai, bi, pi, i;
++ int bmax, pmax;
++ byte mask;
++ byte *flag0;
++ data16 *pixel0;
++ int px, py, x, y;
++
++ pixel0 = mag_malloc((size_t) 2 * mi->p_width * mi->p_height, // GRR POSSIBLE OVERFLOW / FIXME
++ "mag_compress_data#1");
++ flag0 = mag_malloc((size_t) mi->p_width * mi->p_height, // GRR POSSIBLE OVERFLOW / FIXME
++ "mag_compress_data#2");
++
++#define pic(x, y) pic0[(y) * mi->width + (x)]
++ /* convert dots to pixels */
++ i = 0;
++ for(y = py = 0; py < mi->p_height; py++){
++ for(x = px = 0; px < mi->p_width; px++){
++ data16 p = 0;
++ if(mi->m_256){
++ if(x < mi->width)
++ p += pic(x, y);
++ x++;
++ if(x < mi->width)
++ p += pic(x, y) * 256;
++ x++;
++ }else{
++ if(x < mi->width)
++ p += pic(x, y) * 16;
++ x++;
++ if(x < mi->width)
++ p += pic(x, y);
++ x++;
++ if(x < mi->width)
++ p += pic(x, y) * 4096;
++ x++;
++ if(x < mi->width)
++ p += pic(x, y) * 256;
++ x++;
++ }
++ pixel0[i++] = p;
++ }
++ y++;
++ }
++#undef pic
++
++#define pixel(x, y) pixel0[(y) * mi->p_width + (x)]
++#define flag(x, y) flag0[(y) * mi->p_width + (x)]
++ /* get flags */
++ pmax = pi = 0;
++ for(py = 0; py < mi->p_height; py++){
++ for(px = 0; px < mi->p_width; px++){
++ int t;
++ for(t = 0; t < 15; t++){
++ int dx = points[try[t]].dx, dy = points[try[t]].dy;
++ if(dx <= px && dy <= py){
++ if(pixel(px - dx, py - dy) == pixel(px, py))
++ break;
++ }
++ }
++ if(t < 15){
++ flag(px, py) = try[t];
++ }else{
++ flag(px, py) = 0;
++ if(pmax <= pi + 1){
++ pmax += 128;
++ mi->p = mag_realloc(mi->p, (size_t) pmax,
++ "mag_compress_data#3");
++ }
++ mi->p[pi++] = L8(pixel(px, py));
++ mi->p[pi++] = H8(pixel(px, py));
++ }
++ }
++ }
++#undef flag
++#undef pixel
++
++ /* pack 2 flags into 1 byte */
++ for(i = 0; i < mi->p_width / 2 * mi->p_height; i++)
++ flag0[i] = flag0[i * 2] * 16 + flag0[i * 2 + 1];
++
++#define flag(x, y) flag0[(y) * mi->p_width / 2 + (x)]
++ for(py = mi->p_height - 1; py >= 1; py--){
++ for(px = 0; px < mi->p_width / 2; px++)
++ flag(px, py) ^= flag(px, py - 1);
++ }
++#undef flag
++
++ mask = 0x80;
++ ai = bi = bmax = 0;
++ mi->a = mag_malloc((size_t) mi->a_size, "mag_compress_data#4"); // GRR POSSIBLE OVERFLOW / FIXME
++ for(i = 0; i < mi->p_width / 2 * mi->p_height; i++){
++ if(flag0[i] == 0){
++ mi->a[ai] &= ~mask;
++ }else{
++ if(bmax == bi){
++ bmax += 128;
++ mi->b = mag_realloc(mi->b, (size_t) bmax,
++ "mag_compress_data#4");
++ }
++ mi->b[bi++] = flag0[i];
++ mi->a[ai] |= mask;
++ }
++
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ ai++;
++ }
++ }
++
++ if(bi % 2)
++ bi++;
++ mi->b_size = bi;
++
++ mi->p_size = pi;
++
++ free(pixel0);
++ free(flag0);
++}
++
++static void mag_write_check_data(mi)
++ struct mag *mi;
++{
++ if(fwrite(mag_id, (size_t) 8, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_WRITE);
++}
++
++static void mag_write_comment(mi, comment)
++ struct mag *mi;
++ char *comment;
++{
++ char *p;
++ int i;
++
++ if(fputs("XV ", mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++
++ if((p = (char *) getenv("USER")) == NULL)
++ p = "????????";
++ for(i = 5; i < 24; i++){
++ if(*p == '\0')
++ break;
++ if(fputc(*p++, mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++ }
++ for( ; i < 24; i++){
++ if(fputc(' ', mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++ }
++
++ if(comment){
++ int l = strlen(comment);
++ if(l > 0){
++ int i;
++ for(i = 0; i < l; i++){
++ if(comment[i] == 0x1a)
++ comment[i] = ' ';
++ }
++ if(fwrite(comment, (size_t) l, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_WRITE);
++ }
++ }
++
++ if(fputc(0x1a, mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++}
++
++static void mag_write_palette(mi, num, r, g, b, grey)
++ struct mag *mi;
++ int num;
++ byte *r, *g, *b;
++ int grey;
++{
++ int i, left;
++ char buf[3];
++
++ fseek(mi->fp, 32L, SEEK_CUR); /* skip header area */
++ for(i = 0; i < num; i++){
++ buf[0] = *g++;
++ buf[1] = *r++;
++ buf[2] = *b++;
++ if(grey)
++ buf[0] = buf[1] = buf[2] = MONO(buf[1], buf[0], buf[2]);
++ if(fwrite(buf, (size_t) 3, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_WRITE);
++ }
++ if(num < 16){
++ left = 16 - num;
++ }else if(num == 16){
++ left = 0;
++ }else if(num < 256){
++ left = 256 - num;
++ }else if(num == 256){
++ left = 0;
++ }else
++ left = 0; /* shouldn't happen */
++
++ if(left > 0){
++ for(i = 0; i < left; i++){
++ if(fwrite(buf, (size_t) 3, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_WRITE);
++ }
++ }
++}
++
++static void mag_write_flags(mi)
++ struct mag *mi;
++{
++ int i;
++
++ mi->a_off = ftell(mi->fp);
++ for(i = 0; i < mi->a_size; i++){
++ if(fputc(mi->a[i], mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++ }
++
++ mi->b_off = ftell(mi->fp);
++ for(i = 0; i < mi->b_size; i++){
++ if(fputc(mi->b[i], mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++ }
++}
++
++static void mag_write_pixel_data(mi)
++ struct mag *mi;
++{
++ int i;
++
++ mi->p_off = ftell(mi->fp);
++ for(i = 0; i < mi->p_size; i++){
++ if(fputc(mi->p[i], mi->fp) == EOF)
++ mag_file_error(mi, MAG_WRITE);
++ }
++}
++
++static void mag_write_header(mi)
++ struct mag *mi;
++{
++ byte buf[32];
++
++ if(DEBUG) mag_show_struct(mi);
++
++ mi->a_off -= mi->h_off;
++ mi->b_off -= mi->h_off;
++ mi->p_off -= mi->h_off;
++
++ buf[ 0] = buf[1] = buf[2] = 0;
++ buf[ 3] = (mi->m_256 ? 0x80 : 0);
++ buf[ 4] = buf[5] = 0;
++ buf[ 6] = buf[7] = 0;
++ buf[ 8] = L8(mi->x2);
++ buf[ 9] = H8(mi->x2);
++ buf[10] = L8(mi->y2);
++ buf[11] = H8(mi->y2);
++ mag_set_double_word(mi->a_off, &buf[12]);
++ mag_set_double_word(mi->b_off, &buf[16]);
++ mag_set_double_word(mi->b_size, &buf[20]);
++ mag_set_double_word(mi->p_off, &buf[24]);
++ mag_set_double_word(mi->p_size, &buf[28]);
++
++ fseek(mi->fp, mi->h_off, SEEK_SET);
++ if(fwrite(buf, (size_t) 32, (size_t) 1, mi->fp) != 1)
++ mag_file_error(mi, MAG_WRITE);
++}
++
++static void mag_set_double_word(n, p)
++ long n;
++ byte *p;
++{
++ p[0] = n % 256; /* ugly...anything wrong with shift/mask operations? */
++ p[1] = n / 256 % 256; /* (n >> 8) & 0xff */
++ p[2] = n / 256 / 256 % 256; /* (n >> 16) & 0xff */
++ p[3] = n / 256 / 256 / 256 % 256; /* (n >> 24) & 0xff */
++}
++
++/*
++ * The routines to initialize or clean up.
++ * mag_init_info:
++ * initializes a mag structure.
++ * mag_cleanup_mag_info:
++ * cleans up a mag structure.
++ * mag_cleanup_pinfo:
++ * cleans up a PICINFO structure.
++ */
++static void mag_init_info(mi)
++ struct mag *mi;
++{
++ mi->fp = NULL;
++ mi->fsize = 0;
++ mi->m_256 = mi->m_dig = mi->m_8 = mi->m_200 = 0;
++ mi->x1 = mi->y1 = mi->x2 = mi->y2 = 0;
++ mi->left_pad = mi->right_pad = 0;
++ mi->p_width = mi->p_height = mi->width = mi->height = 0;
++ mi->h_off = mi->p_off = mi->p_size = 0;
++ mi->a_off = mi->a_size = mi->b_off = mi->b_size = 0;
++ mi->a = NULL;
++ mi->b = NULL;
++ mi->p = NULL;
++}
++
++static void mag_cleanup_mag_info(mi, writing)
++ struct mag *mi;
++ int writing;
++{
++ if(mi->fp && !writing)
++ fclose(mi->fp);
++ if(mi->a)
++ free(mi->a);
++ if(mi->b)
++ free(mi->b);
++ if(mi->p)
++ free(mi->p);
++}
++
++static void mag_cleanup_pinfo(pinfo)
++ PICINFO *pinfo;
++{
++ if(pinfo->comment){
++ free(pinfo->comment);
++ pinfo->comment = NULL;
++ }
++ if(pinfo->pic){
++ free(pinfo->pic);
++ pinfo->pic = NULL;
++ }
++}
++
++/*
++ * Error handler.
++ * mag_memory_error:
++ * shows an error message, and terminates.
++ * mag_error:
++ * shows an non-file error message, and jumps to the entry for errors.
++ * mag_file_error:
++ * shows an file error message, and jumps to the entry for errors.
++ * mag_file_warning:
++ * shows an file warning message.
++ */
++static void mag_memory_error(scm, fn)
++ char *scm, *fn;
++{
++ char buf[128];
++ sprintf(buf, "%s: can't allocate memory. (%s)", scm, fn);
++ FatalError(buf);
++}
++
++static void mag_error(mi, mn)
++ struct mag *mi;
++ int mn;
++{
++ SetISTR(ISTR_WARNING, "%s", mag_msgs[mn]);
++ longjmp(mi->jmp, 1);
++}
++
++static void mag_file_error(mi, mn)
++ struct mag *mi;
++ int mn;
++{
++ if(feof(mi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", mag_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", mag_msgs[mn], ERRSTR(errno));
++ longjmp(mi->jmp, 1);
++}
++
++static void mag_file_warning(mi, mn)
++ struct mag *mi;
++ int mn;
++{
++ if(feof(mi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", mag_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", mag_msgs[mn], ERRSTR(errno));
++}
++
++static void mag_show_struct (mi)
++ struct mag *mi;
++{
++ fprintf(stderr, " 256 colors: %s\n", mi->m_256 ? "true" : "false");
++ fprintf(stderr, " 8 colors: %s\n", mi->m_8 ? "true" : "false");
++ fprintf(stderr, " digital colors: %s\n", mi->m_dig ? "true" : "false");
++ fprintf(stderr, " aspect ratio: %f\n", mi->m_200 ? 0.5 : 1.0);
++ fprintf(stderr, " image size: %dx%d\n", mi->width, mi->height);
++ fprintf(stderr, " left pad: %d\n", mi->left_pad);
++ fprintf(stderr, " right pad: %d\n", mi->right_pad);
++ fprintf(stderr, " h_off: %ld\n", mi->h_off);
++ fprintf(stderr, " A: off:%ld, size:%ld\n", mi->a_off, mi->a_size);
++ fprintf(stderr, " B: off:%ld, size:%ld\n", mi->b_off, mi->b_size);
++ fprintf(stderr, " P: off:%ld, size:%ld\n", mi->p_off, mi->p_size);
++}
++
++/* Memory related routines. */
++static void *mag_malloc(n, fn)
++ size_t n;
++ char *fn;
++{
++ void *r = (void *) malloc(n);
++ if(r == NULL)
++ mag_memory_error("malloc", fn);
++ return r;
++}
++
++static void *mag_realloc(p, n, fn)
++ void *p;
++ size_t n;
++ char *fn;
++{
++ void *r = (p == NULL) ? (void *) malloc(n) : (void *) realloc(p, n);
++ if(r == NULL)
++ mag_memory_error("realloc", fn);
++ 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
+@@ -0,0 +1,794 @@
++/*
++ * xvmaki.c - load routine for `MAKI' format pictures.
++ *
++ * The `MAKI' format was used by some Japanese personal computer users.
++ */
++
++#include "xv.h"
++#include <setjmp.h>
++
++#ifdef HAVE_MAKI
++
++typedef unsigned short data16;
++typedef unsigned int data32;
++
++struct maki_info {
++ jmp_buf jmp;
++ FILE *fp;
++ long fsize;
++ int x0, y0, x1, y1;
++ int width, height;
++ float aspect;
++ long fb_size;
++ long pa_size, pb_size;
++ int m_maki01b, m_200, m_dig8;
++ data16 ext_flag;
++ byte *fa, *fb, *pa, *pb;
++ byte *vs;
++ int numcols;
++ byte *forma, *formb;
++};
++
++
++static void maki_open_file PARM((struct maki_info*, char*));
++static void maki_check_id PARM((struct maki_info*));
++static void maki_skip_comment PARM((struct maki_info*));
++static void maki_read_header PARM((struct maki_info*));
++static void maki_read_palette PARM((struct maki_info*,
++ byte*, byte*, byte*));
++static void maki_read_flags PARM((struct maki_info*));
++static void maki_read_pixel_data PARM((struct maki_info*));
++static void maki_expand_virtual_screen PARM((struct maki_info*));
++static void maki_expand_pixel_data PARM((struct maki_info*, byte**));
++static void maki_init_info PARM((struct maki_info*));
++
++static void maki_make_pixel_data PARM((struct maki_info*, byte*));
++static void maki_make_virtual_screen PARM((struct maki_info*));
++static void maki_make_flags PARM((struct maki_info*));
++static void maki_write_check_id PARM((struct maki_info*));
++static void maki_write_comment PARM((struct maki_info*));
++static void maki_write_header PARM((struct maki_info*));
++static void maki_write_palette PARM((struct maki_info*,
++ byte*, byte*, byte*, int));
++static void maki_write_flags PARM((struct maki_info*));
++static void maki_write_pixel_data PARM((struct maki_info*));
++
++static void maki_cleanup_maki_info PARM((struct maki_info*, int));
++static void maki_cleanup_pinfo PARM((PICINFO*));
++static void maki_memory_error PARM((char*, char*));
++static void maki_error PARM((struct maki_info*, int));
++static void maki_file_error PARM((struct maki_info*, int));
++static void maki_file_warning PARM((struct maki_info*, int));
++static void maki_show_maki_info PARM((struct maki_info*));
++static void *maki_malloc PARM((size_t, char*));
++static void *maki_realloc PARM((void *, size_t, char*));
++
++static char maki_id_a[] = "MAKI01A ";
++static char maki_id_b[] = "MAKI01B ";
++
++static char *maki_msgs[] = {
++ NULL,
++#define MAKI_OPEN 1
++ "can't open file.",
++#define MAKI_CORRUPT 2
++ "file corrupted.",
++#define MAKI_FORMAT 3
++ "not MAKI format.",
++#define MAKI_BAD_DATA 4
++ "bad data.",
++#define MAKI_COMMENT 5
++ "no '^Z' after comment.",
++#define MAKI_SIZE 6
++ "bad size.",
++#define MAKI_WRITE 7
++ "write failed.",
++};
++
++#define H4(b) ((b) >> 4 & 0xf)
++#define L4(b) ((b) & 0xf)
++#define error(msg_num) longjmp(mi->jmp, msg_num)
++
++int LoadMAKI(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++{
++ struct maki_info maki;
++ int e;
++
++ if(DEBUG) fputs("LoadMAKI:\n", stderr);
++
++ pinfo->comment = NULL;
++ maki_init_info(&maki);
++ if((e = setjmp(maki.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ maki_cleanup_maki_info(&maki, 0);
++ maki_cleanup_pinfo(pinfo);
++ return 0;
++ }
++
++ maki_open_file(&maki, fname);
++ maki_check_id(&maki);
++ maki_skip_comment(&maki);
++ maki_read_header(&maki);
++ maki_read_palette(&maki, pinfo->r, pinfo->g, pinfo->b);
++ maki_read_flags(&maki);
++ maki_read_pixel_data(&maki);
++ maki_expand_virtual_screen(&maki);
++ maki_expand_pixel_data(&maki, &pinfo->pic);
++
++ pinfo->w = pinfo->normw = maki.width;
++ pinfo->h = pinfo->normh = maki.height;
++ pinfo->type = PIC8;
++ pinfo->frmType = F_MAKI;
++ pinfo->colType = F_FULLCOLOR;
++ sprintf(pinfo->fullInfo, "MAKI, 16 colors (%ld bytes)", maki.fsize);
++ sprintf(pinfo->shrtInfo, "%dx%d MAKI", maki.width, maki.height);
++ normaspect = maki.aspect;
++
++ maki_cleanup_maki_info(&maki, 0);
++ return 1;
++}
++
++static void maki_open_file(mi, fname)
++ struct maki_info *mi;
++ char *fname;
++{
++ if((mi->fp = fopen(fname, "rb")) == NULL)
++ maki_file_error(mi, MAKI_OPEN);
++ fseek(mi->fp, (size_t) 0, SEEK_END);
++ mi->fsize = ftell(mi->fp);
++ fseek(mi->fp, (size_t) 0, SEEK_SET);
++}
++
++static void maki_check_id(mi)
++ struct maki_info *mi;
++{
++ char buf[8];
++ if(fread(buf, (size_t) 8, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_CORRUPT);
++ if(strncmp(buf, maki_id_a, (size_t) 8) != 0 &&
++ strncmp(buf, maki_id_b, (size_t) 8) != 0)
++ maki_error(mi, MAKI_FORMAT);
++ mi->m_maki01b = (buf[6] == 'B');
++}
++
++static void maki_skip_comment(mi)
++ struct maki_info *mi;
++{
++ int i;
++ int c;
++
++ for(i = 0; i < 24; i++){
++ if((c = fgetc(mi->fp)) == EOF)
++ maki_file_error(mi, MAKI_CORRUPT);
++ if(c == '\032') /* ^Z, 0x1a */
++ break;
++ }
++ if(c != '\032')
++ maki_file_error(mi, MAKI_COMMENT);
++
++ fseek(mi->fp, 32L, SEEK_SET);
++}
++
++static void maki_read_header(mi)
++ struct maki_info *mi;
++{
++ byte buf[16];
++
++ if(fread(buf, (size_t) 16, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_CORRUPT);
++
++ mi->fb_size = (long)buf[ 0] << 8 | (long)buf[ 1];
++ mi->pa_size = (long)buf[ 2] << 8 | (long)buf[ 3];
++ mi->pb_size = (long)buf[ 4] << 8 | (long)buf[ 5];
++ mi->ext_flag = (long)buf[ 6] << 8 | (long)buf[ 7];
++ mi->x0 = (long)buf[ 8] << 8 | (long)buf[ 9];
++ mi->y0 = (long)buf[10] << 8 | (long)buf[11];
++ mi->x1 = (long)buf[12] << 8 | (long)buf[13];
++ mi->y1 = (long)buf[14] << 8 | (long)buf[15];
++
++ mi->width = mi->x1-- - mi->x0;
++ mi->height = mi->y1-- - mi->y0;
++ mi->m_200 = mi->ext_flag & 1;
++ mi->m_dig8 = mi->ext_flag & 2;
++ mi->aspect = mi->m_200 ? 0.5 : 1.0;
++
++ if(DEBUG) maki_show_maki_info(mi);
++}
++
++static void maki_read_palette(mi, r, g, b)
++ struct maki_info *mi;
++ byte *r, *g, *b;
++{
++ byte buf[48], *p;
++
++ if(fread(buf, (size_t) 48, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_CORRUPT);
++
++ for(p = buf; p < &buf[48]; ){
++ *g++ = *p++;
++ *r++ = *p++;
++ *b++ = *p++;
++ }
++}
++
++static void maki_read_flags(mi)
++ struct maki_info *mi;
++{
++ mi->fa = maki_malloc((size_t) 1000 , "maki_read_flags#1");
++ mi->fb = maki_malloc((size_t) mi->fb_size, "maki_read_flags#2");
++
++ if(fread(mi->fa, (size_t) 1000, (size_t) 1, mi->fp) != 1)
++ maki_file_warning(mi, MAKI_CORRUPT);
++ if(fread(mi->fb, (size_t) mi->fb_size, (size_t) 1, mi->fp) != 1)
++ maki_file_warning(mi, MAKI_CORRUPT);
++}
++
++static void maki_read_pixel_data(mi)
++ struct maki_info *mi;
++{
++ mi->pa = maki_malloc((size_t) mi->pa_size, "maki_read_pixel_data#1");
++ mi->pb = maki_malloc((size_t) mi->pb_size, "maki_read_pixel_data#2");
++
++ if(fread(mi->pa, (size_t) mi->pa_size, (size_t) 1, mi->fp) != 1)
++ maki_file_warning(mi, MAKI_CORRUPT);
++ if(fread(mi->pb, (size_t) mi->pb_size, (size_t) 1, mi->fp) != 1)
++ maki_file_warning(mi, MAKI_CORRUPT);
++}
++
++static void maki_expand_virtual_screen(mi)
++ struct maki_info *mi;
++{
++ int x, y, fai, fbi;
++ int bpl = mi->width / 2 / 8; /* bytes per line */
++ byte mask;
++ mi->vs = maki_malloc((size_t) bpl * mi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "maki_expand_virtual_screen");
++
++ fai = fbi = 0;
++ mask = 0x80;
++ for(y = 0; y < mi->height; y += 4){
++ for(x = 0; x < mi->width / 2; x += 4){
++ if(mi->fa[fai] & mask){
++ byte bh, bl;
++ bh = mi->fb[fbi++];
++ bl = mi->fb[fbi++];
++ if(x % 8 == 0){
++ mi->vs[ y * bpl + x / 8] = H4(bh) << 4;
++ mi->vs[(y + 1) * bpl + x / 8] = L4(bh) << 4;
++ mi->vs[(y + 2) * bpl + x / 8] = H4(bl) << 4;
++ mi->vs[(y + 3) * bpl + x / 8] = L4(bl) << 4;
++ }else{
++ mi->vs[ y * bpl + x / 8] |= H4(bh);
++ mi->vs[(y + 1) * bpl + x / 8] |= L4(bh);
++ mi->vs[(y + 2) * bpl + x / 8] |= H4(bl);
++ mi->vs[(y + 3) * bpl + x / 8] |= L4(bl);
++ }
++ }else{
++ if(x % 8 == 0){
++ mi->vs[ y * bpl + x / 8] = 0;
++ mi->vs[(y + 1) * bpl + x / 8] = 0;
++ mi->vs[(y + 2) * bpl + x / 8] = 0;
++ mi->vs[(y + 3) * bpl + x / 8] = 0;
++ }else{
++/* mi->vs[ y * bpl + x / 8] |= 0;
++ mi->vs[(y + 1) * bpl + x / 8] |= 0;
++ mi->vs[(y + 2) * bpl + x / 8] |= 0;
++ mi->vs[(y + 3) * bpl + x / 8] |= 0; */
++ }
++ }
++
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ fai++;
++ }
++ }
++ }
++}
++
++static void maki_expand_pixel_data(mi, pic)
++ struct maki_info *mi;
++ byte **pic;
++{
++ int x, y;
++ int vsi, pi, max_pi;
++ byte *p;
++ byte mask;
++ int gap;
++ *pic = maki_malloc((size_t) mi->width * mi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "maki_expand_pixel_data");
++
++ vsi = pi = 0;
++ p = mi->pa;
++ max_pi = mi->pa_size - 1;
++ mask = 0x80;
++ for(y = 0; y < mi->height; y++){
++ for(x = 0; x < mi->width; x += 2){
++ if(mi->vs[vsi] & mask){
++ if(pi > max_pi){
++ if(p == mi->pb)
++ maki_error(mi, MAKI_BAD_DATA);
++ pi = 0;
++ p = mi->pb;
++ max_pi = mi->pb_size - 1;
++ }
++ (*pic)[y * mi->width + x ] = H4(p[pi]);
++ (*pic)[y * mi->width + x + 1] = L4(p[pi]);
++ pi++;
++ }else{
++ (*pic)[y * mi->width + x ] = 0;
++ (*pic)[y * mi->width + x + 1] = 0;
++ }
++
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ vsi++;
++ }
++ }
++ }
++
++ gap = mi->m_maki01b ? 4 : 2;
++
++ for(y = gap; y < mi->height; y++){
++ for(x = 0; x < mi->width; x++)
++ (*pic)[y * mi->width + x] ^= (*pic)[(y - gap) * mi->width + x];
++ }
++}
++
++
++int WriteMAKI(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;
++{
++ byte rtemp[256], gtemp[256], btemp[256];
++ struct maki_info maki, *mi = &maki;
++ int e;
++
++ if(DEBUG) fputs("WriteMAKI:\n", stderr);
++
++ maki_init_info(&maki);
++ if((e = setjmp(maki.jmp)) != 0){
++ /* An error occurs */
++ maki_cleanup_maki_info(&maki, 1);
++ return -1;
++ }
++
++ if(w != 640 || h != 400) {
++ char str[512];
++ sprintf(str,"MAKI: %s Should be 640x400", maki_msgs[MAKI_SIZE]);
++ ErrPopUp(str, "\nBummer!");
++ maki_error(mi, MAKI_SIZE);
++ }
++
++ maki.fp = fp;
++ maki.width = w;
++ maki.height = h;
++ maki.x1 = w - 1;
++ maki.y1 = h - 1;
++
++ if(ptype == PIC24){
++ if(!(pic = Conv24to8(pic, w, h, 16, rtemp, gtemp, btemp)))
++ maki_memory_error("Conv24to8#1", "WriteMAKI");
++ rmap = rtemp;
++ gmap = gtemp;
++ bmap = btemp;
++ }else if(numcols > 16){
++ if(!(pic = Conv8to24(pic, w, h, rmap, gmap, bmap)))
++ maki_memory_error("Conv8to24", "WriteMAKI");
++ if(!(pic = Conv24to8(pic, w, h, 16, rtemp, gtemp, btemp)))
++ maki_memory_error("Conv24to8#2", "WriteMAKI");
++ rmap = rtemp;
++ gmap = gtemp;
++ bmap = btemp;
++ }else
++ maki.numcols = numcols;
++
++ maki_make_pixel_data(&maki, pic);
++ maki_make_virtual_screen(&maki);
++ maki_make_flags(&maki);
++ maki_write_check_id(&maki);
++ maki_write_comment(&maki);
++ maki_write_header(&maki);
++ maki_write_palette(&maki, rmap, gmap, bmap, colorstyle == F_GREYSCALE);
++ maki_write_flags(&maki);
++ maki_write_pixel_data(&maki);
++
++ maki_cleanup_maki_info(&maki, 1);
++ return 0;
++}
++
++static void maki_make_pixel_data(mi, pic)
++ struct maki_info *mi;
++ byte *pic;
++{
++ int x, y, i;
++ int nza, nzb;
++
++ mi->forma = maki_malloc((size_t) mi->width / 2 * mi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "maki_make_pixel_data#1");
++ mi->formb = maki_malloc((size_t) mi->width / 2 * mi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "maki_make_pixel_data#2");
++
++ for(y = 0; y < mi->height; y++){
++ for(x = 0; x < mi->width; x += 2){
++ byte b;
++ b = pic[y * mi->width + x] << 4 | pic[y * mi->width + x + 1];
++ mi->forma[y * mi->width / 2 + x / 2] = b;
++ mi->formb[y * mi->width / 2 + x / 2] = b;
++ }
++ }
++
++ for(y = mi->height - 1; y >= 2; y--){
++ for(x = 0; x < mi->width / 2; x++){
++ mi->forma[y * mi->width / 2 + x] ^=
++ mi->forma[(y - 2) * mi->width / 2 + x];
++ }
++ }
++
++ for(y = mi->height - 1; y >= 4; y--){
++ for(x = 0; x < mi->width / 2; x++){
++ mi->formb[y * mi->width / 2 + x] ^=
++ mi->formb[(y - 4) * mi->width / 2 + x];
++ }
++ }
++
++ nza = nzb = 0;
++ for(i = 0; i < mi->width / 2 * mi->height; i++){
++ if(mi->forma[i] != 0)
++ nza++;
++ if(mi->formb[i] != 0)
++ nzb++;
++ }
++ if(nza > nzb){
++ mi->m_maki01b = 1;
++ free(mi->forma);
++ mi->forma = NULL;
++ }else{
++ mi->m_maki01b = 0;
++ free(mi->formb);
++ mi->formb = NULL;
++ }
++}
++
++static void maki_make_virtual_screen(mi)
++ struct maki_info *mi;
++{
++ int bpl = mi->width / 2 / 8;
++ int vsi, pai, pbi, max_pai, max_pbi;
++ byte mask;
++ byte *pixels;
++ int x, y;
++
++ mi->vs = maki_malloc((size_t) bpl * mi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "maki_make_virtual_screen#1");
++
++ if(mi->m_maki01b)
++ pixels = mi->formb;
++ else
++ pixels = mi->forma;
++
++ vsi = pai = pbi = 0;
++ max_pai = max_pbi = -1;
++ mask = 0x80;
++ for(y = 0; y < mi->height; y++){
++ for(x = 0; x < mi->width / 2; x++){
++ if(pixels[y * mi->width / 2 + x] == 0){
++ mi->vs[vsi] &= ~mask;
++ }else{
++ mi->vs[vsi] |= mask;
++ if(y < 200){
++ if(pai > max_pai){
++ max_pai += 1024;
++ mi->pa = maki_realloc(mi->pa, (size_t) max_pai + 1,
++ "maki_make_virtual_screen#2");
++ }
++ mi->pa[pai++] = pixels[y * mi->width / 2 + x];
++ }else{
++ if(pbi > max_pbi){
++ max_pbi += 1024;
++ mi->pb = maki_realloc(mi->pb, (size_t) max_pbi + 2,
++ "maki_make_virtual_screen#3");
++ }
++ mi->pb[pbi++] = pixels[y * mi->width / 2 + x];
++ }
++ }
++
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ vsi++;
++ }
++ }
++ }
++
++ mi->pa_size = pai;
++ mi->pb_size = pbi;
++}
++
++static void maki_make_flags(mi)
++ struct maki_info *mi;
++{
++ int bpl = mi->width / 2 / 8;
++ int fbi, max_fbi;
++ int fai;
++ int x, y;
++ byte mask;
++
++ mi->fa = maki_malloc((size_t) bpl * mi->height, "maki_make_flags#1"); // GRR POSSIBLE OVERFLOW / FIXME
++
++ fbi = fai = 0;
++ max_fbi = -1;
++ mask = 0x80;
++ for(y = 0; y < mi->height; y += 4){
++ for(x = 0; x < mi->width / 2; x += 4){
++ if(x % 8 == 0){
++ if(H4(mi->vs[ y * bpl + x / 8]) == 0 &&
++ H4(mi->vs[(y + 1) * bpl + x / 8]) == 0 &&
++ H4(mi->vs[(y + 2) * bpl + x / 8]) == 0 &&
++ H4(mi->vs[(y + 3) * bpl + x / 8]) == 0){
++ mi->fa[fai] &= ~mask;
++ }else{
++ mi->fa[fai] |= mask;
++ if(fbi + 1 > max_fbi){
++ max_fbi += 1024;
++ mi->fb = maki_realloc(mi->fb, (size_t) max_fbi + 1,
++ "maki_make_flags#2");
++ }
++ mi->fb[fbi++] = H4(mi->vs[ y * bpl + x / 8]) << 4
++ | H4(mi->vs[(y + 1) * bpl + x / 8]);
++ mi->fb[fbi++] = H4(mi->vs[(y + 2) * bpl + x / 8]) << 4
++ | H4(mi->vs[(y + 3) * bpl + x / 8]);
++ }
++ }else{
++ if(L4(mi->vs[ y * bpl + x / 8]) == 0 &&
++ L4(mi->vs[(y + 1) * bpl + x / 8]) == 0 &&
++ L4(mi->vs[(y + 2) * bpl + x / 8]) == 0 &&
++ L4(mi->vs[(y + 3) * bpl + x / 8]) == 0){
++ mi->fa[fai] &= ~mask;
++ }else{
++ mi->fa[fai] |= mask;
++ if(fbi + 1 > max_fbi){
++ max_fbi += 1024;
++ mi->fb = maki_realloc(mi->fb, (size_t) max_fbi + 1,
++ "maki_make_flags#3");
++ }
++ mi->fb[fbi++] = L4(mi->vs[ y * bpl + x / 8]) << 4
++ | L4(mi->vs[(y + 1) * bpl + x / 8]);
++ mi->fb[fbi++] = L4(mi->vs[(y + 2) * bpl + x / 8]) << 4
++ | L4(mi->vs[(y + 3) * bpl + x / 8]);
++ }
++ }
++
++ if((mask >>= 1) == 0){
++ mask = 0x80;
++ fai++;
++ }
++ }
++ }
++
++ mi->fb_size = fbi;
++}
++
++static void maki_write_check_id(mi)
++ struct maki_info *mi;
++{
++ char *id = mi->m_maki01b ? maki_id_b : maki_id_a;
++ if(fwrite(id, (size_t) 8, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++}
++
++static void maki_write_comment(mi)
++ struct maki_info *mi;
++{
++ char buf[24];
++ char *p;
++ int i = 0;
++
++ strcpy(buf, "XV ");
++
++ if((p = (char *) getenv("USER")) == NULL)
++ p = "????????";
++ for(i = 5; i < 23; i++){
++ if(*p == '\0')
++ break;
++ buf[i] = *p++;
++ }
++ for( ; i < 23; i++)
++ buf[i] = ' ';
++
++ buf[i] = '\032'; /* ^Z, 0x1a */
++
++ if(fwrite(buf, (size_t) 24, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++}
++
++static void maki_write_header(mi)
++ struct maki_info *mi;
++{
++ byte buf[16];
++
++ if(DEBUG) maki_show_maki_info(mi);
++
++#define set_word(i, v) {buf[i]=(v)>>8&0xff;buf[i+1]=(v)&0xff;}
++ set_word(0, mi->fb_size);
++ set_word(2, mi->pa_size);
++ set_word(4, mi->pb_size);
++ set_word(6, mi->ext_flag);
++ set_word(8, mi->x0);
++ set_word(10, mi->y0);
++ set_word(12, mi->x1 + 1);
++ set_word(14, mi->y1 + 1);
++#undef set_word
++
++ if(fwrite(buf, (size_t) 16, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++}
++
++static void maki_write_palette(mi, r, g, b, grey)
++ struct maki_info *mi;
++ byte *r, *g, *b;
++ int grey;
++{
++ int i;
++ char buf[3];
++ for(i = 0; i < mi->numcols; i++){
++ buf[0] = *g++;
++ buf[1] = *r++;
++ buf[2] = *b++;
++ if(grey)
++ buf[0] = buf[1] = buf[2] = MONO(buf[1], buf[0], buf[2]);
++ if(fwrite(buf, (size_t) 3, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++ }
++ for( ; i < 16; i++){
++ if(fwrite(buf, (size_t) 3, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++ }
++}
++
++static void maki_write_flags(mi)
++ struct maki_info *mi;
++{
++ int bpl = mi->width / 2 / 8;
++ if(fwrite(mi->fa, (size_t) bpl * mi->height / 16, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++
++ if(fwrite(mi->fb, (size_t) mi->fb_size, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++}
++
++static void maki_write_pixel_data(mi)
++ struct maki_info *mi;
++{
++ if(fwrite(mi->pa, (size_t) mi->pa_size, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++
++ if(fwrite(mi->pb, (size_t) mi->pb_size, (size_t) 1, mi->fp) != 1)
++ maki_file_error(mi, MAKI_WRITE);
++}
++
++
++
++static void maki_init_info(mi)
++ struct maki_info *mi;
++{
++ xvbzero((char *)mi, sizeof(struct maki_info));
++ mi->fp = NULL;
++ mi->fsize = 0;
++ mi->x0 = mi->y0 = mi->x1 = mi->y1 = 0;
++ mi->width = mi->height = 0;
++ mi->aspect = 1.0;
++ mi->fb_size = mi->pa_size = mi->pb_size = 0;
++ mi->m_maki01b = mi->m_200 = mi->m_dig8 = 0;
++ mi->ext_flag = 0;
++ mi->fa = mi->fb = mi->pa = mi->pb = NULL;
++ mi->vs = NULL;
++ mi->numcols = 16;
++ mi->forma = mi->formb = NULL;
++}
++
++static void maki_cleanup_maki_info(mi, writing)
++ struct maki_info *mi;
++ int writing;
++{
++ if(mi->fp && !writing)
++ fclose(mi->fp);
++ if(mi->fa)
++ free(mi->fa);
++ if(mi->fb)
++ free(mi->fb);
++ if(mi->pa)
++ free(mi->pa);
++ if(mi->pb)
++ free(mi->pb);
++ if(mi->vs)
++ free(mi->vs);
++ if(mi->forma)
++ free(mi->forma);
++ if(mi->formb)
++ free(mi->formb);
++}
++
++static void maki_cleanup_pinfo(pi)
++ PICINFO *pi;
++{
++ if(pi->pic){
++ free(pi->pic);
++ pi->pic = NULL;
++ }
++}
++
++static void maki_memory_error(scm, fn)
++ char *scm, *fn;
++{
++ char buf[128];
++ sprintf(buf, "%s: coulndn't allocate memory. (%s)", scm, fn);
++ FatalError(buf);
++}
++
++static void maki_error(mi, mn)
++ struct maki_info *mi;
++ int mn;
++{
++ SetISTR(ISTR_WARNING, "%s", maki_msgs[mn]);
++ longjmp(mi->jmp, 1);
++}
++
++static void maki_file_error(mi, mn)
++ struct maki_info *mi;
++ int mn;
++{
++ if(feof(mi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", maki_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", maki_msgs[mn], ERRSTR(errno));
++ longjmp(mi->jmp, 1);
++}
++
++static void maki_file_warning(mi, mn)
++ struct maki_info *mi;
++ int mn;
++{
++ if(feof(mi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", maki_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", maki_msgs[mn], ERRSTR(errno));
++}
++
++static void maki_show_maki_info(mi)
++ struct maki_info *mi;
++{
++ fprintf(stderr, " file size: %ld.\n", mi->fsize);
++ fprintf(stderr, " image size: %dx%d.\n", mi->width, mi->height);
++ fprintf(stderr, " aspect: %f.\n", mi->aspect);
++ fprintf(stderr, " flag B size: %ld.\n", mi->fb_size);
++ fprintf(stderr, " pixel data size: A:%ld, B:%ld.\n",
++ mi->pa_size, mi->pb_size);
++ fprintf(stderr, " MAKI01B: %s.\n", mi->m_maki01b ? "true" : "false");
++ fprintf(stderr, " 200 line mode: %s.\n", mi->m_200 ? "true" : "false");
++ fprintf(stderr, " digital 8 colors: %s.\n", mi->m_dig8 ? "true" : "false");
++}
++
++static void *maki_malloc(n, fn)
++ size_t n;
++ char *fn;
++{
++ void *r = (void *) malloc(n);
++ if(r == NULL)
++ maki_memory_error("malloc", fn);
++ return r;
++}
++
++static void *maki_realloc(p, n, fn)
++ void *p;
++ size_t n;
++ char *fn;
++{
++ void *r = (p == NULL) ? (void *) malloc(n) : (void *) realloc(p, n);
++ if(r == NULL)
++ maki_memory_error("realloc", fn);
++ 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
+@@ -0,0 +1,2276 @@
++/*
++ * $Id: xvmgcsfx.c,v 1.23 95/11/27 19:03:36 tin329 Exp Locker: tin329 $
++ * xvmgcsfx.c - Use the filters as input and output method.
++ *
++ * Features
++ * ========
++ * 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" .
++ *
++ * Bugs
++ * ====
++ * There are many bugs.
++ * Let's go hunting for insects with an insect net. (it's all joke.)
++ *
++ * Author
++ * ======
++ * Tetsuya INOUE <tin329@chino.it.okayama-u.ac.jp>
++ */
++
++/*
++ * Known Bugs and Todo / $B$"$l$3$l5$$K$J$k$3$H(B
++ *
++ * ~/.xv_mgcsfx $BFb(B
++ * $B!&Dj5A$,IT40A4$@$H%(%i!<(B (':'$B$N?t(B)$B!#(B
++ * $B!&%G%j%_%?$H$7$F(B ':' $B$r;H$&$N$G!"%9%?!<%H%"%C%W%U%!%$%kFb$G(B
++ * ':' $B$rMQ$$$FDj5A$O$G$-$J$$!#(B'\:'$B$G$b%@%a!#(B
++ * $B!&(B magic $B%?%$%W$G!"#8?J?t$O#37eJ,#0!A#7$rD4$Y!"#1#6?J?t$O(B
++ * isxdigit $B$,??$rJV$94VCf=hM}$5$l$k!#$7$+$7!"#1#b#y#t#e$H(B
++ * $B$7$F$7$+I>2A$5$l$J$$!#(B
++ * $B!&%W%j%W%m%;%C%5$r;H$&$H$-$O!"%3%a%s%H$N=q$-J}$KCm0U$7$J$1$l$P$J(B
++ * $B$i$J$$!#%W%j%W%m%;%C%5$K$h$C$F$O%3%a%s%H$,%(%i!<$K$J$k!#(B
++ * $B!&%Q%$%W$X$NF~=PNO$N%U%)!<%^%C%H$N<oN`$,(B PNM $B$N$_(B
++ * $BF~NO(B
++ * $B%U%!%$%k%]%$%s%?$r(B seek $B$7$F$O$$$1$J$$(B
++ * $B%U%!%$%k%5%$%:$rMQ$$$F$O$$$1$J$$(B
++ * $B=PNO(B
++ * $B%U%!%$%k%]%$%s%?$r(B seek $B$7$F$O$$$1$J$$(B
++ * exec $B$G$-$J$/$F=*N;$7$?%W%m%;%9$K=q$-9~$_IT2D(B
++ * $B!&%5%U%#%C%/%9$H%^%8%C%/%J%s%P!<$N;H$$J,$1$r$I$&$9$k$+!#(B
++ * $B%^%8%C%/%J%s%P!<$,F1$8$G!"%5%U%#%C%/%9$,0[$J$k>l9g$rG'$a$k$+!)(B
++ * $B!&(Bcompress(gzip)$B$N%U%!%$%k$O%F%s%]%i%j$G$O(B xvtmp??? $B$H$$$&L>A0$J(B
++ * $B$N$G(B suffix $B$G$O<1JL$G$-$J$$!#(B
++ *
++ * $BG'<1$9$k;~$K(B MACBINARY $B$K$OIi$1$k(B(in xv.c)$B!#(B
++ *
++ * $BB?=E$K(B pipe $B$rDL$9$3$H$,$G$-$J$$!#(B(pipe $B$,(B seek $B$G$-$J$$$+$i(B)
++ * $B!&(Bsocketpair $B$G!"(Brecv $B$K(B MSG_PEEK $B%U%i%0$r$D$+$C$F6uFI$_$9$k!#(B
++ * $B!&$3$l$r$d$k$H%U%!%$%k$NG'<1$,$a$A$c$a$A$cCY$/$J$k!#(B
++ *
++ * $B%j%=!<%9$G@_Dj(B
++ * $B!&%j%=!<%9$G@_Dj$9$kJ}$,LLE]$/$5$$(B
++ *
++ * $B%^%8%C%/%J%s%P!<$N@_Dj$K@55,I=8=(B
++ *
++ * $B%;!<%VMQ%W%m%;%9$,<:GT$9$k>l9g$NBP:v$,:#0l$D(B
++ *
++ * DEC OSF/1 V3.0 $B$G$O!"%Q%$%W$K%G!<%?$,$^$@$J$$;~$KFI$_9~$b$&$H$9$k$H!"(B
++ * read $B$,IT40A4$K$J$k!#(B(in xvpbm.c)
++ * $BF1MM$K=q$-9~$_;~$K$bLdBj$,@8$8$k$+$b$7$l$J$$!#(B
++ */
++
++#define NEEDSDIR /* for stat() */
++#include "xv.h"
++
++
++#ifdef HAVE_MGCSFX
++
++
++#ifdef __osf__
++# ifdef __alpha
++# define ARCHITECTURE64 1
++# endif /* __alpha */
++#endif /* __osf__ */
++
++#ifdef ARCHITECTURE64
++typedef short int16;
++typedef int int32;
++typedef long int64;
++#else
++typedef short int16;
++typedef long int32;
++#endif /* ARCHITECTURE64 */
++
++#ifdef sgi
++# define vfork fork
++#endif
++
++#define USE_SIGCHLD
++#if 0
++# undef USE_SIGCHLD
++#endif
++
++#ifdef USE_SIGCHLD
++# include <sys/wait.h>
++#endif
++
++typedef struct _mgcsfxtab
++{
++ struct _mgcsfxtab *next;
++ char *description;
++ int mgcsfx_type;
++ int offset;
++ union{
++ int16 int16_data;
++ int32 int32_data;
++ char *string_data;
++ } dt;
++ int string_len;
++ char *suffix;
++ int input_image_type;
++ char *input_command;
++ int output_image_type;
++ char *output_command;
++} mgcsfxtab;
++
++
++#ifndef MGCSFXDIR
++# define MGCSFXDIR "/usr/local/lib"
++#endif
++#ifndef SYSCONFDIR
++# define SYSCONFDIR MGCSFXDIR
++#endif
++#ifndef MGCSFX_SITE_RC
++# define MGCSFX_SITE_RC "xv_mgcsfx"
++#endif
++#ifndef MGCSFX_RC
++# define MGCSFX_RC ".xv_mgcsfx"
++#endif
++
++#ifdef USE_MGCSFX_PREPROCESSOR
++# ifndef MGCSFX_PREPROCESSOR
++# define MGCSFX_PREPROCESSOR "/usr/lib/cpp"
++# endif
++#endif
++
++
++/* Check type for Magic number and Suffix */
++enum {T_UNKNOWN,
++ T_MAGIC, T_SUFFIX,
++ T_BEINT16, T_BEINT32, T_BEINT64,
++ T_LEINT16, T_LEINT32, T_LEINT64};
++
++/* Image Type for input and output format */
++enum {IT_UNKNOWN,
++#ifdef HAVE_MGCSFX_AUTO
++ IT_AUTO,
++#endif /* HAVE_MGCSFX_AUTO */
++ IT_PNM, IT_PPM, IT_PGM, IT_PBM,
++ IT_PNM_RAW, IT_PPM_RAW, IT_PGM_RAW, IT_PBM_RAW,
++ IT_PNM_ASCII, IT_PPM_ASCII, IT_PGM_ASCII, IT_PBM_ASCII,
++ IT_GIF, IT_JPEG, IT_TIFF, IT_JFIF, /* IT_PS, IT_COMPRESS,*/
++ IT_XBM, IT_XPM, IT_BMP, IT_SUNRAS, IT_IRIS, IT_XWD,
++ /* IT_TARGA, IT_FITS, IT_PM, IT_UTAHRLE, IT_PCX, IT_PDSVICAR, IT_IFF, */
++ IT_MAG, IT_MAKI, IT_PI, IT_PIC, IT_PIC2 /* , IT_PCD */};
++
++
++/*--------------------------------------------------------------------------*/
++void mgcsfx_handler PARM((int));
++void mgcsfx_handler_setup PARM((void));
++
++#ifdef USE_MGCSFX_PREPROCESSOR
++static char *get_tmp_fname PARM((void));
++static char *make_preprocessed_file PARM((char *));
++#endif /* USE_MGCSFX_PREPROCESSOR */
++
++int is_mgcsfx PARM((char *, unsigned char *, int));
++
++char *mgcsfx_auto_input_com PARM((char *));
++
++
++static mgcsfxtab *free_mgcsfx PARM((mgcsfxtab *));
++static char *fgettoken PARM((FILE*, int));
++static int string_fin PARM((char *));
++static int type_mgcsfx PARM((char *));
++static int type_image PARM((char *));
++
++static void read_mgcsfx PARM((mgcsfxtab **, char *));
++static void init_mgcsfx PARM((void));
++static mgcsfxtab *find_mgcsfx PARM((char *, unsigned char *, int));
++
++int LoadMGCSFX PARM((char *, PICINFO *));
++
++#ifdef SVR4
++typedef void Sigfunc(int);
++static Sigfunc *xv_signal PARM((int , Sigfunc *));
++#endif
++
++/*--------------------------------------------------------------------------*/
++mgcsfxtab *mgcsfx_table = NULL;
++int mgcsfx_setup_flag = 0;
++
++int nitem_mgcsfx = 0;
++int desc_width = 0;
++
++int max_offset_mgcsfx = 0;
++int max_length_mgcsfx = 0;
++int need_buf_size = 0;
++
++static char input_command_ex[1024];
++static int input_command_ex_flag = 0;
++
++#ifdef USE_SIGCHLD
++static int w_p_fail=0;
++#endif
++
++/*--------------------------------------------------------------------------*/
++
++/***************************************************/
++void mgcsfx_handler(sig)
++ int sig;
++{
++#ifdef USE_SIGCHLD
++ int pid, pst;
++#endif
++
++#if defined(SYSV) || defined(SVR4)
++ sighold(sig);
++#else
++ sigblock(sigmask(sig));
++#endif
++
++#ifdef USE_SIGCHLD
++ if(w_p_fail == 1){
++ /*
++ * At this point, process write to broken pipe.
++ * Probably external command was can't exec.
++ */
++ w_p_fail = 2;
++ pid = wait(&pst);
++ }
++#endif
++
++ return;
++
++ /* Quit(1); */ /*exit(1);*/
++}
++
++void mgcsfx_handler_setup()
++{
++#ifdef SVR4
++ xv_signal(SIGPIPE, (void (*)PARM((int))) mgcsfx_handler);
++ xv_signal(SIGCHLD, (void (*)PARM((int))) mgcsfx_handler);
++#else
++# ifdef SYSV
++ sigset(SIGPIPE, (void (*)PARM((int))) mgcsfx_handler);
++ sigset(SIGCHLD, (void (*)PARM((int))) mgcsfx_handler);
++# else
++ signal(SIGPIPE, (void (*)PARM((int))) mgcsfx_handler);
++ signal(SIGCHLD, (void (*)PARM((int))) mgcsfx_handler);
++# endif
++#endif
++}
++
++/***************************************************/
++#ifdef USE_MGCSFX_PREPROCESSOR
++static char *get_tmp_fname()
++{
++ static char tmp[MAXPATHLEN+1];
++
++#ifndef VMS
++ sprintf(tmp, "%s/xvmgcsfxXXXXXX",tmpdir);
++#else
++ /* sprintf(tmp, "Sys$Scratch:xvmgcsfxXXXXXX"); */
++ strcpy(tmp, "[]xvmgcsfxXXXXXX");
++#endif /* VMS */
++
++#ifdef USE_MKSTEMP
++ close(mkstemp(tmp));
++#else
++ mktemp(tmp);
++#endif
++
++ return tmp;
++}
++
++static char *make_preprocessed_file(fname)
++ char *fname;
++{
++ char buf[512];
++ char *tmp_name;
++
++ tmp_name = get_tmp_fname();
++
++#ifndef VMS
++ sprintf(buf,"%s %s > %s", MGCSFX_PREPROCESSOR, fname, tmp_name);
++#else
++ sprintf(buf,"%s %s > %s", MGCSFX_PREPROCESSOR, fname, tmp_name); /* really OK? */
++#endif
++
++ SetISTR(ISTR_INFO, "Preprocessing '%s'...", BaseName(fname));
++#ifndef VMS
++ if (system(buf))
++#else
++ if (!system(buf))
++#endif
++ {
++ SetISTR(ISTR_INFO, "Unable to preprocess '%s'.", BaseName(fname));
++ Warning();
++ return NULL;
++ }
++
++ return tmp_name;
++}
++#endif /* USE_MGCSFX_PREPROCESSOR */
++
++/***************************************************/
++/* $BG'<1$G$-$k%U%!%$%k$+$I$&$+D4$Y$k(B */
++int is_mgcsfx(fname,buffer,size)
++ char *fname;
++ unsigned char *buffer;
++ int size;
++{
++ mgcsfxtab *magic;
++ FILE *fp;
++ unsigned char *buf;
++ int s;
++
++ if(nomgcsfx){
++ return 0;
++ }else{
++ if(size < need_buf_size){
++ if((buf = (unsigned char *)calloc(need_buf_size, sizeof(char)))==NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ return 0;
++ }
++ if((fp = xv_fopen(fname, "r"))==NULL){
++ fprintf(stderr,"Can't open file %s\n", fname);
++ free(buf);
++ return 0;
++ }
++ s = fread(buf, 1, need_buf_size, fp);
++ if((magic = find_mgcsfx(fname, buf, s))!=NULL &&
++ magic->input_command != NULL){
++ free(buf);
++ fclose(fp);
++ return 1;
++ }else{
++ free(buf);
++ fclose(fp);
++ return 0;
++ }
++ }else{
++ if((magic = find_mgcsfx(fname, buffer, size))!=NULL &&
++ magic->input_command != NULL){
++ return 1;
++ }else{
++ return 0;
++ }
++ }
++ }
++}
++
++#ifdef HAVE_MGCSFX_AUTO
++char *mgcsfx_auto_input_com(fname)
++char *fname;
++{
++ static char command[1024];
++ mgcsfxtab *magic;
++ char *ptr;
++
++ FILE *fp;
++ unsigned char *buf;
++ int s;
++
++ if((buf = (unsigned char *)calloc(need_buf_size, sizeof(char)))==NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ return NULL;
++ }
++ if((fp = xv_fopen(fname, "r"))==NULL){
++ fprintf(stderr,"Can't open file %s\n", fname);
++ free(buf);
++ return NULL;
++ }
++ s = fread(buf, 1, need_buf_size, fp);
++ if((magic = find_mgcsfx(fname, buf, s))!=NULL &&
++ magic->input_command != NULL && magic->input_image_type == IT_AUTO){
++ if ((ptr = strstr(magic->input_command, "%s"))){
++ sprintf(command, magic->input_command, fname);
++ }else{
++ sprintf(command, "%s < %s", magic->input_command, fname);
++ }
++ free(buf);
++ fclose(fp);
++ return command;
++ }else{
++ free(buf);
++ fclose(fp);
++ return NULL;
++ }
++}
++#endif /* HAVE_MGCSFX_AUTO */
++
++/***************************************************/
++static mgcsfxtab *free_mgcsfx(m)
++ mgcsfxtab *m;
++{
++ mgcsfxtab *next;
++ if(m == NULL) return NULL;
++ next = m->next;
++ if(m->description != NULL) free(m->description);
++ if(m->mgcsfx_type == T_MAGIC && m->dt.string_data != NULL)
++ free(m->dt.string_data);
++ if(m->suffix != NULL) free(m->suffix);
++ if(m->input_command != NULL) free(m->input_command);
++ if(m->output_command != NULL) free(m->output_command);
++ free(m);
++ return next;
++}
++
++
++
++/***************************************************/
++/* char c $B$^$?$O(B '\n' $B$G6h@Z$i$l$?J8;zNs$r<h$j=P$9(B
++ * $B%U%!%$%k$N:G8e$^$GFI$s$@$i(B NULL $B$rJV$9(B
++ * $B2~9T$J$i2~9T$rJV$9(B($B2~9T$G6h@Z$i$l$?>l9g$O(B '\n' $B$r%9%H%j!<%`$KLa$9(B)
++ */
++#define CBUF_SIZE 1024
++static char *fgettoken(fp, c)
++ FILE *fp;
++ int c; /* Real mean is char */
++{
++ char *buf;
++ char *buf2;
++ int i;
++ int n=0;
++ int max=0;
++ int count = 1;
++
++ char *ss;
++ char *se;
++
++ if((buf = (char *)calloc(CBUF_SIZE, sizeof(char))) == NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ exit(1);
++ }
++ max = CBUF_SIZE;
++ count = 2;
++
++ do{
++ if((i = getc(fp))==EOF || i == '\n' || i == c) break;
++
++ buf[n] = (char)i;
++
++ if(i != c && n == max-1){
++ buf[max] = '\0';
++ if((buf2 = (char *)calloc(CBUF_SIZE * count, sizeof(char))) == NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ exit(1);
++ }
++ strcpy(buf2, buf);
++ free(buf);
++ buf = buf2;
++ buf2 = NULL;
++ max = CBUF_SIZE * count;
++ count++;
++ }
++
++ n++;
++ }while(i != c);
++
++ buf[n] = '\0';
++
++ /* $B:G=i$H:G8e$N6uGrJ8;z$r@Z$j5M$a$k(B */
++ ss = buf + strspn(buf, " \t\b\r\n"); /* find the first non-white space */
++ se = buf + strlen(buf); /* find the end of the string */
++
++ /* strip from the end first */
++ while ((--se >= ss) && strchr(" \t\b\r\n", *se));
++ *(++se) = '\0';
++
++ if(i == EOF && strlen(ss)==0){ /* EOF $B$J$i(B NULL $B$rJV$9(B */
++ free(buf);
++ return NULL;
++ }else if(i == '\n' && strlen(ss)==0){ /* $B2~9T$N$_$N>l9g(B */
++ static char cr[2] = {'\n','\0'};
++ buf2 = strdup(cr);
++ free(buf);
++ return buf2;
++ }else{ /* $BDL>o(B */
++ if(i == '\n' && strlen(ss)>0) ungetc(i,fp);
++ buf2 = strdup(ss);
++ free(buf);
++ return buf2;
++ }
++}
++
++
++
++/***************************************************/
++/* $BJ8;zNsCf$NFC<l5-9f(B(\)$B$r@5$7$$$b$N$K$9$k(B
++ */
++static int string_fin(string_data)
++ char *string_data;
++{
++ char *cptr;
++ char *ptr;
++ int length;
++
++ /* Change all the \xx sequences into a single character */
++ cptr = string_data;
++
++ for (ptr = cptr; *ptr; ++ptr){
++ if (*ptr != '\\'){
++ *cptr = *ptr;
++ }else{
++ switch (*(++ptr)){
++#if defined(__STDC__)
++ case 'a': /* Audible alert (terminal bell) */
++ *cptr = '\007';
++ break;
++ case '?': /* Question mark */
++ *cptr = '\?';
++ break;
++#endif
++ case 'b': /* Backspace */
++ *cptr = '\b';
++ break;
++ case 'f': /* Form feed */
++ *cptr = '\f';
++ break;
++ case 'n': /* Line feed */
++ *cptr = '\n';
++ break;
++ case 'r': /* Carriage return */
++ *cptr = '\r';
++ break;
++ case 't': /* Horizontal tab */
++ *cptr = '\t';
++ break;
++ case 'v': /* Vertical tab */
++ *cptr = '\v';
++ break;
++ case '\\': /* Backslash */
++ *cptr = '\\';
++ break;
++ case '\'': /* Single quote */
++ *cptr = '\'';
++ break;
++ case '"': /* Double quote */
++ *cptr = '\"';
++ break;
++ case '0': /* Octal constant \0 ... \377 */
++ case '1':
++ case '2':
++ case '3':
++ case '4':
++ case '5':
++ case '6':
++ case '7':
++ if ((ptr[1] >= '0') && (ptr[1] <= '7')){
++ if ((ptr[2] >= '0') && (ptr[2] <= '7')){ /* \000 ...\377 */
++ *cptr = ((*ptr - '0') * 64) +((ptr[1] - '0') * 8) +(ptr[1] - '0');
++ ptr += 2;
++ }else{ /* \00 ...\77 */
++ *cptr = ((*ptr - '0') * 8) + (ptr[1] - '0');
++ ++ptr;
++ }
++ }else{ /* \0 ...\7 */
++ *cptr = *ptr - '0';
++ }
++ break;
++ case 'x': /* Hexadecimal constant \x0 .. \xff */
++ if (isxdigit (ptr[1])){
++ *cptr = 0;
++ while (isxdigit (*(++ptr)))
++ *cptr = (*cptr * 16) +
++ (*ptr > '9' ? tolower (*ptr) - ('a' - 10) : *ptr - '0');
++ --ptr;
++ break;
++ }
++ default:
++ /* *(cptr++) = '\\'; No use for treat '\z' as 'z' */
++ *cptr = *ptr;
++ break;
++ }
++ }
++ ++cptr;
++ }
++ *cptr = '\0';
++ length = cptr - string_data;
++ return length;
++}
++
++/***************************************************/
++static int type_mgcsfx(str)
++ char *str;
++{
++ if(str == NULL){
++ return T_UNKNOWN;
++ }else if(!strcmp(str, "magic") || !strcmp(str, "MAGIC")){
++ return T_MAGIC;
++ }else if(!strcmp(str, "string") || !strcmp(str, "STRING")){
++ return T_MAGIC;
++ }else if(!strcmp(str, "suffix") || !strcmp(str, "SUFFIX")){
++ return T_SUFFIX;
++ }else if(!strcmp(str, "beint16") || !strcmp(str, "BEINT16")){
++ return T_BEINT16;
++ }else if(!strcmp(str, "leint16") || !strcmp(str, "LEINT16")){
++ return T_LEINT16;
++ }else if(!strcmp(str, "beint32") || !strcmp(str, "BEINT32")){
++ return T_BEINT32;
++ }else if(!strcmp(str, "leint32") || !strcmp(str, "LEINT32")){
++ return T_LEINT32;
++ }else{
++ return T_UNKNOWN;
++ }
++}
++
++/***************************************************/
++static int type_image(str)
++ char *str;
++{
++ if(str == NULL){
++ return IT_UNKNOWN;
++#ifdef HAVE_MGCSFX_AUTO
++ }else if(!strcmp(str, "auto") || !strcmp(str, "AUTO")){
++ return IT_AUTO;
++#endif /* HAVE_MGCSFX_AUTO */
++ }else if(!strcmp(str, "pnm") || !strcmp(str, "PNM")){
++ return IT_PNM;
++ }else if(!strcmp(str, "ppm") || !strcmp(str, "PPM")){
++ return IT_PPM;
++ }else if(!strcmp(str, "pgm") || !strcmp(str, "PGM")){
++ return IT_PGM;
++ }else if(!strcmp(str, "pbm") || !strcmp(str, "PBM")){
++ return IT_PBM;
++ }else if(!strcmp(str, "pnm_raw") || !strcmp(str, "PNM_RAW")){
++ return IT_PNM_RAW;
++ }else if(!strcmp(str, "ppm_raw") || !strcmp(str, "PPM_RAW")){
++ return IT_PPM_RAW;
++ }else if(!strcmp(str, "pgm_raw") || !strcmp(str, "PGM_RAW")){
++ return IT_PGM_RAW;
++ }else if(!strcmp(str, "pbm_raw") || !strcmp(str, "PBM_RAW")){
++ return IT_PBM_RAW;
++ }else if(!strcmp(str, "pnm_ascii") || !strcmp(str, "PNM_ASCII")){
++ return IT_PNM_ASCII;
++ }else if(!strcmp(str, "ppm_ascii") || !strcmp(str, "PPM_ASCII")){
++ return IT_PPM_ASCII;
++ }else if(!strcmp(str, "pgm_ascii") || !strcmp(str, "PGM_ASCII")){
++ return IT_PGM_ASCII;
++ }else if(!strcmp(str, "pbm_ascii") || !strcmp(str, "PBM_ASCII")){
++ return IT_PBM_ASCII;
++
++ }else if(!strcmp(str, "gif") || !strcmp(str, "GIF")){
++ return IT_GIF;
++ }else if(!strcmp(str, "jpeg") || !strcmp(str, "JPEG")){
++ return IT_JPEG;
++ }else if(!strcmp(str, "tiff") || !strcmp(str, "TIFF")){
++ return IT_TIFF;
++ }else if(!strcmp(str, "jfif") || !strcmp(str, "JFIF")){
++ return IT_JFIF;
++
++ }else if(!strcmp(str, "xbm") || !strcmp(str, "XBM")){
++ return IT_XBM;
++ }else if(!strcmp(str, "xpm") || !strcmp(str, "XPM")){
++ return IT_XPM;
++ }else if(!strcmp(str, "bmp") || !strcmp(str, "BMP")){
++ return IT_BMP;
++ }else if(!strcmp(str, "sunras") || !strcmp(str, "SUNRAS")){
++ return IT_SUNRAS;
++ }else if(!strcmp(str, "iris") || !strcmp(str, "IRIS")){
++ return IT_IRIS;
++ }else if(!strcmp(str, "xwd") || !strcmp(str, "XWD")){
++ return IT_XWD;
++
++ }else if(!strcmp(str, "mag") || !strcmp(str, "MAG")){
++ return IT_MAG;
++ }else if(!strcmp(str, "maki") || !strcmp(str, "MAKI")){
++ return IT_MAKI;
++ }else if(!strcmp(str, "pi") || !strcmp(str, "PI")){
++ return IT_PI;
++ }else if(!strcmp(str, "pic") || !strcmp(str, "PIC")){
++ return IT_PIC;
++ }else if(!strcmp(str, "pic2") || !strcmp(str, "PIC2")){
++ return IT_PIC2;
++
++ }else{
++ return IT_UNKNOWN;
++ }
++}
++
++/*--------------------------------------------------------------------------*/
++#define mgcsfx_read_error(FILENAME, LINENUM, AFTERFIELD) \
++fprintf (stderr,\
++"%s: line %d: missing fields of %s field\n",\
++FILENAME, LINENUM, AFTERFIELD);
++
++#define magic_type_error(FILENAME, LINENUM, MAGICNUMBER) \
++fprintf (stderr,\
++"%s: line %d: invalid <magic type> field '%s'\n",\
++FILENAME, LINENUM, MAGICNUMBER);
++/*--------------------------------------------------------------------------*/
++
++/***************************************************/
++static void read_mgcsfx(mgcsfx_table, fname)
++ mgcsfxtab **mgcsfx_table;
++ char *fname;
++{
++ FILE *fp;
++ char *s;
++ int line_number = 0;
++ int str_len;
++ int reach_end;
++ int def_err;
++
++ char *description;
++ char *mgcsfx_type;
++ char *offset;
++ char *magic;
++ char *suffix;
++ char *i_img;
++ char *i_com;
++ char *o_img;
++ char *o_com;
++
++ mgcsfxtab *ent;
++ mgcsfxtab **entry;
++
++
++ if((fp=fopen(fname, "r"))==NULL){
++ /* fprintf(stderr, "Can't open %s\n",fname); */
++ return;
++ }
++
++ while(1){
++retry:
++ line_number++;
++ def_err = 0;
++
++ s= NULL;
++ description = mgcsfx_type = offset = magic = suffix
++ = i_img = i_com = o_img = o_com = NULL;
++ reach_end = 0;
++
++ if((s = fgettoken(fp, ':'))==NULL) break; /* EOF $B$J$i=*$j(B */
++ if(*s == '#'){/* $B@hF,$,(B '#' $B$J$iFI$_$H$P$9(B */
++ while((s = fgettoken(fp, '\n'))!=NULL){
++ if(*s == '\n'){
++ free(s);
++ goto retry;
++ }
++ free(s);
++ }
++ if(s == NULL) break;
++ }else if(*s == '\n'){/* $B6u9T$OL5;k(B */
++ free(s);
++ goto retry;
++ }
++ if(strlen(s) > 0) description = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "data type");
++ goto next;
++ }
++ if(strlen(s) > 0) mgcsfx_type = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "byte offset");
++ goto next;
++ }
++ if(strlen(s) > 0) offset = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "magic number");
++ goto next;
++ }
++ if(strlen(s) > 0) magic = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "suffix");
++ goto next;
++ }
++ if(strlen(s) > 0) suffix = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "input image type");
++ goto next;
++ }
++ if(strlen(s) > 0) i_img = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "input command");
++ goto next;
++ }
++ if(strlen(s) > 0) i_com = s;
++ else free(s);
++
++ if((s = fgettoken(fp, ':'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ if(s != NULL) free(s);
++ mgcsfx_read_error(fname, line_number, "output image type");
++ goto next;
++ }
++ if(strlen(s) > 0) o_img = s;
++ else free(s);
++
++ if((s = fgettoken(fp, '#'))==NULL || *s == '\n'){/* $B2?$b$J$$$J$i@_Dj%_%9(B */
++ /*
++ free(s);
++ mgcsfx_read_error(fname, line_number, "output command");
++ goto next;
++ */
++ if(s != NULL){
++ *s = '\0';
++ reach_end = 1;
++ }
++ }
++ if(s != NULL){
++ if(strlen(s) > 0) o_com = s;
++ else free(s);
++ }
++
++ if(reach_end == 0){
++ while((s = fgettoken(fp, '\n'))!=NULL){/* $B9TKv$N%4%_$r<N$F$k(B */
++ if(*s == '\n'){
++ free(s);
++ break; /* goto next; */
++ }
++ free(s);
++ }
++ }else{
++ reach_end = 0;
++ }
++
++
++
++ /* --------------------------------------------------------------------- */
++next:;
++
++ if(DEBUG){
++ fprintf(stderr,"Read: file %s: line %d.\n", fname, line_number);
++ fprintf(stderr,"Description : %s\n",
++ description ? description : "-- error --");
++ fprintf(stderr,"Type : %s\n",
++ mgcsfx_type ? mgcsfx_type : "-- error --");
++ fprintf(stderr,"Offset : %s\n", offset ? offset : "--+--");
++ fprintf(stderr,"Magic : %s\n", magic ? magic : "--+--");
++ fprintf(stderr,"Suffix : %s\n", suffix ? suffix : "--+--");
++ fprintf(stderr,"i Image : %s\n", i_img ? i_img : "--+--");
++ fprintf(stderr,"i Command : %s\n", i_com ? i_com : "--+--");
++ fprintf(stderr,"o Image : %s\n", o_img ? o_img : "--+--");
++ fprintf(stderr,"o Command : %s\n", o_com ? o_com : "--+--");
++ fprintf(stderr,"\n");
++ }
++
++ /* create mgcsfxtab */
++ if((ent = (mgcsfxtab *) malloc (sizeof (mgcsfxtab)))==NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ exit(1);
++ }
++ ent->next = NULL;
++ ent->description = NULL;
++ ent->mgcsfx_type = T_UNKNOWN;
++ ent->offset = 0;
++ ent->string_len = 0;
++ ent->suffix = NULL;
++ ent->input_image_type = IT_UNKNOWN;
++ ent->input_command = NULL;
++ ent->output_image_type = IT_UNKNOWN;
++ ent->output_command = NULL;
++
++ if(description != NULL){
++ ent->description = description;
++ description = NULL;
++ }else{
++ fprintf (stderr,"%s: line %d: undefined <description> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++
++ if(mgcsfx_type == NULL){
++ fprintf (stderr,"%s: line %d: undefined <mgcsfx type> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++ ent->mgcsfx_type = type_mgcsfx(mgcsfx_type);
++ switch(ent->mgcsfx_type){
++ case T_SUFFIX:
++ if(suffix == NULL){
++ fprintf (stderr,
++ "%s: line %d: conflict definition : undefined <suffix> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++ break;
++ case T_BEINT16:
++ if (sscanf(magic, "%hi", &(ent->dt.int16_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++ case T_LEINT16:
++ if (sscanf(magic, "%hi", &(ent->dt.int16_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++#ifdef ARCHITECTURE64
++ case T_BEINT32:
++ if (sscanf(magic, "%i", &(ent->dt.int32_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++ case T_LEINT32:
++ if (sscanf(magic, "%i", &(ent->dt.int32_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++#else
++ case T_BEINT32:
++ if (sscanf(magic, "%li", &(ent->dt.int32_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++ case T_LEINT32:
++ if (sscanf(magic, "%li", &(ent->dt.int32_data)) != 1){
++ magic_type_error(fname, line_number, magic);
++ def_err ++;
++ goto next2;
++ }
++ break;
++#endif /* ARCHITECTURE64 */
++ case T_MAGIC:
++ if(magic == NULL){
++ fprintf (stderr,"%s: line %d: undefined <magic> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++ if((str_len = string_fin(magic))<=0){
++ fprintf (stderr,"%s: line %d: invalid <magic> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++
++ ent->string_len = str_len;
++ if((ent->dt.string_data = (char *)malloc(str_len + 1))==NULL){
++ fprintf(stderr,"Can't allocate memory\n");
++ exit(1);
++ }
++ memcpy(ent->dt.string_data, magic, str_len + 1);
++ break;
++ case T_UNKNOWN:
++ default:
++ fprintf (stderr,"%s: line %d: invalid <mgcsfx type> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ break;
++ };
++
++
++ if(offset == NULL){
++ if(ent->mgcsfx_type == T_MAGIC ||
++ ent->mgcsfx_type == T_BEINT16 ||
++ ent->mgcsfx_type == T_LEINT16 ||
++ ent->mgcsfx_type == T_BEINT32 ||
++ ent->mgcsfx_type == T_LEINT32){
++ fprintf (stderr,
++ "%s: line %d: conflict definition : undefined <offset> field.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++ }else{
++ if(ent->mgcsfx_type != T_SUFFIX) sscanf(offset, "%i", &(ent->offset));
++ }
++
++ if(suffix != NULL){
++ ent->suffix = suffix;
++ suffix = NULL;
++ }
++
++ if((i_img == NULL && i_com == NULL) && (o_img == NULL || o_com == NULL)){
++ fprintf (stderr,"%s: line %d: invalid definition.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++ if((o_img == NULL && o_com == NULL) && (i_img == NULL || i_com == NULL)){
++ fprintf (stderr,"%s: line %d: invalid definition.\n",
++ fname, line_number);
++ def_err ++;
++ goto next2;
++ }
++
++ if(i_img != NULL && i_com != NULL){
++ ent->input_image_type = type_image(i_img);
++ ent->input_command = i_com;
++ i_com = NULL;
++ }else{
++ ent->input_image_type = IT_UNKNOWN;
++ ent->input_command = NULL;
++ }
++
++ if(o_img != NULL && o_com != NULL){
++ ent->output_image_type = type_image(o_img);
++ ent->output_command = o_com;
++ o_com = NULL;
++ }else{
++ ent->output_image_type = IT_UNKNOWN;
++ ent->output_command = NULL;
++ }
++ /* end of create mgcsfxtab */
++
++
++next2:;
++
++ if(def_err != 0 || DEBUG){
++ fprintf(stderr,"Description : %s \t -> %s\n",
++ description ? description : "--+--",
++ ent->description ? ent->description : "-- error --");
++ fprintf(stderr,"Type : %s \t -> %d\n",
++ mgcsfx_type ? mgcsfx_type : "--+--",
++ ent->mgcsfx_type);
++ fprintf(stderr,"Offset : %s \t -> %d\n",
++ offset ? offset : "--+--",
++ ent->offset);
++
++ fprintf(stderr,"Magic : %s", magic ? magic : "--+--");
++ switch(ent->mgcsfx_type){
++ case T_BEINT16:
++ case T_LEINT16:
++ fprintf(stderr," \t -> %d\n",ent->dt.int16_data);
++ break;
++ case T_BEINT32:
++ case T_LEINT32:
++ fprintf(stderr," \t -> %ld\n",ent->dt.int32_data);
++ break;
++ case T_MAGIC:
++ fprintf(stderr," \t -> %s\n",ent->dt.string_data);
++ break;
++ default:
++ fprintf(stderr,"\n");
++ break;
++ };
++
++ fprintf(stderr,"Suffix : %s \t -> %s\n",
++ suffix ? suffix : "--+--",
++ ent->suffix ? ent->suffix : "--+--");
++ fprintf(stderr,"i Image : %s \t -> %d\n",
++ i_img ? i_img : "--+--",
++ ent->input_image_type);
++ fprintf(stderr,"i Command : %s \t -> %s\n",
++ i_com ? i_com : "--+--",
++ ent->input_command ? ent->input_command : "--+--");
++ fprintf(stderr,"o Image : %s \t -> %d\n",
++ o_img ? o_img : "--+--",
++ ent->output_image_type);
++ fprintf(stderr,"o Command : %s \t -> %s\n",
++ o_com ? o_com : "--+--",
++ ent->output_command ? ent->output_command : "--+--");
++ fprintf(stderr,"\n");
++ }
++
++ if(description != NULL) free(description);
++ if(mgcsfx_type != NULL) free(mgcsfx_type);
++ if(offset != NULL) free(offset);
++ if(magic != NULL) free(magic);
++ if(suffix != NULL) free(suffix);
++ if(i_img != NULL) free(i_img);
++ if(i_com != NULL) free(i_com);
++ if(o_img != NULL) free(o_img);
++ if(o_com != NULL) free(o_com);
++
++
++ if(def_err != 0) goto next3;
++
++ /* Override any existing entry for this magic number/file type */
++ for(entry = mgcsfx_table; *entry; entry = &((*entry)->next)){
++ if((ent->mgcsfx_type == (*entry)->mgcsfx_type) &&
++ (
++ ((ent->offset == (*entry)->offset) &&
++ (((ent->mgcsfx_type == T_BEINT16) &&
++ (ent->dt.int16_data == (*entry)->dt.int16_data)) ||
++ ((ent->mgcsfx_type == T_BEINT32) &&
++ (ent->dt.int32_data == (*entry)->dt.int32_data)) ||
++ ((ent->mgcsfx_type == T_LEINT16) &&
++ (ent->dt.int16_data == (*entry)->dt.int16_data)) ||
++ ((ent->mgcsfx_type == T_LEINT32) &&
++ (ent->dt.int32_data == (*entry)->dt.int32_data)) ||
++
++ ((ent->mgcsfx_type == T_MAGIC) &&
++ !memcmp(ent->dt.string_data, (*entry)->dt.string_data,
++ ent->string_len))
++ )) ||
++ ((ent->mgcsfx_type == T_SUFFIX) &&
++ !strcmp(ent->suffix, (*entry)->suffix))
++ )
++ ){
++
++ free ((*entry)->description);
++ (*entry)->description = ent->description;
++ ent->description = NULL;
++
++ (*entry)->input_image_type = ent->input_image_type;
++ if ((*entry)->input_command) free ((*entry)->input_command);
++ (*entry)->input_command = ent->input_command;
++ ent->input_command = NULL;
++
++ (*entry)->output_image_type = ent->output_image_type;
++ if ((*entry)->output_command) free ((*entry)->output_command);
++ (*entry)->output_command = ent->output_command;
++ ent->output_command = NULL;
++
++ free_mgcsfx(ent);
++ break;
++ }
++ }
++ if (!*entry){
++ ent->next = NULL;
++ *entry = ent;
++ }
++
++ /* if(s == NULL) break; */
++next3:;
++ if(def_err != 0) free_mgcsfx(ent);
++ } /* end of while(1) */
++}
++
++
++/***************************************************/
++/* $B%^%8%C%/%J%s%P!<Dj5A%U%!%$%kL>$rF@$F!"FI$_9~$^$;$k(B */
++static void init_mgcsfx ()
++{
++ extern char *getenv ();
++
++ char *home_dir;
++ char fname[1024];
++ mgcsfxtab *entry;
++ int len;
++ struct stat st;
++
++#ifdef USE_MGCSFX_PREPROCESSOR
++ char *pp_fname;
++#endif /* USE_MGCSFX_PREPROCESSOR */
++
++ mgcsfx_table = NULL;
++
++ mgcsfx_handler_setup();
++
++ if(nomgcsfx){
++ mgcsfx_setup_flag = 1;
++ nitem_mgcsfx = 0;
++ desc_width = 0;
++ }else{
++ sprintf (fname, "%s/%s", SYSCONFDIR, MGCSFX_SITE_RC);
++ if(stat(fname, &st) == 0 && S_ISREG(st.st_mode)){
++ /* Read the site MagicSuffix table into a linked list */
++#ifdef USE_MGCSFX_PREPROCESSOR
++ if((pp_fname = make_preprocessed_file(fname)) != NULL){
++ read_mgcsfx (&mgcsfx_table, pp_fname);
++ }
++ unlink(pp_fname);
++#else
++ read_mgcsfx (&mgcsfx_table, fname);
++#endif /* USE_MGCSFX_PREPROCESSOR */
++ }
++
++ /* Read the personal MgcSfx table into the list overriding site entries */
++ if ((home_dir = getenv ("HOME"))){
++ sprintf (fname, "%s/%s", home_dir, MGCSFX_RC);
++ if(stat(fname, &st) == 0 && S_ISREG(st.st_mode)){
++#ifdef USE_MGCSFX_PREPROCESSOR
++ if((pp_fname = make_preprocessed_file(fname)) != NULL){
++ read_mgcsfx (&mgcsfx_table, pp_fname);
++ }
++ unlink(pp_fname);
++#else
++ read_mgcsfx (&mgcsfx_table, fname);
++#endif /* USE_MGCSFX_PREPROCESSOR */
++ }
++ }
++
++ mgcsfx_setup_flag = 1;
++
++ nitem_mgcsfx = 0;
++ desc_width = 0;
++ for (entry = mgcsfx_table; entry; entry = entry->next){
++ nitem_mgcsfx ++;
++ len = strlen(entry->description);
++ if(len > desc_width) desc_width = len;
++ if(max_offset_mgcsfx < entry->offset) max_offset_mgcsfx = entry->offset;
++ if(entry->mgcsfx_type == T_MAGIC &&
++ max_length_mgcsfx < entry->string_len)
++ max_length_mgcsfx = entry->string_len;
++ }
++ if(max_length_mgcsfx == 0) max_length_mgcsfx = sizeof(int32);
++ need_buf_size = max_offset_mgcsfx + max_length_mgcsfx + 1;/* 1 is safety */
++ }
++}
++
++/***************************************************/
++/* $B%^%8%C%/%J%s%P!<$rD4$Y$F!"Dj5A$7$F$$$k%F!<%V%k$r8!:w$9$k(B
++ $B%^%8%C%/%J%s%P!<$N%F!<%V%k$rFI$_9~$s$G$$$J$$$J$iFI$_9~$`(B */
++static mgcsfxtab *find_mgcsfx (fname, buffer, buffer_size)
++ char *fname;
++ unsigned char *buffer;
++ int buffer_size;
++{
++ mgcsfxtab *entry;
++ int16 buf16;
++ int32 buf32;
++ char *suf;
++
++ if (mgcsfx_setup_flag == 0) init_mgcsfx ();
++
++ for (entry = mgcsfx_table; entry; entry = entry->next){
++ switch (entry->mgcsfx_type){
++ case T_BEINT16:
++ if ((buffer_size > 0) &&
++ ((entry->offset + sizeof (int16)) <= buffer_size)){
++ buf16 = ((char)*(buffer + entry->offset) << 8) |
++ ((char)*(buffer + entry->offset +1));
++ if(entry->dt.int16_data == buf16) return entry;
++ }
++ break;
++ case T_LEINT16:
++ if ((buffer_size > 0) &&
++ ((entry->offset + sizeof (int16)) <= buffer_size)){
++ buf16 = ((char)*(buffer + entry->offset +1) << 8) |
++ ((char)*(buffer + entry->offset));
++ if(entry->dt.int16_data == buf16) return entry;
++ }
++ break;
++ case T_BEINT32:
++ if ((buffer_size > 0) &&
++ ((entry->offset + sizeof (int32)) <= buffer_size)){
++ buf32 = ((char)*(buffer + entry->offset) << 24) |
++ ((char)*(buffer + entry->offset +1) << 16) |
++ ((char)*(buffer + entry->offset +2) << 8) |
++ ((char)*(buffer + entry->offset +3));
++ if(entry->dt.int32_data == buf32) return entry;
++ }
++ break;
++ case T_LEINT32:
++ if ((buffer_size > 0) &&
++ ((entry->offset + sizeof (int32)) <= buffer_size)){
++ buf32 = ((char)*(buffer + entry->offset +3) << 24) |
++ ((char)*(buffer + entry->offset +2) << 16) |
++ ((char)*(buffer + entry->offset +1) << 8) |
++ ((char)*(buffer + entry->offset));
++ if(entry->dt.int32_data == buf32) return entry;
++ }
++ break;
++ case T_MAGIC:
++ if ((buffer_size > 0) &&
++ ((entry->offset + entry->string_len)
++ <= buffer_size) &&
++ !memcmp (entry->dt.string_data, buffer + entry->offset,
++ entry->string_len ))
++ return entry;
++ break;
++ case T_SUFFIX:
++ if(fname != NULL && entry->suffix != NULL){
++ if(strlen(fname) - strlen(entry->suffix) > 0){
++ suf = fname + (strlen(fname) - strlen(entry->suffix));
++ if(!strcmp(suf, entry->suffix)) return entry;
++ }
++ }
++ break;
++ case T_UNKNOWN:
++ default:
++ return NULL;
++ break;
++ }
++ }
++ return NULL;
++}
++
++
++
++
++
++/***************************************************/
++/* $B%^%8%C%/%J%s%P!<$NDj5A$rD4$Y$F!"$=$l$K$"$o$;$?%3%^%s%I$r<B9T$9$k(B */
++/* if OK return 1, else if ERROR return 0 */
++int
++LoadMGCSFX(file_name, pinfo)
++ char *file_name;
++ PICINFO *pinfo;
++{
++ unsigned char *buffer;
++ int size;
++ mgcsfxtab *magic;
++ mgcsfxtab *magic_cur;
++ char *ptr;
++ char command[1024];
++ int fd[2];
++ int pid = -2;
++ int file;
++ char *fname;
++ int rv;
++ int pst;
++
++ int i_it;
++ char *i_com;
++
++ WaitCursor();
++
++ fname = file_name;
++ if((file = open (fname, O_RDONLY))<0){
++ SetISTR(ISTR_WARNING, "Can't open %s",fname);
++ return 0;
++ }
++
++ if((buffer = (unsigned char *)calloc(need_buf_size, sizeof(char))) == NULL){
++ SetISTR(ISTR_WARNING, "Can't allocate memory");
++ return 0;
++ }
++
++ magic_cur = NULL;
++
++/* do{ */
++ size = read (file, buffer, need_buf_size);
++
++ if (lseek (file, 0L, 0) < 0){ /* can't seek pipe !! */
++ fprintf (stderr, "Can't lseek %s\n", file_name);
++ close(file);
++ return 0;
++ }
++
++ magic = find_mgcsfx (fname, buffer, size);
++
++ if ((magic != NULL && magic->input_command) ||
++ (magic == NULL && mgcsfx && input_command_ex_flag)){
++
++ if(magic == NULL){
++ if (fname != NULL && (ptr = strstr(input_command_ex, "%s"))){
++ sprintf (command, input_command_ex, fname);
++ }else{
++ strcpy (command, input_command_ex);
++ fname=NULL;
++ }
++ }else{
++ /* Use stdin or give file name */
++ if (fname != NULL && (ptr = strstr(magic->input_command, "%s"))){
++ sprintf (command, magic->input_command, fname);
++ }else{
++ strcpy (command, magic->input_command);
++ fname=NULL;
++ }
++ }
++
++ /* Do the pipe/fork/exec here */
++ if (pipe (fd) < 0){
++ fprintf (stderr, "Can't pipe : %s\n", file_name);
++ close(file);
++ return 0;
++ }
++
++ if ((pid = vfork ()) < 0){
++ fprintf (stderr, "Can't vfork : %s\n", file_name);
++ close (fd[0]);
++ close (fd[1]);
++ close(file);
++ return 0;
++ }
++
++ if (!pid){
++ close(0);
++ if (fname == NULL || (open ("/dev/null", O_RDONLY) < 0)){
++ dup(file);
++ }
++ close(file);
++ close(1);
++ dup(fd[1]);
++ close(2);
++ open("/dev/null", O_WRONLY);
++ close(fd[0]);
++ execl("/bin/sh", "/bin/sh", "-c", command, 0);
++ _exit(127);
++ }
++
++ close (fd[1]);
++ dup2(fd[0], file);
++ close (fd[0]);
++ fname = NULL;
++ magic_cur = magic;
++ }
++/* } while(magic != NULL); */
++
++ free(buffer);
++
++ if(magic_cur == NULL && mgcsfx && input_command_ex_flag){
++ i_it = IT_PNM;
++ i_com = input_command_ex;
++ }else{
++ i_it = magic_cur->input_image_type;
++ i_com = magic_cur->input_command;
++ }
++
++ if((magic_cur != NULL && i_com) ||
++ (magic_cur == NULL && mgcsfx && input_command_ex_flag)){
++ switch(i_it){
++ case IT_PNM:
++ case IT_PPM:
++ case IT_PGM:
++ case IT_PBM:
++ case IT_PNM_RAW:
++ case IT_PPM_RAW:
++ case IT_PGM_RAW:
++ case IT_PBM_RAW:
++ case IT_PNM_ASCII:
++ case IT_PPM_ASCII:
++ case IT_PGM_ASCII:
++ case IT_PBM_ASCII:
++ rv = LoadPBM(file_name, pinfo, file);
++ break;
++ case IT_GIF:
++ case IT_JPEG:
++ case IT_TIFF:
++ case IT_JFIF:
++ case IT_XBM:
++ case IT_XPM:
++ case IT_BMP:
++ case IT_SUNRAS:
++ case IT_IRIS:
++ case IT_XWD:
++ case IT_MAG:
++ case IT_MAKI:
++ case IT_PI:
++ case IT_PIC:
++ case IT_PIC2:
++ SetISTR(ISTR_WARNING, "Yet supported input image type (from filter output)");
++ rv = 0;
++ break;
++ case IT_UNKNOWN:
++ SetISTR(ISTR_WARNING, "Unknown input image type (from filter output)");
++ rv = 0;
++ break;
++#ifdef HAVE_MGCSFX_AUTO
++ case IT_AUTO:
++#endif
++ default:
++ SetISTR(ISTR_WARNING, "Error in input image type (from filter output)");
++ rv = 0;
++ break;
++ }
++ }else{
++ rv = 0;
++ }
++
++ /* fail if pid still == -2? */
++ while(wait(&pst) != pid); /* FIXME? pid isn't necessarily initialized... */
++ if( *((char *)&pst) != 0 ) rv = 0;
++
++ input_command_ex_flag = 0;
++
++ return rv;
++
++ /* fclose(fp); close in Load??? */
++ /* return 0; error */
++ /* return 1; ok */
++}
++
++
++
++
++
++/*--------------------------------------------------------------------------*/
++#ifndef MGCSFX_DEFAULT_INPUT_COMMAND
++# define MGCSFX_DEFAULT_INPUT_COMMAND "tifftopnm"
++#endif
++#ifndef MGCSFX_DEFAULT_OUTPUT_COMMAND
++# define MGCSFX_DEFAULT_OUTPUT_COMMAND "pnmtotiff"
++#endif
++
++int MSWIDE = 0;
++int MSHIGH = 0;
++
++#define MS_NBUTTS 2
++#define MS_BOK 0
++#define MS_BCANC 1
++#define BUTTW 60 /* width of buttons (OK or Cancel) */
++#define BUTTH 24 /* height of buttons (OK or Cancel) */
++#define RBSIZE 15 /* width and height of RB button (select, ON or OFF)*/
++#define CWIDE 8 /* width of character */
++/* #define CHIGH height of character defined in xv.h */
++#define MARGIN 3 /* margin of button and label SPACING */
++
++#define MSD_TITLE "Save file with external command..."
++#define MSD_RBTITLE "Type of Magic and Suffix"
++#define MSD_IC_TITLE "input command"
++
++static BUTT msbut[MS_NBUTTS];
++static RBUTT *typeRB;
++
++static char output_command_ex[1024];
++static int output_command_ex_flag = 0;
++
++static int colorType;
++
++static int w_pid;
++static int w_pstatus;
++
++#define MSNAMWIDE 252 /* width of 'file name' entry window */
++#define MAXFNLEN 256 /* max len of filename being entered */
++static char DialogFileName[MAXFNLEN+100]; /* filename being entered */
++static int curPos, stPos, enPos; /* filename textedit stuff */
++
++
++static mgcsfxtab *get_mgcsfx PARM((int));
++static void changeSuffix PARM((int));
++
++static int WriteMGCSFX PARM((FILE**,byte*,int,int,int,
++ byte*,byte*,byte*,int,int,char*,
++ int, int, char*));
++void CreateMGCSFXW PARM((void));
++void MGCSFXDialog PARM((int));
++int MGCSFXCheckEvent PARM((XEvent *));
++int MGCSFXSaveParams PARM((char *, int));
++
++static void drawMSD PARM((int,int,int,int));
++static void clickMSD PARM((int,int));
++static void doCmd PARM((int));
++static int writeMGCSFX PARM((void));
++
++static void changeSuffix PARM((int));
++static void redrawNamMSD PARM((void));
++static void showFNamMSD PARM((void));
++static int keyinMSD PARM((int));
++
++int getInputCom PARM((void));
++int getOutputCom PARM((void));
++/*--------------------------------------------------------------------------*/
++
++/***************************************************/
++/* $B$I$l$rA*$s$@$+D4$Y$k!##0$O%3%^%s%I$rF~NO$9$k$b$N$H$9$k(B */
++static mgcsfxtab *get_mgcsfx(ms_type)
++ int ms_type;
++{
++ mgcsfxtab *magic;
++ int i;
++
++ magic = NULL;
++ if(ms_type != 0){
++ i = 1;
++ for(magic = mgcsfx_table; (magic && i<ms_type); magic = magic->next){i++;}
++ }
++ return magic;
++}
++
++/***************************************************/
++/* $B30It%3%^%s%I$r<B9T$7$F!"$=$l$K=PNO$9$k(B */
++/* if OK return 0, else if ERROR return -1 */
++static
++int WriteMGCSFX(fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,file_name,
++ ms_type, file, comment)
++ FILE **fp;
++ byte *pic;
++ int ptype, w,h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
++ char *file_name;
++ int ms_type;
++ int file; /* file descriptor */
++ char *comment;
++{
++ mgcsfxtab *magic;
++
++ int fd[2];
++ int pid;
++ int rv;
++
++ WaitCursor();
++
++#ifdef USE_SIGCHLD
++ w_p_fail = 1;
++#endif
++
++ magic = get_mgcsfx(ms_type);
++ if(ms_type != 0 && magic == NULL) return -1;
++
++ if ((ms_type == 0 && output_command_ex_flag) ||
++ (ms_type !=0 && magic != NULL && magic->output_command)){
++
++ /* Do the pipe/fork/exec here */
++ if (pipe (fd) < 0){
++ fprintf (stderr, "Can't pipe : %s\n", file_name);
++ return -1;
++ }
++
++ if ((pid = vfork ()) < 0){
++ fprintf (stderr, "Can't vfork : %s\n", file_name);
++ close (fd[0]);
++ close (fd[1]);
++ return -1;
++ }
++
++ if (!pid){
++ close(1);
++ dup(file);
++ close(file);
++ close(0);
++ dup(fd[0]);
++ close(2);
++ open("/dev/null", O_WRONLY);
++ close(fd[1]);
++ if(ms_type == 0){
++ execl("/bin/sh", "/bin/sh", "-c", output_command_ex, 0);
++ }else{
++ execl("/bin/sh", "/bin/sh", "-c", magic->output_command, 0);
++ }
++ _exit(127);
++ }
++
++ close (fd[0]);
++ dup2(fd[1], file);
++ close (fd[1]);
++
++ }else{
++ return -1;
++ }
++
++
++ *fp = fdopen(file, "w");
++
++ /* sleep(1); Best way is wait for checking SIGCHLD, but it's feel waist.*/
++
++#ifdef USE_SIGCHLD
++ if(w_p_fail != 2){
++#endif
++ if(ms_type == 0){
++ rv = WritePBM(*fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,
++ 1, comment);
++ }else{
++ switch(magic -> output_image_type){
++ case IT_PNM:
++ case IT_PPM:
++ case IT_PGM:
++ case IT_PBM:
++ case IT_PNM_RAW:
++ case IT_PPM_RAW:
++ case IT_PGM_RAW:
++ case IT_PBM_RAW:
++ rv = WritePBM(*fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,
++ 1, comment);
++ break;
++ case IT_PNM_ASCII:
++ case IT_PPM_ASCII:
++ case IT_PGM_ASCII:
++ case IT_PBM_ASCII:
++ rv = WritePBM(*fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,
++ 0, comment);
++ break;
++ case IT_GIF:
++ case IT_JPEG:
++ case IT_TIFF:
++ case IT_JFIF:
++ case IT_XBM:
++ case IT_XPM:
++ case IT_BMP:
++ case IT_SUNRAS:
++ case IT_IRIS:
++ case IT_XWD:
++ case IT_MAG:
++ case IT_MAKI:
++ case IT_PI:
++ case IT_PIC:
++ case IT_PIC2:
++ SetISTR(ISTR_WARNING, "Yet supported output image type (to filter input)");
++ rv = -1;
++ break;
++ case IT_UNKNOWN:
++ SetISTR(ISTR_WARNING, "Unknown output image type (to filter input)");
++ rv = -1;
++ break;
++#ifdef HAVE_MGCSFX_AUTO
++ case IT_AUTO:
++#endif
++ default:
++ SetISTR(ISTR_WARNING, "Error in output image type (to filter input)");
++ rv = -1;
++ break;
++ }
++ }
++#ifdef USE_SIGCHLD
++ }else{
++ rv = -1;
++ }
++#endif
++
++#ifdef USE_SIGCHLD
++ if(w_p_fail != 2){
++#endif
++ w_pid = pid;
++#ifdef USE_SIGCHLD
++ w_p_fail = 0;
++ }else{
++ rv = -1;
++ }
++#endif
++
++ output_command_ex_flag = 0;
++
++ return rv;
++
++ /* fclose(*fp); close in CloseOutFile in writeMGCSFX */
++ /* return 0; ok */
++ /* return -1; error */
++}
++
++/***************************************************/
++void CreateMGCSFXW()
++{
++ int y;
++ int type_num;
++ mgcsfxtab *entry;
++
++ if (mgcsfx_setup_flag == 0) init_mgcsfx ();
++
++ if(desc_width < strlen(MSD_IC_TITLE)) desc_width = strlen(MSD_IC_TITLE);
++ nitem_mgcsfx ++;
++
++ MSWIDE = desc_width * CWIDE + RBSIZE + 36; /* 36 is start of RB button */
++ MSHIGH = nitem_mgcsfx * (RBSIZE + MARGIN);
++
++ if(MSWIDE < strlen(MSD_TITLE) + 20) MSWIDE = strlen(MSD_TITLE) + 20;
++ if(MSWIDE < strlen(MSD_RBTITLE) + 16) MSWIDE = strlen(MSD_RBTITLE) + 16;
++ if(MSWIDE < MSNAMWIDE + 10) MSWIDE = MSNAMWIDE + 10;
++ if(MSWIDE < BUTTW * 2 + 10) MSWIDE = BUTTW * 2 + 10;
++
++ MSHIGH += 55 + LINEHIGH + 10 + BUTTH + 10;
++
++ MSWIDE += 20; /* right side margin */
++ MSHIGH += 10; /* RB buttun down side margin */
++
++
++ mgcsfxW = CreateWindow("xv mgcsfx", "XVmgcsfx", NULL,
++ MSWIDE, MSHIGH, infofg, infobg, 0);
++ if (!mgcsfxW) FatalError("can't create mgcsfx window!");
++
++ XSelectInput(theDisp, mgcsfxW,
++ ExposureMask | ButtonPressMask | KeyPressMask);
++
++ mgcsfxNameW = XCreateSimpleWindow(theDisp, mgcsfxW,
++ 10, MSHIGH-LINEHIGH-10-BUTTH-10-1,
++ (u_int) MSNAMWIDE+6, (u_int) LINEHIGH+5,
++ 1, infofg, infobg);
++ if (!mgcsfxNameW) FatalError("can't create mgcsfx name window");
++ XSelectInput(theDisp, mgcsfxNameW, ExposureMask);
++
++ /* Ok $B%\%?%s(B */
++ BTCreate(&msbut[MS_BOK], mgcsfxW,
++ MSWIDE-BUTTW-10-BUTTW-10-1, MSHIGH-BUTTH-10-1,
++ BUTTW, BUTTH,
++ "Ok", infofg, infobg, hicol, locol);
++ /* Cancel $B%\%?%s(B*/
++ BTCreate(&msbut[MS_BCANC], mgcsfxW,
++ MSWIDE-BUTTW-10-1, MSHIGH-BUTTH-10-1,
++ BUTTW, BUTTH,
++ "Cancel", infofg, infobg, hicol, locol);
++
++ y = 55;
++ /* User should input command to exec external command */
++ typeRB = RBCreate(NULL, mgcsfxW, 36, y, MSD_IC_TITLE,
++ infofg, infobg,hicol,locol);
++ y += (RBSIZE + MARGIN); /* 18 */
++
++ type_num = 1;
++ for (entry = mgcsfx_table; entry; entry = entry->next){
++ RBCreate(typeRB, mgcsfxW, 36, y, entry->description,
++ infofg, infobg,hicol,locol);
++ y += (RBSIZE + MARGIN); /* 18 */
++ if(entry->output_command == NULL){
++ RBSetActive(typeRB, type_num, 0); /* if no command, off */
++ }
++ type_num++;
++ }
++
++ XMapSubwindows(theDisp, mgcsfxW);
++}
++
++
++/***************************************************/
++void MGCSFXDialog(vis)
++ int vis;
++{
++ if (vis) {
++ CenterMapWindow(mgcsfxW, msbut[MS_BOK].x + msbut[MS_BOK].w/2,
++ msbut[MS_BOK].y + msbut[MS_BOK].h/2, MSWIDE, MSHIGH);
++ }
++ else XUnmapWindow(theDisp, mgcsfxW);
++ mgcsfxUp = vis;
++}
++
++
++/***************************************************/
++int MGCSFXCheckEvent(xev)
++ XEvent *xev;
++{
++ /* check event to see if it's for one of our subwindows. If it is,
++ deal accordingly, and return '1'. Otherwise, return '0' */
++
++ int rv;
++ rv = 1;
++
++ if (!mgcsfxUp) return (0);
++
++ 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 (e->window == mgcsfxW) drawMSD(x, y, w, h);
++ else rv = 0;
++ }
++
++ else if (xev->type == ButtonPress) {
++ XButtonEvent *e = (XButtonEvent *) xev;
++ int x,y;
++ x = e->x; y = e->y;
++
++ if (e->button == Button1) {
++ if (e->window == mgcsfxW) clickMSD(x,y);
++ else rv = 0;
++ } /* button1 */
++ else rv = 0;
++ } /* button press */
++
++ else if (xev->type == KeyPress) {
++ XKeyEvent *e = (XKeyEvent *) xev;
++ char buf[128]; KeySym ks; XComposeStatus status;
++ int stlen;
++
++ stlen = XLookupString(e,buf,128,&ks,&status);
++ buf[stlen] = '\0';
++
++ if (e->window == mgcsfxW) {
++ if (stlen) {
++ keyinMSD(buf[0]);
++ }
++ }
++ else rv = 0;
++ }
++ else rv = 0;
++
++ if (rv == 0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
++ XBell(theDisp, 50);
++ rv = 1; /* eat it */
++ }
++
++ return (rv);
++}
++
++
++/***************************************************/
++int MGCSFXSaveParams(fname, col)
++ char *fname;
++ int col;
++{
++ colorType = col;
++ strcpy(DialogFileName, GetDirFName());
++ return (0);
++}
++
++/***************************************************/
++/* $B%@%$%"%m%0$rI=<($9$k$H$-$N=hM}(B */
++static void drawMSD(x,y,w,h)
++ int x,y,w,h;
++{
++ int i;
++ XRectangle xr;
++
++ xr.x = x; xr.y = y; xr.width = w; xr.height = h;
++ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
++
++ XSetForeground(theDisp, theGC, infofg);
++ XSetBackground(theDisp, theGC, infobg);
++
++ for (i = 0; i < MS_NBUTTS; i++) BTRedraw(&msbut[i]);
++
++ ULineString(mgcsfxW, typeRB->x-16, typeRB->y-3-DESCENT,
++ MSD_RBTITLE);
++ RBRedraw(typeRB, -1);
++
++ DrawString(mgcsfxW, 20, 29, MSD_TITLE);
++
++ XSetClipMask(theDisp, theGC, None);
++
++ showFNamMSD();
++}
++
++/***************************************************/
++/* $B%@%$%"%m%0$r%/%j%C%/$7$?$H$-$N=hM}(B */
++static void clickMSD(x,y)
++ int x,y;
++{
++ int i;
++ BUTT *bp;
++
++ /* check BUTTs */
++
++ /* check the RBUTTS first, since they don't DO anything */
++ if ((i = RBClick(typeRB, x,y)) >= 0) { /* $BA*Br(B(type)$B%\%?%s$N=hM}(B */
++ (void) RBTrack(typeRB, i); /* $BA*Br(B(type)$B%\%?%s$r2!$7$?$H$-(B */
++ changeSuffix(i);
++ return;
++ }
++
++ for (i = 0; i < MS_NBUTTS; i++) { /* Ok,Cancel $B%\%?%s$N=hM}(B */
++ bp = &msbut[i];
++ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h))
++ break;
++ }
++ if (i < MS_NBUTTS) /* found one */ /* Ok,Cancel $B%\%?%s$r2!$7$?$H$-(B */
++ if (BTTrack(bp)) doCmd(i);
++}
++
++/***************************************************/
++/* $B%\%?%s(B(Ok, Cancel) $B$N=hM}(B */
++static void doCmd(cmd)
++ int cmd;
++{
++ int rv;
++
++ switch (cmd) {
++ case MS_BOK: /* Ok button */ {
++ char *fullname;
++
++ rv = writeMGCSFX(); /* Save with filter(MGCSFX) */
++ MGCSFXDialog(0);
++
++ fullname = GetDirFullName();
++ if (!ISPIPE(fullname[0])) {
++ XVCreatedFile(fullname);
++ if(!rv) StickInCtrlList(0);
++ }
++ }
++ break;
++ case MS_BCANC: /* Cancel button */
++ DialogFileName[0] = '\0';
++ curPos = stPos = enPos = 0;
++ MGCSFXDialog(0);
++ break;
++ default:
++ break;
++ }
++}
++
++/*******************************************/
++static int writeMGCSFX()
++{
++ int rv, type;
++ int ptype, w, h, pfree, nc;
++ byte *inpix, *rmap, *gmap, *bmap;
++
++ FILE *fp = NULL;
++ int file;
++ char *fullname;
++
++ rv = -1;
++ type = RBWhich(typeRB);
++
++ SetDirFName(DialogFileName); /* change filename in dir dialog */
++ fullname = GetDirFullName();
++
++ if(type == 0){
++ if(getOutputCom() == 0) return rv;
++ }
++
++ file = OpenOutFileDesc(fullname);
++ if(file < 0) return rv;
++
++ WaitCursor();
++ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
++
++ rv = WriteMGCSFX(&fp, inpix, ptype, w, h,
++ rmap, gmap, bmap, nc, colorType, fullname,
++ type, file, picComments);
++
++ SetCursors(-1);
++
++ if (CloseOutFile(fp, fullname, rv) == 0) DirBox(0);
++
++ WaitCursor();
++#ifdef USE_SIGCHLD
++ if(w_p_fail == 0){
++#endif
++ while(wait(&w_pstatus) != w_pid); /* if( *((char *)&w_pstatus) != 0 ) ; */
++#ifdef USE_SIGCHLD
++ }else{
++ w_p_fail = 0;
++ }
++#endif
++ w_pid = 0;
++ w_pstatus = 0;
++
++ if (pfree) free(inpix);
++ return rv;
++}
++
++
++/***************************************/
++static void changeSuffix(ms_type)
++ int ms_type;
++{
++ /* see if there's a common suffix at the end of the DialogFileName.
++ if there is, remember what case it was (all caps or all lower), lop
++ it off, and replace it with a new appropriate suffix, in the
++ same case */
++
++ int allcaps;
++ char *suffix, *sp, *dp, lowsuf[512];
++ mgcsfxtab *magic;
++
++ /* find the last '.' in the DialogFileName */
++ suffix = (char *) rindex(DialogFileName, '.');
++ if (!suffix) return;
++ suffix++; /* point to first letter of the suffix */
++
++ /* check for all-caposity */
++ for (sp = suffix, allcaps=1; *sp; sp++)
++ if (islower(*sp)) allcaps = 0;
++
++ /* copy the suffix into an all-lower-case buffer */
++ for (sp=suffix, dp=lowsuf; *sp; sp++, dp++) {
++ *dp = (isupper(*sp)) ? tolower(*sp) : *sp;
++ }
++ *dp = '\0';
++
++
++ magic = get_mgcsfx(ms_type);
++ if(magic != NULL && magic->suffix != NULL){
++ strcpy(lowsuf,(magic->suffix)+1);
++
++ if (allcaps) { /* upper-caseify lowsuf */
++ for (sp=lowsuf; *sp; sp++)
++ *sp = (islower(*sp)) ? toupper(*sp) : *sp;
++ }
++
++ /* one other case: if the original suffix started with a single
++ capital letter, make the new suffix start with a single cap */
++ if (isupper(suffix[0])) lowsuf[0] = toupper(lowsuf[0]);
++
++ strcpy(suffix, lowsuf); /* tack onto DialogFileName */
++ showFNamMSD();
++ }
++}
++
++/***************************************************/
++/* $B%@%$%"%m%0Fb$K%U%!%$%k%M!<%`$rI=<($9$k$H$-$N=hM}(B ($B2<@A$1(B)*/
++static void redrawNamMSD()
++{
++ int cpos;
++
++ /* draw substring DialogFileName[stPos:enPos] and cursor */
++
++ Draw3dRect(mgcsfxNameW, 0, 0, (u_int) MSNAMWIDE+5, (u_int) LINEHIGH+4, R3D_IN, 2,
++ hicol, locol, infobg);
++
++ XSetForeground(theDisp, theGC, infofg);
++
++ if (stPos>0) { /* draw a "there's more over here" doowah */
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 0,0,0,LINEHIGH+5);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 1,0,1,LINEHIGH+5);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 2,0,2,LINEHIGH+5);
++ }
++
++ if ((size_t) enPos < strlen(DialogFileName)) {
++ /* draw a "there's more over here" doowah */
++ XDrawLine(theDisp, mgcsfxNameW, theGC, MSNAMWIDE+5,0,MSNAMWIDE+5,LINEHIGH+5);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, MSNAMWIDE+4,0,MSNAMWIDE+4,LINEHIGH+5);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, MSNAMWIDE+3,0,MSNAMWIDE+3,LINEHIGH+5);
++ }
++
++ XDrawString(theDisp, mgcsfxNameW, theGC,3,ASCENT+3,DialogFileName+stPos, enPos-stPos);
++
++ cpos = XTextWidth(mfinfo, &DialogFileName[stPos], curPos-stPos);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 3+cpos, 2, 3+cpos, 2+CHIGH+1);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 3+cpos, 2+CHIGH+1, 5+cpos, 2+CHIGH+3);
++ XDrawLine(theDisp, mgcsfxNameW, theGC, 3+cpos, 2+CHIGH+1, 1+cpos, 2+CHIGH+3);
++}
++
++/***************************************************/
++/* $B%@%$%"%m%0Fb$K%U%!%$%k%M!<%`$rI=<($9$k(B */
++static void showFNamMSD()
++{
++ int len;
++
++ len = strlen(DialogFileName);
++
++ if (curPos<stPos) stPos = curPos;
++ if (curPos>enPos) enPos = curPos;
++
++ if (stPos>len) stPos = (len>0) ? len-1 : 0;
++ if (enPos>len) enPos = (len>0) ? len-1 : 0;
++
++ /* while substring is shorter than window, inc enPos */
++
++ while (XTextWidth(mfinfo, &DialogFileName[stPos], enPos-stPos) < MSNAMWIDE
++ && enPos<len) { enPos++; }
++
++ /* while substring is longer than window, dec enpos, unless enpos==curpos,
++ in which case, inc stpos */
++
++ while (XTextWidth(mfinfo, &DialogFileName[stPos], enPos-stPos) > MSNAMWIDE) {
++ if (enPos != curPos) enPos--;
++ else stPos++;
++ }
++
++
++ if (ctrlColor) XClearArea(theDisp, mgcsfxNameW, 2,2, (u_int) MSNAMWIDE+5-3,
++ (u_int) LINEHIGH+4-3, False);
++ else XClearWindow(theDisp, mgcsfxNameW);
++
++ redrawNamMSD();
++ BTSetActive(&msbut[MS_BOK], strlen(DialogFileName)!=0);
++}
++
++/***************************************************/
++/* $B%-!<F~NO$7$?$H$-$N=hM}(B */
++static int keyinMSD(c)
++ int c;
++{
++ /* got keypress in dirW. stick on end of DialogFileName */
++ int len;
++
++ len = strlen(DialogFileName);
++
++ if (c>=' ' && c<'\177') { /* printable characters */
++ /* note: only allow 'piped commands' in savemode... */
++
++ /* only allow spaces in 'piped commands', not filenames */
++ if (c==' ' && (!ISPIPE(DialogFileName[0]) || curPos==0)) return (-1);
++
++ /* only allow vertbars in 'piped commands', not filenames */
++ if (c=='|' && curPos!=0 && !ISPIPE(DialogFileName[0])) return(-1);
++
++ if (len >= MAXFNLEN-1) return(-1); /* max length of string */
++ xvbcopy(&DialogFileName[curPos], &DialogFileName[curPos+1], (size_t) (len-curPos+1));
++ DialogFileName[curPos]=c; curPos++;
++ }
++
++ else if (c=='\010' || c=='\177') { /* BS or DEL */
++ if (curPos==0) return(-1); /* at beginning of str */
++ xvbcopy(&DialogFileName[curPos], &DialogFileName[curPos-1], (size_t) (len-curPos+1));
++ curPos--;
++ }
++
++ else if (c=='\025') { /* ^U: clear entire line */
++ DialogFileName[0] = '\0';
++ curPos = 0;
++ }
++
++ else if (c=='\013') { /* ^K: clear to end of line */
++ DialogFileName[curPos] = '\0';
++ }
++
++ else if (c=='\001') { /* ^A: move to beginning */
++ curPos = 0;
++ }
++
++ else if (c=='\005') { /* ^E: move to end */
++ curPos = len;
++ }
++
++ else if (c=='\004') { /* ^D: delete character at curPos */
++ if (curPos==len) return(-1);
++ xvbcopy(&DialogFileName[curPos+1], &DialogFileName[curPos], (size_t) (len-curPos));
++ }
++
++ else if (c=='\002') { /* ^B: move backwards char */
++ if (curPos==0) return(-1);
++ curPos--;
++ }
++
++ else if (c=='\006') { /* ^F: move forwards char */
++ if (curPos==len) return(-1);
++ curPos++;
++ }
++
++ else if (c=='\012' || c=='\015') { /* CR(\r) or LF(\n) */
++ FakeButtonPress(&msbut[MS_BOK]);
++ }
++
++ else if (c=='\033') { /* ESC = Cancel */
++ FakeButtonPress(&msbut[MS_BCANC]);
++ }
++
++ else if (c=='\011') { /* tab = filename expansion */
++ if (1 /* !autoComplete() */) XBell(theDisp, 0);
++ else {
++ curPos = strlen(DialogFileName);
++ }
++ }
++
++ else return(-1); /* unhandled character */
++
++ showFNamMSD();
++
++ return(0);
++}
++
++
++/*******************************************/
++int getInputCom()
++{
++ static char *labels[] = { "\nOk", "\033Cancel" };
++ int i;
++
++ strcpy(input_command_ex, MGCSFX_DEFAULT_INPUT_COMMAND);
++ i = GetStrPopUp("Input External Command (Input is PNM):", labels, 2,
++ input_command_ex, 1024, "",0);
++ if (i == 0 && strlen(input_command_ex) != 0){
++ input_command_ex_flag = 1;
++ return 1;
++ }else{
++ input_command_ex_flag = 0;
++ return 0;
++ }
++}
++
++int getOutputCom()
++{
++ static 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,
++ output_command_ex, 1024, "",0);
++ if (i == 0 && strlen(output_command_ex) != 0){
++ output_command_ex_flag = 1;
++ return 1;
++ }else{
++ output_command_ex_flag = 0;
++ return 0;
++ }
++}
++
++#ifdef SVR4
++Sigfunc *
++xv_signal(signo, func)
++ int signo;
++ Sigfunc *func;
++{
++ struct sigaction act, oact;
++
++ act.sa_handler = func;
++ sigemptyset(&act.sa_mask);
++ act.sa_flags = 0;
++ act.sa_flags |= SA_RESTART;
++
++ if (sigaction(signo, &act, &oact) < 0)
++ return SIG_ERR;
++
++ return oact.sa_handler;
++}
++#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
+@@ -0,0 +1,989 @@
++/*
++ * xvml.c - makes text item structure for multi-lingual textviewer.
++ *
++ * Entry Points:
++ * struct ml_text *ml_draw_text()
++ * struct context *ml_create_context()
++ * int ml_set_charsets()
++ * void get_monofont_size()
++ */
++
++#include "xv.h"
++#include <X11/Xresource.h>
++
++#ifdef TV_MULTILINGUAL /* whole this file. */
++
++#include "xvml.h"
++#define HAVE_STRDUP 1
++#define USE_MULE_EXTENSION
++
++#ifndef __STDC__
++#define CHAR char
++#else
++#define CHAR int
++#endif
++
++#define CODE_SI 0x0e /* LS0 */
++#define CODE_SO 0x0f /* LS1 */
++#define CODE_SS2 ((unsigned char) 0x8e)
++#define CODE_SS3 ((unsigned char) 0x8f)
++
++int ml_tab_width = 64; /* dots */
++
++struct charset {
++ int bpc; /* bytes per char */
++ int noc; /* number of chars */
++ char designator;
++ char *registry;
++ int bit7;
++
++ int loaded;
++ char *fontname;
++
++ XFontStruct *fs;
++} charset[] = {
++ { 1, 94, 'B', "iso8859-1", 0, 0, NULL, NULL},
++ { 1, 96, 'A', "iso8859-1", 1, 0, NULL, NULL},
++ { 1, 94, '0', "omron_udc_zh-0", 0, 0, NULL, NULL},
++ { 1, 94, '2', "mulearabic-0", 0, 0, NULL, NULL},
++ { 1, 94, '3', "mulearabic-1", 0, 0, NULL, NULL},
++ { 1, 94, '4', "mulearabic-2", 0, 0, NULL, NULL},
++ { 1, 94, 'J', "jisx0201.1976-0", 0, 0, NULL, NULL},
++ { 1, 96, '0', "muleipa-1", 1, 0, NULL, NULL},
++ { 1, 96, '1', "viscii1.1-1", 1, 0, NULL, NULL},
++ { 1, 96, '2', "viscii1.1-1", 1, 0, NULL, NULL},
++ { 1, 96, 'B', "iso8859-2", 1, 0, NULL, NULL},
++ { 1, 96, 'C', "iso8859-3", 1, 0, NULL, NULL},
++ { 1, 96, 'D', "iso8859-4", 1, 0, NULL, NULL},
++ { 1, 96, 'T', "tis620.1986-0", 1, 0, NULL, NULL},
++ { 1, 96, 'F', "iso8859-7", 1, 0, NULL, NULL},
++ { 1, 96, 'G', "iso8859-6", 1, 0, NULL, NULL},
++ { 1, 96, 'H', "iso8859-8", 1, 0, NULL, NULL},
++ { 1, 94, 'I', "jisx0201.1976-0", 1, 0, NULL, NULL},
++ { 1, 96, 'L', "iso8859-5", 1, 0, NULL, NULL},
++ { 1, 96, 'M', "iso8859-9", 1, 0, NULL, NULL},
++ { 2, 94, '2', "ethio-0", 0, 0, NULL, NULL},
++ { 2, 94, '@', "jisx0208.1978", 0, 0, NULL, NULL},
++ { 2, 94, 'A', "gb2312.1980-0", 0, 0, NULL, NULL},
++ { 2, 94, 'B', "jisx0208.1983-0", 0, 0, NULL, NULL},
++ { 2, 94, 'C', "ksc5601.1987-0", 0, 0, NULL, NULL},
++ { 2, 94, 'D', "jisx0212.1990-0", 0, 0, NULL, NULL},
++ { 2, 94, '0', "big5.eten-0", 0, 0, NULL, NULL},
++ { 2, 94, '1', "big5.hku-0", 0, 0, NULL, NULL},
++ /* End Mark */
++ { 0, 0, 0, NULL, 0, 0, NULL, NULL},
++};
++#define NR_CHARSETS ((int) (sizeof charset / sizeof charset[0]))
++
++static struct charset *ascii = NULL;
++
++struct context {
++ struct charset *g[4];
++ struct charset **gl, **gr;
++ struct charset **ss;
++ int eol; /* 0: \n, 1: \r\n, 2: \r, 3: any */
++ int valid[4]; /* g[i] is valid? */
++ int short_form; /* allow shortened designator sequence? */
++ int lock_shift; /* allow locking shift? */
++
++ unsigned char *cbuf, *cbp;
++ struct ml_text text;
++ int line;
++ int delta;
++ int toolong;
++
++ Display *dpy;
++ Screen *scr;
++ Window root_win;
++};
++#define DPY (context->dpy)
++#define SCR (context->scr)
++#define ROOT_WIN (context->root_win)
++
++static unsigned char *escape_sequence PARM((unsigned char *));
++static unsigned char *designator_sequence PARM((unsigned char *));
++static void locking_shift PARM((unsigned CHAR));
++static void single_shift PARM((unsigned CHAR));
++static void put_unknown_char PARM((unsigned CHAR));
++static struct charset *search_charset PARM((int, int, int));
++static void pack_string PARM((struct charset *,
++ unsigned char *, int));
++static void init_xrm PARM((void));
++static void init_xrm_fonts PARM((void));
++static void init_xrm_tab PARM((void));
++#ifndef HAVE_STRDUP
++static char *strdup PARM((char *));
++#endif
++
++static char *default_fonts[] = { /* default for xrm_fonts */
++ "-sony-fixed-medium-r-normal--16-*-*-*-*-*-iso8859-1",
++ "-jis-fixed-medium-r-normal--16-*-*-*-*-*-jisx0208.1983-0",
++};
++static int xrm_nfonts;
++static char **xrm_fonts;
++
++static struct context *context; /* current context */
++
++struct ml_text *ml_draw_text(ctx, string, len)
++ struct context *ctx;
++ char *string;
++ int len;
++{
++ unsigned char *str = (unsigned char *) string;
++ unsigned char *estr = str + len;
++
++ context = ctx;
++
++ if(ascii == NULL){
++ fputs("ml_draw_text: call ml_set_charsets, first.\n", stderr);
++ return NULL;
++ }
++
++ if(!str)
++ return &context->text;
++
++ WaitCursor();
++
++ if (context->text.maxlines != 0) {
++ struct ml_text *tp = &context->text;
++ struct ml_line *lp;
++ int i;
++ for (i = tp->nlines, lp = tp->lines; i > 0; i--, lp++) {
++ if (lp->maxitems != 0)
++ free((char *) lp->items);
++ }
++ free((char *) tp->lines);
++ tp->maxlines = tp->nlines = 0;
++ }
++ if (context->cbuf != NULL)
++ free((char *) context->cbuf);
++ context->cbp = (unsigned char *) malloc((size_t) len * 8);/* all \xxx */
++ context->cbuf = context->cbp;
++ context->line = 0;
++ context->delta = 0;
++ context->ss = NULL;
++
++ while(str < estr){
++ if((*str & 0x80) == 0){ /* left half */
++ struct charset *cs = context->ss ? *context->ss : *context->gl;
++ unsigned char min_char, max_char;
++ if (cs != NULL) {
++ if(cs->noc == 94){
++ min_char = 0x21;
++ max_char = 0x7e;
++ }else{
++ min_char = 0x20;
++ max_char = 0x7f;
++ }
++ }
++
++ if (cs == NULL)
++ put_unknown_char(*str++);
++ else if(*str < min_char || *str > max_char){ /* C1 */
++ switch(*str){
++ case ' ':
++ {
++ unsigned char *p = str + 1;
++ while (*p == ' ' && p < estr)
++ p++;
++ pack_string(ascii, str, (int) (p - str));
++ str = p;
++ }
++ break;
++
++ case '\t':
++ pack_string(ascii, str++, 0);
++ break;
++
++ case '\n':
++ switch (context->eol) {
++ case 0: /* unix type eol */
++ pack_string(ascii, str, 0);
++ WaitCursor();
++ str++;
++ break;
++ case 1: /* dos type eol */
++ case 2: /* mac type eol */
++ put_unknown_char('\n');
++ str++;
++ break;
++ case 3: /* any type eol */
++ pack_string(ascii, str++, 0);
++ while (*str == '\n' || *str == '\r')
++ str++;
++ WaitCursor();
++ break;
++ }
++ break;
++
++ case '\r':
++ switch (context->eol) {
++ case 0:
++ put_unknown_char('\r');
++ str++;
++ break;
++ case 1:
++ str++;
++ if (*str == '\n')
++ pack_string(ascii, str++, 0);
++ else
++ put_unknown_char('\r');
++ break;
++ case 2:
++ pack_string(ascii, str, 0);
++ WaitCursor();
++ str++;
++ break;
++ case 3:
++ pack_string(ascii, str++, 0);
++ while (*str == '\n' || *str == '\r')
++ str++;
++ WaitCursor();
++ break;
++ }
++ break;
++
++ case '\033':
++ {
++ unsigned char *p;
++ str++;
++ if((p = escape_sequence(str)) == str)
++ put_unknown_char('\033');
++ else
++ str = p;
++ }
++ break;
++
++ case CODE_SI:
++ case CODE_SO:
++ if (!context->lock_shift)
++ put_unknown_char((unsigned int) *str++);
++ else
++ locking_shift((unsigned int) *str++);
++ break;
++
++ default:
++ put_unknown_char((unsigned int) *str++);
++ }
++ }else{ /* GL */
++ if (context->ss != NULL) {
++ pack_string(cs, str, 1);
++ str += cs->bpc;
++ context->ss = NULL;
++ } else {
++ int n;
++
++ if (cs->bpc == 1) {
++ unsigned char *p = str;
++ for (n = 0; p < estr; n++) {
++ if (*p < min_char || *p > max_char)
++ break;
++ p++;
++ }
++ pack_string(cs, str, n);
++ str = p;
++ } else {
++ unsigned char *p = str;
++ for (n = 0; p < estr - 1; n++) {
++ if (*p < min_char || *p > max_char ||
++ *(p + 1) < min_char || *(p + 1) > max_char)
++ break;
++ p += 2;
++ }
++ if (n > 0)
++ pack_string(cs, str, n);
++ else
++ put_unknown_char(*p++);
++ str = p;
++ }
++ }
++ }
++ }else{ /* right half */
++ struct charset *cs = context->ss ? *context->ss : *context->gr;
++ unsigned char min_char, max_char;
++ if (cs != NULL) {
++ if(cs->noc == 94){
++ min_char = 0xa1;
++ max_char = 0xfe;
++ }else{
++ min_char = 0xa0;
++ max_char = 0xff;
++ }
++ }
++
++ if (cs == NULL)
++ put_unknown_char(*str++);
++ else if(*str < min_char || *str > max_char){ /* C2 */
++ unsigned char c = *str++;
++ switch(c){
++ case CODE_SS2:
++ case CODE_SS3:
++ single_shift((unsigned CHAR) c);
++ break;
++ default:
++ put_unknown_char(c);
++ }
++ }else{ /* GR */
++ if (context->ss != NULL) {
++ pack_string(cs, str, 1);
++ str += cs->bpc;
++ context->ss = NULL;
++ } else {
++ int n;
++
++ if (cs->bpc == 1) {
++ unsigned char *p = str;
++ for (n = 0; p < estr; n++) {
++ if (*p < min_char || *p > max_char)
++ break;
++ p++;
++ }
++ pack_string(cs, str, n);
++ str = p;
++ } else {
++ unsigned char *p = str;
++ for (n = 0; p < estr - 1; n++) {
++ if (*p < min_char || *p > max_char ||
++ *(p + 1) < min_char || *(p + 1) > max_char)
++ break;
++ p += 2;
++ }
++ if (n > 0)
++ pack_string(cs, str, n);
++ else
++ put_unknown_char(*p++);
++ str = p;
++ }
++ }
++ }
++ }
++ }
++
++ {
++ struct ml_text *tp = &context->text;
++ struct ml_line *lp;
++ int i;
++
++ tp->width = 0;
++ tp->height = 0;
++ for (lp = tp->lines, i = tp->nlines; i > 0; lp++, i--) {
++ if (lp->nitems == 0) {
++ lp->ascent = ascii->fs->ascent;
++ lp->descent = ascii->fs->descent;
++ }
++ if (tp->width < lp->width)
++ tp->width = lp->width;
++ tp->height += lp->ascent + lp->descent;
++ }
++ }
++
++ SetCursors(-1);
++ return &context->text;
++}
++
++static unsigned char *escape_sequence(str)
++ unsigned char *str;
++{
++ unsigned char *p;
++ switch(*str){
++ case '$':
++ case '(': case ')': case '*': case '+':
++ case '-': case '.': case '/': case ',':
++ if((p = designator_sequence(str)) == NULL)
++ return str;
++ return p;
++ case 'n': case 'o': case '~': case '}': case '|':
++ if (!context->lock_shift)
++ return str;
++ locking_shift(*str);
++ return str + 1;
++ case 'N': case 'O':
++ single_shift(*str);
++ return str + 1;
++ }
++ return str;
++
++}
++
++static unsigned char *designator_sequence(str)
++ unsigned char *str;
++{
++ unsigned char *p = str;
++ int noc, bpc, n_g, shortened;
++ unsigned char des;
++ struct charset *cs;
++
++ if(*p == '$'){
++ bpc = 2;
++ p++;
++ }else
++ bpc = 1;
++
++ switch(*p++){
++ case '(': noc = 94; n_g = 0; des = *p++; shortened = 0; break;
++ case ')': noc = 94; n_g = 1; des = *p++; shortened = 0; break;
++ case '*': noc = 94; n_g = 2; des = *p++; shortened = 0; break;
++ case '+': noc = 94; n_g = 3; des = *p++; shortened = 0; break;
++#ifdef USE_MULE_EXTENSION
++ case ',': noc = 96; n_g = 0; des = *p++; shortened = 0; break;
++#endif
++ case '-': noc = 96; n_g = 1; des = *p++; shortened = 0; break;
++ case '.': noc = 96; n_g = 2; des = *p++; shortened = 0; break;
++ case '/': noc = 96; n_g = 3; des = *p++; shortened = 0; break;
++ case '@': noc = 94; n_g = 0; des = 'B'; shortened = 0; break;
++ case 'A': noc = 94; n_g = 0; des = 'A'; shortened = 1; break;
++ case 'B': noc = 94; n_g = 0; des = 'B'; shortened = 1; break;
++ default: return NULL;
++ }
++ if (!context->short_form && shortened)
++ return NULL;
++
++ if((cs = search_charset(bpc, noc, des)) == NULL){
++ if(DEBUG){
++ fprintf(stderr, "designator_sequence: (%d,%d,%c) not found.\n",
++ bpc, noc, des);
++ }
++ return NULL;
++ }
++ if (!context->valid[n_g])
++ return NULL;
++ context->g[n_g] = cs;
++ if(DEBUG){
++ fprintf(stderr,
++ "designator_sequence: G%d is `%s'.\n", n_g, cs->registry);
++ }
++ return p;
++}
++
++static void locking_shift(c)
++ unsigned CHAR c;
++{
++ switch((unsigned char) c){
++ case CODE_SI: context->gl = &context->g[0]; break;
++ case CODE_SO: context->gl = &context->g[1]; break;
++ case 'n': context->gl = &context->g[2]; break;
++ case 'o': context->gl = &context->g[3]; break;
++ case '~': context->gr = &context->g[1]; break;
++ case '}': context->gr = &context->g[2]; break;
++ case '|': context->gr = &context->g[3]; break;
++ }
++ if(DEBUG){
++ fprintf(stderr, "locking_shift: (%d,%d).\n",
++ (int)(context->gl - context->g),
++ (int)(context->gr - context->g));
++ }
++}
++
++static void single_shift(c)
++ unsigned CHAR c;
++{
++ switch((unsigned char) c){
++ case CODE_SS2: context->ss = &context->g[2]; break;
++ case CODE_SS3: context->ss = &context->g[3]; break;
++ }
++}
++
++
++static void put_unknown_char(chr)
++ unsigned CHAR chr;
++{
++ unsigned char c = chr;
++
++ if(c < 0x20){
++ unsigned char buf[2];
++ buf[0] = '^';
++ buf[1] = c + 0x40;
++ pack_string(ascii, buf, 2);
++ }else{
++ unsigned char buf[4];
++ buf[0] = '\\';
++ buf[1] = ((c >> 6) & 07) + '0';
++ buf[2] = ((c >> 3) & 07) + '0';
++ buf[3] = ((c ) & 07) + '0';
++ pack_string(ascii, buf, 4);
++ }
++}
++
++struct context *ml_create_context(s)
++ Screen *s;
++{
++ context = (struct context *) malloc(sizeof *context);
++
++ context->g[0] = NULL;
++ context->g[1] = NULL;
++ context->g[2] = NULL;
++ context->g[3] = NULL;
++ context->gl = NULL;
++ context->gr = NULL;
++ context->ss = NULL;
++
++ context->cbuf = NULL;
++ context->text.maxlines = context->text.nlines = 0;
++ context->line = 0;
++ context->delta = 0;
++ context->toolong = 0;
++
++ DPY = DisplayOfScreen(s);
++ SCR = s;
++ ROOT_WIN = RootWindowOfScreen(s);
++
++ return context;
++}
++
++
++int ml_set_charsets(ctx, sys)
++ struct context *ctx;
++ struct coding_system *sys;
++{
++ int retval = 0;
++ int i;
++
++ context = ctx;
++
++ if(ascii == NULL){
++ init_xrm();
++ if((ascii = search_charset(1, 94, 'B')) == NULL){
++ fputs("ml_set_charsets: ascii charset not found.\n", stderr);
++ Quit(1);
++ }
++ if (ascii->fs == NULL) {
++ fputs("ml_set_charsets: iso8859-1 font not found.\n", stderr);
++ Quit(1);
++ }
++ }
++ for(i = 0; i < 4; i++){
++ switch(sys->design[i].bpc){
++ case -1: /* make G[i] invalid */
++ context->valid[i] = 0;
++ break;
++
++ case 0: /* don't change */
++ break;
++
++ case 1: case 2: /* change it */
++ if((context->g[i] = search_charset(sys->design[i].bpc,
++ sys->design[i].noc,
++ sys->design[i].des)) == NULL){
++ fputs("ml_set_charsets: ", stderr);
++ fprintf(stderr, "(%d,%d,%c) is specified as G%d, ",
++ sys->design[i].bpc, sys->design[i].noc,
++ sys->design[i].des, i);
++ fputs("but not found. using `iso8859-1'.\n", stderr);
++ context->g[i] = ascii;
++ retval++;
++ }
++ context->valid[i] = 1;
++ break;
++
++ default: /* error */
++ fprintf(stderr,"ml_set_charsets: bad arguments of G%d. ", i);
++ fputs("using `iso8859-1'.\n", stderr);
++ context->g[i] = ascii;
++ retval++;
++ }
++ }
++ if((unsigned int) sys->gl < 4)
++ context->gl = &context->g[sys->gl];
++ else{
++ fprintf(stderr, "ml_set_charsets: bad number as GL. using G0.\n");
++ context->gl = &context->g[0];
++ }
++ if((unsigned int) sys->gr < 4)
++ context->gr = &context->g[sys->gr];
++ else{
++ fprintf(stderr, "ml_set_charsets: bad number as GR. using G0.\n");
++ context->gr = &context->g[0];
++ }
++ context->eol = sys->eol;
++ context->short_form = sys->short_form;
++ context->lock_shift = sys->lock_shift;
++ return retval;
++}
++
++static struct charset *search_charset(bpc, noc, des)
++ int bpc, noc;
++ int des;
++{
++ struct charset *cset;
++ for(cset = charset; cset->bpc != 0; cset++){
++ if(cset->bpc == bpc &&
++ cset->noc == noc &&
++ cset->designator == (char) des){
++ if(!cset->loaded){
++#if 0
++ int i, l;
++ l = strlen(cset->registry);
++ for (i = 0; i < xrm_nfonts; i++) {
++ int li = strlen(xrm_fonts[i]);
++ if (li > l) {
++ if (xrm_fonts[i][li - l - 1] == '-' &&
++ strcmp(xrm_fonts[i] + li - l,
++ cset->registry) == 0) {
++ if ((cset->fs = XLoadQueryFont(DPY, xrm_fonts[i]))
++ != NULL) {
++ if (DEBUG) {
++ fprintf(stderr, "%s for %s\n",
++ xrm_fonts[i], cset->registry);
++ }
++ cset->fontname = xrm_fonts[i];
++ break;
++ } else
++ SetISTR(ISTR_WARNING,
++ "%s: font not found.", xrm_fonts[i]);
++ }
++ }
++ }
++#else
++ int i, l;
++ l = strlen(cset->registry);
++ for (i = 0; i < xrm_nfonts && cset->fs == NULL; i++) {
++ int j, nfnts = 0;
++ char **fnts = XListFonts(DPY, xrm_fonts[i],
++ 65535, &nfnts);
++ for (j = 0 ; j < nfnts; j++) {
++ int ll = strlen(fnts[j]);
++ if (*(fnts[j] + ll - l - 1) == '-' &&
++ strcmp(fnts[j] + ll - l, cset->registry)== 0) {
++ if ((cset->fs = XLoadQueryFont(DPY, fnts[j]))
++ != NULL) {
++ if (DEBUG) {
++ fprintf(stderr, "%s for %s\n",
++ fnts[j], cset->registry);
++ }
++ cset->fontname = strdup(fnts[j]);
++ break;
++ } else
++ SetISTR(ISTR_WARNING,
++ "%s: font not found", fnts[j]);
++ }
++ }
++ if (fnts != NULL)
++ XFreeFontNames(fnts);
++ }
++#endif
++ if(cset->fs == NULL){
++ SetISTR(ISTR_WARNING,
++ "font for %s not found.\nusing ascii font.",
++ cset->registry);
++ if (ascii != NULL)
++ cset->fs = ascii->fs;
++ }
++
++ cset->loaded = 1;
++ }
++ return cset;
++ }
++ }
++ return NULL;
++}
++
++static void pack_string(cs, str, len)
++ struct charset *cs;
++ unsigned char *str;
++ int len; /* number of chars(not bytes) */
++{
++ struct ml_text *mt = &context->text;
++ struct ml_line *lp;
++ XTextItem16 *ip;
++
++ if (context->line == mt->maxlines) {
++ int oldmax = mt->maxlines;
++ if (mt->maxlines < 1)
++ mt->maxlines = 1;
++ else
++ mt->maxlines = 2 * mt->maxlines;
++ if (oldmax == 0)
++ mt->lines = (struct ml_line *)
++ malloc(sizeof(struct ml_line) * mt->maxlines);
++ else {
++ mt->lines = (struct ml_line *)
++ realloc(mt->lines,
++ sizeof(struct ml_line) * mt->maxlines);
++ }
++ }
++ lp = &mt->lines[context->line];
++ if (mt->nlines == context->line) {
++ mt->nlines++;
++ lp->maxitems = 0;
++ lp->nitems = 0;
++ lp->width = 0;
++ lp->ascent = lp->descent = 0;
++ }
++
++ if (len == 0) {
++ switch (*str) {
++ case '\n':
++ context->line++;
++ context->delta = 0;
++ context->toolong = 0;
++ break;
++ case '\t':
++ {
++ int nx, x = lp->width + context->delta;
++ nx = (x + ml_tab_width) / ml_tab_width * ml_tab_width;
++ context->delta += nx - x;
++ }
++ break;
++ }
++ return;
++ }
++
++ if (context->toolong)
++ return;
++ if (lp->width > 30000) {
++ context->toolong = 1;
++ cs = ascii;
++ str = (unsigned char *) "...";
++ len = 3;
++ }
++
++ if (lp->nitems == lp->maxitems) {
++ int oldmax = lp->maxitems;
++ if (lp->maxitems < 1)
++ lp->maxitems = 1;
++ else
++ lp->maxitems = 2 * lp->maxitems;
++ if (oldmax == 0)
++ lp->items = (XTextItem16 *)
++ malloc(sizeof(XTextItem16) * lp->maxitems);
++ else
++ lp->items = (XTextItem16 *)
++ realloc(lp->items,
++ sizeof(XTextItem16) * lp->maxitems);
++ }
++ ip = &lp->items[lp->nitems++];
++ ip->chars = (XChar2b *) context->cbp;
++ ip->nchars = len;
++ ip->delta = context->delta;
++ ip->font = cs->fs->fid;
++ context->cbp += 2 * len;
++ context->delta = 0;
++
++ if (cs->bpc == 1) {
++ XChar2b *p;
++ unsigned char b7 = cs->bit7 ? 0x80 : 0;
++ int i;
++ for (i = len, p = ip->chars; i > 0; i--, p++) {
++ p->byte1 = '\0';
++ p->byte2 = (*str++ & 0x7f) | b7;
++ }
++ } else {
++ XChar2b *p;
++ unsigned char b7 = cs->bit7 ? 0x80 : 0;
++ int i;
++ for (i = len, p = ip->chars; i > 0; i--, p++) {
++ p->byte1 = (*str++ & 0x7f) | b7;
++ p->byte2 = (*str++ & 0x7f) | b7;
++ }
++ }
++
++ lp->width += XTextWidth16(cs->fs, ip->chars, ip->nchars);
++ if (lp->ascent < cs->fs->ascent)
++ lp->ascent = cs->fs->ascent;
++ if (lp->descent < cs->fs->descent)
++ lp->descent = cs->fs->descent;
++}
++
++void get_monofont_size(wide, high)
++ int *wide, *high;
++{
++ if (ascii == NULL) {
++ fputs("ml_draw_text: call ml_set_charsets, first.\n", stderr);
++ return;
++ }
++ *wide = ascii->fs->max_bounds.width;
++ *high = ascii->fs->ascent + ascii->fs->descent;
++}
++
++static void init_xrm()
++{
++ init_xrm_fonts();
++ init_xrm_tab();
++}
++
++static void init_xrm_fonts()
++{
++ char *p, *fns = XGetDefault(theDisp, "xv", "fontSet");
++ int n;
++ if (fns == NULL) {
++ xrm_fonts = default_fonts;
++ xrm_nfonts = sizeof default_fonts / sizeof *default_fonts;
++ return;
++ }
++ while(*fns == ' ' || *fns == '\t')
++ fns++;
++ if (*fns == '\0') {
++ xrm_fonts = default_fonts;
++ xrm_nfonts = sizeof default_fonts / sizeof *default_fonts;
++ return;
++ }
++ fns = strdup(fns);
++
++ n = 1;
++ for (p = fns; *p != '\0'; p++) {
++ if (*p == ',')
++ n++;
++ }
++ xrm_nfonts = n;
++ xrm_fonts = (char **) malloc(sizeof (char *) * xrm_nfonts);
++ for (n = 0, p = fns; n < xrm_nfonts && *p != '\0'; ) {
++ while (*p == ' ' || *p == '\t')
++ p++;
++ xrm_fonts[n++] = p;
++ while (1) {
++ char *q;
++ while (*p != ' ' && *p != '\t' && *p != ',' && *p != '\0')
++ p++;
++ q = p;
++ while (*q == ' ' || *q == '\t')
++ q++;
++ if (*q == ',' || *q == '\0') {
++ *p = '\0';
++ p = q + 1;
++ break;
++ } else
++ p = q;
++ }
++ }
++ for ( ; n < xrm_nfonts; n++)
++ xrm_fonts[n] = "";
++}
++
++static void init_xrm_tab()
++{
++ char *ts = XGetDefault(theDisp, "xv", "tabWidth");
++ unsigned short tab;
++ if (ts == NULL)
++ tab = 64;
++ else {
++ char *ep;
++ long t;
++ int bad = 0;
++ t = strtol(ts, &ep, 0);
++ tab = (unsigned short) t;
++ if (ep != NULL) {
++ while (*ep == ' ' && *ep == '\t')
++ ep++;
++ if (*ep != '\0')
++ bad = 1;
++ }
++ if (tab != (long) (unsigned long) t)
++ bad = 1;
++ if (bad) {
++ SetISTR(ISTR_WARNING, "bad tab width.");
++ tab = 64;
++ }
++ }
++ ml_tab_width = tab;
++}
++
++
++#ifndef HAVE_STRDUP
++static char *strdup(str)
++ char *str;
++{
++ return strcpy(malloc(strlen(str) + 1), str);
++}
++#endif
++
++char *lookup_registry(d, b7)
++ struct design d;
++ int *b7;
++{
++ int i;
++ for (i = 0; i < NR_CHARSETS; i++) {
++ if (charset[i].bpc == d.bpc && charset[i].noc == d.noc &&
++ charset[i].designator == d.des) {
++ *b7 = charset[i].bit7;
++ return charset[i].registry;
++ }
++ }
++ return NULL;
++}
++
++struct design lookup_design(registry, b7)
++ char *registry;
++ int b7;
++{
++ struct design d;
++ int i;
++ d.bpc = 0;
++ d.noc = 0;
++ d.des = '\0';
++ for (i = 0; i < NR_CHARSETS; i++) {
++ if (strcmp(charset[i].registry, registry) == 0 &&
++ charset[i].bit7 == b7) {
++ d.bpc = charset[i].bpc;
++ d.noc = charset[i].noc;
++ d.des = charset[i].designator;
++ break;
++ }
++ }
++ return d;
++}
++
++char *sjis_to_jis(orig, len, newlen)
++ char *orig;
++ int len, *newlen;
++{
++ unsigned char *new;
++ unsigned char *p, *q, *endp;
++ if (len == 0) {
++ *newlen = 0;
++ return (char *) malloc((size_t) 1);
++ }
++ new = (unsigned char *) malloc((size_t) len * 4); /* big enough */
++ for (p = (unsigned char *) orig, endp = p + len, q = new; p < endp; ) {
++ if ((*p & 0x80) == 0) /* 1 byte char */
++ *q++ = *p++;
++ else if (*p >= 0x81 && *p <= 0x9f) { /* kanji 1st byte */
++ unsigned char c1 = *p++;
++ unsigned char c2 = *p++;
++ if (c2 < 0x40 || c2 > 0xfc) { /* bad 2nd byte */
++ *q++ = CODE_SS2;
++ *q++ = c1;
++ *q++ = CODE_SS2;
++ *q++ = c2;
++ } else { /* right 2nd byte */
++ if (c2 <= 0x9e) {
++ if (c2 > 0x7f)
++ c2--;
++ c1 = (c1 - 0x81) * 2 + 1 + 0xa0;
++ c2 = (c2 - 0x40) + 1 + 0xa0;
++ } else {
++ c1 = (c1 - 0x81) * 2 + 2 + 0xa0;
++ c2 = (c2 - 0x9f) + 1 + 0xa0;
++ }
++ *q++ = c1;
++ *q++ = c2;
++ }
++ } else if (*p >= 0xe0 && *p <= 0xef) { /* kanji 1st byte */
++ unsigned char c1 = *p++;
++ unsigned char c2 = *p++;
++ if (c2 < 0x40 || c2 > 0xfc) { /* bad 2nd byte */
++ *q++ = CODE_SS2;
++ *q++ = c1;
++ *q++ = CODE_SS2;
++ *q++ = c2;
++ } else { /* right 2nd byte */
++ if (c2 <= 0x9e) {
++ c1 = (c1 - 0xe0) * 2 + 63 + 0xa0;
++ c2 = (c2 - 0x40) + 1 + 0xa0;
++ } else {
++ c1 = (c1 - 0xe0) * 2 + 64 + 0xa0;
++ c2 = (c2 - 0x9f) + 1 + 0xa0;
++ }
++ *q++ = c1;
++ *q++ = c2;
++ }
++ } else { /* katakana or something */
++ *q++ = CODE_SS2;
++ *q++ = *p++;
++ }
++ }
++ *newlen = q - new;
++
++ return (char *) realloc(new, (size_t) *newlen);
++}
++
++#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
+@@ -0,0 +1,96 @@
++#ifndef MLVIEW_H
++#define MLVIEW_H
++
++/*
++ * What is this?
++ *
++ * It is a package to show multi-lingual text.
++ *
++ * How to use?
++ *
++ * 1. Call ml_set_screen(Screen *scr);
++ * Tell this package the screen you use.
++ *
++ * 2. Call ml_set_charsets(struct char_spec spec[4], int gl, int gr);
++ * Tell this package the initial charsets.
++ * Gn is set to the charset specified by spec[n], respectively.
++ * GL and GR are set to G[gl] and G[gr], respectively.
++ * If first call, iso8859-1 font is loaded.
++ *
++ * 3. Call ml_draw_text(char *string);
++ * It Creates a bitmap, and returns it to you.
++ * If something goes wrong, it returns None.
++ * DON'T free the returned pixmaps!!
++ *
++ * BUGS:
++ * - Amharic and Tigrigna characters are strange.
++ * - Big5 is not supported.
++ * - Reverse direction is not supported.
++ * - Composing is not supported.
++ * - Cantonese can't be shown.
++ * - Texts which have many lines are buggy.
++ *
++ * NOTE:
++ * - Shifted JIS and Shifted GB must be converted to iso2022 in advance.
++ *
++ * Example of parameters to ml_set_charsets:
++ * - EUC-Japan
++ * spec = { {1, 94, 'B'}, G0 is US-ASCII
++ * {2, 94, 'B'}, G1 is JIS X0208
++ * {1, 94, 'J'}, G2 is (right-half of)JIS X0201
++ * {2, 94, 'D'} }; G3 is JIS X0212
++ * gl = 0; GL is G0
++ * gr = 1; GR is G1
++ *
++ * - Compound Text
++ * spec = { {1, 94, 'B'}, G0 is US-ASCII
++ * {1, 96, 'A'}, G1 is Latin-1
++ * {1, 94, 'B'}, G2 is US-ASCII (maybe unused)
++ * {1, 94, 'B'} }; G3 is US-ASCII (maybe unused)
++ * gl = 0; GL is G0
++ * gr = 1; GR is G1
++ *
++ * - Korean Mail
++ * spec = { {1, 94, 'B'}, G0 is US-ASCII
++ * {2, 94, 'C'}, G1 is KSC5601
++ * {1, 94, 'B'}, G2 is US-ASCII (maybe unused)
++ * {1, 94, 'B'} }; G3 is US-ASCII (maybe unused)
++ * gl = 0; GL is G0
++ * gl = 1; GR is G1
++ */
++
++struct coding_system {
++ struct design {
++ int bpc; /* byte per char if 1 or 2,
++ don't touch if 0, or
++ don't use if -1.*/
++ int noc; /* number of chars (94 or 96) */
++ char des; /* designator ('A', 'B', ...) */
++ } design[4];
++ int gl, gr;
++ int eol;
++ int short_form;
++ int lock_shift;
++};
++
++struct ml_text {
++ int maxlines, nlines;
++ struct ml_line {
++ int maxitems, nitems;
++ int width, ascent, descent;
++ XTextItem16 *items;
++ } *lines;
++ int width, height;
++};
++
++struct context;
++struct ml_text *ml_draw_text PARM((struct context *, char *, int));
++struct context *ml_create_context PARM((Screen *));
++int ml_set_charsets PARM((struct context *,
++ struct coding_system *));
++void get_monofont_size PARM((int *, int *));
++char *sjis_to_jis PARM((char *, int, int *));
++char *lookup_registry PARM((struct design, int *));
++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 @@
++/*
++ * xvpcd.c - load routine for 'PhotoCD' format pictures
++ *
++ * LoadPCD(fname, pinfo, size) - loads a PhotoCD file
++ *
++ * This routine will popup a choice of which of the 5 available resolutions
++ * the user wants to choose, then load it as a 24 bit image.
++ *
++ * Copyright 1993 David Clunie, Melbourne, Australia.
++ *
++ * The outline of this is shamelessly derived from xvpbm.c to read the
++ * file, and xvtiffwr.c to handle the popup window and X stuff (X never
++ * has been my forte !), and the PhotoCD format information (though not
++ * the code) was found in Hadmut Danisch's (danisch@ira.uka.de) hpcdtoppm
++ * program in which he has reverse engineered the format by studying
++ * hex dumps of PhotoCDs ! After all who can afford the Kodak developer's
++ * kit, which none of us have seen yet ? Am I even allowed to mention these
++ * words (Kodak, PhotoCD) ? I presume they are registered trade marks.
++ *
++ * PS. I have no idea how Halmut worked out the YCC <-> RGB conversion
++ * factors, but I have calculated them from his tables and the results
++ * look good enough to me.
++ *
++ * Added size parameter to allow the schnautzer to create thumnails
++ * without requesting the size every time.
++ */
++
++#include "xv.h"
++#include <memory.h>
++
++#ifdef HAVE_PCD
++
++#define TRACE 0
++#if TRACE
++# define trace(x) fprintf x
++#else
++# define trace(x)
++#endif
++
++/* 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.
++
++ Not being able to malloc is a Fatal Error. The program is aborted. */
++
++
++#ifdef __STDC__
++static void magnify(int, int, int, int, int, byte *);
++static int pcdError(char *, char *);
++static int gethuffdata(byte *, byte *, byte *, int, int);
++#else
++static void magnify();
++static int pcdError();
++static int gethuffdata();
++#endif
++
++#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 CBUTT lutCB;
++
++/*
++ * This "beyond 100%" table is taken from ImageMagick (gamma 2.2).
++ * 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
++};
++
++/*******************************************/
++/* The size should be -1 for the popup to ask otherwise fast is assumed */
++/* returns '1' on success */
++/*******************************************/
++int
++LoadPCD(char *fname, PICINFO *pinfo, int theSize)
++{
++ long offset;
++ int mag;
++ 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;
++
++ 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");
++
++ /*
++ * 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;
++
++/* 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
++
++ - 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
++
++ - 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
++
++ - 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 !
++
++ 4base
++ - 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
++
++ (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
++ (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
++
++ (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)
++
++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 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
++
++ - for base, the 16base chroma planes are then halved
++*/
++
++ PCDSetParamOptions(bname);
++ if (theSize == -1)
++ {
++ PCDDialog(1); /* Open PCD Dialog box */
++ SetCursors(-1); /* Somebody has already set it to wait :( */
++ leaveitup=1;
++ goforit=0;
++ size = 1;
++ /* block until the popup window gets closed */
++ while (leaveitup) {
++ int i;
++ XEvent event;
++ XNextEvent(theDisp, &event);
++ HandleEvent(&event, &i);
++ }
++ /* At this point goforit and size will have been set */
++ if (!goforit) {
++ /* nothing allocated so nothing needs freeing */
++ return 0;
++ }
++ WaitCursor();
++ }
++ else
++ {
++ size = theSize;
++ goforit = 1;
++ }
++
++ 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;
++
++ 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 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;
++ }
++
++ /*
++ * rotate?
++ */
++ w = pinfo->w;
++ h = pinfo->h;
++ switch(rotate) {
++ case 0:
++ 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;
++ }
++
++ /*
++ * 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->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.");
++ }
++
++ pic24 = pinfo->pic;
++
++ 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'");
++ }
++
++ 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 */
++
++ 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);
++
++ /*
++ * 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 */
++{
++ int x,y,yi;
++ byte *optr,*nptr,*uptr; /* MUST be unsigned, else averaging fails */
++
++ while (mag > 1) {
++
++ /* create every 2nd new row from 0 */
++ /* even pixels being equal to the old, odd ones averaged with successor */
++ /* special case being the last column which is just set equal to the */
++ /* second last) ... */
++
++ for(y=0;y<h;y++) {
++ yi=h-1-y;
++ 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 */
++
++ for(x=1;x<w;x++) {
++ optr--; nptr-=2; /* next lower pixel(s) */
++ nptr[0]=optr[0]; /* even pixels duped */
++ nptr[1]=(((int)optr[0])+
++ ((int)optr[1])+1)>>1; /* odd averaged */
++ }
++ }
++
++ /* Fill in odd rows, as average of prior & succeeding rows, with */
++ /* even pixels average of one column, odd pixels average of two */
++
++ for(y=0;y<h-1;y++) { /* all but the last old row */
++ optr=p + 2*y*mw; /* start of the new "even" rows */
++ nptr=optr+mw; /* start of the next empty row */
++ uptr=nptr+mw; /* start of the next again (even) */
++
++ for(x=0;x<w-1;x++) { /* for all cols except the last */
++ nptr[0]=(((int)optr[0])+
++ ((int)uptr[0])+1)>>1; /* even pixels */
++ nptr[1]=(((int)optr[0])+
++ ((int)optr[2])+
++ ((int)uptr[0])+
++ ((int)uptr[2])+2)>>2; /* odd pixels */
++ nptr+=2; optr+=2; uptr+=2;
++ }
++ *(nptr++)=(((int)*(optr++))+
++ ((int)*(uptr++))+1)>>1; /* 2nd last pixel */
++ *(nptr++)=(((int)*(optr++))+
++ ((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 */
++
++ h*=2; w*=2;
++ mag>>=1; /* Obviously mag must be a power of 2 ! */
++ }
++}
++
++/*******************************************/
++static int
++pcdError(char *fname, char *st)
++{
++ SetISTR(ISTR_WARNING,"%s: %s", fname, st);
++ return 0;
++}
++
++
++/**** Stuff for PCDDialog box ****/
++
++#define TWIDE 380
++#define THIGH 160
++#define T_NBUTTS 2
++#define T_BOK 0
++#define T_BCANC 1
++#define BUTTH 24
++
++static void drawTD PARM((int, int, int, int));
++static void clickTD PARM((int, int));
++static void doCmd PARM((int));
++static void PCDSetParams PARM((void));
++
++/* local variables */
++static BUTT tbut[T_NBUTTS];
++static RBUTT *resnRB;
++
++
++
++/***************************************************/
++void CreatePCDW()
++{
++ int y;
++
++ pcdW = CreateWindow("xv pcd", "XVpcd", NULL,
++ 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);
++
++ BTCreate(&tbut[T_BCANC], pcdW, TWIDE-70-1, THIGH-10-BUTTH-1, 60, BUTTH,
++ "Cancel", infofg, infobg, hicol, locol);
++
++ y = 55;
++ resnRB = RBCreate(NULL, pcdW, 36, y, "192*128 Base/16",
++ infofg, infobg,hicol,locol);
++ RBCreate(resnRB, pcdW, 36, y+18, "384*256 Base/4",
++ infofg, infobg,hicol,locol);
++ RBCreate(resnRB, pcdW, 36, y+36, "768*512 Base",
++ infofg, infobg, hicol, locol);
++ RBCreate(resnRB, pcdW, TWIDE/2, y, "1536*1024 4Base",
++ infofg, infobg, hicol, locol);
++ RBCreate(resnRB, pcdW, TWIDE/2, y+18, "3072*2048 16Base",
++ infofg, infobg, hicol, locol);
++
++ CBCreate(&lutCB, pcdW, TWIDE/2, y+36, "Linear LUT",
++ infofg, infobg, hicol, locol);
++
++ RBSelect(resnRB, 2);
++
++ XMapSubwindows(theDisp, pcdW);
++}
++
++
++/***************************************************/
++void PCDDialog(vis)
++int vis;
++{
++ if (vis) {
++ CenterMapWindow(pcdW, tbut[T_BOK].x + tbut[T_BOK].w/2,
++ tbut[T_BOK].y + tbut[T_BOK].h/2, TWIDE, THIGH);
++ }
++ else XUnmapWindow(theDisp, pcdW);
++ pcdUp = vis;
++}
++
++
++/***************************************************/
++int PCDCheckEvent(xev)
++XEvent *xev;
++{
++ /* check event to see if it's for one of our subwindows. If it is,
++ deal accordingly, and return '1'. Otherwise, return '0' */
++
++ int rv;
++ rv = 1;
++
++ if (!pcdUp) return 0;
++
++ 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 (e->window == pcdW) drawTD(x, y, w, h);
++ else rv = 0;
++ }
++
++ else if (xev->type == ButtonPress) {
++ XButtonEvent *e = (XButtonEvent *) xev;
++ int x,y;
++ x = e->x; y = e->y;
++
++ if (e->button == Button1) {
++ if (e->window == pcdW) clickTD(x,y);
++ else rv = 0;
++ } /* button1 */
++ else rv = 0;
++ } /* button press */
++
++
++ else if (xev->type == KeyPress) {
++ XKeyEvent *e = (XKeyEvent *) xev;
++ char buf[128]; KeySym ks; XComposeStatus status;
++ int stlen;
++
++ stlen = XLookupString(e,buf,128,&ks,&status);
++ buf[stlen] = '\0';
++
++ RemapKeyCheck(ks, buf, &stlen);
++
++ 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]);
++ }
++ }
++ }
++ else rv = 0;
++ }
++ else rv = 0;
++
++ if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
++ XBell(theDisp, 50);
++ rv = 1; /* eat it */
++ }
++
++ return rv;
++}
++
++
++/***************************************************/
++void
++PCDSetParamOptions(char *fname)
++{
++ int cur;
++ cur = RBWhich(resnRB);
++
++ RBSetActive(resnRB,0,1);
++ RBSetActive(resnRB,1,1);
++ RBSetActive(resnRB,2,1);
++ RBSetActive(resnRB,3,1);
++ RBSetActive(resnRB,4,1);
++ CBSetActive(&lutCB,1);
++}
++
++
++/***************************************************/
++static void
++drawTD(int x, int y, int w, int h)
++{
++ 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);
++
++ XSetForeground(theDisp, theGC, infofg);
++ XSetBackground(theDisp, theGC, infobg);
++
++ for (i=0; i<T_NBUTTS; i++) BTRedraw(&tbut[i]);
++
++ ULineString(pcdW, resnRB->x-16, resnRB->y-10-DESCENT, "Resolution");
++ RBRedraw(resnRB, -1);
++ CBRedraw(&lutCB);
++
++ XDrawString(theDisp, pcdW, theGC, 20, 19, title, strlen(title));
++
++ XSetClipMask(theDisp, theGC, None);
++}
++
++
++/***************************************************/
++static void clickTD(x,y)
++int x,y;
++{
++ int i;
++ BUTT *bp;
++
++ /* check BUTTs */
++
++ /* check the RBUTTS first, since they don't DO anything */
++ if ( (i=RBClick(resnRB, x,y)) >= 0) {
++ (void) RBTrack(resnRB, i);
++ return;
++ }
++
++ if(CBClick(&lutCB, x, y)) {
++ (void) CBTrack(&lutCB);
++ return;
++ }
++
++ for (i=0; i<T_NBUTTS; i++) {
++ bp = &tbut[i];
++ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
++ }
++
++ if (i<T_NBUTTS) { /* found one */
++ if (BTTrack(bp)) doCmd(i);
++ }
++}
++
++
++
++/***************************************************/
++static void doCmd(cmd)
++int cmd;
++{
++ leaveitup=0;
++ goforit=0;
++ switch (cmd) {
++ case T_BOK: PCDSetParams();
++ goforit=1;
++ case T_BCANC: PCDDialog(0);
++ break;
++
++ default: break;
++ }
++}
++
++
++/*******************************************/
++static void PCDSetParams()
++{
++ switch (RBWhich(resnRB)) {
++ case 0: size = 0; break;
++ case 1: size = 1; break;
++ case 2: size = 2; break;
++ case 3: size = 3; break;
++ case 4: size = 4; break;
++ case 5: size = 0; break;
++ default: size = 0; break;
++ }
++}
++
++/*
++ * Read the Huffman tables which consist of an unsigned byte # of entries
++ * (less 1) followed by up to 256 entries, each of which is a series of 4
++ * unsigned bytes - length, highseq, lowseq, and key.
++ *
++ * Store the huffman table into tree type structure:
++ *
++ * int int[n of entries*2]
++ *
++ * Each entry consists of two words (the 1st for zero and the 2nd for one).
++ *
++ * If the word is negative, then subtract it from the current pointer to
++ * get the next entry (ie. it is the negative offset from the current
++ * position*2 in order to skip entries not words) with which to
++ * make a decision.
++ *
++ * If the word is not negative, then the low 8 bits contain the value (which
++ * is supposed to be a signed char) and the rest of the word is zero.
++ */
++static void
++dumphufftab(int n, const byte *h, int m, const int *t)
++{
++ 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");
++ }
++}
++
++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;
++ }
++
++ /*
++ * 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;
++ }
++
++ /*
++ * 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;
++#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;
++ }
++
++ /*
++ * 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 */
++/* fills with sign bit not 0 on right shifts */
++typedef unsigned int WORDTYPE;
++typedef int SWORDTYPE;
++#define WORDSIZE sizeof(WORDTYPE)
++#define NBYTESINBUF 0x800
++
++static byte buffer[NBYTESINBUF];
++static int bitsleft=0;
++static int bytesleft=0;
++static byte *bufptr;
++static WORDTYPE word;
++
++#if 0
++static void
++dumpbuffer(void)
++{
++ int i,left;
++ byte *ptr=buffer;
++
++ fprintf(stderr,"dumpbuffer: bytesleft=%d bitsleft= %d word=0x%08lx\n",
++ bytesleft,bitsleft,(unsigned long)word);
++ for (left=NBYTESINBUF; left>0; left-=16) {
++ fprintf(stderr,"%05d ",left);
++ for (i=0; i<8; i++) {
++ fprintf(stderr,"%02x",*ptr++);
++ fprintf(stderr,"%02x ",*ptr++);
++ }
++ fprintf(stderr,"\n");
++ }
++}
++#endif /* 0 */
++
++static void
++loadbuffer(void)
++{
++ if ((bytesleft=fread(buffer,1,NBYTESINBUF,fp)) == 0) {
++ fprintf(stderr,"Truncation error\n");
++ exit(1);
++ }
++ bufptr=buffer;
++ /* dumpbuffer(); */
++}
++
++static void
++loadbyte(void)
++{
++ if (bytesleft <= 0) loadbuffer();
++ --bytesleft;
++ word|=(WORDTYPE)(*bufptr++)<<(sizeof(WORDTYPE)*8-8-bitsleft);
++ bitsleft+=8;
++}
++
++static int
++getbit(void)
++{
++ int bit;
++
++ while (bitsleft <= 0) loadbyte();
++ --bitsleft;
++ bit=(SWORDTYPE)(word)<0; /* assumes word is signed */
++ /* bit=word>>(sizeof(WORDTYPE)*8-1); */
++ word<<=1;
++ return bit;
++}
++
++static WORDTYPE
++getnn(int nn)
++{
++ WORDTYPE value;
++
++ while (bitsleft <= nn) loadbyte();
++ bitsleft-=nn;
++ value=word>>(sizeof(WORDTYPE)*8-nn);
++ word<<=nn;
++ return value;
++}
++
++static WORDTYPE
++isnn(int nn)
++{
++ WORDTYPE value;
++
++ while (bitsleft <= nn) loadbyte();
++ value=word>>(sizeof(WORDTYPE)*8-nn);
++ return value;
++}
++
++static void
++skipnn(int nn)
++{
++ while (bitsleft <= nn) loadbyte();
++ bitsleft-=nn;
++ word<<=nn;
++}
++
++#define get1() (getbit())
++#define get2() (getnn(2))
++#define get8() (getnn(8))
++#define get13() (getnn(13))
++#define get16() (getnn(16))
++#define get24() (getnn(24))
++
++#define is24() (isnn(24))
++
++#define skip1() (skipnn(1))
++#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;
++#if TRACE
++ 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;
++ }
++
++ /*
++ * 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;
++ }
++
++ /*
++ * 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;
++
++ 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);
++#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];
++ }
++
++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;
++}
++
++#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
+@@ -0,0 +1,1060 @@
++/*
++ * xvpi.c - load routine for `Pi' format pictures.
++ *
++ * The `Pi' format is made by Yanagisawa.
++ * It is common among many Japanese personal computer users.
++ *
++ */
++
++#include "xv.h"
++#include <setjmp.h>
++
++#ifdef HAVE_PI
++
++typedef unsigned short data16;
++typedef unsigned int data32;
++
++struct pi_info {
++ jmp_buf jmp;
++ FILE *fp;
++ struct {
++ int rest;
++ byte cur;
++ }bs;
++ long fsize;
++ byte mode;
++ int width, height;
++ float aspect;
++ int cbits;
++ int numcols;
++ byte *cmap;
++ struct ct_t{
++ struct elt_t *top;
++ struct elt_t{
++ struct elt_t *old, *recent;
++ byte val;
++ } *elt;
++ }*ct;
++ int defcmap;
++ int writing_grey;
++};
++
++static void pi_open_file PARM((struct pi_info*, char*));
++static void pi_read_header PARM((struct pi_info*, char**));
++static void pi_check_id PARM((struct pi_info*));
++static void pi_read_comment PARM((struct pi_info*, char**));
++static void pi_read_palette PARM((struct pi_info*));
++static void pi_expand PARM((struct pi_info*, byte**));
++static byte pi_read_color PARM((struct pi_info*, int));
++static int pi_read_position PARM((struct pi_info*));
++static data32 pi_read_length PARM((struct pi_info*));
++static int pi_copy_pixels PARM((struct pi_info*,
++ byte*, int, int, data32));
++
++static void pi_write_header PARM((struct pi_info*,
++ char*, byte*, byte*, byte*));
++static void pi_write_id PARM((struct pi_info*));
++static void pi_write_comment PARM((struct pi_info*, char*));
++static void pi_write_palette PARM((struct pi_info*, byte*, byte*, byte*));
++static void pi_compress PARM((struct pi_info*, byte*));
++static void pi_write_gabage PARM((struct pi_info*));
++static void pi_write_color PARM((struct pi_info*, int, int));
++static int pi_test_matching PARM((struct pi_info*,
++ byte*, int, int, data32*));
++static void pi_write_position PARM((struct pi_info*, int));
++static void pi_write_length PARM((struct pi_info*, data32));
++
++static void pi_table_create PARM((struct pi_info*));
++static byte pi_table_get_value PARM((struct pi_info*, int, int));
++static int pi_table_lookup_value PARM((struct pi_info*, int, int));
++static data32 pi_read_bits PARM((struct pi_info*, int));
++static void pi_write_bits PARM((struct pi_info*, data32, int));
++static void pi_init_pi_info PARM((struct pi_info*));
++static void pi_cleanup_pi_info PARM((struct pi_info*, int));
++static void pi_cleanup_pinfo PARM((PICINFO*));
++static void pi_memory_error PARM((char*, char*));
++static void pi_error PARM((struct pi_info*, int));
++static void pi_file_error PARM((struct pi_info*, int));
++static void pi_file_warning PARM((struct pi_info*, int));
++static void pi_show_pi_info PARM((struct pi_info*));
++static void *pi_malloc PARM((size_t, char*));
++static void *pi_realloc PARM((void*, size_t, char*));
++
++
++static char *pi_id = "Pi";
++static char *pi_msgs[] = {
++ NULL,
++#define PI_OPEN 1
++ "couldn't open.",
++#define PI_CORRUPT 2
++ "file corrupted.",
++#define PI_FORMAT 3
++ "not PI format.",
++#define PI_PLANES 4
++ "bad number of planes.",
++#define PI_WRITE 5
++ "write failed.",
++};
++
++
++/* The main routine of `Pi' loader. */
++int LoadPi(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++{
++ struct pi_info pi;
++ int e;
++ int i;
++ if(DEBUG) fputs("LoadPi:\n", stderr);
++
++ pinfo->comment = NULL;
++ pi_init_pi_info(&pi);
++ if((e = setjmp(pi.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ pi_cleanup_pi_info(&pi, 0);
++ pi_cleanup_pinfo(pinfo);
++ if(DEBUG) fputs("\n", stderr);
++ return 0;
++ }
++
++ pi_open_file(&pi, fname);
++ pi_read_header(&pi, &pinfo->comment);
++ pi_expand(&pi, &pinfo->pic);
++
++ pinfo->normw = pinfo->w = pi.width;
++ pinfo->normh = pinfo->h = pi.height;
++ pinfo->type = PIC8;
++ if(pi.numcols > 256) /* shouldn't happen. */
++ pi.numcols = 256;
++ for(i = 0; i < pi.numcols; i++){
++ pinfo->r[i] = pi.cmap[i * 3 ];
++ pinfo->g[i] = pi.cmap[i * 3 + 1];
++ pinfo->b[i] = pi.cmap[i * 3 + 2];
++ }
++ pinfo->frmType = F_PI;
++ pinfo->colType = F_FULLCOLOR;
++ sprintf(pinfo->fullInfo, "Pi, %d colors (%ld bytes)",
++ pi.numcols, pi.fsize);
++ sprintf(pinfo->shrtInfo, "%dx%d Pi.", pi.width, pi.height);
++ normaspect = pi.aspect;
++
++ pi_cleanup_pi_info(&pi, 0);
++ if(DEBUG) fputs("\n", stderr);
++ return 1;
++}
++
++static void pi_open_file(pi, fname)
++ struct pi_info *pi;
++ char *fname;
++{
++ if((pi->fp = fopen(fname, "rb")) == NULL)
++ pi_file_error(pi, PI_OPEN);
++ fseek(pi->fp, (size_t) 0, SEEK_END);
++ pi->fsize = ftell(pi->fp);
++ fseek(pi->fp, (size_t) 0, SEEK_SET);
++}
++
++static void pi_read_header(pi, comm)
++ struct pi_info *pi;
++ char **comm;
++{
++ byte buf[10];
++ int mda;
++ int i;
++
++ pi_check_id(pi);
++ pi_read_comment(pi, comm);
++
++ if(fread(buf, (size_t) 10, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_CORRUPT);
++
++ pi->mode = buf[0];
++ pi->defcmap = pi->mode & 0x80;
++ if(buf[1] != 0 && buf[2] != 0)
++ pi->aspect = (float) buf[2] / (int) buf[1];
++ pi->cbits = buf[3];
++ pi->numcols = 1 << pi->cbits;
++
++ if(pi->cbits != 4 && pi->cbits != 8)
++ pi_error(pi, PI_PLANES);
++
++ mda = (int) buf[8] << 8 | (int) buf[9];
++ for(i = 0; i < mda; i++){
++ if(fgetc(pi->fp) == EOF)
++ pi_file_error(pi, PI_CORRUPT);
++ }
++
++ if(fread(buf, (size_t) 4, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_CORRUPT);
++ pi->width = (int) buf[0] << 8 | (int) buf[1];
++ pi->height = (int) buf[2] << 8 | (int) buf[3];
++
++ pi_read_palette(pi);
++
++ if(DEBUG) pi_show_pi_info(pi);
++}
++
++static void pi_check_id(pi)
++ struct pi_info *pi;
++{
++ char buf[2];
++
++ if(fread(buf, (size_t) 2, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_CORRUPT);
++ if(strncmp(buf, pi_id, (size_t) 2) != 0)
++ pi_error(pi, PI_FORMAT);
++}
++
++static void pi_read_comment(pi, comm)
++ struct pi_info *pi;
++ char **comm;
++{
++/*
++ * The comment format is like:
++ * comment string `^Z' dummy string `\0'
++ */
++ int max = -1, i = 0;
++ int c;
++
++ while(1){
++ if((c = fgetc(pi->fp)) == EOF)
++ pi_file_error(pi, PI_CORRUPT);
++ if(c == '\032') /* 0x1a, '^Z' */
++ break;
++ if(max < i){
++ max += 32;
++ *comm = pi_realloc(*comm, (size_t) max + 1, "pi_read_comment(1)");
++ }
++ (*comm)[i++] = c;
++ }
++ if(max < i){
++ max++;
++ *comm = pi_realloc(*comm, (size_t) max + 1, "pi_read_comment(2)");
++ }
++ (*comm)[i] = '\0';
++
++ while((c = fgetc(pi->fp)) != '\0'){ /* skip the dummy area */
++ if(c == EOF)
++ pi_file_error(pi, PI_CORRUPT);
++ }
++}
++
++static void pi_read_palette(pi)
++ struct pi_info *pi;
++{
++ pi->cmap = pi_malloc((size_t) pi->numcols * 3, "pi_read_palette");
++ if(pi->mode & 0x80){
++ if(pi->numcols == 16){
++ int i;
++ byte on;
++
++ on = 0x77;
++ for(i = 0; i < 8; i++){
++ pi->cmap[i * 3 ] = i & 2 ? on : 0;
++ pi->cmap[i * 3 + 1] = i & 4 ? on : 0;
++ pi->cmap[i * 3 + 2] = i & 1 ? on : 0;
++ }
++ on = 0xff;
++ for(; i < 16; i++){
++ pi->cmap[i * 3 ] = i & 2 ? on : 0;
++ pi->cmap[i * 3 + 1] = i & 4 ? on : 0;
++ pi->cmap[i * 3 + 2] = i & 1 ? on : 0;
++ }
++ }else{ /* pi->numcols == 256 */
++ int i;
++ byte r, g, b;
++ r = g = b = 0;
++ for(i = 0; i < 256; i++){
++ pi->cmap[i * 3 ] = r;
++ pi->cmap[i * 3 + 1] = g;
++ pi->cmap[i * 3 + 2] = b;
++ if((b += 0x40) == 0){
++ if((r += 0x20) == 0)
++ g += 0x20;
++ }
++ }
++ }
++ }else{
++ if(fread(pi->cmap, (size_t) pi->numcols * 3, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_CORRUPT);
++ }
++}
++
++/* The main routine to expand `Pi' file. */
++static void pi_expand(pi, pic)
++ struct pi_info *pi;
++ byte **pic;
++{
++ byte prev_col = 0;
++ int prev_pos = -1;
++ int cnt = 0, max_cnt = pi->width * pi->height;
++
++ *pic = pi_malloc((size_t) max_cnt, "pi_expand"); // GRR POSSIBLE OVERFLOW / FIXME
++
++ pi_table_create(pi);
++
++ if(pi->width > 2){
++ (*pic)[0] = pi_read_color(pi, 0);
++ (*pic)[1] = pi_read_color(pi, (*pic)[0]);
++
++ while(cnt < max_cnt){
++ int pos = pi_read_position(pi);
++ if(pos != prev_pos){
++ data32 len = pi_read_length(pi);
++ cnt = pi_copy_pixels(pi, *pic, cnt, pos, len);
++ prev_col = (*pic)[cnt - 1];
++ prev_pos = pos;
++ }else{
++ do{
++ prev_col = pi_read_color(pi, (int) prev_col);
++ (*pic)[cnt++] = prev_col;
++ prev_col = pi_read_color(pi, (int) prev_col);
++ (*pic)[cnt++] = prev_col;
++ }while(pi_read_bits(pi, 1) == 1);
++
++ prev_pos = -1;
++ }
++ }
++ }else{
++ while(cnt < max_cnt){
++ prev_col = pi_read_color(pi, (int) prev_col);
++ (*pic)[cnt++] = prev_col;
++ }
++ }
++}
++
++static byte pi_read_color(pi, prev)
++ struct pi_info *pi;
++ int prev;
++{
++ byte n;
++ if(pi->cbits == 4){
++ if(pi_read_bits(pi, 1) == 1)
++ n = pi_read_bits(pi, 1); /* 1x */
++ else{
++ if(pi_read_bits(pi, 1) == 0)
++ n = pi_read_bits(pi, 1) + 2; /* 00x */
++ else{
++ if(pi_read_bits(pi, 1) == 0)
++ n = pi_read_bits(pi, 2) + 4; /* 010xx */
++ else
++ n = pi_read_bits(pi, 3) + 8; /* 011xxx */
++ }
++ }
++ }else{ /* cbits == 8 */
++ if(pi_read_bits(pi, 1) == 1)
++ n = pi_read_bits(pi, 1);
++ else{
++ int bits = 0;
++ byte base = 2;
++ while(bits < 6){
++ if(pi_read_bits(pi, 1) == 0)
++ break;
++ bits++;
++ base <<= 1;
++ }
++ n = pi_read_bits(pi, bits + 1) + base;
++ }
++ }
++
++ return pi_table_get_value(pi, prev, (int) n);
++}
++
++static int pi_read_position(pi)
++ struct pi_info *pi;
++{
++ byte r;
++ if((r = pi_read_bits(pi, 2)) != 3)
++ return (int) r;
++ else
++ return (int) pi_read_bits(pi, 1) + 3;
++}
++
++static data32 pi_read_length(pi)
++ struct pi_info *pi;
++{
++ data32 r = 1;
++ int bits = 0;
++ while(pi_read_bits(pi, 1) == 1){
++ r <<= 1;
++ bits++;
++ }
++ if(bits > 0)
++ return r + pi_read_bits(pi, bits);
++ return 1;
++}
++
++static int pi_copy_pixels(pi, pic, cnt, pos, len)
++ struct pi_info *pi;
++ byte *pic;
++ int cnt, pos;
++ data32 len;
++{
++ int s = 0, d = cnt;
++ int max = pi->width * pi->height;
++ switch(pos){
++ case 0:
++ if(cnt < 2){
++ if(pic[0] == pic[1])
++ s = cnt - 2;
++ else
++ s = cnt - 4;
++ }else{
++ if(pic[cnt - 2] == pic[cnt - 1])
++ s = cnt - 2;
++ else
++ s = cnt - 4;
++ }
++ break;
++ case 1:
++ s = cnt - pi->width;
++ break;
++ case 2:
++ s = cnt - pi->width * 2;
++ break;
++ case 3:
++ s = cnt - pi->width + 1;
++ break;
++ case 4:
++ s = cnt - pi->width - 1;
++ }
++
++ len *= 2;
++ while(s < 0 && len != 0 && d < max){
++ pic[d++] = pic[-(s++) % 2];
++ len--;
++ }
++ while(len != 0 && d < max){
++ pic[d++] = pic[s++];
++ len--;
++ }
++ return d;
++}
++
++/* The main routine of `Pi' saver. */
++int WritePi(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle,
++ comment)
++ FILE *fp;
++ byte *pic;
++ int ptype, w, h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
++ char *comment;
++{
++ byte rtemp[256], gtemp[256], btemp[256];
++ struct pi_info pi;
++ int e;
++
++ if(DEBUG) fputs("WritePi\n", stderr);
++ pi_init_pi_info(&pi);
++ pi.fp = fp;
++ pi.width = w;
++ pi.height = h;
++ pi.writing_grey = (colorstyle == F_GREYSCALE);
++ if(ptype == PIC24){
++ if(!(pic = Conv24to8(pic, w, h, 256, rtemp, gtemp, btemp)))
++ pi_memory_error("Conv24to8", "WritePi");
++ rmap = rtemp;
++ gmap = gtemp;
++ bmap = btemp;
++ numcols = 256;
++ }
++
++ if((e = setjmp(pi.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ pi_cleanup_pi_info(&pi, 1);
++ if(DEBUG) fputs("\n", stderr);
++ return -1;
++ }
++
++ pi.numcols = numcols;
++ pi_write_header(&pi, comment, rmap, gmap, bmap);
++ pi_compress(&pi, pic);
++ pi_write_gabage(&pi);
++
++ pi_cleanup_pi_info(&pi, 1);
++ if(DEBUG) fputs("\n", stderr);
++ return 0;
++}
++
++static void pi_write_header(pi, comm, r, g, b)
++ struct pi_info *pi;
++ char *comm;
++ byte *r, *g, *b;
++{
++ byte buf[14];
++
++ if(DEBUG) pi_show_pi_info(pi);
++
++ pi_write_id(pi);
++ pi_write_comment(pi, comm);
++
++ buf[0] = buf[1] = buf[2] = 0;
++ buf[3] = pi->cbits = pi->numcols > 16 ? 8 : 4;
++ buf[4] = 'X';
++ buf[5] = 'V';
++ buf[6] = ' ';
++ buf[7] = ' ';
++ buf[8] = buf[9] = 0;
++ buf[10] = pi->width >> 8;
++ buf[11] = pi->width;
++ buf[12] = pi->height >> 8;
++ buf[13] = pi->height;
++ if(fwrite(buf, (size_t) 14, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++
++ pi_write_palette(pi, r, g, b);
++}
++
++static void pi_write_id(pi)
++ struct pi_info *pi;
++{
++ if(fwrite(pi_id, (size_t) 2, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++}
++
++static void pi_write_comment(pi, comm)
++ struct pi_info *pi;
++ char *comm;
++{
++ if(comm){
++ int i;
++ for(i = 0; comm[i]; i++){
++ if(comm[i] == '\032') /* 0x1a, '^Z' */
++ comm[i] = ' ';
++ }
++ if(i > 0){
++ if(fwrite(comm, (size_t) i, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++ }
++ }
++
++ if(fwrite("\032\0", (size_t) 2, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++}
++
++static void pi_write_palette(pi, r, g, b)
++ struct pi_info *pi;
++ byte *r, *g, *b;
++{
++ int i;
++ int pinum = 1 << pi->cbits;
++ char buf[3];
++
++ for(i = 0; i < pi->numcols; i++){
++ buf[0] = *r++;
++ buf[1] = *g++;
++ buf[2] = *b++;
++ if(pi->writing_grey)
++ buf[0] = buf[1] = buf[2] = MONO(buf[0], buf[1], buf[2]);
++ if(fwrite(buf, (size_t) 3, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++ }
++ for( ; i < pinum; i++){
++ if(fwrite(buf, (size_t) 3, (size_t) 1, pi->fp) != 1)
++ pi_file_error(pi, PI_WRITE);
++ }
++ pi->numcols = pinum;
++}
++
++/* The main routine to compress `Pi' format. */
++static void pi_compress(pi, pic)
++ struct pi_info *pi;
++ byte *pic;
++{
++ byte prev_col = 0;
++ int prev_pos = -1;
++ int cnt = 0, max_cnt = pi->width * pi->height;
++ pi_table_create(pi);
++
++ if(pi->width > 2){
++ int pos;
++ data32 len;
++
++ pi_write_color(pi, 0, pic[0]);
++ pi_write_color(pi, pic[0], pic[1]);
++ pos = pi_test_matching(pi, pic, prev_pos, cnt, &len);
++ while(cnt < max_cnt){
++ if(pos >= 0){
++ pi_write_position(pi, pos);
++ pi_write_length(pi, len);
++ if((cnt += len * 2) >= max_cnt)
++ break;
++ prev_col = pic[cnt - 1];
++ prev_pos = pos;
++ pos = pi_test_matching(pi, pic, prev_pos, cnt, &len);
++ }else{
++ pi_write_position(pi, prev_pos);
++ prev_pos = -1;
++ while(pos < 0){
++ pi_write_color(pi, (int) prev_col, pic[cnt]);
++ prev_col = pic[cnt];
++ if(++cnt >= max_cnt)
++ break;
++ pi_write_color(pi, (int) prev_col, pic[cnt]);
++ prev_col = pic[cnt];
++ if(++cnt >= max_cnt)
++ break;
++ pos = pi_test_matching(pi, pic, -1, cnt, &len);
++ if(pos < 0)
++ pi_write_bits(pi, 1, 1);
++ else
++ pi_write_bits(pi, 0, 1);
++ }
++ }
++ }
++ }else{
++ while(cnt < max_cnt){
++ pi_write_color(pi, (int) prev_col, pic[cnt]);
++ prev_col = pic[cnt++];
++ }
++ }
++}
++
++static void pi_write_gabage(pi)
++ struct pi_info *pi;
++{
++ pi_write_bits(pi, 0, 32);
++}
++
++static void pi_write_color(pi, prev, col)
++ struct pi_info *pi;
++ int prev, col;
++{
++ int n = pi_table_lookup_value(pi, prev, col);
++
++ if(pi->cbits == 4){
++ if(n < 2)
++ pi_write_bits(pi, (data32) n | 2, 2);
++ else if(n < 4)
++ pi_write_bits(pi, (data32) n - 2, 3);
++ else if(n < 8)
++ pi_write_bits(pi, (data32) (n - 4) | 8, 5);
++ else
++ pi_write_bits(pi, (data32) (n - 8) | 24, 6);
++ }else{ /* cbits == 8 */
++ if(n < 2){
++ pi_write_bits(pi, (data32) n | 2, 2);
++ }else{
++ int bits = 0;
++ byte base = 2;
++ while(bits < 6){
++ if(n < (int) base * 2)
++ break;
++ bits++;
++ base <<= 1;
++ }
++ pi_write_bits(pi, 0, 1);
++ if(bits > 0)
++ pi_write_bits(pi, 0xffffffff, bits);
++ if(bits < 6)
++ pi_write_bits(pi, 0, 1);
++ pi_write_bits(pi, (data32) n - base, bits + 1);
++ }
++ }
++}
++
++static int pi_test_matching(pi, pic, prev, cnt, len)
++ struct pi_info *pi;
++ byte *pic;
++ int prev, cnt;
++ data32 *len;
++{
++ data32 lens[5];
++ int pos, p;
++ int s, d = 0;
++ int max = pi->width * pi->height;
++
++ for(pos = 0; pos < 5; pos++){
++ switch(pos){
++ case 0:
++ if(cnt < 2){
++ if(pic[0] == pic[1])
++ d = cnt - 2;
++ else
++ d = cnt - 4;
++ }else{
++ if(pic[cnt - 2] == pic[cnt - 1])
++ d = cnt - 2;
++ else
++ d = cnt - 4;
++ }
++ break;
++ case 1:
++ d = cnt - pi->width;
++ break;
++ case 2:
++ d = cnt - pi->width * 2;
++ break;
++ case 3:
++ d = cnt - pi->width + 1;
++ break;
++ case 4:
++ d = cnt - pi->width - 1;
++ }
++ s = cnt;
++ lens[pos] = 0;
++
++ if(prev == 0 && pos == 0)
++ continue;
++
++ while(d < max){
++ if(pic[(d < 0) ? (-d) % 2 : d] != pic[s])
++ break;
++ lens[pos]++;
++ d++;
++ s++;
++ }
++
++ }
++
++ for(pos = 0, p = 1; p < 5; p++){
++ if(lens[p] >= lens[pos])
++ pos = p;
++ }
++
++ if(lens[pos] / 2 == 0)
++ return -1;
++ *len = lens[pos] / 2;
++ return pos;
++}
++
++static void pi_write_position(pi, pos)
++ struct pi_info *pi;
++ int pos;
++{
++ switch(pos){
++ case 0:
++ pi_write_bits(pi, 0, 2);
++ break;
++ case 1:
++ pi_write_bits(pi, 1, 2);
++ break;
++ case 2:
++ pi_write_bits(pi, 2, 2);
++ break;
++ case 3:
++ pi_write_bits(pi, 6, 3);
++ break;
++ case 4:
++ pi_write_bits(pi, 7, 3);
++ break;
++ }
++}
++
++static void pi_write_length(pi, len)
++ struct pi_info *pi;
++ data32 len;
++{
++ int bits = 0;
++ data32 base = 1;
++
++ while(len >= base * 2){
++ bits++;
++ base <<= 1;
++ }
++ if(bits > 0){
++ pi_write_bits(pi, 0xffffffff, bits);
++ pi_write_bits(pi, 0, 1);
++ pi_write_bits(pi, len - base, bits);
++ }else
++ pi_write_bits(pi, 0, 1);
++}
++
++/*
++ * These pi_table_* functions manipulate the color table.
++ * pi_table_create:
++ * allocates and initializes a color table.
++ * pi_table_get_value:
++ * get the specified value, and move it to the top of the list.
++ * pi_table_lookup_value:
++ * look up the specified value, and move it to the top of the list.
++ */
++static void pi_table_create(pi)
++ struct pi_info *pi;
++{
++ struct ct_t *t;
++ int i;
++ byte mask = pi->numcols - 1;
++ pi->ct = pi_malloc(sizeof *pi->ct * pi->numcols, "pi_table_create(1)");
++ for(i = 0, t = pi->ct; i < pi->numcols; i++, t++){
++ int j;
++ byte v = i;
++ t->elt = pi_malloc(sizeof *t->elt * pi->numcols, "pi_table_create(2)");
++ t->top = &t->elt[pi->numcols - 1];
++ for(j = 0; j < pi->numcols; j++){
++ v = (v + 1) & mask;
++ if(j > 0)
++ t->elt[j].old = &t->elt[j - 1];
++ else
++ t->elt[0].old = t->top;
++ if(j < pi->numcols - 1)
++ t->elt[j].recent = &t->elt[j + 1];
++ else
++ t->elt[j].recent = &t->elt[0];
++ t->elt[j].val = v;
++ }
++ t->elt[0].old = t->top;
++ t->top->recent = &t->elt[0];
++ }
++}
++
++static byte pi_table_get_value(pi, left, num)
++ struct pi_info *pi;
++ int left, num;
++{
++ struct ct_t *t = &pi->ct[left];
++ struct elt_t *e = t->top;
++ if(left >= pi->numcols || num >= pi->numcols)
++ abort();
++ if(num != 0){
++ do {
++ e = e->old;
++ }while(--num != 0);
++
++ e->old->recent = e->recent;
++ e->recent->old = e->old;
++
++ e->recent = t->top->recent;
++ e->recent->old = e;
++ e->old = t->top;
++ t->top->recent = e;
++
++ t->top = e;
++ }
++ return e->val;
++}
++
++static int pi_table_lookup_value(pi, left, v)
++ struct pi_info *pi;
++ int left, v;
++{
++ struct ct_t *t = &pi->ct[left];
++ struct elt_t *e = t->top;
++ int num = 0;
++
++ if(left >= pi->numcols || v >= pi->numcols)
++ abort();
++
++ while(e->val != v){
++ e = e->old;
++ num++;
++ }
++
++ if(num != 0){
++ e->old->recent = e->recent;
++ e->recent->old = e->old;
++
++ e->recent = t->top->recent;
++ e->recent->old = e;
++ e->old = t->top;
++ t->top->recent = e;
++
++ t->top = e;
++ }
++
++ return num;
++}
++
++/*
++ * These 2 functions read or write to a bit stream.
++ * pi_read_bits:
++ * reads a specified-bit data from the bit stream.
++ * pi_write_bits:
++ * writes a specified-bit data to the bit stream.
++ */
++static data32 pi_read_bits(pi, numbits)
++ struct pi_info *pi;
++ int numbits;
++{
++ data32 r = 0;
++
++ while(numbits > 0){
++ while(pi->bs.rest > 0 && numbits > 0){
++ r = (r << 1) | (pi->bs.cur & 0x80 ? 1 : 0);
++ pi->bs.cur <<= 1;
++ pi->bs.rest--;
++ numbits--;
++ }
++ if(numbits > 0){
++ int c;
++ if((c = fgetc(pi->fp)) == EOF)
++ pi_file_warning(pi, PI_CORRUPT);
++ pi->bs.cur = c;
++ pi->bs.rest = 8;
++ }
++ }
++
++ return r;
++}
++
++static void pi_write_bits(pi, dat, bits)
++ struct pi_info *pi;
++ data32 dat;
++ int bits;
++{
++ data32 dat_mask = 1 << (bits - 1);
++ while(bits > 0){
++ while(pi->bs.rest < 8 && bits > 0){
++ pi->bs.cur <<= 1;
++ if(dat & dat_mask)
++ pi->bs.cur |= 1;
++ pi->bs.rest++;
++ bits--;
++ dat_mask >>= 1;
++ }
++ if(pi->bs.rest >= 8){
++ if(fputc((int)pi->bs.cur, pi->fp) == EOF)
++ pi_file_error(pi, PI_WRITE);
++ pi->bs.cur = 0;
++ pi->bs.rest = 0;
++ }
++ }
++}
++
++/*
++ * The routines to initialize or clean up.
++ * pi_inif_pi_info:
++ * initializes a pi_info structure.
++ * pi_cleanup_pi_info:
++ * cleanup pi_info structure. It frees allocated memories.
++ * pi_cleanup_pinfo:
++ * cleanup PICINFO structure when an error occurs.
++ */
++static void pi_init_pi_info(pi)
++ struct pi_info *pi;
++{
++ pi->fp = NULL;
++ pi->bs.rest = 0;
++ pi->bs.cur = 0;
++ pi->fsize = 0;
++ pi->mode = 0;
++ pi->width = pi->mode = 0;
++ pi->aspect = 1.0;
++ pi->cbits = 0;
++ pi->numcols = 0;
++ pi->cmap = NULL;
++ pi->ct = NULL;
++ pi->defcmap = 0;
++ pi->writing_grey = 0;
++}
++
++static void pi_cleanup_pi_info(pi, writing)
++ struct pi_info *pi;
++ int writing;
++{
++ if(pi->fp && !writing){
++ fclose(pi->fp);
++ pi->fp = NULL;
++ }
++ if(pi->cmap){
++ free(pi->cmap);
++ pi->cmap = NULL;
++ }
++ if(pi->ct){
++ int i;
++ for(i = 0; i < pi->numcols; i++)
++ free(pi->ct[i].elt);
++ free(pi->ct);
++ pi->ct = NULL;
++ }
++}
++
++static void pi_cleanup_pinfo(pinfo)
++ PICINFO *pinfo;
++{
++ if(pinfo->pic){
++ free(pinfo->pic);
++ pinfo->pic = NULL;
++ }
++ if(pinfo->comment){
++ free(pinfo->comment);
++ pinfo->comment = NULL;
++ }
++}
++
++/*
++ * Error handling routins.
++ * pi_memory_error:
++ * shows a error message, and terminates.
++ * pi_error:
++ * shows a non-file error message.
++ * pi_file_error:
++ * shows a file error message.
++ */
++static void pi_memory_error(scm, fn)
++ char *scm, *fn;
++{
++ char buf[128];
++ sprintf(buf, "%s: couldn't allocate memory. (%s)", scm ,fn);
++ FatalError(buf);
++}
++
++static void pi_error(pi, mn)
++ struct pi_info *pi;
++ int mn;
++{
++ SetISTR(ISTR_WARNING, "%s", pi_msgs[mn]);
++ longjmp(pi->jmp, 1);
++}
++
++static void pi_file_error(pi, mn)
++ struct pi_info *pi;
++ int mn;
++{
++ if(feof(pi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", pi_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", pi_msgs[mn], ERRSTR(errno));
++ longjmp(pi->jmp, 1);
++}
++
++static void pi_file_warning(pi, mn)
++ struct pi_info *pi;
++ int mn;
++{
++ if(feof(pi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", pi_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", pi_msgs[mn], ERRSTR(errno));
++}
++
++static void pi_show_pi_info(pi)
++ struct pi_info *pi;
++{
++ fprintf(stderr, " file size: %ld.\n", pi->fsize);
++ fprintf(stderr, " mode: 0x%02x.\n", pi->mode);
++ fprintf(stderr, " image size: %dx%d.\n", pi->width, pi->height);
++ fprintf(stderr, " aspect: %f.\n", pi->aspect);
++ fprintf(stderr, " number of color bits: %d.\n", pi->cbits);
++ fprintf(stderr, " number of colors: %d.\n", pi->numcols);
++ fprintf(stderr, " using default colormap: %s.\n",
++ pi->defcmap ? "true" : "false");
++ fprintf(stderr, " writing greyscale image: %s.\n",
++ pi->writing_grey ? "true" : "false");
++}
++
++/*
++ * Memory related routines. If failed, they calls pi_memory_error.
++ */
++static void *pi_malloc(n, fn)
++ size_t n;
++ char *fn;
++{
++ void *r = (void *) malloc(n);
++ if(r == NULL)
++ pi_memory_error("malloc", fn);
++ return r;
++}
++
++static void *pi_realloc(p, n, fn)
++ void *p;
++ size_t n;
++ char *fn;
++{
++ void *r = (p == NULL) ? (void *) malloc(n) : (void *) realloc(p, n);
++ if(r == NULL)
++ pi_memory_error("realloc", fn);
++ 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
+@@ -0,0 +1,1285 @@
++/*
++ * xvpic.c - load routine for `PIC' format pictures.
++ *
++ * The `PIC' format is used by many Japanese personal computer users.
++ */
++
++#include "xv.h"
++#include <setjmp.h>
++
++#ifdef HAVE_PIC
++
++typedef unsigned short data16;
++typedef unsigned int data32;
++
++struct pic_info {
++ jmp_buf jmp;
++ FILE *fp;
++ struct {
++ int rest;
++ byte cur;
++ }bs;
++ long fsize;
++ int type, mode;
++ int width, height;
++ float aspect;
++ int cbits;
++ int cmapped;
++ byte *cmap;
++ int cached;
++ struct cache_t {
++ int newest;
++ struct cachenode_t {
++ data32 dat;
++ int newer, older;
++ } *node;
++ } cache;
++ int g_bits, r_bits, b_bits, i_bits;
++ int inv_gr;
++ int tiled256;
++ int numcols;
++ int writing_grey;
++ data32 *data;
++};
++
++static void pic_open_file PARM((struct pic_info*,char*));
++static void pic_check_id PARM((struct pic_info*));
++static void pic_read_comment PARM((struct pic_info*, char**));
++static void pic_read_header PARM((struct pic_info*));
++static void pic_expand_data PARM((struct pic_info*));
++static int pic_expanding_read_len PARM((struct pic_info*));
++static data32 pic_expanding_read_color PARM((struct pic_info*));
++static void pic_expanding_read_chain
++ PARM((struct pic_info*, int, int, data32));
++static void pic_make_xvpic
++ PARM((struct pic_info*, byte**, byte*, byte*, byte*));
++
++static void pic_write_id PARM((struct pic_info*));
++static void pic_write_comment PARM((struct pic_info*, char*));
++static void pic_write_header PARM((struct pic_info*));
++static void pic_write_palette
++ PARM((struct pic_info*, byte*, byte*, byte*));
++static void pic_make_sparse_data PARM((struct pic_info*, byte*));
++static void pic_write_data PARM((struct pic_info*));
++static void pic_write_length PARM((struct pic_info*, data32));
++static void pic_write_color PARM((struct pic_info*, data32));
++static void pic_write_chain
++ PARM((struct pic_info*, int, int, data32));
++
++static data32 pic_read_rgb PARM((struct pic_info*));
++static data32 pic_read_color_code PARM((struct pic_info*));
++static void pic_write_rgb PARM((struct pic_info*, data32));
++static void pic_write_color_code PARM((struct pic_info*, data32));
++
++static void pic_cache_init PARM((struct pic_info*));
++static data32 pic_cache_get_value PARM((struct pic_info*, int));
++static void pic_cache_add_value PARM((struct pic_info*, data32));
++static int pic_cache_lookup PARM((struct pic_info*, data32));
++
++static data32 pic_read_bits PARM((struct pic_info*, int));
++static void pic_write_bits PARM((struct pic_info*, data32, int));
++static byte pic_pad_bit PARM((int, data32));
++
++static void pic_init_info PARM((struct pic_info*));
++static void pic_cleanup_pic_info PARM((struct pic_info*, int));
++static void pic_cleanup_pinfo PARM((PICINFO*));
++static void pic_memory_error PARM((char*, char*));
++static void pic_error PARM((struct pic_info*, int));
++static void pic_file_error PARM((struct pic_info*, int));
++static void pic_file_warning PARM((struct pic_info*, int));
++static void pic_show_pic_info PARM((struct pic_info*));
++static void *pic_malloc PARM((size_t, char*));
++static void *pic_realloc PARM((void*, size_t, char*));
++
++
++static char *pic_id = "PIC";
++
++/* Error Messages */
++static char *pic_msgs[] = {
++ NULL,
++#define PIC_OPEN 1
++ "can't open file.",
++#define PIC_CORRUPT 2
++ "file corrupted.",
++#define PIC_FORMAT 3
++ "not PIC format.",
++#define PIC_SUPPORT 4
++ "unsupported type.",
++#define PIC_COMMENT 5
++ "can't read comment.",
++#define PIC_TYPE 6
++ "bad machine type.",
++#define PIC_MODE 7
++ "bad machine-dependent mode.",
++#define PIC_NUM_COLORS 8
++ "bad number of colors.",
++#define PIC_SIZE 9
++ "bad size.",
++#define PIC_ASPECT 10
++ "bad aspect.",
++#define PIC_WRITE 11
++ "write failed.",
++};
++
++#define H4(b) (((b) >> 4) & 0x0f)
++#define L4(b) ( (b) & 0x0f)
++
++
++/* The main routine to load a PIC file. */
++int LoadPIC(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++{
++ int e;
++ struct pic_info pic;
++ char buf[128];
++
++ if(DEBUG) fputs("LoadPIC:\n", stderr);
++
++ pic_init_info(&pic);
++
++ pinfo->comment = NULL;
++ if((e = setjmp(pic.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ pic_cleanup_pic_info(&pic, 0);
++ pic_cleanup_pinfo(pinfo);
++ if(DEBUG) fputs("\n", stderr);
++ return 0;
++ }
++
++ pic_open_file(&pic, fname);
++ pic_check_id(&pic);
++ pic_read_comment(&pic, &pinfo->comment);
++ pic_read_header(&pic);
++ pic_expand_data(&pic);
++ pic_make_xvpic(&pic, &pinfo->pic, pinfo->r, pinfo->g, pinfo->b);
++
++ pinfo->w = pic.width;
++ if(pic.tiled256)
++ pinfo->h = pic.height * 2;
++ else
++ pinfo->h = pic.height;
++ pinfo->normw = pinfo->w;
++ pinfo->normh = pinfo->h;
++ pinfo->type = pic.cmapped ? PIC8 : PIC24;
++ pinfo->frmType = F_PIC;
++ pinfo->colType = F_FULLCOLOR;
++ strcpy(pinfo->fullInfo, "PIC");
++ switch(pic.type){
++ case 0x0:
++ strcat(pinfo->fullInfo, ", X68k");
++ break;
++ case 0x1:
++ strcat(pinfo->fullInfo, ", PC-88VA");
++ if(pic.mode & 1)
++ strcat(pinfo->fullInfo, ", HR");
++ if(pic.mode & 2)
++ strcat(pinfo->fullInfo, ", tiled 256");
++ break;
++ case 0x2:
++ strcat(pinfo->fullInfo, ", FM-TOWNS");
++ if(pic.mode == 0x5){
++ strcat(pinfo->fullInfo, ", low-resolution");
++ }else{
++ strcat(pinfo->fullInfo, ", high-resolution");
++ }
++ break;
++ case 0x3:
++ strcat(pinfo->fullInfo, ", Macintosh");
++ break;
++ case 0xf:
++ ;
++ }
++ sprintf(buf, " (%ld bytes)", pic.fsize);
++ strcat(pinfo->fullInfo, buf);
++ sprintf(pinfo->shrtInfo, "%dx%d(aspect %4.2f) PIC.",
++ pinfo->w, pinfo->h, pic.aspect);
++ if (!nopicadjust)
++ normaspect = pic.aspect;
++
++ pic_cleanup_pic_info(&pic, 0);
++ if(DEBUG) fputs("\n", stderr);
++ return 1;
++}
++
++static void pic_open_file(pi, fname)
++ struct pic_info *pi;
++ char *fname;
++{
++ if((pi->fp = fopen(fname, "rb")) == NULL)
++ pic_file_error(pi, PIC_OPEN);
++ fseek(pi->fp, (size_t) 0, SEEK_END);
++ pi->fsize = ftell(pi->fp);
++ fseek(pi->fp, (size_t) 0, SEEK_SET);
++}
++
++static void pic_check_id(pi)
++ struct pic_info *pi;
++{
++ char buf[3];
++ if(fread(buf, (size_t) 3, (size_t) 1, pi->fp) != 1)
++ pic_file_error(pi, PIC_CORRUPT);
++ if(strncmp(buf, pic_id, (size_t) 3) != 0)
++ pic_error(pi, PIC_FORMAT);
++}
++
++static void pic_read_comment(pi, comm)
++ struct pic_info *pi;
++ char **comm;
++{
++ /* The comment field is like:
++ * comment-string ^Z dummy \0 \0
++ */
++ int max = -1, i = 0;
++ int c;
++
++ while(1){
++ if((c = fgetc(pi->fp)) == EOF)
++ pic_file_error(pi, PIC_CORRUPT);
++ if(c == '\032') /* 0x1a, '^Z' */
++ break;
++ if(max < i){
++ max += 32;
++ *comm = pic_realloc(*comm, (size_t) max + 1, "pic_read_comment#1");
++ }
++ (*comm)[i++] = c;
++ }
++
++ if(max < i){
++ max++;
++ *comm = pic_realloc(*comm, (size_t) max + 1, "pic_read_comment#2");
++ }
++ (*comm)[i] = '\0';
++
++ while((c = fgetc(pi->fp)) != '\0'){ /* skip the dummy area */
++ if(c == EOF)
++ pic_file_error(pi, PIC_CORRUPT);
++ }
++
++ if(fgetc(pi->fp) != '\0') /* check the reserved byte */
++ pic_error(pi, PIC_SUPPORT);
++}
++
++static void pic_read_header(pi)
++ struct pic_info *pi;
++{
++ pi->mode = pic_read_bits(pi, 4);
++ pi->type = pic_read_bits(pi, 4);
++ pi->cbits = pic_read_bits(pi, 16);
++ pi->width = pic_read_bits(pi, 16);
++ pi->height = pic_read_bits(pi, 16);
++
++ /* machine-dependent setup. */
++ switch(pi->type){
++ case 0x0: /* X68K */
++ if(pi->mode != 0)
++ pic_error(pi, PIC_MODE);
++ switch(pi->cbits){
++ case 4:
++ pi->aspect = 1.0;
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->i_bits = 1;
++ pi->cmapped = 1;
++ break;
++
++ case 8:
++ pi->aspect = 4.0 / 3.0;
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->i_bits = 1;
++ pi->cmapped = 1;
++ break;
++
++ case 15:
++ pi->aspect = 4.0 / 3.0;
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->cached = 1;
++ break;
++
++ case 16:
++ pi->aspect = 4.0 / 3.0;
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->i_bits = 1;
++ pi->cached = 1;
++ break;
++
++ default:
++ pic_error(pi, PIC_NUM_COLORS);
++ }
++ break;
++
++ case 0x1: /* PC-88VA */
++ if(pi->height > 1000)
++ pic_error(pi, PIC_SIZE);
++ switch(pi->width * 1000 + pi->height){
++ case 640400:
++ case 640204:
++ case 640200:
++ case 320408:
++ case 320400:
++ case 320200:
++ break;
++ default:
++ pic_error(pi, PIC_SIZE);
++ }
++ pi->aspect = 400.0 / pi->height;
++ pi->aspect *= pi->width / 640.0;
++ if(pi->mode & 0x1) /* HR mode */
++ pi->aspect *= 2.0;
++ if(pi->mode & 0x2){ /* tiled 256 format */
++ if(pi->cbits != 16)
++ pic_error(pi, PIC_NUM_COLORS);
++ pi->tiled256 = 1;
++ }
++ switch(pi->cbits){
++ case 8:
++ pi->g_bits = pi->r_bits = 3;
++ pi->b_bits = 2;
++ break;
++
++ case 12:
++ pi->g_bits = pi->r_bits = pi->b_bits = 4;
++ pi->cached = 1;
++ break;
++
++ case 16:
++ pi->g_bits = 6;
++ pi->r_bits = pi->b_bits = 5;
++ pi->cached = 1;
++ break;
++
++ default:
++ pic_error(pi, PIC_NUM_COLORS);
++ }
++ break;
++
++ case 0x2: /* FM-TOWNS */
++ if(pi->cbits != 15)
++ pic_error(pi, PIC_NUM_COLORS);
++ switch(pi->mode){
++ case 0x5:
++ case 0xc:
++ break;
++ default:
++ pic_error(pi, PIC_MODE);
++ }
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->cached = 1;
++ break;
++
++ case 0x3: /* MAC */
++ if(pi->cbits != 15)
++ pic_error(pi, PIC_NUM_COLORS);
++ pi->r_bits = pi->g_bits = pi->b_bits = 5;
++ pi->inv_gr = 1;
++ break;
++
++ case 0xf: /* misc */
++ {
++ byte ah, al;
++
++ switch(pi->mode){
++ case 0x0:
++ break;
++ case 0x1:
++ pi->aspect = 4.0 / 3.0;
++ break;
++ case 0xf:
++ break;
++ default:
++ pic_error(pi, PIC_MODE);
++ }
++ pic_read_bits(pi, 16); /* x */
++ pic_read_bits(pi, 16); /* y */
++ ah = pic_read_bits(pi, 8);
++ al = pic_read_bits(pi, 8);
++ if(ah > 0 && al > 0)
++ pi->aspect = (float) al / (int) ah;
++ else if(pi->mode == 0xf)
++ pic_error(pi, PIC_ASPECT);
++ switch(pi->cbits){
++ case 4:
++ case 8:
++ pi->g_bits = pi->r_bits = pi->b_bits = pic_read_bits(pi, 8);
++ pi->cmapped = 1;
++ break;
++
++ case 12:
++ pi->g_bits = pi->r_bits = pi->b_bits = 4;
++ pi->cached = 1;
++ break;
++
++ case 15:
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->cached = 1;
++ break;
++
++ case 16:
++ pi->g_bits = pi->r_bits = pi->b_bits = 5;
++ pi->i_bits = 1;
++ pi->cached = 1;
++ break;
++
++ case 24:
++ pi->g_bits = pi->r_bits = pi->b_bits = 8;
++ pi->cached = 1;
++ break;
++
++ case 32:
++ pic_error(pi, PIC_SUPPORT);
++ break;
++
++ default:
++ pic_error(pi, PIC_NUM_COLORS);
++ }
++ }
++ break;
++
++ default:
++ pic_error(pi, PIC_TYPE);
++ }
++
++ pi->numcols = 1 << pi->cbits;
++
++ /* read palette data */
++ if(pi->cmapped){
++ int i;
++ pi->cmap = pic_malloc((size_t) 3 * pi->numcols, "pic_read_header#1");
++ for(i = 0; i < pi->numcols; i++){
++ data32 c = pic_read_rgb(pi);
++ pi->cmap[i * 3 ] = c >> 16 & 0xff;
++ pi->cmap[i * 3 + 1] = c >> 8 & 0xff;
++ pi->cmap[i * 3 + 2] = c & 0xff;
++ }
++ }
++
++ /* setup color code cache */
++ if(pi->cached)
++ pic_cache_init(pi);
++
++
++ pi->data = pic_malloc(sizeof(data32) * pi->width * pi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "pic_read_header#2");
++ {
++ int i;
++ for(i = 0; i < pi->width * pi->height; i++)
++ pi->data[i] = 0xffffffff;
++ }
++
++ if(DEBUG)
++ pic_show_pic_info(pi);
++}
++
++/* The main routine to expand a PIC file. */
++static void pic_expand_data(pi)
++ struct pic_info *pi;
++{
++ int cnt;
++ data32 c;
++ pi->data[0] = c = 0;
++ for(cnt = -1; cnt < pi->width * pi->height; ){
++ int len = pic_expanding_read_len(pi);
++ cnt += len;
++ if(cnt < pi->width * pi->height){
++ int x = cnt % pi->width;
++ int y = cnt / pi->width;
++ data32 c = pic_expanding_read_color(pi);
++ pic_expanding_read_chain(pi, x, y, c);
++ }
++ }
++}
++
++static int pic_expanding_read_len(pi)
++ struct pic_info *pi;
++{
++ int len;
++ byte bits;
++ for(len = 2, bits = 1; pic_read_bits(pi, 1) == 1; bits++)
++ len <<= 1;
++ return len - 1 + pic_read_bits(pi, bits);
++}
++
++static data32 pic_expanding_read_color(pi)
++ struct pic_info *pi;
++{
++ if(pi->cached){
++ byte b = pic_read_bits(pi, 1);
++ if(b){
++ return pic_cache_get_value(pi, (int) pic_read_bits(pi, 7));
++ }else{
++ data32 c = pic_read_color_code(pi);
++ pic_cache_add_value(pi, c);
++ return c;
++ }
++ }
++ return pic_read_color_code(pi);
++}
++
++static void pic_expanding_read_chain(pi, x, y, c)
++ struct pic_info *pi;
++ int x, y;
++ data32 c;
++{
++ pi->data[y * pi->width + x] = c;
++ if(pic_read_bits(pi, 1) == 1){
++ int fin = 0;
++ while(!fin){
++ switch(pic_read_bits(pi, 2)){
++ case 1: /* left */
++ pi->data[(++y) * pi->width + (--x)] = c;
++ break;
++ case 2: /* middle */
++ pi->data[(++y) * pi->width + x ] = c;
++ break;
++ case 3: /* right */
++ pi->data[(++y) * pi->width + (++x)] = c;
++ break;
++ case 0: /* far or nothing */
++ if(pic_read_bits(pi, 1) == 0)
++ fin = 1;
++ else{
++ if(pic_read_bits(pi, 1) == 0)
++ pi->data[(++y) * pi->width + (x -= 2)] = c;
++ else
++ pi->data[(++y) * pi->width + (x += 2)] = c;
++ }
++ }
++ }
++ }
++}
++
++/*
++ * Make a picture from the expanded data.
++ */
++static void pic_make_xvpic(pi, xp, rp, gp, bp)
++ struct pic_info *pi;
++ byte **xp, *rp, *gp, *bp;
++{
++ if(pi->cmapped){
++ if(pi->tiled256)
++ *xp = pic_malloc((size_t) pi->width * pi->height * 2, // GRR POSSIBLE OVERFLOW / FIXME
++ "pic_make_xvpic#1");
++ else
++ *xp = pic_malloc((size_t) pi->width * pi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "pic_make_xvpic#2");
++ }else
++ *xp = pic_malloc((size_t) pi->width * pi->height * 3, // GRR POSSIBLE OVERFLOW / FIXME
++ "pic_make_xvpic#3");
++
++ if(pi->cmapped){
++ int i;
++
++ for(i = 0; i < pi->numcols; i++){
++ rp[i] = pi->cmap[i * 3 ];
++ gp[i] = pi->cmap[i * 3 + 1];
++ bp[i] = pi->cmap[i * 3 + 2];
++ }
++
++ if(pi->tiled256){
++ int pic_idx = 0, dat_idx;
++ data16 col = 0;
++ for(dat_idx = 0; dat_idx < pi->width * pi->height; dat_idx++){
++ if(pi->data[dat_idx] != 0xffffffff)
++ col = pi->data[dat_idx];
++ (*xp)[pic_idx++] = col & 0xff;
++ (*xp)[pic_idx++] = col >> 8 & 0xff;
++ dat_idx++;
++ }
++ }else{
++ int pic_idx = 0, dat_idx;
++ byte col = 0;
++ for(dat_idx = 0; dat_idx < pi->width * pi->height; dat_idx++){
++ if(pi->data[dat_idx] != 0xffffffff)
++ col = pi->data[dat_idx];
++ (*xp)[pic_idx++] = col;
++ }
++ }
++ }else{
++ int pic_idx = 0, dat_idx;
++ byte r = 0, g = 0, b = 0;
++ for(dat_idx = 0; dat_idx < pi->width * pi->height; dat_idx++){
++ if(pi->data[dat_idx] != 0xffffffff){
++ data32 col = pi->data[dat_idx];
++ r = col >> 16 & 0xff;
++ g = col >> 8 & 0xff;
++ b = col & 0xff;
++ }
++ (*xp)[pic_idx++] = r;
++ (*xp)[pic_idx++] = g;
++ (*xp)[pic_idx++] = b;
++ }
++ }
++}
++
++
++/* The main routine to write PIC file. */
++int WritePIC(fp, pic0, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle,
++ comment)
++ FILE *fp;
++ byte *pic0;
++ int ptype, w, h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
++ char *comment;
++{
++ struct pic_info pic;
++ int e;
++
++ if(DEBUG) fputs("WritePIC:\n", stderr);
++
++ pic_init_info(&pic);
++ pic.fp = fp;
++ pic.width = w;
++ pic.height = h;
++ pic.writing_grey = (colorstyle == F_GREYSCALE);
++ if(ptype != PIC24){ /* PIC8 */
++ pic.cmapped = 1;
++ pic.cached = 0;
++ pic.cbits = 8;
++ pic.g_bits =
++ pic.r_bits =
++ pic.b_bits = 8;
++ pic.i_bits = 0;
++ pic.numcols = numcols;
++ }else{ /* PIC24 */
++ pic.cmapped = 0;
++ pic.cached = 1;
++ pic.cbits = 24;
++ pic.g_bits =
++ pic.r_bits =
++ pic.b_bits = 8;
++ pic.i_bits = 0;
++ pic.numcols = 1 << 24;
++ pic_cache_init(&pic);
++ }
++
++ if((e = setjmp(pic.jmp)) != 0){
++ /* When an error occurs while writing, comes here. */
++ pic_cleanup_pic_info(&pic, 1);
++ if(DEBUG) fputs("\n", stderr);
++ return -1;
++ }
++
++ pic_write_id(&pic);
++ pic_write_comment(&pic, comment);
++ pic_write_header(&pic);
++ if(pic.cmapped)
++ pic_write_palette(&pic, rmap, gmap, bmap);
++ pic_make_sparse_data(&pic, pic0);
++ pic_write_data(&pic);
++ pic_write_bits(&pic, 0, 8);
++
++ pic_cleanup_pic_info(&pic, 1);
++ if(DEBUG) fputs("\n", stderr);
++ return 0;
++}
++
++static void pic_write_id(pi)
++ struct pic_info *pi;
++{
++ if(fwrite("PIC", (size_t) 3, (size_t) 1, pi->fp) != 1)
++ pic_file_error(pi, PIC_WRITE);
++}
++
++static void pic_write_comment(pi, comm)
++ struct pic_info *pi;
++ char *comm;
++{
++ if(comm){
++ while(*comm){
++ int c = *comm;
++ if(c == '\032')
++ c = ' ';
++ if(fputc(*comm, pi->fp) == EOF)
++ pic_file_error(pi, PIC_WRITE);
++ comm++;
++ }
++ }
++ /* write ^Z, 0, and reserved. */
++ if(fwrite("\032\0\0", (size_t)3, (size_t) 1, pi->fp) != 1)
++ pic_file_error(pi, PIC_WRITE);
++}
++
++static void pic_write_header(pi)
++ struct pic_info *pi;
++{
++ if(DEBUG) pic_show_pic_info(pi);
++ pic_write_bits(pi, (data32) 0, 4); /* mode: 1:1 */
++ pic_write_bits(pi, (data32) 0xf, 4); /* type: misc */
++ pic_write_bits(pi, (data32) pi->cbits, 16); /* bits */
++ pic_write_bits(pi, (data32) pi->width, 16); /* width */
++ pic_write_bits(pi, (data32) pi->height, 16); /* height */
++ pic_write_bits(pi, (data32) 0xffff, 16); /* x: unused */
++ pic_write_bits(pi, (data32) 0xffff, 16); /* y: unused */
++ pic_write_bits(pi, (data32) 0x0101, 16); /* real aspect */
++}
++
++static void pic_write_palette(pi, r, g, b)
++ struct pic_info *pi;
++ byte *r, *g, *b;
++{
++ int i;
++ data32 rgb = 0;
++ pic_write_bits(pi, (data32) pi->g_bits, 8);
++ for(i = 0; i < pi->numcols; i++){
++ rgb = (data32) *r++ << 16 | (data32) *g++ << 8 | (data32) *b++;
++ pic_write_rgb(pi, rgb);
++ }
++ for( ; i < 256; i++)
++ pic_write_rgb(pi, rgb);
++}
++
++static void pic_make_sparse_data(pi, dat)
++ struct pic_info *pi;
++ byte *dat;
++{
++ int i;
++ data32 c;
++
++ pi->data = pic_malloc(sizeof(data32) * pi->width * pi->height, // GRR POSSIBLE OVERFLOW / FIXME
++ "pic_make_sparse_data");
++
++ if(pi->cmapped){
++ c = 0;
++ for(i = 0; i < pi->width * pi->height; i++){
++ if(c != dat[i])
++ c = pi->data[i] = dat[i];
++ else
++ pi->data[i] = 0xffffffff;
++ }
++ }else{
++ int j = 0;
++ c = 0;
++ for(i = 0; i < pi->width * pi->height; i++){
++ data32 r, g, b, t;
++ r = dat[j++];
++ g = dat[j++];
++ b = dat[j++];
++ t = r << 16 | g << 8 | b;
++ if(c != t)
++ c = pi->data[i] = t;
++ else
++ pi->data[i] = 0xffffffff;
++ }
++ }
++}
++
++static void pic_write_data(pi)
++ struct pic_info *pi;
++{
++ int i;
++ int max = pi->width * pi->height;
++ data32 c = 0;
++
++ i = -1;
++ while(i < max){
++ int j;
++ for(j = i + 1; j < max; j++){
++ if(pi->data[j] != 0xffffffff)
++ break;
++ }
++ pic_write_length(pi, (data32) j - i);
++ i = j;
++ if(i < max){
++ pic_write_color(pi, c = pi->data[i]);
++ pic_write_chain(pi, i % pi->width, i / pi->width, c);
++ }
++ }
++}
++
++static void pic_write_length(pi, len)
++ struct pic_info *pi;
++ data32 len;
++{
++ int bits = 0; /* leading 1's */
++ int max = 2;
++
++ while(len > max){
++ max = (max + 1) * 2;
++ bits++;
++ }
++ pic_write_bits(pi, 0xffffffff, bits);
++ pic_write_bits(pi, 0, 1);
++ pic_write_bits(pi, len - max / 2, bits + 1);
++}
++
++static void pic_write_color(pi, c)
++ struct pic_info *pi;
++ data32 c;
++{
++ if(pi->cached){
++ int idx = pic_cache_lookup(pi, c);
++ if(idx < 0){ /* not found */
++ pic_write_bits(pi, 0, 1);
++ pic_write_color_code(pi, c);
++ pic_cache_add_value(pi, c);
++ }else{ /* found */
++ pic_write_bits(pi, (data32) 0xffffffff, 1);
++ pic_write_bits(pi, (data32) idx, 7);
++ }
++ }else
++ pic_write_color_code(pi, c);
++}
++
++static void pic_write_chain(pi, x, y, c)
++ struct pic_info *pi;
++ int x, y;
++ data32 c;
++{
++ int ctr = (y + 1) * pi->width + x;
++
++ if(y < pi->height - 1 &&
++ ( pi->data[ctr ] == c ||
++ (x > 0 && pi->data[ctr - 1] == c) ||
++ (x < pi->width - 1 && pi->data[ctr + 1] == c) ||
++ (x > 1 && pi->data[ctr - 2] == c) ||
++ (x < pi->width - 2 && pi->data[ctr + 2] == c))){
++ pic_write_bits(pi, 1, 1);
++ while(++y < pi->height){
++ if(pi->data[ctr] == c){ /* center */
++ pic_write_bits(pi, 2, 2);
++ pi->data[ctr] = 0xffffffff;
++ ctr += pi->width;
++ }else if(x > 0 && pi->data[ctr - 1] == c){ /* left */
++ pic_write_bits(pi, 1, 2);
++ pi->data[ctr - 1] = 0xffffffff;
++ ctr += pi->width - 1;
++ }else if(x < pi->width - 1 && pi->data[ctr + 1] == c){/* right */
++ pic_write_bits(pi, 3, 2);
++ pi->data[ctr + 1] = 0xffffffff;
++ ctr += pi->width + 1;
++ }else if(x > 1 && pi->data[ctr - 2] == c){ /* 2-left */
++ pic_write_bits(pi, 2, 4);
++ pi->data[ctr - 2] = 0xffffffff;
++ ctr += pi->width - 2;
++ }else if(x < pi->width - 2 && pi->data[ctr + 2] == c){/* 2-right */
++ pic_write_bits(pi, 3, 4);
++ pi->data[ctr + 2] = 0xffffffff;
++ ctr += pi->width + 2;
++ }else /* nothing */
++ break;
++ }
++ pic_write_bits(pi, 0, 3);
++ }else
++ pic_write_bits(pi, 0, 1);
++}
++
++
++/*
++ * These 4 functions read or write a color.
++ *
++ * pic_read_rgb:
++ * reads an RGB. Each bit length is [rgb]_bits, but
++ * it is expanded to 8bits when returned.
++ *
++ * pic_read_color_code:
++ * reads a color code, whose length is cbits.
++ * It is the index to the colormap or RGB itself.
++ *
++ * pic_write_rgb:
++ * writes an RGB value.
++ *
++ * pic_write_color_code:
++ * writes a color code.
++ */
++static data32 pic_read_rgb(pi)
++ struct pic_info *pi;
++{
++ int rb = pi->r_bits, gb = pi->g_bits, bb = pi->b_bits;
++ byte r, g, b;
++ if(pi->inv_gr){
++ r = pic_read_bits(pi, rb);
++ g = pic_read_bits(pi, gb);
++ }else{
++ g = pic_read_bits(pi, gb);
++ r = pic_read_bits(pi, rb);
++ }
++ b = pic_read_bits(pi, bb);
++ if(pi->i_bits){
++ byte i;
++ i = pic_read_bits(pi, pi->i_bits);
++ r = r << pi->i_bits | i;
++ g = g << pi->i_bits | i;
++ b = b << pi->i_bits | i;
++ rb += pi->i_bits;
++ gb += pi->i_bits;
++ bb += pi->i_bits;
++ }
++ r = pic_pad_bit(rb, r);
++ g = pic_pad_bit(gb, g);
++ b = pic_pad_bit(bb, b);
++
++ return (data32) r << 16 | (data32) g << 8 | (data32) b;
++}
++
++static data32 pic_read_color_code(pi)
++ struct pic_info *pi;
++{
++ if(pi->cmapped)
++ return pic_read_bits(pi, pi->cbits);
++ return pic_read_rgb(pi);
++}
++
++static void pic_write_rgb(pi, rgb)
++ struct pic_info *pi;
++ data32 rgb;
++{
++ byte r = rgb >> 16;
++ byte g = rgb >> 8;
++ byte b = rgb;
++ if(pi->writing_grey)
++ r = g = b = MONO(r, g, b);
++ pic_write_bits(pi, g, pi->g_bits);
++ pic_write_bits(pi, r, pi->r_bits);
++ pic_write_bits(pi, b, pi->b_bits);
++}
++
++static void pic_write_color_code(pi, code)
++ struct pic_info *pi;
++ data32 code;
++{
++ if(pi->cmapped){
++ pic_write_bits(pi, code, pi->cbits);
++ }else{
++ pic_write_rgb(pi, code);
++ }
++}
++
++
++/*
++ * These pic_cache_* functions are an implementation of the color cache.
++ *
++ * pic_cache_init:
++ * initializes the cache.
++ *
++ * pic_cache_get_value:
++ * gets a color indexed by the argument `idx'.
++ * It updates the `most recently used' time.
++ *
++ * pic_cache_add_value:
++ * adds a color to the top of the cache list.
++ */
++static void pic_cache_init(pi)
++ struct pic_info *pi;
++{
++ int i;
++ pi->cache.node = pic_malloc(sizeof(struct cachenode_t) * 128,
++ "pic_cache_init");
++ for(i = 0; i < 128; i++){
++ pi->cache.node[i].newer = i + 1;
++ pi->cache.node[i].older = i - 1;
++ pi->cache.node[i].dat = 0;
++ }
++ pi->cache.node[ 0].older = 127;
++ pi->cache.node[127].newer = 0;
++ pi->cache.newest = 0;
++}
++
++static data32 pic_cache_get_value(pi, idx)
++ struct pic_info *pi;
++ int idx;
++{
++ struct cachenode_t *p = pi->cache.node;
++ int n = pi->cache.newest;
++ if(n != idx){
++ p[p[idx].newer].older = p[idx].older;
++ p[p[idx].older].newer = p[idx].newer;
++
++ p[p[n].newer].older = idx;
++ p[idx].newer = p[n].newer;
++ p[n].newer = idx;
++ p[idx].older = n;
++
++ pi->cache.newest = idx;
++ }
++ return pi->cache.node[idx].dat;
++}
++
++static void pic_cache_add_value(pi, dat)
++ struct pic_info *pi;
++ data32 dat;
++{
++ pi->cache.newest = pi->cache.node[pi->cache.newest].newer;
++ pi->cache.node[pi->cache.newest].dat = dat;
++}
++
++static int pic_cache_lookup(pi, dat)
++ struct pic_info *pi;
++ data32 dat;
++{
++ int i;
++ for(i = 0; i < 128; i++){
++ if(pi->cache.node[i].dat == dat){
++ pic_cache_get_value(pi, i);
++ return i;
++ }
++ }
++ return -1;
++}
++
++
++/*
++ * These pic_{read,write}_bits functions access the bit stream.
++ * pic_read_bits:
++ * reads the specified bits from the file.
++ *
++ * pic_write_bits:
++ * writes the specified bits to the file.
++ */
++static data32 pic_read_bits(pi, bits)
++ struct pic_info *pi;
++ int bits;
++{
++ data32 r = 0;
++
++ while(bits > 0){
++ while(pi->bs.rest > 0 && bits > 0){
++ r = (r << 1) | (pi->bs.cur & 0x80 ? 1 : 0);
++ pi->bs.cur <<= 1;
++ pi->bs.rest--;
++ bits--;
++ }
++ if(bits > 0){
++ int c;
++ if((c = fgetc(pi->fp)) == EOF){
++ pic_file_warning(pi, PIC_CORRUPT);
++ c = 0;
++ }
++ pi->bs.cur = c;
++ pi->bs.rest = 8;
++ }
++ }
++
++ return r;
++}
++
++static void pic_write_bits(pi, dat, bits)
++ struct pic_info *pi;
++ data32 dat;
++ int bits;
++{
++ data32 dat_mask = 1 << (bits - 1);
++ while(bits > 0){
++ while(pi->bs.rest < 8 && bits > 0){
++ pi->bs.cur <<= 1;
++ if(dat & dat_mask)
++ pi->bs.cur |= 1;
++ pi->bs.rest++;
++ bits--;
++ dat_mask >>= 1;
++ }
++ if(pi->bs.rest >= 8){
++ if(fputc((int)pi->bs.cur, pi->fp) == EOF)
++ pic_error(pi, PIC_WRITE);
++ pi->bs.cur = 0;
++ pi->bs.rest = 0;
++ }
++ }
++}
++
++
++/*
++ * This function extends sub-8-bit data to 8-bit data using bit-replication.
++ */
++static byte pic_pad_bit(bits, dat)
++ int bits;
++ data32 dat;
++{
++ switch(bits){
++ case 1:
++ if(dat & 1)
++ dat = 0xff;
++ else
++ dat = 0;
++ break;
++ case 2:
++ dat = dat << 6 | dat << 4 | dat << 2 | dat;
++ break;
++ case 3:
++ dat = dat << 5 | dat << 2 | dat >> 1;
++ break;
++ case 4:
++ dat = dat << 4 | dat;
++ break;
++ case 5:
++ dat = dat << 3 | dat >> 2;
++ break;
++ case 6:
++ dat = dat << 2 | dat >> 4;
++ break;
++ case 7:
++ dat = dat << 1 | dat >> 6;
++ }
++
++ return dat;
++}
++
++/*
++ * These functions initialize or clean up structures.
++ * pic_init_info:
++ * initializes a pic_info structure.
++ * pic_cleanup_pic_info:
++ * cleans up a pic_info structure.
++ * pic_cleanup_pinfo:
++ * cleans up a PICINFO structure.
++ */
++static void pic_init_info(pi)
++ struct pic_info *pi;
++{
++ pi->fp = NULL;
++ pi->bs.rest = 0;
++ pi->bs.cur = '\0';
++ pi->type = pi->mode = 0;
++ pi->width = pi->height = 0;
++ pi->aspect = 1.0;
++ pi->cbits = 0;
++ pi->cmapped = pi->cached = 0;
++ pi->cache.node = NULL;
++ pi->cmap = NULL;
++ pi->g_bits = pi->r_bits = pi->b_bits = pi->i_bits = 0;
++ pi->inv_gr = 0;
++ pi->tiled256 = 0;
++ pi->numcols = 0;
++ pi->writing_grey = 0;
++}
++
++static void pic_cleanup_pic_info(pi, writing)
++ struct pic_info *pi;
++ int writing;
++{
++ if(!writing && pi->fp)
++ fclose(pi->fp);
++ if(pi->cmap)
++ free(pi->cmap);
++ if(pi->cache.node)
++ free(pi->cache.node);
++ if(pi->data)
++ free(pi->data);
++ pi->fp = NULL;
++ pi->cmap = NULL;
++ pi->cache.node = NULL;
++ pi->data = NULL;
++}
++
++static void pic_cleanup_pinfo(pinfo)
++ PICINFO *pinfo;
++{
++ if(pinfo->pic){
++ free(pinfo->pic);
++ pinfo->pic = NULL;
++ }
++ if(pinfo->comment){
++ free(pinfo->comment);
++ pinfo->comment = NULL;
++ }
++}
++
++/*
++ * Error Handlers.
++ * pic_memory_error:
++ * shows an error message and terminates.
++ * pic_error:
++ * shows a non-file error message and jumps to the entry for errors.
++ * pic_file_error:
++ * shows a file error message and jumps to the entry for errors.
++ * pic_file_warning:
++ * shows a file warning message.
++ */
++static void pic_memory_error(scm, fn)
++ char *scm, *fn;
++{
++ char buf[128];
++ sprintf(buf, "%s: can't allocate memory. (%s)", scm, fn);
++ FatalError(buf);
++}
++
++static void pic_error(pi, mn)
++ struct pic_info *pi;
++ int mn;
++{
++ SetISTR(ISTR_WARNING, "%s", pic_msgs[mn]);
++ longjmp(pi->jmp, 1);
++}
++
++static void pic_file_error(pi, mn)
++ struct pic_info *pi;
++ int mn;
++{
++ if(feof(pi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", pic_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", pic_msgs[mn], ERRSTR(errno));
++ longjmp(pi->jmp, 1);
++}
++
++static void pic_file_warning(pi, mn)
++ struct pic_info *pi;
++ int mn;
++{
++ if(feof(pi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", pic_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", pic_msgs[mn], ERRSTR(errno));
++}
++
++static void pic_show_pic_info(pi)
++ struct pic_info *pi;
++{
++ fprintf(stderr, " file size: %ld.\n", pi->fsize);
++
++ fputs(" machine: ", stderr);
++ switch(pi->type){
++ case 0x0:
++ fputs("X68k", stderr);
++ break;
++ case 0x1:
++ fputs("PC-88VA", stderr);
++ if(pi->mode & 1)
++ fputs(",HR", stderr);
++ if(pi->mode & 2)
++ fputs(",tiled256", stderr);
++ break;
++ case 0x2:
++ fprintf(stderr,
++ "FM-TOWNS,%s-resolution", pi->mode == 5 ? "low" : "high");
++ break;
++ case 0x3:
++ fputs("Macintosh", stderr);
++ break;
++ case 0xf:
++ fputs("misc", stderr);
++ }
++ fputs("\n", stderr);
++
++ fprintf(stderr, " image size: %dx%d\n", pi->width, pi->height);
++ fprintf(stderr, " aspect: %f\n", pi->aspect);
++ fprintf(stderr, " cache: %s\n", pi->cached ? "on" : "off");
++ fprintf(stderr, " colormap: %s\n", pi->cmapped ? "on" : "off");
++ fprintf(stderr, " number of color bits: %d\n", pi->cbits);
++ fprintf(stderr, " number of RGB bits: R%d,G%d,B%d,I%d\n",
++ pi->r_bits, pi->g_bits, pi->b_bits, pi->i_bits);
++ fprintf(stderr, " inverted G&R: %s\n", pi->inv_gr ? "true" : "false");
++ fprintf(stderr, " number of colors: %d\n", pi->numcols);
++}
++
++/* Memory related routines. */
++static void *pic_malloc(n, fn)
++ size_t n;
++ char *fn;
++{
++ void *r = (void *) malloc(n);
++ if(r == NULL)
++ pic_memory_error("malloc", fn);
++ return r;
++}
++
++static void *pic_realloc(p, n, fn)
++ void *p;
++ size_t n;
++ char *fn;
++{
++ void *r = (p == NULL) ? (void *) malloc(n) : (void *) realloc(p, n);
++ if(r == NULL)
++ pic_memory_error("realloc", fn);
++ 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
+@@ -0,0 +1,3608 @@
++/*
++ * $Id: xvpic2.c,v 2.9.1.14 1995/04/24 15:34:15 ikeyan Exp $
++ * xvpic2.c - load and save routines for `PIC2' format pictures.
++ *
++ *
++ * Outline
++ * =======
++ * xvpic2.c supports the PIC2 format image file. It is used some
++ * Japanese personal computer users.
++ *
++ * The PIC2 format is designed by A.Yanagisawa. It is an excellent
++ * format except for its encode/decode speed. ;-)
++ *
++ * The features of the PIC2 format:
++ * - Powerful header information (included author, filename, title,
++ * saver, product number, created date and comment).
++ * - Reversible compression, and very high compression ratio (in many
++ * cases, a higher compression ratio than the JPEG compression;
++ * because of its compression method, PIC2 is especially good at
++ * pictures like cell animation).
++ * - Can handle full-color (24 bits) image.
++ * - Can include multi image blocks into one PIC2 file.
++ * - Have four different block format (P2SS, P2SF, P2BM and
++ * P2BI). P2SS format uses arithmetic compression for storing
++ * data. P2SF uses normal run-length compression. P2BM and P2BI is
++ * raw image format. Select any one according to the situation.
++ *
++ * Explanation of the PIC2 compression:
++
++ * - In the first place, try to record pixel color, uses color caches
++ * which keep some recent colors, and formed according to color's
++ * frequency. PIC2 has some color cache spaces that are switched by
++ * upper pixel value of current pixel. If cache is hit, record
++ * that.
++ * - Unfortunately, in the case of color cache didn't hit, record the
++ * difference from the value estimated with the value of upper and
++ * left pixel of current pixel (similar to PNG's AVG predictor).
++ * - And extract image's color chain if exist, and record that (it
++ * results in image's outline).
++ * - In all cases, arithmetic compression is used in the final stage
++ * before writing the file, which in theory produces the ideal
++ * compression ratio (P2SS).
++ *
++ * Features
++ * ========
++ * - Support 3,6,9,12,15,18,21,24bit PIC2 format (Load/Save).
++ * - Support all image block formats of PIC2 (Load/Save).
++ * - Support multi block PIC2 file (Load/Save).
++ *
++ *
++ * Bugs
++ * ====
++ * - Unsupport 8bit PIC2 image file.
++ *
++ * If you find other bugs (surely exist :-)), send me bug-report.
++ *
++ *
++ * Author
++ * ======
++ * IKEMOTO Masahiro <ikeyan@airlab.cs.ritsumei.ac.jp>
++ */
++
++#define PIC2_IGNORE_UNUSED_FUNCTIONS
++#define NEEDSDIR
++
++#include "xv.h"
++#include <setjmp.h>
++
++#ifdef HAVE_PIC2
++
++typedef unsigned long pixel;
++
++#define pic2_cextoshort(addr) ( \
++ (((short) (((byte *) addr)[0])) << 8) | \
++ ( (short) (((byte *) addr)[1])) \
++)
++#define pic2_cextolong(addr) ( \
++ (((long) (((byte *) addr)[0])) << 24) | \
++ (((long) (((byte *) addr)[1])) << 16) | \
++ (((long) (((byte *) addr)[2])) << 8) | \
++ ( (long) (((byte *) addr)[3])) \
++)
++#define pic2_shorttocex(addr, n) { \
++ ((byte *) addr)[0] = (((unsigned short) (n) >> 8) & 0xff); \
++ ((byte *) addr)[1] = ( (unsigned short) (n) & 0xff); \
++}
++#define pic2_longtocex(addr, n) { \
++ ((byte *) addr)[0] = (((unsigned long) (n) >> 24) & 0xff); \
++ ((byte *) addr)[1] = (((unsigned long) (n) >> 16) & 0xff); \
++ ((byte *) addr)[2] = (((unsigned long) (n) >> 8) & 0xff); \
++ ((byte *) addr)[3] = ( (unsigned long) (n) & 0xff); \
++}
++#define pic2_shift_bits(b, n) (((n) > 0) ? ((b) << (n)) : ((b) >> -(n)))
++
++#define PIC2_READ_MODE 0
++#define PIC2_WRITE_MODE 1
++
++#define PIC2_ARITH_CACHE 32
++#define PIC2_ARITH_CONTEXT 128
++#define PIC2_FAST_CACHE 64
++
++#define PIC2_HEADER_SIZE 124
++#define PIC2_BLOCK_HEADER_SIZE 26
++
++struct pic2_header {
++ char magic[4];
++ char name[18];
++ char subtitle[8];
++ char crlf0[2];
++ char title[30];
++ char crlf1[2];
++ char saver[30];
++ char crlf2[2];
++ char eof[1];
++ char reserve0[1];
++ short flag;
++ short no;
++ long time;
++ long size;
++ short depth;
++ short x_aspect;
++ short y_aspect;
++ short x_max;
++ short y_max;
++ long reserve1;
++};
++
++struct pic2_block {
++ char id[4];
++ long size;
++ short flag;
++ short x_wid;
++ short y_wid;
++ short x_offset;
++ short y_offset;
++ long opaque;
++ long reserve;
++};
++
++struct pic2_info {
++ jmp_buf jmp;
++ FILE *fp;
++ struct {
++ int rest;
++ byte cur;
++ int bits;
++ char zero;
++ }bs;
++ long fsize;
++ struct pic2_header *header;
++ struct pic2_block *block;
++ int n_pal;
++ int pal_bits;
++ byte pal[256][3];
++ char *comment;
++ char mode;
++ long next_pos;
++ long block_pos;
++ short x_max;
++ short y_max;
++ int ynow;
++ byte *buf;
++ pixel *vram_prev;
++ pixel *vram_now;
++ pixel *vram_next;
++ short *flag_now;
++ short *flag_next;
++ short *flag2_now;
++ short *flag2_next;
++ short *flag2_next2;
++ pixel (*cache)[PIC2_ARITH_CACHE];
++ unsigned short *cache_pos;
++ unsigned short *mulu_tab;
++ long aa;
++ long cc;
++ long dd;
++ char cache_hit_c;
++ int (*next_line) PARM((struct pic2_info *, pixel **));
++ char writing_grey;
++ char pagebname[64];
++ int pnum;
++};
++
++static void pic2_open_file PARM((struct pic2_info*,char*));
++static void pic2_read_header PARM((struct pic2_info*));
++static void pic2_read_block_header1 PARM((struct pic2_info*));
++static void pic2_read_block_header2 PARM((struct pic2_info*));
++static short pic2_arith_decode_bit PARM((struct pic2_info*,int));
++static short pic2_arith_decode_nn PARM((struct pic2_info*,int));
++static void pic2_arith_expand_chain PARM((struct pic2_info*,int,int,pixel));
++static short pic2_arith_get_number PARM((struct pic2_info*,int,int));
++static pixel pic2_arith_read_color PARM((struct pic2_info*,int));
++static int pic2_arith_expand_line PARM((struct pic2_info*,pixel**));
++static int pic2_arith_loader_init PARM((struct pic2_info*));
++static int pic2_fast_read_length PARM((struct pic2_info*));
++static void pic2_fast_expand_chain PARM((struct pic2_info*,int,pixel));
++static pixel pic2_fast_read_color PARM((struct pic2_info*,pixel));
++static int pic2_fast_expand_line PARM((struct pic2_info*,pixel**));
++static int pic2_fast_loader_init PARM((struct pic2_info*));
++static int pic2_beta_expand_line PARM((struct pic2_info*,pixel**));
++static int pic2_beta_loader_init PARM((struct pic2_info*));
++static void pic2_make_xvpic PARM((struct pic2_info*,byte**,
++ byte*,byte*,byte*));
++static void pic2_make_pagefile PARM((struct pic2_info*,char*,int));
++static void pic2_setup_pic2_info PARM((struct pic2_info*,
++ char*,char*,char*,char*,
++ int,int,int,int,int,int,char *));
++static void pic2_append PARM((struct pic2_info*));
++static void pic2_write_header1 PARM((struct pic2_info*));
++static void pic2_write_header2 PARM((struct pic2_info*));
++static void pic2_write_block_header PARM((struct pic2_info*));
++static void pic2_arith_write_zero_bit PARM((struct pic2_info*));
++static void pic2_arith_flush_bit_buf PARM((struct pic2_info*));
++static void pic2_arith_carry_bit PARM((struct pic2_info*));
++static void pic2_arith_encode_bit PARM((struct pic2_info*,int,int));
++static void pic2_arith_encode_nbyte PARM((struct pic2_info*,int,int,int));
++static void pic2_arith_encode_nn PARM((struct pic2_info*,int,int));
++static void pic2_arith_press_chain PARM((struct pic2_info*,int));
++static void pic2_arith_put_number PARM((struct pic2_info*,int,int,int));
++static void pic2_arith_write_color PARM((struct pic2_info*,int));
++static void pic2_arith_press_line2 PARM((struct pic2_info*));
++static int pic2_arith_press_line PARM((struct pic2_info*,pixel**));
++static int pic2_arith_saver_init PARM((struct pic2_info*,pixel**));
++static void pic2_fast_write_length PARM((struct pic2_info*,int));
++static void pic2_fast_press_chain PARM((struct pic2_info*,int));
++static void pic2_fast_press_chain2 PARM((struct pic2_info*,int));
++static void pic2_fast_flush_chain PARM((struct pic2_info*));
++static void pic2_fast_write_color PARM((struct pic2_info*,int));
++static void pic2_fast_press_line2 PARM((struct pic2_info*));
++static int pic2_fast_press_line PARM((struct pic2_info*,pixel**));
++static int pic2_fast_saver_init PARM((struct pic2_info*,pixel**));
++static int pic2_beta_press_line PARM((struct pic2_info*,pixel**));
++static int pic2_beta_saver_init PARM((struct pic2_info*,pixel**));
++static void pic2_write_data PARM((struct pic2_info*,byte*,
++ int,int,int,int,int,
++ byte*,byte*,byte*,int,int));
++static int pic2_next_line PARM((struct pic2_info*,pixel**));
++static int pic2_next_block PARM((struct pic2_info*));
++static int pic2_find_block PARM((struct pic2_info*));
++static int pic2_load_block PARM((struct pic2_info*));
++static int pic2_save_block PARM((struct pic2_info*,pixel**,
++ int,int,int,int,char*,pixel));
++#ifndef PIC2_IGNORE_UNUSED_FUNCTIONS
++static void pic2_read_palette PARM((struct pic2_info*,
++ byte*,byte*,byte*));
++static void pic2_write_palette PARM((struct pic2_info*,int,int,
++ byte*,byte*,byte*));
++#endif /* !PIC2_IGNORE_UNUSED_FUNCTIONS */
++static byte pic2_convert_color_bits PARM((int,int,int));
++static byte pic2_pad_color_bits PARM((int,int,int));
++static byte pic2_reduce_color_bits PARM((int,int,int));
++static pixel pic2_exchange_rg PARM((pixel,int));
++static void pic2_handle_para PARM((struct pic2_info*,int));
++static int pic2_alloc_buffer PARM((struct pic2_info*));
++static void pic2_free_buffer PARM((struct pic2_info*));
++static long pic2_seek_file PARM((struct pic2_info*,long,int));
++static long pic2_tell_file PARM((struct pic2_info*));
++static int pic2_read_file PARM((struct pic2_info*,void*,size_t));
++static long pic2_read_long PARM((struct pic2_info*));
++static short pic2_read_short PARM((struct pic2_info*));
++static char pic2_read_char PARM((struct pic2_info*));
++static int pic2_write_file PARM((struct pic2_info*,void*,size_t));
++static int pic2_write_long PARM((struct pic2_info*,long));
++static int pic2_write_short PARM((struct pic2_info*,int));
++static int pic2_write_char PARM((struct pic2_info*,int));
++static unsigned long pic2_read_bits PARM((struct pic2_info*,int));
++static void pic2_write_bits PARM((struct pic2_info*,
++ unsigned long,int));
++static void pic2_flush_bits PARM((struct pic2_info*));
++static void pic2_memory_error PARM((char*,char*));
++static void pic2_error PARM((struct pic2_info*,int));
++static void pic2_file_error PARM((struct pic2_info*,int));
++static void pic2_init_info PARM((struct pic2_info*));
++static void pic2_cleanup_pic2_info PARM((struct pic2_info*,int));
++static void pic2_cleanup_pinfo PARM((PICINFO*));
++static void pic2_show_pic2_info PARM((struct pic2_info*));
++static char *pic2_strncpy PARM((char*,char*,size_t));
++static void *pic2_malloc PARM((size_t,char*));
++static void *pic2_new PARM((size_t,char*));
++
++static int WritePIC2 PARM((FILE*,byte*,int,int,int,
++ byte*,byte*,byte*,int,int,char*,
++ int,int,int,int,int,char*));
++
++static char *pic2_id = "P2DT";
++
++/* Error Messages */
++static char *pic2_msgs[] = {
++ NULL,
++#define PIC2_OPEN 1
++ "can't open file.",
++#define PIC2_CORRUPT 2
++ "file corrupted.",
++#define PIC2_FORMAT 3
++ "not PIC2 format.",
++#define PIC2_DEPTH 4
++ "bit depths not divisible by 3 are unsupported.",
++#define PIC2_TMPFILE 5
++ "unable to create temporary filename???",
++#define PIC2_PAGE 6
++ "couldn't load the page.",
++#define PIC2_APPEND 7
++ "cannot append.",
++#define PIC2_WRITE 8
++ "write failed.",
++};
++
++struct _form_tab {
++ char *id;
++ int (*loader_init) PARM((struct pic2_info *));
++ int (*saver_init) PARM((struct pic2_info *, pixel **));
++} form_tab[] = {
++ { "P2SS", pic2_arith_loader_init, pic2_arith_saver_init},
++ { "P2SF", pic2_fast_loader_init, pic2_fast_saver_init},
++ { "P2BM", pic2_beta_loader_init, pic2_beta_saver_init},
++ { "P2BI", pic2_beta_loader_init, pic2_beta_saver_init},
++};
++#define n_form_tab (sizeof(form_tab) / sizeof(struct _form_tab))
++#define P2SS 0
++#define P2SF 1
++#define P2BM 2
++#define P2BI 3
++
++/* The main routine to load a PIC2 file. */
++int LoadPIC2(fname, pinfo, quick)
++char *fname;
++PICINFO *pinfo;
++int quick;
++{
++ int e, i, block;
++ struct pic2_info pic2;
++
++ if (DEBUG)
++ fputs("LoadPIC2:\n", stderr);
++
++ pic2_init_info(&pic2);
++
++ if ((e = setjmp(pic2.jmp)) != 0){
++ /* When an error occurs, comes here. */
++ pic2_free_buffer(&pic2);
++ pic2_cleanup_pic2_info(&pic2, 0);
++ pic2_cleanup_pinfo(pinfo);
++ if (pic2split)
++ KillPageFiles(pic2.pagebname, pic2.pnum);
++ SetCursors(-1);
++ if (DEBUG)
++ fputs("\n", stderr);
++ return (0);
++ }
++ pic2_open_file(&pic2, fname);
++ pic2_read_header(&pic2);
++
++ if ((i = pic2_find_block(&pic2)) == 0)
++ pic2_file_error(&pic2, PIC2_CORRUPT);
++
++ block = 1;
++ while(i == 2) {
++ SetISTR(ISTR_WARNING, "unknown or invalid block #%d.", block);
++ i = pic2_next_block(&pic2);
++ block++;
++ }
++
++ if (pic2split && !quick) {
++ char firstpage[512];
++ struct stat st;
++#ifndef USE_MKSTEMP
++ int tmpfd;
++#endif
++
++#ifndef VMS
++ sprintf(pic2.pagebname, "%s/xvpic2XXXXXX", tmpdir);
++#else
++ sprintf(pic2.pagebname, "Sys$Scratch:xvpic2XXXXXX");
++#endif
++#ifdef USE_MKSTEMP
++ close(mkstemp(pic2.pagebname));
++#else
++ mktemp(pic2.pagebname);
++ tmpfd = open(pic2.pagebname, O_WRONLY|O_CREAT|O_EXCL, S_IRWUSR);
++ if (tmpfd < 0) FatalError("LoadPIC2(): can't create temporary file");
++ close(tmpfd);
++#endif
++ if (pic2.pagebname[0] == '\0')
++ pic2_error(&pic2, PIC2_TMPFILE);
++ strcat(pic2.pagebname, ".");
++
++ sprintf(firstpage, "%s%d", pic2.pagebname, 1);
++ if (stat(firstpage, &st)) {
++ for (pic2.pnum = 1; i >= 1; pic2.pnum++) {
++ pic2_load_block(&pic2);
++ pic2_make_pagefile(&pic2, pic2.pagebname, pic2.pnum);
++ while(block++, (i = pic2_next_block(&pic2)) == 2)
++ SetISTR(ISTR_WARNING,
++ "unknown or invalid block #%d.", block);
++ }
++ pinfo->numpages = --pic2.pnum;
++ if (!LoadPIC2(firstpage, pinfo, 1))
++ pic2_error(&pic2, PIC2_PAGE);
++ if (pic2.pnum == 1)
++ unlink(firstpage);
++ else
++ strcpy(pinfo->pagebname, pic2.pagebname);
++ } else
++ if (!LoadPIC2(fname, pinfo, 1))
++ pic2_error(&pic2, PIC2_PAGE);
++ } else {
++ char buf[128], format[64];
++ int j;
++
++ pinfo->w = pic2.x_max;
++ pinfo->h = pic2.y_max;
++ pinfo->normw = pinfo->w;
++ pinfo->normh = pinfo->h;
++ pinfo->type = PIC24;
++ for (j = 0; j < n_form_tab; j++) {
++ if (xvbcmp(pic2.block->id, form_tab[j].id, (size_t) 4) == 0)
++ break;
++ }
++ pinfo->frmType = F_PIC2;
++ pinfo->colType = F_FULLCOLOR;
++ pinfo->comment = pic2.comment;
++
++ if (pic2split) {
++ pic2_make_xvpic(&pic2, &pinfo->pic, pinfo->r, pinfo->g, pinfo->b);
++ strcpy(format, form_tab[j].id);
++ } else {
++ for (pic2.pnum = 1; i >= 1; pic2.pnum++) {
++ SetISTR(ISTR_INFO, "composing block #%d", block);
++ pic2_make_xvpic(&pic2, &pinfo->pic,
++ pinfo->r, pinfo->g, pinfo->b);
++ while(block++, (i = pic2_next_block(&pic2)) == 2)
++ SetISTR(ISTR_WARNING,
++ "unknown or invalid block #%d.", block);
++ }
++ if (--block > 1)
++ if (block != --pic2.pnum)
++ sprintf(format, "MultiBlock[%d/%d]", block, pic2.pnum);
++ else
++ sprintf(format, "MultiBlock[%d]", block);
++ else
++ strcpy(format, form_tab[j].id);
++ }
++ sprintf(buf, "PIC2(%s). %d colors (%ld bytes)", format,
++ (int) 1 << pic2.header->depth, pic2.fsize);
++ strcat(pinfo->fullInfo, buf);
++ sprintf(pinfo->shrtInfo, "%dx%d(aspect %4.2f) PIC2(%s).",
++ pinfo->w, pinfo->h,
++ (float) pic2.header->x_aspect / (float) pic2.header->y_aspect,
++ format);
++ if (!nopicadjust)
++ normaspect = (float) pic2.header->x_aspect
++ / (float) pic2.header->y_aspect;
++ }
++ pic2_cleanup_pic2_info(&pic2, 0);
++ SetCursors(-1);
++ if (DEBUG)
++ fputs("\n", stderr);
++ return (1);
++}
++
++/*
++ * This function opens the file, and set its size.
++ */
++static void pic2_open_file(pi, fname)
++ struct pic2_info *pi;
++ char *fname;
++{
++ if ((pi->fp = fopen(fname, "rb")) == NULL)
++ pic2_file_error(pi, PIC2_OPEN);
++ fseek(pi->fp, (size_t) 0, SEEK_END);
++ pi->fsize = ftell(pi->fp);
++ fseek(pi->fp, (size_t) 0, SEEK_SET);
++}
++
++/*
++ * These functions read the PIC2 header informations.
++ * pic2_read_header:
++ * reads the PIC2 header.
++ * pic2_read_block_header1:
++ * reads the id number of block header and the size of block.
++ * pic2_read_block_header2:
++ * reads the rest of block header.
++ */
++static void pic2_read_header(pi)
++struct pic2_info *pi;
++{
++ long s_comment;
++
++ pi->mode = PIC2_READ_MODE;
++
++ /* read header image */
++ pic2_read_file(pi, pi->header->magic, 4);
++ pic2_read_file(pi, pi->header->name, 18);
++ pic2_read_file(pi, pi->header->subtitle, 8);
++ pic2_read_file(pi, pi->header->crlf0, 2);
++ pic2_read_file(pi, pi->header->title, 30);
++ pic2_read_file(pi, pi->header->crlf1, 2);
++ pic2_read_file(pi, pi->header->saver, 30);
++ pic2_read_file(pi, pi->header->crlf2, 2);
++ pic2_read_file(pi, pi->header->eof, 1);
++ pic2_read_file(pi, pi->header->reserve0, 1);
++ pi->header->flag = pic2_read_short(pi);
++ pi->header->no = pic2_read_short(pi);
++ pi->header->time = pic2_read_long(pi);
++ pi->header->size = pic2_read_long(pi);
++ pi->header->depth = pic2_read_short(pi);
++ pi->header->x_aspect = pic2_read_short(pi);
++ pi->header->y_aspect = pic2_read_short(pi);
++ pi->header->x_max = pic2_read_short(pi);
++ pi->header->y_max = pic2_read_short(pi);
++ pi->header->reserve1 = pic2_read_long(pi);
++
++ /* check magic number */
++ if (strncmp(pi->header->magic, pic2_id, (size_t) 4) != 0)
++ pic2_error(pi, PIC2_FORMAT);
++
++ /* read palette data, if exists */
++ if (pi->header->flag & 1) {
++ pi->pal_bits = pic2_read_char(pi);
++ pi->n_pal = pic2_read_short(pi);
++ pic2_read_file(pi, pi->pal, (size_t) (pi->n_pal * 3));
++ }
++
++ /* read comments */
++ s_comment = pi->header->size - pic2_tell_file(pi);
++ pi->comment = pic2_new(s_comment + 1, "pic2_read_header");
++ pic2_read_file(pi, pi->comment, (size_t) s_comment);
++ pi->comment[s_comment] = '\0';
++
++ pi->x_max = pi->header->x_max;
++ pi->y_max = pi->header->y_max;
++
++ /* set initial block point */
++ pi->next_pos = pic2_tell_file(pi);
++}
++
++static void pic2_read_block_header1(pi)
++struct pic2_info *pi;
++{
++ pic2_read_file(pi, pi->block->id, 4);
++ pi->block->size = pic2_read_long(pi);
++}
++
++static void pic2_read_block_header2(pi)
++struct pic2_info *pi;
++{
++ pi->block->flag = pic2_read_short(pi);
++ pi->block->x_wid = pic2_read_short(pi);
++ pi->block->y_wid = pic2_read_short(pi);
++ pi->block->x_offset = pic2_read_short(pi);
++ pi->block->y_offset = pic2_read_short(pi);
++ pi->block->opaque = pic2_read_long(pi);
++ pi->block->reserve = pic2_read_long(pi);
++}
++
++/*
++ * These functions are arithmetic pic2 format extractor.
++ */
++static short pic2_arith_decode_bit(pi, c)
++struct pic2_info *pi;
++int c;
++{
++ unsigned short pp;
++
++ pp = pi->mulu_tab[(pi->aa & 0x7f00) / 2 + c];
++ if (pi->dd >= (int) pp) {
++ pi->dd -= pp;
++ pi->aa -= pp;
++
++ while ((short) pi->aa >= 0) {
++ pi->dd *= 2;
++ if (pic2_read_bits(pi, 1))
++ pi->dd++;
++ pi->aa *= 2;
++ }
++ return (1);
++ } else {
++ pi->aa = pp;
++
++ while ((short) pi->aa >= 0) {
++ pi->dd *= 2;
++ if (pic2_read_bits(pi, 1))
++ pi->dd++;
++ pi->aa *= 2;
++ }
++ return (0);
++ }
++}
++
++static short pic2_arith_decode_nn(pi, c)
++struct pic2_info *pi;
++int c;
++{
++ int n;
++
++ if (pic2_arith_decode_bit(pi, c)) {
++ /* n < 1 */
++ n = 0;
++ } else if (pic2_arith_decode_bit(pi, c + 1)) {
++ /* n < 1 + 2 */
++ n = 1;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ } else if (pic2_arith_decode_bit(pi, c + 2)) {
++ /* n < 1 + 2 + 4 */
++ n = 1 + 2;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ } else if (pic2_arith_decode_bit(pi, c + 3)) {
++ /* n < 1 + 2 + 4 + 8 */
++ n = 1 + 2 + 4;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ if (pic2_arith_decode_bit(pi, c + 10))
++ n += 4;
++ } else if (pic2_arith_decode_bit(pi, c + 4)) {
++ /* n < 1 + 2 + 4 + 8 + 16 */
++ n = 1 + 2 + 4 + 8;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ if (pic2_arith_decode_bit(pi, c + 10))
++ n += 4;
++ if (pic2_arith_decode_bit(pi, c + 11))
++ n += 8;
++ } else if (pic2_arith_decode_bit(pi, c + 5)) {
++ /* n < 1 + 2 + 4 + 8 + 16 + 32 */
++ n = 1 + 2 + 4 + 8 + 16;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ if (pic2_arith_decode_bit(pi, c + 10))
++ n += 4;
++ if (pic2_arith_decode_bit(pi, c + 11))
++ n += 8;
++ if (pic2_arith_decode_bit(pi, c + 12))
++ n += 16;
++
++ } else if (pic2_arith_decode_bit(pi, c + 6)) {
++ /* n < 1 + 2 + 4 + 8 + 16 + 32 + 64 */
++ n = 1 + 2 + 4 + 8 + 16 + 32;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ if (pic2_arith_decode_bit(pi, c + 10))
++ n += 4;
++ if (pic2_arith_decode_bit(pi, c + 11))
++ n += 8;
++ if (pic2_arith_decode_bit(pi, c + 12))
++ n += 16;
++ if (pic2_arith_decode_bit(pi, c + 13))
++ n += 32;
++
++ } else if (pic2_arith_decode_bit(pi, c + 7)) {
++ /* n < 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 */
++ n = 1 + 2 + 4 + 8 + 16 + 32 + 64;
++ if (pic2_arith_decode_bit(pi, c + 8))
++ n += 1;
++ if (pic2_arith_decode_bit(pi, c + 9))
++ n += 2;
++ if (pic2_arith_decode_bit(pi, c + 10))
++ n += 4;
++ if (pic2_arith_decode_bit(pi, c + 11))
++ n += 8;
++ if (pic2_arith_decode_bit(pi, c + 12))
++ n += 16;
++ if (pic2_arith_decode_bit(pi, c + 13))
++ n += 32;
++ if (pic2_arith_decode_bit(pi, c + 14))
++ n += 64;
++
++ } else {
++ n = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128;
++ }
++ return (n);
++}
++
++static void pic2_arith_expand_chain(pi, x, y, cc)
++struct pic2_info *pi;
++int x, y;
++pixel cc;
++{
++ static const unsigned short c_tab[] = {
++ 80 + 6 * 5, /* -5 */
++ 80 + 6 * 4,
++ 80 + 6 * 3,
++ 80 + 6 * 2,
++ 80 + 6 * 1,
++ 80 + 6 * 0, /* 0 */
++ 80 + 6 * 0, /* 1 */
++ };
++ unsigned short b;
++
++ b = c_tab[pi->flag_now[x] + 5];
++ if (!pic2_arith_decode_bit(pi, b++)) {
++ if (pic2_arith_decode_bit(pi, b++)) { /* down */
++ pi->vram_next[x ] = cc;
++ pi->flag_next[x ] = -1;
++ } else if (pic2_arith_decode_bit(pi, b++)) { /* left */
++ pi->vram_next[x - 1] = cc;
++ pi->flag_next[x - 1] = -2;
++ } else if (pic2_arith_decode_bit(pi, b++)) { /* right */
++ pi->vram_next[x + 1] = cc;
++ pi->flag_next[x + 1] = -3;
++ } else if (pic2_arith_decode_bit(pi, b++)) { /* left2 */
++ pi->vram_next[x - 2] = cc;
++ pi->flag_next[x - 2] = -4;
++ } else { /* right2 */
++ pi->vram_next[x + 2] = cc;
++ pi->flag_next[x + 2] = -5;
++ }
++ }
++}
++
++static short pic2_arith_get_number(pi, c, bef)
++struct pic2_info *pi;
++int c, bef;
++{
++ unsigned short n;
++ byte maxcol;
++
++ maxcol = 0xff >> (8 - pi->header->depth / 3);
++
++ n = pic2_arith_decode_nn(pi, c);
++ if (bef > ((int) maxcol >> 1)) {
++ if (n > ((int) maxcol - bef) * 2)
++ n = maxcol - n;
++ else if (n & 1)
++ n = n / 2 + bef + 1;
++ else
++ n = bef - n / 2;
++ } else {
++ if ((int) n > (bef * 2))
++ n = n;
++ else if (n & 1)
++ n = n / 2 + bef + 1;
++ else
++ n = bef - n / 2;
++ }
++ return (n);
++}
++
++static pixel pic2_arith_read_color(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ pixel c1, c2, cc;
++ unsigned short i, j, k, m;
++ short r, g, b, r0, g0, b0;
++ short colbits;
++ pixel rmask, gmask, bmask;
++ byte maxcol;
++
++ colbits = pi->header->depth / 3;
++ rmask = (0xff >> (8 - colbits)) << (colbits * 2);
++ gmask = (0xff >> (8 - colbits)) << colbits;
++ bmask = (0xff >> (8 - colbits));
++ maxcol = (byte) bmask;
++
++ c1 = pi->vram_prev[x];
++ k = ((c1 >> ((colbits - 3) * 3)) & 0x1c0)
++ | ((c1 >> ((colbits - 3) * 2)) & 0x038)
++ | ((c1 >> (colbits - 3) ) & 0x007);
++ if (colbits == 5)
++ k = pic2_exchange_rg(k, 3);
++
++ if (pic2_arith_decode_bit(pi, pi->cache_hit_c)) { /* ouch */
++ pi->cache_hit_c = 16;
++
++ c2 = pi->vram_now[x - 1];
++ r = ((c1 & rmask) + (c2 & rmask)) >> (colbits * 2 + 1);
++ g = ((c1 & gmask) + (c2 & gmask)) >> (colbits + 1);
++ b = ((c1 & bmask) + (c2 & bmask)) >> ( 1);
++
++ g0 = pic2_arith_get_number(pi, 32, g);
++ r = r + g0 - g;
++ if (r > (short) maxcol)
++ r = maxcol;
++ else if (r < 0)
++ r = 0;
++
++ b = b + g0 - g;
++ if (b > (short) maxcol)
++ b = maxcol;
++ else if (b < 0)
++ b = 0;
++
++ r0 = pic2_arith_get_number(pi, 48, r);
++ b0 = pic2_arith_get_number(pi, 64, b);
++
++ pi->cache_pos[k] = j = (pi->cache_pos[k] - 1) & (PIC2_ARITH_CACHE - 1);
++ pi->cache[k][j] = cc = (r0 << (colbits * 2)) | (g0 << colbits) | b0;
++ } else {
++ pi->cache_hit_c = 15;
++
++ j = pic2_arith_decode_nn(pi, 17);
++ m = pi->cache_pos[k];
++ i = (m + j / 2) & (PIC2_ARITH_CACHE - 1);
++ j = (m + j) & (PIC2_ARITH_CACHE - 1);
++
++ cc = pi->cache[k][j];
++ pi->cache[k][j] = pi->cache[k][i];
++ pi->cache[k][i] = pi->cache[k][m];
++ pi->cache[k][m] = cc;
++ }
++ return (cc);
++}
++
++static int pic2_arith_expand_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int ymax;
++ int x, xw;
++ pixel cc;
++
++ pic2_handle_para(pi, 0);
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid - 1;
++
++ if (pi->ynow > ymax)
++ return (-2); /* end */
++
++ /* set right end of previous line before left end of current line. */
++ if (pi->ynow == 0) {
++ cc = 0;
++ } else
++ cc = pi->vram_prev[xw - 1];
++ pi->vram_now[-1] = cc;
++
++ /* clear flag for change point */
++ xvbzero((char *) pi->flag_next, xw * sizeof(pi->flag_next[0]));
++
++ /* clear flag for position probability space */
++ xvbzero((char *) pi->flag2_next2, xw * sizeof(pi->flag2_next2[0]));
++
++ for (x = 0; x < xw; x++) {
++ if (pi->flag_now[x] < 0) {
++ cc = pi->vram_now[x];
++ if (pi->ynow < ymax)
++ pic2_arith_expand_chain(pi, x, pi->ynow, cc);
++ } else if (pic2_arith_decode_bit(pi, pi->flag2_now[x])) {
++ /* ajust probability space around of change point */
++ pi->flag2_now [x + 1]++;
++ pi->flag2_now [x + 2]++;
++ pi->flag2_next [x - 1]++;
++ pi->flag2_next [x ]++;
++ pi->flag2_next [x + 1]++;
++ pi->flag2_next2[x - 1]++;
++ pi->flag2_next2[x ]++;
++ pi->flag2_next2[x + 1]++;
++
++ pi->vram_now[x] = cc = pic2_arith_read_color(pi, x);
++ if (pi->ynow < ymax)
++ pic2_arith_expand_chain(pi, x, pi->ynow, cc);
++ } else
++ pi->vram_now[x] = cc;
++ }
++ if (line != NULL)
++ *line = pi->vram_now;
++ pi->ynow++;
++
++ pic2_handle_para(pi, 1);
++
++ return (pi->ynow - 1);
++}
++
++static int pic2_arith_loader_init(pi)
++struct pic2_info *pi;
++{
++ unsigned short p2b[256];
++ int i, xw;
++
++ pi->ynow = 0;
++
++ /* check the color depth */
++ if (pi->header->depth % 3)
++ pic2_error(pi, PIC2_DEPTH);
++
++ /* set function for extract next line */
++ pi->next_line = pic2_arith_expand_line;
++
++ /* clear cache and flags */
++ xw = pi->block->x_wid;
++ xvbzero((char *) pi->cache, 8 * 8 * 8 * sizeof(pi->cache[0]));
++ xvbzero((char *) pi->cache_pos, 8 * 8 * 8 * sizeof(pi->cache_pos[0]));
++
++ xvbzero((char *) pi->flag_now, xw * sizeof(pi->flag_now[0]));
++ xvbzero((char *) pi->flag2_now, 8 + xw * sizeof(pi->flag2_now[0]));
++ xvbzero((char *) pi->flag2_next, 8 + xw * sizeof(pi->flag2_next[0]));
++
++ /* go to picture data field */
++ pic2_seek_file(pi, pi->block_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++
++ /* clear bit field marker */
++ pi->bs.rest = 0;
++ pi->bs.cur = 0;
++
++ /* read probability table */
++ for (i = 0; i < PIC2_ARITH_CONTEXT; i++)
++ p2b[i] = pic2_read_short(pi);
++
++ /* make multiplication table */
++ for (i = 0; i < 16384; i++) {
++ pi->mulu_tab[i] = (long) (i / 128 + 128) * (int) p2b[i & 127] / 256;
++ if (pi->mulu_tab[i] == 0) pi->mulu_tab[i] = 1;
++ }
++ /* initialize some valuables */
++ pi->aa = 0xffff;
++ pi->dd = 0;
++ for (i = 0; i < 16; i++) {
++ pi->dd *= 2;
++ if (pic2_read_bits(pi, 1))
++ pi->dd |= 1;
++ }
++ pi->cache_hit_c = 16;
++
++ return (0);
++}
++
++/*
++ * These functions are fast pic2 compression extractor.
++ */
++static int pic2_fast_read_length(pi)
++struct pic2_info *pi;
++{
++ int a;
++
++ a = 0;
++ while (pic2_read_bits(pi, 1)) {
++ a++;
++ }
++ if (a == 0)
++ return (0);
++ return (pic2_read_bits(pi, a) + (1 << a) - 1);
++}
++
++static void pic2_fast_expand_chain(pi, x, cc)
++struct pic2_info *pi;
++int x;
++pixel cc;
++{
++ if (pic2_read_bits(pi, 1) != 0) {
++ if (pic2_read_bits(pi, 1) != 0) { /* down */
++ pi->vram_next[x] = cc;
++ pi->flag_next[x] = -1;
++ } else if (pic2_read_bits(pi, 1) != 0) {
++ if (pic2_read_bits(pi, 1) == 0) { /* left2down */
++ pi->vram_next[x - 2] = cc;
++ pi->flag_next[x - 2] = -1;
++ } else { /* left1down */
++ pi->vram_next[x - 1] = cc;
++ pi->flag_next[x - 1] = -1;
++ }
++ } else {
++ if (pic2_read_bits(pi, 1) == 0) { /* right2down */
++ pi->vram_next[x + 2] = cc;
++ pi->flag_next[x + 2] = -1;
++ } else { /* left1down */
++ pi->vram_next[x + 1] = cc;
++ pi->flag_next[x + 1] = -1;
++ }
++ }
++ }
++}
++
++static pixel pic2_fast_read_color(pi, bc)
++struct pic2_info *pi;
++pixel bc;
++{
++ pixel cc;
++ unsigned short j, k, m;
++ short depth, colbits;
++ pixel (*cache)[PIC2_FAST_CACHE];
++
++ depth = pi->header->depth;
++ colbits = depth / 3;
++ cache = (pixel (*)[PIC2_FAST_CACHE]) pi->cache;
++
++ bc = pic2_exchange_rg(bc, colbits);
++ k = pic2_shift_bits(bc, 8 - depth);
++ if (pic2_read_bits(pi, 1) == 0) {
++ pi->cache_pos[k] = m = (pi->cache_pos[k] - 1) & (PIC2_FAST_CACHE - 1);
++ cc = pic2_read_bits(pi, depth);
++ cc = pic2_exchange_rg(cc, colbits);
++ cache[k][m] = cc;
++ } else {
++ j = pic2_read_bits(pi, 6); /* 6= log2(PIC2_FAST_CACHE) */
++ m = pi->cache_pos[k];
++ cc = cache[k][(m + j) & (PIC2_FAST_CACHE - 1)];
++ }
++ return (cc);
++}
++
++static int pic2_fast_expand_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int ymax;
++ int x, xw;
++ pixel cc;
++
++ pic2_handle_para(pi, 0);
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid - 1;
++
++ if (pi->ynow > ymax)
++ return (-2);
++
++ if (pi->ynow == 0) {
++ pi->dd = 0;
++ pi->aa = pic2_fast_read_length(pi);
++ if (pi->aa == 1023)
++ pi->dd = 1023;
++ else if (pi->aa > 1023)
++ pi->aa--;
++ cc = 0;
++ } else
++ cc = pi->vram_prev[xw - 1];
++
++ xvbzero((char *) pi->flag_next, xw * sizeof(pi->flag_next[0]));
++
++ for (x = 0; x < xw; x++) {
++ if (pi->dd > 0) {
++ if (pi->flag_now[x] < 0) { /* on chain ? */
++ cc = pi->vram_now[x];
++ pic2_fast_expand_chain(pi, x, cc);
++ if (--pi->dd == 0) {
++ pi->aa = pic2_fast_read_length(pi);
++ if (pi->aa == 1023)
++ pi->dd = 1023;
++ else if (pi->aa > 1023)
++ pi->aa--;
++ }
++ } else
++ pi->vram_now[x] = cc;
++ } else {
++ if (pi->flag_now[x] < 0) { /* on chain ? */
++ cc = pi->vram_now[x];
++ pic2_fast_expand_chain(pi, x, cc);
++ } else if (--pi->aa < 0) {
++ cc = pi->vram_now[x] = pic2_fast_read_color(pi, cc);
++ pic2_fast_expand_chain(pi, x, cc);
++ pi->aa = pic2_fast_read_length(pi);
++ if (pi->aa == 1023)
++ pi->dd = 1023;
++ else if (pi->aa > 1023)
++ pi->aa--;
++ } else
++ pi->vram_now[x] = cc;
++ }
++ }
++ if (line != NULL)
++ *line = pi->vram_now;
++ pi->ynow++;
++
++ pic2_handle_para(pi, 1);
++
++ return (pi->ynow - 1);
++}
++
++static int pic2_fast_loader_init(pi)
++struct pic2_info *pi;
++{
++ int xw;
++
++ pi->ynow = 0;
++
++ /* check the color depth */
++ if (pi->header->depth % 3)
++ pic2_error(pi, PIC2_DEPTH);
++
++ /* set function for extract next line */
++ pi->next_line = pic2_fast_expand_line;
++
++ /* clear cache and flags */
++ xw = pi->block->x_wid;
++ xvbzero((char *) pi->cache, sizeof(pi->cache[0]) * 256);
++ xvbzero((char *) pi->cache_pos, sizeof(pi->cache_pos[0]) * 8 * 8 * 8);
++ xvbzero((char *) pi->flag_now, (xw + 8) * sizeof(pi->flag_now[0]));
++ xvbzero((char *) pi->flag_next, (xw + 8) * sizeof(pi->flag_next[0]));
++
++ /* go to picture data field */
++ pic2_seek_file(pi, pi->block_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++
++ /* clear bit field marker */
++ pi->bs.rest = 0;
++ pi->bs.cur = 0;
++
++ return (0);
++}
++
++/*
++ * These functions are beta pic2 format extractor.
++ */
++static int pic2_beta_expand_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int i, xw, ymax;
++ byte a, b, c, *p;
++ pixel *pc;
++ short depth, pixbyte, colbits;
++
++ depth = pi->header->depth;
++ pixbyte = depth / 8 + ((depth % 8) > 0);
++ colbits = depth / 3;
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid - 1;
++
++ if (pi->ynow > ymax)
++ return (-2); /* end */
++
++ pc = pi->vram_now;
++ p = (byte *) pi->vram_prev;
++ if (pixbyte == 3) {
++ pic2_read_file(pi, pi->vram_prev, (size_t) (xw * pixbyte));
++ for (i = 0; i < xw; i++, pc++) {
++ a = *p++;
++ b = *p++;
++ c = *p++;
++ *pc = ((pixel) a << 16) | ((pixel) b << 8) | (pixel) c;
++ }
++ } else if (pixbyte == 2) {
++ pic2_read_file(pi, pi->vram_prev, (size_t) (xw * 2));
++ if (strncmp(pi->block->id, "P2BM", 4) == 0) {
++ for (i = 0; i < xw; i++, pc++) {
++ a = *p++;
++ b = *p++;
++ *pc = ((pixel) a << 8) | (pixel) b;
++ if (colbits == 5) {
++ *pc >>= 1;
++ *pc = pic2_exchange_rg(*pc, colbits);
++ }
++ }
++ } else {
++ for (i = 0; i < xw; i++, pc++) {
++ a = *p++;
++ b = *p++;
++ *pc = ((pixel) b << 8) | (pixel) a;
++ if (colbits == 5) {
++ *pc >>= 1;
++ *pc = pic2_exchange_rg(*pc, colbits);
++ }
++ }
++ }
++ } else {
++ pic2_read_file(pi, pi->vram_prev, (size_t) xw);
++ for (i = 0; i < xw; i++)
++ *pc++ = *p++;
++ }
++ if (line != NULL)
++ *line = pi->vram_now;
++
++ pc = pi->vram_prev;
++ pi->vram_prev = pi->vram_now;
++ pi->vram_now = pi->vram_next;
++ pi->vram_next = pc;
++
++ pi->ynow++;
++ return (pi->ynow - 1);
++}
++
++static int pic2_beta_loader_init(pi)
++struct pic2_info *pi;
++{
++ pi->ynow = 0;
++ pi->next_line = pic2_beta_expand_line;
++ pic2_seek_file(pi, pi->block_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++ return (0);
++}
++
++/*
++ * Make a picture from the expanded data.
++ */
++static void pic2_make_xvpic(pi, xp, rp, gp, bp)
++struct pic2_info *pi;
++byte **xp, *rp, *gp, *bp;
++{
++ int line, i;
++ pixel *linep, opaque;
++ short colbits;
++ byte colmask;
++
++ if (*xp == NULL)
++ *xp = pic2_new((size_t) pi->x_max * pi->y_max * 3, "pic2_make_xvpic"); // GRR POSSIBLE OVERFLOW / FIXME
++
++ if (pi->block->flag & 1)
++ opaque = pi->block->opaque;
++ else
++ opaque = 0xffffffff;
++
++ colbits = pi->header->depth / 3;
++ colmask = 0xff >> (8 - colbits);
++
++ line = pic2_load_block(pi);
++ for (;;) {
++ int pic_idx;
++
++ line = pic2_next_line(pi, &linep);
++ if (line < 0)
++ break;
++ pic_idx = ((line + pi->block->y_offset) * pi->x_max
++ + pi->block->x_offset) * 3;
++
++ for (i = 0; i < pi->block->x_wid; i++, linep++) {
++ byte r, g, b;
++
++ if (*linep != opaque) {
++ r = ((*linep >> (colbits * 2)) & colmask);
++ r = pic2_convert_color_bits(r, colbits, 8);
++ g = ((*linep >> colbits ) & colmask);
++ g = pic2_convert_color_bits(g, colbits, 8);
++ b = ( *linep & colmask);
++ b = pic2_convert_color_bits(b, colbits, 8);
++ (*xp)[pic_idx++] = r;
++ (*xp)[pic_idx++] = g;
++ (*xp)[pic_idx++] = b;
++ } else
++ pic_idx += 3;
++
++ WaitCursor();
++ }
++ }
++}
++
++/*
++ * This function splits a multiblock PIC2 file into several pages.
++ */
++static void pic2_make_pagefile(pi, pagebname, pnum)
++struct pic2_info *pi;
++char *pagebname;
++int pnum;
++{
++ struct pic2_info pic2;
++ FILE *fp;
++ char pagefile[64], *buf;
++ size_t imagesize;
++
++ sprintf(pagefile, "%s%d", pagebname, pnum);
++ if ((fp = fopen(pagefile, "wb")) == NULL)
++ pic2_error(pi, PIC2_WRITE);
++
++ xvbcopy((char *) pi, (char *) &pic2, sizeof(struct pic2_info));
++ pic2.fp = fp;
++
++ pic2_write_header1(&pic2);
++
++ pic2_write_block_header(&pic2);
++
++ imagesize = pi->block->size - PIC2_BLOCK_HEADER_SIZE;
++ buf = (char *) pic2_malloc(imagesize, "pic2_make_pagefile");
++
++ pic2_seek_file(pi, pi->block_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++ if (fread(buf, (size_t) 1, imagesize, pi->fp) < imagesize) {
++ free(buf);
++ pic2_file_error(pi, PIC2_CORRUPT);
++ }
++ if (fwrite(buf, (size_t) 1, imagesize, fp) < imagesize) {
++ free(buf);
++ pic2_error(pi, PIC2_WRITE);
++ }
++ free(buf);
++
++ pic2.next_pos = pic2_tell_file(&pic2);
++ pic2_write_header2(&pic2);
++
++ fclose(fp);
++}
++
++/* The main routine to save a PIC2 file. */
++static int WritePIC2(fp, pic0, ptype, w, h, rmap, gmap, bmap, numcols,
++ colorstyle, fname, type, depth, x_offset, y_offset,
++ append, comment)
++FILE *fp;
++byte *pic0;
++int ptype, w, h;
++byte *rmap, *gmap, *bmap;
++int numcols, colorstyle;
++char *fname;
++int type, depth;
++int x_offset, y_offset;
++int append;
++char *comment;
++{
++ struct pic2_info pic2;
++ char creator[256], title[256], saver[256];
++ int e;
++
++ if (DEBUG)
++ fputs("WritePIC2:\n", stderr);
++
++ pic2_init_info(&pic2);
++ pic2.fp = fp;
++ pic2.writing_grey = (colorstyle == F_GREYSCALE);
++
++ if ((e = setjmp(pic2.jmp)) != 0){
++ /* When an error occurs while writing, comes here. */
++ pic2_free_buffer(&pic2);
++ pic2_cleanup_pic2_info(&pic2, 1);
++ SetCursors(-1);
++ if (DEBUG)
++ fputs("\n", stderr);
++ return (-1);
++ }
++ sprintf(creator, "XV Version %s", VERSTR);
++ pic2_strncpy(title, comment, 30);
++ sprintf(saver, "XV %s/UNIX/Bradley", VERSTR);
++
++ if (!append) {
++ pic2_setup_pic2_info(&pic2, creator, fname, title, saver,
++ 0, depth, 1, 1, w, h, comment);
++ pic2_write_header1(&pic2);
++ } else {
++ pic2_read_header(&pic2);
++ pic2_append(&pic2);
++ free(pic2.comment);
++ pic2_setup_pic2_info(&pic2, creator, fname, title, saver,
++ 0, depth, 1, 1, w, h, comment);
++ }
++
++ pic2_write_data(&pic2, pic0, ptype, x_offset, y_offset, w, h,
++ rmap, gmap, bmap, type, depth);
++ pic2_write_header2(&pic2);
++
++ pic2_cleanup_pic2_info(&pic2, 1);
++ SetCursors(-1);
++ if (DEBUG)
++ fputs("\n", stderr);
++ return (0);
++}
++
++/*
++ * This function initializes pic2_info.
++ */
++static void pic2_setup_pic2_info(pi, name, fname, title, saver, no, depth,
++ x_aspect, y_aspect, x_max, y_max, comment)
++struct pic2_info *pi;
++char *name, *fname, *title, *saver;
++int no, depth;
++int x_aspect, y_aspect;
++int x_max, y_max;
++char *comment;
++{
++ char basename[256], *suffix;
++
++ pi->mode = PIC2_WRITE_MODE;
++
++ /* set magic number */
++ strncpy(pi->header->magic, pic2_id, 4);
++
++ /* set creator's name */
++ pic2_strncpy(pi->header->name, (char *) name, 18);
++
++ /* set title and subtitle */
++ pic2_strncpy(pi->header->title, (char *) title, 30);
++ strcpy(basename, BaseName(fname));
++ suffix = (char *) rindex(basename, '.');
++ if (suffix) {
++ suffix++;
++ if (!strcmp(suffix, "p2") || !strcmp(suffix, "P2"))
++ *(suffix - 1) = '\0';
++ }
++ pic2_strncpy(pi->header->subtitle, basename, 8);
++
++ /* set saver */
++ pic2_strncpy(pi->header->saver, saver, 30);
++
++ /* set picture number */
++ pi->header->no = no;
++
++ /* import comment */
++ pi->comment = comment;
++
++ /* set some picture's info */
++ pi->header->depth = depth;
++ pi->header->x_aspect = x_aspect;
++ pi->header->y_aspect = y_aspect;
++ pi->header->x_max = x_max;
++ pi->header->y_max = y_max;
++
++ /* set some gaps */
++ pi->header->crlf0[0] = pi->header->crlf1[0] = pi->header->crlf2[0] = 0x0d;
++ pi->header->crlf0[1] = pi->header->crlf1[1] = pi->header->crlf2[1] = 0x0a;
++
++ pi->header->eof[0] = 0x1a;
++ pi->header->reserve0[0] = 0;
++ pi->header->reserve1 = 0;
++
++ /* set palettes */
++ if (pi->n_pal > 0)
++ pi->header->flag = 1;
++ else
++ pi->header->flag = 0;
++}
++
++/*
++ * This function appends to existing pic2 file.
++ */
++static void pic2_append(pi)
++struct pic2_info *pi;
++{
++ int block;
++
++ block = pic2_find_block(pi);
++ while (block > 0)
++ block = pic2_next_block(pi);
++
++ if (block != 0)
++ pic2_error(pi, PIC2_APPEND);
++}
++
++/*
++ * These functions write the PIC2 header.
++ * pic2_write_header1:
++ * write palette data and comment.
++ * pic2_write_header2:
++ * write the terminate block and rest header.
++ * pic2_write_block_header:
++ * write the block header.
++ */
++static void pic2_write_header1(pi)
++struct pic2_info *pi;
++{
++ char *comment;
++
++ /* seek to block start position */
++ pic2_seek_file(pi, PIC2_HEADER_SIZE, SEEK_SET);
++
++ /* write palette */
++ if (pi->n_pal > 0) {
++ pic2_write_char(pi, pi->pal_bits);
++ pic2_write_short(pi, pi->n_pal);
++ pic2_write_file(pi, pi->pal, (size_t) (pi->n_pal * 3));
++ }
++ /* save comment */
++ comment = pi->comment;
++ if (pi->comment != NULL) {
++ for (comment = pi->comment; *comment; comment++) {
++ if (*comment == '\n') {
++ pic2_write_char(pi, '\r');
++ pic2_write_char(pi, '\n');
++ } else if (*comment != '\r')
++ pic2_write_char(pi, *comment);
++ }
++ pic2_write_char(pi, 0);
++ }
++ /* set the next block position */
++ pi->next_pos = pic2_tell_file(pi);
++ pi->header->size = pi->next_pos;
++}
++
++static void pic2_write_header2(pi)
++struct pic2_info *pi;
++{
++ pic2_seek_file(pi, pi->next_pos, SEEK_SET);
++
++ /* write terminate block */
++ pic2_write_long(pi, 0);
++ pic2_write_long(pi, 0);
++
++ /* set some header information */
++ if (pi->header->x_max < pi->x_max)
++ pi->header->x_max = pi->x_max;
++ if (pi->header->y_max < pi->x_max)
++ pi->header->y_max = pi->y_max;
++
++ pi->header->time = time(NULL);
++ pic2_seek_file(pi, 0, SEEK_SET);
++
++ /* write header image */
++ pic2_write_file(pi, pi->header->magic, 4);
++ pic2_write_file(pi, pi->header->name, 18);
++ pic2_write_file(pi, pi->header->subtitle, 8);
++ pic2_write_file(pi, pi->header->crlf0, 2);
++ pic2_write_file(pi, pi->header->title, 30);
++ pic2_write_file(pi, pi->header->crlf1, 2);
++ pic2_write_file(pi, pi->header->saver, 30);
++ pic2_write_file(pi, pi->header->crlf2, 2);
++ pic2_write_file(pi, pi->header->eof, 1);
++ pic2_write_file(pi, pi->header->reserve0, 1);
++ pic2_write_short(pi, pi->header->flag);
++ pic2_write_short(pi, pi->header->no);
++ pic2_write_long(pi, pi->header->time);
++ pic2_write_long(pi, pi->header->size);
++ pic2_write_short(pi, pi->header->depth);
++ pic2_write_short(pi, pi->header->x_aspect);
++ pic2_write_short(pi, pi->header->y_aspect);
++ pic2_write_short(pi, pi->header->x_max);
++ pic2_write_short(pi, pi->header->y_max);
++ pic2_write_long(pi, pi->header->reserve1);
++}
++
++static void pic2_write_block_header(pi)
++struct pic2_info *pi;
++{
++ pic2_write_file(pi, pi->block->id, 4);
++ pic2_write_long(pi, pi->block->size);
++ pic2_write_short(pi, pi->block->flag);
++ pic2_write_short(pi, pi->block->x_wid);
++ pic2_write_short(pi, pi->block->y_wid);
++ pic2_write_short(pi, pi->block->x_offset);
++ pic2_write_short(pi, pi->block->y_offset);
++ pic2_write_long(pi, pi->block->opaque);
++ pic2_write_long(pi, pi->block->reserve);
++}
++
++/*
++ * These functions implement the arithmetic-format compressor.
++ */
++#define pic2_arith_write_one_bit(pi) (pi->bs.bits++)
++
++static void pic2_arith_write_zero_bit(pi)
++struct pic2_info *pi;
++{
++ if (pi->bs.zero)
++ pic2_write_bits(pi, 0, 1);
++
++ while (pi->bs.bits--)
++ pic2_write_bits(pi, 1, 1);
++
++ pi->bs.bits = 0;
++ pi->bs.zero = 1;
++}
++
++static void pic2_arith_flush_bit_buf(pi)
++struct pic2_info *pi;
++{
++ int i;
++
++ for (i = 0; i < 16; i++) {
++ if (pi->cc & 0x8000)
++ pic2_arith_write_one_bit(pi);
++ else
++ pic2_arith_write_zero_bit(pi);
++ pi->cc <<= 1;
++ }
++ pic2_arith_write_zero_bit(pi);
++ pic2_flush_bits(pi);
++}
++
++static void pic2_arith_carry_bit(pi)
++struct pic2_info *pi;
++{
++ pic2_write_bits(pi, 1, 1);
++
++ if (pi->bs.bits == 0) {
++ pi->bs.zero = 0;
++ } else {
++ while (--pi->bs.bits)
++ pic2_write_bits(pi, 0, 1);
++ pi->bs.zero = 1;
++ }
++}
++
++static void pic2_arith_encode_bit(pi, n, c)
++struct pic2_info *pi;
++int n, c;
++{
++ int pp;
++ long *c_sum, *c_0_sum;
++
++ c_sum = (long *) pi->mulu_tab;
++ c_0_sum = c_sum + PIC2_ARITH_CONTEXT + 1;
++
++ if (pi->dd == 0) {
++ c_sum[c]++;
++ if (n == 0)
++ c_0_sum[c]++;
++ return;
++ }
++ pp = pi->mulu_tab[(pi->aa & 0x7f00) / 2 + c];
++ if (n != 0) {
++ pi->cc = pi->cc + pp;
++ if (pi->cc > 0xffff) {
++ pic2_arith_carry_bit(pi);
++ pi->cc = pi->cc & 0xffff;
++ }
++ pi->aa = pi->aa - pp;
++ while (pi->aa < 0x8000) {
++ if (pi->cc & 0x8000)
++ pic2_arith_write_one_bit(pi);
++ else
++ pic2_arith_write_zero_bit(pi);
++ pi->cc = (pi->cc * 2) & 0xffff;
++ pi->aa = pi->aa * 2;
++ }
++ } else {
++ pi->aa = pp;
++
++ while (pi->aa < 0x8000) {
++ if (pi->cc & 0x8000)
++ pic2_arith_write_one_bit(pi);
++ else
++ pic2_arith_write_zero_bit(pi);
++ pi->cc = (pi->cc * 2) & 0xffff;
++ pi->aa = pi->aa * 2;
++ }
++ }
++}
++
++static void pic2_arith_encode_nbyte(pi, n, c, max)
++struct pic2_info *pi;
++int n, c, max;
++{
++ short i;
++
++ for (i = 0; i < n; i++) {
++ pic2_arith_encode_bit(pi, 0, c + i);
++ }
++ if (n < max)
++ pic2_arith_encode_bit(pi, 1, c + n);
++}
++
++static void pic2_arith_encode_nn(pi, n, c)
++struct pic2_info *pi;
++int n, c;
++{
++ if (n < 1) {
++ pic2_arith_encode_bit(pi, 1, c);
++ } else if (n < 1 + 2) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 1, c + 1);
++ n -= 1;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ } else if (n < 1 + 2 + 4) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 1, c + 2);
++ n -= 1 + 2;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ } else if (n < 1 + 2 + 4 + 8) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 1, c + 3);
++ n -= 1 + 2 + 4;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ pic2_arith_encode_bit(pi, n & 4, c + 10);
++ } else if (n < 1 + 2 + 4 + 8 + 16) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 0, c + 3);
++ pic2_arith_encode_bit(pi, 1, c + 4);
++ n -= 1 + 2 + 4 + 8;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ pic2_arith_encode_bit(pi, n & 4, c + 10);
++ pic2_arith_encode_bit(pi, n & 8, c + 11);
++ } else if (n < 1 + 2 + 4 + 8 + 16 + 32) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 0, c + 3);
++ pic2_arith_encode_bit(pi, 0, c + 4);
++ pic2_arith_encode_bit(pi, 1, c + 5);
++ n -= 1 + 2 + 4 + 8 + 16;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ pic2_arith_encode_bit(pi, n & 4, c + 10);
++ pic2_arith_encode_bit(pi, n & 8, c + 11);
++ pic2_arith_encode_bit(pi, n & 16, c + 12);
++ } else if (n < 1 + 2 + 4 + 8 + 16 + 32 + 64) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 0, c + 3);
++ pic2_arith_encode_bit(pi, 0, c + 4);
++ pic2_arith_encode_bit(pi, 0, c + 5);
++ pic2_arith_encode_bit(pi, 1, c + 6);
++ n -= 1 + 2 + 4 + 8 + 16 + 32;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ pic2_arith_encode_bit(pi, n & 4, c + 10);
++ pic2_arith_encode_bit(pi, n & 8, c + 11);
++ pic2_arith_encode_bit(pi, n & 16, c + 12);
++ pic2_arith_encode_bit(pi, n & 32, c + 13);
++ } else if (n < 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128) {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 0, c + 3);
++ pic2_arith_encode_bit(pi, 0, c + 4);
++ pic2_arith_encode_bit(pi, 0, c + 5);
++ pic2_arith_encode_bit(pi, 0, c + 6);
++ pic2_arith_encode_bit(pi, 1, c + 7);
++ n -= 1 + 2 + 4 + 8 + 16 + 32 + 64;
++ pic2_arith_encode_bit(pi, n & 1, c + 8);
++ pic2_arith_encode_bit(pi, n & 2, c + 9);
++ pic2_arith_encode_bit(pi, n & 4, c + 10);
++ pic2_arith_encode_bit(pi, n & 8, c + 11);
++ pic2_arith_encode_bit(pi, n & 16, c + 12);
++ pic2_arith_encode_bit(pi, n & 32, c + 13);
++ pic2_arith_encode_bit(pi, n & 64, c + 14);
++ } else {
++ pic2_arith_encode_bit(pi, 0, c);
++ pic2_arith_encode_bit(pi, 0, c + 1);
++ pic2_arith_encode_bit(pi, 0, c + 2);
++ pic2_arith_encode_bit(pi, 0, c + 3);
++ pic2_arith_encode_bit(pi, 0, c + 4);
++ pic2_arith_encode_bit(pi, 0, c + 5);
++ pic2_arith_encode_bit(pi, 0, c + 6);
++ pic2_arith_encode_bit(pi, 0, c + 7);
++ }
++}
++
++static void pic2_arith_press_chain(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ int b, d;
++ pixel c;
++
++ b = -(pi->flag_now[x]);
++ c = pi->vram_now[x];
++ d = 0;
++
++ if (b < 0)
++ b = 0;
++
++ if (pi->flag_next[x] == 1 && pi->vram_next[x] == c) {
++ d = 1;
++ pi->flag_next[x] = -1;
++ } else if (pi->flag_next[x - 1] == 1 && pi->vram_next[x - 1] == c) {
++ d = 2;
++ pi->flag_next[x - 1] = -2;
++ } else if (pi->flag_next[x + 1] == 1 && pi->vram_next[x + 1] == c) {
++ d = 3;
++ pi->flag_next[x + 1] = -3;
++ } else if (pi->flag_next[x - 2] == 1 && pi->vram_next[x - 2] == c) {
++ d = 4;
++ pi->flag_next[x - 2] = -4;
++ } else if (pi->flag_next[x + 2] == 1 && pi->vram_next[x + 2] == c) {
++ if ((pi->flag_now[x + 2] != 0 && pi->vram_now[x + 2] == c)
++ || (pi->flag_now[x + 1] != 0 && pi->vram_now[x + 1] == c)
++ || (pi->flag_now[x + 3] != 0 && pi->vram_now[x + 3] == c)) {
++ pic2_arith_encode_nbyte(pi, 0, 80 + 6 * b, 5);
++ return;
++ }
++ d = 5;
++ pi->flag_next[x + 2] = -5;
++ }
++ pic2_arith_encode_nbyte(pi, d, 80 + 6 * b, 5);
++}
++
++static void pic2_arith_put_number(pi, xn, xa, xb)
++struct pic2_info *pi;
++int xn, xa, xb;
++{
++ short n;
++ byte maxcol;
++
++ maxcol = 0xff >> (8 - pi->header->depth / 3);
++
++ if (xa > ((int) maxcol >> 1)) {
++ if (xb > xa)
++ n = (xb - xa) * 2 - 1;
++ else if (xa - ((int) maxcol - xa) > xb)
++ n = maxcol - xb;
++ else
++ n = (xa - xb) * 2;
++ } else {
++ if (xb <= xa)
++ n = (xa - xb) * 2;
++ else if (2 * xa < xb)
++ n = xb;
++ else
++ n = (xb - xa) * 2 - 1;
++ }
++ pic2_arith_encode_nn(pi, n, xn);
++}
++
++static void pic2_arith_write_color(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ pixel c1, c2, cc;
++ short g0, r0, b0, r, g, b;
++ int i, j;
++ unsigned short k;
++ pixel *p, *pp;
++ short colbits;
++ pixel rmask, gmask, bmask;
++ byte maxcol;
++
++ colbits = pi->header->depth / 3;
++ rmask = (0xff >> (8 - colbits)) << (colbits * 2);
++ gmask = (0xff >> (8 - colbits)) << colbits;
++ bmask = (0xff >> (8 - colbits));
++ maxcol = (byte) bmask;
++
++ cc = pi->vram_now[x];
++ c1 = pi->vram_prev[x];
++ k = ((c1 >> ((colbits - 3) * 3)) & 0x1c0)
++ | ((c1 >> ((colbits - 3) * 2)) & 0x038)
++ | ((c1 >> (colbits - 3) ) & 0x007);
++ if (colbits == 5)
++ k = pic2_exchange_rg(k, 3);
++
++ p = pi->cache[k];
++ for (i = 0; i < (PIC2_ARITH_CACHE - 1); i++) {
++ if (cc == *p++)
++ break;
++ }
++ if (i == (PIC2_ARITH_CACHE - 1)) {
++ pp = p - 1;
++ for (j = i; j > 0; j--) {
++ *--p = *--pp;
++ }
++ pi->cache[k][0] = cc;
++ pic2_arith_encode_bit(pi, 1, pi->cache_hit_c);
++ pi->cache_hit_c = 16;
++
++ c2 = pi->vram_now[x - 1];
++ r = ((c1 & rmask) + (c2 & rmask)) >> (colbits * 2 + 1);
++ g = ((c1 & gmask) + (c2 & gmask)) >> (colbits + 1);
++ b = ((c1 & bmask) + (c2 & bmask)) >> ( 1);
++
++ r0 = (cc >> (colbits * 2)) & maxcol;
++ g0 = (cc >> colbits ) & maxcol;
++ b0 = cc & maxcol;
++
++ r = r + g0 - g;
++ if (r < 0)
++ r = 0;
++ else if (r > (short) maxcol)
++ r = maxcol;
++
++ b = b + g0 - g;
++ if (b < 0)
++ b = 0;
++ else if (b > (short) maxcol)
++ b = maxcol;
++
++ pic2_arith_put_number(pi, 32, g, g0);
++ pic2_arith_put_number(pi, 48, r, r0);
++ pic2_arith_put_number(pi, 64, b, b0);
++ } else {
++ *--p = pi->cache[k][i / 2];
++ pi->cache[k][i / 2] = pi->cache[k][0];
++ pi->cache[k][0] = cc;
++
++ pic2_arith_encode_bit(pi, 0, pi->cache_hit_c);
++ pi->cache_hit_c = 15;
++ pic2_arith_encode_nn(pi, i, 17);
++ }
++}
++
++static void pic2_arith_press_line2(pi)
++struct pic2_info *pi;
++{
++ int x, xw, ymax;
++ pixel cc;
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid -1;
++ cc = pi->vram_now[xw - 1]; /* last color */
++ pi->vram_next[-1] = cc;
++
++ /* mark change point */
++ for (x = 0; x < xw; x++)
++ if (cc != pi->vram_next[x]) {
++ pi->flag_next[x] = 1;
++ cc = pi->vram_next[x];
++ } else
++ pi->flag_next[x] = 0;
++
++ for (x = 0; x < xw; x++) {
++ if (pi->flag_now[x] == 1) { /* change point */
++ pi->flag2_now [x + 1]++;
++ pi->flag2_now [x + 2]++;
++ pi->flag2_next [x - 1]++;
++ pi->flag2_next [x ]++;
++ pi->flag2_next [x + 1]++;
++ pi->flag2_next2[x - 1]++;
++ pi->flag2_next2[x ]++;
++ pi->flag2_next2[x + 1]++;
++
++ /* write change point */
++ pic2_arith_encode_bit(pi, 1, pi->flag2_now[x]);
++
++ /* write color */
++ pic2_arith_write_color(pi, x);
++
++ /* if not last line, write chain */
++ if (pi->ynow - 1 < ymax)
++ pic2_arith_press_chain(pi, x);
++ } else if (pi->flag_now[x] == 0) /* not on chain */
++ /* write change point */
++ pic2_arith_encode_bit(pi, 0, pi->flag2_now[x]);
++ else /* on chain */
++ /* if not on last line, write next chain */
++ if (pi->ynow - 1 < ymax)
++ pic2_arith_press_chain(pi, x);
++ }
++}
++
++static int pic2_arith_press_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int i, xw, ymax;
++ long *c_sum, *c_0_sum;
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid -1;
++ c_sum = (long *) pi->mulu_tab;
++ c_0_sum = c_sum + PIC2_ARITH_CONTEXT +1;
++
++ pic2_handle_para(pi, 0);
++
++ xvbzero((char *) pi->flag2_next2 - 4,
++ (8 + xw) * sizeof(pi->flag2_next2[0]));
++
++ if (pi->ynow == 0) { /* first line */
++ int x;
++ pixel cc = 0;
++
++ if (pi->dd != 0) { /* compress pass */
++ unsigned short c_tab[PIC2_ARITH_CONTEXT];
++
++ for (i = 0; i < PIC2_ARITH_CONTEXT; i++) {
++ unsigned long a, b;
++ a = c_0_sum[i];
++ b = c_sum[i];
++ while (a > 32767) {
++ a /= 2;
++ b /= 2;
++ }
++ if (a == b)
++ c_tab[i] = 0xffff; /* b==0 here, too */
++ else
++ c_tab[i] = (65536 * a) / b; /* a < b, so less 65536 */
++ }
++ for (i = 0; i < 16384; i++) {
++ pi->mulu_tab[i] = (long) (i / 128 + 128) * (int) c_tab[i & 127] / 256;
++ if (pi->mulu_tab[i] == 0)
++ pi->mulu_tab[i] = 1; /* 0 is wrong */
++ }
++ for (i = 0; i < PIC2_ARITH_CONTEXT; i++)
++ pic2_write_short(pi, c_tab[i]);
++
++ xvbzero((char *) pi->vram_now, xw * sizeof(pi->vram_now[0]));
++ } else { /* statistical pass */
++ xvbzero((char *) c_0_sum, PIC2_ARITH_CONTEXT * sizeof(c_0_sum[0]));
++ xvbzero((char *) c_sum, PIC2_ARITH_CONTEXT * sizeof(c_sum[0]));
++ }
++
++ /* initialize flags */
++ xvbzero((char *) pi->cache, 8 * 8 * 8 * sizeof(pi->cache[0]));
++ xvbzero((char *) pi->cache_pos, 8 * 8 * 8 * sizeof(pi->cache_pos[0]));
++
++ xvbzero((char *) pi->flag2_next - 4,
++ (8 + xw) * sizeof(pi->flag2_next[0]));
++ xvbzero((char *) pi->flag2_next2 - 4,
++ (8 + xw) * sizeof(pi->flag2_next2[0]));
++
++ pi->vram_next[-1] = cc;
++ for (x = 0; x < xw; x++)
++ if (cc != pi->vram_next[x]) {
++ pi->flag_next[x] = 1;
++ cc = pi->vram_next[x];
++ } else
++ pi->flag_next[x] = 0;
++
++ pi->aa = 0xffff;
++ cc = 0;
++ pi->cache_hit_c = 16;
++ } else /* after second line */
++ pic2_arith_press_line2(pi);
++
++ if (pi->ynow == ymax) {
++ pi->ynow++;
++ pic2_handle_para(pi, 1);
++ pic2_handle_para(pi, 0);
++ pic2_arith_press_line2(pi);
++ }
++ /* line buffer for next data */
++ if (line != NULL)
++ *line = pi->vram_prev;
++
++ pi->ynow++;
++
++ if (pi->ynow - 1 < ymax) {
++ pic2_handle_para(pi, 1);
++ return (pi->ynow);
++ } else { /* end */
++ if (pi->dd == 0) { /* statistical pass */
++ pi->dd = 1;
++ pi->ynow = 0;
++ pic2_handle_para(pi, 1);
++ return (0);
++ } else {
++ pic2_handle_para(pi, 1);
++ pic2_arith_flush_bit_buf(pi);
++ return (-2); /* end */
++ }
++ }
++}
++
++static int pic2_arith_saver_init(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ pi->ynow = 0;
++
++ /* check the color depth */
++ if (pi->header->depth % 3)
++ pic2_error(pi, PIC2_DEPTH);
++
++ /* set next line function */
++ pi->next_line = pic2_arith_press_line;
++
++ if (line != NULL)
++ *line = pi->vram_next + 4;
++
++ pic2_seek_file(pi, pi->next_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++
++ /* clear bit field marker */
++ pi->bs.rest = 0;
++ pi->bs.cur = 0;
++ pi->bs.zero = 0;
++ pi->bs.bits = 0;
++
++ return (0);
++}
++
++/*
++ * These functions are fast pic2 format compressor.
++ */
++static void pic2_fast_write_length(pi, n)
++struct pic2_info *pi;
++int n;
++{
++ int a, b;
++ static const unsigned short len_data[8][2] = {
++ {1, 0},
++ {1, 0},
++ {3, 4},
++ {3, 5},
++ {5, 24},
++ {5, 25},
++ {5, 26},
++ {5, 27},
++ };
++
++ n++;
++ if (n < 8)
++ pic2_write_bits(pi, len_data[n][1], len_data[n][0]);
++ else {
++ a = 0;
++ b = 2;
++ while (n > b - 1) {
++ a = a + 1;
++ b = b * 2;
++ }
++ pic2_write_bits(pi, 0xfffffffe, a + 1);
++ if (a > 0)
++ pic2_write_bits(pi, n - b / 2, a);
++ }
++}
++
++static void pic2_fast_press_chain(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ int ymax;
++ pixel cc;
++
++ ymax = pi->block->y_wid -1;
++ cc = pi->vram_now[x];
++
++ if (pi->ynow - 1 == ymax) {
++ pic2_write_bits(pi, 0, 1);
++ return;
++ }
++ if (pi->flag_next[x] == 1 && pi->vram_next[x] == cc) {
++ pi->flag_next[x] = -1;
++ pic2_write_bits(pi, 3, 2);
++ } else if (pi->flag_next[x - 1] == 1 && pi->vram_next[x - 1] == cc) {
++ pi->flag_next[x - 1] = -1;
++ pic2_write_bits(pi, 11, 4);
++ } else if (pi->flag_next[x + 1] == 1 && pi->vram_next[x + 1] == cc) {
++ pi->flag_next[x + 1] = -1;
++ pic2_write_bits(pi, 9, 4);
++ } else if (pi->flag_next[x - 2] == 1 && pi->vram_next[x - 2] == cc) {
++ pi->flag_next[x - 2] = -1;
++ pic2_write_bits(pi, 10, 4);
++ } else if ((pi->flag_next[x + 2] == 1 && pi->vram_next[x + 2] == cc)
++ && !(pi->flag_now[x + 2] != 0 && pi->vram_now[x + 2] == cc)) {
++ pi->flag_next[x + 2] = -1;
++ pic2_write_bits(pi, 8, 4);
++ } else
++ pic2_write_bits(pi, 0, 1);
++}
++
++static void pic2_fast_press_chain2(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ int ymax;
++ pixel cc;
++ char *chain_buff;
++
++ ymax = pi->block->y_wid -1;
++ chain_buff = (char *) pi->mulu_tab;
++ cc = pi->vram_now[x];
++
++ if (pi->ynow - 1 == ymax) {
++ chain_buff[pi->cc++] = 0;
++ return;
++ }
++ if (pi->flag_next[x] == 1 && pi->vram_next[x] == cc) {
++ pi->flag_next[x] = -1;
++ chain_buff[pi->cc++] = 1;
++ } else if (pi->flag_next[x - 1] == 1 && pi->vram_next[x - 1] == cc) {
++ pi->flag_next[x - 1] = -1;
++ chain_buff[pi->cc++] = 2;
++ } else if (pi->flag_next[x + 1] == 1 && pi->vram_next[x + 1] == cc) {
++ pi->flag_next[x + 1] = -1;
++ chain_buff[pi->cc++] = 3;
++ } else if (pi->flag_next[x - 2] == 1 && pi->vram_next[x - 2] == cc) {
++ pi->flag_next[x - 2] = -1;
++ chain_buff[pi->cc++] = 4;
++ } else if ((pi->flag_next[x + 2] == 1 && pi->vram_next[x + 2] == cc)
++ && !(pi->flag_now[x + 2] != 0 && pi->vram_now[x + 2] == cc)) {
++ pi->flag_next[x + 2] = -1;
++ chain_buff[pi->cc++] = 5;
++ } else
++ chain_buff[pi->cc++] = 0;
++}
++
++static void pic2_fast_flush_chain(pi)
++struct pic2_info *pi;
++{
++ int i;
++ char *chain_buf;
++
++ chain_buf = (char *) pi->mulu_tab;
++ for (i = 0; i < pi->cc; i++){
++ switch (chain_buf[i]) {
++ case 0:
++ pic2_write_bits(pi, 0, 1);
++ break;
++ case 1:
++ pic2_write_bits(pi, 3, 2);
++ break;
++ case 2:
++ pic2_write_bits(pi, 11, 4);
++ break;
++ case 3:
++ pic2_write_bits(pi, 9, 4);
++ break;
++ case 4:
++ pic2_write_bits(pi, 10, 4);
++ break;
++ case 5:
++ pic2_write_bits(pi, 8, 4);
++ break;
++ }
++ }
++ pi->cc = 0;
++}
++
++static void pic2_fast_write_color(pi, x)
++struct pic2_info *pi;
++int x;
++{
++ pixel cc, bc;
++ unsigned short j, k, m;
++ short depth, colbits;
++ pixel (*cache)[PIC2_FAST_CACHE];
++
++ depth = pi->header->depth;
++ colbits = depth / 3;
++ cache = (pixel (*)[PIC2_FAST_CACHE]) pi->cache;
++
++ bc = pi->vram_now[x - 1];
++ bc = pic2_exchange_rg(bc, colbits);
++ k = pic2_shift_bits(bc, 8 - depth);
++ cc = pi->vram_now[x];
++ m = pi->cache_pos[k];
++
++ for (j = 0; j < PIC2_FAST_CACHE; j++)
++ if (cache[k][(m + j) & (PIC2_FAST_CACHE - 1)] == cc)
++ break;
++
++ if (j == PIC2_FAST_CACHE) {
++ m = (m - 1) & (PIC2_FAST_CACHE - 1);
++ pi->cache_pos[k] = m;
++ cache[k][m] = cc;
++
++ cc = pic2_exchange_rg(cc, colbits);
++ pic2_write_bits(pi, 0, 1);
++ pic2_write_bits(pi, cc, depth);
++ } else {
++ pic2_write_bits(pi, 1, 1);
++ pic2_write_bits(pi, j, 6);
++ }
++}
++
++static void pic2_fast_press_line2(pi)
++struct pic2_info *pi;
++{
++ int x, xw;
++ pixel cc;
++
++ xw = pi->block->x_wid;
++ cc = pi->vram_now[xw - 1]; /* last color */
++ pi->vram_next[-1] = cc;
++
++ /* mark change point */
++ for (x = 0; x < xw; x++)
++ if (cc != pi->vram_next[x]) {
++ pi->flag_next[x] = 1;
++ cc = pi->vram_next[x];
++ } else
++ pi->flag_next[x] = 0;
++
++ for (x = 0; x < xw; x++)
++ if (pi->flag_now[x] == 1) { /* change point */
++ if (pi->aa >= 1023)
++ pi->aa++;
++ pic2_fast_write_length(pi, pi->aa);
++ pic2_fast_flush_chain(pi);
++ pi->aa = 0;
++ pic2_fast_write_color(pi, x);
++ pic2_fast_press_chain(pi, x);
++ } else if (pi->flag_now[x] == 0) {
++ pi->aa++;
++ } else {
++ pic2_fast_press_chain2(pi, x);
++ if (pi->cc == 1023) {
++ pic2_fast_write_length(pi, 1023);
++ pic2_fast_flush_chain(pi);
++ pi->aa = 0;
++ }
++ }
++}
++
++static int pic2_fast_press_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int xw, ymax;
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid -1;
++
++ pic2_handle_para(pi, 0);
++
++ if (pi->ynow == 0) { /* first line */
++ int x;
++ pixel cc = 0;
++
++ /* initialize flags */
++ xvbzero((char *) pi->cache, 256 * sizeof(pi->cache[0]));
++ xvbzero((char *) pi->cache_pos,
++ PIC2_FAST_CACHE * sizeof(pi->cache_pos[0]));
++
++ /* mark change point */
++ pi->vram_next[-1] = cc;
++ for (x = 0; x < xw; x++)
++ if (cc != pi->vram_next[x]) {
++ pi->flag_next[x] = 1;
++ cc = pi->vram_next[x];
++ } else
++ pi->flag_next[x] = 0;
++
++ pi->cc = 0;
++ pi->aa = 0;
++ } else /* after second line */
++ pic2_fast_press_line2(pi);
++
++ if (pi->ynow == ymax) {
++ pi->ynow++;
++ pic2_handle_para(pi, 1);
++ pic2_handle_para(pi, 0);
++ pic2_fast_press_line2(pi);
++ }
++ /* line buffer for next data */
++ if (line != NULL)
++ *line = pi->vram_prev;
++
++ pi->ynow++;
++
++ if (pi->ynow - 1 < ymax) {
++ pic2_handle_para(pi, 1);
++ return (pi->ynow);
++ } else { /* end */
++ pic2_handle_para(pi, 1);
++ if (pi->aa >= 1023)
++ pi->aa++;
++ pic2_fast_write_length(pi, pi->aa);
++ pic2_fast_flush_chain(pi);
++ return (-2); /* end */
++ }
++}
++
++static int pic2_fast_saver_init(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ pi->ynow = 0;
++
++ /* check the color depth */
++ if (pi->header->depth % 3)
++ pic2_error(pi, PIC2_DEPTH);
++
++ /* set next line function */
++ pi->next_line = pic2_fast_press_line;
++ if (line != NULL)
++ *line = pi->vram_next + 4;
++
++ pic2_seek_file(pi, pi->next_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++
++ /* clear bit field marker */
++ pi->bs.rest = 0;
++ pi->bs.cur = 0;
++
++ return (0);
++}
++
++/*
++ * These functions are beta pic2 format compressor.
++ */
++static int pic2_beta_press_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int i, xw, ymax;
++ byte *p;
++ pixel *pc;
++ short depth, pixbyte, colbits;
++
++ depth = pi->header->depth;
++ pixbyte = depth / 8 + ((depth % 8) > 0);
++ colbits = depth / 3;
++
++ xw = pi->block->x_wid;
++ ymax = pi->block->y_wid - 1;
++
++ pc = pi->vram_now;
++ p = (byte *) pi->vram_prev;
++ if (pixbyte == 3) {
++ for (i = 0; i < xw; i++, pc++) {
++ *p++ = *pc >> 16;
++ *p++ = *pc >> 8;
++ *p++ = *pc;
++ }
++ pic2_write_file(pi, pi->vram_prev, (size_t) (xw * 3));
++ } else if (pixbyte == 2) {
++ if (strncmp(pi->block->id, "P2BM", 4) == 0)
++ for (i = 0; i < xw; i++, pc++) {
++ if (colbits == 5) {
++ *pc = pic2_exchange_rg(*pc, colbits);
++ *pc <<= 1;
++ }
++ *p++ = *pc >> 8;
++ *p++ = *pc;
++ }
++ else
++ for (i = 0; i < xw; i++, pc++) {
++ if (colbits == 5) {
++ *pc = pic2_exchange_rg(*pc, colbits);
++ *pc <<= 1;
++ }
++ *p++ = *pc;
++ *p++ = *pc >> 8;
++ }
++ pic2_write_file(pi, pi->vram_prev, (size_t) (xw * 2));
++ } else {
++ for (i = 0; i < xw; i++, pc++)
++ *p++ = *pc;
++ pic2_write_file(pi, pi->vram_prev, (size_t) xw);
++ }
++ if (line != NULL)
++ *line = pi->vram_now;
++
++ pi->ynow++;
++ if (pi->ynow > ymax)
++ return (-2);
++ return (pi->ynow);
++}
++
++static int pic2_beta_saver_init(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ pi->ynow = 0;
++
++ *line = pi->vram_now;
++ pi->next_line = pic2_beta_press_line;
++ pic2_seek_file(pi, pi->next_pos + PIC2_BLOCK_HEADER_SIZE, SEEK_SET);
++ return (0);
++}
++
++/*
++ * This function saves compressed data.
++ */
++static void pic2_write_data(pi, data, ptype, x_offset, y_offset, w, h,
++ rmap, gmap, bmap, type, depth)
++struct pic2_info *pi;
++byte *data;
++int ptype;
++int x_offset, y_offset;
++int w, h;
++byte *rmap, *gmap, *bmap;
++int type, depth;
++{
++ int i, line;
++ pixel *linep;
++ short colbits;
++
++ colbits = pi->header->depth / 3;
++
++ line = pic2_save_block(pi, &linep, x_offset, y_offset, w, h,
++ form_tab[type].id, 0xffffffff);
++ while (line >= 0) {
++ byte r, g, b;
++ int pic_idx;
++
++ pic_idx = line * w * ((ptype == PIC24) ? 3 : 1);
++
++ for (i = 0; i < w; i++) {
++ if (ptype != PIC24) {
++ r = rmap[data[pic_idx]];
++ g = gmap[data[pic_idx]];
++ b = bmap[data[pic_idx]];
++ pic_idx++;
++ } else {
++ r = data[pic_idx++];
++ g = data[pic_idx++];
++ b = data[pic_idx++];
++ }
++ if (pi->writing_grey)
++ r = g = b = MONO(r, g, b);
++
++ r = pic2_convert_color_bits(r, 8, colbits);
++ g = pic2_convert_color_bits(g, 8, colbits);
++ b = pic2_convert_color_bits(b, 8, colbits);
++
++ linep[i] = ((pixel) r << (colbits * 2))
++ | ((pixel) g << colbits )
++ | ((pixel) b );
++ }
++ line = pic2_next_line(pi, &linep);
++ WaitCursor();
++ }
++}
++
++/*
++ * This function compresses/extracts one line buffer.
++ */
++static int pic2_next_line(pi, line)
++struct pic2_info *pi;
++pixel **line;
++{
++ int res;
++
++ res = pi->next_line(pi, line);
++ if (res == -2) {
++ if (pi->mode == PIC2_WRITE_MODE) {
++ long new_pos;
++
++ new_pos = pic2_tell_file(pi);
++ pi->block->size = new_pos - pi->next_pos;
++ pic2_seek_file(pi, pi->next_pos, SEEK_SET);
++ pic2_write_block_header(pi);
++ pi->next_pos = new_pos;
++ if (DEBUG)
++ pic2_show_pic2_info(pi);
++ }
++ pic2_free_buffer(pi);
++ }
++ return (res);
++}
++
++/*
++ * These functions find the pic2 image block.
++ * pic2_next_block:
++ * moves the file pointer to the next image block.
++ * pic2_find_block:
++ * finds the first image block and moves the file pointer there.
++ */
++static int pic2_next_block(pi)
++struct pic2_info *pi;
++{
++ int i;
++
++ if (pi->mode != PIC2_READ_MODE)
++ return (-1);
++
++ /* go to block for read */
++ pic2_seek_file(pi, pi->next_pos, SEEK_SET);
++
++ /* read the head of block header */
++ pic2_read_block_header1(pi);
++
++ /* end block ? */
++ if (pi->block->id[0] == 0)
++ return (0);
++
++ /* set current block */
++ pi->block_pos = pi->next_pos;
++
++ /* set next block */
++ pi->next_pos += pi->block->size;
++
++ /* check block id */
++ for (i = 0; i < n_form_tab; i++) {
++ if (xvbcmp(pi->block->id, form_tab[i].id, (size_t) 4) == 0)
++ break;
++ }
++ if (i == n_form_tab)
++ return (2);
++
++ /* read the rest of block header */
++ pic2_read_block_header2(pi);
++
++ if (pi->block->x_offset + pi->block->x_wid > pi->x_max)
++ pi->x_max = pi->block->x_offset + pi->block->x_wid;
++
++ if (pi->block->y_offset + pi->block->y_wid > pi->y_max)
++ pi->y_max = pi->block->y_offset + pi->block->y_wid;
++
++ if (DEBUG)
++ pic2_show_pic2_info(pi);
++ return (1);
++}
++
++static int pic2_find_block(pi)
++struct pic2_info *pi;
++{
++ if (pi->mode != PIC2_READ_MODE)
++ return (-1);
++
++ pi->next_pos = pi->header->size;
++ return (pic2_next_block(pi));
++}
++
++/*
++ * These functions load/save the pic2 image block.
++ * pic2_load_block:
++ * initializes loader information with current block information.
++ * pic2_save_block:
++ * initializes saver information.
++ */
++static int pic2_load_block(pi)
++struct pic2_info *pi;
++{
++ int i;
++
++ for (i = 0; i < n_form_tab; i++) {
++ if (xvbcmp(pi->block->id, form_tab[i].id, (size_t) 4) == 0)
++ break;
++ }
++ if (i == n_form_tab)
++ return (2);
++
++ pic2_alloc_buffer(pi);
++ return (form_tab[i].loader_init(pi));
++}
++
++static int pic2_save_block(pi, line, x, y, xw, yw, id, opaque)
++struct pic2_info *pi;
++pixel **line;
++int x, y, xw, yw;
++char *id;
++pixel opaque;
++{
++ int i;
++
++ for (i = 0; i < n_form_tab; i++) {
++ if (xvbcmp(id, form_tab[i].id, (size_t) 4) == 0)
++ break;
++ }
++ if (i == n_form_tab)
++ return (2);
++
++ strncpy(pi->block->id, id, 4);
++ pi->block->x_wid = xw;
++ pi->block->y_wid = yw;
++ pi->block->x_offset = x;
++ pi->block->y_offset = y;
++ pi->block->reserve = 0;
++
++ if (x < 0)
++ x = 0;
++ if (y < 0)
++ y = 0;
++ if (x + xw > pi->x_max)
++ pi->x_max = x + xw;
++ if (y + yw > pi->y_max)
++ pi->y_max = y + yw;
++
++ if (opaque != 0xffffffff) {
++ pi->block->flag = 1;
++ pi->block->opaque = opaque;
++ } else {
++ pi->block->flag = 0;
++ pi->block->opaque = 0;
++ }
++ pic2_alloc_buffer(pi);
++
++ return (form_tab[i].saver_init(pi, line));
++}
++
++/*
++ * These functions set/get palettes.
++ * pic2_read_palette:
++ * copy the palettes from pic2_info to PICINFO.
++ * pic2_write_palette:
++ * copy the palettes from PICINFO to pic2_info.
++ */
++#ifndef PIC2_IGNORE_UNUSED_FUNCTIONS
++static void pic2_read_palette(pi, r, g, b)
++struct pic2_info *pi;
++byte *r, *g, *b;
++{
++ int i;
++
++ if (pi->n_pal > 256)
++ pi->n_pal = 256;
++
++ if (pi->pal_bits > 8)
++ pi->pal_bits = 8;
++
++ for (i = 0; i < pi->n_pal; i++) {
++ *r++ =pic2_convert_color_bits(pi->pal[i][0] >> (8 - pi->pal_bits),
++ pi->pal_bits, 8);
++ *g++ =pic2_convert_color_bits(pi->pal[i][1] >> (8 - pi->pal_bits),
++ pi->pal_bits, 8);
++ *b++ =pic2_convert_color_bits(pi->pal[i][2] >> (8 - pi->pal_bits),
++ pi->pal_bits, 8);
++ }
++}
++
++static void pic2_write_palette(pi, n_pal, pal_bits, r, g, b)
++struct pic2_info *pi;
++int n_pal, pal_bits;
++byte *r, *g, *b;
++{
++ int i;
++
++ if (n_pal > 256)
++ pi->n_pal = 256;
++ else
++ pi->n_pal = n_pal;
++
++ if (pal_bits > 8)
++ pi->pal_bits = 8;
++ else
++ pi->pal_bits = pal_bits;
++
++ for (i = 0; i < n_pal; i++) {
++ pi->pal[i][0] = pic2_convert_color_bits(*r++, 8, pal_bits)
++ << (8 - pal_bits);
++ pi->pal[i][1] = pic2_convert_color_bits(*g++, 8, pal_bits)
++ << (8 - pal_bits);
++ pi->pal[i][2] = pic2_convert_color_bits(*b++, 8, pal_bits)
++ << (8 - pal_bits);
++ }
++}
++#endif /* PIC2_IGNORE_UNUSED_FUNCTIONS */
++
++/*
++ * These functions handle color bits.
++ * pic2_convert_color_bits:
++ * converts color bits.
++ * pic2_pad_color_bits:
++ * pads color bits.
++ * pic2_reduce_color_bits:
++ * reduces color bits.
++ * pic2_exchange_rg:
++ * exchanges red and green values.
++ */
++static byte pic2_convert_color_bits(c, from, to)
++int c, from, to;
++{
++ if (from == to)
++ return ((byte) c);
++ else if (from < to)
++ return (pic2_pad_color_bits(c, from, to));
++ else
++ return (pic2_reduce_color_bits(c, from, to));
++}
++
++static byte pic2_pad_color_bits(c, from, to)
++int c, from, to;
++{
++ byte p = 0;
++
++ do {
++ to -= from;
++ p |= pic2_shift_bits(c, to);
++ } while (to >= 0);
++ return (p);
++}
++
++static byte pic2_reduce_color_bits(c, from, to)
++int c, from, to;
++{
++ return ((byte) (c >> (from - to)));
++}
++
++static pixel pic2_exchange_rg(p, colbits)
++pixel p;
++int colbits;
++{
++ pixel rmask, gmask, bmask;
++
++ rmask = (0xff >> (8 - colbits)) << (colbits * 2);
++ gmask = (0xff >> (8 - colbits)) << colbits;
++ bmask = (0xff >> (8 - colbits));
++
++ p = ((p << colbits) & rmask)
++ | ((p >> colbits) & gmask)
++ | ( p & bmask);
++ return (p);
++}
++
++/*
++ * This function handles work memory buffer.
++ */
++static void pic2_handle_para(pi, mode)
++struct pic2_info *pi;
++int mode;
++{
++ static pixel *vram_prev, *vram_now, *vram_next;
++ static short *flag_now, *flag_next;
++ static short *flag2_now, *flag2_next, *flag2_next2;
++
++ switch (mode) {
++ case 0:
++ vram_prev = pi->vram_prev;
++ vram_now = pi->vram_now;
++ vram_next = pi->vram_next;
++ flag_now = pi->flag_now;
++ flag_next = pi->flag_next;
++ flag2_now = pi->flag2_now;
++ flag2_next = pi->flag2_next;
++ flag2_next2 = pi->flag2_next2;
++ pi->vram_prev += 4;
++ pi->vram_now += 4;
++ pi->vram_next += 4;
++ pi->flag_now += 4;
++ pi->flag_next += 4;
++ pi->flag2_now += 4;
++ pi->flag2_next += 4;
++ pi->flag2_next2 += 4;
++ break;
++ case 1:
++ pi->vram_prev = vram_now;
++ pi->vram_now = vram_next;
++ pi->vram_next = vram_prev;
++ pi->flag_now = flag_next;
++ pi->flag_next = flag_now;
++ pi->flag2_now = flag2_next;
++ pi->flag2_next = flag2_next2;
++ pi->flag2_next2 = flag2_now;
++ break;
++ }
++}
++
++/*
++ * These functions alloc/free work memory.
++ * pic2_alloc_buffer:
++ * alloc work memory buffer.
++ * pic2_free_buffer:
++ * free work memory buffer.
++ */
++static int pic2_alloc_buffer(pi)
++struct pic2_info *pi;
++{
++ int wid;
++ byte *p;
++
++ if (pi->buf != NULL)
++ return (-1);
++
++ wid = pi->block->x_wid;
++
++ p = pi->buf = (byte *) pic2_new((wid + 8) * sizeof(pixel) * 3 // GRR POSSIBLE OVERFLOW / FIXME
++ + sizeof(pi->cache[0]) * 8 * 8 * 8
++ + sizeof(pi->cache_pos[0]) * 8 * 8 * 8
++ + sizeof(pi->mulu_tab[0]) * 16384
++ + sizeof(pi->flag_now[0]) * ((wid+8) * 5),
++ "pic2_alloc_buffer");
++
++ pi->vram_prev = (pixel *) p;
++ p += (wid + 8) * sizeof(pixel);
++ pi->vram_now = (pixel *) p;
++ p += (wid + 8) * sizeof(pixel);
++ pi->vram_next = (pixel *) p;
++ p += (wid + 8) * sizeof(pixel);
++ pi->cache = (pixel (*)[PIC2_ARITH_CACHE]) p;
++ p += sizeof(pi->cache[0]) * 8 * 8 * 8;
++ pi->cache_pos = (unsigned short *) p;
++ p += sizeof(pi->cache_pos[0]) * 8 * 8 * 8;
++ pi->mulu_tab = (unsigned short *) p;
++ p += sizeof(pi->mulu_tab[0]) * 16384;
++ pi->flag_now = (short *) p;
++ p += sizeof(pi->flag_now[0]) * (wid + 8);
++ pi->flag_next = (short *) p;
++ p += sizeof(pi->flag_next[0]) * (wid + 8);
++ pi->flag2_now = (short *) p;
++ p += sizeof(pi->flag2_now[0]) * (wid + 8);
++ pi->flag2_next = (short *) p;
++ p += sizeof(pi->flag2_next[0]) * (wid + 8);
++ pi->flag2_next2 = (short *) p;
++ p += sizeof(pi->flag2_next2[0]) * (wid + 8);
++ return (0);
++}
++
++static void pic2_free_buffer(pi)
++struct pic2_info *pi;
++{
++ free(pi->buf);
++ pi->buf = NULL;
++}
++
++/*
++ * These functions handle the file pointer.
++ * pic2_seek_file:
++ * moves the file pointer.
++ * pic2_tell_file:
++ * tells the location of the file pointer.
++ */
++static long pic2_seek_file(pi, offset, whence)
++struct pic2_info *pi;
++long offset;
++int whence;
++{
++ long n;
++
++ n = fseek(pi->fp, offset, whence);
++ if (n < 0)
++ pic2_file_error(pi, PIC2_CORRUPT);
++
++ return (n);
++}
++
++static long pic2_tell_file(pi)
++struct pic2_info *pi;
++{
++ return (ftell(pi->fp));
++}
++
++/*
++ * These functions handle file.
++ * pic2_read_file:
++ * reads data from the file.
++ * pic2_read_long:
++ * reads long word data from the file and converts to internal expression.
++ * pic2_read_short:
++ * reads word data from the file and converts to internal expression.
++ * pic2_read_char:
++ * reads byte data from the file.
++ * pic2_write_file:
++ * writes data to the file.
++ * pic2_write_long:
++ * converts long word data to common expression and writes to the file.
++ * pic2_write_short:
++ * converts word data to common expression and writes to the file.
++ * pic2_write_char:
++ * writes byte data to the file.
++ */
++static int pic2_read_file(pi, buf, size)
++struct pic2_info *pi;
++void *buf;
++size_t size;
++{
++ if (fread(buf, (size_t) 1, size, pi->fp) < size)
++ pic2_file_error(pi, PIC2_CORRUPT);
++ return (0);
++}
++
++static long pic2_read_long(pi)
++struct pic2_info *pi;
++{
++ byte buf[4];
++
++ if (fread(buf, (size_t) 4, (size_t) 1, pi->fp) < 1)
++ pic2_file_error(pi, PIC2_CORRUPT);
++ return (pic2_cextolong(buf));
++}
++
++static short pic2_read_short(pi)
++struct pic2_info *pi;
++{
++ byte buf[2];
++
++ if (fread(buf, (size_t) 2, (size_t) 1, pi->fp) < 1)
++ pic2_file_error(pi, PIC2_CORRUPT);
++ return (pic2_cextoshort(buf));
++}
++
++static char pic2_read_char(pi)
++struct pic2_info *pi;
++{
++ int c;
++
++ if ((c = fgetc(pi->fp)) == EOF)
++ pic2_file_error(pi, PIC2_CORRUPT);
++ return ((char) c);
++}
++
++static int pic2_write_file(pi, buf, size)
++struct pic2_info *pi;
++void *buf;
++size_t size;
++{
++ if (fwrite(buf, (size_t) 1, size, pi->fp) < size)
++ pic2_error(pi, PIC2_WRITE);
++ return (0);
++}
++
++static int pic2_write_long(pi, n)
++struct pic2_info *pi;
++long n;
++{
++ byte buf[4];
++
++ pic2_longtocex(buf, n);
++ if (fwrite(buf, (size_t) 4, (size_t) 1, pi->fp) < 1)
++ pic2_error(pi, PIC2_WRITE);
++ return (0);
++}
++
++static int pic2_write_short(pi, n)
++struct pic2_info *pi;
++int n;
++{
++ byte buf[2];
++
++ pic2_shorttocex(buf, n);
++ if (fwrite(buf, (size_t) 2, (size_t) 1, pi->fp) < 1)
++ pic2_error(pi, PIC2_WRITE);
++ return (0);
++}
++
++static int pic2_write_char(pi, c)
++struct pic2_info *pi;
++int c;
++{
++ if (fputc(c, pi->fp) == EOF)
++ pic2_error(pi, PIC2_WRITE);
++ return (0);
++}
++
++/*
++ * These functions access the bit stream.
++ * pic2_read_bits:
++ * reads the specified bits from the file.
++ * pic2_write_bits:
++ * writes the specified bits to the file.
++ * pic2_flush_bits:
++ * flushes bit buffer to the file.
++ */
++static unsigned long pic2_read_bits(pi, bits)
++struct pic2_info *pi;
++int bits;
++{
++ unsigned long r = 0;
++
++ while (bits > 0) {
++ while (pi->bs.rest > 0 && bits > 0) {
++ r = (r << 1) | (pi->bs.cur & 0x80 ? 1 : 0);
++ pi->bs.cur <<= 1;
++ pi->bs.rest--;
++ bits--;
++ }
++ if (bits > 0) {
++ int c;
++ if ((c = fgetc(pi->fp)) == EOF)
++ pic2_file_error(pi, PIC2_CORRUPT);
++ pi->bs.cur = (byte) c;
++ pi->bs.rest = 8;
++ }
++ }
++ return r;
++}
++
++static void pic2_write_bits(pi, dat, bits)
++struct pic2_info *pi;
++unsigned long dat;
++int bits;
++{
++ unsigned long dat_mask = 1 << (bits - 1);
++
++ while (bits > 0) {
++ while (pi->bs.rest < 8 && bits > 0) {
++ pi->bs.cur <<= 1;
++ if (dat & dat_mask)
++ pi->bs.cur |= 1;
++ pi->bs.rest++;
++ bits--;
++ dat_mask >>= 1;
++ }
++ if (pi->bs.rest >= 8) {
++ if ((fputc((int) pi->bs.cur, pi->fp)) == EOF)
++ pic2_error(pi, PIC2_WRITE);
++ pi->bs.cur = 0;
++ pi->bs.rest = 0;
++ }
++ }
++}
++
++static void pic2_flush_bits(pi)
++struct pic2_info *pi;
++{
++ if (pi->bs.rest < 8) {
++ pi->bs.cur <<= 8 - pi->bs.rest;
++ if (fputc((int) pi->bs.cur, pi->fp) == EOF)
++ pic2_error(pi, PIC2_WRITE);
++ pi->bs.cur = 0;
++ pi->bs.rest = 0;
++ }
++}
++
++/*
++ * These functions initialize or clean up structures.
++ * pic2_init_info:
++ * initializes a pic2_info structure.
++ * pic2_cleanup_pic2_info:
++ * cleans up a pic_info structure.
++ * pic2_cleanup_pinfo:
++ * cleans up a PICINFO structure.
++ */
++static void pic2_init_info(pi)
++struct pic2_info *pi;
++{
++ xvbzero((char *) pi, sizeof(struct pic2_info));
++ pi->header = pic2_new(sizeof(struct pic2_header), "pic2_init_info#1");
++ pi->block = pic2_new(sizeof(struct pic2_block), "pic2_init_info#2");
++}
++
++static void pic2_cleanup_pic2_info(pi, writing)
++struct pic2_info *pi;
++int writing;
++{
++ if (!writing && pi->fp)
++ fclose(pi->fp);
++ if (pi->header)
++ free(pi->header);
++ if (pi->block)
++ free(pi->block);
++ pi->fp = NULL;
++ pi->header = NULL;
++ pi->block = NULL;
++ pi->comment = NULL;
++}
++
++static void pic2_cleanup_pinfo(pinfo)
++PICINFO *pinfo;
++{
++ if (pinfo->pic){
++ free(pinfo->pic);
++ pinfo->pic = NULL;
++ }
++ if (pinfo->comment){
++ free(pinfo->comment);
++ pinfo->comment = NULL;
++ }
++}
++
++/*
++ * Error Handlers.
++ * pic2_memory_error:
++ * shows an error message and terminates.
++ * pic2_error:
++ * shows a non-file error message and jumps to the entry for errors.
++ * pic2_file_error:
++ * shows a file error message and jumps to the entry for errors.
++ */
++static void pic2_memory_error(scm, fn)
++char *scm, *fn;
++{
++ char buf[128];
++ sprintf(buf, "%s: can't allocate memory. (%s)", scm, fn);
++ FatalError(buf);
++}
++
++static void pic2_error(pi, mn)
++struct pic2_info *pi;
++int mn;
++{
++ SetISTR(ISTR_WARNING, "%s", pic2_msgs[mn]);
++ longjmp(pi->jmp, 1);
++}
++
++static void pic2_file_error(pi, mn)
++ struct pic2_info *pi;
++ int mn;
++{
++ if (feof(pi->fp))
++ SetISTR(ISTR_WARNING, "%s (end of file)", pic2_msgs[mn]);
++ else
++ SetISTR(ISTR_WARNING, "%s (%s)", pic2_msgs[mn], ERRSTR(errno));
++ longjmp(pi->jmp, 1);
++}
++
++static void pic2_show_pic2_info(pi)
++ struct pic2_info *pi;
++{
++ fprintf(stderr, "file size: %ld.\n", pi->fsize);
++ fprintf(stderr, "full image size: %dx%d\n", pi->x_max, pi->y_max);
++ fprintf(stderr, "number of palettes: %d\n", pi->n_pal);
++ fprintf(stderr, "depth of palettes: %d\n", pi->pal_bits);
++ fprintf(stderr, "current block position: %ld\n", pi->block_pos);
++ fprintf(stderr, "next block position: %ld\n\n", pi->next_pos);
++
++ fprintf(stderr, "header flag: %x\n", pi->header->flag);
++ fprintf(stderr, "header size: %ld\n", pi->header->size);
++ fprintf(stderr, "x_aspect: %d, y_aspect: %d\n",
++ pi->header->x_aspect, pi->header->y_aspect);
++ fprintf(stderr, "number of color bits: %d\n\n", pi->header->depth);
++
++ fprintf(stderr, "image block id: %s\n", pi->block->id);
++ fprintf(stderr, "image block size: %ld\n", pi->block->size);
++ fprintf(stderr, "block flag: %x\n", pi->block->flag);
++
++ fprintf(stderr, "block image size: %dx%d\n",
++ pi->block->x_wid, pi->block->y_wid);
++ fprintf(stderr, "x_offset: %d\n", pi->block->x_offset);
++ fprintf(stderr, "y_offset: %d\n", pi->block->y_offset);
++ fprintf(stderr, "opaque color: %lx\n\n", pi->block->opaque);
++}
++
++/*
++ * This function is similar to strncpy.
++ * But this pads with whitespace after the null character.
++ */
++static char *pic2_strncpy(dest, src, n)
++char *dest, *src;
++size_t n;
++{
++ char *r;
++
++ r = dest;
++ while (n--)
++ if ((src != NULL) && (*src != '\r') && (*src != '\n') && *src)
++ *dest++ = *src++;
++ else
++ *dest++ = ' ';
++ return (r);
++}
++
++/*
++ * These functions create a memory block.
++ */
++static void *pic2_malloc(size, fn)
++size_t size;
++char *fn;
++{
++ void *p;
++
++ p = (void *) malloc(size);
++ if (p == NULL)
++ pic2_memory_error("malloc", fn);
++ return (p);
++}
++
++static void *pic2_new(size, fn)
++size_t size;
++char *fn;
++{
++ void *p;
++
++ p = (void *) pic2_malloc(size, fn);
++ xvbzero((char *) p, size);
++ return (p);
++}
++
++
++
++
++/**** Stuff for PIC2Dialog box ****/
++
++#define TWIDE 320
++#define THIGH 178
++#define T_NBUTTS 2
++#define T_BOK 0
++#define T_BCANC 1
++#define BUTTH 24
++
++static void drawTD PARM((int,int,int,int));
++static void clickTD PARM((int,int));
++static void doCmd PARM((int));
++static void writePIC2 PARM((void));
++
++/* local variables */
++static FILE *fp;
++static char *filename;
++static int colorType;
++static int append;
++static int x_offset;
++static int y_offset;
++static BUTT tbut[T_NBUTTS];
++static RBUTT *typeRB;
++static RBUTT *depthRB;
++
++
++
++/***************************************************/
++void CreatePIC2W()
++{
++ int y;
++
++ pic2W = CreateWindow("xv pic2", "XVpic2", NULL,
++ TWIDE, THIGH, infofg, infobg, 0);
++ if (!pic2W)
++ FatalError("can't create pic2 window!");
++
++ XSelectInput(theDisp, pic2W,
++ ExposureMask | ButtonPressMask | KeyPressMask);
++
++ BTCreate(&tbut[T_BOK], pic2W, TWIDE-140-1, THIGH-10-BUTTH-1, 60, BUTTH,
++ "Ok", infofg, infobg, hicol, locol);
++
++ BTCreate(&tbut[T_BCANC], pic2W, TWIDE-70-1, THIGH-10-BUTTH-1, 60, BUTTH,
++ "Cancel", infofg, infobg, hicol, locol);
++
++ y = 55;
++ typeRB = RBCreate(NULL, pic2W, 36, y, "P2SS",
++ infofg, infobg,hicol,locol);
++ RBCreate(typeRB, pic2W, 36, y+18, "P2SF",
++ infofg, infobg,hicol,locol);
++ RBCreate(typeRB, pic2W, 36, y+36, "P2BM",
++ infofg, infobg, hicol, locol);
++ RBCreate(typeRB, pic2W, 36, y+54, "P2BI",
++ infofg, infobg, hicol, locol);
++
++ depthRB = RBCreate(NULL, pic2W, TWIDE/2-16, y, " 3bit",
++ infofg, infobg,hicol,locol);
++ RBCreate(depthRB, pic2W, TWIDE/2-16, y+18, " 6bit",
++ infofg, infobg,hicol,locol);
++ RBCreate(depthRB, pic2W, TWIDE/2-16, y+36, " 9bit",
++ infofg, infobg, hicol, locol);
++ RBCreate(depthRB, pic2W, TWIDE/2-16, y+54, "12bit",
++ infofg, infobg, hicol, locol);
++ RBCreate(depthRB, pic2W, TWIDE/4*3-16, y, "15bit",
++ infofg, infobg, hicol, locol);
++ RBCreate(depthRB, pic2W, TWIDE/4*3-16, y+18, "18bit",
++ infofg, infobg, hicol, locol);
++ RBCreate(depthRB, pic2W, TWIDE/4*3-16, y+36, "21bit",
++ infofg, infobg, hicol, locol);
++ RBCreate(depthRB, pic2W, TWIDE/4*3-16, y+54, "24bit",
++ infofg, infobg, hicol, locol);
++
++ XMapSubwindows(theDisp, pic2W);
++}
++
++
++/***************************************************/
++void PIC2Dialog(vis)
++int vis;
++{
++ if (vis) {
++ CenterMapWindow(pic2W, tbut[T_BOK].x + tbut[T_BOK].w/2,
++ tbut[T_BOK].y + tbut[T_BOK].h/2, TWIDE, THIGH);
++ }
++ else XUnmapWindow(theDisp, pic2W);
++ pic2Up = vis;
++}
++
++
++/***************************************************/
++int PIC2CheckEvent(xev)
++XEvent *xev;
++{
++ /* check event to see if it's for one of our subwindows. If it is,
++ deal accordingly and return '1'. Otherwise, return '0'. */
++
++ int rv;
++ rv = 1;
++
++ if (!pic2Up)
++ return (0);
++
++ 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 (e->window == pic2W) drawTD(x, y, w, h);
++ else rv = 0;
++ }
++
++ else if (xev->type == ButtonPress) {
++ XButtonEvent *e = (XButtonEvent *) xev;
++ int x,y;
++ x = e->x; y = e->y;
++
++ if (e->button == Button1) {
++ if (e->window == pic2W) clickTD(x,y);
++ else rv = 0;
++ } /* button1 */
++ else rv = 0;
++ } /* button press */
++
++
++ else if (xev->type == KeyPress) {
++ XKeyEvent *e = (XKeyEvent *) xev;
++ char buf[128]; KeySym ks; XComposeStatus status;
++ int stlen;
++
++ stlen = XLookupString(e,buf,128,&ks,&status);
++ buf[stlen] = '\0';
++
++ if (e->window == pic2W) {
++ if (stlen) {
++ 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;
++ }
++ else rv = 0;
++
++ if (rv == 0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
++ XBell(theDisp, 50);
++ rv = 1; /* eat it */
++ }
++
++ return (rv);
++}
++
++
++/***************************************************/
++int PIC2SaveParams(fname, col)
++char *fname;
++int col;
++{
++ filename = fname;
++ colorType = col;
++
++ /* see if we can open the output file before proceeding */
++ fp = pic2_OpenOutFile(filename, &append);
++ if (!fp)
++ return (-1);
++
++ RBSetActive(typeRB,0,1);
++ RBSetActive(typeRB,1,1);
++ RBSetActive(typeRB,2,1);
++ RBSetActive(typeRB,3,1);
++ RBSelect(typeRB,0);
++
++
++ if (append) {
++ struct pic2_info pic2;
++
++ pic2_init_info(&pic2);
++ pic2.fp = fp;
++ pic2_read_header(&pic2);
++
++ RBSetActive(depthRB,0,0);
++ RBSetActive(depthRB,1,0);
++ RBSetActive(depthRB,2,0);
++ RBSetActive(depthRB,3,0);
++ RBSetActive(depthRB,4,0);
++ RBSetActive(depthRB,5,0);
++ RBSetActive(depthRB,6,0);
++ RBSetActive(depthRB,7,0);
++
++ switch (pic2.header->depth) {
++ case 3:
++ RBSetActive(depthRB,0,1);
++ RBSelect(depthRB,0);
++ RBSetActive(typeRB,3,0);
++ break;
++ case 6:
++ RBSetActive(depthRB,1,1);
++ RBSelect(depthRB,1);
++ RBSetActive(typeRB,3,0);
++ break;
++ case 9:
++ RBSetActive(depthRB,2,1);
++ RBSelect(depthRB,2);
++ break;
++ case 12:
++ RBSetActive(depthRB,3,1);
++ RBSelect(depthRB,3);
++ break;
++ case 15:
++ RBSetActive(depthRB,4,1);
++ RBSelect(depthRB,4);
++ break;
++ case 18:
++ RBSetActive(depthRB,5,1);
++ RBSelect(depthRB,5);
++ RBSetActive(typeRB,3,0);
++ break;
++ case 21:
++ RBSetActive(depthRB,6,1);
++ RBSelect(depthRB,6);
++ RBSetActive(typeRB,3,0);
++ break;
++ case 24:
++ RBSetActive(depthRB,7,1);
++ RBSelect(depthRB,7);
++ RBSetActive(typeRB,3,0);
++ break;
++ default: {
++ char str[512];
++ sprintf(str, "unsupported PIC2 file '%s'.", filename);
++ ErrPopUp(str, "\nBummer");
++ CloseOutFile(fp, filename, 0);
++ fp = OpenOutFile(fname);
++ if (!fp)
++ return (-1);
++ break;
++ }
++ }
++ pic2_seek_file(&pic2, 0, SEEK_SET);
++ pic2_cleanup_pic2_info(&pic2, 1);
++ } else {
++ RBSetActive(depthRB,0,1);
++ RBSetActive(depthRB,1,1);
++ RBSetActive(depthRB,2,1);
++ RBSetActive(depthRB,3,1);
++ RBSetActive(depthRB,4,1);
++ RBSetActive(depthRB,5,1);
++ RBSetActive(depthRB,6,1);
++ RBSetActive(depthRB,7,1);
++ RBSelect(depthRB,7);
++ RBSetActive(typeRB,3,0);
++ }
++ return (0);
++}
++
++
++/***************************************************/
++static void drawTD(x,y,w,h)
++int x,y,w,h;
++{
++ char *title = "Save PIC2 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);
++
++ XSetForeground(theDisp, theGC, infofg);
++ XSetBackground(theDisp, theGC, infobg);
++
++ for (i = 0; i < T_NBUTTS; i++)
++ BTRedraw(&tbut[i]);
++
++ ULineString(pic2W, typeRB->x-16, typeRB->y-3-DESCENT, "FormatType");
++ ULineString(pic2W, depthRB->x-16, depthRB->y-3-DESCENT, "ColorDepth");
++ RBRedraw(typeRB, -1);
++ RBRedraw(depthRB, -1);
++
++ DrawString(pic2W, 20, 29, title);
++
++ XSetClipMask(theDisp, theGC, None);
++}
++
++static void clickTD(x,y)
++int x,y;
++{
++ int i;
++ BUTT *bp;
++
++ /* check BUTTs */
++
++ /* check the RBUTTS first, since they don't DO anything */
++ if ((i = RBClick(typeRB, x,y)) >= 0) {
++ (void) RBTrack(typeRB, i);
++ return;
++ } else if ((i = RBClick(depthRB, x,y)) >= 0) {
++ (void) RBTrack(depthRB, i);
++ if ((2 <= i) && (i <= 4))
++ RBSetActive(typeRB,3,1);
++ else {
++ RBSetActive(typeRB,3,0);
++ if (RBWhich(typeRB) == 3)
++ RBSelect(typeRB,0);
++ return;
++ }
++ }
++ for (i = 0; i < T_NBUTTS; i++) {
++ bp = &tbut[i];
++ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h))
++ break;
++ }
++ if (i < T_NBUTTS) /* found one */
++ if (BTTrack(bp))
++ doCmd(i);
++}
++
++
++
++/***************************************************/
++static void doCmd(cmd)
++int cmd;
++{
++ switch (cmd) {
++ case T_BOK: {
++ char *fullname;
++ char buf[64], *x_offsetp, *y_offsetp;
++ static char *labels[] = { "\nOk", "\033Cancel" };
++ XEvent event;
++ int i;
++
++ strcpy(buf, "0,0");
++ i = GetStrPopUp("Enter offset (x,y):", labels, 2, buf, 64,
++ "01234567890,", 1);
++
++ if (i)
++ return;
++ if (strlen(buf)==0)
++ return;
++
++ x_offsetp = buf;
++ y_offsetp = index(buf, ',');
++ if (!y_offsetp)
++ return;
++ *(y_offsetp++) = '\0';
++ if ((*x_offsetp == '\0') || (*y_offsetp == '\0'))
++ return;
++ x_offset = atoi(x_offsetp);
++ y_offset = atoi(y_offsetp);
++
++ XNextEvent(theDisp, &event);
++ HandleEvent(&event, &i);
++
++ writePIC2();
++ PIC2Dialog(0);
++
++ fullname = GetDirFullName();
++ if (!ISPIPE(fullname[0])) {
++ XVCreatedFile(fullname);
++ StickInCtrlList(0);
++ }
++ }
++ break;
++ case T_BCANC:
++ pic2_KillNullFile(fp);
++ PIC2Dialog(0);
++ break;
++ default:
++ break;
++ }
++}
++
++
++/*******************************************/
++static void writePIC2()
++{
++ int w, h, nc, rv, type, depth, ptype, pfree;
++ byte *inpix, *rmap, *gmap, *bmap;
++
++
++ WaitCursor();
++ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
++
++ if (colorType == F_REDUCED)
++ colorType = F_FULLCOLOR;
++
++ switch (RBWhich(typeRB)) {
++ case 0: type = P2SS; break;
++ case 1: type = P2SF; break;
++ case 2: type = P2BM; break;
++ case 3: type = P2BI; break;
++ default: type = P2SS; break;
++ }
++ switch (RBWhich(depthRB)) {
++ case 0: depth = 3; break;
++ case 1: depth = 6; break;
++ case 2: depth = 9; break;
++ case 3: depth = 12; break;
++ case 4: depth = 15; break;
++ case 5: depth = 18; break;
++ case 6: depth = 21; break;
++ case 7: depth = 24; break;
++ default: depth = 24; break;
++ }
++ rv = WritePIC2(fp, inpix, ptype, w, h,
++ rmap, gmap, bmap, nc, colorType, filename,
++ type, depth, x_offset, y_offset, append, picComments);
++
++ if (CloseOutFile(fp, filename, rv) == 0)
++ DirBox(0);
++
++ if (pfree)
++ 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 @@
++/*
++ * xvpng.c - load and write routines for 'PNG' format pictures
++ *
++ * callable functions
++ *
++ * CreatePNGW()
++ * PNGDialog(vis)
++ * PNGCheckEvent(xev)
++ * PNGSaveParams(fname, col)
++ * LoadPNG(fname, pinfo)
++ * VersionInfoPNG()
++ */
++
++/*#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).
++ * 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.
++ */
++
++#include "xv.h"
++
++#ifdef HAVE_PNG
++
++#include "png.h"
++
++/*** Stuff for PNG Dialog box ***/
++#define PWIDE 318
++#define PHIGH 215
++
++#define DISPLAY_GAMMA 2.20 /* default display gamma */
++#define COMPRESSION 6 /* default zlib compression level, not max
++ (Z_BEST_COMPRESSION) */
++
++#define HAVE_tRNS (info_ptr->valid & PNG_INFO_tRNS)
++
++#define DWIDE 86
++#define DHIGH 104
++#define PFX PWIDE-93
++#define PFY 44
++#define PFH 20
++
++#define P_BOK 0
++#define P_BCANC 1
++#define P_NBUTTS 2
++
++#define BUTTH 24
++
++#define LF 10 /* a.k.a. '\n' on ASCII machines */
++#define CR 13 /* a.k.a. '\r' on ASCII machines */
++
++/*** local functions ***/
++static void drawPD PARM((int, int, int, int));
++static void clickPD PARM((int, int));
++static void doCmd PARM((int));
++static void writePNG PARM((void));
++static int WritePNG PARM((FILE *, byte *, int, int, int,
++ byte *, byte *, byte *, int));
++
++static void png_xv_error PARM((png_structp png_ptr,
++ png_const_charp message));
++static void png_xv_warning PARM((png_structp png_ptr,
++ png_const_charp message));
++
++/*** local variables ***/
++static char *filename;
++static char *fbasename;
++static int colorType;
++static int read_anything;
++static double Display_Gamma = DISPLAY_GAMMA;
++
++static DIAL cDial, gDial;
++static BUTT pbut[P_NBUTTS];
++static CBUTT interCB;
++static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB;
++
++/**************************************************************************/
++/* PNG SAVE DIALOG ROUTINES ***********************************************/
++/**************************************************************************/
++
++
++/*******************************************/
++void CreatePNGW()
++{
++ pngW = CreateWindow("xv png", "XVPNG", NULL,
++ PWIDE, PHIGH, infofg, infobg, 0);
++ if (!pngW) FatalError("can't create PNG window!");
++
++ XSelectInput(theDisp, pngW, ExposureMask | ButtonPressMask | KeyPressMask);
++
++ DCreate(&cDial, pngW, 12, 25, DWIDE, DHIGH, (double)Z_NO_COMPRESSION,
++ (double)Z_BEST_COMPRESSION, COMPRESSION, 1.0, 3.0,
++ infofg, infobg, hicol, locol, "Compression", NULL);
++
++ DCreate(&gDial, pngW, DWIDE+27, 25, DWIDE, DHIGH, 1.0, 3.5,DISPLAY_GAMMA,0.01,0.2,
++ infofg, infobg, hicol, locol, "Disp. Gamma", NULL);
++
++ CBCreate(&interCB, pngW, DWIDE+30, DHIGH+3*LINEHIGH+2, "interlace",
++ infofg, infobg, hicol, locol);
++
++ CBCreate(&FdefCB, pngW, PFX, PFY, "Default",
++ infofg, infobg, hicol, locol);
++ FdefCB.val = 1;
++
++ CBCreate(&FnoneCB, pngW, PFX, FdefCB.y + PFH + 4, "none",
++ infofg, infobg, hicol, locol);
++ CBCreate(&FsubCB, pngW, PFX, FnoneCB.y + PFH, "sub",
++ infofg, infobg, hicol, locol);
++ CBCreate(&FupCB, pngW, PFX, FsubCB.y + PFH, "up",
++ infofg, infobg, hicol, locol);
++ CBCreate(&FavgCB, pngW, PFX, FupCB.y + PFH, "average",
++ infofg, infobg, hicol, locol);
++ CBCreate(&FPaethCB, pngW, PFX, FavgCB.y + PFH, "Paeth",
++ infofg, infobg, hicol, locol);
++
++ FnoneCB.val = FsubCB.val = FupCB.val = FavgCB.val = FPaethCB.val = 1;
++ CBSetActive(&FnoneCB, !FdefCB.val);
++ CBSetActive(&FsubCB, !FdefCB.val);
++ CBSetActive(&FupCB, !FdefCB.val);
++ CBSetActive(&FavgCB, !FdefCB.val);
++ CBSetActive(&FPaethCB, !FdefCB.val);
++
++ BTCreate(&pbut[P_BOK], pngW, PWIDE-180-1, PHIGH-10-BUTTH-1, 80, BUTTH,
++ "Ok", infofg, infobg, hicol, locol);
++ BTCreate(&pbut[P_BCANC], pngW, PWIDE-90-1, PHIGH-10-BUTTH-1, 80, BUTTH,
++ "Cancel", infofg, infobg, hicol, locol);
++
++ XMapSubwindows(theDisp, pngW);
++}
++
++
++/*******************************************/
++void PNGDialog(vis)
++ int vis;
++{
++ if (vis) {
++ CenterMapWindow(pngW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2,
++ pbut[P_BOK].y + (int) pbut[P_BOK].h/2,
++ PWIDE, PHIGH);
++ }
++ else XUnmapWindow(theDisp, pngW);
++ pngUp = vis;
++}
++
++
++/*******************************************/
++int PNGCheckEvent(xev)
++ XEvent *xev;
++{
++ /* check event to see if it's for one of our subwindows. If it is,
++ deal accordingly, and return '1'. Otherwise, return '0' */
++
++ int rv;
++ rv = 1;
++
++ if (!pngUp) return 0;
++
++ 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 expose events for 'dumb' windows */
++ if (e->count > 0 && (e->window == cDial.win)) {}
++
++ else if (e->window == pngW) drawPD(x, y, w, h);
++ else if (e->window == cDial.win) DRedraw(&cDial);
++ else if (e->window == gDial.win) DRedraw(&gDial);
++ else rv = 0;
++ }
++
++ else if (xev->type == ButtonPress) {
++ XButtonEvent *e = (XButtonEvent *) xev;
++ int x,y;
++ x = e->x; y = e->y;
++
++ if (e->button == Button1) {
++ if (e->window == pngW) clickPD(x,y);
++ else if (e->window == cDial.win) DTrack(&cDial,x,y);
++ else if (e->window == gDial.win) DTrack(&gDial,x,y);
++ else rv = 0;
++ } /* button1 */
++ else rv = 0;
++ } /* button press */
++
++ else if (xev->type == KeyPress) {
++ XKeyEvent *e = (XKeyEvent *) xev;
++ char buf[128]; KeySym ks;
++ int stlen;
++
++ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
++ buf[stlen] = '\0';
++
++ RemapKeyCheck(ks, buf, &stlen);
++
++ if (e->window == pngW) {
++ if (stlen) {
++ if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
++ FakeButtonPress(&pbut[P_BOK]);
++ }
++ else if (buf[0] == '\033') { /* ESC */
++ FakeButtonPress(&pbut[P_BCANC]);
++ }
++ }
++ }
++ else rv = 0;
++ }
++ else rv = 0;
++
++ if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
++ XBell(theDisp, 50);
++ rv = 1; /* eat it */
++ }
++
++ return rv;
++}
++
++
++/*******************************************/
++void PNGSaveParams(fname, col)
++ char *fname;
++ int col;
++{
++ filename = fname;
++ colorType = col;
++}
++
++
++/*******************************************/
++static void drawPD(x, y, w, h)
++ int x, y, w, h;
++{
++ char *title = "Save PNG file...";
++
++ char ctitle1[20];
++ char *ctitle2 = "Useful range";
++ char *ctitle3 = "is 2 - 7.";
++ char *ctitle4 = "Uncompressed = 0";
++
++ char *ftitle = "Row Filters:";
++
++ char gtitle[20];
++
++ int i;
++ XRectangle xr;
++
++ xr.x = x; xr.y = y; xr.width = w; xr.height = h;
++ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
++
++ XSetForeground(theDisp, theGC, infofg);
++ XSetBackground(theDisp, theGC, infobg);
++
++ for (i=0; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
++
++ DrawString(pngW, 15, 6+ASCENT, title);
++
++ sprintf(ctitle1, "Default = %d", COMPRESSION);
++ DrawString(pngW, 18, 6+DHIGH+cDial.y+ASCENT, ctitle1);
++ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+LINEHIGH, ctitle2);
++ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+2*LINEHIGH, ctitle3);
++ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+3*LINEHIGH, ctitle4);
++
++ sprintf(gtitle, "Default = %g", DISPLAY_GAMMA);
++ DrawString(pngW, DWIDE+30, 6+DHIGH+gDial.y+ASCENT, gtitle);
++
++ ULineString(pngW, FdefCB.x, FdefCB.y-3-DESCENT, ftitle);
++ XDrawRectangle(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y-LINEHIGH-3,
++ 93, 8*LINEHIGH+15);
++ CBRedraw(&FdefCB);
++ XDrawLine(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y+LINEHIGH+4,
++ FdefCB.x+82, FdefCB.y+LINEHIGH+4);
++
++ CBRedraw(&FnoneCB);
++ CBRedraw(&FupCB);
++ CBRedraw(&FsubCB);
++ CBRedraw(&FavgCB);
++ CBRedraw(&FPaethCB);
++
++ CBRedraw(&interCB);
++
++ XSetClipMask(theDisp, theGC, None);
++}
++
++
++/*******************************************/
++static void clickPD(x,y)
++ int x,y;
++{
++ int i;
++ BUTT *bp;
++
++ /* check BUTTs */
++
++ for (i=0; i<P_NBUTTS; i++) {
++ bp = &pbut[i];
++ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
++ }
++
++ if (i<P_NBUTTS) { /* found one */
++ if (BTTrack(bp)) doCmd(i);
++ }
++
++ /* check CBUTTs */
++
++ else if (CBClick(&FdefCB,x,y)) {
++ int oldval = FdefCB.val;
++
++ CBTrack(&FdefCB);
++
++ if (oldval != FdefCB.val)
++ {
++ CBSetActive(&FnoneCB, !FdefCB.val);
++ CBSetActive(&FsubCB, !FdefCB.val);
++ CBSetActive(&FupCB, !FdefCB.val);
++ CBSetActive(&FavgCB, !FdefCB.val);
++ CBSetActive(&FPaethCB, !FdefCB.val);
++
++ CBRedraw(&FnoneCB);
++ CBRedraw(&FupCB);
++ CBRedraw(&FsubCB);
++ CBRedraw(&FavgCB);
++ CBRedraw(&FPaethCB);
++ }
++ }
++ else if (CBClick(&FnoneCB,x,y)) CBTrack(&FnoneCB);
++ else if (CBClick(&FsubCB,x,y)) CBTrack(&FsubCB);
++ else if (CBClick(&FupCB,x,y)) CBTrack(&FupCB);
++ else if (CBClick(&FavgCB,x,y)) CBTrack(&FavgCB);
++ else if (CBClick(&FPaethCB,x,y)) CBTrack(&FPaethCB);
++ else if (CBClick(&interCB,x,y)) CBTrack(&interCB);
++}
++
++
++/*******************************************/
++static void doCmd(cmd)
++ int cmd;
++{
++ switch (cmd) {
++ case P_BOK:
++ {
++ char *fullname;
++
++ writePNG();
++ PNGDialog(0);
++
++ fullname = GetDirFullName();
++ if (!ISPIPE(fullname[0])) {
++ XVCreatedFile(fullname);
++ StickInCtrlList(0);
++ }
++ }
++ break;
++
++ case P_BCANC:
++ PNGDialog(0);
++ break;
++
++ default:
++ break;
++ }
++}
++
++
++/*******************************************/
++static void writePNG()
++{
++ FILE *fp;
++ int w, h, nc, rv, ptype, pfree;
++ byte *inpix, *rmap, *gmap, *bmap;
++
++ fp = OpenOutFile(filename);
++ if (!fp) return;
++
++ fbasename = BaseName(filename);
++
++ WaitCursor();
++ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
++
++ rv = WritePNG(fp, inpix, ptype, w, h, rmap, gmap, bmap, nc);
++
++ SetCursors(-1);
++
++ if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
++
++ if (pfree) free(inpix);
++}
++
++
++/*******************************************/
++int WritePNG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols)
++ FILE *fp;
++ byte *pic;
++ int ptype, w, h;
++ byte *rmap, *gmap, *bmap;
++ int numcols;
++{
++ png_struct *png_ptr;
++ png_info *info_ptr;
++ png_color palette[256];
++ png_textp text;
++ byte remap[256];
++ int i, 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);
++ FatalError(software);
++ }
++
++ if ((info_ptr = png_create_info_struct(png_ptr)) == NULL)
++ {
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ sprintf(software, "png_create_info_struct() failure in WritePNG");
++ FatalError(software);
++ }
++
++ if (setjmp(png_ptr->jmpbuf)) {
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ return -1;
++ }
++
++ png_init_io(png_ptr, fp);
++
++ png_set_compression_level(png_ptr, (int)cDial.val);
++
++ /* Don't bother filtering if we aren't compressing the image */
++ if (FdefCB.val)
++ {
++ if ((int)cDial.val == 0)
++ png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
++ }
++ else
++ {
++ filter = FnoneCB.val ? PNG_FILTER_NONE : 0;
++ filter |= FsubCB.val ? PNG_FILTER_SUB : 0;
++ filter |= FupCB.val ? PNG_FILTER_UP : 0;
++ filter |= FavgCB.val ? PNG_FILTER_AVG : 0;
++ filter |= FPaethCB.val ? PNG_FILTER_PAETH : 0;
++
++ png_set_filter(png_ptr, 0, filter);
++ }
++
++ info_ptr->width = w;
++ info_ptr->height = h;
++ if (w <= 0 || h <= 0) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions out of range (%dx%d)",
++ fbasename, w, h);
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ return -1;
++ }
++
++ info_ptr->interlace_type = interCB.val ? 1 : 0;
++
++ linesize = 0; /* quiet a compiler warning */
++
++ if (colorType == F_FULLCOLOR || colorType == F_REDUCED) {
++ if(ptype == PIC24) {
++ linesize = 3*w;
++ if (linesize/3 < w) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, w, h);
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ return -1;
++ }
++ info_ptr->color_type = PNG_COLOR_TYPE_RGB;
++ info_ptr->bit_depth = 8;
++ } else {
++ linesize = w;
++ info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
++ if(numcols <= 2)
++ info_ptr->bit_depth = 1;
++ else
++ if(numcols <= 4)
++ info_ptr->bit_depth = 2;
++ else
++ if(numcols <= 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];
++ }
++ info_ptr->num_palette = numcols;
++ info_ptr->palette = palette;
++ info_ptr->valid |= PNG_INFO_PLTE;
++ }
++ }
++
++ else if(colorType == F_GREYSCALE || colorType == F_BWDITHER) {
++ info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
++ 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])) {
++ remap[0] = 1;
++ remap[1] = 0;
++ }
++ else {
++ remap[0] = 0;
++ remap[1] = 1;
++ }
++ linesize = w;
++ }
++ else {
++ if(ptype == PIC24) {
++ linesize = 3*w;
++ if (linesize/3 < w) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, w, h);
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ return -1;
++ }
++ info_ptr->bit_depth = 8;
++ }
++ else {
++ 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;
++
++ info_ptr->bit_depth = 8;
++
++ /* Note that this fails most of the time because of gamma */
++ /* try to adjust to 4-bit precision grayscale */
++
++ low_precision=1;
++
++ for(i = 0; i < numcols; i++) {
++ if((remap[i] & 0x0f) * 0x11 != remap[i]) {
++ low_precision = 0;
++ break;
++ }
++ }
++
++ if(low_precision) {
++ for(i = 0; i < numcols; 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]) {
++ low_precision = 0;
++ break;
++ }
++ }
++ }
++
++ if(low_precision) {
++ for(i = 0; i < numcols; 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]) {
++ low_precision = 0;
++ break;
++ }
++ }
++ }
++
++ if(low_precision) {
++ for(i = 0; i < numcols; i++) {
++ remap[i] &= 1;
++ }
++ info_ptr->bit_depth = 1;
++ }
++ }
++ }
++ }
++
++ else
++ png_error(png_ptr, "Unknown colorstyle in WritePNG");
++
++ if ((text = (png_textp)malloc(sizeof(png_text)))) {
++ sprintf(software, "XV %s", REVDATE);
++
++ text->compression = -1;
++ text->key = "Software";
++ text->text = software;
++ text->text_length = strlen(text->text);
++
++ info_ptr->max_text = 1;
++ info_ptr->num_text = 1;
++ info_ptr->text = text;
++ }
++
++ Display_Gamma = gDial.val; /* Save the current gamma for loading */
++
++ 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)
++ png_set_packing(png_ptr);
++
++ pass=png_set_interlace_handling(png_ptr);
++
++ if((png_line = malloc(linesize)) == NULL)
++ png_error(png_ptr, "cannot allocate temp image line");
++
++ 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) {
++ int k;
++ for(k = 0; k < w; k++)
++ png_line[k] = ptype==PIC24 ? MONO(p[k*3], p[k*3+1], p[k*3+2]) :
++ remap[p[k]];
++ png_write_row(png_ptr, png_line);
++ } else /* RGB or palette */
++ png_write_row(png_ptr, p);
++ if((j & 0x1f) == 0) WaitCursor();
++ p += linesize;
++ }
++ }
++
++ free(png_line);
++
++ savecmnt = NULL; /* quiet a compiler warning */
++
++ if (text)
++ {
++ if (picComments && strlen(picComments) &&
++ (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) {
++ png_textp tp;
++ char *comment, *key;
++
++ strcpy(savecmnt, picComments);
++ key = savecmnt;
++ tp = text;
++ info_ptr->num_text = 0;
++
++ comment = strchr(key, ':');
++
++ do {
++ /* Allocate a larger structure for comments if necessary */
++ if (info_ptr->num_text >= info_ptr->max_text)
++ {
++ if ((tp =
++ realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL)
++ {
++ break;
++ }
++ else
++ {
++ text = tp;
++ tp = &text[info_ptr->num_text];
++ info_ptr->max_text += 2;
++ }
++ }
++
++ /* 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) {
++ *(comment++) = '\0';
++ *(comment++) = '\0';
++
++ /* If the comment is the 'Software' chunk XV writes, we remove it,
++ since we have already stored one */
++ if (strcmp(key, "Software") == 0 && strncmp(comment, "XV", 2) == 0) {
++ key = strchr(comment, '\n');
++ if(key)
++ key++; /* skip \n */
++ comment = strchr(key, ':');
++ }
++ /* We have another keyword and/or comment to write out */
++ else {
++ tp->key = key;
++ tp->text = comment;
++
++ /* We have to find the end of this comment, and the next keyword
++ if there is one */
++ for (; NULL != (key = comment = strchr(comment, ':')); comment++)
++ if (key[1] == ':')
++ break;
++
++ /* It looks like another keyword, go backward to the beginning */
++ if (key) {
++ while(key > tp->text && *key != '\n')
++ key--;
++
++ if (key > tp->text && comment - key <= 80) {
++ *key = '\0';
++ key++;
++ }
++ }
++
++ tp->text_length = strlen(tp->text);
++
++ /* We don't have another keyword, so remove the last newline */
++ if (!key && tp->text[tp->text_length - 1] == '\n')
++ {
++ tp->text[tp->text_length] = '\0';
++ tp->text_length--;
++ }
++
++ tp->compression = tp->text_length > 640 ? 0 : -1;
++ info_ptr->num_text++;
++ tp++;
++ }
++ }
++ /* Just a generic comment: make sure line-endings are valid for PNG */
++ else {
++ char *p=key, *q=key; /* only deleting chars, not adding any */
++
++ while (*p) {
++ if (*p == CR) { /* lone CR or CR/LF: EOL either way */
++ *q++ = LF; /* LF is the only allowed PNG line-ending */
++ if (p[1] == LF) /* get rid of any original LF */
++ ++p;
++ } else if (*p == LF) /* lone LF */
++ *q++ = LF;
++ else
++ *q++ = *p;
++ ++p;
++ }
++ *q = '\0'; /* unnecessary...but what the heck */
++ tp->key = "Comment";
++ tp->text = key;
++ tp->text_length = q - key;
++ tp->compression = tp->text_length > 750 ? 0 : -1;
++ info_ptr->num_text++;
++ key = NULL;
++ }
++ } while (key && *key);
++ }
++ else
++ {
++ info_ptr->num_text = 0;
++ }
++ }
++ info_ptr->text = text;
++
++ png_convert_from_time_t(&(info_ptr->mod_time), time(NULL));
++ info_ptr->valid |= PNG_INFO_tIME;
++
++ png_write_end(png_ptr, info_ptr);
++ fflush(fp); /* just in case we core-dump before finishing... */
++
++ if (text)
++ {
++ free(text);
++ /* must do this or png_destroy_write_struct() 0.97+ will free text again: */
++ info_ptr->text = (png_textp)NULL;
++ if (savecmnt)
++ {
++ free(savecmnt);
++ savecmnt = (char *)NULL;
++ }
++ }
++
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++
++ return 0;
++}
++
++
++/*******************************************/
++int LoadPNG(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++/*******************************************/
++{
++ /* returns '1' on success */
++
++ FILE *fp;
++ png_struct *png_ptr;
++ png_info *info_ptr;
++ png_color_16 my_background;
++ int i,j;
++ int linesize, bufsize;
++ int filesize;
++ int pass;
++ int gray_to_rgb;
++ size_t commentsize;
++
++ fbasename = BaseName(fname);
++
++ pinfo->pic = (byte *) NULL;
++ pinfo->comment = (char *) NULL;
++
++ read_anything=0;
++
++ /* open the file */
++ fp = xv_fopen(fname,"r");
++ if (!fp) {
++ SetISTR(ISTR_WARNING,"%s: can't open file", fname);
++ return 0;
++ }
++
++ /* find the size of the file */
++ fseek(fp, 0L, 2);
++ filesize = ftell(fp);
++ fseek(fp, 0L, 0);
++
++ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
++ png_xv_error, png_xv_warning);
++ if(!png_ptr) {
++ fclose(fp);
++ FatalError("malloc failure in LoadPNG");
++ }
++
++ info_ptr = png_create_info_struct(png_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)) {
++ fclose(fp);
++ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
++ if(!read_anything) {
++ if(pinfo->pic) {
++ free(pinfo->pic);
++ pinfo->pic = NULL;
++ }
++ if(pinfo->comment) {
++ free(pinfo->comment);
++ pinfo->comment = NULL;
++ }
++ }
++ return read_anything;
++ }
++
++ png_init_io(png_ptr, fp);
++ png_read_info(png_ptr, info_ptr);
++
++ pinfo->w = pinfo->normw = info_ptr->width;
++ pinfo->h = pinfo->normh = info_ptr->height;
++ if (pinfo->w <= 0 || pinfo->h <= 0) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions out of range (%dx%d)",
++ fbasename, pinfo->w, pinfo->h);
++ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
++ return read_anything;
++ }
++
++ pinfo->frmType = F_PNG;
++
++ sprintf(pinfo->fullInfo, "PNG, %d bit ",
++ info_ptr->bit_depth * info_ptr->channels);
++
++ switch(info_ptr->color_type) {
++ case PNG_COLOR_TYPE_PALETTE:
++ strcat(pinfo->fullInfo, "palette color");
++ break;
++
++ case PNG_COLOR_TYPE_GRAY:
++ strcat(pinfo->fullInfo, "grayscale");
++ break;
++
++ case PNG_COLOR_TYPE_GRAY_ALPHA:
++ strcat(pinfo->fullInfo, "grayscale+alpha");
++ break;
++
++ case PNG_COLOR_TYPE_RGB:
++ strcat(pinfo->fullInfo, "truecolor");
++ break;
++
++ case PNG_COLOR_TYPE_RGB_ALPHA:
++ strcat(pinfo->fullInfo, "truecolor+alpha");
++ break;
++ }
++
++ sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo),
++ ", %sinterlaced. (%d bytes)",
++ info_ptr->interlace_type ? "" : "non-", filesize);
++
++ sprintf(pinfo->shrtInfo, "%lux%lu PNG", info_ptr->width, info_ptr->height);
++
++ if (info_ptr->bit_depth < 8)
++ png_set_packing(png_ptr);
++
++ 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);
++
++ gray_to_rgb = 0; /* quiet a compiler warning */
++
++ if (have_imagebg) {
++ if (info_ptr->bit_depth == 16) {
++ my_background.red = imagebgR;
++ my_background.green = imagebgG;
++ my_background.blue = imagebgB;
++ my_background.gray = imagebgG; /* only used if all three equal... */
++ } else {
++ my_background.red = (imagebgR >> 8);
++ my_background.green = (imagebgG >> 8);
++ my_background.blue = (imagebgB >> 8);
++ my_background.gray = my_background.green;
++ }
++ png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN,
++ 0, Display_Gamma);
++ if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
++ (info_ptr->color_type == PNG_COLOR_TYPE_GRAY && HAVE_tRNS)) &&
++ (imagebgR != imagebgG || imagebgR != imagebgB)) /* i.e., colored bg */
++ {
++ png_set_gray_to_rgb(png_ptr);
++ png_set_expand(png_ptr);
++ gray_to_rgb = 1;
++ }
++ } else {
++ if (info_ptr->valid & PNG_INFO_bKGD) {
++ png_set_background(png_ptr, &info_ptr->background,
++ PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
++ } else {
++ my_background.red = my_background.green = my_background.blue =
++ my_background.gray = 0;
++ png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN,
++ 0, Display_Gamma);
++ }
++ }
++
++ if (info_ptr->bit_depth == 16)
++ png_set_strip_16(png_ptr);
++
++ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
++ info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
++ {
++ if (info_ptr->bit_depth == 1)
++ pinfo->colType = F_BWDITHER;
++ else
++ pinfo->colType = F_GREYSCALE;
++ png_set_expand(png_ptr);
++ }
++
++ pass=png_set_interlace_handling(png_ptr);
++
++ png_read_update_info(png_ptr, info_ptr);
++
++ if(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
++ info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || gray_to_rgb)
++ {
++ linesize = 3 * pinfo->w;
++ if (linesize/3 < pinfo->w) { /* know pinfo->w > 0 (see above) */
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, pinfo->w, pinfo->h);
++ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
++ return read_anything;
++ }
++ pinfo->colType = F_FULLCOLOR;
++ pinfo->type = PIC24;
++ } else {
++ linesize = pinfo->w;
++ pinfo->type = PIC8;
++ if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
++ info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
++ 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++) {
++ pinfo->r[i] = info_ptr->palette[i].red;
++ pinfo->g[i] = info_ptr->palette[i].green;
++ pinfo->b[i] = info_ptr->palette[i].blue;
++ }
++ }
++ }
++
++ bufsize = linesize * pinfo->h;
++ if (bufsize/linesize < pinfo->h) { /* know linesize, pinfo->h > 0 (above) */
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, pinfo->w, pinfo->h);
++ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
++ return read_anything;
++ }
++ pinfo->pic = calloc((size_t)bufsize, (size_t)1);
++
++ 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++) {
++ byte *p = pinfo->pic;
++ for(j = 0; j < pinfo->h; j++) {
++ png_read_row(png_ptr, p, NULL);
++ read_anything = 1;
++ if((j & 0x1f) == 0) WaitCursor();
++ p += linesize;
++ }
++ }
++
++ png_read_end(png_ptr, info_ptr);
++
++ if(info_ptr->num_text > 0) {
++ commentsize = 1;
++
++ for(i = 0; i < info_ptr->num_text; i++)
++ commentsize += strlen(info_ptr->text[i].key) + 1 +
++ info_ptr->text[i].text_length + 2;
++
++ if((pinfo->comment = malloc(commentsize)) == NULL) {
++ png_warning(png_ptr,"can't allocate comment string");
++ }
++ else {
++ pinfo->comment[0] = '\0';
++ for(i = 0; i < info_ptr->num_text; i++) {
++ strcat(pinfo->comment, info_ptr->text[i].key);
++ strcat(pinfo->comment, "::");
++ strcat(pinfo->comment, info_ptr->text[i].text);
++ strcat(pinfo->comment, "\n");
++ }
++ }
++ }
++
++ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
++
++ fclose(fp);
++
++ return 1;
++}
++
++
++/*******************************************/
++static void
++png_xv_error(png_ptr, message)
++ png_structp png_ptr;
++ png_const_charp message;
++{
++ SetISTR(ISTR_WARNING,"%s: libpng error: %s", fbasename, message);
++
++ longjmp(png_ptr->jmpbuf, 1);
++}
++
++
++/*******************************************/
++static void
++png_xv_warning(png_ptr, message)
++ png_structp png_ptr;
++ png_const_charp message;
++{
++ if (!png_ptr)
++ return;
++
++ SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message);
++}
++
++
++/*******************************************/
++void
++VersionInfoPNG() /* GRR 19980605 */
++{
++ fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
++ PNG_LIBPNG_VER_STRING, png_libpng_ver);
++ fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
++ ZLIB_VERSION, zlib_version);
++}
++
++#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
+@@ -0,0 +1,1101 @@
++
++/*
++ * xvvd.c - extract archived file automatically and regard it as a
++ * (virtual) directory.
++ */
++
++#define NEEDSDIR
++
++#include "xv.h"
++
++#ifdef AUTO_EXPAND
++
++static void vd_Dirtovd PARM((char *));
++static void vd_Vdtodir PARM((char *));
++static int vd_Mkvdir PARM((char *));
++static int vd_Rmvdir PARM((char *));
++static int vd_Movevdir PARM((char *, char *));
++static void vd_addvdtable PARM((char *));
++static void vd_packvdtable PARM((void));
++static int vd_recursive_mkdir PARM((char *));
++static int vd_recursive_rmdir PARM((char *));
++static void vd_optimize_path PARM((char *));
++static int vd_ftype PARM((char *));
++static int vd_compp PARM((char *, char *));
++static int vd_UncompressFile PARM((char *, char *));
++static int vd_tarc PARM((char *));
++static u_int vd_tar_sumchk PARM((char *));
++
++#define VD_VDTABLESIZE 100
++
++#define VD_ERR -2
++#define VD_UKN -1
++
++static char *ext_command[] = {
++/* KEEP 0 */
++ NULL,
++#define VD_ARC 1
++ "arc xo %s",
++#define VD_ARJ 2
++ "unarj x %s",
++#define VD_LZH 3
++ "lha -xf %s",
++#define VD_TAR 4
++ "tar xvf %s",
++#define VD_ZIP 5
++ "unzip -xo %s",
++#define VD_ZOO 6
++ "zoo xOS %s",
++};
++
++int vdcount = 0;
++
++static char vdroot[MAXPATHLEN+1];
++static char *vdtable[VD_VDTABLESIZE];
++
++/*
++ * These functions initialize and settle virtual directory system.
++ * Vdinit:
++ * creates root of virtual directory.
++ * Vdsettle:
++ * sweeps virtual directories.
++ */
++void Vdinit()
++{
++#ifndef VMS
++ char tmp[MAXPATHLEN+1];
++
++ xv_getwd(tmp, MAXPATHLEN+1);
++ if (chdir(tmpdir)) {
++ fprintf(stderr, "Warning: cannot chdir to tmpdir = '%s'.\n", tmpdir);
++ fprintf(stderr,
++ " I will use current directory '%s' instead of tmpdir.\n",
++ tmp);
++ }
++ xv_getwd(vdroot, MAXPATHLEN+1);
++ strcat(vdroot, "/.xvvdXXXXXX");
++ chdir(tmp);
++#else
++ sprintf(vdroot, "Sys$Scratch:xvvdXXXXXX");
++#endif /* VMS */
++#ifdef USE_MKSTEMP
++ close(mkstemp(vdroot));
++#else
++ mktemp(vdroot);
++#endif
++
++ if (!vd_recursive_mkdir(vdroot))
++ tmpdir = vdroot;
++}
++
++void Vdsettle()
++{
++ int i;
++
++ for (i = 0; i < vdcount; i++)
++ free(vdtable[i]);
++
++ vdcount = 0;
++
++ vd_recursive_rmdir(vdroot);
++}
++
++/*
++ * This function chdir to virtual directory, if specified path is in
++ * virtual directlry.
++ */
++int Chvdir(dir)
++char *dir;
++{
++ char buf[MAXPATHLEN+1];
++
++ if (Mkvdir(dir) == VD_ERR)
++ return -1;
++
++ strcpy(buf, dir);
++ Dirtovd(buf);
++
++ return (chdir(buf));
++}
++
++/*
++ * These functions convert directory <-> virtual directory.
++ * Dirtovd:
++ * front interface of vd_Dirtovd.
++ * vd_Dirtovd:
++ * converts directory to virtual directory.
++ * Vdtodir:
++ * front interface of vd_Vdtodir.
++ * vd_Vdtodir:
++ * converts virtual directory to normal directory.
++ * Dirtosubst:
++ * converts directory to substance of archive.
++ */
++void Dirtovd(dir)
++char *dir;
++{
++ vd_optimize_path(dir);
++
++ vd_Dirtovd(dir);
++}
++
++static void vd_Dirtovd(dir)
++char *dir;
++{
++ int i;
++
++ for (i = 0; i < vdcount; i++)
++ if (!strncmp(dir, vdtable[i], strlen(vdtable[i]))) {
++ char tmp[MAXPATHLEN+1];
++
++ sprintf(tmp, "%s%s", vdroot, dir);
++ strcpy(dir, tmp);
++ Dirtovd(dir);
++ }
++}
++
++void Vdtodir(dir)
++char *dir;
++{
++ vd_optimize_path(dir);
++
++ vd_Vdtodir(dir);
++}
++
++static void vd_Vdtodir(vd)
++char *vd;
++{
++ int i;
++ char tmp[MAXPATHLEN+1];
++
++ for (i = vdcount-1; i >= 0; i--) {
++ sprintf(tmp, "%s%s", vdroot, vdtable[i]);
++ if(!strncmp(vd, tmp, strlen(tmp))) {
++ strcpy(tmp, vd+strlen(vdroot));
++ strcpy(vd, tmp);
++ Vdtodir(vd);
++ }
++ }
++}
++
++void Dirtosubst(dir)
++char *dir;
++{
++ char tmp[MAXPATHLEN+1];
++
++ Dirtovd(dir);
++
++ strcpy(tmp, dir+strlen(vdroot));
++
++ if (Isarchive(tmp))
++ strcpy(dir, tmp);
++}
++
++/*
++ * These functions make virtual directory and extracts archive, if
++ * specified path is archive.
++ * Mkvdir:
++ * front interface of vd_Mkvdir.
++ * vd_Mkvdir:
++ * does real work.
++ * Mkvdir_force: (used by makeThumbDir(in xvbrowse.c) only)
++ * make virtual directory by force.
++ */
++int Mkvdir(dir)
++char *dir;
++{
++ char dir1[MAXPATHLEN+1], dir2[MAXPATHLEN+1];
++ char *d1, *d2;
++ int rv;
++
++#if defined(SYSV) || defined(SVR4) || defined(__USE_XOPEN_EXTENDED)
++ sighold(SIGHUP);
++ sighold(SIGCHLD);
++#else
++ int mask;
++ mask = sigblock(sigmask(SIGHUP)|sigmask(SIGCHLD));
++#endif
++
++ strcpy(dir1, dir);
++ vd_optimize_path(dir1);
++
++ if ((rv = vd_Mkvdir(dir1)) != VD_ERR)
++ goto MKVDIR_END;
++
++ strcpy(dir2, dir1);
++ d2 = dir2 + strlen(dir2);
++ while (rv == VD_ERR) {
++ d2--;
++ while (*d2 != '/')
++ d2--;
++ *d2 = '\0';
++ rv = vd_Mkvdir(dir2);
++ }
++ d1 = dir1 + strlen(dir2);
++ while ((rv != VD_ERR) && (*d1 != '\0')) {
++ *d2++ = *d1++;
++ while ((*d1 != '/') && (*d1 != '\0'))
++ *d2++ = *d1++;
++ *d2 = '\0';
++ rv = vd_Mkvdir(dir2);
++ }
++
++MKVDIR_END:
++#if defined(SYSV) || defined(SVR4) || defined(__USE_XOPEN_EXTENDED)
++ sigrelse(SIGHUP);
++ sigrelse(SIGCHLD);
++#else
++ sigsetmask(mask);
++#endif
++
++ return rv;
++}
++
++static int vd_Mkvdir(dir)
++char *dir;
++{
++ char dir1[MAXPATHLEN+1], dir2[MAXPATHLEN+1], tmp[MAXPATHLEN+1];
++ int ftype, i;
++ struct stat st;
++ FILE *pfp;
++
++ strcpy(dir1, dir);
++ Dirtovd(dir1);
++ strcpy(dir2, dir1);
++
++ WaitCursor();
++
++ if ((ftype = vd_ftype(dir1)) < 0) {
++ SetCursors(-1);
++ return ftype;
++ }
++ if (ftype == RFT_COMPRESS) {
++ if (!(ftype = vd_compp(dir1, tmp))) {
++ SetCursors(-1);
++ return ftype;
++ }
++ strcpy(dir1, tmp);
++ }
++
++ if (!stat(dir1, &st)) {
++ for(i = 0; i < vdcount; i++)
++ if (!strcmp(vdtable[i], dir2)) {
++ SetCursors(-1);
++ return 0;
++ }
++
++ if (!S_ISDIR(st.st_mode)) {
++ char origdir[MAXPATHLEN+1], buf[MAXPATHLEN+10], buf1[100];
++
++ if (vdcount >= VD_VDTABLESIZE) {
++ ErrPopUp("Sorry, you can't make virtual directory any more.",
++ "\nBummer!");
++ goto VD_MKVDIR_ERR;
++ }
++
++ WaitCursor();
++
++ xv_getwd(origdir, MAXPATHLEN+1);
++
++ sprintf(tmp, "%s%s", vdroot, dir2);
++ if (vd_recursive_mkdir(tmp) || chdir(tmp)) {
++ SetISTR(ISTR_INFO, "fail to make virtual directory.");
++ Warning();
++ goto VD_MKVDIR_ERR;
++ }
++ sprintf(buf, ext_command[ftype], dir1);
++
++ WaitCursor();
++
++ if((pfp = popen(buf, "r")) == NULL) {
++ SetISTR(ISTR_INFO, "fail to extract archive '%s'.",
++ BaseName(dir2));
++ Warning();
++ goto VD_MKVDIR_ERR;
++ }
++ while (1) {
++ if (fread(buf1, 1, sizeof(buf1), pfp) < sizeof(buf1))
++ break;
++ WaitCursor();
++ }
++ if (!feof(pfp)) {
++ SetISTR(ISTR_INFO, "Pipe was broken.");
++ Warning();
++ pclose(pfp);
++ goto VD_MKVDIR_ERR;
++ }
++ pclose(pfp);
++
++ if (strcmp(dir1, dir2))
++ unlink(dir1);
++
++ vd_addvdtable(dir2);
++ Dirtovd(origdir);
++ chdir(origdir);
++ SetCursors(-1);
++ return 0;
++
++VD_MKVDIR_ERR:
++ if (strcmp(dir1, dir2))
++ unlink(dir1);
++ SetCursors(-1);
++ return VD_ERR;
++ }
++ }
++ SetCursors(-1);
++ return VD_ERR;
++}
++
++#ifdef VIRTUAL_TD
++void Mkvdir_force(dir)
++char *dir;
++{
++ char tmp[MAXPATHLEN+1];
++
++ if (vdcount >= VD_VDTABLESIZE) {
++ ErrPopUp("Sorry, you can't make virtual directory any more.",
++ "\nBummer!");
++ return;
++ }
++
++ sprintf(tmp, "%s%s", vdroot, dir);
++ if (vd_recursive_mkdir(tmp)) {
++ SetISTR(ISTR_INFO, "Failed to make virtual directory.");
++ Warning();
++ return;
++ }
++
++ vd_addvdtable(dir);
++}
++#endif /* VIRTUAL_TD */
++
++/*
++ * These functions remove virtual directory, if exists.
++ * Rmvdir:
++ * front interface of vd_Rmvdir.
++ * vd_Rmvdir:
++ * remove virtual directory function.
++ */
++int Rmvdir(dir)
++char *dir;
++{
++ int rv;
++ char buf[MAXPATHLEN+1];
++
++ strcpy(buf, dir);
++ vd_optimize_path(buf);
++
++ rv = vd_Rmvdir(buf);
++ vd_packvdtable();
++ return rv;
++}
++
++static int vd_Rmvdir(dir)
++char *dir;
++{
++ int i;
++ char tmp[MAXPATHLEN+1];
++
++ for(i = 0; i < vdcount; i++)
++ if (!strncmp(dir, vdtable[i], strlen(dir))) {
++ sprintf(tmp, "%s%s", vdroot, vdtable[i]);
++ if (vd_Rmvdir(tmp))
++ return 1;
++ if (vd_recursive_rmdir(tmp))
++ return 1;
++ vdtable[i][0] = '\0';
++ }
++ return 0;
++}
++
++/*
++ * These functions move virtual directory, if exists.
++ * Movevdir:
++ * front interface of move virtual directory function.
++ * vd_Movevdir:
++ * does real work.
++ */
++int Movevdir(src, dst)
++char *src, *dst;
++{
++/*
++ char sbuf[MAXPATHLEN+1], dbuf[MAXPATHLEN+1];
++
++ strcpy(sbuf, src);
++ vd_optimize_path(sbuf);
++
++ strcpy(dbuf, dst);
++ vd_optimize_path(dbuf);
++
++ return (vd_Movevdir(sbuf, dbuf));
++*/
++ return (vd_Movevdir(src, dst));
++}
++
++static int vd_Movevdir(src, dst)
++char *src, *dst;
++{
++ int i;
++ char *p, *pp;
++ char tmp[MAXPATHLEN+1], tmps[MAXPATHLEN+1], tmpd[MAXPATHLEN+1];
++
++ for (i = 0; i < vdcount; i++)
++ if (!strncmp(src, vdtable[i], strlen(src))) {
++ sprintf(tmps, "%s%s", vdroot, vdtable[i]);
++ sprintf(tmp, "%s%s", dst, vdtable[i]+strlen(src));
++ sprintf(tmpd, "%s%s", vdroot, tmp);
++
++ if (vd_Movevdir(tmps, tmpd))
++ return 1;
++
++ pp = vdtable[i];
++ p = (char *) malloc(strlen(tmp)+1);
++ strcpy(p, tmp);
++ vdtable[i] = p;
++
++ strcpy(tmp, tmpd);
++ for (p = tmp+strlen(tmp); *p != '/'; p--)
++ ;
++ *p = '\0';
++
++ if (vd_recursive_mkdir(tmp))
++ goto VD_MOVEVDIR_ERR;
++
++ if (rename(tmps, tmpd) < 0)
++ goto VD_MOVEVDIR_ERR;
++
++ free(pp);
++ }
++ return 0;
++
++VD_MOVEVDIR_ERR:
++ free(vdtable[i]);
++ vdtable[i] = pp;
++ return 1;
++}
++
++/*
++ * These functions handle table of virtual directories.
++ * vd_addvdtable:
++ * adds virtual directory to table.
++ * vd_packvdtable:
++ * removes disused virtual directories from table.
++ */
++static void vd_addvdtable(vd)
++char *vd;
++{
++ char *p;
++ p = (char *) malloc(strlen(vd)+1);
++ strcpy(p, vd);
++ vdtable[vdcount] = p;
++ vdcount++;
++}
++
++static void vd_packvdtable()
++{
++ int i, j;
++
++ for (i = j = 0; i < vdcount; i++)
++ if (vdtable[i][0] != '\0')
++ vdtable[j++] = vdtable[i];
++ else
++ free(vdtable[i]);
++
++ vdcount = j;
++}
++
++/*
++ * These are utility functions.
++ * vd_recursive_mkdir:
++ * makes directories recursively.
++ * vd_recursive_rmdir
++ * removes directories recursively.
++ */
++static int vd_recursive_mkdir(dir)
++char *dir;
++{
++ char buf[MAXPATHLEN+1], *p;
++ struct stat st;
++
++ strcpy(buf, dir);
++
++ if (buf[strlen(buf) - 1] == '/')
++ buf[strlen(buf) - 1] = '\0';
++
++ p = rindex(buf, '/');
++ *p = '\0';
++
++ if (stat(buf, &st) < 0)
++ if (vd_recursive_mkdir(buf) < 0)
++ return (-1);
++
++ *p = '/';
++ if (mkdir(buf, 0700) < 0)
++ return (-1);
++
++ return (0);
++}
++
++static int vd_recursive_rmdir(dir)
++char *dir;
++{
++ char buf[MAXPATHLEN+1], buf2[MAXPATHLEN+1];
++ DIR *dp;
++ struct dirent *di;
++
++ strcpy(buf, dir);
++
++ if (buf[strlen(buf) - 1] == '/')
++ buf[strlen(buf) - 1] = '\0';
++
++ if ((dp = opendir(buf)) == NULL)
++ return (-1);
++
++ while ((di = readdir(dp)) != NULL) {
++ struct stat st;
++
++ if (!strcmp(di->d_name, ".") || !strcmp(di->d_name, ".."))
++ continue;
++
++ sprintf(buf2, "%s/%s", dir, di->d_name);
++
++ stat(buf2, &st);
++ if (S_ISDIR(st.st_mode)) {
++ if (vd_recursive_rmdir(buf2) < 0)
++ goto VD_RECURSIVE_RMDIR_ERR;
++ } else
++ unlink(buf2);
++ }
++ if (rmdir(buf) < 0)
++ goto VD_RECURSIVE_RMDIR_ERR;
++
++ closedir(dp);
++ return (0);
++
++VD_RECURSIVE_RMDIR_ERR:
++ closedir(dp);
++ return (-1);
++}
++
++/*
++ * These functions test specified path.
++ * Isarchive:
++ * tests whether it's an archive?
++ * Isvdir:
++ * tests whether it's in the virtual directory?
++ */
++int Isarchive(path)
++char *path;
++{
++ int ftype;
++
++ if ((ftype = vd_ftype(path)) < 0)
++ return 0;
++
++ if (ftype == RFT_COMPRESS)
++ if (!(ftype = vd_compp(path, NULL)))
++ return 0;
++
++ return ftype;
++}
++
++int Isvdir(path)
++char *path;
++{
++ int rv = 0;
++ char tmp1[MAXPATHLEN+1], tmp2[MAXPATHLEN+1];
++ int archive1, archive2;
++
++ strcpy(tmp1, path);
++ strcpy(tmp2, path);
++
++ vd_optimize_path(tmp1);
++ Dirtovd(tmp2);
++
++ archive1 = Isarchive(tmp1);
++ archive2 = Isarchive(tmp2);
++
++ if (strcmp(tmp1, tmp2)) {
++ char tmp3[MAXPATHLEN+1], tmp4[MAXPATHLEN+1];
++ int archive3, archive4;
++
++ sprintf(tmp3, "%s%s", vdroot, tmp1);
++ strcpy(tmp4, tmp2+strlen(vdroot));
++
++ archive3 = Isarchive(tmp3);
++ archive4 = Isarchive(tmp4);
++
++ if (archive4 && !strcmp(tmp1, tmp4)) {
++ rv |= 06;
++ return rv;
++ }
++ rv |= 01;
++ if (archive2)
++ rv |= 02;
++ else if (archive4)
++ rv |= 06;
++ return rv;
++ }
++ if (archive1)
++ rv |= 02;
++
++ return rv;
++}
++
++/*
++ * This function optimizes given path.
++ * Expand '~' to home directory and removes '.', and treat '..'.
++ */
++static void vd_optimize_path(path)
++char *path;
++{
++ char *tmp, *reserve;
++
++ if (!strcmp(path, STDINSTR))
++ return;
++
++ if (*path == '\0') {
++ xv_getwd(path, MAXPATHLEN+1);
++ return;
++ }
++ if (*path == '~')
++ Globify(path);
++ if (*path != '/') {
++ char tmp[MAXPATHLEN+1];
++
++ strcpy(tmp, path);
++ xv_getwd(path, MAXPATHLEN+1);
++ strcat(path, "/");
++ strcat(path, tmp);
++ }
++
++ reserve = tmp = path;
++ while(*path != '\0') {
++ if (*path == '/') {
++ *tmp++ = *path;
++ while (*++path == '/')
++ ;
++ continue;
++ }
++ if ((*path == '.') && (*(path-1) == '/')) {
++ if (*(path+1) == '/') {
++ tmp--;
++ path++;
++ continue;
++ } else if (*(path+1) == '\0') {
++ tmp--;
++ break;
++ } else if (*(path+1) == '.') {
++ if (*(path+2) == '/') {
++ if ((tmp - reserve) > 1)
++ for (tmp-=2; (*tmp != '/'); tmp--)
++ ;
++ else
++ tmp = reserve;
++ path+=2;
++ continue;
++ } else if (*(path+2) == '\0') {
++ if ((tmp - reserve) > 1)
++ for (tmp-=2; (*tmp != '/'); tmp--)
++ ;
++ else
++ tmp = reserve+1;
++ break;
++ }
++ }
++ }
++ *tmp++ = *path++;
++ }
++ if (((tmp - reserve) > 1) && *(tmp-1) == '/')
++ tmp--;
++ if (tmp == reserve)
++ *tmp++ = '/';
++
++ *tmp = '\0';
++}
++
++/*
++ * These functions detect file type.
++ */
++static int vd_ftype(fname)
++char *fname;
++{
++ /* check archive type */
++
++ FILE *fp;
++ byte magicno[30]; /* first 30 bytes of file */
++ int rv, n;
++ struct stat st;
++
++ if (!fname) return VD_ERR; /* shouldn't happen */
++
++ if ((!stat(fname, &st)) && (st.st_mode & S_IFMT) == S_IFDIR)
++ return VD_UKN;
++ fp = xv_fopen(fname, "r");
++ if (!fp) return VD_ERR;
++
++ n = fread(magicno, (size_t) 1, (size_t) 30, fp);
++ fclose(fp);
++
++ if (n<30) return VD_UKN; /* files less than 30 bytes long... */
++
++ rv = VD_UKN;
++
++ if (magicno[0] == 0x60 && magicno[1]==0xea) rv = VD_ARJ;
++
++ else if (magicno[2] == '-' && magicno[3] == 'l' &&
++ magicno[4] == 'h') rv = VD_LZH;
++
++ else if (strncmp((char *) magicno,"PK", (size_t) 2)==0) rv = VD_ZIP;
++
++ else if (magicno[20]==0xdc && magicno[21]==0xa7 &&
++ magicno[22]==0xc4 && magicno[23]==0xfd) rv = VD_ZOO;
++
++ else if (vd_tarc(fname)) rv = VD_TAR;
++
++ else if (magicno[0]==0x1f && magicno[1]==0x9d) rv = RFT_COMPRESS;
++
++ else if (!strncmp((char *) &magicno[11], "MAJYO", (size_t) 5))
++ rv = VD_UKN; /* XXX */
++
++ else if (magicno[0] == 26) rv = VD_ARC;
++
++#ifdef GUNZIP
++ else if (magicno[0]==0x1f && magicno[1]==0x8b) rv = RFT_COMPRESS;/* gzip */
++ else if (magicno[0]==0x1f && magicno[1]==0x9e) rv = RFT_COMPRESS;/* old */
++ else if (magicno[0]==0x1f && magicno[1]==0x1e) rv = RFT_COMPRESS;/* pack */
++#endif
++
++ return rv;
++}
++
++static int vd_compp(path, newpath)
++char *path, *newpath;
++{
++ /*
++ * uncompress and check archive type.
++ *
++ * If newpath is NULL, uncompress only 512 byte of 'path' and
++ * check archive type, so it is for SPEED-UP strategy.
++ * In this case, caller this function does not have to unlink
++ * tempoary file.
++ * Unfortunately it does not work in VMS system.
++ */
++
++ int file_type, r;
++ char uncompname[128], basename[128];
++ int comptype;
++
++ if (newpath) *newpath = '\0';
++ strncpy(basename, path, 127);
++ comptype = ReadFileType(path);
++#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 */
++ *rindex (basename, '.') = '\0';
++#endif
++#ifdef VMS
++ if (UncompressFile(basename, uncompname)) {
++#else
++ if (newpath == NULL)
++ r = vd_UncompressFile(basename, uncompname);
++ else
++ r = UncompressFile(basename, uncompname, comptype);
++ if (r) {
++#endif
++ if ((file_type = vd_ftype(uncompname)) < 0) {
++ unlink(uncompname);
++ return 0;
++ }
++ if (newpath) strcpy(newpath, uncompname);
++ else unlink(uncompname);
++ } else {
++ return 0;
++ }
++ return file_type;
++}
++
++#define HEADERSIZE 512
++
++static void vd_Dirtovd PARM((char *));
++static int stderr_on PARM((void));
++static int stderr_off PARM((void));
++static FILE *popen_nul PARM((char *, char *));
++
++static int vd_UncompressFile(name, uncompname)
++char *name, *uncompname;
++{
++ /* Yap, I`m nearly same as original `UncompnameFile' function, but,
++ 1) I extract `name' file ONLY first 512 byte.
++ 2) I'm called only from UNIX and UNIX like OS, *NOT* VMS */
++ /* returns '1' on success, with name of uncompressed file in uncompname
++ returns '0' on failure */
++
++ char namez[128], *fname, buf[512], tmp[HEADERSIZE];
++ int n, tmpfd;
++ FILE *pfp, *tfp;
++
++ fname = name;
++ namez[0] = '\0';
++
++
++#ifndef GUNZIP
++ /* see if compressed file name ends with '.Z'. If it *doesn't*, we need
++ to temporarily rename it so it *does*, uncompress it, and rename it
++ *back* to what it was. necessary because uncompress doesn't handle
++ files that don't end with '.Z' */
++
++ if (strlen(name) >= (size_t) 2 &&
++ strcmp(name + strlen(name)-2,".Z")!=0 &&
++ strcmp(name + strlen(name)-2,".z")!=0) {
++ strcpy(namez, name);
++ strcat(namez,".Z");
++
++ if (rename(name, namez) < 0) {
++ sprintf(buf, "Error renaming '%s' to '%s': %s",
++ name, namez, ERRSTR(errno));
++ ErrPopUp(buf, "\nBummer!");
++ return 0;
++ }
++
++ fname = namez;
++ }
++#endif /* not GUNZIP */
++
++ sprintf(uncompname, "%s/xvuXXXXXX", tmpdir);
++#ifdef USE_MKSTEMP
++ tmpfd = mkstemp(uncompname);
++#else
++ mktemp(uncompname);
++#endif
++
++ sprintf(buf,"%s -c %s", UNCOMPRESS, fname);
++ SetISTR(ISTR_INFO, "Uncompressing Header '%s'...", BaseName(fname));
++ if ((pfp = popen_nul(buf, "r")) == NULL) {
++ SetISTR(ISTR_INFO, "Cannot extract for archive '%s'.",
++ BaseName(fname));
++ Warning();
++#ifdef USE_MKSTEMP
++ if (tmpfd >= 0)
++ close(tmpfd);
++#endif
++ return 0;
++ }
++#ifdef USE_MKSTEMP
++ if (tmpfd < 0)
++#else
++ if ((tmpfd = open(uncompname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR)) < 0)
++#endif
++ {
++ SetISTR(ISTR_INFO, "Unable to create temporary file.",
++ BaseName(uncompname));
++ Warning();
++ pclose(pfp);
++ }
++ if ((tfp = fdopen(tmpfd, "w")) == NULL) {
++ SetISTR(ISTR_INFO, "Unable to create temporary file.",
++ BaseName(uncompname));
++ Warning();
++ close(tmpfd);
++ pclose(pfp);
++ return 0;
++ }
++ if ((n = fread(tmp, 1, sizeof(tmp), pfp)) != HEADERSIZE) {
++ SetISTR(ISTR_INFO, "Unable to read '%s'.",
++ BaseName(fname));
++ Warning();
++ pclose(pfp);
++ fflush(tfp);
++ fclose(tfp);
++ close(tmpfd);
++ return 0;
++ }
++ fwrite(tmp, 1, n, tfp);
++ fflush(tfp);
++ fclose(tfp);
++ close(tmpfd);
++ pclose(pfp);
++
++ /* if we renamed the file to end with a .Z for the sake of 'uncompress',
++ rename it back to what it once was... */
++
++ if (strlen(namez)) {
++ if (rename(namez, name) < 0) {
++ sprintf(buf, "Error renaming '%s' to '%s': %s",
++ namez, name, ERRSTR(errno));
++ ErrPopUp(buf, "\nBummer!");
++ }
++ }
++
++ return 1;
++}
++
++#define TARBLOCK 512
++#define CKSTART 148 /* XXX */
++#define CKSIZE 8
++
++/*
++ * Tar file: 1, other: 0
++ */
++static int vd_tarc(fname)
++char *fname;
++{
++ FILE *fp;
++ unsigned int sum;
++ char *ckp, buf[TARBLOCK];
++
++ if ((fp = fopen(fname, "r")) == NULL)
++ return 0;
++
++ fread(buf, TARBLOCK, 1, fp);
++ fclose(fp);
++
++ for (sum = 0, ckp = buf + CKSTART;
++ (ckp < buf + CKSTART + CKSIZE) && *ckp != '\0';
++ ckp++) {
++ sum *= 8;
++ if (*ckp == ' ')
++ continue;
++ if (*ckp < '0' || '7' < *ckp)
++ return 0;
++ sum += *ckp - '0';
++ }
++ if (sum != vd_tar_sumchk(buf))
++ return 0;
++
++ return 1;
++}
++
++static unsigned int vd_tar_sumchk(buf)
++char *buf;
++{
++ int i;
++ unsigned int sum = 0;
++
++ for (i = 0; i < CKSTART; i++) {
++ sum += *(buf + i);
++ }
++ sum += ' ' * 8;
++ for (i += 8; i < TARBLOCK; i++) {
++ sum += *(buf + i);
++ }
++ return sum;
++}
++
++
++static int stde = -1; /* fd of stderr */
++static int nul = -1; /* fd of /dev/null */
++
++/*
++ * switch off the output to stderr(bypass to /dev/null).
++ */
++static int stderr_off()
++{
++ if (nul < 0)
++ nul = open("/dev/null", O_RDONLY);
++ if (nul < 0) {
++ fprintf(stderr, "/dev/null open failure\n");
++ return -1;
++ }
++ if (stde < 0)
++ stde = dup(2);
++ if (stde < 0) {
++ fprintf(stderr, "duplicate stderr failure\n");
++ return -1;
++ }
++ close(2);
++ dup(nul);
++ return 0;
++}
++
++/*
++ * turn on stderr output.
++ */
++static int stderr_on()
++{
++ if ((stde < 0) || (nul < 0)) {
++ fprintf(stderr, "stderr_on should call after stderr_off\n");
++ return -1;
++ }
++ close(2);
++ dup(stde);
++ return 0;
++}
++
++/*
++ * popen with no output to stderr.
++ */
++static FILE *popen_nul(prog, mode)
++char *prog, *mode;
++{
++ FILE *fp;
++
++ stderr_off();
++ fp = popen(prog, mode);
++ stderr_on();
++ return fp;
++}
++
++/*
++ * These functions are for SIGNAL.
++ * If XV end by C-c, there are dust of directory which name is .xvvd???,
++ * made by xvvd. Then, I handle SIGINT, and add good finish.
++ */
++void vd_HUPhandler()
++{
++#if defined(SYSV) || defined(SVR4) || defined(__USE_XOPEN_EXTENDED)
++ sighold(SIGHUP);
++#else
++ int mask;
++ mask = sigblock(sigmask(SIGHUP));
++#endif
++
++ Vdsettle();
++
++#if defined(SYSV) || defined(SVR4) || defined(__USE_XOPEN_EXTENDED)
++ sigrelse(SIGHUP);
++ signal(SIGHUP, (void (*)PARM((int))) vd_HUPhandler);
++#else
++ sigsetmask(mask);
++#endif
++}
++
++void vd_handler(sig)
++int sig;
++{
++#if defined(SYSV) || defined(SVR4) || defined(__USE_XOPEN_EXTENDED)
++ sighold(sig);
++#else
++ sigblock(sigmask(sig));
++#endif
++
++ Quit(1); /*exit(1);*/
++}
++
++int vd_Xhandler(disp,event)
++Display *disp;
++XErrorEvent *event;
++{
++ Quit(1); /*exit(1);*/
++ return (1); /* Not reached */
++}
++
++int vd_XIOhandler(disp)
++Display *disp;
++{
++ fprintf(stderr, "XIO fatal IO error ? (?) on X server\n");
++ fprintf(stderr, "You must exit normally in xv usage.\n");
++ Quit(1); /*exit(1);*/
++ return (1); /* Not reached */
++}
++
++void vd_handler_setup()
++{
++ signal(SIGHUP, (void (*)PARM((int))) vd_HUPhandler);
++ signal(SIGINT, (void (*)PARM((int))) vd_handler);
++ signal(SIGTERM,(void (*)PARM((int))) vd_handler);
++
++ (void)XSetErrorHandler(vd_Xhandler);
++ (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 @@
++/*
++ * xvwbmp.c - i/o routings for WBMP files
++ * defined by OMA (http://www.openmobilealliance.com)
++ * as a standard for images for micro devices.
++ *
++ * exports :
++ *
++ * LoadWBMP(fname, numcols);
++ * WriteWBMP(fp, pic, ptype, w, h, r, g, b, numcols, style);
++ *
++ * author: Pawel S. Veselov <vps@manticore.2y.net>
++ * http://manticore.2y.net/
++ *
++ */
++
++#include "xv.h"
++
++typedef short int16;
++typedef unsigned char uint8;
++typedef unsigned short uint16; /* sizeof (uint16) must == 2 */
++#if defined(__alpha) || _MIPS_SZLONG == 64
++typedef int int32;
++typedef unsigned int uint32; /* sizeof (uint32) must == 4 */
++#else
++typedef long int32;
++typedef unsigned long uint32; /* sizeof (uint32) must == 4 */
++#endif
++
++#define MUST(a) if (!(a)) {\
++ return fail(st_fname, st_err);\
++ close(fd); \
++ }
++#define READU8(fd,u) if ((read(fd, &u, 1)<1)) {\
++ myfree(); \
++ close(fd); \
++ return fail(st_fname, err_ueof); }
++#define SREADU8(fd, u) if ((read(fd, &u, 1,)<1)) {\
++ { st_err = err_ueof; return 0; }
++
++#define SREADC(fd, str, l) { \
++ str = (char*)mymalloc(l); \
++ if (!str) { \
++ myfree(); \
++ FatalError("LoadWBMP: can't malloc extension buffer"); \
++ } \
++ if (read(fd, str, l)<l) { \
++ st_err = err_ueof; \
++ 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 char * st_fname;
++static 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));
++
++void ** mymem = NULL;
++int mymems = 0;
++
++int LoadWBMP(char * fname, PICINFO * pinfo)
++{
++ int fd;
++ int im_type; /* image type (only type 0 supported) */
++ uint8 fix_header; /* fixed header field */
++ int width, height;
++ int npixels, raw_size, aux;
++ uint8 * raw;
++
++ st_fname = fname;
++
++ fd = open(fname, O_RDONLY);
++ if (fd < 0) {
++ return fail(fname, "Couldn't open the file");
++ }
++
++ MUST(read_mb(&im_type, fd));
++ if (im_type) {
++ return fail(fname, err_unst);
++ }
++
++ READU8(fd, fix_header);
++
++ MUST(read_ext(fd, fix_header));
++
++ MUST(read_mb(&width, fd));
++ MUST(read_mb(&height, fd));
++
++ npixels = width * height;
++ raw_size = (npixels+7) / 8;
++ if (width <= 0 || height <= 0 || npixels/width != height ||
++ npixels+7 < npixels)
++ {
++ return fail(fname, "image dimensions out of range");
++ }
++
++ raw = mymalloc(raw_size);
++ if (!raw) {
++ myfree();
++ FatalError("LoadWBMP: can't malloc image buffer");
++ }
++
++ aux = read(fd, raw, raw_size);
++ if (aux < raw_size) {
++ fail(fname, "Image size shrank");
++ raw_size = aux;
++ }
++
++ pinfo->r[0] = 0;
++ pinfo->g[0] = 0;
++ pinfo->b[0] = 0;
++ pinfo->r[1] = 255;
++ pinfo->g[1] = 255;
++ pinfo->b[1] = 255;
++
++ pinfo->pic = render1(raw, raw_size, npixels);
++ pinfo->type = PIC8;
++
++ pinfo->w = pinfo->normw = width;
++ pinfo->h = pinfo->normh = height;
++ pinfo->frmType = F_BWDITHER;
++
++ sprintf(pinfo->fullInfo, "WBMP, 1 bit per pixel, %d bytes", raw_size);
++ sprintf(pinfo->shrtInfo, "%dx%d WBMP (WAP/OMA).", width, height);
++ pinfo->comment = (char*)NULL;
++
++ close(fd);
++
++ myfree();
++ 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 count = 0;
++ uint8 bit = 0;
++ int i;
++
++ write_mb(0, fp); /* type : always 0 */
++ putc(0, fp); /* fixed header : always 0 for type 0 */
++ write_mb((uint32)w, fp);
++ write_mb((uint32)h, fp);
++
++ /* ready to write data */
++
++ for (i=0; i<w*h; i++) {
++ bit |= (((pic[i]&1)<<(7-(count++))));
++ if (count == 8) {
++ putc(bit, fp);
++ count = 0;
++ }
++ }
++
++ if (!count) {
++ putc(bit, fp);
++ }
++
++ return 0;
++}
++
++int fail(char * name, char * msg)
++{
++ SetISTR(ISTR_WARNING, "%s : %s", name, msg);
++ return 0;
++}
++
++void write_mb(uint32 data, FILE * f)
++{
++ int i = 32;
++ uint32 aux = data;
++ int no;
++
++ if (!aux) {
++ i = 1;
++ } else {
++ while (!(aux & 0x80000000)) {
++ aux <<= 1;
++ i--;
++ }
++ }
++
++ /* i tells us how many bits are left to encode */
++
++ no = (i / 7 + ((i % 7)?1:0))-1;
++
++ /*
++ fprintf(stderr, "writing %x, bits to write=%d, passes=%d\n",
++ data, i, no);
++ */
++
++ do {
++ uint8 value = no?0x80:0x0;
++ value |= ((data >> (no*7)) & 0x7f);
++ putc(value, f);
++ } while ((no--)>0);
++
++}
++
++int read_mb(int * dst, int fd)
++{
++ int ac = 0;
++ int ct = 0;
++
++ while (1) {
++ uint8 bt;
++ if ((ct++)==6) {
++ st_err = err_inmb;
++ return 0;
++ }
++
++ if ((read(fd, &bt, 1)) < 1) {
++ st_err = err_ueof;
++ return 0;
++ }
++ ac = (ac << 7) | (bt & 0x7f); /* accumulates up to 42 bits?? FIXME */
++ if (!(bt & 0x80))
++ break;
++ }
++ *dst = ac;
++ return 1;
++}
++
++int read_ext(int fd, uint8 fixed)
++{
++ if (!(fixed&0x7f)) { /* no extensions */
++ return 1;
++ }
++
++ /*
++ * The only described type is WBMP 0, that must not
++ * have extensions.
++ */
++
++ st_err = err_extf;
++ return 0;
++
++ /*
++
++ fixed = (fixed >> 5)&0x3;
++
++ switch (fixed) {
++ case 0:
++ while (true) {
++ SREADU8(fd, fixed);
++ if (!(fixed & 0x7f)) { break; }
++ }
++ break;
++ case 0x3:
++ {
++ char * par;
++ char * val;
++ SREADU8(fd, fixed);
++ SREADC(fd, par, (fixed>>4)&0x6);
++ SREADC(fd, val, fixed&0xf);
++ }
++ break;
++ }
++ */
++}
++
++void * mymalloc(int l)
++{
++ mymem = (void**)realloc(mymem, mymems+1);
++ if (!mymem)
++ FatalError("LoadWBMP: can't realloc buffer");
++ return (mymem[mymems++] = malloc(l));
++}
++
++void myfree()
++{
++ int i;
++
++ if (mymem) {
++ for (i=0; i<mymems; i++) {
++ if (mymem[i])
++ free(mymem[i]);
++ }
++ free(mymem);
++ }
++ mymem = (void**)NULL;
++ mymems = 0;
++}
++
++uint8 * render1(uint8 * data, int size, int npixels)
++{
++ byte * pic;
++ int i;
++ int cnt = 0;
++ uint8 cb = *data;
++
++ pic = calloc(npixels,1); /* checked for overflow by caller */
++ if (!pic) {
++ myfree();
++ FatalError("LoadWBMP: can't allocate 'pic' buffer");
++ }
++
++ /* expand bits into bytes */
++ /* memset(pic, 0, npixels); */
++
++ for (i=0; i<npixels; i++) {
++
++ pic[i] = (cb>>7)&1;
++
++ if ((++cnt)==8) {
++ cb = *(++data);
++ cnt = 0;
++ } else {
++ cb <<=1;
++ }
++ }
++ 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
+@@ -0,0 +1,349 @@
++/*
++ * xvzx.c - load routine for Spectrum screen$
++ *
++ * John Elliott, 7 August 1998
++ *
++ * LoadZX(fname, pinfo) - load file
++ * WriteZX(fp,pic,ptype,w,h,r,g,b,numcols,style,cmt,comment) - convert to
++ * 256x192 SCREEN$ and save.
++ */
++
++#include "copyright.h"
++
++#include "xv.h"
++
++
++
++/*
++ * comments on error handling:
++ * a file with a bad header checksum is a warning error.
++ *
++ * not being able to malloc is a Fatal Error. The program is aborted.
++ */
++
++
++#define TRUNCSTR "File appears to be truncated."
++
++static int zxError PARM((char *, char *));
++
++static char *bname;
++
++/*******************************************/
++int LoadZX(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++/*******************************************/
++{
++ /* returns '1' on success */
++
++ FILE *fp;
++ unsigned int c, c1;
++ int x,y, trunc;
++ byte *zxfile;
++
++ bname = BaseName(fname);
++
++ pinfo->pic = (byte *) NULL;
++ pinfo->comment = (char *) NULL;
++
++ /* Allocate memory for a 256x192x8bit image */
++
++ pinfo->pic = (byte *)malloc(256*192);
++ if (!pinfo->pic) FatalError("malloc failure in xvzx.c LoadZX");
++
++ /* Allocate 1B80h bytes and slurp the whole file into memory */
++
++ zxfile = (byte *)malloc(7040);
++ if (!zxfile) FatalError("malloc failure in xvzx.c LoadZX");
++
++ /* open the file */
++ fp = xv_fopen(fname,"r");
++ if (!fp) return (zxError(bname, "can't open file"));
++
++ /* Load it in en bloc */
++ memset(zxfile, 0, 7040);
++ if (fread(zxfile, 1, 7040, fp) < 7040) trunc = 1;
++
++ /* Transform to 8-bit */
++
++ for (y = 0; y < 192; y++) for (x = 0; x < 256; x++)
++ {
++ /* Spectrum screen layout: three 2k segments at y=0, y=64, y=128 */
++ /* In each segment: Scan lines 0,8,16,...,56,1,9,...,57 etc. Each
++ scanline is 32 bytes, so line 1 is 256 bytes after line 0
++
++ So address of line start is ((y>>6) * 2048) + ((y & 7) * 256)
++ + ((y & 0x38) * 4)
++
++ The colour byte for a cell is at screen + 6k + (y >> 3)*32 + (x>>3)
++
++ */
++
++ int offset;
++ byte *dst = pinfo->pic + 256*y + x;
++ byte attr, pt, mask;
++
++ offset = (y >> 6) * 2048;
++ offset += (y & 7) * 256;
++ offset += (y & 0x38) * 4;
++ offset += (x >> 3);
++
++ pt = zxfile[offset + 128]; /* Ink/paper map */
++
++ offset = 0x1880;
++ offset += (y >> 3) * 32;
++ offset += (x >> 3);
++
++ attr = zxfile[offset]; /* Colours for cell */
++
++ mask = 0x80;
++
++ if (x & 7) mask >>= (x & 7);
++
++ if (pt & mask) *dst = attr & 7; /* Ink */
++ else *dst = (attr >> 3) & 7; /* Paper */
++
++ if (attr & 0x40) *dst |= 8; /* High intensity */
++ }
++
++ /* Picture bytes converted; now build the colour maps */
++
++ pinfo->normw = pinfo->w = 256;
++ pinfo->normh = pinfo->h = 192;
++ pinfo->type = PIC8;
++
++ for (c = 0; c < 16; c++)
++ {
++ if (c < 8) c1 = 192; else c1 = 255; /* low-intensity colours use 192 */
++ /* high-intensity colours use 255 */
++ pinfo->b[c] = (c & 1 ? c1 : 0);
++ pinfo->r[c] = (c & 2 ? c1 : 0);
++ pinfo->g[c] = (c & 4 ? c1 : 0);
++ }
++
++ pinfo->colType = F_FULLCOLOR;
++ pinfo->frmType = F_ZX; /* Save as SCREEN$ */
++ sprintf(pinfo->fullInfo, "Spectrum SCREEN$, load address %04x",
++ zxfile[16]+256*zxfile[17]);
++ strcpy(pinfo->shrtInfo, "Spectrum SCREEN$.");
++
++ /* Almost as an afterthought, check that the +3DOS header is valid.
++
++ If it isn't, then odds are that the file isn't a graphic. But it
++ had the right magic number, so it might be. Let them see it anyway.
++
++ The check is: Byte 127 of the header should be the 8-bit sum of bytes
++ 0-126 of the header. The header should also have the
++ +3DOS magic number, but we know it does or we wouldn't
++ have got this far.
++ */
++
++ c1 = 0;
++ for (c1 = c = 0; c < 127; c++) c1 = ((c1 + zxfile[c]) & 0xFF);
++ if (c1 != zxfile[127]) zxError(bname, "Bad header checksum.");
++
++ fclose(fp);
++ free(zxfile);
++ return 1;
++}
++
++
++
++
++
++/*******************************************/
++static int zxError(fname, st)
++ char *fname, *st;
++{
++ SetISTR(ISTR_WARNING,"%s: %s", fname, st);
++ return 0;
++}
++
++
++/* Spectrum screen file header. The first 18 bytes are used in the magic
++ number test */
++
++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 */
++};
++
++
++
++/* Get the Spectrum colour/bright byte (0-15) from a pixel */
++
++static int PointZX(pic, w, h, rmap, gmap, bmap, x, y)
++ byte *pic;
++ int w,h;
++ byte *rmap, *gmap, *bmap;
++ int x,y;
++{
++ int index, r, g, b, zxc;
++
++ /* If the picture is smaller than the screen, pad out the edges
++ with "bright black" - a colour not otherwise returned */
++
++ if (x >= w || y >= h) return 8;
++
++ /* Get colour index */
++
++ index = pic[y*w + x];
++
++ /* Convert to rgb */
++
++ r = rmap[index];
++ g = gmap[index];
++ b = bmap[index];
++ zxc = 0;
++
++ /* Work out Spectrum colour by a simplistic "nearest colour" method */
++
++ if (b >= 160) zxc |= 1; /* Blue */
++ if (r >= 160) zxc |= 2; /* Red */
++ if (g >= 160) zxc |= 4; /* Green */
++ if (r > 208 || g >= 208 || b >= 208) zxc |= 8; /* High intensity */
++
++ return zxc;
++}
++
++
++/* Work out what colours should be used in a cell */
++
++static void CellZX(pic, w, h, rmap, gmap, bmap, cx, cy, zxfile)
++ byte *pic;
++ int w,h;
++ byte *rmap, *gmap, *bmap;
++ int cx,cy;
++ byte *zxfile;
++{
++ byte counts[16]; /* Count of no. of colours */
++ int offset, ink, paper, n, m, x, y, x0, y0, di, dp;
++
++ x0 = cx * 8; /* Convert from cell to pixel coords */
++ y0 = cy * 8;
++
++ for (n = 0; n < 16; n++) counts[n] = 0; /* Reset all counts */
++
++ /* Count no. of pixels of various colours */
++
++ for (y = y0; y < y0+8; y++) for (x = x0; x < x0+8; x++)
++ {
++ m = PointZX(pic, w, h, rmap, gmap, bmap, x, y);
++
++ counts[m]++;
++ }
++ counts[8] = 0; /* Discard Bright Black (pixels not in the picture area)
++ */
++
++ /* Assign the most popular colour as ink */
++ for (n = m = ink = 0; n < 16; n++) if (counts[n] > m)
++ {
++ ink = n;
++ m = counts[n];
++ }
++ counts[ink] = 0;
++
++ /* Assign the next most popular colour as paper */
++ for (n = m = paper = 0; n < 16; n++) if (counts[n] > m)
++ {
++ paper = n;
++ m = counts[n];
++ }
++ /* We have ink and paper. Set cell's attributes */
++
++ offset = cy*32 + cx + 0x1880;
++
++ /* Set the high-intensity bit if ink is high-intensity */
++ if (ink & 8) zxfile[offset] = 0x40; else zxfile[offset] = 0;
++ zxfile[offset] |= ((paper & 7) << 3);
++ zxfile[offset] |= (ink & 7);
++
++ /* Plot the points */
++ for (y = y0; y < y0+8; y++)
++ {
++ byte mask = 0x80;
++
++ offset = (y >> 6) * 2048;
++ offset += (y & 7) * 256;
++ offset += (y & 0x38) * 4;
++ offset += (x0 >> 3);
++
++ for (x = x0; x < x0+8; x++)
++ {
++ /* Work out whether the point should be plotted as ink or
++ paper */
++ m = PointZX(pic, w, h, rmap, gmap, bmap, x, y);
++
++ di = (ink & 7) - (m & 7); /* "Difference" from ink */
++ dp = (paper & 7) - (m & 7); /* "Difference" from paper */
++
++ if (di < 0) di = -di;
++ if (dp < 0) dp = -dp;
++
++ if (di < dp) /* Point is more like ink */
++ zxfile[offset+128] |= mask;
++
++ mask = (mask >> 1);
++ }
++ }
++
++}
++
++
++
++/*******************************************/
++int WriteZX(fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,comment)
++ FILE *fp;
++ byte *pic;
++ int ptype, w,h;
++ byte *rmap, *gmap, *bmap;
++ int numcols, colorstyle;
++ char *comment;
++{
++ int rv, x, y;
++ byte *zxfile;
++ byte *pic8;
++ byte rtemp[256],gtemp[256],btemp[256];
++
++ /* To simplify matters, reduce 24-bit to 8-bit. Since the Spectrum
++ screen is 3.5-bit anyway, it doesn't make much difference */
++
++ if (ptype == PIC24)
++ {
++ pic8 = Conv24to8(pic, w, h, 256, rtemp,gtemp,btemp);
++ if (!pic8) FatalError("Unable to malloc in WriteZX()");
++ rmap = rtemp; gmap = gtemp; bmap = btemp; numcols=256;
++ }
++ else pic8 = pic;
++
++ ZXheader[127] = 0x71; /* The correct checksum. */
++
++ /* Create a memory image of the SCREEN$ */
++
++ zxfile = (byte *)malloc(7040);
++ if (!zxfile) FatalError("malloc failure in xvzx.c WriteZX");
++
++ memset(zxfile, 0, 7040); /* Reset all points to black */
++ memcpy(zxfile, ZXheader, 128); /* Create +3DOS header */
++
++ /* Convert the image, character cell by character cell */
++ for (y = 0; y < 24; y++) for (x = 0; x < 32; x++)
++ {
++ CellZX(pic8, w, h, rmap, gmap, bmap, x, y, zxfile);
++ }
++ rv = 0;
++ if (fwrite(zxfile, 1, 7040, fp) < 7040) rv = -1;
++
++ if (ptype == PIC24) free(pic8);
++ free(zxfile);
++
++ if (ferror(fp)) rv = -1;
++
++ return rv;
++}
++
diff --git a/source/xap/xv/xv-3.10a-jumbo-fix-patch-20050410.txt b/source/xap/xv/xv-3.10a-jumbo-fix-patch-20050410.txt
new file mode 100644
index 00000000..cc4e72d3
--- /dev/null
+++ b/source/xap/xv/xv-3.10a-jumbo-fix-patch-20050410.txt
@@ -0,0 +1,28743 @@
+diff : xv-3.10a-jumbo-fix-patch-20050410.txt
+
+This is a unified diff. It should be applied (using Larry Wall's "patch"
+program) to the stock XV 3.10a sources. If desired, the jumbo-enhancements
+patch may be applied afterward.
+
+diffs below:
+ Makefile
+ Makefile.std
+ README.jumbo
+ bggen.c
+ bits/icon
+ cleandir
+ config.h
+ copyright.h
+ tiff/Makefile
+ tiff/Makefile.std
+ tiff/RANLIB.sh
+ vdcomp.c
+ xcmap.c
+ xv.c
+ xv.h
+ xv24to8.c
+ xvalg.c
+ xvbmp.c
+ xvbrowse.c
+ xvbutt.c
+ xvcolor.c
+ xvctrl.c
+ xvcut.c
+ xvdflt.c
+ xvdial.c
+ xvdir.c
+ xvevent.c
+ xvfits.c
+ xvgam.c
+ xvgif.c
+ xvgifwr.c
+ xvgrab.c
+ xvgraf.c
+ xviff.c
+ xvimage.c
+ xvinfo.c
+ xviris.c
+ xvjpeg.c
+ xvmisc.c
+ xvpbm.c
+ xvpcx.c
+ xvpds.c
+ xvpictoppm.c
+ xvpm.c
+ xvpopup.c
+ xvps.c
+ xvrle.c
+ xvroot.c
+ xvscrl.c
+ xvsmooth.c
+ xvsunras.c
+ xvtarga.c
+ xvtext.c
+ xvtiff.c
+ xvtiffwr.c
+ xvxbm.c
+ xvxpm.c
+ xvxwd.c
+
+
+diff -ruN xv-3.10a/Makefile xv-3.10a-bugfixes/Makefile
+--- xv-3.10a/Makefile 1995-01-23 12:20:54.000000000 -0800
++++ xv-3.10a-bugfixes/Makefile 2005-04-06 08:17:13.000000000 -0700
+@@ -2,7 +2,11 @@
+
+ # your C compiler (and options) of choice
+ CC = cc
+-# CC = gcc -ansi
++#CC = gcc -ansi
++# note that -ansi kills __USE_MISC (gcc 2.95.3), which (at least in Linux)
++# determines whether stdlib.h includes prototypes for mktemp(), random(), etc.
++# (i.e., if you use it, you will get unnecessary compiler warnings)
++#CC = gcc
+
+ # use this if you're using 'cc' on a DEC Alpha (OSF/1) or MIPS (Ultrix) system:
+ # CC = cc -std1 -Olimit 750
+@@ -14,8 +18,13 @@
+ # -Wuninitialized -Wparentheses
+
+
+-CCOPTS = -O
+-
++CCOPTS = -O
++# these are the usual optimization and warning options for gcc; all such
++# warnings but one (mktemp() use) have been eliminated (at least on Linux):
++#CCOPTS = -O3 -Wall
++# for the next step up in gcc noise, try adding -W (but note that it adds a
++# huge number of unused-parameter and signed/unsigned comparison warnings):
++#CCOPTS = -O3 -Wall -W
+
+ ### NOTE: Sun running OpenWindows:
+ ### if you're using a SUN running OPENWINDOWS, you need to add these two
+@@ -27,6 +36,10 @@
+ ### '-I' options on the CCOPTS line to tell the compiler where said files are.
+
+
++# BeOS _may_ need to use a different version (below), but probably not
++CLEANDIR = cleandir
++
++
+ ### Installation locations
+ BINDIR = /usr/local/bin
+ MANDIR = /usr/local/man/man1
+@@ -38,7 +51,7 @@
+
+
+ ########################### CONFIGURATION OPTIONS ############################
+-### NOTE: be sure to check 'config.h', for a few other configuration options
++### NOTE: be sure to check 'config.h', for a few other configuration options
+ ##############################################################################
+
+ ###
+@@ -59,18 +72,25 @@
+ ### if, for whatever reason, you're unable to get the TIFF library to compile
+ ### on your machine, *COMMENT OUT* the following lines
+ ###
+-TIFF = -DDOTIFF
++### GRR 20050319: USE_TILED_TIFF_BOTLEFT_FIX enables an experimental fix for
++### tiled TIFFs with ORIENTATION_BOTLEFT. It may break other tiled TIFFs,
++### or it may be required for certain other TIFF types (e.g., strips with
++### ORIENTATION_BOTLEFT). I don't have a sufficient variety of TIFF test
++### images at hand.
++###
++#TIFF = -DDOTIFF
++TIFF = -DDOTIFF -DUSE_TILED_TIFF_BOTLEFT_FIX
+ TIFFDIR = tiff
+ TIFFINC = -I$(TIFFDIR)
+ TIFFLIB = $(TIFFDIR)/libtiff.a
+ $(TIFFLIB):
+- ( cd $(TIFFDIR) ; make CC='$(CC)' )
++ ( 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:' dependancy
+ ###
+ PDS = -DDOPDS
+
+@@ -78,17 +98,25 @@
+ #----------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.
++# Solaris, etc., uncomment the following line to get mostly there.
+ #UNIX = -DSVR4
+
+
+-#----------Machine Specific Configurations----------
++#----------Machine-Specific Configurations----------
++
++### If you are using a BeOS system, uncomment the following line
++#MCHN = -DUSE_GETCWD -I/usr/X11/include -L/usr/X11/lib
++###
++### The stock version of cleandir now should work for BeOS, too, so try
++### leaving this commented out:
++#CLEANDIR = cleandir.BeOS
++
+
+ ### If you are using an SGI system, uncomment the following line
+ #MCHN = -Dsgi
+
+
+-### For HP-UX, uncomment the following line:
++### For HP-UX, uncomment the following line
+ #MCHN= -Dhpux -D_HPUX_SOURCE
+ # To use old HP compilers (HPUX 7.0 or so), you may need
+ #MCHN= -Dhpux -D_HPUX_SOURCE +Ns4000
+@@ -102,22 +130,22 @@
+
+
+ ### for LINUX, uncomment the following line
+-#MCHN = -DLINUX
++#MCHN = -DLINUX -L/usr/X11R6/lib
+
+
+ # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
+ #MCHN = -Dsco -DPOSIX
+ #
+ # For ODT 2.0 (UNIX 3.2v4) machines, uncomment the following:
+-#MCHN= -Dsco -DPOSIX -DNO_RANDOM
++#MCHN= -Dsco -DPOSIX -DNO_RANDOM
+ #
+ # Also, you should add '-lc -lx' to the end of the LIBS def below
+ # -lx must be after -lc so you get the right directory routines.
+
+
+ # for UMAX V by Encore Computers uncomment the following line for
+-# the portable c compiler, system specific definitions and
+-# location of local X11 library(if site specific, modify -L option)
++# the portable C compiler, system-specific definitions and
++# location of local X11 library (if site-specific, modify -L option)
+ # No other switches should be necessary, or so I'm told...
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+@@ -147,8 +175,8 @@
+ #TIMERS = -DUSLEEP
+
+
+-# if XV locks up whenever you click on *any* of the buttons, the Timer()
+-# function in xvmisc.c is going out to lunch. A simple workaround is to
++# if XV locks up whenever you click on *any* of the buttons, the Timer()
++# function in xvmisc.c is going out to lunch. A simple workaround is to
+ # uncomment the following line:
+ #TIMERS = -DNOTIMER
+
+@@ -160,7 +188,7 @@
+ #DXWM = -DDXWM
+
+
+-# if, during compilation, your system complains about the types
++# if, during compilation, your system complains about the types
+ # 'u_long', 'u_short', 'u_int', etc. as being undefined, uncomment the
+ # following line:
+ #BSDTYPES = -DBSDTYPES
+@@ -188,7 +216,9 @@
+ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
+ $(DXWM) $(MCHN)
+
++### remove -lm for BeOS:
+ LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
++#LIBS = -lX11 $(JPEGLIB) $(TIFFLIB)
+
+ 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 \
+@@ -231,9 +261,10 @@
+
+ clean: xvclean
+ rm -f bggen vdcomp xcmap xvpictoppm
+- ./cleandir $(JPEGDIR)
+- rm -f $(JPEGDIR)/jconfig.h $(JPEGDIR)/Makefile
+- ./cleandir $(TIFFDIR)
++# clean only local jpeg and tiff dirs, not user's or system's copies:
++ ./$(CLEANDIR) jpeg
++ rm -f jpeg/jconfig.h jpeg/Makefile
++ ./$(CLEANDIR) tiff
+
+
+ install: all
+@@ -246,8 +277,9 @@
+ cp docs/xvdocs.ps* $(LIBDIR)
+
+ tar:
++# tar only local jpeg and tiff dirs, not user's or system's copies:
+ tar cvf xv.tar Makefile* Imakefile *.c *.h bits \
+- docs unsupt vms $(JPEGDIR) $(TIFFDIR) $(MISC)
++ docs unsupt vms jpeg tiff $(MISC)
+
+ xvtar:
+ tar cvf xv.tar Makefile* Imakefile *.c *.h bits
+@@ -257,26 +289,26 @@
+
+ ################# bitmap dependencies ####################
+
+-xv.o: bits/icon bits/iconmask bits/runicon bits/runiconm
+-xv.o: bits/cboard50 bits/gray25
++xv.o: bits/icon bits/iconmask bits/runicon bits/runiconm
++xv.o: bits/cboard50 bits/gray25
+
+ xvbrowse.o: bits/br_file bits/br_dir bits/br_exe bits/br_chr bits/br_blk
+-xvbrowse.o: bits/br_sock bits/br_fifo bits/br_error bits/br_unknown
++xvbrowse.o: bits/br_sock bits/br_fifo bits/br_error # bits/br_unknown
+ xvbrowse.o: bits/br_cmpres bits/br_gif bits/br_pm bits/br_pbm
+ xvbrowse.o: bits/br_sunras bits/br_bmp bits/br_utah bits/br_iris
+-xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
++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
+
+ 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
+ xvbutt.o: bits/rb_dot bits/cb_check bits/mb_chk
+
+ xvctrl.o: bits/gray25 bits/gray50 bits/i_fifo bits/i_chr bits/i_dir
+-xvctrl.o: bits/i_blk bits/i_lnk bits/i_sock bits/i_exe bits/i_reg
++xvctrl.o: bits/i_blk bits/i_lnk bits/i_sock bits/i_exe bits/i_reg
+ xvctrl.o: bits/h_rotl bits/h_rotr bits/fliph bits/flipv bits/p10
+-xvctrl.o: bits/m10 bits/cut bits/copy bits/paste bits/clear
++xvctrl.o: bits/m10 bits/cut bits/copy bits/paste bits/clear
+ xvctrl.o: bits/uicon bits/oicon1 bits/oicon2 bits/icon
+ xvctrl.o: bits/padimg bits/annot
+
+@@ -285,13 +317,13 @@
+ xvdflt.o: bits/logo_top bits/logo_bot bits/logo_out bits/xv_jhb
+ xvdflt.o: bits/xv_cpyrt bits/xv_rev bits/xv_ver
+ xvdflt.o: bits/xf_left bits/xf_right bits/font5x9.h
+-xvdflt.o: xvdflt.h
++xvdflt.o: xvdflt.h
+
+ xvdial.o: bits/dial_cw1 bits/dial_ccw1 bits/dial_cw2 bits/dial_ccw2
+
+ xvdir.o: bits/d_load bits/d_save
+
+-xvevent.o: bits/dropper bits/dropperm bits/pen bits/penm
++xvevent.o: bits/dropper bits/dropperm bits/pen bits/penm
+ xvevent.o: bits/blur bits/blurm
+
+ xvgam.o: bits/h_rotl bits/h_rotr bits/h_flip bits/h_sinc bits/h_sdec
+diff -ruN xv-3.10a/Makefile.std xv-3.10a-bugfixes/Makefile.std
+--- xv-3.10a/Makefile.std 1995-01-23 17:06:26.000000000 -0800
++++ xv-3.10a-bugfixes/Makefile.std 2005-04-06 08:17:13.000000000 -0700
+@@ -2,7 +2,11 @@
+
+ # your C compiler (and options) of choice
+ CC = cc
+-# CC = gcc -ansi
++#CC = gcc -ansi
++# note that -ansi kills __USE_MISC (gcc 2.95.3), which (at least in Linux)
++# determines whether stdlib.h includes prototypes for mktemp(), random(), etc.
++# (i.e., if you use it, you will get unnecessary compiler warnings)
++#CC = gcc
+
+ # use this if you're using 'cc' on a DEC Alpha (OSF/1) or MIPS (Ultrix) system:
+ # CC = cc -std1 -Olimit 750
+@@ -14,8 +18,13 @@
+ # -Wuninitialized -Wparentheses
+
+
+-CCOPTS = -O
+-
++CCOPTS = -O
++# these are the usual optimization and warning options for gcc; all such
++# warnings but one (mktemp() use) have been eliminated (at least on Linux):
++#CCOPTS = -O3 -Wall
++# for the next step up in gcc noise, try adding -W (but note that it adds a
++# huge number of unused-parameter and signed/unsigned comparison warnings):
++#CCOPTS = -O3 -Wall -W
+
+ ### NOTE: Sun running OpenWindows:
+ ### if you're using a SUN running OPENWINDOWS, you need to add these two
+@@ -27,6 +36,10 @@
+ ### '-I' options on the CCOPTS line to tell the compiler where said files are.
+
+
++# BeOS _may_ need to use a different version (below), but probably not
++CLEANDIR = cleandir
++
++
+ ### Installation locations
+ BINDIR = /usr/local/bin
+ MANDIR = /usr/local/man/man1
+@@ -38,7 +51,7 @@
+
+
+ ########################### CONFIGURATION OPTIONS ############################
+-### NOTE: be sure to check 'config.h', for a few other configuration options
++### NOTE: be sure to check 'config.h', for a few other configuration options
+ ##############################################################################
+
+ ###
+@@ -59,18 +72,25 @@
+ ### if, for whatever reason, you're unable to get the TIFF library to compile
+ ### on your machine, *COMMENT OUT* the following lines
+ ###
+-TIFF = -DDOTIFF
++### GRR 20050319: USE_TILED_TIFF_BOTLEFT_FIX enables an experimental fix for
++### tiled TIFFs with ORIENTATION_BOTLEFT. It may break other tiled TIFFs,
++### or it may be required for certain other TIFF types (e.g., strips with
++### ORIENTATION_BOTLEFT). I don't have a sufficient variety of TIFF test
++### images at hand.
++###
++#TIFF = -DDOTIFF
++TIFF = -DDOTIFF -DUSE_TILED_TIFF_BOTLEFT_FIX
+ TIFFDIR = tiff
+ TIFFINC = -I$(TIFFDIR)
+ TIFFLIB = $(TIFFDIR)/libtiff.a
+ $(TIFFLIB):
+- ( cd $(TIFFDIR) ; make CC='$(CC)' )
++ ( 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:' dependancy
+ ###
+ PDS = -DDOPDS
+
+@@ -78,17 +98,25 @@
+ #----------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.
++# Solaris, etc., uncomment the following line to get mostly there.
+ #UNIX = -DSVR4
+
+
+-#----------Machine Specific Configurations----------
++#----------Machine-Specific Configurations----------
++
++### If you are using a BeOS system, uncomment the following line
++#MCHN = -DUSE_GETCWD -I/usr/X11/include -L/usr/X11/lib
++###
++### The stock version of cleandir now should work for BeOS, too, so try
++### leaving this commented out:
++#CLEANDIR = cleandir.BeOS
++
+
+ ### If you are using an SGI system, uncomment the following line
+ #MCHN = -Dsgi
+
+
+-### For HP-UX, uncomment the following line:
++### For HP-UX, uncomment the following line
+ #MCHN= -Dhpux -D_HPUX_SOURCE
+ # To use old HP compilers (HPUX 7.0 or so), you may need
+ #MCHN= -Dhpux -D_HPUX_SOURCE +Ns4000
+@@ -102,22 +130,22 @@
+
+
+ ### for LINUX, uncomment the following line
+-#MCHN = -DLINUX
++#MCHN = -DLINUX -L/usr/X11R6/lib
+
+
+ # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
+ #MCHN = -Dsco -DPOSIX
+ #
+ # For ODT 2.0 (UNIX 3.2v4) machines, uncomment the following:
+-#MCHN= -Dsco -DPOSIX -DNO_RANDOM
++#MCHN= -Dsco -DPOSIX -DNO_RANDOM
+ #
+ # Also, you should add '-lc -lx' to the end of the LIBS def below
+ # -lx must be after -lc so you get the right directory routines.
+
+
+ # for UMAX V by Encore Computers uncomment the following line for
+-# the portable c compiler, system specific definitions and
+-# location of local X11 library(if site specific, modify -L option)
++# the portable C compiler, system-specific definitions and
++# location of local X11 library (if site-specific, modify -L option)
+ # No other switches should be necessary, or so I'm told...
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+@@ -147,8 +175,8 @@
+ #TIMERS = -DUSLEEP
+
+
+-# if XV locks up whenever you click on *any* of the buttons, the Timer()
+-# function in xvmisc.c is going out to lunch. A simple workaround is to
++# if XV locks up whenever you click on *any* of the buttons, the Timer()
++# function in xvmisc.c is going out to lunch. A simple workaround is to
+ # uncomment the following line:
+ #TIMERS = -DNOTIMER
+
+@@ -160,7 +188,7 @@
+ #DXWM = -DDXWM
+
+
+-# if, during compilation, your system complains about the types
++# if, during compilation, your system complains about the types
+ # 'u_long', 'u_short', 'u_int', etc. as being undefined, uncomment the
+ # following line:
+ #BSDTYPES = -DBSDTYPES
+@@ -188,7 +216,9 @@
+ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
+ $(DXWM) $(MCHN)
+
++### remove -lm for BeOS:
+ LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
++#LIBS = -lX11 $(JPEGLIB) $(TIFFLIB)
+
+ 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 \
+@@ -231,9 +261,10 @@
+
+ clean: xvclean
+ rm -f bggen vdcomp xcmap xvpictoppm
+- ./cleandir $(JPEGDIR)
+- rm -f $(JPEGDIR)/jconfig.h $(JPEGDIR)/Makefile
+- ./cleandir $(TIFFDIR)
++# clean only local jpeg and tiff dirs, not user's or system's copies:
++ ./$(CLEANDIR) jpeg
++ rm -f jpeg/jconfig.h jpeg/Makefile
++ ./$(CLEANDIR) tiff
+
+
+ install: all
+@@ -246,8 +277,9 @@
+ cp docs/xvdocs.ps* $(LIBDIR)
+
+ tar:
++# tar only local jpeg and tiff dirs, not user's or system's copies:
+ tar cvf xv.tar Makefile* Imakefile *.c *.h bits \
+- docs unsupt vms $(JPEGDIR) $(TIFFDIR) $(MISC)
++ docs unsupt vms jpeg tiff $(MISC)
+
+ xvtar:
+ tar cvf xv.tar Makefile* Imakefile *.c *.h bits
+@@ -257,26 +289,26 @@
+
+ ################# bitmap dependencies ####################
+
+-xv.o: bits/icon bits/iconmask bits/runicon bits/runiconm
+-xv.o: bits/cboard50 bits/gray25
++xv.o: bits/icon bits/iconmask bits/runicon bits/runiconm
++xv.o: bits/cboard50 bits/gray25
+
+ xvbrowse.o: bits/br_file bits/br_dir bits/br_exe bits/br_chr bits/br_blk
+-xvbrowse.o: bits/br_sock bits/br_fifo bits/br_error bits/br_unknown
++xvbrowse.o: bits/br_sock bits/br_fifo bits/br_error # bits/br_unknown
+ xvbrowse.o: bits/br_cmpres bits/br_gif bits/br_pm bits/br_pbm
+ xvbrowse.o: bits/br_sunras bits/br_bmp bits/br_utah bits/br_iris
+-xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
++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
+
+ 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
+ xvbutt.o: bits/rb_dot bits/cb_check bits/mb_chk
+
+ xvctrl.o: bits/gray25 bits/gray50 bits/i_fifo bits/i_chr bits/i_dir
+-xvctrl.o: bits/i_blk bits/i_lnk bits/i_sock bits/i_exe bits/i_reg
++xvctrl.o: bits/i_blk bits/i_lnk bits/i_sock bits/i_exe bits/i_reg
+ xvctrl.o: bits/h_rotl bits/h_rotr bits/fliph bits/flipv bits/p10
+-xvctrl.o: bits/m10 bits/cut bits/copy bits/paste bits/clear
++xvctrl.o: bits/m10 bits/cut bits/copy bits/paste bits/clear
+ xvctrl.o: bits/uicon bits/oicon1 bits/oicon2 bits/icon
+ xvctrl.o: bits/padimg bits/annot
+
+@@ -285,13 +317,13 @@
+ xvdflt.o: bits/logo_top bits/logo_bot bits/logo_out bits/xv_jhb
+ xvdflt.o: bits/xv_cpyrt bits/xv_rev bits/xv_ver
+ xvdflt.o: bits/xf_left bits/xf_right bits/font5x9.h
+-xvdflt.o: xvdflt.h
++xvdflt.o: xvdflt.h
+
+ xvdial.o: bits/dial_cw1 bits/dial_ccw1 bits/dial_cw2 bits/dial_ccw2
+
+ xvdir.o: bits/d_load bits/d_save
+
+-xvevent.o: bits/dropper bits/dropperm bits/pen bits/penm
++xvevent.o: bits/dropper bits/dropperm bits/pen bits/penm
+ xvevent.o: bits/blur bits/blurm
+
+ xvgam.o: bits/h_rotl bits/h_rotr bits/h_flip bits/h_sinc bits/h_sdec
+diff -ruN xv-3.10a/README.jumbo xv-3.10a-bugfixes/README.jumbo
+--- xv-3.10a/README.jumbo 1969-12-31 16:00:00.000000000 -0800
++++ xv-3.10a-bugfixes/README.jumbo 2005-04-10 19:55:23.000000000 -0700
+@@ -0,0 +1,387 @@
++These are the latest versions 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 two 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, 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
++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.)
++
++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/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.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.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.)
++
++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.
++
++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)
++ 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)
++ GRR = Greg Roelofs (http://pobox.com/~newt/)
++ GV = Guido Vollbeding (http://sylvana.net/guido/)
++ 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/)
++ LCN = Landon Curt "chongo" Noll (http://www.isthe.com/chongo/)
++ 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)
++ TA = Tim Adye (http://hepwww.rl.ac.uk/Adye/xv-psnewstyle.html)
++
++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.)
++
++GRR 20050410
++
++
++How to build
++------------
++
++The following assumes you, the user, already have the libtiff,[1]
++libjpeg,[2] libpng,[3] and zlib[4] libraries downloaded, patched (if
++necessary), compiled, and installed, not to mention a C compiler and
++the bzip2,[5] tar,[6] patch,[7] and make[8] utilities. You should also
++have downloaded the original XV 3.10a source distribution from the XV
++Downloads page[9] and be able to edit its Makefile and config.h files
++as indicated in the INSTALL file. 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://sources.redhat.com/bzip2/
++ [6] http://www.gnu.org/directory/devel/specific/tar.html
++ [7] http://www.gnu.org/directory/devel/specific/patch.html
++ [8] http://www.gnu.org/directory/devel/specific/make.html
++ [9] http://www.trilon.com/xv/downloads.html#src-distrib
++
+++-------------------------------------------------------------------------+
++| |
++| BIG SCARY WARNING |
++| |
++| These patches work for Greg (and parts of them apparently 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 that |
++| 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:
++
++ bzip2 -dc xv-3.10a-jumbo-patches-20050410.tar.bz2 | tar xvf -
++ (or tar xvzf xv-3.10a-jumbo-patches-20050410.tar.gz)
++
++ tar xvzf xv-3.10a.tar.gz
++
++ cd xv-3.10a
++
++ patch -p1 < ../xv-3.10a-jumbo-fix-patch-20050410.txt
++
++ [optional] patch -p1 < ../xv-3.10a-jumbo-enh-patch-20050410.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
++
++That wasn't so hard, was it?
++
++
++Summary of incorporated and unincorporated 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]
++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
++ (from http://www.coara.or.jp/~sudakyo/XV_jp.html)
++ - 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)
++
++
++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-- 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 [??]
++
++ - 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?]
++
++ - 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
++ - 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)
++ - fix for spacebar-for-next-image getting stuck at first text file
++ - 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
++
++
++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
++ (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)
+diff -ruN xv-3.10a/bggen.c xv-3.10a-bugfixes/bggen.c
+--- xv-3.10a/bggen.c 1994-12-22 14:34:41.000000000 -0800
++++ xv-3.10a-bugfixes/bggen.c 2004-05-16 17:50:52.000000000 -0700
+@@ -18,6 +18,11 @@
+ #include <stdio.h>
+ #include <math.h>
+
++#ifdef __STDC__
++# include <stdlib.h> /* atoi() */
++# include <ctype.h> /* isdigit() */
++#endif
++
+ #ifndef M_PI
+ # define M_PI 3.1415926535897932385
+ #endif
+@@ -46,8 +51,8 @@
+
+ typedef unsigned char byte;
+
+-struct color { int r,g,b;
+- int y;
++struct color { int r,g,b;
++ int y;
+ } colors[MAXCOLS], *cur, *nex;
+
+ int numcols;
+@@ -62,7 +67,7 @@
+ double computeDist PARM((int, int, int, int, int));
+ void writePPM PARM((byte *, int, int, int));
+
+-
++
+ /*************************************/
+ int main(argc,argv)
+ int argc;
+@@ -80,18 +85,18 @@
+ char *geom = NULL;
+ char *rptgeom = NULL;
+
+-
++
+ #ifdef VMS
+ getredirection(&argc, &argv);
+ #endif
+-
++
+
+ for (i=1; i<argc; i++) {
+ if (!strncmp(argv[i],"-d",(size_t) 2)) { /* -d disp */
+ i++; if (i<argc) dname = argv[i];
+ }
+ }
+-
++
+ if ((theDisp = XOpenDisplay(dname)) == NULL) {
+ fprintf(stderr,"bggen: Warning - can't open display, screen %s",
+ "size unknown, color names not accepted.\n");
+@@ -99,41 +104,41 @@
+
+
+ cnt = 0; numcols = 0;
+-
++
+ /* parse cmd-line args */
+ for (i=1; i<argc; i++) {
+ if (!strcmp(argv[i],"-h")) { /* -h high */
+ i++; if (i<argc) high = atoi(argv[i]);
+ hset++;
+ }
+-
++
+ else if (!strcmp(argv[i],"-w")) { /* -w wide */
+ i++; if (i<argc) wide = atoi(argv[i]);
+ wset++;
+ }
+-
++
+ else if (!strcmp(argv[i],"-b")) { /* -b bits */
+ i++; if (i<argc) bits = atoi(argv[i]);
+ }
+-
++
+ else if (!strncmp(argv[i],"-g",(size_t) 2)) { /* -g geom */
+ i++; if (i<argc) geom = argv[i];
+ }
+-
++
+ else if (!strncmp(argv[i],"-d",(size_t) 2)) { /* -d disp */
+ i++; if (i<argc) dname = argv[i];
+ }
+-
++
+ else if (!strcmp(argv[i],"-G")) { /* -G rptgeom */
+ i++; if (i<argc) rptgeom = argv[i];
+ }
+-
++
+ else if (!strncmp(argv[i],"-a",(size_t) 2)) doascii++; /* -a */
+-
++
+ else if (!strcmp(argv[i],"-r")) { /* -r rot */
+ i++; if (i<argc) rot = atoi(argv[i]);
+ }
+-
++
+ else if (argv[i][0]=='-') usage(); /* any other '-' option is unknown */
+
+ else if (isdigit(argv[i][0])) {
+@@ -143,7 +148,7 @@
+ case 2: colors[numcols].b = atoi(argv[i]); break;
+ }
+ cnt++;
+-
++
+ if (cnt==3) {
+ if (numcols<MAXCOLS) numcols++;
+ cnt = 0;
+@@ -176,50 +181,50 @@
+ }
+ }
+ }
+-
+-
+-
++
++
++
+ /* print error/usage message, if appropriate */
+ if (cnt || numcols==0 || high<1 || wide<1 || bits<1 || bits>8) usage();
+-
+-
++
++
+ if (geom) {
+ int x,y; unsigned int w,h;
+ i = XParseGeometry(geom, &x, &y, &w, &h);
+ if (i&WidthValue) { wset++; wide = (int) w; }
+ if (i&HeightValue) { hset++; high = (int) h; }
+ }
+-
+-
++
++
+ /* attempt to connect to X server and get screen dimensions */
+ if (theDisp) {
+ i = DefaultScreen(theDisp);
+ if (!wset) wide = DisplayWidth(theDisp, i);
+ if (!hset) high = DisplayHeight(theDisp, i);
+ }
+-
+-
++
++
+ /* normalize 'rot' */
+ while (rot< 0) rot += 360;
+ while (rot>=360) rot -= 360;
+-
+-
++
++
+ rptwide = wide; rpthigh = high;
+ if (rptgeom) {
+ int x,y; unsigned int w,h;
+ i = XParseGeometry(rptgeom, &x, &y, &w, &h);
+ if (i&WidthValue) rptwide = (int) w;
+ if (i&HeightValue) rpthigh = (int) h;
+-
++
+ RANGE(rptwide, 1, wide);
+ RANGE(rpthigh, 1, high);
+ }
+-
+-
+
+-
++
++
++
+ rpic24 = (byte *) malloc(rptwide * rpthigh * 3 * sizeof(byte));
+- if (rptwide != wide || rpthigh != high)
++ if (rptwide != wide || rpthigh != high)
+ pic24 = (byte *) malloc(wide * high * 3 * sizeof(byte));
+ else pic24 = rpic24;
+
+@@ -229,7 +234,7 @@
+ exit(1);
+ }
+ for (i=0, pp=pic24; i<wide*high*3; i++) *pp++ = 0;
+-
++
+
+
+ /*** generate image ***/
+@@ -244,34 +249,34 @@
+ }
+ }
+ }
+-
+-
++
++
+ else if (rot==0) { /* un-rotated linear (vertical) gradient */
+ for (i=0; i<numcols; i++)
+ colors[i].y = ((rpthigh-1) * i) / (numcols-1);
+-
++
+ cur = &colors[0]; nex = cur+1;
+-
++
+ for (i=0; i<rpthigh; i++) {
+ pp = rpic24 + (i * rptwide * 3);
+
+ /* advance to next pair of colors if we're outside region */
+ while (nex->y < i) { cur++; nex++; }
+-
++
+ r = cur->r + ((nex->r - cur->r) * (i - cur->y)) / (nex->y - cur->y);
+ g = cur->g + ((nex->g - cur->g) * (i - cur->y)) / (nex->y - cur->y);
+ b = cur->b + ((nex->b - cur->b) * (i - cur->y)) / (nex->y - cur->y);
+-
++
+ r = r & bmask[bits-1];
+ g = g & bmask[bits-1];
+ b = b & bmask[bits-1];
+-
++
+ for (j=0; j<rptwide; j++) {
+ *pp++ = (byte) r; *pp++ = (byte) g; *pp++ = (byte) b;
+ }
+ }
+ }
+-
++
+ else dorot(rpic24, rptwide, rpthigh, rot);
+
+
+@@ -293,7 +298,7 @@
+ y = ((i-ay) % rpthigh);
+
+ sp = rpic24 + (y * rptwide + x) * 3;
+-
++
+ pp[0] = *sp++; pp[1] = *sp++; pp[2] = *sp++;
+ }
+ }
+@@ -355,12 +360,12 @@
+ mind = computeDist(w-1, 0, cx, cy, rot);
+ maxd = computeDist(0, h-1, cx, cy, rot);
+ }
+-
++
+ del = maxd - mind; /* maximum distance */
+-
++
+ distdebug = 0;
+-
+-
++
++
+ for (y=0; y<h; y++) {
+ pp = pic + (y * w * 3);
+ for (x=0; x<w; x++) {
+@@ -368,11 +373,11 @@
+ rat = (d - mind) / del;
+ if (rat<0.0) rat = 0.0;
+ if (rat>1.0) rat = 1.0;
+-
++
+ cval = rat * nc1;
+ bc = floor(cval);
+ crat = cval - bc;
+-
++
+ if (bc < nc1) {
+ r = colors[bc].r + crat * (colors[bc+1].r - colors[bc].r);
+ g = colors[bc].g + crat * (colors[bc+1].g - colors[bc].g);
+@@ -383,7 +388,7 @@
+ g = colors[nc1].g;
+ b = colors[nc1].b;
+ }
+-
++
+ *pp++ = (byte) r; *pp++ = (byte) g; *pp++ = (byte) b;
+ }
+ }
+@@ -395,9 +400,9 @@
+ int x,y,cx,cy,rot;
+ {
+ /* rot has to be in range 0-359 */
+-
+- double x1, y1, x2, y2, x3, y3, d, d1, b, theta;
+-
++
++ double x1, y1, x2, y2, x3, y3, d, d1, b;
++
+ if (rot == 0) return (double) (y - cy);
+ if (rot == 180) return (double) (cy - y);
+
+@@ -407,7 +412,7 @@
+ /* x2,y2 = vertical projection onto a || line that runs through cx,cy */
+ x2 = x1;
+ y2 = cy - (cx-x2)*tant1;
+-
++
+ d1 = y2 - y1; /* vertical distance between lines */
+ b = d1 * cost1;
+
+@@ -435,11 +440,11 @@
+ int w,h,doascii;
+ {
+ /* dumps a pic24 in PPM format to stdout */
+-
++
+ int x,y;
+-
++
+ printf("P%s %d %d 255\n", (doascii) ? "3" : "6", w, h);
+-
++
+ for (y=0; y<h; y++) {
+ if (doascii) {
+ for (x=0; x<w; x++, pic+=3)
+diff -ruN xv-3.10a/bits/icon xv-3.10a-bugfixes/bits/icon
+--- xv-3.10a/bits/icon 1994-12-22 14:35:28.000000000 -0800
++++ xv-3.10a-bugfixes/bits/icon 2004-04-28 00:53:10.000000000 -0700
+@@ -1,5 +1,6 @@
+ #define icon_width 40
+ #define icon_height 32
++#ifndef OMIT_ICON_BITS
+ static unsigned char icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
+@@ -15,3 +16,4 @@
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
++#endif
+diff -ruN xv-3.10a/cleandir xv-3.10a-bugfixes/cleandir
+--- xv-3.10a/cleandir 1994-12-22 14:34:50.000000000 -0800
++++ xv-3.10a-bugfixes/cleandir 2004-05-10 23:19:16.000000000 -0700
+@@ -1,9 +1,13 @@
+-#!/bin/csh -f
++#!/bin/sh -f
+ # cleandir: if called with an argument, cd's there and does a 'make clean'
+ #
+
+-if ( x$1 != x ) then
+- echo "cleaning $1 subdirectory"
+- cd $1
+- make clean
+-endif
++if [ x"$1" != x ]; then
++ if [ -f "$1"/makefile -o -f "$1"/Makefile ]; then
++ echo "cleaning '$1' subdirectory"
++ cd "$1"
++ make clean
++# else
++# echo "no makefile found; NOT cleaning '$1' subdirectory"
++ fi
++fi
+diff -ruN xv-3.10a/config.h xv-3.10a-bugfixes/config.h
+--- xv-3.10a/config.h 1995-01-05 10:49:21.000000000 -0800
++++ xv-3.10a-bugfixes/config.h 2005-03-21 23:21:31.000000000 -0800
+@@ -8,9 +8,9 @@
+ *
+ * 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
++ * 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,
++ * definition appropriately. (use 'which gunzip' to find if you have gunzip,
+ * and where it lives)
+ */
+ #undef USE_GUNZIP
+@@ -19,7 +19,8 @@
+ # ifdef VMS
+ # define GUNZIP "UNCOMPRESS"
+ # else
+-# define GUNZIP "/usr/local/bin/gunzip -q"
++/* define GUNZIP "/usr/local/bin/gunzip -q" */
++# define GUNZIP "/usr/bin/gzip -dq" /* more portable */
+ # endif
+ #endif
+
+@@ -70,18 +71,18 @@
+ * PostScript file input support:
+ *
+ * if you have the 'ghostscript' package installed (version 2.6 or later),
+- * XV can use it to read and display PostScript files. To do so,
++ * XV can use it to read and display PostScript files. To do so,
+ * uncomment the '#define GS_PATH' line, below. You probably will not
+ * need to modify the GS_LIB or GS_DEV lines, but if you do modify them,
+ * be sure to uncomment them, as well.
+ *
+- * the ghostscript package can be acquired via anonymous ftp on
++ * the ghostscript package can be acquired via anonymous ftp on
+ * prep.ai.mit.edu, in the 'pub/gnu' directory
+ *
+- * GS_PATH specifies the complete path to your gs executable.
++ * GS_PATH specifies the complete path to your gs executable.
+ *
+- * GS_LIB should be set if there's some other gs libs that should be
+- * searched, but aren't by default. (In which case you should probably
++ * GS_LIB should be set if there's some other gs libs that should be
++ * searched, but aren't by default. (In which case you should probably
+ * just fix your 'gs' so it looks in the right places without being told...)
+ *
+ * GS_DEV is the file format that ghostscript will convert PS into. It
+@@ -97,7 +98,7 @@
+ * 'old-style' XV logo image:
+ *
+ * XV now has a nifty, new logo image. The downside is that it increases
+- * the size of the 'xv' executable by 250K or so, and it's possible that
++ * the size of the 'xv' executable by 250K or so, and it's possible that
+ * your compiler may choke while compiling 'xvdflt.c'. If you're compiler
+ * can't handle it, or you're running Linux on a system with minimal memory,
+ * change 'undef' to 'define' in the following line
+@@ -108,8 +109,8 @@
+
+ /***************************************************************************
+ * Backing Store:
+- *
+- * XV can request that 'Backing Store' may be turned on ('WhenMapped') for
++ *
++ * XV can request that 'Backing Store' may be turned on ('WhenMapped') for
+ * several of its windows, which may help performance over a slow network
+ * connection. However, it has been known to behave strangely (or crash)
+ * on some X servers, so it's left here as an option. If you run into trouble
+diff -ruN xv-3.10a/copyright.h xv-3.10a-bugfixes/copyright.h
+--- xv-3.10a/copyright.h 1994-12-22 14:34:56.000000000 -0800
++++ xv-3.10a-bugfixes/copyright.h 2004-05-16 17:53:11.000000000 -0700
+@@ -1,11 +1,11 @@
+ /* Copyright Notice
+ * ================
+ * Copyright 1989, 1994 by John Bradley
+- *
+- * Permission to copy and distribute XV in its entirety, for non-commercial
+- * purposes, is hereby granted without fee, provided that this license
++ *
++ * Permission to copy and distribute XV in its entirety, for non-commercial
++ * purposes, is hereby granted without fee, provided that this license
+ * information and copyright notice appear unmodified in all copies.
+- *
++ *
+ * Note that distributing XV 'bundled' in with any product is considered
+ * to be a 'commercial purpose'.
+ *
+@@ -13,16 +13,16 @@
+ * and/or configured to be in their 'unregistered copy' mode, so that it
+ * is made obvious to the user that XV is shareware, and that they should
+ * consider donating, or at least reading this License Info.
+- *
++ *
+ * The software may be modified for your own purposes, but modified
+ * versions may not be distributed without prior consent of the author.
+- *
++ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the author be held liable for any damages
+ * arising from the use of this software.
+- *
++ *
+ * If you would like to do something with XV that this copyright
+- * prohibits (such as distributing it with a commercial product,
++ * prohibits (such as distributing it with a commercial product,
+ * using portions of the source in some other program, etc.), please
+ * contact the author (preferably via email). Arrangements can
+ * probably be worked out.
+@@ -34,13 +34,13 @@
+ * larger donations are quite welcome. Folks who donate $25 or more
+ * can receive a Real Nice bound copy of the XV manual for no extra
+ * charge.
+- *
++ *
+ * Commercial, government, and institutional users must register their
+ * copies of XV, for the price of $25 per workstation/X terminal or per
+ * XV user, whichever is less. Note that it does NOT say 'simultaneous user',
+- * but rather, the total number of people who use XV on any sort of
+- * recurring basis. Site licenses are available (and recommended) for those
+- * who wish to run XV on a large (>10) number of machines.
++ * but rather, the total number of people who use XV on any sort of
++ * recurring basis. Site licenses are available (and recommended) for those
++ * who wish to run XV on a large (>10) number of machines.
+ * Contact the author for more details.
+ *
+ * The author may be contacted via:
+diff -ruN xv-3.10a/tiff/Makefile xv-3.10a-bugfixes/tiff/Makefile
+--- xv-3.10a/tiff/Makefile 1994-12-22 14:35:12.000000000 -0800
++++ xv-3.10a-bugfixes/tiff/Makefile 2004-05-16 18:49:11.000000000 -0700
+@@ -30,8 +30,10 @@
+ # OF THIS SOFTWARE.
+ #
+
+-AR= ar
+-RANLIB= ./RANLIB.csh
++AR= ar
++CHMOD= chmod
++#RANLIB= ./RANLIB.csh
++RANLIB= ./RANLIB.sh
+
+ IPATH= -I.
+
+@@ -60,6 +62,7 @@
+
+ ${ALL}: ${OBJS}
+ ${AR} rc libtiff.a $?
++ ${CHMOD} +x ${RANLIB}
+ ${RANLIB} libtiff.a
+
+ ${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
+diff -ruN xv-3.10a/tiff/Makefile.std xv-3.10a-bugfixes/tiff/Makefile.std
+--- xv-3.10a/tiff/Makefile.std 1994-12-22 14:35:16.000000000 -0800
++++ xv-3.10a-bugfixes/tiff/Makefile.std 2004-05-16 18:50:39.000000000 -0700
+@@ -30,8 +30,10 @@
+ # OF THIS SOFTWARE.
+ #
+
+-AR= /bin/ar
+-RANLIB= ./RANLIB.csh
++AR= /bin/ar
++CHMOD= chmod
++#RANLIB= ./RANLIB.csh
++RANLIB= ./RANLIB.sh
+
+ IPATH= -I.
+
+@@ -60,6 +62,7 @@
+
+ ${ALL}: ${OBJS}
+ ${AR} rc libtiff.a $?
++ ${CHMOD} +x ${RANLIB}
+ ${RANLIB} libtiff.a
+
+ ${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
+diff -ruN xv-3.10a/tiff/RANLIB.sh xv-3.10a-bugfixes/tiff/RANLIB.sh
+--- xv-3.10a/tiff/RANLIB.sh 1969-12-31 16:00:00.000000000 -0800
++++ xv-3.10a-bugfixes/tiff/RANLIB.sh 2004-05-10 23:31:38.000000000 -0700
+@@ -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
++#
++
++echo "executing 'ranlib $1'..."
++
++# Is there a ranlib? Let's try and then suffer the consequences...
++ranlib $1 >& /dev/null
++
++if [ $? -ne 0 ]; then
++ echo "There doesn't seem to be a ranlib on this system..."
++ echo "Don't worry about it."
++fi
++
++echo ""
++echo ""
++
+diff -ruN xv-3.10a/vdcomp.c xv-3.10a-bugfixes/vdcomp.c
+--- xv-3.10a/vdcomp.c 1994-12-22 14:34:47.000000000 -0800
++++ xv-3.10a-bugfixes/vdcomp.c 2005-03-20 17:48:59.000000000 -0800
+@@ -5,8 +5,8 @@
+ /* Decompresses images using Kris Becker's subroutine DECOMP.C */
+ /* which is included in this program in a shortened version. */
+ /* */
+-/* Reads a variable length compressed PDS image and outputs a */
+-/* fixed length uncompressed image file in PDS format with */
++/* Reads a variable-length compressed PDS image and outputs a */
++/* fixed-length uncompressed image file in PDS format with */
+ /* labels, image histogram, engineering table, line header table */
+ /* and an image with PDS, FITS, VICAR or no labels. If used on */
+ /* a non-byte-swapped machine the image histogram is un-swapped. */
+@@ -108,7 +108,9 @@
+ !defined(bsd43) && \
+ !defined(aux) && \
+ !defined(__bsdi__) && \
+- !defined(sequent)
++ !defined(sequent) && \
++ !defined(__FreeBSD__) && \
++ !defined(__OpenBSD__)
+
+ # if defined(hp300) || defined(hp800) || defined(NeXT)
+ # include <sys/malloc.h> /* it's in 'sys' on HPs and NeXT */
+@@ -121,15 +123,17 @@
+
+ #include <X11/Xos.h>
+
+-#define TRUE 1
+-#define FALSE 0
++#define TRUE 1
++#define FALSE 0
+
+- /* pc i/o defines */
+-#define O_BINARY 0x8000 /* file mode is binary */
++#define NAMELEN 1024 /* inname and outname sizes */
+
+- /* vax i/o defines */
+-#define RECORD_TYPE "rfm=fix" /* VAX fixed length output */
+-#define CTX "ctx=bin" /* no translation of \n */
++ /* PC I/O defines */
++#define O_BINARY 0x8000 /* file mode is binary */
++
++ /* VAX/VMS I/O defines */
++#define RECORD_TYPE "rfm=fix" /* VAX/VMS fixed-length output */
++#define CTX "ctx=bin" /* no translation of \n */
+ #define FOP "fop=cif,sup" /* file processing ops */
+
+ typedef struct leaf { struct leaf *right;
+@@ -176,7 +180,7 @@
+
+ int infile;
+ FILE *outfile;
+-char inname[1024],outname[1024];
++char inname[NAMELEN], outname[NAMELEN];
+ int output_format;
+ int record_bytes, max_lines;
+ int line_samples, fits_pad;
+@@ -185,8 +189,8 @@
+
+ /*************************************************/
+ int main(argc,argv)
+- int argc;
+- char **argv;
++ int argc;
++ char **argv;
+ {
+ unsigned char ibuf[2048],obuf[2048];
+ unsigned char blank=32;
+@@ -200,12 +204,12 @@
+ /* */
+ /*********************************************************************/
+
+- strcpy(inname," ");
++ strcpy(inname," ");
+ strcpy(outname," ");
+ output_format = 0;
+
+ if (argc == 1); /* prompt user for parameters */
+- else if (argc == 2 && (strncmp(argv[1],"help",(size_t) 4) == 0 ||
++ else if (argc == 2 && (strncmp(argv[1],"help",(size_t) 4) == 0 ||
+ strncmp(argv[1],"HELP",(size_t) 4) == 0 ||
+ strncmp(argv[1],"?", (size_t) 1) == 0)) {
+ fprintf(stderr,
+@@ -214,18 +218,22 @@
+ fprintf(stderr," infile - name of compressed image file. \n");
+ fprintf(stderr," outfile - name of uncompressed output file.\n");
+ fprintf(stderr," output format - selected from the following list:\n");
+- fprintf(stderr,"\n");
+- fprintf(stderr," 1 SFDU/PDS format [DEFAULT].\n");
+- fprintf(stderr," 2 FITS format. \n");
+- fprintf(stderr," 3 VICAR format. \n");
+- fprintf(stderr," 4 Unlabelled binary array. \n\n");
++ fprintf(stderr,"\n");
++ fprintf(stderr," 1 SFDU/PDS format [DEFAULT].\n");
++ fprintf(stderr," 2 FITS format. \n");
++ fprintf(stderr," 3 VICAR format. \n");
++ fprintf(stderr," 4 Unlabelled binary array. \n\n");
+ exit(1);
+- }
++ }
+ else {
+- strcpy(inname,argv[1]);
+- if (argc >= 3) strcpy(outname,argv[2]);
++ strncpy(inname, argv[1], sizeof(inname)-1);
++ inname[sizeof(inname)-1] = '\0';
++ if (argc >= 3) {
++ strncpy(outname, argv[2], sizeof(outname)-1);
++ outname[sizeof(outname)-1] = '\0';
++ }
+ if (argc == 3) output_format = 1;
+- if (argc == 4) sscanf(argv[3],"%d",&output_format);
++ if (argc == 4) sscanf(argv[3],"%d",&output_format);
+ }
+
+ host = check_host();
+@@ -244,13 +252,13 @@
+ case 4: no_labels(host); break;
+ }
+
+- if (record_bytes == 836) { /* set up values for image sizes */
++ if (record_bytes == 836) { /* set up values for image sizes */
+ max_lines = 800;
+ fits_pad = 2240;
+ line_samples = 800;
+ }
+ else {
+- max_lines = 1056;
++ max_lines = 1056;
+ fits_pad = 1536;
+ line_samples = 1204;
+ }
+@@ -394,12 +402,12 @@
+ if (record_bytes == 1204) /* do checksum for viking */
+ for (i=0; i<record_bytes; i++) checksum += (int)obuf[i];
+
+- if ((line % 100 == 0) && (outfile != stdout))
++ if ((line % 100 == 0) && (outfile != stdout))
+ fprintf(stderr,"\nline %d",line);
+
+ } while (length > 0 && line < max_lines);
+
+- if (record_bytes == 1204 && (outfile != stdout))
++ if (record_bytes == 1204 && (outfile != stdout))
+ /* print checksum for viking */
+ fprintf(stderr,"\n Image label checksum = %d computed checksum = %d\n",
+ label_checksum,checksum);
+@@ -425,33 +433,36 @@
+ /*********************************************************************/
+
+ int get_files(host)
+-int host;
++ int host;
+ {
+- short shortint;
+ typedef long off_t;
++ short shortint;
++ char *s;
+
+ if (inname[0] == ' ') {
+ printf("\nEnter name of file to be decompressed: ");
+- gets (inname);
++ fgets(inname, sizeof(inname), stdin);
++ if ((s = strchr(inname, '\n')) != NULL)
++ *s = '\0';
+ }
+
+- if (host == 1 | host == 2) {
+- if ((infile = open(inname,O_RDONLY | O_BINARY)) <= 0) {
+- fprintf(stderr,"\ncan't open input file: %s\n",inname);
++ if (host == 1 || host == 2) {
++ if ((infile = open(inname, O_RDONLY | O_BINARY)) <= 0) {
++ fprintf(stderr,"\ncan't open input file: %s\n", inname);
+ exit(1);
+ }
+ }
+- else if (host == 3 | host == 5) {
+- if ((infile = open(inname,O_RDONLY)) <= 0) {
+- fprintf(stderr,"\ncan't open input file: %s\n",inname);
++ else if (host == 3 || host == 5) {
++ if ((infile = open(inname, O_RDONLY)) <= 0) {
++ fprintf(stderr,"\ncan't open input file: %s\n", inname);
+ exit(1);
+ }
+
+ /****************************************************************/
+- /* If we are on a vax see if the file is in var length format. */
+- /* This logic is in here in case the vax file has been stored */
++ /* If we are on a VAX see if the file is in var length format. */
++ /* This logic is in here in case the VAX file has been stored */
+ /* in fixed or undefined format. This might be necessary since */
+- /* vax variable length files can't be moved to other computer */
++ /* VAX variable-length files can't be moved to other computer */
+ /* systems with standard comm programs (kermit, for example). */
+ /****************************************************************/
+
+@@ -459,9 +470,9 @@
+ read(infile,&shortint, (size_t) 2);
+ if (shortint > 0 && shortint < 80) {
+ host = 4; /* change host to 4 */
+- printf("This is not a VAX variable length file.");
++ printf("This is not a VAX variable-length file.");
+ }
+- else printf("This is a VAX variable length file.");
++ else printf("This is a VAX variable-length file.");
+ lseek(infile,(off_t) 0,0); /* reposition to beginning of file */
+ }
+ }
+@@ -474,13 +485,17 @@
+ printf("\n 3. VICAR format.");
+ printf("\n 4. Unlabelled binary array.\n");
+ printf("\n Enter format number:");
+- gets(inname);
++ fgets(inname, sizeof(inname), stdin);
++ if ((s = strchr(inname, '\n')) != NULL)
++ *s = '\0';
+ output_format = atoi(inname);
+ } while (output_format < 1 || output_format > 4);
+
+ if (outname[0] == ' ') {
+ printf("\nEnter name of uncompressed output file: ");
+- gets (outname);
++ fgets(outname, sizeof(outname), stdin);
++ if ((s = strchr(outname, '\n')) != NULL)
++ *s = '\0';
+ }
+
+ return(host);
+@@ -495,68 +510,68 @@
+ /*********************************************************************/
+
+ void open_files(host)
+-int *host;
++ int *host;
+ {
+ if (*host == 1 || *host == 2 || *host == 5) {
+ if (outname[0] == '-') outfile=stdout;
+- else if ((outfile = fopen(outname,"wb"))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ else if ((outfile = fopen(outname, "wb"))==NULL) {
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+
+ else if (*host == 3 || *host == 4) {
+ if (output_format == 1) { /* write PDS format blocks */
+- if (record_bytes == 836) {
+- if ((outfile=fopen(outname,"w"
++ if (record_bytes == 836) {
++ if ((outfile=fopen(outname, "w"
+ #ifdef VMS
+ ,"mrs=836",FOP,CTX,RECORD_TYPE
+ #endif
+ ))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+ else {
+- if ((outfile=fopen(outname,"w"
++ if ((outfile=fopen(outname, "w"
+ #ifdef VMS
+ ,"mrs=1204",FOP,CTX,RECORD_TYPE
+ #endif
+ ))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+ }
+ else if (output_format == 2) { /* write FITS format blocks */
+- if ((outfile=fopen(outname,"w"
++ if ((outfile=fopen(outname, "w"
+ #ifdef VMS
+ ,"mrs=2880",FOP,CTX,RECORD_TYPE
+ #endif
+ ))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+
+- else { /* write fixed length records */
+- if (record_bytes == 836) {
+- if ((outfile=fopen(outname,"w"
++ else { /* write fixed-length records */
++ if (record_bytes == 836) {
++ if ((outfile=fopen(outname, "w"
+ #ifdef VMS
+ ,"mrs=800",FOP,CTX,RECORD_TYPE
+ #endif
+ ))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+ else {
+- if ((outfile=fopen(outname,"w"
++ if ((outfile=fopen(outname, "w"
+ #ifdef VMS
+ ,"mrs=1204",FOP,CTX,RECORD_TYPE
+ #endif
+ ))==NULL) {
+- fprintf(stderr,"\ncan't open output file: %s\n",outname);
++ fprintf(stderr,"\ncan't open output file: %s\n", outname);
+ exit(1);
+ }
+ }
+@@ -572,11 +587,11 @@
+ /*********************************************************************/
+
+ void pds_labels(host)
+- int host;
++ int host;
+ {
+- char outstring[80],ibuf[2048];
++ char ibuf[2048];
+ unsigned char cr=13,lf=10,blank=32;
+- short length,nlen,total_bytes,line,i;
++ short length,total_bytes,i;
+
+
+ total_bytes = 0;
+@@ -613,11 +628,11 @@
+ (size_t) 53,(size_t) 1,outfile);
+ else
+ fwrite("CCSD3ZF0000100000001NJPL3IF0PDS200000001 = SFDU_LABEL",
+- (size_t) 53,(size_t) 1,outfile);
++ (size_t) 53,(size_t) 1,outfile);
+
+ fprintf(outfile,"%c%c",cr,lf);
+ fwrite("/* FILE FORMAT AND LENGTH */",(size_t) 37,(size_t) 1,
+- outfile);
++ outfile);
+ fprintf(outfile,"%c%c",cr,lf);
+ fwrite("RECORD_TYPE = FIXED_LENGTH",(size_t) 47,
+ (size_t) 1,outfile);
+@@ -710,7 +725,7 @@
+ }
+ else {
+ strcpy(ibuf+35,"60");
+- length = length - 2;
++ length = length - 2;
+ }
+
+ fwrite(ibuf,(size_t) length,(size_t) 1,outfile);
+@@ -730,7 +745,7 @@
+ }
+
+ else if ((i = strncmp(ibuf," ENCODING",(size_t) 9)) == 0);
+-
++
+ /*****************************************************************/
+ /* delete the encoding type label in the image object */
+ /*****************************************************************/
+@@ -787,10 +802,10 @@
+ /*********************************************************************/
+
+ void fits_labels(host)
+-int host;
++ int host;
+ {
+ char ibuf[2048],outstring[80];
+- short length,nlen,total_bytes,line,i;
++ short length,total_bytes,i;
+ unsigned char cr=13,lf=10,blank=32;
+
+ do {
+@@ -799,7 +814,7 @@
+ /*****************************************************************/
+ /* find the checksum and store in label_checksum */
+ /*****************************************************************/
+- if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
++ if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
+ ibuf[length] = '\0';
+ label_checksum = atol(ibuf+35);
+ }
+@@ -842,7 +857,7 @@
+
+ if (record_bytes == 836)
+ strcpy(outstring,"NAXIS1 = 800");
+- else
++ else
+ strcpy(outstring,"NAXIS1 = 1204");
+
+ strcat(outstring," ");
+@@ -862,7 +877,7 @@
+
+ strcpy(outstring,"END ");
+ strcat(outstring," ");
+-
++
+ fwrite(outstring,(size_t) 78,(size_t) 1,outfile);
+ fprintf(outfile,"%c%c",cr,lf);
+ total_bytes = total_bytes + 80;
+@@ -871,6 +886,7 @@
+ for (i=total_bytes; i<2880; i++) fputc(blank,outfile);
+ }
+
++
+ /*********************************************************************/
+ /* */
+ /* subroutine vicar_labels - write vicar labels to output file */
+@@ -878,11 +894,10 @@
+ /*********************************************************************/
+
+ void vicar_labels(host)
+-int host;
+-
++ int host;
+ {
+ char ibuf[2048],outstring[80];
+- short length,nlen,total_bytes,line,i;
++ short length,total_bytes,i;
+ unsigned char cr=13,lf=10,blank=32;
+
+ do {
+@@ -890,7 +905,7 @@
+ /*****************************************************************/
+ /* find the checksum and store in label_checksum */
+ /*****************************************************************/
+- if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
++ if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
+ ibuf[length] = '\0';
+ label_checksum = atol(ibuf+35);
+ }
+@@ -950,10 +965,10 @@
+ /*********************************************************************/
+
+ void no_labels(host)
+-int host;
++ int host;
+ {
+- char ibuf[2048],outstring[80];
+- short length,nlen,total_bytes,line,i;
++ char ibuf[2048];
++ short length,i;
+
+ do {
+ length = read_var(ibuf,host);
+@@ -961,7 +976,7 @@
+ /*****************************************************************/
+ /* find the checksum and store in label_checksum */
+ /*****************************************************************/
+- if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
++ if ((i = strncmp(ibuf," CHECKSUM",(size_t) 9)) == 0) {
+ ibuf[length] = '\0';
+ label_checksum = atol(ibuf+35);
+ }
+@@ -984,15 +999,16 @@
+ open_files(&host);
+ }
+
++
+ /*********************************************************************/
+ /* */
+-/* subroutine read_var - read variable length records from input file*/
++/* subroutine read_var - read variable-length records from input file*/
+ /* */
+ /*********************************************************************/
+
+ int read_var(ibuf,host)
+-char *ibuf;
+-int host;
++ char *ibuf;
++ int host;
+ {
+ int length,result,nlen;
+ char temp;
+@@ -1027,19 +1043,19 @@
+ return (length);
+
+ case 3: /*******************************************************/
+- /* VAX host with variable length support */
++ /* VAX host with variable-length support */
+ /*******************************************************/
+ length = read(infile,ibuf,(size_t) 2048/* upper bound */);
+ return (length);
+
+ case 4: /*******************************************************/
+- /* VAX host, but not a variable length file */
++ /* VAX host, but not a variable-length file */
+ /*******************************************************/
+ length = 0;
+ result = read(infile,&length,(size_t) 2);
+ nlen = read(infile,ibuf,(size_t) length+(length%2));
+
+- /* check to see if we crossed a vax record boundary */
++ /* check to see if we crossed a VAX record boundary */
+ while (nlen < length)
+ nlen += read(infile,ibuf+nlen,(size_t) length+(length%2)-nlen);
+ return (length);
+@@ -1061,6 +1077,7 @@
+ return 0;
+ }
+
++
+ /*********************************************************************/
+ /* */
+ /* subroutine check_host - find out what kind of machine we are on */
+@@ -1115,23 +1132,23 @@
+ "Host 5 - 32 bit integers without swapping, no var len support.");
+ }
+
+- if ((*outname)!='-') fprintf(stderr,"%s\n",hostname);
++ if ((*outname) != '-') fprintf(stderr, "%s\n", hostname);
+ return(host);
+ }
+
+
+-int swap_int(inval) /* swap 4 byte integer */
+- int inval;
++int swap_int(inval) /* swap 4 byte integer */
++ int inval;
+ {
+- union /* this union is used to swap 16 and 32 bit integers */
++ union /* this union is used to swap 16 and 32 bit integers */
+ {
+ char ichar[4];
+ short slen;
+ int llen;
+ } onion;
+ char temp;
+-
+- /* byte swap the input field */
++
++ /* byte swap the input field */
+ onion.llen = inval;
+ temp = onion.ichar[0];
+ onion.ichar[0]=onion.ichar[3];
+@@ -1146,17 +1163,16 @@
+ /****************************************************************************
+ *_TITLE decompress - decompresses image lines stored in compressed format *
+ *_ARGS TYPE NAME I/O DESCRIPTION */
+- char *ibuf; /* I Compressed data buffer */
+- char *obuf; /* O Decompressed image line */
+- int *nin; /* I Number of bytes on input buffer */
+- int *nout; /* I Number of bytes in output buffer */
+-
++ char *ibuf; /* I Compressed data buffer */
++ char *obuf; /* O Decompressed image line */
++ int *nin; /* I Number of bytes on input buffer */
++ int *nout; /* I Number of bytes in output buffer */
+ {
+ /* The external root pointer to tree */
+ extern NODE *tree;
+
+ dcmprs(ibuf,obuf,nin,nout,tree);
+-
++
+ return;
+ }
+
+@@ -1165,8 +1181,7 @@
+ /***************************************************************************
+ *_TITLE decmpinit - initializes the Huffman tree *
+ *_ARGS TYPE NAME I/O DESCRIPTION */
+- int *hist; /* I First-difference histogram. */
+-
++ int *hist; /* I First-difference histogram. */
+ {
+ extern NODE *tree; /* Huffman tree root pointer */
+ tree = huff_tree(hist);
+@@ -1178,8 +1193,7 @@
+ /****************************************************************************
+ *_TITLE huff_tree - constructs the Huffman tree; returns pointer to root *
+ *_ARGS TYPE NAME I/O DESCRIPTION */
+- int *hist; /* I First difference histogram */
+-
++ int *hist; /* I First difference histogram */
+ {
+ /* Local variables used */
+ int freq_list[512]; /* Histogram frequency list */
+@@ -1189,7 +1203,6 @@
+ NODE **np; /* Node list pointer */
+
+ int num_freq; /* Number non-zero frequencies in histogram */
+- int sum; /* Sum of all frequencies */
+
+ short int num_nodes; /* Counter for DN initialization */
+ short int cnt; /* Miscellaneous counter */
+@@ -1228,7 +1241,7 @@
+
+ j = 0;
+ for (i=4 ; --i >= 0 ; j = (j << 8) | *(cp+i));
+-
++
+ /* Now make the assignment */
+ *fp++ = j;
+ temp = new_node(num_nodes);
+@@ -1341,7 +1354,7 @@
+ l--;
+ if ( j <= freq_list) break;
+ }
+-
++
+ }
+ return;
+ }
+@@ -1362,9 +1375,9 @@
+ NODE *ptr = root; /* pointer to position in tree */
+ unsigned char test; /* test byte for bit set */
+ unsigned char idn; /* input compressed byte */
+-
++
+ char odn; /* last dn value decompressed */
+-
++
+ char *ilim = ibuf + *nin; /* end of compressed bytes */
+ char *olim = obuf + *nout; /* end of output buffer */
+
+@@ -1406,10 +1419,9 @@
+ /****************************************************************************
+ *_TITLE free_tree - free memory of all allocated nodes *
+ *_ARGS TYPE NAME I/O DESCRIPTION */
+- int *nfreed; /* O Return of total count of nodes *
++ int *nfreed; /* O Return of total count of nodes *
+ * freed. */
+-
+-/*
++/* *
+ *_DESCR This routine is supplied to the programmer to free up all the *
+ * allocated memory required to build the huffman tree. The count *
+ * of the nodes freed is returned in the parameter 'nfreed'. The *
+@@ -1417,11 +1429,10 @@
+ * than one file per run, the program will not keep allocating new *
+ * memory without first deallocating all previous nodes associated *
+ * with the previous file decompression. *
+-
++* *
+ *_HIST 16-AUG-89 Kris Becker USGS, Flagstaff Original Version *
+ *_END *
+ ****************************************************************************/
+-
+ {
+ int total_free = 0;
+
+@@ -1435,36 +1446,33 @@
+
+ int free_node(pnode,total_free)
+ /***************************************************************************
+-*_TITLE free_node - deallocates an allocated NODE pointer
++*_TITLE free_node - deallocates an allocated NODE pointer *
+ *_ARGS TYPE NAME I/O DESCRIPTION */
+ NODE *pnode; /* I Pointer to node to free */
+- int total_free; /* I Total number of freed nodes */
+-
+-/*
++ int total_free; /* I Total number of freed nodes */
++/* *
+ *_DESCR free_node will check both right and left pointers of a node *
+ * and then free the current node using the free() C utility. *
+ * Note that all nodes attached to the node via right or left *
+ * pointers area also freed, so be sure that this is the desired *
+ * result when calling this routine. *
+-
++* *
+ * This routine is supplied to allow successive calls to the *
+ * decmpinit routine. It will free up the memory allocated *
+ * by previous calls to the decmpinit routine. The call to free *
+-* a previous huffman tree is: total = free_node(tree,(int) 0); *
++* a previous huffman tree is: total = free_node(tree,(int) 0); *
+ * This call must be done by the programmer application routine *
+ * and is not done by any of these routines. *
+ *_HIST 16-AUG-89 Kris Becker U.S.G.S Flagstaff Original Version */
+ {
+ if (pnode == (NODE *) NULL) return(total_free);
+-
++
+ if (pnode->right != (NODE *) NULL)
+ total_free = free_node(pnode->right,total_free);
+ if (pnode->left != (NODE *) NULL)
+ total_free = free_node(pnode->left,total_free);
+-
++
+ free((char *) pnode);
+ return(total_free + 1);
+ }
+
+-
+-
+diff -ruN xv-3.10a/xcmap.c xv-3.10a-bugfixes/xcmap.c
+--- xv-3.10a/xcmap.c 1995-01-03 13:14:52.000000000 -0800
++++ xv-3.10a-bugfixes/xcmap.c 2005-03-20 15:51:59.000000000 -0800
+@@ -9,6 +9,9 @@
+
+ /* include files */
+ #include <stdio.h>
++#ifdef __STDC__
++# include <stdlib.h> /* exit(), abs() */
++#endif
+ #include <sys/types.h>
+ #include <ctype.h>
+
+@@ -18,7 +21,7 @@
+ #include <X11/cursorfont.h>
+
+ #ifdef VMS
+-#define index strchr
++# define index strchr
+ #endif
+
+ typedef unsigned char byte;
+@@ -75,50 +78,50 @@
+ int i;
+ char *display, *geom;
+ XEvent event;
+-
++
+ cmd = argv[0];
+ display = geom = NULL;
+-
+-
++
++
+ /*********************Options*********************/
+-
++
+ for (i = 1; i < argc; i++) {
+ char *strind;
+-
++
+ if (!strncmp(argv[i],"-g", (size_t)2)) { /* geometry */
+ i++;
+ geom = argv[i];
+ continue;
+ }
+-
++
+ if (argv[i][0] == '=') { /* old-style geometry */
+ geom = argv[i];
+ continue;
+ }
+-
++
+ if (!strncmp(argv[i],"-d",(size_t) 2)) { /* display */
+ i++;
+ display = argv[i];
+ continue;
+ }
+-
++
+ strind = (char *) index(argv[i], ':'); /* old-style display */
+ if(strind != NULL) {
+ display = argv[i];
+ continue;
+ }
+-
++
+ Syntax();
+ }
+-
+-
++
++
+ /*****************************************************/
+-
++
+ /* Open up the display. */
+-
++
+ if ( (theDisp=XOpenDisplay(display)) == NULL)
+ FatalError("can't open display");
+-
++
+ theScreen = DefaultScreen(theDisp);
+ theCmap = DefaultColormap(theDisp, theScreen);
+ rootW = RootWindow(theDisp,theScreen);
+@@ -126,9 +129,9 @@
+ fcol = WhitePixel(theDisp,theScreen);
+ bcol = BlackPixel(theDisp,theScreen);
+ theVisual = DefaultVisual(theDisp,theScreen);
+-
++
+ dispcells = DisplayCells(theDisp, theScreen);
+-
++
+ if (dispcells>256) {
+ sprintf(tmpstr,"dispcells = %d. %s",
+ dispcells, "This program can only deal with <= 8-bit displays.");
+@@ -140,27 +143,32 @@
+ nxcells = nycells = 8;
+ else if (dispcells>4)
+ nxcells = nycells = 4;
+- else
++ else if (dispcells>2)
+ nxcells = nycells = 2;
+-
++ else
++ {
++ nxcells = 2;
++ nycells = 1;
++ }
++
+ /**************** Create/Open X Resources ***************/
+ if ((mfinfo = XLoadQueryFont(theDisp,FONT))==NULL) {
+ sprintf(tmpstr,"couldn't open '%s' font",FONT);
+ FatalError(tmpstr);
+ }
+-
++
+ mfont=mfinfo->fid;
+ XSetFont(theDisp,theGC,mfont);
+ XSetForeground(theDisp,theGC,fcol);
+ XSetBackground(theDisp,theGC,bcol);
+-
++
+ CreateMainWindow(cmd,geom,argc,argv);
+ Resize(WIDE,HIGH);
+-
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask | ButtonPressMask);
+ XMapWindow(theDisp,mainW);
+-
++
+ /**************** Main loop *****************/
+ while (1) {
+ XNextEvent(theDisp, &event);
+@@ -177,41 +185,41 @@
+ switch (event->type) {
+ case Expose: {
+ XExposeEvent *exp_event = (XExposeEvent *) event;
+-
+- if (exp_event->window==mainW)
++
++ if (exp_event->window==mainW)
+ DrawWindow(exp_event->x,exp_event->y,
+ exp_event->width, exp_event->height);
+ }
+ break;
+-
++
+ case ButtonPress: {
+ XButtonEvent *but_event = (XButtonEvent *) event;
+-
+- if (but_event->window == mainW && but_event->button == Button1)
++
++ if (but_event->window == mainW && but_event->button == Button1)
+ TrackMouse(but_event->x, but_event->y);
+ }
+ break;
+-
++
+ case KeyPress: {
+ XKeyEvent *key_event = (XKeyEvent *) event;
+ KeySym ks;
+ XComposeStatus status;
+-
++
+ XLookupString(key_event,tmpstr,128,&ks,&status);
+ if (tmpstr[0]=='q' || tmpstr[0]=='Q') Quit();
+ }
+ break;
+-
++
+ case ConfigureNotify: {
+ XConfigureEvent *conf_event = (XConfigureEvent *) event;
+-
+- if (conf_event->window == mainW &&
++
++ if (conf_event->window == mainW &&
+ (conf_event->width != WIDE || conf_event->height != HIGH))
+ Resize(conf_event->width, conf_event->height);
+ }
+ break;
+-
+-
++
++
+ case CirculateNotify:
+ case MapNotify:
+ case DestroyNotify:
+@@ -220,7 +228,7 @@
+ case UnmapNotify:
+ case MappingNotify:
+ case ClientMessage: break;
+-
++
+ default: /* ignore unexpected events */
+ break;
+ } /* end of switch */
+@@ -262,24 +270,31 @@
+ XSizeHints hints;
+ int i,x,y;
+ unsigned int w,h;
+-
++
+ WIDE = HIGH = 256; /* default window size */
+-
++
+ x=y=w=h=1;
+ i=XParseGeometry(geom,&x,&y,&w,&h);
+- if (i&WidthValue) WIDE = (int) w;
+- if (i&HeightValue) HIGH = (int) h;
+-
+- if (i&XValue || i&YValue) hints.flags = USPosition;
+- else hints.flags = PPosition;
+-
+- hints.flags |= USSize;
+-
+- if (i&XValue && i&XNegative)
+- x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
+- if (i&YValue && i&YNegative)
+- y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
+-
++ if (i&WidthValue)
++ {
++ WIDE = (int) w;
++ hints.flags |= USSize;
++ }
++ if (i&HeightValue)
++ {
++ HIGH = (int) h;
++ hints.flags |= USSize;
++ }
++
++ if (i&XValue || i&YValue)
++ {
++ if (i&XNegative)
++ x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
++ if (i&YNegative)
++ y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
++ hints.flags |= USPosition;
++ }
++
+ hints.x=x; hints.y=y;
+ hints.width = WIDE; hints.height = HIGH;
+ hints.max_width = DisplayWidth(theDisp,theScreen);
+@@ -288,22 +303,22 @@
+ hints.min_height = 16;
+ hints.width_inc = hints.height_inc = 16;
+ hints.flags |= PMaxSize | PMinSize | PResizeInc;
+-
++
+ xswa.background_pixel = bcol;
+ xswa.border_pixel = fcol;
+ xswa.cursor = XCreateFontCursor (theDisp, XC_top_left_arrow);
+ xswamask = CWBackPixel | CWBorderPixel | CWCursor;
+-
++
+ mainW = XCreateWindow(theDisp,rootW,x,y,(unsigned int) WIDE,
+- (unsigned int) HIGH, 2, 0,
++ (unsigned int) HIGH, 2, 0,
+ (unsigned int) CopyFromParent,
+ CopyFromParent, xswamask, &xswa);
+-
++
+ XSetStandardProperties(theDisp,mainW,"xcmap","xcmap",None,
+ argv,argc,&hints);
+-
++
+ if (!mainW) FatalError("Can't open main window");
+-
++
+ }
+
+
+@@ -312,11 +327,11 @@
+ int x,y,w,h;
+ {
+ int i,j,x1,y1,x2,y2;
+-
++
+ x1 = x / cWIDE; y1 = y / cHIGH; /* (x1,y1) (x2,y2): bounding */
+ x2 = ((x+w) + cWIDE - 1) / cWIDE; /* rect in cell coords */
+ y2 = ((y+h) + cHIGH - 1) / cHIGH;
+-
++
+ for (i=y1; i<y2; i++) {
+ for (j=x1; j<x2; j++) {
+ XSetForeground(theDisp,theGC,(unsigned long) (i*nycells+j) );
+@@ -343,18 +358,18 @@
+ {
+ /* called when there's a button press in the window. draws the pixel
+ value, and loops until button is released */
+-
++
+ Window rootW,childW;
+ int rx,ry,x,y;
+ unsigned int mask;
+-
++
+ pvalup = 0;
+ DrawPixValue(mx,my);
+-
++
+ while (1) {
+ if (XQueryPointer(theDisp,mainW,&rootW,&childW,&rx,&ry,&x,&y,&mask)) {
+ if (!(mask & Button1Mask)) break; /* button released */
+-
++
+ DrawPixValue(x,y);
+ }
+ }
+@@ -367,10 +382,10 @@
+ {
+ static unsigned long pix, lastpix;
+ static int pvaly;
+-
++
+ if (x<0) x=0; if (x>=WIDE) x=WIDE-1;
+ if (y<0) y=0; if (y>=HIGH) y=HIGH-1;
+-
++
+ if (!pvalup) { /* it's not up. make it so */
+ if (y >= HIGH/2) pvaly = 0; else pvaly = HIGH - 12;
+ pvalup = 1;
+@@ -378,30 +393,30 @@
+ XClearArea(theDisp,mainW,0,pvaly,
+ (unsigned int) WIDE, (unsigned int) 13,True);
+ }
+-
++
+ x /= cWIDE; y /= cHIGH;
+-
++
+ pix = y * nxcells + x;
+-
++
+ if (pix != lastpix) {
+ XColor def;
+ char *sp;
+-
++
+ XSetForeground(theDisp,theGC,fcol);
+ lastpix = def.pixel = pix;
+ if (pix<dispcells) {
+ XQueryColor(theDisp, theCmap, &def);
+ sprintf(tmpstr, "Pix %3ld = ($%04x, $%04x, $%04x)",
+ pix, def.red, def.green, def.blue);
+-
+- /* make the hex uppercase */
+- for (sp=tmpstr+4; *sp; sp++)
++
++ /* make the hex uppercase */
++ for (sp=tmpstr+4; *sp; sp++)
+ if (islower(*sp)) *sp = toupper(*sp);
+ }
+ else {
+ sprintf(tmpstr, "Pix %3ld is out of legal range. ", pix);
+ }
+-
++
+ XDrawImageString(theDisp,mainW,theGC,5,pvaly+10,tmpstr,
+ (int) strlen(tmpstr));
+ }
+diff -ruN xv-3.10a/xv.c xv-3.10a-bugfixes/xv.c
+--- xv-3.10a/xv.c 1995-01-19 10:08:43.000000000 -0800
++++ xv-3.10a-bugfixes/xv.c 2005-03-20 22:25:22.000000000 -0800
+@@ -33,9 +33,9 @@
+
+ /* a mono-spaced font needed for the 'pixel value tracking' feature */
+ #define MFONT1 "-misc-fixed-medium-r-normal-*-13-*"
+-#define MFONT2 "6x13"
++#define MFONT2 "6x13"
+ #define MFONT3 "-*-courier-medium-r-*-*-12-*"
+-#define MFONT4 "fixed"
++#define MFONT4 "fixed"
+
+
+ /* default positions for various windows */
+@@ -116,13 +116,13 @@
+
+ /* formerly local vars in main, made local to this module when
+ parseResources() and parseCmdLine() were split out of main() */
+-
++
+ 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 *monofontname, *flistName;
+-int curstype, stdinflag, browseMode, savenorm, preview, pscomp, preset,
++int curstype, stdinflag, browseMode, savenorm, preview, pscomp, preset,
+ rmodeset, gamset, cgamset, perfect, owncmap, rwcolor, stdcmap;
+ int nodecor;
+ double gamval, rgamval, ggamval, bgamval;
+@@ -177,16 +177,16 @@
+
+ LocalCmap = browCmap = 0;
+ stdinflag = 0;
+- autoclose = autoDelete = 0;
++ autoclose = autoDelete = 0;
+ cmapInGam = 0;
+ grabDelay = 0;
+ showzoomcursor = 0;
+ perfect = owncmap = stdcmap = rwcolor = 0;
+
+ ignoreConfigs = 0;
+- browPerfect = 1;
++ browPerfect = 1;
+ gamval = rgamval = ggamval = bgamval = 1.0;
+-
++
+ picType = -1; /* gets set once file is loaded */
+ colorMapMode = CM_NORMAL;
+ haveStdCmap = STD_NONE;
+@@ -230,11 +230,11 @@
+ }
+
+ /* init command-line options flags */
+- infogeom = DEFINFOGEOM; ctrlgeom = DEFCTRLGEOM;
++ infogeom = DEFINFOGEOM; ctrlgeom = DEFCTRLGEOM;
+ gamgeom = DEFGAMGEOM; browgeom = DEFBROWGEOM;
+ textgeom = DEFTEXTGEOM; cmtgeom = DEFCMTGEOM;
+
+- ncols = -1; mono = 0;
++ ncols = -1; mono = 0;
+ ninstall = 0; fixedaspect = 0; noFreeCols = nodecor = 0;
+ DEBUG = 0; bwidth = 2;
+ nolimits = useroot = clrroot = noqcheck = 0;
+@@ -306,7 +306,7 @@
+ /*****************************************************/
+ /*** X Setup ***/
+ /*****************************************************/
+-
++
+ theScreen = DefaultScreen(theDisp);
+ theCmap = DefaultColormap(theDisp, theScreen);
+ rootW = RootWindow(theDisp,theScreen);
+@@ -321,52 +321,66 @@
+ rootDEEP = dispDEEP;
+
+ /* things dependant on theVisual:
+- * dispDEEP, theScreen, rootW, ncells, theCmap, theGC,
++ * dispDEEP, theScreen, rootW, ncells, theCmap, theGC,
+ * vrWIDE, dispWIDE, vrHIGH, dispHIGH, maxWIDE, maxHIGH
+ */
+
+
+-
+ /* if we *haven't* had a non-default visual specified,
+- see if we have a TrueColor or DirectColor visual of 24 or 32 bits,
++ see if we have a TrueColor or DirectColor visual of 24 or 32 bits,
+ and if so, use that as the default visual (prefer TrueColor) */
+
+ if (!visualstr && !useroot) {
++ VisualID defvid;
+ XVisualInfo *vinfo, rvinfo;
+ int best, numvis;
+ long flags;
+
+- best = -1;
++ best = -1;
+ rvinfo.class = TrueColor;
+ rvinfo.screen = theScreen;
+- flags = VisualClassMask | VisualScreenMask;
+-
++ flags = VisualClassMask | VisualScreenMask;
++ defvid = XVisualIDFromVisual(DefaultVisual(theDisp,
++ DefaultScreen(theDisp)));
++
+ vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis);
+- if (vinfo) { /* look for a TrueColor, 24-bit or more (pref 24) */
+- for (i=0, best = -1; i<numvis; i++) {
++ if (vinfo) {
++ /* Check list, use 'default', first 24-bit, or first >24-bit */
++ for (i=0; i<numvis && best==-1; i++) { /* default? */
++ if ((vinfo[i].visualid == defvid) && (vinfo[i].depth >= 24)) best=i;
++ }
++ for (i=0; i<numvis && best==-1; i++) { /* 24-bit ? */
+ if (vinfo[i].depth == 24) best = i;
+- else if (vinfo[i].depth>24 && best<0) best = i;
++ }
++ for (i=0; i<numvis && best==-1; i++) { /* >24-bit ? */
++ if (vinfo[i].depth >= 24) best = i;
+ }
+ }
+
+ if (best == -1) { /* look for a DirectColor, 24-bit or more (pref 24) */
+ rvinfo.class = DirectColor;
+ if (vinfo) XFree((char *) vinfo);
++
+ vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis);
+ if (vinfo) {
+- for (i=0, best = -1; i<numvis; i++) {
++ for (i=0; i<numvis && best==-1; i++) { /* default? */
++ if ((vinfo[i].visualid == defvid) && (vinfo[i].depth >= 24)) best=i;
++ }
++ for (i=0; i<numvis && best==-1; i++) { /* 24-bit ? */
+ if (vinfo[i].depth == 24) best = i;
+- else if (vinfo[i].depth>24 && best<0) best = i;
++ }
++ for (i=0; i<numvis && best==-1; i++) { /* >24-bit ? */
++ if (vinfo[i].depth >= 24) best = i;
+ }
+ }
+ }
+-
++
+ if (best>=0 && best<numvis) useOtherVisual(vinfo, best);
+ if (vinfo) XFree((char *) vinfo);
+ }
+
+
+-
++
+ if (visualstr && useroot) {
+ fprintf(stderr, "%s: %sUsing default visual.\n",
+ cmd, "Warning: Can't use specified visual on root. ");
+@@ -401,11 +415,11 @@
+ long vinfomask;
+ int numvis, best;
+
+- if (vclass >= 0) {
++ if (vclass >= 0) {
+ rvinfo.class = vclass; vinfomask = VisualClassMask;
+ }
+ else { rvinfo.visualid = vid; vinfomask = VisualIDMask; }
+-
++
+ rvinfo.screen = theScreen;
+ vinfomask |= VisualScreenMask;
+
+@@ -429,9 +443,9 @@
+ /* make linear colormap for DirectColor visual */
+ if (theVisual->class == DirectColor) makeDirectCmap();
+
+- defaultVis = (XVisualIDFromVisual(theVisual) ==
++ defaultVis = (XVisualIDFromVisual(theVisual) ==
+ XVisualIDFromVisual(DefaultVisual(theDisp, DefaultScreen(theDisp))));
+-
++
+
+ /* turn GraphicsExposures OFF in the default GC */
+ {
+@@ -456,12 +470,12 @@
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems, bytesafter;
+- Window *newRoot = NULL;
++ byte *newRoot = NULL; /* byte instead of Window avoids type-pun warning */
+ XWindowAttributes xwa;
+ if (XGetWindowProperty (theDisp, children[i], __SWM_VROOT, 0L, 1L,
+ False, XA_WINDOW, &actual_type, &actual_format, &nitems,
+ &bytesafter, (unsigned char **) &newRoot) == Success && newRoot) {
+- vrootW = *newRoot;
++ vrootW = *(Window *)newRoot;
+ XGetWindowAttributes(theDisp, vrootW, &xwa);
+ vrWIDE = xwa.width; vrHIGH = xwa.height;
+ dispDEEP = xwa.depth;
+@@ -492,7 +506,7 @@
+ XColor fc, bc;
+ fc.red = fc.green = fc.blue = 0xffff;
+ bc.red = bc.green = bc.blue = 0x0000;
+-
++
+ XRecolorCursor(theDisp, zoom, &fc, &bc);
+ }
+
+@@ -541,7 +555,7 @@
+
+
+ /* set up fg,bg colors */
+- fg = black; bg = white;
++ fg = black; bg = white;
+ if (fgstr && XParseColor(theDisp, theCmap, fgstr, &ecdef) &&
+ xvAllocColor(theDisp, theCmap, &ecdef)) {
+ fg = ecdef.pixel;
+@@ -590,7 +604,7 @@
+ if (theVisual->class == StaticGray || theVisual->class == GrayScale)
+ mono = 1;
+ }
+-
++
+
+
+ iconPix = MakePix1(rootW, icon_bits, icon_width, icon_height);
+@@ -598,27 +612,27 @@
+ riconPix = MakePix1(rootW, runicon_bits, runicon_width, runicon_height);
+ riconmask= MakePix1(rootW, runiconm_bits, runiconm_width,runiconm_height);
+
+- if (!iconPix || !iconmask || !riconPix || !riconmask)
++ if (!iconPix || !iconmask || !riconPix || !riconmask)
+ FatalError("Unable to create icon pixmaps\n");
+
+- gray50Tile = XCreatePixmapFromBitmapData(theDisp, rootW,
++ gray50Tile = XCreatePixmapFromBitmapData(theDisp, rootW,
+ (char *) cboard50_bits,
+- cboard50_width, cboard50_height,
++ cboard50_width, cboard50_height,
+ infofg, infobg, dispDEEP);
+ if (!gray50Tile) FatalError("Unable to create gray50Tile bitmap\n");
+
+- gray25Tile = XCreatePixmapFromBitmapData(theDisp, rootW,
++ gray25Tile = XCreatePixmapFromBitmapData(theDisp, rootW,
+ (char *) gray25_bits,
+- gray25_width, gray25_height,
++ gray25_width, gray25_height,
+ infofg, infobg, dispDEEP);
+ if (!gray25Tile) FatalError("Unable to create gray25Tile bitmap\n");
+
+
+ /* try to load fonts */
+- if ( (mfinfo = XLoadQueryFont(theDisp,FONT1))==NULL &&
+- (mfinfo = XLoadQueryFont(theDisp,FONT2))==NULL &&
+- (mfinfo = XLoadQueryFont(theDisp,FONT3))==NULL &&
+- (mfinfo = XLoadQueryFont(theDisp,FONT4))==NULL &&
++ if ( (mfinfo = XLoadQueryFont(theDisp,FONT1))==NULL &&
++ (mfinfo = XLoadQueryFont(theDisp,FONT2))==NULL &&
++ (mfinfo = XLoadQueryFont(theDisp,FONT3))==NULL &&
++ (mfinfo = XLoadQueryFont(theDisp,FONT4))==NULL &&
+ (mfinfo = XLoadQueryFont(theDisp,FONT5))==NULL) {
+ sprintf(str,
+ "couldn't open the following fonts:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s",
+@@ -632,14 +646,14 @@
+
+ if (monofontname) {
+ monofinfo = XLoadQueryFont(theDisp, monofontname);
+- if (!monofinfo) fprintf(stderr,"xv: unable to load font '%s'\n",
++ if (!monofinfo) fprintf(stderr,"xv: unable to load font '%s'\n",
+ monofontname);
+- }
++ }
+
+ if (!monofinfo) {
+- if ((monofinfo = XLoadQueryFont(theDisp,MFONT1))==NULL &&
+- (monofinfo = XLoadQueryFont(theDisp,MFONT2))==NULL &&
+- (monofinfo = XLoadQueryFont(theDisp,MFONT3))==NULL &&
++ if ((monofinfo = XLoadQueryFont(theDisp,MFONT1))==NULL &&
++ (monofinfo = XLoadQueryFont(theDisp,MFONT2))==NULL &&
++ (monofinfo = XLoadQueryFont(theDisp,MFONT3))==NULL &&
+ (monofinfo = XLoadQueryFont(theDisp,MFONT4))==NULL) {
+ sprintf(str,"couldn't open %s fonts:\n\t%s\n\t%s\n\t%s\n\t%s",
+ "any of the following",
+@@ -649,28 +663,28 @@
+ }
+
+ monofont=monofinfo->fid;
+-
+
+-
+-
++
++
++
+ /* if ncols wasn't set, set it to 2^dispDEEP, unless dispDEEP=1, in which
+ case ncols = 0; (ncols = max number of colors allocated. on 1-bit
+ displays, no colors are allocated */
+-
++
+ if (ncols == -1) {
+ if (dispDEEP>1) ncols = 1 << ((dispDEEP>8) ? 8 : dispDEEP);
+ else ncols = 0;
+ }
+ else if (ncols>256) ncols = 256; /* so program doesn't blow up */
+-
+-
++
++
+ GenerateFSGamma(); /* has to be done before 'OpenBrowse()' is called */
+-
+-
+-
++
++
++
+ /* no filenames. build one-name (stdio) list (if stdinflag) */
+ if (numnames==0) {
+- if (stdinflag) {
++ if (stdinflag) {
+ /* have to malloc namelist[0] so we can free it in deleteFromList() */
+ namelist[0] = (char *) malloc(strlen(STDINSTR) + 1);
+ if (!namelist[0]) FatalError("unable to to build namelist[0]");
+@@ -679,16 +693,16 @@
+ }
+ else namelist[0] = NULL;
+ }
+-
++
+ if (numnames) makeDispNames();
+-
+-
+- if (viewonly || autoquit) {
+- imap = ctrlmap = gmap = browmap = cmtmap = 0;
++
++
++ if (viewonly || autoquit) {
++ imap = ctrlmap = gmap = browmap = cmtmap = 0;
+ novbrowse = 1;
+ }
+-
+-
++
++
+ /* create the info box window */
+ CreateInfo(infogeom);
+ XSelectInput(theDisp, infoW, ExposureMask | ButtonPressMask | KeyPressMask
+@@ -698,12 +712,12 @@
+ RedrawInfo(0,0,1000,1000); /* explicit draw if mapped */
+ XFlush(theDisp);
+ }
+-
+-
++
++
+ /* create the control box window */
+ CreateCtrl(ctrlgeom);
+ epicMode = EM_RAW; SetEpicMode();
+-
++
+ XSelectInput(theDisp, ctrlW, ExposureMask | ButtonPressMask | KeyPressMask
+ | StructureNotifyMask);
+ if (ctrlmap < 0) { /* map iconified */
+@@ -719,22 +733,22 @@
+ RedrawCtrl(0,0,1000,1000); /* explicit draw if mapped */
+ XFlush(theDisp);
+ }
+-
++
+ fixDispNames();
+ ChangedCtrlList();
+-
++
+ /* disable root modes if using non-default visual */
+ if (!defaultVis) {
+ for (i=RMB_ROOT; i<RMB_MAX; i++) rootMB.dim[i] = 1;
+ }
+-
+-
++
++
+ /* create the directory window */
+ CreateDirW(NULL);
+ XSelectInput(theDisp, dirW, ExposureMask | ButtonPressMask | KeyPressMask);
+ browseCB.val = browseMode;
+ savenormCB.val = savenorm;
+-
++
+ /* create the gamma window */
+ CreateGam(gamgeom, (gamset) ? gamval : -1.0,
+ (cgamset) ? rgamval : -1.0,
+@@ -744,60 +758,60 @@
+ XSelectInput(theDisp, gamW, ExposureMask | ButtonPressMask | KeyPressMask
+ | StructureNotifyMask
+ | (cmapInGam ? ColormapChangeMask : 0));
+-
++
+ GamBox(gmap); /* map it (or not) */
+-
+-
+-
++
++
++
+ stdnfcols = 0; /* so we don't try to free any if we don't create any */
+-
++
+ if (!novbrowse) {
+ MakeBrowCmap();
+ /* create the visual browser window */
+ CreateBrowse(browgeom, fgstr, bgstr, histr, lostr);
+-
++
+ if (browmap) OpenBrowse();
+ }
+ else windowMB.dim[WMB_BROWSE] = 1; /* disable visual schnauzer */
+-
+-
++
++
+ CreateTextWins(textgeom, cmtgeom);
+ if (cmtmap) OpenCommentText();
+-
+-
++
++
+ /* create the ps window */
+ CreatePSD(NULL);
+ XSetTransientForHint(theDisp, psW, dirW);
+ encapsCB.val = preview;
+ pscompCB.val = pscomp;
+-
+-
++
++
+ #ifdef HAVE_JPEG
+ CreateJPEGW();
+ XSetTransientForHint(theDisp, jpegW, dirW);
+ #endif
+-
++
+ #ifdef HAVE_TIFF
+ CreateTIFFW();
+ XSetTransientForHint(theDisp, tiffW, dirW);
+ #endif
+-
+-
++
++
+ LoadFishCursors();
+ SetCursors(-1);
+-
+-
++
++
+ /* if we're not on a colormapped display, turn off rwcolor */
+ if (!CMAPVIS(theVisual)) {
+ if (rwcolor) fprintf(stderr, "xv: not a colormapped display. %s\n",
+ "'rwcolor' turned off.");
+-
++
+ allocMode = AM_READONLY;
+ dispMB.flags[DMB_COLRW] = 0; /* de-'check' */
+ dispMB.dim[DMB_COLRW] = 1; /* and dim it */
+ }
+-
+-
++
++
+ if (force24) {
+ Set824Menus(PIC24);
+ conv24MB.flags[CONV24_LOCK] = 1;
+@@ -812,15 +826,15 @@
+ Set824Menus(PIC8); /* default mode */
+ picType = PIC8;
+ }
+-
+-
+-
++
++
++
+ /* make std colormap, maybe */
+ ChangeCmapMode(colorMapMode, 0, 0);
+
+
+-
+-
++
++
+ /* Do The Thing... */
+ mainLoop();
+ Quit(0);
+@@ -832,12 +846,12 @@
+ /*****************************************************/
+ static void makeDirectCmap()
+ {
+- int i, j, cmaplen, numgot;
++ int i, cmaplen, numgot;
+ byte origgot[256];
+ XColor c;
+ u_long rmask, gmask, bmask;
+ int rshift, gshift, bshift;
+-
++
+
+ rmask = theVisual->red_mask;
+ gmask = theVisual->green_mask;
+@@ -849,22 +863,22 @@
+
+ if (rshift<0) rmask = rmask << (-rshift);
+ else rmask = rmask >> rshift;
+-
++
+ if (gshift<0) gmask = gmask << (-gshift);
+ else gmask = gmask >> gshift;
+-
++
+ if (bshift<0) bmask = bmask << (-bshift);
+ else bmask = bmask >> bshift;
+
+
+ cmaplen = theVisual->map_entries;
+ if (cmaplen>256) cmaplen=256;
+-
++
+
+ /* try to alloc a 'cmaplen' long grayscale colormap. May not get all
+ entries for whatever reason. Build table 'directConv[]' that
+ maps range [0..(cmaplen-1)] into set of colors we did get */
+-
++
+ for (i=0; i<256; i++) { origgot[i] = 0; directConv[i] = 0; }
+
+ for (i=numgot=0; i<cmaplen; i++) {
+@@ -882,9 +896,9 @@
+ }
+ }
+
+-
++
+ if (numgot == 0) FatalError("Got no entries in DirectColor cmap!\n");
+-
++
+ /* directConv may or may not have holes in it. */
+ for (i=0; i<cmaplen; i++) {
+ if (!origgot[i]) {
+@@ -892,10 +906,10 @@
+ numbak = numfwd = 0;
+ while ((i - numbak) >= 0 && !origgot[i-numbak]) numbak++;
+ while ((i + numfwd) < cmaplen && !origgot[i+numfwd]) numfwd++;
+-
++
+ if (i-numbak<0 || !origgot[i-numbak]) numbak = 999;
+ if (i+numfwd>=cmaplen || !origgot[i+numfwd]) numfwd = 999;
+-
++
+ if (numbak<numfwd) directConv[i] = directConv[i-numbak];
+ else if (numfwd<999) directConv[i] = directConv[i+numfwd];
+ else FatalError("DirectColor cmap: can't happen!");
+@@ -926,14 +940,14 @@
+ {
+ if (!vinfo || best<0) return;
+
+- if (vinfo[best].visualid ==
++ if (vinfo[best].visualid ==
+ XVisualIDFromVisual(DefaultVisual(theDisp, theScreen))) return;
+
+ theVisual = vinfo[best].visual;
+
+ if (DEBUG) {
+ fprintf(stderr,"%s: using %s visual (0x%0x), depth = %d, screen = %d\n",
+- cmd,
++ cmd,
+ (vinfo[best].class==StaticGray) ? "StaticGray" :
+ (vinfo[best].class==StaticColor) ? "StaticColor" :
+ (vinfo[best].class==TrueColor) ? "TrueColor" :
+@@ -947,41 +961,41 @@
+ (int) vinfo[best].red_mask, (int) vinfo[best].green_mask,
+ (int) vinfo[best].blue_mask, vinfo[best].bits_per_rgb);
+ }
+-
++
+ dispDEEP = vinfo[best].depth;
+ theScreen = vinfo[best].screen;
+ rootW = RootWindow(theDisp, theScreen);
+ ncells = vinfo[best].colormap_size;
+ theCmap = XCreateColormap(theDisp, rootW, theVisual, AllocNone);
+-
++
+ {
+ /* create a temporary window using this visual so we can
+ create a GC for this visual */
+-
+- Window win;
++
++ Window win;
+ XSetWindowAttributes xswa;
+ XGCValues xgcv;
+ unsigned long xswamask;
+-
++
+ XFlush(theDisp);
+ XSync(theDisp, False);
+-
++
+ xswa.background_pixel = 0;
+ xswa.border_pixel = 1;
+ xswa.colormap = theCmap;
+ xswamask = CWBackPixel | CWBorderPixel | CWColormap;
+-
++
+ win = XCreateWindow(theDisp, rootW, 0, 0, 100, 100, 2, (int) dispDEEP,
+ InputOutput, theVisual, xswamask, &xswa);
+-
++
+ XFlush(theDisp);
+ XSync(theDisp, False);
+-
++
+ theGC = XCreateGC(theDisp, win, 0L, &xgcv);
+-
++
+ XDestroyWindow(theDisp, win);
+ }
+-
++
+ vrWIDE = dispWIDE = DisplayWidth(theDisp,theScreen);
+ vrHIGH = dispHIGH = DisplayHeight(theDisp,theScreen);
+ maxWIDE = dispWIDE; maxHIGH = dispHIGH;
+@@ -1037,8 +1051,8 @@
+ fprintf(stderr,"%s: unable to parse 'aspect' resource\n",cmd);
+ else defaspect = (float) n / (float) d;
+ }
+-
+- if (rd_flag("2xlimit")) limit2x = def_int;
++
++ if (rd_flag("2xlimit")) limit2x = def_int;
+ if (rd_flag("auto4x3")) auto4x3 = def_int;
+ if (rd_flag("autoClose")) autoclose = def_int;
+ if (rd_flag("autoCrop")) autocrop = def_int;
+@@ -1073,7 +1087,7 @@
+
+ if (rd_str ("expand")) {
+ if (index(def_str, ':')) {
+- if (sscanf(def_str, "%lf:%lf", &hexpand, &vexpand)!=2)
++ if (sscanf(def_str, "%lf:%lf", &hexpand, &vexpand)!=2)
+ { hexpand = vexpand = 1.0; }
+ }
+ else hexpand = vexpand = atof(def_str);
+@@ -1108,7 +1122,7 @@
+ if (rd_flag("ownCmap")) owncmap = def_int;
+ if (rd_flag("perfect")) perfect = def_int;
+ if (rd_flag("popupKludge")) winCtrPosKludge = def_int;
+- if (rd_str ("print")) strncpy(printCmd, def_str,
++ if (rd_str ("print")) strncpy(printCmd, def_str,
+ (size_t) PRINTCMDLEN);
+ if (rd_flag("pscompress")) pscomp = def_int;
+ if (rd_flag("pspreview")) preview = def_int;
+@@ -1146,7 +1160,7 @@
+
+ not_in_first_half = 0;
+
+- if (argv[i][0] != '-' && argv[i][0] != '+') {
++ if (argv[i][0] != '-' && argv[i][0] != '+') {
+ /* a file name. put it in list */
+
+ if (!nostat) {
+@@ -1186,54 +1200,54 @@
+
+ else if (!argcmp(argv[i],"-best24",3,0,&pm)) /* -best */
+ conv24 = CONV24_BEST;
+-
++
+ else if (!argcmp(argv[i],"-bg",3,0,&pm)) /* bg color */
+ { if (++i<argc) bgstr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-black",3,0,&pm)) /* black color */
+ { if (++i<argc) blackstr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-bw",3,0,&pm)) /* border width */
+ { if (++i<argc) bwidth=atoi(argv[i]); }
+-
++
+ else if (!argcmp(argv[i],"-cecmap",4,1,&cmapInGam)); /* cmapInGam */
+-
++
+ else if (!argcmp(argv[i],"-cegeometry",4,0,&pm)) /* gammageom */
+ { if (++i<argc) gamgeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-cemap",4,1,&gmap)); /* gmap */
+-
++
+ else if (!argcmp(argv[i],"-cgamma",4,0,&pm)) { /* color gamma */
+ if (i+3<argc) {
+- rgamval = atof(argv[++i]);
+- ggamval = atof(argv[++i]);
+- bgamval = atof(argv[++i]);
++ rgamval = atof(argv[++i]);
++ ggamval = atof(argv[++i]);
++ bgamval = atof(argv[++i]);
+ }
+ cgamset++;
+ }
+-
++
+ else if (!argcmp(argv[i],"-cgeometry",4,0,&pm)) /* ctrlgeom */
+ { if (++i<argc) ctrlgeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-clear",4,1,&clrroot)); /* clear */
+ else if (!argcmp(argv[i],"-close",4,1,&autoclose)); /* close */
+ else if (!argcmp(argv[i],"-cmap", 3,1,&ctrlmap)); /* ctrlmap */
+
+ else if (!argcmp(argv[i],"-cmtgeometry",5,0,&pm)) /* comment geom */
+ { if (++i<argc) cmtgeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-cmtmap",5,1,&cmtmap)); /* map cmt window */
+-
++
+ else if (!argcmp(argv[i],"-crop",3,0,&pm)) { /* crop */
+ if (i+4<argc) {
+- acropX = atoi(argv[++i]);
+- acropY = atoi(argv[++i]);
+- acropW = atoi(argv[++i]);
+- acropH = atoi(argv[++i]);
++ acropX = atoi(argv[++i]);
++ acropY = atoi(argv[++i]);
++ acropW = atoi(argv[++i]);
++ acropH = atoi(argv[++i]);
+ }
+ acrop++;
+ }
+-
++
+ else if (!argcmp(argv[i],"-cursor",3,0,&pm)) /* cursor */
+ { if (++i<argc) curstype = atoi(argv[i]); }
+
+@@ -1265,7 +1279,7 @@
+ else if (!argcmp(argv[i],"-expand",2,0,&pm)) { /* expand factor */
+ if (++i<argc) {
+ if (index(argv[i], ':')) {
+- if (sscanf(argv[i], "%lf:%lf", &hexpand, &vexpand)!=2)
++ if (sscanf(argv[i], "%lf:%lf", &hexpand, &vexpand)!=2)
+ { hexpand = vexpand = 1.0; }
+ }
+ else hexpand = vexpand = atof(argv[i]);
+@@ -1274,47 +1288,47 @@
+
+ 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],"-flist",3,0,&pm)) /* file list */
+ { if (++i<argc) flistName = argv[i]; }
+
+ else if (!argcmp(argv[i],"-gamma",3,0,&pm)) /* gamma */
+ { if (++i<argc) gamval = atof(argv[i]); gamset++; }
+-
++
+ else if (!argcmp(argv[i],"-geometry",3,0,&pm)) /* geometry */
+ { if (++i<argc) maingeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-grabdelay",3,0,&pm)) /* grabDelay */
+ { if (++i<argc) grabDelay = atoi(argv[i]); }
+-
++
+ else if (!argcmp(argv[i],"-gsdev",4,0,&pm)) /* gsDevice */
+ { if (++i<argc) gsDev = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-gsgeom",4,0,&pm)) /* gsGeometry */
+ { if (++i<argc) gsGeomStr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-gsres",4,0,&pm)) /* gsResolution */
+ { if (++i<argc) gsRes=abs(atoi(argv[i])); }
+-
++
+ else if (!argcmp(argv[i],"-hflip",3,1,&autohflip)); /* hflip */
+
+ else if (!argcmp(argv[i],"-hi",3,0,&pm)) /* highlight */
+ { if (++i<argc) histr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-hist", 4,1,&autohisteq)); /* hist eq */
+
+ else if (!argcmp(argv[i],"-hsv", 3,1,&hsvmode)); /* hsvmode */
+
+ else if (!argcmp(argv[i],"-icgeometry",4,0,&pm)) /* icon geometry */
+ { if (++i<argc) icongeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-iconic",4,1,&startIconic)); /* iconic */
+-
++
+ else if (!argcmp(argv[i],"-igeometry",3,0,&pm)) /* infogeom */
+ { if (++i<argc) infogeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-imap", 3,1,&imap)); /* imap */
+ else if (!argcmp(argv[i],"-lbrowse", 3,1,&browseMode)); /* browse mode */
+
+@@ -1323,8 +1337,8 @@
+
+ else if (!argcmp(argv[i],"-loadclear",4,1,&clearonload)); /* clearonload */
+
+-
+- else not_in_first_half = 1;
++
++ else not_in_first_half = 1;
+
+
+
+@@ -1339,18 +1353,18 @@
+ if (!argcmp(argv[i],"-max",4,1,&automax)); /* auto maximize */
+ else if (!argcmp(argv[i],"-maxpect",5,1,&pm)) /* auto maximize */
+ { automax=pm; fixedaspect=pm; }
+-
++
+ else if (!argcmp(argv[i],"-mfn",3,0,&pm)) /* mono font name */
+ { if (++i<argc) monofontname = argv[i]; }
+
+ else if (!argcmp(argv[i],"-mono",3,1,&mono)); /* mono */
+-
++
+ else if (!argcmp(argv[i],"-name",3,0,&pm)) /* name */
+ { if (++i<argc) winTitle = argv[i]; }
+-
++
+ 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],"-nodecor", 4,1,&nodecor));
+ else if (!argcmp(argv[i],"-nofreecols",4,1,&noFreeCols));
+@@ -1367,61 +1381,61 @@
+
+ else if (!argcmp(argv[i],"-preset",3,0,&pm)) /* preset */
+ { if (++i<argc) preset=abs(atoi(argv[i])); }
+-
++
+ else if (!argcmp(argv[i],"-quick24",5,0,&pm)) /* quick 24-to-8 conv */
+ conv24 = CONV24_FAST;
+-
++
+ else if (!argcmp(argv[i],"-quit", 2,1,&autoquit)); /* auto-quit */
+ else if (!argcmp(argv[i],"-random", 4,1,&randomShow)); /* random */
+ else if (!argcmp(argv[i],"-raw", 4,1,&autoraw)); /* force raw */
+
+ else if (!argcmp(argv[i],"-rbg",3,0,&pm)) /* root background color */
+ { if (++i<argc) rootbgstr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-rfg",3,0,&pm)) /* root foreground color */
+ { if (++i<argc) rootfgstr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-rgb",4,1,&pm)) /* rgb mode */
+ hsvmode = !pm;
+-
++
+ else if (!argcmp(argv[i],"-RM",3,0,&pm)) /* auto-delete */
+ autoDelete = 1;
+-
++
+ else if (!argcmp(argv[i],"-rmode",3,0,&pm)) /* root pattern */
+- { if (++i<argc) rootMode = atoi(argv[i]);
++ { if (++i<argc) rootMode = atoi(argv[i]);
+ useroot++; rmodeset++;
+ }
+-
++
+ else if (!argcmp(argv[i],"-root",4,1,&useroot)); /* use root window */
+-
++
+ else if (!argcmp(argv[i],"-rotate",4,0,&pm)) /* rotate */
+ { if (++i<argc) autorotate = atoi(argv[i]); }
+-
++
+ else if (!argcmp(argv[i],"-rv",3,1,&revvideo)); /* reverse video */
+ else if (!argcmp(argv[i],"-rw",3,1,&rwcolor)); /* use r/w color */
+
+ else if (!argcmp(argv[i],"-slow24",3,0,&pm)) /* slow 24->-8 conv.*/
+ conv24 = CONV24_SLOW;
+-
++
+ else if (!argcmp(argv[i],"-smooth",3,1,&autosmooth)); /* autosmooth */
+ else if (!argcmp(argv[i],"-stdcmap",3,1,&stdcmap)); /* use stdcmap */
+
+ else if (!argcmp(argv[i],"-tgeometry",2,0,&pm)) /* textview geom */
+ { if (++i<argc) textgeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-vflip",3,1,&autovflip)); /* vflip */
+ else if (!argcmp(argv[i],"-viewonly",4,1,&viewonly)); /* viewonly */
+
+ else if (!argcmp(argv[i],"-visual",4,0,&pm)) /* visual */
+ { if (++i<argc) visualstr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-vsdisable",4,1,&novbrowse)); /* disable sch? */
+-
++
+ else if (!argcmp(argv[i],"-vsgeometry",4,0,&pm)) /* visSchnauzer geom */
+ { if (++i<argc) browgeom = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-vsmap",4,1,&browmap)); /* visSchnauzer map */
+-
++
+ else if (!argcmp(argv[i],"-vsperfect",3,1,&browPerfect)); /* vs perf. */
+
+ else if (!argcmp(argv[i],"-wait",3,0,&pm)) { /* secs betwn pics */
+@@ -1430,12 +1444,12 @@
+ if (waitsec<0) waitsec = 0;
+ }
+ }
+-
++
+ else if (!argcmp(argv[i],"-white",3,0,&pm)) /* white color */
+ { if (++i<argc) whitestr = argv[i]; }
+-
++
+ else if (!argcmp(argv[i],"-wloop",3,1,&waitloop)); /* waitloop */
+-
++
+ else if (not_in_first_half) cmdSyntax();
+ }
+
+@@ -1462,7 +1476,7 @@
+ }
+
+
+- if (flistName)
++ if (flistName)
+ add_filelist_to_namelist(flistName, namelist, &numnames, MAXNAMES);
+
+ RANGE(curstype,0,254);
+@@ -1475,16 +1489,16 @@
+
+ /* if using root, generally gotta map ctrl window, 'cause there won't be
+ any way to ask for it. (no kbd or mouse events from rootW) */
+- if (useroot && !autoquit) ctrlmap = -1;
++ if (useroot && !autoquit) ctrlmap = -1;
++
+
+-
+ if (abs(autorotate) != 0 && abs(autorotate) != 90 &&
+ abs(autorotate) != 180 && abs(autorotate) != 270) {
+ fprintf(stderr,"Invalid auto rotation value (%d) ignored.\n", autorotate);
+ fprintf(stderr," (Valid values: 0, +-90, +-180, +-270)\n");
+
+ autorotate = 0;
+- }
++ }
+
+
+ if (grabDelay < 0 || grabDelay > 15) {
+@@ -1498,7 +1512,7 @@
+ fprintf(stderr," (Valid values: 1, 2, 3, 4)\n");
+
+ preset = 0;
+- }
++ }
+
+ if (waitsec < 0) noFreeCols = 0; /* disallow nfc if not doing slideshow */
+ if (noFreeCols && perfect) { perfect = 0; owncmap = 1; }
+@@ -1512,13 +1526,13 @@
+
+ defaultCmapMode = colorMapMode; /* default mode for 8-bit images */
+
+- if (nopos) {
++ if (nopos) {
+ maingeom = infogeom = ctrlgeom = gamgeom = browgeom = textgeom = NULL;
+ cmtgeom = NULL;
+ }
+
+ /* if -root and -maxp, disallow 'integer' tiling modes */
+- if (useroot && fixedaspect && automax && !rmodeset &&
++ if (useroot && fixedaspect && automax && !rmodeset &&
+ (rootMode == RM_TILE || rootMode == RM_IMIRROR))
+ rootMode = RM_CSOLID;
+ }
+@@ -1656,7 +1670,7 @@
+ /***********************************/
+ static void rmodeSyntax()
+ {
+- fprintf(stderr,"%s: unknown root mode '%d'. Valid modes are:\n",
++ fprintf(stderr,"%s: unknown root mode '%d'. Valid modes are:\n",
+ cmd, rootMode);
+ fprintf(stderr,"\t0: tiling\n");
+ fprintf(stderr,"\t1: integer tiling\n");
+@@ -1679,13 +1693,11 @@
+ int minlen, plusallowed;
+ int *plusminus;
+ {
+- /* does a string compare between a1 and a2. To return '0', a1 and a2
++ /* 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
+ be at least 'minlen'. Otherwise, return non-zero. plusminus set to '1'
+ if '-option', '0' if '+option' */
+
+- int i;
+-
+ if ((strlen(a1) < (size_t) minlen) || (strlen(a2) < (size_t) minlen))
+ return 1;
+ if (strlen(a1) > strlen(a2)) return 1;
+@@ -1694,7 +1706,7 @@
+
+ if (a1[0]=='-' || (plusallowed && a1[0]=='+')) {
+ /* only set if we match */
+- *plusminus = (a1[0] == '-');
++ *plusminus = (a1[0] == '-');
+ return 0;
+ }
+
+@@ -1721,8 +1733,7 @@
+ int oldCXOFF, oldCYOFF, oldCWIDE, oldCHIGH, wascropped;
+ char *tmp;
+ char *fullname, /* full name of the original file */
+- filename[512], /* full name of file to load (could be /tmp/xxx)*/
+- globnm[512]; /* globbed version of fullname of orig file */
++ filename[512]; /* full name of file to load (could be /tmp/xxx)*/
+
+ xvbzero((char *) &pinfo, sizeof(PICINFO));
+
+@@ -1748,7 +1759,7 @@
+
+ /* if we're not loading next or prev page in a multi-page doc, kill off
+ page files */
+- if (strlen(pageBaseName) && filenum!=OP_PAGEDN && filenum!=OP_PAGEUP)
++ if (strlen(pageBaseName) && filenum!=OP_PAGEDN && filenum!=OP_PAGEUP)
+ killpage = 1;
+
+
+@@ -1799,7 +1810,7 @@
+ }
+
+ else if (filenum == PADDED) {
+- /* need fullfname (used for window/icon name),
++ /* need fullfname (used for window/icon name),
+ basefname(compute from fullfname) */
+
+ i = LoadPad(&pinfo, fullfname);
+@@ -1864,7 +1875,7 @@
+
+
+ /* chop off trailing ".Z", ".z", or ".gz" from displayed basefname, if any */
+- if (strlen(basefname) > (size_t) 2 &&
++ if (strlen(basefname) > (size_t) 2 &&
+ strcmp(basefname+strlen(basefname)-2,".Z")==0)
+ basefname[strlen(basefname)-2]='\0';
+ else {
+@@ -1872,7 +1883,7 @@
+ if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".Z")==0)
+ basefname[strlen(basefname)-2]='\0';
+
+- else if (strlen(basefname)>3 &&
++ else if (strlen(basefname)>3 &&
+ strcmp(basefname+strlen(basefname)-3,".gz")==0)
+ basefname[strlen(basefname)-3]='\0';
+ #endif /* GUNZIP */
+@@ -1881,7 +1892,7 @@
+
+ if (filenum == LOADPIC && ISPIPE(fullname[0])) {
+ /* if we're reading from a pipe, 'filename' will have the /tmp/xvXXXXXX
+- filename, and we can skip a lot of stuff: (such as prepending
++ filename, and we can skip a lot of stuff: (such as prepending
+ 'initdir' to relative paths, dealing with reading from stdin, etc. */
+
+ /* at this point, fullname = "! do some commands",
+@@ -1891,11 +1902,11 @@
+
+ else { /* NOT reading from a PIPE */
+
+- /* if fullname doesn't start with a '/' (ie, it's a relative path),
+- (and it's not LOADPIC and it's not the special case '<stdin>')
++ /* if fullname doesn't start with a '/' (ie, it's a relative path),
++ (and it's not LOADPIC and it's not the special case '<stdin>')
+ then we need to prepend a directory name to it:
+-
+- prepend 'initdir',
++
++ prepend 'initdir',
+ if we have a searchdir (ie, we have multiple places to look),
+ see if such a file exists (via fopen()),
+ if it does, we're done.
+@@ -1904,7 +1915,7 @@
+ if it does, we're done.
+ if it doesn't, remove all prepended directories, and fall through
+ to error code below. */
+-
++
+ if (filenum!=LOADPIC && fullname[0]!='/' && strcmp(fullname,STDINSTR)!=0) {
+ char *tmp1;
+
+@@ -1954,26 +1965,30 @@
+ }
+ }
+ }
+-
++
+ strcpy(filename, fullname);
+-
+-
++
++
+ /* if the file is STDIN, write it out to a temp file */
+
+ if (strcmp(filename,STDINSTR)==0) {
+- FILE *fp;
++ FILE *fp = NULL;
+
+-#ifndef VMS
++#ifndef VMS
+ sprintf(filename,"%s/xvXXXXXX",tmpdir);
+ #else /* it is VMS */
+ sprintf(filename, "[]xvXXXXXX");
+ #endif
++
++#ifdef USE_MKSTEMP
++ fp = fdopen(mkstemp(filename), "w");
++#else
+ mktemp(filename);
++ fp = fopen(filename, "w");
++#endif
++ if (!fp) FatalError("openPic(): can't write temporary file");
+
+ clearerr(stdin);
+- fp = fopen(filename,"w");
+- if (!fp) FatalError("openPic(): can't write temporary file");
+-
+ while ( (i=getchar()) != EOF) putc(i,fp);
+ fclose(fp);
+
+@@ -2003,7 +2018,7 @@
+ ) {
+
+ filetype = ReadFileType(tmpname); /* and try again */
+-
++
+ /* if we made a /tmp file (from stdin, etc.) won't need it any more */
+ if (strcmp(fullname,filename)!=0) unlink(filename);
+
+@@ -2084,7 +2099,7 @@
+ /**************/
+ /* SUCCESS!!! */
+ /**************/
+-
++
+
+ GOTIMAGE:
+ /* successfully read this picture. No failures from here on out
+@@ -2097,7 +2112,7 @@
+ if (conv24MB.flags[CONV24_LOCK]) { /* locked */
+ if (pinfo.type==PIC24 && picType==PIC8) { /* 24 -> 8 bit */
+ byte *pic8;
+- pic8 = Conv24to8(pinfo.pic, pinfo.w, pinfo.h, ncols,
++ pic8 = Conv24to8(pinfo.pic, pinfo.w, pinfo.h, ncols,
+ pinfo.r, pinfo.g, pinfo.b);
+ free(pinfo.pic);
+ pinfo.pic = pic8;
+@@ -2108,7 +2123,7 @@
+
+ else if (pinfo.type!=PIC24 && picType==PIC24) { /* 8 -> 24 bit */
+ byte *pic24;
+- pic24 = Conv8to24(pinfo.pic, pinfo.w, pinfo.h,
++ pic24 = Conv8to24(pinfo.pic, pinfo.w, pinfo.h,
+ pinfo.r, pinfo.g, pinfo.b);
+ free(pinfo.pic);
+ pinfo.pic = pic24;
+@@ -2144,7 +2159,7 @@
+
+ if (mainW && !useroot) {
+ /* avoid generating excess configure events while we resize the window */
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask
+ | ButtonPressMask | KeyReleaseMask
+ | EnterWindowMask | LeaveWindowMask);
+@@ -2162,7 +2177,7 @@
+ pHIGH = pinfo.h;
+ if (pinfo.frmType >=0) SetDirSaveMode(F_FORMAT, pinfo.frmType);
+ if (pinfo.colType >=0) SetDirSaveMode(F_COLORS, pinfo.colType);
+-
++
+ SetISTR(ISTR_FORMAT, pinfo.fullInfo);
+ strcpy(formatStr, pinfo.shrtInfo);
+ picComments = pinfo.comment;
+@@ -2195,11 +2210,11 @@
+
+
+ SetISTR(ISTR_INFO,formatStr);
+-
++
+ SetInfoMode(INF_PART);
+- SetISTR(ISTR_FILENAME,
+- (filenum==DFLTPIC || filenum==GRABBED || frompipe)
+- ? "<none>" : basefname);
++ SetISTR(ISTR_FILENAME, "%s",
++ (filenum==DFLTPIC || filenum==GRABBED || frompipe) ?
++ "<none>" : basefname);
+
+ SetISTR(ISTR_RES,"%d x %d",pWIDE,pHIGH);
+ SetISTR(ISTR_COLOR, "");
+@@ -2219,7 +2234,7 @@
+
+
+ /* handle various 'auto-whatever' command line options
+- Note that if 'frompoll' is set, things that have to do with
++ Note that if 'frompoll' is set, things that have to do with
+ setting the expansion factor are skipped, as we'll want it to
+ display in the (already-existing) window at the same size */
+
+@@ -2254,7 +2269,7 @@
+ w = eWIDE; h = (w*3) / 4;
+ eWIDE = w; eHIGH = h;
+ }
+-
++
+
+ if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL;
+
+@@ -2306,14 +2321,14 @@
+ aspWIDE = eWIDE; aspHIGH = eHIGH; /* aspect-corrected eWIDE,eHIGH */
+
+ if (hexpand < 0.0) eWIDE=(int)(aspWIDE / -hexpand); /* neg: reciprocal */
+- else eWIDE=(int)(aspWIDE * hexpand);
++ else eWIDE=(int)(aspWIDE * hexpand);
+ if (vexpand < 0.0) eHIGH=(int)(aspHIGH / -vexpand); /* neg: reciprocal */
+- else eHIGH=(int)(aspHIGH * vexpand);
++ else eHIGH=(int)(aspHIGH * vexpand);
+
+ if (maingeom) {
+ /* deal with geometry spec. Note, they shouldn't have given us
+ *both* an expansion factor and a geomsize. The geomsize wins out */
+-
++
+ int i,x,y,gewide,gehigh; u_int w,h;
+
+ gewide = eWIDE; gehigh = eHIGH;
+@@ -2321,11 +2336,11 @@
+
+ if (i&WidthValue) gewide = (int) w;
+ if (i&HeightValue) gehigh = (int) h;
+-
++
+ /* handle case where the pinheads only specified width *or * height */
+ if (( i&WidthValue && ~i&HeightValue) ||
+ (~i&WidthValue && i&HeightValue)) {
+-
++
+ if (i&WidthValue) { gehigh = (aspHIGH * gewide) / pWIDE; }
+ else { gewide = (aspWIDE * gehigh) / pHIGH; }
+ }
+@@ -2391,7 +2406,7 @@
+
+ /* if we're using an integer tiled root mode, truncate eWIDE/eHIGH to
+ be an integer divisor of the display size */
+-
++
+ if (useroot && (rootMode == RM_TILE || rootMode == RM_IMIRROR)) {
+ /* make picture size a divisor of the rootW size. round down */
+ i = (dispWIDE + eWIDE-1) / eWIDE; eWIDE = (dispWIDE + i-1) / i;
+@@ -2419,7 +2434,7 @@
+
+ /* 'dithering' makes no sense in 24-bit mode */
+ if (picType == PIC24 && epicMode == EM_DITH) epicMode = EM_RAW;
+-
++
+ SetEpicMode();
+ } /* end of !frompoll */
+
+@@ -2450,7 +2465,7 @@
+ if (useroot) mainW = vrootW;
+ if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL;
+
+- NewPicGetColors(autonorm, autohisteq);
++ NewPicGetColors(autonorm, autohisteq);
+
+ GenerateEpic(eWIDE, eHIGH); /* want to dither *after* color allocs */
+ CreateXImage();
+@@ -2474,7 +2489,7 @@
+ SetISTR(ISTR_INFO,"%s %s %s", formatStr,
+ (picType==PIC8) ? "8-bit mode." : "24-bit mode.",
+ tmp);
+-
++
+ SetInfoMode(INF_FULL);
+ if (freename) free(fullname);
+
+@@ -2499,16 +2514,16 @@
+
+ return 1;
+
+-
++
+ FAILED:
+ SetCursors(-1);
+ KillPageFiles(pinfo.pagebname, pinfo.numpages);
+
+- if (fullname && strcmp(fullname,filename)!=0)
++ if (fullname && strcmp(fullname,filename)!=0)
+ unlink(filename); /* kill /tmp file */
+ if (freename) free(fullname);
+
+- if (!fromint && !polling && filenum>=0 && filenum<nList.nstr)
++ if (!fromint && !polling && filenum>=0 && filenum<nList.nstr)
+ deleteFromList(filenum);
+
+ if (polling) sleep(1);
+@@ -2546,7 +2561,7 @@
+ fp = xv_fopen(fname, "r");
+ if (!fp) return RFT_ERROR;
+
+- n = fread(magicno, (size_t) 1, (size_t) 30, fp);
++ n = fread(magicno, (size_t) 1, (size_t) 30, fp);
+ fclose(fp);
+
+ if (n<30) return RFT_UNKNOWN; /* files less than 30 bytes long... */
+@@ -2559,7 +2574,7 @@
+ else if (strncmp((char *) magicno,"VIEW", (size_t) 4)==0 ||
+ strncmp((char *) magicno,"WEIV", (size_t) 4)==0) rv = RFT_PM;
+
+- else if (magicno[0] == 'P' && magicno[1]>='1' &&
++ else if (magicno[0] == 'P' && magicno[1]>='1' &&
+ magicno[1]<='6') rv = RFT_PBM;
+
+ /* note: have to check XPM before XBM, as first 2 chars are the same */
+@@ -2586,7 +2601,7 @@
+
+ else if (magicno[0]==0x0a && magicno[1] <= 5) rv = RFT_PCX;
+
+- else if (strncmp((char *) magicno, "FORM", (size_t) 4)==0 &&
++ else if (strncmp((char *) magicno, "FORM", (size_t) 4)==0 &&
+ strncmp((char *) magicno+8, "ILBM", (size_t) 4)==0) rv = RFT_IFF;
+
+ else if (magicno[0]==0 && magicno[1]==0 &&
+@@ -2597,12 +2612,12 @@
+ else if (magicno[4]==0x00 && magicno[5]==0x00 &&
+ magicno[6]==0x00 && magicno[7]==0x07) rv = RFT_XWD;
+
+- else if (strncmp((char *) magicno,"SIMPLE ", (size_t) 8)==0 &&
++ else if (strncmp((char *) magicno,"SIMPLE ", (size_t) 8)==0 &&
+ magicno[29] == 'T') rv = RFT_FITS;
+-
++
+
+ #ifdef HAVE_JPEG
+- else if (magicno[0]==0xff && magicno[1]==0xd8 &&
++ else if (magicno[0]==0xff && magicno[1]==0xd8 &&
+ magicno[2]==0xff) rv = RFT_JFIF;
+ #endif
+
+@@ -2668,7 +2683,7 @@
+ #endif
+
+ #ifdef HAVE_TIFF
+- case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
++ case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break;
+ #endif
+
+ #ifdef HAVE_PDS
+@@ -2703,7 +2718,7 @@
+ to what it was. necessary because uncompress doesn't handle files
+ that don't end with '.Z' */
+
+- if (strlen(name) >= (size_t) 2 &&
++ if (strlen(name) >= (size_t) 2 &&
+ strcmp(name + strlen(name)-2,".Z")!=0 &&
+ strcmp(name + strlen(name)-2,".z")!=0) {
+ strcpy(namez, name);
+@@ -2721,34 +2736,42 @@
+ #endif /* not VMS and not GUNZIP */
+
+
+-
+ #ifndef VMS
+ sprintf(uncompname, "%s/xvuXXXXXX", tmpdir);
++#else
++ strcpy(uncompname, "[]xvuXXXXXX");
++#endif
++
++#ifdef USE_MKSTEMP
++ close(mkstemp(uncompname));
++#else
+ mktemp(uncompname);
++#endif
++
++#ifndef VMS
+ sprintf(buf,"%s -c %s >%s", UNCOMPRESS, fname, uncompname);
+ #else /* it IS VMS */
+- strcpy(uncompname, "[]xvuXXXXXX");
+- mktemp(uncompname);
+-# ifdef GUNZIP
++# ifdef GUNZIP
+ sprintf(buf,"%s %s %s", UNCOMPRESS, fname, uncompname);
+-# else
++# else
+ sprintf(buf,"%s %s", UNCOMPRESS, fname);
+-# endif
++# endif
+ #endif
+
+ SetISTR(ISTR_INFO, "Uncompressing '%s'...", BaseName(fname));
+ #ifndef VMS
+- if (system(buf)) {
++ if (system(buf))
+ #else
+- if (!system(buf)) {
++ if (!system(buf))
+ #endif
++ {
+ SetISTR(ISTR_INFO, "Unable to uncompress '%s'.", BaseName(fname));
+ Warning();
+ return 0;
+ }
+
+-#ifndef VMS
+- /* if we renamed the file to end with a .Z for the sake of 'uncompress',
++#ifndef VMS
++ /* if we renamed the file to end with a .Z for the sake of 'uncompress',
+ rename it back to what it once was... */
+
+ if (strlen(namez)) {
+@@ -2769,7 +2792,7 @@
+ }
+ */
+ #endif /* not VMS */
+-
++
+ return 1;
+ }
+
+@@ -2798,11 +2821,11 @@
+ {
+ int i;
+
+- /* some stuff that necessary whenever running an algorithm or
++ /* some stuff that necessary whenever running an algorithm or
+ installing a new 'pic' (or switching 824 modes) */
+
+ numcols = 0; /* gets set by SortColormap: set to 0 for PIC24 images */
+- for (i=0; i<256; i++) cols[i]=infobg;
++ for (i=0; i<256; i++) cols[i]=infobg;
+
+ if (picType == PIC8) {
+ byte trans[256];
+@@ -2811,18 +2834,18 @@
+ }
+
+ if (picType == PIC8) {
+- /* see if image is a b/w bitmap.
++ /* see if image is a b/w bitmap.
+ If so, use '-black' and '-white' colors */
+ if (numcols == 2) {
+ if ((rMap[0] == gMap[0] && rMap[0] == bMap[0] && rMap[0] == 255) &&
+ (rMap[1] == gMap[1] && rMap[1] == bMap[1] && rMap[1] == 0)) {
+ /* 0=wht, 1=blk */
+- rMap[0] = (whtRGB>>16)&0xff;
+- gMap[0] = (whtRGB>>8)&0xff;
++ rMap[0] = (whtRGB>>16)&0xff;
++ gMap[0] = (whtRGB>>8)&0xff;
+ bMap[0] = whtRGB&0xff;
+
+ rMap[1] = (blkRGB>>16)&0xff;
+- gMap[1] = (blkRGB>>8)&0xff;
++ gMap[1] = (blkRGB>>8)&0xff;
+ bMap[1] = blkRGB&0xff;
+ }
+
+@@ -2852,10 +2875,10 @@
+ }
+
+ /* save the desired RGB colormap (before dicking with it) */
+- for (i=0; i<numcols; i++) {
+- rorg[i] = rcmap[i] = rMap[i];
+- gorg[i] = gcmap[i] = gMap[i];
+- borg[i] = bcmap[i] = bMap[i];
++ for (i=0; i<numcols; i++) {
++ rorg[i] = rcmap[i] = rMap[i];
++ gorg[i] = gcmap[i] = gMap[i];
++ borg[i] = bcmap[i] = bMap[i];
+ }
+ }
+
+@@ -2888,7 +2911,7 @@
+ {
+ /* cmd is something like: "! bggen 100 0 0"
+ *
+- * runs command (with "> /tmp/xv******" appended).
++ * runs command (with "> /tmp/xv******" appended).
+ * returns "/tmp/xv******" in fname
+ * returns '0' if everything's cool, '1' on error
+ */
+@@ -2899,8 +2922,12 @@
+ if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
+
+ sprintf(tmpname,"%s/xvXXXXXX", tmpdir);
++#ifdef USE_MKSTEMP
++ close(mkstemp(tmpname));
++#else
+ mktemp(tmpname);
+- if (tmpname[0] == '\0') { /* mktemp() blew up */
++#endif
++ if (tmpname[0] == '\0') { /* mktemp() or mkstemp() blew up */
+ sprintf(str,"Unable to create temporary filename.");
+ ErrPopUp(str, "\nHow unlikely!");
+ return 1;
+@@ -2946,7 +2973,7 @@
+ while (numnames>0) {
+ if (openPic(0)) return; /* success */
+ else {
+- if (polling && !i)
++ if (polling && !i)
+ fprintf(stderr,"%s: POLLING: Waiting for file '%s' \n\tto %s\n",
+ cmd, namelist[0], "be created, or whatever...");
+ i = 1;
+@@ -2970,11 +2997,11 @@
+ int i;
+
+ if (curname>=0) i = curname+1;
+- else if (nList.selected >= 0 && nList.selected < numnames)
++ else if (nList.selected >= 0 && nList.selected < numnames)
+ i = nList.selected;
+ else i = 0;
+
+-
++
+ while (i<numnames && !openPic(i));
+ if (i<numnames) return; /* success */
+
+@@ -2989,7 +3016,7 @@
+
+ if (!randomShow) {
+ if (curname>=0) i = curname+1;
+- else if (nList.selected >= 0 && nList.selected < numnames)
++ else if (nList.selected >= 0 && nList.selected < numnames)
+ i = nList.selected;
+ else i = 0;
+
+@@ -3015,7 +3042,7 @@
+ if (!randomShow) {
+
+ if (curname>=0) i = curname+1;
+- else if (nList.selected >= 0 && nList.selected < numnames)
++ else if (nList.selected >= 0 && nList.selected < numnames)
+ i = nList.selected;
+ else i = 0;
+
+@@ -3044,7 +3071,7 @@
+ int i;
+
+ if (curname>0) i = curname-1;
+- else if (nList.selected>0 && nList.selected < numnames)
++ else if (nList.selected>0 && nList.selected < numnames)
+ i = nList.selected - 1;
+ else i = numnames-1;
+
+@@ -3089,7 +3116,7 @@
+ 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;
+@@ -3097,7 +3124,7 @@
+ }
+
+ for (k=abs(random()) % listLen; loadList[k]; k = (k+1) % listLen);
+-
++
+ left_to_load--;
+ loadList[k] = TRUE;
+
+@@ -3107,13 +3134,13 @@
+ /****************/
+ static void mainLoop()
+ {
+- /* search forward until we manage to display a picture,
+- then call EventLoop. EventLoop will eventually return
++ /* search forward until we manage to display a picture,
++ then call EventLoop. EventLoop will eventually return
+ NEXTPIC, PREVPIC, NEXTQUIT, QUIT, or, if >= 0, a filenum to GOTO */
+
+ int i;
+
+- /* if curname<0 (there is no 'current' file), 'Next' means view the
++ /* if curname<0 (there is no 'current' file), 'Next' means view the
+ selected file (or the 0th file, if no selection either), and 'Prev' means
+ view the one right before the selected file */
+
+@@ -3133,7 +3160,7 @@
+ }
+
+ else if (i==PREVPIC) {
+- if (curname>0 || (curname<0 && nList.selected>0))
++ if (curname>0 || (curname<0 && nList.selected>0))
+ openPrevPic();
+ }
+
+@@ -3151,7 +3178,7 @@
+
+ else if (i==THISNEXT) { /* open current sel, 'next' until success */
+ int j;
+- j = nList.selected;
++ j = nList.selected;
+ if (j<0) j = 0;
+ while (j<numnames && !openPic(j));
+ if (!pic) openPic(DFLTPIC);
+@@ -3219,12 +3246,12 @@
+ hints.width = eWIDE; hints.height = eHIGH;
+ hints.max_width = maxWIDE; hints.max_height = maxHIGH;
+ hints.flags |= USSize | PMaxSize;
+-
++
+ xswa.bit_gravity = StaticGravity;
+ xswa.background_pixel = bg;
+ xswa.border_pixel = fg;
+ xswa.colormap = theCmap;
+-
++
+ xswa.backing_store = WhenMapped;
+
+ /* NOTE: I've turned 'backing-store' off on the image window, as some
+@@ -3233,9 +3260,9 @@
+ improvement anyway (for the image window), unless you're on a slow
+ network. In any event, I'm not *turning off* backing store, I'm
+ just not explicitly turning it *on*. If your X server is set up
+- that windows, by default, have backing-store turned on, then the
++ that windows, by default, have backing-store turned on, then the
+ image window will, too */
+-
++
+ xswamask = CWBackPixel | CWBorderPixel | CWColormap /* | CWBackingStore */;
+ if (!clearonload) xswamask |= CWBitGravity;
+
+@@ -3251,11 +3278,11 @@
+
+ SetWindowPos(&xwa);
+ hints.flags = PSize | PMaxSize;
+- }
++ }
+
+ else {
+ mainW = XCreateWindow(theDisp,rootW,x,y, (u_int) eWIDE, (u_int) eHIGH,
+- (u_int) bwidth, (int) dispDEEP, InputOutput,
++ (u_int) bwidth, (int) dispDEEP, InputOutput,
+ theVisual, xswamask, &xswa);
+ if (!mainW) FatalError("can't create window!");
+
+@@ -3274,8 +3301,8 @@
+ xwmh.input = True;
+ xwmh.flags = InputHint;
+
+- xwmh.icon_pixmap = iconPix;
+- xwmh.icon_mask = iconmask;
++ xwmh.icon_pixmap = iconPix;
++ xwmh.icon_mask = iconmask;
+ xwmh.flags |= (IconPixmapHint | IconMaskHint);
+
+
+@@ -3302,7 +3329,7 @@
+ XSetClassHint(theDisp, mainW, &classh);
+
+
+- if (nodecor) { /* turn of image window decorations (in MWM) */
++ if (nodecor) { /* turn of image window decorations (in MWM) */
+ Atom mwm_wm_hints;
+ struct s_mwmhints {
+ long flags;
+@@ -3311,7 +3338,7 @@
+ u_long input_mode;
+ long status;
+ } mwmhints;
+-
++
+ mwm_wm_hints = XInternAtom(theDisp, "_MOTIF_WM_HINTS", False);
+ if (mwm_wm_hints != None) {
+ xvbzero((char *) &mwmhints, sizeof(mwmhints));
+@@ -3319,13 +3346,13 @@
+ mwmhints.decorations = 4;
+
+ XChangeProperty(theDisp, mainW, mwm_wm_hints, mwm_wm_hints, 32,
+- PropModeReplace, (byte *) &mwmhints,
+- (int) (sizeof(mwmhints))/4);
++ PropModeReplace, (byte *) &mwmhints,
++ (int) (sizeof(mwmhints))/4);
+ XSync(theDisp, False);
+ }
+ }
+
+-
++
+ firstTime = 0;
+ }
+
+@@ -3366,8 +3393,8 @@
+ int *w, *h;
+ {
+ /* computes new values of eWIDE and eHIGH which will have aspect ratio
+- 'normaspect'. If 'grow' it will preserve aspect by enlarging,
+- otherwise, it will shrink to preserve aspect ratio.
++ 'normaspect'. If 'grow' it will preserve aspect by enlarging,
++ otherwise, it will shrink to preserve aspect ratio.
+ Returns these values in 'w' and 'h' */
+
+ float xr,yr,curaspect,a,exp;
+@@ -3380,14 +3407,14 @@
+ curaspect = xr / yr;
+
+ /* if too narrow & shrink, shrink height. too wide and grow, grow height */
+- if ((curaspect < normaspect && !grow) ||
++ if ((curaspect < normaspect && !grow) ||
+ (curaspect > normaspect && grow)) { /* modify height */
+ exp = curaspect / normaspect;
+ *h = (int) (eHIGH * exp + .5);
+ }
+
+ /* if too narrow & grow, grow width. too wide and shrink, shrink width */
+- if ((curaspect < normaspect && grow) ||
++ if ((curaspect < normaspect && grow) ||
+ (curaspect > normaspect && !grow)) { /* modify width */
+ exp = normaspect / curaspect;
+ *w = (int) (eWIDE * exp + .5);
+@@ -3423,22 +3450,22 @@
+ suffix = namelist[0];
+ prelen = 0; /* length of prefix to be removed */
+ n = i = 0; /* shut up pesky compiler warnings */
+-
++
+ done = 0;
+ while (!done) {
+ suffix = (char *) index(suffix,'/'); /* find next '/' in file name */
+ if (!suffix) break;
+-
++
+ suffix++; /* go past it */
+ n = suffix - namelist[0];
+ for (i=1; i<numnames; i++) {
+ if (strncmp(namelist[0], namelist[i], (size_t) n)!=0) { done=1; break; }
+ }
+-
++
+ if (!done) prelen = n;
+ }
+-
+- for (i=0; i<numnames; i++)
++
++ for (i=0; i<numnames; i++)
+ dispnames[i] = namelist[i] + prelen;
+ }
+
+@@ -3447,20 +3474,20 @@
+ static void fixDispNames()
+ {
+ /* fix dispnames array so that names don't go off right edge */
+-
++
+ int i,j;
+ char *tmp;
+-
++
+ for (i=j=0; i<numnames; i++) {
+ char *dname;
+-
++
+ dname = dispnames[i];
+ if (StringWidth(dname) > (nList.w-10-16)) { /* have to trunc. */
+ tmp = dname;
+ while (1) {
+ tmp = (char *) index(tmp,'/'); /* find next '/' in filename */
+ if (!tmp) { tmp = dname; break; }
+-
++
+ tmp++; /* move to char following the '/' */
+ if (StringWidth(tmp) <= (nList.w-10-16)) { /* is cool now */
+ j++; break;
+@@ -3484,9 +3511,9 @@
+
+ name = GetDirFName();
+ GetDirPath(cwd);
+-
++
+ AddFNameToCtrlList(cwd, name);
+-
++
+ if (select) {
+ nList.selected = numnames-1;
+ curname = numnames - 1;
+@@ -3501,32 +3528,32 @@
+ char *fpath, *fname;
+ {
+ /* stick given path/name into 'namelist'. Doesn't redraw list */
+-
+- char *fullname, *dname;
++
++ char *fullname;
+ char cwd[MAXPATHLEN], globnm[MAXPATHLEN+100];
+ int i;
+-
++
+ if (!fpath) fpath = ""; /* bulletproofing... */
+- if (!fname) fname = "";
+-
++ if (!fname) fname = "";
++
+ if (numnames == MAXNAMES) return; /* full up */
+-
++
+ /* handle globbing */
+ if (fname[0] == '~') {
+ strcpy(globnm, fname);
+ Globify(globnm);
+ fname = globnm;
+ }
+-
++
+ if (fname[0] != '/') { /* prepend path */
+ strcpy(cwd, fpath); /* copy it to a modifiable place */
+-
++
+ /* make sure fpath has a trailing '/' char */
+ if (strlen(cwd)==0 || cwd[strlen(cwd)-1]!='/') strcat(cwd, "/");
+-
++
+ fullname = (char *) malloc(strlen(cwd) + strlen(fname) + 2);
+ if (!fullname) FatalError("couldn't alloc name in AddFNameToCtrlList()\n");
+-
++
+ sprintf(fullname, "%s%s", cwd, fname);
+ }
+ else { /* copy name to fullname */
+@@ -3534,15 +3561,15 @@
+ if (!fullname) FatalError("couldn't alloc name in AddFNameToCtrlList()\n");
+ strcpy(fullname, fname);
+ }
+-
+-
++
++
+ /* see if this name is a duplicate. Don't add it if it is. */
+ for (i=0; i<numnames; i++)
+ if (strcmp(fullname, namelist[i]) == 0) {
+ free(fullname);
+ return;
+ }
+-
++
+ namelist[numnames] = fullname;
+ numnames++;
+ makeDispNames();
+@@ -3578,7 +3605,7 @@
+ /* called to enable/disable the Prev/Next buttons whenever curname and/or
+ numnames and/or nList.selected change */
+
+- /* if curname<0 (there is no 'current' file), 'Next' means view the
++ /* if curname<0 (there is no 'current' file), 'Next' means view the
+ selected file (or the 0th file, if no selection either), and 'Prev' means
+ view the one right before the selected file */
+
+@@ -3591,15 +3618,15 @@
+ BTSetActive(&but[BPREV], (curname>0));
+ }
+ }
+-
++
+
+ /***********************************/
+ int DeleteCmd()
+ {
+ /* 'delete' button was pressed. Pop up a dialog box to determine
+ what should be deleted, then do it.
+- returns '1' if THE CURRENTLY VIEWED entry was deleted from the list,
+- in which case the 'selected' filename on the ctrl list is now
++ returns '1' if THE CURRENTLY VIEWED entry was deleted from the list,
++ in which case the 'selected' filename on the ctrl list is now
+ different, and should be auto-loaded, or something */
+
+ static char *bnames[] = { "\004Disk File", "\nList Entry", "\033Cancel" };
+@@ -3616,9 +3643,9 @@
+ "'Disk File' deletes file associated with selection.");
+
+ del = PopUp(str, bnames, 3);
+-
++
+ if (del == 2) return 0; /* cancel */
+-
++
+ if (del == 0) { /* 'Disk File' */
+ char *name;
+ if (namelist[delnum][0] != '/') { /* prepend 'initdir' */
+@@ -3669,13 +3696,13 @@
+
+ if (delnum != numnames-1) {
+ /* snip out of namelist and dispnames lists */
+- xvbcopy((char *) &namelist[delnum+1], (char *) &namelist[delnum],
++ xvbcopy((char *) &namelist[delnum+1], (char *) &namelist[delnum],
+ (numnames - delnum - 1) * sizeof(namelist[0]));
+
+- xvbcopy((char *) &dispnames[delnum+1], (char *) &dispnames[delnum],
++ xvbcopy((char *) &dispnames[delnum+1], (char *) &dispnames[delnum],
+ (numnames - delnum - 1) * sizeof(dispnames[0]));
+ }
+-
++
+ numnames--;
+ if (numnames==0) BTSetActive(&but[BDELETE],0);
+ windowMB.dim[WMB_TEXTVIEW] = (numnames==0);
+@@ -3686,7 +3713,7 @@
+ if (nList.selected >= numnames) nList.selected = numnames-1;
+ if (nList.selected < 0) nList.selected = 0;
+
+- SCSetRange(&nList.scrl, 0, numnames - nList.nlines,
++ SCSetRange(&nList.scrl, 0, numnames - nList.nlines,
+ nList.scrl.val, nList.nlines-1);
+ ScrollToCurrent(&nList);
+ DrawCtrlNumFiles();
+@@ -3753,7 +3780,7 @@
+ if (useroot && resetroot) ClearRoot();
+
+ if (mainW == (Window) NULL || useroot) { /* window not visible */
+- useroot = 0;
++ useroot = 0;
+
+ if (haveoldinfo) { /* just remap mainW and resize it */
+ XWMHints xwmh;
+@@ -3771,8 +3798,8 @@
+ xwmh.input = True;
+ xwmh.flags = InputHint;
+
+- xwmh.icon_pixmap = iconPix;
+- xwmh.icon_mask = iconmask;
++ xwmh.icon_pixmap = iconPix;
++ xwmh.icon_mask = iconmask;
+ xwmh.flags |= ( IconPixmapHint | IconMaskHint) ;
+
+ xwmh.flags |= StateHint;
+@@ -3787,7 +3814,7 @@
+ else { /* first time. need to create mainW */
+ mainW = (Window) NULL;
+ createMainWindow(maingeom, fnam);
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask | ButtonPressMask
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -3802,7 +3829,7 @@
+
+ else { /* mainW already visible */
+ createMainWindow(maingeom, fnam);
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask | ButtonPressMask
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -3845,13 +3872,13 @@
+ if (LocalCmap) regen=1;
+
+ /* this reallocs the colors */
+- if (colorMapMode==CM_PERFECT || colorMapMode==CM_OWNCMAP)
++ if (colorMapMode==CM_PERFECT || colorMapMode==CM_OWNCMAP)
+ ChangeCmapMode(CM_NORMAL, 0, 0);
+-
+-
++
++
+ XUnmapWindow(theDisp, mainW);
+ mainW = vrootW;
+-
++
+ if (!ctrlUp) { /* make sure ctrl is up when going to 'root' mode */
+ XWMHints xwmh;
+ xwmh.input = True;
+@@ -3861,7 +3888,7 @@
+ CtrlBox(1);
+ }
+ }
+-
++
+ useroot = 1;
+ rootMode = dispMode - RMB_ROOT;
+ ew = eWIDE; eh = eHIGH;
+@@ -3877,7 +3904,7 @@
+ GenerateEpic(ew, eh);
+ CreateXImage();
+ }
+- else if (regen) CreateXImage();
++ else if (regen) CreateXImage();
+
+ KillOldRootInfo();
+ MakeRootPic();
+@@ -3954,7 +3981,7 @@
+ if (rd_str_cl(name, "", 0)) { /* sets def_str */
+ if (sscanf(def_str, "%d", &def_int) == 1) return 1;
+ else {
+- fprintf(stderr, "%s: couldn't read integer value for %s resource\n",
++ fprintf(stderr, "%s: couldn't read integer value for %s resource\n",
+ cmd, name);
+ return 0;
+ }
+@@ -3976,14 +4003,14 @@
+ char *name;
+ {
+ /* returns '1' if successful. result in def_int */
+-
++
+ char buf[256];
+
+ if (rd_str_cl(name, "", 0)) { /* sets def_str */
+ strcpy(buf, def_str);
+ lower_str(buf);
+
+- def_int = (strcmp(buf, "on")==0) ||
++ def_int = (strcmp(buf, "on")==0) ||
+ (strcmp(buf, "1")==0) ||
+ (strcmp(buf, "true")==0) ||
+ (strcmp(buf, "yes")==0);
+@@ -3992,12 +4019,12 @@
+
+ else return 0;
+ }
+-
++
+
+
+
+ static int xrm_initted = 0;
+-
++
+ /***********************************/
+ int rd_str_cl (name_str, class_str, reinit)
+ char *name_str;
+@@ -4044,14 +4071,14 @@
+ byte *data;
+
+ i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0),
+- resAtom, 0L, 1L, False,
+- XA_STRING, &actType, &actFormat, &nitems, &nleft,
++ 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,
++ i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L,
+ (long) ((nleft+4+3)/4),
+- False, XA_STRING, &actType, &actFormat,
++ False, XA_STRING, &actType, &actFormat,
+ &nitems, &nleft, (unsigned char **) &data);
+ if (i==Success && actType==XA_STRING && actFormat==8 && data) {
+ def_resource = XrmGetStringDatabase((char *) data);
+@@ -4064,8 +4091,8 @@
+
+
+ if (!gotit) {
+- xrm_str = XResourceManagerString(theDisp);
+-
++ xrm_str = XResourceManagerString(theDisp);
++
+ if (xrm_str) {
+ def_resource = XrmGetStringDatabase(xrm_str);
+ if (DEBUG) fprintf(stderr,"rd_str_cl: Using RESOURCE_MANAGER prop.\n");
+@@ -4073,7 +4100,7 @@
+ else { /* no RESOURCE_MANAGER prop. read from 'likely' file */
+ char foo[256], *homedir, *xenviron;
+ XrmDatabase res1;
+-
++
+ #ifdef VMS
+ strcpy(foo, "SYS$LOGIN:DECW$XDEFAULTS.DAT");
+ #else
+@@ -4081,33 +4108,33 @@
+ if (!homedir) homedir = ".";
+ sprintf(foo,"%s/.Xdefaults", homedir);
+ #endif
+-
++
+ def_resource = XrmGetFileDatabase(foo);
+-
++
+ if (DEBUG) {
+ fprintf(stderr,"rd_str_cl: No RESOURCE_MANAGER prop.\n");
+ fprintf(stderr,"rd_str_cl: Using file '%s' (%s) ",
+ foo, (def_resource) ? "success" : "failure");
+ }
+-
+-
++
++
+ /* merge file pointed to by XENVIRONMENT */
+ xenviron = (char *) getenv("XENVIRONMENT");
+ if (xenviron) {
+ res1 = XrmGetFileDatabase(xenviron);
+-
++
+ if (DEBUG) {
+ fprintf(stderr,"merging XENVIRONMENT='%s' (%s) ",
+ xenviron, (res1) ? "success" : "failure");
+ }
+-
++
+ if (res1) { /* merge databases */
+ if (!def_resource) def_resource = res1;
+ else XrmMergeDatabases(res1, &def_resource);
+ }
+ }
+-
+-
++
++
+ if (DEBUG) fprintf(stderr,"\n\n");
+ }
+ }
+@@ -4120,13 +4147,13 @@
+ strcpy (q_name, PROGNAME);
+ strcat (q_name, ".");
+ strcat (q_name, name_str);
+-
++
+ strcpy (q_class, "Program");
+ strcat (q_class, ".");
+ strcat (q_class, class_str);
+
+ (void) XrmGetResource(def_resource, q_name, q_class, &type, &result);
+-
++
+ def_str = result.addr;
+ if (def_str) return (1);
+ else return (0);
+diff -ruN xv-3.10a/xv.h xv-3.10a-bugfixes/xv.h
+--- xv-3.10a/xv.h 1995-01-23 12:22:23.000000000 -0800
++++ xv-3.10a-bugfixes/xv.h 2005-04-10 09:37:18.000000000 -0700
+@@ -1,6 +1,6 @@
+ /*
+ * xv.h - header file for xv, but you probably guessed as much
+- *
++ *
+ * Author: John Bradley (bradley@cis.upenn.edu)
+ */
+
+@@ -8,8 +8,14 @@
+ #include "config.h"
+
+
+-#define REVDATE "Version 3.10a Rev: 12/29/94"
+-#define VERSTR "3.10a"
++/* xv 3.10a: 19941229 */
++/* PNG patch 1.2d: 19960731 */
++/* GRR orig jumbo fixes patch: 20000213 */
++/* 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"
+
+ /*
+ * uncomment the following, and modify for your site, but only if you've
+@@ -62,15 +68,27 @@
+ #endif
+
+
+-#ifdef LINUX
++/* 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__
++ * block is now moved after this #include */
++#include <X11/Xos.h> /* need type declarations immediately */
++
++
++#ifdef __linux__
+ # ifndef _LINUX_LIMITS_H
+ # include <linux/limits.h>
+ # endif
++# define USLEEP
++ /* want only one or the other defined, not both: */
++# if !defined(BSDTYPES) && !defined(__USE_BSD)
++# define BSDTYPES
++# endif
++# if defined(BSDTYPES) && defined(__USE_BSD)
++# undef BSDTYPES
++# endif
+ #endif
+
+
+-#include <X11/Xos.h> /* need type declarations immediately */
+-
+ /*********************************************************/
+
+
+@@ -115,17 +133,21 @@
+ #ifndef VMS
+ # include <errno.h>
+ extern int errno; /* SHOULD be in errno.h, but often isn't */
+-# ifndef __NetBSD__
++# if !defined(__NetBSD__) && !(defined(__linux__) && defined(__USE_BSD))
+ extern char *sys_errlist[]; /* this too... */
+ # endif
+ #endif
+
+
+ /* not everyone has the strerror() function, or so I'm told */
+-#ifndef VMS
+-# define ERRSTR(x) sys_errlist[x]
+-#else
++#ifdef VMS
+ # define ERRSTR(x) strerror(x, vaxc$errno)
++#else
++# if defined(__BEOS__) || defined(__linux__) /* or all modern/glibc systems? */
++# define ERRSTR(x) strerror(x)
++# else
++# define ERRSTR(x) sys_errlist[x]
++# endif
+ #endif
+
+
+@@ -159,7 +181,9 @@
+ !defined(bsd43) && \
+ !defined(aux) && \
+ !defined(__bsdi__) && \
+- !defined(sequent)
++ !defined(sequent) && \
++ !defined(__FreeBSD__) && \
++ !defined(__OpenBSD__)
+
+ # if defined(hp300) || defined(hp800) || defined(NeXT)
+ # include <sys/malloc.h> /* it's in 'sys' on HPs and NeXT */
+@@ -205,6 +229,10 @@
+ # include <limits.h>
+ # endif
+
++# ifdef __BEOS__
++# include <socket.h>
++# endif
++
+ /*** for select() call ***/
+ # ifdef __hpux
+ # define XV_FDTYPE (int *)
+@@ -259,7 +287,7 @@
+ * make them if missing, along with a few fictitious ones
+ * Cameron Simpson (cameron@cse.unsw.edu.au)
+ */
+-
++
+ #ifndef S_ISDIR /* missing POSIX-type macros */
+ # define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+ # define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK)
+@@ -308,10 +336,18 @@
+
+ #ifndef VMS /* VMS hates multi-line definitions */
+ # if defined(SVR4) || defined(SYSV) || defined(sco) || \
+- defined(XENIX) || defined(__osf__)
++ defined(XENIX) || defined(__osf__) || defined(__linux__)
+ # undef USE_GETCWD
+ # define USE_GETCWD /* use 'getcwd()' instead of 'getwd()' */
+-# endif
++# endif /* >> SECURITY ISSUE << */
++#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()' */
+ #endif
+
+
+@@ -320,15 +356,15 @@
+ /*****************************/
+
+ #ifdef DOJPEG
+-#define HAVE_JPEG
++# define HAVE_JPEG
+ #endif
+
+ #ifdef DOTIFF
+-#define HAVE_TIFF
++# define HAVE_TIFF
+ #endif
+
+ #ifdef DOPDS
+-#define HAVE_PDS
++# define HAVE_PDS
+ #endif
+
+
+@@ -442,7 +478,7 @@
+
+ /* following list gives indicies into 'saveFormats[]' array in xvdir.c
+ note that JPEG and TIFF entries may or may not exist, and following
+- constants have to be adjusted accordingly. Also, don't worry about
++ constants have to be adjusted accordingly. Also, don't worry about
+ duplicate cases if JPGINC or TIFINC = 0. All code that references
+ F_JPEG or F_TIFF is #ifdef'd, so it won't be a problem */
+
+@@ -482,7 +518,7 @@
+ /* return values from ReadFileType()
+ * positive values are *definitely* readable formats (HAVE_*** is defined)
+ * negative values are random files that XV can't read, but display as
+- * different icons in the visual browser
++ * different icons in the visual browser
+ */
+ #define RFT_ERROR -1 /* couldn't open file, or whatever... */
+ #define RFT_UNKNOWN 0
+@@ -742,7 +778,7 @@
+
+ typedef unsigned char byte;
+
+-typedef struct scrl {
++typedef struct scrl {
+ Window win; /* window ID */
+ int x,y,w,h; /* window coords in parent */
+ int len; /* length of major axis */
+@@ -972,12 +1008,12 @@
+ /* this is converted to 'theImage' */
+ WHERE int eWIDE, eHIGH; /* size of epic */
+
+-WHERE byte *egampic; /* expanded, gammified cpic
++WHERE byte *egampic; /* expanded, gammified cpic
+ (only used in 24-bit mode) */
+
+ WHERE int p_offx, p_offy; /* offset of reparented windows */
+ WHERE int ch_offx,ch_offy; /* ChngAttr ofst for reparented windows */
+-WHERE int kludge_offx, /* WM kludges for SetWindowPos routine */
++WHERE int kludge_offx, /* WM kludges for SetWindowPos routine */
+ kludge_offy;
+ WHERE int winCtrPosKludge; /* kludge for popup positioning... */
+
+@@ -1072,7 +1108,7 @@
+ WHERE int autoDelete; /* delete cmd-line files on exit? */
+
+ #define PRINTCMDLEN 256
+-WHERE char printCmd[PRINTCMDLEN];
++WHERE char printCmd[PRINTCMDLEN];
+
+ /* stuff used for 'info' box */
+ WHERE Window infoW;
+@@ -1135,7 +1171,7 @@
+ /* stuff used for 'ps' box */
+ WHERE Window psW;
+ WHERE int psUp; /* is psW mapped, or what? */
+-WHERE CBUTT encapsCB, pscompCB;
++WHERE CBUTT encapsCB, pscompCB;
+ WHERE char *gsDev, *gsGeomStr;
+ WHERE int gsRes;
+
+@@ -1210,7 +1246,7 @@
+
+ /*************************** XVMISC.C ***************************/
+ void StoreDeleteWindowProp PARM((Window));
+-Window CreateWindow PARM((char *, char *, char *, int, int,
++Window CreateWindow PARM((char *, char *, char *, int, int,
+ u_long, u_long, int));
+ void DrawString PARM((Window, int, int, char *));
+ void CenterString PARM((Window, int, int, char *));
+@@ -1222,7 +1258,7 @@
+ void GenExpose PARM((Window, int, int, u_int, u_int));
+ void DimRect PARM((Window, int, int, u_int, u_int, u_long));
+
+-void Draw3dRect PARM((Window, int, int, u_int, u_int, int, int,
++void Draw3dRect PARM((Window, int, int, u_int, u_int, int, int,
+ u_long, u_long, u_long));
+
+ void RemapKeyCheck PARM((KeySym, char *, int *));
+@@ -1237,7 +1273,7 @@
+ void SetCursors PARM((int));
+ char *BaseName PARM((char *));
+
+-void DrawTempGauge PARM((Window, int, int, int, int, double,
++void DrawTempGauge PARM((Window, int, int, int, int, double,
+ u_long, u_long, u_long, u_long, char *));
+ void ProgressMeter PARM((int, int, int, char *));
+ void XVDeletedFile PARM((char *));
+@@ -1248,6 +1284,7 @@
+ void xv_getwd PARM((char *, size_t));
+ char *xv_strstr PARM((char *, char *));
+ FILE *xv_fopen PARM((char *, char *));
++void xv_mktemp PARM((char *, char *));
+ void Timer PARM((int));
+
+ /*************************** XVCOLOR.C ***************************/
+@@ -1282,11 +1319,11 @@
+ void DrawEpic PARM((void));
+ void KillOldPics PARM((void));
+
+-byte *FSDither PARM((byte *, int, int, int,
++byte *FSDither PARM((byte *, int, int, int,
+ byte *, byte *, byte *, int, int));
+
+ void CreateXImage PARM((void));
+-XImage *Pic8ToXImage PARM((byte *, u_int, u_int, u_long *,
++XImage *Pic8ToXImage PARM((byte *, u_int, u_int, u_long *,
+ byte *, byte *, byte *));
+
+ XImage *Pic24ToXImage PARM((byte *, u_int, u_int));
+@@ -1306,21 +1343,21 @@
+ void DoAlg PARM((int));
+
+ /*************************** XVSMOOTH.C ***************************/
+-byte *SmoothResize PARM((byte *, int, int, int, int, byte *, byte *,
++byte *SmoothResize PARM((byte *, int, int, int, int, byte *, byte *,
+ byte *, byte *, byte *, byte *, int));
+
+-byte *Smooth24 PARM((byte *, int, int, int, int, int,
++byte *Smooth24 PARM((byte *, int, int, int, int, int,
+ byte *, byte *, byte *));
+
+-byte *DoColorDither PARM((byte *, byte *, int, int, byte *, byte *,
++byte *DoColorDither PARM((byte *, byte *, int, int, byte *, byte *,
+ byte *, byte *, byte *, byte *, int));
+
+-byte *Do332ColorDither PARM((byte *, byte *, int, int, byte *, byte *,
++byte *Do332ColorDither PARM((byte *, byte *, int, int, byte *, byte *,
+ byte *, byte *, byte *, byte *, int));
+
+ /*************************** XV24TO8.C **************************/
+ void Init24to8 PARM((void));
+-byte *Conv24to8 PARM((byte *, int, int, int,
++byte *Conv24to8 PARM((byte *, int, int, int,
+ byte *, byte *, byte *));
+
+ byte *Conv8to24 PARM((byte *, int, int, byte *, byte *, byte *));
+@@ -1337,7 +1374,7 @@
+ void DrawCtrlStr PARM((void));
+ void ScrollToCurrent PARM((LIST *));
+
+-void LSCreate PARM((LIST *, Window, int, int, int, int, int,
++void LSCreate PARM((LIST *, Window, int, int, int, int, int,
+ char **, int, u_long, u_long, u_long, u_long,
+ void (*)(int, SCRL *), int, int));
+
+@@ -1384,7 +1421,7 @@
+ FILE *OpenOutFile PARM((char *));
+ int CloseOutFile PARM((FILE *, char *, int));
+
+-byte *GenSavePic PARM((int*, int*,int*, int*, int*,
++byte *GenSavePic PARM((int*, int*,int*, int*, int*,
+ byte**, byte**, byte**));
+ void GetSaveSize PARM((int *, int *));
+
+@@ -1451,11 +1488,11 @@
+ void GamSetAutoApply PARM((int));
+
+ /*************************** XVSCRL.C ***************************/
+-void SCCreate PARM((SCRL *, Window, int, int, int, int,
+- int, int, int, int, u_long, u_long,
++void SCCreate PARM((SCRL *, Window, int, int, int, int,
++ int, int, int, int, u_long, u_long,
+ u_long, u_long, void (*)(int, SCRL *)));
+
+-void SCChange PARM((SCRL *, int, int, int, int, int,
++void SCChange PARM((SCRL *, int, int, int, int, int,
+ int, int, int));
+
+ void SCSetRange PARM((SCRL *, int, int, int, int));
+@@ -1465,8 +1502,8 @@
+
+
+ /*************************** XVDIAL.C ***************************/
+-void DCreate PARM((DIAL *, Window, int, int, int, int, int,
+- int, int, int, u_long, u_long, u_long,
++void DCreate PARM((DIAL *, Window, int, int, int, int, int,
++ int, int, int, u_long, u_long, u_long,
+ u_long, char *, char *));
+
+ void DSetRange PARM((DIAL *, int, int, int, int));
+@@ -1477,7 +1514,7 @@
+
+
+ /**************************** XVBUTT.C ***************************/
+-void BTCreate PARM((BUTT *, Window, int, int, u_int, u_int,
++void BTCreate PARM((BUTT *, Window, int, int, u_int, u_int,
+ char *, u_long, u_long, u_long, u_long));
+
+ void BTSetActive PARM((BUTT *, int));
+@@ -1485,7 +1522,7 @@
+ int BTTrack PARM((BUTT *));
+
+
+-RBUTT *RBCreate PARM((RBUTT *, Window, int, int, char *,
++RBUTT *RBCreate PARM((RBUTT *, Window, int, int, char *,
+ u_long, u_long, u_long, u_long));
+
+ void RBRedraw PARM((RBUTT *, int));
+@@ -1497,7 +1534,7 @@
+ int RBTrack PARM((RBUTT *, int));
+
+
+-void CBCreate PARM((CBUTT *, Window, int, int, char *,
++void CBCreate PARM((CBUTT *, Window, int, int, char *,
+ u_long, u_long, u_long, u_long));
+
+ void CBRedraw PARM((CBUTT *));
+@@ -1506,8 +1543,8 @@
+ int CBTrack PARM((CBUTT *));
+
+
+-void MBCreate PARM((MBUTT *, Window, int, int, u_int, u_int,
+- char *,
++void MBCreate PARM((MBUTT *, Window, int, int, u_int, u_int,
++ char *,
+ char **, int,u_long,u_long, u_long, u_long));
+
+ void MBRedraw PARM((MBUTT *));
+@@ -1519,7 +1556,7 @@
+
+
+ /**************************** XVGRAF.C ***************************/
+-void CreateGraf PARM((GRAF *, Window, int, int,
++void CreateGraf PARM((GRAF *, Window, int, int,
+ u_long, u_long, char *));
+
+ void InitGraf PARM((GRAF *));
+@@ -1539,32 +1576,32 @@
+ int LoadGIF PARM((char *, PICINFO *));
+
+ /*************************** XVGIFWR.C **************************/
+-int WriteGIF PARM((FILE *, byte *, int, int, int,
++int WriteGIF PARM((FILE *, byte *, int, int, int,
+ byte *, byte *, byte *, int, int, char *));
+
+ /**************************** XVPM.C ****************************/
+ int LoadPM PARM((char *, PICINFO *));
+-int WritePM PARM((FILE *, byte *, int, int, int, byte *,
++int WritePM PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int, char *));
+
+ /**************************** XVPBM.C ***************************/
+ int LoadPBM PARM((char *, PICINFO *));
+-int WritePBM PARM((FILE *, byte *, int, int, int, byte *,
++int WritePBM PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int, int, char *));
+
+ /**************************** XVXBM.C ***************************/
+ int LoadXBM PARM((char *, PICINFO *));
+-int WriteXBM PARM((FILE *, byte *, int, int, byte *, byte *,
++int WriteXBM PARM((FILE *, byte *, int, int, byte *, byte *,
+ byte *, char *));
+
+ /**************************** XVSUNRAS.C ***************************/
+ int LoadSunRas PARM((char *, PICINFO *));
+-int WriteSunRas PARM((FILE *, byte *, int, int, int, byte *,
++int WriteSunRas PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte*, int, int, int));
+
+ /**************************** XVBMP.C ***************************/
+ int LoadBMP PARM((char *, PICINFO *));
+-int WriteBMP PARM((FILE *, byte *, int, int, int, byte *,
++int WriteBMP PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int));
+
+ /**************************** XVRLE.C ***************************/
+@@ -1572,7 +1609,7 @@
+
+ /**************************** XVIRIS.C ***************************/
+ int LoadIRIS PARM((char *, PICINFO *));
+-int WriteIRIS PARM((FILE *, byte *, int, int, int, byte *,
++int WriteIRIS PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int));
+
+ /**************************** XVPCX.C ***************************/
+@@ -1583,12 +1620,12 @@
+
+ /**************************** XVTARGA.C ***************************/
+ int LoadTarga PARM((char *, PICINFO *));
+-int WriteTarga PARM((FILE *, byte *, int, int, int, byte *,
++int WriteTarga PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int));
+
+ /**************************** XVXPM.C ***************************/
+ int LoadXPM PARM((char *, PICINFO *));
+-int WriteXPM PARM((FILE *, byte *, int, int, int, byte *,
++int WriteXPM PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte *, int, int, char *, char *));
+
+ /**************************** XVXWD.C ***************************/
+@@ -1607,7 +1644,7 @@
+ void JPEGSaveParams PARM((char *, int));
+
+ /**************************** XVTIFF.C ***************************/
+-int LoadTIFF PARM((char *, PICINFO *));
++int LoadTIFF PARM((char *, PICINFO *, int));
+ void CreateTIFFW PARM((void));
+ void TIFFDialog PARM((int));
+ int TIFFCheckEvent PARM((XEvent *));
+@@ -1628,7 +1665,7 @@
+ void CenterMapWindow PARM((Window, int, int, int, int));
+ int PopUp PARM((char *, char **, int));
+ void ErrPopUp PARM((char *, char *));
+-int GetStrPopUp PARM((char *, char **, int, char *, int,
++int GetStrPopUp PARM((char *, char **, int, char *, int,
+ char *, int));
+ int GrabPopUp PARM((int *, int *));
+ int PadPopUp PARM((int *, char **, int *, int *, int *, int *));
+diff -ruN xv-3.10a/xv24to8.c xv-3.10a-bugfixes/xv24to8.c
+--- xv-3.10a/xv24to8.c 1995-01-13 11:49:21.000000000 -0800
++++ xv-3.10a-bugfixes/xv24to8.c 2004-05-16 18:00:58.000000000 -0700
+@@ -14,15 +14,15 @@
+ *
+ * The Conv24to8 procedure will set up the following: it will allocate, make
+ * & return 'pic8', a 'w' by 'h' (passed in values) 8-bit picture.
+- * it will load up the rmap, gmap and bmap colormap arrays. it will NOT
++ * it will load up the rmap, gmap and bmap colormap arrays. it will NOT
+ * calculate numcols, since the cmap sort procedure has to be called anyway
+ *
+- * Conv24to8 returns 'pic8' if successful, 'NULL' on failure (presumably on a
++ * Conv24to8 returns 'pic8' if successful, 'NULL' on failure (presumably on a
+ * malloc())
+ *
+- * The 'slow' code, while still based on Heckbert's Median Cut algorithm,
++ * The 'slow' code, while still based on Heckbert's Median Cut algorithm,
+ * has been shamelessly lifted from the Independent JPEG Group's software
+- * (jquant2.c), as (for a variety of reasons) theirs was far better than
++ * (jquant2.c), as (for a variety of reasons) theirs was far better than
+ * the version I was previously using. Thanks guys!
+ *
+ * Also, as is my way, I've stripped out most of the IJG's well-written
+@@ -65,10 +65,10 @@
+ {
+ /* returns pointer to new 8-bit-per-pixel image (w*h) if successful, or
+ NULL if unsuccessful */
+-
++
+ int i;
+ byte *pic8;
+-
++
+ if (!pic24) return NULL;
+
+ pic8 = (byte *) malloc((size_t) (w * h));
+@@ -79,9 +79,9 @@
+
+ if (nc<=0) nc = 255; /* 'nc == 0' breaks code */
+
+- if (!noqcheck && quick_check(pic24, w,h, pic8, rm,gm,bm, nc)) {
++ if (!noqcheck && quick_check(pic24, w,h, pic8, rm,gm,bm, nc)) {
+ SetISTR(ISTR_INFO,"No color compression was necessary.\n");
+- return pic8;
++ return pic8;
+ }
+
+ switch (conv24) {
+@@ -89,19 +89,19 @@
+ SetISTR(ISTR_INFO,"Doing 'quick' 24-bit to 8-bit conversion.");
+ i = quick_quant(pic24, w, h, pic8, rm, gm, bm, nc);
+ break;
+-
++
+ case CONV24_BEST:
+ SetISTR(ISTR_INFO,"Doing 'best' 24-bit to 8-bit conversion.");
+ i = ppm_quant(pic24, w, h, pic8, rm, gm, bm, nc);
+ break;
+-
++
+ case CONV24_SLOW:
+ default:
+ SetISTR(ISTR_INFO,"Doing 'slow' 24-bit to 8-bit conversion.");
+ i = slow_quant(pic24, w, h, pic8, rm, gm, bm, nc);
+ break;
+ }
+-
++
+ if (i) { free(pic8); pic8 = NULL; }
+ return pic8;
+ }
+@@ -134,7 +134,7 @@
+
+ return pic24;
+ }
+-
++
+
+ /****************************/
+ static int quick_check(pic24, w,h, pic8, rmap,gmap,bmap, maxcol)
+@@ -154,10 +154,10 @@
+ if (maxcol>256) maxcol = 256;
+
+ /* put the first color in the table by hand */
+- nc = 0; mid = 0;
++ nc = 0; mid = 0;
+
+ for (i=w*h,p=pic24; i; i--) {
+- col = (((u_long) *p++) << 16);
++ col = (((u_long) *p++) << 16);
+ col += (((u_long) *p++) << 8);
+ col += *p++;
+
+@@ -184,7 +184,7 @@
+ pic24 into colormap offsets into 'colors' */
+
+ for (i=w*h,p=pic24, pix=pic8; i; i--,pix++) {
+- col = (((u_long) *p++) << 16);
++ col = (((u_long) *p++) << 16);
+ col += (((u_long) *p++) << 8);
+ col += *p++;
+
+@@ -206,7 +206,7 @@
+
+ /* and load up the 'desired colormap' */
+ for (i=0; i<nc; i++) {
+- rmap[i] = colors[i]>>16;
++ rmap[i] = colors[i]>>16;
+ gmap[i] = (colors[i]>>8) & 0xff;
+ bmap[i] = colors[i] & 0xff;
+ }
+@@ -224,7 +224,7 @@
+ {
+ /* called after 'pic8' has been alloced, pWIDE,pHIGH set up, mono/1-bit
+ checked already */
+-
++
+ /* up to 256 colors: 3 bits R, 3 bits G, 2 bits B (RRRGGGBB) */
+ #define RMASK 0xe0
+ #define RSHIFT 0
+@@ -252,7 +252,7 @@
+ gmap[i] = (((i<<GSHIFT) & GMASK) * 255 + GMASK/2) / GMASK;
+ bmap[i] = (((i<<BSHIFT) & BMASK) * 255 + BMASK/2) / BMASK;
+ }
+-
++
+
+ thisline = (int *) malloc(pwide3 * sizeof(int));
+ nextline = (int *) malloc(pwide3 * sizeof(int));
+@@ -262,40 +262,40 @@
+ fprintf(stderr,"%s: unable to allocate memory in quick_quant()\n", cmd);
+ return(1);
+ }
+-
++
+ /* get first line of picture */
+ for (j=pwide3, tmpptr=nextline; j; j--) *tmpptr++ = (int) *p24++;
+-
++
+ for (i=0; i<h; i++) {
+ tmpptr = thisline; thisline = nextline; nextline = tmpptr; /* swap */
+-
++
+ if ((i&0x3f) == 0) WaitCursor();
+
+ if (i!=imax) /* get next line */
+ for (j=pwide3, tmpptr=nextline; j; j--)
+ *tmpptr++ = (int) *p24++;
+-
++
+ for (j=0, thisptr=thisline, nextptr=nextline; j<w; j++,pp++) {
+ r1 = *thisptr++; g1 = *thisptr++; b1 = *thisptr++;
+- RANGE(r1,0,255); RANGE(g1,0,255); RANGE(b1,0,255);
+-
++ RANGE(r1,0,255); RANGE(g1,0,255); RANGE(b1,0,255);
++
+ /* choose actual pixel value */
+- val = (((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) |
++ val = (((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) |
+ ((b1&BMASK)>>BSHIFT));
+ *pp = val;
+-
++
+ /* compute color errors */
+ r1 -= rmap[val];
+ g1 -= gmap[val];
+ b1 -= bmap[val];
+-
++
+ /* Add fractions of errors to adjacent pixels */
+ if (j!=jmax) { /* adjust RIGHT pixel */
+ thisptr[0] += (r1*7) / 16;
+ thisptr[1] += (g1*7) / 16;
+ thisptr[2] += (b1*7) / 16;
+ }
+-
++
+ if (i!=imax) { /* do BOTTOM pixel */
+ nextptr[0] += (r1*5) / 16;
+ nextptr[1] += (g1*5) / 16;
+@@ -316,7 +316,7 @@
+ }
+ }
+ }
+-
++
+ free(thisline);
+ free(nextline);
+ return 0;
+@@ -329,7 +329,7 @@
+ #undef BMASK
+ #undef BSHIFT
+ }
+-
++
+
+
+
+@@ -381,7 +381,7 @@
+
+ /* Luminance macro. */
+
+-/*
++/*
+ * #define PPM_LUMIN(p) \
+ * ( 0.299 * PPM_GETR(p) + 0.587 * PPM_GETG(p) + 0.114 * PPM_GETB(p) )
+ */
+@@ -472,7 +472,7 @@
+
+ if (DEBUG) fprintf(stderr,"%s: remapping to ppm-style internal fmt\n", fn);
+ WaitCursor();
+-
++
+ pixels = (pixel **) malloc(rows * sizeof(pixel *));
+ if (!pixels) FatalError("couldn't allocate 'pixels' array");
+ for (row=0; row<rows; row++) {
+@@ -488,7 +488,7 @@
+ if (DEBUG) fprintf(stderr,"%s: done format remapping\n", fn);
+
+
+-
++
+
+ /*
+ * attempt to make a histogram of the colors, unclustered.
+@@ -503,7 +503,7 @@
+
+ chv = ppm_computechist(pixels, cols, rows, MAXCOLORS, &colors);
+ if (chv != (chist_vec) 0) break;
+-
++
+ if (DEBUG) fprintf(stderr, "%s: too many colors!\n", fn);
+ newmaxval = maxval / 2;
+ if (DEBUG) fprintf(stderr, "%s: rescaling colors (maxval=%d) %s\n",
+@@ -635,7 +635,7 @@
+ int boxes;
+
+ bv = (box_vector) malloc(sizeof(struct box) * newcolors);
+- colormap = (chist_vec)
++ colormap = (chist_vec)
+ malloc(sizeof(struct chist_item) * newcolors );
+
+ if (!bv || !colormap) FatalError("unable to malloc in mediancut()");
+@@ -723,7 +723,7 @@
+ else if (gl >= bl)
+ qsort((char*) &(chv[indx]), (size_t) clrs, sizeof(struct chist_item),
+ greencompare );
+- else
++ else
+ qsort((char*) &(chv[indx]), (size_t) clrs, sizeof(struct chist_item),
+ bluecompare );
+ }
+@@ -750,7 +750,7 @@
+ ++boxes;
+ qsort((char*) bv, (size_t) boxes, sizeof(struct box), sumcompare);
+ } /* while (boxes ... */
+-
++
+ /*
+ ** Ok, we've got enough boxes. Now choose a representative color for
+ ** each box. There are a number of possible ways to make this choice.
+@@ -761,7 +761,7 @@
+ ** method is used by switching the commenting on the REP_ defines at
+ ** the beginning of this source file.
+ */
+-
++
+ for (bi=0; bi<boxes; bi++) {
+ /* REP_AVERAGE_PIXELS version */
+ register int indx = bv[bi].index;
+@@ -791,7 +791,7 @@
+ static int redcompare(p1, p2)
+ const void *p1, *p2;
+ {
+- return (int) PPM_GETR( ((chist_vec)p1)->color ) -
++ return (int) PPM_GETR( ((chist_vec)p1)->color ) -
+ (int) PPM_GETR( ((chist_vec)p2)->color );
+ }
+
+@@ -799,7 +799,7 @@
+ static int greencompare(p1, p2)
+ const void *p1, *p2;
+ {
+- return (int) PPM_GETG( ((chist_vec)p1)->color ) -
++ return (int) PPM_GETG( ((chist_vec)p1)->color ) -
+ (int) PPM_GETG( ((chist_vec)p2)->color );
+ }
+
+@@ -807,7 +807,7 @@
+ static int bluecompare(p1, p2)
+ const void *p1, *p2;
+ {
+- return (int) PPM_GETB( ((chist_vec)p1)->color ) -
++ return (int) PPM_GETB( ((chist_vec)p1)->color ) -
+ (int) PPM_GETB( ((chist_vec)p2)->color );
+ }
+
+@@ -821,7 +821,7 @@
+
+
+ /****************************************************************************/
+-static chist_vec
++static chist_vec
+ ppm_computechist(pixels, cols, rows, maxcolors, colorsP)
+ pixel** pixels;
+ int cols, rows, maxcolors;
+@@ -840,7 +840,7 @@
+
+
+ /****************************************************************************/
+-static chash_table ppm_computechash(pixels, cols, rows,
++static chash_table ppm_computechash(pixels, cols, rows,
+ maxcolors, colorsP )
+ pixel** pixels;
+ int cols, rows, maxcolors;
+@@ -861,14 +861,14 @@
+
+ for (chl = cht[hash]; chl != (chist_list) 0; chl = chl->next)
+ if (PPM_EQUAL(chl->ch.color, *pP)) break;
+-
++
+ if (chl != (chist_list) 0) ++(chl->ch.value);
+ else {
+ if ((*colorsP)++ > maxcolors) {
+ ppm_freechash(cht);
+ return (chash_table) 0;
+ }
+-
++
+ chl = (chist_list) malloc(sizeof(struct chist_list_item));
+ if (!chl) FatalError("ran out of memory computing hash table");
+
+@@ -878,7 +878,7 @@
+ cht[hash] = chl;
+ }
+ }
+-
++
+ return cht;
+ }
+
+@@ -1114,7 +1114,7 @@
+ register int i;
+ register long maxc = 0;
+ boxptr which = NULL;
+-
++
+ for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
+ if (boxp->colorcount > maxc && boxp->volume > 0) {
+ which = boxp;
+@@ -1133,7 +1133,7 @@
+ register int i;
+ register INT32 maxv = 0;
+ boxptr which = NULL;
+-
++
+ for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
+ if (boxp->volume > maxv) {
+ which = boxp;
+@@ -1153,11 +1153,11 @@
+ int c0min,c0max,c1min,c1max,c2min,c2max;
+ INT32 dist0,dist1,dist2;
+ long ccount;
+-
++
+ c0min = boxp->c0min; c0max = boxp->c0max;
+ c1min = boxp->c1min; c1max = boxp->c1max;
+ c2min = boxp->c2min; c2max = boxp->c2max;
+-
++
+ if (c0max > c0min)
+ for (c0 = c0min; c0 <= c0max; c0++)
+ for (c1 = c1min; c1 <= c1max; c1++) {
+@@ -1229,7 +1229,7 @@
+ dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
+ dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
+ boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
+-
++
+ ccount = 0;
+ for (c0 = c0min; c0 <= c0max; c0++)
+ for (c1 = c1min; c1 <= c1max; c1++) {
+@@ -1315,11 +1315,11 @@
+ long c0total = 0;
+ long c1total = 0;
+ long c2total = 0;
+-
++
+ c0min = boxp->c0min; c0max = boxp->c0max;
+ c1min = boxp->c1min; c1max = boxp->c1max;
+ c2min = boxp->c2min; c2max = boxp->c2max;
+-
++
+ for (c0 = c0min; c0 <= c0max; c0++)
+ for (c1 = c1min; c1 <= c1max; c1++) {
+ histp = & histogram[c0][c1][c2min];
+@@ -1332,7 +1332,7 @@
+ }
+ }
+ }
+-
++
+ sl_colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
+ sl_colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
+ sl_colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
+@@ -1505,12 +1505,12 @@
+ bptr = bestdist;
+ for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
+ *bptr++ = 0x7FFFFFFFL;
+-
++
+ /* Nominal steps between cell centers ("x" in Thomas article) */
+ #define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE)
+ #define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE)
+ #define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE)
+-
++
+ for (i = 0; i < numcolors; i++) {
+ icolor = colorlist[i];
+ /* Compute (square of) distance from minc0/c1/c2 to this color */
+@@ -1576,7 +1576,7 @@
+ minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);
+ minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);
+ minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);
+-
++
+ numcolors = find_nearby_colors(minc0, minc1, minc2, colorlist);
+
+ /* Determine the actually nearest colors. */
+diff -ruN xv-3.10a/xvalg.c xv-3.10a-bugfixes/xvalg.c
+--- xv-3.10a/xvalg.c 1994-12-22 14:34:47.000000000 -0800
++++ xv-3.10a-bugfixes/xvalg.c 2004-05-16 18:01:13.000000000 -0700
+@@ -38,7 +38,7 @@
+ double, int));
+ static void doPixel PARM((byte *,int,int,byte *, int,int,int,int,
+ int, int));
+-static void doSpread PARM((byte *,int,int,byte *, int,int,int,int,
++static void doSpread PARM((byte *,int,int,byte *, int,int,int,int,
+ int, int));
+ static void doMedianFilter PARM((byte *,int,int,byte *, int,int,int,int, int));
+
+@@ -89,7 +89,7 @@
+ /************************************************************/
+ void AlgInit()
+ {
+- /* called whenver an image file is loaded. disposes of origPic
++ /* called whenver an image file is loaded. disposes of origPic
+ if neccessary, and points it to null */
+
+ if (origPic) free(origPic);
+@@ -160,7 +160,7 @@
+ {
+ /* runs a n*n convolution mask (all 1's) over 'pic',
+ producing a 24-bit version. Then calls 24to8 to generate a new 8-bit
+- image, and installs it.
++ image, and installs it.
+
+ Note that 'n' must be odd for things to work properly */
+
+@@ -169,7 +169,7 @@
+ static char *labels[] = { "\nOk", "\033Cancel" };
+ char txt[256];
+ static char buf[64] = { '3', '\0' };
+-
++
+ sprintf(txt, "Blur: \n\n%s",
+ "Enter mask size (ex. 3, 5, 7, ...)");
+
+@@ -178,7 +178,7 @@
+ n = atoi(buf);
+
+ if (n < 1 || (n&1)!=1) {
+- ErrPopUp("Error: The value entered must be odd and greater than zero.",
++ ErrPopUp("Error: The value entered must be odd and greater than zero.",
+ "\nOh!");
+ return;
+ }
+@@ -194,7 +194,7 @@
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+-
++
+ doBlurConvolv(pic24, pWIDE,pHIGH, tmpPic, sx,sy,sw,sh, n);
+
+ end24bitAlg(pic24, tmpPic);
+@@ -212,7 +212,7 @@
+ static char *labels[] = { "\nOk", "\033Cancel" };
+ char txt[256];
+ static char buf[64] = { '7', '5', '\0' };
+-
++
+ sprintf(txt, "Sharpen: \n\n%s",
+ "Enter enhancement factor (0-99%)");
+
+@@ -236,7 +236,7 @@
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+-
++
+ doSharpConvolv(pic24, pWIDE,pHIGH, tmpPic, sx,sy,sw,sh, n);
+
+ end24bitAlg(pic24, tmpPic);
+@@ -264,7 +264,7 @@
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+
+ doEdgeConvolv(pic24, pWIDE, pHIGH, tmpPic, sx,sy,sw,sh);
+-
++
+ SetISTR(ISTR_INFO, "%snormalizing...", str);
+
+ /* Normalize results */
+@@ -292,19 +292,19 @@
+ /************************/
+ static void TinFoil()
+ {
+- byte *pic24, *p24, *tmpPic, *tp, *tlp;
++ byte *pic24, *tmpPic, *tp, *tlp;
+ char *str;
+- int i, j, v, maxv,sx,sy,sw,sh;
+-
++ int i, j, v, sx,sy,sw,sh;
++
+ WaitCursor();
+-
++
+ str = "Doing cheesy embossing effect...";
+ SetISTR(ISTR_INFO, str);
+-
++
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+
+@@ -315,9 +315,9 @@
+ *tp++ = 128; *tp++ = 128; *tp++ = 128;
+ }
+ }
+-
++
+ doAngleConvolv(pic24, pWIDE, pHIGH, tmpPic, sx,sy,sw,sh);
+-
++
+ /* mono-ify selected area of tmpPic */
+ for (i=sy; i<sy+sh; i++) {
+ tp = tlp = tmpPic + (i*pWIDE + sx) * 3;
+@@ -327,9 +327,9 @@
+ tp[0] = tp[1] = tp[2] = (byte) v;
+ }
+ }
+-
++
+ end24bitAlg(pic24, tmpPic);
+-}
++}
+
+
+ /************************/
+@@ -345,7 +345,7 @@
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+
+@@ -365,7 +365,7 @@
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ WaitCursor();
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+@@ -396,12 +396,12 @@
+ rotval = atof(buf);
+
+ if (rotval == 0.0) return;
+-
++
+
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ WaitCursor();
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+@@ -443,11 +443,11 @@
+ return;
+ }
+
+-
++
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ WaitCursor();
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+@@ -493,11 +493,11 @@
+ return;
+ }
+
+-
++
+ if (HaveSelection()) GetSelRCoords(&sx,&sy,&sw,&sh);
+ else { sx = 0; sy = 0; sw = pWIDE; sh = pHIGH; }
+ CropRect2Rect(&sx,&sy,&sw,&sh, 0,0,pWIDE,pHIGH);
+-
++
+ WaitCursor();
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+@@ -521,7 +521,7 @@
+ static char *labels[] = { "\nOk", "\033Cancel" };
+ char txt[256];
+ static char buf[64] = { '3', '\0' };
+-
++
+ sprintf(txt, "DeSpeckle (median filter): \n\n%s",
+ "Enter mask size (ex. 3, 5, 7, ...)");
+
+@@ -530,7 +530,7 @@
+ n = atoi(buf);
+
+ if (n < 1 || (n&1)!=1) {
+- ErrPopUp("Error: The value entered must be odd and greater than zero.",
++ ErrPopUp("Error: The value entered must be odd and greater than zero.",
+ "\nOh!");
+ return;
+ }
+@@ -546,7 +546,7 @@
+
+ if (start24bitAlg(&pic24, &tmpPic)) return;
+ xvbcopy((char *) pic24, (char *) tmpPic, (size_t) (pWIDE*pHIGH*3));
+-
++
+ doMedianFilter(pic24, pWIDE,pHIGH, tmpPic, sx,sy,sw,sh, n);
+
+ end24bitAlg(pic24, tmpPic);
+@@ -560,7 +560,7 @@
+ int w,h, selx,sely,selw,selh, n;
+ {
+
+- /* convolves with an n*n array, consisting of only 1's.
++ /* convolves with an n*n array, consisting of only 1's.
+ Operates on rectangular region 'selx,sely,selw,selh' (in pic coords)
+ Region is guaranteed to be completely within pic boundaries
+ 'n' must be odd */
+@@ -568,7 +568,7 @@
+ register byte *p24;
+ register int rsum,gsum,bsum;
+ byte *rp;
+- int i,j,k,x,y,x1,y1,count,n2;
++ int x,y,x1,y1,count,n2;
+
+
+ printUTime("start of blurConvolv");
+@@ -589,7 +589,7 @@
+ for (y1=y-n2; y1<=y+n2; y1++) {
+
+ if (y1>=sely && y1<sely+selh) {
+- p24 = pic24 + y1*w*3 +(x-n2)*3;
++ p24 = pic24 + y1*w*3 +(x-n2)*3;
+
+ for (x1=x-n2; x1<=x+n2; x1++) {
+ if (x1>=selx && x1<selx+selw) {
+@@ -631,7 +631,7 @@
+ byte *p24;
+ int rv, gv, bv;
+ byte *rp;
+- int i,j,k,x,y,x1,y1;
++ int i,x,y;
+ double fact, ifact, hue,sat,val, vsum;
+ double *linem1, *line0, *linep1, *tmpptr;
+
+@@ -673,7 +673,7 @@
+ for (y=sely+1; y<(sely+selh)-1; y++) {
+ ProgressMeter(sely+1, (sely+selh)-2, y, "Sharpen");
+ if ((y & 15) == 0) WaitCursor();
+-
++
+ tmpptr = linem1; linem1 = line0; line0 = linep1; linep1 = tmpptr;
+
+ /* get next line */
+@@ -691,7 +691,7 @@
+ vsum = linem1[i-1] + linem1[i] + linem1[i+1] +
+ line0 [i-1] + line0 [i] + line0 [i+1] +
+ linep1[i-1] + linep1[i] + linep1[i+1];
+-
++
+ rgb2hsv((int) p24[0], (int) p24[1], (int) p24[2], &hue, &sat, &val);
+
+ val = ((val - (fact * vsum) / 9) / ifact);
+@@ -723,22 +723,22 @@
+ {
+
+ /* convolves with two edge detection masks (vertical and horizontal)
+- simultaneously, taking Max(abs(results))
+-
++ simultaneously, taking Max(abs(results))
++
+ The two masks are (hard coded):
+
+ -1 0 1 -1 -1 -1
+ H = -1 0 1 and V = 0 0 0
+ -1 0 1 1 1 1
+
+- divided into
++ divided into
+ -1 0 0 0 0 0 0 0 1 0 1 0
+ a = 0 0 0 , b = -1 0 1 , c = 0 0 0 , d = 0 0 0 .
+ 0 0 1 0 0 0 -1 0 0 0 -1 0
+
+ So H = a + b + c, V = a - c - d.
+ gradient = max(abs(H),abs(V)).
+-
++
+ Also, only does pixels in which the masks fit fully onto the picture
+ (no pesky boundary conditionals) */
+
+@@ -746,7 +746,7 @@
+ register byte *p24;
+ register int bperlin, a, b, c, d, rsum, gsum, bsum;
+ byte *rp;
+- int i, x, y;
++ int x, y;
+
+
+ printUTime("start of edgeConvolv");
+@@ -818,13 +818,13 @@
+ {
+
+ /* convolves with edge detection mask, at 45 degrees to horizontal.
+-
++
+ The mask is (hard coded):
+
+ -2 -1 0
+ -1 0 1
+ 0 1 2
+-
++
+ Also, only does pixels in which the masks fit fully onto the picture
+ (no pesky boundary conditionals)
+
+@@ -833,7 +833,7 @@
+ register byte *p24;
+ register int bperlin,rsum,gsum,bsum;
+ byte *rp;
+- int i, x,y;
++ int x,y;
+
+
+ printUTime("start of doAngleConvolv");
+@@ -912,14 +912,14 @@
+ for each pixel in the image (assume, for a second, a grayscale image),
+ compute a histogram of the n*n rectangle centered on the pixel.
+ replace the pixel with the color that had the greatest # of hits in
+- the histogram. Note that 'n' should be odd.
++ the histogram. Note that 'n' should be odd.
+
+ I've modified the algorithm to do the *right* thing for RGB images.
+ (jhb, 6/94) */
+
+
+ register byte *pp;
+- register int bperlin, rsum,gsum,bsum;
++ register int bperlin;
+ byte *rp, *p24, *plin;
+ int i,j,k,x,y,n2,col,cnt,maxcnt;
+ int *nnrect;
+@@ -933,7 +933,7 @@
+
+ /* nnrect[] is an n*n array of ints, with '-1' meaning 'outside the region'
+ otherwise they'll have 24-bit RGB values */
+-
++
+ nnrect = (int *) malloc(n * n * sizeof(int));
+ if (!nnrect) FatalError("can't malloc nnrect[] in doOilPaint()\n");
+
+@@ -943,13 +943,13 @@
+
+ p24 = pic24 + ((y-n2)*w + selx-n2)*3; /* pts to top-left of mask */
+ rp = results + (y*w + selx)*3;
+-
++
+ for (x=selx; x<selx+selw; x++) {
+ /* fill 'nnrect' with valid pixels from n*n region centered round x,y */
+ pp = plin = p24;
+ for (i=y-n2, k=0; i<y+n2; i++) {
+ for (j=x-n2; j<x+n2; j++, k++, pp+=3) {
+- if (i>=sely && i<sely+selh && j>=selx && j<selx+selw) {
++ if (i>=sely && i<sely+selh && j>=selx && j<selx+selw) {
+ nnrect[k] = (((int) pp[0])<<16) | (((int) pp[1])<<8) | pp[2];
+ }
+ else nnrect[k] = -1;
+@@ -957,7 +957,7 @@
+ plin += bperlin; pp = plin;
+ }
+
+-
++
+ /* find 'most popular color' in nnrect, not counting '-1' */
+ maxcnt = cnt = col = 0;
+ for (i=0; i<n*n; i++) {
+@@ -1021,7 +1021,7 @@
+ p24 = pic24 + (y*w + selx) * 3;
+ rf += (double) p24[0]; gf += (double) p24[1]; bf += (double) p24[2];
+ i++;
+-
++
+ p24 = pic24 + (y*w + (selx+selw-1)) * 3;
+ rf += (double) p24[0]; gf += (double) p24[1]; bf += (double) p24[2];
+ i++;
+@@ -1047,7 +1047,7 @@
+ if (dx==0 && dy==0) { ex = selx; ey = sely; } /* don't care */
+ else if (dx==0) { ex = cx; ey = (dy<0) ? sely : sely+selh-1; }
+ else if (dy==0) { ey = cy; ex = (dx<0) ? selx : selx+selw-1; }
+- else {
++ else {
+ slope = ((double) dy) / dx;
+ if (fabs(slope) > fabs(dslope)) { /* y axis is major */
+ ey = (dy<0) ? sely : sely+selh-1;
+@@ -1092,7 +1092,7 @@
+ printUTime("end of blend");
+ }
+
+-
++
+
+ /************************/
+ static void doRotate(pic24, w, h, results, selx,sely,selw,selh, rotval, clear)
+@@ -1104,7 +1104,7 @@
+ by the amount specified in degrees (rotval), and stores the result in
+ 'results', which is also a w*h 24-bit image. The rotated bits are
+ clipped to fit in 'results'. If 'clear', the (unrotated) rectangular
+- region is cleared (in results) first.
++ region is cleared (in results) first.
+ sel[x,y,w,h] is guaranteed to be within image bounds */
+
+ byte *pp, *dp;
+@@ -1118,7 +1118,7 @@
+ printUTime("start of rotate");
+
+ /*
+- * cfx,cfy - center point of sel rectangle (double)
++ * cfx,cfy - center point of sel rectangle (double)
+ * rx1,ry1 - top-left of sel, rotated
+ * rx2,ry2 - bot-left of sel, rotated
+ * rx3,ry3 - top-right of sel, rotated
+@@ -1174,7 +1174,7 @@
+ /* now, for each pixel in rb[x,y,w,h], do the inverse rotation to see if
+ it would be in the original unrotated selection rectangle. if it *is*,
+ compute and store an appropriate color, otherwise skip it */
+-
++
+ for (y=rby; y<rby+rbh; y++) {
+ dp = results + (y * w + rbx) * 3;
+
+@@ -1194,7 +1194,7 @@
+ int p0r,p0g,p0b, p1r,p1g,p1b, p2r,p2g,p2b, p3r,p3g,p3b;
+ int rv,gv,bv;
+ double rd,gd,bd, p0wgt, p1wgt, p2wgt, p3wgt;
+-
++
+ /* compute the color, same idea as in Smooth**(). The color
+ will be a linear combination of the colors of the center pixel,
+ its left-or-right neighbor, its top-or-bottom neighbor, and
+@@ -1265,9 +1265,9 @@
+ }
+ #endif /* ROTATE_FOO */
+
+- dp[0] = (byte) (rv&0xff);
+- dp[1] = (byte) (gv&0xff);
+- dp[2] = (byte) (bv&0xff);
++ dp[0] = (byte) (rv&0xff);
++ dp[1] = (byte) (gv&0xff);
++ dp[2] = (byte) (bv&0xff);
+ }
+ }
+ }
+@@ -1311,11 +1311,11 @@
+ #ifdef FOO
+ fprintf(stderr,"rotXfer: rotating (%4d,%4d) %7.2f degrees around",
+ x,y, rad*180.0 / M_PI);
+- fprintf(stderr,"(%4d,%4d) -> %7.2f %7.2f (d=%f ang=%f)\n",
++ fprintf(stderr,"(%4d,%4d) -> %7.2f %7.2f (d=%f ang=%f)\n",
+ cx,cy, *rx,*ry, d, ang);
+ #endif
+ }
+-
++
+
+
+ /************************/
+@@ -1323,29 +1323,29 @@
+ byte *pic24, *results;
+ int w, h, selx,sely,selw,selh, pixX,pixY;
+ {
+- /* runs 'pixelization' algorithm. replaces each pixX-by-pixY region
++ /* runs 'pixelization' algorithm. replaces each pixX-by-pixY region
+ (smaller on edges) with the average color within that region */
+-
++
+ byte *pp;
+ int nwide, nhigh, i,j, x,y, x1,y1, stx,sty;
+ int nsum, rsum, gsum, bsum;
+-
++
+ printUTime("start of pixelize");
+-
++
+ /* center grid on selection */
+ nwide = (selw + pixX-1) / pixX;
+ nhigh = (selh + pixY-1) / pixY;
+-
++
+ stx = selx - (nwide*pixX - selw)/2;
+ sty = sely - (nhigh*pixY - selh)/2;
+-
++
+ y = sty;
+ for (i=0; i<nhigh; i++, y+=pixY) {
+ ProgressMeter(0, nhigh-1, i, "Pixelize");
+-
++
+ x = stx;
+ for (j=0; j<nwide; j++, x+=pixX) {
+-
++
+ /* COMPUTE AVERAGE COLOR FOR RECT:[x,y,pixX,pixY] */
+ nsum = rsum = gsum = bsum = 0;
+ for (y1=y; y1<y+pixY; y1++) {
+@@ -1357,17 +1357,17 @@
+ }
+ }
+ }
+-
++
+ if (nsum>0) { /* just to be safe... */
+ rsum /= nsum; gsum /= nsum; bsum /= nsum;
+ RANGE(rsum,0,255); RANGE(gsum,0,255); RANGE(bsum,0,255);
+ }
+-
+-
++
++
+ /* STORE color in rect:[x,y,pixX,pixY] */
+ for (y1=y; y1<y+pixY; y1++) {
+ if (!j && (y1 & 255)==0) WaitCursor();
+-
++
+ pp = results + (y1 * w + x) * 3;
+ for (x1=x; x1<x+pixX; x1++, pp+=3) {
+ if (PTINRECT(x1,y1, selx,sely,selw,selh)) {
+@@ -1381,7 +1381,7 @@
+ printUTime("end of pixelize");
+ }
+
+-
++
+
+ /************************/
+ static void doSpread(pic24, w, h, results, selx,sely,selw,selh, pixX, pixY)
+@@ -1393,17 +1393,17 @@
+ by pixX,pixY. If pixX<0, it is treated as a single 'distance' value
+ (after being abs()'d). */
+
+- /* assumes that initially 'results' is a copy of pic24. Doesn't
++ /* assumes that initially 'results' is a copy of pic24. Doesn't
+ even look at pic24 */
+-
++
+ byte *pp, *dp, r,g,b;
+- int x,y, dx,dy, x1,y1, d, xrng, xoff, yrng, yoff, i,j;
++ int x,y, x1,y1, d;
+ int minx, maxx, miny, maxy, rdist;
+ time_t nowT;
+
+ time(&nowT);
+ srandom((unsigned int) nowT);
+-
++
+ printUTime("start of spread");
+
+ for (y=sely; y<sely+selh; y++) {
+@@ -1453,7 +1453,7 @@
+ printUTime("end of spread");
+ }
+
+-
++
+
+ /************************/
+ static void doMedianFilter(pic24, w, h, results, selx,sely,selw,selh, n)
+@@ -1468,7 +1468,7 @@
+ register byte *p24;
+ register int rsum,gsum,bsum;
+ byte *rp;
+- int i,j,k,x,y,x1,y1,count,n2,nsq,c2;
++ int x,y,x1,y1,count,n2,nsq,c2;
+ int *rtab, *gtab, *btab;
+
+ printUTime("start of doMedianFilter");
+@@ -1494,7 +1494,7 @@
+ for (y1=y-n2; y1<=y+n2; y1++) {
+
+ if (y1>=sely && y1<sely+selh) {
+- p24 = pic24 + y1*w*3 +(x-n2)*3;
++ p24 = pic24 + y1*w*3 +(x-n2)*3;
+
+ for (x1=x-n2; x1<=x+n2; x1++) {
+ if (x1>=selx && x1<selx+selw) {
+@@ -1509,12 +1509,12 @@
+ }
+
+
+- /* now sort the rtab,gtab,btab arrays, (using shell sort)
+- and pick the middle value. doing it in-line, rather than
++ /* now sort the rtab,gtab,btab arrays, (using shell sort)
++ and pick the middle value. doing it in-line, rather than
+ as a function call (ie, 'qsort()') , for speed */
+- {
++ {
+ int i,j,t,d;
+-
++
+ for (d=count/2; d>0; d=d/2) {
+ for (i=d; i<count; i++) {
+ for (j=i-d; j>=0 && rtab[j]>rtab[j+d]; j-=d) {
+@@ -1531,14 +1531,14 @@
+ }
+ }
+ }
+-
++
+ c2 = count/2;
+ *rp++ = (byte) ( (count&1) ? rtab[c2] : (rtab[c2] + rtab[c2-1])/2);
+ *rp++ = (byte) ( (count&1) ? gtab[c2] : (gtab[c2] + gtab[c2-1])/2);
+ *rp++ = (byte) ( (count&1) ? btab[c2] : (btab[c2] + btab[c2-1])/2);
+ }
+ }
+-
++
+ free(rtab); free(gtab); free(btab);
+ printUTime("end of doMedianFilter");
+ }
+@@ -1549,7 +1549,7 @@
+ static void intsort(a, n)
+ int *a, n;
+ {
+- /* uses the shell-sort algorithm. for the relatively small data sets
++ /* uses the shell-sort algorithm. for the relatively small data sets
+ we'll be using, should be quicker than qsort() because of all the
+ function calling overhead associated with qsort(). */
+
+@@ -1571,7 +1571,7 @@
+ byte **pic24, **tmpPic;
+ {
+ /* generates a 24-bit version of 'pic', if neccessary, and also mallocs
+- * a pWIDE*pHIGH*3 24-bit output pic.
++ * a pWIDE*pHIGH*3 24-bit output pic.
+ *
+ * Returns '1' if there's some sort of screwup, '0' if cool
+ */
+@@ -1588,7 +1588,7 @@
+ *tmpPic = (byte *) calloc((size_t) (pWIDE * pHIGH * 3), (size_t) 1);
+ if (!(*tmpPic)) {
+ SetCursors(-1);
+- ErrPopUp("Unable to malloc() tmp 24-bit image in start24bitAlg()",
++ ErrPopUp("Unable to malloc() tmp 24-bit image in start24bitAlg()",
+ "\nTough!");
+ if (picType == PIC8) free(*pic24);
+ return 1;
+@@ -1609,16 +1609,16 @@
+ saveOrigPic(); /* also kills pic/cpic/epic/egampic/theImage, NOT pic24 */
+
+ /* copy results to pic24 */
+- xvbcopy((char *) outPic, (char *) pic24, (size_t) (pWIDE*pHIGH*3));
++ xvbcopy((char *) outPic, (char *) pic24, (size_t) (pWIDE*pHIGH*3));
+ free(outPic);
+
+ if (picType == PIC8) {
+ pic = Conv24to8(pic24, pWIDE, pHIGH, ncols, rMap,gMap,bMap);
+ free(pic24);
+- if (!pic) {
++ if (!pic) {
+ SetCursors(-1);
+ ErrPopUp("Some sort of failure occured in 24to8 conversion\n","\nDamn!");
+- NoAlg();
++ NoAlg();
+ return;
+ }
+ }
+@@ -1632,7 +1632,7 @@
+ static void saveOrigPic()
+ {
+ /* saves original picture into origPic, if it hasn't already been done.
+- This allows us to undo algorithms...
++ This allows us to undo algorithms...
+
+ Also, frees all pics, (except 'pic', if we're in PIC24 mode) */
+
+@@ -1649,7 +1649,7 @@
+ /* make a backup copy of 'pic' */
+ origPic = (byte *) malloc((size_t)(pWIDE*pHIGH*((picType==PIC8) ? 1 : 3)));
+ if (!origPic) FatalError("out of memory in 'saveOrigPic()'");
+- xvbcopy((char *) pic, (char *) origPic,
++ xvbcopy((char *) pic, (char *) origPic,
+ (size_t) (pWIDE * pHIGH * ((picType==PIC8) ? 1 : 3)));
+
+ origPicType = picType;
+diff -ruN xv-3.10a/xvbmp.c xv-3.10a-bugfixes/xvbmp.c
+--- xv-3.10a/xvbmp.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvbmp.c 2005-03-27 18:12:17.000000000 -0800
+@@ -14,7 +14,7 @@
+ 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 LoadPBM returns non-zero
++ stuff is tossed, and LoadBMP returns non-zero
+
+ not being able to malloc is a Fatal Error. The program is aborted. */
+
+@@ -54,9 +54,9 @@
+ {
+ FILE *fp;
+ int i, c, c1, rv;
+- unsigned int bfSize, bfOffBits, biSize, biWidth, biHeight, biPlanes;
+- unsigned int biBitCount, biCompression, biSizeImage, biXPelsPerMeter;
+- unsigned int biYPelsPerMeter, biClrUsed, biClrImportant;
++ 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;
+@@ -69,7 +69,7 @@
+
+ fp = xv_fopen(fname,"r");
+ if (!fp) return (bmpError(bname, "couldn't open file"));
+-
++
+ fseek(fp, 0L, 2); /* figure out the file size */
+ filesize = ftell(fp);
+ fseek(fp, 0L, 0);
+@@ -104,11 +104,11 @@
+ biHeight = getshort(fp);
+ biPlanes = getshort(fp);
+ biBitCount = getshort(fp);
+-
++
+ /* Not in old versions so have to compute them*/
+ biSizeImage = (((biPlanes * biBitCount*biWidth)+31)/32)*4*biHeight;
+-
+- biCompression = BI_RGB;
++
++ biCompression = BI_RGB;
+ biXPelsPerMeter = biYPelsPerMeter = 0;
+ biClrUsed = biClrImportant = 0;
+ }
+@@ -127,11 +127,14 @@
+
+
+ /* error checking */
+- if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) ||
+- biPlanes!=1 || biCompression>BI_RLE4) {
+-
+- sprintf(buf,"Bogus BMP File! (bitCount=%d, Planes=%d, Compression=%d)",
+- biBitCount, biPlanes, biCompression);
++ if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) ||
++ biPlanes!=1 || biCompression>BI_RLE4 ||
++ biWidth<=0 || biHeight<=0 ||
++ (biClrUsed && biClrUsed > (1 << biBitCount))) {
++
++ sprintf(buf,
++ "Bogus BMP File! (%dx%d, Bits=%d, Colors=%d, Planes=%d, Compr=%d)",
++ biWidth, biHeight, biBitCount, biClrUsed, biPlanes, biCompression);
+
+ bmpError(bname, buf);
+ goto ERROR;
+@@ -154,7 +157,7 @@
+ /* skip ahead to colormap, using biSize */
+ c = biSize - 40; /* 40 bytes read from biSize to biClrImportant */
+ for (i=0; i<c; i++) getc(fp);
+-
++
+ bPad = bfOffBits - (biSize + 14);
+ }
+
+@@ -162,6 +165,11 @@
+ if (biBitCount!=24) {
+ 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);
+@@ -173,7 +181,7 @@
+ }
+ }
+
+- if (FERROR(fp))
++ if (FERROR(fp))
+ { bmpError(bname,"EOF reached in BMP colormap"); goto ERROR; }
+
+ if (DEBUG>1) {
+@@ -188,7 +196,7 @@
+ if (biSize != WIN_OS2_OLD) {
+ /* Waste any unused bytes between the colour map (if present)
+ and the start of the actual bitmap data. */
+-
++
+ while (bPad > 0) {
+ (void) getc(fp);
+ bPad--;
+@@ -198,11 +206,21 @@
+ /* create pic8 or pic24 */
+
+ if (biBitCount==24) {
+- pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1);
++ u_int npixels = biWidth * biHeight;
++ u_int count = 3 * npixels;
++
++ if (biWidth == 0 || biHeight == 0 || npixels/biWidth != biHeight ||
++ count/3 != npixels)
++ return (bmpError(bname, "image dimensions too large"));
++ pic24 = (byte *) calloc((size_t) count, (size_t) 1);
+ if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'"));
+ }
+ else {
+- pic8 = (byte *) calloc((size_t) biWidth * biHeight, (size_t) 1);
++ u_int npixels = biWidth * biHeight;
++
++ if (biWidth == 0 || biHeight == 0 || npixels/biWidth != biHeight)
++ return (bmpError(bname, "image dimensions too large"));
++ pic8 = (byte *) calloc((size_t) npixels, (size_t) 1);
+ if (!pic8) return(bmpError(bname, "couldn't malloc 'pic8'"));
+ }
+
+@@ -216,7 +234,7 @@
+ biCompression);
+ else rv = loadBMP24(fp,pic24,biWidth,biHeight);
+
+- if (rv) bmpError(bname, "File appears truncated. Winging it.\n");
++ if (rv) bmpError(bname, "File appears truncated. Winging it.");
+
+ fclose(fp);
+
+@@ -254,7 +272,7 @@
+ ERROR:
+ fclose(fp);
+ return 0;
+-}
++}
+
+
+ /*******************************************/
+@@ -277,7 +295,7 @@
+ c = getc(fp);
+ bitnum = 0;
+ }
+-
++
+ if (j<w) {
+ *pp++ = (c & 0x80) ? 1 : 0;
+ c <<= 1;
+@@ -287,7 +305,7 @@
+ }
+
+ return (FERROR(fp));
+-}
++}
+
+
+
+@@ -299,24 +317,24 @@
+ {
+ int i,j,c,c1,x,y,nybnum,padw,rv;
+ byte *pp;
+-
+-
++
++
+ rv = 0;
+ c = c1 = 0;
+-
++
+ 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--) {
+ pp = pic8 + (i * w);
+ if ((i&0x3f)==0) WaitCursor();
+-
++
+ for (j=nybnum=0; j<padw; j++,nybnum++) {
+ if ((nybnum & 1) == 0) { /* read next byte */
+ c = getc(fp);
+ nybnum = 0;
+ }
+-
++
+ if (j<w) {
+ *pp++ = (c & 0xf0) >> 4;
+ c <<= 4;
+@@ -325,55 +343,55 @@
+ if (FERROR(fp)) break;
+ }
+ }
+-
++
+ else if (comp == BI_RLE4) { /* read RLE4 compressed data */
+- x = y = 0;
++ x = y = 0;
+ pp = pic8 + x + (h-y-1)*w;
+-
++
+ while (y<h) {
+ c = getc(fp); if (c == EOF) { rv = 1; break; }
+-
++
+ if (c) { /* encoded mode */
+ c1 = getc(fp);
+- for (i=0; i<c; i++,x++,pp++)
++ for (i=0; i<c; i++,x++,pp++)
+ *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
+ }
+-
++
+ else { /* c==0x00 : escape codes */
+ c = getc(fp); if (c == EOF) { rv = 1; break; }
+-
++
+ if (c == 0x00) { /* end of line */
+ x=0; y++; pp = pic8 + x + (h-y-1)*w;
+- }
+-
++ }
++
+ else if (c == 0x01) break; /* end of pic8 */
+-
++
+ else if (c == 0x02) { /* delta */
+ c = getc(fp); x += c;
+ c = getc(fp); y += c;
+ pp = pic8 + x + (h-y-1)*w;
+ }
+-
++
+ else { /* absolute mode */
+ for (i=0; i<c; i++, x++, pp++) {
+ if ((i&1) == 0) c1 = getc(fp);
+ *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
+ }
+-
++
+ if (((c&3)==1) || ((c&3)==2)) getc(fp); /* read pad byte */
+ }
+ } /* escape processing */
+ if (FERROR(fp)) break;
+ } /* while */
+ }
+-
++
+ else {
+ fprintf(stderr,"unknown BMP compression type 0x%0x\n", comp);
+ }
+-
++
+ if (FERROR(fp)) rv = 1;
+ return rv;
+-}
++}
+
+
+
+@@ -385,7 +403,7 @@
+ {
+ int i,j,c,c1,padw,x,y,rv;
+ byte *pp;
+-
++
+ rv = 0;
+
+ if (comp == BI_RGB) { /* read uncompressed data */
+@@ -404,7 +422,7 @@
+ }
+
+ else if (comp == BI_RLE8) { /* read RLE8 compressed data */
+- x = y = 0;
++ x = y = 0;
+ pp = pic8 + x + (h-y-1)*w;
+
+ while (y<h) {
+@@ -420,7 +438,7 @@
+
+ if (c == 0x00) { /* end of line */
+ x=0; y++; pp = pic8 + x + (h-y-1)*w;
+- }
++ }
+
+ else if (c == 0x01) break; /* end of pic8 */
+
+@@ -435,21 +453,21 @@
+ c1 = getc(fp);
+ *pp = c1;
+ }
+-
++
+ if (c & 1) getc(fp); /* odd length run: read an extra pad byte */
+ }
+ } /* escape processing */
+ if (FERROR(fp)) break;
+ } /* while */
+ }
+-
++
+ else {
+ fprintf(stderr,"unknown BMP compression type 0x%0x\n", comp);
+ }
+
+ if (FERROR(fp)) rv = 1;
+ return rv;
+-}
++}
+
+
+
+@@ -469,7 +487,7 @@
+ for (i=h-1; i>=0; i--) {
+ pp = pic24 + (i * w * 3);
+ if ((i&0x3f)==0) WaitCursor();
+-
++
+ for (j=0; j<w; j++) {
+ pp[2] = getc(fp); /* blue */
+ pp[1] = getc(fp); /* green */
+@@ -484,30 +502,30 @@
+ }
+
+ return rv;
+-}
++}
+
+
+
+ /*******************************************/
+-static unsigned int getshort(fp)
++static u_int getshort(fp)
+ FILE *fp;
+ {
+ int c, c1;
+ c = getc(fp); c1 = getc(fp);
+- return ((unsigned int) c) + (((unsigned int) c1) << 8);
++ return ((u_int) c) + (((u_int) c1) << 8);
+ }
+
+
+ /*******************************************/
+-static unsigned int getint(fp)
++static u_int getint(fp)
+ FILE *fp;
+ {
+ int c, c1, c2, c3;
+ c = getc(fp); c1 = getc(fp); c2 = getc(fp); c3 = getc(fp);
+- return ((unsigned int) c) +
+- (((unsigned int) c1) << 8) +
+- (((unsigned int) c2) << 16) +
+- (((unsigned int) c3) << 24);
++ return ((u_int) c) +
++ (((u_int) c1) << 8) +
++ (((u_int) c2) << 16) +
++ (((u_int) c3) << 24);
+ }
+
+
+@@ -518,7 +536,7 @@
+ {
+ int c, c1;
+
+- c = ((unsigned int ) i) & 0xff; c1 = (((unsigned int) i)>>8) & 0xff;
++ c = ((u_int) i) & 0xff; c1 = (((u_int) i)>>8) & 0xff;
+ putc(c, fp); putc(c1,fp);
+ }
+
+@@ -529,10 +547,10 @@
+ int i;
+ {
+ int c, c1, c2, c3;
+- c = ((unsigned int ) i) & 0xff;
+- c1 = (((unsigned int) i)>>8) & 0xff;
+- c2 = (((unsigned int) i)>>16) & 0xff;
+- c3 = (((unsigned int) i)>>24) & 0xff;
++ c = ((u_int) i) & 0xff;
++ c1 = (((u_int) i)>>8) & 0xff;
++ c2 = (((u_int) i)>>16) & 0xff;
++ c3 = (((u_int) i)>>24) & 0xff;
+
+ putc(c, fp); putc(c1,fp); putc(c2,fp); putc(c3,fp);
+ }
+@@ -562,11 +580,11 @@
+ * 8-bit image
+ * note that PIC24 and F_BWDITHER/F_REDUCED won't happen
+ *
+- * if colorstyle == F_BWDITHER, it writes a 1-bit image
++ * if colorstyle == F_BWDITHER, it writes a 1-bit image
+ *
+ */
+
+- int i,j, nc, nbits, bperlin, cmaplen;
++ int i,j, nc, nbits, bperlin, cmaplen, npixels;
+ byte *graypic, *sp, *dp, graymap[256];
+
+ nc = nbits = cmaplen = 0;
+@@ -576,10 +594,16 @@
+ /* generate a faked 8-bit per pixel image with a grayscale cmap,
+ so that it can just fall through existing 8-bit code */
+
+- graypic = (byte *) malloc((size_t) w*h);
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h) {
++ SetISTR(ISTR_WARNING, "image dimensions too large");
++ return -1;
++ }
++
++ graypic = (byte *) malloc((size_t) npixels);
+ if (!graypic) FatalError("unable to malloc in WriteBMP()");
+
+- for (i=0,sp=pic824,dp=graypic; i<w*h; i++,sp+=3, dp++) {
++ for (i=0,sp=pic824,dp=graypic; i<npixels; i++,sp+=3, dp++) {
+ *dp = MONO(sp[0],sp[1],sp[2]);
+ }
+
+@@ -611,7 +635,7 @@
+ for (i=0; i<numcols; i++) {
+ /* see if color #i is a duplicate */
+ for (j=0; j<i; j++) {
+- if (rmap[i] == rmap[j] && gmap[i] == gmap[j] &&
++ if (rmap[i] == rmap[j] && gmap[i] == gmap[j] &&
+ bmap[i] == bmap[j]) break;
+ }
+
+@@ -689,13 +713,13 @@
+ #else
+ if (!FERROR(fp)) return -1;
+ #endif
+-
++
+ return 0;
+ }
+
+
+-
+-
++
++
+ /*******************************************/
+ static void writeBMP1(fp, pic8, w, h)
+ FILE *fp;
+@@ -708,7 +732,7 @@
+ padw = ((w + 31)/32) * 32; /* 'w', padded to be a multiple of 32 */
+
+ for (i=h-1; i>=0; i--) {
+- pp = pic8 + (i * w);
++ pp = pic8 + (i * w);
+ if ((i&0x3f)==0) WaitCursor();
+
+ for (j=bitnum=c=0; j<=padw; j++,bitnum++) {
+@@ -716,7 +740,7 @@
+ putc(c,fp);
+ bitnum = c = 0;
+ }
+-
++
+ c <<= 1;
+
+ if (j<w) {
+@@ -724,7 +748,7 @@
+ }
+ }
+ }
+-}
++}
+
+
+
+@@ -758,7 +782,7 @@
+ }
+ }
+ }
+-}
++}
+
+
+
+@@ -768,7 +792,7 @@
+ byte *pic8;
+ int w,h;
+ {
+- int i,j,c,padw;
++ int i,j,padw;
+ byte *pp;
+
+ padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */
+@@ -780,7 +804,7 @@
+ for (j=0; j<w; j++) putc(pc2nc[*pp++], fp);
+ for ( ; j<padw; j++) putc(0, fp);
+ }
+-}
++}
+
+
+ /*******************************************/
+@@ -789,7 +813,7 @@
+ byte *pic24;
+ int w,h;
+ {
+- int i,j,c,padb;
++ int i,j,padb;
+ byte *pp;
+
+ padb = (4 - ((w*3) % 4)) & 0x03; /* # of pad bytes to write at EOscanline */
+@@ -807,7 +831,7 @@
+
+ for (j=0; j<padb; j++) putc(0, fp);
+ }
+-}
++}
+
+
+
+diff -ruN xv-3.10a/xvbrowse.c xv-3.10a-bugfixes/xvbrowse.c
+--- xv-3.10a/xvbrowse.c 1995-01-19 09:49:17.000000000 -0800
++++ xv-3.10a-bugfixes/xvbrowse.c 2004-05-16 18:01:25.000000000 -0700
+@@ -1,6 +1,6 @@
+ /*
+ * xvbrowse.c - visual schnauzer routines
+- *
++ *
+ * includes:
+ * void CreateBrowse(char *, char *, char *, char *, char *);
+ * void OpenBrowse();
+@@ -34,7 +34,7 @@
+ #include "bits/br_sock"
+ #include "bits/br_fifo"
+ #include "bits/br_error"
+-#include "bits/br_unknown"
++/* #include "bits/br_unknown" commented out (near line 492) */
+ #include "bits/br_cmpres"
+
+ #include "bits/br_gif"
+@@ -97,7 +97,7 @@
+ #define BF_MAX 28 /* # of built-in icons */
+
+ #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \
+- ftyp!=BF_SOCK && ftyp!=BF_FIFO)
++ ftyp!=BF_SOCK && ftyp!=BF_FIFO)
+
+ #define DEF_BROWWIDE 615 /* default size of window */
+ #define DEF_BROWHIGH 356
+@@ -150,12 +150,12 @@
+ static char *hideHstr = "Hide 'hidden' files";
+
+ static char *cmdMList[] = { "Change directory...\t^c",
+- "Delete file(s)\t^d",
+- "New directory...\t^n",
+- "Rename file...\t^r",
++ "Delete file(s)\t^d",
++ "New directory...\t^n",
++ "Rename file...\t^r",
+ "Rescan directory\t^s",
+- "Update icons\t^u",
+- "Open new window\t^w",
++ "Update icons\t^u",
++ "Open new window\t^w",
+ "Generate icon(s)\t^g",
+ "Select all files\t^a",
+ "Text view\t^t",
+@@ -260,7 +260,7 @@
+ static void genSelectedIcons PARM((BROWINFO *));
+ static void genIcon PARM((BROWINFO *, BFIL *));
+ static void loadThumbFile PARM((BROWINFO *, BFIL *));
+-static void writeThumbFile PARM((BROWINFO *, BFIL *, byte *, int,
++static void writeThumbFile PARM((BROWINFO *, BFIL *, byte *, int,
+ int, char *));
+
+ static void makeThumbDir PARM((BROWINFO *));
+@@ -284,7 +284,7 @@
+ static void rm_dir PARM((BROWINFO *, char *));
+ static void rm_dir1 PARM((BROWINFO *));
+
+-static void dragFiles PARM((BROWINFO *, BROWINFO *, char *, char *,
++static void dragFiles PARM((BROWINFO *, BROWINFO *, char *, char *,
+ char *, char **, int, int));
+ static int moveFile PARM((char *, char *));
+ static int copyFile PARM((char *, char *));
+@@ -369,8 +369,8 @@
+ if (gset & YNegative) gy1 = gy - i * 20;
+ else gy1 = gy + i * 20;
+
+- if ((gset & WidthValue) && (gset & HeightValue))
+- sprintf(wgeom, "%dx%d%s%d%s%d", gw, gh,
++ if ((gset & WidthValue) && (gset & HeightValue))
++ sprintf(wgeom, "%dx%d%s%d%s%d", gw, gh,
+ (gset & XNegative) ? "-" : "+", abs(gx1),
+ (gset & YNegative) ? "-" : "+", abs(gy1));
+ else
+@@ -402,11 +402,11 @@
+
+ /* note: everything is sized and positioned in ResizeBrowse() */
+
+- br->iconW = XCreateSimpleWindow(theDisp, br->win, 1,1, 100,100,
++ br->iconW = XCreateSimpleWindow(theDisp, br->win, 1,1, 100,100,
+ 1,browfg,browbg);
+ if (!br->iconW) FatalError("can't create schnauzer icon window!");
+
+- SCCreate(&(br->scrl), br->win, 0,0, 1,100, 0,0,0,0,
++ SCCreate(&(br->scrl), br->win, 0,0, 1,100, 0,0,0,0,
+ browfg, browbg, browhi, browlo, drawIconWin);
+
+
+@@ -486,7 +486,7 @@
+ bfIcons[BF_SOCK]=MakePix1(br->win,br_sock_bits,br_sock_width,br_sock_height);
+ bfIcons[BF_FIFO]=MakePix1(br->win,br_fifo_bits,br_fifo_width,br_fifo_height);
+
+- bfIcons[BF_ERROR] = MakePix1(br->win, br_error_bits,
++ bfIcons[BF_ERROR] = MakePix1(br->win, br_error_bits,
+ br_error_width, br_error_height);
+
+ /* bfIcons[BF_UNKNOWN] = MakePix1(br->win, br_unknown_bits,
+@@ -501,9 +501,9 @@
+
+ bfIcons[BF_SUNRAS] = MakePix1(br->win, br_sunras_bits,
+ br_sunras_width, br_sunras_height);
+- bfIcons[BF_BMP] = MakePix1(br->win,br_bmp_bits,
++ bfIcons[BF_BMP] = MakePix1(br->win,br_bmp_bits,
+ br_bmp_width, br_bmp_height);
+- bfIcons[BF_UTAHRLE] = MakePix1(br->win, br_utahrle_bits,
++ bfIcons[BF_UTAHRLE] = MakePix1(br->win, br_utahrle_bits,
+ br_utahrle_width, br_utahrle_height);
+
+ bfIcons[BF_IRIS]=MakePix1(br->win,br_iris_bits,br_iris_width,br_iris_height);
+@@ -528,13 +528,13 @@
+
+ /* check that they all got built */
+ for (i=0; i<BF_MAX && bfIcons[i]; i++);
+- if (i<BF_MAX)
++ if (i<BF_MAX)
+ FatalError("unable to create all built-in icons for schnauzer");
+
+ for (i=0; i<MAXBRWIN; i++) {
+ resizeBrowse(&binfo[i], DEF_BROWWIDE, DEF_BROWHIGH);
+
+- XSelectInput(theDisp, binfo[i].win, ExposureMask | ButtonPressMask |
++ XSelectInput(theDisp, binfo[i].win, ExposureMask | ButtonPressMask |
+ KeyPressMask | StructureNotifyMask);
+ }
+
+@@ -557,7 +557,7 @@
+ movecurs = XCreatePixmapCursor(theDisp,mcpix,fcmpix,&cursfg,&cursbg,13,13);
+ copycurs = XCreatePixmapCursor(theDisp,ccpix,fcmpix,&cursfg,&cursbg,13,13);
+ delcurs = XCreatePixmapCursor(theDisp,dcpix,fcmpix,&cursbg,&cursfg,13,13);
+- if (!movecurs || !copycurs || !delcurs)
++ if (!movecurs || !copycurs || !delcurs)
+ FatalError("unable to create schnauzer cursors...");
+ }
+ else FatalError("unable to create schnauzer cursors...");
+@@ -566,7 +566,7 @@
+ XFreePixmap(theDisp, ccpix);
+ XFreePixmap(theDisp, dcpix);
+ XFreePixmap(theDisp, fcmpix);
+-
++
+
+ hasBeenSized = 1; /* we can now start looking at browse events */
+ }
+@@ -586,11 +586,11 @@
+ if (!br->vis) break;
+ }
+ if (i==MAXBRWIN) return; /* full up: shouldn't happen */
+-
++
+ anyBrowUp = 1;
+ XMapRaised(theDisp, br->win);
+ br->vis = 1;
+-
++
+ freeBfList(br);
+
+ /* see if some browser is pointing to the same path as CWD. If so,
+@@ -645,7 +645,7 @@
+ /* free all info for this browse window */
+ freeBfList(br);
+ sprintf(br->path, BOGUSPATH);
+-
++
+ /* turn on 'open new window' command doodads */
+ windowMB.dim[WMB_BROWSE] = 0;
+ for (i=0; i<MAXBRWIN; i++) {
+@@ -739,8 +739,7 @@
+ /* checks event to see if it's a browse-window related thing. If it
+ is, it eats the event and returns '1', otherwise '0'. */
+
+- int i, rv;
+- char buf[1024];
++ int rv;
+
+ rv = 1;
+
+@@ -788,7 +787,7 @@
+ fprintf(stderr,"grouped %d expose events into %d,%d %dx%d rect\n",
+ count, rect.x, rect.y, rect.width, rect.height);
+ }
+-
++
+ if (e->window == br->win) drawBrow(br);
+
+ else if (e->window == br->iconW)
+@@ -811,7 +810,7 @@
+ 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,
++ i = clickIconWin(br, x,y,(unsigned long) e->time,
+ (e->state&ControlMask) || (e->state&ShiftMask));
+
+ }
+@@ -837,7 +836,7 @@
+
+ if (br->wide != e->width || br->high != e->height) {
+ if (DEBUG) fprintf(stderr,"Forcing a redraw! (from configure)\n");
+- XClearArea(theDisp, br->win, 0, 0,
++ XClearArea(theDisp, br->win, 0, 0,
+ (u_int) e->width, (u_int) e->height, True);
+ resizeBrowse(br, e->width, e->height);
+ }
+@@ -877,7 +876,7 @@
+ int w,h;
+ {
+ XSizeHints hints;
+- int i, minv, maxv, curv, page, maxh;
++ int i, maxv, page, maxh;
+
+ if (br->wide == w && br->high == h) return; /* no change in size */
+
+@@ -895,7 +894,7 @@
+ br->iwHigh = (maxh / ISPACE_HIGH) * ISPACE_HIGH;
+ if (br->iwHigh < ISPACE_HIGH) br->iwHigh = ISPACE_HIGH;
+
+- XMoveResizeWindow(theDisp, br->iconW, LRMARGINS, TOPMARGIN,
++ XMoveResizeWindow(theDisp, br->iconW, LRMARGINS, TOPMARGIN,
+ (u_int) br->iwWide, (u_int) br->iwHigh);
+
+
+@@ -907,11 +906,11 @@
+ for (i=0; i<BR_NBUTTS; i++) {
+ /* 'close' always goes on right-most edge */
+
+- if (i<br->numbutshown)
++ if (i<br->numbutshown)
+ br->but[i].x = br->wide - (1+br->numbutshown-i) * (BUTTW+5);
+ else if (i==BR_CLOSE)
+ br->but[i].x = br->wide - (BUTTW+5);
+- else
++ else
+ br->but[i].x = br->wide + 10; /* offscreen */
+
+ br->but[i].y = br->high - BUTTH - 5;
+@@ -928,11 +927,11 @@
+ br->numWide = br->iwWide / ISPACE_WIDE;
+ br->visHigh = br->iwHigh / ISPACE_HIGH;
+
+- /* compute minv,maxv,curv,page values based on new current size */
++ /* compute maxv,page values based on new current size */
+ computeScrlVals(br, &maxv, &page);
+ if (br->scrl.val>maxv) br->scrl.val = maxv;
+-
+- SCChange(&br->scrl, LRMARGINS+br->iwWide+1, TOPMARGIN,
++
++ SCChange(&br->scrl, LRMARGINS+br->iwWide+1, TOPMARGIN,
+ 1, br->iwHigh, 0, maxv, br->scrl.val, page);
+ }
+
+@@ -945,7 +944,7 @@
+ /* put string in *all* browse windows */
+ int i;
+
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ setBrowStr(&binfo[i], str);
+ }
+
+@@ -956,6 +955,7 @@
+ char *str;
+ {
+ strncpy(br->dispstr, str, (size_t) 256);
++ br->dispstr[255] = '\0';
+ drawBrowStr(br);
+ XFlush(theDisp);
+ }
+@@ -992,7 +992,7 @@
+
+ char tmp[64];
+
+- sprintf(tmp, "Re-coloring icons: processed %d out of %d...",
++ sprintf(tmp, "Re-coloring icons: processed %d out of %d...",
+ i+1, br->bfLen);
+ setBrowStr(br, tmp);
+ }
+@@ -1011,14 +1011,14 @@
+ {
+ /* called when file 'name' has been deleted. If any of the browsers
+ were showing the directory that the file was in, does a rescan() */
+-
++
+ int i;
+ char buf[MAXPATHLEN + 2], *tmp;
+
+ strcpy(buf, name);
+ tmp = BaseName(buf);
+ *tmp = '\0'; /* truncate after last '/' */
+-
++
+ for (i=0; i<MAXBRWIN; i++) {
+ if (strcmp(binfo[i].path, buf)==0) rescanDir(&binfo[i]);
+ }
+@@ -1070,9 +1070,9 @@
+ case BR_GENICON: genSelectedIcons(br); break;
+
+ case BR_SELALL: {
+- int i; char buf[128];
++ int i;
+
+- for (i=0; i<br->bfLen; i++)
++ for (i=0; i<br->bfLen; i++)
+ br->bfList[i].lit = 1;
+ br->numlit = br->bfLen;
+
+@@ -1087,13 +1087,13 @@
+ break;
+
+ case BR_TEXTVIEW: doTextCmd(br); break;
+-
++
+ case BR_QUIT: Quit(0); break;
+
+ case BR_CLOSE: closeBrowse(br); break;
+
+ case BR_HIDDEN: br->showhidden = !br->showhidden;
+- br->cmdMB.list[cmd] = (br->showhidden)
++ br->cmdMB.list[cmd] = (br->showhidden)
+ ? hideHstr : showHstr;
+ rescanDir(br);
+ break;
+@@ -1137,16 +1137,16 @@
+
+ if (br->bfLen != 1) sprintf(foo, "%d files", br->bfLen);
+ else strcpy(foo, "1 file");
+-
++
+ XSetForeground(theDisp, theGC, browbg);
+- XFillRectangle(theDisp,br->win, theGC, x+1,y+1,
++ XFillRectangle(theDisp,br->win, theGC, x+1,y+1,
+ (u_int) StringWidth(foo)+6, (u_int) br->dirMB.h-1);
+
+ XSetForeground(theDisp,theGC,browfg);
+ XDrawRectangle(theDisp,br->win, theGC, x,y,
+ (u_int) StringWidth(foo)+7, (u_int) br->dirMB.h);
+
+- Draw3dRect(br->win, x+1, y+1, (u_int) StringWidth(foo)+5,
++ Draw3dRect(br->win, x+1, y+1, (u_int) StringWidth(foo)+5,
+ (u_int) br->dirMB.h-2, R3D_IN, 2, browhi, browlo, browbg);
+
+ XSetForeground(theDisp,theGC,browfg);
+@@ -1163,7 +1163,7 @@
+
+ if (nf != 1) sprintf(foo,"%d files",nf);
+ else strcpy(foo,"1 file");
+-
++
+ XClearArea(theDisp,br->win, 30, br->dirMB.y,
+ (u_int) StringWidth(foo)+8, (u_int) br->dirMB.h+1, False);
+ }
+@@ -1185,13 +1185,13 @@
+
+ XSetForeground(theDisp,theGC,browfg);
+ XDrawRectangle(theDisp,br->win, theGC, x,y, (u_int) w, (u_int) h);
+- Draw3dRect(br->win, x+1, y+1, (u_int) w-2, (u_int) h-2,
++ Draw3dRect(br->win, x+1, y+1, (u_int) w-2, (u_int) h-2,
+ R3D_IN, 2, browhi, browlo, browbg);
+
+ XSetForeground(theDisp,theGC,browfg);
+ XSetBackground(theDisp,theGC,browbg);
+- XCopyPlane(theDisp, trashPix, br->win, theGC,
+- 0,0,(u_int) br_trash_width, (u_int) br_trash_height,
++ XCopyPlane(theDisp, trashPix, br->win, theGC,
++ 0,0,(u_int) br_trash_width, (u_int) br_trash_height,
+ x+(w-br_trash_width)/2, y+(h-br_trash_height)/2,
+ 1L);
+ }
+@@ -1222,7 +1222,7 @@
+ y = br->high - (BUTTH+10) - (CHIGH + 6);
+
+ XSetForeground(theDisp, theGC, browbg);
+- XFillRectangle(theDisp, br->win, theGC, 0, y+3,
++ XFillRectangle(theDisp, br->win, theGC, 0, y+3,
+ (u_int) br->wide, (u_int) CHIGH+1);
+
+ XSetForeground(theDisp, theGC, browfg);
+@@ -1277,7 +1277,7 @@
+ {
+ /* sets the '# files selected' string in the brow window appropriately */
+
+- /* criteria:
++ /* criteria:
+ * if no files are lit, display ''
+ * if 1 file is lit, pretend it was selected, fall through...
+ * if 1 or more files are lit
+@@ -1316,7 +1316,7 @@
+
+ else if (bf->ftype != BF_DIR) { /* no info. display file size */
+ struct stat st;
+-
++
+ sprintf(buf, "%s%s", br->path, bf->name); /* build filename */
+ if (stat(buf, &st) == 0) {
+ sprintf(buf, "%s: %ld bytes", bf->name, st.st_size);
+@@ -1360,8 +1360,8 @@
+ if (j>=0 && j < br->bfLen) drawIcon(br,j);
+ }
+ }
+-
+- Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
++
++ Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
+ R3D_IN, 2, browhi, browlo, browbg);
+ }
+
+@@ -1371,10 +1371,8 @@
+ int delta;
+ SCRL *sptr;
+ {
+- int i,indx, x,y, ix,iy, num;
+- BFIL *bf;
++ int i,indx, num;
+ BROWINFO *br;
+- char tmpstr[64], *nstr;
+
+ /* figure out BROWINFO pointer from SCRL pointer */
+ for (i=0; i<MAXBRWIN; i++) {
+@@ -1385,7 +1383,7 @@
+ br = &binfo[i];
+
+ /* make sure we've been sized. Necessary, as creating/modifying the
+- scrollbar calls this routine directly, rather than through
++ scrollbar calls this routine directly, rather than through
+ BrowseCheckEvent() */
+
+ if (!hasBeenSized) return;
+@@ -1413,12 +1411,12 @@
+ if (y+h > br->iwHigh-4) h = (br->iwHigh-4)-y + 2;
+ }
+ XFillRectangle(theDisp, br->iconW, theGC, x, y, ISPACE_WIDE, (u_int) h);
+-
++
+ if (indx>=0 && indx < br->bfLen) drawIcon(br, indx);
+ }
+ }
+
+- Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
++ Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
+ R3D_IN, 2, browhi, browlo, browbg);
+ }
+
+@@ -1431,7 +1429,10 @@
+ {
+ int i,x,y,ix,iy,sw,sh,sx,sy;
+ BFIL *bf;
+- char tmpstr[64], fixedname[64], *nstr, *str;
++ char tmpstr[64], *nstr, *str;
++#ifdef VMS
++ char fixedname[64];
++#endif
+
+
+ if (num<0 || num >= br->bfLen) return;
+@@ -1463,12 +1464,12 @@
+ }
+
+ else if (bf->ftype == BF_HAVEIMG && bf->ximage) {
+- XPutImage(theDisp, br->iconW, theGC, bf->ximage, 0,0, ix,iy,
++ XPutImage(theDisp, br->iconW, theGC, bf->ximage, 0,0, ix,iy,
+ (u_int) bf->w, (u_int) bf->h);
+ }
+
+ else { /* shouldn't happen */
+- XDrawRectangle(theDisp, br->iconW, theGC, ix, iy,
++ XDrawRectangle(theDisp, br->iconW, theGC, ix, iy,
+ (u_int) bf->w, (u_int) bf->h);
+ }
+
+@@ -1488,24 +1489,25 @@
+
+ /* decide if the title is too big, and shorten if neccesary */
+ if (StringWidth(str) > ISPACE_WIDE-6) {
+- int dotpos;
++ int dotpos;
+ strncpy(tmpstr, str, (size_t) 56);
++ tmpstr[56] = '\0'; /* MR: otherwise it dies on long file names */
+ dotpos = strlen(tmpstr);
+ strcat(tmpstr,"...");
+
+ while(StringWidth(tmpstr) > ISPACE_WIDE-6 && dotpos>0) {
+ /* change last non-dot char in tmpstr to a dot, and lop off
+ last dot */
+-
++
+ dotpos--;
+ tmpstr[dotpos] = '.';
+ tmpstr[dotpos+3] = '\0';
+ }
+-
++
+ nstr = tmpstr;
+ }
+ else nstr = str;
+-
++
+
+ /* draw the title */
+ sw = StringWidth(nstr);
+@@ -1516,12 +1518,12 @@
+
+ XSetForeground(theDisp, theGC,
+ (bf->lit && bf->lit!=ICON_ONLY) ? browfg : browbg);
+- XFillRectangle(theDisp, br->iconW, theGC, sx, sy,
++ XFillRectangle(theDisp, br->iconW, theGC, sx, sy,
+ (u_int) sw + 4, (u_int) sh + 2);
+
+ XSetForeground(theDisp, theGC,
+ (bf->lit && bf->lit!=ICON_ONLY) ? browbg : browfg);
+- CenterString(br->iconW, x + ISPACE_WIDE/2,
++ CenterString(br->iconW, x + ISPACE_WIDE/2,
+ y + ISPACE_TOP + ISIZE_HIGH + ISPACE_TTOP + CHIGH/2, nstr);
+ }
+
+@@ -1535,7 +1537,6 @@
+
+ int i,x,y,ix,iy,w,h;
+ BFIL *bf;
+- char tmpstr[64], *nstr;
+
+ if (num<0 || num >= br->bfLen) return;
+ bf = &(br->bfList[num]);
+@@ -1579,12 +1580,12 @@
+ y = (i / br->numWide) * ISPACE_HIGH;
+
+ XSetForeground(theDisp, theGC, browbg);
+- XFillRectangle(theDisp, br->iconW, theGC,
++ XFillRectangle(theDisp, br->iconW, theGC,
+ x, y + ISPACE_TOP + ISIZE_HIGH + ISPACE_TTOP - 1,
+ (u_int) ISPACE_WIDE, (u_int) LINEHIGH);
+
+- if (ctrlColor)
+- Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
++ if (ctrlColor)
++ Draw3dRect(br->iconW, 0, 0, (u_int) br->iwWide-1, (u_int) br->iwHigh-1,
+ R3D_IN, 2, browhi, browlo, browbg);
+ }
+
+@@ -1658,7 +1659,7 @@
+ /* returns '-1' normally, returns an index into bfList[] if the user
+ double-clicks an icon */
+
+- int i,j, base, num, x,y,ix,iy, rv, sel, cpymode, dodel;
++ int i,j, rv, sel, cpymode, dodel;
+ BROWINFO *destBr;
+ BFIL *bf;
+ char buf[256], *destFolderName;
+@@ -1681,7 +1682,7 @@
+ }
+
+ changedNumLit(br, sel, 0);
+- br->lastIconClicked = -1;
++ br->lastIconClicked = -1;
+ }
+
+
+@@ -1725,10 +1726,9 @@
+
+ changedNumLit(br, sel, 0);
+
+-
++
+ /* see if we've double-clicked something */
+ if (sel==br->lastIconClicked && mtime-br->lastClickTime < DBLCLICKTIME) {
+- int k;
+ br->lastIconClicked = -1; /* YES */
+
+ doubleClick(br, sel);
+@@ -1759,10 +1759,10 @@
+ first = 1; hasrect = 0; cpymode = 0;
+ origsval = br->scrl.val;
+
+- if ( (sel>=0 && !multi) || sel==-1) {
++ if ( (sel>=0 && !multi) || sel==-1) {
+ /* clicked on an icon, or clicked on nothing... */
+
+- while (!XQueryPointer(theDisp, rootW, &rW, &cW, &rootx, &rooty,
++ while (!XQueryPointer(theDisp, rootW, &rW, &cW, &rootx, &rooty,
+ &x,&y,&mask));
+ if (mask & Button1Mask) { /* still held down */
+
+@@ -1773,7 +1773,7 @@
+ else curs = movecurs;
+
+ /* change cursors */
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ XDefineCursor(theDisp,binfo[i].iconW, curs);
+
+ samepos = oldx = oldy = oldbrnum = 0;
+@@ -1785,43 +1785,43 @@
+
+ if (sel>=0) { /* see if changed copy/move status (and cursor) */
+ int cmod;
+-
++
+ cmod = (mask&ControlMask || mask&ShiftMask) ? 1 : 0;
+
+ if (cmod != cpymode && !dodel) {
+ curs = (cmod) ? copycurs : movecurs;
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ XDefineCursor(theDisp,binfo[i].iconW, curs);
+ }
+ cpymode = cmod;
+-
+-
++
++
+ /* see if cursor is in any of the trash can areas */
+ for (i=0; i<MAXBRWIN; i++) {
+ if (binfo[i].vis) {
+- XTranslateCoordinates(theDisp, rW, binfo[i].win, rootx,rooty,
++ XTranslateCoordinates(theDisp, rW, binfo[i].win, rootx,rooty,
+ &bwx,&bwy, &cW);
+ if (inTrash(&binfo[i], bwx, bwy)) break;
+ }
+ }
+-
++
+ if (dodel && i==MAXBRWIN) { /* moved out */
+ dodel = 0;
+ curs = (cpymode) ? copycurs : movecurs;
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ XDefineCursor(theDisp,binfo[i].iconW, curs);
+ }
+-
++
+ else if (!dodel && i<MAXBRWIN) { /* moved in */
+ dodel = 1;
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ XDefineCursor(theDisp,binfo[i].iconW, delcurs);
+ }
+ }
+
+
+
+- XTranslateCoordinates(theDisp, rW, br->iconW, rootx,rooty,
++ XTranslateCoordinates(theDisp, rW, br->iconW, rootx,rooty,
+ &iwx,&iwy, &cW);
+
+ /* find deepest child that the mouse is in */
+@@ -1837,12 +1837,12 @@
+ /* if it's in any icon window, and we're doing icon-dragging
+ OR we're doing a rectangle-drag */
+
+- if (i<MAXBRWIN || sel == -1) {
++ if (i<MAXBRWIN || sel == -1) {
+ if (i<MAXBRWIN) destBr = &binfo[i];
+ if (sel == -1) destBr = br;
+
+- /* AUTO-SCROLLING: scroll any icon window if we're doing an
+- icon-drag. Only scroll the original window if we're doing
++ /* AUTO-SCROLLING: scroll any icon window if we're doing an
++ icon-drag. Only scroll the original window if we're doing
+ a rect drag */
+
+ if (sel>=0 && (oldx!=x || oldy!=y || oldbrnum!=i)) { /* moved */
+@@ -1873,7 +1873,7 @@
+ }
+ }
+
+-
++
+ /* if we clicked on an icon (originally), and therefore are
+ showing the 'move files' cursor, see if the cursor is within
+ the icon region of any folders. If so, light up *the icon
+@@ -1904,9 +1904,9 @@
+
+ /* Dragging a selection rectangle. */
+
+- else {
++ else {
+ static int prevx, prevy, prevcnt;
+- int origy, top, left, wide, high, cnt;
++ int origy, cnt;
+
+ if (first) { prevx = mx; prevy = my; first=0; prevcnt = -1; }
+
+@@ -1922,18 +1922,18 @@
+
+ rx = (mx < x) ? mx : x;
+ ry = (origy < y) ? origy : y;
+- rw = abs(mx - x);
++ rw = abs(mx - x);
+ rh = abs(origy - y);
+
+ /* figure out which icons need to be lit/unlit. Only
+ redraw those that have changed state */
+-
++
+ for (i=0,cnt=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
+- int ix, iy, isin, light;
++ int ix, iy, isin;
+
+- ix = ((i%br->numWide) * ISPACE_WIDE)
++ ix = ((i%br->numWide) * ISPACE_WIDE)
+ + ISPACE_WIDE/2 - bf->w/2;
+- iy = ((i/br->numWide) * ISPACE_HIGH)
++ iy = ((i/br->numWide) * ISPACE_HIGH)
+ + ISPACE_TOP + ISIZE_HIGH - bf->h;
+
+ iy = iy - br->scrl.val * ISPACE_HIGH;
+@@ -1994,7 +1994,7 @@
+ }
+
+ /* RELEASED BUTTON: back to normal arrow cursor */
+- for (i=0; i<MAXBRWIN; i++)
++ for (i=0; i<MAXBRWIN; i++)
+ XDefineCursor(theDisp, binfo[i].iconW, None);
+
+ if (sel == -1) { /* was dragging rectangle */
+@@ -2007,7 +2007,7 @@
+ if (bf->lit == TEMP_LIT || bf->lit == TEMP_LIT1) {
+ bf->lit = 1; drawIcon(br, i);
+ }
+-
++
+ if (bf->lit) br->numlit++;
+ }
+
+@@ -2020,7 +2020,6 @@
+
+ /* if doing a copy or a move, do the thing to the files */
+ if (sel >= 0) {
+- char *destFolder;
+
+ if (DEBUG) {
+ fprintf(stderr,"---------------\n");
+@@ -2029,7 +2028,7 @@
+ fprintf(stderr,"Dest Folder: '%s'\n", destFolderName);
+ }
+
+-
++
+ if (!br->numlit) {
+ if (DEBUG) fprintf(stderr, "no selected files. Nothing to do!\n");
+ }
+@@ -2042,7 +2041,7 @@
+ if (DEBUG) fprintf(stderr, "no destination. Nothing to do!\n");
+ }
+
+- else if (strcmp(destFolderName,".") == 0 &&
++ else if (strcmp(destFolderName,".") == 0 &&
+ strcmp(br->path, destBr->path) == 0) {
+ if (DEBUG) fprintf(stderr,"source == destination. Nothing to do!\n");
+ }
+@@ -2067,12 +2066,12 @@
+ }
+ }
+ if (DEBUG) fprintf(stderr,"\n\n");
+-
++
+ #ifdef VMS
+ /*
+- * For VMS, our directory file names are identifed by the
+- * special filename extension, ".DIR". Unfortunately, this
+- * needs to be stripped before we ever actually use the name
++ * For VMS, our directory file names are identifed by the
++ * special filename extension, ".DIR". Unfortunately, this
++ * needs to be stripped before we ever actually use the name
+ * in a copy command... :( RLD 26-FEB-1993
+ */
+
+@@ -2080,7 +2079,7 @@
+ #endif
+
+
+- dragFiles(br, destBr, br->path, destBr->path, destFolderName, nlist,
++ dragFiles(br, destBr, br->path, destBr->path, destFolderName, nlist,
+ ncnt, cpymode);
+
+ /* free namelist */
+@@ -2155,7 +2154,7 @@
+ }
+
+
+-
++
+ /* double-clicked something. We should do something about it */
+ if (br->bfList[sel].ftype == BF_DIR) { /* try to cd */
+ #ifndef VMS
+@@ -2193,7 +2192,7 @@
+ *event_retP = THISNEXT;
+ }
+ else { *event_retP = LOADPIC; SetDirFName(buf); }
+-
++
+ *event_doneP = 1; /* make MainLoop load image */
+ }
+ }
+@@ -2259,7 +2258,7 @@
+ stlen = XLookupString(kevt, buf, 128, &ks, (XComposeStatus *) NULL);
+ shift = kevt->state & ShiftMask;
+ ck = CursorKey(ks, shift, 1);
+- dealt = 1;
++ dealt = 1;
+
+ RemapKeyCheck(ks, buf, &stlen);
+
+@@ -2306,7 +2305,7 @@
+ char fname[MAXPATHLEN];
+
+ /* if 'shift-space' find last lit icon, select the next one after it,
+- and load it. If 'space' do the same, but lose prior lit. These
++ and load it. If 'space' do the same, but lose prior lit. These
+ are the only cases where br->numlit >1 allowed */
+
+ if (br->numlit>1 && buf[0] != ' ') return;
+@@ -2314,7 +2313,7 @@
+ if (buf[0]==' ' && (br->numlit>1 || (br->numlit==1 && shift))) {
+ for (i=br->bfLen-1; i>=0 && !br->bfList[i].lit; i--); /* i=last lit */
+ if (i==br->bfLen-1) return;
+-
++
+ i++;
+ if (!shift) {
+ for (j=0; j<br->bfLen; j++) {
+@@ -2364,7 +2363,7 @@
+ for (i=0; i<br->bfLen && !br->bfList[i].lit; i++); /* find lit one */
+ sprintf(fname, "%s%s", br->path, br->bfList[i].name);
+ viewsel = !(strcmp(fname, fullfname));
+-
++
+ if (viewsel) {
+ if (buf[0]==' ') browKey(br, CK_RIGHT);
+ else browKey(br, CK_LEFT);
+@@ -2372,7 +2371,7 @@
+
+ if (!br->bfList[i].lit || !viewsel) { /* changed selection */
+ for (i=0; i<br->bfLen && !br->bfList[i].lit; i++); /* find it */
+- if (br->bfList[i].ftype != BF_DIR)
++ if (br->bfList[i].ftype != BF_DIR)
+ doubleClick(br, -1);
+ }
+ }
+@@ -2410,10 +2409,10 @@
+ /* handle up/down/left/right keys
+ *
+ * if precisely *one* item is lit, than the up/down/left/right keys move
+- * the selection.
++ * the selection.
+ *
+ * if NO items are lit, then left/right select the first/last fully-displayed
+- * icon, and up/down simply scroll window up or down, without selecting
++ * icon, and up/down simply scroll window up or down, without selecting
+ * anything
+ *
+ * if more than one item is lit, up/down/left/right keys BEEP
+@@ -2443,8 +2442,8 @@
+ if (key == CK_DOWN) j = i + br->numWide;
+ if (key == CK_LEFT) j = i - 1;
+ if (key == CK_RIGHT) j = i + 1;
+-
+- if (j >= 0 && j < br->bfLen) {
++
++ if (j >= 0 && j < br->bfLen) {
+ br->bfList[i].lit = 0;
+ br->bfList[j].lit = 1;
+ makeIconVisible(br,j);
+@@ -2455,7 +2454,7 @@
+ }
+ }
+
+-
++
+ if (br->numlit == 0) { /* no current selection */
+ if (key == CK_UP) SCSetVal(&br->scrl, br->scrl.val - 1);
+ if (key == CK_DOWN) SCSetVal(&br->scrl, br->scrl.val + 1);
+@@ -2541,13 +2540,13 @@
+ * The VMS chdir always needs 2 components (device and directory),
+ * so convert "/device" to "/device/000000" and convert
+ * "/" to "/XV_Root_Device/000000" (XV_RootDevice will need to be
+- * a special concealed device setup to provide list of available
++ * a special concealed device setup to provide list of available
+ * disks).
+ *
+ * End 'tmppath' by changing trailing '/' (of dir name) to a '\0'
+ */
+ *rindex ( tmppath, '/') = '\0';
+- if ( ((br->ndirs-sel) == 2) && (strlen(tmppath) > 1) )
++ if ( ((br->ndirs-sel) == 2) && (strlen(tmppath) > 1) )
+ strcat ( tmppath, "/000000" ); /* add root dir for device */
+ else if ((br->ndirs-sel) == 1 )
+ strcpy ( tmppath, "/XV_Root_Device/000000" ); /* fake top level */
+@@ -2599,7 +2598,7 @@
+ static void copyDirInfo(srcbr, dstbr)
+ BROWINFO *srcbr, *dstbr;
+ {
+- /* copies br info from an already existing browser window
++ /* copies br info from an already existing browser window
+ (ie, one that is already showing the same directory) */
+
+ int i, oldnum, maxv, page;
+@@ -2619,7 +2618,7 @@
+ dstbr->dirMB.list = srcbr->mblist;
+ dstbr->dirMB.nlist = srcbr->ndirs;
+
+- XClearArea(theDisp, dstbr->dirMB.win, dstbr->dirMB.x, dstbr->dirMB.y,
++ XClearArea(theDisp, dstbr->dirMB.win, dstbr->dirMB.x, dstbr->dirMB.y,
+ dstbr->dirMB.w+3, dstbr->dirMB.h+3, False);
+
+ i = StringWidth(dstbr->mblist[0]) + 10;
+@@ -2644,7 +2643,7 @@
+
+ if ((i&0x03) == 0) drawTemp(dstbr, i, dstbr->bfLen);
+ if ((i & 0x3f) == 0) WaitCursor();
+-
++
+ sbf = &(srcbr->bfList[i]);
+ dbf = &(dstbr->bfList[i]);
+
+@@ -2670,7 +2669,7 @@
+ if (sbf->pimage) {
+ dbf->pimage = (byte *) malloc((size_t) dbf->w * dbf->h);
+ if (!dbf->pimage) FatalError("ran out of memory for dbf->pimage");
+- xvbcopy((char *) sbf->pimage, (char *) dbf->pimage,
++ xvbcopy((char *) sbf->pimage, (char *) dbf->pimage,
+ (size_t) (dbf->w * dbf->h));
+ }
+ else dbf->pimage = (byte *) NULL;
+@@ -2681,10 +2680,10 @@
+ xvbcopy((char *) sbf->ximage, (char *) dbf->ximage, sizeof(XImage));
+
+ if (sbf->ximage->data) {
+- dbf->ximage->data = (char *) malloc((size_t) dbf->ximage->height *
++ dbf->ximage->data = (char *) malloc((size_t) dbf->ximage->height *
+ dbf->ximage->bytes_per_line);
+ if (!dbf->ximage->data) FatalError("ran out of memory for ximg data");
+- xvbcopy((char *) sbf->ximage->data, (char *) dbf->ximage->data,
++ xvbcopy((char *) sbf->ximage->data, (char *) dbf->ximage->data,
+ (size_t) dbf->ximage->height * dbf->ximage->bytes_per_line);
+ }
+ }
+@@ -2701,15 +2700,15 @@
+ computeScrlVals(dstbr, &maxv, &page);
+ if (dstbr->scrl.val > maxv) dstbr->scrl.val = maxv;
+
+- XClearArea(theDisp, dstbr->iconW, 0, 0, (u_int) dstbr->iwWide,
++ XClearArea(theDisp, dstbr->iconW, 0, 0, (u_int) dstbr->iwWide,
+ (u_int) dstbr->iwHigh, True);
+ SCSetRange(&dstbr->scrl, 0, maxv, dstbr->scrl.val, page);
+
+ SetCursors(-1);
+ }
+
+-
+-
++
++
+
+ /***************************************************************/
+ static void scanDir(br)
+@@ -2726,7 +2725,7 @@
+ * and it's reasonable to expect folks to want to add their own bitmaps
+ */
+
+- int i,j,k,oldbflen,vmsparent;
++ int i,j,oldbflen,vmsparent;
+ BFIL *bf;
+
+ DIR *dirp;
+@@ -2775,7 +2774,7 @@
+
+ /* build brMBlist */
+ for (i = br->ndirs-1,j=0; i>=0; i--,j++) {
+- size_t stlen = (i<(br->ndirs-1)) ? dirnames[i+1] - dirnames[i]
++ size_t stlen = (i<(br->ndirs-1)) ? dirnames[i+1] - dirnames[i]
+ : strlen(dirnames[i]);
+
+ br->mblist[j] = (char *) malloc(stlen+1);
+@@ -2784,13 +2783,13 @@
+ strncpy(br->mblist[j], dirnames[i], stlen);
+ br->mblist[j][stlen] = '\0';
+ }
+-
++
+
+ /* refresh the brdirMB button */
+ br->dirMB.list = br->mblist;
+ br->dirMB.nlist = br->ndirs;
+
+- XClearArea(theDisp, br->dirMB.win, br->dirMB.x, br->dirMB.y,
++ XClearArea(theDisp, br->dirMB.win, br->dirMB.x, br->dirMB.y,
+ br->dirMB.w+3, br->dirMB.h+3, False);
+
+ i = StringWidth(br->mblist[0]) + 10;
+@@ -2815,7 +2814,7 @@
+ /* count how many files are in the list */
+
+ dirp = opendir(".");
+- if (!dirp) {
++ if (!dirp) {
+ endScan(br, oldbflen);
+ setBrowStr(br, "Couldn't read current directory.");
+ SetCursors(-1);
+@@ -2827,11 +2826,11 @@
+ #endif
+
+ while ( (dp = readdir(dirp)) != NULL) {
+- if (strcmp(dp->d_name, ".") &&
++ if (strcmp(dp->d_name, ".") &&
+ strcmp(dp->d_name, THUMBDIR)) {
+- if (!br->showhidden && dp->d_name[0] == '.' &&
++ if (!br->showhidden && dp->d_name[0] == '.' &&
+ strcmp(dp->d_name,"..")!=0) continue;
+- else
++ else
+ br->bfLen++;
+ }
+ if ((br->bfLen & 0x3f) == 0) WaitCursor();
+@@ -2877,13 +2876,13 @@
+ }
+ else {
+ do { dp = readdir(dirp); }
+- while (dp && (strcmp(dp->d_name, ".")==0 ||
++ while (dp && (strcmp(dp->d_name, ".")==0 ||
+ strcmp(dp->d_name, THUMBDIR)==0 ||
+ strcmp(dp->d_name, THUMBDIRNAME)==0 ||
+ (br->ndirs==1 && strcmp(dp->d_name,"..")==0) ||
+- (!br->showhidden && dp->d_name[0] == '.' &&
++ (!br->showhidden && dp->d_name[0] == '.' &&
+ strcmp(dp->d_name,"..")!=0)));
+-
++
+ if (!dp) { br->bfLen = i; break; } /* dir got shorter... */
+ }
+
+@@ -2940,11 +2939,11 @@
+ if (w<1) w = 1;
+ if (h<1) h = 1;
+
+- XClearArea(theDisp, br->iconW, (ctrlColor) ? 2 : 0, (ctrlColor) ? 2 : 0,
++ XClearArea(theDisp, br->iconW, (ctrlColor) ? 2 : 0, (ctrlColor) ? 2 : 0,
+ (u_int) w, (u_int) h, False);
+
+ SCSetRange(&br->scrl, 0, maxv, br->scrl.val, page);
+-
++
+ SetCursors(-1);
+ }
+
+@@ -2972,7 +2971,7 @@
+ bf->pimage = (byte *) NULL;
+ bf->ximage = (XImage *) NULL;
+ bf->lit = 0;
+-
++
+
+ if (stat(bf->name, &st)==0) {
+ bf->ftype = stat2bf((u_int) st.st_mode);
+@@ -3048,11 +3047,11 @@
+ bfcompares++;
+ if ((bfcompares & 0x7f)==0) WaitCursor();
+
+- /* sort critera: directories first, in alphabetical order,
++ /* sort critera: directories first, in alphabetical order,
+ followed by everything else, in alphabetical order */
+-
++
+ if ((b1->ftype == BF_DIR && b2->ftype == BF_DIR) ||
+- (b1->ftype != BF_DIR && b2->ftype != BF_DIR))
++ (b1->ftype != BF_DIR && b2->ftype != BF_DIR))
+ return strcmp(b1->name, b2->name);
+
+ else if (b1->ftype == BF_DIR && b2->ftype != BF_DIR) return -1;
+@@ -3108,7 +3107,7 @@
+ for (i=0; i<bflen; i++) {
+ bfnames[i] = (char *) malloc(strlen(br->bfList[i].name) + 1);
+ if (!bfnames[i]) FatalError("couldn't alloc bfnames in rescanDir()");
+-
++
+ strcpy(bfnames[i], br->bfList[i].name);
+ }
+ }
+@@ -3121,7 +3120,7 @@
+
+ /* note, either (or both) dirnames/bfnames can be NULL, in which case
+ their respective 'len's will be zero */
+-
++
+ /* sort the two name lists */
+ if (bflen) qsort((char *) bfnames, (size_t) bflen, sizeof(char *),namcmp);
+ if (dirlen) qsort((char *) dirnames, (size_t) dirlen,sizeof(char *),namcmp);
+@@ -3153,7 +3152,7 @@
+ }
+ }
+ bflen = j;
+-
++
+
+ for (i=j=0; i<dirlen; i++) {
+ if (dirnames[i] && strcmp(dirnames[i],".") && strcmp(dirnames[i],"..") &&
+@@ -3162,21 +3161,21 @@
+ }
+ }
+ dirlen = j;
+-
++
+
+ if (DEBUG) {
+ fprintf(stderr,"%d files seem to have gone away: ", bflen);
+- for (i=0; i<bflen; i++)
++ for (i=0; i<bflen; i++)
+ fprintf(stderr,"%s ", bfnames[i]);
+ fprintf(stderr,"\n\n");
+
+ fprintf(stderr,"%d files seem to have appeared: ", dirlen);
+- for (i=0; i<dirlen; i++)
++ for (i=0; i<dirlen; i++)
+ fprintf(stderr,"%s ", dirnames[i]);
+ fprintf(stderr,"\n\n");
+ }
+-
+-
++
++
+ /* create a new bfList */
+ newlen = br->bfLen - bflen + dirlen; /* oldlen - #del'd + #created */
+ if (newlen>0) {
+@@ -3241,7 +3240,7 @@
+ if (bf->pimage) free(bf->pimage);
+ if (bf->ximage) xvDestroyImage(bf->ximage);
+ }
+-
++
+ free(br->bfList);
+ }
+
+@@ -3267,13 +3266,13 @@
+ int *lenP;
+ int dohidden;
+ {
+- /* loads up all directory entries into an array. This *isn't* a great
+- way to do it, but I can't count on 'scandir()' existing on
++ /* loads up all directory entries into an array. This *isn't* a great
++ way to do it, but I can't count on 'scandir()' existing on
+ every system. Returns 'NULL' on failure, or pointer to array of
+ 'lenP' strings on success. '.' and '..' ARE included in list
+ if !dohidden, all '.*' files are skipped (except . and ..) */
+
+- int i, j, dirlen;
++ int i, dirlen;
+ DIR *dirp;
+ char **names;
+ #ifdef NODIRENT
+@@ -3294,9 +3293,9 @@
+ /* count # of entries in dir (worst case) */
+ for (dirlen=0; (dp = readdir(dirp)) != NULL; dirlen++);
+ if (!dirlen) {
+- closedir(dirp);
++ closedir(dirp);
+ *lenP = dirlen;
+- return (char **) NULL;
++ return (char **) NULL;
+ }
+
+
+@@ -3312,7 +3311,7 @@
+
+ if (!dohidden) {
+ #ifndef VMS
+- if (dp->d_name[0] == '.' &&
++ if (dp->d_name[0] == '.' &&
+ strcmp(dp->d_name,"." )!=0 &&
+ strcmp(dp->d_name,"..")!=0) continue;
+ #endif
+@@ -3324,7 +3323,7 @@
+ strcpy(names[i], dp->d_name);
+ i++;
+ }
+-
++
+ if (i<dirlen) dirlen = i; /* dir got shorter... */
+
+ closedir(dirp);
+@@ -3359,7 +3358,7 @@
+ static void genSelectedIcons(br)
+ BROWINFO *br;
+ {
+- int i, sval, first, numvis, cnt;
++ int i, cnt;
+
+ setBrowStr(br, "");
+
+@@ -3395,7 +3394,7 @@
+ BFIL *bf;
+ {
+ /* given a BFIL entry, load up the file.
+- * if we succeeded in loading up the file,
++ * if we succeeded in loading up the file,
+ * generate an aspect-correct 8-bit image using brow Cmap
+ * otherwise
+ * replace this icon with the BF_UNKNOWN, or BF_ERR icons
+@@ -3408,20 +3407,20 @@
+ byte *icon24, *icon8;
+ char str[256], str1[256], *readname, uncompname[128];
+ char basefname[128], *uncName;
+-
+-
++
++
+ if (!bf || !bf->name || bf->name[0] == '\0') return; /* shouldn't happen */
+ str[0] = '\0';
+ basefname[0] = '\0';
+ pinfo.pic = (byte *) NULL;
+ pinfo.comment = (char *) NULL;
+ readname = bf->name;
+-
++
+ /* free any old info in 'bf' */
+ if (bf->imginfo) free (bf->imginfo);
+ if (bf->pimage) free (bf->pimage);
+ if (bf->ximage) xvDestroyImage(bf->ximage);
+-
++
+ bf->imginfo = (char *) NULL;
+ bf->pimage = (byte *) NULL;
+ bf->ximage = (XImage *) NULL;
+@@ -3429,9 +3428,9 @@
+
+ /* skip all 'special' files */
+ if (!ISLOADABLE(bf->ftype)) return;
+-
++
+ filetype = ReadFileType(bf->name);
+-
++
+ if (filetype == RFT_COMPRESS) {
+ #if (defined(VMS) && !defined(GUNZIP))
+ /* VMS decompress doesn't like the file to have a trailing .Z in fname
+@@ -3442,7 +3441,7 @@
+ #else
+ uncName = bf->name;
+ #endif
+-
++
+ if (UncompressFile(uncName, uncompname)) {
+ filetype = ReadFileType(uncompname);
+ readname = uncompname;
+@@ -3453,61 +3452,61 @@
+ bf->ftype = BF_ERROR;
+ }
+ }
+-
++
+ /* get rid of comments. don't need 'em */
+ if (pinfo.comment) free(pinfo.comment); pinfo.comment = (char *) NULL;
+-
+- if (filetype == RFT_ERROR) {
++
++ if (filetype == RFT_ERROR) {
+ sprintf(str,"Couldn't open file '%s'", bf->name);
+ setBrowStr(br, str);
+ bf->ftype = BF_ERROR;
+ }
+-
++
+ else if (filetype == RFT_UNKNOWN) {
+ /* if it *was* an 'exe', leave it that way */
+ if (bf->ftype != BF_EXE) bf->ftype = BF_UNKNOWN;
+ }
+-
++
+ else {
+ /* otherwise it's a known filetype... do the *hard* part now... */
+-
++
+ i = ReadPicFile(readname, filetype, &pinfo, 1);
+ KillPageFiles(pinfo.pagebname, pinfo.numpages);
+-
++
+ if (!i) bf->ftype = BF_ERROR;
+-
++
+ if (i && (pinfo.w<=0 || pinfo.h<=0)) { /* bogus size */
+ bf->ftype = BF_ERROR;
+ free(pinfo.pic); pinfo.pic = (byte *) NULL;
+ }
+-
++
+ if (bf->ftype==BF_ERROR && filetype==RFT_XBM) bf->ftype = BF_UNKNOWN;
+ }
+-
++
+ /* get rid of comment, as we don't need it */
+- if (pinfo.comment) {
++ if (pinfo.comment) {
+ free(pinfo.comment); pinfo.comment = (char *) NULL;
+ }
+-
++
+ /* if we made an uncompressed file, we can rm it now */
+ if (readname != bf->name) unlink(readname);
+-
+-
++
++
+ /* at this point either BF_ERROR, BF_UNKNOWN, BF_EXE or pic */
+-
++
+ if (!pinfo.pic) {
+ if (bf->ftype == BF_EXE) return; /* don't write thumbfiles for exe's */
+-
++
+ bf->w = br_file_width; bf->h = br_file_height;
+ writeThumbFile(br, bf, NULL, 0, 0, NULL); /* BF_ERROR, BF_UNKNOWN */
+ return;
+ }
+-
++
+ /* at this point, we have a pic, so it must be an image file */
+-
+-
++
++
+ /* compute size of icon (iwide,ihigh) */
+-
++
+ wexpand = (double) pinfo.w / (double) ISIZE_WIDE;
+ hexpand = (double) pinfo.h / (double) ISIZE_HIGH;
+
+@@ -3527,13 +3526,13 @@
+
+
+ /* generate icon */
+- icon24 = Smooth24(pinfo.pic, pinfo.type==PIC24, pinfo.w, pinfo.h,
++ icon24 = Smooth24(pinfo.pic, pinfo.type==PIC24, pinfo.w, pinfo.h,
+ iwide, ihigh, pinfo.r,pinfo.g,pinfo.b);
+ if (!icon24) { bf->ftype = BF_FILE; free(pinfo.pic); return; }
+
+ sprintf(str, "%dx%d ", pinfo.normw, pinfo.normh);
+ switch (filetype) {
+- case RFT_GIF: if (xv_strstr(pinfo.shrtInfo, "GIF89"))
++ case RFT_GIF: if (xv_strstr(pinfo.shrtInfo, "GIF89"))
+ strcat(str,"GIF89 file");
+ else
+ strcat(str,"GIF87 file");
+@@ -3543,12 +3542,12 @@
+
+ case RFT_PBM: if (xv_strstr(pinfo.fullInfo, "raw")) strcat(str,"Raw ");
+ else strcat(str,"Ascii ");
+-
++
+ for (i=0; i<3 && (strlen(pinfo.fullInfo)>(size_t)3); i++){
+ str1[0] = pinfo.fullInfo[i]; str1[1] = '\0';
+ strcat(str, str1);
+ }
+-
++
+ strcat(str," file");
+ break;
+
+@@ -3569,19 +3568,19 @@
+ case RFT_FITS: strcat(str,"FITS file"); break;
+ default: strcat(str,"file of unknown type"); break;
+ }
+-
+-
++
++
+ /* find out length of original file */
+ { FILE *fp;
+ long filesize;
+ char buf[64];
+-
++
+ fp = fopen(bf->name, "r");
+ if (fp) {
+ fseek(fp, 0L, 2);
+ filesize = ftell(fp);
+ fclose(fp);
+-
++
+ sprintf(buf," (%ld bytes)", filesize);
+ strcat(str, buf);
+ }
+@@ -3609,17 +3608,17 @@
+ bf->w = iwide;
+ bf->h = ihigh;
+ bf->ftype = BF_HAVEIMG;
+-
++
+ bf->ximage = Pic8ToXImage(icon8, (u_int) iwide, (u_int) ihigh, browcols,
+ browR, browG, browB);
+-
++
+ free(icon24);
+ free(pinfo.pic);
+ }
+
+
+
+-
++
+
+
+ /*
+@@ -3682,7 +3681,7 @@
+ /* read comments until we see '#END_OF_COMMENTS', or hit EOF */
+ while (1) {
+ if (!fgets(buf, 256, fp)) goto errexit;
+-
++
+ if (!strncmp(buf, "#END_OF_COMMENTS", strlen("#END_OF_COMMENTS")))
+ break;
+
+@@ -3714,7 +3713,7 @@
+
+
+ /* read width, height, maxval */
+- if (!fgets(buf, 256, fp) || sscanf(buf, "%d %d %d", &w, &h, &mv) != 3)
++ if (!fgets(buf, 256, fp) || sscanf(buf, "%d %d %d", &w, &h, &mv) != 3)
+ goto errexit;
+
+
+@@ -3738,14 +3737,14 @@
+ bf->h = h;
+ bf->ftype = BF_HAVEIMG;
+ bf->imginfo = info;
+-
+- bf->ximage = Pic8ToXImage(icon8, (u_int) w, (u_int) h, browcols,
++
++ bf->ximage = Pic8ToXImage(icon8, (u_int) w, (u_int) h, browcols,
+ browR, browG, browB);
+ }
+ else {
+ if (info) free(info);
+ }
+-
++
+ fclose(fp);
+ return;
+
+@@ -3757,7 +3756,7 @@
+ }
+
+
+-
++
+ /***************************************************************/
+ static void writeThumbFile(br, bf, icon8, w, h, info)
+ BROWINFO *br;
+@@ -3787,7 +3786,7 @@
+
+ fp = fopen(thFname, "w");
+ if (!fp) {
+- sprintf(buf, "Can't create thumbnail file '%s': %s", thFname,
++ sprintf(buf, "Can't create thumbnail file '%s': %s", thFname,
+ ERRSTR(errno));
+ setBrowStr(br, buf);
+ return; /* can't write... */
+@@ -3829,9 +3828,9 @@
+ setBrowStr(br, buf);
+ return; /* can't write... */
+ }
+-
++
+ fclose(fp);
+-
++
+ chmod(thFname, (mode_t) perm);
+ }
+
+@@ -3915,7 +3914,7 @@
+
+ if (s1 || s2 || filest.st_mtime > thumbst.st_mtime ||
+ filest.st_ctime > thumbst.st_ctime) {
+- /* either stat'ing the file or the thumbfile failed, or
++ /* either stat'ing the file or the thumbfile failed, or
+ both stat's succeeded and the file has a newer mod or creation
+ time than the thumbnail file */
+
+@@ -3926,8 +3925,8 @@
+
+ if (bf->ftype != BF_EXE) {
+ iconsBuilt++;
+- if (DEBUG)
+- fprintf(stderr,"icon made:fname='%s' thfname='%s' %d,%d,%d,%d\n",
++ 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);
+ }
+ }
+@@ -3974,7 +3973,7 @@
+ }
+ }
+ statcount++;
+-
++
+ if ((statcount % 30)==0) WaitCursor();
+ }
+ closedir(dirp);
+@@ -3998,16 +3997,16 @@
+ {
+ if (maxcnt<1) return; /* none of that naughty ol' divide by zero stuff */
+
+- DrawTempGauge(br->win, 5, br->dirMB.y,
++ DrawTempGauge(br->win, 5, br->dirMB.y,
+ (int) br->dirMB.x-10, (int) br->dirMB.h,
+ (double) cnt / (double) maxcnt,
+ browfg, browbg, browhi, browlo, "");
+ }
+-
++
+ static void clearTemp(br)
+ BROWINFO *br;
+ {
+- XClearArea(theDisp, br->win, 5, br->dirMB.y,
++ XClearArea(theDisp, br->win, 5, br->dirMB.y,
+ (u_int) br->dirMB.x-10+1, (u_int) br->dirMB.h + 1, True);
+ }
+
+@@ -4048,7 +4047,7 @@
+ /* find the selected file */
+ for (i=0; i<br->bfLen && !br->bfList[i].lit; i++);
+ if (i==br->bfLen) return; /* shouldn't happen */
+-
++
+ origname = br->bfList[i].name; num = i;
+
+ if (strcmp(origname, "..")==0) {
+@@ -4058,7 +4057,7 @@
+ return;
+ }
+
+- sprintf(txt, "Enter a new name for the %s '%s':",
++ sprintf(txt, "Enter a new name for the %s '%s':",
+ (br->bfList[i].ftype==BF_DIR) ? "directory" : "file",
+ origname);
+
+@@ -4107,7 +4106,7 @@
+ drawIcon(br, num);
+
+ for (i=0; i<MAXBRWIN; i++) {
+- if (&binfo[i] != br && strcmp(binfo[i].path, br->path)==0)
++ if (&binfo[i] != br && strcmp(binfo[i].path, br->path)==0)
+ rescanDir(&binfo[i]);
+ }
+
+@@ -4133,7 +4132,7 @@
+ if (cdBrow(br)) return;
+
+ buf[0] = '\0';
+- i = GetStrPopUp("Enter name for new directory:", labels, 2,
++ i = GetStrPopUp("Enter name for new directory:", labels, 2,
+ buf, 128, "/ |\'\"<>,", 0);
+ if (i) return; /* cancelled */
+
+@@ -4161,7 +4160,7 @@
+
+ /* rescan current br, and all other br's pointing to same directory */
+ for (i=0; i<MAXBRWIN; i++) {
+- if (strcmp(binfo[i].path, br->path)==0)
++ if (strcmp(binfo[i].path, br->path)==0)
+ rescanDir(&binfo[i]);
+ }
+
+@@ -4179,7 +4178,7 @@
+ int i;
+ static char buf[MAXPATHLEN+100];
+ static char *labels[] = { "\nOk", "\033Cancel" };
+- char str[512];
++ char str[512];
+
+ buf[0] = '\0';
+ i = GetStrPopUp("Change to directory:", labels, 2, buf, MAXPATHLEN, " ", 0);
+@@ -4226,7 +4225,7 @@
+ */
+
+ BFIL *bf;
+- int i, j, numdirs, numfiles, slen, firstdel;
++ int i, numdirs, numfiles, slen, firstdel;
+ char buf[512];
+ static char *yesno[] = { "\004Delete", "\033Cancel" };
+
+@@ -4258,7 +4257,7 @@
+ }
+
+
+- /* if any plain files are being toasted, bring up the low-key
++ /* if any plain files are being toasted, bring up the low-key
+ confirmation box */
+
+ if (numfiles) {
+@@ -4281,7 +4280,7 @@
+ i = PopUp(buf, yesno, 2);
+ if (i) return; /* cancelled */
+ }
+-
++
+
+ /* if any directories are being toasted, bring up the are you REALLY sure
+ confirmation box */
+@@ -4309,7 +4308,7 @@
+
+
+ /* okay, at this point they've been warned. do the deletion */
+-
++
+ for (i=0, bf=br->bfList; i<br->bfLen; i++,bf++) {
+ if (bf->lit) {
+ if (bf->ftype == BF_DIR) rm_dir (br, bf->name);
+@@ -4340,7 +4339,7 @@
+
+ /* rescan other br's that are looking at this directory */
+ for (i=0; i<MAXBRWIN; i++) {
+- if (&binfo[i] != br && strcmp(binfo[i].path, br->path)==0)
++ if (&binfo[i] != br && strcmp(binfo[i].path, br->path)==0)
+ rescanDir(&binfo[i]);
+ }
+
+@@ -4356,7 +4355,7 @@
+ int i;
+ static char buf[MAXPATHLEN+100];
+ static char *labels[] = { "\nOk", "\033Cancel" };
+- char str[512];
++ char str[512];
+
+ buf[0] = '\0';
+ strcpy(str,"Select file name(s). Wildcard '*' is allowed. ");
+@@ -4396,7 +4395,7 @@
+ {
+ int i;
+ static char *labels[] = { "\nOk", "\033Cancel" };
+- char str[512];
++ char str[512];
+
+ strcpy(str,"Recursive Update: This could take *quite* a while.\n");
+ strcat(str,"Are you sure?");
+@@ -4415,7 +4414,7 @@
+
+
+ /*******************************************/
+-static void recurseUpdate(br, subdir)
++static void recurseUpdate(br, subdir)
+ BROWINFO *br;
+ char *subdir;
+ {
+@@ -4430,7 +4429,7 @@
+ * and for each subdir in this dir, recurse
+ *
+ * if cur dir != orig dir, cd back to orig dir and reload 'br'
+- */
++ */
+
+ int i;
+ char orgDir[MAXPATHLEN + 2];
+@@ -4449,7 +4448,7 @@
+ }
+
+ xv_getwd(curDir, sizeof(curDir));
+-
++
+ /* have we looped? */
+ for (i=0; i<dirStackLen && strcmp(curDir, dirStack[i]); i++);
+ if (i<dirStackLen) { /* YES */
+@@ -4481,8 +4480,8 @@
+ /* do subdirectories of this directory, not counting . .. and .xvpics */
+ for (i=0; i<br->bfLen; i++) {
+ bf = &(br->bfList[i]);
+- if (bf &&
+- bf->ftype == BF_DIR &&
++ if (bf &&
++ bf->ftype == BF_DIR &&
+ strcmp(bf->name, ".") &&
+ strcmp(bf->name, "..") &&
+ strcmp(bf->name, THUMBDIRNAME) ) {
+@@ -4524,7 +4523,7 @@
+ tmp = (char *) rindex(buf1, '/');
+ if (!tmp) strcpy(buf1,".");
+ else *tmp = '\0';
+-
++
+ sprintf(buf, "%s/%s/%s", buf1, THUMBDIR, BaseName(name));
+ if (DEBUG) fprintf(stderr," (%s)\n", buf);
+
+@@ -4548,7 +4547,7 @@
+ BROWINFO *br;
+ {
+ /* recursively delete this directory, and all things under it */
+-
++
+ int i, dirlen, longpath, oldpathlen;
+ char **names, *name, buf[512];
+ struct stat st;
+@@ -4569,7 +4568,7 @@
+ name = names[i];
+
+ /* skip . and .. (not that we should ever see them... */
+- if (name[0] == '.' && (name[1]=='\0' ||
++ if (name[0] == '.' && (name[1]=='\0' ||
+ (name[1]=='.' && name[2]=='\0'))) goto done;
+
+ if (strlen(name) + oldpathlen >= (MAXPATHLEN-3)) {
+@@ -4586,7 +4585,7 @@
+ rmdirPath[oldpathlen] = '\0';
+ goto done;
+ }
+-
++
+ if (stat2bf((u_int) st.st_mode) == BF_DIR) { /* skip, for now */
+ rmdirPath[oldpathlen] = '\0';
+ continue; /* don't remove from list */
+@@ -4594,7 +4593,7 @@
+
+ rm_file(br, rmdirPath);
+ rmdirPath[oldpathlen] = '\0';
+-
++
+ done: /* remove name from list */
+ free(name);
+ names[i] = (char *) NULL;
+@@ -4645,19 +4644,19 @@
+
+
+ /*******************************************/
+-static void dragFiles(srcBr, dstBr, srcpath, dstpath, dstdir,
++static void dragFiles(srcBr, dstBr, srcpath, dstpath, dstdir,
+ names, nlen, cpymode)
+ BROWINFO *srcBr, *dstBr;
+ char *srcpath, *dstpath, *dstdir, **names;
+ int nlen, cpymode;
+ {
+- /* move or copy file(s) and their associated thumbnail files.
++ /* move or copy file(s) and their associated thumbnail files.
+ srcpath and dstpath will have trailing '/'s. dstdir is name of
+ folder in dstpath (or "." or "..") to write to. names is an nlen
+ long array of strings (the simple filenames of the files to move)
+ if 'cpymode' copy files, otherwise move them */
+
+- int i, j, k, dothumbs, fail;
++ int i, j, dothumbs, fail;
+ char dstp[MAXPATHLEN + 1];
+ char src[MAXPATHLEN+1], dst[MAXPATHLEN+1];
+ char buf[128];
+@@ -4750,7 +4749,7 @@
+
+
+ /* clear all files in the destination folder */
+- for (i=0; i<dstBr->bfLen; i++) {
++ for (i=0; i<dstBr->bfLen; i++) {
+ dstBr->bfList[i].lit = 0;
+ }
+ dstBr->numlit = 0;
+@@ -4760,10 +4759,10 @@
+ for (i=0; i<nlen; i++) {
+ char *name; BFIL *bf;
+ name = names[i];
+- for (j=0, bf=dstBr->bfList;
++ for (j=0, bf=dstBr->bfList;
+ j<dstBr->bfLen && strcmp(name, bf->name)!=0; j++, bf++);
+- if (j<dstBr->bfLen) {
+- bf->lit = 1; dstBr->numlit++;
++ if (j<dstBr->bfLen) {
++ bf->lit = 1; dstBr->numlit++;
+ }
+ }
+
+@@ -4783,10 +4782,10 @@
+ changedNumLit(srcBr, -1, 0);
+
+
+- if (fail) sprintf(buf, "Some files were not %s because of errors.",
++ if (fail) sprintf(buf, "Some files were not %s because of errors.",
+ cpymode ? "copied" : "moved");
+
+- else if (nlen>1) sprintf(buf, "%d files %s", nlen,
++ else if (nlen>1) sprintf(buf, "%d files %s", nlen,
+ (cpymode) ? "copied" : "moved");
+ else buf[0] = '\0';
+ setBrowStr(srcBr, buf);
+@@ -4824,7 +4823,7 @@
+ dstdir = (stat2bf((u_int) st.st_mode) == BF_DIR);
+
+ if (overwrite==OWRT_ASK) {
+- sprintf(buf, "%s '%s' exists.\n\nOverwrite?",
++ sprintf(buf, "%s '%s' exists.\n\nOverwrite?",
+ dstdir ? "Directory" : "File", dst);
+ i = PopUp(buf, owbuts, 4);
+
+@@ -4848,7 +4847,7 @@
+ }
+ }
+
+-
++
+ if (!rename(src, dst)) return 0; /* Ok */
+ if (errno != EXDEV) return 1; /* failure, of some sort */
+
+@@ -4896,7 +4895,7 @@
+ /* possible cases: source is either a file or a directory, or doesn't exist,
+ destination is either a file, a directory, or doesn't exist.
+
+- if source doesn't exist, nothing to do.
++ if source doesn't exist, nothing to do.
+ if source is a file:
+ if dest is a file, popup 'overwriting' question, delete file if ok
+ if dest is a dir, popup 'overwriting dir' question, delete dir if ok
+@@ -4957,7 +4956,7 @@
+ /* destination doesn't exist no more, if it ever did... */
+ userMask = umask(0); /* grab the umask */
+ umask((mode_t) userMask); /* put it back... */
+-
++
+
+ strcpy(cpSrcPath, src);
+ strcpy(cpDstPath, dst);
+@@ -5017,7 +5016,7 @@
+ called recursively by cp_dir, there are *no* guarantees that either file
+ exists or not */
+
+- int i, havedst;
++ int havedst;
+ struct stat srcSt, dstSt;
+
+ if (stat(cpSrcPath, &srcSt)) { /* src doesn't exist, usefully... */
+@@ -5037,7 +5036,7 @@
+ }
+
+
+- switch(stat2bf((u_int) srcSt.st_mode)) {
++ switch(stat2bf((u_int) srcSt.st_mode)) {
+ /* determine how to copy, by filetype */
+
+ /* NOTE: There is no S_IFLNK case here, since we're using 'stat()' and
+@@ -5059,12 +5058,12 @@
+ return;
+ }
+ }
+-
++
+ cp_dir();
+ if (!havedst) chmod(cpDstPath, srcSt.st_mode);
+-
++
+ break;
+-
++
+
+ case BF_CHR:
+ case BF_BLK: cp_special(&srcSt, havedst); break;
+@@ -5089,12 +5088,12 @@
+ {
+ int i, dirlen, oldsrclen, olddstlen, longpath;
+ char **names, *name;
+- struct stat srcSt, dstSt;
++ struct stat srcSt;
+
+
+ /* src and dst directories both exists now. copy entries */
+
+- if (DEBUG) fprintf(stderr,"cp_dir: src='%s', dst='%s'\n",
++ if (DEBUG) fprintf(stderr,"cp_dir: src='%s', dst='%s'\n",
+ cpSrcPath, cpDstPath);
+
+ longpath = 0;
+@@ -5110,9 +5109,9 @@
+
+ for (i=0; i<dirlen && overwrite!=OWRT_CANCEL; i++) {
+ name = names[i];
+- if (name[0] == '.' && (name[1]=='\0' ||
++ if (name[0] == '.' && (name[1]=='\0' ||
+ (name[1]=='.' && name[2]=='\0'))) goto done;
+-
++
+ /* add name to src and dst paths */
+ if ((strlen(name) + oldsrclen >= (MAXPATHLEN-3)) ||
+ (strlen(name) + olddstlen >= (MAXPATHLEN-3))) {
+@@ -5130,12 +5129,12 @@
+ cpSrcPath[oldsrclen] = '\0';
+ goto done;
+ }
+-
++
+ if (stat2bf((u_int) srcSt.st_mode) == BF_DIR) {
+ cpSrcPath[oldsrclen] = '\0';
+ continue; /* don't remove from list, just skip */
+ }
+-
++
+ strcat(cpDstPath, "/");
+ strcat(cpDstPath, name);
+ cp(); /* RECURSE */
+@@ -5169,7 +5168,7 @@
+ strcat(cpDstPath, name);
+
+ cp(); /* RECURSE */
+-
++
+ cpSrcPath[oldsrclen] = '\0';
+ cpDstPath[olddstlen] = '\0';
+ }
+@@ -5191,10 +5190,10 @@
+ /*****************************/
+ {
+ register int srcFd, dstFd, rcount, wcount, i;
+- char str[512], buf[8192];
++ char buf[8192];
+ static char *owbuts[4] = { "\nOk", "dDon't Ask", "nNo", "\033Cancel" };
+
+- if (DEBUG) fprintf(stderr,"cp_file: src='%s', dst='%s'\n",
++ if (DEBUG) fprintf(stderr,"cp_file: src='%s', dst='%s'\n",
+ cpSrcPath, cpDstPath);
+
+ if ((srcFd = open(cpSrcPath, O_RDONLY, 0)) == -1) {
+@@ -5255,7 +5254,7 @@
+ int exists;
+ /*********************************/
+ {
+- if (DEBUG) fprintf(stderr,"cp_spec: src='%s', dst='%s'\n",
++ if (DEBUG) fprintf(stderr,"cp_spec: src='%s', dst='%s'\n",
+ cpSrcPath, cpDstPath);
+
+ if (exists && unlink(cpDstPath)) {
+@@ -5281,7 +5280,7 @@
+ int exists;
+ /*********************************/
+ {
+- if (DEBUG) fprintf(stderr,"cp_fifo: src='%s', dst='%s'\n",
++ if (DEBUG) fprintf(stderr,"cp_fifo: src='%s', dst='%s'\n",
+ cpSrcPath, cpDstPath);
+
+ #ifdef S_IFIFO
+@@ -5302,12 +5301,12 @@
+
+
+
+-
++
+ /*********************************/
+ static int stat2bf(uistmode)
+ u_int uistmode;
+ {
+- /* given the 'st.st_mode' field from a successful stat(), returns
++ /* 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*
+ return BF_EXE */
+
+@@ -5357,8 +5356,8 @@
+ static int selmatch1(name, arg)
+ char *name, *arg;
+ {
+- /* returns non-zero if 'name' matches 'arg'. Any '*' chars found in arg
+- are considered wildcards that match any number of characters,
++ /* returns non-zero if 'name' matches 'arg'. Any '*' chars found in arg
++ are considered wildcards that match any number of characters,
+ including zero. */
+
+ char *sp, *oldnp;
+@@ -5379,7 +5378,7 @@
+ while (*name) name++;
+ while (*arg ) arg++;
+ name--; arg--;
+-
++
+ while (*arg != '*') {
+ if (*arg != *name || name<oldnp) return 0;
+ arg--; name--;
+@@ -5388,7 +5387,7 @@
+ }
+
+ else { /* there are more '*'s in arg... */
+- /* find the first occurrence of the string between the two '*'s.
++ /* find the first occurrence of the string between the two '*'s.
+ if the '*'s are next to each other, just throw away the first one */
+
+ arg++; /* points to char after first '*' */
+@@ -5410,7 +5409,7 @@
+ arg = sp+1;
+ }
+ }
+- }
++ }
+ }
+
+ if (!*arg && !*name) return 1;
+diff -ruN xv-3.10a/xvbutt.c xv-3.10a-bugfixes/xvbutt.c
+--- xv-3.10a/xvbutt.c 1995-01-03 13:19:51.000000000 -0800
++++ xv-3.10a-bugfixes/xvbutt.c 2004-05-16 18:01:29.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvbutt.c - regular, 'radio', 'checkbox', and 'menu' pushbuttons
+ *
+ * callable functions:
+@@ -16,7 +16,7 @@
+ * RBSetActive() - sets active status of an RBUTT
+ * RBClick() - finds clicked-on rb in a list
+ * RBTrack() - tracks rb after click, until release
+- *
++ *
+ * CBCreate() - create a CBUTT (checkbox button)
+ * CBRedraw() - redraw a CBUTT
+ * CBSetActive() - change active status of a CBUTT
+@@ -26,7 +26,7 @@
+ * MBCreate() - create a MBUTT (menu button)
+ * MBRedraw() - redraw a MBUTT
+ * MBSetActive() - change active status of a MBUTT
+- * MBWhich() - returns # of first checked selection
++ * MBWhich() - returns # of first checked selection
+ * MBSelect() - similar to RBSelect() ...
+ * MBClick() - returns true if given MB was clicked on
+ * MBTrack() - tracks MBUTT after click, until release
+@@ -116,7 +116,7 @@
+ void BTRedraw(bp)
+ BUTT *bp;
+ {
+- int i,x,y,r,x1,y1;
++ int x,y,r,x1,y1;
+ unsigned int w,h;
+ XPoint tpts[10], bpts[10], ipts[5];
+
+@@ -170,13 +170,13 @@
+ XSetForeground(theDisp, theGC, bp->fg);
+ XDrawLines(theDisp, bp->win, theGC, ipts, 5, CoordModeOrigin); /* inset */
+
+- XDrawLine(theDisp, bp->win, theGC, x+1, y + 1,
++ XDrawLine(theDisp, bp->win, theGC, x+1, y + 1,
+ ipts[0].x, ipts[0].y);
+ XDrawLine(theDisp, bp->win, theGC, x+1, y + (int) h - 1,
+ ipts[1].x, ipts[1].y);
+ XDrawLine(theDisp, bp->win, theGC, x + (int) w - 1, y + (int) h - 1,
+ ipts[2].x, ipts[2].y);
+- XDrawLine(theDisp, bp->win, theGC, x + (int) w - 1, y+1,
++ XDrawLine(theDisp, bp->win, theGC, x + (int) w - 1, y+1,
+ ipts[3].x, ipts[3].y);
+
+ if (bp->lit) {
+@@ -184,12 +184,12 @@
+ XDrawRectangle(theDisp, bp->win, theGC, x+1, y+1, w-2, h-2);
+ }
+ }
+-
++
+ else { /* ctrlColor */
+ XSetForeground(theDisp, theGC, bp->bg);
+ XFillRectangle(theDisp, bp->win, theGC, x+1, y+1, w-1, h-1);
+
+- Draw3dRect(bp->win, x+1, y+1, w-2, h-2, R3D_OUT, bp->fwidth,
++ Draw3dRect(bp->win, x+1, y+1, w-2, h-2, R3D_OUT, bp->fwidth,
+ bp->hi, bp->lo, bp->bg);
+
+ XSetForeground(theDisp, theGC, bp->fg);
+@@ -198,7 +198,7 @@
+ if (bp->lit)
+ XDrawRectangle(theDisp, bp->win, theGC, x+1, y+1, w-2, h-2);
+ }
+-
++
+
+
+
+@@ -210,7 +210,7 @@
+
+ XSetBackground(theDisp, theGC, bp->bg);
+
+- if (bp->colorpix)
++ if (bp->colorpix)
+ XCopyArea (theDisp,bp->pix, bp->win, theGC, 0,0,bp->pw,bp->ph, x1,y1);
+ else
+ XCopyPlane(theDisp,bp->pix, bp->win, theGC, 0,0,bp->pw,bp->ph, x1,y1,1L);
+@@ -262,15 +262,15 @@
+ if (bp->lit==inval && PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) {
+ bp->lit = !inval; BTRedraw(bp); XFlush(theDisp);
+ }
+-
++
+ if (bp->lit!=inval && !PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) {
+ bp->lit = inval; BTRedraw(bp); XFlush(theDisp);
+ }
+ }
+
+ rval = (bp->lit != inval);
+-
+- if (bp->lit && !bp->toggle)
++
++ if (bp->lit && !bp->toggle)
+ { bp->lit = 0; BTRedraw(bp); XFlush(theDisp); }
+
+ return(rval);
+@@ -295,13 +295,13 @@
+ {
+ /* mallocs an RBUTT, fills in the fields, and appends it to rblist
+ if rblist is NULL, this is the first rb in the list. It will
+- be made the 'selected' one
++ be made the 'selected' one
+
+- Note: no need to check return status. It'll fatal error if it
++ Note: no need to check return status. It'll fatal error if it
+ can't malloc */
+
+ RBUTT *rb, *rbptr;
+- Pixmap rb_frame, rb_frame1, rb_top, rb_bot, rb_dtop, rb_dbot, rb_body,
++ Pixmap rb_frame, rb_frame1, rb_top, rb_bot, rb_dtop, rb_dbot, rb_body,
+ rb_dot;
+
+ rb = (RBUTT *) malloc(sizeof(RBUTT));
+@@ -348,7 +348,7 @@
+ rb_off = XCreatePixmap(theDisp, rootW, RBSIZE, RBSIZE, dispDEEP);
+ rb_off1 = XCreatePixmap(theDisp, rootW, RBSIZE, RBSIZE, dispDEEP);
+
+- if (!rb_frame || !rb_frame1 || !rb_top || !rb_bot || !rb_dtop ||
++ if (!rb_frame || !rb_frame1 || !rb_top || !rb_bot || !rb_dtop ||
+ !rb_dbot || !rb_body || !rb_dot || !rb_on || !rb_on1 ||
+ !rb_off || !rb_off1)
+ FatalError("unable to create radio-button pixmaps");
+@@ -410,7 +410,7 @@
+ XFillRectangle(theDisp, rb_on, theGC, 0,0,RBSIZE,RBSIZE);
+ XFillRectangle(theDisp, rb_on1, theGC, 0,0,RBSIZE,RBSIZE);
+ }
+-
++
+ XSetStipple(theDisp, theGC, rb_frame);
+ XSetForeground(theDisp, theGC, fg);
+ XFillRectangle(theDisp, rb_on, theGC, 0,0,RBSIZE,RBSIZE);
+@@ -437,7 +437,7 @@
+
+ return(rb);
+ }
+-
++
+
+
+
+@@ -475,23 +475,23 @@
+ int lit;
+ {
+ /* draws the rb being pointed at */
+-
++
+ Pixmap pix;
+-
++
+ if (!rb) return; /* rb = NULL */
+-
++
+ XSetForeground(theDisp, theGC, rb->fg);
+-
++
+ if (rb->selected) { pix = (lit) ? rb_on1 : rb_on; }
+ else { pix = (lit) ? rb_off1 : rb_off; }
+-
++
+ XCopyArea(theDisp, pix, rb->win, theGC, 0,0,RBSIZE,RBSIZE, rb->x, rb->y);
+- DrawString(rb->win, rb->x + RBSIZE + 4,
++ DrawString(rb->win, rb->x + RBSIZE + 4,
+ rb->y + RBSIZE/2 - CHIGH/2 + ASCENT, rb->str);
+
+ if (!rb->active) { /* if non-active, dim button and string */
+ DimRect(rb->win, rb->x, rb->y, RBSIZE, RBSIZE, rb->bg);
+- DimRect(rb->win, rb->x + RBSIZE + 4, rb->y + RBSIZE/2 - CHIGH/2,
++ DimRect(rb->win, rb->x + RBSIZE + 4, rb->y + RBSIZE/2 - CHIGH/2,
+ (u_int) StringWidth(rb->str), (u_int) CHIGH, rb->bg);
+ }
+ }
+@@ -527,19 +527,19 @@
+ }
+
+
+-
++
+ /***********************************************/
+ int RBWhich(rblist)
+ RBUTT *rblist;
+ {
+ int i;
+-
++
+ /* returns index of currently selected rb. if none, returns -1 */
+-
++
+ i = 0;
+- while (rblist && !rblist->selected)
++ while (rblist && !rblist->selected)
+ { rblist = (RBUTT *) rblist->next; i++; }
+-
++
+ if (!rblist) return -1; /* didn't find one */
+ return i;
+ }
+@@ -550,9 +550,9 @@
+ RBUTT *rblist;
+ {
+ int i;
+-
++
+ /* returns # of rb's in the list */
+-
++
+ i = 0;
+ while (rblist) { rblist = (RBUTT *) rblist->next; i++; }
+ return i;
+@@ -566,13 +566,13 @@
+ {
+ RBUTT *rb;
+ int i;
+-
++
+ /* sets 'active' status of rb #n. does redrawing */
+-
++
+ rb=rblist; i=0;
+ while (rb && i!=n) { rb = (RBUTT *) rb->next; i++; }
+ if (!rb) return; /* n out of range. do nothing */
+-
++
+ if (rb->active != act) {
+ rb->active = act;
+ drawRB(rb, 0);
+@@ -588,13 +588,13 @@
+ int i;
+
+ /* searches through rblist to see if mouse click at mx,my is in the
+- clickable region of any of the rb's. If it finds one, it returns
++ clickable region of any of the rb's. If it finds one, it returns
+ it's index in the list. If not, returns -1 */
+
+ i = 0;
+ while (rblist) {
+ if (PTINRECT(mx, my, rblist->x, rblist->y, RBSIZE, RBSIZE)) break;
+-
++
+ rblist = (RBUTT *) rblist->next;
+ i++;
+ }
+@@ -613,9 +613,9 @@
+ Window rW, cW;
+ int i, x, y, rx, ry, lit, rv;
+ unsigned int mask;
+-
++
+ /* returns '1' if selection changed */
+-
++
+ rb=rblist; i=0;
+ while (rb && i!=n) { rb = (RBUTT *) rb->next; i++; }
+ if (!rb) return 0; /* n out of range */
+@@ -637,7 +637,7 @@
+ drawRB(rb, lit);
+ XFlush(theDisp);
+ }
+-
++
+ if (lit && !PTINRECT(x, y, rb->x, rb->y, RBSIZE, RBSIZE)) {
+ lit=0;
+ drawRB(rb, lit);
+@@ -690,14 +690,14 @@
+ do so. We'll be needing them, y'see... */
+
+ if (!cbpixmade) {
+- cbcheck = XCreatePixmapFromBitmapData(theDisp, rootW,
++ cbcheck = XCreatePixmapFromBitmapData(theDisp, rootW,
+ (char *) cb_check_bits,
+ cb_check_width, cb_check_height, fg, bg, dispDEEP);
+
+ cbpixmade = 1;
+ }
+ }
+-
++
+
+
+
+@@ -708,25 +708,25 @@
+ /* draws the cb being pointed at */
+
+ XSetForeground(theDisp, theGC, cb->bg);
+- XFillRectangle(theDisp, cb->win, theGC, cb->x+2, cb->y+2,
++ XFillRectangle(theDisp, cb->win, theGC, cb->x+2, cb->y+2,
+ XVCBSIZE-3,XVCBSIZE-3);
+
+ XSetForeground(theDisp, theGC, cb->fg);
+ XDrawRectangle(theDisp, cb->win, theGC, cb->x, cb->y, XVCBSIZE, XVCBSIZE);
+ Draw3dRect(cb->win, cb->x+1, cb->y+1, XVCBSIZE-2, XVCBSIZE-2, R3D_OUT, 2,
+- cb->hi, cb->lo, cb->bg);
++ cb->hi, cb->lo, cb->bg);
+
+- if (cb->val) XCopyArea(theDisp, cbcheck, cb->win, theGC,
+- 0, 0, cb_check_width, cb_check_height,
++ if (cb->val) XCopyArea(theDisp, cbcheck, cb->win, theGC,
++ 0, 0, cb_check_width, cb_check_height,
+ cb->x+3, cb->y+3);
+-
++
+ XSetForeground(theDisp, theGC, cb->fg);
+- DrawString(cb->win, cb->x + XVCBSIZE+4,
++ DrawString(cb->win, cb->x + XVCBSIZE+4,
+ cb->y+XVCBSIZE/2 - CHIGH/2 + ASCENT, cb->str);
+
+ if (!cb->active) { /* if non-active, dim button and string */
+ DimRect(cb->win, cb->x, cb->y, XVCBSIZE, XVCBSIZE, cb->bg);
+- DimRect(cb->win, cb->x + XVCBSIZE+4, cb->y+XVCBSIZE/2 - CHIGH/2,
++ DimRect(cb->win, cb->x + XVCBSIZE+4, cb->y+XVCBSIZE/2 - CHIGH/2,
+ (u_int) StringWidth(cb->str), (u_int) CHIGH, cb->bg);
+ }
+ }
+@@ -761,7 +761,6 @@
+ Window rW, cW;
+ int x, y, rx, ry, lit;
+ unsigned int mask;
+- Pixmap litpix, darkpix;
+
+ /* called once we've figured out that the mouse clicked in 'cb' */
+
+@@ -782,7 +781,7 @@
+ drawCB(cb,lit);
+ XFlush(theDisp);
+ }
+-
++
+ if (lit && !PTINRECT(x, y, cb->x, cb->y, XVCBSIZE, XVCBSIZE)) {
+ lit=0;
+ drawCB(cb,lit);
+@@ -809,28 +808,28 @@
+ {
+ /* draws highlighting */
+ if (lit) {
+- if (ctrlColor)
++ if (ctrlColor)
+ Draw3dRect(cb->win, cb->x+1, cb->y+1, XVCBSIZE-2, XVCBSIZE-2, R3D_IN, 2,
+ cb->hi, cb->lo, cb->bg);
+ else {
+ XSetForeground(theDisp, theGC, cb->fg);
+- XDrawRectangle(theDisp, cb->win, theGC, cb->x+1, cb->y+1,
++ XDrawRectangle(theDisp, cb->win, theGC, cb->x+1, cb->y+1,
+ XVCBSIZE-2, XVCBSIZE-2);
+ }
+ }
+
+ else {
+- if (ctrlColor)
++ if (ctrlColor)
+ Draw3dRect(cb->win, cb->x+1, cb->y+1, XVCBSIZE-2, XVCBSIZE-2, R3D_OUT, 2,
+ cb->hi, cb->lo, cb->bg);
+ else {
+ XSetForeground(theDisp, theGC, cb->bg);
+- XDrawRectangle(theDisp, cb->win, theGC, cb->x+1, cb->y+1,
++ XDrawRectangle(theDisp, cb->win, theGC, cb->x+1, cb->y+1,
+ XVCBSIZE-2, XVCBSIZE-2);
+ }
+ }
+ }
+-
++
+
+
+ /******************* MBUTT ROUTINES ************************/
+@@ -851,7 +850,7 @@
+ XSetWindowAttributes xswa;
+ unsigned long xswamask;
+ int i;
+-
++
+ if (!mbpixmade) {
+ mbchk = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) mb_chk_bits,
+ mb_chk_width, mb_chk_height, fg, bg, dispDEEP);
+@@ -889,7 +888,7 @@
+ xswa.save_under = True;
+ xswamask = CWBackPixel | CWBorderPixel | CWSaveUnder;
+
+- mb->mwin = XCreateWindow(theDisp, mb->win, x, y, w, h,
++ mb->mwin = XCreateWindow(theDisp, mb->win, x, y, w, h,
+ (u_int) 2, (int) dispDEEP, InputOutput,
+ theVisual, xswamask, &xswa);
+
+@@ -898,7 +897,7 @@
+ XSelectInput(theDisp, mb->mwin, ExposureMask | VisibilityChangeMask);
+ XSetTransientForHint(theDisp, mb->mwin, mb->win);
+ }
+-
++
+
+
+
+@@ -908,15 +907,15 @@
+ {
+ /* draws a menu button in it's normal state. (When it's actively being
+ used (to select an item), all drawing is handled in MBTrack) */
+-
++
+ int x,y,i,r,x1,y1;
+ unsigned int w,h;
+-
++
+ r = 2; /* amt of shadow */
+ x = mb->x; y = mb->y; w = mb->w; h = mb->h;
+- x1 = x + (int) w;
++ x1 = x + (int) w;
+ y1 = y + (int) h;
+-
++
+ XSetForeground(theDisp, theGC, mb->bg);
+ XFillRectangle(theDisp, mb->win, theGC, x+1, y+1, w-1, h-1);
+
+@@ -940,7 +939,7 @@
+ XSetBackground(theDisp, theGC, mb->bg);
+ XCopyPlane(theDisp, mb->pix, mb->win, theGC, 0,0,
+ (u_int) mb->pw, (u_int) mb->ph, x1,y1, 1L);
+- if (!mb->active)
++ if (!mb->active)
+ DimRect(mb->win, x1,y1, (u_int) mb->pw, (u_int) mb->ph, mb->bg);
+ }
+
+@@ -997,14 +996,14 @@
+ MBUTT *mb;
+ {
+ /* returns index of first checked selection, or '-1' if nothing selected */
+-
++
+ int i;
+
+ if (!mb->hascheck) return -1;
+
+ for (i=0; i<mb->nlist; i++)
+ if (mb->flags[i]) return i;
+-
++
+ return -1;
+ }
+
+@@ -1017,13 +1016,13 @@
+ /* makes entry #n the selected entry (ie, the only one with a check mark)
+ Does all redrawing. Does nothing if entry #n already selected.
+ Don't let it select 'dim' entries */
+-
++
+ int i;
+-
++
+ if (n<0 || n>mb->nlist) return; /* # out of range */
+ if (!mb->hascheck) return; /* shouldn't happen */
+ if (mb->flags[n]) return; /* already selected */
+-
++
+ for (i=0; i<MAXMBLEN; i++) mb->flags[i] = 0;
+
+ mb->flags[n] = 1;
+@@ -1083,7 +1082,7 @@
+ }
+ }
+ mwide += 8; /* extra room at edges */
+-
++
+ /* make wider if any checked menu items */
+ for (i=0; i<mb->nlist && !mb->flags[i]; i++);
+ hascheck = (i<mb->nlist || mb->hascheck);
+@@ -1091,7 +1090,7 @@
+ if (hascheck && mb->title) mwide += 8;
+
+ if (mwide < (mb->w+1)) mwide = mb->w+1; /* at least as wide as button */
+-
++
+ mhigh = mb->nlist * LINEHIGH + 2 + extratop;
+
+ mx = mb->x-1; my = mb->y - 1;
+@@ -1144,10 +1143,10 @@
+ }
+
+ if (mb->flags[i]) {
+- XCopyArea(theDisp, mbchk, win, theGC, 0, 0, mb_chk_width, mb_chk_height,
++ XCopyArea(theDisp, mbchk, win, theGC, 0, 0, mb_chk_width, mb_chk_height,
+ x - 10, y - 8);
+ }
+-
++
+ if (!strcmp(mb->list[i], MBSEP)) {
+ mb->dim[i] = 1; /* don't select this one */
+ if (ctrlColor) {
+@@ -1161,15 +1160,15 @@
+ XDrawLine(theDisp,win,theGC,4,y-(ASCENT/2)+1, mwide-5, y-(ASCENT/2)+1);
+ XSetForeground(theDisp, theGC, mb->fg);
+ }
+- else
++ else
+ XDrawLine(theDisp, win, theGC, 4, y-(ASCENT/2), mwide-5, y-(ASCENT/2));
+ }
+ else {
+ DrawString(win, x, y, txtstr);
+- if (tabstr)
++ if (tabstr)
+ DrawString(win, mwide - mtabwide - 4, y, tabstr);
+
+- if (mb->dim[i])
++ if (mb->dim[i])
+ DimRect(win, x, y-ASCENT, (u_int) mwide, (u_int) CHIGH, mb->bg);
+ XSetForeground(theDisp, theGC, mb->fg);
+ }
+diff -ruN xv-3.10a/xvcolor.c xv-3.10a-bugfixes/xvcolor.c
+--- xv-3.10a/xvcolor.c 1995-01-06 11:29:23.000000000 -0800
++++ xv-3.10a-bugfixes/xvcolor.c 2004-05-16 18:01:37.000000000 -0700
+@@ -52,7 +52,7 @@
+ int pwide, phigh, *pnumcols;
+ {
+ /* operates on 8-bit images. sorts the colormap into 'best' order
+- * 'order' is the 'best' order to allocate the colors. 'trans' is a
++ * 'order' is the 'best' order to allocate the colors. 'trans' is a
+ * transformation to be done to pic, cpic, and epic (in PIC8 mode) to
+ * compress the colormap
+ */
+@@ -67,22 +67,22 @@
+ /* initialize histogram and compute it */
+ for (i=0; i<256; i++) hist[i]=0;
+ for (i=pwide*phigh, p=pic; i; i--, p++) hist[*p]++;
+-
++
+ if (DEBUG>1) {
+ fprintf(stderr,"%s: Desired colormap\n",cmd);
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ if (hist[i]) fprintf(stderr,"(%3d %02x,%02x,%02x %d)\n",
+ i,rmap[i],gmap[i],bmap[i], hist[i]);
+ fprintf(stderr,"\n\n");
+ }
+-
+-
++
++
+ /* put the actually-used colors into the 'c' array in the order they occur
+ also, while we're at it, calculate ncols, and close up gaps in
+ colortable */
+-
++
+ for (i=ncols=0; i<256; i++) {
+- if (hist[i]) {
++ if (hist[i]) {
+ rmap[ncols] = rmap[i];
+ gmap[ncols] = gmap[i];
+ bmap[ncols] = bmap[i];
+@@ -104,8 +104,8 @@
+ }
+ xvbcopy((char *) &c[entry], (char *) &c1[0], sizeof(CMAPENT));
+ c[entry].use = 0; /* dealt with */
+-
+-
++
++
+ /* sort rest of colormap. Half of the entries are allocated on the
+ basis of distance from already allocated colors, and half on the
+ basis of usage. (NB: 'taxicab' distance is used throughout this file.)
+@@ -116,7 +116,7 @@
+ To obtain O(n^2) performance, we keep each unselected color
+ (in c[], with use>0) marked with the minimum distance to any of
+ the selected colors (in c1[]). Each time we select a color, we
+- can update the minimum distances in O(n) time.
++ can update the minimum distances in O(n) time.
+
+ mod by Tom Lane Tom.Lane@g.gp.cs.cmu.edu */
+
+@@ -134,8 +134,8 @@
+ for (j=0, cj=c; j<ncols; j++,cj++) {
+ if (cj->use) { /* this color has not been marked already */
+ /* update mindist */
+- d = (cj->r - ckR)*(cj->r - ckR) +
+- (cj->g - ckG)*(cj->g - ckG) +
++ d = (cj->r - ckR)*(cj->r - ckR) +
++ (cj->g - ckG)*(cj->g - ckG) +
+ (cj->b - ckB)*(cj->b - ckB);
+ if (cj->mindist > d) cj->mindist = d;
+ if (cj->mindist > mdist) { mdist = cj->mindist; entry = j; }
+@@ -148,8 +148,8 @@
+ for (j=0, cj=c; j<ncols; j++,cj++) {
+ if (cj->use) { /* this color has not been marked already */
+ /* update mindist */
+- d = (cj->r - ckR)*(cj->r - ckR) +
+- (cj->g - ckG)*(cj->g - ckG) +
++ d = (cj->r - ckR)*(cj->r - ckR) +
++ (cj->g - ckG)*(cj->g - ckG) +
+ (cj->b - ckB)*(cj->b - ckB);
+ if (cj->mindist > d) cj->mindist = d;
+ if (cj->use > mdist) { mdist = cj->use; entry = j; }
+@@ -162,18 +162,18 @@
+ xvbcopy((char *) &c[entry], (char *) &c1[i], sizeof(CMAPENT));
+ c[entry].use = 0;
+ }
+-
++
+
+ for (i=0; i<ncols; i++) order[i] = (byte) c1[i].oldindex;
+
+ if (DEBUG>1) {
+ fprintf(stderr,"%s: result of sorting colormap\n",cmd);
+- for (i=0; i<ncols; i++)
++ for (i=0; i<ncols; i++)
+ fprintf(stderr,"(%3d %02x,%02x,%02x) ",i,rmap[i],gmap[i],bmap[i]);
+ fprintf(stderr,"\n\n");
+-
++
+ fprintf(stderr,"%s: allocation order table\n",cmd);
+- for (i=0; i<ncols; i++)
++ for (i=0; i<ncols; i++)
+ fprintf(stderr,"order[%d] = -> %d\n", i, order[i]);
+ fprintf(stderr,"\n");
+ }
+@@ -240,7 +240,7 @@
+ SetISTR(ISTR_COLOR,"Using %s colormap.",
+ (haveStdCmap == STD_111 ? "2x2x2" :
+ haveStdCmap == STD_222 ? "4x4x4" :
+- haveStdCmap == STD_232 ? "4x8x4" :
++ haveStdCmap == STD_232 ? "4x8x4" :
+ haveStdCmap == STD_666 ? "6x6x6" : "8x8x4"));
+
+ if (ncols>0) SetISTR(ISTR_COLOR2,stdCmapSuccess);
+@@ -251,7 +251,7 @@
+
+ for (i=0; i<numcols; i++) {
+ int i332;
+- i332 = ((int)rMap[i]&0xe0) | (((int)gMap[i]&0xe0)>>3) |
++ i332 = ((int)rMap[i]&0xe0) | (((int)gMap[i]&0xe0)>>3) |
+ (((int)bMap[i]&0xc0)>>6);
+
+ cols[i] = stdcols[i332];
+@@ -291,7 +291,7 @@
+ }
+
+ else {
+- for (i=0; i<nfcols; i++)
++ for (i=0; i<nfcols; i++)
+ xvFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
+
+ nfcols = 0;
+@@ -314,19 +314,19 @@
+ unique = p2alloc = 0;
+ rwthistime = 0;
+
+- /* FIRST PASS COLOR ALLOCATION:
++ /* FIRST PASS COLOR ALLOCATION:
+ for each color in the 'desired colormap', try to get it via
+ xvAllocColor(). If for any reason it fails, mark that pixel
+ 'unallocated' and worry about it later. Repeat. */
+
+- /* attempt to allocate first ncols entries in colormap
++ /* attempt to allocate first ncols entries in colormap
+ note: On displays with less than 8 bits per RGB gun, it's quite
+ possible that different colors in the original picture will be
+ mapped to the same color on the screen. X does this for you
+- silently. However, this is not-desirable for this application,
++ silently. However, this is not-desirable for this application,
+ because when I say 'allocate me 32 colors' I want it to allocate
+ 32 different colors, not 32 instances of the same 4 shades... */
+-
++
+
+ for (i=0; i<256; i++) failed[i] = 1;
+
+@@ -334,7 +334,7 @@
+
+ for (i=0; i<numcols && unique<ncols; i++) {
+ c = colAllocOrder[i];
+- if (mono) {
++ if (mono) {
+ int intens = MONO(rMap[c], gMap[c], bMap[c]);
+ defs[c].red = defs[c].green = defs[c].blue = intens<<8;
+ }
+@@ -346,8 +346,8 @@
+
+ defs[c].flags = DoRed | DoGreen | DoBlue;
+
+- if (!(colorMapMode==CM_OWNCMAP && cmap==theCmap && CMAPVIS(theVisual))
+- && xvAllocColor(theDisp,cmap,&defs[c])) {
++ if (!(colorMapMode==CM_OWNCMAP && cmap==theCmap && CMAPVIS(theVisual))
++ && xvAllocColor(theDisp,cmap,&defs[c])) {
+ unsigned long pixel, *fcptr;
+
+ pixel = cols[c] = defs[c].pixel;
+@@ -355,7 +355,7 @@
+ gdisp[c] = defs[c].green >> 8;
+ bdisp[c] = defs[c].blue >> 8;
+ failed[c]= 0;
+-
++
+ /* see if the newly allocated color is new and different */
+ for (j=0, fcptr=freecols; j<nfcols && *fcptr!=pixel; j++,fcptr++);
+ if (j==nfcols) unique++;
+@@ -365,24 +365,24 @@
+ }
+
+ else {
+- /* the allocation failed. If we want 'perfect' color, and we haven't
++ /* the allocation failed. If we want 'perfect' color, and we haven't
+ already created our own colormap, we'll want to do so */
+ if ((colorMapMode == CM_PERFECT || colorMapMode == CM_OWNCMAP)
+ && !LocalCmap && CMAPVIS(theVisual)) {
+ LocalCmap = XCreateColormap(theDisp, vrootW, theVisual, AllocNone);
+-
++
+ if (LocalCmap) { /* succeeded, presumably */
+ /* free all colors that were allocated, and try again with the
+ new colormap. This is necessary because 'XCopyColormapAndFree()'
+ has the unpleasant side effect of freeing up the various
+ colors I need for the control panel, etc. */
+
+- for (i=0; i<nfcols; i++)
++ for (i=0; i<nfcols; i++)
+ xvFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
+-
++
+ if (mainW && !useroot) XSetWindowColormap(theDisp,mainW, LocalCmap);
+
+- if (mainW && !useroot && cmapInGam)
++ if (mainW && !useroot && cmapInGam)
+ XSetWindowColormap(theDisp,gamW, LocalCmap);
+ cmap = LocalCmap;
+
+@@ -402,9 +402,9 @@
+ }
+ }
+ } /* FIRST PASS */
+-
+-
+-
++
++
++
+ if (nfcols==numcols) {
+ if (numcols != unique)
+ SetISTR(ISTR_COLOR,"Got all %d colors. (%d unique)", numcols,
+@@ -415,7 +415,7 @@
+ SetISTR(ISTR_COLOR2,"");
+ return;
+ }
+-
++
+
+
+ /* SECOND PASS COLOR ALLOCATION:
+@@ -427,7 +427,7 @@
+ is in the X colormap. Try to allocate that color (read only).
+ If that fails, the THIRD PASS will deal with it */
+
+- SetISTR(ISTR_COLOR,"Got %d of %d colors. (%d unique)",
++ SetISTR(ISTR_COLOR,"Got %d of %d colors. (%d unique)",
+ nfcols,numcols,unique);
+
+ /* read entire colormap (or first 256 entries) into 'ctab' */
+@@ -436,28 +436,28 @@
+ if (dc>0) { /* only do SECOND PASS if there IS a colormap to read */
+ for (i=0; i<dc; i++) ctab[i].pixel = (unsigned long) i;
+ XQueryColors(theDisp, cmap, ctab, dc);
+-
++
+ for (i=0; i<numcols && unique<ncols; i++) {
+ c = colAllocOrder[i];
+-
++
+ if (failed[c]) { /* an unallocated pixel */
+ int d, mdist, close;
+ int rd, gd, bd, ri, gi, bi;
+-
++
+ mdist = 1000000; close = -1;
+ ri = rMap[c]; gi = gMap[c]; bi = bMap[c];
+-
++
+ for (j=0; j<dc; j++) {
+ rd = ri - (ctab[j].red >>8);
+ gd = gi - (ctab[j].green>>8);
+ bd = bi - (ctab[j].blue >>8);
+-
++
+ d = rd*rd + gd*gd + bd*bd;
+ if (d<mdist) { mdist=d; close=j; }
+ }
+-
++
+ if (close<0) FatalError("This Can't Happen! (How reassuring.)");
+- if (xvAllocColor(theDisp, cmap, &ctab[close])) {
++ if (xvAllocColor(theDisp, cmap, &ctab[close])) {
+ xvbcopy((char *) &ctab[close], (char *) &defs[c], sizeof(XColor));
+ failed[c]= 0;
+ cols[c] = ctab[close].pixel;
+@@ -487,7 +487,7 @@
+
+ mdist = 1000000; close = -1;
+ ri = rMap[c]; gi = gMap[c]; bi = bMap[c];
+-
++
+ /* search the alloc'd colors */
+ for (j=0; j<nfcols; j++) {
+ k = fc2pcol[j];
+@@ -535,7 +535,7 @@
+ unsigned long pmr[1], pix[1];
+ c = colAllocOrder[i];
+
+- if (cellgroup[c]) {
++ if (cellgroup[c]) {
+ int n;
+ /* this color is part of a group. see if its group's
+ been seen already, and if so, skip this */
+@@ -548,11 +548,11 @@
+ }
+ }
+
+- if (!(colorMapMode==CM_OWNCMAP && cmap==theCmap && CMAPVIS(theVisual)) &&
++ if (!(colorMapMode==CM_OWNCMAP && cmap==theCmap && CMAPVIS(theVisual)) &&
+ XAllocColorCells(theDisp, cmap, False, pmr, 0, pix, 1)) {
+ defs[c].pixel = cols[c] = pix[0];
+ failed[c] = 0;
+- if (mono) {
++ if (mono) {
+ int intens = MONO(rMap[c], gMap[c], bMap[c]);
+ defs[c].red = defs[c].green = defs[c].blue = intens<<8;
+ }
+@@ -573,20 +573,20 @@
+ }
+
+ else {
+- if ((colorMapMode == CM_PERFECT || colorMapMode == CM_OWNCMAP)
++ if ((colorMapMode == CM_PERFECT || colorMapMode == CM_OWNCMAP)
+ && !LocalCmap && CMAPVIS(theVisual)) {
+ LocalCmap = XCreateColormap(theDisp, vrootW, theVisual, AllocNone);
+-
++
+ /* free all colors that were allocated, and try again with the
+ new colormap. This is necessary because 'XCopyColormapAndFree()'
+ has the unpleasant side effect of freeing up the various
+ colors I need for the control panel, etc. */
+
+- for (i=0; i<nfcols; i++)
++ for (i=0; i<nfcols; i++)
+ xvFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
+-
++
+ if (mainW && !useroot) XSetWindowColormap(theDisp,mainW, LocalCmap);
+- if (mainW && !useroot && cmapInGam)
++ if (mainW && !useroot && cmapInGam)
+ XSetWindowColormap(theDisp,gamW, LocalCmap);
+ cmap = LocalCmap;
+
+@@ -608,7 +608,7 @@
+ }
+
+ else {
+- /* Failed to allocate all colors in picture. Map remaining desired
++ /* Failed to allocate all colors in picture. Map remaining desired
+ colors into closest allocated desired colors */
+
+ if (nfcols==0 && !LocalCmap) {
+@@ -623,7 +623,7 @@
+ allocROColors();
+ return;
+ }
+-
++
+ SetISTR(ISTR_COLOR,"Got %d of %d colors.", nfcols,numcols);
+
+ for (i=0; i<numcols; i++) {
+@@ -662,7 +662,7 @@
+ j = fc2pcol[i];
+ defs[j].pixel = freecols[i];
+
+- if (mono) {
++ if (mono) {
+ int intens = MONO(rMap[j], gMap[j], bMap[j]);
+ defs[j].red = defs[j].green = defs[j].blue = intens<<8;
+ }
+@@ -706,9 +706,9 @@
+ if (theVisual->class == TrueColor || theVisual->class == DirectColor) {
+ unsigned long r, g, b, rmask, gmask, bmask, origr, origg, origb;
+ int rshift, gshift, bshift;
+-
+- /* shift r,g,b so that high bit of 16-bit color specification is
+- * aligned with high bit of r,g,b-mask in visual,
++
++ /* shift r,g,b so that high bit of 16-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
+ */
+@@ -781,7 +781,7 @@
+ " mask=%04lx,%04lx,%04lx pix=%08lx\n",
+ rmask, gmask, bmask, cdef->pixel);
+ }
+-
++
+ return 1;
+ }
+ else {
+@@ -811,7 +811,7 @@
+ {
+ int i, j;
+
+- /* if regroup is set, we *must* do a full realloc, as the cols[] array
++ /* if regroup is set, we *must* do a full realloc, as the cols[] array
+ isn't correct anymore. (cell groupings changed) */
+
+ ApplyECctrls(); /* set {r,g,b}cmap[editColor] based on dial settings */
+@@ -830,16 +830,16 @@
+ }
+ }
+
+-
++
+ /* do something clever if we're using R/W color and this colorcell isn't
+ shared */
+
+ if (!regroup && allocMode==AM_READWRITE && rwthistime) {
+ /* let's try to be clever */
+- /* determine if the editColor cell is unique, or shared (among
++ /* determine if the editColor cell is unique, or shared (among
+ non-group members, that is) */
+
+- for (i=j=0; i<numcols; i++)
++ for (i=j=0; i<numcols; i++)
+ if (rwpc2pc[i] == rwpc2pc[editColor]) j++;
+
+ /* if this is a group, subtract off the non-this-one pixels from group */
+@@ -901,7 +901,7 @@
+ }
+
+ /* shift 0..i-1 down one position */
+- xvbcopy((char *) colAllocOrder, (char *) colAllocOrder+1,
++ xvbcopy((char *) colAllocOrder, (char *) colAllocOrder+1,
+ i * sizeof(colAllocOrder[0]));
+ colAllocOrder[0] = editColor;
+ }
+@@ -930,9 +930,9 @@
+ * stdfreecols[256] - list of colors to free on exit
+ * stdnfcols - # of colors to free
+ *
+- * possibly modifies browR, browG, browB, and browcols arrays
++ * possibly modifies browR, browG, browB, and browcols arrays
+ * (if !browPerfect)
+- */
++ */
+
+ /* returns '1' if the colors were reallocated, '0' otherwise */
+
+@@ -946,18 +946,18 @@
+
+ /* note:
+ * if (ncols==0) (ie, we're either on, or emulating a b/w display),
+- * build std*[], std*disp[], colormaps, but don't actually
++ * build std*[], std*disp[], colormaps, but don't actually
+ * allocate any colors.
+ */
+
+- int i,j,r,g,b, desMode, screwed;
++ int i, r,g,b, desMode, screwed;
+ XColor def;
+ byte rmap[256],gmap[256],bmap[256],order[256];
+ unsigned long descols[256];
+ int des2got[256], failed[256];
+ int maplen, exactCnt, nearCnt;
+-
+-
++
++
+ /* generate stdr,stdg,stdb cmap. Same in all cases */
+ for (r=0, i=0; r<8; r++)
+ for (g=0; g<8; g++)
+@@ -966,10 +966,10 @@
+ stdg[i] = (g*255)/7;
+ stdb[i] = (b*255)/3;
+ }
+-
+-
++
++
+ /* determine what size cmap we should build */
+- if (theVisual->class == TrueColor ||
++ if (theVisual->class == TrueColor ||
+ theVisual->class == DirectColor) desMode = STD_332;
+ else if (colorMapMode == CM_STDCMAP) desMode = STD_232;
+ else desMode = STD_222;
+@@ -983,9 +983,9 @@
+ }
+
+
+- if (DEBUG) fprintf(stderr,"MakeStdCmaps: have=%d, des=%d, ncols=%d\n",
++ if (DEBUG) fprintf(stderr,"MakeStdCmaps: have=%d, des=%d, ncols=%d\n",
+ haveStdCmap, desMode, ncols);
+-
++
+ if (haveStdCmap != STD_NONE && haveStdCmap == desMode) return 0;
+ freeStdCmaps();
+
+@@ -997,7 +997,7 @@
+ for (i=0; i<256; i++) des2got[i] = i;
+ exactCnt = nearCnt = 0;
+
+-
++
+ if (desMode == STD_111) { /* try to alloc 8 colors */
+ /* generate a 1/1/1 desired colormap */
+ maplen = 8;
+@@ -1009,7 +1009,7 @@
+ bmap[i] = (b*255);
+ }
+ }
+-
++
+ else if (desMode == STD_222) { /* try to alloc 64 colors */
+ /* generate a 2/2/2 desired colormap */
+ maplen = 64;
+@@ -1021,7 +1021,7 @@
+ bmap[i] = (b*255)/3;
+ }
+ }
+-
++
+ else if (desMode == STD_232) { /* try to alloc 128 colors */
+ /* generate a 2/3/2 desired colormap */
+ maplen = 128;
+@@ -1033,7 +1033,7 @@
+ bmap[i] = (b*255)/3;
+ }
+ }
+-
++
+ else if (desMode == STD_666) { /* try to alloc 216 colors */
+ /* generate a 6*6*6 desired colormap */
+ maplen = 216;
+@@ -1045,14 +1045,14 @@
+ bmap[i] = (b*255)/5;
+ }
+ }
+-
++
+ else { /* desMode == STD_332 */
+ maplen = 256;
+ for (i=0; i<maplen; i++) {
+ rmap[i] = stdr[i]; gmap[i] = stdg[i]; bmap[i] = stdb[i];
+ }
+ }
+-
++
+
+ /* sort the colors according to the diversity algorithm... */
+ diverseOrder(rmap,gmap,bmap,maplen,order);
+@@ -1072,7 +1072,7 @@
+ def.red = rmap[order[i]] << 8;
+ def.green = gmap[order[i]] << 8;
+ def.blue = bmap[order[i]] << 8;
+-
++
+ def.flags = DoRed | DoGreen | DoBlue;
+
+ if (xvAllocColor(theDisp, theCmap, &def)) { /* success */
+@@ -1090,34 +1090,34 @@
+
+ if (numgot != maplen) {
+ /* PHASE 2: find 'close' colors in colormap, try to alloc those */
+-
++
+ /* read entire colormap (or first 256 entries) into 'ctab' */
+ dc = (ncells<256) ? ncells : 256;
+ if (dc>0) {
+ for (i=0; i<dc; i++) ctab[i].pixel = (unsigned long) i;
+ XQueryColors(theDisp, theCmap, ctab, dc);
+-
++
+ for (i=0; i<maplen; i++) {
+ if (failed[i]) {
+-
++
+ /* find closest color in colormap, and try to alloc it */
+ mind = 1000000; /* greater than 3 * (256^2) */
+ for (j=0,num = -1; j<dc; j++) {
+ rd = rmap[i] - (ctab[j].red >>8);
+ gd = gmap[i] - (ctab[j].green>>8);
+ bd = bmap[i] - (ctab[j].blue >>8);
+-
++
+ d = CDIST(rd, gd, bd);
+ if (d<mind) { mind = d; num = j; }
+ }
+-
++
+ if (num < 0) screwed = 1;
+ else if (xvAllocColor(theDisp, theCmap, &ctab[num])) { /*success*/
+ des2got[i] = i;
+ descols[i] = ctab[num].pixel;
+ failed[i] = 0;
+- nearCnt++;
+- /* for (j=0; j<stdnfcols && stdfreecols[j]!=ctab[num].pixel;
++ nearCnt++;
++ /* for (j=0; j<stdnfcols && stdfreecols[j]!=ctab[num].pixel;
+ j++); */
+ stdfreecols[stdnfcols++] = ctab[num].pixel;
+ }
+@@ -1125,12 +1125,12 @@
+ }
+ }
+ }
+-
+- /* PHASE 3: map remaining unallocated colors into closest we got */
+-
++
++ /* PHASE 3: map remaining unallocated colors into closest we got */
++
+ for (i=0; i<maplen; i++) {
+ if (failed[i]) {
+-
++
+ /* find closest alloc'd color */
+ mind = 1000000; /* greater than 3 * (256^2) */
+ for (j=0,num=0; j<maplen; j++) {
+@@ -1139,7 +1139,7 @@
+ if (d<mind) { mind = d; num = j; }
+ }
+ }
+-
++
+ if (failed[num]) screwed = 1;
+ else {
+ descols[i] = descols[num];
+@@ -1151,8 +1151,8 @@
+ }
+
+
+- /* at this point, we have 'descols', a maplen long array of
+- X pixel values that maps 1/1/1, 2/2/2, 6*6*6, or 3/3/2 values
++ /* at this point, we have 'descols', a maplen long array of
++ X pixel values that maps 1/1/1, 2/2/2, 6*6*6, or 3/3/2 values
+ into an X pixel value */
+
+ /* build stdcols and stdrdisp,stdgdisp,stdbdisp colormap */
+@@ -1170,7 +1170,7 @@
+
+ stdcols[i332] = descols[des2got[i111]];
+ }
+- }
++ }
+
+ else if (desMode == STD_222) {
+ for (r=0; r<8; r++)
+@@ -1186,7 +1186,7 @@
+
+ stdcols[i332] = descols[des2got[i222]];
+ }
+- }
++ }
+
+ else if (desMode == STD_232) {
+ for (r=0; r<8; r++)
+@@ -1201,7 +1201,7 @@
+ stdbdisp[i332] = bmap[des2got[i232]];
+ stdcols[i332] = descols[des2got[i232]];
+ }
+- }
++ }
+
+ else if (desMode == STD_666) {
+ for (r=0,i=0; r<8; r++)
+@@ -1221,7 +1221,7 @@
+
+ stdcols[i] = descols[des2got[i666]];
+ }
+- }
++ }
+
+ else { /* desMode == STD_332 */
+ for (i=0; i<256; i++) {
+@@ -1249,22 +1249,22 @@
+ if (DEBUG > 1) {
+ fprintf(stderr,"MakeStdCmaps: ncols=%d maplen=%d\n", ncols, maplen);
+ fprintf(stderr," std*[]= ");
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ fprintf(stderr,"%02x,%02x,%02x ",stdr[i],stdg[i],stdb[i]);
+ fprintf(stderr,"\n\n");
+
+ fprintf(stderr," disp[]= ");
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ fprintf(stderr,"%02x,%02x,%02x ",stdrdisp[i],stdgdisp[i],stdbdisp[i]);
+ fprintf(stderr,"\n\n");
+
+ fprintf(stderr," stdcols[]= ");
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ fprintf(stderr,"%02lx ",stdcols[i]);
+ fprintf(stderr,"\n\n");
+
+ fprintf(stderr," stdfreecols[%d] = ", stdnfcols);
+- for (i=0; i<stdnfcols; i++)
++ for (i=0; i<stdnfcols; i++)
+ fprintf(stderr,"%02lx ",stdfreecols[i]);
+ fprintf(stderr,"\n\n");
+ }
+@@ -1272,8 +1272,8 @@
+ if (exactCnt == maplen)
+ sprintf(stdCmapSuccess, "Got all %d colors.", exactCnt);
+ else {
+- if (nearCnt>0)
+- sprintf(stdCmapSuccess, "Got %d out of %d colors. (%d close color%s)",
++ if (nearCnt>0)
++ sprintf(stdCmapSuccess, "Got %d out of %d colors. (%d close color%s)",
+ exactCnt, maplen, nearCnt, (nearCnt>1) ? "s" : "");
+ else
+ sprintf(stdCmapSuccess, "Got %d out of %d colors.", exactCnt, maplen);
+@@ -1292,11 +1292,11 @@
+ /* This function should only be called once, at the start of the program.
+ *
+ * produces many things:
+- * browR,browG,browB[256]
++ * browR,browG,browB[256]
+ * - a 3/3/2 colormap used by genIcon
+ * browcols[256] - maps 3/3/2 values into X colors
+ * browCmap - local cmap used in browse window, if browPerfect
+- */
++ */
+
+ int i,j,r,g,b, screwed, num, exactCnt, nearCnt;
+ XColor def;
+@@ -1306,8 +1306,8 @@
+ long d, mind;
+
+
+- if (DEBUG)
+- fprintf(stderr,"MakeBrowCmap: perfect = %d, ncols = %d\n",
++ if (DEBUG)
++ fprintf(stderr,"MakeBrowCmap: perfect = %d, ncols = %d\n",
+ browPerfect, ncols);
+
+ if (ncols == 0 || !CMAPVIS(theVisual)) browPerfect = 0;
+@@ -1350,7 +1350,7 @@
+ def.red = rmap[order[i]] << 8;
+ def.green = gmap[order[i]] << 8;
+ def.blue = bmap[order[i]] << 8;
+-
++
+ def.flags = DoRed | DoGreen | DoBlue;
+
+ if (xvAllocColor(theDisp, browCmap, &def)) { /* success */
+@@ -1358,14 +1358,14 @@
+ descols[order[i]] = def.pixel;
+
+ if (DEBUG>1)
+- fprintf(stderr,"makebrowcmap: Phase 1: Alloc %x,%x,%x succeeded!\n",
++ fprintf(stderr,"makebrowcmap: Phase 1: Alloc %x,%x,%x succeeded!\n",
+ rmap[order[i]], gmap[order[i]], bmap[order[i]]);
+ }
+ else failed[order[i]] = 1;
+ }
+
+-
+- /* PHASE 2: map remaining unallocated colors into closest we got */
++
++ /* PHASE 2: map remaining unallocated colors into closest we got */
+
+ for (i=0; i<256; i++) {
+ if (failed[i]) {
+@@ -1377,9 +1377,9 @@
+ if (d<mind) { mind = d; num = j; }
+ }
+ }
+-
++
+ if (DEBUG>1)
+- fprintf(stderr,"makebrowcmap: closest to %x,%x,%x = %x,%x,%x\n",
++ fprintf(stderr,"makebrowcmap: closest to %x,%x,%x = %x,%x,%x\n",
+ rmap[i],gmap[i],bmap[i], rmap[num], gmap[num], bmap[num]);
+
+ if (failed[num]) screwed = 1;
+@@ -1406,7 +1406,7 @@
+ byte *rmap, *gmap, *bmap, *order;
+ int maplen;
+ {
+- /* takes a colormap (maxlen 256) and produces an order array that
++ /* takes a colormap (maxlen 256) and produces an order array that
+ contains the most-diverse order for allocating these colors */
+
+ int dist[256], i, pick, maxv, ocnt, d;
+@@ -1422,7 +1422,7 @@
+
+ ocnt = 0;
+ order[ocnt++] = pick;
+-
++
+ /* init dist[] array */
+ for (i=0; i<maplen; i++) dist[i] = 1000000;
+
+@@ -1509,14 +1509,14 @@
+ else if (cmode == CM_NORMAL) {
+ if (novbrowse || browPerfect || haveStdCmap != iconCmapSize)
+ freeStdCmaps();
+-
++
+ /* if using browser, and killed stdcmap, make icon stdcmap */
+ if (!novbrowse && !browPerfect && haveStdCmap == STD_NONE) {
+ if (MakeStdCmaps() && anyBrowUp && CMAPVIS(theVisual))
+ RegenBrowseIcons();
+ }
+ }
+-
++
+ else if (cmode == CM_PERFECT) { }
+ else if (cmode == CM_OWNCMAP) { }
+
+@@ -1540,7 +1540,7 @@
+ SetEpicMode();
+ if (genepic) GenerateEpic(eWIDE, eHIGH);
+ }
+- else {
++ else {
+ if (oldmode == CM_STDCMAP && cmode != CM_STDCMAP && epicMode != EM_RAW) {
+ /* just left STDCMAP mode. Switch to using 'RAW' */
+ epicMode = EM_RAW;
+diff -ruN xv-3.10a/xvctrl.c xv-3.10a-bugfixes/xvctrl.c
+--- xv-3.10a/xvctrl.c 1994-12-22 14:34:41.000000000 -0800
++++ xv-3.10a-bugfixes/xvctrl.c 2004-05-23 11:56:37.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvctrl.c - Control box handling functions
+ *
+ * callable functions:
+@@ -9,7 +9,7 @@
+ * RedrawCtrl(x,y,w,h) - called by 'expose' events
+ * ClickCtrl(x,y)
+ * DrawCtrlStr() - called to redraw 'ISTR_INFO' string in ctrlW
+- * ScrollToCurrent() - called when list selection is changed
++ * ScrollToCurrent() - called when list selection is changed
+ *
+ * LSCreate() - creates a listbox
+ * LSRedraw() - redraws 'namelist' box
+@@ -49,7 +49,10 @@
+ #include "bits/uicon"
+ #include "bits/oicon1"
+ #include "bits/oicon2"
+-#include "bits/icon"
++#ifdef REGSTR
++# define OMIT_ICON_BITS
++# include "bits/icon"
++#endif
+
+ #define CTRLWIDE 440 /* (fixed) size of control window */
+ #define CTRLHIGH 348 /* 379 */
+@@ -80,7 +83,7 @@
+ in xv.h */
+
+
+-static char *dispMList[] = { "Raw\tr",
++static char *dispMList[] = { "Raw\tr",
+ "Dithered\td",
+ "Smooth\ts",
+ MBSEP,
+@@ -91,7 +94,7 @@
+ "Use Own Colormap",
+ "Use Std. Colormap" };
+
+-static char *rootMList[] = { "Window",
++static char *rootMList[] = { "Window",
+ "Root: tiled",
+ "Root: integer tiled",
+ "Root: mirrored",
+@@ -159,12 +162,12 @@
+ void CreateCtrl(geom)
+ char *geom;
+ {
+- int i, listh, topskip;
++ int listh, topskip;
+ double skip;
+ XSetWindowAttributes xswa;
+ Pixmap oicon1Pix, oicon2Pix;
+
+- ctrlW = CreateWindow("xv controls", "XVcontrols", geom,
++ ctrlW = CreateWindow("xv controls", "XVcontrols", geom,
+ CTRLWIDE, CTRLHIGH, infofg, infobg, 0);
+ if (!ctrlW) FatalError("can't create controls window!");
+
+@@ -205,10 +208,10 @@
+ oicon2Pix = MakePix1(ctrlW, oicon2_bits, oicon2_width, oicon2_height);
+
+ if (!grayTile || !dimStip || !fifoPix || !chrPix || !dirPix ||
+- !blkPix || !lnkPix || !regPix || !rotlPix || !fliphPix ||
++ !blkPix || !lnkPix || !regPix || !rotlPix || !fliphPix ||
+ !flipvPix || !p10Pix || !m10Pix || !cutPix || !copyPix ||
+ !pastePix || !clearPix || !uiconPix || !oiconPix || !oicon1Pix ||
+- !oicon2Pix || !padPix || !annotPix)
++ !oicon2Pix || !padPix || !annotPix)
+ FatalError("unable to create all pixmaps in CreateCtrl()\n");
+
+
+@@ -226,7 +229,7 @@
+ XFreePixmap(theDisp, oicon1Pix);
+ XFreePixmap(theDisp, oicon2Pix);
+
+-
++
+
+ if (ctrlColor) XSetWindowBackground(theDisp, ctrlW, locol);
+ else XSetWindowBackgroundPixmap(theDisp, ctrlW, grayTile);
+@@ -234,7 +237,7 @@
+ listh = LINEHIGH * NLINES;
+
+ LSCreate(&nList, ctrlW, 5, 52, (CTRLWIDE-BUTTW-18),
+- LINEHIGH*NLINES, NLINES, dispnames, numnames,
++ LINEHIGH*NLINES, NLINES, dispnames, numnames,
+ infofg, infobg, hicol, locol, RedrawNList, 0, 0);
+ nList.selected = 0; /* default to first name selected */
+
+@@ -245,8 +248,8 @@
+
+ topskip = nList.y;
+ skip = ((double) (nList.h - (CHIGH+5))) / 6.0;
+- if (skip > SBUTTH+8) {
+- skip = SBUTTH + 7;
++ if (skip > SBUTTH+8) {
++ skip = SBUTTH + 7;
+ topskip = nList.y + (nList.h - (6*skip + (CHIGH+5))) / 2;
+ }
+
+@@ -258,7 +261,7 @@
+ #define R_BY3 (topskip + (int)(3*skip))
+ #define R_BY4 (topskip + (int)(4*skip))
+ #define R_BY5 (topskip + (int)(5*skip))
+-
++
+ BTCreate(&but[BNEXT], ctrlW, R_BX0, R_BY0, R_BW1, SBUTTH, "Next", BCLS);
+ BTCreate(&but[BPREV], ctrlW, R_BX0, R_BY1, R_BW1, SBUTTH, "Prev", BCLS);
+ BTCreate(&but[BLOAD], ctrlW, R_BX0, R_BY2, R_BW1, SBUTTH, "Load", BCLS);
+@@ -309,7 +312,7 @@
+ BTCreate(&but[BABOUT], ctrlW,BX4, BY1,BUTTW,BUTTH,"About XV",BCLS);
+ BTCreate(&but[BQUIT], ctrlW,BX5, BY1,BUTTW,BUTTH,"Quit", BCLS);
+
+- BTCreate(&but[BXV], ctrlW,5,5, 100, (u_int) nList.y - 5 - 2 - 5,
++ BTCreate(&but[BXV], ctrlW,5,5, 100, (u_int) nList.y - 5 - 2 - 5,
+ "", BCLS);
+
+ SetButtPix(&but[BCOPY], copyPix, copy_width, copy_height);
+@@ -329,7 +332,7 @@
+ if (ctrlColor) {
+ SetButtPix(&but[BXV], oiconPix, oicon1_width, oicon1_height);
+ but[BXV].colorpix = 1;
+- }
++ }
+ else SetButtPix(&but[BXV], iconPix, icon_width, icon_height);
+ #else
+ SetButtPix(&but[BXV], uiconPix, uicon_width, uicon_height);
+@@ -338,21 +341,21 @@
+ XMapSubwindows(theDisp, ctrlW);
+
+
+- /* have to create menu buttons after XMapSubWindows, as we *don't* want
++ /* have to create menu buttons after XMapSubWindows, as we *don't* want
+ the popup menus mapped */
+
+- MBCreate(&dispMB, ctrlW, CTRLWIDE - 8 - 112 - 2*(112+2), 5,112,19,
++ MBCreate(&dispMB, ctrlW, CTRLWIDE - 8 - 112 - 2*(112+2), 5,112,19,
+ "Display", dispMList, DMB_MAX, BCLS);
+- MBCreate(&conv24MB, ctrlW, CTRLWIDE - 8 - 112 - (112+2), 5,112,19,
++ MBCreate(&conv24MB, ctrlW, CTRLWIDE - 8 - 112 - (112+2), 5,112,19,
+ "24/8 Bit", conv24MList, CONV24_MAX, BCLS);
+- MBCreate(&algMB, ctrlW, CTRLWIDE - 8 - 112, 5,112,19,
++ MBCreate(&algMB, ctrlW, CTRLWIDE - 8 - 112, 5,112,19,
+ "Algorithms", algMList, ALG_MAX, BCLS);
+
+- MBCreate(&rootMB, ctrlW, CTRLWIDE - 8 - 112 - 2*(112+2), 5+21,112,19,
++ MBCreate(&rootMB, ctrlW, CTRLWIDE - 8 - 112 - 2*(112+2), 5+21,112,19,
+ "Root", rootMList, RMB_MAX, BCLS);
+- MBCreate(&windowMB, ctrlW, CTRLWIDE - 8 - 112 - (112+2), 5+21,112,19,
++ MBCreate(&windowMB, ctrlW, CTRLWIDE - 8 - 112 - (112+2), 5+21,112,19,
+ "Windows", windowMList, WMB_MAX, BCLS);
+- MBCreate(&sizeMB, ctrlW, CTRLWIDE - 8 - 112, 5+21,112,19,
++ MBCreate(&sizeMB, ctrlW, CTRLWIDE - 8 - 112, 5+21,112,19,
+ "Image Size", sizeMList, SZMB_MAX, BCLS);
+
+
+@@ -395,7 +398,7 @@
+ byte *bits;
+ int w,h;
+ {
+- return XCreatePixmapFromBitmapData(theDisp, win, (char *) bits,
++ return XCreatePixmapFromBitmapData(theDisp, win, (char *) bits,
+ (u_int) w, (u_int) h, 1L,0L,1);
+ }
+
+@@ -404,7 +407,7 @@
+ void CtrlBox(vis)
+ int vis;
+ {
+- if (vis) XMapRaised(theDisp, ctrlW);
++ if (vis) XMapRaised(theDisp, ctrlW);
+ else XUnmapWindow(theDisp, ctrlW);
+
+ ctrlUp = vis;
+@@ -416,7 +419,6 @@
+ int x,y,w,h;
+ {
+ int i;
+- XRectangle xr;
+
+ RANGE(w, 0, CTRLWIDE);
+ RANGE(h, 0, CTRLHIGH);
+@@ -452,7 +454,7 @@
+ /***************************************************/
+ void DrawCtrlNumFiles()
+ {
+- int x,y,w,h;
++ int x,y,w;
+ char foo[40];
+
+ x = but[BNEXT].x;
+@@ -463,14 +465,14 @@
+ XSetBackground(theDisp, theGC, infobg);
+
+ sprintf(foo, "%d file%s", numnames, (numnames==1) ? "" : "s");
+-
++
+ XSetForeground(theDisp, theGC, infobg);
+ XFillRectangle(theDisp,ctrlW, theGC, x+1,y+1, (u_int) w-1, (u_int) CHIGH+5);
+
+ XSetForeground(theDisp,theGC,infofg);
+ XDrawRectangle(theDisp,ctrlW, theGC, x,y, (u_int) w, (u_int) CHIGH+6);
+
+- Draw3dRect(ctrlW, x+1,y+1, (u_int) w-2, (u_int) CHIGH+4,
++ Draw3dRect(ctrlW, x+1,y+1, (u_int) w-2, (u_int) CHIGH+4,
+ R3D_IN, 2, hicol, locol, infobg);
+
+ XSetForeground(theDisp,theGC,infofg);
+@@ -489,7 +491,7 @@
+ st1 = GetISTR(ISTR_WARNING);
+
+ XSetForeground(theDisp, theGC, infobg);
+- XFillRectangle(theDisp, ctrlW, theGC, 0, y+1,
++ XFillRectangle(theDisp, ctrlW, theGC, 0, y+1,
+ CTRLWIDE, (u_int)((CHIGH+4)*2+1));
+
+ XSetForeground(theDisp, theGC, infofg);
+@@ -501,7 +503,7 @@
+ XSetForeground(theDisp, theGC, locol);
+ XDrawLine(theDisp, ctrlW, theGC, 0, y+1, CTRLWIDE, y+1);
+ XDrawLine(theDisp, ctrlW, theGC, 0, y+CHIGH+5, CTRLWIDE, y+CHIGH+5);
+- XDrawLine(theDisp, ctrlW, theGC, 0, y+(CHIGH+4)*2+1,
++ XDrawLine(theDisp, ctrlW, theGC, 0, y+(CHIGH+4)*2+1,
+ CTRLWIDE, y+(CHIGH+4)*2+1);
+ }
+
+@@ -542,16 +544,16 @@
+ void ScrollToCurrent(lst)
+ LIST *lst;
+ {
+- /* called when selected item on list is changed. Makes the selected
++ /* called when selected item on list is changed. Makes the selected
+ item visible. If it already is, nothing happens. Otherwise, it
+- attempts to scroll so that the selection appears in the middle of
++ attempts to scroll so that the selection appears in the middle of
+ the list window */
+
+ int halfway;
+
+ if (lst->selected < 0) return; /* no selection, do nothing */
+
+- if (lst->selected > lst->scrl.val &&
++ if (lst->selected > lst->scrl.val &&
+ lst->selected < lst->scrl.val + lst->nlines-1) LSRedraw(lst, 0);
+ else {
+ halfway = (lst->nlines)/2; /* offset to the halfway pt. of the list */
+@@ -590,7 +592,7 @@
+ lp->win = XCreateSimpleWindow(theDisp,win,x,y,(u_int) w, (u_int) h,1,fg,bg);
+ if (!lp->win) FatalError("can't create list window!");
+
+- lp->x = x; lp->y = y;
++ lp->x = x; lp->y = y;
+ lp->w = w; lp->h = h;
+ lp->fg = fg; lp->bg = bg;
+ lp->hi = hi; lp->lo = lo;
+@@ -603,7 +605,7 @@
+
+ XSelectInput(theDisp, lp->win, ExposureMask | ButtonPressMask);
+
+- SCCreate(&lp->scrl, lp->win, w-20, -1, 1, h, 0,
++ SCCreate(&lp->scrl, lp->win, w-20, -1, 1, h, 0,
+ nstr-nlines, 0, nlines-1, fg, bg, hi, lo, fptr);
+
+ XMapSubwindows(theDisp, lp->win);
+@@ -646,7 +648,7 @@
+ LIST *lp;
+ {
+ /* redraws lists 3d-effect, which can be trounced by drawSel() */
+- Draw3dRect(lp->win, 0, 0, lp->w-1, lp->h-1, R3D_IN, 2,
++ Draw3dRect(lp->win, 0, 0, lp->w-1, lp->h-1, R3D_IN, 2,
+ lp->hi, lp->lo, lp->bg);
+ }
+
+@@ -675,43 +677,43 @@
+ else { fg = lp->fg; bg = lp->bg; }
+
+ XSetForeground(theDisp, theGC, bg);
+- XFillRectangle(theDisp, lp->win, theGC, x0, y0+i*LINEHIGH,
++ XFillRectangle(theDisp, lp->win, theGC, x0, y0+i*LINEHIGH,
+ (u_int) wide+1, (u_int) LINEHIGH);
+
+ if (j>=0 && j<lp->nstr) { /* only draw string if valid */
+ XSetForeground(theDisp, theGC, fg);
+ XSetBackground(theDisp, theGC, bg);
+
+- if (!lp->filetypes)
++ if (!lp->filetypes)
+ DrawString(lp->win, x0+3, y0+i*LINEHIGH + ASCENT + 1, lp->str[j]);
+ else {
+ int ypos = y0 + i*LINEHIGH + (LINEHIGH - i_fifo_height)/2;
+
+- if (lp->str[j][0] == C_FIFO)
++ if (lp->str[j][0] == C_FIFO)
+ XCopyPlane(theDisp, fifoPix, lp->win, theGC, 0, 0,
+ i_fifo_width, i_fifo_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_CHR)
++ else if (lp->str[j][0] == C_CHR)
+ XCopyPlane(theDisp, chrPix, lp->win, theGC, 0, 0,
+ i_chr_width, i_chr_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_DIR)
++ else if (lp->str[j][0] == C_DIR)
+ XCopyPlane(theDisp, dirPix, lp->win, theGC, 0, 0,
+ i_dir_width, i_dir_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_BLK)
++ else if (lp->str[j][0] == C_BLK)
+ XCopyPlane(theDisp, blkPix, lp->win, theGC, 0, 0,
+ i_blk_width, i_blk_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_LNK)
++ else if (lp->str[j][0] == C_LNK)
+ XCopyPlane(theDisp, lnkPix, lp->win, theGC, 0, 0,
+ i_lnk_width, i_lnk_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_SOCK)
++ else if (lp->str[j][0] == C_SOCK)
+ XCopyPlane(theDisp, sockPix, lp->win, theGC, 0, 0,
+ i_sock_width, i_sock_height, x0+3, ypos, 1L);
+
+- else if (lp->str[j][0] == C_EXE)
++ else if (lp->str[j][0] == C_EXE)
+ XCopyPlane(theDisp, exePix, lp->win, theGC, 0, 0,
+ i_exe_width, i_exe_height, x0+3, ypos, 1L);
+
+@@ -720,8 +722,8 @@
+ i_reg_width, i_reg_height, x0+3, ypos, 1L);
+
+
+- DrawString(lp->win, x0+3 + i_fifo_width + 3,
+- y0+i*LINEHIGH + ASCENT + 1,
++ DrawString(lp->win, x0+3 + i_fifo_width + 3,
++ y0+i*LINEHIGH + ASCENT + 1,
+ lp->str[j]+1);
+ }
+ }
+@@ -735,7 +737,7 @@
+ {
+ int i;
+
+- for (i = lp->scrl.val; i < lp->scrl.val + lp->nlines; i++)
++ for (i = lp->scrl.val; i < lp->scrl.val + lp->nlines; i++)
+ drawSel(lp,i);
+ ls3d(lp);
+ }
+@@ -762,7 +764,7 @@
+ if (sel >= lp->nstr) sel = lp->selected;
+
+ /* see if it's a double click */
+- if (ev->time - lasttime < DBLCLKTIME && sel==lastsel
++ if (ev->time - lasttime < DBLCLKTIME && sel==lastsel
+ && (lp->scrl.val + (y-y0)/LINEHIGH) < lp->nstr
+ && !INACTIVE(lp,sel)) {
+ return (sel);
+@@ -782,7 +784,7 @@
+ while (XQueryPointer(theDisp,lp->win,&rW,&cW,&rx,&ry,&x,&y,&mask)) {
+ if (!(mask & Button1Mask)) break; /* button released */
+
+- if (y<y0) { /* scroll up in list */
++ if (y<y0) { /* scroll up in list */
+ if (lp->scrl.val > lp->scrl.min) {
+ lp->selected = lp->scrl.val - 1;
+ SCSetVal(&lp->scrl, lp->scrl.val - 1);
+@@ -804,7 +806,7 @@
+ if (sel >= lp->nstr) sel = lp->nstr - 1;
+
+ if (sel != lp->selected && sel >= lp->scrl.val &&
+- sel < lp->scrl.val + lp->nlines) {
++ sel < lp->scrl.val + lp->nlines) {
+ /* dragged to another on current page */
+ oldsel = lp->selected;
+ lp->selected = sel;
+@@ -829,17 +831,17 @@
+ else if (key==LS_PAGEDOWN) SCSetVal(&lp->scrl,lp->scrl.val + (lp->nlines-1));
+ else if (key==LS_HOME) SCSetVal(&lp->scrl,lp->scrl.min);
+ else if (key==LS_END) SCSetVal(&lp->scrl,lp->scrl.max);
+-
++
+ else if (key==LS_LINEUP) {
+ /* if the selected item visible, but not the top line */
+- if (lp->selected > lp->scrl.val &&
++ if (lp->selected > lp->scrl.val &&
+ lp->selected <= lp->scrl.val + lp->nlines - 1) {
+ /* then just move it */
+ lp->selected--;
+ drawSel(lp, lp->selected); drawSel(lp, lp->selected+1);
+ ls3d(lp);
+ }
+-
++
+ /* if it's the top line... */
+ else if (lp->selected == lp->scrl.val) {
+ if (lp->selected > 0) {
+@@ -847,7 +849,7 @@
+ SCSetVal(&lp->scrl, lp->selected);
+ }
+ }
+-
++
+ /* if it's not visible, put it on the bottom line */
+ else {
+ lp->selected = lp->scrl.val + lp->nlines - 1;
+@@ -856,10 +858,10 @@
+ ls3d(lp);
+ }
+ }
+-
++
+ else if (key==LS_LINEDOWN) {
+ /* if the selected item visible, but not the bottom line */
+- if (lp->selected >= lp->scrl.val &&
++ if (lp->selected >= lp->scrl.val &&
+ lp->selected < lp->scrl.val + lp->nlines - 1) {
+ if (lp->selected < lp->nstr-1) {
+ /* then just move it */
+@@ -868,7 +870,7 @@
+ ls3d(lp);
+ }
+ }
+-
++
+ /* if it's the bottom line... */
+ else if (lp->selected == lp->scrl.val + lp->nlines - 1) {
+ if (lp->selected < lp->nstr-1) {
+@@ -876,7 +878,7 @@
+ SCSetVal(&lp->scrl, lp->scrl.val+1);
+ }
+ }
+-
++
+ /* if it's not visible, put it on the top line */
+ else {
+ lp->selected = lp->scrl.val;
+diff -ruN xv-3.10a/xvcut.c xv-3.10a-bugfixes/xvcut.c
+--- xv-3.10a/xvcut.c 1995-01-13 11:55:48.000000000 -0800
++++ xv-3.10a-bugfixes/xvcut.c 2004-05-16 18:01:43.000000000 -0700
+@@ -15,7 +15,7 @@
+ * static void clearSelectedArea();
+ * static void makeClipFName ();
+ * static int countcols24 (byte *, int,int, int,int,int,int));
+- * static int countNewCols (byte*, int, int, byte*, int,
++ * static int countNewCols (byte*, int, int, byte*, int,
+ * int, int, int, int);
+ *
+ * void InitSelection ();
+@@ -72,7 +72,7 @@
+ static void clearSelectedArea PARM((void));
+ static void makeClipFName PARM((void));
+ static int countcols24 PARM((byte *, int, int, int, int, int, int));
+-static int countNewCols PARM((byte *, int, int, byte *, int,
++static int countNewCols PARM((byte *, int, int, byte *, int,
+ int, int, int, int));
+ static int dragHandle PARM((XButtonEvent *));
+ static void dragSelection PARM((XButtonEvent *, u_int, int));
+@@ -210,7 +210,7 @@
+ if (!PasteAllowed()) { XBell(theDisp, 0); return; }
+
+ cimg = getFromClip();
+- if (!cimg) return;
++ if (!cimg) return;
+
+ /* if there's no selection, make one! */
+ if (!HaveSelection()) makePasteSel(cimg);
+@@ -231,7 +231,7 @@
+
+ byte *dp, *dpic, *clippic, *clipcmap;
+ int clipw, cliph, clipis24, len, istran, trval;
+- int i, j, sx,sy,sw,sh, cx,cy,cw,ch, dx,dy,dw,dh,dx2,dy2;
++ int i, j, sx,sy,sw,sh, cx,cy,cw,ch, dx,dy,dw,dh;
+
+
+ /*
+@@ -245,7 +245,7 @@
+ ((int) (cimg[CIMG_LEN + 2]<<16)) |
+ ((int) (cimg[CIMG_LEN + 3]<<24));
+
+- if (len < CIMG_PIC24) return;
++ if (len < CIMG_PIC24) return;
+
+ istran = cimg[CIMG_TRANS];
+ trval = cimg[CIMG_TRVAL];
+@@ -268,7 +268,7 @@
+ * already, because if we *are*, we'd prefer to do any clipboard rescaling
+ * in 24-bit space for the obvious reasons.
+ *
+- * possibilities:
++ * possibilities:
+ * PIC24 - easy, do clipboard rescale in 24-bit space
+ * PIC8, and clipboard is 8 bits, (or 24-bits, but with <=256 colors)
+ * and total unique colors < 256:
+@@ -283,7 +283,7 @@
+
+ /* dx,dy,dw,dh is the rectangle (in PIC coords) where the paste will occur
+ (cropped to be entirely within PIC */
+-
++
+ dx = sx; dy = sy; dw = sw; dh = sh;
+ CropRect2Rect(&dx, &dy, &dw, &dh, 0, 0, pWIDE, pHIGH);
+
+@@ -291,7 +291,7 @@
+ /* cx,cy,cw,ch is the rectangle of the clipboard data (in clipboard coords)
+ that will actually be used in the paste operation */
+
+- cx = (sx>=0) ? 0 : ((-sx) * clipw) / sw;
++ cx = (sx>=0) ? 0 : ((-sx) * clipw) / sw;
+ cy = (sy>=0) ? 0 : ((-sy) * cliph) / sh;
+ cw = (dw * clipw) / sw;
+ ch = (dh * cliph) / sh;
+@@ -302,26 +302,26 @@
+ if (picType == PIC8) {
+ int ncc, keep8;
+ char buf[512];
+-
++
+ if (clipis24) { /* pasting in a 24-bit image that *requires* promotion */
+ static char *bnames[] = { "\nOkay", "\033Cancel" };
+ strcpy(buf, "Warning: Pasting this 24-bit image will require ");
+ strcat(buf, "promoting the current image to 24 bits.");
+-
++
+ if (PopUp(buf, bnames, 2)) goto exit; /* Cancelled */
+ else Change824Mode(PIC24); /* promote pic to 24 bits */
+ }
+
+ else { /* clip is 8 bits */
+ ncc = countNewCols(clippic,clipw,cliph,clipcmap,clipis24,cx,cy,cw,ch);
+-
++
+ if (ncc + numcols > 256) {
+ static char *bnames[] = { "\nPromote", "8Keep 8-bit", "\033Cancel" };
+ strcpy(buf,"Warning: The image and the clipboard combine to have ");
+ strcat(buf,"more than 256 unique colors. Promoting the ");
+ strcat(buf,"image to 24 bits is recommended, otherwise the contents ");
+ strcat(buf,"of the clipboard will probably lose some colors.");
+-
++
+ keep8 = PopUp(buf, bnames, 3);
+ if (keep8==2) goto exit; /* Cancel */
+ else if (keep8==0) Change824Mode(PIC24); /* promote pic to 24 bits */
+@@ -331,8 +331,8 @@
+
+
+
+-
+-
++
++
+ /* legal possibilities at this point:
+ * pic is PIC24: clip is 8 or 24
+ * pic is PIC8: clip is 8, or clip is 24 but has 256 or fewer colors
+@@ -342,18 +342,18 @@
+
+ if (picType == PIC8) {
+ int clx, cly, r,g,b,k,mind,close,newcols;
+- byte *cp, *clp, *pp, *ccp, newr[256], newg[256], newb[256], remap[256];
++ byte *cp, *clp, *pp, newr[256], newg[256], newb[256], remap[256];
+ byte order[256], trans[256];
+ int bperpix, dpncols;
+-
++
+ dpic = (byte *) malloc((size_t) dw * dh);
+ if (!dpic) FatalError("Out of memory in DoImgPaste()\n");
+-
++
+ bperpix = (clipis24) ? 3 : 1;
+ newcols = 0;
+-
++
+ /* dpic = a scaled, 8-bit representation of clippic[cx,cy,cw,ch] */
+-
++
+ if (!clipis24) { /* copy colormap from clip data into newr,g,b[] */
+ for (i=0; i<256; i++) {
+ newr[i] = clipcmap[i*3];
+@@ -366,22 +366,22 @@
+ dp = dpic + i*dw;
+ cly = cy + (i * ch) / dh;
+ clp = clippic + (cly*clipw * bperpix);
+-
++
+ for (j=0; j<dw; j++, dp++) {
+ /* get appropriate pixel from clippic */
+ clx = cx + (j * cw) / dw;
+ cp = clp + (clx * bperpix);
+-
++
+ if (!clipis24) *dp = *cp;
+ else { /* build colormap as we go... */
+ r = *cp++; g = *cp++; b = *cp++;
+-
++
+ /* look it up in new colormap, add if not there */
+ for (k=0; k<newcols && (r!=newr[k] || g!=newg[k] ||b!=newb[k]); k++);
+ if (k==newcols && k<256) {
+ newr[k]=r; newg[k]=g; newb[k]=b; newcols++;
+ }
+-
++
+ *dp = (byte) (k & 0xff);
+ }
+ }
+@@ -401,23 +401,23 @@
+ }
+ }
+ }
+-
+-
+-
++
++
++
+ /* COLORMAP MERGING */
+-
++
+ newcols = 0;
+-
++
+ for (i=0; i<dpncols; i++) {
+ if (istran && i==trval) continue;
+-
++
+ for (j=0; j<numcols; j++) { /* look for an exact match */
+ if (rMap[j]==newr[i] && gMap[j]==newg[i] && bMap[j]==newb[i]) break;
+ }
+ if (j<numcols) remap[i] = j;
+ else { /* no exact match */
+ newcols++;
+-
++
+ if (numcols < 256) {
+ rMap[numcols] = newr[i];
+ gMap[numcols] = newg[i];
+@@ -429,7 +429,7 @@
+ r = newr[i]; g=newg[i]; b=newb[i];
+ mind = 256*256 + 256*256 + 256*256;
+ for (j=close=0; j<numcols; j++) {
+- k = ((rMap[j]-r) * (rMap[j]-r)) +
++ k = ((rMap[j]-r) * (rMap[j]-r)) +
+ ((gMap[j]-g) * (gMap[j]-g)) +
+ ((bMap[j]-b) * (bMap[j]-b));
+ if (k<mind) { mind = k; close = j; }
+@@ -438,10 +438,10 @@
+ }
+ }
+ }
+-
+-
++
++
+ /* copy the data into PIC */
+-
++
+ dp = dpic;
+ for (i=dy; i<dy+dh; i++) {
+ pp = pic + (i*pWIDE) + dx;
+@@ -451,7 +451,7 @@
+ }
+ }
+ free(dpic);
+-
++
+ if (newcols) InstallNewPic(); /* does color reallocation, etc. */
+ else {
+ GenerateCpic();
+@@ -459,16 +459,16 @@
+ DrawEpic();
+ }
+ }
+-
++
+
+ /******************** PIC24 handling **********************/
+-
+-
++
++
+ else {
+ byte *tmppic, *cp, *pp, *clp;
+ int bperpix;
+ int trr, trg, trb, clx, cly;
+-
++
+ trr = trg = trb = 0;
+ if (istran) {
+ if (clipis24) {
+@@ -482,24 +482,24 @@
+ trb = clipcmap[trval*3+2];
+ }
+ }
+-
++
+ bperpix = (clipis24) ? 3 : 1;
+
+ if (!istran && (cw != dw || ch != dh)) { /* need to resize, can smooth */
+ byte rmap[256], gmap[256], bmap[256];
+-
++
+ tmppic = (byte *) malloc((size_t) cw * ch * bperpix);
+ if (!tmppic) FatalError("Out of memory in DoImgPaste()\n");
+-
+- /* copy relevant hunk of clippic into tmppic (Smooth24 only works on
++
++ /* copy relevant hunk of clippic into tmppic (Smooth24 only works on
+ complete images */
+-
++
+ for (i=0; i<ch; i++) {
+ dp = tmppic + i*cw*bperpix;
+ cp = clippic + ((i+cy)*clipw + cx) * bperpix;
+ for (j=0; j<cw*bperpix; j++) *dp++ = *cp++;
+ }
+-
++
+ if (!clipis24) {
+ for (i=0; i<256; i++) {
+ rmap[i] = clipcmap[i*3];
+@@ -507,15 +507,15 @@
+ bmap[i] = clipcmap[i*3+2];
+ }
+ }
+-
++
+ dpic = Smooth24(tmppic, clipis24, cw,ch, dw,dh, rmap,gmap,bmap);
+ if (!dpic) FatalError("Out of memory (2) in DoImgPaste()\n");
+ free(tmppic);
+-
++
+ /* copy the resized, smoothed, 24-bit data into 'pic' */
+-
++
+ /* XXX: (deal with smooth-resized transparent imgs) */
+-
++
+ dp = dpic;
+ for (i=dy; i<dy+dh; i++) {
+ pp = pic + (i*pWIDE + dx) * 3;
+@@ -536,11 +536,11 @@
+ pp = pic + ((i+dy)*pWIDE + dx) * 3;
+ cly = cy + (i * ch) / dh;
+ clp = clippic + (cly*clipw * bperpix);
+-
++
+ for (j=0; j<dw; j++, pp+=3) {
+ clx = cx + (j * cw) / dw;
+ cp = clp + (clx * bperpix);
+-
++
+ if (clipis24) {
+ if (!istran || cp[0]!=trr || cp[1]!=trg || cp[2]==trb) {
+ pp[0] = *cp++; pp[1] = *cp++; pp[2] = *cp++;
+@@ -557,14 +557,14 @@
+ }
+ }
+
+-
++
+ GenerateCpic();
+ GenerateEpic(eWIDE, eHIGH);
+ DrawEpic();
+ }
+-
+-
+- exit:
++
++
++ exit:
+ SetCursors(-1);
+ }
+
+@@ -577,20 +577,20 @@
+ XColor cfg, cbg;
+
+ dragcurs = XCreateFontCursor(theDisp, XC_fleur);
+- p1 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) cut_bits,
++ p1 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) cut_bits,
+ cut_width, cut_height, 1L, 0L, 1);
+- p2 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) cutm_bits,
++ p2 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) cutm_bits,
+ cutm_width, cutm_height, 1L, 0L, 1);
+- p3 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) copy_bits,
++ p3 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) copy_bits,
+ copy_width, copy_height, 1L, 0L, 1);
+- p4 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) copym_bits,
++ p4 = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) copym_bits,
+ copym_width, copym_height, 1L, 0L, 1);
+ if (p1 && p2 && p3 && p4) {
+ cfg.red = cfg.green = cfg.blue = 0;
+ cbg.red = cbg.green = cbg.blue = 0xffff;
+- cutcurs = XCreatePixmapCursor(theDisp, p1,p2, &cfg, &cbg,
++ cutcurs = XCreatePixmapCursor(theDisp, p1,p2, &cfg, &cbg,
+ cut_x_hot, cut_y_hot);
+- copycurs = XCreatePixmapCursor(theDisp, p3,p4, &cfg, &cbg,
++ copycurs = XCreatePixmapCursor(theDisp, p3,p4, &cfg, &cbg,
+ copy_x_hot, copy_y_hot);
+ if (!cutcurs || !copycurs) FatalError("can't create cut/copy cursors...");
+ }
+@@ -619,7 +619,7 @@
+
+ if (!CutAllowed()) { XBell(theDisp, 0); return (byte *) NULL; }
+ if (!HaveSelection()) return (byte *) NULL;
+-
++
+ GetSelRCoords(&x,&y,&w,&h);
+ CropRect2Rect(&x,&y,&w,&h, 0,0,pWIDE,pHIGH);
+
+@@ -663,15 +663,15 @@
+ if (picType == PIC24 && !do24) { /* 24-bit data as 8-bit */
+ int nc,pr,pg,pb;
+ byte *cm;
+-
++
+ nc = 0;
+ dp = cimg + CIMG_PIC8;
+-
++
+ for (i=y; i<y+h; i++) {
+ pp = pic + i*pWIDE*3 + x*3;
+ for (j=x; j<x+w; j++, pp+=3) {
+ pr = pp[0]; pg = pp[1]; pb = pp[2];
+-
++
+ cm = cimg + CIMG_CMAP;
+ for (k=0; k<nc; k++,cm+=3) {
+ if (pr==cm[0] && pg==cm[1] && pb==cm[2]) break;
+@@ -682,12 +682,12 @@
+ cimg[CIMG_CMAP + nc*3 + 1] = pg;
+ cimg[CIMG_CMAP + nc*3 + 2] = pb;
+ }
+-
++
+ *dp++ = (byte) k;
+ }
+ }
+ }
+-
++
+
+ else if (picType == PIC24) { /* 24-bit data as 24-bit */
+ dp = cimg + CIMG_PIC24;
+@@ -705,26 +705,26 @@
+ else if (picType == PIC8) { /* 8-bit selection */
+ byte *cm = cimg + CIMG_CMAP;
+ for (i=0; i<256; i++) { /* copy colormap */
+- if (i<numcols) {
++ if (i<numcols) {
+ *cm++ = rMap[i];
+ *cm++ = gMap[i];
+ *cm++ = bMap[i];
+ }
+ }
+-
++
+ dp = cimg + CIMG_PIC8;
+ for (i=y; i<y+h; i++) { /* copy image */
+ pp = pic + i*pWIDE + x;
+ for (j=x; j<x+w; j++) *dp++ = *pp++;
+ }
+ }
+-
++
+ return cimg;
+ }
+
+
+
+-
++
+ /********************************************/
+ static byte *getFromClip()
+ {
+@@ -743,14 +743,14 @@
+ clipAtom = XInternAtom(theDisp, CLIPPROP, True);
+ if (clipAtom != None) XDeleteProperty(theDisp, rootW, clipAtom);
+ }
+-
+-
++
++
+ clipAtom = XInternAtom(theDisp, CLIPPROP, True); /* find prop */
+ if (clipAtom != None) {
+
+ /* try to retrieve the length of the data in the property */
+- i = XGetWindowProperty(theDisp, rootW, clipAtom, 0L, 1L, False, XA_STRING,
+- &actType, &actFormat, &nitems, &nleft,
++ i = XGetWindowProperty(theDisp, rootW, clipAtom, 0L, 1L, False, XA_STRING,
++ &actType, &actFormat, &nitems, &nleft,
+ (unsigned char **) &data);
+
+ if (i==Success && actType==XA_STRING && actFormat==8 && nleft>0) {
+@@ -763,9 +763,9 @@
+ XFree((void *) data);
+
+ /* read the rest of the data (len bytes) */
+- i = XGetWindowProperty(theDisp, rootW, clipAtom, 1L,
+- (long) ((len-4)+3)/4,
+- False, XA_STRING, &actType, &actFormat, &nitems,
++ i = XGetWindowProperty(theDisp, rootW, clipAtom, 1L,
++ (long) ((len-4)+3)/4,
++ False, XA_STRING, &actType, &actFormat, &nitems,
+ &nleft, (unsigned char **) &data);
+
+ if (i==Success) {
+@@ -791,8 +791,8 @@
+ }
+ }
+
+-
+- /* if we're still here, then the prop method was less than successful.
++
++ /* if we're still here, then the prop method was less than successful.
+ use the file method, instead */
+
+ if (!clipfname) makeClipFName();
+@@ -800,7 +800,7 @@
+ fp = fopen(clipfname, "r");
+ if (!fp) {
+ unlink(clipfname);
+- sprintf(str, "Can't read clipboard file '%s'\n\n %s.",
++ sprintf(str, "Can't read clipboard file '%s'\n\n %s.",
+ clipfname, ERRSTR(errno));
+ ErrPopUp(str,"\nBletch!");
+ return (byte *) NULL;
+@@ -877,19 +877,19 @@
+ clipAtom = XInternAtom(theDisp, CLIPPROP, True);
+ if (clipAtom != None) XDeleteProperty(theDisp, rootW, clipAtom);
+ }
+-
+-
++
++
+ if (!forceClipFile) {
+ clipAtom = XInternAtom(theDisp, CLIPPROP, False); /* find or make prop */
+ if (clipAtom != None) {
+ /* try to store the data in the property */
+-
++
+ xerrcode = 0;
+ XChangeProperty(theDisp, rootW, clipAtom, XA_STRING, 8, PropModeReplace,
+ cimg, len);
+ XSync(theDisp, False); /* make it happen *now* */
+ if (!xerrcode) return; /* success! */
+-
++
+ /* failed, use file method */
+ XDeleteProperty(theDisp, rootW, clipAtom);
+ }
+@@ -903,7 +903,7 @@
+ fp = fopen(clipfname, "w");
+ if (!fp) {
+ unlink(clipfname);
+- sprintf(str, "Can't write clipboard file '%s'\n\n %s.",
++ sprintf(str, "Can't write clipboard file '%s'\n\n %s.",
+ clipfname, ERRSTR(errno));
+ ErrPopUp(str,"\nBletch!");
+ return;
+@@ -996,7 +996,7 @@
+ byte *pp;
+
+ nc = 0;
+-
++
+ for (i=y; nc<257 && i<y+h; i++) {
+ pp = pic + i*pwide*3 + x*3;
+ for (j=x; nc<257 && j<x+w; j++, pp+=3) {
+@@ -1022,7 +1022,7 @@
+ */
+
+ int i, j, k, nc, r,g,b;
+- byte *pp, *cp;
++ byte *pp;
+ byte newr[257], newg[257], newb[257];
+
+ if (picType != PIC8) return 0; /* shouldn't happen */
+@@ -1034,7 +1034,7 @@
+ pp = newpic + i*w*3 + cx*3;
+ for (j=cx; j<cx+cw; j++) {
+ r = *pp++; g = *pp++; b = *pp++;
+-
++
+ /* lookup r,g,b in 'pic's colormap and the newcolors colormap */
+ for (k=0; k<nc && (r!=newr[k] || g!=newg[k] || b!=newb[k]); k++);
+ if (k==nc) {
+@@ -1062,11 +1062,11 @@
+ /* now see which of the used colors are new */
+ for (i=0, nc=0; i<256; i++) {
+ if (!coluse[i]) continue;
+-
+- r = newcmap[i*3];
+- g = newcmap[i*3+1];
++
++ r = newcmap[i*3];
++ g = newcmap[i*3+1];
+ b = newcmap[i*3+2];
+-
++
+ /* lookup r,g,b in pic's colormap */
+ for (k=0; k<numcols && (r!=rMap[k] || g!=gMap[k] || b!=bMap[k]);k++);
+ if (k==numcols) { /* it's a new color, alright */
+@@ -1075,7 +1075,7 @@
+ }
+ }
+ }
+-
++
+ return nc;
+ }
+
+@@ -1143,7 +1143,7 @@
+ /* NOTE: SELECTION IS *NOT* GUARANTEED to be within the bounds of 'pic'.
+ It is only guaranteed to *intersect* pic. */
+
+- *xp = selrx; *yp = selry;
++ *xp = selrx; *yp = selry;
+ *wp = selrw; *hp = selrh;
+ }
+
+@@ -1200,7 +1200,7 @@
+ if (lastClickButton==Button1 && (ev->time - lastClickTime) < DBLCLKTIME) {
+ lastClickButton=Button3;
+ if (HaveSelection() && PTINRECT(px, py, selrx, selry, selrw, selrh)) {
+- EnableSelection(0);
++ EnableSelection(0);
+ rv = 1;
+ }
+ else {
+@@ -1225,7 +1225,7 @@
+ else if (ev->button == Button2) { /* do a drag & drop operation */
+ if (HaveSelection() && PTINRECT(px,py,selrx,selry,selrw,selrh)) {
+ /* clip selection rect to pic */
+- EnableSelection(0);
++ EnableSelection(0);
+ CropRect2Rect(&selrx, &selry, &selrw, &selrh, 0, 0, pWIDE, pHIGH);
+
+ if (selrw<1 || selrh<1) rv = 0;
+@@ -1253,8 +1253,8 @@
+ * holding SHIFT constrains selection to be square,
+ * holding CTRL constrains selection to keep original aspect ratio
+ */
+-
+- int i, mex, mey, mpx, mpy, offx,offy;
++
++ int mex, mey, mpx, mpy, offx,offy;
+ int sex, sey, sex2, sey2, sew, seh, sew2, seh2, hs, h2;
+ int istp, isbt, islf, isrt, isvm, ishm;
+ int cnstsq, cnstasp;
+@@ -1272,7 +1272,7 @@
+ sew2 = sew/2;
+ seh2 = seh/2;
+ sex2--; sey2--;
+-
++
+ if (sew>=35 && seh>=35) hs=7;
+ else if (sew>=20 && seh>=20) hs=5;
+ else if (sew>= 9 && seh>= 9) hs=3;
+@@ -1307,7 +1307,7 @@
+
+
+ /* it's definitely in a handle... track 'til released */
+-
++
+ DrawSelection(0);
+ selFilled = 1;
+ selTracking = 1;
+@@ -1366,12 +1366,12 @@
+ else { chwide=1; newwide = (int) (seh*orgaspect); }
+ }
+ }
+-
++
+ if (chwide) {
+ if (islf) { sex = (sex+sew) - newwide; }
+ sew = newwide;
+ }
+-
++
+ if (chhigh) {
+ if (istp) { sey = (sey+seh) - newhigh; }
+ seh = newhigh;
+@@ -1380,7 +1380,7 @@
+
+ if (sew<1) sew=1;
+ if (seh<1) seh=1;
+-
++
+ if (sex!=selrx || sey!=selry || sew!=selrw || seh!=selrh) {
+ DrawSelection(0);
+ selrx = sex; selry = sey; selrw = sew; selrh = seh;
+@@ -1395,14 +1395,14 @@
+ Timer(100);
+ }
+ }
+-
++
+ EnableSelection(0);
+
+ selFilled = 0;
+ selTracking = 0;
+
+ /* only 'enable' the selection if it intersects CPIC */
+- if (selrx < cXOFF+cWIDE && selrx+selrw > cXOFF &&
++ if (selrx < cXOFF+cWIDE && selrx+selrw > cXOFF &&
+ selry < cYOFF+cHIGH && selry+selrh > cYOFF) EnableSelection(1);
+
+ return 1;
+@@ -1422,7 +1422,7 @@
+ *
+ * if 'dragndrop', changes cursor, monitors CTRL status
+ */
+-
++
+ int mpx, mpy, offx, offy;
+ int newsx, newsy, orgsx, orgsy, cnstrain, docopy, lastdocopy;
+ Window rW, cW;
+@@ -1436,9 +1436,9 @@
+
+ CoordE2P(ev->x, ev->y, &mpx, &mpy);
+ offx = mpx - selrx; offy = mpy - selry;
+-
++
+ /* track rectangle until we get a release */
+-
++
+ DrawSelection(0);
+ selFilled = 1;
+ selTracking = 1;
+@@ -1467,7 +1467,7 @@
+ dx = newsx - orgsx; dy = newsy - orgsy;
+ if (abs(dx) > abs(dy)) dy = 0;
+ else if (abs(dy) > abs(dx)) dx = 0;
+-
++
+ newsx = orgsx + dx; newsy = orgsy + dy;
+ }
+
+@@ -1485,7 +1485,7 @@
+ Timer(100);
+ }
+ }
+-
++
+ EnableSelection(0);
+
+ selFilled = 0;
+@@ -1495,7 +1495,7 @@
+
+ /* only do <whatever> if the selection intersects CPIC */
+
+- if (selrx < cXOFF+cWIDE && selrx+selrw > cXOFF &&
++ if (selrx < cXOFF+cWIDE && selrx+selrw > cXOFF &&
+ selry < cYOFF+cHIGH && selry+selrh > cYOFF) {
+
+ EnableSelection(1);
+@@ -1503,10 +1503,10 @@
+ if (dragndrop) {
+ int tmpsx, tmpsy;
+ byte *data;
+-
++
+ tmpsx = selrx; tmpsy = selry;
+ selrx = orgsx; selry = orgsy;
+-
++
+ data = getSelection(); /* copy old data */
+ if (data) {
+ if (!docopy) clearSelectedArea();
+@@ -1531,29 +1531,29 @@
+ int rx,ry,ox,oy,x,y,active, x1, y1, x2, y2, cnstrain;
+ int i, px,py,px2,py2,pw,ph;
+ unsigned int mask;
+-
++
+ /* called on a B1 press in mainW to draw a new rectangular selection.
+ * any former selection has already been removed. holding shift down
+- * while tracking constrains selection to a square
++ * while tracking constrains selection to a square
+ */
+-
++
+ active = 0;
+-
++
+ x1 = ox = ev->x; y1 = oy = ev->y; /* nail down one corner */
+ selrx = selry = selrw = selrh = 0;
+ selTracking = 1;
+-
++
+ while (1) {
+ if (!XQueryPointer(theDisp,mainW,&rW,&cW,&rx,&ry,&x,&y,&mask)) continue;
+ if (!(mask & Button1Mask)) break; /* button released */
+ cnstrain = (mask & ShiftMask);
+-
++
+ if (x!=ox || y!=oy) { /* moved. erase and redraw (?) */
+ x2 = x; y2 = y;
+-
++
+ /* x1,y1,x2,y2 are in epic coords. sort, convert to pic coords,
+ and if changed, erase+redraw */
+-
++
+ CoordE2P(x1, y1, &px, &py);
+ CoordE2P(x2, y2, &px2, &py2);
+ if (px>px2) { i=px; px=px2; px2=i; }
+@@ -1561,17 +1561,17 @@
+ pw = px2-px+1; ph=py2-py+1;
+
+ /* keep px,py,pw,ph inside 'pic' */
+-
++
+ if (px<0) { pw+=px; px=0; }
+ if (py<0) { ph+=py; py=0; }
+ if (px>pWIDE-1) px = pWIDE-1;
+ if (py>pHIGH-1) py = pHIGH-1;
+-
++
+ if (pw<0) pw=0;
+ if (ph<0) ph=0;
+ if (px+pw>pWIDE) pw = pWIDE - px;
+ if (py+ph>pHIGH) ph = pHIGH - py;
+-
++
+ if (cnstrain) { /* make a square at smaller of w,h */
+ if (ph>pw) { if (y2<y1) py += (ph-pw); ph=pw; }
+ else if (pw>ph) { if (x2<x1) px += (pw-ph); pw=ph; }
+@@ -1579,12 +1579,12 @@
+
+ /* put x,y,w,h -> selr{x,y,w,h}
+ if the rectangle has changed, erase old and draw new */
+-
++
+ if (px!=selrx || py!=selry || pw!=selrw || ph!=selrh) {
+ DrawSelection(0);
+ selrx = px; selry = py; selrw = pw; selrh = ph;
+ DrawSelection(1);
+-
++
+ haveSel = active = (pw>0 && ph>0);
+ if (infoUp) SetSelectionString();
+ XFlush(theDisp);
+@@ -1615,7 +1615,7 @@
+ set, pick a new 'color' to invert the selection with */
+
+ int x,y,x1,y1,w,h;
+-
++
+ if (newcol) selColor = (selColor+1) & 0x7;
+
+ /* convert selr{x,y,w,h} into epic coords */
+@@ -1650,7 +1650,7 @@
+ if (y<0 && y+h>eHIGH && selFilled!=1)
+ XDrawLine(theDisp, mainW, theGC, x, eHIGH/2, x+w, eHIGH/2);
+
+-
++
+ if (selFilled==0 || selFilled == 1) {
+ /* one little kludge: if w or h == eWIDE or eHIGH, make it one smaller */
+ if (x+w == eWIDE) w--;
+@@ -1664,17 +1664,17 @@
+ else if (w>=20 && h>=20) { hs=5; h1=4; h2=2; }
+ else if (w>= 9 && h>= 9) { hs=3; h1=2; h2=1; }
+ else hs=h1=h2=0;
+-
++
+ if (hs) {
+ XFillRectangle(theDisp,mainW,theGC,x+1, y+1, (u_int)h1,(u_int)h1);
+ XFillRectangle(theDisp,mainW,theGC,x+w/2-h2,y+1, (u_int)hs,(u_int)h1);
+ XFillRectangle(theDisp,mainW,theGC,x+w-h1, y+1, (u_int)h1,(u_int)h1);
+-
++
+ XFillRectangle(theDisp,mainW,theGC,x+1, y+h/2-h2,
+ (u_int)h1, (u_int)hs);
+ XFillRectangle(theDisp,mainW,theGC,x+w-h1,y+h/2-h2,
+ (u_int)h1, (u_int)hs);
+-
++
+ XFillRectangle(theDisp,mainW,theGC,x+1, y+h-h1,
+ (u_int)h1,(u_int)h1);
+ XFillRectangle(theDisp,mainW,theGC,x+w/2-h2,y+h-h1,
+@@ -1683,7 +1683,7 @@
+ (u_int)h1,(u_int)h1);
+ }
+ }
+-
++
+ if (selFilled==1) {
+ XDrawLine(theDisp, mainW, theGC, x+1, y+1, x+w-1, y+h-1);
+ XDrawLine(theDisp, mainW, theGC, x+1, y+h-1, x+w-1, y+1);
+@@ -1692,8 +1692,8 @@
+ else if (selFilled==2) {
+ XFillRectangle(theDisp, mainW, theGC, x,y,(u_int) w, (u_int) h);
+ }
+-
+-
++
++
+ XSetFunction(theDisp,theGC,GXcopy);
+ XSetPlaneMask(theDisp, theGC, AllPlanes);
+ }
+@@ -1703,7 +1703,7 @@
+ void MoveGrowSelection(dx,dy,dw,dh)
+ int dx,dy,dw,dh;
+ {
+- /* moves and/or grows the selection by the specified amount
++ /* moves and/or grows the selection by the specified amount
+ (in pic coords). keeps the selection entirely within 'pic'.
+ (called by 'CropKey()') */
+
+@@ -1729,7 +1729,7 @@
+ }
+ }
+
+-
++
+ /***********************************/
+ void BlinkSelection(cnt)
+ int cnt;
+diff -ruN xv-3.10a/xvdflt.c xv-3.10a-bugfixes/xvdflt.c
+--- xv-3.10a/xvdflt.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvdflt.c 2004-05-16 18:01:46.000000000 -0700
+@@ -16,12 +16,12 @@
+ #include "bits/xv_rev"
+ #include "bits/xv_ver"
+ #include "bits/xf_left"
+-#include "bits/xf_right"
++/* #include "bits/xf_right" not used */
+ #include "bits/font5x9.h"
+
+
+ #ifndef USEOLDPIC
+-# include "xvdflt.h"
++# include "xvdflt.h"
+ #endif
+
+
+@@ -100,21 +100,21 @@
+ setcolor(pinfo, 252, 0, 0, 0); /* black background for text */
+
+
+- xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
++ xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2+1, 203+1, 252);
+- xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
++ xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2, 203, 250);
+
+ i = xv_ver_width + xv_rev_width + 30;
+
+- xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
++ xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 - (i/2) + xv_ver_width/2+1, 220+1,252);
+- xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
++ xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 + (i/2) - xv_rev_width/2+1, 220+1,252);
+
+- xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
++ xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 - (i/2) + xv_ver_width/2, 220, 250);
+- xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
++ xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 + (i/2) - xv_rev_width/2, 220, 250);
+
+ strcpy(str,"Press <right> mouse button for menu.");
+@@ -169,7 +169,7 @@
+ for (i=k=0; i<DHIGH; i+=xf_left_height) {
+ for (j=0; j<DWIDE; j+=xf_left_width) {
+ k++;
+- if (k&1)
++ if (k&1)
+ xbm2pic((byte *) xf_left_bits, xf_left_width, xf_left_height,
+ dfltpic, DWIDE, DHIGH, j + xf_left_width/2,
+ i + xf_left_height/2, 1);
+@@ -179,29 +179,29 @@
+
+
+
+- xbm2pic((byte *) xvpic_logo_out_bits, xvpic_logo_out_width,
++ xbm2pic((byte *) xvpic_logo_out_bits, xvpic_logo_out_width,
+ xvpic_logo_out_height, dfltpic, DWIDE, DHIGH, DWIDE/2 + 10, 80, 103);
+
+- xbm2pic((byte *) xvpic_logo_top_bits, xvpic_logo_top_width,
++ xbm2pic((byte *) xvpic_logo_top_bits, xvpic_logo_top_width,
+ xvpic_logo_top_height, dfltpic, DWIDE, DHIGH, DWIDE/2 + 10, 80, 100);
+
+- xbm2pic((byte *) xvpic_logo_bot_bits, xvpic_logo_bot_width,
++ xbm2pic((byte *) xvpic_logo_bot_bits, xvpic_logo_bot_width,
+ xvpic_logo_bot_height, dfltpic, DWIDE, DHIGH, DWIDE/2 + 10, 80, 101);
+
+
+
+- xbm2pic((byte *) xv_jhb_bits, xv_jhb_width, xv_jhb_height,
++ xbm2pic((byte *) xv_jhb_bits, xv_jhb_width, xv_jhb_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2, 160, 102);
+
+- xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
++ xbm2pic((byte *) xv_cpyrt_bits, xv_cpyrt_width, xv_cpyrt_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2, 203, 102);
+
+ i = xv_ver_width + xv_rev_width + 30;
+
+- xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
++ xbm2pic((byte *) xv_ver_bits, xv_ver_width, xv_ver_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 - (i/2) + xv_ver_width/2, 220, 102);
+
+- xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
++ xbm2pic((byte *) xv_rev_bits, xv_rev_width, xv_rev_height,
+ dfltpic, DWIDE, DHIGH, DWIDE/2 + (i/2) - xv_rev_width/2, 220, 102);
+
+ strcpy(str,"Press <right> mouse button for menu.");
+@@ -281,7 +281,7 @@
+ }
+ }
+ }
+-}
++}
+
+
+ /*******************************************/
+@@ -300,7 +300,7 @@
+ byte *dfltpic;
+ PICINFO *pinfo;
+ {
+- int i,j,k, dr, dg, db;
++ int i,j, dr, dg, db;
+ byte *pp;
+
+ pp = dfltpic;
+@@ -357,7 +357,7 @@
+
+ for ( ; *str; str++, cx+=6) {
+ i = (byte) *str;
+- if (i >= 32 && i < 128)
++ if (i >= 32 && i < 128)
+ xbm2pic(font5x9[i - 32], 5, 9, pic, pw, ph, cx, cy, col);
+ }
+ }
+diff -ruN xv-3.10a/xvdial.c xv-3.10a-bugfixes/xvdial.c
+--- xv-3.10a/xvdial.c 1995-01-03 13:20:31.000000000 -0800
++++ xv-3.10a-bugfixes/xvdial.c 2004-05-16 18:01:57.000000000 -0700
+@@ -1,11 +1,11 @@
+-/*
++/*
+ * xvdial.c - DIAL handling functions
+ *
+ * callable functions:
+ *
+ * DCreate() - creates a dial
+ * DSetRange() - sets min/max/current values of control
+- * DSetVal() - sets value of control
++ * DSetVal() - sets value of control
+ * DSetActive() - turns dial '.active' on and off
+ * DRedraw() - redraws the dial
+ * DTrack() - called when clicked. Operates control 'til mouseup
+@@ -50,7 +50,7 @@
+
+
+ /***************************************************/
+-void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page,
++void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page,
+ fg, bg, hi, lo, title, units)
+ DIAL *dp;
+ Window parent;
+@@ -60,13 +60,13 @@
+ {
+
+ if (!pixmaps_built) {
+- cw1Pix = XCreatePixmapFromBitmapData(theDisp, parent,
++ cw1Pix = XCreatePixmapFromBitmapData(theDisp, parent,
+ (char *) dial_cw1_bits, PW, PH, fg, bg, dispDEEP);
+- ccw1Pix = XCreatePixmapFromBitmapData(theDisp, parent,
++ ccw1Pix = XCreatePixmapFromBitmapData(theDisp, parent,
+ (char *) dial_ccw1_bits, PW, PH, fg, bg, dispDEEP);
+- cw2Pix = XCreatePixmapFromBitmapData(theDisp, parent,
++ cw2Pix = XCreatePixmapFromBitmapData(theDisp, parent,
+ (char *) dial_cw2_bits, PW, PH, fg, bg, dispDEEP);
+- ccw2Pix = XCreatePixmapFromBitmapData(theDisp, parent,
++ ccw2Pix = XCreatePixmapFromBitmapData(theDisp, parent,
+ (char *) dial_ccw2_bits, PW, PH, fg, bg, dispDEEP);
+ }
+
+@@ -126,14 +126,14 @@
+ if (curv == dp->val) return;
+
+ /* erase old arrow */
+- XSetForeground(theDisp, theGC, dp->bg);
++ XSetForeground(theDisp, theGC, dp->bg);
+ drawArrow(dp);
+
+ dp->val = curv;
+
+ /* draw new arrow and string */
+ XSetForeground(theDisp, theGC, dp->fg);
+- XSetBackground(theDisp, theGC, dp->bg);
++ XSetBackground(theDisp, theGC, dp->bg);
+ drawArrow(dp);
+ drawValStr(dp);
+ if (!dp->active) dimDial(dp);
+@@ -229,18 +229,18 @@
+ case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break;
+ case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break;
+ }
+- if (dp->drawobj != NULL) (dp->drawobj)();
++ if (dp->drawobj != NULL) (dp->drawobj)();
+ Timer(INC1WAIT);
+ lit = 1;
+ }
+
+- else {
++ else {
+ i = computeDialVal(dp, mx, my);
+ DSetVal(dp, i);
+- if (dp->drawobj != NULL) (dp->drawobj)();
++ if (dp->drawobj != NULL) (dp->drawobj)();
+ }
+
+-
++
+ /* loop until mouse is released */
+ while (XQueryPointer(theDisp,dp->win,&rW,&cW,&rx,&ry,&x,&y,&mask)) {
+ if (!(mask & Button1Mask)) break; /* button released */
+@@ -252,7 +252,7 @@
+ DSetVal(dp, i);
+ if (j != dp->val) {
+ /* track whatever dial controls */
+- if (dp->drawobj != NULL) (dp->drawobj)();
++ if (dp->drawobj != NULL) (dp->drawobj)();
+ }
+ }
+
+@@ -266,7 +266,7 @@
+
+ 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+1);
+ break;
+ case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page);
+ break;
+@@ -277,7 +277,7 @@
+ }
+
+ /* track whatever dial controls */
+- if (dp->drawobj != NULL) (dp->drawobj)();
++ if (dp->drawobj != NULL) (dp->drawobj)();
+
+ Timer(INC2WAIT);
+ }
+@@ -305,17 +305,17 @@
+
+ /* returns region * that x,y is in. returns -1 if none */
+
+- for (i=0; i<4; i++)
++ for (i=0; i<4; i++)
+ if (PTINRECT(x,y, dp->bx[i], dp->by[i], 14, 10)) return i;
+
+- if (PTINRECT(x,y, dp->cx - dp->rad, dp->cy - dp->rad,
++ if (PTINRECT(x,y, dp->cx - dp->rad, dp->cy - dp->rad,
+ 2*dp->rad, 2*dp->rad))
+ return INDIAL;
+
+ return -1;
+ }
+
+-
++
+ /***************************************************/
+ static void drawArrow(dp)
+ DIAL *dp;
+@@ -366,10 +366,10 @@
+ XSetForeground(theDisp, theGC, dp->fg);
+ XSetBackground(theDisp, theGC, dp->bg);
+ XSetFont(theDisp, theGC, monofont);
+- XDrawImageString(theDisp, dp->win, theGC,
++ XDrawImageString(theDisp, dp->win, theGC,
+ dp->w/2 - XTextWidth(monofinfo, foo1, (int) strlen(foo1))/2,
+ dp->h-14 - (monofinfo->ascent + monofinfo->descent)/2
+- + monofinfo->ascent,
++ + monofinfo->ascent,
+ foo1, (int) strlen(foo1));
+ XSetFont(theDisp, theGC, mfont);
+ }
+@@ -431,7 +431,7 @@
+ }
+ else if (dx>0) angle = atan((double) dy / (double) dx) * RAD2DEG;
+ else angle = atan((double) -dy / (double) -dx) * RAD2DEG + 180.0;
+-
++
+ /* map angle into range: -90..270, then into to value */
+ if (angle > 270.0) angle -= 360.0;
+ if (angle < -90.0) angle += 360.0;
+diff -ruN xv-3.10a/xvdir.c xv-3.10a-bugfixes/xvdir.c
+--- xv-3.10a/xvdir.c 1995-01-03 13:21:39.000000000 -0800
++++ xv-3.10a-bugfixes/xvdir.c 2005-03-20 18:38:30.000000000 -0800
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvdir.c - Directory changin', file i/o dialog box
+ *
+ * callable functions:
+@@ -50,7 +50,7 @@
+ #define COLWIDE 150 /* width of colMB */
+
+ /* NOTE: make sure these match up with F_* definitions in xv.h */
+-static char *saveColors[] = { "Full Color",
++static char *saveColors[] = { "Full Color",
+ "Greyscale",
+ "B/W Dithered",
+ "Reduced Color" };
+@@ -83,14 +83,16 @@
+ static int dnamcmp PARM((const void *, const void *));
+ static int FNameCdable PARM((void));
+ static void loadCWD PARM((void));
++#ifdef FOO
+ static int cd_able PARM((char *));
++#endif
+ static void scrollToFileName PARM((void));
+ static void setFName PARM((char *));
+ static void showFName PARM((void));
+ static void changeSuffix PARM((void));
+ static int autoComplete PARM((void));
+
+-static byte *handleBWandReduced PARM((byte *, int,int,int, int, int *,
++static byte *handleBWandReduced PARM((byte *, int,int,int, int, int *,
+ byte **, byte **, byte **));
+ static byte *handleNormSel PARM((int *, int *, int *, int *));
+
+@@ -119,7 +121,7 @@
+ static char oldfname[MAXFNLEN+100];
+
+ /* the name of the file actually opened. (the temp file if we are piping) */
+-static char outFName[256];
++static char outFName[256];
+ static int dopipe;
+
+
+@@ -127,48 +129,46 @@
+ void CreateDirW(geom)
+ char *geom;
+ {
+- int w, y;
+-
+ path[0] = '\0';
+
+ xv_getwd(loadpath, sizeof(loadpath));
+ xv_getwd(savepath, sizeof(savepath));
+
+-
++
+ dirW = CreateWindow("","XVdir", geom, DIRWIDE, DIRHIGH, infofg, infobg, 0);
+ if (!dirW) FatalError("couldn't create 'directory' window!");
+
+- LSCreate(&dList, dirW, 10, 5 + 3*(6+LINEHIGH) + 6, LISTWIDE,
+- LINEHIGH*NLINES, NLINES, fnames, numfnames, infofg, infobg,
++ LSCreate(&dList, dirW, 10, 5 + 3*(6+LINEHIGH) + 6, LISTWIDE,
++ LINEHIGH*NLINES, NLINES, fnames, numfnames, infofg, infobg,
+ hicol, locol, RedrawDList, 1, 0);
+
+- dnamW = XCreateSimpleWindow(theDisp, dirW, 80, dList.y + (int) dList.h + 30,
+- (u_int) DNAMWIDE+6, (u_int) LINEHIGH+5,
++ dnamW = XCreateSimpleWindow(theDisp, dirW, 80, dList.y + (int) dList.h + 30,
++ (u_int) DNAMWIDE+6, (u_int) LINEHIGH+5,
+ 1, infofg, infobg);
+ if (!dnamW) FatalError("can't create name window");
+ XSelectInput(theDisp, dnamW, ExposureMask);
+
+
+- CBCreate(&browseCB, dirW, DIRWIDE/2, dList.y + (int) dList.h + 6,
++ CBCreate(&browseCB, dirW, DIRWIDE/2, dList.y + (int) dList.h + 6,
+ "Browse", infofg, infobg, hicol,locol);
+
+- CBCreate(&savenormCB, dirW, 220, dList.y + (int) dList.h + 6,
++ CBCreate(&savenormCB, dirW, 220, dList.y + (int) dList.h + 6,
+ "Normal Size", infofg, infobg,hicol,locol);
+
+- CBCreate(&saveselCB, dirW, 80, dList.y + (int) dList.h + 6,
++ CBCreate(&saveselCB, dirW, 80, dList.y + (int) dList.h + 6,
+ "Selected Area", infofg, infobg,hicol,locol);
+
+
+ /* y-coordinates get filled in when window is opened */
+- BTCreate(&dbut[S_BOK], dirW, 259, 0, 80, BUTTH,
++ BTCreate(&dbut[S_BOK], dirW, 259, 0, 80, BUTTH,
+ "Ok", infofg, infobg,hicol,locol);
+- BTCreate(&dbut[S_BCANC], dirW, 259, 0, 80, BUTTH,
++ BTCreate(&dbut[S_BCANC], dirW, 259, 0, 80, BUTTH,
+ "Cancel", infofg,infobg,hicol,locol);
+- BTCreate(&dbut[S_BRESCAN], dirW, 259, 0, 80, BUTTH,
++ BTCreate(&dbut[S_BRESCAN], dirW, 259, 0, 80, BUTTH,
+ "Rescan", infofg,infobg,hicol,locol);
+- BTCreate(&dbut[S_BOLDSET], dirW, 259, 0, 80, BUTTH,
++ BTCreate(&dbut[S_BOLDSET], dirW, 259, 0, 80, BUTTH,
+ "Prev Set", infofg,infobg,hicol,locol);
+- BTCreate(&dbut[S_BOLDNAM], dirW, 259, 0, 80, BUTTH,
++ BTCreate(&dbut[S_BOLDNAM], dirW, 259, 0, 80, BUTTH,
+ "Prev Name", infofg,infobg,hicol,locol);
+
+ SetDirFName("");
+@@ -180,33 +180,33 @@
+ * create MBUTTs *after* calling XMapSubWindows() to keep popup unmapped
+ */
+
+- MBCreate(&dirMB, dirW, 50, dList.y -(LINEHIGH+6),
++ MBCreate(&dirMB, dirW, 50, dList.y -(LINEHIGH+6),
+ (u_int) DDWIDE, (u_int) LINEHIGH, NULL, NULL, 0,
+ infofg,infobg,hicol,locol);
+
+- MBCreate(&fmtMB, dirW, DIRWIDE-FMTWIDE-10, 5,
+- (u_int) FMTWIDE, (u_int) LINEHIGH, NULL, saveFormats, F_MAXFMTS,
++ MBCreate(&fmtMB, dirW, DIRWIDE-FMTWIDE-10, 5,
++ (u_int) FMTWIDE, (u_int) LINEHIGH, NULL, saveFormats, F_MAXFMTS,
+ infofg,infobg,hicol,locol);
+ fmtMB.hascheck = 1;
+ MBSelect(&fmtMB, 0);
+
+- MBCreate(&colMB, dirW, DIRWIDE-COLWIDE-10, 5+LINEHIGH+6,
+- (u_int) COLWIDE, (u_int) LINEHIGH, NULL, saveColors, F_MAXCOLORS,
++ MBCreate(&colMB, dirW, DIRWIDE-COLWIDE-10, 5+LINEHIGH+6,
++ (u_int) COLWIDE, (u_int) LINEHIGH, NULL, saveColors, F_MAXCOLORS,
+ infofg,infobg,hicol,locol);
+ colMB.hascheck = 1;
+ MBSelect(&colMB, 0);
+
+
+- d_loadPix = XCreatePixmapFromBitmapData(theDisp, dirW,
+- (char *) d_load_bits, d_load_width, d_load_height,
++ d_loadPix = XCreatePixmapFromBitmapData(theDisp, dirW,
++ (char *) d_load_bits, d_load_width, d_load_height,
+ infofg, infobg, dispDEEP);
+
+- d_savePix = XCreatePixmapFromBitmapData(theDisp, dirW,
+- (char *) d_save_bits, d_save_width, d_save_height,
++ d_savePix = XCreatePixmapFromBitmapData(theDisp, dirW,
++ (char *) d_save_bits, d_save_width, d_save_height,
+ infofg, infobg, dispDEEP);
+
+ }
+-
++
+
+ /***************************************************/
+ void DirBox(mode)
+@@ -261,7 +261,7 @@
+
+ BTSetActive(&dbut[S_BOLDSET], haveoldinfo);
+ BTSetActive(&dbut[S_BOLDNAM], haveoldinfo);
+-
++
+ CBSetActive(&saveselCB, HaveSelection());
+
+ MBSetActive(&fmtMB, 1);
+@@ -303,15 +303,15 @@
+ if (gap>16) {
+ gap = 16;
+ top = dList.y + (dList.h - (nbts*BUTTH) - (ngaps*gap))/2;
+-
++
+ for (i=0; i<nbts; i++) dbut[i].y = top + i*(BUTTH+gap);
+ }
+ else {
+- for (i=0; i<nbts; i++)
++ for (i=0; i<nbts; i++)
+ dbut[i].y = dList.y + ((dList.h-BUTTH)*i) / ngaps;
+ }
+ }
+-
++
+
+
+ /***************************************************/
+@@ -320,23 +320,22 @@
+ {
+ int i, ypos, txtw;
+ char foo[30], *str;
+- XRectangle xr;
+
+ if (dList.nstr==1) strcpy(foo,"1 file");
+ else sprintf(foo,"%d files",dList.nstr);
+
+ ypos = dList.y + dList.h + 8 + ASCENT;
+ XSetForeground(theDisp, theGC, infobg);
+- XFillRectangle(theDisp, dirW, theGC, 10, ypos-ASCENT,
++ XFillRectangle(theDisp, dirW, theGC, 10, ypos-ASCENT,
+ (u_int) DIRWIDE, (u_int) CHIGH);
+ XSetForeground(theDisp, theGC, infofg);
+ DrawString(dirW, 10, ypos, foo);
+
+
+- if (dirUp == BLOAD) str = "Load file:";
++ if (dirUp == BLOAD) str = "Load file:";
+ else str = "Save file:";
+ DrawString(dirW, 10, dList.y + (int) dList.h + 30 + 4 + ASCENT, str);
+-
++
+ /* draw dividing line */
+ XSetForeground(theDisp, theGC, infofg);
+ XDrawLine(theDisp, dirW, theGC, 0, dirMB.y-6, DIRWIDE, dirMB.y-6);
+@@ -346,11 +345,11 @@
+ XSetForeground(theDisp, theGC, hicol);
+ }
+ XDrawLine(theDisp, dirW, theGC, 0, dirMB.y-4, DIRWIDE, dirMB.y-4);
+-
+-
+-
++
++
++
+ for (i=0; i<(savemode ? S_NBUTTS : S_LOAD_NBUTTS); i++) BTRedraw(&dbut[i]);
+-
++
+ MBRedraw(&dirMB);
+ MBRedraw(&fmtMB);
+ MBRedraw(&colMB);
+@@ -362,7 +361,7 @@
+ if (StringWidth(COLLABEL) > txtw) txtw = StringWidth(COLLABEL);
+
+ if (!savemode) {
+- XCopyArea(theDisp, d_loadPix, dirW, theGC, 0,0,d_load_width,d_load_height,
++ XCopyArea(theDisp, d_loadPix, dirW, theGC, 0,0,d_load_width,d_load_height,
+ 10, (dirMB.y-6)/2 - d_load_height/2);
+
+ XSetFillStyle(theDisp, theGC, FillStippled);
+@@ -399,18 +398,18 @@
+ i = v = 0;
+ if (MBClick(&fmtMB, x,y) && (v=MBTrack(&fmtMB))>=0) i=1;
+ else if (MBClick(&colMB, x,y) && (v=MBTrack(&colMB))>=0) i=2;
+-
++
+ if (i) { /* changed one of them */
+ if (i==1) SetDirSaveMode(F_FORMAT, v);
+ else SetDirSaveMode(F_COLORS, v);
+ changeSuffix();
+ }
+ }
+-
+-
++
++
+ if (!savemode) { /* LOAD */
+ if (CBClick(&browseCB,x,y)) CBTrack(&browseCB);
+- }
++ }
+ else { /* SAVE */
+ if (CBClick(&savenormCB,x,y)) CBTrack(&savenormCB);
+ else if (CBClick(&saveselCB,x,y)) CBTrack(&saveselCB);
+@@ -482,7 +481,7 @@
+ }
+
+ if (oldnumnames != numnames) { /* added some */
+- if (numnames>0) BTSetActive(&but[BDELETE],1);
++ if (numnames>0) BTSetActive(&but[BDELETE],1);
+ windowMB.dim[WMB_TEXTVIEW] = (numnames==0);
+
+ LSNewData(&nList, dispnames, numnames);
+@@ -564,7 +563,7 @@
+ * a special concealed device setup to provide a list of available
+ * disks).
+ */
+- if ( ((ndirs-sel) == 2) && (strlen(tmppath) > 1) )
++ if ( ((ndirs-sel) == 2) && (strlen(tmppath) > 1) )
+ strcat ( tmppath, "/000000" ); /* add root dir for device */
+ else if ((ndirs-sel) == 1 ) {
+ strcpy ( tmppath, "/XV_Root_Device/000000" ); /* fake top level */
+@@ -602,7 +601,7 @@
+ xv_getwd(path, sizeof(path));
+ LoadCurrentDirectory();
+ }
+-
++
+
+
+ /***************************************************/
+@@ -621,7 +620,7 @@
+ #else
+ struct dirent *dp;
+ #endif
+-
++
+
+ /* get rid of previous file names */
+ for (i=0; i<numfnames; i++) free(fnames[i]);
+@@ -680,12 +679,12 @@
+ strncpy(dirMBlist[j], dirs[i], stlen);
+ dirMBlist[j][stlen] = '\0';
+ }
+-
++
+
+ lastdir = dirs[ndirs-1];
+ dirMB.list = dirMBlist;
+ dirMB.nlist = ndirs;
+- XClearArea(theDisp, dirMB.win, dirMB.x, dirMB.y,
++ XClearArea(theDisp, dirMB.win, dirMB.x, dirMB.y,
+ (u_int) dirMB.w+3, (u_int) dirMB.h+3, False);
+ i = StringWidth(dirMBlist[0]) + 10;
+ dirMB.x = dirMB.x + dirMB.w/2 - i/2;
+@@ -704,8 +703,8 @@
+
+ i=0;
+ while ( (dp = readdir(dirp)) != NULL) {
+- if (strcmp(dp->d_name, ".")==0 ||
+- (strcmp(dp->d_name, "..")==0 &&
++ if (strcmp(dp->d_name, ".")==0 ||
++ (strcmp(dp->d_name, "..")==0 &&
+ (strcmp(path,"/")==0 || strcmp(path,"//")==0)) ||
+ strcmp(dp->d_name, THUMBDIR)==0) {
+ /* skip over '.' and '..' and THUMBDIR */
+@@ -733,7 +732,7 @@
+ /* For VMS we will default all files EXCEPT directories to avoid
+ the high cost of the VAX C implementation of the stat function.
+ Suggested by Kevin Oberman (OBERMAN@icdc.llnl.gov) */
+-
++
+ if (xv_strstr (fnames[i]+1, ".DIR") != NULL) fnames[i][0] = C_DIR;
+ if (xv_strstr (fnames[i]+1, ".EXE") != NULL) fnames[i][0] = C_EXE;
+ if (xv_strstr (fnames[i]+1, ".OBJ") != NULL) fnames[i][0] = C_BLK;
+@@ -784,11 +783,13 @@
+
+
+ /***************************************************/
++#ifdef FOO
+ static int cd_able(str)
+ char *str;
+ {
+ return ((str[0] == C_DIR || str[0] == C_LNK));
+ }
++#endif /* FOO */
+
+
+ /***************************************************/
+@@ -829,7 +830,7 @@
+ int len;
+
+ len = strlen(filename);
+-
++
+ if (c>=' ' && c<'\177') { /* printable characters */
+ /* note: only allow 'piped commands' in savemode... */
+
+@@ -918,19 +919,19 @@
+ {
+ /* called to 'auto complete' a filename being entered. If the name that
+ has been entered so far is anything but a simple filename (ie, has
+- spaces, pipe char, '/', etc) fails. If it is a simple filename,
++ spaces, pipe char, '/', etc) fails. If it is a simple filename,
+ looks through the name list to find something that matches what's already
+ been typed. If nothing matches, it fails. If more than one thing
+ matches, it sets the name to the longest string that the multiple
+- matches have in common, and succeeds (and beeps).
++ matches have in common, and succeeds (and beeps).
+ If only one matches, sets the string to the match and succeeds.
+-
++
+ returns zero on failure, non-zero on success */
+-
++
+ int i, firstmatch, slen, nummatch, cnt;
+
+ /* is filename a simple filename? */
+- if (strlen(filename)==0 ||
++ if (strlen(filename)==0 ||
+ ISPIPE(filename[0]) ||
+ index(filename, '/') ||
+ filename[0]=='~' ) return 0;
+@@ -946,7 +947,7 @@
+ firstmatch = i;
+
+ /* count # of matches */
+- for (i=firstmatch, nummatch=0;
++ for (i=firstmatch, nummatch=0;
+ i<dList.nstr && strncmp(filename, dList.str[i]+1, (size_t) slen)==0;
+ i++, nummatch++);
+
+@@ -960,14 +961,14 @@
+ while (dList.str[firstmatch][slen+1]!='\0') {
+ filename[slen] = dList.str[firstmatch][slen+1];
+ slen++; filename[slen] = '\0';
+-
++
+ for (i=firstmatch, cnt=0;
+ i<dList.nstr && strncmp(filename, dList.str[i]+1, (size_t) slen)==0;
+ i++, cnt++);
+
+ if (cnt != nummatch) { slen--; filename[slen] = '\0'; break; }
+- }
+-
++ }
++
+ XBell(theDisp, 0);
+
+ return 1;
+@@ -1003,7 +1004,7 @@
+ i = pos - (NLINES/2);
+ SCSetVal(&dList.scrl, i);
+ }
+-
++
+
+ /***************************************************/
+ void RedrawDNamW()
+@@ -1012,7 +1013,7 @@
+
+ /* draw substring filename[stPos:enPos] and cursor */
+
+- Draw3dRect(dnamW, 0, 0, (u_int) DNAMWIDE+5, (u_int) LINEHIGH+4, R3D_IN, 2,
++ Draw3dRect(dnamW, 0, 0, (u_int) DNAMWIDE+5, (u_int) LINEHIGH+4, R3D_IN, 2,
+ hicol, locol, infobg);
+
+ XSetForeground(theDisp, theGC, infofg);
+@@ -1023,7 +1024,7 @@
+ XDrawLine(theDisp, dnamW, theGC, 2,0,2,LINEHIGH+5);
+ }
+
+- if ((size_t) enPos < strlen(filename)) {
++ if ((size_t) enPos < strlen(filename)) {
+ /* draw a "there's more over here" doowah */
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+5,0,DNAMWIDE+5,LINEHIGH+5);
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+4,0,DNAMWIDE+4,LINEHIGH+5);
+@@ -1057,7 +1058,7 @@
+ fmt = MBWhich(&fmtMB);
+ col = MBWhich(&colMB);
+
+- if (fmt<0 || col<0)
++ if (fmt<0 || col<0)
+ FatalError("xv: no 'checked' format or color. shouldn't happen!\n");
+
+
+@@ -1068,19 +1069,19 @@
+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
+ return -1;
+ }
+-
++
+ for (i=0; i<numnames; i++) {
+ if ((i&0x3f)==0) WaitCursor();
+ if (namelist[i][0] != '/') fprintf(fp, "%s/%s\n", initdir, namelist[i]);
+ else fprintf(fp, "%s\n", namelist[i]);
+ }
+-
++
+ i = (ferror(fp)) ? 1 : 0;
+ if (CloseOutFile(fp, fullname, i) == 0) {
+ DirBox(0);
+ XVCreatedFile(fullname);
+ }
+-
++
+ SetCursors(-1);
+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
+ return i;
+@@ -1147,34 +1148,41 @@
+ rv = WritePBM (fp, thepic, ptype, w, h, rp,gp,bp, nc,col,1,picComments);
+ break;
+
+- case F_PBMASCII:
++ case F_PBMASCII:
+ rv = WritePBM (fp, thepic, ptype, w, h, rp,gp,bp, nc,col,0,picComments);
+ break;
+
+ case F_XBM:
+- rv = WriteXBM (fp, thepic, w, h, rp, gp, bp, fullname); break;
++ rv = WriteXBM (fp, thepic, w, h, rp, gp, bp, fullname);
++ break;
+
+ case F_SUNRAS:
+- rv = WriteSunRas(fp, thepic, ptype, w, h, rp, gp, bp, nc, col,0); break;
++ rv = WriteSunRas(fp, thepic, ptype, w, h, rp, gp, bp, nc, col,0);
++ break;
+
+ case F_BMP:
+- rv = WriteBMP (fp, thepic, ptype, w, h, rp, gp, bp, nc, col); break;
++ rv = WriteBMP (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;
+-
++ rv = WriteIRIS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
++ break;
++
+ case F_TARGA:
+- rv = WriteTarga (fp, thepic, ptype, w, h, rp, gp, bp, nc, col); break;
+-
++ rv = WriteTarga (fp, thepic, ptype, w, h, rp, gp, bp, nc, col);
++ break;
++
+ case F_XPM:
+- rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
+- fullname, picComments);
++ rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
++ fullname, picComments);
++ break;
++
+ case F_FITS:
+- rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
+- picComments);
++ rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
++ picComments);
+ break;
+ }
+-
++
+
+ if (CloseOutFile(fp, fullname, rv) == 0) {
+ DirBox(0);
+@@ -1184,12 +1192,12 @@
+ }
+ }
+
+-
++
+ if (pfree) free(thepic);
+-
++
+ SetCursors(-1);
+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
+-
++
+ return rv;
+ }
+
+@@ -1200,6 +1208,7 @@
+ char *st;
+ {
+ strncpy(deffname, st, (size_t) MAXFNLEN-1);
++ deffname[MAXFNLEN-1] = '\0';
+ setFName(st);
+ }
+
+@@ -1212,7 +1221,7 @@
+ filename[MAXFNLEN-1] = '\0'; /* make sure it's terminated */
+ curPos = strlen(st);
+ stPos = 0; enPos = curPos;
+-
++
+ showFName();
+ }
+
+@@ -1221,17 +1230,17 @@
+ static void showFName()
+ {
+ int len;
+-
++
+ len = strlen(filename);
+-
++
+ if (curPos<stPos) stPos = curPos;
+ if (curPos>enPos) enPos = curPos;
+-
++
+ if (stPos>len) stPos = (len>0) ? len-1 : 0;
+ if (enPos>len) enPos = (len>0) ? len-1 : 0;
+-
++
+ /* while substring is shorter than window, inc enPos */
+-
++
+ while (XTextWidth(mfinfo, &filename[stPos], enPos-stPos) < DNAMWIDE
+ && enPos<len) { enPos++; }
+
+@@ -1244,7 +1253,7 @@
+ }
+
+
+- if (ctrlColor) XClearArea(theDisp, dnamW, 2,2, (u_int) DNAMWIDE+5-3,
++ if (ctrlColor) XClearArea(theDisp, dnamW, 2,2, (u_int) DNAMWIDE+5-3,
+ (u_int) LINEHIGH+4-3, False);
+ else XClearWindow(theDisp, dnamW);
+
+@@ -1270,7 +1279,7 @@
+ else {
+ strcpy(globname, filename);
+ if (globname[0] == '~') Globify(globname);
+-
++
+ if (globname[0] != '/') sprintf(fullname, "%s%s", path, globname);
+ else strcpy(fullname, globname);
+ }
+@@ -1294,10 +1303,10 @@
+ MBRedraw(&fmtMB);
+ }
+ }
+-
++
+ if (bnum>=0) MBSelect(&colMB, bnum);
+ }
+-
++
+
+ else if (group == F_FORMAT) {
+ MBSelect(&fmtMB, bnum);
+@@ -1322,10 +1331,10 @@
+ colMB.dim[F_GREYSCALE] = 0;
+ colMB.dim[F_BWDITHER] = 0;
+ colMB.dim[F_REDUCED] = (picType==PIC8) ? 0 : 1;
+- if (picType!=PIC8 && MBWhich(&colMB)==F_REDUCED)
++ if (picType!=PIC8 && MBWhich(&colMB)==F_REDUCED)
+ MBSelect(&colMB, F_FULLCOLOR);
+ }
+-
++
+ if (MBWhich(&fmtMB) == F_FILELIST) {
+ MBSetActive(&colMB, 0);
+ CBSetActive(&savenormCB, 0);
+@@ -1337,12 +1346,12 @@
+ }
+ }
+
+-
++
+
+ /***************************************/
+ static void changeSuffix()
+ {
+- /* see if there's a common suffix at the end of the filename.
++ /* see if there's a common suffix at the end of the filename.
+ if there is, remember what case it was (all caps or all lower), lop
+ it off, and replace it with a new appropriate suffix, in the
+ same case */
+@@ -1356,7 +1365,7 @@
+ suffix++; /* point to first letter of the suffix */
+
+ /* check for all-caposity */
+- for (sp = suffix, allcaps=1; *sp; sp++)
++ for (sp = suffix, allcaps=1; *sp; sp++)
+ if (islower(*sp)) allcaps = 0;
+
+ /* copy the suffix into an all-lower-case buffer */
+@@ -1401,7 +1410,7 @@
+ case F_GIF: strcpy(lowsuf,"gif"); break;
+ case F_PM: strcpy(lowsuf,"pm"); break;
+ case F_PBMRAW:
+- case F_PBMASCII: if (col == F_FULLCOLOR || col == F_REDUCED)
++ case F_PBMASCII: if (col == F_FULLCOLOR || col == F_REDUCED)
+ strcpy(lowsuf,"ppm");
+ else if (col == F_GREYSCALE) strcpy(lowsuf,"pgm");
+ else if (col == F_BWDITHER) strcpy(lowsuf,"pbm");
+@@ -1426,10 +1435,10 @@
+ }
+
+ if (allcaps) { /* upper-caseify lowsuf */
+- for (sp=lowsuf; *sp; sp++)
++ for (sp=lowsuf; *sp; sp++)
+ *sp = (islower(*sp)) ? toupper(*sp) : *sp;
+ }
+-
++
+ /* one other case: if the original suffix started with a single
+ capital letter, make the new suffix start with a single cap */
+ if (isupper(suffix[0])) lowsuf[0] = toupper(lowsuf[0]);
+@@ -1439,7 +1448,7 @@
+ }
+
+ }
+-
++
+
+ /***************************************************/
+ int DirCheckCD()
+@@ -1462,7 +1471,7 @@
+ static int FNameCdable()
+ {
+ /* returns '1' if filename is a directory, and goes there */
+-
++
+ char newpath[1024];
+ struct stat st;
+ int retval = 0;
+@@ -1518,7 +1527,7 @@
+ retval = 1;
+ }
+ }
+-
++
+ return retval;
+ }
+
+@@ -1550,7 +1559,7 @@
+
+ if (*uname=='\0') { /* no name. substitute ~ with $HOME */
+ char *homedir;
+- homedir = (char *) getenv("HOME");
++ homedir = (char *) getenv("HOME");
+ if (homedir == NULL) homedir = ".";
+ strcpy(tmp,homedir);
+ strcat(tmp,sp);
+@@ -1579,7 +1588,7 @@
+ /* opens file for output. does various error handling bits. Returns
+ an open file pointer if success, NULL if failure */
+
+- FILE *fp;
++ FILE *fp = NULL;
+ struct stat st;
+
+ if (!filename || filename[0] == '\0') return NULL;
+@@ -1596,23 +1605,34 @@
+ #else
+ strcpy(outFName, "[]xvXXXXXX.lis");
+ #endif
++#ifdef USE_MKSTEMP
++ fp = fdopen(mkstemp(outFName), "w");
++#else
+ mktemp(outFName);
++#endif
+ dopipe = 1;
+ }
+
+
+- /* see if file exists (ie, we're overwriting) */
+- if (stat(outFName, &st)==0) { /* stat succeeded, file must exist */
+- static char *foo[] = { "\nOk", "\033Cancel" };
+- char str[512];
++#ifdef USE_MKSTEMP /* (prior) nonexistence of file is already guaranteed by */
++ if (!dopipe) /* mkstemp(), but now mkstemp() itself has created it */
++#endif
++ /* see if file exists (i.e., we're overwriting) */
++ if (stat(outFName, &st)==0) { /* stat succeeded, file must exist */
++ static char *foo[] = { "\nOk", "\033Cancel" };
++ char str[512];
+
+- sprintf(str,"Overwrite existing file '%s'?", outFName);
+- if (PopUp(str, foo, 2)) return NULL;
+- }
+-
++ sprintf(str,"Overwrite existing file '%s'?", outFName);
++ if (PopUp(str, foo, 2)) return NULL;
++ }
++
++
++ /* Open file (if not already open via mkstemp()) */
++#ifdef USE_MKSTEMP
++ if (!dopipe)
++#endif
++ fp = fopen(outFName, "w");
+
+- /* Open file */
+- fp = fopen(outFName, "w");
+ if (!fp) {
+ char str[512];
+ sprintf(str,"Can't write file '%s'\n\n %s.",outFName, ERRSTR(errno));
+@@ -1622,7 +1642,7 @@
+
+ return fp;
+ }
+-
++
+
+ /***************************************/
+ int CloseOutFile(fp, filename, failed)
+@@ -1642,9 +1662,8 @@
+ return 1;
+ }
+
+-
++
+ if (fclose(fp) == EOF) {
+- static char *foo[] = { "\nWeird!" };
+ char str[512];
+ sprintf(str,"Can't close file '%s'\n\n %s.",outFName, ERRSTR(errno));
+ ErrPopUp(str, "\nWeird!");
+@@ -1666,7 +1685,7 @@
+ }
+
+ SetISTR(ISTR_INFO,"Successfully wrote '%s'%s", outFName, buf);
+-
++
+ if (dopipe) {
+ char cmd[512], str[1024];
+ int i;
+@@ -1709,7 +1728,7 @@
+ return 0;
+ }
+
+-
++
+
+
+ static byte rBW[2], gBW[2], bBW[2];
+@@ -1732,7 +1751,7 @@
+ bwpic = (byte *) NULL;
+ *nc = numcols; *rpp = rMap; *gpp = gMap; *bpp = bMap;
+
+- /* quick check: if we're saving a 24-bit image, then none of this
++ /* quick check: if we're saving a 24-bit image, then none of this
+ complicated 'reduced'/dithered/smoothed business comes into play.
+ 'reduced' is disabled, for semi-obvious reasons, in 24-bit mode,
+ as is 'dithered'. If 'smoothed', and we're saving at current
+@@ -1744,32 +1763,32 @@
+ if we're saving B/W DITHERED, and deal accordingly */
+
+
+- if (ptype == PIC24) {
++ if (ptype == PIC24) {
+ if (color != F_BWDITHER) return NULL;
+ else { /* generate a bw-dithered version */
+ byte *p24, *thepic;
+-
++
+ thepic = pic;
+ p24 = GammifyPic24(thepic, pw, ph);
+ if (p24) thepic = p24;
+-
++
+ /* generate a FSDithered 1-byte per pixel image */
+ bwpic = FSDither(thepic, PIC24, pw, ph, NULL,NULL,NULL, 0, 1);
+ if (!bwpic) FatalError("unable to malloc dithered picture (DoSave)");
+-
++
+ if (p24) free(p24); /* won't need it any more */
+-
++
+ /* build a BW colormap */
+ rBW[0] = gBW[0] = bBW[0] = 0;
+ rBW[1] = gBW[1] = bBW[1] = 255;
+-
++
+ *rpp = rBW; *gpp = gBW; *bpp = bBW;
+ *nc = 2;
+-
++
+ return bwpic;
+ }
+ }
+-
++
+
+
+ /* ptype == PIC8 ... */
+@@ -1777,7 +1796,7 @@
+ *nc = numcols; *rpp = rMap; *gpp = gMap; *bpp = bMap;
+ if (color==F_REDUCED) { *rpp = rdisp; *gpp = gdisp; *bpp = bdisp; }
+
+- /* if DITHER or SMOOTH, and color==FULLCOLOR or GREY,
++ /* if DITHER or SMOOTH, and color==FULLCOLOR or GREY,
+ make color=REDUCED, so it will be written with the correct colortable */
+
+ if ((epicMode == EM_DITH || epicMode == EM_SMOOTH) && color != F_REDUCED) {
+@@ -1789,7 +1808,7 @@
+ *rpp = gray; *gpp = gray; *bpp = gray;
+ }
+ }
+-
++
+
+
+
+@@ -1823,8 +1842,8 @@
+ * and whether or not it should be freed when we're done with it. The 'pic'
+ * returned is the desired portion of 'cpic' or 'epic' if there is a
+ * selection, and the saveselCB is enabled, or alternately, it's the
+- * whole cpic or epic.
+- *
++ * whole cpic or epic.
++ *
+ * if selection does not intersect cpic/epic, returns cpic/epic
+ * NEVER RETURNS NULL
+ */
+@@ -1837,7 +1856,7 @@
+ if (savenormCB.val) { thepic = cpic; pw = cWIDE; ph = cHIGH; }
+ else { thepic = epic; pw = eWIDE; ph = eHIGH; }
+
+- *pwide = pw; *phigh = ph;
++ *pwide = pw; *phigh = ph;
+
+
+ if (saveselCB.active && saveselCB.val && HaveSelection()) {
+@@ -1862,7 +1881,7 @@
+ CoordP2E(x2,y2, &x2, &y2);
+ slx = x1; sly = y1; slw = x2-x1; slh = y2-y1;
+ CropRect2Rect(&slx, &sly, &slw, &slh, 0,0,pw,ph);
+-
++
+ if (slw<1 || slh<1) { slx = sly = 0; slw=pw; slh=ph; }
+
+ if (slx!=0 || sly!=0 || slw!=pw || slh!=ph) {
+@@ -1871,7 +1890,7 @@
+ }
+ }
+
+- *pwide = slw; *phigh = slh;
++ *pwide = slw; *phigh = slh;
+ }
+
+ return thepic;
+@@ -1884,11 +1903,11 @@
+ byte **rmapP, **gmapP, **bmapP;
+ {
+ /* handles the whole ugly mess of the various save options.
+- * returns an image, of type 'ptypeP', size 'wP,hP'.
++ * returns an image, of type 'ptypeP', size 'wP,hP'.
+ * if (*ptypeP == PIC8), also returns numcols 'ncP', and the r,g,b map
+ * to use rmapP, gmapP, bmapP.
+ *
+- * if freeP is set, image can safely be freed after it is saved
++ * if freeP is set, image can safely be freed after it is saved
+ */
+
+ byte *pic1, *pic2;
+@@ -1896,9 +1915,9 @@
+
+ pic1 = handleNormSel(&ptype, &w, &h, &pfree);
+
+- pic2 = handleBWandReduced(pic1, ptype, w,h, MBWhich(&colMB),
++ pic2 = handleBWandReduced(pic1, ptype, w,h, MBWhich(&colMB),
+ ncP, rmapP, gmapP, bmapP);
+- if (pic2) {
++ if (pic2) {
+ if (pfree) free(pic1);
+ pic1 = pic2;
+ pfree = 1;
+@@ -1906,7 +1925,7 @@
+ }
+
+
+- if (ptype == PIC24) {
++ if (ptype == PIC24) {
+ pic2 = GammifyPic24(pic1, w, h);
+ if (pic2) {
+ if (pfree) free(pic1);
+@@ -1920,7 +1939,7 @@
+ return pic1;
+ }
+
+-
++
+ /***************************************/
+ void GetSaveSize(wP, hP)
+ int *wP, *hP;
+@@ -1947,7 +1966,7 @@
+ CoordP2E(x2,y2, &x2, &y2);
+ slx = x1; sly = y1; slw = x2-x1; slh = y2-y1;
+ CropRect2Rect(&slx, &sly, &slw, &slh, 0,0,eWIDE,eHIGH);
+-
++
+ if (slw<1 || slh<1) { slx = sly = 0; slw=eWIDE; slh=eHIGH; }
+ }
+ }
+@@ -1982,7 +2001,7 @@
+
+ if (stat(namelist[curname], &origStat)==0) {
+ haveStat = 1;
+- if (DEBUG) fprintf(stderr," origStat.size=%ld, origStat.mtime=%d\n",
++ if (DEBUG) fprintf(stderr," origStat.size=%ld, origStat.mtime=%ld\n",
+ origStat.st_size, origStat.st_mtime);
+ }
+ }
+@@ -1993,7 +2012,7 @@
+ int CheckPoll(del)
+ int del;
+ {
+- /* returns '1' if the file has been modified, and either
++ /* returns '1' if the file has been modified, and either
+ A) the file has stabilized (st = lastStat), or
+ B) 'del' seconds have gone by since the file last changed size
+ */
+@@ -2007,14 +2026,14 @@
+ (strcmp(namelist[curname], STDINSTR)!=0)) {
+
+ if (stat(namelist[curname], &st)==0) {
+- if (DEBUG) fprintf(stderr," st.size=%ld, st.mtime=%d\n",
++ if (DEBUG) fprintf(stderr," st.size=%ld, st.mtime=%ld\n",
+ st.st_size, st.st_mtime);
+
+ if ((st.st_size == origStat.st_size) &&
+ (st.st_mtime == origStat.st_mtime)) return 0; /* no change */
+
+ /* if it's changed since last looked ... */
+- if (!haveLastStat ||
++ if (!haveLastStat ||
+ st.st_size != lastStat.st_size ||
+ st.st_mtime != lastStat.st_mtime) {
+ xvbcopy((char *) &st, (char *) &lastStat, sizeof(struct stat));
+@@ -2031,7 +2050,7 @@
+ }
+ }
+ }
+-
++
+ return 0;
+ }
+
+@@ -2042,14 +2061,13 @@
+ {
+ /* called when file 'name' has been deleted. If any of the browsers
+ were showing the directory that the file was in, does a rescan() */
+-
+- int i;
++
+ char buf[MAXPATHLEN + 2], *tmp;
+
+ strcpy(buf, name);
+ tmp = BaseName(buf);
+ *tmp = '\0'; /* truncate after last '/' */
+-
++
+ if (strcmp(path, buf)==0) LoadCurrentDirectory();
+ }
+
+diff -ruN xv-3.10a/xvevent.c xv-3.10a-bugfixes/xvevent.c
+--- xv-3.10a/xvevent.c 1995-01-23 15:20:24.000000000 -0800
++++ xv-3.10a-bugfixes/xvevent.c 2004-05-16 18:02:03.000000000 -0700
+@@ -101,15 +101,15 @@
+ while (!done) {
+
+ if (waitsec > -1 && 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)
++ /* 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);
+ waiting = 1;
+ }
+
+
+- /* if there's an XEvent pending *or* we're not doing anything
++ /* 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) {
+ XNextEvent(theDisp, &event);
+@@ -187,7 +187,7 @@
+
+ #ifdef VMS
+ static int borders_sized = 0;
+-
++
+ if (!borders_sized && !useroot && exp_event->window == mainW) {
+ /*
+ * Initial expose of main window, find the size of the ancestor
+@@ -198,13 +198,13 @@
+ int status, count, mwid, mhgt, x, y, w, h, b, d, mbrd;
+ Window root, parent, *children, crw = exp_event->window;
+ borders_sized = 1;
+- status = XGetGeometry(theDisp, crw,
++ status = XGetGeometry(theDisp, crw,
+ &root, &x, &y, &mwid, &mhgt, &mbrd, &d);
+-
++
+ for ( parent = crw, w=mwid, h=mhgt;
+ status && (parent != root) && (parent != vrootW); ) {
+ crw = parent;
+- status = XQueryTree ( theDisp, crw, &root, &parent,
++ status = XQueryTree ( theDisp, crw, &root, &parent,
+ &children, &count );
+ if ( children != NULL ) XFree ( children );
+ }
+@@ -221,7 +221,7 @@
+ win = exp_event->window;
+ x = exp_event->x; y = exp_event->y;
+ w = exp_event->width; h = exp_event->height;
+-
++
+ if (PUCheckEvent (event)) break; /* event has been processed */
+ if (PSCheckEvent (event)) break; /* event has been processed */
+
+@@ -238,7 +238,7 @@
+ if (TextCheckEvent (event, &retval, &done)) break; /* event eaten */
+
+ /* if the window doesn't do intelligent redraw, drop but last expose */
+- if (exp_event->count>0 &&
++ if (exp_event->count>0 &&
+ win != mainW && win != ctrlW && win != dirW && win != infoW) break;
+
+
+@@ -301,7 +301,7 @@
+ if (DEBUG) fprintf(stderr,"No configs pending.\n");
+ /* if (DEBUG) XClearArea(theDisp, mainW, x,y,w,h, False); */
+ DrawWindow(x,y,w,h);
+-
++
+ if (HaveSelection()) DrawSelection(0);
+
+ canstartwait = 1; /* finished drawing */
+@@ -314,7 +314,7 @@
+ else if (win == infoW) RedrawInfo(x,y,w,h);
+ else if (win == ctrlW) RedrawCtrl(x,y,w,h);
+ else if (win == dirW) RedrawDirW(x,y,w,h);
+-
++
+ XSetClipMask(theDisp, theGC, None);
+ XDestroyRegion(reg);
+ }
+@@ -324,10 +324,10 @@
+ else if (win == dList.win) LSRedraw(&dList,0);
+ else if (win == dList.scrl.win) SCRedraw(&dList.scrl);
+ else if (win == dnamW) RedrawDNamW();
+- }
++ }
+ break;
+
+-
++
+
+ case ClientMessage: {
+ Atom proto, delwin;
+@@ -382,8 +382,8 @@
+ XSizeHints hints;
+
+ /*
+- * if there's a virtual window manager running (e.g. tvtwm / olvwm),
+- * we're going to get 'cevt' values in terms of the
++ * if there's a virtual window manager running (e.g. tvtwm / olvwm),
++ * we're going to get 'cevt' values in terms of the
+ * 'real' root window (the one that is the size of the screen).
+ * We'll want to translate them into values that are in terms of
+ * the 'virtual' root window (the 'big' one)
+@@ -392,7 +392,7 @@
+ if (vrootW != rootW) {
+ int x1,y1; Window child;
+
+- XTranslateCoordinates(theDisp, rootW, vrootW, cevt->x, cevt->y,
++ XTranslateCoordinates(theDisp, rootW, vrootW, cevt->x, cevt->y,
+ &x1, &y1, &child);
+ if (DEBUG) fprintf(stderr," CONFIG trans %d,%d root -> %d,%d vroot\n",
+ cevt->x, cevt->y, x1, y1);
+@@ -401,11 +401,11 @@
+
+ #ifndef VMS
+ /* read hints for this window and adjust any position hints, but
+- only if this is a 'synthetic' event sent to us by the WM
++ only if this is a 'synthetic' event sent to us by the WM
+ ('real' events from the server have useless x,y info, since the
+ mainW has been reparented by the WM) */
+
+- if (cevt->send_event &&
++ if (cevt->send_event &&
+ XGetNormalHints(theDisp, cevt->window, &hints)) {
+
+ if (DEBUG) fprintf(stderr," CONFIG got hints (0x%x %d,%d)\n",
+@@ -439,11 +439,11 @@
+ * This sucks!
+ *
+ * So, if we have just loaded an image, and we get a Synthetic conf
+- * that is not the desired size (eWIDExeHIGH), ignore it, as it's
++ * that is not the desired size (eWIDExeHIGH), ignore it, as it's
+ * just the conf generated by moving the old window. And stop
+ * ignoring further config events
+ *
+- * EVIL KLUDGE: do *not* ignore configs that are <100x100. Not
++ * EVIL KLUDGE: do *not* ignore configs that are <100x100. Not
+ * ignoring them won't be a big performance problem, and it'll get
+ * around the 'I only got one config in the wrong size' problem when
+ * initially displaying small images
+@@ -453,7 +453,7 @@
+
+ /* fprintf(stderr,"***mainw, ignore=%d, send_event=%d, evtSize=%d,%d, size=%d,%d\n", ignoreConfigs, cevt->send_event, cevt->width, cevt->height, eWIDE, eHIGH); */
+
+- if (ignoreConfigs==1 && cevt->send_event &&
++ if (ignoreConfigs==1 && cevt->send_event &&
+ (cevt->width != eWIDE || cevt->height != eHIGH)) {
+ ignoreConfigs=0; /* ignore this one only */
+ break;
+@@ -470,7 +470,7 @@
+ else {
+ XEvent xev;
+ if (DEBUG) fprintf(stderr,"No configs pend.");
+-
++
+ if (cevt->width == eWIDE && cevt->height == eHIGH) {
+ if (DEBUG) fprintf(stderr,"No redraw\n");
+ }
+@@ -478,12 +478,12 @@
+ if (DEBUG) fprintf(stderr,"Do full redraw\n");
+
+ Resize(cevt->width, cevt->height);
+-
++
+ /* eat any pending expose events and do a full redraw */
+ while (XCheckTypedWindowEvent(theDisp, mainW, Expose, &xev)) {
+ XExposeEvent *exp = (XExposeEvent *) &xev;
+
+- if (DEBUG)
++ if (DEBUG)
+ fprintf(stderr," ate expose (%s) (count=%d) %d,%d %dx%d\n",
+ exp->send_event ? "synth" : "real", exp->count,
+ exp->x, exp->y, exp->width, exp->height);
+@@ -508,9 +508,9 @@
+
+ }
+ break;
+-
+
+-
++
++
+ case CirculateNotify:
+ case DestroyNotify:
+ case GravityNotify: break;
+@@ -554,7 +554,7 @@
+
+ /* don't do it if we've just switched to a root mode */
+ if ((unmap_event->window == mainW && dispMode == 0) ||
+- (unmap_event->window == ctrlW && dispMode != 0)) {
++ (unmap_event->window == ctrlW && dispMode != 0)) {
+
+ if (autoclose) {
+ if (autoclose>1) autoclose -= 2; /* grab kludge */
+@@ -586,8 +586,8 @@
+ XReparentEvent *reparent_event = (XReparentEvent *) event;
+
+ if (DEBUG) {
+- fprintf(stderr,"Reparent: mainW=%x ->win=%x ->ev=%x ->parent=%x ",
+- (u_int) mainW, (u_int) reparent_event->window,
++ fprintf(stderr,"Reparent: mainW=%x ->win=%x ->ev=%x ->parent=%x ",
++ (u_int) mainW, (u_int) reparent_event->window,
+ (u_int) reparent_event->event, (u_int) reparent_event->parent);
+ fprintf(stderr,"%d,%d\n", reparent_event->x, reparent_event->y);
+ }
+@@ -598,7 +598,7 @@
+
+ p_offx = p_offy = 0; /* topleft correction for WMs titlebar */
+
+- if (ch_offx == 0 && ch_offy == 0) {
++ if (ch_offx == 0 && ch_offy == 0) {
+ /* looks like the user is running MWM or OLWM */
+
+ XWindowAttributes xwa;
+@@ -609,8 +609,8 @@
+
+ XSync(theDisp, False);
+ XGetWindowAttributes(theDisp, mainW, &xwa);
+-
+- if (DEBUG)
++
++ if (DEBUG)
+ fprintf(stderr,"XGetAttr: mainW %d,%d %dx%d\n", xwa.x, xwa.y,
+ xwa.width, xwa.height);
+
+@@ -620,8 +620,8 @@
+
+ XSync(theDisp, False);
+ XGetWindowAttributes(theDisp, reparent_event->parent, &xwa);
+-
+- if (DEBUG)
++
++ if (DEBUG)
+ fprintf(stderr,"XGetAttr: parent %d,%d %dx%d\n", xwa.x, xwa.y,
+ xwa.width, xwa.height);
+ }
+@@ -641,42 +641,42 @@
+ p_offy = xwa.y;
+ }
+
+-
++
+ /* move window around a bit... */
+ {
+ XWindowAttributes xwa;
+ GetWindowPos(&xwa);
+ xwa.width = eWIDE; xwa.height = eHIGH;
+-
++
+ /* try to keep the damned thing on-screen, if possible */
+ if (xwa.x + xwa.width > dispWIDE) xwa.x = dispWIDE - xwa.width;
+ if (xwa.y + xwa.height > dispHIGH) xwa.y = dispHIGH - xwa.height;
+ if (xwa.x < 0) xwa.x = 0;
+ if (xwa.y < 0) xwa.y = 0;
+-
++
+ SetWindowPos(&xwa);
+ }
+
+ }
+ }
+ break;
+-
++
+
+ case EnterNotify:
+ case LeaveNotify: {
+ XCrossingEvent *cross_event = (XCrossingEvent *) event;
+ if (cross_event->window == mainW || 0
+ /* (cross_event->window == gamW && cmapInGam) */ ) {
+-
++
+ if (cross_event->type == EnterNotify && cross_event->window == mainW) {
+ zoomCurs(cross_event->state);
+ }
+
+
+- if (cross_event->type == EnterNotify && LocalCmap && !ninstall)
++ if (cross_event->type == EnterNotify && LocalCmap && !ninstall)
+ XInstallColormap(theDisp,LocalCmap);
+
+- if (cross_event->type == LeaveNotify && LocalCmap && !ninstall)
++ if (cross_event->type == LeaveNotify && LocalCmap && !ninstall)
+ XUninstallColormap(theDisp,LocalCmap);
+ }
+ }
+@@ -685,12 +685,12 @@
+
+ case SelectionClear: break;
+
+- case SelectionRequest:
++ case SelectionRequest:
+ {
+ XSelectionRequestEvent *xsrevt = (XSelectionRequestEvent *) event;
+ XSelectionEvent xse;
+
+- if (xsrevt->owner != ctrlW ||
++ if (xsrevt->owner != ctrlW ||
+ xsrevt->selection != XA_PRIMARY ||
+ xsrevt->target != XA_STRING) { /* can't do it. */
+ xse.property = None;
+@@ -702,7 +702,7 @@
+ if (xse.property != None) {
+ xerrcode = 0;
+ XChangeProperty(theDisp, xsrevt->requestor, xse.property,
+- XA_STRING, 8, PropModeReplace,
++ XA_STRING, 8, PropModeReplace,
+ (byte *) ((xevPriSel) ? xevPriSel : "\0"),
+ (int) ((xevPriSel) ? strlen(xevPriSel)+1 : 1));
+ XSync(theDisp, False);
+@@ -721,9 +721,9 @@
+ XSync(theDisp, False);
+ }
+ break;
+-
+-
+-
++
++
++
+ default: break; /* ignore unexpected events */
+ } /* switch */
+
+@@ -738,7 +738,7 @@
+ int i;
+ {
+ /* called to handle selection of a dispMB item */
+-
++
+ if (i<0 || i>=DMB_MAX) return;
+
+ if (dispMB.dim[i]) return; /* disabled */
+@@ -747,36 +747,36 @@
+ if (i==DMB_RAW) epicMode = EM_RAW;
+ else if (i==DMB_DITH) epicMode = EM_DITH;
+ else epicMode = EM_SMOOTH;
+-
+- SetEpicMode();
++
++ SetEpicMode();
+ GenerateEpic(eWIDE, eHIGH);
+ DrawEpic();
+ SetCursors(-1);
+ }
+-
++
+ else if (i==DMB_COLRW) { /* toggle rw on/off */
+ dispMB.flags[i] = !dispMB.flags[i];
+ allocMode = (dispMB.flags[i]) ? AM_READWRITE : AM_READONLY;
+ ChangeCmapMode(colorMapMode, 1, 0);
+ }
+-
++
+ else if (i>=DMB_COLNORM && i<=DMB_COLSTDC && !dispMB.flags[i]) {
+ switch (i) {
+- case DMB_COLNORM:
+- ChangeCmapMode(CM_NORMAL, 1, 0);
+- defaultCmapMode = CM_NORMAL;
++ case DMB_COLNORM:
++ ChangeCmapMode(CM_NORMAL, 1, 0);
++ defaultCmapMode = CM_NORMAL;
+ break;
+- case DMB_COLPERF:
++ case DMB_COLPERF:
+ ChangeCmapMode(CM_PERFECT,1, 0);
+- defaultCmapMode = CM_PERFECT;
++ defaultCmapMode = CM_PERFECT;
+ break;
+- case DMB_COLOWNC:
++ case DMB_COLOWNC:
+ ChangeCmapMode(CM_OWNCMAP,1, 0);
+- defaultCmapMode = CM_OWNCMAP;
++ defaultCmapMode = CM_OWNCMAP;
+ break;
+- case DMB_COLSTDC:
++ case DMB_COLSTDC:
+ ChangeCmapMode(CM_STDCMAP,1, 0);
+- defaultCmapMode = CM_STDCMAP;
++ defaultCmapMode = CM_STDCMAP;
+ break;
+ }
+ }
+@@ -788,17 +788,17 @@
+ int i;
+ {
+ /* called to handle selection of a rootMB item */
+-
++
+ if (i<0 || i>=RMB_MAX) return;
+ if (rootMB.flags[i]) return;
+ if (rootMB.dim[i]) return;
+
+ dispMode = i;
+-
++
+ /* move checkmark */
+ for (i=RMB_WINDOW; i<RMB_MAX; i++) rootMB.flags[i] = 0;
+ rootMB.flags[dispMode] = 1;
+-
++
+ HandleDispMode();
+ }
+
+@@ -818,25 +818,25 @@
+ else if (i==CONV24_24BIT && state824==1) {
+ /* went 24->8->24 */
+ char buf[512];
+-
++
+ sprintf(buf,"Warning: You appear to have taken a 24-bit ");
+ strcat(buf, "image, turned it to an 8-bit image, and turned ");
+ strcat(buf, "it back into a 24-bit image. Understand that ");
+ strcat(buf, "image data has probably been lost in this ");
+ strcat(buf, "transformation. You *may* want to reload the ");
+ strcat(buf, "original image to avoid this problem.");
+-
++
+ ErrPopUp(buf, "\nI Know!");
+-
++
+ state824 = 2; /* shut up until next image is loaded */
+ }
+ }
+ }
+-
++
+ else if (i==CONV24_LOCK) {
+ conv24MB.flags[i] = !conv24MB.flags[i];
+ }
+-
++
+ else if (i>=CONV24_FAST && i<=CONV24_BEST) {
+ conv24 = i;
+ for (i=CONV24_FAST; i<=CONV24_BEST; i++) {
+@@ -859,15 +859,15 @@
+ else chdir(initdir);
+ OpenBrowse();
+ break;
+-
++
+ case WMB_COLEDIT: GamBox (!gamUp); break;
+ case WMB_INFO: InfoBox(!infoUp); break;
+-
+- case WMB_COMMENT:
++
++ case WMB_COMMENT:
+ if (!commentUp) OpenCommentText();
+ else CloseCommentText();
+ break;
+-
++
+ case WMB_TEXTVIEW: textViewCmd(); break;
+ case WMB_ABOUTXV: ShowLicense(); break;
+ case WMB_KEYHELP: ShowKeyHelp(); break;
+@@ -892,19 +892,19 @@
+ double r,wr,hr;
+ wr = ((double) cWIDE) / maxWIDE;
+ hr = ((double) cHIGH) / maxHIGH;
+-
++
+ r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */
+ w = (int) ((cWIDE / r) + 0.5);
+ h = (int) ((cHIGH / r) + 0.5);
+ }
+ else { w = cWIDE; h = cHIGH; }
+-
++
+ WResize(w, h);
+ break;
+
+ case SZMB_MAXPIC: WMaximize(); break;
+
+- case SZMB_MAXPECT:
++ case SZMB_MAXPECT:
+ {
+ int w1,h1;
+ w1 = eWIDE; h1 = eHIGH;
+@@ -925,24 +925,24 @@
+ if (h==eHIGH) h++;
+ WResize(w,h);
+ break;
+-
+-
++
++
+ case SZMB_SETSIZE: setSizeCmd(); break;
+ case SZMB_ASPECT: FixAspect(1, &w, &h); WResize(w,h); break;
+
+- case SZMB_4BY3:
++ case SZMB_4BY3:
+ w = eWIDE; h = (w * 3) / 4;
+ if (h>maxHIGH) { h = eHIGH; w = (h*4)/3; }
+ WResize(w,h);
+ break;
+
+- case SZMB_INTEXP:
++ case SZMB_INTEXP:
+ {
+ /* round (eWIDE/cWIDE),(eHIGH/cHIGH) to nearest
+ integer expansion/compression values */
+-
++
+ double w,h;
+-
++
+ if (eWIDE >= cWIDE) {
+ w = ((double) eWIDE) / cWIDE;
+ w = floor(w + 0.5);
+@@ -961,7 +961,7 @@
+ }
+ w = pick;
+ }
+-
++
+ if (eHIGH >= cHIGH) {
+ h = ((double) eHIGH) / cHIGH;
+ h = floor(h + 0.5);
+@@ -980,11 +980,11 @@
+ }
+ h = pick;
+ }
+-
++
+ WResize((int) (w*cWIDE), (int) (h*cHIGH));
+ }
+ break;
+-
++
+ default: break;
+ }
+ }
+@@ -998,7 +998,7 @@
+ int i;
+ char txt[512], str[PRINTCMDLEN + 10];
+ static char *labels[] = { " Color", " Grayscale", " B/W", "\033Cancel" };
+-
++
+ 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");
+ #ifndef VMS
+@@ -1011,11 +1011,11 @@
+ if (i == 3 || strlen(printCmd)==0) return; /* CANCEL */
+
+ if (dirUp == BLOAD) DirBox(0);
+-
++
+ SetDirSaveMode(F_FORMAT, F_PS);
+ SetDirSaveMode(F_COLORS, i);
+
+- if (printCmd[0] != '|' && printCmd[0] != '!')
++ if (printCmd[0] != '|' && printCmd[0] != '!')
+ sprintf(str, "| %s", printCmd);
+ else strcpy(str, printCmd);
+
+@@ -1090,7 +1090,7 @@
+ Window win;
+ {
+ static char foo[16];
+-
++
+ if (win == mainW) return "mainW";
+ else if (win == rootW) return "rootW";
+ else if (win == vrootW) return "vrootW";
+@@ -1106,7 +1106,7 @@
+ }
+ }
+
+-
++
+ /***********************************/
+ static void handleButtonEvent(event, donep, retvalp)
+ XEvent *event;
+@@ -1127,38 +1127,36 @@
+ case ButtonPress:
+ /* *always* check for pop-up events, as errors can happen... */
+ if (PUCheckEvent (event)) break;
+-
++
+ if (autoquit && win == mainW) Quit(0);
+-
++
+ if (viewonly) break; /* ignore all other button presses */
+-
++
+ if (win == mainW && !useroot && showzoomcursor) {
+ DoZoom(x, y, but_event->button);
+ break;
+ }
+-
++
+ if (PSCheckEvent (event)) break;
+-
++
+ #ifdef HAVE_JPEG
+ if (JPEGCheckEvent(event)) break;
+ #endif
+-
++
+ #ifdef HAVE_TIFF
+ if (TIFFCheckEvent(event)) break;
+ #endif
+-
++
+ if (GamCheckEvent (event)) break;
+ if (BrowseCheckEvent (event, &retval, &done)) break;
+ if (TextCheckEvent (event, &retval, &done)) break;
+-
++
+ switch (but_event->button) {
+-
+- case Button1:
++
++ case Button1:
+ if (win == mainW) DoSelection(but_event);
+-
++
+ else if (win == ctrlW) {
+- int w,h;
+-
+ if (MBClick(&dispMB, x,y)) SelectDispMB (MBTrack(&dispMB) );
+ else if (MBClick(&conv24MB, x,y)) Select24to8MB (MBTrack(&conv24MB));
+ else if (MBClick(&rootMB, x,y)) SelectRootMB (MBTrack(&rootMB) );
+@@ -1170,9 +1168,9 @@
+ if (i>=0) DoAlg(i);
+ break;
+ }
+-
++
+ i=ClickCtrl(x,y);
+-
++
+ switch (i) {
+ case BNEXT: retval= NEXTPIC; done=1; break;
+ case BPREV: retval= PREVPIC; done=1; break;
+@@ -1192,21 +1190,21 @@
+ case BROTR: Rotate(0); break;
+ case BFLIPH: Flip(0); break;
+ case BFLIPV: Flip(1); break;
+-
++
+ case BCROP: Crop(); break;
+ case BUNCROP: UnCrop(); break;
+ case BACROP: AutoCrop(); break;
+-
++
+ case BPAD:
+ {
+ int mode, wide, high, opaque, omode; char *str;
+-
++
+ while (PadPopUp(&mode, &str, &wide, &high, &opaque, &omode)==0) {
+- if (DoPad(mode, str, wide, high, opaque, omode)) {
++ if (DoPad(mode, str, wide, high, opaque, omode)) {
+ done = 1; retval = PADDED; break;
+ }
+- }
+- }
++ }
++ }
+ break;
+
+ case BANNOT: annotatePic(); break;
+@@ -1214,27 +1212,27 @@
+ case BABOUT: SelectWindowMB(WMB_ABOUTXV); break;
+ case BXV: retval = DFLTPIC; done=1; break;
+ case BQUIT: retval = QUIT; done=1; break;
+-
++
+ default: break;
+ }
+-
++
+ if (i==BFLIPH || i==BFLIPV) {
+ DrawEpic();
+ SetCursors(-1);
+ }
+ }
+-
++
+ else if (win == nList.win) {
+ i=LSClick(&nList,but_event);
+ if (curname<0) ActivePrevNext();
+ if (i>=0) { done = 1; retval = i; }
+ }
+-
++
+ else if (win == nList.scrl.win) SCTrack(&nList.scrl, x, y);
+-
++
+ else if (win == dirW) {
+ i=ClickDirW(x,y);
+-
++
+ switch (i) {
+ case S_BOK: if (dirUp == BLOAD) {
+ if (!DirCheckCD()) {
+@@ -1246,53 +1244,53 @@
+ DoSave();
+ }
+ break;
+-
++
+ case S_BCANC: DirBox(0); break;
+-
++
+ case S_BRESCAN:
+ WaitCursor(); LoadCurrentDirectory(); SetCursors(-1);
+ break;
+ }
+ }
+-
++
+ else if (win == dList.win) {
+ i=LSClick(&dList,but_event);
+ SelectDir(i);
+ }
+-
++
+ else if (win == dList.scrl.win) SCTrack(&dList.scrl, x,y);
+ else if (win == infoW) InfoBox(0); /* close info */
+-
++
+ break;
+-
+-
+- case Button2:
++
++
++ case Button2:
+ if (win == mainW && !useroot) {
+ if (!shift && !DoSelection(but_event)) TrackPicValues(x,y);
+ else if (shift) Paint();
+ }
+ break;
+-
++
+ case Button3: /* if using root, MUST NOT get rid of ctrlbox. */
+- if (!shift && !useroot) CtrlBox(!ctrlUp);
++ if (!shift && !useroot) CtrlBox(!ctrlUp);
+ else if (shift) BlurPaint();
+ break;
+-
++
+ default: break;
+ }
+ }
+-
++
+ *donep = done; *retvalp = retval;
+ }
+
+-
++
+ /***********************************/
+ static void handleKeyEvent(event, donep, retvalp)
+ XEvent *event;
+ int *donep, *retvalp;
+ {
+ /* handles KeyPress and KeyRelease events, called from HandleEvent */
+-
++
+ XKeyEvent *key_event;
+ KeySym ks;
+ char buf[128];
+@@ -1306,26 +1304,26 @@
+ switch (event->type) {
+ case KeyRelease:
+ if (viewonly) break; /* ignore all user input */
+-
++
+ stlen = XLookupString(key_event,buf,128,&ks,(XComposeStatus *) NULL);
+ dealt = 0;
+-
++
+ if (key_event->window == mainW) {
+ u_int foo = key_event->state;
+
+- if (ks == XK_Shift_L || ks == XK_Shift_R)
++ if (ks == XK_Shift_L || ks == XK_Shift_R)
+ foo = foo & (u_int) (~ShiftMask);
+- if (ks == XK_Control_L || ks == XK_Control_R)
++ if (ks == XK_Control_L || ks == XK_Control_R)
+ foo = foo & (u_int) (~ControlMask);
+- if (ks == XK_Meta_L || ks == XK_Meta_R)
++ if (ks == XK_Meta_L || ks == XK_Meta_R)
+ foo = foo & (u_int) (~Mod1Mask);
+- if (ks == XK_Alt_L || ks == XK_Alt_R)
++ if (ks == XK_Alt_L || ks == XK_Alt_R)
+ foo = foo & (u_int) (~Mod1Mask);
+
+ zoomCurs(foo);
+ }
+ break;
+-
++
+
+ case KeyPress:
+ svkeystate = key_event->state;
+@@ -1343,11 +1341,11 @@
+ if (PUCheckEvent (event)) break; /* always check popups */
+
+ if (autoquit && key_event->window == mainW) Quit(0);
+-
++
+ if (viewonly && !frominterrupt) break; /* ignore all user input */
+-
++
+ if (PSCheckEvent (event)) break;
+-
++
+ if (key_event->window == mainW) {
+ u_int foo = key_event->state;
+
+@@ -1371,7 +1369,7 @@
+ if (TextCheckEvent (event, &retval, &done)) break;
+
+
+- /* check for pageup/pagedown, 'p' in main window
++ /* 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) */
+
+@@ -1386,7 +1384,7 @@
+ else XBell(theDisp,0);
+ }
+
+- else if (ck==CK_PAGEDOWN ||
++ else if (ck==CK_PAGEDOWN ||
+ (ck==CK_DOWN && shift && !but[BCROP].active)) {
+ if (strlen(pageBaseName) && numPages>1) {
+ done = 1; retval = OP_PAGEDN;
+@@ -1429,7 +1427,7 @@
+
+ if (dealt) break;
+ }
+-
++
+
+
+ /* check for crop rect keys */
+@@ -1468,7 +1466,7 @@
+ if (theList == &dList && dealt) { /* changed dir selection */
+ SelectDir(-1); /* nothing was double-clicked */
+ }
+-
++
+ if (dealt) break;
+ }
+
+@@ -1491,7 +1489,7 @@
+ else if (ks==XK_2) FakeButtonPress(&gbut[G_B2]);
+ else if (ks==XK_3) FakeButtonPress(&gbut[G_B3]);
+ else if (ks==XK_4) FakeButtonPress(&gbut[G_B4]);
+- else if (ks==XK_r || ks==XK_0)
++ else if (ks==XK_r || ks==XK_0)
+ FakeButtonPress(&gbut[G_BRESET]);
+
+ else if (ks==XK_x) FakeButtonPress(&but[BCUT]);
+@@ -1521,7 +1519,7 @@
+
+ else if (ks==XK_a) FakeButtonPress(&gbut[G_BAPPLY]);
+
+- else if (ks==XK_8) {
++ else if (ks==XK_8) {
+ if (picType==PIC8) Select24to8MB(CONV24_24BIT);
+ else Select24to8MB(CONV24_8BIT);
+ }
+@@ -1530,20 +1528,20 @@
+
+ if (dealt) break;
+ }
+-
++
+ if (!stlen) break;
+-
++
+ if (key_event->window == dirW) {
+ if (DirKey(buf[0])) XBell(theDisp,0);
+ }
+ else { /* commands valid in any window */
+ switch (buf[0]) {
+-
++
+ /* things in dispMB */
+ case 'r': SelectDispMB(DMB_RAW); break;
+ case 'd': SelectDispMB(DMB_DITH); break;
+ case 's': SelectDispMB(DMB_SMOOTH); break;
+-
++
+ /* things in sizeMB */
+ case 'n': SelectSizeMB(SZMB_NORM); break;
+ case 'm': SelectSizeMB(SZMB_MAXPIC); break;
+@@ -1556,7 +1554,7 @@
+ case 'a': SelectSizeMB(SZMB_ASPECT); break;
+ case '4': SelectSizeMB(SZMB_4BY3); break;
+ case 'I': SelectSizeMB(SZMB_INTEXP); break;
+-
++
+ /* things in windowMB */
+ case '\026':
+ case 'V': SelectWindowMB(WMB_BROWSE); break; /* ^V or V */
+@@ -1565,36 +1563,36 @@
+ case '\003': SelectWindowMB(WMB_COMMENT); break; /* ^C */
+ case '\024': SelectWindowMB(WMB_TEXTVIEW); break; /* ^T */
+ case '\001': SelectWindowMB(WMB_ABOUTXV); break; /* ^A */
+-
+-
+-
++
++
++
+ /* buttons in ctrlW */
+ case '\t':
+ case ' ': FakeButtonPress(&but[BNEXT]); break;
+-
++
+ case '\r':
+ case '\n':
+ if (nList.selected >= 0 && nList.selected < nList.nstr) {
+- done = 1; retval = nList.selected;
++ done = 1; retval = nList.selected;
+ if (frominterrupt) retval = RELOAD;
+ }
+ break;
+-
++
+ case '\010':
+ case '\177': 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 '\004': FakeButtonPress(&but[BDELETE]); break; /* ^D */
+-
++
+ /* BCOPY, BCUT, BPASTE, BCLEAR handled in 'meta' case */
+-
++
+ case '\007': FakeButtonPress(&but[BGRAB]); break; /* ^G */
+-
++
+ /* BUP10, BDN10 handled in sizeMB case */
+-
++
+ case 'T': FakeButtonPress(&but[BROTL]); break;
+ case 't': FakeButtonPress(&but[BROTR]); break;
+ case 'h': FakeButtonPress(&but[BFLIPH]); break;
+@@ -1604,24 +1602,24 @@
+ case 'C': FakeButtonPress(&but[BACROP]); break;
+ case 'P': FakeButtonPress(&but[BPAD]); break;
+ case 'A': FakeButtonPress(&but[BANNOT]); break;
+-
++
+ /* BABOUT handled in windowMB case */
+-
++
+ case '\021': /* ^Q */
+ case 'q': FakeButtonPress(&but[BQUIT]); break;
+-
++
+ case '?': if (!useroot) CtrlBox(!ctrlUp); break;
+-
++
+ /* things in color editor */
+ case 'R': FakeButtonPress(&gbut[G_BRESET]); break;
+ case 'H': FakeButtonPress(&gbut[G_BHISTEQ]); break;
+ case 'N': FakeButtonPress(&gbut[G_BMAXCONT]); break;
+-
++
+ default: break;
+ }
+ }
+ }
+-
++
+ *donep = done; *retvalp = retval;
+ }
+
+@@ -1657,7 +1655,7 @@
+ else name = namelist[i];
+
+ TextView(name);
+-
++
+ if (name != namelist[i]) free(name);
+ }
+
+@@ -1671,7 +1669,7 @@
+ int i, arg1, arg2, numargs, pct1, pct2, state, neww, newh;
+ char txt[512], buf[64], *sp, ch;
+ static char *labels[] = { "\nOk", "\033Cancel" };
+-
++
+ sprintf(txt, "Enter new image display size (ex. '400 x 300'),\n");
+ strcat (txt, "expansion ratio (ex. '75%'),\n");
+ strcat (txt, "or expansion ratios (ex. '200% x 125%'):");
+@@ -1685,7 +1683,7 @@
+
+
+ /* attempt to parse the string accordingly...
+- * parses strings of the type: <num> [%] [ x <num> [%] ]
++ * parses strings of the type: <num> [%] [ x <num> [%] ]
+ * (-ish. <num> all by itself isn't legal)
+ * there may be any # of spaces between items, including zero
+ */
+@@ -1825,7 +1823,7 @@
+
+ if (theImage)
+ XPutImage(theDisp,mainW,theGC,theImage,x,y,x,y, (u_int) w, (u_int) h);
+- else
++ else
+ if (DEBUG) fprintf(stderr,"Tried to DrawWindow when theImage was NULL\n");
+ }
+
+@@ -1872,7 +1870,7 @@
+ XWindowAttributes xwa;
+ xvbzero((char *) &xwa, sizeof(XWindowAttributes));
+ xwa.x = xwa.y = 0;
+- xwa.width = dispWIDE;
++ xwa.width = dispWIDE;
+ xwa.height = dispHIGH;
+ SetWindowPos(&xwa);
+ }
+@@ -1898,14 +1896,14 @@
+ rotatesLeft++;
+ XClearWindow(theDisp, mainW); /* get rid of old bits */
+ GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
+- { int ew, eh;
++ { int ew, eh;
+ ew = eWIDE; eh = eHIGH;
+ WResize(eWIDE, eHIGH);
+ if (ew>maxWIDE || eh>maxHIGH) { /* rotated pic too big, scale down */
+ double r,wr,hr;
+ wr = ((double) ew) / maxWIDE;
+ hr = ((double) eh) / maxHIGH;
+-
++
+ r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */
+ ew = (int) ((ew / r) + 0.5);
+ eh = (int) ((eh / r) + 0.5);
+@@ -1920,7 +1918,7 @@
+ void WCrop(w,h,dx,dy)
+ int w,h,dx,dy;
+ {
+- int cx, cy, cw, ch, ex, ey;
++ int ex, ey;
+ XWindowAttributes xwa;
+
+ if (useroot) {
+@@ -1931,7 +1929,7 @@
+ else {
+ /* we want to move window to old x,y + dx,dy (in pic coords) */
+ GetWindowPos(&xwa);
+-
++
+ if (!origcropvalid) { /* first crop. remember win pos */
+ origcropvalid = 1;
+ origcropx = xwa.x;
+@@ -1939,7 +1937,7 @@
+ }
+
+ CoordC2E(dx, dy, &ex, &ey);
+-
++
+ xwa.x += ex; xwa.y += ey;
+ xwa.width = w; xwa.height = h;
+ GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
+@@ -1980,7 +1978,7 @@
+ if (xwa.x<0) xwa.x = 0;
+ if (xwa.y<0) xwa.y = 0;
+ xwa.width = w; xwa.height = h;
+-
++
+ if (!useroot) {
+ SetWindowPos(&xwa);
+ GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
+@@ -1995,8 +1993,8 @@
+ XWindowAttributes *xwa;
+ {
+ Window child;
+-
+- /* returns the x,y,w,h coords of mainW. x,y are relative to rootW
++
++ /* returns the x,y,w,h coords of mainW. x,y are relative to rootW
+ the border is not included (x,y map to top-left pixel in window) */
+
+ /* Get the window width/height */
+@@ -2023,7 +2021,7 @@
+
+ /* if we're less than max size in one axis, allow window manager doohickeys
+ on the screen */
+-
++
+ if (xwa->width < dispWIDE && xwc.x < p_offx) xwc.x = p_offx;
+ if (xwa->height < dispHIGH && xwc.y < p_offy) xwc.y = p_offy;
+
+@@ -2034,9 +2032,9 @@
+ #ifdef BAD_IDEA
+ /* if there is a virtual window manager running, then we should translate
+ the coordinates that are in terms of 'real' screen into coordinates
+- that are in terms of the 'virtual' root window
++ that are in terms of the 'virtual' root window
+ from: Daren W. Latham <dwl@mentat.udev.cdc.com> */
+-
++
+ if (vrootW != rootW) { /* virtual window manager running */
+ int x1,y1;
+ Window child;
+@@ -2045,14 +2043,14 @@
+ xwc.x,xwc.y,x1,y1);
+ xwc.x = x1; xwc.y = y1;
+ }
+-#endif
++#endif
+
+
+ if (DEBUG) {
+ fprintf(stderr,
+ "SWP: xwa=%d,%d %dx%d xwc=%d,%d %dx%d off=%d,%d bw=%d klg=%d,%d\n",
+ xwa->x, xwa->y, xwa->width, xwa->height,
+- xwc.x, xwc.y, xwc.width, xwc.height, p_offx, p_offy,
++ xwc.x, xwc.y, xwc.width, xwc.height, p_offx, p_offy,
+ xwa->border_width, kludge_offx, kludge_offy);
+ }
+
+@@ -2080,7 +2078,7 @@
+
+ /* all non-DXWM window managers (?) */
+ /* Move/Resize the window. */
+- XConfigureWindow(theDisp, mainW,
++ XConfigureWindow(theDisp, mainW,
+ CWX | CWY | CWWidth | CWHeight /*| CWBorderWidth*/, &xwc);
+ }
+
+@@ -2090,7 +2088,7 @@
+ static void CropKey(dx,dy,grow,crop)
+ int dx,dy,grow,crop;
+ {
+- int x1,x2,y1,y2,active, ocx, ocy;
++ int ocx, ocy;
+
+ if (crop) { /* chop off a pixel from the appropriate edge */
+ int dealt=1;
+@@ -2112,7 +2110,7 @@
+ }
+ return;
+ }
+-
++
+ if (grow) MoveGrowSelection(0, 0, dx, dy);
+ else MoveGrowSelection(dx, dy, 0, 0);
+ }
+@@ -2128,7 +2126,7 @@
+ u_long wh, bl;
+ int ty, w, ecol, done1;
+ char foo[128];
+- char *str =
++ char *str =
+ "8888,8888 = 123,123,123 #123456 (123,123,123 HSV) [-2345,-2345]";
+
+ ecol = 0; wh = infobg; bl = infofg;
+@@ -2136,14 +2134,14 @@
+ if (!dropper) {
+ Pixmap pix, mask;
+ XColor cfg, cbg;
+-
++
+ cfg.red = cfg.green = cfg.blue = 0x0000;
+ cbg.red = cbg.green = cbg.blue = 0xffff;
+-
++
+ pix = MakePix1(rootW, dropper_bits, dropper_width, dropper_height);
+ mask= MakePix1(rootW, dropperm_bits, dropperm_width, dropperm_height);
+- if (pix && mask)
+- dropper = XCreatePixmapCursor(theDisp, pix, mask, &cfg, &cbg,
++ if (pix && mask)
++ dropper = XCreatePixmapCursor(theDisp, pix, mask, &cfg, &cbg,
+ dropper_x_hot, dropper_y_hot);
+ if (pix) XFreePixmap(theDisp, pix);
+ if (mask) XFreePixmap(theDisp, mask);
+@@ -2151,7 +2149,7 @@
+
+ if (dropper) XDefineCursor(theDisp, mainW, dropper);
+
+- /* do a colormap search for black and white if LocalCmap
++ /* do a colormap search for black and white if LocalCmap
+ and use those colors instead of infobg and infofg */
+
+ if (LocalCmap) {
+@@ -2159,7 +2157,7 @@
+
+ for (i=0; i<nfcols; i++) ctab[i].pixel = freecols[i];
+ XQueryColors(theDisp,LocalCmap,ctab,nfcols);
+-
++
+ /* find 'blackest' pixel */
+ cval = 0x10000 * 3;
+ for (i=0; i<nfcols; i++)
+@@ -2176,7 +2174,7 @@
+ wh = ctab[i].pixel;
+ }
+ }
+-
++
+
+ XSetFont(theDisp, theGC, monofont);
+ w = XTextWidth(monofinfo, str, (int) strlen(str));
+@@ -2185,7 +2183,7 @@
+ else ty = eHIGH-(monofinfo->ascent + mfinfo->descent)-4;
+
+ XSetForeground(theDisp, theGC, bl);
+- XFillRectangle(theDisp, mainW, theGC, 0, ty, (u_int) w + 8,
++ XFillRectangle(theDisp, mainW, theGC, 0, ty, (u_int) w + 8,
+ (u_int) (monofinfo->ascent+monofinfo->descent) + 4);
+ XSetForeground(theDisp, theGC, wh);
+ XSetBackground(theDisp, theGC, bl);
+@@ -2198,15 +2196,15 @@
+
+ if (!XQueryPointer(theDisp,mainW,&rW,&cW,&rx,&ry,&x,&y,&mask)) continue;
+ if (done1 && !(mask & Button2Mask)) break; /* button released */
+-
++
+ CoordE2P(x,y, &px, &py);
+- RANGE(px,0,pWIDE-1);
++ RANGE(px,0,pWIDE-1);
+ RANGE(py,0,pHIGH-1);
+-
++
+ if (px!=ox || py!=oy || !done1) { /* moved, or firsttime. erase & draw */
+ double h1, s1, v1;
+ int rval, gval, bval;
+-
++
+ if (picType == PIC8) {
+ ecol = pix = pic[py * pWIDE + px];
+ rval = rcmap[pix]; gval = gcmap[pix]; bval = bcmap[pix];
+@@ -2216,7 +2214,7 @@
+ gval = pic[py * pWIDE * 3 + px * 3 + 1];
+ bval = pic[py * pWIDE * 3 + px * 3 + 2];
+ }
+-
++
+ clearR = rval; clearG = gval; clearB = bval;
+
+ rgb2hsv(rval, gval, bval, &h1, &s1, &v1);
+@@ -2229,8 +2227,8 @@
+ px, py, rval, gval, bval, rval, gval, bval,
+ (int) h1, (int) (s1 * 100), (int) (v1 * 100),
+ px-orgx, py-orgy);
+-
+- XDrawImageString(theDisp,mainW,theGC, 4, ty + 2 + monofinfo->ascent,
++
++ XDrawImageString(theDisp,mainW,theGC, 4, ty + 2 + monofinfo->ascent,
+ foo, (int) strlen(foo));
+ ox = px; oy = py;
+ done1 = 1;
+@@ -2275,7 +2273,7 @@
+
+ /* returns true if there's a config event in which mainW changes size
+ in the event queue */
+-
++
+ XSync(theDisp, False);
+ foo = 0;
+ XCheckIfEvent(theDisp, &ev, IsConfig, &foo);
+@@ -2328,7 +2326,7 @@
+ * BadMatch errors on XGetImage
+ */
+
+- if ((xerrcode == BadAlloc) ||
++ if ((xerrcode == BadAlloc) ||
+ (xerrcode == BadAccess && err->request_code==88 /* X_FreeColors */ ) ||
+ (err->request_code == 113 /* X_KillClient */ ) ||
+ (xerrcode == BadLength && err->request_code==18 /* X_ChangeProp */ ) ||
+@@ -2361,7 +2359,7 @@
+ {
+ /* but first, if any input-grabbing popups are active, we have to 'cancel'
+ them. */
+-
++
+ if (psUp) PSDialog(0); /* close PS window */
+
+ #ifdef HAVE_JPEG
+@@ -2400,14 +2398,14 @@
+ if (!pen) {
+ Pixmap pix, pmask;
+ XColor cfg, cbg;
+-
++
+ cfg.red = cfg.green = cfg.blue = 0x0000;
+ cbg.red = cbg.green = cbg.blue = 0xffff;
+-
++
+ pix = MakePix1(rootW, pen_bits, pen_width, pen_height);
+ pmask= MakePix1(rootW, penm_bits, penm_width, penm_height);
+- if (pix && pmask)
+- pen = XCreatePixmapCursor(theDisp, pix, pmask, &cfg, &cbg,
++ if (pix && pmask)
++ pen = XCreatePixmapCursor(theDisp, pix, pmask, &cfg, &cbg,
+ pen_x_hot, pen_y_hot);
+ if (pix) XFreePixmap(theDisp, pix);
+ if (pmask) XFreePixmap(theDisp, pmask);
+@@ -2416,7 +2414,7 @@
+ if (pen) XDefineCursor(theDisp, mainW, pen);
+
+
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask /* | ButtonPressMask */
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -2435,7 +2433,7 @@
+
+ switch (state) {
+ case 0: /* initial state: make sure we do one pixel */
+- px1 = lx = px; py1 = ly = py;
++ px1 = lx = px; py1 = ly = py;
+ paintPixel(px, py);
+
+ if (nmask & ShiftMask ) state = 99;
+@@ -2444,7 +2442,7 @@
+ else state = 10;
+ break;
+
+-
++
+ case 1: /* waiting for click */
+ if (nmask & ShiftMask) state = 99;
+ else if ( mask & Button2Mask) {
+@@ -2459,7 +2457,7 @@
+ }
+ break;
+
+-
++
+ case 10: /* in freehand drawing mode */
+ if (nmask & ShiftMask ) state = 99;
+ else if (nmask & Button2Mask) state = 1;
+@@ -2507,11 +2505,11 @@
+ XSync(theDisp, False);
+ Timer(100);
+ }
+-
++
+ if (nmask & Button2Mask) seenRelease = 1;
+ }
+ break;
+-
++
+ case 99: /* EXIT loop: cleanup */
+ if (line) { /* erase old xor-line */
+ paintXLine(lx, ly, px1, py1, 0);
+@@ -2521,11 +2519,11 @@
+ break;
+ }
+ }
+-
+-
++
++
+ WaitCursor();
+-
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask | ButtonPressMask
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -2557,17 +2555,17 @@
+ byte *pp = pic + (y * pWIDE + x) * 3;
+ pp[0] = clearR; pp[1] = clearG; pp[2] = clearB;
+ }
+-
++
+ /* visual feedback */
+ CoordP2E(x, y, &ex, &ey);
+ CoordP2E(x+1, y+1, &ex1, &ey1);
+-
++
+ ew = ex1-ex; eh = ey1-ey;
+-
++
+ if (picType == PIC8) XSetForeground(theDisp, theGC, cols[editColor]);
+ else XSetForeground(theDisp, theGC, RGBToXColor(clearR, clearG, clearB));
+-
+- if (ew>0 && eh>0)
++
++ if (ew>0 && eh>0)
+ XFillRectangle(theDisp,mainW,theGC, ex,ey, (u_int) ew, (u_int) eh);
+ }
+
+@@ -2577,7 +2575,7 @@
+ int x,y,x1,y1;
+ {
+ int dx,dy,i,lx,ly,adx,ady;
+-
++
+ dx = x1-x; dy = y1-y;
+ adx = abs(dx); ady = abs(dy);
+
+@@ -2598,7 +2596,7 @@
+ paintPixel(lx,ly);
+ }
+ }
+-
++
+
+ }
+
+@@ -2618,14 +2616,14 @@
+ CoordP2E(x+1,y+1,&tx1,&ty1);
+ ex = tx + (tx1 - tx)/2;
+ ey = ty + (ty1 - ty)/2;
+-
++
+ CoordP2E(x1, y1, &tx, &ty);
+ CoordP2E(x1+1,y1+1,&tx1,&ty1);
+ ex1 = tx + (tx1 - tx)/2;
+ ey1 = ty + (ty1 - ty)/2;
+-
++
+ if (ex==ex1 && ey==ey1) return;
+-
++
+ XSetPlaneMask(theDisp, theGC, xorMasks[pntxlcol]);
+ XSetFunction(theDisp, theGC, GXinvert);
+ XDrawLine(theDisp, mainW, theGC, ex, ey, ex1, ey1);
+@@ -2638,10 +2636,8 @@
+ static void BlurPaint()
+ {
+ Window rW,cW;
+- int rx,ry,ox,oy,x,y, px,py, ex,ey, ex1,ey1, ew, eh, done1, dragging;
+- int uppedpic;
++ int rx,ry,ox,oy,x,y, px,py, done1, dragging;
+ u_int mask;
+- byte *pp;
+
+ /* blurs pixels in either editCol (PIC8) or clear{R,G,B} (PIC24) until
+ 'shift' key is released. */
+@@ -2653,14 +2649,14 @@
+ if (!blur) {
+ Pixmap pix, mask;
+ XColor cfg, cbg;
+-
++
+ cfg.red = cfg.green = cfg.blue = 0x0000;
+ cbg.red = cbg.green = cbg.blue = 0xffff;
+-
++
+ pix = MakePix1(rootW, blur_bits, blur_width, blur_height);
+ mask= MakePix1(rootW, blurm_bits, blurm_width, blurm_height);
+- if (pix && mask)
+- blur = XCreatePixmapCursor(theDisp, pix, mask, &cfg, &cbg,
++ if (pix && mask)
++ blur = XCreatePixmapCursor(theDisp, pix, mask, &cfg, &cbg,
+ blur_x_hot, blur_y_hot);
+ if (pix) XFreePixmap(theDisp, pix);
+ if (mask) XFreePixmap(theDisp, mask);
+@@ -2669,7 +2665,7 @@
+ if (blur) XDefineCursor(theDisp, mainW, blur);
+
+
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask /* | ButtonPressMask */
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -2682,12 +2678,12 @@
+ if (!(mask & Button3Mask)) { dragging = 0; continue; }
+
+ CoordE2P(x,y, &px, &py);
+-
++
+ if (!dragging || (dragging && (px!=ox || py!=oy))) { /* click or drag */
+ if (!dragging) blurPixel(px,py);
+ else {
+ int dx,dy,i,lx,ly;
+-
++
+ dx = px-ox; dy = py-oy; /* at least one will be non-zero */
+ if (abs(dx) > abs(dy)) { /* X is major axis */
+ for (i=0; i<=abs(dx); i++) {
+@@ -2707,10 +2703,10 @@
+ done1 = 1; dragging = 1; ox = px; oy = py;
+ }
+ }
+-
++
+ WaitCursor();
+-
+- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
++
++ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
+ | StructureNotifyMask | ButtonPressMask
+ | KeyReleaseMask | ColormapChangeMask
+ | EnterWindowMask | LeaveWindowMask );
+@@ -2731,9 +2727,9 @@
+ {
+ /* returns position of highest set bit in 'ul' as an integer (0-31),
+ or -1 if none */
+-
++
+ int i; unsigned long hb;
+-
++
+ hb = 0x80; hb = hb << 24; /* hb = 0x80000000UL */
+ for (i=31; ((ul & hb) == 0) && i>=0; i--, ul<<=1);
+ return i;
+@@ -2757,7 +2753,7 @@
+
+ d = 3*(256*256); j=0;
+ for (i=0; i<numcols; i++) {
+- di = ((r-rMap[i]) * (r-rMap[i])) +
++ di = ((r-rMap[i]) * (r-rMap[i])) +
+ ((g-gMap[i]) + (g-gMap[i])) +
+ ((b-bMap[i]) * (b-bMap[i]));
+ if (i==0 || di<d) { j=i; d=di; }
+@@ -2771,45 +2767,45 @@
+ if (theVisual->class==TrueColor || theVisual->class==DirectColor) {
+ unsigned long rmask, gmask, bmask;
+ int rshift, gshift, bshift, cshift, maplen;
+-
++
+ /* 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);
+-
++
+ if (theVisual->class == DirectColor) {
+ maplen = theVisual->map_entries;
+ if (maplen>256) maplen=256;
+ cshift = 7 - highbit((u_long) (maplen-1));
+-
++
+ 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;
+-
++
+ rv =r | g | b;
+ }
+-
++
+ else { /* non-TrueColor/DirectColor visual */
+ if (!ncols)
+ rv = ((r + g + b >= 128*3) ? white : black);
+@@ -2820,14 +2816,14 @@
+
+ return rv;
+ }
+-
+-
++
++
+ /***********************/
+ static void blurPixel(x,y)
+ int x,y;
+ {
+ /* blurs pixel x,y (pic coords) into pic in editColor (PIC8) or clearR,G,B
+- (PIC24) and does appropriate screen feedback. Does a 3x3 average
++ (PIC24) and does appropriate screen feedback. Does a 3x3 average
+ around the pixel, and replaces it with the average value (PIC24), or
+ the closest existing color to the average value (PIC8) */
+
+@@ -2861,7 +2857,7 @@
+ if (picType == PIC8) { /* find nearest actual color */
+ d = 3*(256*256); j=0;
+ for (i=0; i<numcols; i++) {
+- di = ((ar-rMap[i]) * (ar-rMap[i])) +
++ di = ((ar-rMap[i]) * (ar-rMap[i])) +
+ ((ag-gMap[i]) + (ag-gMap[i])) +
+ ((ab-bMap[i]) * (ab-bMap[i]));
+ if (i==0 || di<d) { j=i; d=di; }
+@@ -2874,17 +2870,17 @@
+ pp = pic + (y * pWIDE + x) * 3;
+ pp[0] = ar; pp[1] = ag; pp[2] = ab;
+ }
+-
++
+ /* visual feedback */
+ CoordP2E(x, y, &ex, &ey);
+ CoordP2E(x+1, y+1, &ex1, &ey1);
+-
++
+ ew = ex1-ex; eh = ey1-ey;
+-
++
+ if (picType == PIC8) XSetForeground(theDisp, theGC, cols[ac]);
+ else XSetForeground(theDisp, theGC, RGBToXColor(ar, ag, ab));
+-
+- if (ew>0 && eh>0)
++
++ if (ew>0 && eh>0)
+ XFillRectangle(theDisp,mainW,theGC, ex,ey, (u_int) ew, (u_int) eh);
+ }
+
+@@ -2901,13 +2897,13 @@
+ static char buf[256] = {'\0'};
+ static char *labels[] = {"\nOk", "\033Cancel" };
+
+- sprintf(txt, "Image Annotation:\n\n%s",
++ sprintf(txt, "Image Annotation:\n\n%s",
+ "Enter string to be placed on image.");
+-
++
+ i = GetStrPopUp(txt, labels, 2, buf, 256, "", 0);
+ if (i==1 || strlen(buf)==0) return;
+-
+-
++
++
+ /* build a 'cimg' array to be pasted on clipboard */
+ w = strlen(buf) * 6 - 1; h = 9;
+ len = CIMG_PIC8 + w*h;
+diff -ruN xv-3.10a/xvfits.c xv-3.10a-bugfixes/xvfits.c
+--- xv-3.10a/xvfits.c 1994-12-27 23:43:29.000000000 -0800
++++ xv-3.10a-bugfixes/xvfits.c 2005-04-02 21:08:45.000000000 -0800
+@@ -63,7 +63,7 @@
+ /* returns '1' on success */
+
+ FITS fs;
+- int i, nx, ny, nz, bitpix, np, nrd, ioerror;
++ int i, nx, ny, nz, bitpix, nrd, ioerror, npixels, bufsize;
+ byte *image;
+ char *error;
+ char basename[64];
+@@ -72,7 +72,7 @@
+ fits_block = (char *) malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+-
++
+ error = ftopen3d(&fs, fname, &nx, &ny, &nz, &bitpix);
+ if (error) {
+ SetISTR(ISTR_WARNING, "%s", error);
+@@ -80,9 +80,15 @@
+ }
+
+ if (quick) nz = 1; /* only load first plane */
+- np = nx * ny * nz;
++ npixels = nx * ny;
++ bufsize = nz * npixels;
++ if (nx <= 0 || ny <= 0 || npixels/nx != ny || bufsize/nz != npixels) {
++ SetISTR(ISTR_WARNING, "FITS image dimensions out of range (%dx%dx%d)",
++ nx, ny, nz);
++ return 0;
++ }
+
+- image = (byte *) malloc((size_t) np);
++ image = (byte *) malloc((size_t) bufsize);
+ if (!image) FatalError("Insufficient memory for image");
+
+ /*
+@@ -90,7 +96,7 @@
+ * to ensure that we get that same scaling for all planes.
+ */
+
+- nrd = ftgbyte(&fs, image, np);
++ nrd = ftgbyte(&fs, image, bufsize);
+ ioerror = ferror(fs.fp);
+ ftclose(&fs);
+
+@@ -104,33 +110,32 @@
+ return 0;
+ }
+
+- else if (nrd < np) { /* read partial image */
++ else if (nrd < bufsize) { /* read partial image */
+ if (ioerror)
+ SetISTR(ISTR_WARNING, "%s", "Truncated FITS file due to I/O error");
+ else
+ SetISTR(ISTR_WARNING, "%s", "Truncated FITS file");
+-
++
+ { byte *foo;
+- for (foo=image+nrd; foo<image+np; foo++) *foo=0x80; /* pad with grey */
++ for (foo=image+nrd; foo<image+bufsize; foo++) *foo=0x80; /* pad with grey */
+ }
+ }
+
+ if (nz > 1) {
+ /* how many planes do we actually have? */
+- nz = (nrd-1)/(nx*ny) + 1;
++ nz = (nrd-1)/(npixels) + 1;
+
+ /* returns how many sub-files created */
+ nz = splitfits(image, fs.comment, nx, ny, nz, basename);
+- np = nx * ny;
+- image = (byte *)realloc(image, (size_t) np); /* toss all but first */
++ image = (byte *)realloc(image, (size_t) npixels); /* toss all but first */
+ }
+-
++
+ /* There seems to be a convention that fits files be displayed using
+ * a cartesian coordinate system. Thus the first pixel is in the lower left
+ * corner. Fix this by reflecting in the line y=ny/2.
+ */
+ flip(image, nx, ny);
+-
++
+ /* Success! */
+ pinfo->pic = image;
+ pinfo->type = PIC8;
+@@ -149,12 +154,12 @@
+ pinfo->numpages = nz;
+ strcpy(pinfo->pagebname, basename);
+ }
+-
++
+ return 1;
+-}
++}
++
+
+
+-
+ /*******************************************/
+ int WriteFITS(fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,comment)
+ FILE *fp;
+@@ -164,16 +169,16 @@
+ int numcols, colorstyle;
+ char *comment;
+ {
+- int i, j, np, nend;
++ int i, j, npixels, nend;
+ byte *ptr;
+ char *error;
+ byte rgb[256];
+-
++
+ if (!fits_block) {
+ fits_block = (char *) malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+-
++
+ error = wrheader(fp, w, h, comment);
+ if (error) {
+ SetISTR(ISTR_WARNING, "%s", error);
+@@ -197,12 +202,12 @@
+ }
+ }
+
+- np = w*h;
++ npixels = w*h;
+
+ /* nend is the number of padding characters at the end of the last block */
+- nend = ((np+BLOCKSIZE-1)/BLOCKSIZE)*BLOCKSIZE - np;
++ nend = ((npixels+BLOCKSIZE-1)/BLOCKSIZE)*BLOCKSIZE - npixels;
+ if (nend) for (i=0; i<nend; i++) putc('\0', fp);
+-
++
+ return 0;
+ }
+
+@@ -216,17 +221,16 @@
+ char *basename;
+ {
+ /*
+- * Given a 3 dimensional FITS image, this splits it up into nz 2-d files.
++ * Given a 3-dimensional FITS image, this splits it up into nz 2-d files.
+ * It returns the number of files actually stored.
+ * If only one file could be written, then no split files are created.
+ * It returns the basename of the split files in bname.
+ * If there was a problem writing files, then a error message will be set.
+ */
+-
+- int i, np=nx * ny, ioerror, nwrt;
++
++ int i, npixels=nx * ny, nwrt;
+ FILE *fp;
+ char *error;
+- byte *work;
+ char filename[70];
+
+ #ifndef VMS
+@@ -234,8 +238,12 @@
+ #else
+ sprintf(basename, "Sys$Disk:[]xvpgXXXXXX");
+ #endif
+-
++
++#ifdef USE_MKSTEMP
++ close(mkstemp(basename));
++#else
+ mktemp(basename);
++#endif
+ if (basename[0] == '\0') {
+ SetISTR(ISTR_WARNING, "%s", "Unable to build temporary filename");
+ return 1;
+@@ -251,7 +259,7 @@
+ error = "Unable to open temporary file";
+ break;
+ }
+-
++
+ if (wrheader(fp, nx, ny, comment)) {
+ error = "I/O error writing temporary file";
+ fclose(fp);
+@@ -259,15 +267,15 @@
+ break;
+ }
+
+- nwrt = fwrite(image+i*np, sizeof(byte), (size_t) np, fp);
++ nwrt = fwrite(image+i*npixels, sizeof(byte), (size_t) npixels, fp);
+ fclose(fp);
+
+ if (nwrt == 0) { /* failed to write any data */
+ error = "I/O error writing temporary file";
+ unlink(filename);
+ break;
+- }
+- else if (nwrt < np)
++ }
++ else if (nwrt < npixels)
+ error = "I/O error writing temporary file";
+ }
+
+@@ -291,13 +299,13 @@
+ char *comment;
+ {
+ /* Writes a minimalist FITS file header */
+-
++
+ char *block = fits_block, *bp;
+- int i, j, wrotehist, lenhist;
++ int i, j, lenhist;
+ char history[80];
+
+ for (i=0, bp=block; i<BLOCKSIZE; i++, bp++) *bp = ' ';
+-
++
+ sprintf(history, "Written by XV %s", VERSTR);
+ lenhist = strlen(history);
+
+@@ -309,7 +317,7 @@
+ wrcard(&block[80*i++], "NAXIS2", T_INT, ny, NULL); /* write NAXIS2 card */
+
+ /* Write HISTORY keyword */
+- wrcard(&block[80*i++], "HISTORY", T_STR, lenhist, history);
++ wrcard(&block[80*i++], "HISTORY", T_STR, lenhist, history);
+
+ if (comment && *comment != '\0') {
+ while (*comment == '\n') comment++; /* Skip any blank lines */
+@@ -317,7 +325,7 @@
+ for (j=0; j<72; j++)
+ if (comment[j] == '\0' || comment[j] == '\n') break;
+
+- /*
++ /*
+ * Check to see if it is an xv history record; if so, then avoid
+ * duplicating it.
+ */
+@@ -330,7 +338,7 @@
+ for (i=0, bp=block; i<BLOCKSIZE; i++, bp++) *bp = ' ';
+ i = 0;
+ }
+-
++
+ comment += j;
+ while (*comment == '\n') comment++; /* Skip any blank lines */
+ }
+@@ -358,40 +366,40 @@
+ * Will return an error message if the primary data unit is not a
+ * 2 or 3-dimensional array.
+ */
+-
++
+ FILE *fp;
+ int naxis, i;
+ char *error;
+-
++
+ fp = xv_fopen(file, "r");
+ if (!fp) return "Unable to open FITS file";
+-
++
+ fs->fp = fp;
+ fs->bitpix = 0;
+ fs->naxis = 0;
+ fs->cpos = 0;
+-
++
+ /* read header */
+ error = rdheader(fs);
+ if (error) {
+ ftclose(fs);
+ return error;
+ }
+-
++
+ naxis = fs->naxis;
+-
++
+ /* get number of data */
+ fs->ndata = 1;
+- for (i=0; i<naxis; i++)
++ for (i=0; i<naxis; i++)
+ fs->ndata = fs->ndata * fs->axes[i];
+-
++
+ *nx = fs->axes[0];
+ *ny = fs->axes[1];
+ if (naxis == 2) *nz = 1;
+ else *nz = fs->axes[2];
+-
++
+ *bitpix = fs->bitpix;
+-
++
+ return NULL;
+ }
+
+@@ -418,11 +426,11 @@
+ char *block=fits_block, *p;
+ char *error;
+ long int val; /* the value */
+-
++
+ fs->comment = NULL;
+ commlen = 0;
+ commsize = 256;
+-
++
+ res = fread(block, sizeof(char), (size_t) BLOCKSIZE, fs->fp);
+ if (res != BLOCKSIZE) return "Error reading FITS file";
+ i = 0;
+@@ -464,13 +472,13 @@
+ if (res != BLOCKSIZE) return "Error reading FITS file";
+ i = 0;
+ }
+-
++
+ sprintf(name, "NAXIS%d", j+1);
+ error = rdcard(&block[i*80], name, T_INT, &val);
+ if (error) return error;
+ if (val < 0) return "Bad NAXISn value in FITS file";
+ if (val == 0) return "FITS file does not contain an image";
+-
++
+ if (j < 3) fs->axes[j] = val;
+ else if (val != 1) return "FITS file has more than three dimensions";
+ i++;
+@@ -488,21 +496,21 @@
+ if (res != BLOCKSIZE) return "Unexpected eof in FITS file";
+ i = 0;
+ }
+-
++
+ p = &block[i*80];
+ if (strncmp(p, "END ", (size_t) 8) == 0) break;
+- if (strncmp(p, "HISTORY ", (size_t) 8) == 0 ||
++ if (strncmp(p, "HISTORY ", (size_t) 8) == 0 ||
+ strncmp(p, "COMMENT ", (size_t) 8) == 0) {
+ p += 8; /* skip keyword */
+ for (j=71; j >= 0; j--) if (p[j] != ' ') break;
+ j++; /* make j length of comment */
+ if (j > 0) { /* skip blank comment cards */
+ if (fs->comment == NULL) {
+- fs->comment = (char *) malloc((size_t) commsize);
++ fs->comment = (char *) malloc((size_t) commsize); /* initially 256 */
+ if (fs->comment == NULL)
+ FatalError("Insufficient memory for comment buffer");
+ }
+-
++
+ if (commlen + j + 2 > commsize) { /* if too small */
+ char *new;
+ commsize += commsize; /* double size of array */
+@@ -515,7 +523,7 @@
+ free(fs->comment);
+ fs->comment = new;
+ }
+-
++
+ xvbcopy(p, &fs->comment[commlen], (size_t) j); /* add string */
+ commlen += j;
+ fs->comment[commlen++] = '\n'; /* with trailing cr */
+@@ -556,9 +564,9 @@
+
+ l = strlen(name);
+ if (l) xvbcopy(name, card, (size_t) l); /* copy name */
+-
++
+ if (dtype == T_NOVAL) return;
+-
++
+ if (dtype == T_STR) {
+ l = kvalue;
+ if (l <= 0) return;
+@@ -566,9 +574,9 @@
+ xvbcopy(svalue, &card[8], (size_t) l);
+ return;
+ }
+-
++
+ card[8] = '=';
+-
++
+ if (dtype == T_LOG)
+ card[29] = kvalue ? 'T' : 'F';
+ else { /* T_INT */
+@@ -599,7 +607,7 @@
+ int i, ptr;
+ char namestr[9];
+ static char error[45];
+-
++
+ xvbcopy(card, namestr, (size_t) 8);
+
+ for (i=7; i>=0 && namestr[i] == ' '; i--);
+@@ -609,24 +617,24 @@
+ sprintf(error, "Keyword %s not found in FITS file", name);
+ return error;
+ }
+-
++
+
+ /* get start of value */
+ ptr = 10;
+ while (ptr < 80 && card[ptr] == ' ') ptr++;
+ if (ptr == 80) return "FITS file has missing keyword value"; /* no value */
+-
++
+ if (dtype == T_LOG) {
+ if (ptr != 29 || (card[29] != 'T' && card[29] != 'F'))
+ return "Keyword has bad logical value in FITS file";
+ *kvalue = (card[29] == 'T');
+- }
++ }
+
+ else { /* an integer */
+ int j;
+ long int ival;
+ char num[21];
+-
++
+ if (ptr > 29) return "Keyword has bad integer value in FITS file";
+ xvbcopy(&card[ptr], num, (size_t) (30-ptr));
+ num[30-ptr] = '\0';
+@@ -634,7 +642,7 @@
+ if (j != 1) return "Keyword has bad integer value in FITS file";
+ *kvalue = ival;
+ }
+-
++
+ return NULL;
+ }
+
+@@ -660,13 +668,13 @@
+ */
+
+ int res;
+-
++
+ if (nelem == 0) return 0;
+-
++
+ res = fread(buffer, (size_t) fs->size, (size_t) nelem, fs->fp);
+ /* if failed to read all the data because at end of file */
+ if (res != nelem && feof(fs->fp)) {
+- /* nblock is the number of elements in a record.
++ /* nblock is the number of elements in a record.
+ size is always a factor of BLOCKSIZE */
+
+ int loffs, nblock=BLOCKSIZE/fs->size;
+@@ -714,7 +722,7 @@
+ byte *ptr=buffer;
+
+ /*
+- * conversions. Although the data may be signed, reverse using unsigned
++ * conversions. Although the data may be signed, reverse using unsigned
+ * variables.
+ * Because the native int types may be larger than the types in the file,
+ * we start from the end and work backwards to avoid overwriting data
+@@ -741,12 +749,12 @@
+ ((unsigned int)ptr[2] << 8) |
+ ((unsigned int)ptr[3]);
+ }
+-
++
+ /* convert from IEE 754 single precision to native form */
+ else if (fs->bitpix == -32) {
+ int j, k, expo;
+ static float *exps=NULL;
+-
++
+ if (exps == NULL) {
+ exps = (float *)malloc(256 * sizeof(float));
+ if (exps == NULL) FatalError("Insufficient memory for exps store");
+@@ -754,7 +762,7 @@
+ for (i=151; i < 256; i++) exps[i] = 2.*exps[i-1];
+ for (i=149; i >= 0; i--) exps[i] = 0.5*exps[i+1];
+ }
+-
++
+ for (i=0; i < n; i++, ptr+=4) {
+ k = (int)*ptr;
+ j = ((int)ptr[1] << 16) | ((int)ptr[2] << 8) | (int)ptr[3];
+@@ -765,13 +773,13 @@
+ }
+
+ }
+-
++
+ /* convert from IEE 754 double precision to native form */
+ else if (fs->bitpix == -64) {
+ int expo, k, l;
+ unsigned int j;
+ static double *exps=NULL;
+-
++
+ if (exps == NULL) {
+ exps = (double *)malloc(2048 * sizeof(double));
+ if (exps == NULL) FatalError("Insufficient memory for exps store");
+@@ -779,7 +787,7 @@
+ for (i=1076; i < 2048; i++) exps[i] = 2.*exps[i-1];
+ for (i=1074; i >= 0; i--) exps[i] = 0.5*exps[i+1];
+ }
+-
++
+ for (i=0; i < n; i++, ptr+=8) {
+ k = (int)*ptr;
+ j = ((unsigned int)ptr[1] << 24) | ((unsigned int)ptr[2] << 16) |
+@@ -813,23 +821,36 @@
+ */
+
+ void *voidbuff;
+- int i, n, nrd;
++ int i, n, nrd, bufsize, overflow=0;
+
+ /* if the data is byte, then read it directly */
+ if (fs->bitpix == 8)
+ return ftgdata(fs, cbuff, nelem);
+-
++
+ /* allocate a buffer to store the image */
+- if (fs->bitpix == 16)
+- voidbuff = (void *)malloc(nelem * sizeof(short int));
+- else if (fs->bitpix == 32)
+- voidbuff = (void *)malloc(nelem * sizeof(int));
+- else
+- voidbuff = (void *)malloc(nelem * (size_t) fs->size); /* float, double */
++ if (fs->bitpix == 16) {
++ bufsize = nelem * sizeof(short int);
++ if (bufsize/nelem != (int)sizeof(short int))
++ overflow = 1;
++ } else if (fs->bitpix == 32) {
++ bufsize = nelem * sizeof(int);
++ if (bufsize/nelem != (int)sizeof(short int))
++ overflow = 1;
++ } else {
++ bufsize = nelem * fs->size; /* float, double */
++ if (bufsize/nelem != fs->size)
++ overflow = 1;
++ }
+
++ if (overflow) {
++ SetISTR(ISTR_WARNING, "FITS image dimensions out of range");
++ return 0;
++ }
++
++ voidbuff = (void *)malloc((size_t) bufsize);
+ if (voidbuff == NULL) {
+ char emess[60];
+- sprintf(emess, "Insufficient memory for raw image of %d bytes",
++ sprintf(emess, "Insufficient memory for raw image of %d bytes",
+ nelem*fs->size);
+ FatalError(emess);
+ }
+@@ -843,28 +864,28 @@
+ short int *buffer=voidbuff;
+ int max, min, maxmin_t;
+ float scale;
+-
++
+ min = max = buffer[0];
+ for (i=1; i < n; i++, buffer++) maxmin(*buffer, max, min);
+ scale = (max == min) ? 0. : 255./(float)(max-min);
+-
++
+ /* rescale and convert */
+ for (i=0, buffer=voidbuff; i < n; i++)
+ cbuff[i] = (byte)(scale*(float)((int)buffer[i]-min));
+-
++
+ /* convert long int to byte */
+- }
++ }
+
+ else if (fs->bitpix == 32) {
+ int *buffer=voidbuff;
+ int max, min, maxmin_t;
+ float scale, fmin;
+-
++
+ min = max = buffer[0];
+ for (i=1; i < n; i++, buffer++) maxmin(*buffer, max, min);
+ scale = (max == min) ? 1. : 255./((double)max-(double)min);
+ fmin = (float)min;
+-
++
+ /* rescale and convert */
+ if (scale < 255./2.1e9) /* is max-min too big for an int ? */
+ for (i=0, buffer=voidbuff; i < n; i++)
+@@ -872,34 +893,34 @@
+ else /* use integer subtraction */
+ for (i=0, buffer=voidbuff; i < n; i++)
+ cbuff[i] = (byte)(scale*(float)(buffer[i]-min));
+-
+-
+- }
++
++
++ }
+
+ /* convert float to byte */
+ else if (fs->bitpix == -32) {
+ float *buffer=voidbuff;
+ float max, min, maxmin_t, scale;
+-
++
+ min = max = buffer[0];
+ for (i=1; i < n; i++, buffer++) maxmin(*buffer, max, min);
+ scale = (max == min) ? 0. : 255./(max-min);
+-
++
+ /* rescale and convert */
+ for (i=0, buffer=voidbuff; i < n; i++)
+ cbuff[i] = (byte)(scale*(buffer[i]-min));
+-
+- }
++
++ }
+
+ /* convert double to byte */
+ else if (fs->bitpix == -64) {
+ double *buffer=voidbuff;
+ double max, min, maxmin_t, scale;
+-
++
+ min = max = buffer[0];
+ for (i=1; i < n; i++, buffer++) maxmin(*buffer, max, min);
+ scale = (max == min) ? 0. : 255./(max-min);
+-
++
+ /* rescale and convert */
+ for (i=0, buffer=voidbuff; i < n; i++)
+ cbuff[i] = (byte)(scale*(buffer[i]-min));
+@@ -923,7 +944,7 @@
+ int i;
+ int j, v;
+ byte *buff1, *buff2;
+-
++
+ for (i=0; i < ny/2; i++) {
+ buff1 = &buffer[i*nx];
+ buff2 = &buffer[(ny-1-i)*nx];
+diff -ruN xv-3.10a/xvgam.c xv-3.10a-bugfixes/xvgam.c
+--- xv-3.10a/xvgam.c 1995-01-13 11:51:14.000000000 -0800
++++ xv-3.10a-bugfixes/xvgam.c 2004-05-16 18:02:11.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvgam.c
+ *
+ * callable functions:
+@@ -87,7 +87,7 @@
+ GRAF_STATE istate, rstate, gstate, bstate;
+ };
+
+-static struct gamstate undo[MAXUNDO], preset[4], defstate;
++static struct gamstate undo[MAXUNDO], preset[4], defstate;
+ static struct gamstate *defLoadState;
+
+ static int uptr, uhead, utail;
+@@ -153,7 +153,7 @@
+ static void dragHueDial PARM((void));
+ static void dragEditColor PARM((void));
+
+-static void HDCreate PARM((HDIAL *, Window, int, int, int, int,
++static void HDCreate PARM((HDIAL *, Window, int, int, int, int,
+ int, int, char *, u_long, u_long));
+
+ static void HDRedraw PARM((HDIAL *, int));
+@@ -212,13 +212,13 @@
+ {
+ XSetWindowAttributes xswa;
+
+- gamW = CreateWindow("xv color editor", "XVcedit", geom,
++ gamW = CreateWindow("xv color editor", "XVcedit", geom,
+ GAMW, GAMH, infofg,infobg, 0);
+ if (!gamW) FatalError("can't create cedit window!");
+-
++
+ cmapF = XCreateSimpleWindow(theDisp,gamW, 10, 8,CMAPF_WIDE,CMAPF_HIGH,
+ 1,infofg,infobg);
+- butF = XCreateSimpleWindow(theDisp,gamW, 10, 336,BUTF_WIDE,BUTF_HIGH,
++ butF = XCreateSimpleWindow(theDisp,gamW, 10, 336,BUTF_WIDE,BUTF_HIGH,
+ 1,infofg,infobg);
+ modF = XCreateSimpleWindow(theDisp,gamW, 10, 438,MODF_WIDE,MODF_HIGH,
+ 1,infofg,infobg);
+@@ -227,7 +227,7 @@
+ rgbF = XCreateSimpleWindow(theDisp,gamW, 467, 8,RGBF_WIDE,RGBF_HIGH,
+ 1,infofg,infobg);
+
+- if (!cmapF || !butF || !modF || !hsvF || !rgbF)
++ if (!cmapF || !butF || !modF || !hsvF || !rgbF)
+ FatalError("couldn't create frame windows");
+
+ #ifdef BACKING_STORE
+@@ -251,25 +251,25 @@
+ /********** COLORMAP editing doo-wahs ***********/
+
+
+- BTCreate(&gbut[G_BCOLUNDO], cmapF, 5, 165, 66, BUTTH,
++ BTCreate(&gbut[G_BCOLUNDO], cmapF, 5, 165, 66, BUTTH,
+ "ColUndo", infofg, infobg, hicol, locol);
+- BTCreate(&gbut[G_BCOLREV], cmapF, 5 + 66 + 1, 165, 67, BUTTH,
++ BTCreate(&gbut[G_BCOLREV], cmapF, 5 + 66 + 1, 165, 67, BUTTH,
+ "Revert", infofg, infobg, hicol, locol);
+- BTCreate(&gbut[G_BHSVRGB], cmapF, 5+66+67+2, 165, 66, BUTTH,
++ BTCreate(&gbut[G_BHSVRGB], cmapF, 5+66+67+2, 165, 66, BUTTH,
+ "RGB/HSV", infofg, infobg, hicol, locol);
+
+- BTCreate(&gbut[G_BMONO], cmapF, 5, 189, 66, BUTTH,
++ BTCreate(&gbut[G_BMONO], cmapF, 5, 189, 66, BUTTH,
+ "Grey", infofg, infobg, hicol, locol);
+- BTCreate(&gbut[G_BRV], cmapF, 5 + 66 + 1, 189, 67, BUTTH,
++ BTCreate(&gbut[G_BRV], cmapF, 5 + 66 + 1, 189, 67, BUTTH,
+ "RevVid", infofg, infobg, hicol, locol);
+- BTCreate(&gbut[G_BRNDCOL], cmapF, 5 + 66 + 67 + 2, 189, 66, BUTTH,
++ 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,360,180, 5,
+ 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,360,180, 5,
+ 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,360,180, 5,
+ infofg, infobg, hicol, locol, "Value", NULL);
+
+ rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor;
+@@ -291,44 +291,44 @@
+ #define BY2 (BY0 + BYSPACE*2)
+ #define BY3 (BY0 + BYSPACE*3)
+
+- BTCreate(&gbut[G_BAPPLY], butF, BX0,BY0, 52,BUTTH,"Apply",
++ BTCreate(&gbut[G_BAPPLY], butF, BX0,BY0, 52,BUTTH,"Apply",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BNOGAM], butF, BX0,BY1, 52,BUTTH,"NoMod",
++ BTCreate(&gbut[G_BNOGAM], butF, BX0,BY1, 52,BUTTH,"NoMod",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BMAXCONT],butF, BX0,BY2, 52,BUTTH,"Norm",
++ BTCreate(&gbut[G_BMAXCONT],butF, BX0,BY2, 52,BUTTH,"Norm",
+ infofg,infobg,hicol,locol);
+ BTCreate(&gbut[G_BHISTEQ], butF, BX0,BY3, 52,BUTTH,"HistEq",
+ infofg,infobg,hicol,locol);
+
+ BTCreate(&gbut[G_BUP_BR],butF, BX1,BY0, 52,BUTTH,"Brite",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BDN_BR],butF, BX1,BY1, 52,BUTTH,"Dim",
++ BTCreate(&gbut[G_BDN_BR],butF, BX1,BY1, 52,BUTTH,"Dim",
+ infofg,infobg,hicol,locol);
+ BTCreate(&gbut[G_BUP_CN],butF, BX1,BY2, 52,BUTTH,"Sharp",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BDN_CN],butF, BX1,BY3, 52,BUTTH,"Dull",
++ BTCreate(&gbut[G_BDN_CN],butF, BX1,BY3, 52,BUTTH,"Dull",
+ infofg,infobg,hicol,locol);
+
+- BTCreate(&gbut[G_BRESET],butF, BX2, BY0, 52,BUTTH,"Reset",
++ BTCreate(&gbut[G_BRESET],butF, BX2, BY0, 52,BUTTH,"Reset",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_B1], butF, BX2, BY1, 25,BUTTH,"1",
++ BTCreate(&gbut[G_B1], butF, BX2, BY1, 25,BUTTH,"1",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_B2], butF, BX2+26,BY1, 26,BUTTH,"2",
++ BTCreate(&gbut[G_B2], butF, BX2+26,BY1, 26,BUTTH,"2",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_B3], butF, BX2, BY2, 25,BUTTH,"3",
++ BTCreate(&gbut[G_B3], butF, BX2, BY2, 25,BUTTH,"3",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_B4], butF, BX2+26,BY2, 26,BUTTH,"4",
++ BTCreate(&gbut[G_B4], butF, BX2+26,BY2, 26,BUTTH,"4",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BSET], butF, BX2, BY3, 52,BUTTH,"Set",
++ BTCreate(&gbut[G_BSET], butF, BX2, BY3, 52,BUTTH,"Set",
+ infofg,infobg,hicol,locol);
+
+- BTCreate(&gbut[G_BUNDO], butF, BX3, BY0, 52,BUTTH,"Undo",
++ BTCreate(&gbut[G_BUNDO], butF, BX3, BY0, 52,BUTTH,"Undo",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BREDO], butF, BX3, BY1, 52,BUTTH,"Redo",
++ BTCreate(&gbut[G_BREDO], butF, BX3, BY1, 52,BUTTH,"Redo",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BGETRES],butF,BX3, BY2, 52,BUTTH,"CutRes",
++ BTCreate(&gbut[G_BGETRES],butF,BX3, BY2, 52,BUTTH,"CutRes",
+ infofg,infobg,hicol,locol);
+- BTCreate(&gbut[G_BCLOSE],butF, BX3, BY3, 52,BUTTH,"Close",
++ BTCreate(&gbut[G_BCLOSE],butF, BX3, BY3, 52,BUTTH,"Close",
+ infofg,infobg,hicol,locol);
+
+
+@@ -338,11 +338,11 @@
+
+ CBCreate(&enabCB, modF,2,2, "Display with HSV/RGB mods.",
+ infofg,infobg,hicol,locol);
+- CBCreate(&autoCB, modF,2,2+17, "Auto-apply HSV/RGB mods.",
++ CBCreate(&autoCB, modF,2,2+17, "Auto-apply HSV/RGB mods.",
+ infofg,infobg,hicol,locol);
+ CBCreate(&dragCB, modF,2,2+17*2,"Auto-apply while dragging.",
+ infofg,infobg,hicol,locol);
+- CBCreate(&resetCB,modF,2,2+17*3,"Auto-reset on new image.",
++ CBCreate(&resetCB,modF,2,2+17*3,"Auto-reset on new image.",
+ infofg,infobg,hicol,locol);
+
+ enabCB.val = autoCB.val = resetCB.val = dragCB.val = 1;
+@@ -359,23 +359,23 @@
+
+ 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, 100, 0, 5,
+ infofg, infobg,hicol,locol, "Saturation", "%");
+
+- hueRB = RBCreate(NULL, hsvF, 7, 153, "1",
++ hueRB = RBCreate(NULL, hsvF, 7, 153, "1",
+ infofg, infobg,hicol,locol);
+- RBCreate (hueRB,hsvF, 47, 153, "2",
++ RBCreate (hueRB,hsvF, 47, 153, "2",
+ infofg, infobg,hicol,locol);
+- RBCreate (hueRB,hsvF, 87, 153, "3",
++ RBCreate (hueRB,hsvF, 87, 153, "3",
+ infofg, infobg,hicol,locol);
+- RBCreate (hueRB,hsvF, 7, 170, "4",
++ RBCreate (hueRB,hsvF, 7, 170, "4",
+ infofg, infobg,hicol,locol);
+- RBCreate (hueRB,hsvF, 47, 170, "5",
++ RBCreate (hueRB,hsvF, 47, 170, "5",
+ infofg, infobg,hicol,locol);
+- RBCreate (hueRB,hsvF, 87, 170, "6",
++ RBCreate (hueRB,hsvF, 87, 170, "6",
+ infofg, infobg,hicol,locol);
+
+- BTCreate(&hueclrB, hsvF, 127, 158, 70, BUTTH, "Reset",
++ BTCreate(&hueclrB, hsvF, 127, 158, 70, BUTTH, "Reset",
+ infofg, infobg,hicol,locol);
+
+ initHmap();
+@@ -394,13 +394,13 @@
+
+ InitGraf(&gGraf);
+ CreateGraf(&gGraf, rgbF, 10, 179, infofg, infobg, "Green");
+-
++
+ InitGraf(&bGraf);
+ CreateGraf(&bGraf, rgbF, 10, 338, infofg, infobg, "Blue");
+
+ satDial.drawobj = dragGamma;
+ intGraf.drawobj = rGraf.drawobj = gGraf.drawobj = bGraf.drawobj = dragGamma;
+-
++
+ SetHSVmode();
+
+ ctrls2gamstate(&defstate);
+@@ -415,14 +415,14 @@
+ Str2Graf(&preset[1].rstate,"L 4 : 0,0 : 127,0 : 128,255 : 255,255");
+ Str2Graf(&preset[1].gstate,"L 4 : 0,0 : 127,0 : 128,255 : 255,255");
+ Str2Graf(&preset[1].bstate,"L 4 : 0,0 : 127,0 : 128,255 : 255,255");
+-
++
+
+ /* set up preset2 as a 'temperature' pseudo-color preset */
+ ctrls2gamstate(&preset[2]);
+ Str2Graf(&preset[2].rstate,"S 4 : 0,0 : 105,0 : 155,140 : 255,255");
+ Str2Graf(&preset[2].gstate,"S 5 : 0,0 : 57,135 : 127,255 : 198,135 : 255,0");
+ Str2Graf(&preset[2].bstate,"S 4 : 0,255 : 100,140 : 150,0 : 255,0");
+-
++
+
+ /* set up preset3 as a 'map' pseudo-color preset */
+ ctrls2gamstate(&preset[3]);
+@@ -480,7 +480,7 @@
+
+ computeHSVlinear();
+ }
+-
++
+
+ /***************************************************/
+ int GamCheckEvent(xev)
+@@ -492,14 +492,14 @@
+ int rv;
+
+ rv = 1;
+-
++
+ 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 &&
++ if (e->count > 0 &&
+ (e->window == satDial.win || e->window == rhDial.win ||
+ e->window == gsDial.win || e->window == bvDial.win ||
+ e->window == cmapF || e->window == modF ||
+@@ -600,7 +600,7 @@
+
+
+ else if (e->window == hsvF) {
+- if (HDClick(&srcHD, x,y) || HDClick(&dstHD, x,y)) {
++ if (HDClick(&srcHD, x,y) || HDClick(&dstHD, x,y)) {
+ dials2hmap();
+ build_hremap();
+ changedGam();
+@@ -654,7 +654,7 @@
+ e->window == gsDial.win ||
+ e->window == bvDial.win) {
+
+- if ((e->window == rhDial.win && DTrack(&rhDial, x,y)) ||
++ if ((e->window == rhDial.win && DTrack(&rhDial, x,y)) ||
+ (e->window == gsDial.win && DTrack(&gsDial, x,y)) ||
+ (e->window == bvDial.win && DTrack(&bvDial, x,y))) {
+ saveCMap(&prevcmap);
+@@ -683,7 +683,7 @@
+ XKeyEvent *e = (XKeyEvent *) xev;
+ char buf[128]; KeySym ks;
+ int stlen;
+-
++
+ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
+ buf[stlen] = '\0';
+
+@@ -792,7 +792,7 @@
+ int x,y;
+ {
+ XPoint pts[8];
+-
++
+ pts[0].x = x+10; pts[0].y = y;
+ pts[1].x = x-4; pts[1].y = y-100;
+ pts[2].x = x-4; pts[2].y = y-40;
+@@ -873,11 +873,11 @@
+ XSetForeground(theDisp, theGC, infofg);
+
+ if (picType != PIC8) {
+- CenterString(cmapF, CMAPX + CMAPW/2, CMAPY + CMAPH/2,
++ CenterString(cmapF, CMAPX + CMAPW/2, CMAPY + CMAPH/2,
+ "No colormap in 24-bit mode.");
+ return;
+ }
+-
++
+
+
+ for (i=0; i<numcols; i++) {
+@@ -941,14 +941,14 @@
+ if (bp->win == butF && PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
+ }
+
+- /* if 'Set' is lit, and we didn't click 'set' or 'Reset' or '1'..'4',
++ /* if 'Set' is lit, and we didn't click 'set' or 'Reset' or '1'..'4',
+ turn it off */
+ if (i!=G_BSET && i!=G_B1 && i!=G_B2 && i!=G_B3 && i!=G_B4 && i!=G_BRESET
+ && gbut[G_BSET].lit) {
+- gbut[G_BSET].lit = 0;
++ gbut[G_BSET].lit = 0;
+ BTRedraw(&gbut[G_BSET]);
+ }
+-
++
+
+ if (i<G_NBUTTS) { /* found one */
+ if (BTTrack(bp)) doCmd(i);
+@@ -1003,7 +1003,7 @@
+ } /* if i<numcols */
+ } /* if but==1 */
+
+-
++
+ else if (but==2) { /* color smooth */
+ int cellnum, delc, col1, j, delr, delg, delb;
+
+@@ -1025,9 +1025,9 @@
+ gcmap[col1 + i] = gcmap[col1] + (delg * i) / delc;
+ bcmap[col1 + i] = bcmap[col1] + (delb * i) / delc;
+
+- if (cellgroup[col1 + i]) {
++ if (cellgroup[col1 + i]) {
+ /* propogate new color to all members of this group */
+- for (j=0; j<numcols; j++)
++ for (j=0; j<numcols; j++)
+ if (cellgroup[j] == cellgroup[col1 + i]) {
+ rcmap[j] = rcmap[col1 + i];
+ gcmap[j] = gcmap[col1 + i];
+@@ -1043,7 +1043,7 @@
+ }
+
+ if (i<numcols) { /* something changed */
+- xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
++ xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
+ sizeof(struct cmapstate));
+ BTSetActive(&gbut[G_BCOLUNDO],1);
+ applyGamma(1);
+@@ -1067,7 +1067,7 @@
+
+ lastcell = curcell;
+
+- j = XGrabPointer(theDisp, cmapF, False, 0, GrabModeAsync,
++ j = XGrabPointer(theDisp, cmapF, False, 0, GrabModeAsync,
+ GrabModeAsync, None, None, (Time) CurrentTime);
+ while (1) {
+ Window rW,cW;
+@@ -1076,7 +1076,7 @@
+
+ if (XQueryPointer(theDisp,cmapF,&rW,&cW,&rx,&ry,&x,&y,&mask)) {
+ /* if button3 and shift released */
+- if (!(mask & (Button3Mask | ShiftMask))) break;
++ if (!(mask & (Button3Mask | ShiftMask))) break;
+
+ /* if user lets go of B3, reset addonly/delonly flag & lastcell */
+ if (!(mask & Button3Mask) && (mask & ShiftMask)) {
+@@ -1112,7 +1112,7 @@
+
+ if (recolor) {
+ /* colors changed. save to color undo area */
+- xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
++ xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
+ sizeof(struct cmapstate));
+ BTSetActive(&gbut[G_BCOLUNDO],1);
+ applyGamma(1); /* have to regen entire image when groupings chg */
+@@ -1146,12 +1146,12 @@
+ /* cases: curgroup>0, clicked on something in same group
+ remove target from group
+ curgroup>0, clicked on something in different group
+- merge groups. (target group gets
++ merge groups. (target group gets
+ set equal to current values)
+ curgroup>0, clicked on something in no group
+ add target to curgroup
+ curgroup=0, clicked on something in a group
+- add editColor to target group,
++ add editColor to target group,
+ set curgroup = target group
+ target group gets current values
+ curgroup=0, clicked on something in no group
+@@ -1185,7 +1185,7 @@
+ }
+ }
+
+- else if ((mode!=DELONLY) && cellgroup[cnum] != curgroup &&
++ else if ((mode!=DELONLY) && cellgroup[cnum] != curgroup &&
+ cellgroup[cnum]>0) {
+ /* merge clicked-on group into curgroup */
+ mode = ADDONLY;
+@@ -1196,11 +1196,11 @@
+ selectCell(i,1);
+ rcmap[i] = rcmap[editColor];
+ gcmap[i] = gcmap[editColor];
+- bcmap[i] = bcmap[editColor];
++ bcmap[i] = bcmap[editColor];
+ }
+ }
+ }
+-
++
+ else if ((mode!=DELONLY) && cellgroup[cnum] == 0) {
+ /* merge clicked-on cell into curgroup */
+ mode = ADDONLY;
+@@ -1209,7 +1209,7 @@
+ selectCell(cnum,1);
+ rcmap[cnum] = rcmap[editColor];
+ gcmap[cnum] = gcmap[editColor];
+- bcmap[cnum] = bcmap[editColor];
++ bcmap[cnum] = bcmap[editColor];
+ }
+ }
+
+@@ -1224,14 +1224,14 @@
+ selectCell(i,1);
+ rcmap[i] = rcmap[editColor];
+ gcmap[i] = gcmap[editColor];
+- bcmap[i] = bcmap[editColor];
++ bcmap[i] = bcmap[editColor];
+ }
+ }
+ curgroup = cellgroup[cnum];
+ cellgroup[editColor] = curgroup;
+ }
+-
+- else if ((mode!=DELONLY) && (cellgroup[cnum] == 0)
++
++ else if ((mode!=DELONLY) && (cellgroup[cnum] == 0)
+ && (cnum != editColor)) {
+ /* create new group for these two cells (cnum and editColor) */
+ mode = ADDONLY;
+@@ -1247,14 +1247,14 @@
+ }
+
+ return rv;
+-}
+-
++}
++
+
+ /*********************/
+ void ChangeEC(num)
+ int num;
+ {
+- /* given a color # that is to become the new editColor, do all
++ /* given a color # that is to become the new editColor, do all
+ highlighting/unhighlighting, copy editColor's rgb values to
+ the rgb/hsv dials */
+
+@@ -1301,8 +1301,8 @@
+ DSetVal(&bvDial, bcmap[editColor]);
+ }
+ }
+-
+-
++
++
+ /*********************/
+ void ApplyECctrls()
+ {
+@@ -1310,7 +1310,7 @@
+
+ if (hsvmode) {
+ int rv, gv, bv;
+- hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0,
++ hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0,
+ ((double) bvDial.val) / 100.0, &rv, &gv, &bv);
+ rcmap[editColor] = rv;
+ gcmap[editColor] = gv;
+@@ -1330,7 +1330,7 @@
+ {
+ /* this function generates the Floyd-Steinberg gamma curve (fsgamcr)
+
+- This function generates a 4 point spline curve to be used as a
++ This function generates a 4 point spline curve to be used as a
+ non-linear grey 'colormap'. Two of the points are nailed down at 0,0
+ and 255,255, and can't be changed. You specify the other two. If
+ you specify points on the line (0,0 - 255,255), you'll get the normal
+@@ -1345,7 +1345,7 @@
+ double yf[4];
+
+ InitSpline(x, y, 4, yf);
+-
++
+ for (i=0; i<256; i++) {
+ j = (int) EvalSpline(x, y, yf, 4, (double) i);
+ if (j<0) j=0;
+@@ -1364,14 +1364,14 @@
+
+ switch (cmd) {
+
+- case G_BAPPLY:
++ case G_BAPPLY:
+ if (enabCB.val != 1) { enabCB.val = 1; CBRedraw(&enabCB); }
+- applyGamma(0);
++ applyGamma(0);
+ break;
+
+ case G_BNOGAM:
+ if (enabCB.val != 0) { enabCB.val = 0; CBRedraw(&enabCB); }
+- applyGamma(0);
++ applyGamma(0);
+ break;
+
+ case G_BUNDO: gamUndo(); break;
+@@ -1383,7 +1383,7 @@
+
+
+
+- case G_BDN_BR:
++ case G_BDN_BR:
+ case G_BUP_BR: GetGrafState(&intGraf, &gs);
+ for (i=0; i < gs.nhands; i++) {
+ if (cmd==G_BUP_BR) gs.hands[i].y += 10;
+@@ -1434,7 +1434,7 @@
+ else if (cmd==G_B3) ptr = &preset[2];
+ else if (cmd==G_B4) ptr = &preset[3];
+ else if (cmd==G_BRESET) ptr = &defstate;
+-
++
+ if (gbut[G_BSET].lit) {
+ ctrls2gamstate(ptr);
+ gbut[G_BSET].lit = 0;
+@@ -1454,7 +1454,7 @@
+ break;
+
+
+- case G_BCOLREV:
++ case G_BCOLREV:
+ {
+ struct cmapstate tmp1cmap;
+ int gchg;
+@@ -1463,9 +1463,9 @@
+ gchg = (i!=numcols);
+
+ saveCMap(&tmpcmap); /* buffer current cmapstate */
+-
++
+ for (i=0; i<numcols; i++) { /* do reversion */
+- rcmap[i] = rorg[i];
++ rcmap[i] = rorg[i];
+ gcmap[i] = gorg[i];
+ bcmap[i] = borg[i];
+ cellgroup[i] = 0;
+@@ -1473,12 +1473,12 @@
+ curgroup = maxgroup = 0;
+
+ saveCMap(&tmp1cmap); /* buffer current cmapstate */
+-
++
+ /* prevent multiple 'Undo All's from filling Undo buffer */
+- if (xvbcmp((char *) &tmpcmap, (char *) &tmp1cmap,
++ if (xvbcmp((char *) &tmpcmap, (char *) &tmp1cmap,
+ sizeof(struct cmapstate))) {
+ /* the reversion changed the cmapstate */
+- xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
++ xvbcopy((char *) &tmpcmap, (char *) &prevcmap,
+ sizeof(struct cmapstate));
+ BTSetActive(&gbut[G_BCOLUNDO],1);
+
+@@ -1496,7 +1496,7 @@
+ BTSetActive(&gbut[G_BCOLUNDO],1);
+ rndCols();
+ break;
+-
++
+ case G_BRV:
+ saveCMap(&prevcmap);
+ BTSetActive(&gbut[G_BCOLUNDO],1);
+@@ -1523,7 +1523,7 @@
+ ChangeEC(editColor);
+ applyGamma(1);
+ break;
+-
++
+
+ case G_BMONO:
+ saveCMap(&prevcmap);
+@@ -1534,7 +1534,7 @@
+ ChangeEC(editColor);
+ applyGamma(1);
+ break;
+-
++
+
+ case G_BCOLUNDO:
+ for (i=0; i<numcols && cellgroup[i]==prevcmap.cellgroup[i]; i++);
+@@ -1560,7 +1560,7 @@
+ rhDial.title = "Red";
+ 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);
+@@ -1615,12 +1615,12 @@
+ GammifyColors();
+
+ /* if current 'desired' colormap hasn't changed, don't DO anything */
+- if (!xvbcmp((char *) rMap, (char *) oldr, (size_t) numcols) &&
+- !xvbcmp((char *) gMap, (char *) oldg, (size_t) numcols) &&
++ if (!xvbcmp((char *) rMap, (char *) oldr, (size_t) numcols) &&
++ !xvbcmp((char *) gMap, (char *) oldg, (size_t) numcols) &&
+ !xvbcmp((char *) bMap, (char *) oldb, (size_t) numcols)) return;
+
+ /* special case: if using R/W color, just modify the colors and leave */
+- if (allocMode==AM_READWRITE && rwthistime &&
++ if (allocMode==AM_READWRITE && rwthistime &&
+ (!cmapchange || nfcols==numcols)) {
+ XColor ctab[256];
+
+@@ -1647,10 +1647,10 @@
+ gdisp[i] = gMap[rwpc2pc[i]];
+ bdisp[i] = bMap[rwpc2pc[i]];
+ }
+-
++
+ return;
+ }
+-
++
+ FreeColors();
+
+ {
+@@ -1663,10 +1663,10 @@
+ AllocColors();
+
+
+- if (epicMode != EM_RAW) {
++ if (epicMode != EM_RAW) {
+ /* regen image, as we'll probably want to dither differently, given
+ new colors and such */
+-
++
+ GenerateEpic(eWIDE, eHIGH);
+ }
+ }
+@@ -1701,7 +1701,7 @@
+ for (i=255; i>0 && !hist[i]; i--);
+ *rmaxv = i;
+ }
+-
++
+ else { /* PIC24 */
+ int v,minv,maxv;
+
+@@ -1724,7 +1724,7 @@
+ hist[v]++;
+ }
+ }
+-
++
+ *rminv = minv; *rmaxv = maxv;
+ }
+
+@@ -1764,13 +1764,13 @@
+ int i, histeq[256], minv, maxv;
+
+ calcHistEQ(histeq, &minv, &maxv); /* ignore minv,maxv */
+-
+- for (i=0; i<256; i++)
++
++ for (i=0; i<256; i++)
+ intGraf.func[i] = histeq[i];
+-
++
+ for (i=0; i< intGraf.nhands; i++)
+ intGraf.hands[i].y = intGraf.func[intGraf.hands[i].x];
+-
++
+ intGraf.entergamma = 0;
+
+ if (gamUp) {
+@@ -1797,7 +1797,7 @@
+ if (v>maxv) maxv = v;
+ }
+ }
+- else {
++ else {
+ int histeq[256];
+ calcHistEQ(histeq, &minv, &maxv); /* ignore histeq */
+ }
+@@ -1833,11 +1833,11 @@
+ for (i=0; i<numcols; i++) Gammify1(i);
+ }
+ else {
+- for (i=0; i<numcols; i++) {
++ for (i=0; i<numcols; i++) {
+ rMap[i] = rcmap[i];
+ gMap[i] = gcmap[i];
+ bMap[i] = bcmap[i];
+- if (!ncols)
++ if (!ncols)
+ cols[i] = (((int)rMap[i]) + ((int)gMap[i]) + ((int)bMap[i]) >= 128*3)
+ ? white : black;
+ }
+@@ -1875,7 +1875,7 @@
+ if (DEBUG>1) fprintf(stderr," (v=%f)",v);
+
+ if (h>=0) {
+- hi = (int) h;
++ hi = (int) h;
+ if (hi<0) hi += 360;
+ if (hi>=360) hi -= 360;
+ h = (double) hremap[hi];
+@@ -1884,7 +1884,7 @@
+ if (whtHD.enabCB.val) {
+ h = (double) whtHD.stval;
+ s = (double) whtHD.satval / 100.0;
+-
++
+ /* special case: if stval = satval = 0, set hue = -1 */
+ if (whtHD.stval == 0 && whtHD.satval == 0) h = -1.0;
+ }
+@@ -1899,13 +1899,13 @@
+ if (DEBUG>1) fprintf(stderr," -> %d,%d,%d",rv,gv,bv);
+ }
+
+- rMap[col] = rGraf.func[rv];
++ rMap[col] = rGraf.func[rv];
+ gMap[col] = gGraf.func[gv];
+ bMap[col] = bGraf.func[bv];
+
+- if (!ncols)
+- cols[col] =
+- (((int)rMap[col]) + ((int)gMap[col]) + ((int)bMap[col]) >= 128*3)
++ if (!ncols)
++ cols[col] =
++ (((int)rMap[col]) + ((int)gMap[col]) + ((int)bMap[col]) >= 128*3)
+ ? white : black;
+
+ if (DEBUG>1) fprintf(stderr," -> %d,%d,%d\n",rMap[col],gMap[col],bMap[col]);
+@@ -2001,8 +2001,8 @@
+ {
+ xvbcopy((char *) hmap, (char *) gs->hmap, sizeof(hmap));
+
+- gs->wht_stval = whtHD.stval;
+- gs->wht_satval = whtHD.satval;
++ gs->wht_stval = whtHD.stval;
++ gs->wht_satval = whtHD.satval;
+ gs->wht_enab = whtHD.enabCB.val;
+
+ gs->hueRBnum = RBWhich(hueRB);
+@@ -2042,7 +2042,7 @@
+ srcHD.ccwise = hm->src_ccw;
+ HDRedraw(&srcHD, HD_ALL | HD_CLEAR);
+ }
+-
++
+ if (dstHD.stval != hm->dst_st ||
+ dstHD.enval != hm->dst_en ||
+ dstHD.ccwise != hm->dst_ccw) {
+@@ -2051,7 +2051,7 @@
+ dstHD.ccwise = hm->dst_ccw;
+ HDRedraw(&dstHD, HD_ALL | HD_CLEAR);
+ }
+- }
++ }
+
+
+ if (whtHD.stval != gs->wht_stval || whtHD.satval != gs->wht_satval ||
+@@ -2063,7 +2063,7 @@
+ HDRedraw(&whtHD, HD_ALL | HD_CLEAR);
+ changed++;
+ }
+-
++
+ if (gs->satval != satDial.val) {
+ DSetVal(&satDial,gs->satval);
+ changed++;
+@@ -2203,7 +2203,7 @@
+ }
+
+
+-
++
+
+ /*********************/
+ static void parseResources()
+@@ -2226,7 +2226,7 @@
+ if (i) { sprintf(gname,"preset%d",i); gsp = &preset[i-1]; }
+ else { sprintf(gname,"default"); gsp = &defstate; }
+
+- xvbcopy((char *) gsp, (char *) &gs,
++ xvbcopy((char *) gsp, (char *) &gs,
+ sizeof(struct gamstate)); /* load 'gs' with defaults */
+
+ for (j=0; j<6; j++) { /* xv.*.huemap resources */
+@@ -2239,7 +2239,7 @@
+ lower_str(def_str);
+ if (sscanf(def_str,"%d %d %s %d %d %s",
+ &fst, &fen, fcw, &tst, &ten, tcw) != 6) {
+- fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
++ fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
+ cmd, tmp, def_str);
+ }
+ else {
+@@ -2260,7 +2260,7 @@
+ int wst, wsat, enab;
+ if (DEBUG) fprintf(stderr,"parseResource 'xv.%s: %s'\n",tmp, def_str);
+ if (sscanf(def_str,"%d %d %d", &wst, &wsat, &enab) != 3) {
+- fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
++ fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
+ cmd, tmp, def_str);
+ }
+ else { /* successful parse */
+@@ -2276,7 +2276,7 @@
+ int sat;
+ if (DEBUG) fprintf(stderr,"parseResource 'xv.%s: %s'\n",tmp, def_str);
+ if (sscanf(def_str,"%d", &sat) != 1) {
+- fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
++ fprintf(stderr,"%s: unable to parse resource 'xv.%s: %s'\n",
+ cmd, tmp, def_str);
+ }
+ else { /* successful parse */
+@@ -2304,7 +2304,7 @@
+ }
+ }
+ }
+-
++
+ /* copy (potentially) modified gs back to default/preset */
+ xvbcopy((char *) &gs, (char *) gsp, sizeof(struct gamstate));
+ }
+@@ -2324,16 +2324,16 @@
+ /* write out current state */
+ ctrls2gamstate(&gstate);
+ strcpy(gname, "xv.default");
+-
++
+ /* write out huemap resources */
+ for (i=0; i<6; i++) {
+ if (1 || gstate.hmap[i].src_st != gstate.hmap[i].dst_st ||
+ gstate.hmap[i].src_en != gstate.hmap[i].dst_en ||
+ gstate.hmap[i].src_ccw != gstate.hmap[i].dst_ccw) {
+- sprintf(tmp, "%s.huemap%d: %3d %3d %3s %3d %3d %3s\n", gname, i+1,
+- gstate.hmap[i].src_st, gstate.hmap[i].src_en,
++ sprintf(tmp, "%s.huemap%d: %3d %3d %3s %3d %3d %3s\n", gname, i+1,
++ gstate.hmap[i].src_st, gstate.hmap[i].src_en,
+ gstate.hmap[i].src_ccw ? "CCW" : "CW",
+- gstate.hmap[i].dst_st, gstate.hmap[i].dst_en,
++ gstate.hmap[i].dst_st, gstate.hmap[i].dst_en,
+ gstate.hmap[i].dst_ccw ? "CCW" : "CW");
+ strcat(rsrc, tmp);
+ }
+@@ -2341,7 +2341,7 @@
+
+ /* write out whtmap resource */
+ if (1 || gstate.wht_stval || gstate.wht_satval || gstate.wht_enab != 1) {
+- sprintf(tmp, "%s.whtmap: %d %d %d\n", gname, gstate.wht_stval,
++ sprintf(tmp, "%s.whtmap: %d %d %d\n", gname, gstate.wht_stval,
+ gstate.wht_satval, gstate.wht_enab);
+ strcat(rsrc, tmp);
+ }
+@@ -2372,7 +2372,7 @@
+
+ NewCutBuffer(rsrc);
+ }
+-
++
+
+ /*****************************/
+ static void dragGamma ()
+@@ -2381,14 +2381,14 @@
+ while gamma ctrls are being dragged
+ applies change to image if dragCB.val is set
+ does NOT call saveGamState() (as changedGam does) */
+-
++
+ if (dragCB.val && dragCB.active) {
+ hsvnonlinear = 1; /* force HSV calculations during drag */
+ applyGamma(0);
+ }
+ }
+
+-
++
+ /*****************************/
+ static void dragHueDial()
+ {
+@@ -2396,7 +2396,7 @@
+ while hue gamma ctrls are being dragged
+ applies change to image if dragCB.val is set
+ does NOT call saveGamState() (as changedGam does) */
+-
++
+ if (dragCB.val && dragCB.active) {
+ dials2hmap();
+ build_hremap();
+@@ -2413,14 +2413,14 @@
+ while color editor ctrls are being dragged
+ applies change to image if dragCB.val is set
+ does NOT call saveCMap(&prevcmap); BTSetActive(&gbut[G_BCOLUNDO],1); */
+-
++
+ if (dragCB.val && dragCB.active) ApplyEditColor(0);
+ }
+
+
+-
+-
+-
++
++
++
+
+ /**********************************************/
+ /************* HUE wheel functions ***********/
+@@ -2470,7 +2470,7 @@
+ hdbpix2[HDB_ROTR] = hdbpix1[HDB_ROTR];
+ }
+
+-
++
+ #define BCOLS fg,bg,hicol,locol
+
+ if (hd->range) {
+@@ -2526,7 +2526,7 @@
+ XSetForeground(theDisp, theGC, hd->fg);
+ XDrawArc(theDisp, hd->win, theGC, hd->x - HD_RADIUS, hd->y - HD_RADIUS,
+ HD_RADIUS*2, HD_RADIUS*2, 0, 360*64);
+-
++
+ for (i=0; i<6; i++) {
+ int kldg;
+
+@@ -2553,8 +2553,8 @@
+ a = hdg2xdg(hd->stval) * DEG2RAD;
+ pol2xy(hd->x, hd->y, a, HD_RADIUS - 4, &x, &y);
+ XDrawLine(theDisp, hd->win, theGC, hd->x, hd->y, x,y);
+-
+- if (flags & HD_CLHNDS)
++
++ if (flags & HD_CLHNDS)
+ XFillRectangle(theDisp, hd->win, theGC, x-2,y-2, 5,5);
+ else {
+ XSetForeground(theDisp, theGC, hd->bg);
+@@ -2567,8 +2567,8 @@
+ a = hdg2xdg(hd->enval) * DEG2RAD;
+ pol2xy(hd->x, hd->y, a, HD_RADIUS - 4, &x, &y);
+ XDrawLine(theDisp, hd->win, theGC, hd->x, hd->y, x,y);
+-
+- if (flags & HD_CLHNDS)
++
++ if (flags & HD_CLHNDS)
+ XFillRectangle(theDisp, hd->win, theGC, x-2,y-2, 5,5);
+ else {
+ XSetForeground(theDisp, theGC, hd->bg);
+@@ -2587,7 +2587,7 @@
+ r = ((HD_RADIUS - 4) * hd->satval) / 100;
+ pol2xy(hd->x, hd->y, a, r, &x, &y);
+
+- if (flags & HD_CLHNDS)
++ if (flags & HD_CLHNDS)
+ XFillRectangle(theDisp, hd->win, theGC, x-2,y-2, 5,5);
+ else {
+ XFillRectangle(theDisp, hd->win, theGC, hd->x-1, hd->y-1, 3,3);
+@@ -2600,7 +2600,7 @@
+ }
+ }
+ }
+-
++
+
+
+
+@@ -2653,13 +2653,13 @@
+ XSetBackground(theDisp, theGC, hd->bg);
+
+ if (hd->range) {
+- sprintf(vstr,"%3d\007,%3d\007 %s", hd->stval, hd->enval,
++ sprintf(vstr,"%3d\007,%3d\007 %s", hd->stval, hd->enval,
+ hd->ccwise ? "CCW" : " CW");
+ }
+ else {
+ sprintf(vstr,"%3d\007 %3d%%", hd->stval, hd->satval);
+ }
+-
++
+ XDrawImageString(theDisp, hd->win, theGC,
+ hd->x - XTextWidth(monofinfo, vstr, (int) strlen(vstr))/2,
+ hd->y + HD_RADIUS + 24, vstr, (int) strlen(vstr));
+@@ -2669,7 +2669,7 @@
+
+ if (flags & HD_TITLE) {
+ XSetForeground(theDisp, theGC, hd->fg);
+- ULineString(hd->win, hd->x - HD_RADIUS - 15, hd->y - HD_RADIUS - 4,
++ ULineString(hd->win, hd->x - HD_RADIUS - 15, hd->y - HD_RADIUS - 4,
+ hd->str);
+ }
+
+@@ -2694,7 +2694,7 @@
+ }
+
+
+-
++
+ /**************************************************/
+ static int HDClick(hd,mx,my)
+ HDIAL *hd;
+@@ -2716,7 +2716,7 @@
+ if (!hd->range && !hd->enabCB.val) return 0; /* disabled */
+
+
+- if ( ((mx - hd->x) * (mx - hd->x) + (my - hd->y) * (my - hd->y))
++ if ( ((mx - hd->x) * (mx - hd->x) + (my - hd->y) * (my - hd->y))
+ < (HD_RADIUS * HD_RADIUS)) {
+ return HDTrack(hd,mx,my);
+ }
+@@ -2816,14 +2816,14 @@
+ hd->satval--; if (hd->satval<0) hd->satval = 0;
+ HDRedraw(hd, HD_HANDS | HD_VALS);
+ }
+-
++
+ else if (bnum == HDB_SAT && hd->satval<100) {
+ HDRedraw(hd, HD_CLHNDS);
+ hd->satval++; if (hd->satval>100) hd->satval = 100;
+ HDRedraw(hd, HD_HANDS | HD_VALS);
+ }
+ }
+-
++
+ break;
+ }
+
+@@ -2836,7 +2836,7 @@
+ }
+
+ if (bp->lit) { bp->lit = 0; BTRedraw(bp); }
+-
++
+ return 1;
+ }
+
+@@ -2872,7 +2872,7 @@
+
+ dx = x - hd->x; dy = y - hd->y;
+ dist = sqrt(dx*dx + dy*dy);
+-
++
+ newsat = (int) (dist / ((double) (HD_RADIUS - 4)) * 100);
+ RANGE(newsat,0,100);
+
+@@ -2899,7 +2899,7 @@
+ a = hdg2xdg(hd->enval) * DEG2RAD;
+ pol2xy(hd->x, hd->y, a, HD_RADIUS-4, &x,&y);
+ if (PTINRECT(mx,my,x-3,y-3,7,7)) handle = 2;
+-
++
+
+
+ if (!handle) { /* not in either, rotate both */
+@@ -2939,7 +2939,7 @@
+ }
+ rv = (origj != j);
+ }
+-
++
+
+ else { /* in one of the handles */
+ if (handle==1) valp = &(hd->stval); else valp = &(hd->enval);
+@@ -2958,22 +2958,22 @@
+
+ if (!hd->ccwise) {
+ ddist = (hd->enval - hd->stval + 360) % 360;
+- if (handle==1)
++ if (handle==1)
+ ndist = (hd->enval - j + 360) % 360;
+ else
+ ndist = (j - hd->stval + 360) % 360;
+ }
+ else {
+ ddist = (hd->stval - hd->enval + 360) % 360;
+- if (handle==1)
++ if (handle==1)
+ ndist = (j - hd->enval + 360) % 360;
+ else
+ ndist = (hd->stval - j + 360) % 360;
+ }
+
+- if (abs(ddist - ndist) >= 180 && ddist<180)
++ if (abs(ddist - ndist) >= 180 && ddist<180)
+ hd->ccwise = !hd->ccwise;
+-
++
+ *valp = j;
+ HDRedraw(hd, HD_HANDS | HD_DIR | HD_VALS);
+
+@@ -2986,8 +2986,8 @@
+
+ return rv;
+ }
+-
+-
++
++
+
+ /**************************************************/
+ static int hdg2xdg(hdg)
+@@ -3012,7 +3012,7 @@
+ *yp = cy - (int) (sin(ang) * (double) rad);
+ }
+
+-
++
+ /***************************************************/
+ static int computeHDval(hd, x, y)
+ HDIAL *hd;
+@@ -3044,7 +3044,7 @@
+
+
+
+-
++
+ /****************************************************/
+ static void initHmap()
+ {
+@@ -3117,10 +3117,10 @@
+ (hmap[i].src_en != hmap[i].dst_en) ||
+ (hmap[i].src_ccw != hmap[i].dst_ccw)) { /* not a 1:1 mapping */
+
+- st1 = hmap[i].src_st;
++ st1 = hmap[i].src_st;
+ en1 = hmap[i].src_en;
+ if (hmap[i].src_ccw) {
+- inc1 = -1;
++ inc1 = -1;
+ len1 = (st1 - en1 + 360) % 360;
+ }
+ else {
+@@ -3131,7 +3131,7 @@
+ st2 = hmap[i].dst_st;
+ en2 = hmap[i].dst_en;
+ if (hmap[i].dst_ccw) {
+- inc2 = -1;
++ inc2 = -1;
+ len2 = (st2 - en2 + 360) % 360;
+ }
+ else {
+@@ -3179,7 +3179,7 @@
+
+ byte *pp, *op;
+ int i,j;
+- int rv, gv, bv, vi, hi;
++ int rv, gv, bv;
+ byte *outpic;
+ int min, max, del, h, s, v;
+ int f, p, q, t, vs100, vsf10000;
+@@ -3270,7 +3270,7 @@
+
+ /* map near-black to black to avoid weird effects */
+ if (v <= 16) s = 0;
+-
++
+ /* apply intGraf.func[] function to 'v' (the intensity) */
+ v = intGraf.func[v];
+
+@@ -3295,7 +3295,7 @@
+ if (h==NOHUE || !s) { rv = gv = bv = v; }
+ else {
+ if (h==360) h = 0;
+-
++
+ h = (h*100) / 60; /* h is in range 000..599 (0.0 - 5.99) */
+ j = h - (h%100); /* j = 000, 100, 200, 300, 400, 500 */
+ f = h - j; /* 'fractional' part of h (00..99) */
+@@ -3305,7 +3305,7 @@
+ p = v - vs100;
+ q = v - vsf10000;
+ t = v - vs100 + vsf10000;
+-
++
+ switch (j) {
+ case 000: rv = v; gv = t; bv = p; break;
+ case 100: rv = q; gv = v; bv = p; break;
+@@ -3319,7 +3319,7 @@
+ } /* if hsvmod */
+
+
+- *op++ = rGraf.func[rv];
++ *op++ = rGraf.func[rv];
+ *op++ = gGraf.func[gv];
+ *op++ = bGraf.func[bv];
+ }
+diff -ruN xv-3.10a/xvgif.c xv-3.10a-bugfixes/xvgif.c
+--- xv-3.10a/xvgif.c 1995-01-10 11:54:41.000000000 -0800
++++ xv-3.10a-bugfixes/xvgif.c 2005-04-03 11:53:13.000000000 -0700
+@@ -28,13 +28,14 @@
+ typedef int boolean;
+
+ #define NEXTBYTE (*dataptr++)
++#define SKIPBYTE (dataptr++) /* quiet some compiler warnings */
+ #define EXTENSION 0x21
+ #define IMAGESEP 0x2c
+ #define TRAILER 0x3b
+ #define INTERLACEMASK 0x40
+ #define COLORMAPMASK 0x80
+
+-
++
+
+ FILE *fp;
+
+@@ -82,11 +83,11 @@
+ char *id89 = "GIF89a";
+
+ static int EGApalette[16][3] = {
+- {0,0,0}, {0,0,128}, {0,128,0}, {0,128,128},
++ {0,0,0}, {0,0,128}, {0,128,0}, {0,128,128},
+ {128,0,0}, {128,0,128}, {128,128,0}, {200,200,200},
+ {100,100,100}, {100,100,255}, {100,255,100}, {100,255,255},
+ {255,100,100}, {255,100,255}, {255,255,100}, {255,255,255} };
+-
++
+
+ static int readImage PARM((PICINFO *));
+ static int readCode PARM((void));
+@@ -108,12 +109,13 @@
+ {
+ /* returns '1' if successful */
+
+- register byte ch, ch1, *origptr;
++ register byte ch, *origptr;
+ register int i, block;
+ int aspect, gotimage;
+
+ /* initialize variables */
+- BitOffset = XC = YC = Pass = OutCount = gotimage = 0;
++ BitOffset = XC = YC = OutCount = gotimage = 0;
++ Pass = -1;
+ RawGIF = Raster = pic8 = NULL;
+ gif89 = 0;
+
+@@ -129,16 +131,19 @@
+ fseek(fp, 0L, 2);
+ filesize = ftell(fp);
+ fseek(fp, 0L, 0);
+-
+- /* the +256's are so we can read truncated GIF files without fear of
++
++ if (filesize + 256 < filesize)
++ return( gifError(pinfo, "GIF file size is too large") );
++
++ /* the +256's are so we can read truncated GIF files without fear of
+ segmentation violation */
+ if (!(dataptr = RawGIF = (byte *) calloc((size_t) filesize+256, (size_t) 1)))
+- return( gifError(pinfo, "not enough memory to read gif file") );
+-
+- if (!(Raster = (byte *) calloc((size_t) filesize+256,(size_t) 1)))
+- return( gifError(pinfo, "not enough memory to read gif file") );
+-
+- if (fread(dataptr, (size_t) filesize, (size_t) 1, fp) != 1)
++ FatalError("LoadGIF: not enough memory to read GIF file");
++
++ if (!(Raster = (byte *) calloc((size_t) filesize+256,(size_t) 1)))
++ FatalError("LoadGIF: not enough memory to read GIF file");
++
++ if (fread(dataptr, (size_t) filesize, (size_t) 1, fp) != 1)
+ return( gifError(pinfo, "GIF data read failed") );
+
+
+@@ -147,35 +152,35 @@
+ if (strncmp((char *) dataptr, id87, (size_t) 6)==0) gif89 = 0;
+ else if (strncmp((char *) dataptr, id89, (size_t) 6)==0) gif89 = 1;
+ else return( gifError(pinfo, "not a GIF file"));
+-
++
+ dataptr += 6;
+-
++
+ /* Get variables from the GIF screen descriptor */
+-
++
+ ch = NEXTBYTE;
+ RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */
+ ch = NEXTBYTE;
+ RHeight = ch + 0x100 * NEXTBYTE;
+-
++
+ ch = NEXTBYTE;
+ HasColormap = ((ch & COLORMAPMASK) ? True : False);
+-
++
+ BitsPerPixel = (ch & 7) + 1;
+ numcols = ColorMapSize = 1 << BitsPerPixel;
+ BitMask = ColorMapSize - 1;
+-
++
+ Background = NEXTBYTE; /* background color... not used. */
+-
++
+ aspect = NEXTBYTE;
+ if (aspect) {
+ 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);
+ }
+-
+-
++
++
+ /* Read in global colormap. */
+-
++
+ if (HasColormap)
+ for (i=0; i<ColorMapSize; i++) {
+ pinfo->r[i] = NEXTBYTE;
+@@ -221,19 +226,19 @@
+ if (blocksize == 2) {
+ aspnum = NEXTBYTE;
+ aspden = NEXTBYTE;
+- if (aspden>0 && aspnum>0)
++ if (aspden>0 && aspnum>0)
+ normaspect = (float) aspnum / (float) aspden;
+ else { normaspect = 1.0; aspnum = aspden = 1; }
+
+- if (DEBUG) fprintf(stderr,"GIF87 aspect extension: %d:%d = %f\n\n",
++ if (DEBUG) fprintf(stderr,"GIF87 aspect extension: %d:%d = %f\n\n",
+ aspnum, aspden,normaspect);
+ }
+ else {
+- for (i=0; i<blocksize; i++) NEXTBYTE;
++ for (i=0; i<blocksize; i++) SKIPBYTE;
+ }
+
+ while ((sbsize=NEXTBYTE)>0) { /* eat any following data subblocks */
+- for (i=0; i<sbsize; i++) NEXTBYTE;
++ for (i=0; i<sbsize; i++) SKIPBYTE;
+ }
+ }
+
+@@ -254,9 +259,11 @@
+
+
+ if (cmtlen>0) { /* build into one un-blocked comment */
++ /* this can overflow iff cmtlen == 2G - 1, but then filesize
++ * would have to be > 2GB, which was disallowed above */
+ cmt = (byte *) malloc((size_t) (cmtlen + 1));
+- if (!cmt) gifWarning("couldn't malloc space for comments\n");
+- else {
++ if (!cmt) FatalError("LoadGIF: couldn't malloc space for comments");
++ /* else */ {
+ sp = cmt;
+ do {
+ sbsize = (*ptr1++);
+@@ -267,10 +274,10 @@
+ if (pinfo->comment) { /* have to strcat onto old comments */
+ cmt1 = (byte *) malloc(strlen(pinfo->comment) + cmtlen + 2);
+ if (!cmt1) {
+- gifWarning("couldn't malloc space for comments\n");
+ free(cmt);
++ FatalError("LoadGIF: couldn't malloc space for comments");
+ }
+- else {
++ /* else */ {
+ strcpy((char *) cmt1, (char *) pinfo->comment);
+ strcat((char *) cmt1, (char *) "\n");
+ strcat((char *) cmt1, (char *) cmt);
+@@ -288,8 +295,8 @@
+ else if (fn == 0x01) { /* PlainText Extension */
+ int j,sbsize,ch;
+ int tgLeft, tgTop, tgWidth, tgHeight, cWidth, cHeight, fg, bg;
+-
+- SetISTR(ISTR_INFO, "%s: %s", bname,
++
++ SetISTR(ISTR_INFO, "%s: %s", bname,
+ "PlainText extension found in GIF file. Ignored.");
+
+ sbsize = NEXTBYTE;
+@@ -302,12 +309,12 @@
+ fg = NEXTBYTE;
+ bg = NEXTBYTE;
+ i=12;
+- for ( ; i<sbsize; i++) NEXTBYTE; /* read rest of first subblock */
+-
++ for ( ; i<sbsize; i++) SKIPBYTE; /* read rest of first subblock */
++
+ if (DEBUG) fprintf(stderr,
+ "PlainText: tgrid=%d,%d %dx%d cell=%dx%d col=%d,%d\n",
+ tgLeft, tgTop, tgWidth, tgHeight, cWidth, cHeight, fg, bg);
+-
++
+ /* read (and ignore) data sub-blocks */
+ do {
+ j = 0;
+@@ -326,16 +333,16 @@
+
+ if (DEBUG) fprintf(stderr,"Graphic Control extension\n\n");
+
+- SetISTR(ISTR_INFO, "%s: %s", bname,
++ SetISTR(ISTR_INFO, "%s: %s", bname,
+ "Graphic Control Extension in GIF file. Ignored.");
+-
++
+ /* read (and ignore) data sub-blocks */
+ do {
+ j = 0; sbsize = NEXTBYTE;
+- while (j<sbsize) { NEXTBYTE; j++; }
++ while (j<sbsize) { SKIPBYTE; j++; }
+ } while (sbsize);
+ }
+-
++
+
+ else if (fn == 0xFF) { /* Application Extension */
+ int j, sbsize;
+@@ -345,10 +352,10 @@
+ /* read (and ignore) data sub-blocks */
+ do {
+ j = 0; sbsize = NEXTBYTE;
+- while (j<sbsize) { NEXTBYTE; j++; }
++ while (j<sbsize) { SKIPBYTE; j++; }
+ } while (sbsize);
+ }
+-
++
+
+ else { /* unknown extension */
+ int j, sbsize;
+@@ -358,11 +365,11 @@
+ SetISTR(ISTR_INFO,
+ "%s: Unknown extension 0x%02x in GIF file. Ignored.",
+ bname, fn);
+-
++
+ /* read (and ignore) data sub-blocks */
+ do {
+ j = 0; sbsize = NEXTBYTE;
+- while (j<sbsize) { NEXTBYTE; j++; }
++ while (j<sbsize) { SKIPBYTE; j++; }
+ } while (sbsize);
+ }
+ }
+@@ -370,36 +377,36 @@
+
+ else if (block == IMAGESEP) {
+ if (DEBUG) fprintf(stderr,"imagesep (got=%d) ",gotimage);
+- if (DEBUG) fprintf(stderr," at start: offset=0x%lx\n",dataptr-RawGIF);
++ if (DEBUG) fprintf(stderr," at start: offset=0x%x\n",dataptr-RawGIF);
+
+ if (gotimage) { /* just skip over remaining images */
+ int i,misc,ch,ch1;
+
+ /* skip image header */
+- NEXTBYTE; NEXTBYTE; /* left position */
+- NEXTBYTE; NEXTBYTE; /* top position */
+- NEXTBYTE; NEXTBYTE; /* width */
+- NEXTBYTE; NEXTBYTE; /* height */
++ 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++) {
+- NEXTBYTE; NEXTBYTE; NEXTBYTE;
++ SKIPBYTE; SKIPBYTE; SKIPBYTE;
+ }
+ }
+
+- NEXTBYTE; /* minimum code size */
++ SKIPBYTE; /* minimum code size */
+
+ /* skip image data sub-blocks */
+ do {
+ ch = ch1 = NEXTBYTE;
+- while (ch--) NEXTBYTE;
++ while (ch--) SKIPBYTE;
+ if ((dataptr - RawGIF) > filesize) break; /* EOF */
+ } while(ch1);
+ }
+
+ else if (readImage(pinfo)) gotimage = 1;
+- if (DEBUG) fprintf(stderr," at end: dataptr=0x%lx\n",dataptr-RawGIF);
++ if (DEBUG) fprintf(stderr," at end: dataptr=0x%x\n",dataptr-RawGIF);
+ }
+
+
+@@ -415,7 +422,7 @@
+
+ /* don't mention bad block if file was trunc'd, as it's all bogus */
+ if ((dataptr - origptr) < filesize) {
+- sprintf(str, "Unknown block type (0x%02x) at offset 0x%lx",
++ sprintf(str, "Unknown block type (0x%02x) at offset 0x%x",
+ block, (dataptr - origptr) - 1);
+
+ if (!gotimage) return gifError(pinfo, str);
+@@ -431,7 +438,7 @@
+ free(RawGIF); RawGIF = NULL;
+ free(Raster); Raster = NULL;
+
+- if (!gotimage)
++ if (!gotimage)
+ return( gifError(pinfo, "no image data found in GIF file") );
+
+ return 1;
+@@ -448,7 +455,7 @@
+ npixels = maxpixels = 0;
+
+ /* read in values from the image descriptor */
+-
++
+ ch = NEXTBYTE;
+ LeftOfs = ch + 0x100 * NEXTBYTE;
+ ch = NEXTBYTE;
+@@ -472,33 +479,33 @@
+
+ if (!HasColormap && !(Misc&0x80)) {
+ /* no global or local colormap */
+- SetISTR(ISTR_WARNING, "%s: %s", bname,
++ SetISTR(ISTR_WARNING, "%s: %s", bname,
+ "No colormap in this GIF file. Assuming EGA colors.");
+ }
+-
+
+-
++
++
+ /* Start reading the raster data. First we get the intial code size
+ * and compute decompressor constant values, based on this code size.
+ */
+-
++
+ CodeSize = NEXTBYTE;
+
+ ClearCode = (1 << CodeSize);
+ EOFCode = ClearCode + 1;
+ FreeCode = FirstFree = ClearCode + 2;
+-
++
+ /* The GIF spec has it that the code size is the code size used to
+ * compute the above values is the code size given in the file, but the
+ * code size used in compression/decompression is the code size given in
+ * the file plus one. (thus the ++).
+ */
+-
++
+ CodeSize++;
+ InitCodeSize = CodeSize;
+ MaxCode = (1 << CodeSize);
+ ReadMask = MaxCode - 1;
+-
++
+
+
+ /* UNBLOCK:
+@@ -506,7 +513,7 @@
+ * to the Raster array, turning it from a series of blocks into one long
+ * data stream, which makes life much easier for readCode().
+ */
+-
++
+ ptr1 = Raster;
+ do {
+ ch = ch1 = NEXTBYTE;
+@@ -525,18 +532,21 @@
+ fprintf(stderr,"xv: LoadGIF() - picture is %dx%d, %d bits, %sinterlaced\n",
+ Width, Height, BitsPerPixel, Interlace ? "" : "non-");
+ }
+-
++
+
+ /* Allocate the 'pic' */
+- maxpixels = Width*Height;
++ maxpixels = Width*Height; /* 65535*65535 max (but everything is int) */
++ if (Width <= 0 || Height <= 0 || maxpixels/Width != Height)
++ return( gifError(pinfo, "image dimensions out of range") );
+ picptr = pic8 = (byte *) malloc((size_t) maxpixels);
+- if (!pic8) return( gifError(pinfo, "couldn't malloc 'pic8'") );
++ if (!pic8) FatalError("LoadGIF: couldn't malloc 'pic8'");
++
++
+
+-
+ /* Decompress the file, continuing until you see the GIF EOF code.
+ * One obvious enhancement is to add checking for corrupt files here.
+ */
+-
++
+ Code = readCode();
+ while (Code != EOFCode) {
+ /* Clear code sets everything back to its initial value, then reads the
+@@ -563,58 +573,58 @@
+ break; }
+
+ CurCode = InCode = Code;
+-
++
+ /* If greater or equal to FreeCode, not in the hash table yet;
+ * repeat the last character decoded
+ */
+-
++
+ if (CurCode >= FreeCode) {
+ CurCode = OldCode;
+ if (OutCount > 4096) { /* printf("outcount1 blew up\n"); */ break; }
+ OutCode[OutCount++] = FinChar;
+ }
+-
++
+ /* Unless this code is raw data, pursue the chain pointed to by CurCode
+ * through the hash table to its end; each code in the chain puts its
+ * associated output code on the output queue.
+ */
+-
++
+ while (CurCode > BitMask) {
+ if (OutCount > 4096) break; /* corrupt file */
+ OutCode[OutCount++] = Suffix[CurCode];
+ CurCode = Prefix[CurCode];
+ }
+-
++
+ if (OutCount > 4096) { /* printf("outcount blew up\n"); */ break; }
+-
++
+ /* The last code in the chain is treated as raw data. */
+-
++
+ FinChar = CurCode & BitMask;
+ OutCode[OutCount++] = FinChar;
+-
++
+ /* Now we put the data out to the Output routine.
+ * It's been stacked LIFO, so deal with it that way...
+ */
+
+ /* safety thing: prevent exceeding range of 'pic8' */
+ if (npixels + OutCount > maxpixels) OutCount = maxpixels-npixels;
+-
++
+ npixels += OutCount;
+ if (!Interlace) for (i=OutCount-1; i>=0; i--) *picptr++ = OutCode[i];
+ else for (i=OutCount-1; i>=0; i--) doInterlace(OutCode[i]);
+ OutCount = 0;
+
+ /* Build the hash table on-the-fly. No table is stored in the file. */
+-
++
+ Prefix[FreeCode] = OldCode;
+ Suffix[FreeCode] = FinChar;
+ OldCode = InCode;
+-
++
+ /* Point to the next slot in the table. If we exceed the current
+ * MaxCode value, increment the code size unless it's already 12. If it
+ * is, do nothing: the next code decompressed better be CLEAR
+ */
+-
++
+ FreeCode++;
+ if (FreeCode >= MaxCode) {
+ if (CodeSize < 12) {
+@@ -627,7 +637,7 @@
+ Code = readCode();
+ if (npixels >= maxpixels) break;
+ }
+-
++
+ if (npixels != maxpixels) {
+ SetISTR(ISTR_WARNING,"%s: %s", bname,
+ "This GIF file seems to be truncated. Winging it.");
+@@ -640,7 +650,7 @@
+ /* fill in the PICINFO structure */
+
+ pinfo->pic = pic8;
+- pinfo->w = Width;
++ pinfo->w = Width;
+ pinfo->h = Height;
+ pinfo->type = PIC8;
+ pinfo->frmType = F_GIF;
+@@ -650,8 +660,8 @@
+
+ sprintf(pinfo->fullInfo,
+ "GIF%s, %d bit%s per pixel, %sinterlaced. (%d bytes)",
+- (gif89) ? "89" : "87", BitsPerPixel,
+- (BitsPerPixel==1) ? "" : "s",
++ (gif89) ? "89" : "87", BitsPerPixel,
++ (BitsPerPixel==1) ? "" : "s",
+ Interlace ? "" : "non-", filesize);
+
+ sprintf(pinfo->shrtInfo, "%dx%d GIF%s.",Width,Height,(gif89) ? "89" : "87");
+@@ -668,13 +678,13 @@
+ * maintain our location in the Raster array as a BIT Offset. We compute
+ * the byte Offset into the raster array by dividing this by 8, pick up
+ * three bytes, compute the bit Offset into our 24-bit chunk, shift to
+- * bring the desired code to the bottom, then mask it off and return it.
++ * bring the desired code to the bottom, then mask it off and return it.
+ */
+
+ static int readCode()
+ {
+ int RawCode, ByteOffset;
+-
++
+ ByteOffset = BitOffset / 8;
+ RawCode = Raster[ByteOffset] + (Raster[ByteOffset + 1] << 8);
+ if (CodeSize >= 8)
+@@ -692,42 +702,47 @@
+ {
+ static byte *ptr = NULL;
+ static int oldYC = -1;
+-
++
++ if (Pass == -1) { /* first time through - init stuff */
++ oldYC = -1;
++ Pass = 0;
++ }
++
+ if (oldYC != YC) { ptr = pic8 + YC * Width; oldYC = YC; }
+-
++
+ if (YC<Height)
+ *ptr++ = Index;
+-
++
+ /* Update the X-coordinate, and if it overflows, update the Y-coordinate */
+-
++
+ if (++XC == Width) {
+-
++
+ /* deal with the interlace as described in the GIF
+ * spec. Put the decoded scan line out to the screen if we haven't gone
+ * past the bottom of it
+ */
+-
++
+ XC = 0;
+-
++
+ switch (Pass) {
+ case 0:
+ YC += 8;
+ if (YC >= Height) { Pass++; YC = 4; }
+ break;
+-
++
+ case 1:
+ YC += 8;
+ if (YC >= Height) { Pass++; YC = 2; }
+ break;
+-
++
+ case 2:
+ YC += 4;
+ if (YC >= Height) { Pass++; YC = 1; }
+ break;
+-
++
+ case 3:
+ YC += 2; break;
+-
++
+ default:
+ break;
+ }
+@@ -735,7 +750,7 @@
+ }
+
+
+-
++
+ /*****************************/
+ static int gifError(pinfo, st)
+ PICINFO *pinfo;
+diff -ruN xv-3.10a/xvgifwr.c xv-3.10a-bugfixes/xvgifwr.c
+--- xv-3.10a/xvgifwr.c 1995-01-03 13:22:21.000000000 -0800
++++ xv-3.10a-bugfixes/xvgifwr.c 2004-05-16 18:03:27.000000000 -0700
+@@ -2,11 +2,11 @@
+ * xvgifwr.c - handles writing of GIF files. based on flgife.c and
+ * flgifc.c from the FBM Library, by Michael Maudlin
+ *
+- * Contains:
++ * Contains:
+ * WriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle,
+ * comment)
+ *
+- * Note: slightly brain-damaged, in that it'll only write non-interlaced
++ * Note: slightly brain-damaged, in that it'll only write non-interlaced
+ * GIF files (in the interests of speed, or something)
+ *
+ */
+@@ -34,7 +34,7 @@
+ * James A. Woods (decvax!ihnp4!ames!jaw)
+ * Joe Orost (decvax!vax135!petsd!joe)
+ *****************************************************************/
+-
++
+
+ #include "xv.h"
+
+@@ -44,7 +44,6 @@
+ static int curx, cury;
+ static long CountDown;
+ static int Interlace;
+-static byte bw[2] = {0, 0xff};
+
+ static void putword PARM((int, FILE *));
+ static void compress PARM((int, FILE *, byte *, int));
+@@ -97,7 +96,7 @@
+ 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] &&
++ if (rmap[i] == rmap[j] && gmap[i] == gmap[j] &&
+ bmap[i] == bmap[j]) break;
+ }
+
+@@ -115,15 +114,15 @@
+ /* figure out 'BitsPerPixel' */
+ for (i=1; i<8; i++)
+ if ( (1<<i) >= nc) break;
+-
++
+ BitsPerPixel = i;
+
+ ColorMapSize = 1 << BitsPerPixel;
+-
++
+ RWidth = Width = w;
+ RHeight = Height = h;
+ LeftOfs = TopOfs = 0;
+-
++
+ CountDown = w * h; /* # of pixels we'll be doing */
+
+ if (BitsPerPixel <= 1) InitCodeSize = 2;
+@@ -137,7 +136,7 @@
+ return (1);
+ }
+
+- if (DEBUG)
++ if (DEBUG)
+ fprintf(stderr,"WrGIF: pic=%lx, w,h=%dx%d, numcols=%d, Bits%d,Cmap=%d\n",
+ (u_long) pic8, w,h,numcols,BitsPerPixel,ColorMapSize);
+
+@@ -152,7 +151,7 @@
+ i = 0x80; /* Yes, there is a color map */
+ i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */
+ i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */
+- fputc(i,fp);
++ fputc(i,fp);
+
+ fputc(Background, fp); /* background color */
+
+@@ -290,7 +289,7 @@
+ /*
+ * compress stdin to stdout
+ *
+- * Algorithm: use open addressing double hashing (no chaining) on the
++ * Algorithm: use open addressing double hashing (no chaining) on the
+ * prefix code / next character combination. We do a variant of Knuth's
+ * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ * secondary probe. Here, the modular division first probe is gives way
+@@ -370,7 +369,7 @@
+ cl_hash( (count_int) hsize_reg); /* clear hash table */
+
+ output(ClearCode);
+-
++
+ while (len) {
+ c = pc2nc[*data++]; len--;
+ in_count++;
+@@ -399,7 +398,7 @@
+ continue;
+ }
+
+- if ( (long)HashTabOf (i) >= 0 )
++ if ( (long)HashTabOf (i) >= 0 )
+ goto probe;
+
+ nomatch:
+@@ -454,7 +453,7 @@
+ cur_accum |= ((long)code << cur_bits);
+ else
+ cur_accum = code;
+-
++
+ cur_bits += n_bits;
+
+ while( cur_bits >= 8 ) {
+@@ -482,7 +481,7 @@
+ maxcode = MAXCODE(n_bits);
+ }
+ }
+-
++
+ if( code == EOFCode ) {
+ /* At EOF, write the rest of the buffer */
+ while( cur_bits > 0 ) {
+@@ -492,11 +491,11 @@
+ }
+
+ flush_char();
+-
++
+ fflush( g_outfile );
+
+ #ifdef FOO
+- if( ferror( g_outfile ) )
++ if( ferror( g_outfile ) )
+ FatalError("unable to write GIF file");
+ #endif
+ }
+@@ -582,7 +581,7 @@
+ int c;
+ {
+ accum[ a_count++ ] = c;
+- if( a_count >= 254 )
++ if( a_count >= 254 )
+ flush_char();
+ }
+
+@@ -596,4 +595,4 @@
+ fwrite(accum, (size_t) 1, (size_t) a_count, g_outfile );
+ a_count = 0;
+ }
+-}
++}
+diff -ruN xv-3.10a/xvgrab.c xv-3.10a-bugfixes/xvgrab.c
+--- xv-3.10a/xvgrab.c 1994-12-22 14:34:47.000000000 -0800
++++ xv-3.10a-bugfixes/xvgrab.c 2004-05-16 18:03:30.000000000 -0700
+@@ -6,7 +6,7 @@
+ * Contains:
+ * int Grab() - handles the GRAB command
+ * int LoadGrab(); - 'loads' the pic from the last succesful Grab
+- *
++ *
+ */
+
+ #include "copyright.h"
+@@ -14,29 +14,54 @@
+ #define NEEDSTIME
+ #include "xv.h"
+
+-static byte *grabPic = (byte *) NULL;
+-static int gbits; /* either '8' or '24' */
+-static byte grabmapR[256], grabmapG[256], grabmapB[256]; /* colormap */
+-static int gWIDE,gHIGH;
+-static int grabInProgress=0;
+-static int hidewins = 0;
+-static GC rootGC;
+-
+-static void flashrect PARM((int, int, int, int, int));
+-static void startflash PARM((void));
+-static void endflash PARM((void));
+-static int grabImage PARM((Window, int, int, int, int));
+-static void ungrabX PARM((void));
+-static int convertImage PARM((XImage *, XColor *, int,
+- XWindowAttributes *));
+-
+-static int lowbitnum PARM((unsigned long));
+-static int getxcolors PARM((XWindowAttributes *, XColor **));
+-static Window xvClientWindow PARM((Display *, Window));
++
++union swapun {
++ CARD32 l;
++ CARD16 s;
++ CARD8 b[sizeof(CARD32)];
++};
+
+
++struct rectlist {
++ int x,y,w,h;
++ struct rectlist *next;
++};
+
+
++static byte *grabPic = (byte *) NULL;
++static int gptype;
++static byte grabmapR[256], grabmapG[256], grabmapB[256];
++static int gXOFF, gYOFF, gWIDE,gHIGH;
++static int grabInProgress=0;
++static int hidewins = 0;
++static GC rootGC;
++static struct rectlist *regrabList;
++
++
++static void flashrect PARM((int, int, int, int, int));
++static void startflash PARM((void));
++static void endflash PARM((void));
++static void ungrabX PARM((void));
++static int lowbitnum PARM((unsigned long));
++static int getxcolors PARM((XWindowAttributes *, XColor **));
++
++static void printWinTree PARM((Window, int));
++static void errSpace PARM((int));
++
++static int grabRootRegion PARM((int, int, int, int));
++static int grabWinImage PARM((Window, VisualID, Colormap, int));
++static int convertImageAndStuff PARM((XImage *, XColor *, int,
++ XWindowAttributes *,
++ int,int,int,int));
++
++static int RectIntersect PARM((int,int,int,int, int,int,int,int));
++
++static int CountColors24 PARM((byte *, int, int,
++ int, int, int, int));
++
++static int Trivial24to8 PARM((byte *, int, int, byte *,
++ byte *, byte *, byte *, int));
++
+ /***********************************/
+ int Grab()
+ {
+@@ -45,8 +70,7 @@
+
+ int i, x, y, x1, y1, x2, y2, ix, iy, iw, ih, rv;
+ int rx, ry, pretendGotB1, autograb;
+- int oldaclose;
+- Window rW, cW, clickWin, tmpwin;
++ Window rW, cW, clickWin;
+ unsigned int mask;
+ XColor fc, bc;
+
+@@ -75,7 +99,7 @@
+ grabInProgress = 1; /* guard against recursive grabs during delay */
+ time(&startT);
+ while (1) {
+- time(&t);
++ time(&t);
+ if (t >= startT + grabDelay) break;
+ if (XPending(theDisp)>0) {
+ XEvent evt;
+@@ -91,25 +115,25 @@
+ grabInProgress = 0;
+ }
+
+-
++
+ rootGC = DefaultGC(theDisp, theScreen);
+-
++
+ if (grabPic) { /* throw away previous 'grabbed' pic, if there is one */
+ free(grabPic); grabPic = (byte *) NULL;
+ }
+
+
+ fc.flags = bc.flags = DoRed | DoGreen | DoBlue;
+- fc.red = fc.green = fc.blue = 0xffff;
++ fc.red = fc.green = fc.blue = 0xffff;
+ bc.red = bc.green = bc.blue = 0x0000;
+ XRecolorCursor(theDisp, tcross, &fc, &bc);
+
+
+ XBell(theDisp, 0); /* beep once at start of grab */
+
+- if (!autograb) XGrabButton(theDisp, (u_int) AnyButton, 0, rootW, False, 0,
++ if (!autograb) XGrabButton(theDisp, (u_int) AnyButton, 0, rootW, False, 0,
+ GrabModeAsync, GrabModeSync, None, tcross);
+-
++
+ if (autograb) {
+ XGrabServer(theDisp); /* until we've done the grabImage */
+ if (!XQueryPointer(theDisp,rootW,&rW,&cW,&rx,&ry,&x1,&y1,&mask)) {
+@@ -136,7 +160,7 @@
+ XNextEvent(theDisp, &evt);
+ i = HandleEvent(&evt, &done);
+ if (done) { /* only 'new image' cmd accepted=quit */
+- if (i==QUIT) {
++ if (i==QUIT) {
+ XUngrabButton(theDisp, (u_int) AnyButton, 0, rootW);
+ Quit(0);
+ }
+@@ -145,12 +169,12 @@
+
+ }
+ }
+-
+-
++
++
+ /***
+ *** got button click (or pretending we did, if autograb)
+ ***/
+-
++
+
+ if (mask & Button3Mask || rW!=rootW) { /* Button3: CANCEL GRAB */
+ while (1) { /* wait for button to be released */
+@@ -158,7 +182,7 @@
+ if (!(mask & Button3Mask)) break;
+ }
+ }
+-
++
+ XUngrabButton(theDisp, (u_int) AnyButton, 0, rootW);
+ XBell(theDisp, 0);
+ XBell(theDisp, 0);
+@@ -175,69 +199,40 @@
+ if (!(mask & Button1Mask)) break;
+ }
+ }
+-
+- if (!cW || cW == rootW) clickWin = rootW;
+- else {
+- int xr, yr; Window chwin;
+- XTranslateCoordinates(theDisp, rW, cW, rx, ry, &xr, &yr, &chwin);
+- if (chwin != None) {
+- XWindowAttributes clickxwa, parentxwa;
+-
+- clickWin = xvClientWindow(theDisp, chwin);
+-
+- /* decide if we want to just grab clickWin, or cW.
+- basically, if they're different in any important way
+- (depth, visual, colormap), grab 'clickWin' only,
+- as it's the important part */
+-
+- if (!clickWin ||
+- (XGetWindowAttributes(theDisp, clickWin, &clickxwa) &&
+- XGetWindowAttributes(theDisp, cW, &parentxwa) &&
+- clickxwa.visual->class == parentxwa.visual->class &&
+- clickxwa.colormap == parentxwa.colormap &&
+- clickxwa.depth == parentxwa.depth)
+- )
+- clickWin = cW; /* close enough! */
+- }
+- else clickWin = cW;
+-
+- if (DEBUG)
+- fprintf(stderr, "rW = %x, cW = %x, chwin = %x, clickWin = %x\n",
+- (u_int) rW, (u_int) cW, (u_int) chwin, (u_int) clickWin);
+- }
+-
+-
++
++ clickWin = (cW) ? cW : rootW;
++
+ if (clickWin == rootW) { /* grab entire screen */
+ if (DEBUG) fprintf(stderr,"Grab: clicked on root window.\n");
+ ix = iy = 0; iw = dispWIDE; ih = dispHIGH;
+ }
+ else {
+ int x,y; Window win; unsigned int rw,rh,rb,rd;
+-
++
+ if (XGetGeometry(theDisp,clickWin,&rW, &x, &y, &rw, &rh, &rb, &rd)) {
+ iw = (int) rw; ih = (int) rh;
+-
++
+ XTranslateCoordinates(theDisp, clickWin, rootW, 0, 0, &ix,&iy, &win);
+-
+- if (DEBUG) fprintf(stderr,"clickWin=0x%x: %d,%d %dx%d depth=%ud\n",
+- (u_int) clickWin, ix, iy, iw, ih, rd);
++
++ if (DEBUG) fprintf(stderr,"clickWin=0x%x: %d,%d %dx%d depth=%ud\n",
++ (u_int) clickWin, ix, iy, iw, ih, rd);
+ }
+ else {
+ ix = iy = 0; iw = dispWIDE; ih = dispHIGH; clickWin = rootW;
+ if (DEBUG) fprintf(stderr,"XGetGeometry failed? (using root win)\n");
+ }
+ }
+-
+-
++
++
+ /* range checking: keep rectangle fully on-screen */
+ if (ix<0) { iw += ix; ix = 0; }
+ if (iy<0) { ih += iy; iy = 0; }
+ if (ix+iw>dispWIDE) iw = dispWIDE-ix;
+ if (iy+ih>dispHIGH) ih = dispHIGH-iy;
+-
+-
++
++
+ if (DEBUG) fprintf(stderr,"using %d,%d (%dx%d)\n", ix, iy, iw, ih);
+-
++
+ /* flash the rectangle a bit... */
+ startflash();
+ for (i=0; i<5; i++) {
+@@ -252,13 +247,12 @@
+
+ else { /* Button2: TRACK A RECTANGLE */
+ int origrx, origry;
+- Window origcW;
+
+- clickWin = rootW; origcW = cW;
++ clickWin = rootW;
+ origrx = ix = x2 = rx;
+ origry = iy = y2 = ry;
+ iw = ih = 0;
+-
++
+ XGrabServer(theDisp);
+ startflash();
+
+@@ -276,51 +270,36 @@
+ iw = abs(rx - x1); ih = abs(ry - y1);
+ x2 = rx; y2 = ry;
+ }
+-
++
+ if (iw>1 && ih>1) flashrect(ix,iy,iw,ih,1); /* turn on rect */
+ }
+
+ flashrect(ix, iy, iw, ih, 0); /* turn off rect */
++
++ /* flash the rectangle a bit... */
++ for (i=0; i<5; i++) {
++ flashrect(ix, iy, iw, ih, 1);
++ XFlush(theDisp); Timer(100);
++ flashrect(ix, iy, iw, ih, 0);
++ XFlush(theDisp); Timer(100);
++ }
+ endflash();
+-
++
+ XUngrabServer(theDisp);
+-
+-
+- if (origcW == cW) { /* maybe it's entirely in one window??? */
+- if (cW) { /* will be 0 if clicked in rootW */
+- Window stwin, enwin, stwin1, enwin1;
+- if (DEBUG) fprintf(stderr,"origcW=%x cW=%x ",
+- (u_int) origcW, (u_int) cW);
+- XTranslateCoordinates(theDisp,rootW,cW, origrx,origry,&x,&y,&stwin);
+- XTranslateCoordinates(theDisp,rootW,cW, rx, ry, &x,&y,&enwin);
+-
+- if (DEBUG) fprintf(stderr,"stwin=%x enwin=%x ",
+- (u_int) stwin, (u_int) enwin);
+- if (stwin == enwin && stwin != None) {
+- stwin1 = xvClientWindow(theDisp, stwin);
+- enwin1 = xvClientWindow(theDisp, enwin);
+- if (DEBUG) fprintf(stderr,"stwin1=%x enwin1=%x ",
+- (u_int) stwin1, (u_int) enwin1);
+-
+- if (stwin1 == enwin1 && stwin1) clickWin = stwin1;
+- else clickWin = stwin;
+- }
+- if (DEBUG) fprintf(stderr,"\n");
+- }
+- else clickWin = rootW;
+- }
+ }
+-
++
+
+ /***
+- *** now that clickWin,ix,iy,iw,ih are known, try to grab the bits...
++ *** grab screen area (ix,iy,iw,ih)
+ ***/
+
+
++ if (DEBUG>1) printWinTree(clickWin, 0);
++
+ WaitCursor();
+
+ if (!autograb) XGrabServer(theDisp); /* until we've done the grabImage */
+- rv = grabImage(clickWin,ix,iy,iw,ih); /* ungrabs the server & button */
++ rv = grabRootRegion(ix, iy, iw, ih); /* ungrabs the server & button */
+
+ SetCursors(-1);
+
+@@ -337,25 +316,25 @@
+
+ if (DEBUG) fprintf(stderr,"==remapped mainW. waiting for Config.\n");
+
+- /* sit here until we see a MapNotify on mainW followed by a
++ /* sit here until we see a MapNotify on mainW followed by a
+ ConfigureNotify on mainW */
+
+ state = 0;
+- while (1) {
++ while (state != 3) {
+ XEvent event;
+ XNextEvent(theDisp, &event);
+ HandleEvent(&event, &i);
+
+- if (state==0 && event.type == MapNotify &&
+- event.xmap.window == mainW) state = 1;
++ if (!(state&1) && event.type == MapNotify &&
++ event.xmap.window == mainW) state |= 1;
+
+- if (state==1 && event.type == ConfigureNotify &&
+- event.xconfigure.window == mainW) break;
++ if (!(state&2) && event.type == ConfigureNotify &&
++ event.xconfigure.window == mainW) state |= 2;
+ }
+
+ if (DEBUG) fprintf(stderr,"==after remapping mainW, GOT Config.\n");
+ }
+-
++
+ else if (ctrlW) CtrlBox(1);
+ }
+
+@@ -364,6 +343,45 @@
+
+
+ /***********************************/
++int LoadGrab(pinfo)
++ PICINFO *pinfo;
++{
++ /* loads up (into XV structures) last image successfully grabbed.
++ returns '0' on failure, '1' on success */
++
++ int i;
++
++ if (!grabPic) return 0; /* no image to use */
++
++ pinfo->type = gptype;
++ if (pinfo->type == PIC8) {
++ for (i=0; i<256; i++) {
++ pinfo->r[i] = grabmapR[i];
++ pinfo->g[i] = grabmapG[i];
++ pinfo->b[i] = grabmapB[i];
++ }
++ }
++
++ pinfo->pic = grabPic;
++ pinfo->normw = pinfo->w = gWIDE;
++ pinfo->normh = pinfo->h = gHIGH;
++ pinfo->frmType = -1;
++ pinfo->colType = -1;
++
++ sprintf(pinfo->fullInfo,"<%s internal>",
++ (pinfo->type == PIC8) ? "8-bit" : "24-bit");
++
++ sprintf(pinfo->shrtInfo,"%dx%d image.",gWIDE, gHIGH);
++
++ pinfo->comment = (char *) NULL;
++
++ grabPic = (byte *) NULL;
++
++ return 1;
++}
++
++
++/***********************************/
+ static void flashrect(x,y,w,h,show)
+ int x,y,w,h,show;
+ {
+@@ -373,7 +391,7 @@
+ XSetPlaneMask(theDisp, rootGC, xorMasks[maskno]);
+
+ if (!show) { /* turn off rectangle */
+- if (isvis)
++ if (isvis)
+ XDrawRectangle(theDisp, rootW, rootGC, x, y, (u_int) w-1, (u_int) h-1);
+
+ isvis = 0;
+@@ -391,15 +409,16 @@
+
+ /***********************************/
+ static void startflash()
+-{
++{
+ /* set up for drawing a flashing rectangle */
+ XSetFunction(theDisp, rootGC, GXinvert);
+ XSetSubwindowMode(theDisp, rootGC, IncludeInferiors);
+ }
+
++
+ /***********************************/
+ static void endflash()
+-{
++{
+ XSetFunction(theDisp, rootGC, GXcopy);
+ XSetSubwindowMode(theDisp, rootGC, ClipByChildren);
+ XSetPlaneMask(theDisp, rootGC, AllPlanes);
+@@ -408,21 +427,157 @@
+
+
+ /***********************************/
+-static int grabImage(clickWin, x, y, w, h)
+- Window clickWin;
++static void ungrabX()
++{
++ XUngrabServer(theDisp);
++ XUngrabButton(theDisp, (u_int) AnyButton, 0, rootW);
++}
++
++
++/**************************************/
++static int lowbitnum(ul)
++ unsigned long ul;
++{
++ /* returns position of lowest set bit in 'ul' as an integer (0-31),
++ or -1 if none */
++
++ int i;
++ for (i=0; ((ul&1) == 0) && i<32; i++, ul>>=1);
++ if (i==32) i = -1;
++ return i;
++}
++
++
++
++/**********************************************/
++/* getxcolors() function snarfed from 'xwd.c' */
++/**********************************************/
++
++#define lowbit(x) ((x) & (~(x) + 1))
++
++static int getxcolors(win_info, colors)
++ XWindowAttributes *win_info;
++ XColor **colors;
++{
++ int i, ncolors;
++
++ *colors = (XColor *) NULL;
++
++ if (win_info->visual->class == TrueColor) {
++ if (DEBUG>1) fprintf(stderr,"TrueColor visual: no colormap needed\n");
++ return 0;
++ }
++
++ else if (!win_info->colormap) {
++ if (DEBUG>1) fprintf(stderr,"no colormap associated with window\n");
++ return 0;
++ }
++
++ ncolors = win_info->visual->map_entries;
++ if (DEBUG>1) fprintf(stderr,"%d entries in colormap\n", ncolors);
++
++ if (!(*colors = (XColor *) malloc (sizeof(XColor) * ncolors)))
++ FatalError("malloc failed in getxcolors()");
++
++
++ if (win_info->visual->class == DirectColor) {
++ Pixel red, green, blue, red1, green1, blue1;
++
++ if (DEBUG>1) fprintf(stderr,"DirectColor visual\n");
++
++ red = green = blue = 0;
++ red1 = lowbit(win_info->visual->red_mask);
++ green1 = lowbit(win_info->visual->green_mask);
++ blue1 = lowbit(win_info->visual->blue_mask);
++ for (i=0; i<ncolors; i++) {
++ (*colors)[i].pixel = red|green|blue;
++ (*colors)[i].pad = 0;
++ red += red1;
++ if (red > win_info->visual->red_mask) red = 0;
++ green += green1;
++ if (green > win_info->visual->green_mask) green = 0;
++ blue += blue1;
++ if (blue > win_info->visual->blue_mask) blue = 0;
++ }
++ }
++ else {
++ for (i=0; i<ncolors; i++) {
++ (*colors)[i].pixel = i;
++ (*colors)[i].pad = 0;
++ }
++ }
++
++ XQueryColors(theDisp, win_info->colormap, *colors, ncolors);
++
++ return(ncolors);
++}
++
++
++
++/*******************************************/
++static void printWinTree(win,tab)
++ Window win;
++ int tab;
++{
++ u_int i, nchildren;
++ Window root, parent, *children, chwin;
++ XWindowAttributes xwa;
++ int xr, yr;
++
++ if (!XGetWindowAttributes(theDisp, win, &xwa)) {
++ errSpace(tab);
++ fprintf(stderr,"pWT: can't XGetWindowAttributes(%08x)\n", (u_int) win);
++ return;
++ }
++
++ XTranslateCoordinates(theDisp, win, rootW, 0,0, &xr,&yr, &chwin);
++ if (xwa.map_state==IsViewable) {
++ errSpace(tab);
++ fprintf(stderr,"%08x: %4d,%4d %4dx%4d vis: %02x cm=%x %s\n",
++ (u_int) win, xr,yr, xwa.width, xwa.height,
++ (u_int) XVisualIDFromVisual(xwa.visual),
++ (u_int) xwa.colormap,
++ ((xwa.map_state==IsUnmapped) ? "unmapped " :
++ (xwa.map_state==IsUnviewable) ? "unviewable" :
++ (xwa.map_state==IsViewable) ? "viewable " :
++ "<unknown> ") );
++
++ if (!XQueryTree(theDisp, win, &root, &parent, &children, &nchildren)) {
++ errSpace(tab);
++ fprintf(stderr,"pWT: XQueryTree(%08x) failed\n", (u_int) win);
++ if (children) XFree((char *)children);
++ return;
++ }
++
++ for (i=0; i<nchildren; i++) printWinTree(children[i], tab+1);
++ if (children) XFree((char *)children);
++ }
++
++ return;
++}
++
++
++/***********************************/
++static void errSpace(n)
++ int n;
++{
++ for ( ; n>0; n--) putc(' ', stderr);
++}
++
++
++
++
++/***********************************/
++static int grabRootRegion(x, y, w, h)
+ int x, y, w, h;
+ {
+ /* attempts to grab the specified rectangle of the root window
+- returns '1' on success. clickWin is used to figure out the depth
+- and colormap to use */
++ returns '1' on success */
+
+- XImage *image;
+- XWindowAttributes xwa;
+- XColor *colors;
+- int ncolors, i, ix, iy;
+- char str[256];
+- Window win;
++ XWindowAttributes xwa;
++ int i;
+
++ regrabList = (struct rectlist *) NULL;
+
+ /* range checking */
+ if (x<0) { w += x; x = 0; }
+@@ -430,86 +585,246 @@
+ if (x+w>dispWIDE) w = dispWIDE-x;
+ if (y+h>dispHIGH) h = dispHIGH-y;
+
+- if (w==0 || h==0) { /* selected nothing */
++ if (w<=0 || h<=0) { /* selected nothing */
+ ungrabX();
+ return 0;
+ }
+
+- if (!XGetWindowAttributes(theDisp, clickWin, &xwa)) {
+- sprintf(str,"Unable to get window attributes for clicked-on window\n");
++
++ /* grab this region, using the default (root's) visual */
++
++ /* now for all top-level windows (children of root), in bottom->top order
++ if they intersect the grabregion
++ are they drawn entirely (including children) using default visual+cmap?
++ yes: if they intersect 'regrab' list, grab'em - else skip'em
++ no: grab them, add their rectangle to 'regrab' list
++ */
++
++
++ /* make a 24bit grabPic */
++ gptype = PIC24;
++ gXOFF = x; gYOFF = y; gWIDE = w; gHIGH = h;
++ grabPic = (byte *) malloc((size_t) gWIDE * gHIGH * 3);
++ if (!grabPic) {
+ ungrabX();
+- ErrPopUp(str, "\nThat Sucks!");
++ ErrPopUp("Unable to malloc() space for grabbed image!", "\nBite Me!");
+ return 0;
+ }
+
+-
+- XTranslateCoordinates(theDisp, rootW, clickWin, x, y, &ix, &iy, &win);
+-
+- xerrcode = 0;
+- image = XGetImage(theDisp, clickWin, ix, iy, (u_int) w, (u_int) h,
+- AllPlanes, ZPixmap);
+- if (xerrcode || !image || !image->data) {
+- sprintf(str, "Unable to get image (%d,%d %dx%d) from display", ix,iy,w,h);
++ if (!XGetWindowAttributes(theDisp, rootW, &xwa)) {
+ ungrabX();
+- ErrPopUp(str, "\nThat Sucks!");
++ ErrPopUp("Can't get window attributes for root window!", "\nBite Me!");
+ return 0;
+ }
+
+- ncolors = getxcolors(&xwa, &colors);
++ i = grabWinImage(rootW, XVisualIDFromVisual(xwa.visual), xwa.colormap,0);
+
+ ungrabX();
+
+- if (ncolors && DEBUG) {
+- fprintf(stderr, "Colormap:\n");
+- for (i=0; i<ncolors; i++)
+- fprintf(stderr,"%02x%02x%02x ",colors[i].red>>8, colors[i].green>>8,
+- colors[i].blue>>8);
+- fprintf(stderr,"\n");
+- }
+-
+-
+ XBell(theDisp, 0); /* beep twice at end of grab */
+ XBell(theDisp, 0);
+
+- i = convertImage(image, colors, ncolors, &xwa);
++ { /* free regrabList */
++ struct rectlist *rr, *tmprr;
++ rr = regrabList;
++ while (rr) {
++ tmprr = rr->next;
++ free((char *) rr);
++ rr = tmprr;
++ }
++ regrabList = (struct rectlist *) NULL;
++ }
++
++ if (i) {
++ ErrPopUp("Warning: Problems occurred during grab.","\nWYSInWYG!");
++ return 0;
++ }
+
+- /* DO *NOT* use xvDestroyImage(), as the 'data' field was alloc'd by X, not
+- necessarily through 'malloc() / free()' */
+- XDestroyImage(image);
+-
+- if (colors) free((char *) colors);
+
+- return i;
++ /* if 256 or fewer colors in grabPic, make it a PIC8 */
++ i = CountColors24(grabPic, gWIDE, gHIGH, 0,0,gWIDE,gHIGH);
++ if (i<=256) {
++ byte *pic8;
++ pic8 = (byte *) malloc((size_t) (gWIDE * gHIGH));
++ if (pic8) {
++ if (Trivial24to8(grabPic, gWIDE,gHIGH, pic8,
++ grabmapR,grabmapG,grabmapB,256)) {
++ free((char *) grabPic);
++ grabPic = pic8;
++ gptype = PIC8;
++ }
++ }
++ }
++
++ return 1; /* full success */
+ }
+
+
+-static void ungrabX()
++/***********************************/
++static int grabWinImage(win, parentVid, parentCmap, toplevel)
++ Window win;
++ VisualID parentVid;
++ Colormap parentCmap;
++ int toplevel;
+ {
+- XUngrabServer(theDisp);
+- XUngrabButton(theDisp, (u_int) AnyButton, 0, rootW);
+-}
++ /* grabs area of window (and its children) that intersects
++ * grab region (root coords: gXOFF,gYOFF,gWIDE,gHIGH), and stuffs
++ * relevant bits into the grabPic (a gWIDE*gHIGH PIC24)
++ *
++ * Note: special kludge for toplevel windows (children of root):
++ * since that's the only case where a window can be obscuring something
++ * that isn't its parent
++ *
++ * returns 0 if okay, 1 if problems occurred
++ */
++
++
++ int i, rv, dograb;
++ int wx, wy, ww, wh; /* root coords of window */
++ int gx, gy, gw, gh; /* root coords of grab region of win*/
++ Window chwin; /* unused */
++ u_int nchildren;
++ Window root, parent, *children;
++ XWindowAttributes xwa;
+
++ /* first, quick checks to avoid recursing down useless branches */
+
++ if (!XGetWindowAttributes(theDisp, win, &xwa)) {
++ if (DEBUG) fprintf(stderr,"gWI: can't get win attr (%08x)\n", (u_int) win);
++ return 1;
++ }
+
++ if (xwa.class == InputOnly || xwa.map_state != IsViewable) return 0;
+
++ rv = 0;
++ dograb = 1;
++ wx = 0; wy = 0; ww = (int) xwa.width; wh = (int) xwa.height;
++
++ /* if this window doesn't intersect, none of its children will, either */
++ XTranslateCoordinates(theDisp, win, rootW, 0,0, &wx, &wy, &chwin);
++ if (!RectIntersect(wx,wy,ww,wh, gXOFF,gYOFF,gWIDE,gHIGH)) return 0;
++
++ gx = wx; gy = wy; gw = ww; gh = wh;
++ CropRect2Rect(&gx,&gy,&gw,&gh, gXOFF,gYOFF,gWIDE,gHIGH);
++
++ if (win==rootW) {
++ /* always grab */
++ }
++
++ else if (XVisualIDFromVisual(xwa.visual) == parentVid &&
++ ((xwa.visual->class==TrueColor) || xwa.colormap == parentCmap)) {
++
++ /* note: if both visuals are TrueColor, don't compare cmaps */
++
++ /* normally, if the vis/cmap info of a window is the same as its parent,
++ no need to regrab window. special case if this is a toplevel
++ window, as it can be obscuring windows that *aren't* its parent */
++
++ if (toplevel) {
++ /* we probably already have this region. Check it against regrabList
++ If it intersects none, no need to grab.
++ If it intersects one, crop to that rectangle and grab
++ if it intersects >1, don't crop, just grab gx,gy,gw,gh */
++
++ struct rectlist *rr, *cr;
++
++ i=0; cr=rr=regrabList;
++ while (rr) {
++ if (RectIntersect(gx,gy,gw,gh, rr->x,rr->y,rr->w,rr->h)) {
++ i++; cr = rr;
++ }
++ rr = rr->next;
++ }
++
++ if (i==0) dograb=0; /* no need to grab */
++
++ if (i==1) CropRect2Rect(&gx,&gy,&gw,&gh, cr->x,cr->y,cr->w,cr->h);
++ }
++ else dograb = 0;
++ }
++
++ else {
++ /* different vis/cmap from parent:
++ add to regrab list, if not already fully contained in list */
++ struct rectlist *rr;
++
++ /* check to see if fully contained... */
++ rr=regrabList;
++ while (rr && RectIntersect(gx,gy,gw,gh, rr->x,rr->y,rr->w,rr->h)!=2)
++ rr = rr->next;
++
++ if (!rr) { /* add to list */
++ if (DEBUG)
++ fprintf(stderr,"added to regrabList: %d,%d %dx%d\n",gx,gy,gw,gh);
++
++ rr = (struct rectlist *) malloc(sizeof(struct rectlist));
++ if (!rr) return 1;
++ else {
++ rr->x = gx; rr->y = gy; rr->w = gw; rr->h = gh;
++ rr->next = regrabList;
++ regrabList = rr;
++ }
++ }
++ }
++
++ /* at this point, we have to grab gx,gy,gw,gh from 'win' */
++
++ if (dograb) {
++ int ix, iy, ncolors;
++ XColor *colors;
++ XImage *image;
++
++ XTranslateCoordinates(theDisp, rootW, win, gx, gy, &ix, &iy, &chwin);
++
++ if (DEBUG)
++ fprintf(stderr,"Grabbing win (%08x) %d,%d %dx%d\n",
++ (u_int) win, gx,gy,gw,gh);
++
++ WaitCursor();
++
++ xerrcode = 0;
++ image = XGetImage(theDisp, win, ix, iy, (u_int) gw, (u_int) gh,
++ AllPlanes, ZPixmap);
++ if (xerrcode || !image || !image->data) return 1;
++
++ ncolors = getxcolors(&xwa, &colors);
++ rv = convertImageAndStuff(image, colors, ncolors, &xwa,
++ gx - gXOFF, gy - gYOFF, gw, gh);
++ XDestroyImage(image); /* can't use xvDestroyImage: alloc'd by X! */
++ if (colors) free((char *) colors);
++ }
++
++
++ /* recurse into children to see if any of them are 'different'... */
++
++ if (!XQueryTree(theDisp, win, &root, &parent, &children, &nchildren)) {
++ if (DEBUG) fprintf(stderr,"XQueryTree(%08x) failed\n", (u_int) win);
++ if (children) XFree((char *)children);
++ return rv+1;
++ }
++
++ for (i=0; i<nchildren; i++) {
++ rv += grabWinImage(children[i], XVisualIDFromVisual(xwa.visual),
++ xwa.colormap, (win==rootW));
++ }
++ if (children) XFree((char *)children);
++
++ return rv;
++}
+
+-union swapun {
+- CARD32 l;
+- CARD16 s;
+- CARD8 b[sizeof(CARD32)];
+-};
+
+
+ /**************************************/
+-static int convertImage(image, colors, ncolors, xwap)
++static int convertImageAndStuff(image, colors, ncolors, xwap, gx,gy,gw,gh)
+ XImage *image;
+ XColor *colors;
+ int ncolors;
+ XWindowAttributes *xwap;
++ int gx,gy,gw,gh; /* position within grabPic (guaranteed OK) */
+ {
+- /* attempts to conver the image from whatever weird-ass format it might
+- be in into something E-Z to deal with (either an 8-bit colormapped
+- image, or a 24-bit image). Returns '1' on success. */
++ /* attempts to convert the image from whatever weird-ass format it might
++ be in into a 24-bit RGB image, and stuff it into grabPic
++ Returns 0 on success, 1 on failure */
+
+ /* this code owes a lot to 'xwdtopnm.c', part of the pbmplus package,
+ written by Jef Poskanzer */
+@@ -528,7 +843,6 @@
+ int isLsbMachine, flipBytes;
+ Visual *visual;
+ char errstr[256];
+- static char *foo[] = { "\nThat Sucks!" };
+
+
+ /* quiet compiler warnings */
+@@ -538,20 +852,20 @@
+ pixvalue = 0;
+ rmask = gmask = bmask = 0;
+ rshift = gshift = bshift = 0;
+-
++ r8shift = g8shift = b8shift = 0;
+
+ /* determine byte order of the machine we're running on */
+ sw.l = 1;
+ isLsbMachine = (sw.b[0]) ? 1 : 0;
+
+- if (xwap && xwap->visual) visual = xwap->visual;
+- else visual = theVisual;
++ visual = xwap->visual;
++
+
+- if (DEBUG) {
++ if (DEBUG>1) {
+ fprintf(stderr,"convertImage:\n");
+ fprintf(stderr," %dx%d (offset %d), %s\n",
+- image->width, image->height, image->xoffset,
+- (image->format == XYBitmap || image->format == XYPixmap)
++ image->width, image->height, image->xoffset,
++ (image->format == XYBitmap || image->format == XYPixmap)
+ ? "XYPixmap" : "ZPixmap");
+
+ fprintf(stderr,"byte_order = %s, bitmap_bit_order = %s, unit=%d, pad=%d\n",
+@@ -575,41 +889,17 @@
+ sprintf(errstr, "%s\nReturned image bitmap_unit (%d) non-standard.",
+ "Can't deal with this display.", image->bitmap_unit);
+ ErrPopUp(errstr, "\nThat Sucks!");
+- return 0;
++ return 1;
+ }
+
+ if (!ncolors && visual->class != TrueColor) {
+ sprintf(errstr, "%s\nOnly TrueColor displays can have no colormap.",
+ "Can't deal with this display.");
+ ErrPopUp(errstr, "\nThat Sucks!");
+- return 0;
++ return 1;
+ }
+
+
+- /* build the 'global' grabPic stuff */
+- gWIDE = image->width; gHIGH = image->height;
+-
+- if (visual->class == TrueColor || visual->class == DirectColor ||
+- ncolors > 256) {
+- grabPic = (byte *) malloc((size_t) gWIDE * gHIGH * 3);
+- gbits = 24;
+- }
+- else {
+- grabPic = (byte *) malloc((size_t) gWIDE * gHIGH);
+- gbits = 8;
+-
+- /* load up the colormap */
+- for (i=0; i<ncolors; i++) {
+- grabmapR[i] = colors[i].red >> 8;
+- grabmapG[i] = colors[i].green >> 8;
+- grabmapB[i] = colors[i].blue >> 8;
+- }
+- }
+-
+- if (!grabPic) FatalError("unable to malloc grabPic in convertImage()");
+- pptr = grabPic;
+-
+-
+ if (visual->class == TrueColor || visual->class == DirectColor) {
+ unsigned int tmp;
+
+@@ -634,16 +924,35 @@
+ while (tmp >= 256) { tmp >>= 1; b8shift -= 1; }
+ while (tmp < 128) { tmp <<= 1; b8shift += 1; }
+
+- if (DEBUG)
++ if (DEBUG>1)
+ fprintf(stderr,"True/DirectColor: shifts=%d,%d,%d 8shifts=%d,%d,%d\n",
+ rshift, gshift, bshift, r8shift, g8shift, b8shift);
+ }
+
+
+- bits_per_item = image->bitmap_unit;
+- bits_used = bits_per_item;
++ bits_per_item = image->bitmap_unit;
+ bits_per_pixel = image->bits_per_pixel;
+
++
++ /* add code for freako 'exceed' server, where bitmapunit = 8
++ and bitsperpix = 32 (and depth=24)... */
++
++ if (bits_per_item < bits_per_pixel) {
++ bits_per_item = bits_per_pixel;
++
++ /* round bits_per_item up to next legal value, if necc */
++ if (bits_per_item < 8) bits_per_item = 8;
++ else if (bits_per_item < 16) bits_per_item = 16;
++ else bits_per_item = 32;
++ }
++
++
++ /* which raises the question: how (can?) you ever have a 24 bits per pix,
++ (ie, 3 bytes, no alpha/padding) */
++
++
++ bits_used = bits_per_item; /* so it will get a new item first time */
++
+ if (bits_per_pixel == 32) pixmask = 0xffffffff;
+ else pixmask = (((CARD32) 1) << bits_per_pixel) - 1;
+
+@@ -652,14 +961,15 @@
+
+ /* if we're on an lsbfirst machine, or the image came from an lsbfirst
+ machine, we should flip the bytes around. NOTE: if we're on an
+- lsbfirst machine *and* the image came from an lsbfirst machine,
++ lsbfirst machine *and* the image came from an lsbfirst machine,
+ *don't* flip bytes, as it should work out */
+
+- /* pity we don't have a logical exclusive-or */
+ flipBytes = ( isLsbMachine && byte_order != LSBFirst) ||
+ (!isLsbMachine && byte_order == LSBFirst);
+
+ for (i=0; i<image->height; i++) {
++ pptr = grabPic + ((i+gy) * gWIDE + gx) * 3;
++
+ lineptr = (byte *) image->data + (i * image->bytes_per_line);
+ bptr = ((CARD8 *) lineptr) - 1;
+ sptr = ((CARD16 *) lineptr) - 1;
+@@ -667,35 +977,39 @@
+ bits_used = bits_per_item;
+
+ for (j=0; j<image->width; j++) {
+-
+ /* get the next pixel value from the image data */
+
+ if (bits_used == bits_per_item) { /* time to move on to next b/s/l */
+ switch (bits_per_item) {
+- case 8: bptr++; break;
+- case 16: sptr++; sval = *sptr;
+- if (flipBytes) { /* swap CARD16 */
+- sw.s = sval;
+- tmpbyte = sw.b[0];
+- sw.b[0] = sw.b[1];
+- sw.b[1] = tmpbyte;
+- sval = sw.s;
+- }
+- break;
+- case 32: lptr++; lval = *lptr;
+- if (flipBytes) { /* swap CARD32 */
+- sw.l = lval;
+- tmpbyte = sw.b[0];
+- sw.b[0] = sw.b[3];
+- sw.b[3] = tmpbyte;
+- tmpbyte = sw.b[1];
+- sw.b[1] = sw.b[2];
+- sw.b[2] = tmpbyte;
+- lval = sw.l;
+- }
+- break;
++ case 8:
++ bptr++; break;
++
++ case 16:
++ sptr++; sval = *sptr;
++ if (flipBytes) { /* swap CARD16 */
++ sw.s = sval;
++ tmpbyte = sw.b[0];
++ sw.b[0] = sw.b[1];
++ sw.b[1] = tmpbyte;
++ sval = sw.s;
++ }
++ break;
++
++ case 32:
++ lptr++; lval = *lptr;
++ if (flipBytes) { /* swap CARD32 */
++ sw.l = lval;
++ tmpbyte = sw.b[0];
++ sw.b[0] = sw.b[3];
++ sw.b[3] = tmpbyte;
++ tmpbyte = sw.b[1];
++ sw.b[1] = sw.b[2];
++ sw.b[2] = tmpbyte;
++ lval = sw.l;
++ }
++ break;
+ }
+-
++
+ bits_used = 0;
+ if (bit_order == MSBFirst) bit_shift = bits_per_item - bits_per_pixel;
+ else bit_shift = 0;
+@@ -711,11 +1025,11 @@
+ else bit_shift += bits_per_pixel;
+ bits_used += bits_per_pixel;
+
+-
++
+ /* okay, we've got the next pixel value in 'pixvalue' */
+-
++
+ if (visual->class == TrueColor || visual->class == DirectColor) {
+- /* in either case, we have to take the pixvalue and
++ /* in either case, we have to take the pixvalue and
+ break it out into individual r,g,b components */
+ rval = (pixvalue & rmask) >> rshift;
+ gval = (pixvalue & gmask) >> gshift;
+@@ -741,212 +1055,169 @@
+ /* use pixel value as an index into colors array */
+
+ if (pixvalue >= ncolors) {
+- FatalError("convertImage(): pixvalue >= ncolors");
+- }
+-
+- if (gbits == 24) { /* too many colors for 8-bit colormap */
+- *pptr++ = (colors[pixvalue].red) >> 8;
+- *pptr++ = (colors[pixvalue].green) >> 8;
+- *pptr++ = (colors[pixvalue].blue) >> 8;
++ fprintf(stderr, "WARNING: convertImage(): pixvalue >= ncolors\n");
++ return 1;
+ }
+- else *pptr++ = pixvalue & 0xff;
+
++ *pptr++ = (colors[pixvalue].red) >> 8;
++ *pptr++ = (colors[pixvalue].green) >> 8;
++ *pptr++ = (colors[pixvalue].blue) >> 8;
+ }
+ }
+ }
+
+- return 1;
++ return 0;
+ }
+
+
+
+-/**************************************/
+-static int lowbitnum(ul)
+- unsigned long ul;
++/***********************************/
++static int RectIntersect(ax,ay,aw,ah, bx,by,bw,bh)
++ int ax,ay,aw,ah, bx,by,bw,bh;
+ {
+- /* returns position of lowest set bit in 'ul' as an integer (0-31),
+- or -1 if none */
+-
+- int i;
+- for (i=0; ((ul&1) == 0) && i<32; i++, ul>>=1);
+- if (i==32) i = -1;
+- return i;
+-}
++ /* returns 0 if rectangles A and B do not intersect
++ returns 1 if A partially intersects B
++ returns 2 if rectangle A is fully enclosed by B */
+
++ int ax1,ay1, bx1,by1;
+
++ ax1 = ax+aw-1; ay1 = ay+ah-1;
++ bx1 = bx+bw-1; by1 = by+bh-1;
+
+-/**************************************/
+-/* following code snarfed from 'xwd.c' */
+-/**************************************/
++ if (ax1<bx || ax>bx1 || ay1<by || ay>by1) return 0;
+
+-#define lowbit(x) ((x) & (~(x) + 1))
++ if (ax>=bx && ax1<=bx1 && ay>=by && ay1<=by) return 2;
+
++ return 1;
++}
+
+-static int getxcolors(win_info, colors)
+- XWindowAttributes *win_info;
+- XColor **colors;
+-{
+- int i, ncolors;
+- Colormap cmap;
+-
+- *colors = (XColor *) NULL;
+-
+- if (win_info->visual->class == TrueColor) {
+- if (DEBUG) fprintf(stderr,"TrueColor visual: no colormap needed\n");
+- return 0;
+- }
+
+- else if (!win_info->colormap) {
+- if (DEBUG) fprintf(stderr,"no colormap associated with window\n");
+- return 0;
+- }
+
+- ncolors = win_info->visual->map_entries;
+- if (DEBUG) fprintf(stderr,"%d entries in colormap\n", ncolors);
+
+- if (!(*colors = (XColor *) malloc (sizeof(XColor) * ncolors)))
+- FatalError("malloc failed in getxcolors()");
+
++/** stuff needed to make new xvgrab work in 3.10a. **/
+
+- if (win_info->visual->class == DirectColor) {
+- Pixel red, green, blue, red1, green1, blue1;
++/********************************************/
++static int CountColors24(pic, pwide, phigh, x, y, w, h)
++ byte *pic;
++ int pwide, phigh, x,y,w,h;
++{
++ /* counts the # of unique colors in a selected rect of a PIC24
++ returns '0-256' or >256 */
+
+- if (DEBUG) fprintf(stderr,"DirectColor visual\n");
++ int i, j, nc;
++ int low, high, mid;
++ u_int colors[257], col;
++ byte *pp;
++
++ nc = 0;
++
++ for (i=y; nc<257 && i<y+h; i++) {
++ pp = pic + (i*pwide + x)*3;
++
++ for (j=x; nc<257 && j<x+w; j++, pp+=3) {
++ col = (((u_int) pp[0])<<16) + (((u_int) pp[1])<<8) + pp[2];
++
++ /* binary search the 'colors' array to see if it's in there */
++ low = 0; high = nc-1;
++ while (low <= high) {
++ mid = (low+high)/2;
++ if (col < colors[mid]) high = mid - 1;
++ else if (col > colors[mid]) low = mid + 1;
++ else break;
++ }
+
+- red = green = blue = 0;
+- red1 = lowbit(win_info->visual->red_mask);
+- green1 = lowbit(win_info->visual->green_mask);
+- blue1 = lowbit(win_info->visual->blue_mask);
+- for (i=0; i<ncolors; i++) {
+- (*colors)[i].pixel = red|green|blue;
+- (*colors)[i].pad = 0;
+- red += red1;
+- if (red > win_info->visual->red_mask) red = 0;
+- green += green1;
+- if (green > win_info->visual->green_mask) green = 0;
+- blue += blue1;
+- if (blue > win_info->visual->blue_mask) blue = 0;
+- }
+- }
+- else {
+- for (i=0; i<ncolors; i++) {
+- (*colors)[i].pixel = i;
+- (*colors)[i].pad = 0;
++ if (high < low) { /* didn't find color in list, add it. */
++ xvbcopy((char *) &colors[low], (char *) &colors[low+1],
++ (nc - low) * sizeof(u_int));
++ colors[low] = col;
++ nc++;
++ }
+ }
+ }
+
+- XQueryColors(theDisp, win_info->colormap, *colors, ncolors);
+-
+- return(ncolors);
++ return nc;
+ }
+-
+
+
+-
+-
+-/***********************************/
+-int LoadGrab(pinfo)
+- PICINFO *pinfo;
++/****************************/
++static int Trivial24to8(pic24, w,h, pic8, rmap,gmap,bmap, maxcol)
++ byte *pic24, *pic8, *rmap, *gmap, *bmap;
++ int w,h,maxcol;
+ {
+- /* loads up (into XV structures) last image successfully grabbed.
+- returns '0' on failure, '1' on success */
+-
+- int i;
+-
+- if (!grabPic) return 0; /* no image to use */
+-
+- if (gbits == 24) pinfo->type = PIC24;
+- else {
+- pinfo->type = PIC8;
++ /* scans picture until it finds more than 'maxcol' different colors. If it
++ finds more than 'maxcol' colors, it returns '0'. If it DOESN'T, it does
++ the 24-to-8 conversion by simply sticking the colors it found into
++ a colormap, and changing instances of a color in pic24 into colormap
++ indicies (in pic8) */
++
++ unsigned long colors[256],col;
++ int i, nc, low, high, mid;
++ byte *p, *pix;
++
++ if (maxcol>256) maxcol = 256;
++
++ /* put the first color in the table by hand */
++ nc = 0; mid = 0;
++
++ for (i=w*h,p=pic24; i; i--) {
++ col = (((u_long) *p++) << 16);
++ col += (((u_long) *p++) << 8);
++ col += *p++;
++
++ /* binary search the 'colors' array to see if it's in there */
++ low = 0; high = nc-1;
++ while (low <= high) {
++ mid = (low+high)/2;
++ if (col < colors[mid]) high = mid - 1;
++ else if (col > colors[mid]) low = mid + 1;
++ else break;
++ }
+
+- for (i=0; i<256; i++) {
+- pinfo->r[i] = grabmapR[i];
+- pinfo->g[i] = grabmapG[i];
+- pinfo->b[i] = grabmapB[i];
++ if (high < low) { /* didn't find color in list, add it. */
++ if (nc>=maxcol) return 0;
++ xvbcopy((char *) &colors[low], (char *) &colors[low+1],
++ (nc - low) * sizeof(u_long));
++ colors[low] = col;
++ nc++;
+ }
+ }
+
+- pinfo->pic = grabPic;
+- pinfo->normw = pinfo->w = gWIDE;
+- pinfo->normh = pinfo->h = gHIGH;
+- pinfo->frmType = -1;
+- pinfo->colType = -1;
+-
+- sprintf(pinfo->fullInfo,"<%s internal>",
+- (pinfo->type == PIC8) ? "8-bit" : "24-bit");
+-
+- sprintf(pinfo->shrtInfo,"%dx%d image.",gWIDE, gHIGH);
+-
+- pinfo->comment = (char *) NULL;
+-
+- grabPic = (byte *) NULL;
+-
+- return 1;
+-}
+-
+-
+-
+-
+-
+-#include <X11/Xlib.h>
+-#include <X11/Xatom.h>
+-
+-static Window TryChildren PARM((Display *, Window, Atom));
+
+-/* Find a window with WM_STATE, else return '0' */
++ /* run through the data a second time, this time mapping pixel values in
++ pic24 into colormap offsets into 'colors' */
+
+-static Window xvClientWindow (dpy, win)
+- Display *dpy;
+- Window win;
+-{
+- Atom WM_STATE;
+- Atom type = None;
+- int format;
+- unsigned long nitems, after;
+- unsigned char *data;
+- Window inf;
+-
+- WM_STATE = XInternAtom(dpy, "WM_STATE", True);
+- if (!WM_STATE) return win;
++ for (i=w*h,p=pic24, pix=pic8; i; i--,pix++) {
++ col = (((u_long) *p++) << 16);
++ col += (((u_long) *p++) << 8);
++ col += *p++;
++
++ /* binary search the 'colors' array. It *IS* in there */
++ low = 0; high = nc-1;
++ while (low <= high) {
++ mid = (low+high)/2;
++ if (col < colors[mid]) high = mid - 1;
++ else if (col > colors[mid]) low = mid + 1;
++ else break;
++ }
+
+- XGetWindowProperty(dpy, win, WM_STATE, 0L, 0L, False, AnyPropertyType,
+- &type, &format, &nitems, &after, &data);
+- if (type) return win;
++ if (high < low) {
++ fprintf(stderr,"Trivial24to8: impossible situation!\n");
++ exit(1);
++ }
++ *pix = mid;
++ }
+
+- inf = TryChildren(dpy, win, WM_STATE);
++ /* and load up the 'desired colormap' */
++ for (i=0; i<nc; i++) {
++ rmap[i] = colors[i]>>16;
++ gmap[i] = (colors[i]>>8) & 0xff;
++ bmap[i] = colors[i] & 0xff;
++ }
+
+- return inf;
++ return 1;
+ }
+
+-static Window TryChildren (dpy, win, WM_STATE)
+- Display *dpy;
+- Window win;
+- Atom WM_STATE;
+-{
+- Window root, parent;
+- Window *children;
+- unsigned int nchildren;
+- unsigned int i;
+- Atom type = None;
+- int format;
+- unsigned long nitems, after;
+- unsigned char *data;
+- Window inf = 0;
+-
+- if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
+- return 0;
+
+- for (i = 0; !inf && (i < nchildren); i++) {
+- XGetWindowProperty(dpy, children[i], WM_STATE, 0L, 0L, False,
+- AnyPropertyType, &type, &format, &nitems,
+- &after, &data);
+- if (type)
+- inf = children[i];
+- }
+
+- for (i = 0; !inf && (i < nchildren); i++)
+- inf = TryChildren(dpy, children[i], WM_STATE);
+
+- if (children) XFree((char *)children);
+- return inf;
+-}
+diff -ruN xv-3.10a/xvgraf.c xv-3.10a-bugfixes/xvgraf.c
+--- xv-3.10a/xvgraf.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvgraf.c 2004-05-16 18:03:34.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvgraf.c - GRAF window handling functions
+ *
+ * callable functions:
+@@ -88,7 +88,7 @@
+ gp->win = XCreateSimpleWindow(theDisp, parent, x,y, GWIDE, GHIGH, 1, fg,bg);
+ if (!gp->win) FatalError("can't create graph (main) window");
+
+- gp->gwin = XCreateSimpleWindow(theDisp, gp->win, 2, GHIGH-132,
++ gp->gwin = XCreateSimpleWindow(theDisp, gp->win, 2, GHIGH-132,
+ 128, 128, 1, fg,bg);
+ if (!gp->gwin) FatalError("can't create graph (sub) window");
+
+@@ -96,7 +96,7 @@
+ BTCreate(&gp->butts[i], gp->win, GWIDE-GBWIDE-2, 1+i * (GBHIGH + 1),
+ GBWIDE, GBHIGH, (char *) NULL, fg, bg, hicol, locol);
+ gp->butts[i].pix = gfbpix[i];
+- gp->butts[i].pw = PW;
++ gp->butts[i].pw = PW;
+ gp->butts[i].ph = PH;
+ }
+
+@@ -132,7 +132,7 @@
+
+ gp->gammamode = 0; gp->gamma = 1.0;
+ }
+-
++
+
+ /***************************************************/
+ void RedrawGraf(gp, gwin)
+@@ -148,7 +148,7 @@
+ else {
+ Draw3dRect(gp->win, 0,0, GWIDE-1, GHIGH-1, R3D_OUT, 1, hicol, locol,
+ gp->bg);
+-
++
+ XSetForeground(theDisp, theGC, gp->fg);
+ XSetBackground(theDisp, theGC, gp->bg);
+ DrawString(gp->win, 2, 1+ASCENT, gp->str);
+@@ -165,7 +165,7 @@
+ {
+ int i,x,y;
+ XPoint pts[129], *pt;
+-
++
+
+ if (gp->entergamma) {
+ char *str1 = "Enter gamma";
+@@ -181,15 +181,15 @@
+ x = 10 + StringWidth(str2) + 8;
+ y = 30 + ASCENT + CHIGH + 3;
+ i = StringWidth(gp->gvstr);
+- if (gp->entergamma < 0 && strlen(gp->gvstr)) {
++ if (gp->entergamma < 0 && strlen(gp->gvstr)) {
+ /* show string highlited */
+ XFillRectangle(theDisp, gp->gwin, theGC, x-1, y-ASCENT-1,
+ (u_int) i+2, (u_int) CHIGH+2);
+ XSetForeground(theDisp, theGC, gp->bg);
+ }
+- else
++ else
+ XDrawLine(theDisp, gp->gwin, theGC, x+i, y-ASCENT, x+i, y+DESCENT);
+-
++
+ DrawString(gp->gwin, x,y, gp->gvstr);
+
+ return;
+@@ -267,7 +267,7 @@
+ if (i<N_GFB) { /* found one */
+ if (BTTrack(bp)) { /* it was selected */
+ switch (i) {
+- case GFB_SPLINE:
++ case GFB_SPLINE:
+ case GFB_LINE:
+ gp->gammamode = 0;
+
+@@ -312,7 +312,7 @@
+ if (gp->nhands < MAX_GHANDS) {
+ /* find largest x-gap in handles, put new handle in mid */
+ int lgap, lpos, x, y;
+-
++
+ lgap = gp->hands[1].x - gp->hands[0].x;
+ lpos = 1;
+ for (j=1; j<gp->nhands-1; j++)
+@@ -320,11 +320,11 @@
+ lgap = gp->hands[j+1].x - gp->hands[j].x;
+ lpos = j+1;
+ }
+-
++
+ /* open up position in hands[] array */
+- xvbcopy((char *) &gp->hands[lpos], (char *) &gp->hands[lpos+1],
++ xvbcopy((char *) &gp->hands[lpos], (char *) &gp->hands[lpos+1],
+ (gp->nhands - lpos) * sizeof(XPoint));
+-
++
+ x = gp->hands[lpos-1].x + lgap/2;
+ y = gp->func[x];
+ gp->hands[lpos].x = x;
+@@ -343,7 +343,7 @@
+ BTSetActive(&gp->butts[GFB_DELH], 1);
+ }
+ break;
+-
++
+ case GFB_DELH:
+ if (gp->nhands > 2) {
+ /* find (middle) point whose x-distance to previous
+@@ -361,9 +361,9 @@
+ mdist = dist; mpos = j;
+ }
+ }
+-
++
+ /* delete position 'mpos' in hands[] array */
+- xvbcopy((char *) &gp->hands[mpos+1], (char *) &gp->hands[mpos],
++ xvbcopy((char *) &gp->hands[mpos+1], (char *) &gp->hands[mpos],
+ (gp->nhands-mpos-1) * sizeof(XPoint));
+
+ gp->nhands--;
+@@ -408,16 +408,16 @@
+
+ /* keep original mouse position in 'mx,my', and warp mouse to center
+ of screen */
+- grab = !XGrabPointer(theDisp, gp->gwin, False, 0, GrabModeAsync,
++ grab = !XGrabPointer(theDisp, gp->gwin, False, 0, GrabModeAsync,
+ GrabModeAsync, None, inviso, (Time) CurrentTime);
+- XWarpPointer(theDisp, None, rootW, 0,0,0,0,
++ XWarpPointer(theDisp, None, rootW, 0,0,0,0,
+ (int) dispWIDE/2, (int) dispHIGH/2);
+
+- origx = dispWIDE/2; origy = dispHIGH/2;
++ origx = dispWIDE/2; origy = dispHIGH/2;
+ orighx = gp->hands[h].x; orighy = gp->hands[h].y;
+
+ gp->gammamode = 0;
+- offx = gp->hands[h].x - origx;
++ offx = gp->hands[h].x - origx;
+ offy = gp->hands[h].y - origy;
+
+ vertonly = (h==0 || h==(gp->nhands-1));
+@@ -434,7 +434,7 @@
+
+ dx = x - origx; dy = origy - y; /* flip y axis */
+
+- /* new (virt) position of handle is (desired)
++ /* new (virt) position of handle is (desired)
+ orighx + dx, orighy + dy */
+
+ if (!vertonly) { /* keep this handle between its neighbors */
+@@ -448,7 +448,7 @@
+ if (newx != gp->hands[h].x || newy != gp->hands[h].y) {
+ /* this handle has moved... */
+ XSetForeground(theDisp, theGC, gp->bg);
+- XFillRectangle(theDisp, gp->gwin, theGC,
++ XFillRectangle(theDisp, gp->gwin, theGC,
+ (gp->hands[h].x/2)-3, ((255-gp->hands[h].y)/2)-3, 7,7);
+
+ gp->hands[h].x = newx; gp->hands[h].y = newy;
+@@ -464,7 +464,7 @@
+ }
+
+ drawHandPos(gp, -1);
+- XWarpPointer(theDisp, None, gp->gwin, 0,0,0,0,
++ XWarpPointer(theDisp, None, gp->gwin, 0,0,0,0,
+ gp->hands[h].x/2, (255-gp->hands[h].y)/2);
+ if (grab) XUngrabPointer(theDisp, (Time) CurrentTime);
+ }
+@@ -481,9 +481,9 @@
+ {
+ int w;
+ char *tstr = "888,888";
+-
++
+ /* if hnum < 0, clears the text area */
+-
++
+ XSetFont(theDisp, theGC, monofont);
+ w = XTextWidth(monofinfo, tstr, (int) strlen(tstr));
+
+@@ -492,12 +492,12 @@
+
+ XSetForeground(theDisp, theGC, gp->fg);
+ XSetBackground(theDisp, theGC, gp->bg);
+- XDrawImageString(theDisp, gp->win, theGC, 130-w, 1+ASCENT,
++ XDrawImageString(theDisp, gp->win, theGC, 130-w, 1+ASCENT,
+ str, (int) strlen(str));
+
+ XSetFont(theDisp, theGC, mfont);
+ }
+-
++
+
+ /***************************************************/
+ int GrafKey(gp,str)
+@@ -518,7 +518,7 @@
+ }
+
+ while (*str) {
+- if (gp->entergamma == -1 &&
++ if (gp->entergamma == -1 &&
+ (*str != '\012' && *str != '\015' && *str != '\033')) {
+ gp->entergamma = 1;
+ gp->gvstr[0] = '\0';
+@@ -529,7 +529,7 @@
+ len = strlen(gp->gvstr);
+
+ if (*str>= '0' && *str <= '9') {
+- if (len < GVMAX) {
++ if (len < GVMAX) {
+ gp->gvstr[len++] = *str;
+ gp->gvstr[len] = '\0';
+ ok = 1;
+@@ -607,18 +607,18 @@
+
+ /* do sanity check. (x-coords must be sorted (strictly increasing)) */
+
+- for (i=0; i<gp->nhands; i++) {
+- RANGE(gp->hands[i].x, 0, 255);
++ for (i=0; i<gp->nhands; i++) {
++ RANGE(gp->hands[i].x, 0, 255);
+ RANGE(gp->hands[i].y, 0, 255);
+ }
+
+ gp->hands[0].x = 0; gp->hands[gp->nhands-1].x = 255;
+ for (i=1; i<gp->nhands-1; i++) {
+ if (gp->hands[i].x < i) gp->hands[i].x = i;
+- if (gp->hands[i].x > 256-gp->nhands+i)
++ if (gp->hands[i].x > 256-gp->nhands+i)
+ gp->hands[i].x = 256-gp->nhands+i;
+
+- if (gp->hands[i].x <= gp->hands[i-1].x)
++ if (gp->hands[i].x <= gp->hands[i-1].x)
+ gp->hands[i].x = gp->hands[i-1].x + 1;
+ }
+
+@@ -647,17 +647,17 @@
+ else { /* gp->gamma == 0.0 */
+ for (i=0; i<256; i++) gp->func[i] = 0;
+ }
+-
+-
++
++
+ for (i=0; i<gp->nhands; i++) {
+ gp->hands[i].y = gp->func[gp->hands[i].x];
+ }
+ }
+-
++
+ else if (!gp->spline) { /* do linear interpolation */
+ int y,x1,y1,x2,y2;
+ double yd;
+-
++
+ for (i=0; i<gp->nhands-1; i++) {
+ x1 = gp->hands[ i ].x; y1 = gp->hands[ i ].y;
+ x2 = gp->hands[i+1].x; y2 = gp->hands[i+1].y;
+@@ -676,12 +676,12 @@
+ double yf[MAX_GHANDS];
+ double yd;
+
+- for (i=0; i<gp->nhands; i++) {
++ for (i=0; i<gp->nhands; i++) {
+ x[i] = gp->hands[i].x; y[i] = gp->hands[i].y;
+ }
+-
++
+ InitSpline(x, y, gp->nhands, yf);
+-
++
+ for (i=0; i<256; i++) {
+ yd = EvalSpline(x, y, yf, gp->nhands, (double) i);
+ j = (int) floor(yd + 0.5);
+@@ -750,7 +750,7 @@
+ if (!str) return 1; /* NULL strings don't parse well! */
+
+ /* first, strip all pesky whitespace from str */
+- for (sp=str, dp=tstr; *sp; sp++)
++ for (sp=str, dp=tstr; *sp; sp++)
+ if (*sp > ' ') { *dp = *sp; dp++; }
+ *dp = '\0';
+
+@@ -764,7 +764,7 @@
+ }
+ else return 1;
+ }
+-
++
+ /* read Spline, or Line (S/L) character */
+ sp = tstr;
+ if (*sp == 'S' || *sp == 's') spline = 1;
+@@ -784,7 +784,7 @@
+ while (*sp && *sp != ':') {*dp = *sp; dp++; sp++; }
+ *dp++ = '\0';
+ if (sscanf(tstr1,"%d,%d",&x, &y) != 2) return 1;
+- if (x < 0 || x > 255 ||
++ if (x < 0 || x > 255 ||
+ y < 0 || y > 255) return 1; /* out of range */
+ coords[i].x = x; coords[i].y = y;
+ }
+@@ -837,7 +837,7 @@
+ IFSET(gp->gamma, gsp->gamma);
+ IFSET(gp->nhands, gsp->nhands);
+
+- if (strcmp(gp->gvstr, gsp->gvstr))
++ if (strcmp(gp->gvstr, gsp->gvstr))
+ { strcpy(gp->gvstr, gsp->gvstr); rv++; }
+
+ for (i=0; i<gp->nhands; i++) {
+@@ -880,7 +880,7 @@
+ sig = ((double) x[i]-x[i-1]) / ((double) x[i+1] - x[i-1]);
+ p = sig * y2[i-1] + 2.0;
+ y2[i] = (sig-1.0) / p;
+- u[i] = (((double) y[i+1]-y[i]) / (x[i+1]-x[i])) -
++ u[i] = (((double) y[i+1]-y[i]) / (x[i+1]-x[i])) -
+ (((double) y[i]-y[i-1]) / (x[i]-x[i-1]));
+ u[i] = (6.0 * u[i]/(x[i+1]-x[i-1]) - sig*u[i-1]) / p;
+ }
+@@ -912,9 +912,9 @@
+ if (h==0.0) FatalError("bad xvalues in splint\n");
+ a = (xa[khi]-x)/h;
+ b = (x-xa[klo])/h;
+- return (a*ya[klo] + b*ya[khi] + ((a*a*a-a)*y2a[klo] +(b*b*b-b)*y2a[khi])
++ return (a*ya[klo] + b*ya[khi] + ((a*a*a-a)*y2a[klo] +(b*b*b-b)*y2a[khi])
+ * (h*h) / 6.0);
+ }
+-
++
+
+
+diff -ruN xv-3.10a/xviff.c xv-3.10a-bugfixes/xviff.c
+--- xv-3.10a/xviff.c 1995-01-13 11:54:54.000000000 -0800
++++ xv-3.10a-bugfixes/xviff.c 2005-04-03 11:57:56.000000000 -0700
+@@ -39,7 +39,7 @@
+
+ static long filesize;
+
+-static int readID PARM((FILE *, char *));
++/* static int readID PARM((FILE *, char *)); DOES NOT EXIST */
+ static int iffError PARM((char *, char *));
+ static void decomprle PARM((byte *, byte *, long, long));
+ static unsigned int iff_getword PARM((byte *));
+@@ -65,16 +65,16 @@
+ /*******************************************/
+ {
+ /* returns '1' on success */
+-
++
+ register byte bitmsk, rval, gval, bval;
+ register long col, colbit;
+ FILE *fp;
+ int rv;
+- int BMHDok, CMAPok, CAMGok, BODYok;
++ int BMHDok, CMAPok, CAMGok;
+ int bmhd_width, bmhd_height, bmhd_bitplanes, bmhd_transcol;
+ int i, j, k, lineskip, colors, fmt;
+ byte bmhd_masking, bmhd_compression;
+- long chunkLen, camg_viewmode, decomp_bufsize;
++ long chunkLen, camg_viewmode;
+ byte *databuf, *dataptr, *cmapptr, *picptr, *pic, *bodyptr;
+ byte *workptr, *workptr2, *workptr3, *decomp_mem;
+
+@@ -138,6 +138,7 @@
+ BODY chunk was found or dataptr ran over end of file */
+
+ while ((rv<0) && (dataptr < (databuf + filesize))) {
++ int npixels = 0;
+ chunkLen = (iff_getlong(dataptr + 4) + 1) & 0xfffffffe; /* make even */
+
+ if (strncmp((char *) dataptr, "BMHD", (size_t) 4)==0) { /* BMHD chunk? */
+@@ -149,25 +150,30 @@
+ bmhd_transcol = iff_getword(dataptr + 8 + 12);
+ BMHDok = 1; /* got BMHD */
+ dataptr += 8 + chunkLen; /* to next chunk */
++
++ npixels = bmhd_width * bmhd_height; /* 65535*65535 max */
++ if (bmhd_width <= 0 || bmhd_height <= 0
++ || npixels/bmhd_width != bmhd_height)
++ return (iffError(bname, "xviff: image dimensions out of range"));
+ }
+
+
+ else if (strncmp((char *) dataptr, "CMAP", (size_t) 4)==0) { /* CMAP ? */
+ cmapptr = dataptr + 8;
+ colors = chunkLen / 3; /* calc no of colors */
+-
++
+ /* copy colors to color map */
+ for (i=0; i < colors; i++) {
+ pinfo->r[i] = *cmapptr++;
+ pinfo->g[i] = *cmapptr++;
+ pinfo->b[i] = *cmapptr++;
+ }
+-
++
+ CMAPok = 1; /* got CMAP */
+ dataptr += 8 + chunkLen; /* to next chunk */
+ }
+
+-
++
+ else if (strncmp((char *) dataptr, "CAMG", (size_t) 4)==0) { /* CAMG ? */
+ camg_viewmode = iff_getlong(dataptr + 8); /* get viewmodes */
+ CAMGok = 1; /* got CAMG */
+@@ -176,19 +182,28 @@
+
+
+ else if (strncmp((char *) dataptr, "BODY", (size_t) 4)==0) { /* BODY ? */
++ int byte_width = (((bmhd_width + 15) >> 4) << 1); /* 8192 max */
++
+ bodyptr = dataptr + 8; /* -> BODY data */
+-
++
+ if (BMHDok) { /* BMHD found? */
+ /* if BODY is compressed, allocate buffer for decrunched BODY and
+ decompress it (run length encoding) */
+-
++
+ if (bmhd_compression == 1) {
+ /* calc size of decrunch buffer - (size of the actual picture
+ decompressed in interleaved Amiga bitplane format) */
+
+- decomp_bufsize = (((bmhd_width + 15) >> 4) << 1)
+- * bmhd_height * bmhd_bitplanes;
+-
++ int bytes_per_bitplane = byte_width * bmhd_height; /* 536862720 max */
++ long decomp_bufsize = bytes_per_bitplane * bmhd_bitplanes;
++
++ if (byte_width <= 0 || bmhd_height <= 0 ||
++ bytes_per_bitplane/byte_width != bmhd_height ||
++ decomp_bufsize/bytes_per_bitplane != bmhd_bitplanes)
++ {
++ return (iffError(bname, "xviff: image dimensions out of range"));
++ }
++
+ if ((decomp_mem = (byte *)malloc((size_t) decomp_bufsize)) != NULL) {
+ decomprle(dataptr + 8, decomp_mem, chunkLen, decomp_bufsize);
+ bodyptr = decomp_mem; /* -> uncompressed BODY */
+@@ -200,12 +215,13 @@
+ FatalError("xviff: cannot malloc() decrunch buffer");
+ }
+ }
+-
++
+
+ /* the following determines the type of the ILBM file.
+ it's either NORMAL, EHB, HAM, HAM8 or 24BIT */
+-
++
+ fmt = ILBM_NORMAL; /* assume normal ILBM */
++ /* FIXME: does ILBM_NORMAL really support up to 255 bitplanes? */
+
+ if (bmhd_bitplanes == 24) fmt = ILBM_24BIT;
+ else if (bmhd_bitplanes == 8) {
+@@ -216,7 +232,7 @@
+ if (camg_viewmode & 0x80) fmt = ILBM_EHB;
+ else if (camg_viewmode & 0x800) fmt = ILBM_HAM;
+ }
+-
++
+
+ if (DEBUG) {
+ fprintf(stderr, "LoadIFF: %s %dx%d, planes=%d (%d cols), comp=%d\n",
+@@ -225,9 +241,9 @@
+ (fmt==ILBM_HAM8) ? "HAM8 ILBM" :
+ (fmt==ILBM_EHB) ? "EHB ILBM" :
+ (fmt==ILBM_24BIT) ? "24BIT ILBM" : "unknown ILBM",
+- bmhd_width, bmhd_height, bmhd_bitplanes,
++ bmhd_width, bmhd_height, bmhd_bitplanes,
+ 1<<bmhd_bitplanes, bmhd_compression);
+- }
++ }
+
+
+ if ((fmt==ILBM_NORMAL) || (fmt==ILBM_EHB) || (fmt==ILBM_HAM)) {
+@@ -248,8 +264,14 @@
+
+
+ if ((fmt == ILBM_HAM) || (fmt == ILBM_HAM8) || (fmt == ILBM_24BIT)) {
+- if ((picptr=(byte *) malloc((size_t)bmhd_width*bmhd_height*3))
+- ==NULL) {
++ int bufsize = 3 * npixels;
++
++ if (bufsize/3 != npixels) {
++ if (databuf) free(databuf);
++ if (decomp_mem) free(decomp_mem);
++ return (iffError(bname, "xviff: image dimensions out of range"));
++ }
++ if ((picptr=(byte *) malloc((size_t) bufsize)) == NULL) {
+ if (databuf) free(databuf);
+ if (decomp_mem) free(decomp_mem);
+ return (iffError(bname, "xviff: no memory for decoded picture"));
+@@ -258,8 +280,8 @@
+ else {
+ pic = picptr;
+ workptr = bodyptr;
+- lineskip = ((bmhd_width + 15) >> 4) << 1;
+-
++ lineskip = byte_width;
++
+ for (i=0; i<bmhd_height; i++) {
+ bitmsk = 0x80;
+ workptr2 = workptr;
+@@ -338,28 +360,28 @@
+
+
+ else if ((fmt == ILBM_NORMAL) || (fmt == ILBM_EHB)) {
+- if ((picptr = (byte *) malloc((size_t) bmhd_width * bmhd_height))
+- == NULL) {
++ /* if bmhd_width and bmhd_height are OK (checked in BMHD block
++ * above; guaranteed by BMHDok), then npixels is OK, too */
++ if ((picptr = (byte *) malloc((size_t) npixels)) == NULL) {
+ if (databuf) free(databuf);
+ if (decomp_mem) free(decomp_mem);
+ return (iffError(bname, "xviff: no memory for decoded picture"));
+ }
+-
++
+ else if (fmt == ILBM_EHB) {
+ if (DEBUG) fprintf(stderr,"Doubling CMAP for EHB mode\n");
+-
++
+ for (i=0; i<32; i++) {
+ pinfo->r[i + colors] = pinfo->r[i] >> 1;
+ pinfo->g[i + colors] = pinfo->g[i] >> 1;
+ pinfo->b[i + colors] = pinfo->b[i] >> 1;
+ }
+ }
+-
++
+ pic = picptr; /* ptr to chunky buffer */
+ workptr = bodyptr; /* ptr to uncmp'd pic, planar format */
+-
+- lineskip = ((bmhd_width + 15) >> 4) << 1; /* # of bytes/line */
+-
++ lineskip = byte_width;
++
+ for (i=0; i<bmhd_height; i++) {
+ bitmsk = 0x80; /* left most bit (mask) */
+ workptr2 = workptr; /* work ptr to source */
+@@ -367,14 +389,14 @@
+ col = 0;
+ colbit = 1;
+ workptr3 = workptr2; /* ptr to byte in 1st pln */
+-
++
+ for (k=0; k<bmhd_bitplanes; k++) {
+ if (*workptr3 & bitmsk) /* if bit set in this pln */
+ col = col + colbit; /* add bit to chunky byte */
+ workptr3 += lineskip; /* go to next line */
+ colbit <<= 1; /* shift color bit */
+ }
+-
++
+ *pic++ = col; /* write to chunky buffer */
+ bitmsk = bitmsk >> 1; /* shift mask to next bit */
+ if (bitmsk == 0) { /* if mask is zero */
+@@ -382,7 +404,7 @@
+ workptr2++; /* mv ptr to next byte */
+ }
+ } /* for j ... */
+-
++
+ workptr += lineskip * bmhd_bitplanes; /* to next line */
+ } /* for i ... */
+
+@@ -399,7 +421,7 @@
+ pinfo->colType = F_FULLCOLOR;
+ pinfo->frmType = -1;
+
+- sprintf(pinfo->fullInfo, "%s (%ld bytes)",
++ sprintf(pinfo->fullInfo, "%s (%ld bytes)",
+ (fmt==ILBM_NORMAL) ? "IFF ILBM" :
+ (fmt==ILBM_HAM) ? "HAM ILBM" :
+ (fmt==ILBM_HAM8) ? "HAM8 ILBM" :
+@@ -414,7 +436,8 @@
+ } /* if BMHDok */
+
+ else rv = 0; /* didn't get BMHD header */
+- }
++
++ } /* "BODY" chunk */
+
+ else {
+ if (DEBUG)
+@@ -440,10 +463,10 @@
+
+ /**************************************************************************
+ void decomprle(source, destination, source length, buffer size)
+-
++
+ Decompress run-length encoded data from source to destination. Terminates
+ when source is decoded completely or destination buffer is full.
+-
++
+ The decruncher is as optimized as I could make it, without risking
+ safety in case of corrupt BODY chunks.
+ ***************************************************************************/
+@@ -455,12 +478,12 @@
+ register long slen, dlen;
+ {
+ register byte codeByte, dataByte;
+-
++
+ while ((slen > 0) && (dlen > 0)) {
+-
++
+ /* read control byte */
+ codeByte = *sptr++;
+-
++
+ if (codeByte < 0x80) {
+ codeByte++;
+ if ((slen > (long) codeByte) && (dlen >= (long) codeByte)) {
+diff -ruN xv-3.10a/xvimage.c xv-3.10a-bugfixes/xvimage.c
+--- xv-3.10a/xvimage.c 1995-01-13 16:11:36.000000000 -0800
++++ xv-3.10a-bugfixes/xvimage.c 2005-03-31 07:23:39.000000000 -0800
+@@ -34,7 +34,7 @@
+ static void do_pan_calc PARM((int, int, int *, int *));
+ static void crop1 PARM((int, int, int, int, int));
+ static int doAutoCrop24 PARM((void));
+-static void floydDitherize1 PARM((XImage *, byte *, int, int, int,
++static void floydDitherize1 PARM((XImage *, byte *, int, int, int,
+ byte *, byte *,byte *));
+ static int highbit PARM((unsigned long));
+
+@@ -74,7 +74,7 @@
+ GenerateEpic(w,h);
+ CreateXImage();
+ }
+-
++
+
+
+ /********************************************/
+@@ -90,15 +90,15 @@
+
+ cp = cpic;
+ bperpix = (picType == PIC8) ? 1 : 3;
+-
++
+ for (i=0; i<cHIGH; i++) {
+ if ((i&63)==0) WaitCursor();
+ pp = pic + (i+cYOFF) * (pWIDE*bperpix) + (cXOFF * bperpix);
+- for (j=0; j<cWIDE*bperpix; j++)
++ for (j=0; j<cWIDE*bperpix; j++)
+ *cp++ = *pp++;
+ }
+ }
+-
++
+
+
+ /***********************************/
+@@ -112,10 +112,10 @@
+ clptr = NULL; cxarrp = NULL; cy = 0; /* shut up compiler */
+
+ SetISTR(ISTR_EXPAND, "%.5g%% x %.5g%% (%d x %d)",
+- 100.0 * ((float) w) / cWIDE,
++ 100.0 * ((float) w) / cWIDE,
+ 100.0 * ((float) h) / cHIGH, w, h);
+
+- if (DEBUG)
++ if (DEBUG)
+ fprintf(stderr,"GenerateEpic(%d,%d) eSIZE=%d,%d cSIZE=%d,%d epicode=%d\n",
+ w,h,eWIDE,eHIGH,cWIDE,cHIGH, epicMode);
+
+@@ -124,7 +124,7 @@
+ eWIDE = w; eHIGH = h;
+
+
+- if (epicMode == EM_SMOOTH) {
++ if (epicMode == EM_SMOOTH) {
+ if (picType == PIC8) {
+ epic = SmoothResize(cpic, cWIDE, cHIGH, eWIDE, eHIGH,
+ rMap,gMap,bMap, rdisp,gdisp,bdisp, numcols);
+@@ -143,7 +143,7 @@
+
+
+ /* generate a 'raw' epic, as we'll need it for ColorDither if EM_DITH */
+-
++
+ if (eWIDE==cWIDE && eHIGH==cHIGH) { /* 1:1 expansion. point epic at cpic */
+ epic = cpic;
+ }
+@@ -163,13 +163,13 @@
+ /* the scaling routine. not really all that scary after all... */
+
+ /* OPTIMIZATON: Malloc an eWIDE array of ints which will hold the
+- values of the equation px = (pWIDE * ex) / eWIDE. Faster than doing
++ values of the equation px = (pWIDE * ex) / eWIDE. Faster than doing
+ a mul and a div for every point in picture */
+
+ cxarr = (int *) malloc(eWIDE * sizeof(int));
+ if (!cxarr) FatalError("unable to allocate cxarr");
+
+- for (ex=0; ex<eWIDE; ex++)
++ for (ex=0; ex<eWIDE; ex++)
+ cxarr[ex] = bperpix * ((cWIDE * ex) / eWIDE);
+
+ elptr = epptr = epic;
+@@ -182,7 +182,7 @@
+ clptr = cpic + (cy * cWIDE * bperpix);
+
+ if (bperpix == 1) {
+- for (ex=0, cxarrp = cxarr; ex<eWIDE; ex++, epptr++)
++ for (ex=0, cxarrp = cxarr; ex<eWIDE; ex++, epptr++)
+ *epptr = clptr[*cxarrp++];
+ }
+ else {
+@@ -190,7 +190,7 @@
+
+ for (ex=0, cxarrp = cxarr; ex<eWIDE; ex++,cxarrp++) {
+ cp = clptr + *cxarrp;
+- for (j=0; j<bperpix; j++)
++ for (j=0; j<bperpix; j++)
+ *epptr++ = *cp++;
+ }
+ }
+@@ -203,7 +203,7 @@
+ if (picType == PIC8 && epicMode == EM_DITH) {
+ byte *tmp;
+
+- tmp = DoColorDither(NULL, epic, eWIDE, eHIGH, rMap,gMap,bMap,
++ tmp = DoColorDither(NULL, epic, eWIDE, eHIGH, rMap,gMap,bMap,
+ rdisp,gdisp,bdisp, numcols);
+ if (tmp) { /* success */
+ FreeEpic();
+@@ -214,7 +214,7 @@
+ }
+ }
+ }
+-
++
+
+
+ /***********************************/
+@@ -233,7 +233,7 @@
+ static void do_zoom(mx,my)
+ int mx,my;
+ {
+- int i,w,h,x,y,x2,y2;
++ int i;
+ int rx,ry,rx2,ry2, orx, ory, orw, orh;
+ int px,py,pw,ph,opx,opy,opw,oph,m;
+ Window rW, cW; unsigned int mask; int rtx, rty;
+@@ -254,10 +254,10 @@
+ while (1) {
+ if (!XQueryPointer(theDisp,mainW,&rW,&cW,&rtx,&rty,
+ &mx,&my,&mask)) continue;
+-
++
+ if (!(mask & ControlMask)) break;
+ if (!(mask & Button1Mask)) break; /* button released */
+-
++
+ compute_zoom_rect(mx, my, &px, &py, &pw, &ph);
+ if (px!=opx || py!=opy) {
+ XDrawRectangle(theDisp,mainW,theGC, orx,ory, (u_int)orw, (u_int)orh);
+@@ -283,7 +283,7 @@
+ XSetPlaneMask(theDisp, theGC, AllPlanes);
+ return;
+ }
+-
++
+
+ for (i=0; i<4; i++) {
+ XDrawRectangle(theDisp, mainW, theGC, orx, ory, (u_int) orw, (u_int) orh);
+@@ -297,7 +297,7 @@
+ /* if rectangle is *completely* outside epic, don't zoom */
+ if (orx+orw<0 || ory+orh<0 || orx>=eWIDE || ory>=eHIGH) return;
+
+-
++
+ crop1(opx, opy, opw, oph, DO_ZOOM);
+ }
+
+@@ -306,15 +306,15 @@
+ static void compute_zoom_rect(x, y, px, py, pw, ph)
+ int x, y, *px, *py, *pw, *ph;
+ {
+- /* given a mouse pos (in epic coords), return x,y,w,h PIC coords for
+- a 'zoom in by 2x' rectangle to be tracked. The rectangle stays
++ /* given a mouse pos (in epic coords), return x,y,w,h PIC coords for
++ a 'zoom in by 2x' rectangle to be tracked. The rectangle stays
+ completely within 'pic' boundaries, and moves in 'pic' increments */
+
+ CoordE2P(x, y, px, py);
+- *pw = (cWIDE+1)/2;
++ *pw = (cWIDE+1)/2;
+ *ph = (cHIGH+1)/2;
+
+- *px = *px - (*pw)/2;
++ *px = *px - (*pw)/2;
+ *py = *py - (*ph)/2;
+
+ RANGE(*px, 0, pWIDE - *pw);
+@@ -327,7 +327,7 @@
+ {
+ int x,y,w,h, x2,y2, ex,ey,ew,eh;
+
+- /* compute a cropping rectangle (in pic coordinates) that's twice
++ /* compute a cropping rectangle (in pic coordinates) that's twice
+ the size of eWIDE,eHIGH, centered around eWIDE/2, eHIGH/2, but no
+ larger than pWIDE,PHIGH */
+
+@@ -362,7 +362,7 @@
+ int i, ox,oy,offx,offy, rw,rh, px, py, dx, dy,m;
+ Window rW, cW; unsigned int mask; int rx, ry;
+
+- offx = ox = mx;
++ offx = ox = mx;
+ offy = oy = my;
+ rw = eWIDE-1; rh = eHIGH-1;
+ m = 0;
+@@ -374,50 +374,50 @@
+
+ /* track until Button2 is released */
+ while (1) {
+- if (!XQueryPointer(theDisp, mainW, &rW, &cW, &rx, &ry,
++ if (!XQueryPointer(theDisp, mainW, &rW, &cW, &rx, &ry,
+ &mx, &my, &mask)) continue;
+ if (!(mask & ControlMask)) break; /* cancelled */
+ if (!(mask & Button2Mask)) break; /* button released */
+-
++
+ if (mask & ShiftMask) { /* constrain mx,my to horiz or vertical */
+ if (abs(mx-offx) > abs(my-offy)) my = offy;
+ else mx = offx;
+ }
+-
++
+ do_pan_calc(offx, offy, &mx, &my);
+-
++
+ if (mx!=ox || my!=oy) {
+- XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
++ XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
+ (u_int) rw, (u_int) rh);
+- XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
++ XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
+ (u_int) rw, (u_int) rh);
+ ox = mx; oy = my;
+ }
+ else {
+- XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
++ XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
+ (u_int) rw, (u_int) rh);
+ m = (m+1)&7;
+ XSetPlaneMask(theDisp, theGC, xorMasks[m]);
+- XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
++ XDrawRectangle(theDisp, mainW, theGC, ox-offx, oy-offy,
+ (u_int) rw, (u_int) rh);
+ XFlush(theDisp);
+ Timer(100);
+ }
+ }
+-
++
+ mx = ox; my = oy; /* in case mx,my changed on button release */
+
+ if (!(mask & ControlMask)) { /* cancelled */
+- XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
++ XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
+ (u_int) rw, (u_int) rh);
+ XSetFunction(theDisp, theGC, GXcopy);
+ XSetPlaneMask(theDisp, theGC, AllPlanes);
+ return;
+ }
+-
++
+
+ for (i=0; i<4; i++) {
+- XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
++ XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
+ (u_int) rw, (u_int) rh);
+ XFlush(theDisp);
+ Timer(100);
+@@ -430,7 +430,7 @@
+ dx = px - cXOFF; dy = py - cYOFF;
+
+ if (dx==0 && dy==0) { /* didn't pan anywhere */
+- XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
++ XDrawRectangle(theDisp, mainW, theGC, mx-offx, my-offy,
+ (u_int) rw, (u_int) rh);
+ XSetFunction(theDisp, theGC, GXcopy);
+ XSetPlaneMask(theDisp, theGC, AllPlanes);
+@@ -485,7 +485,7 @@
+ /***********************************/
+ void Crop()
+ {
+- int i, x, y, w, h;
++ int x, y, w, h;
+
+ if (!HaveSelection()) return;
+
+@@ -499,8 +499,7 @@
+ static void crop1(x,y,w,h,zm)
+ int x,y,w,h,zm;
+ {
+- int i,j,oldew,oldeh,oldcx,oldcy;
+- byte *cp, *pp;
++ int oldew,oldeh,oldcx,oldcy;
+
+ oldcx = cXOFF; oldcy = cYOFF;
+ oldew = eWIDE; oldeh = eHIGH;
+@@ -529,7 +528,7 @@
+ if (cpic == pic) return; /* not cropped */
+
+ BTSetActive(&but[BUNCROP],0);
+-
++
+ if (epicMode == EM_SMOOTH) { /* turn off smoothing */
+ epicMode = EM_RAW; SetEpicMode();
+ }
+@@ -538,7 +537,7 @@
+ FreeEpic();
+ if (cpic && cpic != pic) free(cpic);
+ cpic = NULL;
+-
++
+
+ w = (pWIDE * eWIDE) / cWIDE; h = (pHIGH * eHIGH) / cHIGH;
+ if (w>maxWIDE || h>maxHIGH) {
+@@ -566,7 +565,7 @@
+ WUnCrop();
+ SetCropString();
+ }
+-
++
+
+ /***********************************/
+ void AutoCrop()
+@@ -583,7 +582,7 @@
+ WCrop(eWIDE, eHIGH, cXOFF-oldcx, cYOFF-oldcy);
+ }
+ }
+-
++
+ SetCursors(-1);
+ }
+
+@@ -650,7 +649,7 @@
+
+ /* do the actual cropping */
+ if (cleft || ctop || cbot || cright) {
+- DoCrop(cXOFF+cleft, cYOFF+ctop,
++ DoCrop(cXOFF+cleft, cYOFF+ctop,
+ cWIDE-(cleft+cright), cHIGH-(ctop+cbot));
+ return 1;
+ }
+@@ -673,7 +672,7 @@
+ # define NEIGHBOR 16 /* within 6% of neighboring pixels */
+ # define MISSPCT 6 /* and up to 6% that don't match */
+ # define inabsrange(a,n) ( (a) < n && (a) > -n )
+-
++
+
+ if (cHIGH<3 || cWIDE<3) return 0;
+
+@@ -739,7 +738,7 @@
+ while (cleft + 1 < cWIDE) { /* see if we can delete this line */
+ oldr = bgR; oldg = bgG; oldb = bgB;
+
+- for (i=0, misses=0, cp1=cp; i<cHIGH && misses<maxmiss;
++ for (i=0, misses=0, cp1=cp; i<cHIGH && misses<maxmiss;
+ i++, cp1 += (cWIDE * 3)) {
+ r=cp1[0]-bgR; g=cp1[1]-bgG; b=cp1[2]-bgB;
+ R=cp1[0]-oldr; G=cp1[1]-oldg; B=cp1[2]-oldb;
+@@ -763,7 +762,7 @@
+ while (cleft + cright + 1 < cWIDE) { /* see if we can delete this line */
+ oldr = bgR; oldg = bgG; oldb = bgB;
+
+- for (i=0, misses=0, cp1=cp; i<cHIGH && misses<maxmiss;
++ for (i=0, misses=0, cp1=cp; i<cHIGH && misses<maxmiss;
+ i++, cp1 += (cWIDE*3)) {
+ r=cp1[0]-bgR; g=cp1[1]-bgG; b=cp1[2]-bgB;
+ R=cp1[0]-oldr; G=cp1[1]-oldg; B=cp1[2]-oldb;
+@@ -784,8 +783,8 @@
+ if (cleft || ctop || cbot || cright) {
+ if (cWIDE - (cleft + cright) < 1 ||
+ cHIGH - (ctop + cbot ) < 1) return 0; /* sanity check */
+-
+- DoCrop(cXOFF+cleft, cYOFF+ctop,
++
++ DoCrop(cXOFF+cleft, cYOFF+ctop,
+ cWIDE-(cleft+cright), cHIGH-(ctop+cbot));
+ return 1;
+ }
+@@ -802,7 +801,7 @@
+ and sticks likely values into eWIDE,eHIGH, assuming you wanted to
+ crop. epic is not regnerated (but is freed) */
+
+- int i, j, k, bperpix;
++ int i, j, bperpix;
+ byte *cp, *pp;
+ double expw, exph;
+
+@@ -837,7 +836,7 @@
+ else {
+ /* at this point, we want to generate cpic, which will contain a
+ cWIDE*cHIGH subsection of 'pic', top-left at cXOFF,cYOFF */
+-
++
+ cpic = (byte *) malloc((size_t) (cWIDE * cHIGH * bperpix));
+
+ if (cpic == NULL) {
+@@ -852,7 +851,7 @@
+ cp = cpic;
+ for (i=0; i<cHIGH; i++) {
+ pp = pic + (i+cYOFF) * (pWIDE*bperpix) + (cXOFF * bperpix);
+- for (j=0; j<cWIDE*bperpix; j++)
++ for (j=0; j<cWIDE*bperpix; j++)
+ *cp++ = *pp++;
+ }
+ }
+@@ -861,7 +860,7 @@
+ SetCropString();
+ BTSetActive(&but[BUNCROP], (cpic!=pic));
+
+- eWIDE = (int) (cWIDE * expw);
++ eWIDE = (int) (cWIDE * expw);
+ eHIGH = (int) (cHIGH * exph);
+
+ if (eWIDE>maxWIDE || eHIGH>maxHIGH) { /* make 'normal' size */
+@@ -869,7 +868,7 @@
+ double r,wr,hr;
+ wr = ((double) cWIDE) / maxWIDE;
+ hr = ((double) cHIGH) / maxHIGH;
+-
++
+ r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */
+ eWIDE = (int) ((cWIDE / r) + 0.5);
+ eHIGH = (int) ((cHIGH / r) + 0.5);
+@@ -906,12 +905,12 @@
+ int dir;
+ {
+ int i;
+-
++
+ /* dir=0: 90 degrees clockwise, else 90 degrees counter-clockwise */
+ WaitCursor();
+-
++
+ RotatePic(pic, picType, &pWIDE, &pHIGH, dir);
+-
++
+ /* rotate clipped version and modify 'clip' coords */
+ if (cpic != pic && cpic != NULL) {
+ if (!dir) {
+@@ -928,7 +927,7 @@
+ RotatePic(cpic, picType, &cWIDE, &cHIGH,dir);
+ }
+ else { cWIDE = pWIDE; cHIGH = pHIGH; }
+-
++
+ /* rotate expanded version */
+ if (epic != cpic && epic != NULL) {
+ WaitCursor();
+@@ -940,7 +939,7 @@
+ SetISTR(ISTR_RES,"%d x %d",pWIDE,pHIGH);
+
+ SetISTR(ISTR_EXPAND, "%.5g%% x %.5g%% (%d x %d)",
+- 100.0 * ((float) eWIDE) / cWIDE,
++ 100.0 * ((float) eWIDE) / cWIDE,
+ 100.0 * ((float) eHIGH) / cHIGH, eWIDE, eHIGH);
+ }
+
+@@ -951,7 +950,7 @@
+ int *wp, *hp;
+ int ptype, dir;
+ {
+- /* rotates a w*h array of bytes 90 deg clockwise (dir=0)
++ /* rotates a w*h array of bytes 90 deg clockwise (dir=0)
+ or counter-clockwise (dir != 0). swaps w and h */
+
+ byte *pic1, *pix1, *pix;
+@@ -960,7 +959,7 @@
+
+ bperpix = (ptype == PIC8) ? 1 : 3;
+
+- w = *wp; h = *hp;
++ w = *wp; h = *hp;
+ pix1 = pic1 = (byte *) malloc((size_t) (w*h*bperpix));
+ if (!pic1) FatalError("Not enough memory to rotate!");
+
+@@ -968,15 +967,15 @@
+ if (dir==0) {
+ for (i=0; i<w; i++) { /* CW */
+ if (bperpix == 1) {
+- for (j=h-1, pix=pic+(h-1)*w + i; j>=0; j--, pix1++, pix-=w)
++ for (j=h-1, pix=pic+(h-1)*w + i; j>=0; j--, pix1++, pix-=w)
+ *pix1 = *pix;
+ }
+ else {
+ int bperlin = w*bperpix;
+ int k;
+-
+- for (j=h-1, pix=pic+(h-1)*w*bperpix + i*bperpix;
+- j>=0; j--, pix -= bperlin)
++
++ for (j=h-1, pix=pic+(h-1)*w*bperpix + i*bperpix;
++ j>=0; j--, pix -= bperlin)
+ for (k=0; k<bperpix; k++) *pix1++ = pix[k];
+ }
+ }
+@@ -984,25 +983,25 @@
+ else {
+ for (i=w-1; i>=0; i--) { /* CCW */
+ if (bperpix == 1) {
+- for (j=0, pix=pic+i; j<h; j++, pix1++, pix+=w)
++ for (j=0, pix=pic+i; j<h; j++, pix1++, pix+=w)
+ *pix1 = *pix;
+ }
+ else {
+ int k;
+ int bperlin = w*bperpix;
+-
+- for (j=0, pix=pic+i*bperpix; j<h; j++, pix+=bperlin)
++
++ for (j=0, pix=pic+i*bperpix; j<h; j++, pix+=bperlin)
+ for (k=0; k<bperpix; k++) *pix1++ = pix[k];
+ }
+ }
+ }
+-
+-
++
++
+ /* copy the rotated buffer into the original buffer */
+ xvbcopy((char *) pic1, (char *) pic, (size_t) (w*h*bperpix));
+-
++
+ free(pic1);
+-
++
+ /* swap w and h */
+ *wp = h; *hp = w;
+ }
+@@ -1017,7 +1016,7 @@
+ *
+ * Note: flips pic, cpic, and epic. Doesn't touch Ximage, nor does it draw
+ */
+-
++
+ WaitCursor();
+
+ if (HaveSelection()) { /* only flip selection region */
+@@ -1026,7 +1025,7 @@
+ }
+
+ FlipPic(pic, pWIDE, pHIGH, dir);
+-
++
+ /* flip clipped version */
+ if (cpic && cpic != pic) {
+ WaitCursor();
+@@ -1048,21 +1047,21 @@
+ int dir;
+ {
+ /* flips a w*h array of bytes horizontally (dir=0) or vertically (dir!=0) */
+-
++
+ byte *plin;
+ int i,j,k,l,bperpix,bperlin;
+-
++
+ bperpix = (picType == PIC8) ? 1 : 3;
+ bperlin = w * bperpix;
+-
++
+ if (dir==0) { /* horizontal flip */
+ byte *leftp, *rightp;
+-
++
+ for (i=0; i<h; i++) {
+ plin = pic + i*bperlin;
+ leftp = plin;
+ rightp = plin + (w-1)*bperpix;
+-
++
+ for (j=0; j<w/2; j++, rightp -= (2*bperpix)) {
+ for (l=0; l<bperpix; l++, leftp++, rightp++) {
+ k = *leftp; *leftp = *rightp; *rightp = k;
+@@ -1070,14 +1069,14 @@
+ }
+ }
+ }
+-
++
+ else { /* vertical flip */
+ byte *topp, *botp;
+-
++
+ for (i=0; i<w; i++) {
+ topp = pic + i*bperpix;
+ botp = pic + (h-1)*bperlin + i*bperpix;
+-
++
+ for (j=0; j<h/2; j++, topp+=(w-1)*bperpix, botp-=(w+1)*bperpix) {
+ for (l=0; l<bperpix; l++, topp++, botp++) {
+ k = *topp; *topp = *botp; *botp = k;
+@@ -1093,26 +1092,26 @@
+ int dir;
+ {
+ /* flips selected area in 'pic', regens cpic and epic appropriately */
+-
++
+ int x,y,w,h;
+ byte *plin;
+ int i,j,k,l,bperpix;
+-
++
+ GetSelRCoords(&x,&y,&w,&h);
+ CropRect2Rect(&x,&y,&w,&h, 0,0,pWIDE,pHIGH);
+ if (w<1) w=1;
+ if (h<1) h=1;
+-
++
+ bperpix = (picType == PIC8) ? 1 : 3;
+-
++
+ if (dir==0) { /* horizontal flip */
+ byte *leftp, *rightp;
+-
++
+ for (i=y; i<y+h; i++) {
+ plin = pic + (i*pWIDE + x) * bperpix;
+ leftp = plin;
+ rightp = plin + (w-1)*bperpix;
+-
++
+ for (j=0; j<w/2; j++, rightp -= (2*bperpix)) {
+ for (l=0; l<bperpix; l++, leftp++, rightp++) {
+ k = *leftp; *leftp = *rightp; *rightp = k;
+@@ -1120,14 +1119,14 @@
+ }
+ }
+ }
+-
++
+ else { /* vertical flip */
+ byte *topp, *botp;
+-
++
+ for (i=x; i<x+w; i++) {
+ topp = pic + ( y * pWIDE + i) * bperpix;
+ botp = pic + ((y+h-1) * pWIDE + i) * bperpix;
+-
++
+ for (j=0; j<h/2; j++, topp+=(pWIDE-1)*bperpix, botp-=(pWIDE+1)*bperpix) {
+ for (l=0; l<bperpix; l++, topp++, botp++) {
+ k = *topp; *topp = *botp; *botp = k;
+@@ -1139,22 +1138,22 @@
+ GenerateCpic();
+ GenerateEpic(eWIDE,eHIGH);
+ }
+-
++
+
+ /************************/
+ void InstallNewPic()
+ {
+ /* given a new pic and colormap, (or new 24-bit pic) installs everything,
+ regens cpic and epic, and redraws image */
+-
++
+ /* toss old cpic and epic, if any */
+ FreeEpic();
+ if (cpic && cpic != pic) free(cpic);
+ cpic = NULL;
+-
++
+ /* toss old colors, and allocate new ones */
+ NewPicGetColors(0,0);
+-
++
+ /* generate cpic,epic,theImage from new 'pic' */
+ crop1(cXOFF, cYOFF, cWIDE, cHIGH, DO_ZOOM);
+ HandleDispMode();
+@@ -1166,15 +1165,15 @@
+ void DrawEpic()
+ {
+ /* given an 'epic', builds a new Ximage, and draws it. Basically
+- called whenever epic is changed, or whenever color allocation
+- changes (ie, the created X image will look different for the
++ called whenever epic is changed, or whenever color allocation
++ changes (ie, the created X image will look different for the
+ same epic) */
+-
++
+ CreateXImage();
+
+ if (useroot) MakeRootPic();
+ else DrawWindow(0,0,eWIDE,eHIGH);
+-
++
+ if (HaveSelection()) DrawSelection(0);
+ }
+
+@@ -1189,7 +1188,7 @@
+ if (pic) free(pic);
+ xvDestroyImage(theImage); theImage = NULL;
+ pic = egampic = epic = cpic = NULL;
+-
++
+ if (picComments) free(picComments);
+ picComments = (char *) NULL;
+ ChangeCommentText();
+@@ -1203,7 +1202,7 @@
+ byte *pic824, *rmap, *gmap, *bmap;
+ int ptype, wide, high;
+ {
+- /* does floyd-steinberg ditherizing algorithm.
++ /* does floyd-steinberg ditherizing algorithm.
+ *
+ * takes a wide*high input image, of type 'ptype' (PIC8, PIC24)
+ * (if PIC8, colormap is specified by rmap,gmap,bmap)
+@@ -1212,14 +1211,14 @@
+ *
+ * Note: this algorithm is *only* used when running on a 1-bit display
+ */
+-
++
+ register byte pix8, bit;
+ int *thisline, *nextline;
+ int *thisptr, *nextptr, *tmpptr;
+ int i, j, err, bperpix, bperln, order;
+ byte *pp, *image, w1, b1, w8, b8, rgb[256];
+-
+-
++
++
+ if (ptype == PIC8) { /* monoify colormap */
+ for (i=0; i<256; i++)
+ rgb[i] = MONO(rmap[i], gmap[i], bmap[i]);
+@@ -1234,7 +1233,7 @@
+
+ thisline = (int *) malloc(wide * sizeof(int));
+ nextline = (int *) malloc(wide * sizeof(int));
+- if (!thisline || !nextline)
++ if (!thisline || !nextline)
+ FatalError("ran out of memory in floydDitherize1()\n");
+
+
+@@ -1249,10 +1248,10 @@
+ *tmpptr++ = fsgamcr[rgb[*pp]];
+ }
+
+-
++
+ w1 = white&0x1; b1=black&0x1;
+ w8 = w1<<7; b8 = b1<<7; /* b/w bit in high bit */
+-
++
+
+ for (i=0; i<high; i++) {
+ if ((i&0x3f) == 0) WaitCursor();
+@@ -1326,7 +1325,7 @@
+
+
+ /************************/
+-byte *FSDither(inpic, intype, w, h, rmap, gmap, bmap,
++byte *FSDither(inpic, intype, w, h, rmap, gmap, bmap,
+ bval, wval)
+ byte *inpic, *rmap, *gmap, *bmap;
+ int w,h, intype, bval, wval;
+@@ -1338,14 +1337,21 @@
+ * and 'wval' as the 'black' and 'white' pixel values, respectively
+ */
+
+- int i, j, err, w1, h1;
++ int i, j, err, w1, h1, npixels, linebufsize;
+ byte *pp, *outpic, rgb[256];
+ int *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
+
+
+- outpic = (byte *) malloc((size_t) (w * h));
++ npixels = w * h;
++ linebufsize = w * sizeof(int);
++ if (w <= 0 || h <= 0 || npixels/w != h || linebufsize/w != sizeof(int)) {
++ SetISTR(ISTR_WARNING, "Invalid image dimensions for dithering");
++ return (byte *)NULL;
++ }
++
++ outpic = (byte *) malloc((size_t) npixels);
+ if (!outpic) return outpic;
+-
++
+
+ if (intype == PIC8) { /* monoify colormap */
+ for (i=0; i<256; i++)
+@@ -1353,9 +1359,9 @@
+ }
+
+
+- thisline = (int *) malloc(w * sizeof(int));
+- nextline = (int *) malloc(w * sizeof(int));
+- if (!thisline || !nextline)
++ thisline = (int *) malloc(linebufsize);
++ nextline = (int *) malloc(linebufsize);
++ if (!thisline || !nextline)
+ FatalError("ran out of memory in FSDither()\n");
+
+
+@@ -1394,13 +1400,13 @@
+ pp = outpic + i * w;
+ thisptr = thisline; nextptr = nextline;
+
+- if (i&1 == 0) { /* go right */
++ if ((i&1) == 0) { /* go right */
+ for (j=0; j<w; j++, pp++, thisptr++, nextptr++) {
+ if (*thisptr<128) { err = *thisptr; *pp = (byte) bval; }
+ else { err = *thisptr-255; *pp = (byte) wval; }
+-
++
+ if (j<w1) thisptr[1] += ((err*7)/16);
+-
++
+ if (i<h1) {
+ nextptr[0] += ((err*5)/16);
+ if (j>0) nextptr[-1] += ((err*3)/16);
+@@ -1414,9 +1420,9 @@
+ for (j=w-1; j>=0; j--, pp--, thisptr--, nextptr--) {
+ if (*thisptr<128) { err = *thisptr; *pp = (byte) bval; }
+ else { err = *thisptr-255; *pp = (byte) wval; }
+-
++
+ if (j>0) thisptr[-1] += ((err*7)/16);
+-
++
+ if (i<h1) {
+ nextptr[0] += ((err*5)/16);
+ if (j>0) nextptr[-1] += (err/16);
+@@ -1449,8 +1455,8 @@
+ }
+
+
+- if (picType == PIC8)
+- theImage = Pic8ToXImage(epic, (u_int) eWIDE, (u_int) eHIGH,
++ if (picType == PIC8)
++ theImage = Pic8ToXImage(epic, (u_int) eWIDE, (u_int) eHIGH,
+ cols, rMap, gMap, bMap);
+ else if (picType == PIC24)
+ theImage = Pic24ToXImage(egampic, (u_int) eWIDE, (u_int) eHIGH);
+@@ -1482,7 +1488,7 @@
+
+ if (!pic8) return xim; /* shouldn't happen */
+
+- if (DEBUG > 1)
++ if (DEBUG > 1)
+ fprintf(stderr,"Pic8ToXImage(): creating a %dx%d Ximage, %d bits deep\n",
+ wide, high, dispDEEP);
+
+@@ -1491,7 +1497,7 @@
+ if (dispDEEP == 1) {
+ byte *imagedata;
+
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, XYPixmap, 0, NULL,
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, XYPixmap, 0, NULL,
+ wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -1506,11 +1512,11 @@
+
+ /* if ncols==0, do a 'black' and 'white' dither */
+ if (ncols == 0) {
+- /* note that if dispDEEP > 8, dithpic will just have '0' and '1' instead
++ /* note that if dispDEEP > 8, dithpic will just have '0' and '1' instead
+ of 'black' and 'white' */
+
+ dithpic = FSDither(pic8, PIC8, (int) wide, (int) high, rmap, gmap, bmap,
+- (int) ((dispDEEP <= 8) ? black : 0),
++ (int) ((dispDEEP <= 8) ? black : 0),
+ (int) ((dispDEEP <= 8) ? white : 1));
+ }
+
+@@ -1521,14 +1527,14 @@
+ case 8: {
+ byte *imagedata, *ip, *pp;
+ int j, imWIDE, nullCount;
+-
++
+ nullCount = (4 - (wide % 4)) & 0x03; /* # of padding bytes per line */
+ imWIDE = wide + nullCount;
+-
++
+ /* Now create the image data - pad each scanline as necessary */
+ imagedata = (byte *) malloc((size_t) (imWIDE * high));
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+-
++
+ pp = (dithpic) ? dithpic : pic8;
+
+ for (i=0, ip=imagedata; i<high; i++) {
+@@ -1543,9 +1549,9 @@
+
+ for (j=0; j<nullCount; j++, ip++) *ip = 0;
+ }
+-
++
+ xim = XCreateImage(theDisp,theVisual,dispDEEP,ZPixmap,0,
+- (char *) imagedata, wide, high,
++ (char *) imagedata, wide, high,
+ 32, imWIDE);
+ if (!xim) FatalError("couldn't create xim!");
+ }
+@@ -1554,13 +1560,13 @@
+
+
+ /*********************************/
+-
++
+ case 4: {
+ byte *imagedata, *ip, *pp;
+ byte *lip;
+ int bperline, half, j;
+
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 8, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -1569,7 +1575,7 @@
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+ xim->data = (char *) imagedata;
+
+-
++
+ pp = (dithpic) ? dithpic : pic8;
+
+ if (xim->bits_per_pixel == 4) {
+@@ -1601,20 +1607,20 @@
+ else FatalError("This display's too bizarre. Can't create XImage.");
+ }
+ break;
+-
++
+
+ /*********************************/
+-
++
+ case 2: { /* by M.Kossa@frec.bull.fr (Marc Kossa) */
+ /* MSBFirst mods added by dale@ntg.com (Dale Luck) */
+- /* additional fixes by evol@infko.uni-koblenz.de
++ /* additional fixes by evol@infko.uni-koblenz.de
+ (Randolf Werner) for NeXT 2bit grayscale with MouseX */
+
+ byte *imagedata, *ip, *pp;
+ byte *lip;
+ int bperline, half, j;
+
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 8, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -1674,11 +1680,11 @@
+ *ip = (dithpic) ? *pp : (byte) xcolors[*pp];
+ }
+ }
+-
++
+ else FatalError("This display's too bizarre. Can't create XImage.");
+ }
+ break;
+-
++
+
+ /*********************************/
+
+@@ -1686,8 +1692,8 @@
+ case 6: {
+ byte *imagedata, *ip, *pp;
+ int bperline;
+-
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 8, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -1707,17 +1713,16 @@
+ }
+ }
+ break;
+-
++
+
+ /*********************************/
+
+ case 12:
+ case 15:
+ case 16: {
+- unsigned short *imagedata, *ip;
+- byte *pp;
++ byte *imagedata, *ip, *pp;
+
+- imagedata = (unsigned short *) malloc((size_t) (2*wide*high));
++ imagedata = (byte *) malloc((size_t) (2*wide*high));
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+
+ xim = XCreateImage(theDisp,theVisual,dispDEEP,ZPixmap,0,
+@@ -1736,10 +1741,12 @@
+ if (xim->byte_order == MSBFirst) {
+ for (i=wide*high, ip=imagedata; i>0; i--,pp++) {
+ if (((i+1)&0x1ffff) == 0) WaitCursor();
+- if (dithpic) {
+- *ip++ = ((*pp) ? white : black) & 0xffff;
+- }
+- else *ip++ = xcolors[*pp] & 0xffff;
++
++ if (dithpic) xcol = ((*pp) ? white : black) & 0xffff;
++ else xcol = xcolors[*pp] & 0xffff;
++
++ *ip++ = (xcol>>8) & 0xff;
++ *ip++ = (xcol) & 0xff;
+ }
+ }
+ else { /* LSBFirst */
+@@ -1749,14 +1756,14 @@
+ if (dithpic) xcol = ((*pp) ? white : black) & 0xffff;
+ else xcol = xcolors[*pp];
+
+- /* WAS *ip++ = ((xcol>>8) & 0xff) | ((xcol&0xff) << 8); */
+- *ip++ = (unsigned short) (xcol);
++ *ip++ = (xcol) & 0xff;
++ *ip++ = (xcol>>8) & 0xff;
+ }
+ }
+ }
+ break;
+
+-
++
+ /*********************************/
+
+ case 24:
+@@ -1766,7 +1773,7 @@
+
+ imagedata = (byte *) malloc((size_t) (4*wide*high));
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+-
++
+ xim = XCreateImage(theDisp,theVisual,dispDEEP,ZPixmap,0,
+ (char *) imagedata, wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+@@ -1774,7 +1781,7 @@
+ do32 = (xim->bits_per_pixel == 32);
+
+ pp = (dithpic) ? dithpic : pic8;
+-
++
+ if (xim->byte_order == MSBFirst) {
+ for (i=0, ip=imagedata; i<high; i++) {
+ if (((i+1)&0x7f) == 0) WaitCursor();
+@@ -1809,8 +1816,8 @@
+
+
+ /*********************************/
+-
+- default:
++
++ default:
+ sprintf(str,"no code to handle this display type (%d bits deep)",
+ dispDEEP);
+ FatalError(str);
+@@ -1823,7 +1830,7 @@
+ return(xim);
+ }
+
+-static int foo = 0;
++
+
+ /***********************************/
+ XImage *Pic24ToXImage(pic24, wide, high)
+@@ -1840,8 +1847,8 @@
+ * variation of RGB the X device in question wants. No color allocation
+ * is involved.
+ *
+- * Alternately, if we're on a PseudoColor, GrayScale, StaticColor or
+- * StaticGray display, we're going to continue to operate in an 8-bit
++ * Alternately, if we're on a PseudoColor, GrayScale, StaticColor or
++ * StaticGray display, we're going to continue to operate in an 8-bit
+ * 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
+@@ -1861,7 +1868,7 @@
+ if (dispDEEP == 1) {
+ byte *imagedata;
+
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, XYPixmap, 0, NULL,
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, XYPixmap, 0, NULL,
+ wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -1929,8 +1936,8 @@
+ 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,
++ /* 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
+ */
+@@ -1945,7 +1952,7 @@
+ /* shift the bits around */
+ if (rshift<0) r = r << (-rshift);
+ else r = r >> rshift;
+-
++
+ if (gshift<0) g = g << (-gshift);
+ else g = g >> gshift;
+
+@@ -2019,17 +2026,17 @@
+ bwdith = 0;
+
+ if (ncols == 0 && dispDEEP != 1) { /* do 'black' and 'white' dither */
+- /* note that if dispDEEP > 8, pic8 will just have '0' and '1' instead
++ /* note that if dispDEEP > 8, pic8 will just have '0' and '1' instead
+ of 'black' and 'white' */
+
+- pic8 = FSDither(pic24, PIC24, (int) wide, (int) high, NULL, NULL, NULL,
+- (int) ((dispDEEP <= 8) ? black : 0),
++ pic8 = FSDither(pic24, PIC24, (int) wide, (int) high, NULL, NULL, NULL,
++ (int) ((dispDEEP <= 8) ? black : 0),
+ (int) ((dispDEEP <= 8) ? white : 1));
+ bwdith = 1;
+ }
+
+ else { /* do color dither using stdcmap */
+- pic8 = Do332ColorDither(pic24, NULL, (int) wide, (int) high,
++ pic8 = Do332ColorDither(pic24, NULL, (int) wide, (int) high,
+ NULL, NULL, NULL,
+ stdrdisp, stdgdisp, stdbdisp, 256);
+ }
+@@ -2046,14 +2053,14 @@
+ case 8: {
+ byte *imagedata, *ip, *pp;
+ int j, imWIDE, nullCount;
+-
++
+ nullCount = (4 - (wide % 4)) & 0x03; /* # of padding bytes per line */
+ imWIDE = wide + nullCount;
+-
++
+ /* Now create the image data - pad each scanline as necessary */
+ imagedata = (byte *) malloc((size_t) (imWIDE * high));
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+-
++
+ for (i=0, pp=pic8, ip=imagedata; i<high; i++) {
+ if (((i+1)&0x7f) == 0) WaitCursor();
+
+@@ -2066,7 +2073,7 @@
+ }
+
+ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0,
+- (char *) imagedata, wide, high,
++ (char *) imagedata, wide, high,
+ 32, imWIDE);
+ if (!xim) FatalError("couldn't create xim!");
+ }
+@@ -2074,14 +2081,14 @@
+
+
+ /*********************************/
+-
++
+ case 4: {
+ byte *imagedata, *ip, *pp;
+ byte *lip;
+ int bperline, half, j;
+ unsigned long xcol;
+-
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -2123,14 +2130,14 @@
+ else FatalError("This display's too bizarre. Can't create XImage.");
+ }
+ break;
+-
++
+
+
+ /*********************************/
+-
++
+ case 2: { /* by M.Kossa@frec.bull.fr (Marc Kossa) */
+ /* MSBFirst mods added by dale@ntg.com (Dale Luck) */
+- /* additional fixes by evol@infko.uni-koblenz.de
++ /* additional fixes by evol@infko.uni-koblenz.de
+ (Randolf Werner) for NeXT 2bit grayscale with MouseX */
+
+ byte *imagedata, *ip, *pp;
+@@ -2138,7 +2145,7 @@
+ int bperline, half, j;
+ unsigned long xcol;
+
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+
+@@ -2201,22 +2208,22 @@
+ }
+ }
+ }
+-
++
+ else FatalError("This display's too bizarre. Can't create XImage.");
+ }
+ break;
+-
++
+
+ /*********************************/
+-
++
+ case 6: {
+ byte *imagedata, *lip, *ip, *pp;
+ int bperline;
+-
+- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
++
++ xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
+ wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+-
++
+ if (xim->bits_per_pixel != 8)
+ FatalError("This display's too bizarre. Can't create XImage.");
+
+@@ -2238,7 +2245,7 @@
+ }
+ break;
+
+-
++
+ /*********************************/
+
+ case 15:
+@@ -2282,7 +2289,7 @@
+ }
+ break;
+
+-
++
+ /*********************************/
+
+ /* this wouldn't seem likely to happen, but what the heck... */
+@@ -2295,7 +2302,7 @@
+
+ imagedata = (byte *) malloc((size_t) (4*wide*high));
+ if (!imagedata) FatalError("couldn't malloc imagedata");
+-
++
+ xim = XCreateImage(theDisp,theVisual,dispDEEP,ZPixmap,0,
+ (char *) imagedata, wide, high, 32, 0);
+ if (!xim) FatalError("couldn't create xim!");
+@@ -2303,7 +2310,7 @@
+ bperpix = xim->bits_per_pixel;
+
+ pp = pic8;
+-
++
+ if (xim->byte_order == MSBFirst) {
+ for (i=wide*high, ip=imagedata; i>0; i--,pp++) {
+ if (((i+1)&0x1ffff) == 0) WaitCursor();
+@@ -2327,7 +2334,7 @@
+ if (bperpix == 32) *ip++ = 0;
+ }
+ }
+- }
++ }
+ break;
+
+ } /* end of the switch */
+@@ -2346,7 +2353,7 @@
+ int mode;
+ {
+ /* move checkmark */
+- conv24MB.flags[CONV24_8BIT] = (mode==PIC8);
++ conv24MB.flags[CONV24_8BIT] = (mode==PIC8);
+ conv24MB.flags[CONV24_24BIT] = (mode==PIC24);
+
+ if (mode == PIC24) {
+@@ -2383,15 +2390,13 @@
+ void Change824Mode(mode)
+ int mode;
+ {
+- static int oldcmapmode = -1;
+-
+ if (mode == picType) return; /* same mode, do nothing */
+
+ Set824Menus(mode);
+
+ if (!pic) { /* done all we wanna do when there's no pic */
+ picType = mode;
+- return;
++ return;
+ }
+
+ /* should probably actually *do* something involving colors, regenrating
+@@ -2474,7 +2479,7 @@
+ int ptype, w,h, sx,sy,sw,sh;
+ {
+ /* mallocs and returns the selected subimage (sx,sy,sw,sh) of pic.
+- selection is guaranteed to be within pic boundaries.
++ selection is guaranteed to be within pic boundaries.
+ NEVER RETURNS NULL */
+
+ byte *rpic, *sp, *dp;
+@@ -2520,7 +2525,6 @@
+ installs the new pic and all that... Returns '0' on failure */
+
+ int rv;
+- char loadName[256];
+
+ if (padPic) free(padPic);
+ if (holdcomment) free(holdcomment);
+@@ -2530,8 +2534,8 @@
+
+ rv = 1;
+
+- if ((mode != PAD_LOAD) && (wide == pWIDE && high == pHIGH && opaque==100)) {
+- ErrPopUp("Padding to same size as pic while fully opaque has no effect.",
++ if ((mode != PAD_LOAD) && (wide == cWIDE && high == cHIGH && opaque==100)) {
++ ErrPopUp("Padding to same size as pic while fully opaque has no effect.",
+ "\nI see");
+ return 0;
+ }
+@@ -2539,8 +2543,8 @@
+ WaitCursor();
+
+ if (mode == PAD_SOLID) rv = doPadSolid(str, wide, high, opaque,omode);
+- else if (mode == PAD_BGGEN) rv = doPadBggen(str, wide, high, opaque,omode);
+- else if (mode == PAD_LOAD) rv = doPadLoad (str, wide, high, opaque,omode);
++ else if (mode == PAD_BGGEN) rv = doPadBggen(str, wide, high, opaque,omode);
++ else if (mode == PAD_LOAD) rv = doPadLoad (str, wide, high, opaque,omode);
+
+ SetCursors(-1);
+
+@@ -2556,7 +2560,7 @@
+
+ return 1;
+ }
+-
++
+
+ /***********************************/
+ int LoadPad(pinfo, fname)
+@@ -2645,7 +2649,7 @@
+ return 0;
+ }
+ }
+-
++
+
+
+ pic24 = (byte *) malloc(wide * high * 3 * sizeof(byte));
+@@ -2656,7 +2660,7 @@
+ return 0;
+ }
+
+-
++
+ /* fill pic24 with solidRGB */
+ for (i=0,pp=pic24; i<wide*high; i++, pp+=3) {
+ pp[0] = (solidRGB>>16) & 0xff;
+@@ -2697,7 +2701,11 @@
+ #else
+ strcpy(fname, "Sys$Disk:[]xvuXXXXXX");
+ #endif
++#ifdef USE_MKSTEMP
++ close(mkstemp(fname));
++#else
+ mktemp(fname);
++#endif
+
+ /* run bggen to generate the background */
+ sprintf(syscmd, "bggen -g %dx%d %s > %s", wide, high, str, fname);
+@@ -2713,7 +2721,7 @@
+ ErrPopUp(errstr, "\nDoh!");
+ return 0;
+ }
+-
++
+
+ /* read the file that's been created */
+ if (!ReadImageFile1(fname, &pinfo)) {
+@@ -2791,7 +2799,7 @@
+ int wide, high, opaque,omode;
+ {
+ /* copies 'pic' onto the given 24-bit background image, converts back to
+- 8-bit (if necessary), and loads up pad* variables.
++ 8-bit (if necessary), and loads up pad* variables.
+ frees pic24 if necessary */
+
+ byte *pp, *p24;
+@@ -2806,30 +2814,30 @@
+
+ /* copy 'pic' centered onto pic24. */
+
+- sx = (wide - pWIDE) / 2;
+- sy = (high - pHIGH) / 2;
+-
+- for (py = 0; py<pHIGH; py++) {
+- ProgressMeter(0, pHIGH-1, py, "Pad");
++ sx = (wide - cWIDE) / 2;
++ sy = (high - cHIGH) / 2;
++
++ for (py = 0; py<cHIGH; py++) {
++ ProgressMeter(0, cHIGH-1, py, "Pad");
+ if ((py & 0x1f)==0) WaitCursor();
+
+ p24y = sy + py;
+ if (p24y >= 0 && p24y < high) {
+- for (px=0; px<pWIDE; px++) {
++ for (px=0; px<cWIDE; px++) {
+ p24x = sx + px;
+ if (p24x >= 0 && p24x < wide) {
+ p24 = pic24 + (p24y*wide + p24x)*3;
+-
+-
++
++
+ if (picType == PIC24) { /* src is PIC24 */
+- pp = pic + (py * pWIDE + px) *3;
++ pp = cpic + (py * cWIDE + px) *3;
+ r = pp[0]; g = pp[1]; b = pp[2];
+ }
+ else { /* src is PIC8 */
+- pp = pic + (py*pWIDE + px);
++ pp = cpic + (py*cWIDE + px);
+ r = rMap[*pp]; g = gMap[*pp]; b = bMap[*pp];
+ }
+-
++
+ if (omode == PAD_ORGB) {
+ rval = (r * fg) / 100 + ((int) p24[0] * bg) / 100;
+ gval = (g * fg) / 100 + ((int) p24[1] * bg) / 100;
+@@ -2845,7 +2853,7 @@
+
+ if (omode == PAD_OINT) {
+ h = fh;
+- s = fs;
++ s = fs;
+ /* v = (fv * fg) / 100.0 + (bv * bg) / 100.0; */
+ v = (fv * bv * bw) + (fv * fw);
+ }
+@@ -2855,18 +2863,18 @@
+ h = fh;
+ /* s = (fs * fg) / 100.0 + (bs * bg) / 100.0; */
+ s = (fs * bs * bw) + (fs * fw);
+- v = fv;
++ v = fv;
+ }
+ else if (omode == PAD_OHUE) { /* the hard one! */
+- int fdeg,bdeg,len1,len2;
+-
++ int fdeg,bdeg;
++
+ fdeg = (fh<0) ? -1 : (int) floor(fh + 0.5);
+ bdeg = (bh<0) ? -1 : (int) floor(bh + 0.5);
+
+ if (fdeg>=0 && bdeg>=0) { /* both are colors */
+ /* convert H,S onto x,y coordinates on the colorwheel for
+ constant V */
+-
++
+ double fx,fy, bx,by, ox,oy;
+
+ if (fg == 100 || bg == 100) { /* E-Z special case */
+@@ -2874,17 +2882,17 @@
+ else { h = bh; s = fs; v=fv; }
+ }
+ else { /* general case */
+-
++
+ fh *= (3.14159 / 180.0); /* -> radians */
+ bh *= (3.14159 / 180.0);
+-
++
+ fx = fs * cos(fh); fy = fs * sin(fh);
+ bx = bs * cos(bh); by = bs * sin(bh);
+-
++
+ /* compute pt. on line between fx,fy and bx,by */
+ ox = (fx * (fg/100.0)) + (bx * (bg/100.0));
+ oy = (fy * (fg/100.0)) + (by * (bg/100.0));
+-
++
+ /* convert ox,oy back into hue,sat */
+ s = sqrt((ox * ox) + (oy * oy));
+ if (ox == 0.0) {
+@@ -2897,7 +2905,7 @@
+ while (h<0.0) h += 360.0;
+ while (h>=360.0) h -= 360.0;
+ }
+-
++
+ v = fv;
+ }
+ }
+@@ -2924,7 +2932,7 @@
+ v = (fv * bv * bw) + (fv * fw);
+ hsv2rgb(h,s,v, &rval,&gval,&bval);
+ }
+-
++
+ RANGE(rval, 0, 255); RANGE(gval, 0, 255); RANGE(bval, 0, 255);
+ *p24++ = rval; *p24++ = gval; *p24++ = bval;
+ }
+@@ -2958,12 +2966,15 @@
+
+
+ /*******************************/
+-static int ReadImageFile1(name, pinfo)
++static int ReadImageFile1(name, pinfo)
+ char *name;
+ PICINFO *pinfo;
+ {
+ int i, ftype;
+- char basefname[128], uncompname[128], errstr[256], *uncName, *readname;
++ char uncompname[128], errstr[256], *uncName, *readname;
++#ifdef VMS
++ char basefname[128];
++#endif
+
+ ftype = ReadFileType(name);
+
+@@ -2976,7 +2987,7 @@
+ #else
+ uncName = name;
+ #endif
+-
++
+ if (UncompressFile(uncName, uncompname)) {
+ ftype = ReadFileType(uncompname);
+ readname = uncompname;
+@@ -3004,7 +3015,7 @@
+ KillPageFiles(pinfo->pagebname, pinfo->numpages);
+
+ if (!i || (i && (pinfo->w<=0 || pinfo->h<=0))) {
+- if (i) {
++ if (i) {
+ if (pinfo->pic) free(pinfo->pic);
+ if (pinfo->comment) free(pinfo->comment);
+ }
+@@ -3021,6 +3032,6 @@
+
+
+
+-
++
+
+
+diff -ruN xv-3.10a/xvinfo.c xv-3.10a-bugfixes/xvinfo.c
+--- xv-3.10a/xvinfo.c 1994-12-22 14:34:41.000000000 -0800
++++ xv-3.10a-bugfixes/xvinfo.c 2004-05-16 18:03:43.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvinfo.c - 'Info' box handling functions
+ *
+ * callable functions:
+@@ -8,7 +8,7 @@
+ * maps/unmaps window, etc.
+ * RedrawInfo(x,y,w,h) - called by 'expose' events
+ * SetInfoMode(mode) - changes amount of info Info window shows
+- * SetISTR(st, fmt, args) - sprintf's into ISTR #st. Redraws it in window
++ * SetISTR(st, fmt, args) - sprintf's into ISTR #st. Redraws it in window
+ * char *GetISTR(st) - returns pointer to ISTR #st, or NULL if st bogus
+ */
+
+@@ -45,18 +45,18 @@
+ void CreateInfo(geom)
+ char *geom;
+ {
+- infoW = CreateWindow("xv info", "XVinfo", geom, INFOWIDE, INFOHIGH,
++ infoW = CreateWindow("xv info", "XVinfo", geom, INFOWIDE, INFOHIGH,
+ infofg, infobg, 0);
+ if (!infoW) FatalError("can't create info window!");
+-
+- pennPix = XCreatePixmapFromBitmapData(theDisp, infoW,
++
++ pennPix = XCreatePixmapFromBitmapData(theDisp, infoW,
+ (char *) penn_bits, penn_width, penn_height, infofg, infobg, dispDEEP);
+
+ pnetPix = XCreatePixmapFromBitmapData(theDisp,infoW,
+- (char *) pennnet_bits, pennnet_width, pennnet_height,
++ (char *) pennnet_bits, pennnet_width, pennnet_height,
+ infofg, infobg, dispDEEP);
+ }
+-
++
+
+ /***************************************************/
+ void InfoBox(vis)
+@@ -64,7 +64,7 @@
+ {
+ if (vis) XMapRaised(theDisp, infoW);
+ else XUnmapWindow(theDisp, infoW);
+-
++
+ infoUp = vis;
+ }
+
+@@ -74,15 +74,15 @@
+ int x,y,w,h;
+ {
+ int i;
+-
++
+ XSetForeground(theDisp, theGC, infofg);
+ XSetBackground(theDisp, theGC, infobg);
+
+ /* draw the two icons */
+ XCopyArea(theDisp, pennPix, infoW, theGC, 0, 0, penn_width, penn_height,
+ 36 - penn_width/2, 36 - penn_height/2);
+- XCopyArea(theDisp, pnetPix, infoW, theGC, 0, 0, pennnet_width,
+- pennnet_height, INFOWIDE - 36 - pennnet_width/2,
++ XCopyArea(theDisp, pnetPix, infoW, theGC, 0, 0, pennnet_width,
++ pennnet_height, INFOWIDE - 36 - pennnet_width/2,
+ 36 - pennnet_height/2);
+
+ /* draw the credits */
+@@ -90,7 +90,7 @@
+ CenterString(infoW, INFOWIDE/2, 36-LINEHIGH, str);
+ CenterString(infoW, INFOWIDE/2, 36,
+ "by John Bradley (bradley@dccs.upenn.edu)");
+- CenterString(infoW, INFOWIDE/2, 36+LINEHIGH,
++ CenterString(infoW, INFOWIDE/2, 36+LINEHIGH,
+ "Copyright 1994, John Bradley - All Rights Reserved");
+
+
+@@ -139,8 +139,8 @@
+
+ if (infoMode == INF_NONE || infoMode == INF_STR) return;
+ if (infoMode == INF_PART && fnum>=3) return;
+-
+- XDrawString(theDisp, infoW, theGC, 10, TOPBASE + fnum*LINEHIGH,
++
++ XDrawString(theDisp, infoW, theGC, 10, TOPBASE + fnum*LINEHIGH,
+ fname[fnum], (int) strlen(fname[fnum]));
+ }
+
+@@ -150,7 +150,7 @@
+ int st;
+ {
+ /* erase area of string, and draw it with new contents */
+-
++
+ if (infoMode == INF_NONE) return;
+ if (infoMode == INF_STR && st > ISTR_WARNING) return;
+ if (infoMode == INF_PART && st > ISTR_RES) return;
+@@ -170,12 +170,12 @@
+ }
+ else {
+ XSetForeground(theDisp, theGC, infobg);
+- XFillRectangle(theDisp, infoW, theGC,
+- STLEFT, TOPBASE - ASCENT + (st-ISTR_FILENAME)*LINEHIGH,
++ XFillRectangle(theDisp, infoW, theGC,
++ STLEFT, TOPBASE - ASCENT + (st-ISTR_FILENAME)*LINEHIGH,
+ (u_int) INFOWIDE-STLEFT, (u_int) LINEHIGH);
+ XSetForeground(theDisp, theGC, infofg);
+ XDrawString(theDisp, infoW, theGC, STLEFT,
+- TOPBASE + (st-ISTR_FILENAME)*LINEHIGH, istrs[st],
++ TOPBASE + (st-ISTR_FILENAME)*LINEHIGH, istrs[st],
+ (int) strlen(istrs[st]));
+ }
+ }
+@@ -187,21 +187,21 @@
+ int mode;
+ {
+ int y1, y2;
+-
++
+ infoMode = mode;
+ if (infoUp) { /* only do this if window is mapped */
+ y1 = TOPBASE - ASCENT;
+ y2 = INFOHIGH-43;
+-
++
+ XSetForeground(theDisp, theGC, infobg);
+-
+- XFillRectangle(theDisp,infoW,theGC,0,y1,
++
++ XFillRectangle(theDisp,infoW,theGC,0,y1,
+ (u_int) INFOWIDE, (u_int) y2-y1);
+- XFillRectangle(theDisp,infoW,theGC,0,INFOHIGH-39,
++ XFillRectangle(theDisp,infoW,theGC,0,INFOHIGH-39,
+ (u_int) INFOWIDE, (u_int) 17);
+- XFillRectangle(theDisp,infoW,theGC,0,INFOHIGH-19,
++ XFillRectangle(theDisp,infoW,theGC,0,INFOHIGH-19,
+ (u_int) INFOWIDE, (u_int) 17);
+-
++
+ drawStrings();
+ }
+ }
+@@ -237,9 +237,9 @@
+ else istrs[stnum][0] = '\0';
+ }
+ va_end(args);
+-
++
+ if (stnum == ISTR_COLOR) {
+- sprintf(istrs[ISTR_INFO], "%s %s %s", formatStr,
++ sprintf(istrs[ISTR_INFO], "%s %s %s", formatStr,
+ (picType==PIC8) ? "8-bit mode." : "24-bit mode.",
+ istrs[ISTR_COLOR]);
+ }
+@@ -250,19 +250,19 @@
+ XFlush(theDisp);
+ }
+
+- if (ctrlUp && (stnum == ISTR_INFO || stnum == ISTR_WARNING ||
++ if (ctrlUp && (stnum == ISTR_INFO || stnum == ISTR_WARNING ||
+ stnum == ISTR_COLOR)) {
+ DrawCtrlStr();
+ XFlush(theDisp);
+ }
+
+- if (anyBrowUp && (stnum == ISTR_WARNING || stnum == ISTR_INFO)
++ if (anyBrowUp && (stnum == ISTR_WARNING || stnum == ISTR_INFO)
+ && strlen(istrs[stnum])) {
+ SetBrowStr(istrs[stnum]);
+ XFlush(theDisp);
+ }
+
+- if (stnum == ISTR_WARNING && !ctrlUp && !infoUp && !anyBrowUp &&
++ if (stnum == ISTR_WARNING && !ctrlUp && !infoUp && !anyBrowUp &&
+ strlen(istrs[stnum])) {
+ OpenAlert(istrs[stnum]);
+ sleep(3);
+diff -ruN xv-3.10a/xviris.c xv-3.10a-bugfixes/xviris.c
+--- xv-3.10a/xviris.c 1994-12-22 14:34:47.000000000 -0800
++++ xv-3.10a-bugfixes/xviris.c 2005-04-03 12:08:03.000000000 -0700
+@@ -14,7 +14,7 @@
+ *
+ * This code should work on machines with any byte order.
+ *
+- * Could someone make this run real fast using multiple processors
++ * Could someone make this run real fast using multiple processors
+ * or how about using memory mapped files to speed it up?
+ *
+ * Paul Haeberli - 1991
+@@ -44,7 +44,7 @@
+ u_short zsize;
+ u_long min;
+ u_long max;
+- u_long wastebytes;
++ u_long wastebytes;
+ char name[80];
+ u_long colormap;
+
+@@ -112,7 +112,8 @@
+ IMAGE img;
+ byte *rawdata, *rptr;
+ byte *pic824, *bptr;
+- int trunc, i, j;
++ int trunc, i, npixels, bufsize;
++ u_short ii, jj;
+ long filesize;
+
+ trunc = 0;
+@@ -133,11 +134,11 @@
+ img.imagic = getshort(fp);
+ img.type = getshort(fp);
+ img.dim = getshort(fp);
+- img.xsize = getshort(fp);
++ img.xsize = getshort(fp); /* u_short */
+ img.ysize = getshort(fp);
+ img.zsize = getshort(fp);
+
+- if (FERROR(fp)) {
++ if (FERROR(fp) || img.xsize == 0 || img.ysize == 0 || img.zsize == 0) {
+ fclose(fp);
+ return irisError(bname, "error in header info");
+ }
+@@ -148,7 +149,7 @@
+ }
+
+ rawdata = getimagedata(fp, &img);
+- if (!rawdata) {
++ if (!rawdata) {
+ fclose(fp);
+ if (loaderr) irisError(bname, loaderr);
+ return 0;
+@@ -162,18 +163,22 @@
+ /* got the raw image data. Convert to an XV image (1,3 bytes / pix) */
+
+
++ npixels = img.xsize * img.ysize; /* 65535*65535 = (2^32 - 131071) max */
++ if (npixels/img.xsize != img.ysize)
++ return irisError(bname, "IRIS image dimensions out of range");
++
+ if (img.zsize < 3) { /* grayscale */
+- pic824 = (byte *) malloc((size_t) img.xsize * img.ysize);
++ pic824 = (byte *) malloc((size_t) npixels);
+ if (!pic824) FatalError("couldn't malloc pic824 in LoadIRIS()");
+
+ /* copy plane 3 from rawdata into pic824, inverting pic vertically */
+- for (i=0, bptr=pic824; i<(int) img.ysize; i++) {
+- rptr = rawdata + 3 + ((img.ysize - 1) - i) * (img.xsize * 4);
+- for (j=0; j<(int) img.xsize; j++, bptr++, rptr+=4) *bptr = *rptr;
++ for (ii=0, bptr=pic824; ii<img.ysize; ii++) {
++ rptr = rawdata + 3 + ((img.ysize - 1) - ii) * (img.xsize * 4);
++ for (jj=0; jj<img.xsize; jj++, bptr++, rptr+=4) *bptr = *rptr;
+ }
+
+
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+
+ pinfo->pic = pic824;
+@@ -188,13 +193,17 @@
+ }
+
+ else { /* truecolor */
+- pic824 = (byte *) malloc((size_t) img.xsize * img.ysize * 3);
++ bufsize = 3 * npixels;
++ if (npixels/img.xsize != img.ysize || bufsize/3 != npixels) {
++ return irisError(bname, "IRIS image dimensions out of range");
++ }
++ pic824 = (byte *) malloc((size_t) bufsize);
+ if (!pic824) FatalError("couldn't malloc pic824 in LoadIRIS()");
+-
++
+ /* copy plane 3 from rawdata into pic824, inverting pic vertically */
+- for (i=0, bptr=pic824; i<(int) img.ysize; i++) {
+- rptr = rawdata + ((img.ysize - 1) - i) * (img.xsize * 4);
+- for (j=0; j<(int) img.xsize; j++, rptr+=4) {
++ for (ii=0, bptr=pic824; ii<img.ysize; ii++) {
++ rptr = rawdata + ((img.ysize - 1) - ii) * (img.xsize * 4);
++ for (jj=0; jj<img.xsize; jj++, rptr+=4) {
+ *bptr++ = rptr[3];
+ *bptr++ = rptr[2];
+ *bptr++ = rptr[1];
+@@ -220,7 +229,7 @@
+ pinfo->comment = (char *) NULL;
+
+ return 1;
+-}
++}
+
+
+ /*******************************************/
+@@ -237,15 +246,15 @@
+ FILE *fp;
+ IMAGE *img;
+ {
+- /* read in a B/W RGB or RGBA iris image file and return a
++ /* read in a B/W RGB or RGBA iris image file and return a
+ pointer to an array of 4-byte pixels, arranged ABGR, NULL on error */
+
+ byte *base, *lptr;
+ byte *verdat;
+- int y, z, pos, len, tablen;
++ int y, z, tablen;
+ int xsize, ysize, zsize;
+ int bpp, rle, cur, badorder;
+- int rlebuflen;
++ int rlebuflen, npixels, bufsize;
+
+
+ rle = ISRLE(img->type);
+@@ -257,21 +266,33 @@
+ return (byte *) NULL;
+ }
+
+- xsize = img->xsize;
++ xsize = img->xsize; /* all three are > 0 (checked by caller), <= 65535 */
+ ysize = img->ysize;
+ zsize = img->zsize;
++ npixels = xsize * ysize; /* 65535*65535 = (2^32 - 131071) max */
++ if (npixels/xsize != ysize) {
++ loaderr = "IRIS image dimensions out of range";
++ return (byte *) NULL;
++ }
+
+ if (rle) {
+ byte *rledat;
+ u_long *starttab, *lengthtab;
+
+- rlebuflen = 2 * xsize + 10;
++ rlebuflen = 2 * xsize + 10; /* 10 <= rlebuflen <= 131080 */
+ tablen = ysize * zsize;
+- starttab = (u_long *) malloc((size_t) tablen * sizeof(long));
+- lengthtab = (u_long *) malloc((size_t) tablen * sizeof(long));
++ bufsize = tablen * sizeof(long);
++
++ if (tablen/ysize != zsize || bufsize/tablen != sizeof(long)) {
++ loaderr = "IRIS image dimensions out of range";
++ return (byte *)NULL;
++ }
++
++ starttab = (u_long *) malloc((size_t) bufsize);
++ lengthtab = (u_long *) malloc((size_t) bufsize);
+ rledat = (byte *) malloc((size_t) rlebuflen);
+
+- if (!starttab || !lengthtab || !rledat)
++ if (!starttab || !lengthtab || !rledat)
+ FatalError("out of memory in LoadIRIS()");
+
+ fseek(fp, 512L, 0);
+@@ -298,7 +319,13 @@
+ fseek(fp, (long) (512 + 2*tablen*4), 0);
+ cur = 512 + 2*tablen*4;
+
+- base = (byte *) malloc((size_t) (xsize*ysize+TAGLEN) * 4);
++ bufsize = 4 * (npixels+TAGLEN);
++ if (bufsize/4 != (npixels+TAGLEN)) {
++ loaderr = "Bogus IRIS File!";
++ free(starttab); free(lengthtab); free(rledat);
++ return (byte *)NULL;
++ }
++ base = (byte *) malloc((size_t) bufsize);
+ if (!base) FatalError("out of memory in LoadIRIS()");
+
+ addimgtag(base,xsize,ysize);
+@@ -349,12 +376,17 @@
+ } /* end of RLE case */
+
+ else { /* not RLE */
++ bufsize = 4 * (npixels+TAGLEN);
++ if (bufsize/4 != (npixels+TAGLEN)) {
++ loaderr = "Bogus IRIS File!";
++ return (byte *)NULL;
++ }
++ base = (byte *) malloc((size_t) bufsize);
+ verdat = (byte *) malloc((size_t) xsize);
+- base = (byte *) malloc((size_t) (xsize*ysize+TAGLEN) * 4);
+ if (!base || !verdat) FatalError("out of memory in LoadIRIS()");
+
+ addimgtag(base,xsize,ysize);
+-
++
+ fseek(fp,512L,0);
+
+ for (z=0; z<zsize; z++) {
+@@ -457,7 +489,7 @@
+ byte *dptr;
+ int xsize, ysize;
+ {
+- /* this is used to extract image data from core dumps.
++ /* this is used to extract image data from core dumps.
+ I doubt this is necessary... --jhb */
+
+ dptr = dptr + (xsize * ysize * 4);
+@@ -499,26 +531,31 @@
+ int ptype, w, h, numcols, colorstyle;
+ {
+ /* writes a greyscale or 24-bit RGB IRIS file to the already open
+- stream, rle compressed */
++ stream, RLE-compressed; returns 0 on success, -1 on minor error */
+
+ IMAGE img;
+- int i, j, pos, len, tablen, rlebuflen, zsize;
++ int i, j, pos, len, tablen, rlebuflen, zsize, npixels, bufsize;
+ u_long *starttab, *lengthtab;
+ byte *rlebuf, *pptr;
+ byte *lumbuf, *lptr, *longpic;
+
+ xvbzero((char *) &img, sizeof(IMAGE));
+-
++
+ /* write header information */
+ fwrite(&img, sizeof(IMAGE), (size_t) 1, fp);
+ fseek(fp, 0L, 0);
+
++ if (w <= 0 || h <= 0 || w > 65535 || h > 65535) {
++ SetISTR(ISTR_WARNING, "image dimensions too large for IRIS format");
++ return -1;
++ }
++
+ /* load up header */
+ img.imagic = IMAGIC;
+ img.type = ITYPE_RLE | (1 & BPPMASK); /* RLE, 1 byteperpix */
+ img.dim = (colorstyle == F_FULLCOLOR) ? 3 : 2;
+- img.xsize = w;
+- img.ysize = h;
++ img.xsize = (u_short)w;
++ img.ysize = (u_short)h;
+ img.zsize = zsize = (colorstyle == F_FULLCOLOR) ? 3 : 1;
+ img.min = 0;
+ img.max = 255;
+@@ -537,22 +574,33 @@
+ if (ferror(fp)) { fclose(fp); return -1; }
+
+ /* allocate RLE compression tables & stuff */
+- rlebuflen = 2*w + 10;
+- tablen = h * zsize;
++ rlebuflen = 2*w + 10; /* 10 <= rlebuflen <= 131080 */
++ tablen = h * zsize; /* 1 <= tablen <= 196605 */
+
++ /* no overflow is possible with any of these (given check on w,h above): */
+ starttab = (u_long *) malloc((size_t) tablen * sizeof(long));
+ lengthtab = (u_long *) malloc((size_t) tablen * sizeof(long));
+ rlebuf = (byte *) malloc((size_t) rlebuflen);
+- lumbuf = (byte *) malloc((size_t) w * 4);
++ lumbuf = (byte *) malloc((size_t) w * 4); /* 262140 max */
+
+- if (!starttab || !lengthtab || !rlebuf || !lumbuf)
++ if (!starttab || !lengthtab || !rlebuf || !lumbuf)
+ FatalError("out of memory in WriteIRIS()");
+
+ pos = 512 + 2 * (tablen * 4);
+ fseek(fp, (long) pos, 0);
+
+ /* convert image into 4-byte per pix image that the compress routines want */
+- longpic = (byte *) malloc((size_t) w * h * 4);
++ npixels = w * h;
++ bufsize = 4 * npixels;
++ if (npixels/w != h || bufsize/4 != npixels) {
++ SetISTR(ISTR_WARNING, "can't malloc longpic in WriteIRIS()");
++ free(starttab);
++ free(lengthtab);
++ free(rlebuf);
++ free(lumbuf);
++ return -1;
++ }
++ longpic = (byte *) malloc((size_t) bufsize);
+ if (!longpic) FatalError("couldn't malloc longpic in WriteIRIS()");
+
+ for (i=0, pptr=pic; i<h; i++) {
+@@ -574,7 +622,7 @@
+ }
+ }
+ }
+-
++
+
+
+ /* compress and write the data */
+@@ -584,12 +632,13 @@
+ if (zsize == 1) {
+ lumrow(lptr, lumbuf, w);
+ len = compressrow(lumbuf, rlebuf, CHANOFFSET(j), w);
+- }
++ }
+ else {
+ len = compressrow(lptr, rlebuf, CHANOFFSET(j), w);
+ }
+
+ if (len > rlebuflen) {
++ /* this condition shouldn't kill XV, just abort writing the image */
+ FatalError("WriteIRIS: rlebuf is too small");
+ exit(1);
+ }
+@@ -618,10 +667,10 @@
+
+ return 0;
+ }
+-
++
+
+ /*************************************/
+-static void lumrow(rgbptr, lumptr, n)
++static void lumrow(rgbptr, lumptr, n)
+ byte *rgbptr, *lumptr;
+ int n;
+ {
+@@ -640,7 +689,7 @@
+ int z, cnt;
+ {
+ byte *iptr, *ibufend, *sptr, *optr;
+- short todo, cc;
++ short todo, cc;
+ long count;
+
+ lbuf += z;
+@@ -685,7 +734,7 @@
+ cc = *iptr;
+ iptr += 4;
+ while ((iptr<ibufend) && (*iptr == cc)) iptr += 4;
+-
++
+ count = (iptr-sptr)/4;
+ while (count) {
+ todo = count>126 ? 126:count;
+@@ -694,7 +743,7 @@
+ *optr++ = cc;
+ }
+ }
+-
++
+ *optr++ = 0;
+ return (optr - rlebuf);
+ }
+diff -ruN xv-3.10a/xvjpeg.c xv-3.10a-bugfixes/xvjpeg.c
+--- xv-3.10a/xvjpeg.c 1995-01-05 00:17:13.000000000 -0800
++++ xv-3.10a-bugfixes/xvjpeg.c 2005-03-27 16:23:06.000000000 -0800
+@@ -35,7 +35,7 @@
+ This is currently hardcoded to be twice the size of a schnauzer icon, as
+ the schnauzer's the only thing that does a quick load... */
+
+-#define QUICKWIDE 160
++#define QUICKWIDE 160
+ #define QUICKHIGH 120
+
+ struct my_error_mgr {
+@@ -80,28 +80,26 @@
+ /***************************************************/
+ void CreateJPEGW()
+ {
+- XClassHint classh;
+-
+ jpegW = CreateWindow("xv jpeg","XVjpeg",NULL,JWIDE,JHIGH,infofg,infobg,0);
+ if (!jpegW) FatalError("can't create jpeg window!");
+-
++
+ 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, 100, 75, 5,
+ infofg, infobg, hicol, locol, "Quality", "%");
+-
+- DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5,
++
++ DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5,
+ infofg, infobg, hicol, locol, "Smoothing", "%");
+-
+- BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH,
++
++ BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH,
+ "Ok", infofg, infobg, hicol, locol);
+-
+- BTCreate(&jbut[J_BCANC], jpegW, JWIDE-90-1, JHIGH-10-BUTTH-1, 80, BUTTH,
++
++ BTCreate(&jbut[J_BCANC], jpegW, JWIDE-90-1, JHIGH-10-BUTTH-1, 80, BUTTH,
+ "Cancel", infofg, infobg, hicol, locol);
+-
++
+ XMapSubwindows(theDisp, jpegW);
+ }
+-
++
+
+ /***************************************************/
+ void JPEGDialog(vis)
+@@ -122,32 +120,32 @@
+ {
+ /* check event to see if it's for one of our subwindows. If it is,
+ deal accordingly, and return '1'. Otherwise, return '0' */
+-
++
+ int rv;
+ rv = 1;
+-
++
+ if (!jpegUp) return 0;
+-
++
+ 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 expose events for 'dumb' windows */
+- if (e->count > 0 && (e->window == qDial.win ||
++ if (e->count > 0 && (e->window == qDial.win ||
+ e->window == smDial.win)) {}
+-
++
+ else if (e->window == jpegW) drawJD(x, y, w, h);
+ else if (e->window == qDial.win) DRedraw(&qDial);
+ else if (e->window == smDial.win) DRedraw(&smDial);
+ else rv = 0;
+ }
+-
++
+ else if (xev->type == ButtonPress) {
+ XButtonEvent *e = (XButtonEvent *) xev;
+ int x,y;
+ x = e->x; y = e->y;
+-
++
+ if (e->button == Button1) {
+ if (e->window == jpegW) clickJD(x,y);
+ else if (e->window == qDial.win) DTrack(&qDial, x,y);
+@@ -156,18 +154,18 @@
+ } /* button1 */
+ else rv = 0;
+ } /* button press */
+-
+-
++
++
+ else if (xev->type == KeyPress) {
+ XKeyEvent *e = (XKeyEvent *) xev;
+ char buf[128]; KeySym ks;
+ int stlen;
+-
++
+ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
+ buf[stlen] = '\0';
+-
++
+ RemapKeyCheck(ks, buf, &stlen);
+-
++
+ if (e->window == jpegW) {
+ if (stlen) {
+ if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
+@@ -181,12 +179,12 @@
+ else rv = 0;
+ }
+ else rv = 0;
+-
++
+ if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
+ XBell(theDisp, 50);
+ rv = 1; /* eat it */
+ }
+-
++
+ return rv;
+ }
+
+@@ -211,17 +209,17 @@
+ char *title3 = "quality = bigger file.";
+ char *title4 = "Use smoothing if saving";
+ char *title5 = "an 8-bit image (eg, a GIF).";
+-
++
+ char *qtitle1 = "Default = 75.";
+ char *qtitle2 = "Useful range";
+ char *qtitle3 = "is 5-95.";
+ char *smtitle1 = "Default = 0 (none).";
+ char *smtitle2 = "10-30 is enough";
+ char *smtitle3 = "for typical GIFs.";
+-
++
+ int i;
+ XRectangle xr;
+-
++
+ xr.x = x; xr.y = y; xr.width = w; xr.height = h;
+ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
+
+@@ -240,11 +238,11 @@
+ DrawString(jpegW, 15, 10+100+10+ASCENT, qtitle1);
+ DrawString(jpegW, 15, 10+100+10+ASCENT+LINEHIGH, qtitle2);
+ DrawString(jpegW, 15, 10+100+10+ASCENT+LINEHIGH*2, qtitle3);
+-
++
+ DrawString(jpegW, 115, 10+100+10+ASCENT+LINEHIGH*0, smtitle1);
+ DrawString(jpegW, 115, 10+100+10+ASCENT+LINEHIGH*1, smtitle2);
+ DrawString(jpegW, 115, 10+100+10+ASCENT+LINEHIGH*2, smtitle3);
+-
++
+ XSetClipMask(theDisp, theGC, None);
+ }
+
+@@ -255,14 +253,14 @@
+ {
+ int i;
+ BUTT *bp;
+-
++
+ /* check BUTTs */
+-
++
+ for (i=0; i<J_NBUTTS; i++) {
+ bp = &jbut[i];
+ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
+ }
+-
++
+ if (i<J_NBUTTS) { /* found one */
+ if (BTTrack(bp)) doCmd(i);
+ }
+@@ -281,7 +279,7 @@
+
+ writeJPEG();
+ JPEGDialog(0);
+-
++
+ fullname = GetDirFullName();
+ if (!ISPIPE(fullname[0])) {
+ XVCreatedFile(fullname);
+@@ -304,7 +302,7 @@
+ static void writeJPEG()
+ {
+ FILE *fp;
+- int i, nc, rv, w, h, ptype, pfree;
++ int i, nc, rv, w, h, npixels, ptype, pfree;
+ register byte *ip, *ep;
+ byte *inpix, *rmap, *gmap, *bmap;
+ byte *image8, *image24;
+@@ -322,6 +320,14 @@
+ WaitCursor();
+ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
+
++ /* this case may not be possible to trigger, but not totally clear, so... */
++ npixels = w*h;
++ if (w <= 0 || h <= 0 || npixels/w < h) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, w, h);
++ return;
++ }
++
+ image8 = image24 = (byte *) NULL;
+
+
+@@ -332,37 +338,46 @@
+ if (i==nc) colorType = F_GREYSCALE; /* made it all the way through */
+ }
+ else { /* PIC24 */
+- for (i=0,ip=inpix; i<w*h && ip[0]==ip[1] && ip[1]==ip[2]; i++,ip+=3);
+- if (i==w*h) colorType = F_GREYSCALE; /* all the way through */
++ for (i=0,ip=inpix; i<npixels && ip[0]==ip[1] && ip[1]==ip[2]; i++,ip+=3);
++ if (i==npixels) colorType = F_GREYSCALE; /* all the way through */
+ }
+ }
+-
+-
++
++
+ /* first thing to do is build an 8/24-bit Greyscale/TrueColor image
+ (meaning: non-colormapped) */
+-
++
+ if (colorType == F_GREYSCALE) { /* build an 8-bit Greyscale image */
+- image8 = (byte *) malloc((size_t) w * h);
++ image8 = (byte *) malloc((size_t) npixels);
+ if (!image8) FatalError("writeJPEG: unable to malloc image8\n");
+-
++
+ if (ptype == PIC8) {
+- for (i=0,ip=image8,ep=inpix; i<w * h; i++, ip++, ep++)
++ for (i=0,ip=image8,ep=inpix; i<npixels; i++, ip++, ep++)
+ *ip = MONO(rmap[*ep], gmap[*ep], bmap[*ep]);
+ }
+ else { /* PIC24 */
+- for (i=0,ip=image8,ep=inpix; i<w*h; i++, ip++, ep+=3)
++ for (i=0,ip=image8,ep=inpix; i<npixels; i++, ip++, ep+=3)
+ *ip = MONO(ep[0],ep[1],ep[2]);
+ }
+ }
+
+ else { /* *not* F_GREYSCALE */
+ if (ptype == PIC8) {
+- image24 = (byte *) malloc((size_t) w * h * 3);
++ int count = 3*npixels;
++
++ /* already know npixels > 0 (above) */
++ if (count/3 < npixels) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, w, h);
++ return;
++ }
++
++ image24 = (byte *) malloc((size_t) count);
+ if (!image24) { /* this simply isn't going to work */
+ FatalError("writeJPEG: unable to malloc image24\n");
+ }
+
+- for (i=0, ip=image24, ep=inpix; i<w*h; i++, ep++) {
++ for (i=0, ip=image24, ep=inpix; i<npixels; i++, ep++) {
+ *ip++ = rmap[*ep];
+ *ip++ = gmap[*ep];
+ *ip++ = bmap[*ep];
+@@ -374,16 +389,16 @@
+ }
+ }
+
+-
++
+ /* in any event, we've got some valid image. Do the JPEG Thing */
+ rv = writeJFIF(fp, (colorType==F_GREYSCALE) ? image8 : image24,
+ w, h, colorType);
+-
++
+ if (colorType == F_GREYSCALE) free(image8);
+ else if (ptype == PIC8) free(image24);
+
+ if (pfree) free(inpix);
+-
++
+ if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
+ SetCursors(-1);
+ }
+@@ -400,7 +415,7 @@
+
+
+ /**************************************************/
+-METHODDEF void xv_error_exit(cinfo)
++METHODDEF void xv_error_exit(cinfo)
+ j_common_ptr cinfo;
+ {
+ my_error_ptr myerr;
+@@ -412,7 +427,7 @@
+
+
+ /**************************************************/
+-METHODDEF void xv_error_output(cinfo)
++METHODDEF void xv_error_output(cinfo)
+ j_common_ptr cinfo;
+ {
+ my_error_ptr myerr;
+@@ -464,7 +479,7 @@
+ FILE *fp;
+ static byte *pic;
+ long filesize;
+- int i,w,h,bperpix;
++ int i,w,h,bperpix,bperline,count;
+
+
+ fbasename = BaseName(fname);
+@@ -546,16 +561,16 @@
+ if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
+ cinfo.out_color_space = JCS_GRAYSCALE;
+ cinfo.quantize_colors = FALSE;
+-
++
+ SetISTR(ISTR_INFO,"Loading %dx%d Greyscale JPEG (%ld bytes)...",
+ w,h,filesize);
+-
++
+ for (i=0; i<256; i++) pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+ }
+ else {
+ cinfo.out_color_space = JCS_RGB;
+ cinfo.quantize_colors = FALSE; /* default: give 24-bit image to XV */
+-
++
+ if (!quick && picType==PIC8 && conv24MB.flags[CONV24_LOCK] == 1) {
+ /*
+ * we're locked into 8-bit mode:
+@@ -563,23 +578,23 @@
+ * if CONV24_SLOW, use JPEG's two-pass quantizer
+ * if CONV24_BEST, or other, ask for 24-bit image and hand it to XV
+ */
+-
++
+ cinfo.desired_number_of_colors = 256;
+-
++
+ if (conv24 == CONV24_FAST || conv24 == CONV24_SLOW) {
+ cinfo.quantize_colors = TRUE;
+ state824=1; /* image was converted from 24 to 8 bits */
+-
++
+ cinfo.two_pass_quantize = (conv24 == CONV24_SLOW);
+ }
+ }
+-
++
+ SetISTR(ISTR_INFO,"Loading %dx%d Color JPEG (%ld bytes)...",
+ w,h,filesize);
+ }
+-
++
+ jpeg_calc_output_dimensions(&cinfo); /* note colorspace changes... */
+-
++
+
+ if (cinfo.output_components != 1 && cinfo.output_components != 3) {
+ SetISTR(ISTR_WARNING, "%s: can't read %d-plane JPEG file!",
+@@ -594,7 +609,18 @@
+ bperpix = cinfo.output_components;
+ pinfo->type = (bperpix == 1) ? PIC8 : PIC24;
+
+- pic = (byte *) malloc((size_t) (w * h * bperpix));
++ bperline = w * bperpix;
++ count = h * bperline;
++ if (w <= 0 || h <= 0 || bperline/w < bperpix || count/h < bperline) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large (%dx%d)",
++ fbasename, w, h);
++ jpeg_destroy_decompress(&cinfo);
++ fclose(fp);
++ if (comment) free(comment);
++ return 0;
++ }
++
++ pic = (byte *) malloc((size_t) count);
+ if (!pic) {
+ SetISTR(ISTR_WARNING, "%s: can't read JPEG file - out of memory",
+ fbasename);
+@@ -603,15 +629,24 @@
+ if (comment) free(comment);
+ return 0;
+ }
+-
++
+ jpeg_start_decompress(&cinfo);
+
+ while (cinfo.output_scanline < cinfo.output_height) {
++ if (cinfo.output_scanline < 0) { /* should never happen, but... */
++ SetISTR(ISTR_WARNING, "%s: invalid negative scanline (%d)",
++ fbasename, cinfo.output_scanline);
++ jpeg_destroy_decompress(&cinfo);
++ fclose(fp);
++ if (comment) free(comment);
++ free(pic);
++ return 0;
++ }
+ rowptr[0] = (JSAMPROW) &pic[cinfo.output_scanline * w * bperpix];
+ (void) jpeg_read_scanlines(&cinfo, rowptr, (JDIMENSION) 1);
+ }
+
+-
++
+
+ /* return 'PICINFO' structure to XV */
+
+@@ -623,7 +658,7 @@
+ if (cinfo.out_color_space == JCS_GRAYSCALE) {
+ sprintf(pinfo->fullInfo, "Greyscale JPEG. (%ld bytes)", filesize);
+ pinfo->colType = F_GREYSCALE;
+-
++
+ for (i=0; i<256; i++) pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+ }
+ else {
+@@ -638,10 +673,10 @@
+ }
+ }
+ }
+-
+- sprintf(pinfo->shrtInfo, "%dx%d %s JPEG. ", w,h,
++
++ sprintf(pinfo->shrtInfo, "%dx%d %s JPEG. ", w,h,
+ (cinfo.out_color_space == JCS_GRAYSCALE) ? "Greyscale " : "Color ");
+-
++
+ pinfo->comment = comment;
+
+ jpeg_finish_decompress(&cinfo);
+@@ -651,8 +686,8 @@
+ comment = (char *) NULL;
+ return 1;
+ }
+-
+-
++
++
+
+
+ /**************************************************/
+@@ -660,7 +695,7 @@
+ j_decompress_ptr cinfo;
+ {
+ struct jpeg_source_mgr *datasrc = cinfo->src;
+-
++
+ if (datasrc->bytes_in_buffer == 0) {
+ if (! (*datasrc->fill_input_buffer) (cinfo))
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
+@@ -688,7 +723,7 @@
+ }
+ else comment = (char *) realloc(comment, strlen(comment) + length + 1);
+ if (!comment) FatalError("out of memory in xv_process_comment");
+-
++
+ oldsp = sp = comment + strlen(comment);
+ hasnull = 0;
+
+@@ -770,19 +805,19 @@
+
+ sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n",
+ CREATOR_STR, REVDATE, qDial.val, smDial.val);
+-
++
+ if (picComments) { /* append XV comment */
+ char *sp, *sp1; int done;
+
+ i = strlen(picComments);
+ comment = (char *) malloc(i + strlen(xvcmt) + 2 + 1);
+ if (!comment) FatalError("out of memory in writeJFIF()");
+-
++
+ strcpy(comment, picComments);
+-
++
+ /* see if there's a line that starts with 'CREATOR: ' in the
+ comments. If there is, rip it out. */
+-
++
+ sp = comment; done = 0;
+ while (!done && *sp) {
+ if (strncmp(sp, CREATOR_STR, strlen(CREATOR_STR)) == 0) {
+@@ -801,7 +836,7 @@
+ }
+ }
+
+- /* count # of \n's at end of comment.
++ /* count # of \n's at end of comment.
+ If none, add 2. If one, add 1. If two or more, add none. */
+
+ sp = comment + strlen(comment);
+@@ -814,15 +849,15 @@
+ strcat(comment, xvcmt);
+ }
+ else comment = xvcmt;
+-
+-
++
++
+ jpeg_write_marker(&cinfo,JPEG_COM,(byte *) comment,(u_int) strlen(comment));
+-
++
+ while (cinfo.next_scanline < cinfo.image_height) {
+ rowptr[0] = (JSAMPROW) &pic[cinfo.next_scanline * w * bperpix];
+ (void) jpeg_write_scanlines(&cinfo, rowptr, (JDIMENSION) 1);
+ }
+-
++
+ jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress(&cinfo);
+ return 0;
+diff -ruN xv-3.10a/xvmisc.c xv-3.10a-bugfixes/xvmisc.c
+--- xv-3.10a/xvmisc.c 1995-01-13 15:41:34.000000000 -0800
++++ xv-3.10a-bugfixes/xvmisc.c 2005-03-20 22:47:06.000000000 -0800
+@@ -28,6 +28,8 @@
+ * int xvbcmp (s1, s2, length)
+ * void xvbzero(s, length)
+ * char *xv_strstr(s1, s2)
++ * FILE *xv_fopen(str, str)
++ * void xv_mktemp(str)
+ * void Timer(milliseconds)
+ */
+
+@@ -36,6 +38,10 @@
+ #define NEEDSTIME
+ #include "xv.h"
+
++#ifdef __linux__ /* probably others, too, but being conservative */
++# include <unistd.h> /* getwd() */
++#endif
++
+ #include "bits/fc_left"
+ #include "bits/fc_leftm"
+ #include "bits/fc_left1"
+@@ -61,12 +67,12 @@
+
+ /* the following fakes 'XSetWMProtocols(theDisp, win, &atom_DELWIN, 1);' */
+
+- if (! atom_PROTOCOLS)
++ if (! atom_PROTOCOLS)
+ atom_PROTOCOLS = XInternAtom (theDisp, "WM_PROTOCOLS", False);
+
+ if (atom_PROTOCOLS == None) return;
+
+- XChangeProperty(theDisp, win, atom_PROTOCOLS, XA_ATOM, 32,
++ XChangeProperty(theDisp, win, atom_PROTOCOLS, XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) &atom_DELWIN, 1);
+ }
+
+@@ -91,9 +97,9 @@
+ x = y = 1;
+ i = XParseGeometry(geom,&x,&y, (unsigned int *) &w, (unsigned int *) &h);
+
+- if ((i&XValue || i&YValue)) hints.flags = USPosition;
++ if ((i&XValue || i&YValue)) hints.flags = USPosition;
+ else hints.flags = PPosition;
+-
++
+ if (!usesize || !(i&WidthValue)) w = defw;
+ if (!usesize || !(i&HeightValue)) h = defh;
+
+@@ -130,7 +136,7 @@
+ xswamask = CWBackPixel | CWBorderPixel | CWColormap;
+ if (!usesize) xswamask |= CWBitGravity;
+
+- win = XCreateWindow(theDisp, rootW, x, y, (u_int) w, (u_int) h,
++ win = XCreateWindow(theDisp, rootW, x, y, (u_int) w, (u_int) h,
+ (u_int) bwidth, (int) dispDEEP, InputOutput,
+ theVisual, xswamask, &xswa);
+ if (!win) return(win); /* leave immediately if couldn't create */
+@@ -152,7 +158,7 @@
+
+ return(win);
+ }
+-
++
+
+
+ /**************************************************/
+@@ -164,7 +170,7 @@
+ XDrawString(theDisp, win, theGC, x, y, str, (int) strlen(str));
+ }
+
+-
++
+ /**************************************************/
+ void CenterString(win,x,y,str)
+ Window win;
+@@ -174,7 +180,7 @@
+ DrawString(win, CENTERX(mfinfo, x, str), CENTERY(mfinfo, y), str);
+ }
+
+-
++
+ /**************************************************/
+ void ULineString(win,x,y,str)
+ Window win;
+@@ -182,11 +188,11 @@
+ char *str;
+ {
+ DrawString(win, x, y, str);
+- XDrawLine(theDisp, win, theGC, x, y+DESCENT-1,
++ XDrawLine(theDisp, win, theGC, x, y+DESCENT-1,
+ x+StringWidth(str), y+DESCENT-1);
+ }
+
+-
++
+ /**************************************************/
+ int StringWidth(str)
+ char *str;
+@@ -194,13 +200,13 @@
+ return(XTextWidth(mfinfo, str, (int) strlen(str)));
+ }
+
+-
++
+ /**************************************************/
+ int CursorKey(ks, shift, dotrans)
+ KeySym ks;
+ int shift, dotrans;
+ {
+- /* called by the KeyPress/KeyRelease event handler to determine if a
++ /* called by the KeyPress/KeyRelease event handler to determine if a
+ given keypress is a cursor key. More complex than you'd think, since
+ certain Sun Keyboards generate a variety of odd keycodes, and not all
+ keyboards *have* all these keys. Note that 'shifted' arrow keys
+@@ -225,16 +231,16 @@
+
+ int i = CK_NONE;
+
+- if (ks==XK_Up || ks==XK_KP_Up ||
++ if (ks==XK_Up || ks==XK_KP_Up ||
+ ks==XK_KP_8 || ks==XK_F28) i=CK_UP;
+
+- else if (ks==XK_Down || ks==XK_KP_Down ||
++ else if (ks==XK_Down || ks==XK_KP_Down ||
+ ks==XK_KP_2 || ks==XK_F34) i=CK_DOWN;
+
+- else if (ks==XK_Left || ks==XK_KP_Left ||
++ else if (ks==XK_Left || ks==XK_KP_Left ||
+ ks==XK_KP_4 || ks==XK_F30) i=CK_LEFT;
+
+- else if (ks==XK_Right || ks==XK_KP_Right ||
++ else if (ks==XK_Right || ks==XK_KP_Right ||
+ ks==XK_KP_6 || ks==XK_F32) i=CK_RIGHT;
+
+ else if (ks==XK_Prior || ks==XK_KP_Prior ||
+@@ -257,7 +263,7 @@
+ else if (i==CK_UP) i=CK_PAGEUP;
+ else if (i==CK_DOWN) i=CK_PAGEDOWN;
+ }
+-
++
+ return i;
+ }
+
+@@ -334,9 +340,9 @@
+ ev.window = win;
+ ev.x = x; ev.y = y; ev.width = w; ev.height = h;
+ ev.count = 0;
+-
++
+ XSendEvent(theDisp, win, False, NoEventMask, (XEvent *) &ev);
+-}
++}
+
+
+ /***********************************/
+@@ -381,7 +387,7 @@
+ u_int w, h;
+ u_long bg;
+ {
+- /* stipple a rectangular region by drawing 'bg' where there's 1's
++ /* stipple a rectangular region by drawing 'bg' where there's 1's
+ in the stipple pattern */
+
+ XSetFillStyle (theDisp, theGC, FillStippled);
+@@ -400,7 +406,7 @@
+ unsigned int w,h;
+ unsigned long hi, lo, bg;
+ {
+- int i,r,x1,y1;
++ int i, x1, y1;
+
+ x1 = x + (int) w;
+ y1 = y + (int) h;
+@@ -413,7 +419,7 @@
+ XDrawLine(theDisp, win, theGC, x+i, y1-i, x+i, y+i);
+ XDrawLine(theDisp, win, theGC, x+i, y+i, x1-i, y+i);
+ }
+-
++
+ /* draw bot-right */
+ XSetForeground(theDisp, theGC, (inout==R3D_OUT) ? lo : hi);
+
+@@ -431,18 +437,18 @@
+ }
+ }
+ }
+-
++
+
+
+ /**************************************************/
+ void SetCropString()
+ {
+ /* sets the crop string in the info box to be correct. should
+- be called whenever 'but[BCROP].active', cXOFF,cYOFF,cWIDE,cHIGH
++ be called whenever 'but[BCROP].active', cXOFF,cYOFF,cWIDE,cHIGH
+ are changed */
+
+- if (cpic != pic)
+- SetISTR(ISTR_CROP, "%dx%d rectangle starting at %d,%d",
++ if (cpic != pic)
++ SetISTR(ISTR_CROP, "%dx%d rectangle starting at %d,%d",
+ cWIDE, cHIGH, cXOFF, cYOFF);
+ else SetISTR(ISTR_CROP, "<none>");
+ }
+@@ -469,7 +475,7 @@
+ char *st;
+
+ /* give 'em time to read message */
+- if (infoUp || ctrlUp || anyBrowUp) sleep(3);
++ if (infoUp || ctrlUp || anyBrowUp) sleep(3);
+ else {
+ st = GetISTR(ISTR_INFO);
+ OpenAlert(st);
+@@ -477,7 +483,7 @@
+ CloseAlert();
+ }
+ }
+-
++
+
+ /***********************************/
+ void FatalError (identifier)
+@@ -491,7 +497,7 @@
+ /***********************************/
+ void Quit(i)
+ int i;
+-{
++{
+ /* called when the program exits. frees everything explictly created
+ EXCEPT allocated colors. This is used when 'useroot' is in operation,
+ as we have to keep the alloc'd colors around, but we don't want anything
+@@ -521,9 +527,9 @@
+ #endif
+
+ /* if NOT using stdcmap for images, free stdcmap */
+- if (colorMapMode != CM_STDCMAP) {
++ if (colorMapMode != CM_STDCMAP) {
+ int j;
+- for (j=0; j<stdnfcols; j++)
++ for (j=0; j<stdnfcols; j++)
+ xvFreeColors(theDisp, theCmap, &stdfreecols[j], 1, 0L);
+ }
+
+@@ -543,13 +549,13 @@
+ if (origlist[j][0] != '/') { /* relative path, prepend 'initdir' */
+ sprintf(str,"%s/%s", initdir, origlist[j]);
+ if (unlink(str)) {
+- fprintf(stderr,"%s: can't delete '%s' - %s\n",
++ fprintf(stderr,"%s: can't delete '%s' - %s\n",
+ cmd, str, ERRSTR(errno));
+ }
+ }
+ else {
+ if (unlink(origlist[j])) {
+- fprintf(stderr,"%s: can't delete '%s' - %s\n",
++ fprintf(stderr,"%s: can't delete '%s' - %s\n",
+ cmd, origlist[j], ERRSTR(errno));
+ }
+ }
+@@ -567,7 +573,7 @@
+ void LoadFishCursors()
+ {
+ #define fc_w 16
+-#define fc_h 16
++#define fc_h 16
+
+ Pixmap flpix,flmpix,fmpix,fmmpix,frpix,frmpix;
+ Pixmap fl1pix, fl1mpix, fr1pix, fr1mpix;
+@@ -592,7 +598,7 @@
+
+ fr1pix = XCreatePixmapFromBitmapData(theDisp, ctrlW, (char *) fc_right1_bits,
+ fc_w, fc_h, 1L, 0L, 1);
+- fr1mpix = XCreatePixmapFromBitmapData(theDisp, ctrlW,
++ fr1mpix = XCreatePixmapFromBitmapData(theDisp, ctrlW,
+ (char *) fc_right1m_bits,
+ fc_w, fc_h, 1L, 0L, 1);
+
+@@ -613,7 +619,7 @@
+ fr1curs= XCreatePixmapCursor(theDisp, fr1pix,fr1mpix,&fg, &bg, 8,8);
+ frcurs = XCreatePixmapCursor(theDisp, frpix, frmpix, &fg, &bg, 8,8);
+
+- if (!flcurs || !fmcurs || !frcurs || !fl1curs || !fr1curs)
++ if (!flcurs || !fmcurs || !frcurs || !fl1curs || !fr1curs)
+ { flcurs = fmcurs = frcurs = (Cursor) NULL; }
+ }
+
+@@ -633,8 +639,8 @@
+ time(&lastwaittime);
+ waiting=1;
+ xwmh.input = True;
+- xwmh.icon_pixmap = riconPix;
+- xwmh.icon_mask = riconmask;
++ xwmh.icon_pixmap = riconPix;
++ xwmh.icon_mask = riconmask;
+ xwmh.flags = (InputHint | IconPixmapHint | IconMaskHint) ;
+ if (!useroot && mainW) XSetWMHints(theDisp, mainW, &xwmh);
+ if ( useroot && ctrlW) XSetWMHints(theDisp, ctrlW, &xwmh);
+@@ -665,8 +671,8 @@
+ if (waiting) {
+ waiting=0;
+ xwmh.input = True;
+- xwmh.icon_pixmap = iconPix;
+- xwmh.icon_mask = iconmask;
++ xwmh.icon_pixmap = iconPix;
++ xwmh.icon_mask = iconmask;
+ xwmh.flags = (InputHint | IconPixmapHint | IconMaskHint) ;
+ if (!useroot && mainW) XSetWMHints(theDisp, mainW, &xwmh);
+ if ( useroot && ctrlW) XSetWMHints(theDisp, ctrlW, &xwmh);
+@@ -694,11 +700,11 @@
+
+ XFlush(theDisp);
+ }
+-
++
+
+ static void set_cursors(mainc, otherc)
+ Cursor mainc, otherc;
+-{
++{
+ if (!useroot && mainW) XDefineCursor(theDisp, mainW, mainc);
+ if (infoW) XDefineCursor(theDisp, infoW, otherc);
+ if (ctrlW) XDefineCursor(theDisp, ctrlW, otherc);
+@@ -708,11 +714,11 @@
+
+ SetBrowseCursor(otherc);
+ SetTextCursor(otherc);
+-
++
+ #ifdef HAVE_JPEG
+ if (jpegW) XDefineCursor(theDisp, jpegW, otherc);
+ #endif
+-
++
+ #ifdef HAVE_TIFF
+ if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
+ #endif
+@@ -725,7 +731,7 @@
+ {
+ char *basname;
+
+- /* given a complete path name ('/foo/bar/weenie.gif'), returns just the
++ /* given a complete path name ('/foo/bar/weenie.gif'), returns just the
+ 'simple' name ('weenie.gif'). Note that it does not make a copy of
+ the name, so don't be modifying it... */
+
+@@ -736,7 +742,7 @@
+ return basname;
+ }
+
+-
++
+ /***************************************************/
+ void DrawTempGauge(win, x,y,w,h, ratio, fg,bg,hi,lo, str)
+ Window win;
+@@ -773,14 +779,14 @@
+ if (numchars) { /* do string */
+ if (barwide < maxwide) {
+ XSetForeground(theDisp, theGC, bg);
+- XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
++ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
+ (u_int) (maxwide-barwide), (u_int) (h-5));
+ }
+-
++
+ XSetFunction(theDisp, theGC, GXinvert);
+ XSetPlaneMask(theDisp, theGC, fg ^ bg);
+
+- XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
++ XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+ CENTERY(mfinfo, (y+h/2)), str, numchars);
+
+ XSetFunction(theDisp, theGC, GXcopy);
+@@ -789,18 +795,18 @@
+
+ else if (barwide < maxwide) {
+ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 0, x+w-3, y+h/2 + 0);
+-
++
+ XSetForeground(theDisp, theGC, lo);
+ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 1, x+w-3, y+h/2 + 1);
+-
++
+ XSetForeground(theDisp, theGC, hi);
+ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 2, x+w-3, y+h/2 + 2);
+-
++
+ XSetForeground(theDisp, theGC, bg);
+- XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
++ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
+ (u_int) (maxwide-barwide), (u_int) (h/2 - 3));
+-
+- XFillRectangle(theDisp, win, theGC, x+3+barwide, y+h/2 + 3,
++
++ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+h/2 + 3,
+ (u_int) (maxwide-barwide),(u_int)((h-3) - (h/2+3)) + 1);
+ }
+ }
+@@ -815,35 +821,35 @@
+ if (numchars) {
+ if (barwide < maxwide) {
+ XSetForeground(theDisp, theGC, bg);
+- XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
++ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
+ (u_int) (maxwide-barwide), (u_int) (h-1));
+ }
+-
++
+ XSetFunction(theDisp, theGC, GXinvert);
+ XSetPlaneMask(theDisp, theGC, fg ^ bg);
+
+- XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
++ XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+ CENTERY(mfinfo, (y+h/2)), str, numchars);
+
+ XSetFunction(theDisp, theGC, GXcopy);
+ XSetPlaneMask(theDisp, theGC, AllPlanes);
+ }
+-
++
+ else if (barwide < maxwide) {
+ XDrawLine(theDisp, win, theGC, x+1+barwide, y+h/2, x+w-1, y+h/2);
+-
++
+ XSetForeground(theDisp, theGC, bg);
+- XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
++ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
+ (u_int) (maxwide-barwide), (u_int) (h/2 - 1));
+-
+- XFillRectangle(theDisp, win, theGC, x+1+barwide, y+h/2 + 1,
++
++ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+h/2 + 1,
+ (u_int)(maxwide-barwide),(u_int)(((h-1) - (h/2+1))+1));
+ }
+ }
+
+ XFlush(theDisp);
+ }
+-
++
+
+
+ /***************************************************/
+@@ -852,7 +858,7 @@
+ char *str;
+ {
+ /* called during 'long' operations (algorithms, smoothing, etc.) to
+- give some indication that the program will ever finish. Draws a
++ give some indication that the program will ever finish. Draws a
+ temperature gauge in either mainW (if not useRoot), or ctrlW.
+ Tries to be clever: only draws gauge if it looks like the operation is
+ going to take more than a few seconds. Calling with val == max removes
+@@ -887,7 +893,7 @@
+ if (!waiting) { /* not waiting (or not waiting any longer) */
+ if (nowTime == lastTime && val<max) return; /* max one draw per second */
+ lastTime = nowTime;
+- DrawTempGauge(win, xpos, ypos, 100,19, doneness,
++ DrawTempGauge(win, xpos, ypos, 100,19, doneness,
+ infofg,infobg,hicol,locol,str);
+
+ if (val >= max) { /* remove temp gauge */
+@@ -945,7 +951,7 @@
+ */
+
+ if (src==dst || len<=0) return; /* nothin' to do */
+-
++
+ if (src<dst && src+len>dst) { /* do a backward copy */
+ src = src + len - 1;
+ dst = dst + len - 1;
+@@ -957,7 +963,7 @@
+ for ( ; len>0; len--, src++, dst++) *dst = *src;
+ }
+ }
+-
++
+
+ /***************************************************/
+ int xvbcmp (s1, s2, len)
+@@ -987,7 +993,7 @@
+ {
+ /* gets the current working directory. No trailing '/' */
+
+- char *rv;
++ char *rv;
+
+ #ifdef USE_GETCWD
+ rv = (char *) getcwd(buf, buflen);
+@@ -996,7 +1002,7 @@
+ #endif
+
+ if (!rv || strlen(rv)==0) {
+- if (((rv=(char *) getenv("PWD"))==NULL) &&
++ if (((rv=(char *) getenv("PWD"))==NULL) &&
+ ((rv=(char *) getenv("cwd"))==NULL)) rv = "./";
+ strcpy(buf, rv);
+ }
+@@ -1006,7 +1012,7 @@
+
+ /***************************************************/
+
+-/*
++/*
+ * Source code for the "strstr" library routine.
+ *
+ * Copyright 1988 Regents of the University of California
+@@ -1066,6 +1072,22 @@
+ }
+
+
++/***************************************************/
++/* GRR 20050320: added actual mk[s]temp() call... */
++void xv_mktemp(buf, fname)
++ char *buf, *fname;
++{
++#ifndef VMS
++ sprintf(buf, "%s/%s", tmpdir, fname);
++#else
++ sprintf(buf, "Sys$Disk:[]%s", fname);
++#endif
++#ifdef USE_MKSTEMP
++ close(mkstemp(buf));
++#else
++ mktemp(buf);
++#endif
++}
+
+
+ /*******/
+@@ -1124,7 +1146,7 @@
+ {
+ /* default Timer() method now uses 'select()', which probably works
+ on all systems *anyhow* (except for VMS...) */
+-
++
+ struct timeval time;
+
+ time.tv_sec = usec / 1000000L;
+diff -ruN xv-3.10a/xvpbm.c xv-3.10a-bugfixes/xvpbm.c
+--- xv-3.10a/xvpbm.c 1995-01-03 13:23:44.000000000 -0800
++++ xv-3.10a-bugfixes/xvpbm.c 2005-04-03 14:25:28.000000000 -0700
+@@ -115,7 +115,7 @@
+ }
+
+ return rv;
+-}
++}
+
+
+
+@@ -127,15 +127,21 @@
+ {
+ byte *pic8;
+ byte *pix;
+- int i,j,bit,w,h;
++ int i,j,bit,w,h,npixels;
++
++ w = pinfo->w;
++ h = pinfo->h;
+
+- w = pinfo->w; h = pinfo->h;
+- pic8 = (byte *) calloc((size_t) w * h, (size_t) 1);
+- if (!pic8) return pbmError(bname, "couldn't malloc 'pic8'");
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h)
++ return pbmError(bname, "image dimensions too large");
++
++ pic8 = (byte *) calloc((size_t) npixels, (size_t) 1);
++ if (!pic8) FatalError("couldn't malloc 'pic8' for PBM");
+
+ pinfo->pic = pic8;
+ pinfo->type = PIC8;
+- sprintf(pinfo->fullInfo, "PBM, %s format. (%ld bytes)",
++ sprintf(pinfo->fullInfo, "PBM, %s format. (%ld bytes)",
+ (raw) ? "raw" : "ascii", filesize);
+ sprintf(pinfo->shrtInfo, "%dx%d PBM.", w, h);
+ pinfo->colType = F_BWDITHER;
+@@ -153,7 +159,7 @@
+ for (j=0; j<w; j++, pix++) *pix = getbit(fp, pinfo);
+ }
+
+- if (numgot != w*h) pbmError(bname, TRUNCSTR);
++ if (numgot != npixels) pbmError(bname, TRUNCSTR);
+ if (garbage) {
+ return(pbmError(bname, "Garbage characters in image data."));
+ }
+@@ -192,17 +198,23 @@
+ int raw, maxv;
+ {
+ byte *pix, *pic8;
+- int i,j,bitshift,w,h, holdmaxv;
++ int i,j,bitshift,w,h,npixels, holdmaxv;
++
+
++ w = pinfo->w;
++ h = pinfo->h;
+
+- w = pinfo->w; h = pinfo->h;
+- pic8 = (byte *) calloc((size_t) w*h, (size_t) 1);
+- if (!pic8) return(pbmError(bname, "couldn't malloc 'pic8'"));
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h)
++ return pbmError(bname, "image dimensions too large");
++
++ pic8 = (byte *) calloc((size_t) npixels, (size_t) 1);
++ if (!pic8) FatalError("couldn't malloc 'pic8' for PGM");
+
+
+ pinfo->pic = pic8;
+ pinfo->type = PIC8;
+- sprintf(pinfo->fullInfo, "PGM, %s format. (%ld bytes)",
++ sprintf(pinfo->fullInfo, "PGM, %s format. (%ld bytes)",
+ (raw) ? "raw" : "ascii", filesize);
+ sprintf(pinfo->shrtInfo, "%dx%d PGM.", pinfo->w, pinfo->h);
+ pinfo->colType = F_GREYSCALE;
+@@ -236,11 +248,11 @@
+ }
+ }
+ else {
+- numgot = fread(pic8, (size_t) 1, (size_t) w*h, fp); /* read raw data */
++ numgot = fread(pic8, (size_t)1, (size_t)npixels, fp); /* read raw data */
+ }
+ }
+
+- if (numgot != w*h) pbmError(bname, TRUNCSTR); /* warning only */
++ if (numgot != npixels) pbmError(bname, TRUNCSTR); /* warning only */
+
+ if (garbage) {
+ return (pbmError(bname, "Garbage characters in image data."));
+@@ -256,18 +268,24 @@
+ PICINFO *pinfo;
+ int raw, maxv;
+ {
+- byte *pix, *pic24, scale[256], *pic8;
+- int i,j,bitshift, w, h, holdmaxv;
++ byte *pix, *pic24, scale[256];
++ int i,j,bitshift, w, h, npixels, bufsize, holdmaxv;
++
++ w = pinfo->w;
++ h = pinfo->h;
+
+- w = pinfo->w; h = pinfo->h;
++ npixels = w * h;
++ bufsize = 3*npixels;
++ if (w <= 0 || h <= 0 || npixels/w != h || bufsize/3 != npixels)
++ return pbmError(bname, "image dimensions too large");
+
+ /* allocate 24-bit image */
+- pic24 = (byte *) calloc((size_t) w*h*3, (size_t) 1);
+- if (!pic24) FatalError("couldn't malloc 'pic24'");
++ pic24 = (byte *) calloc((size_t) bufsize, (size_t) 1);
++ if (!pic24) FatalError("couldn't malloc 'pic24' for PPM");
+
+ pinfo->pic = pic24;
+ pinfo->type = PIC24;
+- sprintf(pinfo->fullInfo, "PPM, %s format. (%ld bytes)",
++ sprintf(pinfo->fullInfo, "PPM, %s format. (%ld bytes)",
+ (raw) ? "raw" : "ascii", filesize);
+ sprintf(pinfo->shrtInfo, "%dx%d PPM.", w, h);
+ pinfo->colType = F_FULLCOLOR;
+@@ -297,20 +315,20 @@
+ }
+ }
+ else {
+- numgot = fread(pic24, (size_t) 1, (size_t) w*h*3, fp); /* read data */
++ numgot = fread(pic24, (size_t) 1, (size_t) bufsize, fp); /* read data */
+ }
+ }
+-
+- if (numgot != w*h*3) pbmError(bname, TRUNCSTR);
++
++ if (numgot != bufsize) pbmError(bname, TRUNCSTR);
+
+ if (garbage)
+ return(pbmError(bname, "Garbage characters in image data."));
+
+
+- /* have to scale all RGB values up (Conv24to8 expects RGB values to
+- range from 0-255 */
++ /* have to scale up all RGB values (Conv24to8 expects RGB values to
++ range from 0-255) */
+
+- if (maxv<255) {
++ if (maxv<255) {
+ for (i=0; i<=maxv; i++) scale[i] = (i * 255) / maxv;
+
+ for (i=0, pix=pic24; i<h; i++) {
+@@ -360,8 +378,8 @@
+ pinfo->comment[0] = '\0';
+ }
+ else {
+- tmpptr = (char *) realloc(pinfo->comment,
+- strlen(pinfo->comment) + strlen(cmt) + 1);
++ tmpptr = (char *) realloc(pinfo->comment,
++ strlen(pinfo->comment) + strlen(cmt) + 1);
+ if (!tmpptr) FatalError("realloc failure in xvpbm.c getint");
+ pinfo->comment = tmpptr;
+ }
+@@ -445,8 +463,8 @@
+ pinfo->comment[0] = '\0';
+ }
+ else {
+- tmpptr = (char *) realloc(pinfo->comment,
+- strlen(pinfo->comment) + strlen(cmt) + 1);
++ tmpptr = (char *) realloc(pinfo->comment,
++ strlen(pinfo->comment) + strlen(cmt) + 1);
+ if (!tmpptr) FatalError("realloc failure in xvpbm.c getint");
+ pinfo->comment = tmpptr;
+ }
+@@ -490,7 +508,7 @@
+ char *comment;
+ {
+ /* writes a PBM/PGM/PPM file to the already open stream
+- if (raw), writes as RAW bytes, otherwise writes as ASCII
++ if (raw), writes as RAW bytes, otherwise writes as ASCII
+ 'colorstyle' single-handedly determines the type of file written
+ if colorstyle==0, (Full Color) a PPM file is written
+ if colorstyle==1, (Greyscale) a PGM file is written
+@@ -546,7 +564,7 @@
+ }
+ }
+ else {
+- if (ptype==PIC8)
++ if (ptype==PIC8)
+ fprintf(fp,"%3d %3d %3d ",rmap[*pix], gmap[*pix], bmap[*pix]);
+ else
+ fprintf(fp,"%3d %3d %3d ",pix[0], pix[1], pix[2]);
+@@ -554,7 +572,7 @@
+ len+=12;
+ if (len>58) { fprintf(fp,"\n"); len=0; }
+ }
+-
++
+ pix += (ptype==PIC24) ? 3 : 1;
+ }
+ }
+@@ -626,10 +644,3 @@
+
+ return 0;
+ }
+-
+-
+-
+-
+-
+-
+-
+diff -ruN xv-3.10a/xvpcx.c xv-3.10a-bugfixes/xvpcx.c
+--- xv-3.10a/xvpcx.c 1995-01-10 15:06:37.000000000 -0800
++++ xv-3.10a-bugfixes/xvpcx.c 2005-03-25 08:10:03.000000000 -0800
+@@ -29,7 +29,7 @@
+ #define PCX_YMAXH 11
+ /* hres (12,13) and vres (14,15) not used */
+ #define PCX_CMAP 16 /* start of 16*3 colormap data */
+-#define PCX_PLANES 65
++#define PCX_PLANES 65
+ #define PCX_BPRL 66
+ #define PCX_BPRH 67
+
+@@ -51,8 +51,8 @@
+ {
+ FILE *fp;
+ long filesize;
+- char *bname, *errstr;
+- byte hdr[128], *image;
++ char *bname;
++ byte hdr[128];
+ int i, colors, gray, fullcolor;
+
+ pinfo->type = PIC8;
+@@ -64,7 +64,7 @@
+ /* open the stream */
+ fp = xv_fopen(fname,"r");
+ if (!fp) return (pcxError(bname, "unable to open file"));
+-
++
+
+ /* figure out the file size */
+ fseek(fp, 0L, 2);
+@@ -84,10 +84,10 @@
+ return pcxError(bname,"unrecognized magic number");
+ }
+
+- pinfo->w = (hdr[PCX_XMAXL] + ((int) hdr[PCX_XMAXH]<<8))
++ pinfo->w = (hdr[PCX_XMAXL] + ((int) hdr[PCX_XMAXH]<<8))
+ - (hdr[PCX_XMINL] + ((int) hdr[PCX_XMINH]<<8));
+
+- pinfo->h = (hdr[PCX_YMAXL] + ((int) hdr[PCX_YMAXH]<<8))
++ pinfo->h = (hdr[PCX_YMAXL] + ((int) hdr[PCX_YMAXH]<<8))
+ - (hdr[PCX_YMINL] + ((int) hdr[PCX_YMINH]<<8));
+
+ pinfo->w++; pinfo->h++;
+@@ -96,10 +96,10 @@
+ fullcolor = (hdr[PCX_BPP] == 8 && hdr[PCX_PLANES] == 3);
+
+ if (DEBUG) {
+- fprintf(stderr,"PCX: %dx%d image, version=%d, encoding=%d\n",
++ fprintf(stderr,"PCX: %dx%d image, version=%d, encoding=%d\n",
+ pinfo->w, pinfo->h, hdr[PCX_VER], hdr[PCX_ENC]);
+ fprintf(stderr," BitsPerPixel=%d, planes=%d, BytePerRow=%d, colors=%d\n",
+- hdr[PCX_BPP], hdr[PCX_PLANES],
++ hdr[PCX_BPP], hdr[PCX_PLANES],
+ hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8),
+ colors);
+ }
+@@ -190,9 +190,9 @@
+
+ if (colors > 2 || (colors==2 && !gray)) { /* grayscale or PseudoColor */
+ pinfo->colType = (gray) ? F_GREYSCALE : F_FULLCOLOR;
+- sprintf(pinfo->fullInfo,
+- "%s PCX, %d plane%s, %d bit%s per pixel. (%ld bytes)",
+- (gray) ? "Greyscale" : "Color",
++ sprintf(pinfo->fullInfo,
++ "%s PCX, %d plane%s, %d bit%s per pixel. (%ld bytes)",
++ (gray) ? "Greyscale" : "Color",
+ hdr[PCX_PLANES], (hdr[PCX_PLANES]==1) ? "" : "s",
+ hdr[PCX_BPP], (hdr[PCX_BPP]==1) ? "" : "s",
+ filesize);
+@@ -218,15 +218,21 @@
+ byte *hdr;
+ {
+ /* load an image with at most 8 bits per pixel */
+-
++
+ byte *image;
+-
++ int count;
++
+ /* note: overallocation to make life easier... */
+- image = (byte *) malloc((size_t) (pinfo->h + 1) * pinfo->w + 16);
++ count = (pinfo->h + 1) * pinfo->w + 16; /* up to 65537*65536+16 (~ 65552) */
++ if (pinfo->w <= 0 || pinfo->h <= 0 || count/pinfo->w < pinfo->h) {
++ pcxError(fname, "Bogus 8-bit PCX file!!");
++ return (0);
++ }
++ image = (byte *) malloc((size_t) count);
+ if (!image) FatalError("Can't alloc 'image' in pcxLoadImage8()");
+-
+- xvbzero((char *) image, (size_t) ((pinfo->h+1) * pinfo->w + 16));
+-
++
++ xvbzero((char *) image, (size_t) count);
++
+ switch (hdr[PCX_BPP]) {
+ case 1: pcxLoadRaster(fp, image, 1, hdr, pinfo->w, pinfo->h); break;
+ case 8: pcxLoadRaster(fp, image, 8, hdr, pinfo->w, pinfo->h); break;
+@@ -249,25 +255,33 @@
+ byte *hdr;
+ {
+ byte *pix, *pic24, scale[256];
+- int c, i, j, w, h, maxv, cnt, planes, bperlin, nbytes;
+-
++ int c, i, j, w, h, maxv, cnt, planes, bperlin, nbytes, count;
++
+ w = pinfo->w; h = pinfo->h;
+-
+- planes = (int) hdr[PCX_PLANES];
+- bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8);
+-
++
++ planes = (int) hdr[PCX_PLANES]; /* 255 max, but can't get here unless = 3 */
++ bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8); /* 65535 max */
++
++ j = h*planes; /* w and h are limited to 65536, planes to 3 */
++ count = w*j; /* ...so this could wrap up to 3 times */
++ nbytes = bperlin*j; /* ...and this almost 3 times */
++ if (w <= 0 || h <= 0 || planes <= 0 || bperlin <= 0 ||
++ j/h < planes || count/w < j || nbytes/bperlin < j) {
++ pcxError(fname, "Bogus 24-bit PCX file!!");
++ return (0);
++ }
++
+ /* allocate 24-bit image */
+- pic24 = (byte *) malloc((size_t) w*h*planes);
+- if (!pic24) FatalError("couldn't malloc 'pic24'");
+-
+- xvbzero((char *) pic24, (size_t) w*h*planes);
+-
++ pic24 = (byte *) malloc((size_t) count);
++ if (!pic24) FatalError("Can't malloc 'pic24' in pcxLoadImage24()");
++
++ xvbzero((char *) pic24, (size_t) count);
++
+ maxv = 0;
+ pix = pinfo->pic = pic24;
+ i = 0; /* planes, in this while loop */
+ j = 0; /* bytes per line, in this while loop */
+- nbytes = bperlin*h*planes;
+-
++
+ while (nbytes > 0 && (c = getc(fp)) != EOF) {
+ if ((c & 0xC0) == 0xC0) { /* have a rep. count */
+ cnt = c & 0x3F;
+@@ -275,9 +289,9 @@
+ if (c == EOF) { getc(fp); break; }
+ }
+ else cnt = 1;
+-
++
+ if (c > maxv) maxv = c;
+-
++
+ while (cnt-- > 0) {
+ if (j < w) {
+ *pix = c;
+@@ -297,19 +311,19 @@
+ }
+ }
+ }
+-
+-
++
++
+ /* scale all RGB to range 0-255, if they aren't */
+
+- if (maxv<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*planes; j++, pix++) *pix = scale[*pix];
+ }
+ }
+-
++
+ return 1;
+ }
+
+@@ -321,13 +335,13 @@
+ byte *image, *hdr;
+ int depth,w,h;
+ {
+- /* supported: 8 bits per pixel, 1 plane, or 1 bit per pixel, 1-8 planes */
++ /* supported: 8 bits per pixel, 1 plane; or 1 bit per pixel, 1-8 planes */
+
+ int row, bcnt, bperlin, pad;
+ int i, j, b, cnt, mask, plane, pmask;
+ byte *oldimage;
+
+- bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8);
++ bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8); /* 65535 max */
+ if (depth == 1) pad = (bperlin * 8) - w;
+ else pad = bperlin - w;
+
+@@ -342,7 +356,7 @@
+ if (b == EOF) { getc(fp); return; }
+ }
+ else cnt = 1;
+-
++
+ for (i=0; i<cnt; i++) {
+ if (depth == 1) {
+ for (j=0, mask=0x80; j<8; j++) {
+@@ -351,12 +365,12 @@
+ }
+ }
+ else *image++ = (byte) b;
+-
++
+ bcnt++;
+-
++
+ if (bcnt == bperlin) { /* end of a line reached */
+ bcnt = 0;
+- plane++;
++ plane++;
+
+ if (plane >= (int) hdr[PCX_PLANES]) { /* moved to next row */
+ plane = 0;
+@@ -367,13 +381,13 @@
+ }
+ else { /* next plane, same row */
+ image = oldimage;
+- }
++ }
+
+ pmask = 1 << plane;
+ }
+ }
+ }
+-}
++}
+
+
+
+diff -ruN xv-3.10a/xvpds.c xv-3.10a-bugfixes/xvpds.c
+--- xv-3.10a/xvpds.c 1995-01-03 13:25:52.000000000 -0800
++++ xv-3.10a-bugfixes/xvpds.c 2005-04-03 11:31:30.000000000 -0700
+@@ -22,23 +22,23 @@
+ Choice of algorithm for 16->8 bit conversion--linear or histogram stretch.
+ (adds CONV24_HIST item in "24/8 bit" pull-down menu.)
+ Uses any "palette.tab" file in cwd to color PDS/VICAR image.
+-
++
+ * 9-2-91 began integration. Much of this code is lifted from vicar.c,
+ which I wrote for xloadimage. This is a little simpler, though.
+-
++
+ * 10-17-91 pdsuncomp is called with system(), which typically feeds the
+ commandline to sh. Make sure that your .profile adds wherever
+ you have pdsuncomp to the PATH, like
+-
++
+ PATH=$PATH:/usr/local/bin
+-
++
+ * 11-15-91 substituted vdcomp from Viking CD's for pdsuncomp. I added
+ recognition of - and shut off various messages
+-
++
+ * 1-5-92 merged into xv rel 2
+-
++
+ * 3-11-92 cleaned up some comments
+-
++
+ * 3-24-92 Got some new CD's from NASA of mosics and other processed Viking
+ stuff. There are actually records terminated with CRNLCR in
+ these images, as well as ones that identify the spacecraft name
+@@ -46,14 +46,14 @@
+ yet further to deal with these. There's a Sun 4 XView binary for
+ an image display program on these discs, but it's nowhere near as
+ neat as the good Mr. Bradley's XV.
+-
+-
++
++
+ * Sources of these CD's:
+ *
+ * National Space Science Data Center
+ * Goddard Space Flight Center
+ * Code 933.4
+- * Greenbelt, Maryland
++ * Greenbelt, Maryland
+ * (301) 286-6695
+ * or call
+ * (301) 286-9000 (300,1200,2400 bps)
+@@ -91,10 +91,10 @@
+ * Copyright 1989, 1990 by Anthony A. Datri
+ *
+ * Permission to use, copy, and distribute for non-commercial purposes,
+- * is hereby granted without fee, providing that the above copyright
++ * is hereby granted without fee, providing that the above copyright
+ * notice appear in all copies, that both the copyright notice and this
+ * permission notice appear in supporting documentation.
+- *
++ *
+ * In exception to the above, permission to John Bradley is hereby granted to
+ * distribute this code as he sees fit within the context of his "xv" image
+ * viewer.
+@@ -132,8 +132,8 @@
+
+
+ static int lastwasinote = FALSE;
+-static char scanbuff [MAX_SIZE],
+- rtbuff [RTBUFFSIZE],
++static char scanbuff [MAX_SIZE],
++ rtbuff [RTBUFFSIZE],
+ inote [20*COMMENTSIZE],
+ infobuff [COMMENTSIZE],
+ spacecraft [COMMENTSIZE],
+@@ -203,10 +203,10 @@
+ }
+ return(count);
+
+- case EOF: *bp='\0'; return(count);
+-
++ case EOF: *bp='\0'; return(count);
++
+ case '\0': return(count);
+-
++
+ default: count++; *bp++ = c;
+ }
+ }
+@@ -242,7 +242,7 @@
+ * disc seem to leave off the first two bytes. Sigh. This may sometimes be
+ * a distinction between the fixed and variable-record files.
+ */
+-
++
+ /*******************************************/
+ int LoadPDS(fname, pinfo)
+ char *fname;
+@@ -250,11 +250,11 @@
+ {
+ /* returns '1' on success, '0' on failure */
+
+- int tempnum;
++ int tempnum, bytewidth, bufsize;
+ FILE *zf;
+ static int isfixed,teco,i,j,itype,vaxbyte,
+ recsize,hrecsize,irecsize,isimage,labelrecs,labelsofar,
+- x,y,lpsize,lssize,samplesize,returnp,labelsize,yy;
++ w,h,lpsize,lssize,samplesize,returnp,labelsize,yy;
+ char *tmp;
+ char *ftypstr;
+ unsigned long filesize;
+@@ -265,7 +265,7 @@
+ returnp = isimage = FALSE;
+ itype = PDSTRASH;
+
+- teco = i = j = recsize = hrecsize = irecsize = labelrecs = x = y = 0;
++ teco = i = j = recsize = hrecsize = irecsize = labelrecs = w = h = 0;
+ lpsize = lssize = samplesize = labelsize = labelsofar = 0;
+
+ (*pdsuncompfname) = (*iname) = (*target) = (*filtname) = (*garbage) = '\0';
+@@ -363,7 +363,7 @@
+ * length indicator. If the length indicator is odd, then a pad byte
+ * is appended to the end of the record so that all records contain
+ * an even number of bytes." */
+-
++
+ i=getc(zf);
+ j=getc(zf);
+ if (j == EOF) {
+@@ -371,7 +371,7 @@
+ fclose(zf);
+ return 0;
+ }
+-
++
+ teco = i + (j << 8);
+ if (teco % 2) teco++;
+
+@@ -380,7 +380,7 @@
+ fclose(zf);
+ return 0;
+ }
+-
++
+ scanbuff[teco]='\0';
+ }
+
+@@ -429,11 +429,11 @@
+ (sscanf(scanbuff," LABEL_RECORDS = %d", &labelrecs) == 1)) {
+ lastwasinote=FALSE;
+ continue;
+- } else if (sscanf(scanbuff," IMAGE_LINES = %d",&y) == 1) {
++ } else if (sscanf(scanbuff," IMAGE_LINES = %d",&h) == 1) {
+ isimage=TRUE; lastwasinote=FALSE; continue;
+- } else if (sscanf(scanbuff," LINE_SAMPLES = %d",&x) == 1) {
++ } else if (sscanf(scanbuff," LINE_SAMPLES = %d",&w) == 1) {
+ lastwasinote=FALSE; continue;
+- } else if (sscanf(scanbuff," LINES = %d",&y) == 1) {
++ } else if (sscanf(scanbuff," LINES = %d",&h) == 1) {
+ isimage=TRUE; lastwasinote=FALSE; continue;
+ } else if (sscanf(scanbuff," HEADER_RECORD_BYTES = %d",&hrecsize)==1) {
+ lastwasinote=FALSE; continue;
+@@ -472,7 +472,7 @@
+
+ } else if (sscanf(scanbuff," INSTRUMENT_GAIN_STATE = %s",gainmode)==1) {
+ lastwasinote=FALSE; continue;
+-
++
+ } else if (sscanf(scanbuff," EDIT_MODE_ID = %s", editmode) == 1) {
+ lastwasinote=FALSE; continue;
+
+@@ -531,11 +531,11 @@
+ * get my hands on the clown who designed this format...
+ * What we basically assume here
+ * is that a NOTE record that doesn't end with a " is
+- * followed by some number of continuations, one of which
++ * followed by some number of continuations, one of which
+ * will have a " in it. If this turns out to not be true,
+ * well, we'll segmentation fault real soon. We use
+ * lastwasinote as a semaphore to indicate that the previous
+- * record was an unfinished NOTE record. We clear the
++ * record was an unfinished NOTE record. We clear the
+ * flag in each of the above record types for potential
+ * error recovery, although it really breaks up the beauty
+ * of the cascading sscanfs. Dykstra'd love me for this one */
+@@ -568,10 +568,10 @@
+ fclose(zf);
+ return 0;
+ }
+-
++
+ vaxbyte = strncmp(sampletype, "VAX_", (size_t) 4) == 0 ||
+ strncmp(sampletype, "LSB_", (size_t) 4) == 0;
+-
++
+ } else if (itype == VICAR) {
+ /* we've got a VICAR file. Let's find out how big the puppy is */
+ ungetc(' ', zf);
+@@ -582,8 +582,8 @@
+ SetISTR(ISTR_WARNING,"LoadPDS: bad NL in VICAR\n");
+ returnp=TRUE;
+ }
+-
+- if (sscanf(tmp," NL = %d",&y) != 1) {
++
++ if (sscanf(tmp," NL = %d",&h) != 1) {
+ SetISTR(ISTR_WARNING,"LoadPDS: bad scan NL in VICAR\n");
+ returnp=TRUE;
+ }
+@@ -593,7 +593,7 @@
+ returnp=TRUE;
+ }
+
+- if (sscanf(tmp, " NS = %d",&x) != 1) {
++ if (sscanf(tmp, " NS = %d",&w) != 1) {
+ SetISTR(ISTR_WARNING,"LoadPDS: bad scan NS in VICAR\n");
+ returnp=TRUE;
+ }
+@@ -625,6 +625,13 @@
+ returnp=TRUE;
+ }
+
++ /* samplesize can be arbitrarily large (up to int limit) in non-VICAR files */
++ if (samplesize != 8 && samplesize != 16) {
++ SetISTR(ISTR_WARNING,"LoadPDS: %d bits per pixel not supported",
++ samplesize);
++ returnp=TRUE;
++ }
++
+ if (returnp) {
+ fclose(zf);
+ return 0;
+@@ -689,11 +696,19 @@
+
+ #ifndef VMS
+ sprintf(pdsuncompfname,"%s/xvhuffXXXXXX", tmpdir);
+- mktemp(pdsuncompfname);
+- sprintf(scanbuff,"%s %s - 4 >%s",PDSUNCOMP,fname,pdsuncompfname);
+ #else
+ strcpy(pdsuncompfname,"sys$disk:[]xvhuffXXXXXX");
++#endif
++
++#ifdef USE_MKSTEMP
++ close(mkstemp(pdsuncompfname));
++#else
+ mktemp(pdsuncompfname);
++#endif
++
++#ifndef VMS
++ sprintf(scanbuff,"%s %s - 4 >%s",PDSUNCOMP,fname,pdsuncompfname);
++#else
+ sprintf(scanbuff,"%s %s %s 4",PDSUNCOMP,fname,pdsuncompfname);
+ #endif
+
+@@ -727,63 +742,72 @@
+ fread(scanbuff, (size_t) labelsize, (size_t) 1, zf);
+ }
+
+- x *= samplesize/8;
++ /* samplesize is bits per pixel; guaranteed at this point to be 8 or 16 */
++ bytewidth = w * (samplesize/8);
++ bufsize = bytewidth * h;
++ if (w <= 0 || h <= 0 || bytewidth/w != (samplesize/8) ||
++ bufsize/bytewidth != h)
++ {
++ SetISTR(ISTR_WARNING,"LoadPDS: image dimensions out of range (%dx%dx%d)",
++ w, h, samplesize/8);
++ fclose(zf);
++ return 0;
++ }
+
+- image = (byte *) malloc((size_t) x*y);
++ image = (byte *) malloc((size_t) bufsize);
+ if (image == NULL) {
+- SetISTR(ISTR_WARNING,"LoadPDS: couldn't malloc %d",x*y);
+ fclose(zf);
+ if (isfixed == FALSE)
+ unlink(pdsuncompfname);
+- exit(1);
++ FatalError("LoadPDS: can't malloc image buffer");
+ }
+
+ if ((lssize || lpsize) &&
+ ((itype == PDSFIXED) || (itype == VIKINGFIXED) || (itype == VICAR)) ) {
+ /* ARrrrgh. Some of these images have crud intermixed with the image, */
+ /* preventing us from freading in one fell swoop */
+- /* (whatever a fell swoop is */
++ /* (whatever a fell swoop is) */
+
+- for (yy=0; yy<y; yy++) {
+- if (lpsize &&
+- ((teco=(fread(scanbuff,(size_t) lpsize,(size_t) 1,zf))) != 1)) {
++ for (yy=0; yy<h; yy++) {
++ if (lpsize &&
++ (teco=fread(scanbuff,(size_t) lpsize,(size_t) 1,zf)) != 1) {
+ SetISTR(ISTR_WARNING, "LoadPDS: unexpected EOF reading prefix");
+ fclose(zf);
+ return 0;
+ }
+-
+- if ((teco=(fread(image+(yy*x), (size_t) x, (size_t) 1,zf))) != 1) {
++
++ teco = fread(image+(yy*bytewidth), (size_t) bytewidth, (size_t) 1,zf);
++ if (teco != 1) {
+ SetISTR(ISTR_WARNING, "LoadPDS: unexpected EOF reading line %d",yy);
+ fclose(zf);
+ return 0;
+ }
+
+- if (lssize &&
+- ((teco=(fread(scanbuff,(size_t) lssize,(size_t) 1,zf))) != 1)) {
++ if (lssize &&
++ (teco=fread(scanbuff,(size_t) lssize,(size_t) 1,zf)) != 1) {
+ SetISTR(ISTR_WARNING, "LoadPDS: unexpected EOF reading suffix");
+ fclose(zf);
+ return 0;
+ }
+ }
+
+- } else if ((yy=fread(image, (size_t) x*y, (size_t) 1, zf)) != 1) {
++ } else if ((yy=fread(image, (size_t) bytewidth*h, (size_t) 1, zf)) != 1) {
+ SetISTR(ISTR_WARNING,"LoadPDS: error reading image data");
+ fclose(zf);
+ if (itype==PDSVARIABLE || itype==VIKINGVARIABLE)
+ unlink(pdsuncompfname);
+-
+ return 0;
+ }
+
+- fclose(zf);
++ fclose(zf);
+
+
+ if (isfixed == FALSE)
+ unlink(pdsuncompfname);
+
+ pinfo->pic = image;
+- pinfo->w = x;
+- pinfo->h = y;
++ pinfo->w = w; /* true pixel-width now (no longer bytewidth!) */
++ pinfo->h = h;
+
+ if (samplesize == 16)
+ if (Convert16BitImage(fname, pinfo,
+@@ -798,25 +822,25 @@
+ if (pinfo->comment) {
+ char tmp[256];
+ *(pinfo->comment) = '\0';
+-
++
+ sprintf(tmp, "Spacecraft: %-28sTarget: %-32s\n", spacecraft, target);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Filter: %-32sMission phase: %-24s\n", filtname, mphase);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Image time: %-28sGain mode: %-29s\n", itime, gainmode);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Edit mode: %-29sScan mode: %-29s\n", editmode, scanmode);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Exposure: %-30sShutter mode: %-25s\n", exposure,shuttermode);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Instrument: %-28sImage time: %-28s\n", iname, itime);
+ strcat(pinfo->comment, tmp);
+-
++
+ sprintf(tmp, "Image Note: %-28s", inote);
+ strcat(pinfo->comment, tmp);
+ }
+@@ -868,23 +892,20 @@
+ m = 65536 * sizeof(byte);
+ lut = (byte *) malloc(m);
+ if (lut == NULL) {
+- SetISTR(ISTR_WARNING,"LoadPDS: couldn't malloc %d", m);
+- return 0;
++ FatalError("LoadPDS: can't malloc LUT buffer");
+ }
+- pinfo->w /= 2;
+
+ /* allocate histogram table */
+ m = 65536 * sizeof(long);
+ hist = (long *) malloc(m);
+ if (hist == NULL) {
+- SetISTR(ISTR_WARNING,"LoadPDS: couldn't malloc %d", m);
+ free(lut);
+- return 0;
++ FatalError("LoadPDS: can't malloc histogram buffer");
+ }
+
+ /* check whether histogram file exists */
+ #ifdef VMS
+- c = (char *) rindex(strcpy(name,
++ c = (char *) rindex(strcpy(name,
+ (c = (char *) rindex(fname, ':')) ? c+1 : fname),
+ ']');
+ #else
+@@ -947,14 +968,20 @@
+ }
+ }
+
+- /* allocate new 8-bit image */
+ free(hist);
++
++ /* allocate new 8-bit image */
+ n = pinfo->w * pinfo->h;
++ if (pinfo->w <= 0 || pinfo->h <= 0 || n/pinfo->w != pinfo->h) {
++ SetISTR(ISTR_WARNING,"LoadPDS: image dimensions out of range (%dx%d)",
++ pinfo->w, pinfo->h);
++ free(lut);
++ return 0;
++ }
+ pPix8 = (byte *)malloc(n*sizeof(byte));
+ if (pPix8 == NULL) {
+- SetISTR(ISTR_WARNING,"LoadPDS: couldn't malloc %d", n*sizeof(byte));
+ free(lut);
+- return 0;
++ FatalError("LoadPDS: can't malloc 16-to-8-bit conversion buffer");
+ }
+
+ /* convert the 16-bit image to 8-bit */
+@@ -979,16 +1006,16 @@
+ FILE *fp;
+ char name[1024], buf[256], *c;
+ int i, n, r, g, b;
+-
++
+ #ifdef VMS
+- c = (char *) rindex(strcpy(name,
++ c = (char *) rindex(strcpy(name,
+ (c = (char *) rindex(fname, ':')) ? c+1 : fname),
+ ']');
+ #else
+ c = (char *) rindex(strcpy(name, fname), '/');
+ #endif /* VMS */
+ (void)strcpy(c ? c+1 : name, "palette.tab");
+-
++
+ if ((fp = xv_fopen(name, "r")) == NULL)
+ return 0;
+ for (i = 0; i < 256; i++) {
+@@ -1014,7 +1041,3 @@
+
+
+ #endif /* HAVE_PDS */
+-
+-
+-
+-
+diff -ruN xv-3.10a/xvpictoppm.c xv-3.10a-bugfixes/xvpictoppm.c
+--- xv-3.10a/xvpictoppm.c 1995-01-13 11:57:14.000000000 -0800
++++ xv-3.10a-bugfixes/xvpictoppm.c 2005-04-10 09:36:04.000000000 -0700
+@@ -77,7 +77,7 @@
+ FILE *fp;
+ byte *icon8, *pic24, *ip, *pp;
+ char buf[256];
+- int i, builtin, w, h, mv;
++ int i, builtin, w, h, maxval, npixels, p24sz;
+
+ fp = stdin;
+ builtin = 0;
+@@ -88,42 +88,45 @@
+ /* read comments until we see '#END_OF_COMMENTS', or hit EOF */
+ while (1) {
+ if (!fgets(buf, 256, fp)) errexit();
+-
++
+ if (!strncmp(buf, "#END_OF_COMMENTS", (size_t) 16)) break;
+
+ else if (!strncmp(buf, "#BUILTIN:", (size_t) 9)) {
+ builtin = 1;
+- fprintf(stderr,"Built-In icon: no image to convert!\n");
++ fprintf(stderr, "Built-in icon: no image to convert\n");
+ exit(1);
+ }
+ }
+
+
+ /* read width, height, maxval */
+- if (!fgets(buf, 256, fp) || sscanf(buf, "%d %d %d", &w, &h, &mv) != 3)
++ if (!fgets(buf, 256, fp) || sscanf(buf, "%d %d %d", &w, &h, &maxval) != 3)
+ errexit();
+
++ npixels = w * h;
++ p24sz = 3 * npixels;
+
+- if (w<1 || h<1 || mv != 255) {
+- fprintf(stderr,"Bogus thumbnail file!\n");
++ if (w <= 0 || h <= 0 || maxval != 255 || npixels/w != h || p24sz/3 != npixels)
++ {
++ fprintf(stderr, "Thumbnail dimensions out of range\n");
+ exit(1);
+ }
+
+
+ /* read binary data */
+- icon8 = (byte *) malloc((size_t) w * h);
++ icon8 = (byte *) malloc((size_t) npixels);
+ if (!icon8) errexit();
+
+- i = fread(icon8, (size_t) 1, (size_t) w*h, fp);
+- if (i != w*h) errexit();
++ i = fread(icon8, (size_t) 1, (size_t) npixels, fp);
++ if (i != npixels) errexit();
++
+
+-
+ /* make 24-bit version of icon */
+- pic24 = (byte *) malloc((size_t) w * h * 3);
++ pic24 = (byte *) malloc((size_t) p24sz);
+ if (!pic24) errexit();
+
+ /* convert icon from 332 to 24-bit image */
+- for (i=0, ip=icon8, pp=pic24; i<w*h; i++, ip++, pp+=3) {
++ for (i=0, ip=icon8, pp=pic24; i<npixels; i++, ip++, pp+=3) {
+ pp[0] = ( ((int) ((*ip >> 5) & 0x07)) * 255) / 7;
+ pp[1] = ( ((int) ((*ip >> 2) & 0x07)) * 255) / 7;
+ pp[2] = ( ((int) ((*ip >> 0) & 0x03)) * 255) / 3;
+@@ -160,10 +163,3 @@
+
+ if (ferror(fp)) errexit();
+ }
+-
+-
+-
+-
+-
+-
+-
+diff -ruN xv-3.10a/xvpm.c xv-3.10a-bugfixes/xvpm.c
+--- xv-3.10a/xvpm.c 1994-12-22 14:34:40.000000000 -0800
++++ xv-3.10a-bugfixes/xvpm.c 2005-03-29 08:30:12.000000000 -0800
+@@ -60,7 +60,7 @@
+
+ FILE *fp;
+ byte *pic8;
+- int isize,i,flipit,w,h;
++ int isize,i,flipit,w,h,npixels,nRGBbytes;
+ char *bname;
+
+ bname = BaseName(fname);
+@@ -103,10 +103,11 @@
+ thePic.pm_cmtsize = flip4(thePic.pm_cmtsize);
+ }
+
+- w = thePic.pm_ncol; h = thePic.pm_nrow;
++ w = thePic.pm_ncol;
++ h = thePic.pm_nrow;
+
+ /* make sure that the input picture can be dealt with */
+- if ( thePic.pm_nband!=1 ||
++ if ( thePic.pm_nband!=1 ||
+ (thePic.pm_form!=PM_I && thePic.pm_form!=PM_C) ||
+ (thePic.pm_form==PM_I && thePic.pm_np>1) ||
+ (thePic.pm_form==PM_C && (thePic.pm_np==2 || thePic.pm_np>4)) ) {
+@@ -114,20 +115,27 @@
+ fprintf(stderr,"(ie, 1-plane PM_I, or 1-, 3-, or 4-plane PM_C)\n");
+
+ return pmError(bname, "PM file in unsupported format");
+- }
++ }
+
+
+ isize = pm_isize(&thePic);
++ npixels = w*h;
++ nRGBbytes = 3*npixels;
++
++ /* make sure image is more-or-less valid (and no overflows) */
++ if (isize <= 0 || w <= 0 || h <= 0 || npixels/w < h ||
++ nRGBbytes/3 < npixels || thePic.pm_cmtsize < 0)
++ return pmError(bname, "Bogus PM file!!");
+
+- if (DEBUG)
++ if (DEBUG)
+ fprintf(stderr,"%s: LoadPM() - loading a %dx%d %s pic, %d planes\n",
+- cmd, w, h, (thePic.pm_form==PM_I) ? "PM_I" : "PM_C",
++ cmd, w, h, (thePic.pm_form==PM_I) ? "PM_I" : "PM_C",
+ thePic.pm_np);
+
+-
++
+ /* allocate memory for picture and read it in */
+ thePic.pm_image = (char *) malloc((size_t) isize);
+- if (thePic.pm_image == NULL)
++ if (thePic.pm_image == NULL)
+ return( pmError(bname, "unable to malloc PM picture") );
+
+ if (fread(thePic.pm_image, (size_t) isize, (size_t) 1, fp) != 1) {
+@@ -147,7 +155,7 @@
+ }
+ }
+ }
+-
++
+ fclose(fp);
+
+
+@@ -155,11 +163,11 @@
+ int *intptr;
+ byte *pic24, *picptr;
+
+- if ((pic24 = (byte *) malloc((size_t) w*h*3))==NULL) {
++ if ((pic24 = (byte *) malloc((size_t) nRGBbytes))==NULL) {
+ if (thePic.pm_cmt) free(thePic.pm_cmt);
+ return( pmError(bname, "unable to malloc 24-bit picture") );
+ }
+-
++
+ intptr = (int *) thePic.pm_image;
+ picptr = pic24;
+
+@@ -190,7 +198,7 @@
+ else if (thePic.pm_form == PM_C && thePic.pm_np>1) {
+ byte *pic24, *picptr, *rptr, *gptr, *bptr;
+
+- if ((pic24 = (byte *) malloc((size_t) w*h*3))==NULL) {
++ if ((pic24 = (byte *) malloc((size_t) nRGBbytes))==NULL) {
+ if (thePic.pm_cmt) free(thePic.pm_cmt);
+ return( pmError(bname, "unable to malloc 24-bit picture") );
+ }
+@@ -210,12 +218,12 @@
+ pinfo->pic = pic24;
+ pinfo->type = PIC24;
+ }
+-
++
+
+ else if (thePic.pm_form == PM_C && thePic.pm_np==1) {
+ /* don't have to convert, just point pic at thePic.pm_image */
+ pic8 = (byte *) thePic.pm_image;
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i; /* build mono cmap */
+
+ pinfo->pic = pic8;
+@@ -228,10 +236,10 @@
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+
+ pinfo->frmType = F_PM;
+- pinfo->colType = (thePic.pm_form==PM_I || thePic.pm_np>1)
++ pinfo->colType = (thePic.pm_form==PM_I || thePic.pm_np>1)
+ ? F_FULLCOLOR : F_GREYSCALE;
+- sprintf(pinfo->fullInfo,"PM, %s. (%d plane %s) (%ld bytes)",
+- (thePic.pm_form==PM_I || thePic.pm_np>1)
++ sprintf(pinfo->fullInfo,"PM, %s. (%d plane %s) (%d bytes)",
++ (thePic.pm_form==PM_I || thePic.pm_np>1)
+ ? "24-bit color" : "8-bit greyscale",
+ thePic.pm_np, (thePic.pm_form==PM_I) ? "PM_I" : "PM_C",
+ isize + PM_IOHDR_SIZE + thePic.pm_cmtsize);
+@@ -313,7 +321,7 @@
+
+ else if (colorstyle == 1) { /* GreyScale: 8 bits per pixel */
+ byte rgb[256];
+-
++
+ if (ptype == PIC8) {
+ for (i=0; i<numcols; i++) rgb[i] = MONO(rmap[i],gmap[i],bmap[i]);
+ for (i=0, p=pic; i<w*h; i++, p++) {
+diff -ruN xv-3.10a/xvpopup.c xv-3.10a-bugfixes/xvpopup.c
+--- xv-3.10a/xvpopup.c 1995-01-19 10:09:31.000000000 -0800
++++ xv-3.10a-bugfixes/xvpopup.c 2004-05-16 18:04:13.000000000 -0700
+@@ -1,5 +1,5 @@
+-/*
+- * xvpopup.c - popup "Are you sure? Yes/No/Maybe" sort of dialog box
++/*
++ * xvpopup.c - pop up "Are you sure? Yes/No/Maybe" sort of dialog box
+ *
+ * callable functions:
+ *
+@@ -20,7 +20,8 @@
+
+ #include "xv.h"
+
+-#include "bits/icon"
++#define OMIT_ICON_BITS
++#include "bits/icon" /* icon_bits[] not used, but icon_width/height are */
+
+ #define PUWIDE 400
+ #define PUHIGH 170
+@@ -86,8 +87,8 @@
+ static char *padMthdNames[] = { "Solid Fill", "Run 'bggen'", "Load Image" };
+
+ static int padColDefLen = 9;
+-static char *padColDefNames[] = { "black", "red", "yellow", "green",
+- "cyan", "blue", "magenta", "white",
++static char *padColDefNames[] = { "black", "red", "yellow", "green",
++ "cyan", "blue", "magenta", "white",
+ "50% gray" };
+
+ static char *padColDefVals[] = { "black", "red", "yellow", "green",
+@@ -105,8 +106,8 @@
+ "Red Balls",
+ "Red+Yellow Diamonds" };
+
+-static char *padBgDefVals[] = {
+- "black white",
++static char *padBgDefVals[] = {
++ "black white",
+ "100 100 255 50 50 150",
+ "red green blue",
+ "black red yellow green blue purple black",
+@@ -150,11 +151,11 @@
+ if (wy + h > dispHIGH) wy = dispHIGH - h;
+ }
+
+-
++
+ if (winCtrPosKludge) {
+ wx -= (p_offx + ch_offx);
+ wy -= (p_offy + ch_offy);
+- }
++ }
+ else {
+ wx -= (ch_offx);
+ wy -= (ch_offy);
+@@ -197,7 +198,7 @@
+ /* attach controls to popW, now that it exists */
+ if (poptyp==ISGRAB) ahideCB.win = popW;
+ else if (poptyp == ISPAD) {
+-
++
+ if (!padHaveDooDads) {
+ DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100,
+ 1, 2048, pWIDE, 10,
+@@ -230,8 +231,8 @@
+ XMapWindow(theDisp, padWDial.win);
+ XMapWindow(theDisp, padHDial.win);
+ XMapWindow(theDisp, padODial.win);
+- }
+-
++ }
++
+
+ XResizeWindow(theDisp, popW, (u_int) puwide, (u_int) puhigh);
+ XStoreName (theDisp, popW, wname);
+@@ -257,9 +258,9 @@
+ }
+ else if (poptyp == ISPAD) {
+ BTSetActive(&bts[0], (int) strlen(gsBuf));
+- i = pWIDE * 3; RANGE(i,2048,9999);
++ i = pWIDE * 3; RANGE(i,2048,9999);
+ DSetRange(&padWDial, 1, i, padWDial.val, 10);
+- i = pHIGH * 3; RANGE(i,2048,9999);
++ i = pHIGH * 3; RANGE(i,2048,9999);
+ DSetRange(&padHDial, 1, i, padHDial.val, 10);
+
+ DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */
+@@ -283,14 +284,14 @@
+ }
+ }
+
+- /* center first button in window around mouse position, with constraint that
++ /* 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;
+
+ /* MUST wait for VisibilityNotify event to come in, else we run the risk
+- of UnMapping the window *before* the Map request completed. This
++ 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... */
+
+@@ -338,10 +339,10 @@
+ button labels have 1-character accellerators at the front, same
+ as in PopUp(). Note that it would be suboptimal to make any
+ of the 1-character accellerators be the same character as one of
+- the edit-text command keys
++ the edit-text command keys
+
+ Also note that the filter string should only contain normal printable
+- characters (' ' through '\177'), as ctrl chars are pre-filtered
++ characters (' ' through '\177'), as ctrl chars are pre-filtered
+ (ie, interpreted as emacs-like commands) */
+
+ gsBuf = buf; gsBufLen = buflen;
+@@ -358,7 +359,7 @@
+ gsy = PUHIGH - 10 - BUTTH - 10 - gsh - 20;
+
+ gsw = PUWIDE - gsx - 10;
+-
++
+ changedGSBuf(); /* careful! popW doesn't exist yet! */
+
+ return doPopUp(txt, labels, n, ISGETSTR, "xv prompt");
+@@ -390,7 +391,7 @@
+ changedGSBuf(); /* careful! popW doesn't exist yet! */
+
+ /* window value gets filled in in doPopUp() */
+- CBCreate(&ahideCB, (Window) NULL,
++ CBCreate(&ahideCB, (Window) NULL,
+ PUWIDE-10-18-StringWidth(HIDESTR),
+ gsy+2, HIDESTR, infofg, infobg, hicol, locol);
+ ahideCB.val = *pHide;
+@@ -464,8 +465,8 @@
+
+ changedGSBuf(); /* careful! popW doesn't exist yet! */
+
+- if (padHaveDooDads) {
+- oldW = padWDial.val;
++ if (padHaveDooDads) {
++ oldW = padWDial.val;
+ oldH = padHDial.val;
+ oldO = padODial.val;
+ }
+@@ -496,8 +497,8 @@
+ XUnmapWindow(theDisp, padODial.win);
+
+ /* load up return values */
+- *pMode = padMode;
+- *pStr = padBuf;
++ *pMode = padMode;
++ *pStr = padBuf;
+ *pWide = padWDial.val;
+ *pHigh = padHDial.val;
+ *pOpaque = padODial.val;
+@@ -513,8 +514,6 @@
+ /* generates padCol* and padBg* lists used in 'Defaults' MBUTT. Grabs
+ all the X resources values it can, and adds appropriate defaults */
+
+- int i;
+-
+ rd_str_cl("foo", "", 1); /* rebuild database */
+
+ build1PadList("color", padColVals, padColNames, &padColLen,
+@@ -526,15 +525,15 @@
+ build1PadList("load", padLoadVals, padLoadNames, &padLoadLen,
+ (char **) NULL, (char **) NULL, 0);
+ }
+-
+-
++
++
+ /***************************************************/
+ static void build1PadList(typstr, vals, nams, lenp, dvals, dnams, dlen)
+ char *typstr, **vals, **nams, **dvals, **dnams;
+ int *lenp, dlen;
+ {
+ int i;
+- char resname[128], name[256], value[256];
++ char resname[128];
+
+ for (i=0; i<*lenp; i++) { /* kill old lists */
+ free(nams[i]);
+@@ -548,7 +547,7 @@
+ vals[*lenp] = (char *) malloc(strlen(def_str)+1);
+ if (!vals[*lenp]) continue;
+ strcpy(vals[*lenp], def_str);
+-
++
+ sprintf(resname, "pad.%s.name%d", typstr, i);
+ if (rd_str_cl(resname, "Dialog.Menu.Slot",0)) { /* and it has a name! */
+ nams[*lenp] = (char *) malloc(strlen(def_str)+1);
+@@ -560,13 +559,14 @@
+ nams[*lenp] = (char *) malloc((size_t) 32);
+ if (!nams[*lenp]) { free(vals[*lenp]); continue; }
+ strncpy(nams[*lenp], vals[*lenp], (size_t) 31);
++ nams[*lenp][31] = '\0';
+ }
+-
++
+ if (strlen(nams[*lenp]) > (size_t) 20) { /* fix long names */
+ char *sp = nams[*lenp] + 18;
+ *sp++ = '.'; *sp++ = '.'; *sp++ = '.'; *sp++ = '\0';
+ }
+-
++
+ *lenp = (*lenp) + 1;
+ }
+ }
+@@ -583,7 +583,7 @@
+ strcpy(nams[*lenp], dnams[i]);
+ *lenp = (*lenp) + 1;
+ }
+-}
++}
+
+
+
+@@ -605,7 +605,7 @@
+ void OpenAlert(txt)
+ char *txt;
+ {
+- /* pops up a window with txt displayed in it (*no buttons*).
++ /* pops up a window with txt displayed in it (*no buttons*).
+ returns immediately. window is closed by 'CloseAlert()'.
+ No 'PopUp()' calls are allowed while an Alert is displayed. */
+
+@@ -624,14 +624,14 @@
+ puwide = PUWIDE; puhigh = PUHIGH;
+ XResizeWindow(theDisp, popW, (u_int) puwide, (u_int) puhigh);
+
+- /* center last button in window around mouse position, with constraint that
++ /* center last button in window around mouse position, with constraint that
+ window be fully on the screen */
+
+ CenterMapWindow(popW, puwide/2, puhigh/2, puwide, puhigh);
+ popUp = ISALERT;
+
+ /* MUST wait for VisibilityNotify event to come in, else we run the risk
+- of UnMapping the window *before* the Map request completed. This
++ 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... */
+
+@@ -695,7 +695,7 @@
+ XKeyEvent *e = (XKeyEvent *) xev;
+ char buf[128]; KeySym ks;
+ int stlen, i, shift, ck;
+-
++
+ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
+ shift = e->state & ShiftMask;
+ ck = CursorKey(ks, shift, 0);
+@@ -725,7 +725,7 @@
+ rv = 1;
+ }
+
+- if (!rv && (popUp==ISGETSTR || popUp==ISGRAB || popUp==ISPAD)) {
++ if (!rv && (popUp==ISGETSTR || popUp==ISGRAB || popUp==ISPAD)) {
+ if (e->window == popW) { doGetStrKey(buf[0]); rv = 1; }
+ }
+ }
+@@ -775,10 +775,10 @@
+ int i, inbreak, lineno, top, hardcr, maxln, len[TR_MAXLN];
+
+ XSetForeground(theDisp, theGC, fg);
+-
++
+ sp = txt; lineno = hardcr = 0;
+
+- maxln = h / LINEHIGH;
++ maxln = h / LINEHIGH;
+ RANGE(maxln,0,TR_MAXLN);
+ while (*sp && lineno<maxln) {
+
+@@ -797,7 +797,7 @@
+ while (XTextWidth(mfinfo, sp, (int)(ep-sp))<= w && *ep && *ep!='\n') ep++;
+ if (*ep=='\n') { ep++; hardcr=1; } /* eat newline */
+
+- /* if we got too wide, back off until we find a break position
++ /* if we got too wide, back off until we find a break position
+ (last char before a space or a '/') */
+
+ if (XTextWidth(mfinfo, sp, (int)(ep-sp)) > w) {
+@@ -812,7 +812,7 @@
+ }
+
+ start[lineno] = sp; len[lineno] = ep-sp;
+-
++
+ /* make sure we don't print a trailing '\n' character! */
+ if (len[lineno] > 0) {
+ while (sp[len[lineno]-1] == '\n') len[lineno] = len[lineno] - 1;
+@@ -835,7 +835,7 @@
+ /***************************************************/
+ static void createPUD()
+ {
+- popW = CreateWindow("xv confirm", "XVconfirm", "+0+0",
++ popW = CreateWindow("xv confirm", "XVconfirm", "+0+0",
+ PUWIDE, PUHIGH, infofg, infobg, 0);
+ if (!popW) FatalError("can't create popup window!");
+
+@@ -847,7 +847,7 @@
+ bts = (BUTT *) NULL;
+ nbts = selected = firsttime = 0;
+ }
+-
++
+
+ /***************************************************/
+ static void attachPUD()
+@@ -913,24 +913,24 @@
+ XDrawLine(theDisp, popW, theGC, 16+1+75+75+5, puhigh-140 + 6+8,
+ 16+1+75+75+5, puhigh-10-4);
+ }
+-
++
+
+ XSetForeground(theDisp, theGC, infofg);
+- XDrawRectangle(theDisp, popW, theGC, 268, puhigh-140,
++ XDrawRectangle(theDisp, popW, theGC, 268, puhigh-140,
+ (u_int) puwide - 10 - 268, 130-BUTTH-10);
+- Draw3dRect(popW, 268+1, puhigh-140+1, (u_int) puwide -10-268-2,
++ Draw3dRect(popW, 268+1, puhigh-140+1, (u_int) puwide -10-268-2,
+ 130-2 - BUTTH-10, R3D_IN,2,hicol,locol,infobg);
+-
+- TextRect(popW,padInst,268+5, puhigh-140+3, puwide-10-268-10,
++
++ TextRect(popW,padInst,268+5, puhigh-140+3, puwide-10-268-10,
+ 130-6 - BUTTH-10, infofg);
+ }
+
+ else {
+ XCopyPlane(theDisp, iconPix, popW, theGC, 0,0, icon_width, icon_height,
+ 10,10+(puhigh-30-BUTTH-icon_height)/2, 1L);
+-
++
+ xt = 10+icon_width+20; yt = 10;
+-
++
+ if (popUp == ISGETSTR) {
+ TextRect(popW, text, xt, yt, puwide-10-xt, gsy-20, infofg);
+ drawGSBuf();
+@@ -947,22 +947,22 @@
+ /***************************************************/
+ static void drawPadOMStr()
+ {
+- CenterString(popW, padODial.x + (padODial.w - 13)/2,
++ CenterString(popW, padODial.x + (padODial.w - 13)/2,
+ puhigh-16-100-12, padOMStr[padOMode]);
+ }
+-
++
+ /***************************************************/
+ static void clickPUD(x,y)
+ int x,y;
+ {
+ int i;
+ BUTT *bp;
+-
++
+ 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)) {
+ popUp = 0; selected = i; return;
+ }
+@@ -1017,11 +1017,11 @@
+ gsCurPos = strlen(gsBuf);
+ gsStPos = gsEnPos = 0;
+ changedGSBuf();
+- if (ctrlColor)
+- XClearArea(theDisp, popW, gsx+3,gsy+3,
++ if (ctrlColor)
++ XClearArea(theDisp, popW, gsx+3,gsy+3,
+ (u_int)gsw-5, (u_int)gsh-5, False);
+ else
+- XClearArea(theDisp, popW, gsx+1,gsy+1,
++ XClearArea(theDisp, popW, gsx+1,gsy+1,
+ (u_int)gsw-1, (u_int)gsh-1, False);
+ drawGSBuf();
+
+@@ -1032,7 +1032,7 @@
+ DSetActive (&padWDial, (i!=PAD_LOAD));
+ DSetActive (&padHDial, (i!=PAD_LOAD));
+
+- XClearArea(theDisp, popW, 184+5, puhigh-140+3,
++ XClearArea(theDisp, popW, 184+5, puhigh-140+3,
+ (u_int) puwide-10-184-10, 130-6 - BUTTH-10, True);
+
+ padMode = i;
+@@ -1049,11 +1049,11 @@
+ gsCurPos = strlen(gsBuf);
+ gsStPos = gsEnPos = 0;
+ changedGSBuf();
+- if (ctrlColor)
+- XClearArea(theDisp, popW, gsx+3,gsy+3,
++ if (ctrlColor)
++ XClearArea(theDisp, popW, gsx+3,gsy+3,
+ (u_int)gsw-5, (u_int)gsh-5, False);
+ else
+- XClearArea(theDisp, popW, gsx+1,gsy+1,
++ XClearArea(theDisp, popW, gsx+1,gsy+1,
+ (u_int)gsw-1, (u_int)gsh-1, False);
+ drawGSBuf();
+
+@@ -1079,8 +1079,8 @@
+ /* handle characters typed at GetStrPopUp window. Button accel. keys
+ have already been checked for elsewhere. Practical upshot is that
+ we don't have to do anything with ESC or Return (as these will normally
+- be Cancel and Ok buttons)
+-
++ be Cancel and Ok buttons)
++
+ Normally returns '0'. Returns '1' if character wasn't accepted, for
+ whatever reason. */
+
+@@ -1089,7 +1089,7 @@
+ len = strlen(gsBuf);
+ if (gsFilter) flen = strlen(gsFilter);
+ else flen = 0;
+-
++
+
+ if (c>=' ' && c<'\177') { /* 'NORMAL' CHARACTERS */
+ if (flen) { /* check filter string */
+@@ -1097,7 +1097,7 @@
+ if (!gsAllow && i< flen) return 1; /* found in 'disallow' filter */
+ if ( gsAllow && i==flen) return 1; /* not found in 'allow' filter */
+ }
+-
++
+ if (len >= gsBufLen-1) return 1; /* at max length */
+
+ xvbcopy(&gsBuf[gsCurPos], &gsBuf[gsCurPos+1], (size_t) len-gsCurPos+1);
+@@ -1147,7 +1147,7 @@
+
+ changedGSBuf(); /* compute gsEnPos, gsStPos */
+
+- if (ctrlColor)
++ if (ctrlColor)
+ XClearArea(theDisp, popW, gsx+3,gsy+3, (u_int)gsw-5, (u_int)gsh-5, False);
+ else
+ XClearArea(theDisp, popW, gsx+1,gsy+1, (u_int)gsw-1, (u_int)gsh-1, False);
+@@ -1175,7 +1175,7 @@
+ /***************************************************/
+ static void changedGSBuf()
+ {
+- /* cursor position (or whatever) may have changed. adjust displayed
++ /* cursor position (or whatever) may have changed. adjust displayed
+ portion of gsBuf */
+
+ int len;
+@@ -1212,7 +1212,7 @@
+
+ XSetForeground(theDisp, theGC, infofg);
+ XDrawRectangle(theDisp, popW, theGC, gsx, gsy, (u_int) gsw, (u_int) gsh);
+- Draw3dRect(popW, gsx+1, gsy+1, (u_int) gsw-2, (u_int) gsh-2,
++ Draw3dRect(popW, gsx+1, gsy+1, (u_int) gsw-2, (u_int) gsh-2,
+ R3D_IN, 2, hicol,locol,infobg);
+
+ XSetForeground(theDisp, theGC, infofg);
+diff -ruN xv-3.10a/xvps.c xv-3.10a-bugfixes/xvps.c
+--- xv-3.10a/xvps.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvps.c 2005-03-30 08:18:17.000000000 -0800
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvps.c - Postscript dialog box, file output functions
+ *
+ * callable functions:
+@@ -71,10 +71,13 @@
+ static void psColorImage PARM((FILE *));
+ static void psColorMap PARM((FILE *fp, int, int, byte *, byte *, byte *));
+ static void psRleCmapImage PARM((FILE *, int));
+-static void epsPreview PARM((FILE *, byte *, int, int, int, int,
++static void epsPreview PARM((FILE *, byte *, int, int, int, int,
+ byte *, byte *, byte *, int));
+ static int writeBWStip PARM((FILE *, byte *, char *, int, int, int));
+
++#ifdef GS_PATH
++static void buildCmdStr PARM((char *, char *, char *, int, int));
++#endif
+
+
+ /* local variables */
+@@ -123,7 +126,7 @@
+ void CreatePSD(geom)
+ char *geom;
+ {
+- psW = CreateWindow("xv postscript", "XVps", geom,
++ psW = CreateWindow("xv postscript", "XVps", geom,
+ PSWIDE, PSHIGH, infofg, infobg, 0);
+ if (!psW) FatalError("can't create postscript window!");
+
+@@ -139,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, 800, 100, 5,
+ infofg, infobg, hicol, locol, "Width", "%");
+- DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5,
++ DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5,
+ infofg, infobg, hicol, locol, "Height", "%");
+ xsDial.drawobj = changedScale;
+ ysDial.drawobj = changedScale;
+@@ -154,38 +157,38 @@
+ RBCreate(orientRB, psW, 36+80, 240+18, "Landscape", infofg, infobg,
+ hicol, locol);
+
+- paperRB = RBCreate(NULL, psW,36, 240+18+36, "8.5\"x11\"",
++ paperRB = RBCreate(NULL, psW,36, 240+18+36, "8.5\"x11\"",
+ infofg, infobg, hicol, locol);
+ RBCreate(paperRB, psW, 36+80, 240+18+36, "A4",
+ infofg, infobg, hicol, locol);
+- RBCreate(paperRB, psW, 36+122, 240+18+36, "B5",
++ RBCreate(paperRB, psW, 36+122, 240+18+36, "B5",
+ infofg, infobg, hicol, locol);
+- RBCreate(paperRB, psW, 36+164, 240+18+36, "A3",
++ RBCreate(paperRB, psW, 36+164, 240+18+36, "A3",
+ infofg, infobg, hicol, locol);
+ RBCreate(paperRB, psW, 36, 240+36+36, "8.5\"x14\"",
+ infofg, infobg, hicol, locol);
+- RBCreate(paperRB, psW, 36+80, 240+36+36, "11\"x17\"",
++ RBCreate(paperRB, psW, 36+80, 240+36+36, "11\"x17\"",
+ infofg, infobg, hicol, locol);
+- RBCreate(paperRB, psW, 36, 240+54+36, "4\"x5\"",
++ RBCreate(paperRB, psW, 36, 240+54+36, "4\"x5\"",
+ infofg, infobg, hicol, locol);
+- RBCreate(paperRB, psW, 36+80, 240+54+36, "35mm slide",
++ RBCreate(paperRB, psW, 36+80, 240+54+36, "35mm slide",
+ infofg, infobg, hicol, locol);
+
+- BTCreate(&psbut[PS_BOK], psW, PSWIDE-180, PSHIGH-10-BUTTH, 80, BUTTH,
++ BTCreate(&psbut[PS_BOK], psW, PSWIDE-180, PSHIGH-10-BUTTH, 80, BUTTH,
+ "Ok", infofg, infobg, hicol, locol);
+- BTCreate(&psbut[PS_BCANC], psW, PSWIDE-90, PSHIGH-10-BUTTH, 80, BUTTH,
++ BTCreate(&psbut[PS_BCANC], psW, PSWIDE-90, PSHIGH-10-BUTTH, 80, BUTTH,
+ "Cancel", infofg, infobg, hicol, locol);
+
+- BTCreate(&psbut[PS_BCENT], psW, 240, 154, 55, BUTTH-2,
++ BTCreate(&psbut[PS_BCENT], psW, 240, 154, 55, BUTTH-2,
+ "Center", infofg, infobg, hicol, locol);
+- BTCreate(&psbut[PS_BORG], psW, 298, 154, 55, BUTTH-2,
++ BTCreate(&psbut[PS_BORG], psW, 298, 154, 55, BUTTH-2,
+ "Origin", infofg, infobg, hicol, locol);
+- BTCreate(&psbut[PS_BMAX], psW, 356, 154, 55, BUTTH-2,
++ BTCreate(&psbut[PS_BMAX], psW, 356, 154, 55, BUTTH-2,
+ "Max", infofg, infobg, hicol, locol);
+
+- BTCreate(&psbut[PS_BPOSX], psW, 256-14, 190+13-8, 8,8, "",
++ BTCreate(&psbut[PS_BPOSX], psW, 256-14, 190+13-8, 8,8, "",
+ infofg, infobg, hicol, locol);
+- BTCreate(&psbut[PS_BPOSY], psW, 256-14, 190+26-8, 8,8, "",
++ BTCreate(&psbut[PS_BPOSY], psW, 256-14, 190+26-8, 8,8, "",
+ infofg, infobg, hicol, locol);
+
+ posxType = posyType = 0;
+@@ -246,7 +249,7 @@
+
+ XMapSubwindows(theDisp, psW);
+ }
+-
++
+
+ /***************************************************/
+ void PSDialog(vis)
+@@ -289,7 +292,7 @@
+ x = e->x; y = e->y; w = e->width; h = e->height;
+
+ /* throw away excess expose events for 'dumb' windows */
+- if (e->count > 0 &&
++ if (e->count > 0 &&
+ (e->window == xsDial.win || e->window == ysDial.win ||
+ e->window == pageF)) {}
+
+@@ -332,7 +335,7 @@
+ XKeyEvent *e = (XKeyEvent *) xev;
+ char buf[128]; KeySym ks;
+ int stlen, shift, ck;
+-
++
+ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
+ shift = e->state & ShiftMask;
+ ck = CursorKey(ks, shift, 0);
+@@ -497,7 +500,7 @@
+ XSetFont(theDisp, theGC, mfont);
+ }
+
+-
++
+ /***************************************************/
+ static void drawSizeStr()
+ {
+@@ -522,7 +525,7 @@
+ XSetFont(theDisp, theGC, mfont);
+ }
+
+-
++
+ /***************************************************/
+ static void drawResStr()
+ {
+@@ -540,9 +543,9 @@
+ XSetFont(theDisp, theGC, mfont);
+ }
+
+-
+-
+-
++
++
++
+ /***************************************************/
+ static void drawPage()
+ {
+@@ -554,7 +557,7 @@
+ XSetForeground(theDisp, theGC, infofg);
+ XDrawRectangle(theDisp, pageF, theGC, pageRect.x, pageRect.y,
+ (u_int) pageRect.width, (u_int) pageRect.height);
+-
++
+ drawIRect(1);
+ }
+
+@@ -611,7 +614,7 @@
+ unsigned int mask;
+ double offx, offy, newx, newy;
+
+- /* compute offset (in inches) between 'drag point' and
++ /* compute offset (in inches) between 'drag point' and
+ the top-left corner of the image */
+
+ offx = ((mx - pageRect.x) / in2pix) - pos_inx;
+@@ -642,7 +645,7 @@
+ char *fullname;
+
+ switch (cmd) {
+- case PS_BOK: writePS();
++ case PS_BOK: writePS();
+ PSDialog(0);
+ fullname = GetDirFullName();
+ if (!ISPIPE(fullname[0])) {
+@@ -721,15 +724,15 @@
+
+ GetSaveSize(&w, &h);
+
+- sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
+- sz_iny = (double) h / PIX2INCH * (ysDial.val / 100.0);
++ sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
++ sz_iny = (double) h / PIX2INCH * (ysDial.val / 100.0);
+
+ /* round to integer .001ths of an inch */
+ sz_inx = floor(sz_inx * 1000.0 + 0.5) / 1000.0;
+ sz_iny = floor(sz_iny * 1000.0 + 0.5) / 1000.0;
+
+- dpix = (int) (PIX2INCH / (xsDial.val / 100.0));
+- dpiy = (int) (PIX2INCH / (ysDial.val / 100.0));
++ dpix = (int) (PIX2INCH / (xsDial.val / 100.0));
++ dpiy = (int) (PIX2INCH / (ysDial.val / 100.0));
+
+ /* make sure 'center' of image is still on page */
+ hsx = sz_inx/2; hsy = sz_iny/2;
+@@ -783,20 +786,20 @@
+ {
+ int x,y,w,h;
+ XRectangle xr;
+-
++
+ x = pageRect.x + (int) (pos_inx * in2pix);
+ y = pageRect.y + (int) (pos_iny * in2pix);
+ w = sz_inx * in2pix;
+ h = sz_iny * in2pix;
+-
++
+ xr.x = pageRect.x + 1;
+ xr.y = pageRect.y + 1;
+ xr.width = pageRect.width - 1;
+ xr.height = pageRect.height - 1;
+-
++
+ if (draw) XSetForeground(theDisp, theGC, infofg);
+ else XSetForeground(theDisp, theGC, infobg);
+-
++
+ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
+ XDrawRectangle(theDisp, pageF, theGC, x, y, (u_int) w, (u_int) h);
+ XDrawLine(theDisp, pageF, theGC, x, y, x+w, y+h);
+@@ -839,15 +842,15 @@
+ DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5));
+ DSetVal(&ysDial, xsDial.val);
+
+- sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
+- sz_iny = (double) h / PIX2INCH * (ysDial.val / 100.0);
++ sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
++ sz_iny = (double) h / PIX2INCH * (ysDial.val / 100.0);
+
+ /* round to integer .001ths of an inch */
+ sz_inx = floor(sz_inx * 1000.0 + 0.5) / 1000.0;
+ sz_iny = floor(sz_iny * 1000.0 + 0.5) / 1000.0;
+
+- dpix = (int) (PIX2INCH / (xsDial.val / 100.0));
+- dpiy = (int) (PIX2INCH / (ysDial.val / 100.0));
++ dpix = (int) (PIX2INCH / (xsDial.val / 100.0));
++ dpiy = (int) (PIX2INCH / (ysDial.val / 100.0));
+
+ pos_inx = psizex/2 - sz_inx/2;
+ pos_iny = psizey/2 - sz_iny/2;
+@@ -888,7 +891,7 @@
+ static void writePS()
+ {
+ FILE *fp;
+- int i, j, q, err, rpix, gpix, bpix, nc, ptype;
++ int i, j, err, rpix, gpix, bpix, nc, ptype;
+ int iw, ih, ox, oy, slen, lwidth, bits, colorps, w, h, pfree;
+ double iwf, ihf;
+ byte *inpix, *rmap, *gmap, *bmap;
+@@ -900,13 +903,19 @@
+ if (!fp) return;
+
+ WaitCursor();
+-
++
+ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
+
+-
++ if (w <= 0 || h <= 0 || w*2 < w) {
++ SetISTR(ISTR_WARNING,"%s: Image dimensions out of range", filename);
++ CloseOutFile(fp, filename, 1);
++ return;
++ }
++
++
+ /* printed image will have size iw,ih (in picas) */
+ iw = (int) (sz_inx * 72.0 + 0.5);
+- ih = (int) (sz_iny * 72.0 + 0.5);
++ ih = (int) (sz_iny * 72.0 + 0.5);
+ iwf = sz_inx * 72.0;
+ ihf = sz_iny * 72.0;
+
+@@ -923,12 +932,12 @@
+ fprintf(fp,"%%%%Creator: XV %s - by John Bradley\n",REVDATE);
+
+ if (RBWhich(orientRB)==ORNT_LAND) /* Landscape mode */
+- fprintf(fp,"%%%%BoundingBox: %d %d %d %d\n",
++ fprintf(fp,"%%%%BoundingBox: %d %d %d %d\n",
+ (int) (pos_iny * 72.0 + 0.5),
+ (int) (pos_inx * 72.0 + 0.5),
+ (int) (pos_iny * 72.0 + 0.5) + ih,
+ (int) (pos_inx * 72.0 + 0.5) + iw);
+- else
++ else
+ fprintf(fp,"%%%%BoundingBox: %d %d %d %d\n", ox, oy, ox+iw, oy+ih);
+
+ fprintf(fp,"%%%%Pages: 1\n");
+@@ -943,9 +952,9 @@
+ case F_BWDITHER: slen = (w+7)/8; bits = 1; colorps = 0; break;
+ default: FatalError("unknown colorType in writePS()"); break;
+ }
+-
++
+ if (encapsCB.val) epsPreview(fp, inpix, ptype, colorType, w, h,
+- rmap,gmap,bmap,
++ rmap,gmap,bmap,
+ (RBWhich(orientRB)==ORNT_LAND) );
+
+ fprintf(fp,"%%%%EndProlog\n\n");
+@@ -978,7 +987,7 @@
+ fprintf(fp,"%% print in landscape mode\n");
+ fprintf(fp,"90 rotate 0 %d translate\n\n",(int) (-psizey*72.0));
+ }
+-
++
+ if (RBWhich(paperRB) == PSZ_4BY5 ||
+ RBWhich(paperRB) == PSZ_35MM) {
+ fprintf(fp,"%% we're going to a 4x5 or a 35mm film recorder.\n");
+@@ -1083,12 +1092,12 @@
+ gpix = inpix[1];
+ bpix = inpix[2];
+ }
+-
+- if (colorps) {
++
++ if (colorps) {
+ err = fprintf(fp,"%02x%02x%02x",rpix,gpix,bpix);
+ lwidth+=6;
+ }
+-
++
+ else { /* greyscale */
+ err = fprintf(fp,"%02x", MONO(rpix,gpix,bpix));
+ lwidth+=2;
+@@ -1106,7 +1115,7 @@
+ fprintf(fp,"\n\n");
+ fprintf(fp,"%%\n");
+ fprintf(fp,"%% Compression made this file %.2f%% %s\n",
+- 100.0 * ((double) outbytes) /
++ 100.0 * ((double) outbytes) /
+ ((double) eWIDE * eHIGH * ((colorps) ? 3 : 1)),
+ "of the uncompressed size.");
+ fprintf(fp,"%%\n");
+@@ -1147,10 +1156,10 @@
+ *
+ * returns length of the rleline vector
+ */
+-
++
+ int i, j, blocklen, isrun, rlen;
+ byte block[256], pix;
+-
++
+ blocklen = isrun = rlen = 0;
+
+ for (i=0; i<wide; i++) {
+@@ -1186,7 +1195,7 @@
+ }
+ }
+ }
+-
++
+ else { /* not a run */
+ if (pix == block[blocklen-1]) { /* case 3: non-run, prev==cur */
+ if (blocklen>1) { /* have a non-run block to flush */
+@@ -1215,7 +1224,7 @@
+
+ else {
+ rleline[rlen++] = (blocklen-1) | 0x80;
+- for (j=0; j<blocklen; j++)
++ for (j=0; j<blocklen; j++)
+ rleline[rlen++] = block[j];
+ }
+
+@@ -1231,15 +1240,15 @@
+
+ else {
+ rleline[rlen++] = (blocklen-1) | 0x80;
+- for (j=0; j<blocklen; j++)
++ for (j=0; j<blocklen; j++)
+ rleline[rlen++] = block[j];
+ }
+ }
+
+ return rlen;
+ }
+-
+-
++
++
+ /**********************************************/
+ static void psColorImage(fp)
+ FILE *fp;
+@@ -1276,7 +1285,7 @@
+ fprintf(fp," %% Utility procedure for colorimage operator.\n");
+ fprintf(fp," %% This procedure takes two procedures off the\n");
+ fprintf(fp," %% stack and merges them into a single procedure.\n\n");
+-
++
+ fprintf(fp," /mergeprocs { %% def\n");
+ fprintf(fp," dup length\n");
+ fprintf(fp," 3 -1 roll\n");
+@@ -1326,12 +1335,12 @@
+ for (i=0; i<nc; i++) {
+ if (color) fprintf(fp,"%02x%02x%02x ", rmap[i],gmap[i],bmap[i]);
+ else fprintf(fp,"%02x ", MONO(rmap[i],gmap[i],bmap[i]));
+-
++
+ if ((i%10) == 9) fprintf(fp,"\n");
+ }
+ if (i%10) fprintf(fp,"\n");
+ fprintf(fp,"pop pop %% lose return values from readhexstring\n\n\n");
+-
++
+ }
+
+
+@@ -1407,7 +1416,7 @@
+
+
+ /**********************************************/
+-static void epsPreview(fp, pic, ptype, colorType, w, h, rmap,gmap,bmap,
++static void epsPreview(fp, pic, ptype, colorType, w, h, rmap,gmap,bmap,
+ landscape)
+ FILE *fp;
+ byte *pic;
+@@ -1420,21 +1429,37 @@
+
+
+ if (landscape) { /* generate a rotated version of the pic */
+- int bperpix;
++ int npixels, bufsize;
+ byte *lpic;
+
+- bperpix = (ptype == PIC8) ? 1 : 3;
+- lpic = (byte *) malloc((size_t) w * h * bperpix);
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h) {
++ SetISTR(ISTR_WARNING,"%s: Image dimensions out of range", filename);
++/* CloseOutFile(fp, filename, 1); can't do since caller still writing */
++ return;
++ }
++ if (ptype == PIC8)
++ bufsize = npixels;
++ else {
++ bufsize = 3*npixels;
++ if (bufsize/3 != npixels) {
++ SetISTR(ISTR_WARNING,"%s: Image dimensions out of range", filename);
++/* CloseOutFile(fp, filename, 1); can't do since caller still writing */
++ return;
++ }
++ }
++
++ lpic = (byte *) malloc((size_t) bufsize);
+ if (!lpic) FatalError("can't alloc mem to rotate image in epsPreview");
+
+- xvbcopy((char *) pic, (char *) lpic, (size_t) w * h * bperpix);
++ xvbcopy((char *) pic, (char *) lpic, (size_t) bufsize);
+ RotatePic(lpic, ptype, &w, &h, 0);
+ pic = lpic;
+ }
+-
++
+
+ /* put in an EPSI preview */
+-
++
+ if (colorType != F_BWDITHER) { /* have to generate a preview */
+ prev = FSDither(pic, ptype, w, h, rmap,gmap,bmap, 0, 1);
+
+@@ -1451,8 +1476,8 @@
+ flipbw = (MONO(rmap[0],gmap[0],bmap[0]) > MONO(rmap[1],gmap[1],bmap[1]));
+ }
+
+-
+- fprintf(fp,"%%%%BeginPreview: %d %d %d %d\n", w, h, 1,
++
++ fprintf(fp,"%%%%BeginPreview: %d %d %d %d\n", w, h, 1,
+ (w/(72*4) + 1) * h);
+
+ writeBWStip(fp, prev, "% ", w, h, !flipbw);
+@@ -1471,7 +1496,7 @@
+ char *prompt;
+ int w, h, flipbw;
+ {
+- /* write the given 'pic' (B/W stippled, 1 byte per pixel, 0=blk,1=wht)
++ /* write the given 'pic' (B/W stippled, 1 byte per pixel, 0=blk,1=wht)
+ out as hexadecimal, max of 72 hex chars per line.
+
+ if 'flipbw', then 0=white, 1=black
+@@ -1535,25 +1560,32 @@
+ document is multiple pages, a series of PNM files are created, and
+ the first one is loaded (but not deleted) */
+
+-
+- char tmp[512], tmp1[512], tmpname[64];
+- int gsresult, nump, i, filetype;
++#ifdef GS_PATH
++ char tmp[512], gscmd[512], cmdstr[512], tmpname[64];
++ int gsresult, nump, i, filetype, doalert, epsf;
+ char *rld;
++#endif
+
+ pinfo->pic = (byte *) NULL;
+ pinfo->comment = (char *) NULL;
+
+-
+ #ifdef GS_PATH
+
++ doalert = (!quick && !ctrlUp && !infoUp); /* open alert if no info wins */
++ epsf = 0;
++
+ #ifndef VMS
+ sprintf(tmpname, "%s/xvpgXXXXXX", tmpdir);
+ #else
+ sprintf(tmpname, "Sys$Scratch:xvpgXXXXXX");
+ #endif
+
++#ifdef USE_MKSTEMP
++ close(mkstemp(tmpname));
++#else
+ mktemp(tmpname);
+- if (tmpname[0] == '\0') { /* mktemp() blew up */
++#endif
++ if (tmpname[0] == '\0') { /* mktemp() or mkstemp() blew up */
+ sprintf(str,"LoadPS: Unable to create temporary filename???");
+ ErrPopUp(str, "\nHow unlikely!");
+ return 0;
+@@ -1561,13 +1593,13 @@
+ strcat(tmpname,".");
+
+
+- /* build command string */
++ /* build 'gscmd' string */
+
+ #ifndef VMS /* VMS needs quotes around mixed case command lines */
+- sprintf(tmp, "%s -sDEVICE=%s -r%d -q -dNOPAUSE -sOutputFile=%s%%d ",
++ sprintf(gscmd, "%s -sDEVICE=%s -r%d -q -dNOPAUSE -sOutputFile=%s%%d ",
+ GS_PATH, gsDev, gsRes, tmpname);
+ #else
+- sprintf(tmp,
++ sprintf(gscmd,
+ "%s \"-sDEVICE=%s\" -r%d -q \"-dNOPAUSE\" \"-sOutputFile=%s%%d\" ",
+ GS_PATH, gsDev, gsRes, tmpname);
+ #endif
+@@ -1575,74 +1607,60 @@
+
+ #ifdef GS_LIB
+ # ifndef VMS
+- sprintf(tmp1, "-I%s ", GS_LIB);
++ sprintf(tmp, "-I%s ", GS_LIB);
+ # else
+- sprintf(tmp1, "\"-I%s\"", GS_LIB);
++ sprintf(tmp, "\"-I%s\" ", GS_LIB);
+ # endif
+- strcat(tmp, tmp1);
++ strcat(gscmd, tmp);
+ #endif
+
+- if (gsGeomStr) {
+- sprintf(tmp1, "-g%s ", gsGeomStr);
+- strcat(tmp, tmp1);
+- }
+-
+- /* if 'quick' is set, stop processing after first page by tacking
+- some PostScript commands that break the 'showpage' operator onto
+- the front of the stream passed to the ghostscript interpreter */
+
++ /* prevent some potential naughtiness... */
+ #ifndef VMS
+- if (quick) {
+- sprintf(tmp1, "echo '%s' | cat - %s | %s -",
+- "/showpage { showpage quit } bind def", /* mk showpage exit */
+- fname, tmp);
+- strcpy(tmp, tmp1);
+- }
+- else {
+- strcat(tmp, " -- ");
+- strcat(tmp, 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 */
+- 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);
++ strcat(gscmd, "-dSAFER ");
++#else
++ strcat(gscmd, "\"-dSAFER\" ");
+ #endif
+
+
++ if (gsGeomStr) {
++ sprintf(tmp, "-g%s ", gsGeomStr);
++ strcat(gscmd, tmp);
++ }
+
+
+- WaitCursor();
+-
+- if (DEBUG) fprintf(stderr,"LoadPS: executing command '%s'\n", tmp);
+- SetISTR(ISTR_INFO, "Running '%s'...", GS_PATH);
++ do {
++ buildCmdStr(cmdstr, gscmd, fname, quick, epsf);
+
+- sprintf(tmp1, "Running %s", tmp);
+- if (!quick && !ctrlUp && !infoUp) OpenAlert(tmp1);
++ if (DEBUG) fprintf(stderr,"LoadPS: executing command '%s'\n", cmdstr);
++ SetISTR(ISTR_INFO, "Running '%s'...", GS_PATH);
++ sprintf(tmp, "Running %s", cmdstr);
++ if (doalert && epsf==0) OpenAlert(tmp); /* open alert first time only */
+
+-#ifndef VMS
+- gsresult = system(tmp);
+-#else
+- gsresult = !system(tmp);
++ WaitCursor();
++ gsresult = system(cmdstr);
++ WaitCursor();
++#ifdef VMS
++ gsresult = !gsresult; /* VMS returns non-zero if OK */
+ #endif
+
+- WaitCursor();
++ /* count # of files produced... */
++ for (i=1; i<1000; i++) {
++ struct stat st;
++ sprintf(tmp, "%s%d", tmpname, i);
++ if (stat(tmp, &st)!=0) break;
++ }
++ nump = i-1;
++ WaitCursor();
+
+- if (!quick && !ctrlUp && !infoUp) CloseAlert();
++ /* EPSF hack: if gsresult==0 (OK) and 0 pages produced,
++ try tacking a 'showpage' onto the end of the file, do it again... */
++
++ if (!gsresult && !nump && !epsf) epsf++;
++ } while (!gsresult && !nump && epsf<2);
++
++ if (doalert) CloseAlert();
+
+- /* figure out how many page files were created, by stating files.
+- breaks out on first failure, assuming there won't be any more after
+- that, and it would complicate matters too much anyhow... */
+-
+- for (i=1; i<1000; i++) {
+- struct stat st;
+- sprintf(tmp, "%s%d", tmpname, i);
+- if (stat(tmp, &st)!=0) break;
+- }
+- nump = i-1;
+
+ WaitCursor();
+
+@@ -1664,7 +1682,7 @@
+ return 0;
+ }
+
+- SetISTR(ISTR_INFO, "Running '%s'... Done. (%d page%s)",
++ SetISTR(ISTR_INFO, "Running '%s'... Done. (%d page%s)",
+ GS_PATH, nump, (nump==1) ? "" : "s");
+ }
+
+@@ -1677,8 +1695,8 @@
+
+ sprintf(tmp, "%s%d", tmpname, 1);
+ filetype = ReadFileType(tmp);
+-
+- if (filetype == RFT_ERROR || filetype == RFT_UNKNOWN ||
++
++ if (filetype == RFT_ERROR || filetype == RFT_UNKNOWN ||
+ filetype == RFT_COMPRESS) { /* shouldn't happen */
+ SetISTR(ISTR_WARNING, "Couldn't load first page '%s'", tmp);
+ KillPageFiles(tmpname, nump);
+@@ -1695,7 +1713,7 @@
+ KillPageFiles(tmpname, nump);
+ SetCursors(-1);
+ return 0;
+- }
++ }
+
+
+ /* SUCCESS! */
+@@ -1712,3 +1730,38 @@
+ we don't have 'gs' package */
+ }
+
++
++
++/******************************************************************/
++#ifdef GS_PATH
++void buildCmdStr(str, gscmd, fname, quick, epsf)
++ char *str, *gscmd, *fname;
++ int quick, epsf;
++{
++ /* note 'epsf' set only on files that don't have a showpage cmd */
++
++#ifndef VMS
++
++ if (epsf) sprintf(str, "echo '\n showpage ' | cat '%s' - | %s -",
++ fname, gscmd);
++
++ else if (quick) sprintf(str, "echo '%s' | cat - '%s' | %s -",
++ "/showpage { showpage quit } bind def",
++ fname, gscmd);
++
++ else sprintf(str, "%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 */
++ 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 */
++}
++#endif /* GS_PATH */
++
++
++
+diff -ruN xv-3.10a/xvrle.c xv-3.10a-bugfixes/xvrle.c
+--- xv-3.10a/xvrle.c 1995-01-19 09:27:47.000000000 -0800
++++ xv-3.10a-bugfixes/xvrle.c 2005-03-29 23:29:14.000000000 -0800
+@@ -43,8 +43,8 @@
+ byte bgcol[256];
+ byte maps[3][256];
+ int xpos, ypos, w, h, flags, ncolors, pixelbits, ncmap, cmaplen;
+- int cmtlen;
+- byte *img, *pic8;
++ int cmtlen, npixels, bufsize=0;
++ byte *img;
+ long filesize;
+ char *bname, *errstr;
+
+@@ -57,7 +57,7 @@
+ /* open the stream */
+ fp = xv_fopen(fname,"r");
+ if (!fp) return (rleError(bname, "unable to open file"));
+-
++
+
+ /* figure out the file size */
+ fseek(fp, 0L, 2);
+@@ -85,7 +85,7 @@
+ if (DEBUG) {
+ fprintf(stderr,"RLE: %dx%d image at %d,%d\n", w, h, xpos, ypos);
+ fprintf(stderr,"flags: 0x%02x (%s%s%s%s)\n",
+- flags,
++ flags,
+ (flags & H_CLEARFIRST) ? "CLEARFIRST " : "",
+ (flags & H_NO_BACKGROUND) ? "NO_BG " : "",
+ (flags & H_ALPHA) ? "ALPHA " : "",
+@@ -93,7 +93,7 @@
+
+ fprintf(stderr, "%d bands, %d pixelbits, %d cmap bands, %d cmap entries\n",
+ ncolors, pixelbits, ncmap, cmaplen);
+- }
++ }
+
+ if (!(flags & H_NO_BACKGROUND)) {
+ if (DEBUG) fprintf(stderr, "background value: ");
+@@ -176,32 +176,44 @@
+
+ errstr = NULL;
+ if (ncolors == 0 || ncolors == 2)
+- errstr = "Unsupt. # of channels in RLE file.\n";
++ errstr = "Unsupported number of channels in RLE file";
+
+ if (pixelbits != 8)
+- errstr = "Only 8-bit pixels supported in RLE files.\n";
++ errstr = "Only 8-bit pixels supported in RLE files";
+
+ if (ncmap==0 || ncmap==1 || ncmap == 3 || ncmap == ncolors) { /* ok */ }
+- else errstr = "Invalid # of colormap channels in RLE file.\n";
++ else errstr = "Invalid number of colormap channels in RLE file";
+
+- if (w<1 || h<1)
+- errstr = "Bogus size in RLE header.\n";
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h)
++ errstr = "RLE image dimensions out of range";
+
+
+ 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) w * h, (size_t) 1);
+- else img = (byte *) calloc((size_t) w * h * 3, (size_t) 1);
++ 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 (!img) {
+ fclose(fp);
+- if (pinfo->comment) free(pinfo->comment); pinfo->comment = (char *) NULL;
+- return rleError(bname, "unable to allocate image data.\n");
++ if (pinfo->comment)
++ free(pinfo->comment);
++ pinfo->comment = (char *) NULL;
++ return rleError(bname, "Unable to allocate RLE image data");
+ }
+
+
+@@ -209,10 +221,10 @@
+ if ((flags & H_CLEARFIRST) && !(flags & H_NO_BACKGROUND)) {
+ byte *ip;
+ if (ncolors == 1) {
+- for (i=0, ip=img; i<w*h; i++, ip++) *ip = bgcol[0];
++ for (i=0, ip=img; i<npixels; i++, ip++) *ip = bgcol[0];
+ }
+ else {
+- for (i=0, ip=img; i<w*h; i++)
++ for (i=0, ip=img; i<npixels; i++)
+ for (j=0; j<3; j++, ip++) *ip = bgcol[j];
+ }
+ }
+@@ -230,7 +242,7 @@
+ if (ncmap) {
+ byte *ip;
+ int imagelen, cmask;
+- imagelen = (ncolors==1) ? w*h : w*h*3;
++ imagelen = (ncolors==1) ? npixels : bufsize;
+ cmask = (cmaplen-1);
+
+ if (ncmap == 1) { /* single gamma curve */
+@@ -238,7 +250,7 @@
+ }
+
+ else if (ncmap >= 3 && ncolors >=3) { /* one curve per band */
+- for (i=0, ip=img; i<w*h; i++) {
++ for (i=0, ip=img; i<npixels; i++) {
+ *ip = maps[0][*ip & cmask]; ip++;
+ *ip = maps[1][*ip & cmask]; ip++;
+ *ip = maps[2][*ip & cmask]; ip++;
+@@ -250,7 +262,7 @@
+ /* finally, convert into XV internal format */
+
+ pinfo->pic = img;
+- pinfo->w = w;
++ pinfo->w = w;
+ pinfo->h = h;
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->frmType = -1; /* no default format to save in */
+@@ -260,7 +272,7 @@
+ if (ncmap == 0 || ncmap == 1) { /* grey, or grey with gamma curve */
+ pinfo->colType = F_GREYSCALE;
+ sprintf(pinfo->fullInfo, "Greyscale RLE. (%ld bytes)", filesize);
+- for (i=0; i<256; i++)
++ for (i=0; i<256; i++)
+ pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
+ }
+ else {
+@@ -272,7 +284,7 @@
+ pinfo->b[i] = maps[2][i];
+ }
+ }
+-
++
+ sprintf(pinfo->shrtInfo, "%dx%d RLE.",w, h);
+ }
+
+@@ -294,7 +306,7 @@
+ int w, h, ncolors, ncmap;
+ {
+ int posx, posy, plane, bperpix, i, pixval, skipcalls;
+- int opcode, operand, done, c, c1;
++ int opcode, operand, done, c, c1;
+ byte *ip;
+
+ posx = posy = plane = done = skipcalls = 0;
+@@ -324,7 +336,7 @@
+ case RSkipPixelsOp:
+ if (opcode & LONG_OP) { getc(fp); operand = GETINT(fp); }
+ else operand = getc(fp);
+-
++
+ posx += operand;
+ break;
+
+@@ -340,7 +352,7 @@
+ c = getc(fp);
+ if (plane<ncolors && posy<h && (posx+i < w)) *ip = c;
+ }
+-
++
+ if (operand & 1) getc(fp); /* word boundary */
+ posx += operand;
+ break;
+@@ -358,7 +370,7 @@
+ for (i=0; i<operand; i++, ip+=bperpix) {
+ if (plane<ncolors && posy<h && (posx+i < w)) *ip = pixval;
+ }
+-
++
+ /* if (operand & 1) getc(fp); */ /* word boundary */
+ posx += operand;
+ break;
+diff -ruN xv-3.10a/xvroot.c xv-3.10a-bugfixes/xvroot.c
+--- xv-3.10a/xvroot.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvroot.c 2004-05-16 18:04:21.000000000 -0700
+@@ -22,7 +22,7 @@
+ /***********************************/
+ void MakeRootPic()
+ {
+- /* called after 'epic' has been generated (if we're using root).
++ /* called after 'epic' has been generated (if we're using root).
+ creates the XImage and the pixmap, sets the root to the new
+ pixmap, and refreshes the display */
+
+@@ -67,32 +67,32 @@
+
+
+ if (rmode == RM_NORMAL || rmode == RM_TILE) {
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0,
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0,
+ (u_int) eWIDE, (u_int) eHIGH);
+ }
+
+ else if (rmode == RM_MIRROR || rmode == RM_IMIRROR) {
+ /* quadrant 2 */
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0,
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0,
+ (u_int) eWIDE, (u_int) eHIGH);
+ if (epic == NULL) FatalError("epic == NULL in RM_MIRROR code...\n");
+
+ /* quadrant 1 */
+ FlipPic(epic, eWIDE, eHIGH, 0); /* flip horizontally */
+ CreateXImage();
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, eWIDE,0,
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, eWIDE,0,
+ (u_int) eWIDE, (u_int) eHIGH);
+
+ /* quadrant 4 */
+ FlipPic(epic, eWIDE, eHIGH, 1); /* flip vertically */
+ CreateXImage();
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, eWIDE,eHIGH,
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, eWIDE,eHIGH,
+ (u_int) eWIDE, (u_int) eHIGH);
+
+ /* quadrant 3 */
+ FlipPic(epic, eWIDE, eHIGH, 0); /* flip horizontally */
+ CreateXImage();
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,eHIGH,
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,eHIGH,
+ (u_int) eWIDE, (u_int) eHIGH);
+
+ FlipPic(epic, eWIDE, eHIGH, 1); /* flip vertically (back to orig) */
+@@ -122,15 +122,15 @@
+ for (i=ay; i < (int) eHIGH; i+=h) {
+ for (j=ax; j < (int) eWIDE; j+=w) {
+ /* if image goes off tmpPix, only draw subimage */
+-
++
+ x = j; y = i; w1 = w; h1 = h; offx = offy = 0;
+ if (x<0) { offx = -x; w1 -= offx; x = 0; }
+ if (x+w1>eWIDE) { w1 = (eWIDE-x); }
+
+ if (y<0) { offy = -y; h1 -= offy; y = 0; }
+ if (y+h1>eHIGH) { h1 = (eHIGH-y); }
+-
+- XPutImage(theDisp, tmpPix, theGC, theImage, offx, offy,
++
++ XPutImage(theDisp, tmpPix, theGC, theImage, offx, offy,
+ x, y, (u_int) w1, (u_int) h1);
+ }
+ }
+@@ -140,7 +140,7 @@
+
+ else if (rmode == RM_CWARP) { /* warp effect */
+ XSetForeground(theDisp, theGC, rootfg);
+- for (i=0; i<=dispWIDE; i+=8)
++ for (i=0; i<=dispWIDE; i+=8)
+ XDrawLine(theDisp,tmpPix,theGC, i,0, (int) dispWIDE-i,(int) dispHIGH);
+ for (i=0; i<=dispHIGH; i+=8)
+ XDrawLine(theDisp,tmpPix,theGC, 0,i, (int) dispWIDE, (int) dispHIGH-i);
+@@ -150,16 +150,16 @@
+ XSetForeground(theDisp, theGC, rootfg);
+ for (i=k=0; i<dispHIGH; i+=20,k++) {
+ XDrawLine(theDisp, tmpPix, theGC, 0, i, (int) dispWIDE, i);
+- for (j=(k&1) * 20 + 10; j<dispWIDE; j+=40)
++ for (j=(k&1) * 20 + 10; j<dispWIDE; j+=40)
+ XDrawLine(theDisp, tmpPix, theGC, j,i,j,i+20);
+ }
+ }
+
+
+ /* draw the image centered on top of the background */
+- if (rmode != RM_CENTILE)
+- XPutImage(theDisp, tmpPix, theGC, theImage, 0,0,
+- ((int) dispWIDE-eWIDE)/2, ((int) dispHIGH-eHIGH)/2,
++ if (rmode != RM_CENTILE)
++ XPutImage(theDisp, tmpPix, theGC, theImage, 0,0,
++ ((int) dispWIDE-eWIDE)/2, ((int) dispHIGH-eHIGH)/2,
+ (u_int) eWIDE, (u_int) eHIGH);
+ }
+
+@@ -172,7 +172,7 @@
+ if (dispWIDE == eWIDE) {
+ /* horizontal center line */
+ int y, ay;
+-
++
+ y = eHIGH - ((dispHIGH/2)%eHIGH); /* Starting point in picture to copy */
+ ay = 0; /* Vertical anchor point */
+ while (ay < dispHIGH) {
+@@ -189,7 +189,7 @@
+ else if (dispHIGH == eHIGH) {
+ /* vertical centerline */
+ int x, ax;
+-
++
+ x = eWIDE - ((dispWIDE/2)%eWIDE); /* Starting point in picture to copy */
+ ax = 0; /* Horizontal anchor point */
+ while (ax < dispWIDE) {
+@@ -206,10 +206,10 @@
+ else {
+ /* vertical and horizontal centerlines */
+ int x,y, ax,ay;
+-
++
+ y = eHIGH - ((dispHIGH/2)%eHIGH); /* Starting point in picture to copy */
+ ay = 0; /* Vertical anchor point */
+-
++
+ while (ay < dispHIGH) {
+ x = eWIDE - ((dispWIDE/2)%eWIDE);/* Starting point in picture to cpy */
+ ax = 0; /* Horizontal anchor point */
+@@ -276,8 +276,8 @@
+ gc_init.foreground = BlackPixel(theDisp, theScreen);
+ gc_init.background = WhitePixel(theDisp, theScreen);
+ gc = XCreateGC(theDisp, vrootW, GCForeground|GCBackground, &gc_init);
+- pix = XCreatePixmap(theDisp, vrootW, root_weave_width,
+- root_weave_height,
++ pix = XCreatePixmap(theDisp, vrootW, root_weave_width,
++ root_weave_height,
+ (unsigned int) DefaultDepth(theDisp, theScreen));
+
+ XCopyPlane(theDisp, bitmap, pix, gc, 0,0, root_weave_width,
+@@ -333,8 +333,8 @@
+ prop = XInternAtom(theDisp, "_XSETROOT_ID", True);
+ if (prop == None) return; /* no old pixmap to kill */
+
+- if (XGetWindowProperty(theDisp, vrootW, prop, 0L, 1L, True,
+- AnyPropertyType, &type, &format, &length,
++ if (XGetWindowProperty(theDisp, vrootW, prop, 0L, 1L, True,
++ AnyPropertyType, &type, &format, &length,
+ &after, &data) == Success) {
+
+ if (type==XA_PIXMAP && format==32 && length==1 && after==0 && data) {
+@@ -348,4 +348,4 @@
+
+
+
+-
++
+diff -ruN xv-3.10a/xvscrl.c xv-3.10a-bugfixes/xvscrl.c
+--- xv-3.10a/xvscrl.c 1994-12-22 14:34:41.000000000 -0800
++++ xv-3.10a-bugfixes/xvscrl.c 2004-05-16 18:04:25.000000000 -0700
+@@ -1,4 +1,4 @@
+-/*
++/*
+ * xvscrl.c - Scroll Bar handling functions
+ *
+ * callable functions:
+@@ -6,7 +6,7 @@
+ * SCCreate() - creates the Scroll Bar window.
+ * SCChange() - resize/repositions the Scroll Bar window.
+ * SCSetRange() - sets min/max/current values of control
+- * SCSetVal() - sets value of control
++ * SCSetVal() - sets value of control
+ * SCRedraw() - redraws scroll bar
+ * SCTrack() - called when clicked. Operates control 'til mouseup
+ */
+@@ -50,7 +50,7 @@
+
+
+ /***************************************************/
+-void SCCreate(sp, parent, x, y, vert, len, minv, maxv, curv, page,
++void SCCreate(sp, parent, x, y, vert, len, minv, maxv, curv, page,
+ fg, bg, hi, lo, func)
+ SCRL *sp;
+ Window parent;
+@@ -71,7 +71,7 @@
+ downhPix = MakePix1(parent, downh_bits, downh_width, downh_height);
+ uph1Pix = MakePix1(parent, uph1_bits, uph1_width, uph1_height);
+ downh1Pix= MakePix1(parent, downh1_bits, downh1_width, downh1_height);
+-
++
+ sgray = XCreatePixmapFromBitmapData(theDisp, parent,
+ (char *) scrlgray_bits, scrlgray_width, scrlgray_height,
+ fg,bg,dispDEEP);
+@@ -124,7 +124,7 @@
+ sp->len = len;
+ sp->uplit = sp->dnlit = 0;
+
+- if (vert) XMoveResizeWindow(theDisp, sp->win, x,y,
++ if (vert) XMoveResizeWindow(theDisp, sp->win, x,y,
+ (u_int) sp->tsize,(u_int) len);
+ else XMoveResizeWindow(theDisp, sp->win, x,y,
+ (u_int) len, (u_int) sp->tsize);
+@@ -144,7 +144,7 @@
+ if (maxv<minv) maxv=minv;
+ sp->min = minv; sp->max = maxv; sp->page = page;
+ sp->active = (minv < maxv);
+-
++
+ /* adjust scroll bar background */
+ if (sp->active) {
+ if (ctrlColor) XSetWindowBackground(theDisp, sp->win, sp->lo);
+@@ -174,7 +174,7 @@
+
+ sp->val = curv;
+
+- if (sp->active)
++ if (sp->active)
+ sp->tpos = sp->tmin + ((sp->tmax - sp->tmin)*(curv - sp->min))
+ / (sp->max - sp->min);
+
+@@ -194,20 +194,20 @@
+ XSetBackground(theDisp, theGC, sp->bg);
+
+ XClearWindow(theDisp, sp->win);
+-
++
+ drawArrow(sp,UPLINE); /* draw up/down arrows */
+ drawArrow(sp,DNLINE);
+
+ XSetForeground(theDisp, theGC, sp->fg);
+
+- if (sp->vert) {
++ if (sp->vert) {
+ XDrawLine(theDisp, sp->win, theGC, 0, sp->tsize, sp->tsize, sp->tsize);
+- XDrawLine(theDisp, sp->win, theGC, 0, sp->len-sp->tsize-1,
++ XDrawLine(theDisp, sp->win, theGC, 0, sp->len-sp->tsize-1,
+ sp->tsize, sp->len-sp->tsize-1);
+ }
+ else { /* horizontal version */
+ XDrawLine(theDisp, sp->win, theGC, sp->tsize, 0, sp->tsize, sp->tsize);
+- XDrawLine(theDisp, sp->win, theGC, sp->len - sp->tsize-1, 0,
++ XDrawLine(theDisp, sp->win, theGC, sp->len - sp->tsize-1, 0,
+ sp->len - sp->tsize-1, sp->tsize);
+ }
+
+@@ -225,7 +225,7 @@
+
+ if (arr == UPLINE) {
+ XSetForeground(theDisp, theGC, sp->bg);
+- XFillRectangle(theDisp, sp->win, theGC, 0, 0,
++ XFillRectangle(theDisp, sp->win, theGC, 0, 0,
+ (u_int) sp->tsize, (u_int) sp->tsize);
+
+ if (sp->vert) butpix = (sp->uplit) ? up1Pix : upPix;
+@@ -235,14 +235,14 @@
+ XSetBackground(theDisp, theGC, sp->bg);
+ XCopyPlane(theDisp, butpix, sp->win, theGC, 0, 0, up_width,up_height,
+ 3,3, 1L);
+- Draw3dRect(sp->win, 0,0, (u_int) sp->tsize-1, (u_int) sp->tsize-1,
++ Draw3dRect(sp->win, 0,0, (u_int) sp->tsize-1, (u_int) sp->tsize-1,
+ (sp->uplit) ? R3D_IN : R3D_OUT, 2, sp->hi, sp->lo, sp->bg);
+ }
+
+ else if (arr == DNLINE) {
+ if (sp->vert) {
+ XSetForeground(theDisp, theGC, sp->bg);
+- XFillRectangle(theDisp, sp->win, theGC, 0, sp->len - sp->tsize,
++ XFillRectangle(theDisp, sp->win, theGC, 0, sp->len - sp->tsize,
+ (u_int) sp->tsize, (u_int) sp->tsize);
+ butpix = (sp->dnlit) ? down1Pix : downPix;
+
+@@ -251,8 +251,8 @@
+ XCopyPlane(theDisp, butpix, sp->win, theGC, 0, 0, up_width,up_height,
+ 3, sp->len - 3 - up_height, 1L);
+
+- Draw3dRect(sp->win, 0, sp->len - sp->tsize,
+- (u_int) sp->tsize-1, (u_int) sp->tsize-1,
++ Draw3dRect(sp->win, 0, sp->len - sp->tsize,
++ (u_int) sp->tsize-1, (u_int) sp->tsize-1,
+ (sp->dnlit) ? R3D_IN : R3D_OUT, 2, sp->hi, sp->lo, sp->bg);
+ }
+
+@@ -267,8 +267,8 @@
+ XCopyPlane(theDisp, butpix, sp->win, theGC, 0, 0, up_width,up_height,
+ sp->len - 3 - up_width, 3, 1L);
+
+- Draw3dRect(sp->win, sp->len - sp->tsize, 0,
+- (u_int) sp->tsize-1, (u_int) sp->tsize-1,
++ Draw3dRect(sp->win, sp->len - sp->tsize, 0,
++ (u_int) sp->tsize-1, (u_int) sp->tsize-1,
+ (sp->dnlit) ? R3D_IN : R3D_OUT, 2, sp->hi, sp->lo, sp->bg);
+ }
+ }
+@@ -283,17 +283,17 @@
+ {
+ if (sp->vert) {
+ /* clear out thumb area with background color */
+- XClearArea(theDisp, sp->win, 0, sp->tsize+1, (u_int) sp->tsize,
++ XClearArea(theDisp, sp->win, 0, sp->tsize+1, (u_int) sp->tsize,
+ (u_int) ((sp->len-sp->tsize-1)-(sp->tsize+1)), False);
+
+ if (sp->active) { /* a thumb is necessary */
+
+ XSetForeground(theDisp, theGC, sp->bg);
+- XFillRectangle(theDisp, sp->win, theGC, 1, sp->tpos+1,
++ XFillRectangle(theDisp, sp->win, theGC, 1, sp->tpos+1,
+ (u_int) (sp->tsize-2), (u_int) (sp->tsize-2));
+
+ XSetForeground(theDisp, theGC, sp->fg);
+- XDrawRectangle(theDisp, sp->win, theGC, 0, sp->tpos,
++ XDrawRectangle(theDisp, sp->win, theGC, 0, sp->tpos,
+ (u_int) (sp->tsize-1), (u_int) (sp->tsize-1));
+
+ XDrawLine(theDisp, sp->win, theGC, 9-3, sp->tpos+6, 9+3, sp->tpos+6);
+@@ -301,7 +301,7 @@
+ XDrawLine(theDisp, sp->win, theGC, 9-3, sp->tpos+10,9+3, sp->tpos+10);
+ XDrawLine(theDisp, sp->win, theGC, 9-3, sp->tpos+12,9+3, sp->tpos+12);
+
+- Draw3dRect(sp->win, 1, sp->tpos+1,
++ Draw3dRect(sp->win, 1, sp->tpos+1,
+ (u_int) sp->tsize-3, (u_int) sp->tsize-3, R3D_OUT,2,
+ sp->hi, sp->lo, sp->bg);
+ }
+@@ -309,17 +309,17 @@
+
+ else { /* horizontal */
+ /* clear out thumb area with background color */
+- XClearArea(theDisp, sp->win, sp->tsize+1, 0,
+- (u_int) ((sp->len-sp->tsize-1)-(sp->tsize+1)),
++ XClearArea(theDisp, sp->win, sp->tsize+1, 0,
++ (u_int) ((sp->len-sp->tsize-1)-(sp->tsize+1)),
+ (u_int) sp->tsize, False);
+
+ if (sp->active) { /* a thumb is necessary */
+ XSetForeground(theDisp, theGC, sp->bg);
+- XFillRectangle(theDisp, sp->win, theGC, sp->tpos+1, 1,
++ XFillRectangle(theDisp, sp->win, theGC, sp->tpos+1, 1,
+ (u_int) (sp->tsize-2), (u_int) (sp->tsize-2));
+
+ XSetForeground(theDisp, theGC, sp->fg);
+- XDrawRectangle(theDisp, sp->win, theGC, sp->tpos, 0,
++ XDrawRectangle(theDisp, sp->win, theGC, sp->tpos, 0,
+ (u_int) (sp->tsize-1), (u_int) (sp->tsize-1));
+
+ XDrawLine(theDisp, sp->win, theGC, sp->tpos+6, 9-3, sp->tpos+6, 9+3);
+@@ -327,7 +327,7 @@
+ XDrawLine(theDisp, sp->win, theGC, sp->tpos+10,9-3, sp->tpos+10,9+3);
+ XDrawLine(theDisp, sp->win, theGC, sp->tpos+12,9-3, sp->tpos+12,9+3);
+
+- Draw3dRect(sp->win, sp->tpos+1, 1,
++ Draw3dRect(sp->win, sp->tpos+1, 1,
+ (u_int) sp->tsize-3, (u_int) sp->tsize-3, R3D_OUT,2,
+ sp->hi, sp->lo, sp->bg);
+ }
+@@ -450,8 +450,8 @@
+ case DNLINE: /* arrows */
+ pos = whereInScrl(sp,x,y);
+ if (pos == ipos) {
+- if (!lit) {
+- lit = 1;
++ if (!lit) {
++ lit = 1;
+ if (ipos == UPLINE) { sp->uplit = 1; drawArrow(sp,UPLINE); }
+ else { sp->dnlit = 1; drawArrow(sp,DNLINE); }
+ }
+@@ -467,16 +467,16 @@
+ }
+ }
+ }
+-
++
+ else {
+- if (lit) {
+- lit = 0;
++ if (lit) {
++ lit = 0;
+ if (ipos == UPLINE) { sp->uplit = 0; drawArrow(sp,UPLINE); }
+ else { sp->dnlit = 0; drawArrow(sp,DNLINE); }
+ }
+ }
+ break;
+-
++
+ }
+ }
+
+diff -ruN xv-3.10a/xvsmooth.c xv-3.10a-bugfixes/xvsmooth.c
+--- xv-3.10a/xvsmooth.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvsmooth.c 2004-05-16 18:04:28.000000000 -0700
+@@ -4,11 +4,11 @@
+ * Contains:
+ * byte *SmoothResize(src8, swide, shigh, dwide, dhigh,
+ * rmap, gmap, bmap, rdmap, gdmap, bdmap, maplen)
+- * byte *Smooth24(pic824, is24, swide, shigh, dwide, dhigh,
++ * byte *Smooth24(pic824, is24, swide, shigh, dwide, dhigh,
+ * rmap, gmap, bmap)
+- * byte *DoColorDither(pic24, pic8, w, h, rmap,gmap,bmap,
++ * byte *DoColorDither(pic24, pic8, w, h, rmap,gmap,bmap,
+ * rdisp, gdisp, bdisp, maplen)
+- * byte *Do332ColorDither(pic24, pic8, w, h, rmap,gmap,bmap,
++ * byte *Do332ColorDither(pic24, pic8, w, h, rmap,gmap,bmap,
+ * rdisp, gdisp, bdisp, maplen)
+ */
+
+@@ -18,21 +18,21 @@
+
+ static int smoothX PARM((byte *, byte *, int, int, int, int, int,
+ byte *, byte *, byte *));
+-static int smoothY PARM((byte *, byte *, int, int, int, int, int,
++static int smoothY PARM((byte *, byte *, int, int, int, int, int,
+ byte *, byte *, byte *));
+ static int smoothXY PARM((byte *, byte *, int, int, int, int, int,
+ byte *, byte *, byte *));
+
+
+ /***************************************************/
+-byte *SmoothResize(srcpic8, swide, shigh, dwide, dhigh,
++byte *SmoothResize(srcpic8, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap, rdmap, gdmap, bdmap, maplen)
+ byte *srcpic8, *rmap, *gmap, *bmap, *rdmap, *gdmap, *bdmap;
+ int swide, shigh, dwide, dhigh, maplen;
+ {
+- /* generic interface to Smooth and ColorDither code.
+- given an 8-bit-per, swide * shigh image with colormap rmap,gmap,bmap,
+- will generate a new 8-bit-per, dwide * dhigh image, which is dithered
++ /* generic interface to Smooth and ColorDither code.
++ given an 8-bit-per, swide * shigh image with colormap rmap,gmap,bmap,
++ will generate a new 8-bit-per, dwide * dhigh image, which is dithered
+ using colors found in rdmap, gdmap, bdmap arrays */
+
+ /* returns ptr to a dwide*dhigh array of bytes, or NULL on failure */
+@@ -50,7 +50,7 @@
+
+ return (byte *) NULL;
+ }
+-
++
+
+
+ /***************************************************/
+@@ -83,23 +83,23 @@
+ bperpix = (is24) ? 3 : 1;
+
+ /* decide which smoothing routine to use based on type of expansion */
+- if (dwide < swide && dhigh < shigh)
++ if (dwide < swide && dhigh < shigh)
+ retval = smoothXY(pic24, pic824, is24, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap);
+
+- else if (dwide < swide && dhigh >= shigh)
++ else if (dwide < swide && dhigh >= shigh)
+ retval = smoothX (pic24, pic824, is24, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap);
+
+- else if (dwide >= swide && dhigh < shigh)
++ else if (dwide >= swide && dhigh < shigh)
+ retval = smoothY (pic24, pic824, is24, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap);
+
+ else {
+ /* dwide >= swide && dhigh >= shigh */
+
+- /* cx,cy = original pixel in pic824. px,py = relative position
+- of pixel ex,ey inside of cx,cy as percentages +-50%, +-50%.
++ /* cx,cy = original pixel in pic824. px,py = relative position
++ of pixel ex,ey inside of cx,cy as percentages +-50%, +-50%.
+ 0,0 = middle of pixel */
+
+ /* we can save a lot of time by precomputing cxtab[] and pxtab[], both
+@@ -115,10 +115,10 @@
+
+ for (ex=0; ex<dwide; ex++) {
+ cxtab[ex] = (ex * swide) / dwide;
+- pxtab[ex] = (((ex * swide)* 100) / dwide)
++ pxtab[ex] = (((ex * swide)* 100) / dwide)
+ - (cxtab[ex] * 100) - 50;
+ }
+-
++
+ for (ey=0; ey<dhigh; ey++) {
+ byte *pptr, rA, gA, bA, rB, gB, bB, rC, gC, bC, rD, gD, bD;
+
+@@ -162,7 +162,7 @@
+ cC = pic824[cyOff + x1]; /* left/right center pixel */
+ cD = pic824[cyOff + cx]; /* center pixel */
+ }
+-
++
+ /* quick check */
+ if (!is24 && cA == cB && cB == cC && cC == cD) {
+ /* set this pixel to the same color as in pic8 */
+@@ -178,30 +178,30 @@
+ pD = 100 - (pA + pB + pC);
+
+ if (is24) {
+- *pp++ = ((int) (pA * rA))/100 + ((int) (pB * rB))/100 +
++ *pp++ = ((int) (pA * rA))/100 + ((int) (pB * rB))/100 +
+ ((int) (pC * rC))/100 + ((int) (pD * rD))/100;
+
+- *pp++ = ((int) (pA * gA))/100 + ((int) (pB * gB))/100 +
++ *pp++ = ((int) (pA * gA))/100 + ((int) (pB * gB))/100 +
+ ((int) (pC * gC))/100 + ((int) (pD * gD))/100;
+
+- *pp++ = ((int) (pA * bA))/100 + ((int) (pB * bB))/100 +
++ *pp++ = ((int) (pA * bA))/100 + ((int) (pB * bB))/100 +
+ ((int) (pC * bC))/100 + ((int) (pD * bD))/100;
+ }
+ else { /* 8-bit pic */
+- *pp++ = ((int) (pA * rmap[cA]))/100 + ((int)(pB * rmap[cB]))/100 +
++ *pp++ = ((int) (pA * rmap[cA]))/100 + ((int)(pB * rmap[cB]))/100 +
+ ((int) (pC * rmap[cC]))/100 + ((int)(pD * rmap[cD]))/100;
+
+- *pp++ = ((int) (pA * gmap[cA]))/100 + ((int)(pB * gmap[cB]))/100 +
++ *pp++ = ((int) (pA * gmap[cA]))/100 + ((int)(pB * gmap[cB]))/100 +
+ ((int) (pC * gmap[cC]))/100 + ((int)(pD * gmap[cD]))/100;
+
+- *pp++ = ((int)(pA * bmap[cA]))/100 + ((int)(pB * bmap[cB]))/100 +
++ *pp++ = ((int)(pA * bmap[cA]))/100 + ((int)(pB * bmap[cB]))/100 +
+ ((int)(pC * bmap[cC]))/100 + ((int)(pD * bmap[cD]))/100;
+ }
+ }
+ }
+ }
+
+- free(cxtab);
++ free(cxtab);
+ free(pxtab);
+ retval = 0; /* okay */
+ }
+@@ -218,7 +218,7 @@
+
+
+ /***************************************************/
+-static int smoothX(pic24, pic824, is24, swide, shigh, dwide, dhigh,
++static int smoothX(pic24, pic824, is24, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap)
+ byte *pic24, *pic824, *rmap, *gmap, *bmap;
+ int is24, swide, shigh, dwide, dhigh;
+@@ -253,7 +253,7 @@
+
+ bperpix = (is24) ? 3 : 1;
+
+- for (j=0; j<=swide; j++)
++ for (j=0; j<=swide; j++)
+ pixarr[j] = (j*dwide + (15*swide)/16) / swide;
+
+ cptr = pic824; cptr1 = cptr + swide * bperpix;
+@@ -280,7 +280,7 @@
+ lbufG[j] = ((int) ((*cptr++ * pcnt0) + (*cptr1++ * pcnt1))) >> 6;
+ lbufB[j] = ((int) ((*cptr++ * pcnt0) + (*cptr1++ * pcnt1))) >> 6;
+ }
+- }
++ }
+ else { /* 8-bit input pic */
+ for (j=0; j<swide; j++, cptr++, cptr1++) {
+ lbufR[j] = ((int)((rmap[*cptr]* pcnt0) + (rmap[*cptr1]* pcnt1))) >> 6;
+@@ -314,8 +314,8 @@
+ return 0;
+ }
+
+-
+-
++
++
+
+
+
+@@ -405,7 +405,7 @@
+ lbufB[j] += ((int)((bmap[*cptr]*pct0[j])+(bmap[*cptr1]*pct1[j]))) >> 6;
+ }
+ }
+-
++
+ linecnt++;
+ }
+
+@@ -421,13 +421,13 @@
+ return retval;
+ }
+
+-
+-
++
++
+
+
+
+ /***************************************************/
+-static int smoothXY(pic24, pic824, is24, swide, shigh, dwide, dhigh,
++static int smoothXY(pic24, pic824, is24, swide, shigh, dwide, dhigh,
+ rmap, gmap, bmap)
+ byte *pic24, *pic824, *rmap, *gmap, *bmap;
+ int is24, swide, shigh, dwide, dhigh;
+@@ -462,7 +462,7 @@
+
+ bperpix = (is24) ? 3 : 1;
+
+- for (j=0; j<=swide; j++)
++ for (j=0; j<=swide; j++)
+ pixarr[j] = (j*dwide + (15*swide)/16) / swide;
+
+ lastline = linecnt = pixR = pixG = pixB = 0;
+@@ -526,20 +526,20 @@
+ return 0;
+ }
+
+-
+-
++
++
+
+ /********************************************/
+-byte *DoColorDither(pic24, pic8, w, h, rmap, gmap, bmap,
++byte *DoColorDither(pic24, pic8, w, h, rmap, gmap, bmap,
+ rdisp, gdisp, bdisp, maplen)
+ byte *pic24, *pic8, *rmap, *gmap, *bmap, *rdisp, *gdisp, *bdisp;
+ int w, h, maplen;
+ {
+ /* takes a 24 bit picture, of size w*h, dithers with the colors in
+ rdisp, gdisp, bdisp (which have already been allocated),
+- and generates an 8-bit w*h image, which it returns.
++ and generates an 8-bit w*h image, which it returns.
+ ignores input value 'pic8'
+- returns NULL on error
++ returns NULL on error
+
+ note: the rdisp,gdisp,bdisp arrays should be the 'displayed' colors,
+ not the 'desired' colors
+@@ -547,7 +547,7 @@
+ if pic24 is NULL, uses the passed-in pic8 (an 8-bit image) as
+ the source, and the rmap,gmap,bmap arrays as the desired colors */
+
+- byte *np, *ep, *newpic;
++ byte *np, *ep, *newpic;
+ short *cache;
+ int r2, g2, b2;
+ int *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
+@@ -558,11 +558,11 @@
+ int fserrmap[512]; /* -255 .. 0 .. +255 */
+
+ /* compute somewhat non-linear floyd-steinberg error mapping table */
+- for (i=j=0; i<=0x40; i++,j++)
++ for (i=j=0; i<=0x40; i++,j++)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+- for ( ; i<0x80; i++, j += !(i&1) ? 1 : 0)
++ for ( ; i<0x80; i++, j += !(i&1) ? 1 : 0)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+- for ( ; i<=0xff; i++)
++ for ( ; i<=0xff; i++)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+
+
+@@ -575,7 +575,7 @@
+ cache = (short *) calloc((size_t) (2<<14), sizeof(short));
+ thisline = (int *) malloc(pwide3 * sizeof(int));
+ nextline = (int *) malloc(pwide3 * sizeof(int));
+- if (!cache || !newpic || !thisline || !nextline) {
++ if (!cache || !newpic || !thisline || !nextline) {
+ if (newpic) free(newpic);
+ if (cache) free(cache);
+ if (thisline) free(thisline);
+@@ -624,30 +624,30 @@
+
+ r2 = *thisptr++; g2 = *thisptr++; b2 = *thisptr++;
+
+- /* map r2,g2,b2 components (could be outside 0..255 range)
++ /* map r2,g2,b2 components (could be outside 0..255 range)
+ into 0..255 range */
+-
++
+ if (r2<0 || g2<0 || b2<0) { /* are there any negatives in RGB? */
+ if (r2<g2) { if (r2<b2) k = 0; else k = 2; }
+ else { if (g2<b2) k = 1; else k = 2; }
+
+ switch (k) {
+ case 0: g2 -= r2; b2 -= r2; d = (abs(r2) * 3) / 2; /* RED */
+- r2 = 0;
++ r2 = 0;
+ g2 = (g2>d) ? g2 - d : 0;
+ b2 = (b2>d) ? b2 - d : 0;
+ break;
+
+ case 1: r2 -= g2; b2 -= g2; d = (abs(g2) * 3) / 2; /* GREEN */
+ r2 = (r2>d) ? r2 - d : 0;
+- g2 = 0;
++ g2 = 0;
+ b2 = (b2>d) ? b2 - d : 0;
+ break;
+
+ case 2: r2 -= b2; g2 -= b2; d = (abs(b2) * 3) / 2; /* BLUE */
+ r2 = (r2>d) ? r2 - d : 0;
+ g2 = (g2>d) ? g2 - d : 0;
+- b2 = 0;
++ b2 = 0;
+ break;
+ }
+ }
+@@ -674,7 +674,7 @@
+ mind = 10000;
+ for (k=closest=0; k<maplen && mind>7; k++) {
+ d = abs(r2 - rdisp[k])
+- + abs(g2 - gdisp[k])
++ + abs(g2 - gdisp[k])
+ + abs(b2 - bdisp[k]);
+ if (d<mind) { mind = d; closest = k; }
+ }
+@@ -703,7 +703,7 @@
+ thisptr[1] += (gerr*7)/16;
+ thisptr[2] += (berr*7)/16;
+ }
+-
++
+ if (i!=imax) { /* do BOTTOM pixel */
+ nextptr[0] += (rerr*5)/16;
+ nextptr[1] += (gerr*5)/16;
+@@ -735,7 +735,7 @@
+
+
+ /********************************************/
+-byte *Do332ColorDither(pic24, pic8, w, h, rmap, gmap, bmap,
++byte *Do332ColorDither(pic24, pic8, w, h, rmap, gmap, bmap,
+ rdisp, gdisp, bdisp, maplen)
+ byte *pic24, *pic8, *rmap, *gmap, *bmap, *rdisp, *gdisp, *bdisp;
+ int w, h, maplen;
+@@ -744,9 +744,9 @@
+
+ /* takes a 24 bit picture, of size w*h, dithers with the colors in
+ rdisp, gdisp, bdisp (which have already been allocated),
+- and generates an 8-bit w*h image, which it returns.
++ and generates an 8-bit w*h image, which it returns.
+ ignores input value 'pic8'
+- returns NULL on error
++ returns NULL on error
+
+ note: the rdisp,gdisp,bdisp arrays should be the 'displayed' colors,
+ not the 'desired' colors
+@@ -754,7 +754,7 @@
+ if pic24 is NULL, uses the passed-in pic8 (an 8-bit image) as
+ the source, and the rmap,gmap,bmap arrays as the desired colors */
+
+- byte *np, *ep, *newpic;
++ byte *np, *ep, *newpic;
+ int r2, g2, b2;
+ int *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
+ int i, j, rerr, gerr, berr, pwide3;
+@@ -763,11 +763,11 @@
+ int fserrmap[512]; /* -255 .. 0 .. +255 */
+
+ /* compute somewhat non-linear floyd-steinberg error mapping table */
+- for (i=j=0; i<=0x40; i++,j++)
++ for (i=j=0; i<=0x40; i++,j++)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+- for ( ; i<0x80; i++, j += !(i&1) ? 1 : 0)
++ for ( ; i<0x80; i++, j += !(i&1) ? 1 : 0)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+- for ( ; i<=0xff; i++)
++ for ( ; i<=0xff; i++)
+ { fserrmap[256+i] = j; fserrmap[256-i] = -j; }
+
+
+@@ -778,7 +778,7 @@
+ newpic = (byte *) malloc((size_t) (w * h));
+ thisline = (int *) malloc(pwide3 * sizeof(int));
+ nextline = (int *) malloc(pwide3 * sizeof(int));
+- if (!newpic || !thisline || !nextline) {
++ if (!newpic || !thisline || !nextline) {
+ if (newpic) free(newpic);
+ if (thisline) free(thisline);
+ if (nextline) free(nextline);
+@@ -830,7 +830,7 @@
+
+
+ for (j=0; j<w; j++) {
+- int k, d, mind, closest, rb,gb,bb;
++ int rb,gb,bb;
+
+ r2 = *thisptr++; g2 = *thisptr++; b2 = *thisptr++;
+ if (i&1) thisptr -= 6; /* move left */
+@@ -846,7 +846,7 @@
+ bb = (b2 + 0x20); /* round 2 bits */
+ RANGE(bb,0,255);
+ bb = bb & 0xc0;
+-
++
+
+ *np = rb | (gb>>3) | (bb>>6);
+
+diff -ruN xv-3.10a/xvsunras.c xv-3.10a-bugfixes/xvsunras.c
+--- xv-3.10a/xvsunras.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvsunras.c 2005-04-02 18:04:20.000000000 -0800
+@@ -54,8 +54,8 @@
+ PICINFO *pinfo;
+ {
+ FILE *fp;
+- int linesize,lsize,csize,isize,i,w,h,d;
+- byte *image, *line, *pic8;
++ int linesize,lsize,csize,isize,i,w,h,d,npixels,nbytes;
++ byte *image, *line;
+ struct rasterfile sunheader;
+ char *bname;
+
+@@ -85,7 +85,7 @@
+ sunheader.ras_depth != 8 &&
+ sunheader.ras_depth != 24 &&
+ sunheader.ras_depth != 32) {
+- fprintf (stderr, "Sun rasterfile image has depth %d\n",
++ fprintf (stderr, "Sun rasterfile image has depth %d\n",
+ sunheader.ras_depth);
+ fprintf (stderr, "Depths supported are 1, 8, 24, and 32\n");
+ fclose(fp);
+@@ -115,26 +115,59 @@
+
+ w = sunheader.ras_width;
+ h = sunheader.ras_height;
+- d = sunheader.ras_depth;
+- isize = sunheader.ras_length ?
+- sunheader.ras_length :
+- (w * h * d) / 8;
++ d = sunheader.ras_depth; /* 1, 8, 24, or 32 (above) */
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h) {
++ fprintf (stderr, "Sun rasterfile image has invalid dimensions (%dx%d)\n",
++ w, h);
++ fclose(fp);
++ return 0;
++ }
++ if (d == 1)
++ nbytes = npixels/8; /* should round up here, but used only for printf */
++ else {
++ nbytes = npixels * (d/8);
++/*
++ [nbytes (isize) used only in printfs; don't really care about overflows]
++ if (nbytes/npixels != (d/8)) {
++ fprintf (stderr, "Sun rasterfile has invalid dimensions (%dx%dx%d)\n",
++ w, h, d);
++ fclose(fp);
++ return 0;
++ }
++ */
++ }
++ isize = sunheader.ras_length ? sunheader.ras_length : nbytes;
+ csize = (sunheader.ras_maptype == RMT_NONE) ? 0 : sunheader.ras_maplength;
+
+
+- /* compute length of the output (xv-format) image */
+- lsize = w * h;
+- if (d == 24 || d == 32) lsize = lsize * 3;
++ /* length of the output (xv-format) image */
++ lsize = npixels;
++ if (d == 24 || d == 32) {
++ lsize *= 3;
++ if (lsize/3 != npixels) {
++ fprintf (stderr, "Sun rasterfile has invalid dimensions (%dx%dx%d)\n",
++ w, h, d);
++ fclose(fp);
++ return 0;
++ }
++ }
+
+
+ linesize = w * d;
++ if (linesize/w != d || linesize + 15 < linesize) {
++ fprintf (stderr, "Sun rasterfile has invalid dimensions (%dx%dx%d)\n",
++ w, h, d);
++ fclose(fp);
++ return 0;
++ }
+ if (linesize % 16) linesize += (16 - (linesize % 16));
+ linesize /= 8;
+
+ if (DEBUG) {
+ fprintf(stderr,"%s: LoadSunRas() - loading a %dx%d pic, %d planes\n",
+ cmd, w, h, d);
+- fprintf (stderr,
++ fprintf (stderr,
+ "type %d, maptype %d, isize %d, csize %d, lsize %d, linesize %d\n",
+ sunheader.ras_type, sunheader.ras_maptype,
+ isize, csize, lsize, linesize);
+@@ -188,13 +221,13 @@
+ }
+
+ switch (d) {
+- case 1: sunRas1to8 (image + w * i, line, w);
++ case 1: sunRas1to8 (image + w * i, line, w);
+ break;
+ case 8: xvbcopy((char *) line, (char *) image + w * i, (size_t) w);
+ break;
+ case 24: xvbcopy((char *) line, (char *) image + w * i * 3, (size_t) w*3);
+ break;
+-
++
+ case 32:
+ {
+ int k;
+@@ -202,7 +235,7 @@
+ ip = line;
+ op = (byte *) (image + w * i * 3);
+ for (k = 0; k<w; k++) {
+- *ip++; /* skip 'alpha' */
++ ip++; /* skip 'alpha' */
+ *op++ = *ip++; /* red */
+ *op++ = *ip++; /* green */
+ *op++ = *ip++; /* blue */
+@@ -210,9 +243,9 @@
+ }
+ }
+ }
+-
++
+ free(line);
+-
++
+ if (DEBUG) fprintf(stderr,"Sun ras: image loaded!\n");
+
+
+@@ -224,7 +257,7 @@
+ else pinfo->type = PIC8;
+
+ pinfo->pic = image;
+- pinfo->w = w;
++ pinfo->w = w;
+ pinfo->h = h;
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->frmType = F_SUNRAS;
+@@ -364,10 +397,15 @@
+
+ /* special case: if PIC24 and writing GREYSCALE, write 8-bit file */
+ if (ptype == PIC24 && colorstyle == F_GREYSCALE) {
+- graypic = (byte *) malloc((size_t) w*h);
++ int npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h) {
++ SetISTR(ISTR_WARNING, "Image is too large (%dx%d)", w, h);
++ return (2);
++ }
++ graypic = (byte *) malloc((size_t) npixels);
+ if (!graypic) FatalError("unable to malloc in WriteSunRas()");
+-
+- for (i=0,sp=pic,dp=graypic; i<w*h; i++,sp+=3,dp++) {
++
++ for (i=0,sp=pic,dp=graypic; i<npixels; i++,sp+=3,dp++) {
+ *dp = MONO(sp[0],sp[1],sp[2]);
+ }
+
+@@ -379,9 +417,18 @@
+ }
+
+
+- if (ptype==PIC24) { d = 24; linesize = w * 3; }
+- else if (colorstyle != F_BWDITHER) { d = 8; linesize = w; }
+- else {
++ if (ptype==PIC24) {
++ d = 24;
++ linesize = w * 3;
++ if (linesize/w != 3) {
++ SetISTR(ISTR_WARNING, "Image is too wide (%d)", w);
++ if (graypic) free(graypic);
++ return (2);
++ }
++ } else if (colorstyle != F_BWDITHER) {
++ d = 8;
++ linesize = w;
++ } else {
+ d = 1;
+ linesize = w;
+ if (linesize % 8) linesize += (8 - linesize % 8);
+@@ -391,6 +438,11 @@
+
+
+ if (linesize % 2) linesize++;
++ if (linesize == 0) {
++ SetISTR(ISTR_WARNING, "Image is too wide (%d)", w);
++ if (graypic) free(graypic);
++ return (2);
++ }
+ line = (byte *) malloc((size_t) linesize);
+ if (!line) {
+ SetISTR(ISTR_WARNING, "Can't allocate memory for save!\n");
+@@ -428,7 +480,7 @@
+ write_sun_long (sunheader.ras_maplength, fp);
+
+ /* write the colormap */
+- if (d == 8)
++ if (d == 8) {
+ if (colorstyle == 1) /* grayscale */
+ for (color=0; color<3; color++)
+ for (i=0; i<numcols; i++)
+@@ -438,6 +490,7 @@
+ fwrite (gmap, sizeof(byte), (size_t) numcols, fp);
+ fwrite (bmap, sizeof(byte), (size_t) numcols, fp);
+ }
++ }
+
+
+ /* write the image */
+diff -ruN xv-3.10a/xvtarga.c xv-3.10a-bugfixes/xvtarga.c
+--- xv-3.10a/xvtarga.c 1994-12-22 14:34:55.000000000 -0800
++++ xv-3.10a-bugfixes/xvtarga.c 2005-03-31 07:33:07.000000000 -0800
+@@ -17,8 +17,8 @@
+ * 0:
+ * 1: colormap type
+ * 2: image type (1=colmap RGB, 2=uncomp RGB, 3=uncomp gray)
+- * 3:
+- * 4:
++ * 3:
++ * 4:
+ * 5: colormap_length, low byte
+ * 6: colormap_length, high byte
+ * 7: bits per cmap entry (8, 24, 32)
+@@ -28,7 +28,7 @@
+ * 14: height, low byte
+ * 15: height, high byte
+ * 16: bits per pixel (8, 24)
+- * 17: flags
++ * 17: flags
+ */
+
+
+@@ -48,7 +48,7 @@
+ /* returns '1' on success */
+
+ FILE *fp;
+- int i, row, c, c1, w, h, r, g, b, flags, intlace, topleft, trunc;
++ int i, row, c, c1, w, h, npixels, bufsize, flags, intlace, topleft, trunc;
+ byte *pic24, *pp;
+
+ bname = BaseName(fname);
+@@ -88,7 +88,9 @@
+ c=getc(fp); c1=getc(fp);
+ h = c1*256 + c;
+
+- if (w<1 || h<1) {
++ npixels = w * h;
++ bufsize = 3 * npixels;
++ if (w <= 0 || h <= 0 || npixels/w != h || bufsize/3 != npixels) {
+ fclose(fp);
+ SetISTR(ISTR_WARNING,"%s: error in Targa header (bad image size)", bname);
+ return 0;
+@@ -115,7 +117,7 @@
+ #endif
+
+
+- pic24 = (byte *) calloc((size_t) w*h*3, (size_t) 1);
++ pic24 = (byte *) calloc((size_t) bufsize, (size_t) 1);
+ if (!pic24) FatalError("couldn't malloc 'pic24'");
+
+
+@@ -134,7 +136,7 @@
+ if (i < h / 2) row = 2 * i;
+ else row = 2 * (i - h/2) + 1;
+ }
+-
++
+ else row = i; /* no interlace */
+
+
+@@ -150,7 +152,7 @@
+
+
+ /* swap R,B values (file is in BGR, pic24 should be in RGB) */
+- for (i=0, pp=pic24; i<w*h; i++, pp+=3) {
++ for (i=0, pp=pic24; i<npixels; i++, pp+=3) {
+ c = pp[0]; pp[0] = pp[2]; pp[2] = c;
+ }
+
+@@ -185,7 +187,7 @@
+
+ /* write the header */
+ for (i=0; i<12; i++) putc( (i==2) ? 2 : 0, fp);
+-
++
+ putc(w&0xff, fp);
+ putc((w>>8)&0xff,fp);
+ putc(h&0xff, fp);
+diff -ruN xv-3.10a/xvtext.c xv-3.10a-bugfixes/xvtext.c
+--- xv-3.10a/xvtext.c 1995-01-13 15:46:28.000000000 -0800
++++ xv-3.10a-bugfixes/xvtext.c 2004-05-16 18:04:38.000000000 -0700
+@@ -1,6 +1,6 @@
+ /*
+ * xvtext.c - text file display window routines
+- *
++ *
+ * includes:
+ * void CreateTextWins(geom, cmtgeom);
+ * void OpenTextView(text, textlen, title, freeonclose);
+@@ -98,8 +98,7 @@
+ XSizeHints hints;
+ XSetWindowAttributes xswa;
+ TVINFO *tv;
+- int gx,gy,gw,gh,gset,gx1,gy1;
+-
++
+
+ mfwide = monofinfo->max_bounds.width;
+ mfhigh = monofinfo->ascent + monofinfo->descent;
+@@ -120,10 +119,10 @@
+ tv = &tinfo[i];
+
+ tv->win = CreateWindow((i<CMTWIN) ? "xv text viewer" : "xv image comments",
+- "XVtextview",
+- (i<CMTWIN) ? geom : cmtgeom,
+- defwide,
+- (i<CMTWIN) ? defhigh : cmthigh,
++ "XVtextview",
++ (i<CMTWIN) ? geom : cmtgeom,
++ defwide,
++ (i<CMTWIN) ? defhigh : cmthigh,
+ infofg, infobg, 1);
+ if (!tv->win) FatalError("can't create textview window!");
+
+@@ -135,17 +134,17 @@
+
+ /* note: everything is sized and positioned in resizeText() */
+
+- tv->textW = XCreateSimpleWindow(theDisp, tv->win, 1,1, 100,100,
++ tv->textW = XCreateSimpleWindow(theDisp, tv->win, 1,1, 100,100,
+ 1,infofg,infobg);
+ if (!tv->textW) FatalError("can't create textview text window!");
+
+- SCCreate(&(tv->vscrl), tv->win, 0,0, 1,100, 0,0,0,0,
++ SCCreate(&(tv->vscrl), tv->win, 0,0, 1,100, 0,0,0,0,
+ infofg, infobg, hicol, locol, drawTextW);
+
+- SCCreate(&(tv->hscrl), tv->win, 0,0, 0,100, 0,0,0,0,
++ SCCreate(&(tv->hscrl), tv->win, 0,0, 0,100, 0,0,0,0,
+ infofg, infobg, hicol, locol, drawTextW);
+
+- if (XGetNormalHints(theDisp, tv->win, &hints))
++ if (XGetNormalHints(theDisp, tv->win, &hints))
+ hints.flags |= PMinSize;
+ else
+ hints.flags = PMinSize;
+@@ -162,7 +161,7 @@
+
+ XSelectInput(theDisp, tv->textW, ExposureMask | ButtonPressMask);
+
+-
++
+ BTCreate(&(tv->but[TV_ASCII]), tv->win, 0,0,BUTTW,BUTTH,
+ "Ascii",infofg,infobg,hicol,locol);
+ BTCreate(&(tv->but[TV_HEX]), tv->win, 0,0,BUTTW,BUTTH,
+@@ -185,7 +184,7 @@
+ for (i=0; i<MAXTVWIN; i++) {
+ resizeText(&tinfo[i], defwide, (i<CMTWIN) ? defhigh : cmthigh);
+
+- XSelectInput(theDisp, tinfo[i].win, ExposureMask | ButtonPressMask |
++ XSelectInput(theDisp, tinfo[i].win, ExposureMask | ButtonPressMask |
+ KeyPressMask | StructureNotifyMask);
+ }
+
+@@ -200,7 +199,6 @@
+ {
+ /* given a filename, attempts to read in the file and open a textview win */
+
+- int i;
+ long textlen;
+ char *text, buf[512], title[128], rfname[MAXPATHLEN+1];
+ char *basefname[128]; /* just current fname, no path */
+@@ -222,7 +220,7 @@
+ if (!UncompressFile(basefname, rfname)) return;/* failed to uncompress */
+ #endif
+ }
+-
++
+
+
+ fp = fopen(rfname, "r");
+@@ -246,7 +244,7 @@
+
+ text = (char *) malloc((size_t) textlen);
+ if (!text) {
+- sprintf(buf, "Couldn't malloc %ld bytes to read file '%s'",
++ sprintf(buf, "Couldn't malloc %ld bytes to read file '%s'",
+ textlen, rfname);
+ ErrPopUp(buf, "\nSo what!");
+ fclose(fp);
+@@ -267,8 +265,8 @@
+ /* note: text gets freed when window gets closed */
+ }
+
+-
+-
++
++
+ /***************************************************************/
+ void OpenTextView(text, len, title, freeonclose)
+ char *text, *title;
+@@ -276,7 +274,6 @@
+ {
+ /* opens up a textview window */
+
+- int i, oldone;
+ TVINFO *tv;
+
+ tv = &tinfo[0];
+@@ -293,6 +290,7 @@
+ tv->textlen = len;
+ tv->freeonclose = freeonclose;
+ strncpy(tv->title, title, (size_t) TITLELEN-1);
++ tv->title[TITLELEN-1] = '\0';
+
+ computeText(tv); /* compute # lines and linestarts array */
+
+@@ -316,7 +314,6 @@
+ {
+ /* opens up the reserved 'comment' textview window */
+
+- int i;
+ TVINFO *tv;
+
+ tv = &tinfo[CMTWIN];
+@@ -351,9 +348,9 @@
+ tv->textlen = (tv->text) ? strlen(tv->text) : 0;
+ tv->freeonclose = 0;
+
+- if (strlen(fullfname))
++ if (strlen(fullfname))
+ sprintf(tv->title, "File: '%s'", BaseName(fullfname));
+- else
++ else
+ sprintf(tv->title, "<no file loaded>");
+
+ computeText(tv); /* compute # lines and linestarts array */
+@@ -504,7 +501,7 @@
+ if (tv->freeonclose && tv->text) free(tv->text);
+ if (tv->lines) free(tv->lines);
+
+- tv->text = (char *) NULL;
++ tv->text = (char *) NULL;
+ tv->lines = (char **) NULL;
+ tv->numlines = tv->textlen = tv->hexmode = 0;
+ }
+@@ -518,7 +515,7 @@
+ /* checks event to see if it's a text-window related thing. If it
+ is, it eats the event and returns '1', otherwise '0'. */
+
+- int i, rv;
++ int rv;
+
+ rv = 1;
+
+@@ -560,7 +557,7 @@
+ count++;
+ } while (XCheckWindowEvent(theDisp, evt.xexpose.window,
+ ExposureMask, &evt));
+-
++
+ XClipBox(reg, &rect); /* bounding box of region */
+ XSetRegion(theDisp, theGC, reg);
+
+@@ -570,7 +567,7 @@
+ fprintf(stderr,"grouped %d expose events into %d,%d %dx%d rect\n",
+ count, rect.x, rect.y, rect.width, rect.height);
+ }
+-
++
+ if (e->window == tv->win) drawTextView(tv);
+ else if (e->window == tv->textW) drawTextW(0, &(tv->vscrl));
+
+@@ -584,7 +581,7 @@
+
+ else if (xev->type == ButtonPress) {
+ XButtonEvent *e = (XButtonEvent *) xev;
+- int i,x,y;
++ int x,y;
+ x = e->x; y = e->y;
+
+ if (e->button == Button1) {
+@@ -615,7 +612,7 @@
+
+ if (tv->wide != e->width || tv->high != e->height) {
+ if (DEBUG) fprintf(stderr,"Forcing a redraw! (from configure)\n");
+- XClearArea(theDisp, tv->win, 0, 0,
++ XClearArea(theDisp, tv->win, 0, 0,
+ (u_int) e->width, (u_int) e->height, True);
+ resizeText(tv, e->width, e->height);
+ }
+@@ -633,7 +630,7 @@
+ TVINFO *tv;
+ int w,h;
+ {
+- int i, maxw, maxh, hmax, hpage, vmax, vpage;
++ int i, maxw, maxh;
+ XSizeHints hints;
+
+ if (tv->wide == w && tv->high == h) return; /* no change in size */
+@@ -657,7 +654,7 @@
+ tv->twWide = tv->chwide * mfwide + 6;
+ tv->twHigh = tv->chhigh * mfhigh + 6;
+
+- XMoveResizeWindow(theDisp, tv->textW, LRMARGINS, TOPMARGIN,
++ XMoveResizeWindow(theDisp, tv->textW, LRMARGINS, TOPMARGIN,
+ (u_int) tv->twWide, (u_int) tv->twHigh);
+
+ for (i=0; i<TV_NBUTTS; i++) {
+@@ -692,8 +689,8 @@
+ hpag = tv->chwide / 4;
+ vpag = tv->chhigh - 1;
+
+-
+- SCChange(&tv->vscrl, LRMARGINS + tv->twWide+1, TOPMARGIN,
++
++ SCChange(&tv->vscrl, LRMARGINS + tv->twWide+1, TOPMARGIN,
+ 1, tv->twHigh, 0, vmax, tv->vscrl.val, vpag);
+
+ SCChange(&tv->hscrl, LRMARGINS, TOPMARGIN + tv->twHigh + 1,
+@@ -731,11 +728,11 @@
+ y = 5;
+
+ XSetForeground(theDisp, theGC, infobg);
+- XFillRectangle(theDisp, tv->win, theGC, 5+1, y+1,
++ XFillRectangle(theDisp, tv->win, theGC, 5+1, y+1,
+ (u_int) StringWidth(tv->title)+6, (u_int) CHIGH+4);
+
+ XSetForeground(theDisp, theGC, infofg);
+- XDrawRectangle(theDisp, tv->win, theGC, 5, y,
++ XDrawRectangle(theDisp, tv->win, theGC, 5, y,
+ (u_int) StringWidth(tv->title)+7, (u_int) CHIGH+5);
+
+ Draw3dRect(tv->win, 5+1, y+1, (u_int) StringWidth(tv->title)+5,
+@@ -763,15 +760,15 @@
+
+ if (tv->hexmode) nl = tv->hexlines;
+ else {
+- if (tv->numlines>0 &&
+- tv->lines[tv->numlines-1] - tv->lines[tv->numlines-2] == 1)
++ if (tv->numlines>0 &&
++ tv->lines[tv->numlines-1] - tv->lines[tv->numlines-2] == 1)
+ nl = tv->numlines - 2; /* line after last \n has zero length */
+ else nl = tv->numlines - 1;
+ }
+ if (nl<0) nl = 0;
+
+- sprintf(tmpstr, "%d byte%s, %d line%s",
+- tv->textlen, (tv->textlen!=1) ? "s" : "",
++ sprintf(tmpstr, "%d byte%s, %d line%s",
++ tv->textlen, (tv->textlen!=1) ? "s" : "",
+ nl, (nl!=1) ? "s" : "");
+
+ w = StringWidth(tmpstr) + 7; /* width of frame */
+@@ -779,13 +776,13 @@
+ y = 6;
+
+ XSetForeground(theDisp, theGC, infobg);
+- XFillRectangle(theDisp, tv->win, theGC, (x-w)+1, y+1,
++ XFillRectangle(theDisp, tv->win, theGC, (x-w)+1, y+1,
+ (u_int) (w-1), (u_int) CHIGH+4);
+
+ XSetForeground(theDisp, theGC, infofg);
+ XDrawRectangle(theDisp, tv->win, theGC, x-w, y, (u_int) w, (u_int) CHIGH+5);
+
+- Draw3dRect(tv->win, (x-w)+1, y+1, (u_int) (w-2), (u_int) CHIGH+3,
++ Draw3dRect(tv->win, (x-w)+1, y+1, (u_int) (w-2), (u_int) CHIGH+3,
+ R3D_IN,2,hicol,locol,infobg);
+
+ XSetForeground(theDisp, theGC, infofg);
+@@ -800,10 +797,10 @@
+ int x, y, w, nl;
+ char tmpstr[64];
+
+- nl = (tv->hexmode) ? tv->hexlines : tv->numlines-1;
++ nl = (tv->hexmode) ? tv->hexlines : tv->numlines-1;
+
+- sprintf(tmpstr, "%d byte%s, %d line%s",
+- tv->textlen, (tv->textlen>1) ? "s" : "",
++ sprintf(tmpstr, "%d byte%s, %d line%s",
++ tv->textlen, (tv->textlen>1) ? "s" : "",
+ nl, (nl>1) ? "s" : "");
+
+ w = StringWidth(tmpstr) + 7; /* width of frame */
+@@ -825,14 +822,14 @@
+ u_char *sp, *ep, *lp;
+
+ /* figure out TVINFO pointer from SCRL pointer */
+- for (i=0; i<MAXTVWIN && sptr != &tinfo[i].vscrl
++ for (i=0; i<MAXTVWIN && sptr != &tinfo[i].vscrl
+ && sptr != &tinfo[i].hscrl; i++);
+ if (i==MAXTVWIN) return; /* didn't find one */
+
+ tv = &tinfo[i];
+
+ /* make sure we've been sized. Necessary, as creating/modifying the
+- scrollbar calls this routine directly, rather than through
++ scrollbar calls this routine directly, rather than through
+ TextCheckEvent() */
+
+ if (!hasBeenSized) return;
+@@ -849,7 +846,7 @@
+ for (i=0; i<tv->chhigh; i++) { /* draw each line */
+ lnum = i + tv->vscrl.val;
+ if (lnum < tv->numlines-1) {
+-
++
+ /* find start of displayed portion of line. This is *wildly*
+ complicated by the ctrl-character and tab expansion... */
+
+@@ -902,7 +899,7 @@
+ if (extrach == 2) *lp = '^';
+ else if (extrach == 1) *lp = *sp + 64;
+ }
+-
++
+ else if (*sp > 127) {
+ if (!extrach) extrach = 4;
+ if (extrach == 4) *lp = '\\';
+@@ -926,7 +923,7 @@
+ }
+
+ /* draw the line */
+- XDrawImageString(theDisp, tv->textW, theGC,
++ XDrawImageString(theDisp, tv->textW, theGC,
+ 3, i*mfhigh + 3 + mfascent, linestr, lwide);
+ } /* for i ... */
+ } /* if hexmode */
+@@ -936,7 +933,7 @@
+ for (i=0; i<tv->chhigh; i++) { /* draw each line */
+ lnum = i + tv->vscrl.val;
+ if (lnum < tv->hexlines) {
+-
++
+ char hexstr[80], tmpstr[16];
+
+ /* generate hex for this line */
+@@ -972,7 +969,7 @@
+ now build 'linestr', which is going to have hexstr shifted
+ and/or padded with blanks (ie, the displayed portion or hexstr) */
+
+- /* skip obscured beginning of line, if any */
++ /* skip obscured beginning of line, if any */
+ for (cpos=0, sp=(byte *) hexstr; cpos<hpos && *sp; cpos++, sp++);
+
+ for (cpos=0, lp=(byte *)linestr; cpos<lwide; cpos++, lp++) {
+@@ -985,16 +982,16 @@
+ }
+
+ /* draw the line */
+- XDrawImageString(theDisp, tv->textW, theGC,
++ XDrawImageString(theDisp, tv->textW, theGC,
+ 3, i*mfhigh + 3 + mfascent, linestr, lwide);
+ } /* for i ... */
+ } /* else hexmode */
+-
++
+
+
+ XSetFont(theDisp, theGC, mfont);
+
+- Draw3dRect(tv->textW, 0, 0, (u_int) (tv->twWide-1), (u_int) (tv->twHigh-1),
++ Draw3dRect(tv->textW, 0, 0, (u_int) (tv->twWide-1), (u_int) (tv->twHigh-1),
+ R3D_IN, 2, hicol, locol, infobg);
+ }
+
+@@ -1033,7 +1030,7 @@
+ stlen = XLookupString(kevt, buf, 128, &ks, (XComposeStatus *) NULL);
+ shift = kevt->state & ShiftMask;
+ ck = CursorKey(ks, shift, 1);
+- dealt = 1;
++ dealt = 1;
+
+ RemapKeyCheck(ks, buf, &stlen);
+
+@@ -1060,8 +1057,6 @@
+ TVINFO *tv;
+ int key;
+ {
+- int i,j;
+-
+ if (!tv->textlen) return;
+
+ /* an arrow key (or something like that) was pressed in icon window.
+@@ -1108,7 +1103,7 @@
+ else { /* switch to ascii mode */
+ pos = oldvscrl * 16;
+ for (i=0; i<tv->numlines-1; i++) {
+- if (tv->lines[i+1] - tv->text > pos &&
++ if (tv->lines[i+1] - tv->text > pos &&
+ tv->lines[i] - tv->text <= pos) break;
+ }
+ if (i<tv->numlines-1) SCSetVal(&tv->vscrl, i);
+@@ -1127,9 +1122,9 @@
+ int i,j,wide,maxwide,space;
+ byte *sp;
+
+- if (!tv->text) {
+- tv->numlines = tv->hexlines = 0;
+- tv->lines = (char **) NULL;
++ if (!tv->text) {
++ tv->numlines = tv->hexlines = 0;
++ tv->lines = (char **) NULL;
+ return;
+ }
+
+@@ -1153,8 +1148,8 @@
+
+ tv->lines[tv->numlines - 1] = tv->text + tv->textlen + 1;
+
+- /* each line has a trailing '\n' character, except for the last line,
+- which has a trailing '\0' character. In any case, all lines can
++ /* each line has a trailing '\n' character, except for the last line,
++ which has a trailing '\0' character. In any case, all lines can
+ be printed by printing ((lines[n+1] - lines[n]) - 1) characters,
+ starting with lines[n].
+
+@@ -1164,13 +1159,13 @@
+
+ /* compute length of longest line, when shown in 'ascii' mode. Takes
+ into account the fact that non-printing chars (<32 or >127) will be
+- shown in an 'expanded' form. (<32 chars will be shown as '^A'
++ shown in an 'expanded' form. (<32 chars will be shown as '^A'
+ (or whatever), and >127 chars will be shown as octal '\275') */
+
+ maxwide = 0;
+ for (i=0; i<tv->numlines-1; i++) {
+ /* compute displayed width of line #i */
+- for (sp=(byte *) tv->lines[i], wide=0; sp<(byte *) tv->lines[i+1]-1;
++ for (sp=(byte *) tv->lines[i], wide=0; sp<(byte *) tv->lines[i+1]-1;
+ sp++) {
+ if (*sp == '\011') { /* tab to next multiple of 8 */
+ space = ((wide+8) & (~7)) - wide;
+diff -ruN xv-3.10a/xvtiff.c xv-3.10a-bugfixes/xvtiff.c
+--- xv-3.10a/xvtiff.c 1995-01-13 11:53:34.000000000 -0800
++++ xv-3.10a-bugfixes/xvtiff.c 2005-03-27 17:25:31.000000000 -0800
+@@ -1,7 +1,7 @@
+ /*
+ * xvtiff.c - load routine for 'TIFF' format pictures
+ *
+- * LoadTIFF(fname, numcols) - load a TIFF file
++ * LoadTIFF(fname, numcols, quick) - load a TIFF file
+ */
+
+ #ifndef va_start
+@@ -15,6 +15,35 @@
+ #include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */
+
+
++/* Portions fall under the following copyright:
++ *
++ * Copyright (c) 1992, 1993, 1994 Sam Leffler
++ * Copyright (c) 1992, 1993, 1994 Silicon Graphics, Inc.
++ *
++ * Permission to use, copy, modify, distribute, and sell this software and
++ * its documentation for any purpose is hereby granted without fee, provided
++ * that (i) the above copyright notices and this permission notice appear in
++ * all copies of the software and related documentation, and (ii) the names of
++ * Sam Leffler and Silicon Graphics may not be used in any advertising or
++ * publicity relating to the software without the specific, prior written
++ * permission of Sam Leffler and Silicon Graphics.
++ *
++ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
++ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
++ *
++ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
++ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
++ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
++ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
++ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
++ * OF THIS SOFTWARE.
++ */
++
++
++static int copyTiff PARM((TIFF *, char *));
++static int cpStrips PARM((TIFF *, TIFF *));
++static int cpTiles PARM((TIFF *, TIFF *));
+ static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
+ static byte *loadColor PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
+ static int loadImage PARM((TIFF *, uint32, uint32, byte *, int));
+@@ -28,19 +57,23 @@
+ static int error_occurred;
+
+ /*******************************************/
+-int LoadTIFF(fname, pinfo)
+- char *fname;
++int LoadTIFF(fname, pinfo, quick)
++ char *fname;
+ PICINFO *pinfo;
++ int quick;
+ /*******************************************/
+ {
+ /* returns '1' on success, '0' on failure */
+
+ TIFF *tif;
+ uint32 w, h;
++ float xres, yres;
+ short bps, spp, photo, orient;
+ FILE *fp;
+ byte *pic8;
+ char *desc, oldpath[MAXPATHLEN+1], tmppath[MAXPATHLEN+1], *sp;
++ char tmp[256], tmpname[256];
++ int i, nump;
+
+ error_occurred = 0;
+
+@@ -60,6 +93,8 @@
+ filesize = ftell(fp);
+ fclose(fp);
+
++
++
+ rmap = pinfo->r; gmap = pinfo->g; bmap = pinfo->b;
+
+ /* a kludge: temporarily cd to the directory that the file is in (if
+@@ -80,10 +115,61 @@
+ else filename = BaseName(fname);
+ }
+ }
+-
+-
+
+- tif=TIFFOpen(filename,"r");
++
++ nump = 1;
++
++ if (!quick) {
++ /* see if there's more than 1 image in tiff file, to determine if we
++ should do multi-page thing... */
++
++ tif = TIFFOpen(filename,"r");
++ if (!tif) return 0;
++ while (TIFFReadDirectory(tif)) nump++;
++ TIFFClose(tif);
++ if (DEBUG)
++ fprintf(stderr,"LoadTIFF: %d page%s found\n", nump, nump==1 ? "" : "s");
++
++
++ /* if there are multiple images, copy them out to multiple tmp files,
++ and load the first one... */
++
++ /* GRR 20050320: converted this fake mktemp() to use mktemp()/mkstemp()
++ internally (formerly it simply prepended tmpdir to the string and
++ returned immediately) */
++ xv_mktemp(tmpname, "xvpgXXXXXX");
++
++ if (tmpname[0] == '\0') { /* mktemp() or mkstemp() blew up */
++ sprintf(str,"LoadTIFF: Unable to create temporary filename???");
++ ErrPopUp(str, "\nHow unlikely!");
++ return 0;
++ }
++
++ if (nump>1) {
++ TIFF *in;
++
++ in = TIFFOpen(filename, "r");
++ if (!in) return 0;
++ for (i=1; i<=nump; i++) {
++ sprintf(tmp, "%s%d", tmpname, i);
++ if (!copyTiff(in, tmp)) {
++ SetISTR(ISTR_WARNING, "LoadTIFF: Error writing page files!");
++ break;
++ }
++
++ if (!TIFFReadDirectory(in)) break;
++ }
++ if (DEBUG)
++ fprintf(stderr,"LoadTIFF: %d page%s written\n",
++ i-1, (i-1)==1 ? "" : "s");
++
++ sprintf(tmp, "%s%d", tmpname, 1); /* open page #1 */
++ filename = tmp;
++ }
++ } /* if (!quick) ... */
++
++
++ tif = TIFFOpen(filename,"r");
+ if (!tif) return 0;
+
+ /* flip orientation so that image comes in X order */
+@@ -107,6 +193,11 @@
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bps);
+ TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
++ if ((TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) == 1) &&
++ (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) == 1)) {
++ normaspect = yres / xres;
++ if (DEBUG) fprintf(stderr,"TIFF aspect = %f\n", normaspect);
++ }
+
+ if (spp == 1) {
+ pic8 = loadPalette(tif, w, h, photo, bps, pinfo);
+@@ -116,19 +207,19 @@
+
+ /* try to get comments, if any */
+ pinfo->comment = (char *) NULL;
+-
++
+ desc = (char *) NULL;
+
+ TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &desc);
+ if (desc && strlen(desc) > (size_t) 0) {
+ /* kludge: tiff library seems to return bizarre comments */
+- if (strlen(desc)==4 && strcmp(desc, "\367\377\353\370")==0) {}
++ if (strlen(desc)==4 && strcmp(desc, "\367\377\353\370")==0) {}
+ else {
+ pinfo->comment = (char *) malloc(strlen(desc) + 1);
+ if (pinfo->comment) strcpy(pinfo->comment, desc);
+ }
+ }
+-
++
+ TIFFClose(tif);
+
+ /* un-kludge */
+@@ -139,6 +230,8 @@
+ if (pic8) free(pic8);
+ if (pinfo->comment) free(pinfo->comment);
+ pinfo->comment = (char *) NULL;
++ if (!quick && nump>1) KillPageFiles(tmpname, nump);
++ SetCursors(-1);
+ return 0;
+ }
+
+@@ -148,15 +241,168 @@
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->frmType = F_TIFF;
+
++ if (nump>1) strcpy(pinfo->pagebname, tmpname);
++ pinfo->numpages = nump;
+
+ if (pinfo->pic) return 1;
+
++
+ /* failed. if we malloc'd a comment, free it */
+ if (pinfo->comment) free(pinfo->comment);
+ pinfo->comment = (char *) NULL;
+
++ if (!quick && nump>1) KillPageFiles(tmpname, nump);
++ SetCursors(-1);
++
+ return 0;
+-}
++}
++
++
++
++
++/*******************************************/
++
++#define CopyField(tag, v) \
++ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
++#define CopyField2(tag, v1, v2) \
++ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2)
++#define CopyField3(tag, v1, v2, v3) \
++ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3)
++
++
++/*******************************************/
++static int copyTiff(in, fname)
++ TIFF *in;
++ char *fname;
++{
++ /* copies tiff (sub)image to given filename. (Used only for multipage
++ images.) Returns 0 on error */
++
++ TIFF *out;
++ short bitspersample, samplesperpixel, shortv, *shortav;
++ uint32 w, l;
++ float floatv;
++ char *stringv;
++ uint32 longv;
++ uint16 *red, *green, *blue, shortv2;
++ int rv;
++
++ out = TIFFOpen(fname, "w");
++ if (!out) return 0;
++
++ CopyField (TIFFTAG_SUBFILETYPE, longv);
++ CopyField (TIFFTAG_TILEWIDTH, w);
++ CopyField (TIFFTAG_TILELENGTH, l);
++ CopyField (TIFFTAG_IMAGEWIDTH, w);
++ CopyField (TIFFTAG_IMAGELENGTH, l);
++ CopyField (TIFFTAG_BITSPERSAMPLE, bitspersample);
++ CopyField (TIFFTAG_COMPRESSION, shortv);
++ CopyField (TIFFTAG_PREDICTOR, shortv);
++ CopyField (TIFFTAG_PHOTOMETRIC, shortv);
++ CopyField (TIFFTAG_THRESHHOLDING, shortv);
++ CopyField (TIFFTAG_FILLORDER, shortv);
++ CopyField (TIFFTAG_ORIENTATION, shortv);
++ CopyField (TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
++ CopyField (TIFFTAG_MINSAMPLEVALUE, shortv);
++ CopyField (TIFFTAG_MAXSAMPLEVALUE, shortv);
++ CopyField (TIFFTAG_XRESOLUTION, floatv);
++ CopyField (TIFFTAG_YRESOLUTION, floatv);
++ CopyField (TIFFTAG_GROUP3OPTIONS, longv);
++ CopyField (TIFFTAG_GROUP4OPTIONS, longv);
++ CopyField (TIFFTAG_RESOLUTIONUNIT, shortv);
++ CopyField (TIFFTAG_PLANARCONFIG, shortv);
++ CopyField (TIFFTAG_ROWSPERSTRIP, longv);
++ CopyField (TIFFTAG_XPOSITION, floatv);
++ CopyField (TIFFTAG_YPOSITION, floatv);
++ CopyField (TIFFTAG_IMAGEDEPTH, longv);
++ CopyField (TIFFTAG_TILEDEPTH, longv);
++ CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav);
++ CopyField3(TIFFTAG_COLORMAP, red, green, blue);
++ CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2);
++ CopyField (TIFFTAG_ARTIST, stringv);
++ CopyField (TIFFTAG_IMAGEDESCRIPTION,stringv);
++ CopyField (TIFFTAG_MAKE, stringv);
++ CopyField (TIFFTAG_MODEL, stringv);
++ CopyField (TIFFTAG_SOFTWARE, stringv);
++ CopyField (TIFFTAG_DATETIME, stringv);
++ CopyField (TIFFTAG_HOSTCOMPUTER, stringv);
++ CopyField (TIFFTAG_PAGENAME, stringv);
++ CopyField (TIFFTAG_DOCUMENTNAME, stringv);
++
++ if (TIFFIsTiled(in)) rv = cpTiles (in, out);
++ else rv = cpStrips(in, out);
++
++ TIFFClose(out);
++ return rv;
++}
++
++
++/*******************************************/
++static int cpStrips(in, out)
++ TIFF *in, *out;
++{
++ tsize_t bufsize;
++ byte *buf;
++
++ bufsize = TIFFStripSize(in);
++ if (bufsize <= 0) return 0; /* tsize_t is signed */
++ buf = (byte *) malloc((size_t) bufsize);
++ if (buf) {
++ tstrip_t s, ns = TIFFNumberOfStrips(in);
++ uint32 *bytecounts;
++
++ TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
++ for (s = 0; s < ns; s++) {
++ if (bytecounts[s] > bufsize) {
++ buf = (unsigned char *) realloc(buf, (size_t) bytecounts[s]);
++ if (!buf) return (0);
++ bufsize = bytecounts[s];
++ }
++ if (TIFFReadRawStrip (in, s, buf, (tsize_t) bytecounts[s]) < 0 ||
++ TIFFWriteRawStrip(out, s, buf, (tsize_t) bytecounts[s]) < 0) {
++ free(buf);
++ return 0;
++ }
++ }
++ free(buf);
++ return 1;
++ }
++ return 0;
++}
++
++
++/*******************************/
++static int cpTiles(in, out)
++ TIFF *in, *out;
++{
++ tsize_t bufsize;
++ byte *buf;
++
++ bufsize = TIFFTileSize(in);
++ if (bufsize <= 0) return 0; /* tsize_t is signed */
++ buf = (unsigned char *) malloc((size_t) bufsize);
++ if (buf) {
++ ttile_t t, nt = TIFFNumberOfTiles(in);
++ uint32 *bytecounts;
++
++ TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts);
++ for (t = 0; t < nt; t++) {
++ if (bytecounts[t] > bufsize) {
++ buf = (unsigned char *)realloc(buf, (size_t) bytecounts[t]);
++ if (!buf) return (0);
++ bufsize = bytecounts[t];
++ }
++ if (TIFFReadRawTile (in, t, buf, (tsize_t) bytecounts[t]) < 0 ||
++ TIFFWriteRawTile(out, t, buf, (tsize_t) bytecounts[t]) < 0) {
++ free(buf);
++ return 0;
++ }
++ }
++ free(buf);
++ return 1;
++ }
++ return 0;
++}
+
+
+ /*******************************************/
+@@ -167,6 +413,7 @@
+ PICINFO *pinfo;
+ {
+ byte *pic8;
++ uint32 npixels;
+
+ switch (photo) {
+ case PHOTOMETRIC_PALETTE:
+@@ -178,7 +425,7 @@
+ case PHOTOMETRIC_MINISWHITE:
+ case PHOTOMETRIC_MINISBLACK:
+ pinfo->colType = (bps==1) ? F_BWDITHER : F_GREYSCALE;
+- sprintf(pinfo->fullInfo,"TIFF, %u-bit, %s format. (%ld bytes)",
++ sprintf(pinfo->fullInfo,"TIFF, %u-bit, %s format. (%ld bytes)",
+ bps,
+ photo == PHOTOMETRIC_MINISWHITE ? "min-is-white" :
+ "min-is-black",
+@@ -186,9 +433,16 @@
+ break;
+ }
+
+- sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
++ sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h);
++
++ npixels = w*h;
++ if (npixels/w != h) {
++ /* SetISTR(ISTR_WARNING, "loadPalette() - image dimensions too large"); */
++ TIFFError(filename, "Image dimensions too large");
++ return (byte *) NULL;
++ }
+
+- pic8 = (byte *) malloc((size_t) w*h);
++ pic8 = (byte *) malloc((size_t) npixels);
+ if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'");
+
+ if (loadImage(tif, w, h, pic8, 0)) return pic8;
+@@ -205,19 +459,28 @@
+ PICINFO *pinfo;
+ {
+ byte *pic24, *pic8;
++ uint32 npixels, count;
+
+ pinfo->colType = F_FULLCOLOR;
+- sprintf(pinfo->fullInfo, "TIFF, %u-bit, %s format. (%ld bytes)",
++ sprintf(pinfo->fullInfo, "TIFF, %u-bit, %s format. (%ld bytes)",
+ bps,
+ (photo == PHOTOMETRIC_RGB ? "RGB" :
+ photo == PHOTOMETRIC_YCBCR ? "YCbCr" :
+ "???"),
+ filesize);
+
+- sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
++ sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h);
++
++ npixels = w*h;
++ count = 3*npixels;
++ if (npixels/w != h || count/3 != npixels) {
++ /* SetISTR(ISTR_WARNING, "loadPalette() - image dimensions too large"); */
++ TIFFError(filename, "Image dimensions too large");
++ return (byte *) NULL;
++ }
+
+ /* allocate 24-bit image */
+- pic24 = (byte *) malloc((size_t) w*h*3);
++ pic24 = (byte *) malloc((size_t) count);
+ if (!pic24) FatalError("loadColor() - couldn't malloc 'pic24'");
+
+ pic8 = (byte *) NULL;
+@@ -301,10 +564,10 @@
+ static byte **BWmap;
+ static byte **PALmap;
+
+-typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
++typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
+ uint32, uint32, int, int));
+
+-typedef void (*tileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*,
++typedef void (*tileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*,
+ RGBvalue*, uint32, uint32, int, int));
+
+
+@@ -312,13 +575,13 @@
+
+ static int gt PARM((TIFF *, uint32, uint32, byte *));
+ static uint32 setorientation PARM((TIFF *, uint32));
+-static int gtTileContig PARM((TIFF *, byte *, RGBvalue *,
++static int gtTileContig PARM((TIFF *, byte *, RGBvalue *,
+ uint32, uint32, int));
+-static int gtTileSeparate PARM((TIFF *, byte *, RGBvalue *,
++static int gtTileSeparate PARM((TIFF *, byte *, RGBvalue *,
+ uint32, uint32, int));
+-static int gtStripContig PARM((TIFF *, byte *, RGBvalue *,
++static int gtStripContig PARM((TIFF *, byte *, RGBvalue *,
+ uint32, uint32, int));
+-static int gtStripSeparate PARM((TIFF *, byte *, RGBvalue *,
++static int gtStripSeparate PARM((TIFF *, byte *, RGBvalue *,
+ uint32, uint32, int));
+
+ static int makebwmap PARM((void));
+@@ -349,18 +612,18 @@
+ static void putRGBcontig16bittile PARM((byte *, u_short *, RGBvalue *,
+ uint32, uint32, int, int));
+
+-static void putRGBseparate8bittile PARM((byte *, u_char *, u_char *,
+- u_char *, RGBvalue *,
++static void putRGBseparate8bittile PARM((byte *, u_char *, u_char *,
++ u_char *, RGBvalue *,
+ uint32, uint32, int, int));
+
+-static void putRGBseparate16bittile PARM((byte *, u_short *, u_short *,
+- u_short *, RGBvalue *,
++static void putRGBseparate16bittile PARM((byte *, u_short *, u_short *,
++ u_short *, RGBvalue *,
+ uint32, uint32, int, int));
+
+
+ static void initYCbCrConversion PARM((void));
+
+-static void putRGBContigYCbCrClump PARM((byte *, u_char *, int, int,
++static void putRGBContigYCbCrClump PARM((byte *, u_char *, int, int,
+ uint32, int, int, int));
+
+ static void putcontig8bitYCbCrtile PARM((byte *, u_char *, RGBvalue *,
+@@ -382,10 +645,10 @@
+
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
+ switch (bitspersample) {
+- case 1:
+- case 2:
++ case 1:
++ case 2:
+ case 4:
+- case 8:
++ case 8:
+ case 16: break;
+
+ default:
+@@ -397,8 +660,8 @@
+
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
+ switch (samplesperpixel) {
+- case 1:
+- case 3:
++ case 1:
++ case 3:
+ case 4: break;
+
+ default:
+@@ -470,7 +733,7 @@
+ TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, &minsamplevalue);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, &maxsamplevalue);
+ Map = NULL;
+-
++
+ switch (photometric) {
+ case PHOTOMETRIC_YCBCR:
+ TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS,
+@@ -481,12 +744,12 @@
+ &refBlackWhite);
+ initYCbCrConversion();
+ /* fall thru... */
+-
++
+ case PHOTOMETRIC_RGB:
+ bpp *= 3;
+ if (minsamplevalue == 0 && maxsamplevalue == 255)
+ break;
+-
++
+ /* fall thru... */
+ case PHOTOMETRIC_MINISBLACK:
+ case PHOTOMETRIC_MINISWHITE:
+@@ -509,7 +772,7 @@
+ if (range<256) {
+ for (x=0; x<=range; x++) rmap[x] = gmap[x] = bmap[x] = Map[x];
+ } else {
+- for (x=0; x<256; x++)
++ for (x=0; x<256; x++)
+ rmap[x] = gmap[x] = bmap[x] = Map[(range*x)/255];
+ }
+
+@@ -590,6 +853,8 @@
+ TIFF *tif;
+ uint32 h;
+ {
++ /* note that orientation was flipped in LoadTIFF() (near line 175) */
++
+ uint32 y;
+
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &orientation);
+@@ -613,6 +878,11 @@
+ orientation = ORIENTATION_TOPLEFT;
+ /* fall thru... */
+ case ORIENTATION_TOPLEFT:
++ /* GRR 20050319: This may be wrong for tiled images (also stripped?);
++ * looks like we want to return th-1 instead of h-1 in at least some
++ * cases. For now, just added quick hack (USE_TILED_TIFF_BOTLEFT_FIX)
++ * to gtTileContig(). (Note that, as of libtiff 3.7.1, tiffcp still
++ * has exactly the same bug.) */
+ y = h-1;
+ break;
+ }
+@@ -623,11 +893,11 @@
+
+
+ /*
+- * Get an tile-organized image that has
++ * Get a tile-organized image that has
+ * PlanarConfiguration contiguous if SamplesPerPixel > 1
+ * or
+ * SamplesPerPixel == 1
+- */
++ */
+ /*******************************************/
+ static int gtTileContig(tif, raster, Map, h, w, bpp)
+ TIFF *tif;
+@@ -642,11 +912,14 @@
+ int fromskew, toskew;
+ u_int nrow;
+ tileContigRoutine put;
++ tsize_t bufsize;
+
+ put = pickTileContigCase(Map);
+ if (put == 0) return (0);
+
+- buf = (u_char *) malloc((size_t) TIFFTileSize(tif));
++ bufsize = TIFFTileSize(tif);
++ if (bufsize <= 0) return 0; /* tsize_t is signed */
++ buf = (u_char *) malloc((size_t) bufsize);
+ if (buf == 0) {
+ TIFFError(filename, "No space for tile buffer");
+ return (0);
+@@ -655,12 +928,27 @@
+ TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
+ TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
+ y = setorientation(tif, h);
++#ifdef USE_TILED_TIFF_BOTLEFT_FIX /* image _originally_ ORIENTATION_BOTLEFT */
++ /* this fix causes tiles as a whole to be placed starting at the top,
++ * regardless of orientation; the only difference is what happens within
++ * a given tile (see toskew, below) */
++ /* GRR FIXME: apply globally in setorientation()? */
++ if (orientation == ORIENTATION_TOPLEFT)
++ y = th-1;
++#endif
++ /* toskew causes individual tiles to copy from bottom to top for
++ * ORIENTATION_TOPLEFT and from top to bottom otherwise */
+ toskew = (orientation == ORIENTATION_TOPLEFT ? -tw + -w : -tw + w);
+
+ for (row = 0; row < h; row += th) {
+ nrow = (row + th > h ? h - row : th);
+ for (col = 0; col < w; col += tw) {
+- if (TIFFReadTile(tif,buf,(uint32)col, (uint32)row, 0, 0) < 0
++ /*
++ * This reads the tile at (col,row) into buf. "The data placed in buf
++ * are returned decompressed and, typically, in the native byte- and
++ * bit-ordering, but are otherwise packed."
++ */
++ if (TIFFReadTile(tif, buf, (uint32)col, (uint32)row, 0, 0) < 0
+ && stoponerr) break;
+
+ if (col + tw > w) {
+@@ -670,14 +958,18 @@
+ */
+ uint32 npix = w - col;
+ fromskew = tw - npix;
+- (*put)(raster + (y*w + col)*bpp, buf, Map, npix, (uint32) nrow,
+- fromskew, (int) ((toskew + fromskew)*bpp));
++ (*put)(raster + (y*w + col)*bpp, buf, Map, npix, (uint32) nrow,
++ fromskew, (int) ((toskew + fromskew)*bpp) );
+ } else
+- (*put)(raster + (y*w + col)*bpp, buf, Map, tw, (uint32) nrow,
++ (*put)(raster + (y*w + col)*bpp, buf, Map, tw, (uint32) nrow,
+ 0, (int) (toskew*bpp));
+ }
+
++#ifdef USE_TILED_TIFF_BOTLEFT_FIX /* image _originally_ ORIENTATION_BOTLEFT */
++ y += nrow;
++#else
+ y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow);
++#endif
+ }
+ free(buf);
+ return (1);
+@@ -687,11 +979,11 @@
+
+
+ /*
+- * Get an tile-organized image that has
++ * Get a tile-organized image that has
+ * SamplesPerPixel > 1
+ * PlanarConfiguration separated
+ * We assume that all such images are RGB.
+- */
++ */
+
+ /*******************************************/
+ static int gtTileSeparate(tif, raster, Map, h, w, bpp)
+@@ -701,20 +993,26 @@
+ uint32 h, w;
+ int bpp;
+ {
+- uint32 col, row, y;
+ uint32 tw, th;
++ uint32 col, row, y;
+ u_char *buf;
+ u_char *r, *g, *b;
+- int tilesize;
++ tsize_t tilesize;
++ uint32 bufsize;
+ int fromskew, toskew;
+ u_int nrow;
+ tileSeparateRoutine put;
+-
++
+ put = pickTileSeparateCase(Map);
+ if (put == 0) return (0);
+
+ tilesize = TIFFTileSize(tif);
+- buf = (u_char *)malloc((size_t) (3*tilesize));
++ bufsize = 3*tilesize;
++ if (tilesize <= 0 || bufsize/3 != tilesize) { /* tsize_t is signed */
++ TIFFError(filename, "Image dimensions too large");
++ return 0;
++ }
++ buf = (u_char *) malloc((size_t) bufsize);
+ if (buf == 0) {
+ TIFFError(filename, "No space for tile buffer");
+ return (0);
+@@ -751,10 +1049,10 @@
+ */
+ uint32 npix = w - col;
+ fromskew = tw - npix;
+- (*put)(raster + (y*w + col)*bpp, r, g, b, Map, npix, (uint32) nrow,
++ (*put)(raster + (y*w + col)*bpp, r, g, b, Map, npix, (uint32) nrow,
+ fromskew, (int) ((toskew + fromskew)*bpp));
+ } else
+- (*put)(raster + (y*w + col)*bpp, r, g, b, Map, tw, (uint32) nrow,
++ (*put)(raster + (y*w + col)*bpp, r, g, b, Map, tw, (uint32) nrow,
+ 0, (int) (toskew*bpp));
+ }
+ y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow);
+@@ -768,7 +1066,7 @@
+ * PlanarConfiguration contiguous if SamplesPerPixel > 1
+ * or
+ * SamplesPerPixel == 1
+- */
++ */
+ /*******************************************/
+ static int gtStripContig(tif, raster, Map, h, w, bpp)
+ TIFF *tif;
+@@ -784,11 +1082,15 @@
+ uint32 imagewidth;
+ int scanline;
+ int fromskew, toskew;
+-
++ tsize_t bufsize;
++
+ put = pickTileContigCase(Map);
+ if (put == 0)
+ return (0);
+- buf = (u_char *) malloc((size_t) TIFFStripSize(tif));
++
++ bufsize = TIFFStripSize(tif);
++ if (bufsize <= 0) return 0; /* tsize_t is signed */
++ buf = (u_char *) malloc((size_t) bufsize);
+ if (buf == 0) {
+ TIFFError(filename, "No space for strip buffer");
+ return (0);
+@@ -828,20 +1130,29 @@
+ uint32 h, w;
+ int bpp;
+ {
++ uint32 nrow, row, y;
+ u_char *buf;
+ u_char *r, *g, *b;
+- uint32 row, y, nrow;
++ tsize_t stripsize;
++ uint32 bufsize;
++ int fromskew, toskew;
+ int scanline;
+ tileSeparateRoutine put;
+ uint32 rowsperstrip;
+ uint32 imagewidth;
+- u_int stripsize;
+- int fromskew, toskew;
+-
++
+ stripsize = TIFFStripSize(tif);
+- r = buf = (u_char *) malloc((size_t) 3*stripsize);
+- if (buf == 0)
++ bufsize = 3*stripsize;
++ if (stripsize <= 0 || bufsize/3 != stripsize) { /* tsize_t is signed */
++ TIFFError(filename, "Image dimensions too large");
++ return 0;
++ }
++ buf = (u_char *) malloc((size_t) bufsize);
++ if (buf == 0) {
++ TIFFError(filename, "No space for strip buffer");
+ return (0);
++ }
++ r = buf;
+ g = r + stripsize;
+ b = g + stripsize;
+ put = pickTileSeparateCase(Map);
+@@ -861,7 +1172,7 @@
+ nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
+ band = 0;
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, (uint32) row, band),
+- (tdata_t) r, (tsize_t)(nrow*scanline)) < 0
++ (tdata_t) r, (tsize_t)(nrow*scanline)) < 0
+ && stoponerr) break;
+
+ band = 1;
+@@ -871,7 +1182,7 @@
+
+ band = 2;
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, (uint32) row, band),
+- (tdata_t) b, (tsize_t)(nrow*scanline)) < 0
++ (tdata_t) b, (tsize_t)(nrow*scanline)) < 0
+ && stoponerr) break;
+
+ (*put)(raster + y*w*bpp, r, g, b, Map, w, nrow, fromskew, toskew*bpp);
+@@ -895,7 +1206,7 @@
+ register int i;
+ int nsamples = 8 / bitspersample;
+ register byte *p;
+-
++
+ BWmap = (byte **)malloc(
+ 256*sizeof (byte *)+(256*nsamples*sizeof(byte)));
+ if (BWmap == NULL) {
+@@ -949,7 +1260,7 @@
+ register int i;
+ int nsamples = 8 / bitspersample;
+ register byte *p;
+-
++
+ PALmap = (byte **)malloc(
+ 256*sizeof (byte *)+(256*nsamples*sizeof(byte)));
+ if (PALmap == NULL) {
+@@ -1014,7 +1325,7 @@
+ #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; }
+
+ #define UNROLL8(w, op1, op2) { \
+- uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 8; x -= 8) { \
+ op1; \
+ REPEAT8(op2); \
+@@ -1026,7 +1337,7 @@
+ }
+
+ #define UNROLL4(w, op1, op2) { \
+- register uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 4; x -= 4) { \
+ op1; \
+ REPEAT4(op2); \
+@@ -1038,7 +1349,7 @@
+ }
+
+ #define UNROLL2(w, op1, op2) { \
+- register uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 2; x -= 2) { \
+ op1; \
+ REPEAT2(op2); \
+@@ -1048,7 +1359,7 @@
+ op2; \
+ } \
+ }
+-
++
+
+ #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; }
+
+@@ -1065,7 +1376,7 @@
+ int fromskew, toskew;
+ {
+ while (h-- > 0) {
+- UNROLL8(w,0, *cp++ = PALmap[*pp++][0]);
++ UNROLL8(w, , *cp++ = PALmap[*pp++][0])
+ cp += toskew;
+ pp += fromskew;
+ }
+@@ -1082,7 +1393,7 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 2;
+ while (h-- > 0) {
+ UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++);
+@@ -1103,7 +1414,7 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 4;
+ while (h-- > 0) {
+ UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++);
+@@ -1123,10 +1434,10 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 8;
+ while (h-- > 0) {
+- UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++);
++ UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++)
+ cp += toskew;
+ pp += fromskew;
+ }
+@@ -1164,10 +1475,10 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 8;
+ while (h-- > 0) {
+- UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++);
++ UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++)
+ cp += toskew;
+ pp += fromskew;
+ }
+@@ -1184,7 +1495,7 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 4;
+ while (h-- > 0) {
+ UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++);
+@@ -1204,7 +1515,7 @@
+ int fromskew, toskew;
+ {
+ register byte *bw;
+-
++
+ fromskew /= 2;
+ while (h-- > 0) {
+ UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++);
+@@ -1224,7 +1535,7 @@
+ int fromskew, toskew;
+ {
+ register uint32 x;
+-
++
+ while (h-- > 0) {
+ for (x=w; x>0; x--) {
+ *cp++ = Map[(pp[0] << 8) + pp[1]];
+@@ -1262,11 +1573,11 @@
+ }
+ } else {
+ while (h-- > 0) {
+- UNROLL8(w,0,
++ UNROLL8(w, ,
+ *cp++ = pp[0];
+ *cp++ = pp[1];
+ *cp++ = pp[2];
+- pp += samplesperpixel);
++ pp += samplesperpixel)
+ cp += toskew;
+ pp += fromskew;
+ }
+@@ -1284,7 +1595,7 @@
+ int fromskew, toskew;
+ {
+ register u_int x;
+-
++
+ fromskew *= samplesperpixel;
+ if (Map) {
+ while (h-- > 0) {
+@@ -1320,7 +1631,7 @@
+ RGBvalue *Map;
+ uint32 w, h;
+ int fromskew, toskew;
+-
++
+ {
+ if (Map) {
+ while (h-- > 0) {
+@@ -1335,11 +1646,11 @@
+ }
+ } else {
+ while (h-- > 0) {
+- UNROLL8(w,0,
++ UNROLL8(w, ,
+ *cp++ = *r++;
+ *cp++ = *g++;
+ *cp++ = *b++;
+- );
++ )
+ SKEW(r, g, b, fromskew);
+ cp += toskew;
+ }
+@@ -1357,7 +1668,7 @@
+ int fromskew, toskew;
+ {
+ uint32 x;
+-
++
+ if (Map) {
+ while (h-- > 0) {
+ for (x = w; x > 0; x--) {
+@@ -1381,7 +1692,7 @@
+ }
+ }
+
+-#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
++#define Code2V(c, RB, RW, CR) (((((int)c)-(int)RB)*(float)CR)/(float)(RW-RB))
+
+ #define CLAMP(f,min,max) \
+ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
+@@ -1391,16 +1702,32 @@
+ #define LumaBlue YCbCrCoeffs[2]
+
+ static float D1, D2;
+-static float D3, D4, D5;
++static float D3, D4 /*, D5 */;
+
+
+ static void initYCbCrConversion()
+ {
++ /*
++ * Old, broken version (goes back at least to 19920426; made worse 19941222):
++ * YCbCrCoeffs[] = {0.299, 0.587, 0.114}
++ * D1 = 1.402
++ * D2 = 0.714136
++ * D3 = 1.772
++ * D4 = 0.138691 <-- bogus
++ * D5 = 1.70358 <-- unnecessary
++ *
++ * New, fixed version (GRR 20050319):
++ * YCbCrCoeffs[] = {0.299, 0.587, 0.114}
++ * D1 = 1.402
++ * D2 = 0.714136
++ * D3 = 1.772
++ * D4 = 0.344136
++ */
+ D1 = 2 - 2*LumaRed;
+ D2 = D1*LumaRed / LumaGreen;
+ D3 = 2 - 2*LumaBlue;
+- D4 = D2*LumaBlue / LumaGreen;
+- D5 = 1.0 / LumaGreen;
++ D4 = D3*LumaBlue / LumaGreen; /* ARGH, used to be D2*LumaBlue/LumaGreen ! */
++/* D5 = 1.0 / LumaGreen; */ /* unnecessary */
+ }
+
+ static void putRGBContigYCbCrClump(cp, pp, cw, ch, w, n, fromskew, toskew)
+@@ -1412,7 +1739,7 @@
+ {
+ float Cb, Cr;
+ int j, k;
+-
++
+ Cb = Code2V(pp[n], refBlackWhite[2], refBlackWhite[3], 127);
+ Cr = Code2V(pp[n+1], refBlackWhite[4], refBlackWhite[5], 127);
+ for (j = 0; j < ch; j++) {
+@@ -1421,8 +1748,24 @@
+ Y = Code2V(*pp++,
+ refBlackWhite[0], refBlackWhite[1], 255);
+ R = Y + Cr*D1;
++/* G = Y*D5 - Cb*D4 - Cr*D2; highly bogus! */
++ G = Y - Cb*D4 - Cr*D2;
+ B = Y + Cb*D3;
+- G = Y*D5 - Cb*D4 - Cr*D2;
++ /*
++ * These are what the JPEG/JFIF equations--which aren't _necessarily_
++ * what JPEG/TIFF uses but which seem close enough--are supposed to be,
++ * according to Avery Lee (e.g., see http://www.fourcc.org/fccyvrgb.php):
++ *
++ * R = Y + 1.402 (Cr-128)
++ * G = Y - 0.34414 (Cb-128) - 0.71414 (Cr-128)
++ * B = Y + 1.772 (Cb-128)
++ *
++ * Translated into xvtiff.c notation:
++ *
++ * R = Y + Cr*D1
++ * G = Y - Cb*D4' - Cr*D2 (i.e., omit D5 and fix D4)
++ * B = Y + Cb*D3
++ */
+ cp[3*k+0] = CLAMP(R,0,255);
+ cp[3*k+1] = CLAMP(G,0,255);
+ cp[3*k+2] = CLAMP(B,0,255);
+@@ -1452,7 +1795,7 @@
+ u_int Coff = YCbCrVertSampling * YCbCrHorizSampling;
+ byte *tp;
+ uint32 x;
+-
++
+ /* XXX adjust fromskew */
+ while (h >= YCbCrVertSampling) {
+ tp = cp;
+@@ -1481,7 +1824,7 @@
+ pp += Coff+2;
+ }
+ if (x > 0)
+- putRGBContigYCbCrClump(tp, pp, (int) x, (int) h, w,
++ putRGBContigYCbCrClump(tp, pp, (int) x, (int) h, w,
+ (int)Coff, (int)(YCbCrHorizSampling-x),toskew);
+ }
+ }
+@@ -1493,7 +1836,7 @@
+ RGBvalue* Map;
+ {
+ tileContigRoutine put = 0;
+-
++
+ switch (photometric) {
+ case PHOTOMETRIC_RGB:
+ switch (bitspersample) {
+@@ -1501,7 +1844,7 @@
+ case 16: put = (tileContigRoutine) putRGBcontig16bittile; break;
+ }
+ break;
+-
++
+ case PHOTOMETRIC_PALETTE:
+ switch (bitspersample) {
+ case 8: put = put8bitcmaptile; break;
+@@ -1544,7 +1887,7 @@
+ RGBvalue* Map;
+ {
+ tileSeparateRoutine put = 0;
+-
++
+ switch (photometric) {
+ case PHOTOMETRIC_RGB:
+ switch (bitspersample) {
+diff -ruN xv-3.10a/xvtiffwr.c xv-3.10a-bugfixes/xvtiffwr.c
+--- xv-3.10a/xvtiffwr.c 1995-01-03 13:28:13.000000000 -0800
++++ xv-3.10a-bugfixes/xvtiffwr.c 2005-03-28 08:39:52.000000000 -0800
+@@ -9,15 +9,15 @@
+
+ #ifdef HAVE_TIFF
+
+-#include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */
++#include <tiffio.h> /* has to be after xv.h, as it needs varargs/stdarg */
+
+
+ #define ALLOW_JPEG 0 /* set to '1' to allow 'JPEG' choice in dialog box */
+
+
+ static void setupColormap PARM((TIFF *, byte *, byte *, byte *));
+-static int WriteTIFF PARM((FILE *, byte *, int, int, int,
+- byte *, byte *, byte *, int, int,
++static int WriteTIFF PARM((FILE *, byte *, int, int, int,
++ byte *, byte *, byte *, int, int,
+ char *, int, char *));
+
+
+@@ -29,7 +29,7 @@
+ {
+ short red[256], green[256], blue[256];
+ int i;
+-
++
+ /* convert 8-bit colormap to 16-bit */
+ for (i=0; i<256; i++) {
+ #define SCALE(x) ((((int)x)*((1L<<16)-1))/255)
+@@ -43,6 +43,7 @@
+
+
+ /*******************************************/
++/* Returns '0' if successful. */
+ static int WriteTIFF(fp,pic,ptype,w,h,rmap,gmap,bmap,numcols,colorstyle,
+ fname,comp,comment)
+ FILE *fp;
+@@ -55,6 +56,13 @@
+ TIFF *tif;
+ byte *pix;
+ int i,j;
++ int npixels = w*h;
++
++ if (w <= 0 || h <= 0 || npixels/w != h) {
++ SetISTR(ISTR_WARNING, "%s: image dimensions too large", fname);
++ /* TIFFError(fname, "Image dimensions too large"); */
++ return -1;
++ }
+
+ #ifndef VMS
+ tif = TIFFOpen(fname, "w");
+@@ -62,7 +70,7 @@
+ tif = TIFFFdOpen(dup(fileno(fp)), fname, "w");
+ #endif
+
+- if (!tif) return 0;
++ if (!tif) return -1; /* GRR: was 0 */
+
+ WaitCursor();
+
+@@ -84,19 +92,27 @@
+ TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, h);
+
+ TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, (int)2);
+- TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)1200.0);
+- TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float)1200.0);
++ TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float) 72.0);
++ TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float) 72.0);
+
+
+ /* write the image data */
+
+ if (ptype == PIC24) { /* only have to deal with FULLCOLOR or GREYSCALE */
+ if (colorstyle == F_FULLCOLOR) {
++ int count = 3*npixels;
++
++ if (count/3 != npixels) { /* already know w, h, npixels > 0 */
++ /* SetISTR(ISTR_WARNING, "%s: image dimensions too large", fname); */
++ TIFFError(fname, "Image dimensions too large");
++ return -1;
++ }
++
+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+-
+- TIFFWriteEncodedStrip(tif, 0, pic, w*h*3);
++
++ TIFFWriteEncodedStrip(tif, 0, pic, count);
+ }
+
+ else { /* colorstyle == F_GREYSCALE */
+@@ -106,13 +122,13 @@
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+
+- tpic = (byte *) malloc((size_t) w*h);
++ tpic = (byte *) malloc((size_t) npixels);
+ if (!tpic) FatalError("unable to malloc in WriteTIFF()");
+
+- for (i=0, tp=tpic, sp=pic; i<w*h; i++, sp+=3)
++ for (i=0, tp=tpic, sp=pic; i<npixels; i++, sp+=3)
+ *tp++ = MONO(sp[0],sp[1],sp[2]);
+-
+- TIFFWriteEncodedStrip(tif, 0, tpic, w*h);
++
++ TIFFWriteEncodedStrip(tif, 0, tpic, npixels);
+
+ free(tpic);
+ }
+@@ -123,32 +139,42 @@
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
+ setupColormap(tif, rmap, gmap, bmap);
+- TIFFWriteEncodedStrip(tif, 0, pic, w*h);
++ TIFFWriteEncodedStrip(tif, 0, pic, npixels);
+ }
+
+ else if (colorstyle == F_GREYSCALE) { /* 8-bit greyscale */
+ byte rgb[256];
+- byte *tpic = (byte *) malloc((size_t) w*h);
++ byte *tpic = (byte *) malloc((size_t) npixels);
+ byte *tp = tpic;
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+ for (i=0; i<numcols; i++) rgb[i] = MONO(rmap[i],gmap[i],bmap[i]);
+- for (i=0, pix=pic; i<w*h; i++,pix++) {
++ for (i=0, pix=pic; i<npixels; i++,pix++) {
+ if ((i&0x7fff)==0) WaitCursor();
+ *tp++ = rgb[*pix];
+ }
+- TIFFWriteEncodedStrip(tif, 0, tpic, w*h);
++ TIFFWriteEncodedStrip(tif, 0, tpic, npixels);
+ free(tpic);
+ }
+
+ else if (colorstyle == F_BWDITHER) { /* 1-bit B/W stipple */
+ int bit,k,flipbw;
+ byte *tpic, *tp;
++ tsize_t stripsize; /* signed */
+
+ flipbw = (MONO(rmap[0],gmap[0],bmap[0]) > MONO(rmap[1],gmap[1],bmap[1]));
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+- tpic = (byte *) malloc((size_t) TIFFStripSize(tif));
++ stripsize = TIFFStripSize(tif);
++ if (stripsize <= 0) {
++ TIFFError(fname, "Image dimensions too large");
++ return -1;
++ }
++ tpic = (byte *) malloc((size_t) stripsize);
++ if (tpic == 0) {
++ TIFFError(fname, "No space for strip buffer");
++ return -1;
++ }
+ tp = tpic;
+ for (i=0, pix=pic; i<h; i++) {
+ if ((i&15)==0) WaitCursor();
+@@ -167,7 +193,7 @@
+ *tp++ = (byte) (k & 0xff);
+ }
+ }
+- TIFFWriteEncodedStrip(tif, 0, tpic, TIFFStripSize(tif));
++ TIFFWriteEncodedStrip(tif, 0, tpic, stripsize);
+ free(tpic);
+ }
+ }
+@@ -209,16 +235,16 @@
+ {
+ int y;
+
+- tiffW = CreateWindow("xv tiff", "XVtiff", NULL,
++ tiffW = CreateWindow("xv tiff", "XVtiff", NULL,
+ TWIDE, THIGH, infofg, infobg, 0);
+ if (!tiffW) FatalError("can't create tiff window!");
+
+ XSelectInput(theDisp, tiffW, ExposureMask | ButtonPressMask | KeyPressMask);
+
+- BTCreate(&tbut[T_BOK], tiffW, TWIDE-140-1, THIGH-10-BUTTH-1, 60, BUTTH,
++ BTCreate(&tbut[T_BOK], tiffW, TWIDE-140-1, THIGH-10-BUTTH-1, 60, BUTTH,
+ "Ok", infofg, infobg, hicol, locol);
+
+- BTCreate(&tbut[T_BCANC], tiffW, TWIDE-70-1, THIGH-10-BUTTH-1, 60, BUTTH,
++ BTCreate(&tbut[T_BCANC], tiffW, TWIDE-70-1, THIGH-10-BUTTH-1, 60, BUTTH,
+ "Cancel", infofg, infobg, hicol, locol);
+
+ y = 55;
+@@ -237,7 +263,7 @@
+
+ XMapSubwindows(theDisp, tiffW);
+ }
+-
++
+
+ /***************************************************/
+ void TIFFDialog(vis)
+@@ -288,9 +314,9 @@
+
+ else if (xev->type == KeyPress) {
+ XKeyEvent *e = (XKeyEvent *) xev;
+- char buf[128]; KeySym ks; XComposeStatus status;
++ char buf[128]; KeySym ks; XComposeStatus status;
+ int stlen;
+-
++
+ stlen = XLookupString(e,buf,128,&ks,&status);
+ buf[stlen] = '\0';
+
+@@ -381,7 +407,7 @@
+ /* check BUTTs */
+
+ /* check the RBUTTS first, since they don't DO anything */
+- if ( (i=RBClick(compRB, x,y)) >= 0) {
++ if ( (i=RBClick(compRB, x,y)) >= 0) {
+ (void) RBTrack(compRB, i);
+ return;
+ }
+@@ -417,7 +443,7 @@
+ }
+ }
+ break;
+-
++
+ case T_BCANC: TIFFDialog(0); break;
+
+ default: break;
+diff -ruN xv-3.10a/xvxbm.c xv-3.10a-bugfixes/xvxbm.c
+--- xv-3.10a/xvxbm.c 1994-12-22 14:34:41.000000000 -0800
++++ xv-3.10a-bugfixes/xvxbm.c 2005-03-28 22:06:50.000000000 -0800
+@@ -25,7 +25,7 @@
+ * move forward to next occurence of '0x'
+ * repeat
+ */
+-
++
+
+ static int xbmError PARM((char *, char *));
+
+@@ -59,7 +59,7 @@
+
+ /* read width: skip lines until we hit a #define */
+ while (1) {
+- if (!fgets(line,256,fp))
++ if (!fgets(line,256,fp))
+ return(xbmError(bname, "EOF reached in header info."));
+
+ if (strncmp(line,"#define", (size_t) 7)==0 &&
+@@ -70,9 +70,9 @@
+
+ /* read height: skip lines until we hit another #define */
+ while (1) {
+- if (!fgets(line,256,fp))
++ if (!fgets(line,256,fp))
+ return(xbmError(bname, "EOF reached in header info."));
+-
++
+ if (strncmp(line,"#define", (size_t) 7)==0 &&
+ sscanf(line,"#define %s %d", name, &h)==2 &&
+ xv_strstr(name, "_height") != NULL) break;
+@@ -84,18 +84,18 @@
+ c = getc(fp); c1 = getc(fp);
+ while (c1!=EOF && !(c=='0' && c1=='x') ) { c = c1; c1 = getc(fp); }
+
+- if (c1==EOF)
++ if (c1==EOF)
+ return(xbmError(bname, "No bitmap data found"));
+
+- if (w<1 || h<1 || w>10000 || h>10000)
++ if (w<1 || h<1 || w>10000 || h>10000)
+ return(xbmError(bname, "not an XBM file"));
+-
+- pic8 = (byte *) calloc((size_t) w*h, (size_t) 1);
++
++ pic8 = (byte *) calloc((size_t) w*h, (size_t) 1); /* safe (10^8 max) */
+ if (!pic8) return(xbmError(bname, "couldn't malloc 'pic8'"));
+
+ /* load up the pinfo structure */
+ pinfo->pic = pic8;
+- pinfo->w = w;
++ pinfo->w = w;
+ pinfo->h = h;
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->type = PIC8;
+@@ -125,13 +125,13 @@
+ if (!bit) {
+ /* get next byte from file. we're already positioned at it */
+ c = getc(fp); c1 = getc(fp);
+- if (c<0 || c1<0) {
+- /* EOF: break out of loop */
++ if (c<0 || c1<0) {
++ /* EOF: break out of loop */
+ c=c1='0'; i=h; j=w;
+ xbmError(bname, "The file would appear to be truncated.");
+ }
+
+- if (hex[c1] == 255) {
++ if (hex[c1] == 255) {
+ if (hex[c] == 255) k = 0; /* no digits after the '0x' ... */
+ else k = hex[c];
+ }
+@@ -149,7 +149,7 @@
+ fclose(fp);
+
+ return 1;
+-}
++}
+
+
+
+@@ -172,7 +172,7 @@
+ {
+ /* pic is expected to be an array of w*h bytes, each of which is either
+ '0' or '1'.
+- The 'darker' of {rmap,gmap,bmap}[0] and {rmap,gmap,bmap}[1] is
++ The 'darker' of {rmap,gmap,bmap}[0] and {rmap,gmap,bmap}[1] is
+ considered black, and the other one, white.
+ Some sort of stippling algorithm should've
+ been called already to produce pic, otherwise the output won't be at all
+@@ -188,7 +188,7 @@
+ foo = (char *) index(name,'.');
+ if (foo) *foo='\0'; /* truncated name at first '.' */
+
+- fprintf(fp,"#define %s_width %d\n",name,w);
++ fprintf(fp,"#define %s_width %d\n",name,w);
+ fprintf(fp,"#define %s_height %d\n",name,h);
+ fprintf(fp,"static char %s_bits[] = {\n",name);
+
+diff -ruN xv-3.10a/xvxpm.c xv-3.10a-bugfixes/xvxpm.c
+--- xv-3.10a/xvxpm.c 1994-12-22 14:34:42.000000000 -0800
++++ xv-3.10a-bugfixes/xvxpm.c 2005-03-28 22:22:50.000000000 -0800
+@@ -10,7 +10,7 @@
+ * format images.
+ *
+ * Thanks go to Sam Yates (syates@spam.maths.adelaide.edu.au) for
+- * provideing inspiration.
++ * providing inspiration.
+ */
+
+ #define VALUES_LEN 80 /* Max length of values line */
+@@ -63,7 +63,7 @@
+ PICINFO *pinfo;
+ {
+ /* returns '1' on success */
+-
++
+ FILE *fp;
+ hentry item;
+ int c;
+@@ -73,100 +73,110 @@
+ byte *i_sptr; /* image search pointer */
+ long filesize;
+ int w, h, nc, cpp, line_pos;
++ int npixels;
+ short i, j, k; /* for() loop indexes */
+ hentry *clmp; /* colormap hash-table */
+ hentry *c_sptr; /* cmap hash-table search pointer*/
+ XColor col;
+-
++
+ bname = BaseName(fname);
+ fp = fopen(fname, "r");
+ if (!fp)
+ return (XpmLoadError(bname, "couldn't open file"));
+-
++
+ if (DEBUG)
+ printf("LoadXPM(): Loading xpm from %s\n", fname);
+-
++
+ fseek(fp, 0L, 2);
+ filesize = ftell(fp);
+ fseek(fp, 0L, 0);
+-
++
+ bufchar = -2;
+ in_quote = FALSE;
+-
++
+ /* Read in the values line. It is the first string in the
+ * xpm, and contains four numbers. w, h, num_colors, and
+ * chars_per_pixel. */
+-
++
+ /* First, get to the first string */
+ while (((c = XpmGetc(fp))!=EOF) && (c != '"')) ;
+ line_pos = 0;
+-
++
+ /* Now, read in the string */
+ while (((c = XpmGetc(fp))!=EOF) && (line_pos < VALUES_LEN) && (c != '"')) {
+ values[line_pos++] = c;
+ }
+ if (c != '"')
+ return (XpmLoadError(bname, "error parsing values line"));
+-
++
+ values[line_pos] = '\0';
+ sscanf(values, "%d%d%d%d", &w, &h, &nc, &cpp);
+ if (nc <= 0 || cpp <= 0)
+ return (XpmLoadError(bname, "No colours in Xpm?"));
+-
++
++ npixels = w * h;
++ if (w <= 0 || h <= 0 || npixels/w != h)
++ return (XpmLoadError(bname, "Image dimensions out of range"));
++
+ if (nc > 256)
+ pinfo->type = PIC24;
+ else
+ pinfo->type = PIC8;
+-
++
+ if (DEBUG)
+ printf("LoadXPM(): reading a %dx%d image (%d colors)\n", w, h, nc);
+-
++
+ /* We got this far... */
+ WaitCursor();
+-
++
+ if (!hash_init(nc))
+ return (XpmLoadError(bname, "Not enough memory to hash colormap"));
+-
++
+ clmp = (hentry *) malloc(nc * sizeof(hentry)); /* Holds the colormap */
+- if (pinfo->type == PIC8) pic = (byte *) malloc((size_t) (w*h));
+- else pic = (byte *) malloc((size_t) (w*h*3));
+-
++ if (pinfo->type == PIC8)
++ pic = (byte *) malloc((size_t) npixels);
++ else {
++ int bufsize = 3*npixels;
++ if (bufsize/3 != npixels)
++ return (XpmLoadError(bname, "Image dimensions out of range"));
++ pic = (byte *) malloc((size_t) bufsize);
++ }
++
+ if (!clmp || !pic)
+ return (XpmLoadError(bname, "Not enough memory to load pixmap"));
+-
++
+ c_sptr = clmp;
+ i_sptr = pic;
+-
++
+ /* initialize the 'hex' array for zippy ASCII-hex -> int conversion */
+-
++
+ for (i = 0 ; i < 256 ; i++) hex[i] = 0;
+ for (i = '0'; i <= '9' ; i++) hex[i] = i - '0';
+ for (i = 'a'; i <= 'f' ; i++) hex[i] = i - 'a' + 10;
+ for (i = 'A'; i <= 'F' ; i++) hex[i] = i - 'A' + 10;
+-
++
+ /* Again, we've made progress. */
+ WaitCursor();
+-
++
+ /* Now, we need to read the colormap. */
+ pinfo->colType = F_BWDITHER;
+ for (i = 0 ; i < nc ; i++) {
+ while (((c = XpmGetc(fp))!=EOF) && (c != '"')) ;
+ if (c != '"')
+ return (XpmLoadError(bname, "Error reading colormap"));
+-
++
+ for (j = 0 ; j < cpp ; j++)
+ c_sptr->token[j] = XpmGetc(fp);
+ c_sptr->token[j] = '\0';
+-
++
+ while (((c = XpmGetc(fp))!=EOF) && ((c == ' ') || (c == '\t'))) ;
+ if (c == EOF) /* The failure condition of getc() */
+ return (XpmLoadError(bname, "Error parsing colormap line"));
+-
++
+ do {
+ char key[3];
+ char color[40]; /* Need to figure a good size for this... */
+- short hd; /* Hex digits per R, G, or B */
+-
++
+ for (j=0; j<2 && (c != ' ') && (c != '\t') && (c != EOF); j++) {
+ key[j] = c;
+ c = XpmGetc(fp);
+@@ -185,14 +195,14 @@
+
+ while ((c == ' ') || (c == '\t'))
+ c = XpmGetc(fp);
+-
++
+ if (DEBUG > 1)
+ printf("LoadXPM(): Got color key '%s', color '%s'\n",
+ key, color);
+-
++
+ if (key[0] == 's') /* Don't find a color for a symbolic name */
+ continue;
+-
++
+ if (XParseColor(theDisp,theCmap,color,&col)) {
+ if (pinfo->type == PIC8) {
+ pinfo->r[i] = col.red >> 8;
+@@ -201,8 +211,8 @@
+ c_sptr->cv_index = i;
+
+ /* Is there a better way to do this? */
+- if (pinfo->colType != F_FULLCOLOR)
+- if (pinfo->colType == F_GREYSCALE)
++ if (pinfo->colType != F_FULLCOLOR) {
++ if (pinfo->colType == F_GREYSCALE) {
+ if (pinfo->r[i] == pinfo->g[i] &&
+ pinfo->g[i] == pinfo->b[i])
+ /* Still greyscale... */
+@@ -210,9 +220,9 @@
+ else
+ /* It's color */
+ pinfo->colType = F_FULLCOLOR;
+- else
++ } else {
+ if (pinfo->r[i] == pinfo->g[i] &&
+- pinfo->g[i] == pinfo->b[i])
++ pinfo->g[i] == pinfo->b[i]) {
+ if ((pinfo->r[i] == 0 || pinfo->r[i] == 0xff) &&
+ (pinfo->g[i] == 0 || pinfo->g[i] == 0xff) &&
+ (pinfo->b[i] == 0 || pinfo->b[i] == 0xff))
+@@ -221,10 +231,12 @@
+ else
+ /* It's greyscale */
+ pinfo->colType = F_GREYSCALE;
+- else
++ } else
+ /* It's color */
+ pinfo->colType = F_FULLCOLOR;
+-
++ }
++ }
++
+ }
+ else { /* PIC24 */
+ c_sptr->cv_rgb[0] = col.red >> 8;
+@@ -242,7 +254,7 @@
+ Timer(1000);
+ rgb = 0x808080;
+ }
+-
++
+ if (pinfo->type == PIC8) {
+ pinfo->r[i] = (rgb>>16) & 0xff;
+ pinfo->g[i] = (rgb>> 8) & 0xff;
+@@ -256,39 +268,39 @@
+ }
+ }
+
+-
++
+ xvbcopy((char *) c_sptr, (char *) &item, sizeof(item));
+ hash_insert(&item);
+-
+- if (DEBUG > 1)
++
++ if (DEBUG > 1)
+ printf("LoadXPM(): Cmap entry %d, 0x%02x 0x%02x 0x%02x, token '%s'\n",
+ i, pinfo->r[i], pinfo->g[i], pinfo->b[i], c_sptr->token);
+-
++
+ if (*key == 'c') { /* This is the color entry, keep it. */
+ while (c!='"' && c!=EOF) c = XpmGetc(fp);
+ break;
+ }
+-
++
+ } while (c != '"');
+ c_sptr++;
+
+ if (!(i%13)) WaitCursor();
+ } /* for */
+-
++
+
+ if (DEBUG)
+ printf("LoadXPM(): Read and stored colormap.\n");
+-
++
+ /* Now, read the pixmap. */
+ for (i = 0 ; i < h ; i++) {
+ while (((c = XpmGetc(fp))!=EOF) && (c != '"')) ;
+ if (c != '"')
+ return (XpmLoadError(bname, "Error reading colormap"));
+-
++
+ for (j = 0 ; j < w ; j++) {
+ char pixel[TOKEN_LEN];
+ hentry *mapentry;
+-
++
+ for (k = 0 ; k < cpp ; k++)
+ pixel[k] = XpmGetc(fp);
+ pixel[k] = '\0';
+@@ -300,7 +312,7 @@
+ pixel);
+ return (XpmLoadError(bname, "Can't map resolve into colormap"));
+ }
+-
++
+ if (pinfo->type == PIC8)
+ *i_sptr++ = mapentry->cv_index;
+ else {
+@@ -310,27 +322,27 @@
+ }
+ } /* for ( j < w ) */
+ (void)XpmGetc(fp); /* Throw away the close " */
+-
++
+ if (!(i%7)) WaitCursor();
+ } /* for ( i < h ) */
+-
++
+ pinfo->pic = pic;
+ pinfo->normw = pinfo->w = w;
+ pinfo->normh = pinfo->h = h;
+ pinfo->frmType = F_XPM;
+
+ if (DEBUG) printf("LoadXPM(): pinfo->colType is %d\n", pinfo->colType);
+-
++
+ sprintf(pinfo->fullInfo, "Xpm v3 Pixmap (%ld bytes)", filesize);
+ sprintf(pinfo->shrtInfo, "%dx%d Xpm.", w, h);
+ pinfo->comment = (char *)NULL;
+-
++
+ hash_destroy();
+ free(clmp);
+-
++
+ if (fp != stdin)
+ fclose(fp);
+-
++
+ return(1);
+ }
+
+@@ -349,17 +361,17 @@
+ FILE *f;
+ {
+ int c, d, lastc;
+-
++
+ if (bufchar != -2) {
+ /* The last invocation of this routine read the character... */
+ c = bufchar;
+ bufchar = -2;
+ return(c);
+ }
+-
++
+ if ((c = getc(f)) == EOF)
+ return(EOF);
+-
++
+ if (c == '"')
+ in_quote = !in_quote;
+ else if (!in_quote && c == '/') { /* might be a C-style comment */
+@@ -389,14 +401,14 @@
+
+
+ /***************************************/
+-static int hash(token)
++static int hash(token)
+ char *token;
+ {
+ int i, sum;
+
+ for (i=sum=0; token[i] != '\0'; i++)
+ sum += token[i];
+-
++
+ sum = sum % hash_len;
+ return (sum);
+ }
+@@ -414,7 +426,7 @@
+ */
+
+ int i;
+-
++
+ hash_len = 257;
+
+ hashtab = (hentry **) malloc(sizeof(hentry *) * hash_len);
+@@ -425,7 +437,7 @@
+
+ for (i = 0 ; i < hash_len ; i++)
+ hashtab[i] = NULL;
+-
++
+ return 1;
+ }
+
+@@ -436,22 +448,22 @@
+ {
+ int key;
+ hentry *tmp;
+-
++
+ key = hash(entry->token);
+-
++
+ tmp = (hentry *) malloc(sizeof(hentry));
+ if (!tmp) {
+ SetISTR(ISTR_WARNING, "Couldn't malloc hash entry in LoadXPM()!\n");
+ return 0;
+ }
+-
++
+ xvbcopy((char *)entry, (char *)tmp, sizeof(hentry));
+-
++
+ if (hashtab[key]) tmp->next = hashtab[key];
+ else tmp->next = NULL;
+-
++
+ hashtab[key] = tmp;
+-
++
+ return 1;
+ }
+
+@@ -462,9 +474,9 @@
+ {
+ int key;
+ hentry *tmp;
+-
++
+ key = hash(token);
+-
++
+ tmp = hashtab[key];
+ while (tmp && strcmp(token, tmp->token)) {
+ tmp = tmp->next;
+@@ -479,7 +491,7 @@
+ {
+ int i;
+ hentry *tmp;
+-
++
+ for (i=0; i<hash_len; i++) {
+ while (hashtab[i]) {
+ tmp = hashtab[i]->next;
+@@ -487,7 +499,7 @@
+ hashtab[i] = tmp;
+ }
+ }
+-
++
+ free(hashtab);
+ return;
+ }
+@@ -508,10 +520,10 @@
+ /* Note here, that tokenchars is assumed to contain 64 valid token */
+ /* characters. It's hardcoded to assume this for benefit of generating */
+ /* tokens, when there are more than 64^2 colors. */
+-
++
+ short i, imax, j; /* for() loop indices */
+ short cpp = 0;
+- char *tokenchars =
++ char *tokenchars =
+ ".#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ char *tokens;
+ char image_name[256], *foo;
+@@ -523,20 +535,21 @@
+ long li; /* for() loop index */
+ int numcol;
+ #endif
+-
+- if (DEBUG)
++
++ if (DEBUG) {
+ if (ptype == PIC8)
+ printf("WriteXPM(): Write a %d color, colortype %d, PIC8 image.\n",
+ nc, col);
+ else
+ printf("WriteXPM(): Write a colortype %d, PIC24 image.\n", col);
+-
++ }
++
+ foo = BaseName(name);
+ strcpy(image_name, foo);
+ foo = (char *)strchr(image_name, '.');
+ if (foo)
+ *foo = '\0'; /* Truncate name at first '.' */
+-
++
+ #ifdef USE_UNFINISHED_24BIT_WRITING_CODE
+ if (ptype == PIC24)
+ return -1;
+@@ -547,15 +560,15 @@
+ /* 'packed'. Code in here to do that should be removed if */
+ /* Conv24to8 is "fixed" to do this... */
+ /* Chris P. Ross (cross@eng.umd.edu) 28-Sept-94 */
+-
++
+ numcol = 0;
+-
++
+ if (ptype == PIC24) {
+ /* Reduce to an 8-bit image. Would be nice to actually write */
+ /* the 24-bit image. I'll have to code that someday... */
+ pic8 = Conv24to8(pic, w, h, 256, rtemp, gtemp, btemp);
+ if (!pic8) {
+- SetISTR(ISTR_WARNING,
++ SetISTR(ISTR_WARNING,
+ "%s: Unable to convert to 8-bit image in WriteXPM()",
+ image_name);
+ return 1;
+@@ -594,7 +607,7 @@
+ }
+ #endif
+
+-
++
+ #ifdef USE_UNFINISHED_24BIT_WRITING_CODE
+ if (ptype == PIC24) cpp = 4;
+ else if (numcol > 64) cpp = 2;
+@@ -609,7 +622,7 @@
+ fprintf(fp, "/* width height num_colors chars_per_pixel */\n");
+ fprintf(fp, "\" %3d %3d %6d %1d\",\n", w, h, numcol, cpp);
+ fprintf(fp, "/* colors */\n");
+-
++
+ switch (cpp) {
+
+ case 1: /* <= 64 colors; index into tokenchars */
+@@ -681,12 +694,12 @@
+
+ case 4:
+ /* Generate a colormap */
+-
++
+ break;
+ default:
+ break;
+ }
+-
++
+ if (fprintf(fp, "\"\n};\n") == EOF) {
+ return 1;
+ } else
+diff -ruN xv-3.10a/xvxwd.c xv-3.10a-bugfixes/xvxwd.c
+--- xv-3.10a/xvxwd.c 1994-12-22 14:34:40.000000000 -0800
++++ xv-3.10a-bugfixes/xvxwd.c 2005-03-28 22:37:07.000000000 -0800
+@@ -1,10 +1,10 @@
+-/*
++/*
+ ** Based on xwdtopnm.c - read and write an X11 or X10 window dump file
+ **
+ ** Modified heavily by Markus Baur (mbaur@ira.uka.de) for use as a part
+ ** of xv-2.21, 12/30/92
+ **
+- ** Hacked up again to support xv-3.00 and XWDs from 64bit machines
++ ** Hacked up again to support xv-3.00 and XWDs from 64bit machines
+ ** (e.g. DEC Alphas), 04/10/94
+ **
+ ** Copyright (C) 1989, 1991 by Jef Poskanzer.
+@@ -19,47 +19,53 @@
+ */
+
+ #include "xv.h"
++#include <limits.h> /* for CHAR_BIT */
++
++/* SJT: just in case ... */
++#ifndef CHAR_BIT
++# define CHAR_BIT 8
++#endif
+
+
+ /***************************** x11wd.h *****************************/
+ #define X11WD_FILE_VERSION 7
+ typedef struct {
+- CARD32 header_size; /* Size of the entire file header (bytes). */
+- CARD32 file_version; /* X11WD_FILE_VERSION */
+- CARD32 pixmap_format; /* Pixmap format */
+- CARD32 pixmap_depth; /* Pixmap depth */
+- CARD32 pixmap_width; /* Pixmap width */
+- CARD32 pixmap_height; /* Pixmap height */
+- CARD32 xoffset; /* Bitmap x offset */
+- CARD32 byte_order; /* MSBFirst, LSBFirst */
+- CARD32 bitmap_unit; /* Bitmap unit */
+- CARD32 bitmap_bit_order; /* MSBFirst, LSBFirst */
+- CARD32 bitmap_pad; /* Bitmap scanline pad */
+- CARD32 bits_per_pixel; /* Bits per pixel */
+- CARD32 bytes_per_line; /* Bytes per scanline */
+- CARD32 visual_class; /* Class of colormap */
+- CARD32 red_mask; /* Z red mask */
+- CARD32 green_mask; /* Z green mask */
+- CARD32 blue_mask; /* Z blue mask */
+- CARD32 bits_per_rgb; /* Log base 2 of distinct color values */
+- CARD32 colormap_entries; /* Number of entries in colormap */
+- CARD32 ncolors; /* Number of Color structures */
+- CARD32 window_width; /* Window width */
+- CARD32 window_height; /* Window height */
+- CARD32 window_x; /* Window upper left X coordinate */
+- CARD32 window_y; /* Window upper left Y coordinate */
+- CARD32 window_bdrwidth; /* Window border width */
++ CARD32 header_size; /* Size of the entire file header (bytes). */
++ CARD32 file_version; /* X11WD_FILE_VERSION */
++ CARD32 pixmap_format; /* Pixmap format */
++ CARD32 pixmap_depth; /* Pixmap depth */
++ CARD32 pixmap_width; /* Pixmap width */
++ CARD32 pixmap_height; /* Pixmap height */
++ CARD32 xoffset; /* Bitmap x offset */
++ CARD32 byte_order; /* MSBFirst, LSBFirst */
++ CARD32 bitmap_unit; /* Bitmap unit */
++ CARD32 bitmap_bit_order; /* MSBFirst, LSBFirst */
++ CARD32 bitmap_pad; /* Bitmap scanline pad */
++ CARD32 bits_per_pixel; /* Bits per pixel */
++ CARD32 bytes_per_line; /* Bytes per scanline */
++ CARD32 visual_class; /* Class of colormap */
++ CARD32 red_mask; /* Z red mask */
++ CARD32 grn_mask; /* Z green mask */
++ CARD32 blu_mask; /* Z blue mask */
++ CARD32 bits_per_rgb; /* Log base 2 of distinct color values */
++ CARD32 colormap_entries; /* Number of entries in colormap */
++ CARD32 ncolors; /* Number of Color structures */
++ CARD32 window_width; /* Window width */
++ CARD32 window_height; /* Window height */
++ CARD32 window_x; /* Window upper left X coordinate */
++ CARD32 window_y; /* Window upper left Y coordinate */
++ CARD32 window_bdrwidth; /* Window border width */
+ #ifdef WORD64
+- CARD32 header_pad;
++ CARD32 header_pad;
+ #endif
+- } X11WDFileHeader;
++} X11WDFileHeader;
+
+ typedef struct {
+ CARD32 num;
+ CARD16 red, green, blue;
+- CARD8 flags; /* do_red, do_green, do_blue */
++ CARD8 flags; /* do_red, do_green, do_blue */
+ CARD8 pad;
+- } X11XColor;
++} X11XColor;
+
+
+ /*-------------------------------------------------------------------------*/
+@@ -67,7 +73,7 @@
+ typedef byte pixel;
+
+ /* local functions */
+-static int getinit PARM((FILE *, int*, int*, int*, CARD32 *,
++static int getinit PARM((FILE *, int*, int*, int*, CARD32 *,
+ CARD32, PICINFO *));
+ static CARD32 getpixnum PARM((FILE *));
+ static int xwdError PARM((char *));
+@@ -78,19 +84,27 @@
+ static int readbiglong PARM((FILE *, CARD32 *));
+ static int readlittleshort PARM((FILE *, CARD16 *));
+ static int readlittlelong PARM((FILE *, CARD32 *));
++#if 0 /* NOTUSED */
+ static int writebigshort PARM((FILE *, int));
+ static int writebiglong PARM((FILE *, CARD32));
++#endif
++
++static void getcolorshift PARM((CARD32, int *, int *)); /* SJT */
+
++/* SJT: for 16bpp and 24bpp shifts */
++static int red_shift_right, red_justify_left,
++ grn_shift_right, grn_justify_left,
++ blu_shift_right, blu_justify_left;
+ static byte *pic8, *pic24;
+-static CARD32 red_mask, green_mask, blue_mask;
+-static int bits_per_item, bits_used, bit_shift, bits_per_pixel;
++static CARD32 red_mask, grn_mask, blu_mask;
++static int bits_per_item, bits_used, bit_shift,
++ bits_per_pixel, bits_per_rgb;
+ static char buf[4];
+ static char *byteP;
+ static CARD16 *shortP;
+ static CARD32 *longP;
+ static CARD32 pixel_mask;
+ static int byte_swap, byte_order, bit_order, filesize;
+-static byte bw[2] = {0, 0xff};
+
+ static char *bname;
+
+@@ -105,7 +119,7 @@
+
+ pixel *xP;
+ int col;
+- int rows, cols, padright, row;
++ int rows, cols, padright, row, npixels, bufsize;
+ CARD32 maxval, visualclass;
+ FILE *ifp;
+
+@@ -116,22 +130,28 @@
+
+ ifp = xv_fopen(fname, "r");
+ if (!ifp) return (xwdError("can't open file"));
+-
++
+ /* figure out the file size (used to check colormap size) */
+ fseek(ifp, 0L, 2);
+ filesize = ftell(ifp);
+ fseek(ifp, 0L, 0);
+-
++
+
+ if (getinit(ifp, &cols, &rows, &padright, &visualclass, maxval, pinfo))
+ return 0;
+
++ npixels = cols * rows;
++ if (cols <= 0 || rows <= 0 || npixels/cols != rows) {
++ xwdError("Image dimensions out of range");
++ return 0;
++ }
++
+
+ switch (visualclass) {
+ case StaticGray:
+ case GrayScale:
+ pinfo->colType = F_GREYSCALE;
+- pic8 = (byte *) calloc((size_t) cols*rows, (size_t) 1);
++ pic8 = (byte *) calloc((size_t) npixels, (size_t) 1);
+ if (!pic8) {
+ xwdError("couldn't malloc 'pic'");
+ return 0;
+@@ -140,18 +160,18 @@
+ for (row=0; row<rows; row++) {
+ for (col=0, xP=pic8+(row*cols); col<cols; col++, xP++)
+ *xP = getpixnum(ifp);
+-
++
+ for (col=0; col<padright; col++) getpixnum(ifp);
+ }
+
+ pinfo->type = PIC8;
+ pinfo->pic = pic8;
+- break;
++ break;
+
+ case StaticColor:
+ case PseudoColor:
+ pinfo->colType = F_FULLCOLOR;
+- pic8 = (byte *) calloc((size_t) cols*rows, (size_t) 1);
++ pic8 = (byte *) calloc((size_t) npixels, (size_t) 1);
+ if (!pic8) {
+ xwdError("couldn't malloc 'pic'");
+ return 0;
+@@ -162,15 +182,20 @@
+ *xP = getpixnum(ifp);
+ for (col=0; col<padright; col++) getpixnum(ifp);
+ }
+-
++
+ pinfo->type = PIC8;
+ pinfo->pic = pic8;
+- break;
++ break;
+
+ case TrueColor:
+ case DirectColor:
+ pinfo->colType = F_FULLCOLOR;
+- pic24 = (byte *) calloc((size_t) cols*rows*3, (size_t) 1);
++ bufsize = 3*npixels;
++ if (bufsize/3 != npixels) {
++ xwdError("Image dimensions out of range");
++ return 0;
++ }
++ pic24 = (byte *) calloc((size_t) bufsize, (size_t) 1);
+ if (!pic24) {
+ xwdError("couldn't malloc 'pic24'");
+ return 0;
+@@ -179,42 +204,44 @@
+ for (row=0; row<rows; row++) {
+ for (col=0, xP=pic24+(row*cols*3); col<cols; col++) {
+ CARD32 ul;
+-
++
+ ul = getpixnum(ifp);
+ switch (bits_per_pixel) {
+- case 16:
+- *xP++ = ((ul & red_mask) >> 0);
+- *xP++ = ((ul & green_mask) >> 5);
+- *xP++ = ((ul & blue_mask) >> 10);
+- break;
+-
+- case 24:
+- case 32:
+- *xP++ = (ul ) & 0xff;
+- *xP++ = (ul>> 8) & 0xff;
+- *xP++ = (ul>>16) & 0xff;
+- break;
+-
++ case 16:
++ case 24:
++ case 32:
++ /* SJT: shift all the way to the right and then shift left. The
++ pairs of shifts could be combined. There will be two right and
++ one left shift, but it's unknown which will be which. It seems
++ easier to do the shifts (which might be 0) separately than to
++ have a complex set of tests. I believe this is independent of
++ byte order but I have no way to test.
++ */
++ *xP++ = ((ul & red_mask) >> red_shift_right) << red_justify_left;
++ *xP++ = ((ul & grn_mask) >> grn_shift_right) << grn_justify_left;
++ *xP++ = ((ul & blu_mask) >> blu_shift_right) << blu_justify_left;
++ break;
++
+ default:
+- xwdError("True/Direct only supports 16, 24, and 32 bits");
++ xwdError("True/Direct supports only 16, 24, and 32 bits");
+ return 0;
+ }
+ }
+
+ for (col=0; col<padright; col++) getpixnum(ifp);
+ }
+-
++
+ pinfo->type = PIC24;
+ pinfo->pic = pic24;
+ break;
+-
++
+ default:
+ xwdError("unknown visual class");
+ return 0;
+ }
+
+ sprintf(pinfo->fullInfo, "XWD, %d-bit %s. (%d bytes)",
+- bits_per_pixel,
++ bits_per_pixel,
+ ((visualclass == StaticGray ) ? "StaticGray" :
+ (visualclass == GrayScale ) ? "GrayScale" :
+ (visualclass == StaticColor) ? "StaticColor" :
+@@ -258,10 +285,10 @@
+ maxv = 255L;
+
+ h11P = (X11WDFileHeader*) header;
+-
++
+ if (fread(&header[0], sizeof(*h11P), (size_t) 1, file) != 1)
+ return(xwdError("couldn't read X11 XWD file header"));
+-
++
+ if (h11P->file_version != X11WD_FILE_VERSION) {
+ byte_swap = 1;
+ h11P->header_size = bs_long(h11P->header_size);
+@@ -279,8 +306,8 @@
+ h11P->bytes_per_line = bs_long(h11P->bytes_per_line);
+ h11P->visual_class = bs_long(h11P->visual_class);
+ h11P->red_mask = bs_long(h11P->red_mask);
+- h11P->green_mask = bs_long(h11P->green_mask);
+- h11P->blue_mask = bs_long(h11P->blue_mask);
++ h11P->grn_mask = bs_long(h11P->grn_mask);
++ h11P->blu_mask = bs_long(h11P->blu_mask);
+ h11P->bits_per_rgb = bs_long(h11P->bits_per_rgb);
+ h11P->colormap_entries = bs_long(h11P->colormap_entries);
+ h11P->ncolors = bs_long(h11P->ncolors);
+@@ -294,7 +321,7 @@
+ for (i=0; i<h11P->header_size - sizeof(*h11P); i++)
+ if (getc(file) == EOF)
+ return(xwdError("couldn't read rest of X11 XWD file header"));
+-
++
+ /* Check whether we can handle this dump. */
+ if (h11P->pixmap_depth > 24)
+ return(xwdError("can't handle X11 pixmap_depth > 24"));
+@@ -303,27 +330,31 @@
+ return(xwdError("can't handle X11 bits_per_rgb > 24"));
+
+ if (h11P->pixmap_format != ZPixmap && h11P->pixmap_depth != 1) {
+- sprintf(errstr, "can't handle X11 pixmap_format %d with depth != 1",
++ sprintf(errstr, "can't handle X11 pixmap_format %ld with depth != 1",
+ h11P->pixmap_format);
+ return(xwdError(errstr));
+ }
+
+ if (h11P->bitmap_unit != 8 && h11P->bitmap_unit != 16 &&
+ h11P->bitmap_unit != 32) {
+- sprintf(errstr, "X11 bitmap_unit (%d) is non-standard - can't handle",
++ sprintf(errstr, "X11 bitmap_unit (%ld) is non-standard - can't handle",
+ h11P->bitmap_unit);
+ return(xwdError(errstr));
+ }
+-
++
+ grayscale = 1;
+ if (h11P->ncolors > 0) { /* Read X11 colormap. */
+- x11colors = (X11XColor*) malloc(h11P->ncolors * sizeof(X11XColor));
++ int bufsize = h11P->ncolors * sizeof(X11XColor);
++
++ if (bufsize/sizeof(X11XColor) != h11P->ncolors)
++ return(xwdError("too many colors"));
++ x11colors = (X11XColor*) malloc(bufsize);
+ if (!x11colors) return(xwdError("out of memory"));
+-
+- if (h11P->header_size + h11P->ncolors * sizeof(X11XColor)
++
++ if (h11P->header_size + bufsize
+ + h11P->pixmap_height * h11P->bytes_per_line + h11P->ncolors * 4
+ == filesize ) word64 = 1;
+-
++
+ if (word64) {
+ for (i = 0; i < h11P->ncolors; ++i) {
+ if (fread(&pad, sizeof(pad), (size_t) 1, file ) != 1)
+@@ -334,11 +365,11 @@
+ }
+ }
+ else {
+- if (fread(x11colors, sizeof(X11XColor), (size_t) h11P->ncolors, file)
++ if (fread(x11colors, sizeof(X11XColor), (size_t) h11P->ncolors, file)
+ != h11P->ncolors)
+ return(xwdError("couldn't read X11 XWD colormap"));
+ }
+-
++
+ for (i = 0; i < h11P->ncolors; ++i) {
+ if (byte_swap) {
+ x11colors[i].red = (CARD16) bs_short(x11colors[i].red);
+@@ -356,8 +387,11 @@
+ grayscale = 0;
+ }
+ }
+-
++
+ *visualclassP = h11P->visual_class;
++ /* SJT: FIXME. If bits_per_pixel == 16 maxv could be either 31 or 63.
++ It doesn't matter, though, because maxv is never used beyond here.
++ */
+ if (*visualclassP == TrueColor || *visualclassP == DirectColor) {
+ if (h11P->bits_per_pixel == 16) maxv = 31;
+ else maxv = 255;
+@@ -389,24 +423,48 @@
+ }
+ }
+ }
+-
++
+ *colsP = h11P->pixmap_width;
+ *rowsP = h11P->pixmap_height;
+ *padrightP = h11P->bytes_per_line * 8 / h11P->bits_per_pixel -
+ h11P->pixmap_width;
+-
++
+ bits_per_item = h11P->bitmap_unit;
+- bits_used = bits_per_item;
+ bits_per_pixel = h11P->bits_per_pixel;
+ byte_order = h11P->byte_order;
+ bit_order = h11P->bitmap_bit_order;
+-
++ bits_per_rgb = h11P->bits_per_rgb;
++
++
++ /* add sanity-code for freako 'exceed' server, where bitmapunit = 8
++ and bitsperpix = 32 (and depth=24)... */
++
++ if (bits_per_item < bits_per_pixel) {
++ bits_per_item = bits_per_pixel;
++
++ /* round bits_per_item up to next legal value, if necc */
++ if (bits_per_item < 8) bits_per_item = 8;
++ else if (bits_per_item < 16) bits_per_item = 16;
++ else bits_per_item = 32;
++ }
++
++
++ /* which raises the question: how (can?) you ever have a 24 bits per pix,
++ (ie, 3 bytes, no alpha/padding) */
++
++
++ bits_used = bits_per_item;
++
+ if (bits_per_pixel == sizeof(pixel_mask) * 8) pixel_mask = (CARD32) -1;
+ else pixel_mask = (1 << bits_per_pixel) - 1;
+-
+- red_mask = h11P->red_mask;
+- green_mask = h11P->green_mask;
+- blue_mask = h11P->blue_mask;
++
++ red_mask = h11P->red_mask;
++ grn_mask = h11P->grn_mask;
++ blu_mask = h11P->blu_mask;
++
++ getcolorshift(red_mask, &red_shift_right, &red_justify_left);
++ getcolorshift(grn_mask, &grn_shift_right, &grn_justify_left);
++ getcolorshift(blu_mask, &blu_shift_right, &blu_justify_left);
+
+ byteP = (char *) buf;
+ shortP = (CARD16 *) buf;
+@@ -416,18 +474,57 @@
+ }
+
+
++/* SJT: figure out the proper shifts */
++static void getcolorshift (CARD32 mask, int *rightshift, int *leftshift)
++{
++ int lshift, rshift;
++ unsigned int uu;
++
++ if (mask == 0)
++ {
++ *rightshift = *leftshift = 0;
++ return;
++ }
++
++ uu = mask;
++ lshift = rshift = 0;
++ while ((uu & 0xf) == 0)
++ {
++ rshift += 4;
++ uu >>= 4;
++ }
++ while ((uu & 1) == 0)
++ {
++ rshift++;
++ uu >>= 1;
++ }
++
++ while (uu != 0)
++ {
++ if (uu & 1)
++ {
++ lshift++;
++ uu >>= 1;
++ }
++ }
++ *rightshift = rshift;
++ *leftshift = CHAR_BIT * sizeof(pixel) - lshift;
++ return;
++}
++
++
+ /******************************/
+ static CARD32 getpixnum(file)
+ FILE* file;
+ {
+ int n;
+-
++
+ if (bits_used == bits_per_item) {
+ switch (bits_per_item) {
+ case 8:
+ *byteP = getc(file);
+ break;
+-
++
+ case 16:
+ if (byte_order == MSBFirst) {
+ if (readbigshort(file, shortP) == -1)
+@@ -438,7 +535,7 @@
+ xwdWarning("unexpected EOF");
+ }
+ break;
+-
++
+ case 32:
+ if (byte_order == MSBFirst) {
+ if (readbiglong(file, longP) == -1)
+@@ -449,41 +546,41 @@
+ xwdWarning("unexpected EOF");
+ }
+ break;
+-
++
+ default:
+ xwdWarning("can't happen");
+ }
+ bits_used = 0;
+-
++
+ if (bit_order == MSBFirst)
+ bit_shift = bits_per_item - bits_per_pixel;
+ else
+ bit_shift = 0;
+ }
+-
++
+ switch (bits_per_item) {
+ case 8:
+ n = (*byteP >> bit_shift) & pixel_mask;
+ break;
+-
++
+ case 16:
+ n = (*shortP >> bit_shift) & pixel_mask;
+ break;
+-
++
+ case 32:
+ n = (*longP >> bit_shift) & pixel_mask;
+ break;
+-
++
+ default:
+ n = 0;
+ xwdWarning("can't happen");
+ }
+-
++
+ if (bit_order == MSBFirst) bit_shift -= bits_per_pixel;
+ else bit_shift += bits_per_pixel;
+
+ bits_used += bits_per_pixel;
+-
++
+ return n;
+ }
+
+@@ -511,7 +608,7 @@
+
+
+
+-/*
++/*
+ * Byte-swapping junk.
+ */
+
+@@ -537,7 +634,7 @@
+ {
+ union cheat u;
+ unsigned char t;
+-
++
+ u.l = l;
+ t = u.c[0]; u.c[0] = u.c[3]; u.c[3] = t;
+ t = u.c[1]; u.c[1] = u.c[2]; u.c[2] = t;
+@@ -549,7 +646,7 @@
+
+
+
+-/*
++/*
+ * Endian I/O.
+ */
+
+@@ -584,7 +681,7 @@
+ {
+ *sP = getc(in) & 0xff;
+ *sP |= (getc(in) & 0xff) << 8;
+-
++
+ if (ferror(in)) return -1;
+ return 0;
+ }
+@@ -604,6 +701,7 @@
+ }
+
+
++#if 0 /* NOTUSED */
+ static int writebiglong(out, l)
+ FILE* out;
+ CARD32 l;
+@@ -624,3 +722,4 @@
+ putc(s&0xff, out);
+ return 0;
+ }
++#endif /* 0 (NOTUSED) */
diff --git a/source/xap/xv/xv-3.10a.patch b/source/xap/xv/xv-3.10a.patch
new file mode 100644
index 00000000..0bf8210f
--- /dev/null
+++ b/source/xap/xv/xv-3.10a.patch
@@ -0,0 +1,2745 @@
+Installation Instructions:
+
+This patch will update XV 3.10 to 3.10a.
+
+Copy this file into the top-level XV source directory, and apply it using:
+ patch -p0 <xv-3.10a.patch
+
+Then do a 'make clean', followed by a 'make' (or 'make install').
+
+Note: if you don't have a copy of the 'patch' utility, you can get one
+ via anonymous ftp on ftp.cis.upenn.edu, in pub/xv. Of course,
+ once you're there, it may be easier to just pick up the latest copy
+ of the XV distribution, rather than try to patch your existing copy,
+ but hey, that's up to you...
+
+
+
+diff -c -r ../xv-3.10/CHANGELOG ./CHANGELOG
+*** ../xv-3.10/CHANGELOG Thu Dec 22 14:18:39 1994
+--- ./CHANGELOG Mon Jan 23 18:21:55 1995
+***************
+*** 1,12 ****
+ Revision History
+ ----------------
+
+! Make_xv.com in vms directory wouldn't build xvxpm.c or xvfits.c (and thus, XV!)
+! (Rick Dyson (dyson@sunfish.Physics.UIowa.Edu))
+
+
+! XV 3.10 Public Release 12/21/94
+! -------------------------
+ Bug Fix: Greyscale downsampling bug in JPEG code fixed.
+ (Tom Lane (tgl@sss.pgh.pa.us))
+
+--- 1,84 ----
+ Revision History
+ ----------------
+
+! XV 3.10a bug-fix release 12/29/94
+! ----------------------------------
+! Bug Fix: Problems loading JPEG files in 8-bit mode on some systems.
+! (Rick Richardson (rick@digibd.com))
+! (Chad R. Larson (chad@anasazi.com))
+
++ Bug Fix: Added '-pkludge' command line option and 'popupKludge' boolean
++ resource. If true, selects the 'old-style' pop-up window positioning
++ code. The various popup windows should appear with the Ok button
++ (or whatever) centered around the cursor. If the windows routinely
++ pop up slightly off-center from the cursor, try turning this on.
+
+! Bug Fix: '3' and 'Q' characters in the Text Annotation character set were
+! boogered up... (Sidik Isani (si@acpub.duke.edu))
+!
+! Bug Fix: '-iconic' option wasn't working.
+! (David Pesetsky (iedsp@agt.gmeds.com))
+!
+! Bug Fix: Didn't properly read greyscale RLE files.
+! (Robert Cunningham (rkc@xn.ll.mit.edu))
+!
+! Bug Fix: 'AutoCrop' on 24-bit images could produce 0x0 images. A problem!
+! (Leon Shaner (leon@mtu.edu))
+!
+! Bug Fix: GIF reader would blow up if there were multiple comments.
+! (Markus Gyger (mgyger@itr.ch))
+!
+! Bug Fix: Behavior under virtual window managers may be improved.
+! (steveg@pa.dec.com)
+!
+! Enhancement: Text in 'temperature gauge' (during slow operations) is now
+! XOR'd on, so it isn't obscured by the filled area of the gauge.
+! (Jerry Whelan (jerryw@bnl.gov))
+!
+! Enhancement: man page for vdcomp written
+! (James Ralston Crawford (qralston+@pitt.edu))
+!
+! Enhancement: PCX code can now read 24-bit PCX files.
+! (Dave Cohrs (cohrs@legato.com))
+!
+! Portability: Patch for Linux (David Hankins (dhankins@oz.net))
+!
+! Portability: Patches for ISC 4.0 Interactive/SunSoft Unix
+! (Jack Bailey (jjb@jagware.bcc.com))
+!
+! Portability: Compiler noise (from Sun's Professional C compiler) cleaned up.
+! (John Fritz (jfritz@bpo-ess.ceco.com))
+!
+! Portability: Many nits picked by Pyramid compiler
+! (Chad R. Larson (chad@anasazi.com))
+!
+! Portability: Some malloc's in xvfits.c needed casting.
+! (Bill Silvert (sysop@biome.bio.ns.ca))
+!
+! Portability: Further VMS problems solved.
+! (Rick Dyson (dyson@sunfish.physics.uiowa.edu))
+!
+! Portability: select() on HP-UX 9.x expects (int *) instead of (fd_set *)
+! (Richard Allen (ra@os.is))
+!
+! Portability: Removed 'const' from second parameter in decl. for decode_run()
+! in tif_fax3.c. (Glenn Spargo (gspargo@ctron.com))
+!
+! Portability: Added 'fcntl.h' to xv.h, as some systems may not have O_RDONLY
+! declared elsewhere. (Mitchell Blank (blankm@cae.wisc.edu))
+!
+! Portability: Font selection strings in xv.c didn't have enough '*'s in them.
+! Would fail on some X servers.
+! (Rick Richardson (rick@digibd.com))
+!
+! Second XV 3.10 Public Release 12/22/94
+! ----------------------------------------
+! Bug Fix: Make_xv.com in vms directory wouldn't build xvxpm.c or xvfits.c
+! (and thus, XV!) (Rick Dyson (dyson@sunfish.Physics.UIowa.Edu))
+!
+!
+! Initial XV 3.10 Public Release 12/21/94
+! ----------------------------------------
+ Bug Fix: Greyscale downsampling bug in JPEG code fixed.
+ (Tom Lane (tgl@sss.pgh.pa.us))
+
+diff -c -r ../xv-3.10/Imakefile ./Imakefile
+*** ../xv-3.10/Imakefile Thu Dec 22 14:12:21 1994
+--- ./Imakefile Fri Jan 13 15:24:01 1995
+***************
+*** 264,269 ****
+--- 264,270 ----
+ InstallManPageLong(docs/bggen,$(MANDIR),bggen)
+ InstallManPageLong(docs/xcmap,$(MANDIR),xcmap)
+ InstallManPageLong(docs/xvp2p,$(MANDIR),xvpictoppm)
++ InstallManPageLong(docs/vdcomp,$(MANDIR),vdcomp)
+
+ tar:
+ tar cf xv.tar Makefile* Imakefile *.c *.h bits docs \
+
+diff -c -r ../xv-3.10/Makefile ./Makefile
+*** ../xv-3.10/Makefile Thu Jan 19 13:40:09 1995
+--- ./Makefile Mon Jan 23 15:20:54 1995
+***************
+*** 92,99 ****
+--- 92,110 ----
+ #MCHN= -Dhpux -D_HPUX_SOURCE
+ # 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
++ # 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)
++ # to whichever of those lines you used, as HP tends to store their X11
++ # include files in a non-standard place...
+
+
++ ### for LINUX, uncomment the following line
++ #MCHN = -DLINUX
++
++
+ # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
+ #MCHN = -Dsco -DPOSIX
+ #
+***************
+*** 111,120 ****
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+
+! # For Interactive Unix System machines
+! # you'll want to modify add the following options to the end of the
+! # LIBS definition (below) (or so I'm told)
+! # -lnsl_s -linet -lgen
+
+
+ #----------'Roll Your Own' Options----------
+--- 122,129 ----
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+
+! # For Interactive/SunSoft Unix ISC 4.0 (whatever *that* is!)
+! #MCHN = -DSVR4 -DBSDTYPES
+
+
+ #----------'Roll Your Own' Options----------
+***************
+*** 233,238 ****
+--- 242,248 ----
+ 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)
+
+ tar:
+
+diff -c -r ../xv-3.10/Makefile.std ./Makefile.std
+*** ../xv-3.10/Makefile.std Thu Dec 22 14:12:21 1994
+--- ./Makefile.std Mon Jan 23 20:06:26 1995
+***************
+*** 92,99 ****
+--- 92,110 ----
+ #MCHN= -Dhpux -D_HPUX_SOURCE
+ # 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
++ # 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)
++ # to whichever of those lines you used, as HP tends to store their X11
++ # include files in a non-standard place...
+
+
++ ### for LINUX, uncomment the following line
++ #MCHN = -DLINUX
++
++
+ # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
+ #MCHN = -Dsco -DPOSIX
+ #
+***************
+*** 111,120 ****
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+
+! # For Interactive Unix System machines
+! # you'll want to modify add the following options to the end of the
+! # LIBS definition (below) (or so I'm told)
+! # -lnsl_s -linet -lgen
+
+
+ #----------'Roll Your Own' Options----------
+--- 122,129 ----
+ #
+ #MCHN = -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4
+
+! # For Interactive/SunSoft Unix ISC 4.0 (whatever *that* is!)
+! #MCHN = -DSVR4 -DBSDTYPES
+
+
+ #----------'Roll Your Own' Options----------
+***************
+*** 233,238 ****
+--- 242,248 ----
+ 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)
+
+ tar:
+
+diff -c -r ../xv-3.10/xcmap.c ./xcmap.c
+*** ../xv-3.10/xcmap.c Thu Dec 22 14:12:20 1994
+--- ./xcmap.c Tue Jan 03 16:14:52 1995
+***************
+*** 102,108 ****
+ continue;
+ }
+
+! strind = index(argv[i], ':'); /* old-style display */
+ if(strind != NULL) {
+ display = argv[i];
+ continue;
+--- 102,108 ----
+ continue;
+ }
+
+! strind = (char *) index(argv[i], ':'); /* old-style display */
+ if(strind != NULL) {
+ display = argv[i];
+ continue;
+
+diff -c -r ../xv-3.10/xv.c ./xv.c
+*** ../xv-3.10/xv.c Thu Dec 22 14:12:15 1994
+--- ./xv.c Thu Jan 19 13:08:43 1995
+***************
+*** 25,33 ****
+
+
+ /* program needs one of the following fonts. Trys them in ascending order */
+! #define FONT1 "-*-lucida-medium-r-*-*-12-*"
+! #define FONT2 "-*-helvetica-medium-r-*-*-12-*"
+! #define FONT3 "-*-helvetica-medium-r-*-*-11-*"
+ #define FONT4 "6x13"
+ #define FONT5 "fixed"
+
+--- 25,33 ----
+
+
+ /* program needs one of the following fonts. Trys them in ascending order */
+! #define FONT1 "-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-*"
+! #define FONT2 "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*"
+! #define FONT3 "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
+ #define FONT4 "6x13"
+ #define FONT5 "fixed"
+
+***************
+*** 218,224 ****
+ fgstr = "#000000"; bgstr = "#B2C0DC";
+ histr = "#C6D5E2"; lostr = "#8B99B5";
+
+! cmd = rindex(argv[0],'/');
+ if (!cmd) cmd = argv[0]; else cmd++;
+
+ tmpstr = (char *) getenv("TMPDIR");
+--- 218,224 ----
+ fgstr = "#000000"; bgstr = "#B2C0DC";
+ histr = "#C6D5E2"; lostr = "#8B99B5";
+
+! cmd = (char *) rindex(argv[0],'/');
+ if (!cmd) cmd = argv[0]; else cmd++;
+
+ tmpstr = (char *) getenv("TMPDIR");
+***************
+*** 261,267 ****
+ xorMasks[6] = 0xc4c4c4c5;
+ xorMasks[7] = 0xffffffff;
+
+! kludge_offx = kludge_offy = 0;
+
+ conv24 = CONV24_SLOW; /* use 'slow' algorithm by default */
+
+--- 261,267 ----
+ xorMasks[6] = 0xc4c4c4c5;
+ xorMasks[7] = 0xffffffff;
+
+! kludge_offx = kludge_offy = winCtrPosKludge = 0;
+
+ conv24 = CONV24_SLOW; /* use 'slow' algorithm by default */
+
+***************
+*** 1107,1112 ****
+--- 1107,1113 ----
+ if (rd_flag("nostat")) nostat = def_int;
+ if (rd_flag("ownCmap")) owncmap = def_int;
+ if (rd_flag("perfect")) perfect = def_int;
++ if (rd_flag("popupKludge")) winCtrPosKludge = def_int;
+ if (rd_str ("print")) strncpy(printCmd, def_str,
+ (size_t) PRINTCMDLEN);
+ if (rd_flag("pscompress")) pscomp = def_int;
+***************
+*** 1361,1366 ****
+--- 1362,1368 ----
+ else if (!argcmp(argv[i],"-nostat", 4,1,&nostat)); /* nostat */
+ else if (!argcmp(argv[i],"-owncmap", 2,1,&owncmap)); /* own cmap */
+ else if (!argcmp(argv[i],"-perfect", 3,1,&perfect)); /* -perfect */
++ else if (!argcmp(argv[i],"-pkludge", 3,1,&winCtrPosKludge));
+ else if (!argcmp(argv[i],"-poll", 3,1,&polling)); /* chk mod? */
+
+ else if (!argcmp(argv[i],"-preset",3,0,&pm)) /* preset */
+***************
+*** 1615,1620 ****
+--- 1617,1623 ----
+ printoption("[-/+nostat]");
+ printoption("[-/+owncmap]");
+ printoption("[-/+perfect]");
++ printoption("[-/+pkludge]");
+ printoption("[-/+poll]");
+ printoption("[-preset #]");
+ printoption("[-quick24]");
+***************
+*** 1683,1689 ****
+
+ int i;
+
+! if (strlen(a1) < minlen || strlen(a2) < minlen) return 1;
+ if (strlen(a1) > strlen(a2)) return 1;
+
+ if (strncmp(a1+1, a2+1, strlen(a1)-1)) return 1;
+--- 1686,1693 ----
+
+ int i;
+
+! if ((strlen(a1) < (size_t) minlen) || (strlen(a2) < (size_t) minlen))
+! return 1;
+ if (strlen(a1) > strlen(a2)) return 1;
+
+ if (strncmp(a1+1, a2+1, strlen(a1)-1)) return 1;
+***************
+*** 1860,1866 ****
+
+
+ /* chop off trailing ".Z", ".z", or ".gz" from displayed basefname, if any */
+! if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".Z")==0)
+ basefname[strlen(basefname)-2]='\0';
+ else {
+ #ifdef GUNZIP
+--- 1864,1871 ----
+
+
+ /* 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)
+ basefname[strlen(basefname)-2]='\0';
+ else {
+ #ifdef GUNZIP
+***************
+*** 2698,2705 ****
+ to what it was. necessary because uncompress doesn't handle files
+ that don't end with '.Z' */
+
+! if (strlen(name)>=2 && strcmp(name + strlen(name)-2,".Z")!=0 &&
+! strcmp(name + strlen(name)-2,".z")!=0) {
+ strcpy(namez, name);
+ strcat(namez,".Z");
+
+--- 2703,2711 ----
+ to what it was. necessary because uncompress doesn't handle files
+ that don't end with '.Z' */
+
+! if (strlen(name) >= (size_t) 2 &&
+! strcmp(name + strlen(name)-2,".Z")!=0 &&
+! strcmp(name + strlen(name)-2,".z")!=0) {
+ strcpy(namez, name);
+ strcat(namez,".Z");
+
+***************
+*** 2890,2896 ****
+ char fullcmd[512], tmpname[64], str[512];
+ int i;
+
+! if (!cmd || strlen(cmd)<2) return 1;
+
+ sprintf(tmpname,"%s/xvXXXXXX", tmpdir);
+ mktemp(tmpname);
+--- 2896,2902 ----
+ char fullcmd[512], tmpname[64], str[512];
+ int i;
+
+! if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
+
+ sprintf(tmpname,"%s/xvXXXXXX", tmpdir);
+ mktemp(tmpname);
+***************
+*** 3270,3276 ****
+
+ xwmh.icon_pixmap = iconPix;
+ xwmh.icon_mask = iconmask;
+! xwmh.flags |= ( IconPixmapHint | IconMaskHint) ;
+
+
+ if (startIconic && firstTime) {
+--- 3276,3282 ----
+
+ xwmh.icon_pixmap = iconPix;
+ xwmh.icon_mask = iconmask;
+! xwmh.flags |= (IconPixmapHint | IconMaskHint);
+
+
+ if (startIconic && firstTime) {
+***************
+*** 3787,3793 ****
+--- 3793,3802 ----
+ | EnterWindowMask | LeaveWindowMask );
+
+ StoreDeleteWindowProp(mainW);
++ XFlush(theDisp);
+ XMapWindow(theDisp,mainW);
++ XFlush(theDisp);
++ if (startIconic) sleep(2); /* give it time to get the window up...*/
+ }
+ }
+
+diff -c -r ../xv-3.10/xv.h ./xv.h
+*** ../xv-3.10/xv.h Thu Dec 22 14:12:15 1994
+--- ./xv.h Mon Jan 23 15:22:23 1995
+***************
+*** 8,15 ****
+ #include "config.h"
+
+
+! #define REVDATE "Version 3.10 Rev: 12/16/94"
+! #define VERSTR "3.10"
+
+ /*
+ * uncomment the following, and modify for your site, but only if you've
+--- 8,15 ----
+ #include "config.h"
+
+
+! #define REVDATE "Version 3.10a Rev: 12/29/94"
+! #define VERSTR "3.10a"
+
+ /*
+ * uncomment the following, and modify for your site, but only if you've
+***************
+*** 62,67 ****
+--- 62,74 ----
+ #endif
+
+
++ #ifdef LINUX
++ # ifndef _LINUX_LIMITS_H
++ # include <linux/limits.h>
++ # endif
++ #endif
++
++
+ #include <X11/Xos.h> /* need type declarations immediately */
+
+ /*********************************************************/
+***************
+*** 198,203 ****
+--- 205,217 ----
+ # include <limits.h>
+ # endif
+
++ /*** for select() call ***/
++ # ifdef __hpux
++ # define XV_FDTYPE (int *)
++ # else
++ # define XV_FDTYPE (fd_set *)
++ # endif
++
+ #endif /* NEEDSTIME */
+
+
+***************
+*** 214,219 ****
+--- 228,237 ----
+ # include <dirent.h>
+ # endif
+
++ # if defined(SVR4) || defined(SYSV)
++ # include <fcntl.h>
++ # endif
++
+ # include <sys/param.h>
+ # include <sys/stat.h>
+
+***************
+*** 961,966 ****
+--- 979,985 ----
+ WHERE int ch_offx,ch_offy; /* ChngAttr ofst for reparented windows */
+ WHERE int kludge_offx, /* WM kludges for SetWindowPos routine */
+ kludge_offy;
++ WHERE int winCtrPosKludge; /* kludge for popup positioning... */
+
+ WHERE int ignoreConfigs; /* an evil kludge... */
+
+diff -c -r ../xv-3.10/xv24to8.c ./xv24to8.c
+*** ../xv-3.10/xv24to8.c Thu Dec 22 14:12:15 1994
+--- ./xv24to8.c Fri Jan 13 14:49:21 1995
+***************
+*** 374,382 ****
+
+ #define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \
+ PPM_ASSIGN( (newp), \
+! (int) PPM_GETR(p) * (newmaxval) / ((int)oldmaxval), \
+! (int) PPM_GETG(p) * (newmaxval) / ((int)oldmaxval), \
+! (int) PPM_GETB(p) * (newmaxval) / ((int)oldmaxval) )
+
+
+ /* Luminance macro. */
+--- 374,382 ----
+
+ #define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \
+ PPM_ASSIGN( (newp), \
+! ((int) PPM_GETR(p)) * ((int)newmaxval) / ((int)oldmaxval), \
+! ((int) PPM_GETG(p)) * ((int)newmaxval) / ((int)oldmaxval), \
+! ((int) PPM_GETB(p)) * ((int)newmaxval) / ((int)oldmaxval) )
+
+
+ /* Luminance macro. */
+
+diff -c -r ../xv-3.10/xvbrowse.c ./xvbrowse.c
+*** ../xv-3.10/xvbrowse.c Thu Dec 22 14:12:20 1994
+--- ./xvbrowse.c Thu Jan 19 12:49:17 1995
+***************
+*** 20,26 ****
+ #define NEEDSDIR
+ #include "xv.h"
+
+! #ifdef VMS
+ typedef unsigned int mode_t; /* file mode bits */
+ #endif
+
+--- 20,26 ----
+ #define NEEDSDIR
+ #include "xv.h"
+
+! #if defined(VMS) || defined(isc)
+ typedef unsigned int mode_t; /* file mode bits */
+ #endif
+
+***************
+*** 2579,2585 ****
+ int rv;
+
+ /* temporarily excise trailing '/' char from br->path */
+! if (strlen(br->path)>2 && br->path[strlen(br->path)-1] == '/')
+ br->path[strlen(br->path)-1] = '\0';
+
+ rv = chdir(br->path);
+--- 2579,2585 ----
+ int rv;
+
+ /* temporarily excise trailing '/' char from br->path */
+! if ((strlen(br->path) > (size_t) 2) && br->path[strlen(br->path)-1] == '/')
+ br->path[strlen(br->path)-1] = '\0';
+
+ rv = chdir(br->path);
+***************
+*** 3544,3550 ****
+ case RFT_PBM: if (xv_strstr(pinfo.fullInfo, "raw")) strcat(str,"Raw ");
+ else strcat(str,"Ascii ");
+
+! for (i=0; i<3 && strlen(pinfo.fullInfo)>3; i++) {
+ str1[0] = pinfo.fullInfo[i]; str1[1] = '\0';
+ strcat(str, str1);
+ }
+--- 3544,3550 ----
+ case RFT_PBM: if (xv_strstr(pinfo.fullInfo, "raw")) strcat(str,"Raw ");
+ else strcat(str,"Ascii ");
+
+! for (i=0; i<3 && (strlen(pinfo.fullInfo)>(size_t)3); i++){
+ str1[0] = pinfo.fullInfo[i]; str1[1] = '\0';
+ strcat(str, str1);
+ }
+***************
+*** 4521,4527 ****
+
+ /* try to delete a thumbnail file, as well. ignore errors */
+ strcpy(buf1, name); /* tmp1 = leading path of name */
+! tmp = rindex(buf1, '/');
+ if (!tmp) strcpy(buf1,".");
+ else *tmp = '\0';
+
+--- 4521,4527 ----
+
+ /* try to delete a thumbnail file, as well. ignore errors */
+ strcpy(buf1, name); /* tmp1 = leading path of name */
+! tmp = (char *) rindex(buf1, '/');
+ if (!tmp) strcpy(buf1,".");
+ else *tmp = '\0';
+
+diff -c -r ../xv-3.10/xvbutt.c ./xvbutt.c
+*** ../xv-3.10/xvbutt.c Thu Dec 22 14:12:16 1994
+--- ./xvbutt.c Tue Jan 03 16:19:51 1995
+***************
+*** 961,967 ****
+
+ /* truncate at TAB, if any */
+ strcpy(stbuf, str);
+! if ((str = index(stbuf, '\t')) != NULL) *str = '\0';
+ str = stbuf;
+
+ x1 = CENTERX(mfinfo, x + w/2, str);
+--- 961,967 ----
+
+ /* truncate at TAB, if any */
+ strcpy(stbuf, str);
+! if ((str = (char *) index(stbuf, '\t')) != NULL) *str = '\0';
+ str = stbuf;
+
+ x1 = CENTERX(mfinfo, x + w/2, str);
+***************
+*** 1073,1079 ****
+ char *sp, str[256];
+
+ strcpy(str, mb->list[i]);
+! sp = index(str, '\t');
+ j = StringWidth(sp+1);
+ if (j>mtabwide) mtabwide = j;
+
+--- 1073,1079 ----
+ char *sp, str[256];
+
+ strcpy(str, mb->list[i]);
+! sp = (char *) index(str, '\t');
+ j = StringWidth(sp+1);
+ if (j>mtabwide) mtabwide = j;
+
+***************
+*** 1139,1145 ****
+ for (i=0; i<mb->nlist; i++) {
+ char txtstr[256], *tabstr;
+ strcpy(txtstr, mb->list[i]);
+! if ((tabstr = index(txtstr, '\t'))) {
+ *tabstr = '\0'; tabstr++;
+ }
+
+--- 1139,1145 ----
+ for (i=0; i<mb->nlist; i++) {
+ char txtstr[256], *tabstr;
+ strcpy(txtstr, mb->list[i]);
+! if ((tabstr = (char *) index(txtstr, '\t'))) {
+ *tabstr = '\0'; tabstr++;
+ }
+
+diff -c -r ../xv-3.10/xvcolor.c ./xvcolor.c
+*** ../xv-3.10/xvcolor.c Thu Dec 22 14:12:17 1994
+--- ./xvcolor.c Fri Jan 06 14:29:23 1995
+***************
+*** 616,622 ****
+ *foo = "No r/w cells available. Using r/o color.";
+
+ tmp = GetISTR(ISTR_WARNING);
+! if (strlen(tmp)>0) sprintf(tstr, "%s %s", tmp, foo);
+ else sprintf(tstr, "%s", foo);
+ SetISTR(ISTR_WARNING,tstr);
+
+--- 616,622 ----
+ *foo = "No r/w cells available. Using r/o color.";
+
+ tmp = GetISTR(ISTR_WARNING);
+! if (strlen(tmp) > (size_t) 0) sprintf(tstr, "%s %s", tmp, foo);
+ else sprintf(tstr, "%s", foo);
+ SetISTR(ISTR_WARNING,tstr);
+
+***************
+*** 790,799 ****
+ }
+
+
+! void xvFreeColors(dp, cm,pixels, npixels, planes)
+ Display *dp;
+ Colormap cm;
+! unsigned long pixels[];
+ int npixels;
+ unsigned long planes;
+ {
+--- 790,799 ----
+ }
+
+
+! void xvFreeColors(dp, cm, pixels, npixels, planes)
+ Display *dp;
+ Colormap cm;
+! unsigned long *pixels;
+ int npixels;
+ unsigned long planes;
+ {
+
+diff -c -r ../xv-3.10/xvcut.c ./xvcut.c
+*** ../xv-3.10/xvcut.c Thu Dec 22 14:12:21 1994
+--- ./xvcut.c Fri Jan 13 14:55:48 1995
+***************
+*** 760,766 ****
+ len |= ((int) data[2])<<16;
+ len |= ((int) data[3])<<24;
+
+! XFree(data);
+
+ /* read the rest of the data (len bytes) */
+ i = XGetWindowProperty(theDisp, rootW, clipAtom, 1L,
+--- 760,766 ----
+ len |= ((int) data[2])<<16;
+ len |= ((int) data[3])<<24;
+
+! XFree((void *) data);
+
+ /* read the rest of the data (len bytes) */
+ i = XGetWindowProperty(theDisp, rootW, clipAtom, 1L,
+***************
+*** 774,780 ****
+
+ data1 = (byte *) malloc((size_t) len);
+ if (!data1) {
+! XFree(data);
+ ErrPopUp("Insufficient memory to retrieve clipboard!", "\nShucks!");
+ return (byte *) NULL;
+ }
+--- 774,780 ----
+
+ data1 = (byte *) malloc((size_t) len);
+ if (!data1) {
+! XFree((void *) data);
+ ErrPopUp("Insufficient memory to retrieve clipboard!", "\nShucks!");
+ return (byte *) NULL;
+ }
+***************
+*** 785,791 ****
+ data1[3] = (len>>24) & 0xff;
+ xvbcopy((char *) data, (char *) data1+4, (size_t) len-4);
+
+! XFree(data);
+ return data1;
+ }
+ }
+--- 785,791 ----
+ data1[3] = (len>>24) & 0xff;
+ xvbcopy((char *) data, (char *) data1+4, (size_t) len-4);
+
+! XFree((void *) data);
+ return data1;
+ }
+ }
+
+diff -c -r ../xv-3.10/xvdial.c ./xvdial.c
+*** ../xv-3.10/xvdial.c Thu Dec 22 14:12:17 1994
+--- ./xvdial.c Tue Jan 03 16:20:31 1995
+***************
+*** 358,364 ****
+
+ if (dp->units) strcat(foo,dp->units);
+ foo1[0] = '\0';
+! if (strlen(foo)<i) {
+ for (i = i - strlen(foo); i>0; i--) strcat(foo1," ");
+ }
+ strcat(foo1, foo);
+--- 358,364 ----
+
+ 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," ");
+ }
+ strcat(foo1, foo);
+
+diff -c -r ../xv-3.10/xvdir.c ./xvdir.c
+*** ../xv-3.10/xvdir.c Thu Dec 22 14:12:16 1994
+--- ./xvdir.c Tue Jan 03 16:21:39 1995
+***************
+*** 650,656 ****
+ changedDir = strcmp(path, oldpath);
+ strcpy(oldpath, path);
+
+! if (strlen(path)>1 && path[strlen(path)-1] != '/')
+ strcat(path,"/"); /* tack on a trailing '/' to make path consistent */
+
+ /* path will be something like: "/u3/bradley/src/weiner/whatever/" */
+--- 650,656 ----
+ changedDir = strcmp(path, oldpath);
+ strcpy(oldpath, path);
+
+! if ((strlen(path) > (size_t) 1) && path[strlen(path)-1] != '/')
+ strcat(path,"/"); /* tack on a trailing '/' to make path consistent */
+
+ /* path will be something like: "/u3/bradley/src/weiner/whatever/" */
+***************
+*** 851,857 ****
+ xvbcopy(&filename[curPos], &filename[curPos-1], (size_t) (len-curPos+1));
+ curPos--;
+
+! if (strlen(filename)>0) scrollToFileName();
+ }
+
+ else if (c=='\025') { /* ^U: clear entire line */
+--- 851,857 ----
+ xvbcopy(&filename[curPos], &filename[curPos-1], (size_t) (len-curPos+1));
+ curPos--;
+
+! if (strlen(filename) > (size_t) 0) scrollToFileName();
+ }
+
+ else if (c=='\025') { /* ^U: clear entire line */
+***************
+*** 1023,1029 ****
+ XDrawLine(theDisp, dnamW, theGC, 2,0,2,LINEHIGH+5);
+ }
+
+! if (enPos<strlen(filename)) { /* draw a "there's more over here" doowah */
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+5,0,DNAMWIDE+5,LINEHIGH+5);
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+4,0,DNAMWIDE+4,LINEHIGH+5);
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+3,0,DNAMWIDE+3,LINEHIGH+5);
+--- 1023,1030 ----
+ XDrawLine(theDisp, dnamW, theGC, 2,0,2,LINEHIGH+5);
+ }
+
+! if ((size_t) enPos < strlen(filename)) {
+! /* draw a "there's more over here" doowah */
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+5,0,DNAMWIDE+5,LINEHIGH+5);
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+4,0,DNAMWIDE+4,LINEHIGH+5);
+ XDrawLine(theDisp, dnamW, theGC, DNAMWIDE+3,0,DNAMWIDE+3,LINEHIGH+5);
+***************
+*** 1538,1544 ****
+ if (*fname != '~') return 0; /* doesn't start with a tilde, don't expand */
+
+ /* look for the first '/' after the tilde */
+! sp = index(fname,'/');
+ if (sp == 0) { /* no '/' after the tilde */
+ sp = fname+strlen(fname); /* sp = end of string */
+ }
+--- 1539,1545 ----
+ if (*fname != '~') return 0; /* doesn't start with a tilde, don't expand */
+
+ /* look for the first '/' after the tilde */
+! sp = (char *) index(fname,'/');
+ if (sp == 0) { /* no '/' after the tilde */
+ sp = fname+strlen(fname); /* sp = end of string */
+ }
+
+diff -c -r ../xv-3.10/xvevent.c ./xvevent.c
+*** ../xv-3.10/xvevent.c Thu Dec 22 14:12:17 1994
+--- ./xvevent.c Mon Jan 23 18:20:24 1995
+***************
+*** 1407,1413 ****
+ okay = 0;
+ do {
+ i = GetStrPopUp(txt, labels, 2, buf, 64, "0123456789", 1);
+! if (!i && strlen(buf)>0) { /* hit 'Ok', had a string entered */
+ /* check for page in range */
+ j = atoi(buf);
+ if (j>=1 && j<=numPages) {
+--- 1407,1414 ----
+ okay = 0;
+ do {
+ i = GetStrPopUp(txt, labels, 2, buf, 64, "0123456789", 1);
+! if (!i && strlen(buf) > (size_t) 0) {
+! /* hit 'Ok', had a string entered */
+ /* check for page in range */
+ j = atoi(buf);
+ if (j>=1 && j<=numPages) {
+***************
+*** 2030,2035 ****
+--- 2031,2037 ----
+ xwc.height = xwa->height;
+
+
++ #ifdef BAD_IDEA
+ /* if there is a virtual window manager running, then we should translate
+ the coordinates that are in terms of 'real' screen into coordinates
+ that are in terms of the 'virtual' root window
+***************
+*** 2043,2049 ****
+ xwc.x,xwc.y,x1,y1);
+ xwc.x = x1; xwc.y = y1;
+ }
+!
+
+
+ if (DEBUG) {
+--- 2045,2051 ----
+ xwc.x,xwc.y,x1,y1);
+ xwc.x = x1; xwc.y = y1;
+ }
+! #endif
+
+
+ if (DEBUG) {
+
+diff -c -r ../xv-3.10/xvfits.c ./xvfits.c
+*** ../xv-3.10/xvfits.c Thu Dec 22 14:12:21 1994
+--- ./xvfits.c Wed Dec 28 02:43:29 1994
+***************
+*** 69,75 ****
+ char basename[64];
+
+ if (fits_block == NULL) {
+! fits_block = malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+
+--- 69,75 ----
+ char basename[64];
+
+ if (fits_block == NULL) {
+! fits_block = (char *) malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+
+***************
+*** 170,176 ****
+ byte rgb[256];
+
+ if (!fits_block) {
+! fits_block = malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+
+--- 170,176 ----
+ byte rgb[256];
+
+ if (!fits_block) {
+! fits_block = (char *) malloc((size_t) BLOCKSIZE);
+ if (!fits_block) FatalError("Insufficient memory for FITS block buffer");
+ }
+
+***************
+*** 498,504 ****
+ j++; /* make j length of comment */
+ if (j > 0) { /* skip blank comment cards */
+ if (fs->comment == NULL) {
+! fs->comment = malloc((size_t) commsize);
+ if (fs->comment == NULL)
+ FatalError("Insufficient memory for comment buffer");
+ }
+--- 498,504 ----
+ j++; /* make j length of comment */
+ if (j > 0) { /* skip blank comment cards */
+ if (fs->comment == NULL) {
+! fs->comment = (char *) malloc((size_t) commsize);
+ if (fs->comment == NULL)
+ FatalError("Insufficient memory for comment buffer");
+ }
+
+diff -c -r ../xv-3.10/xvgam.c ./xvgam.c
+*** ../xv-3.10/xvgam.c Thu Dec 22 14:12:15 1994
+--- ./xvgam.c Fri Jan 13 14:51:14 1995
+***************
+*** 1838,1844 ****
+ gMap[i] = gcmap[i];
+ bMap[i] = bcmap[i];
+ if (!ncols)
+! cols[i] = (rMap[i] + gMap[i] + bMap[i] >= 128*3) ? white : black;
+ }
+ }
+ }
+--- 1838,1845 ----
+ gMap[i] = gcmap[i];
+ bMap[i] = bcmap[i];
+ if (!ncols)
+! cols[i] = (((int)rMap[i]) + ((int)gMap[i]) + ((int)bMap[i]) >= 128*3)
+! ? white : black;
+ }
+ }
+ }
+***************
+*** 1903,1909 ****
+ bMap[col] = bGraf.func[bv];
+
+ if (!ncols)
+! cols[col] = (rMap[col] + gMap[col] + bMap[col] >= 128*3) ? white : black;
+
+ if (DEBUG>1) fprintf(stderr," -> %d,%d,%d\n",rMap[col],gMap[col],bMap[col]);
+ }
+--- 1904,1912 ----
+ bMap[col] = bGraf.func[bv];
+
+ if (!ncols)
+! cols[col] =
+! (((int)rMap[col]) + ((int)gMap[col]) + ((int)bMap[col]) >= 128*3)
+! ? white : black;
+
+ if (DEBUG>1) fprintf(stderr," -> %d,%d,%d\n",rMap[col],gMap[col],bMap[col]);
+ }
+
+diff -c -r ../xv-3.10/xvgif.c ./xvgif.c
+*** ../xv-3.10/xvgif.c Thu Dec 22 14:12:15 1994
+--- ./xvgif.c Tue Jan 10 14:54:41 1995
+***************
+*** 254,260 ****
+
+
+ if (cmtlen>0) { /* build into one un-blocked comment */
+! cmt = (byte *) malloc((size_t) cmtlen);
+ if (!cmt) gifWarning("couldn't malloc space for comments\n");
+ else {
+ sp = cmt;
+--- 254,260 ----
+
+
+ if (cmtlen>0) { /* build into one un-blocked comment */
+! cmt = (byte *) malloc((size_t) (cmtlen + 1));
+ if (!cmt) gifWarning("couldn't malloc space for comments\n");
+ else {
+ sp = cmt;
+***************
+*** 262,270 ****
+ sbsize = (*ptr1++);
+ for (j=0; j<sbsize; j++, sp++, ptr1++) *sp = *ptr1;
+ } while (sbsize);
+
+ if (pinfo->comment) { /* have to strcat onto old comments */
+! cmt1 = (byte *) malloc(strlen(pinfo->comment) + cmtlen);
+ if (!cmt1) {
+ gifWarning("couldn't malloc space for comments\n");
+ free(cmt);
+--- 262,271 ----
+ sbsize = (*ptr1++);
+ for (j=0; j<sbsize; j++, sp++, ptr1++) *sp = *ptr1;
+ } while (sbsize);
++ *sp = '\0';
+
+ if (pinfo->comment) { /* have to strcat onto old comments */
+! cmt1 = (byte *) malloc(strlen(pinfo->comment) + cmtlen + 2);
+ if (!cmt1) {
+ gifWarning("couldn't malloc space for comments\n");
+ free(cmt);
+***************
+*** 271,276 ****
+--- 272,278 ----
+ }
+ else {
+ strcpy((char *) cmt1, (char *) pinfo->comment);
++ strcat((char *) cmt1, (char *) "\n");
+ strcat((char *) cmt1, (char *) cmt);
+ free(pinfo->comment);
+ free(cmt);
+
+diff -c -r ../xv-3.10/xvgifwr.c ./xvgifwr.c
+*** ../xv-3.10/xvgifwr.c Thu Dec 22 14:12:16 1994
+--- ./xvgifwr.c Tue Jan 03 16:22:21 1995
+***************
+*** 141,147 ****
+ fprintf(stderr,"WrGIF: pic=%lx, w,h=%dx%d, numcols=%d, Bits%d,Cmap=%d\n",
+ (u_long) pic8, w,h,numcols,BitsPerPixel,ColorMapSize);
+
+! if (comment && strlen(comment)>0)
+ fwrite("GIF89a", (size_t) 1, (size_t) 6, fp); /* the GIF magic number */
+ else
+ fwrite("GIF87a", (size_t) 1, (size_t) 6, fp); /* the GIF magic number */
+--- 141,147 ----
+ fprintf(stderr,"WrGIF: pic=%lx, w,h=%dx%d, numcols=%d, Bits%d,Cmap=%d\n",
+ (u_long) pic8, w,h,numcols,BitsPerPixel,ColorMapSize);
+
+! if (comment && strlen(comment) > (size_t) 0)
+ fwrite("GIF89a", (size_t) 1, (size_t) 6, fp); /* the GIF magic number */
+ else
+ fwrite("GIF87a", (size_t) 1, (size_t) 6, fp); /* the GIF magic number */
+***************
+*** 175,181 ****
+ }
+ }
+
+! if (comment && strlen(comment)>0) { /* write comment blocks */
+ char *sp;
+ int i, blen;
+
+--- 175,181 ----
+ }
+ }
+
+! if (comment && strlen(comment) > (size_t) 0) { /* write comment blocks */
+ char *sp;
+ int i, blen;
+
+diff -c -r ../xv-3.10/xviff.c ./xviff.c
+*** ../xv-3.10/xviff.c Thu Dec 22 14:12:20 1994
+--- ./xviff.c Fri Jan 13 14:54:54 1995
+***************
+*** 463,469 ****
+
+ if (codeByte < 0x80) {
+ codeByte++;
+! if ((slen > codeByte) && (dlen >= codeByte)) {
+ slen -= codeByte + 1;
+ dlen -= codeByte;
+ while (codeByte > 0) {
+--- 463,469 ----
+
+ if (codeByte < 0x80) {
+ codeByte++;
+! if ((slen > (long) codeByte) && (dlen >= (long) codeByte)) {
+ slen -= codeByte + 1;
+ dlen -= codeByte;
+ while (codeByte > 0) {
+***************
+*** 476,482 ****
+
+ else if (codeByte > 0x80) {
+ codeByte = 0x81 - (codeByte & 0x7f);
+! if ((slen > 0) && (dlen >= codeByte)) {
+ dataByte = *sptr++;
+ slen -= 2;
+ dlen -= codeByte;
+--- 476,482 ----
+
+ else if (codeByte > 0x80) {
+ codeByte = 0x81 - (codeByte & 0x7f);
+! if ((slen > (long) 0) && (dlen >= (long) codeByte)) {
+ dataByte = *sptr++;
+ slen -= 2;
+ dlen -= codeByte;
+
+diff -c -r ../xv-3.10/xvimage.c ./xvimage.c
+*** ../xv-3.10/xvimage.c Thu Dec 22 14:12:17 1994
+--- ./xvimage.c Fri Jan 13 19:11:36 1995
+***************
+*** 675,680 ****
+--- 675,682 ----
+ # define inabsrange(a,n) ( (a) < n && (a) > -n )
+
+
++ if (cHIGH<3 || cWIDE<3) return 0;
++
+ ctop = cbot = cleft = cright = 0;
+
+ if (picType != PIC24) FatalError("doAutoCrop24 called when pic!=PIC24");
+***************
+*** 780,787 ****
+
+ /* do the actual cropping */
+ if (cleft || ctop || cbot || cright) {
+ DoCrop(cXOFF+cleft, cYOFF+ctop,
+! cWIDE-(cleft+cright), cHIGH-(ctop+cbot));
+ return 1;
+ }
+
+--- 782,792 ----
+
+ /* do the actual cropping */
+ if (cleft || ctop || cbot || cright) {
++ if (cWIDE - (cleft + cright) < 1 ||
++ cHIGH - (ctop + cbot ) < 1) return 0; /* sanity check */
++
+ DoCrop(cXOFF+cleft, cYOFF+ctop,
+! cWIDE-(cleft+cright), cHIGH-(ctop+cbot));
+ return 1;
+ }
+
+***************
+*** 859,865 ****
+ eWIDE = (int) (cWIDE * expw);
+ eHIGH = (int) (cHIGH * exph);
+
+! if (eWIDE > maxWIDE || h > maxHIGH) { /* make 'normal' size */
+ if (cWIDE>maxWIDE || cHIGH>maxHIGH) {
+ double r,wr,hr;
+ wr = ((double) cWIDE) / maxWIDE;
+--- 864,870 ----
+ eWIDE = (int) (cWIDE * expw);
+ eHIGH = (int) (cHIGH * exph);
+
+! if (eWIDE>maxWIDE || eHIGH>maxHIGH) { /* make 'normal' size */
+ if (cWIDE>maxWIDE || cHIGH>maxHIGH) {
+ double r,wr,hr;
+ wr = ((double) cWIDE) / maxWIDE;
+***************
+*** 873,878 ****
+--- 878,886 ----
+ }
+
+
++ if (eWIDE<1) eWIDE = 1;
++ if (eHIGH<1) eHIGH = 1;
++
+ SetCursors(-1);
+ }
+
+***************
+*** 2823,2831 ****
+ }
+
+ if (omode == PAD_ORGB) {
+! rval = (r * fg) / 100 + (p24[0] * bg) / 100;
+! gval = (g * fg) / 100 + (p24[1] * bg) / 100;
+! bval = (b * fg) / 100 + (p24[2] * bg) / 100;
+ }
+ else { /* one of the HSV modes */
+ double fh,fs,fv,fw, bh,bs,bv,bw, h,s,v;
+--- 2831,2839 ----
+ }
+
+ if (omode == PAD_ORGB) {
+! rval = (r * fg) / 100 + ((int) p24[0] * bg) / 100;
+! gval = (g * fg) / 100 + ((int) p24[1] * bg) / 100;
+! bval = (b * fg) / 100 + ((int) p24[2] * bg) / 100;
+ }
+ else { /* one of the HSV modes */
+ double fh,fs,fv,fw, bh,bs,bv,bw, h,s,v;
+
+diff -c -r ../xv-3.10/xvjpeg.c ./xvjpeg.c
+*** ../xv-3.10/xvjpeg.c Thu Dec 22 14:12:16 1994
+--- ./xvjpeg.c Thu Jan 05 03:17:13 1995
+***************
+*** 612,620 ****
+ }
+
+
+- jpeg_finish_decompress(&cinfo);
+
+-
+ /* return 'PICINFO' structure to XV */
+
+ pinfo->pic = pic;
+--- 612,618 ----
+***************
+*** 646,655 ****
+
+ pinfo->comment = comment;
+
+ jpeg_destroy_decompress(&cinfo);
+ fclose(fp);
+
+! comment = NULL;
+ return 1;
+ }
+
+--- 644,654 ----
+
+ pinfo->comment = comment;
+
++ jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+ fclose(fp);
+
+! comment = (char *) NULL;
+ return 1;
+ }
+
+***************
+*** 806,812 ****
+ If none, add 2. If one, add 1. If two or more, add none. */
+
+ sp = comment + strlen(comment);
+! for (i=0; i<3 && i<strlen(comment); i++) {
+ sp--;
+ if (*sp != '\n') break;
+ }
+--- 805,811 ----
+ If none, add 2. If one, add 1. If two or more, add none. */
+
+ sp = comment + strlen(comment);
+! for (i=0; i<3 && ((size_t) i < strlen(comment)); i++) {
+ sp--;
+ if (*sp != '\n') break;
+ }
+
+diff -c -r ../xv-3.10/xvmisc.c ./xvmisc.c
+*** ../xv-3.10/xvmisc.c Thu Dec 22 14:12:15 1994
+--- ./xvmisc.c Fri Jan 13 18:41:34 1995
+***************
+*** 729,735 ****
+ 'simple' name ('weenie.gif'). Note that it does not make a copy of
+ the name, so don't be modifying it... */
+
+! basname = rindex(fname, '/');
+ if (!basname) basname = fname;
+ else basname++;
+
+--- 729,735 ----
+ 'simple' name ('weenie.gif'). Note that it does not make a copy of
+ the name, so don't be modifying it... */
+
+! basname = (char *) rindex(fname, '/');
+ if (!basname) basname = fname;
+ else basname++;
+
+***************
+*** 770,802 ****
+ XSetForeground(theDisp, theGC, fg);
+ XFillRectangle(theDisp,win,theGC, x+3, y+3, (u_int) barwide, (u_int) h-5);
+
+! if (barwide < maxwide) {
+! if (numchars) {
+ XSetForeground(theDisp, theGC, bg);
+ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
+ (u_int) (maxwide-barwide), (u_int) (h-5));
+-
+- XSetForeground(theDisp, theGC, fg);
+- XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+- CENTERY(mfinfo, (y+h/2)), str, numchars);
+ }
+- else {
+- XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 0, x+w-3, y+h/2 + 0);
+-
+- XSetForeground(theDisp, theGC, lo);
+- XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 1, x+w-3, y+h/2 + 1);
+
+! XSetForeground(theDisp, theGC, hi);
+! XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 2, x+w-3, y+h/2 + 2);
+!
+! XSetForeground(theDisp, theGC, bg);
+! XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
+! (u_int) (maxwide-barwide), (u_int) (h/2 - 3));
+!
+! XFillRectangle(theDisp, win, theGC, x+3+barwide, y+h/2 + 3,
+! (u_int) (maxwide-barwide),(u_int)((h-3) - (h/2+3)) + 1);
+! }
+ }
+ }
+
+ else {
+--- 770,808 ----
+ XSetForeground(theDisp, theGC, fg);
+ XFillRectangle(theDisp,win,theGC, x+3, y+3, (u_int) barwide, (u_int) h-5);
+
+! if (numchars) { /* do string */
+! if (barwide < maxwide) {
+ XSetForeground(theDisp, theGC, bg);
+ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
+ (u_int) (maxwide-barwide), (u_int) (h-5));
+ }
+
+! XSetFunction(theDisp, theGC, GXinvert);
+! XSetPlaneMask(theDisp, theGC, fg ^ bg);
+!
+! XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+! CENTERY(mfinfo, (y+h/2)), str, numchars);
+!
+! XSetFunction(theDisp, theGC, GXcopy);
+! XSetPlaneMask(theDisp, theGC, AllPlanes);
+ }
++
++ else if (barwide < maxwide) {
++ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 0, x+w-3, y+h/2 + 0);
++
++ XSetForeground(theDisp, theGC, lo);
++ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 1, x+w-3, y+h/2 + 1);
++
++ XSetForeground(theDisp, theGC, hi);
++ XDrawLine(theDisp,win,theGC,x+3+barwide, y+h/2 + 2, x+w-3, y+h/2 + 2);
++
++ XSetForeground(theDisp, theGC, bg);
++ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+3,
++ (u_int) (maxwide-barwide), (u_int) (h/2 - 3));
++
++ XFillRectangle(theDisp, win, theGC, x+3+barwide, y+h/2 + 3,
++ (u_int) (maxwide-barwide),(u_int)((h-3) - (h/2+3)) + 1);
++ }
+ }
+
+ else {
+***************
+*** 806,832 ****
+ XSetForeground(theDisp, theGC, fg);
+ XFillRectangle(theDisp,win,theGC, x+1, y+1, (u_int) barwide, (u_int) h-1);
+
+! if (barwide < maxwide) {
+! if (numchars) {
+ XSetForeground(theDisp, theGC, bg);
+ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
+ (u_int) (maxwide-barwide), (u_int) (h-1));
+-
+- XSetForeground(theDisp, theGC, fg);
+- XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+- CENTERY(mfinfo, (y+h/2)), str, numchars);
+ }
+! else {
+! XDrawLine(theDisp, win, theGC, x+1+barwide, y+h/2, x+w-1, y+h/2);
+!
+! XSetForeground(theDisp, theGC, bg);
+! XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
+! (u_int) (maxwide-barwide), (u_int) (h/2 - 1));
+!
+! XFillRectangle(theDisp, win, theGC, x+1+barwide, y+h/2 + 1,
+! (u_int)(maxwide-barwide),(u_int)(((h-1) - (h/2+1))+1));
+! }
+ }
+ }
+
+ XFlush(theDisp);
+--- 812,844 ----
+ XSetForeground(theDisp, theGC, fg);
+ XFillRectangle(theDisp,win,theGC, x+1, y+1, (u_int) barwide, (u_int) h-1);
+
+! if (numchars) {
+! if (barwide < maxwide) {
+ XSetForeground(theDisp, theGC, bg);
+ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
+ (u_int) (maxwide-barwide), (u_int) (h-1));
+ }
+!
+! XSetFunction(theDisp, theGC, GXinvert);
+! XSetPlaneMask(theDisp, theGC, fg ^ bg);
+!
+! XDrawString(theDisp, win, theGC, CENTERX(mfinfo, (x+w/2), str),
+! CENTERY(mfinfo, (y+h/2)), str, numchars);
+!
+! XSetFunction(theDisp, theGC, GXcopy);
+! XSetPlaneMask(theDisp, theGC, AllPlanes);
+ }
++
++ else if (barwide < maxwide) {
++ XDrawLine(theDisp, win, theGC, x+1+barwide, y+h/2, x+w-1, y+h/2);
++
++ XSetForeground(theDisp, theGC, bg);
++ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+1,
++ (u_int) (maxwide-barwide), (u_int) (h/2 - 1));
++
++ XFillRectangle(theDisp, win, theGC, x+1+barwide, y+h/2 + 1,
++ (u_int)(maxwide-barwide),(u_int)(((h-1) - (h/2+1))+1));
++ }
+ }
+
+ XFlush(theDisp);
+***************
+*** 1117,1124 ****
+
+ time.tv_sec = usec / 1000000L;
+ time.tv_usec = usec % 1000000L;
+! select(0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL, &time);
+ }
+ #endif /* VMS */
+ }
+
+--- 1129,1137 ----
+
+ time.tv_sec = usec / 1000000L;
+ time.tv_usec = usec % 1000000L;
+! select(0, XV_FDTYPE NULL, XV_FDTYPE NULL, XV_FDTYPE NULL, &time);
+ }
+ #endif /* VMS */
+ }
++
+
+diff -c -r ../xv-3.10/xvpbm.c ./xvpbm.c
+*** ../xv-3.10/xvpbm.c Thu Dec 22 14:12:16 1994
+--- ./xvpbm.c Tue Jan 03 16:23:44 1995
+***************
+*** 353,359 ****
+ *sp++ = '\n';
+ *sp = '\0';
+
+! if (strlen(cmt) > 0) { /* add to pinfo->comment */
+ if (!pinfo->comment) {
+ pinfo->comment = (char *) malloc(strlen(cmt)+1);
+ if (!pinfo->comment) FatalError("malloc failure in xvpbm.c getint");
+--- 353,359 ----
+ *sp++ = '\n';
+ *sp = '\0';
+
+! if (strlen(cmt) > (size_t) 0) { /* add to pinfo->comment */
+ if (!pinfo->comment) {
+ pinfo->comment = (char *) malloc(strlen(cmt)+1);
+ if (!pinfo->comment) FatalError("malloc failure in xvpbm.c getint");
+***************
+*** 438,444 ****
+ *sp++ = '\n';
+ *sp = '\0';
+
+! if (strlen(cmt) > 0) { /* add to pinfo->comment */
+ if (!pinfo->comment) {
+ pinfo->comment = (char *) malloc(strlen(cmt)+1);
+ if (!pinfo->comment) FatalError("malloc failure in xvpbm.c getint");
+--- 438,444 ----
+ *sp++ = '\n';
+ *sp = '\0';
+
+! if (strlen(cmt) > (size_t) 0) { /* add to pinfo->comment */
+ if (!pinfo->comment) {
+ pinfo->comment = (char *) malloc(strlen(cmt)+1);
+ if (!pinfo->comment) FatalError("malloc failure in xvpbm.c getint");
+
+diff -c -r ../xv-3.10/xvpcx.c ./xvpcx.c
+*** ../xv-3.10/xvpcx.c Thu Dec 22 14:12:20 1994
+--- ./xvpcx.c Tue Jan 10 18:06:37 1995
+***************
+*** 36,44 ****
+ #define PCX_MAPSTART 0x0c /* Start of appended colormap */
+
+
+! static int pcxLoadImage PARM((char *, FILE *, byte *, byte *, int, int));
+! static void pcxLoadRaster PARM((FILE *, byte *, int, byte *, int, int));
+! static int pcxError PARM((char *, char *));
+
+
+
+--- 36,45 ----
+ #define PCX_MAPSTART 0x0c /* Start of appended colormap */
+
+
+! static int pcxLoadImage8 PARM((char *, FILE *, PICINFO *, byte *));
+! static int pcxLoadImage24 PARM((char *, FILE *, PICINFO *, byte *));
+! static void pcxLoadRaster PARM((FILE *, byte *, int, byte *, int, int));
+! static int pcxError PARM((char *, char *));
+
+
+
+***************
+*** 52,58 ****
+ long filesize;
+ char *bname, *errstr;
+ byte hdr[128], *image;
+! int i, colors, gray;
+
+ pinfo->type = PIC8;
+ pinfo->pic = (byte *) NULL;
+--- 53,59 ----
+ long filesize;
+ char *bname, *errstr;
+ byte hdr[128], *image;
+! int i, colors, gray, fullcolor;
+
+ pinfo->type = PIC8;
+ pinfo->pic = (byte *) NULL;
+***************
+*** 92,97 ****
+--- 93,99 ----
+ pinfo->w++; pinfo->h++;
+
+ colors = 1 << (hdr[PCX_BPP] * hdr[PCX_PLANES]);
++ fullcolor = (hdr[PCX_BPP] == 8 && hdr[PCX_PLANES] == 3);
+
+ if (DEBUG) {
+ fprintf(stderr,"PCX: %dx%d image, version=%d, encoding=%d\n",
+***************
+*** 102,108 ****
+ colors);
+ }
+
+! if (colors>256) {
+ fclose(fp);
+ return pcxError(bname,"No more than 256 colors allowed in PCX file.");
+ }
+--- 104,110 ----
+ colors);
+ }
+
+! if (colors>256 && !fullcolor) {
+ fclose(fp);
+ return pcxError(bname,"No more than 256 colors allowed in PCX file.");
+ }
+***************
+*** 112,134 ****
+ return pcxError(bname,"Unsupported PCX encoding format.");
+ }
+
+! /* note: overallocation to make life easier... */
+! image = (byte *) malloc((size_t) (pinfo->h + 1) * pinfo->w + 16);
+! if (!image) FatalError("Can't alloc 'image' in LoadPCX()");
+!
+! xvbzero((char *) image, (size_t) ((pinfo->h+1) * pinfo->w + 16));
+!
+! if (!pcxLoadImage(bname, fp, image, hdr, pinfo->w, pinfo->h)) {
+! free(image);
+! fclose(fp);
+! return 0;
+ }
+
+
+ if (ferror(fp) | feof(fp)) /* just a warning */
+ pcxError(bname, "PCX file appears to be truncated.");
+
+! if (colors>16) { /* handle trailing colormap */
+ while (1) {
+ i=getc(fp);
+ if (i==PCX_MAPSTART || i==EOF) break;
+--- 114,138 ----
+ return pcxError(bname,"Unsupported PCX encoding format.");
+ }
+
+! /* load the image, the image function fills in pinfo->pic */
+! if (!fullcolor) {
+! if (!pcxLoadImage8(bname, fp, pinfo, hdr)) {
+! fclose(fp);
+! return 0;
+! }
+ }
++ else {
++ if (!pcxLoadImage24(bname, fp, pinfo, hdr)) {
++ fclose(fp);
++ return 0;
++ }
++ }
+
+
+ if (ferror(fp) | feof(fp)) /* just a warning */
+ pcxError(bname, "PCX file appears to be truncated.");
+
+! if (colors>16 && !fullcolor) { /* handle trailing colormap */
+ while (1) {
+ i=getc(fp);
+ if (i==PCX_MAPSTART || i==EOF) break;
+***************
+*** 171,185 ****
+ /* finally, convert into XV internal format */
+
+
+! pinfo->pic = image;
+! pinfo->type = PIC8;
+ pinfo->frmType = -1; /* no default format to save in */
+
+ /* check for grayscaleitude */
+! for (i=0; i<colors; i++) {
+! if ((pinfo->r[i] != pinfo->g[i]) || (pinfo->r[i] != pinfo->b[i])) break;
+ }
+- gray = (i==colors) ? 1 : 0;
+
+
+ if (colors > 2 || (colors==2 && !gray)) { /* grayscale or PseudoColor */
+--- 175,191 ----
+ /* finally, convert into XV internal format */
+
+
+! pinfo->type = fullcolor ? PIC24 : PIC8;
+ pinfo->frmType = -1; /* no default format to save in */
+
+ /* check for grayscaleitude */
+! gray = 0;
+! if (!fullcolor) {
+! for (i=0; i<colors; i++) {
+! if ((pinfo->r[i] != pinfo->g[i]) || (pinfo->r[i] != pinfo->b[i])) break;
+! }
+! gray = (i==colors) ? 1 : 0;
+ }
+
+
+ if (colors > 2 || (colors==2 && !gray)) { /* grayscale or PseudoColor */
+***************
+*** 205,227 ****
+
+
+ /*****************************/
+! static int pcxLoadImage(fname, fp, image, hdr, w, h)
+! char *fname;
+! FILE *fp;
+! byte *image, *hdr;
+! int w, h;
+ {
+ switch (hdr[PCX_BPP]) {
+! case 1: pcxLoadRaster(fp, image, 1, hdr, w, h); break;
+! case 8: pcxLoadRaster(fp, image, 8, hdr, w, h); break;
+ default:
+ pcxError(fname, "Unsupported # of bits per plane.");
+ return (0);
+ }
+
+ return 1;
+ }
+
+
+
+
+--- 211,317 ----
+
+
+ /*****************************/
+! static int pcxLoadImage8(fname, fp, pinfo, hdr)
+! char *fname;
+! FILE *fp;
+! PICINFO *pinfo;
+! byte *hdr;
+ {
++ /* load an image with at most 8 bits per pixel */
++
++ byte *image;
++
++ /* note: overallocation to make life easier... */
++ image = (byte *) malloc((size_t) (pinfo->h + 1) * pinfo->w + 16);
++ if (!image) FatalError("Can't alloc 'image' in pcxLoadImage8()");
++
++ xvbzero((char *) image, (size_t) ((pinfo->h+1) * pinfo->w + 16));
++
+ switch (hdr[PCX_BPP]) {
+! case 1: pcxLoadRaster(fp, image, 1, hdr, pinfo->w, pinfo->h); break;
+! case 8: pcxLoadRaster(fp, image, 8, hdr, pinfo->w, pinfo->h); break;
+ default:
+ pcxError(fname, "Unsupported # of bits per plane.");
++ free(image);
+ return (0);
+ }
+
++ pinfo->pic = image;
+ return 1;
+ }
+
++
++ /*****************************/
++ static int pcxLoadImage24(fname, fp, pinfo, hdr)
++ char *fname;
++ FILE *fp;
++ PICINFO *pinfo;
++ byte *hdr;
++ {
++ byte *pix, *pic24, scale[256];
++ int c, i, j, w, h, maxv, cnt, planes, bperlin, nbytes;
++
++ w = pinfo->w; h = pinfo->h;
++
++ planes = (int) hdr[PCX_PLANES];
++ bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8);
++
++ /* allocate 24-bit image */
++ pic24 = (byte *) malloc((size_t) w*h*planes);
++ if (!pic24) FatalError("couldn't malloc 'pic24'");
++
++ xvbzero((char *) pic24, (size_t) w*h*planes);
++
++ maxv = 0;
++ pix = pinfo->pic = pic24;
++ i = 0; /* planes, in this while loop */
++ j = 0; /* bytes per line, in this while loop */
++ nbytes = bperlin*h*planes;
++
++ while (nbytes > 0 && (c = getc(fp)) != EOF) {
++ if ((c & 0xC0) == 0xC0) { /* have a rep. count */
++ cnt = c & 0x3F;
++ c = getc(fp);
++ if (c == EOF) { getc(fp); break; }
++ }
++ else cnt = 1;
++
++ if (c > maxv) maxv = c;
++
++ while (cnt-- > 0) {
++ if (j < w) {
++ *pix = c;
++ pix += planes;
++ }
++ j++;
++ nbytes--;
++ if (j == bperlin) {
++ j = 0;
++ if (++i < planes) {
++ pix -= (w*planes)-1; /* next plane on this line */
++ }
++ else {
++ pix -= (planes-1); /* start of next line, first plane */
++ i = 0;
++ }
++ }
++ }
++ }
++
++
++ /* scale all RGB to range 0-255, if they aren't */
++
++ 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*planes; j++, pix++) *pix = scale[*pix];
++ }
++ }
++
++ return 1;
++ }
+
+
+
+diff -c -r ../xv-3.10/xvpds.c ./xvpds.c
+*** ../xv-3.10/xvpds.c Thu Dec 22 14:12:17 1994
+--- ./xvpds.c Tue Jan 03 16:25:52 1995
+***************
+*** 513,519 ****
+ } else if ((sscanf(scanbuff," EXPOSURE_DURATION = %s", exposure) == 1)
+ || (sscanf(scanbuff," INSTRUMENT_EXPOSURE_DURATION = %s",
+ exposure) == 1)) {
+! tmptmp = index(scanbuff,'=');
+ tmptmp++;
+ while((*tmptmp) == ' ')
+ tmptmp++;
+--- 513,519 ----
+ } else if ((sscanf(scanbuff," EXPOSURE_DURATION = %s", exposure) == 1)
+ || (sscanf(scanbuff," INSTRUMENT_EXPOSURE_DURATION = %s",
+ exposure) == 1)) {
+! tmptmp = (char *) index(scanbuff,'=');
+ tmptmp++;
+ while((*tmptmp) == ' ')
+ tmptmp++;
+***************
+*** 521,527 ****
+ lastwasinote=FALSE; continue;
+
+ } else if (sscanf(scanbuff, "NOTE = %s", inote) == 1) {
+! tmptmp = index(scanbuff,'='); tmptmp++;
+ while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++;
+ strcpy(inote,tmptmp);
+ strcat(inote," ");
+--- 521,527 ----
+ lastwasinote=FALSE; continue;
+
+ } else if (sscanf(scanbuff, "NOTE = %s", inote) == 1) {
+! tmptmp = (char *) index(scanbuff,'='); tmptmp++;
+ while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++;
+ strcpy(inote,tmptmp);
+ strcat(inote," ");
+***************
+*** 884,892 ****
+
+ /* check whether histogram file exists */
+ #ifdef VMS
+! c = rindex(strcpy(name, (c = rindex(fname, ':')) ? c+1 : fname), ']');
+ #else
+! c = rindex(strcpy(name, fname), '/');
+ #endif /* VMS */
+ (void)strcpy(c ? c+1 : name, "hist.tab");
+
+--- 884,894 ----
+
+ /* check whether histogram file exists */
+ #ifdef VMS
+! c = (char *) rindex(strcpy(name,
+! (c = (char *) rindex(fname, ':')) ? c+1 : fname),
+! ']');
+ #else
+! c = (char *) rindex(strcpy(name, fname), '/');
+ #endif /* VMS */
+ (void)strcpy(c ? c+1 : name, "hist.tab");
+
+***************
+*** 979,987 ****
+ int i, n, r, g, b;
+
+ #ifdef VMS
+! c = rindex(strcpy(name, (c = rindex(fname, ':')) ? c+1 : fname), ']');
+ #else
+! c = rindex(strcpy(name, fname), '/');
+ #endif /* VMS */
+ (void)strcpy(c ? c+1 : name, "palette.tab");
+
+--- 981,991 ----
+ int i, n, r, g, b;
+
+ #ifdef VMS
+! c = (char *) rindex(strcpy(name,
+! (c = (char *) rindex(fname, ':')) ? c+1 : fname),
+! ']');
+ #else
+! c = (char *) rindex(strcpy(name, fname), '/');
+ #endif /* VMS */
+ (void)strcpy(c ? c+1 : name, "palette.tab");
+
+diff -c -r ../xv-3.10/xvpictoppm.c ./xvpictoppm.c
+*** ../xv-3.10/xvpictoppm.c Thu Dec 22 14:12:24 1994
+--- ./xvpictoppm.c Fri Jan 13 14:57:14 1995
+***************
+*** 124,132 ****
+
+ /* convert icon from 332 to 24-bit image */
+ for (i=0, ip=icon8, pp=pic24; i<w*h; i++, ip++, pp+=3) {
+! pp[0] = (((*ip >> 5) & 0x07) * 255) / 7;
+! pp[1] = (((*ip >> 2) & 0x07) * 255) / 7;
+! pp[2] = (((*ip >> 0) & 0x03) * 255) / 3;
+ }
+
+ free(icon8);
+--- 124,132 ----
+
+ /* convert icon from 332 to 24-bit image */
+ for (i=0, ip=icon8, pp=pic24; i<w*h; i++, ip++, pp+=3) {
+! pp[0] = ( ((int) ((*ip >> 5) & 0x07)) * 255) / 7;
+! pp[1] = ( ((int) ((*ip >> 2) & 0x07)) * 255) / 7;
+! pp[2] = ( ((int) ((*ip >> 0) & 0x03)) * 255) / 3;
+ }
+
+ free(icon8);
+
+diff -c -r ../xv-3.10/xvpopup.c ./xvpopup.c
+*** ../xv-3.10/xvpopup.c Thu Dec 22 14:12:16 1994
+--- ./xvpopup.c Thu Jan 19 13:09:31 1995
+***************
+*** 150,161 ****
+ if (wy + h > dispHIGH) wy = dispHIGH - h;
+ }
+
+! /* wx -= (p_offx + ch_offx);
+! wy -= (p_offy + ch_offy); */
+
+- wx -= (ch_offx);
+- wy -= (ch_offy);
+-
+ if (!XGetNormalHints(theDisp, win, &hints)) hints.flags = 0;
+ hints.width = hints.min_width = hints.max_width = w;
+ hints.height = hints.min_height = hints.max_height = h;
+--- 150,165 ----
+ if (wy + h > dispHIGH) wy = dispHIGH - h;
+ }
+
+!
+! if (winCtrPosKludge) {
+! wx -= (p_offx + ch_offx);
+! wy -= (p_offy + ch_offy);
+! }
+! else {
+! wx -= (ch_offx);
+! wy -= (ch_offy);
+! }
+
+ if (!XGetNormalHints(theDisp, win, &hints)) hints.flags = 0;
+ hints.width = hints.min_width = hints.max_width = w;
+ hints.height = hints.min_height = hints.max_height = h;
+***************
+*** 249,255 ****
+
+ if (poptyp == ISGRAB) {
+ BTSetActive(&bts[0], (int) strlen(gsBuf));
+! BTSetActive(&bts[1], (strlen(gsBuf)>0 && atoi(gsBuf)>0));
+ }
+ else if (poptyp == ISPAD) {
+ BTSetActive(&bts[0], (int) strlen(gsBuf));
+--- 253,259 ----
+
+ if (poptyp == ISGRAB) {
+ BTSetActive(&bts[0], (int) strlen(gsBuf));
+! BTSetActive(&bts[1], (strlen(gsBuf)>(size_t)0 && atoi(gsBuf)>(size_t)0));
+ }
+ else if (poptyp == ISPAD) {
+ BTSetActive(&bts[0], (int) strlen(gsBuf));
+***************
+*** 350,356 ****
+ gsx = 10 + icon_width + 20;
+ gsy = 10+(PUHIGH-30-BUTTH-gsh)/2;
+
+! if (strlen(txt) > 60)
+ gsy = PUHIGH - 10 - BUTTH - 10 - gsh - 20;
+
+ gsw = PUWIDE - gsx - 10;
+--- 354,360 ----
+ gsx = 10 + icon_width + 20;
+ gsy = 10+(PUHIGH-30-BUTTH-gsh)/2;
+
+! if (strlen(txt) > (size_t) 60)
+ gsy = PUHIGH - 10 - BUTTH - 10 - gsh - 20;
+
+ gsw = PUWIDE - gsx - 10;
+***************
+*** 558,564 ****
+ strncpy(nams[*lenp], vals[*lenp], (size_t) 31);
+ }
+
+! if (strlen(nams[*lenp]) > 20) { /* fix long names */
+ char *sp = nams[*lenp] + 18;
+ *sp++ = '.'; *sp++ = '.'; *sp++ = '.'; *sp++ = '\0';
+ }
+--- 562,568 ----
+ strncpy(nams[*lenp], vals[*lenp], (size_t) 31);
+ }
+
+! if (strlen(nams[*lenp]) > (size_t) 20) { /* fix long names */
+ char *sp = nams[*lenp] + 18;
+ *sp++ = '.'; *sp++ = '.'; *sp++ = '.'; *sp++ = '\0';
+ }
+***************
+*** 1154,1166 ****
+ /* if we have a string of any sort, turn on the default '\n' button
+ (if there is one) */
+ for (i=0; i<nbts && accel[i]!='\n'; i++);
+! if (i<nbts) BTSetActive(&bts[i], strlen(gsBuf)>0);
+ }
+ else if (popUp == ISGRAB) {
+ /* need a string of length 1 to enable Grab (bts[0]), and a string
+ with an atoi() of at least '1' to enable AutoGrab (bts[1]) */
+! BTSetActive(&bts[0], strlen(gsBuf)>0);
+! BTSetActive(&bts[1], (strlen(gsBuf)>0 && atoi(gsBuf)>0));
+ }
+
+ return(0);
+--- 1158,1170 ----
+ /* if we have a string of any sort, turn on the default '\n' button
+ (if there is one) */
+ for (i=0; i<nbts && accel[i]!='\n'; i++);
+! if (i<nbts) BTSetActive(&bts[i], (strlen(gsBuf) > (size_t) 0));
+ }
+ else if (popUp == ISGRAB) {
+ /* need a string of length 1 to enable Grab (bts[0]), and a string
+ with an atoi() of at least '1' to enable AutoGrab (bts[1]) */
+! BTSetActive(&bts[0], (strlen(gsBuf) > (size_t) 0));
+! BTSetActive(&bts[1], (strlen(gsBuf)>(size_t)0 && atoi(gsBuf)>(size_t)0));
+ }
+
+ return(0);
+***************
+*** 1219,1225 ****
+ XDrawLine(theDisp, popW, theGC, gsx+3, gsy+1, gsx+3, gsy + gsh-1);
+ }
+
+! if (gsEnPos<strlen(gsBuf)) { /* draw a "there's more over here" doowah */
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-3, gsy+1, gsx+gsw-3, gsy+gsh-1);
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-2, gsy+1, gsx+gsw-2, gsy+gsh-1);
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-1, gsy+1, gsx+gsw-1, gsy+gsh-1);
+--- 1223,1230 ----
+ XDrawLine(theDisp, popW, theGC, gsx+3, gsy+1, gsx+3, gsy + gsh-1);
+ }
+
+! if ((size_t) gsEnPos < strlen(gsBuf)) {
+! /* draw a "there's more over here" doowah */
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-3, gsy+1, gsx+gsw-3, gsy+gsh-1);
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-2, gsy+1, gsx+gsw-2, gsy+gsh-1);
+ XDrawLine(theDisp, popW, theGC, gsx+gsw-1, gsy+1, gsx+gsw-1, gsy+gsh-1);
+
+diff -c -r ../xv-3.10/xvrle.c ./xvrle.c
+*** ../xv-3.10/xvrle.c Thu Dec 22 14:12:22 1994
+--- ./xvrle.c Thu Jan 19 12:27:47 1995
+***************
+*** 257,263 ****
+
+ if (ncolors == 1) { /* grayscale or PseudoColor */
+ pinfo->type = PIC8;
+! if (ncmap == 1) {
+ pinfo->colType = F_GREYSCALE;
+ sprintf(pinfo->fullInfo, "Greyscale RLE. (%ld bytes)", filesize);
+ for (i=0; i<256; i++)
+--- 257,263 ----
+
+ if (ncolors == 1) { /* grayscale or PseudoColor */
+ pinfo->type = PIC8;
+! if (ncmap == 0 || ncmap == 1) { /* grey, or grey with gamma curve */
+ pinfo->colType = F_GREYSCALE;
+ sprintf(pinfo->fullInfo, "Greyscale RLE. (%ld bytes)", filesize);
+ for (i=0; i<256; i++)
+
+diff -c -r ../xv-3.10/xvtext.c ./xvtext.c
+*** ../xv-3.10/xvtext.c Thu Dec 22 14:12:20 1994
+--- ./xvtext.c Fri Jan 13 18:46:28 1995
+***************
+*** 1220,1226 ****
+ LC("the xv distribution. Do *not* send mail unless absolutely necessary");
+ LC("(ie, you don't have ftp capability).");
+ LC("");
+! LC("Note: The documentation ('xvdocs.ps') may be installed in '/usr/local'.");
+ LC("");
+ LC("If you're viewing this information via the 'About XV' command, and");
+ LC("you'd like to print it out, a copy of this info can be found in the ");
+--- 1220,1226 ----
+ LC("the xv distribution. Do *not* send mail unless absolutely necessary");
+ LC("(ie, you don't have ftp capability).");
+ LC("");
+! LC("Note: The docs (xvdocs.ps) may be installed in '/usr/local/lib'.");
+ LC("");
+ LC("If you're viewing this information via the 'About XV' command, and");
+ LC("you'd like to print it out, a copy of this info can be found in the ");
+
+diff -c -r ../xv-3.10/xvtiff.c ./xvtiff.c
+*** ../xv-3.10/xvtiff.c Thu Dec 22 14:12:20 1994
+--- ./xvtiff.c Fri Jan 13 14:53:34 1995
+***************
+*** 120,126 ****
+ desc = (char *) NULL;
+
+ TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &desc);
+! if (desc && strlen(desc)>0) {
+ /* kludge: tiff library seems to return bizarre comments */
+ if (strlen(desc)==4 && strcmp(desc, "\367\377\353\370")==0) {}
+ else {
+--- 120,126 ----
+ desc = (char *) NULL;
+
+ TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &desc);
+! if (desc && strlen(desc) > (size_t) 0) {
+ /* kludge: tiff library seems to return bizarre comments */
+ if (strlen(desc)==4 && strcmp(desc, "\367\377\353\370")==0) {}
+ else {
+***************
+*** 1381,1388 ****
+ }
+ }
+
+! /* #define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB)) */
+! #define Code2V(c, RB, RW, CR) ((((c)-RB)*(float)CR)/(float)(RW-RB))
+
+ #define CLAMP(f,min,max) \
+ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
+--- 1381,1387 ----
+ }
+ }
+
+! #define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
+
+ #define CLAMP(f,min,max) \
+ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
+
+diff -c -r ../xv-3.10/xvtiffwr.c ./xvtiffwr.c
+*** ../xv-3.10/xvtiffwr.c Thu Dec 22 14:12:20 1994
+--- ./xvtiffwr.c Tue Jan 03 16:28:13 1995
+***************
+*** 70,76 ****
+ TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h);
+ TIFFSetField(tif, TIFFTAG_COMPRESSION, comp);
+
+! if (comment && strlen(comment)>0) {
+ TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, comment);
+ }
+
+--- 70,76 ----
+ TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h);
+ TIFFSetField(tif, TIFFTAG_COMPRESSION, comp);
+
+! if (comment && strlen(comment) > (size_t) 0) {
+ TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, comment);
+ }
+
+diff -c -r ../xv-3.10/bits/font5x9.h ./bits/font5x9.h
+*** ../xv-3.10/bits/font5x9.h Thu Dec 22 14:12:58 1994
+--- ./bits/font5x9.h Tue Jan 03 15:18:06 1995
+***************
+*** 21,27 ****
+ {0x0e, 0x11, 0x19, 0x15, 0x13, 0x11, 0x0e, 0x00, 0x00}, /* 0 */
+ {0x04, 0x06, 0x05, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x00}, /* 1 */
+ {0x0e, 0x11, 0x10, 0x0c, 0x02, 0x01, 0x1f, 0x00, 0x00}, /* 2 */
+! {0x0e, 0x11, 0x10, 0x0c, 0x02, 0x01, 0x1f, 0x00, 0x00}, /* 3 */
+ {0x09, 0x09, 0x09, 0x1f, 0x08, 0x08, 0x08, 0x00, 0x00}, /* 4 */
+ {0x1f, 0x01, 0x01, 0x0f, 0x10, 0x10, 0x0f, 0x00, 0x00}, /* 5 */
+ {0x0e, 0x01, 0x01, 0x0f, 0x11, 0x11, 0x0e, 0x00, 0x00}, /* 6 */
+--- 21,27 ----
+ {0x0e, 0x11, 0x19, 0x15, 0x13, 0x11, 0x0e, 0x00, 0x00}, /* 0 */
+ {0x04, 0x06, 0x05, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x00}, /* 1 */
+ {0x0e, 0x11, 0x10, 0x0c, 0x02, 0x01, 0x1f, 0x00, 0x00}, /* 2 */
+! {0x0f, 0x10, 0x10, 0x0e, 0x10, 0x10, 0x0f, 0x00, 0x00}, /* 3 */
+ {0x09, 0x09, 0x09, 0x1f, 0x08, 0x08, 0x08, 0x00, 0x00}, /* 4 */
+ {0x1f, 0x01, 0x01, 0x0f, 0x10, 0x10, 0x0f, 0x00, 0x00}, /* 5 */
+ {0x0e, 0x01, 0x01, 0x0f, 0x11, 0x11, 0x0e, 0x00, 0x00}, /* 6 */
+***************
+*** 51,57 ****
+ {0x11, 0x13, 0x13, 0x15, 0x19, 0x19, 0x11, 0x00, 0x00}, /* N */
+ {0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00}, /* O */
+ {0x0f, 0x11, 0x11, 0x0f, 0x01, 0x01, 0x01, 0x00, 0x00}, /* P */
+! {0x0f, 0x11, 0x11, 0x0f, 0x01, 0x01, 0x01, 0x00, 0x00}, /* Q */
+ {0x0f, 0x11, 0x11, 0x0f, 0x05, 0x09, 0x11, 0x00, 0x00}, /* R */
+ {0x0e, 0x11, 0x01, 0x0e, 0x10, 0x11, 0x0e, 0x00, 0x00}, /* S */
+ {0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00}, /* T */
+--- 51,57 ----
+ {0x11, 0x13, 0x13, 0x15, 0x19, 0x19, 0x11, 0x00, 0x00}, /* N */
+ {0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00}, /* O */
+ {0x0f, 0x11, 0x11, 0x0f, 0x01, 0x01, 0x01, 0x00, 0x00}, /* P */
+! {0x0e, 0x11, 0x11, 0x11, 0x11, 0x15, 0x0e, 0x18, 0x00}, /* Q */
+ {0x0f, 0x11, 0x11, 0x0f, 0x05, 0x09, 0x11, 0x00, 0x00}, /* R */
+ {0x0e, 0x11, 0x01, 0x0e, 0x10, 0x11, 0x0e, 0x00, 0x00}, /* S */
+ {0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00}, /* T */
+
+diff -c -r ../xv-3.10/bits/xv_rev ./bits/xv_rev
+*** ../xv-3.10/bits/xv_rev Thu Dec 22 14:12:54 1994
+--- ./bits/xv_rev Fri Jan 13 17:37:10 1995
+***************
+*** 11,29 ****
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+! 0x00, 0x00, 0xa0, 0x03, 0x00, 0x04, 0x10, 0x00, 0x00, 0x20, 0x3c, 0x10,
+! 0xe1, 0x41, 0x3c, 0x10, 0x01, 0x00, 0x20, 0x60, 0x04, 0x00, 0x04, 0x10,
+! 0x00, 0x00, 0x30, 0x42, 0x90, 0x11, 0x42, 0x42, 0x18, 0x01, 0x00, 0xa0,
+! 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x41, 0x48, 0x09, 0x20,
+ 0x41, 0x14, 0x01, 0xc7, 0x7b, 0xe0, 0x80, 0x09, 0xc5, 0x13, 0x27, 0x13,
+! 0x20, 0x20, 0x08, 0x89, 0x23, 0x71, 0x14, 0x81, 0x28, 0x23, 0x60, 0x60,
+! 0x8a, 0x24, 0x93, 0xe8, 0x12, 0x20, 0x10, 0x04, 0x65, 0x14, 0x4e, 0x12,
+! 0x01, 0xae, 0x24, 0xa0, 0xe0, 0x51, 0xa4, 0x54, 0x28, 0x02, 0x20, 0x0c,
+! 0x04, 0x15, 0x14, 0x40, 0x79, 0x81, 0x49, 0x24, 0x21, 0x11, 0x50, 0x44,
+! 0x54, 0x28, 0x02, 0x20, 0x02, 0x04, 0x09, 0x92, 0xa0, 0x16, 0x5d, 0x0c,
+! 0xa2, 0x20, 0x16, 0x23, 0x04, 0x52, 0x24, 0x12, 0x20, 0x41, 0x02, 0x09,
+! 0x89, 0x11, 0x10, 0x83, 0xeb, 0x61, 0x20, 0xe8, 0x20, 0xe4, 0x91, 0x23,
+! 0x12, 0x20, 0x7f, 0x02, 0xf1, 0x08, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+--- 11,29 ----
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+! 0x00, 0x00, 0xa0, 0x03, 0x00, 0x04, 0x10, 0x00, 0x00, 0x84, 0x07, 0xf1,
+! 0xe0, 0x41, 0x3c, 0x10, 0x01, 0x00, 0x20, 0x60, 0x04, 0x00, 0x04, 0x10,
+! 0x00, 0x00, 0x46, 0x08, 0x09, 0x11, 0x42, 0x42, 0x18, 0x01, 0x00, 0xa0,
+! 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x88, 0x04, 0x09, 0x22,
+ 0x41, 0x14, 0x01, 0xc7, 0x7b, 0xe0, 0x80, 0x09, 0xc5, 0x13, 0x27, 0x13,
+! 0x04, 0x84, 0x80, 0x88, 0x23, 0x71, 0x14, 0x81, 0x28, 0x23, 0x60, 0x60,
+! 0x8a, 0x24, 0x93, 0xe8, 0x12, 0x04, 0x42, 0x40, 0x70, 0x12, 0x4e, 0x12,
+! 0x01, 0xae, 0x24, 0xa0, 0xe0, 0x51, 0xa4, 0x54, 0x28, 0x02, 0x84, 0x41,
+! 0x30, 0x00, 0x12, 0x40, 0x79, 0x81, 0x49, 0x24, 0x21, 0x11, 0x50, 0x44,
+! 0x54, 0x28, 0x02, 0x44, 0x40, 0x08, 0x04, 0x91, 0xa0, 0x16, 0x5d, 0x0c,
+! 0xa2, 0x20, 0x16, 0x23, 0x04, 0x52, 0x24, 0x12, 0x24, 0x28, 0x04, 0x8d,
+! 0x88, 0x11, 0x10, 0x83, 0xeb, 0x61, 0x20, 0xe8, 0x20, 0xe4, 0x91, 0x23,
+! 0x12, 0xe4, 0x2f, 0xfc, 0x71, 0x08, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+diff -c -r ../xv-3.10/bits/xv_ver ./bits/xv_ver
+*** ../xv-3.10/bits/xv_ver Thu Dec 22 14:12:58 1994
+--- ./bits/xv_ver Fri Jan 13 17:34:48 1995
+***************
+*** 6,20 ****
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+! 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00,
+! 0x00, 0x08, 0x00, 0x80, 0x1f, 0x04, 0x07, 0x00, 0x82, 0x00, 0x00, 0x08,
+! 0x00, 0x80, 0x08, 0x86, 0x08, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
+! 0x04, 0x45, 0x10, 0x00, 0x24, 0x98, 0xe4, 0x89, 0x23, 0x03, 0x1c, 0x24,
+! 0x10, 0x00, 0x24, 0xa6, 0x97, 0x49, 0xe4, 0x02, 0x23, 0x24, 0x10, 0x00,
+! 0x14, 0x9e, 0x50, 0x2a, 0x24, 0x02, 0x20, 0x24, 0x10, 0x00, 0x18, 0x81,
+! 0x20, 0x2a, 0x24, 0x42, 0x20, 0x24, 0x08, 0x00, 0x08, 0xb1, 0x00, 0x29,
+! 0x22, 0x42, 0x98, 0x24, 0x06, 0x00, 0x08, 0x8e, 0xf0, 0xc8, 0x21, 0x82,
+! 0x87, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+--- 6,20 ----
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+! 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00,
+! 0x00, 0x02, 0x00, 0xe0, 0x07, 0xc1, 0x01, 0x00, 0x41, 0x00, 0x00, 0x02,
+! 0x00, 0x20, 0x82, 0x21, 0x02, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
+! 0x41, 0x11, 0x04, 0x00, 0x12, 0x26, 0x79, 0xe2, 0xc8, 0x00, 0x07, 0x09,
+! 0xc4, 0x01, 0x92, 0xe9, 0x65, 0x12, 0xb9, 0xc0, 0x08, 0x09, 0x24, 0x02,
+! 0x8a, 0x27, 0x94, 0x0a, 0x89, 0x00, 0x08, 0x09, 0x84, 0x03, 0x4c, 0x20,
+! 0x88, 0x0a, 0x89, 0x10, 0x08, 0x09, 0x62, 0x02, 0x44, 0x2c, 0x40, 0x8a,
+! 0x88, 0x10, 0x26, 0x89, 0x11, 0x03, 0x84, 0x23, 0x3c, 0x72, 0x88, 0xe0,
+! 0x21, 0x71, 0xe0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+diff -c -r ../xv-3.10/tiff/tif_fax3.c ./tiff/tif_fax3.c
+*** ../xv-3.10/tiff/tif_fax3.c Thu Dec 22 14:12:41 1994
+--- ./tiff/tif_fax3.c Fri Dec 23 17:39:28 1994
+***************
+*** 370,376 ****
+ * Decode a code and return the associated run length.
+ */
+ static int32
+! decode_run(TIFF* tif, const u_short fsm[][256])
+ {
+ Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data;
+ int state = sp->b.bit;
+--- 370,376 ----
+ * Decode a code and return the associated run length.
+ */
+ static int32
+! decode_run(TIFF* tif, /*const*/ u_short fsm[][256])
+ {
+ Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data;
+ int state = sp->b.bit;
+
+diff -c -r ../xv-3.10/tiff/tiffcomp.h ./tiff/tiffcomp.h
+*** ../xv-3.10/tiff/tiffcomp.h Thu Dec 22 14:12:42 1994
+--- ./tiff/tiffcomp.h Thu Jan 19 12:47:56 1995
+***************
+*** 67,72 ****
+--- 67,76 ----
+ #endif
+ #endif
+
++ #ifdef isc
++ #define BSDTYPES
++ #endif
++
+ /*
+ * Workarounds for BSD lseek definitions.
+ */
+
+diff -c -r ../xv-3.10/vms/Makefile.mms ./vms/Makefile.mms
+*** ../xv-3.10/vms/Makefile.mms Thu Dec 22 14:12:37 1994
+--- ./vms/Makefile.mms Sun Dec 25 03:21:22 1994
+***************
+*** 11,30 ****
+ # 15-APR-1993 for v3.00 (DEC C changes)
+ # 25-MAY-1993 merged ALPHA.MMS and MAKEFILE.MMS
+ # 27-APR-1994 for v3.01
+! # 6-DEC-1994 for v3.10
+ #
+ # Modeled after the original Unix Makefile for xv
+ # Most of the Unix comments have been left intact to help debug any
+ # problems.
+
+- #********
+- #
+- # REQUIRED USER EDIT POINT!!!!!!!!!!!
+- # You must put in the correct place where the root of this XV
+- # directory is located
+- #
+- #********
+- XVDIR = [XV-3_10]
+
+ # BE SURE TO SET THIS TO YOUR SITE'S DESTINATION DIRECTORY...!!!
+ BINDIR = Sys$Disk:[]
+--- 11,22 ----
+ # 15-APR-1993 for v3.00 (DEC C changes)
+ # 25-MAY-1993 merged ALPHA.MMS and MAKEFILE.MMS
+ # 27-APR-1994 for v3.01
+! # 23-DEC-1994 for v3.10
+ #
+ # Modeled after the original Unix Makefile for xv
+ # Most of the Unix comments have been left intact to help debug any
+ # problems.
+
+
+ # BE SURE TO SET THIS TO YOUR SITE'S DESTINATION DIRECTORY...!!!
+ BINDIR = Sys$Disk:[]
+***************
+*** 57,64 ****
+ # VMS MMS USERS!!!
+ #
+ # if you don't use the JPEG package as supplied with XV, you
+! # will need fill in the complete directory specifications for
+! # BOTH JPEGDIR and XVDIR!!
+ #
+ JPEG = ,HAVE_JPEG
+ JPEGDIR = [.JPEG]
+--- 49,55 ----
+ # VMS MMS USERS!!!
+ #
+ # if you don't use the JPEG package as supplied with XV, you
+! # will need fill in the complete directory specifications for JPEGDIR.
+ #
+ JPEG = ,HAVE_JPEG
+ JPEGDIR = [.JPEG]
+***************
+*** 72,79 ****
+ # Also, comment out the LIBTIFF dependancy at the end of this Makefile
+ #
+ # if you don't use the TIFF package as supplied with XV, you
+! # will need to fill in the complete directory specifications for
+! # BOTH TIFFDIR and XVDIR!!
+ #
+ TIFF = ,HAVE_TIFF
+ TIFFDIR = [.TIFF]
+--- 63,69 ----
+ # Also, comment out the LIBTIFF dependancy at the end of this Makefile
+ #
+ # if you don't use the TIFF package as supplied with XV, you
+! # will need to fill in the complete directory specifications for TIFFDIR.
+ #
+ TIFF = ,HAVE_TIFF
+ TIFFDIR = [.TIFF]
+***************
+*** 135,145 ****
+ @- Define /NoLog Sys DECC$Library_Include
+ .else
+ .ifdef DECC
+! × @- Define /NoLog Sys DECC$Library_Include
+ .else
+ @- Define /NoLog Sys Sys$Library
+ .endif
+ @- Define /NoLog X11 DECW$Include
+ .endif
+
+ all : $(BITS) $(OPTS) lib xv bggen decompress xcmap xvpictoppm help
+--- 125,136 ----
+ @- Define /NoLog Sys DECC$Library_Include
+ .else
+ .ifdef DECC
+! @- Define /NoLog Sys DECC$Library_Include
+ .else
+ @- Define /NoLog Sys Sys$Library
+ .endif
+ @- Define /NoLog X11 DECW$Include
++ @- XVDIR = F$Environment ("Default")
+ .endif
+
+ all : $(BITS) $(OPTS) lib xv bggen decompress xcmap xvpictoppm help
+***************
+*** 181,204 ****
+ $(JPEGLIB) :
+ Set Default $(JPEGDIR)
+ .ifdef ALPHA
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.$(MMS) /Macro = "ALPHA = 1" LIBJPEG.OLB
+ .else
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.$(MMS) LIBJPEG.OLB
+ .endif
+! Set Default $(XVDIR)
+
+ $(TIFFLIB) :
+ Set Default $(TIFFDIR)
+ .ifdef ALPHA
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.$(MMS) /Macro = "ALPHA = 1" LIBTIFF.OLB
+ .else
+ .ifdef DECC
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.$(MMS) /Macro = "ALPHA = 1" LIBTIFF.OLB
+ .else
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.$(MMS) LIBTIFF.OLB
+ .endif
+ .endif
+! Set Default $(XVDIR)
+
+ $(XVLIB) : $(OBJS)
+ If "''F$Search ("$(XVLIB)")'" .eqs. "" Then Library /Create $(XVLIB)
+--- 172,195 ----
+ $(JPEGLIB) :
+ Set Default $(JPEGDIR)
+ .ifdef ALPHA
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.MMS /Macro = "ALPHA = 1" LIBJPEG.OLB
+ .else
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.MMS LIBJPEG.OLB
+ .endif
+! Set Default 'XVDIR'
+
+ $(TIFFLIB) :
+ Set Default $(TIFFDIR)
+ .ifdef ALPHA
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.MMS /Macro = "ALPHA = 1" LIBTIFF.OLB
+ .else
+ .ifdef DECC
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.MMS /Macro = "ALPHA = 1" LIBTIFF.OLB
+ .else
+! $(MMS) $(MMSDEFAULTS) /Description = MAKEFILE.MMS LIBTIFF.OLB
+ .endif
+ .endif
+! Set Default 'XVDIR'
+
+ $(XVLIB) : $(OBJS)
+ If "''F$Search ("$(XVLIB)")'" .eqs. "" Then Library /Create $(XVLIB)
+***************
+*** 273,280 ****
+ - Delete /NoConfirm /NoLog *.obj;*,*.exe;*,*.log;*,*.olb;*,*.hlb;*
+ - Purge /NoConfirm /NoLog
+ Set Default [.JPEG]
+! $(MMS) /Description = MAKEFILE.$(MMS) clean
+ - Delete /NoConfirm /NoLog *.olb;*
+ Set Default [-.TIFF]
+! $(MMS) /Description = MAKEFILE.$(MMS) clean
+ Set Default [-]
+--- 264,271 ----
+ - Delete /NoConfirm /NoLog *.obj;*,*.exe;*,*.log;*,*.olb;*,*.hlb;*
+ - Purge /NoConfirm /NoLog
+ Set Default [.JPEG]
+! $(MMS) /Description = MAKEFILE.MMS clean
+ - Delete /NoConfirm /NoLog *.olb;*
+ Set Default [-.TIFF]
+! $(MMS) /Description = MAKEFILE.MMS clean
+ Set Default [-]
+
+diff -c -r ../xv-3.10/vms/README.vms ./vms/README.vms
+*** ../xv-3.10/vms/README.vms Thu Dec 22 14:12:37 1994
+--- ./vms/README.vms Sun Dec 25 03:21:22 1994
+***************
+*** 1,9 ****
+! 6-Dec-1994
+
+! First, read the release notes for the Unix version of XV as well
+! as these. You can ignore the Unix specific comments, but there are
+! references to the config.h file for local configurations and general
+! use of the program that are relevant to VMS users as well.
+
+ Release notes for building XV (v3.10) on a VMS platform. This
+ includes the newer ALPHA/VMS machines. As in the previous release,
+--- 1,10 ----
+! 23-DEC-1994
+
+! First, read the various INSTALL and README files for the Unix
+! version of XV as well as these. You can ignore the Unix specific
+! comments, but there are references to the config.h file for local
+! configurations and general use of the program that are relevant to
+! VMS users as well.
+
+ Release notes for building XV (v3.10) on a VMS platform. This
+ includes the newer ALPHA/VMS machines. As in the previous release,
+***************
+*** 24,42 ****
+
+ SETUP.COM
+ A simple command procedure to setup the final compiled XV
+! package of programs. It can be executed by itself or used with
+! many of the commonly available SETUP packages (i.e., the
+! FERMILAB version). If it is kept in the same directory as the
+! binaries, it will be able to get the necessary symbols setup
+! anywhere the directory structure is located WITHOUT the need to
+! edit the command procedure. Move them all around together and
+! you will be OK.
+
+ MAKEFILE.MMS (in the top level directory)
+! This is a MMS description file for the VMS MMS utility. YOU
+! SHOULD EDIT THE FILE FIRST TO MAKE SURE THE CUSTOMIZING FEATURES
+! ARE APPROPRIATE FOR YOUR SYSTEM. For users without MMS you will
+! need to use MAKE_XV.COM instead.
+
+ Installation Instructions:
+
+--- 25,48 ----
+
+ SETUP.COM
+ A simple command procedure to setup the final compiled XV
+! package of programs. It helps the aux programs of XV be found
+! by DCL foreign symbols. If you don't want to use the names I
+! have chosen for them, you should be able to alter the CONFIG.H
+! file to point to the names you want to use instead. This has
+! not been tested by me, so let me know if you try this. It
+! should work! :) It can be executed by itself or used with many
+! of the commonly available SETUP packages (i.e., the FERMILAB
+! version). If it is kept in the same directory as the binaries,
+! it will be able to get the necessary symbols setup anywhere the
+! directory structure is located WITHOUT the need to edit the
+! command procedure. Move them all around together and you will
+! be OK.
+
+ MAKEFILE.MMS (in the top level directory)
+! This is a description file for the VMS MMS (or the PD MMK)
+! utility. YOU SHOULD BROWSE THE FILE FIRST TO MAKE SURE THE
+! CUSTOMIZING FEATURES ARE APPROPRIATE FOR YOUR SYSTEM. For users
+! without MMS (MMK) you will need to use MAKE_XV.COM instead.
+
+ Installation Instructions:
+
+***************
+*** 100,114 ****
+ to resolve first!!! Note specifically the references to JPEG
+ and TIFF. This is also true for the MAKEFILE.MMS in the JPEG
+ sub-directory and the MAKEFILE.MMS file in the TIFF
+! sub-directory. Also check the top-level directory name at the
+! top of the MMS file. You have to put in your local choice of
+! name. (I was lazy in not trying to autodetect it, sorry.)
+!
+
+! EXCEPT for the destination of the binaries, root of the
+! directory tree, and X11 Window interface, I *think* it should
+! work for everyone without any modifications. (famous last
+! words...)
+
+ When you are satisfied that everything is correct for your
+ site, just type
+--- 106,116 ----
+ to resolve first!!! Note specifically the references to JPEG
+ and TIFF. This is also true for the MAKEFILE.MMS in the JPEG
+ sub-directory and the MAKEFILE.MMS file in the TIFF
+! sub-directory.
+
+! EXCEPT for the destination of the binaries, and X11 Window
+! interface, I *think* it should work for everyone without any
+! modifications. (famous last words...)
+
+ When you are satisfied that everything is correct for your
+ site, just type
+
+diff -c -r ../xv-3.10/vms/tiff.patches ./vms/tiff.patches
+*** ../xv-3.10/vms/tiff.patches Thu Dec 22 14:12:38 1994
+--- ./vms/tiff.patches Thu Jan 19 12:47:14 1995
+***************
+*** 5,10 ****
+--- 5,11 ----
+ In tiff/Makefile.hpux, you need to add -D_HPUX_SOURCE to CFLAGS.
+ Otherwise libtiff won't build under gcc or strict-ANSI cc.
+
++ In tiff/tiffcomp.h, add '#ifdef isc ... #define BSDTYPES ... #endif'
+
+ Index: tiff/Makefile.mms
+ *** /dev/null Wed Dec 14 08:22:27 1994
+
+
+*** /dev/null Mon Jan 23 20:08:17 1995
+--- BUGS Thu Jan 19 13:10:07 1995
+***************
+*** 0 ****
+--- 1,21 ----
++ DOCS:
++ File docs/xvdoc.ps has an error in the banner for page 2. The page title is
++ "Section 2: The Image Window" when it should be "Section 1: Overview".
++
++ Add mention of '-pkludge' and 'popupKludge'
++
++ Hall of Fame: Lester Ingber should be 'ingber@alumni.caltech.edu'
++
++
++ From: James Ralston Crawford (qralston+@pitt.edu)
++ When deleting files in 'xv controls' window, it should also delete
++ thumbnail file, if any
++
++
++ From: Mitchell Blank Jr <blankm@cae.wisc.edu>
++ (try an use schnauzer in /usr/feh/foo, where feh is rwx--x--x. Need to
++ set a var each time chdir is successfully called (make xv_chdir).
++ Then in xv_getwd, if getcwd() fails, try stat()'ing the var.
++ If it exists, assume we're there, and return the var. Otherwise, fall back
++ to other directories...
++
+
+*** /dev/null Mon Jan 23 20:08:17 1995
+--- docs/vdcomp.man Fri Jan 13 15:18:47 1995
+***************
+*** 0 ****
+--- 1,82 ----
++ .\"
++ .\" $Id: vdcomp.man,v 1.2 1995/01/12 23:35:28 qralston Exp $
++ .\"
++ .\" $Log: vdcomp.man,v $
++ .\" Revision 1.2 1995/01/12 23:35:28 qralston
++ .\" Created from the information in the comments in vdcomp.c.
++ .\" James Ralston Crawford <qralston+@pitt.edu>
++ .\"
++ .TH vdcomp 1
++ .SH Name
++ \fIvdcomp\fP - decompress a compressed PDS image
++ .SH Synopsis
++ \fIvdcomp\fP [ infile ] [ outfile ] [ format-code ]
++ .SH Description
++ The \fIvdcomp\fP program reads a variable length compressed PDS image
++ and outputs a fixed length uncompressed image file in PDS format with
++ labels, image histogram, engineering table, line header table and an
++ image with PDS, FITS, VICAR or no labels.
++ .PP
++ If used on a non-byte-swapped machine the image histogram is
++ un-swapped.
++ .SH Options
++ \fIVdcomp\fP will prompt for any options that are not supplied on the
++ command-line.
++ .PP
++ \fIinfile\fP
++ .br
++ .RS
++ The name of compressed image file.
++ .RE
++ .PP
++ \fIoutfile\fP
++ .br
++ .RS
++ The name of uncompressed image file.
++ .RE
++ .PP
++ \fIformat-code\fP
++ .br
++ .RS
++ Select from the following list:
++ .br
++ .RS
++ \fI1\fP - SFDU/PDS format [default]
++ .br
++ \fI2\fP - FITS format
++ .br
++ \fI3\fP - VICAR format
++ .br
++ \fI4\fP - unlabelled binary array
++ .RE
++ .RE
++ .SH Limitations
++ This program has been tested on a VAX 780 (VMS 4.6), SUN Workstation
++ (UNIX 4.2, release 3.4), an IBM PC (MICROSOFT 5.1 compiler) and
++ Macintosh IIx using Lightspeed C version 3.0. When converting to
++ other systems, check for portability conflicts.
++ .SH Credits
++ This program uses Kris Becker's subroutine DECOMP.C (which is included
++ in this program in a shortened version).
++ .SH History
++ bradley@cis.upenn.edu 06-23-94 ansi-fied program
++ .PP
++ datri@convex.com, 11-15-91 added recognition of - as stdout for output
++ filename; disabled various messages; directed messages to stderr;
++ added exit status
++ .PP
++ DEC89 Modified program to handle both Voyager and Viking images.
++ .PP
++ OCT89 Converted Voyager decompression program to handle Viking
++ compressed images. Changed obuf to 'unsigned' to simplify computation
++ of checksum.
++ .PP
++ AUG89 Added code to get command line arguments for filenames and
++ output format; routines to free memory used by the Huffman tree);
++ fixed the SFDU label output length; and modified the I/O routines so
++ that the open for Host type 2 uses binary I/O.
++ .PP
++ JUN89 Fixed READVAR, to get length on 16-bit unswapped hosts.
++ .PP
++ JUL88 C driver to decompress standard Voyager Compressed images by
++ Mike Martin 1989/12/02.
+
+*** /dev/null Mon Jan 23 20:23:48 1995
+--- docs/xv.ann Tue Jan 03 13:58:15 1995
+***************
+*** 0 ****
+--- 1,38 ----
++ They said it couldn't be done. They said it never *would* be done.
++ They smiled knowingly to themselves as each predicted release date
++ inevitably passed by, unmarked by the emergence of a new version...
++
++ Well, who asked them! And who do they think they are, anyhow!?!
++
++ Announcing the Exciting New Release of XV, Version 3.10!
++
++ Finally, all the stuff you've been waiting for: image cut & paste, pixel
++ editing, text annotation (of a sort), nifty new algorithms, new image formats
++ (Targa, XPM, FITS, XWD, IFF), improved schnauzing capabilities, a spiffy
++ new 'pad' command, and whatnot. Plenty of whatnot.
++
++ Of course, we're particularly proud of our Exclusive 3-D Fish Technology.
++
++ At the moment, you can get this decidedly 'fine' piece of software via
++ anonymous ftp on the following sites:
++
++ Hostname Directory
++ -------- ---------
++ ftp.cis.upenn.edu: pub/xv
++ ftp.upenn.edu: data/bradley
++ ftp.duke.edu: pub/archive/xv
++ gatekeeper.dec.com: pub/graphics/xv
++
++ The file is called 'xv-3.10.tar.gz' (or 'xv-3.10.tar.Z' if you don't have
++ the 'gunzip' program).
++
++ BTW, if any of you fine folks can get these files put up on one of the major
++ ftp sites (wustl, gatekeeper, etc.) please do so, and let me know!
++
++ Enjoy!
++
++ John Bradley
++
++ -------------------------
++ Note: These tar files (xv-3.10.tar.Z and xv-3.10.tar.gz) have been replaced
++ as of 12/22/94, as the initial ones wouldn't build correctly on VMS.
diff --git a/source/xap/xv/xv.SlackBuild b/source/xap/xv/xv.SlackBuild
new file mode 100755
index 00000000..3ef40a7b
--- /dev/null
+++ b/source/xap/xv/xv.SlackBuild
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VERSION=3.10a
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-5}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-xv
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf xv-3.10
+tar xvf $CWD/xv-3.10.tar.gz || exit 1
+cd xv-3.10 || exit 1
+chown -R root:root .
+zcat $CWD/xv-3.10a.patch.gz | patch -p0 --verbose --backup --suffix=.orig || exit
+bzcat $CWD/xv-3.10a-jumbo-fix-patch-20050410.txt.bz2 | patch -p1 --verbose --backup --suffix=.orig || exit
+bzcat $CWD/xv-3.10a-jumbo-enh-patch-20050501.txt.bz2 | patch -p1 --verbose --backup --suffix=.orig || exit
+zcat $CWD/xv.prefix.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit
+if [ "$ARCH" = "x86_64" ]; then
+ zcat $CWD/xv.prefix_x86_64.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit
+fi
+make -f Makefile.std
+strip --strip-unneeded bggen vdcomp xcmap xv xvpictoppm
+mkdir -p $PKG/usr/bin
+cat bggen > $PKG/usr/bin/bggen
+cat vdcomp > $PKG/usr/bin/vdcomp
+cat xcmap > $PKG/usr/bin/xcmap
+cat xv > $PKG/usr/bin/xv
+cat xvpictoppm > $PKG/usr/bin/xvpictoppm
+chmod 755 $PKG/usr/bin/*
+mkdir -p $PKG/usr/man/man1
+for page in docs/xv.man docs/bggen.man docs/xcmap.man docs/xvp2p.man ; do
+ cat $page | gzip -9c > $PKG/usr/man/man1/`basename $page .man`.1.gz
+done
+mkdir -p $PKG/usr/doc/xv-$VERSION
+cp -a \
+ BUGS IDEAS INSTALL README README.jumbo README.pcd \
+ $PKG/usr/doc/xv-$VERSION
+( cd docs
+ cp -a \
+ penn.policy xv.blurb xv.ann xvdocs.ps \
+ $PKG/usr/doc/xv-$VERSION
+ bzip2 -9 $PKG/usr/doc/xv-$VERSION/xvdocs.ps )
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# Build the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/xv-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xv/xv.prefix.diff b/source/xap/xv/xv.prefix.diff
new file mode 100644
index 00000000..0e610833
--- /dev/null
+++ b/source/xap/xv/xv.prefix.diff
@@ -0,0 +1,11 @@
+--- ./Makefile.std.orig 2005-07-12 15:15:19.000000000 -0700
++++ ./Makefile.std 2005-07-12 15:16:08.000000000 -0700
+@@ -41,7 +41,7 @@
+
+
+ ### Installation locations
+-PREFIX = /usr/local
++PREFIX = /usr/X11R6
+ BINDIR = $(PREFIX)/bin
+ MANDIR = $(PREFIX)/man/man1
+ MANSUF = 1
diff --git a/source/xap/xv/xv.prefix_x86_64.diff b/source/xap/xv/xv.prefix_x86_64.diff
new file mode 100644
index 00000000..fd6803d5
--- /dev/null
+++ b/source/xap/xv/xv.prefix_x86_64.diff
@@ -0,0 +1,20 @@
+--- xv-3.10/Makefile.std.orig 2008-11-06 22:16:03.000000000 +0000
++++ xv-3.10/Makefile.std 2008-11-06 22:24:11.000000000 +0000
+@@ -46,7 +46,7 @@
+ MANDIR = $(PREFIX)/man/man1
+ MANSUF = 1
+ DOCDIR = $(PREFIX)/doc/xv-3.10a
+-LIBDIR = $(PREFIX)/lib/xv
++LIBDIR = $(PREFIX)/lib64/xv
+ SYSCONFDIR = $(PREFIX)/etc
+ DESTDIR =
+
+@@ -200,7 +200,7 @@
+
+
+ ### for LINUX, uncomment the following line
+-#MCHN = -DLINUX -L/usr/X11R6/lib
++MCHN = -DLINUX -L/usr/X11R6/lib64
+
+
+ # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
diff --git a/source/xap/xxgdb/slack-desc b/source/xap/xxgdb/slack-desc
new file mode 100644
index 00000000..4905df86
--- /dev/null
+++ b/source/xap/xxgdb/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+xxgdb: xxgdb (graphical program debugger interface)
+xxgdb:
+xxgdb: Xxgdb is a graphical user interface to the gdb debugger under the X
+xxgdb: Window System. It provides visual feedback and mouse input for the
+xxgdb: user to control program execution through breakpoints, to examine and
+xxgdb: traverse the function call stack, and to display values of variables
+xxgdb: and data structures.
+xxgdb:
+xxgdb:
+xxgdb:
+xxgdb:
diff --git a/source/xap/xxgdb/xxgdb.SlackBuild b/source/xap/xxgdb/xxgdb.SlackBuild
new file mode 100755
index 00000000..97c130f6
--- /dev/null
+++ b/source/xap/xxgdb/xxgdb.SlackBuild
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+PKGNAM=xxgdb
+VERSION=${VERSION:-1.12}
+ARCH=${ARCH:-x86_64}
+BUILD=${BUILD:-2}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-${PKGNAM}
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-march=i486 -mtune=i686"
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+cd $TMP
+rm -rf ${PKGNAM}-${VERSION}
+tar xvf $CWD/${PKGNAM}-$VERSION.tar.gz || exit 1
+cd ${PKGNAM}-$VERSION || exit 1
+
+zcat $CWD/xxgdb.fix_glibc_and_gcc.diff.gz | patch -p1 --verbose --backup --suffix=.orig
+
+# Make sure ownerships and permissions are sane:
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+xmkmf || exit 1
+make CCOPTIONS="$SLKCFLAGS" || exit 1
+make install DESTDIR="$PKG"
+make install.man DESTDIR="$PKG"
+
+# Strip binaries:
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Compress and link manpages, if any:
+if [ -d $PKG/usr/man ]; then
+ ( cd $PKG/usr/man
+ for manpagedir in $(find . -type d -name "man*") ; do
+ ( cd $manpagedir
+ for eachpage in $( find . -type l -maxdepth 1) ; do
+ ln -s $( readlink $eachpage ).gz $eachpage.gz
+ rm $eachpage
+ done
+ gzip -9 *.*
+ )
+ done
+ )
+fi
+
+# Compress info files, if any:
+if [ -d $PKG/usr/info ]; then
+ ( cd $PKG/usr/info
+ rm -f dir
+ gzip -9 *
+ )
+fi
+
+# Add a documentation directory:
+mkdir -p ${PKG}/usr/doc/${PKGNAM}-$VERSION
+cp -a \
+ README README.NEW_INTERFACE XDBX_README XDbx.NEW_INTERFACE XXGDB_README \
+ $PKG/usr/doc/${PKGNAM}-$VERSION
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+# Build the package:
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/source/xap/xxgdb/xxgdb.fix_glibc_and_gcc.diff b/source/xap/xxgdb/xxgdb.fix_glibc_and_gcc.diff
new file mode 100644
index 00000000..b61d57ce
--- /dev/null
+++ b/source/xap/xxgdb/xxgdb.fix_glibc_and_gcc.diff
@@ -0,0 +1,45 @@
+diff -Naur xxgdb-1.12/Imakefile xxgdb-1.12.fixed/Imakefile
+--- xxgdb-1.12/Imakefile 1995-06-19 19:20:55.000000000 -0300
++++ xxgdb-1.12.fixed/Imakefile 2007-02-21 10:40:57.000000000 -0200
+@@ -59,7 +59,7 @@
+ #endif
+
+ #ifdef LinuxArchitecture
+-DEFINES = -DSYSV $(DEFGDB)
++DEFINES = $(DEFGDB)
+ #endif
+
+ #if defined(NeXTArchitecture) || defined(NextArchitecture)
+diff -Naur xxgdb-1.12/filemenu.c xxgdb-1.12.fixed/filemenu.c
+--- xxgdb-1.12/filemenu.c 1994-08-29 16:38:28.000000000 -0300
++++ xxgdb-1.12.fixed/filemenu.c 2007-02-21 10:47:47.000000000 -0200
+@@ -207,12 +207,12 @@
+ return False;
+ if (statbuf.st_mode & S_IFDIR) { /* is directory */
+ strcat(entry->d_name, "/");
+- ++(entry->d_namlen);
++ ++(entry->d_reclen);
+ return True;
+ }
+ if (statbuf.st_mode & S_IEXEC) { /* is executable */
+ strcat(entry->d_name, "*");
+- ++(entry->d_namlen);
++ ++(entry->d_reclen);
+ return True;
+ }
+ return True;
+diff -Naur xxgdb-1.12/gdb_handler.c xxgdb-1.12.fixed/gdb_handler.c
+--- xxgdb-1.12/gdb_handler.c 1995-04-19 13:46:22.000000000 -0300
++++ xxgdb-1.12.fixed/gdb_handler.c 2007-02-21 10:51:30.000000000 -0200
+@@ -85,10 +85,7 @@
+ * query_gdb(): Send command to gdb.
+ */
+
+-#ifdef SYSV
+-# include <signal.h>
+-#endif
+-
++#include <signal.h>
+
+ /*
+ * Display an outlined arrow to locate the calling routine in a stack