changeset 265:8efd647ea9ca r20-5b31

Import from CVS: tag r20-5b31
author cvs
date Mon, 13 Aug 2007 10:25:37 +0200
parents 682d2a9d41a5
children 18d185df8c54
files CHANGES-beta ChangeLog aclocal.m4 configure configure.in configure.usage etc/Emacs.ad etc/README.HYPERBOLE etc/README.OO-BROWSER lib-src/config.values.in lisp/ChangeLog lisp/about.el lisp/auto-autoloads.el lisp/dumped-lisp.el lisp/faces.el lisp/files.el lisp/keydefs.el lisp/lisp.el lisp/make-docfile.el lisp/modeline.el lisp/msw-faces.el lisp/msw-glyphs.el lisp/mwheel.el lisp/setup-paths.el lisp/simple.el lisp/update-elc.el lisp/winnt.el lisp/x-faces.el lisp/x-menubar.el lisp/x-mouse.el man/ChangeLog man/internals/internals.texi modules/Makefile.in modules/aclocal.m4 modules/base64/Makefile.in modules/base64/base64.c modules/configure.in modules/example/Makefile.in modules/example/purified.c modules/ldap/Makefile.in modules/ldap/configure.in modules/ldap/eldap.c modules/ldap/eldap.h modules/zlib/Makefile.in modules/zlib/zlib.c nt/ChangeLog nt/Installation.el nt/xemacs.mak src/ChangeLog src/Makefile.in.in src/alloc.c src/cmds.c src/config.h.in src/console-tty.c src/console-tty.h src/console.h src/dgif_lib.c src/dll.c src/dlopen.c src/eldap.c src/eldap.h src/emacs.c src/event-stream.c src/file-coding.c src/fileio.c src/gif_err.c src/gif_lib.h src/gifalloc.c src/glyphs-x.c src/glyphs.h src/imgproc.c src/imgproc.h src/keymap.c src/lisp.h src/lread.c src/marker.c src/ntplay.c src/redisplay-msw.c src/redisplay-output.c src/redisplay-tty.c src/redisplay.c src/s/cygwin32.h src/s/windowsnt.h src/sheap.c src/sound.c src/symsinit.h src/sysdll.c src/sysdll.h src/window.c version.sh
diffstat 90 files changed, 6881 insertions(+), 3891 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES-beta	Mon Aug 13 10:24:47 2007 +0200
+++ b/CHANGES-beta	Mon Aug 13 10:25:37 2007 +0200
@@ -1,4 +1,31 @@
 							-*- indented-text -*-
+to 20.5 beta31 "Myotonic"
+-- modules directory with dll examples courtesy of William Perry
+-- Upside-down TIFF fix from Jareth Hein
+-- ldap/eudc fixes from Oscar Figueiredo
+-- file coding changes/cleanup from Kirill Katsnelson
+-- separation of internal motion commands from user keystroke motion commands
+   from Kyle Jones
+-- miscellaneous cursor bug fixes from Kyle Jones
+-- More bug fixes from Kirill Katsnelson
+-- Better error message for unbound major modes from Pete Ware
+-- Updates on DLL support from William Perry
+-- New GIF support from Jareth Hein
+-- Miscellaneous MS windows fixes from Kirill Katsnelson
+-- Scrollable modeline deferred until 21.1
+-- 20.5 is renamed to 21.0
+-- TMPDIR fixes from Glynn Clements
+-- cygwin dll detection fixes from Andy Piper
+-- NT .wav sound support from Andy Piper
+-- Cygwin configuration fixes from Andy Piper
+-- mouse-4, mouse-5 portability keysyms
+-- Options -> Browse Faces now calls customize-face from Kyle Jones
+-- miscellaneous bug fixes
+-- DLL configuration and portability fixes from William Perry
+-- Marker and sound fixes from Hrvoje Niksic
+-- face initialization bug fixes from Kyle Jones
+-- static initializer fix from Kyle Jones
+
 to 20.5 beta30 "Moxotó"
 -- find-gc.el fixes courtesy of Markus Linnala
 -- mousewheel support courtesy of William Perry
--- a/ChangeLog	Mon Aug 13 10:24:47 2007 +0200
+++ b/ChangeLog	Mon Aug 13 10:25:37 2007 +0200
@@ -1,3 +1,68 @@
+1998-03-16  SL Baur  <steve@altair.xemacs.org>
+
+	* XEmacs 21.0 beta31 is released.
+
+1998-03-16  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* configure.usage (Usage): Correct information about gif, tiff
+	and WNN entries
+
+1998-03-13  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in: typo fix in sed command.
+	From P. E. Jareth Hein <jareth@camelot-soft.com>
+
+	* configure.in (all_widgets): Check for snprintf().
+
+1998-03-11  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* configure.in: New gif support
+
+1998-03-10  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in (have_glibc): Don't define _GNU_SOURCE for glibc.
+
+Mon Mar 09 13:00:55 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* configure.in: don't add libc to link list for dlopen ordinary
+	link takes care of this. check for dlfcn.h
+
+1998-03-10  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in: Examine each directory of X11 include path for
+	inclusion into BITMAPDIR.
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* aclocal.m4: Add legalese.
+
+Mon Mar 09 13:00:55 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* configure.in: make sure we have ndbm.h as well as libgdbm.a for
+	database support.
+
+	* configure.in: move msw checking after x checking so that
+	auto-detection works.
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in: New DLL support.
+	* aclocal.m4: New file.
+	From William M. Perry <wmperry@aventail.com>
+
+1998-03-08  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in (xemacs_betaname): Align messages for minimal
+	tagbits and indexed lrecords.
+	Suggested by Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+1998-03-09  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* etc/Emacs.ad: Example using leading dot resources to
+	  initalize faces changes to use Emacs.foo since the
+	  leading dot syntax doesn't work.  Initialization of
+	  text-cursor face moved to faces.el.
+
 1998-03-07  SL Baur  <steve@altair.xemacs.org>
 
 	* XEmacs 20.5-beta30 is released.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aclocal.m4	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,99 @@
+dnl aclocal.m4 --- Dynamically linked library support for XEmacs
+dnl Copyright (C) 1998 Free Software Foundation, Inc.
+dnl Author: William Perry <wmperry@aventail.com>
+dnl This file is part of XEmacs
+
+AC_DEFUN(XE_MAKE_SHAREDLIB, [
+dll_ld="ld"
+dll_lflags="-shared"
+dll_cflags="-r"
+dll_oflags="-o "
+
+AC_MSG_CHECKING(how to build a shared library)
+case `uname -rs` in
+	UNIX_SV*|UNIX_System_V*)
+		dll_lflags="-G"
+		dll_cflags=-Kpic
+		dll_ld="ld"
+		;;
+	BSD/OS*)
+		dll_cflags=
+		dll_lflags="-r"
+		dll_ld="shlicc2"
+		;;
+	FreeBSD*2*)
+		dll_lflags="-Bshareable"
+		dll_cflags="-fPIC -DPIC"
+		dll_ld=ld
+		;;
+	SunOS*4.*)
+ 		dll_cflags="-P"
+		dll_lflags="-dp -assert pure-text -assert nodefinitions"
+		;;
+	SunOS*5.*)
+		dll_ld="cc"
+		dll_cflags="-KPIC"
+		dll_lflags="-G"
+		dll_oflags="-W0,-y-o -W0,-y"
+		;;	
+	IRIX*5.*|IRIX*6.*)
+		dll_cflags="-KPIC"
+		;;
+	OSF1*)
+		;;
+	HP-UX*)
+		dll_ld="ld"
+		dll_lflags="-b"
+		dll_cflags="+z"
+		;;
+	SCO_SV*)
+		dll_ld="ld"
+		dll_lflags="-G"
+		dll_cflags="-Kpic"
+		;;
+	AIX*)
+		dll_lflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:\${@:.ell=.exp} -b noentry -lc"
+		dll_ld="ld"
+		;;
+	*)
+		;;
+	esac
+
+	if test "$GCC" = "yes" ; then
+		dll_cflags="-fPIC"
+		case `uname -rs` in
+		SunOS*5.*)
+			dll_ld="ld"
+			dll_oflags="-o "
+			dll_lflags="-G"
+			;;
+		SCO_SV*)
+			dll_ld="ld"
+			dll_lflags="-G"
+			dll_cflags="-b elf"
+			;;
+		FreeBSD*)
+			dll_cflags="-DDLSYM_NEEDS_UNDERSCORE -DPIC -fPIC"
+			dll_lflags="-Bshareable"
+			dll_ld=ld
+			;;
+		BSD/OS*)
+			dll_cflags=
+			dll_lflags="-r"
+			dll_ld="shlicc2"
+			;;
+		UNIX_SV*)
+			dll_cflags="-fPIC"
+			;;
+		*)
+			dll_ld="$CC"
+			dll_lflags="-shared"
+		esac
+	fi
+
+	AC_MSG_RESULT("lflags: $dll_lflags cflags: $dll_cflags")
+AC_SUBST(dll_ld)
+AC_SUBST(dll_cflags)
+AC_SUBST(dll_oflags)
+AC_SUBST(dll_lflags)
+])dnl
--- a/configure	Mon Aug 13 10:24:47 2007 +0200
+++ b/configure	Mon Aug 13 10:25:37 2007 +0200
@@ -248,7 +248,6 @@
 with_dlmalloc='default'
 native_sound_lib=''
 use_assertions="yes"
-with_gif=""
 with_toolbars=""
 with_tty=""
 use_union_type="no"
@@ -399,7 +398,7 @@
   \`yes', \`no', or \`default'."
 echo "  Use \`$progname --help' to show usage.") >&2 && exit 1 ;;
 	  esac
-	  case "$opt" in use_* ) opt="`echo $opt | sed /use/with/`" ;; esac
+	  case "$opt" in use_* ) opt="`echo $opt | sed s/use/with/`" ;; esac
           eval "$opt=\"$val\""
         ;;
 
@@ -643,7 +642,7 @@
 
 if test -z "$configuration"; then
   echo $ac_n "checking "host system type"""... $ac_c" 1>&6
-echo "configure:647: checking "host system type"" >&5
+echo "configure:646: checking "host system type"" >&5
     if configuration=`${CONFIG_SHELL-/bin/sh} $srcdir/config.guess | \
     sed 's/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/'` ; then
     echo "$ac_t""$configuration" 1>&6
@@ -657,7 +656,7 @@
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:661: checking whether ln -s works" >&5
+echo "configure:660: checking whether ln -s works" >&5
 
 rm -f conftestdata
 if ln -s X conftestdata 2>/dev/null
@@ -834,7 +833,7 @@
 
 
 echo "checking "the configuration name"" 1>&6
-echo "configure:838: checking "the configuration name"" >&5
+echo "configure:837: checking "the configuration name"" >&5
 internal_configuration=`echo $configuration | sed 's/-\(workshop\)//'`
 if canonical=`$srcdir/config.sub "$internal_configuration"` ; then : ; else
   exit $?
@@ -1281,7 +1280,6 @@
  fi
 fi
 
-
 test -n "$compiler" && CC="$compiler"
 if test "$with_gcc" = "no"; then   case "$CC" in "" | *gcc* ) CC="${NON_GNU_CC-cc}" ;; esac
 fi
@@ -1292,7 +1290,7 @@
 # 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:1296: checking for $ac_word" >&5
+echo "configure:1294: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1318,7 +1316,7 @@
   # 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:1322: checking for $ac_word" >&5
+echo "configure:1320: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1363,7 +1361,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1367: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1365: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
@@ -1375,11 +1373,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1379 "configure"
+#line 1377 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
-if { (eval echo configure:1383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
@@ -1399,19 +1397,19 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1403: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1401: 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 $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1408: checking whether we are using GNU C" >&5
+echo "configure:1406: checking whether we are using GNU C" >&5
 
 cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1415: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1413: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1425,7 +1423,7 @@
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS=
   echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1429: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1427: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1454,7 +1452,7 @@
   # 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:1458: checking for $ac_word" >&5
+echo "configure:1456: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1480,7 +1478,7 @@
   # 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:1484: checking for $ac_word" >&5
+echo "configure:1482: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1525,7 +1523,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1529: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1527: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
@@ -1537,11 +1535,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1541 "configure"
+#line 1539 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
-if { (eval echo configure:1545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
@@ -1561,19 +1559,19 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1565: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1563: 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 $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1570: checking whether we are using GNU C" >&5
+echo "configure:1568: checking whether we are using GNU C" >&5
 
 cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1575: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1587,7 +1585,7 @@
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS=
   echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1591: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1589: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1616,7 +1614,7 @@
   # 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:1620: checking for $ac_word" >&5
+echo "configure:1618: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1642,7 +1640,7 @@
   # 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:1646: checking for $ac_word" >&5
+echo "configure:1644: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1687,7 +1685,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1691: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1689: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
@@ -1699,11 +1697,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1703 "configure"
+#line 1701 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
-if { (eval echo configure:1707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
@@ -1723,19 +1721,19 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1727: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1725: 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 $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1732: checking whether we are using GNU C" >&5
+echo "configure:1730: checking whether we are using GNU C" >&5
 
 cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1749,7 +1747,7 @@
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS=
   echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1753: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1751: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1782,7 +1780,7 @@
 test -n "$NON_GNU_CPP" -a "$GCC" != "yes" -a -z "$CPP" && CPP="$NON_GNU_CPP"
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1786: checking how to run the C preprocessor" >&5
+echo "configure:1784: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1795,13 +1793,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1799 "configure"
+#line 1797 "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:1805: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1803: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -1812,13 +1810,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1816 "configure"
+#line 1814 "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:1822: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -1841,9 +1839,9 @@
 
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:1845: checking for AIX" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1847 "configure"
+echo "configure:1843: checking for AIX" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1845 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -1870,9 +1868,9 @@
 
 
 echo $ac_n "checking for GNU libc""... $ac_c" 1>&6
-echo "configure:1874: checking for GNU libc" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1876 "configure"
+echo "configure:1872: checking for GNU libc" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1874 "configure"
 #include "confdefs.h"
 #include <features.h>
 int main() {
@@ -1884,7 +1882,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1888: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1886: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_glibc=yes
 else
@@ -1895,19 +1893,11 @@
 fi
 rm -f conftest*
 echo "$ac_t""$have_glibc" 1>&6
-test "$have_glibc" = "yes" && { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining _GNU_SOURCE
-EOF
-cat >> confdefs.h <<\EOF
-#define _GNU_SOURCE 1
-EOF
-}
-
 
 echo $ac_n "checking whether we are using SunPro C""... $ac_c" 1>&6
-echo "configure:1909: checking whether we are using SunPro C" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1911 "configure"
+echo "configure:1899: checking whether we are using SunPro C" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1901 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1918,7 +1908,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1912: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   __sunpro_c=yes
 else
@@ -2194,7 +2184,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2198: checking for dynodump" >&5
+echo "configure:2188: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2292,19 +2282,19 @@
 
 if test "$add_runtime_path" = "yes"; then
       echo $ac_n "checking "for runtime libraries flag"""... $ac_c" 1>&6
-echo "configure:2296: checking "for runtime libraries flag"" >&5
+echo "configure:2286: checking "for runtime libraries flag"" >&5
   dash_r=""
   for try_dash_r in "-R" "-R " "-rpath "; do
     xe_check_libs="${try_dash_r}/no/such/file-or-directory"
     cat > conftest.$ac_ext <<EOF
-#line 2301 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:2308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 2291 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -2391,10 +2381,10 @@
 fi
 after_morecore_hook_exists=yes
 echo $ac_n "checking for malloc_get_state""... $ac_c" 1>&6
-echo "configure:2395: checking for malloc_get_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2398 "configure"
+echo "configure:2385: checking for malloc_get_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2388 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_get_state(); below.  */
@@ -2417,7 +2407,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_malloc_get_state=yes"
 else
@@ -2437,10 +2427,10 @@
 fi
 
 echo $ac_n "checking for malloc_set_state""... $ac_c" 1>&6
-echo "configure:2441: checking for malloc_set_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2444 "configure"
+echo "configure:2431: checking for malloc_set_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2434 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_set_state(); below.  */
@@ -2463,7 +2453,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_malloc_set_state=yes"
 else
@@ -2483,16 +2473,16 @@
 fi
 
 echo $ac_n "checking whether __after_morecore_hook exists""... $ac_c" 1>&6
-echo "configure:2487: checking whether __after_morecore_hook exists" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2489 "configure"
+echo "configure:2477: checking whether __after_morecore_hook exists" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2479 "configure"
 #include "confdefs.h"
 extern void (* __after_morecore_hook)();
 int main() {
 __after_morecore_hook = 0
 ; return 0; }
 EOF
-if { (eval echo configure:2496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -2557,7 +2547,7 @@
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2561: checking for $ac_word" >&5
+echo "configure:2551: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -2610,7 +2600,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./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:2614: checking for a BSD compatible install" >&5
+echo "configure:2604: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
   IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
@@ -2661,7 +2651,7 @@
 # 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:2665: checking for $ac_word" >&5
+echo "configure:2655: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -2692,15 +2682,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2696: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2699 "configure"
+echo "configure:2686: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2689 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2704: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2694: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2733,15 +2723,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2737: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2740 "configure"
+echo "configure:2727: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2730 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2774,15 +2764,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2778: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2781 "configure"
+echo "configure:2768: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2771 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2776: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2812,10 +2802,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:2816: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2819 "configure"
+echo "configure:2806: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2809 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -2831,7 +2821,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:2835: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2825: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -2855,10 +2845,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2859: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2862 "configure"
+echo "configure:2849: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2852 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2866,7 +2856,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2860: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2883,7 +2873,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2887 "configure"
+#line 2877 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2901,7 +2891,7 @@
 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 <<EOF
-#line 2905 "configure"
+#line 2895 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2919,7 +2909,7 @@
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
 cat > conftest.$ac_ext <<EOF
-#line 2923 "configure"
+#line 2913 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2930,7 +2920,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:2924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   :
 else
@@ -2955,10 +2945,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2959: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2962 "configure"
+echo "configure:2949: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2952 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2967,7 +2957,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2991,10 +2981,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:2995: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2998 "configure"
+echo "configure:2985: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2988 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3006,7 +2996,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:3010: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3000: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -3031,9 +3021,9 @@
 
 
 echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6
-echo "configure:3035: checking for struct utimbuf" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3037 "configure"
+echo "configure:3025: checking for struct utimbuf" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3027 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3052,7 +3042,7 @@
 static struct utimbuf x; x.actime = x.modtime;
 ; return 0; }
 EOF
-if { (eval echo configure:3056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3046: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -3072,10 +3062,10 @@
 rm -f conftest*
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3076: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3079 "configure"
+echo "configure:3066: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3069 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3092,7 +3082,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3114,10 +3104,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3118: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3121 "configure"
+echo "configure:3108: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3111 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3148,10 +3138,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3152: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3155 "configure"
+echo "configure:3142: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3145 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3182,10 +3172,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3186: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3189 "configure"
+echo "configure:3176: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3179 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3221,10 +3211,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3225: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3228 "configure"
+echo "configure:3215: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3218 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3255,10 +3245,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3259: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3262 "configure"
+echo "configure:3249: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3252 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3290,9 +3280,9 @@
 
 
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:3294: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3296 "configure"
+echo "configure:3284: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3286 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3308,7 +3298,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:3312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3302: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -3330,10 +3320,10 @@
 rm -f conftest*
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:3334: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3337 "configure"
+echo "configure:3324: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3327 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -3341,7 +3331,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:3345: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3335: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -3365,10 +3355,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:3369: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3372 "configure"
+echo "configure:3359: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3362 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -3376,7 +3366,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:3380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -3399,10 +3389,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:3403: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3406 "configure"
+echo "configure:3393: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3396 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -3412,7 +3402,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:3416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -3438,10 +3428,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3442: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3445 "configure"
+echo "configure:3432: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3435 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3490,7 +3480,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3494: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3484: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3515,7 +3505,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:3519: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:3509: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -3540,12 +3530,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3544: checking whether byte ordering is bigendian" >&5
+echo "configure:3534: checking whether byte ordering is bigendian" >&5
 
 ac_cv_c_bigendian=unknown
 # See if sys/param.h defines the BYTE_ORDER macro.
 cat > conftest.$ac_ext <<EOF
-#line 3549 "configure"
+#line 3539 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3556,11 +3546,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3550: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   # It does; now see whether it defined to BIG_ENDIAN or not.
 cat > conftest.$ac_ext <<EOF
-#line 3564 "configure"
+#line 3554 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3571,7 +3561,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3575: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3565: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -3588,7 +3578,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 3592 "configure"
+#line 3582 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -3601,7 +3591,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:3605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -3627,10 +3617,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:3631: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3634 "configure"
+echo "configure:3621: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3624 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3641,7 +3631,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -3668,10 +3658,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3672: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3675 "configure"
+echo "configure:3662: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3665 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3682,7 +3672,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -3703,10 +3693,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3707: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3710 "configure"
+echo "configure:3697: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3700 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3717,7 +3707,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -3738,10 +3728,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:3742: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3745 "configure"
+echo "configure:3732: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3735 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3752,7 +3742,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -3773,10 +3763,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:3777: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3780 "configure"
+echo "configure:3767: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3770 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3787,7 +3777,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_void_p=`cat conftestval`
 else
@@ -3809,7 +3799,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:3813: checking for long file names" >&5
+echo "configure:3803: checking for long file names" >&5
 
 ac_cv_sys_long_file_names=yes
 # Test for long file names in all the places we know might matter:
@@ -3856,12 +3846,12 @@
 
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:3860: checking for sin in -lm" >&5
+echo "configure:3850: checking for sin in -lm" >&5
 ac_lib_var=`echo m'_'sin | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lm "
 cat > conftest.$ac_ext <<EOF
-#line 3865 "configure"
+#line 3855 "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
@@ -3872,7 +3862,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:3876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3914,14 +3904,14 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 3918 "configure"
+#line 3908 "configure"
 #include "confdefs.h"
 #include <math.h>
 int main() {
 return atanh(1.0) + asinh(1.0) + acosh(1.0); 
 ; return 0; }
 EOF
-if { (eval echo configure:3925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_INVERSE_HYPERBOLIC
@@ -3938,7 +3928,7 @@
 rm -f conftest*
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:3942: checking type of mail spool file locking" >&5
+echo "configure:3932: checking type of mail spool file locking" >&5
 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
 if   test "$mail_locking" = "lockf"; then { test "$extra_verbose" = "yes" && cat << \EOF
@@ -3962,12 +3952,12 @@
 
 
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:3966: checking for kstat_open in -lkstat" >&5
+echo "configure:3956: checking for kstat_open in -lkstat" >&5
 ac_lib_var=`echo kstat'_'kstat_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lkstat "
 cat > conftest.$ac_ext <<EOF
-#line 3971 "configure"
+#line 3961 "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
@@ -3978,7 +3968,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:3982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4012,12 +4002,12 @@
 
 
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:4016: checking for kvm_read in -lkvm" >&5
+echo "configure:4006: checking for kvm_read in -lkvm" >&5
 ac_lib_var=`echo kvm'_'kvm_read | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lkvm "
 cat > conftest.$ac_ext <<EOF
-#line 4021 "configure"
+#line 4011 "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
@@ -4028,7 +4018,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:4032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4062,12 +4052,12 @@
 
 
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:4066: checking for cma_open in -lpthreads" >&5
+echo "configure:4056: checking for cma_open in -lpthreads" >&5
 ac_lib_var=`echo pthreads'_'cma_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpthreads "
 cat > conftest.$ac_ext <<EOF
-#line 4071 "configure"
+#line 4061 "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
@@ -4078,7 +4068,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4114,7 +4104,7 @@
 fi
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:4118: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:4108: checking whether the -xildoff compiler flag is required" >&5
 if   ${CC-cc} '-###' -xildon  no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ; then
   if ${CC-cc} '-###' -xildoff no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ;
     then echo "$ac_t""no" 1>&6;
@@ -4125,7 +4115,7 @@
 
 if test "$opsys" = "sol2" && test "$OS_RELEASE" -ge 56; then
   echo $ac_n "checking for \"-z ignore\" linker flag""... $ac_c" 1>&6
-echo "configure:4129: checking for \"-z ignore\" linker flag" >&5
+echo "configure:4119: checking for \"-z ignore\" linker flag" >&5
   case "`ld -h 2>&1`" in
     *-z\ ignore\|record* ) echo "$ac_t""yes" 1>&6
       ld_switch_site="-z ignore $ld_switch_site" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-z ignore\" to \$ld_switch_site"; fi ;;
@@ -4135,7 +4125,7 @@
 
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:4139: checking "for specified window system"" >&5
+echo "configure:4129: checking "for specified window system"" >&5
 
 if test "$with_x11" != "no"; then
     test "$x_includes $x_libraries" != "NONE NONE" && \
@@ -4165,7 +4155,7 @@
 # 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:4169: checking for X" >&5
+echo "configure:4159: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -4225,12 +4215,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 4229 "configure"
+#line 4219 "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:4234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4299,14 +4289,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4303 "configure"
+#line 4293 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:4310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -4415,17 +4405,17 @@
     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:4419: checking whether -R must be followed by a space" >&5
+echo "configure:4409: 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 4422 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4412 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -4441,14 +4431,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 4445 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4435 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -4484,12 +4474,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:4488: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:4478: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldnet "
 cat > conftest.$ac_ext <<EOF
-#line 4493 "configure"
+#line 4483 "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
@@ -4500,7 +4490,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4494: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4524,12 +4514,12 @@
     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:4528: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:4518: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldnet_stub "
 cat > conftest.$ac_ext <<EOF
-#line 4533 "configure"
+#line 4523 "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
@@ -4540,7 +4530,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4569,10 +4559,10 @@
     # 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:4573: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4576 "configure"
+echo "configure:4563: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4566 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -4595,7 +4585,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -4616,12 +4606,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:4620: checking for gethostbyname in -lnsl" >&5
+echo "configure:4610: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lnsl "
 cat > conftest.$ac_ext <<EOF
-#line 4625 "configure"
+#line 4615 "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
@@ -4632,7 +4622,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:4636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4662,10 +4652,10 @@
     # -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:4666: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4669 "configure"
+echo "configure:4656: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4659 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -4688,7 +4678,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -4711,12 +4701,12 @@
 xe_msg_checking="for connect in -lsocket"
 test -n "$X_EXTRA_LIBS" && xe_msg_checking="$xe_msg_checking using extra libs $X_EXTRA_LIBS"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:4715: checking "$xe_msg_checking"" >&5
+echo "configure:4705: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lsocket $X_EXTRA_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4720 "configure"
+#line 4710 "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
@@ -4727,7 +4717,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:4731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4751,10 +4741,10 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:4755: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4758 "configure"
+echo "configure:4745: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4748 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -4777,7 +4767,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -4798,12 +4788,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:4802: checking for remove in -lposix" >&5
+echo "configure:4792: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lposix "
 cat > conftest.$ac_ext <<EOF
-#line 4807 "configure"
+#line 4797 "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
@@ -4814,7 +4804,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:4818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4838,10 +4828,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:4842: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4845 "configure"
+echo "configure:4832: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4835 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -4864,7 +4854,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -4885,12 +4875,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:4889: checking for shmat in -lipc" >&5
+echo "configure:4879: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lipc "
 cat > conftest.$ac_ext <<EOF
-#line 4894 "configure"
+#line 4884 "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
@@ -4901,7 +4891,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:4905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4935,12 +4925,12 @@
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   
 echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:4939: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:4929: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lICE "
 cat > conftest.$ac_ext <<EOF
-#line 4944 "configure"
+#line 4934 "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
@@ -4951,7 +4941,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:4955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4986,81 +4976,6 @@
   no  ) window_system=none HAVE_X_WINDOWS=no  ;;
 esac
 
-if test "$with_msw" != "no"; then
-  echo "checking for MS-Windows" 1>&6
-echo "configure:4992: checking for MS-Windows" >&5
-  
-echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
-echo "configure:4995: checking for main in -lgdi32" >&5
-ac_lib_var=`echo gdi32'_'main | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lgdi32 "
-cat > conftest.$ac_ext <<EOF
-#line 5000 "configure"
-#include "confdefs.h"
-
-int main() {
-main()
-; return 0; }
-EOF
-if { (eval echo configure:5007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
-xe_check_libs=""
-
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
-  echo "$ac_t""yes" 1>&6
-  with_msw=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-  if test "$with_msw" = "yes"; then
-    { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining HAVE_MS_WINDOWS
-EOF
-cat >> confdefs.h <<\EOF
-#define HAVE_MS_WINDOWS 1
-EOF
-}
-
-    libs_system="$libs_system -lshell32 -lgdi32 -luser32" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lshell32 -lgdi32 -luser32\" to \$libs_system"; fi
-    if test "$window_system" != x11; then
- 	window_system=msw
-	test "$with_scrollbars" != "no" && with_scrollbars=msw \
-	    && extra_objs="$extra_objs scrollbar-msw.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"scrollbar-msw.o\""
- fi
-	test "$with_menubars"   != "no" && with_menubars=msw \
-	    && extra_objs="$extra_objs menubar-msw.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"menubar-msw.o\""
- fi
-	with_dialogs=msw
-	with_toolbars=no
-    else
-	test "$with_scrollbars"   != "no" && extra_objs="$extra_objs scrollbar-msw.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"scrollbar-msw.o\""
- fi
-	test "$with_menubars"   != "no" && extra_objs="$extra_objs menubar-msw.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"menubar-msw.o\""
- fi
-    fi
-    const_is_losing=no
-    with_file_coding=yes
-    extra_objs="$extra_objs console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o\""
- fi
-  fi
-fi
-
 if test "$with_x11" = "yes"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_X_WINDOWS
@@ -5158,8 +5073,29 @@
     echo
   fi
 
+            bitmapdirs=
+  if test "$x_includes" != NONE; then
+    for i in $x_includes; do
+      if test -d "$i/bitmaps"; then
+	bitmapdirs="$i/bitmaps:$bitmapdirs"
+      fi
+      if test -d "$i/X11/bitmaps"; then
+	bitmapdirs="$i/X11/bitmaps:$bitmapdirs"
+      fi
+    done
+    bitmapdirs=`echo "$bitmapdirs" | sed s/.$//`
+  fi
+  test ! -z "$bitmapdirs" && { test "$extra_verbose" = "yes" && cat << EOF
+    Defining BITMAPDIR = "$bitmapdirs"
+EOF
+cat >> confdefs.h <<EOF
+#define BITMAPDIR "$bitmapdirs"
+EOF
+}
+
+
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:5163: checking for X defines extracted by xmkmf" >&5
+echo "configure:5099: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -5191,15 +5127,15 @@
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:5195: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5198 "configure"
+echo "configure:5131: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5134 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5203: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5223,12 +5159,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:5227: checking for XOpenDisplay in -lX11" >&5
+echo "configure:5163: checking for XOpenDisplay in -lX11" >&5
 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 "
 cat > conftest.$ac_ext <<EOF
-#line 5232 "configure"
+#line 5168 "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
@@ -5239,7 +5175,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5264,12 +5200,12 @@
 xe_msg_checking="for XGetFontProperty in -lX11"
 test -n "-b i486-linuxaout" && xe_msg_checking="$xe_msg_checking using extra libs -b i486-linuxaout"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:5268: checking "$xe_msg_checking"" >&5
+echo "configure:5204: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo X11'_'XGetFontProperty | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 -b i486-linuxaout"
 cat > conftest.$ac_ext <<EOF
-#line 5273 "configure"
+#line 5209 "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
@@ -5280,7 +5216,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:5284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5307,12 +5243,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:5311: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:5247: checking for XShapeSelectInput in -lXext" >&5
 ac_lib_var=`echo Xext'_'XShapeSelectInput | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXext "
 cat > conftest.$ac_ext <<EOF
-#line 5316 "configure"
+#line 5252 "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
@@ -5323,7 +5259,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:5327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5263: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5346,12 +5282,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:5350: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:5286: checking for XtOpenDisplay in -lXt" >&5
 ac_lib_var=`echo Xt'_'XtOpenDisplay | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXt "
 cat > conftest.$ac_ext <<EOF
-#line 5355 "configure"
+#line 5291 "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
@@ -5362,7 +5298,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5385,14 +5321,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:5389: checking the version of X11 being used" >&5
+echo "configure:5325: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 5391 "configure"
+#line 5327 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     main(int c, char* v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:5396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:5332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -5416,15 +5352,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5420: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5423 "configure"
+echo "configure:5356: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5359 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5364: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5455,7 +5391,7 @@
 
 
     echo $ac_n "checking for XFree86""... $ac_c" 1>&6
-echo "configure:5459: checking for XFree86" >&5
+echo "configure:5395: checking for XFree86" >&5
   if test -d "/usr/X386/include" -o \
           -f "/etc/XF86Config"    -o \
 	  -f "/etc/X11/XF86Config" -o \
@@ -5475,12 +5411,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:5479: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:5415: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
 ac_lib_var=`echo Xmu'_'XmuReadBitmapDataFromFile | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXmu "
 cat > conftest.$ac_ext <<EOF
-#line 5484 "configure"
+#line 5420 "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
@@ -5491,7 +5427,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:5495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5530,19 +5466,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:5534: checking for main in -lXbsd" >&5
+echo "configure:5470: checking for main in -lXbsd" >&5
 ac_lib_var=`echo Xbsd'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXbsd "
 cat > conftest.$ac_ext <<EOF
-#line 5539 "configure"
+#line 5475 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5482: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5568,6 +5504,81 @@
   fi
 
 fi 
+if test "$with_msw" != "no"; then
+  echo "checking for MS-Windows" 1>&6
+echo "configure:5510: checking for MS-Windows" >&5
+  
+echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
+echo "configure:5513: checking for main in -lgdi32" >&5
+ac_lib_var=`echo gdi32'_'main | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -lgdi32 "
+cat > conftest.$ac_ext <<EOF
+#line 5518 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:5525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  with_msw=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+  if test "$with_msw" = "yes"; then
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_MS_WINDOWS
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_MS_WINDOWS 1
+EOF
+}
+
+    libs_system="$libs_system -lshell32 -lgdi32 -luser32" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lshell32 -lgdi32 -luser32\" to \$libs_system"; fi
+    if test "$window_system" != x11; then
+ 	window_system=msw
+	test "$with_scrollbars" != "no" && with_scrollbars=msw \
+	    && extra_objs="$extra_objs scrollbar-msw.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"scrollbar-msw.o\""
+ fi
+	test "$with_menubars"   != "no" && with_menubars=msw \
+	    && extra_objs="$extra_objs menubar-msw.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"menubar-msw.o\""
+ fi
+	with_dialogs=msw
+	with_toolbars=no
+    else
+	test "$with_scrollbars"   != "no" && extra_objs="$extra_objs scrollbar-msw.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"scrollbar-msw.o\""
+ fi
+	test "$with_menubars"   != "no" && extra_objs="$extra_objs menubar-msw.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"menubar-msw.o\""
+ fi
+    fi
+    const_is_losing=no
+    with_file_coding=yes
+    extra_objs="$extra_objs console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o\""
+ fi
+  fi
+fi
+
 test -z "$window_system" && window_system="none"
 
 if test "$window_system" = "none" ; then
@@ -5601,7 +5612,7 @@
 esac
 
 echo "checking for session-management option" 1>&6
-echo "configure:5605: checking for session-management option" >&5;
+echo "configure:5616: checking for session-management option" >&5;
 if test "$with_session" != "no"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SESSION
@@ -5616,15 +5627,15 @@
 test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
 test -z "$with_xauth" && { ac_safe=`echo "X11/Xauth.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xauth.h""... $ac_c" 1>&6
-echo "configure:5620: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5623 "configure"
+echo "configure:5631: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5634 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5639: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5647,12 +5658,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:5651: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:5662: checking for XauGetAuthByAddr in -lXau" >&5
 ac_lib_var=`echo Xau'_'XauGetAuthByAddr | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXau "
 cat > conftest.$ac_ext <<EOF
-#line 5656 "configure"
+#line 5667 "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
@@ -5663,7 +5674,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:5667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5727,15 +5738,15 @@
       for dir in "" "Tt/" "desktop/" ; do
     ac_safe=`echo "${dir}tt_c.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}tt_c.h""... $ac_c" 1>&6
-echo "configure:5731: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5734 "configure"
+echo "configure:5742: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5745 "configure"
 #include "confdefs.h"
 #include <${dir}tt_c.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5750: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5764,12 +5775,12 @@
 xe_msg_checking="for tt_message_create in -ltt"
 test -n "$extra_libs" && xe_msg_checking="$xe_msg_checking using extra libs $extra_libs"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:5768: checking "$xe_msg_checking"" >&5
+echo "configure:5779: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo tt'_'tt_message_create | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltt $extra_libs"
 cat > conftest.$ac_ext <<EOF
-#line 5773 "configure"
+#line 5784 "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
@@ -5780,7 +5791,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:5784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5829,15 +5840,15 @@
 
 test -z "$with_cde" && { ac_safe=`echo "Dt/Dt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Dt/Dt.h""... $ac_c" 1>&6
-echo "configure:5833: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5836 "configure"
+echo "configure:5844: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5847 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5841: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5852: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5860,12 +5871,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:5864: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:5875: checking for DtDndDragStart in -lDtSvc" >&5
 ac_lib_var=`echo DtSvc'_'DtDndDragStart | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lDtSvc "
 cat > conftest.$ac_ext <<EOF
-#line 5869 "configure"
+#line 5880 "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
@@ -5876,7 +5887,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:5880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5913,18 +5924,18 @@
 fi
 
 echo "checking for LDAP" 1>&6
-echo "configure:5917: checking for LDAP" >&5
+echo "configure:5928: checking for LDAP" >&5
 test -z "$with_ldap" && { ac_safe=`echo "ldap.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ldap.h""... $ac_c" 1>&6
-echo "configure:5920: checking for ldap.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5923 "configure"
+echo "configure:5931: checking for ldap.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5934 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5939: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5947,15 +5958,15 @@
  }
 test -z "$with_ldap" && { ac_safe=`echo "lber.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for lber.h""... $ac_c" 1>&6
-echo "configure:5951: checking for lber.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5954 "configure"
+echo "configure:5962: checking for lber.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5965 "configure"
 #include "confdefs.h"
 #include <lber.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5959: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5970: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5980,12 +5991,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber" && xe_msg_checking="$xe_msg_checking using extra libs -llber"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:5984: checking "$xe_msg_checking"" >&5
+echo "configure:5995: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber"
 cat > conftest.$ac_ext <<EOF
-#line 5989 "configure"
+#line 6000 "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
@@ -5996,7 +6007,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:6000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6019,12 +6030,12 @@
  }
 test \( -z "$with_ldap" -o "$with_ldap" = "yes" \) -a  "$with_umich_ldap" = "no" && { 
 echo $ac_n "checking for ldap_set_option in -lldap10""... $ac_c" 1>&6
-echo "configure:6023: checking for ldap_set_option in -lldap10" >&5
+echo "configure:6034: checking for ldap_set_option in -lldap10" >&5
 ac_lib_var=`echo ldap10'_'ldap_set_option | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap10 "
 cat > conftest.$ac_ext <<EOF
-#line 6028 "configure"
+#line 6039 "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
@@ -6035,7 +6046,7 @@
 ldap_set_option()
 ; return 0; }
 EOF
-if { (eval echo configure:6039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6119,13 +6130,13 @@
 if test "$with_x11" = "yes"; then
 
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:6123: checking for X11 graphics libraries" >&5
+echo "configure:6134: checking for X11 graphics libraries" >&5
 
     echo $ac_n "checking for Xpm - no older than 3.4f""... $ac_c" 1>&6
-echo "configure:6126: checking for Xpm - no older than 3.4f" >&5
+echo "configure:6137: checking for Xpm - no older than 3.4f" >&5
   xe_check_libs=-lXpm
   test -z "$with_xpm" && { cat > conftest.$ac_ext <<EOF
-#line 6129 "configure"
+#line 6140 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
   int main(int c, char **v) {
@@ -6135,7 +6146,7 @@
 		  0 ;
   }
 EOF
-if { (eval echo configure:6139: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:6150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ./conftest foobar; xpm_status=$?;
     if test "$xpm_status" = "0"; then with_xpm=yes; else with_xpm=no; fi;
@@ -6173,15 +6184,15 @@
 
     test -z "$with_xface" && { ac_safe=`echo "compface.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for compface.h""... $ac_c" 1>&6
-echo "configure:6177: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6180 "configure"
+echo "configure:6188: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6191 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6196: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6204,12 +6215,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:6208: checking for UnGenFace in -lcompface" >&5
+echo "configure:6219: checking for UnGenFace in -lcompface" >&5
 ac_lib_var=`echo compface'_'UnGenFace | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcompface "
 cat > conftest.$ac_ext <<EOF
-#line 6213 "configure"
+#line 6224 "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
@@ -6220,7 +6231,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:6224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6254,7 +6265,79 @@
     libs_x="-lcompface $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lcompface\" to \$libs_x"; fi
   fi
 
-    test -z "$with_gif" && with_gif=yes;
+    echo $ac_n "checking for giflib - no older than 3.1""... $ac_c" 1>&6
+echo "configure:6270: checking for giflib - no older than 3.1" >&5
+  test -z "$with_gif" && { ac_safe=`echo "gif_lib.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for gif_lib.h""... $ac_c" 1>&6
+echo "configure:6273: checking for gif_lib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6276 "configure"
+#include "confdefs.h"
+#include <gif_lib.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:6281: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+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*
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+with_gif=no
+fi
+ }
+  test -z "$with_gif" && { 
+echo $ac_n "checking for GetGifError in -lgif""... $ac_c" 1>&6
+echo "configure:6304: checking for GetGifError in -lgif" >&5
+ac_lib_var=`echo gif'_'GetGifError | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -lgif "
+cat > conftest.$ac_ext <<EOF
+#line 6309 "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 GetGifError();
+
+int main() {
+GetGifError()
+; return 0; }
+EOF
+if { (eval echo configure:6320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  : 
+else
+  echo "$ac_t""no" 1>&6
+with_gif=no
+fi
+
+ }
+  test -z "$with_gif" && with_gif=yes
   if test "$with_gif" = "yes"; then
     { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_GIF
@@ -6264,22 +6347,20 @@
 EOF
 }
 
-    extra_objs="$extra_objs dgif_lib.o gif_err.o gifalloc.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"dgif_lib.o gif_err.o gifalloc.o\""
- fi
+    libs_x="-lgif $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lgif\" to \$libs_x"; fi
   fi
 
     test -z "$with_jpeg" && { ac_safe=`echo "jpeglib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for jpeglib.h""... $ac_c" 1>&6
-echo "configure:6275: checking for jpeglib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6278 "configure"
+echo "configure:6356: checking for jpeglib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6359 "configure"
 #include "confdefs.h"
 #include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6364: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6302,12 +6383,12 @@
  }
   test -z "$with_jpeg" && { 
 echo $ac_n "checking for jpeg_destroy_decompress in -ljpeg""... $ac_c" 1>&6
-echo "configure:6306: checking for jpeg_destroy_decompress in -ljpeg" >&5
+echo "configure:6387: checking for jpeg_destroy_decompress in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'jpeg_destroy_decompress | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ljpeg "
 cat > conftest.$ac_ext <<EOF
-#line 6311 "configure"
+#line 6392 "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
@@ -6318,7 +6399,7 @@
 jpeg_destroy_decompress()
 ; return 0; }
 EOF
-if { (eval echo configure:6322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6403: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6354,15 +6435,15 @@
 
     test -z "$with_png" && { ac_safe=`echo "png.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for png.h""... $ac_c" 1>&6
-echo "configure:6358: checking for png.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6361 "configure"
+echo "configure:6439: checking for png.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6442 "configure"
 #include "confdefs.h"
 #include <png.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6447: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6384,10 +6465,10 @@
 fi
  }
   test -z "$with_png" && { echo $ac_n "checking for pow""... $ac_c" 1>&6
-echo "configure:6388: checking for pow" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6391 "configure"
+echo "configure:6469: checking for pow" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6472 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pow(); below.  */
@@ -6410,7 +6491,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6414: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_pow=yes"
 else
@@ -6435,12 +6516,12 @@
 xe_msg_checking="for png_read_image in -lpng"
 test -n "$extra_libs" && xe_msg_checking="$xe_msg_checking using extra libs $extra_libs"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6439: checking "$xe_msg_checking"" >&5
+echo "configure:6520: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo png'_'png_read_image | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpng $extra_libs"
 cat > conftest.$ac_ext <<EOF
-#line 6444 "configure"
+#line 6525 "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
@@ -6451,7 +6532,7 @@
 png_read_image()
 ; return 0; }
 EOF
-if { (eval echo configure:6455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6493,12 +6574,12 @@
 xe_msg_checking="for TIFFReadScanline in -ltiff"
 test -n "$extra_libs" && xe_msg_checking="$xe_msg_checking using extra libs $extra_libs"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6497: checking "$xe_msg_checking"" >&5
+echo "configure:6578: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo tiff'_'TIFFReadScanline | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltiff $extra_libs"
 cat > conftest.$ac_ext <<EOF
-#line 6502 "configure"
+#line 6583 "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
@@ -6509,7 +6590,7 @@
 TIFFReadScanline()
 ; return 0; }
 EOF
-if { (eval echo configure:6513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6547,12 +6628,12 @@
     
     
 echo $ac_n "checking for XawScrollbarSetThumb in -lXaw""... $ac_c" 1>&6
-echo "configure:6551: checking for XawScrollbarSetThumb in -lXaw" >&5
+echo "configure:6632: checking for XawScrollbarSetThumb in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'XawScrollbarSetThumb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXaw "
 cat > conftest.$ac_ext <<EOF
-#line 6556 "configure"
+#line 6637 "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
@@ -6563,7 +6644,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:6567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6587,15 +6668,15 @@
                     
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:6591: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6594 "configure"
+echo "configure:6672: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6675 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6599: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6612,12 +6693,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:6616: checking for XmStringFree in -lXm" >&5
+echo "configure:6697: checking for XmStringFree in -lXm" >&5
 ac_lib_var=`echo Xm'_'XmStringFree | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXm "
 cat > conftest.$ac_ext <<EOF
-#line 6621 "configure"
+#line 6702 "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
@@ -6628,7 +6709,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:6632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6919,7 +7000,7 @@
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:6923: checking for Mule-related features" >&5
+echo "configure:7004: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -6944,15 +7025,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6948: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6951 "configure"
+echo "configure:7029: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7032 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6956: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6983,12 +7064,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:6987: checking for strerror in -lintl" >&5
+echo "configure:7068: checking for strerror in -lintl" >&5
 ac_lib_var=`echo intl'_'strerror | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lintl "
 cat > conftest.$ac_ext <<EOF
-#line 6992 "configure"
+#line 7073 "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
@@ -6999,7 +7080,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:7003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7032,19 +7113,19 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:7036: checking for Mule input methods" >&5
+echo "configure:7117: checking for Mule input methods" >&5
       test -z "$with_xim" -a "$opsys" != "sol2" && with_xim=no
   case "$with_xim" in "" | "yes" )
     echo "checking for XIM" 1>&6
-echo "configure:7040: checking for XIM" >&5
+echo "configure:7121: checking for XIM" >&5
     
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:7043: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:7124: checking for XmImMbLookupString in -lXm" >&5
 ac_lib_var=`echo Xm'_'XmImMbLookupString | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXm "
 cat > conftest.$ac_ext <<EOF
-#line 7048 "configure"
+#line 7129 "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
@@ -7055,7 +7136,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:7059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7120,15 +7201,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:7124: checking for XFontSet" >&5
+echo "configure:7205: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:7127: checking for XmbDrawString in -lX11" >&5
+echo "configure:7208: checking for XmbDrawString in -lX11" >&5
 ac_lib_var=`echo X11'_'XmbDrawString | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 "
 cat > conftest.$ac_ext <<EOF
-#line 7132 "configure"
+#line 7213 "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
@@ -7139,7 +7220,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:7143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7179,15 +7260,15 @@
     test "$with_wnn6" = "yes" && with_wnn=yes # wnn6 implies wnn support
   test -z "$with_wnn" && { ac_safe=`echo "wnn/jllib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for wnn/jllib.h""... $ac_c" 1>&6
-echo "configure:7183: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7186 "configure"
+echo "configure:7264: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7267 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7212,10 +7293,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7216: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7219 "configure"
+echo "configure:7297: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7300 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7238,7 +7319,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7267,12 +7348,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:7271: checking for crypt in -lcrypt" >&5
+echo "configure:7352: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcrypt "
 cat > conftest.$ac_ext <<EOF
-#line 7276 "configure"
+#line 7357 "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
@@ -7283,7 +7364,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:7287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7317,12 +7398,12 @@
   fi
     test -z "$with_wnn" && { 
 echo $ac_n "checking for jl_dic_list_e in -lwnn""... $ac_c" 1>&6
-echo "configure:7321: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:7402: checking for jl_dic_list_e in -lwnn" >&5
 ac_lib_var=`echo wnn'_'jl_dic_list_e | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn "
 cat > conftest.$ac_ext <<EOF
-#line 7326 "configure"
+#line 7407 "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
@@ -7333,7 +7414,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:7337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7370,12 +7451,12 @@
  fi
     
 echo $ac_n "checking for jl_fi_dic_list in -lwnn""... $ac_c" 1>&6
-echo "configure:7374: checking for jl_fi_dic_list in -lwnn" >&5
+echo "configure:7455: checking for jl_fi_dic_list in -lwnn" >&5
 ac_lib_var=`echo wnn'_'jl_fi_dic_list | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn "
 cat > conftest.$ac_ext <<EOF
-#line 7379 "configure"
+#line 7460 "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
@@ -7386,7 +7467,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:7390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7418,15 +7499,15 @@
 
     test -z "$with_canna" && { ac_safe=`echo "canna/RK.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/RK.h""... $ac_c" 1>&6
-echo "configure:7422: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7425 "configure"
+echo "configure:7503: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7506 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7430: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7511: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7449,12 +7530,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:7453: checking for RkBgnBun in -lRKC" >&5
+echo "configure:7534: checking for RkBgnBun in -lRKC" >&5
 ac_lib_var=`echo RKC'_'RkBgnBun | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lRKC "
 cat > conftest.$ac_ext <<EOF
-#line 7458 "configure"
+#line 7539 "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
@@ -7465,7 +7546,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:7469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7488,12 +7569,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:7492: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:7573: checking for jrKanjiControl in -lcanna" >&5
 ac_lib_var=`echo canna'_'jrKanjiControl | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcanna "
 cat > conftest.$ac_ext <<EOF
-#line 7497 "configure"
+#line 7578 "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
@@ -7504,7 +7585,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:7508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7553,12 +7634,12 @@
   libs_x="-lXm $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lXm\" to \$libs_x"; fi
     
 echo $ac_n "checking for layout_object_getvalue in -li18n""... $ac_c" 1>&6
-echo "configure:7557: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:7638: checking for layout_object_getvalue in -li18n" >&5
 ac_lib_var=`echo i18n'_'layout_object_getvalue | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -li18n "
 cat > conftest.$ac_ext <<EOF
-#line 7562 "configure"
+#line 7643 "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
@@ -7569,7 +7650,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:7573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7639,13 +7720,13 @@
 
 fi
 
-for ac_func in cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask strcasecmp strerror tzset ulimit usleep utimes waitpid
+for ac_func in cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf strcasecmp strerror tzset ulimit usleep utimes waitpid vsnprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7646: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7649 "configure"
+echo "configure:7727: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7730 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7668,7 +7749,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7705,10 +7786,10 @@
     for ac_func in realpath
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7709: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7712 "configure"
+echo "configure:7790: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7793 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7731,7 +7812,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7764,16 +7845,16 @@
 esac
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:7768: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7770 "configure"
+echo "configure:7849: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7851 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:7777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -7793,16 +7874,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:7797: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7799 "configure"
+echo "configure:7878: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7880 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:7806: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7887: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -7822,11 +7903,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:7826: checking whether localtime caches TZ" >&5
+echo "configure:7907: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 7830 "configure"
+#line 7911 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -7861,7 +7942,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:7865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -7890,9 +7971,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday cannot accept two arguments""... $ac_c" 1>&6
-echo "configure:7894: checking whether gettimeofday cannot accept two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7896 "configure"
+echo "configure:7975: checking whether gettimeofday cannot accept two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7977 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -7914,7 +7995,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 else
@@ -7936,19 +8017,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:7940: checking for inline" >&5
+echo "configure:8021: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 7945 "configure"
+#line 8026 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:7952: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8033: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -7998,17 +8079,17 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:8002: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8005 "configure"
+echo "configure:8083: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8086 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:8012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -8032,10 +8113,10 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:8036: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8039 "configure"
+echo "configure:8117: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8120 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -8058,7 +8139,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:8062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -8097,10 +8178,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:8101: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8104 "configure"
+echo "configure:8182: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8185 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -8124,10 +8205,10 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8128: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8131 "configure"
+echo "configure:8209: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8212 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8150,7 +8231,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8180,10 +8261,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:8184: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8187 "configure"
+echo "configure:8265: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8268 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -8202,7 +8283,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:8206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -8230,15 +8311,15 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:8234: checking for vfork.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8237 "configure"
+echo "configure:8315: checking for vfork.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8318 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8242: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8266,10 +8347,10 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:8270: checking for working vfork" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8273 "configure"
+echo "configure:8351: checking for working vfork" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8354 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -8364,7 +8445,7 @@
   }
 }
 EOF
-if { (eval echo configure:8368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_vfork_works=yes
 else
@@ -8389,10 +8470,10 @@
 
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:8393: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8396 "configure"
+echo "configure:8474: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8477 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -8402,7 +8483,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:8406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -8429,10 +8510,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8433: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8436 "configure"
+echo "configure:8514: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8517 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8455,7 +8536,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8483,10 +8564,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:8487: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8490 "configure"
+echo "configure:8568: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8571 "configure"
 #include "confdefs.h"
 
 /*
@@ -8541,7 +8622,7 @@
 }
 
 EOF
-if { (eval echo configure:8545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -8567,10 +8648,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:8571: checking for working mmap" >&5
+echo "configure:8652: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 8574 "configure"
+#line 8655 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -8603,7 +8684,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:8607: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   have_mmap=yes
 else
@@ -8637,15 +8718,15 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:8641: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8644 "configure"
+echo "configure:8722: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8725 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8649: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8730: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8688,15 +8769,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "termio.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termio.h""... $ac_c" 1>&6
-echo "configure:8692: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8695 "configure"
+echo "configure:8773: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8776 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8700: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8728,10 +8809,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:8732: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8735 "configure"
+echo "configure:8813: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8816 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -8754,7 +8835,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -8769,15 +8850,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "netinet/in.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for netinet/in.h""... $ac_c" 1>&6
-echo "configure:8773: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8776 "configure"
+echo "configure:8854: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8857 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8862: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8794,15 +8875,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "arpa/inet.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for arpa/inet.h""... $ac_c" 1>&6
-echo "configure:8798: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8801 "configure"
+echo "configure:8879: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8882 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8806: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8887: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8827,9 +8908,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:8831: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:8912: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 8833 "configure"
+#line 8914 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -8840,7 +8921,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:8844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SOCKADDR_SUN_LEN
@@ -8858,9 +8939,9 @@
 fi
 rm -f conftest*
       echo $ac_n "checking "for ip_mreq struct in netinet/in.h"""... $ac_c" 1>&6
-echo "configure:8862: checking "for ip_mreq struct in netinet/in.h"" >&5
+echo "configure:8943: checking "for ip_mreq struct in netinet/in.h"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 8864 "configure"
+#line 8945 "configure"
 #include "confdefs.h"
 
 #include <netinet/in.h>
@@ -8869,7 +8950,7 @@
 static struct ip_mreq x;
 ; return 0; }
 EOF
-if { (eval echo configure:8873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_MULTICAST
@@ -8900,10 +8981,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:8904: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8907 "configure"
+echo "configure:8985: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8988 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -8926,7 +9007,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_msgget=yes"
 else
@@ -8941,15 +9022,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:8945: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8948 "configure"
+echo "configure:9026: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9029 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9034: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8966,15 +9047,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/msg.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/msg.h""... $ac_c" 1>&6
-echo "configure:8970: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8973 "configure"
+echo "configure:9051: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9054 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8978: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9012,15 +9093,15 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:9016: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9019 "configure"
+echo "configure:9097: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9100 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9047,15 +9128,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "sys/dir.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/dir.h""... $ac_c" 1>&6
-echo "configure:9051: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9054 "configure"
+echo "configure:9132: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9135 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9140: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9088,15 +9169,15 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:9092: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9095 "configure"
+echo "configure:9173: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9176 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9126,7 +9207,7 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:9130: checking "for sound support"" >&5
+echo "configure:9211: checking "for sound support"" >&5
 case "$with_sound" in
   native | both ) with_native_sound=yes;;
   nas    | no   ) with_native_sound=no;;
@@ -9137,15 +9218,15 @@
     if test -n "$native_sound_lib"; then
     ac_safe=`echo "multimedia/audio_device.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for multimedia/audio_device.h""... $ac_c" 1>&6
-echo "configure:9141: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9144 "configure"
+echo "configure:9222: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9225 "configure"
 #include "confdefs.h"
 #include <multimedia/audio_device.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9149: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9230: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9193,12 +9274,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:9197: checking for ALopenport in -laudio" >&5
+echo "configure:9278: checking for ALopenport in -laudio" >&5
 ac_lib_var=`echo audio'_'ALopenport | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -laudio "
 cat > conftest.$ac_ext <<EOF
-#line 9202 "configure"
+#line 9283 "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
@@ -9209,7 +9290,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:9213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9240,12 +9321,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:9244: checking for AOpenAudio in -lAlib" >&5
+echo "configure:9325: checking for AOpenAudio in -lAlib" >&5
 ac_lib_var=`echo Alib'_'AOpenAudio | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lAlib "
 cat > conftest.$ac_ext <<EOF
-#line 9249 "configure"
+#line 9330 "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
@@ -9256,7 +9337,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:9260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9294,15 +9375,15 @@
     for dir in "machine" "sys" "linux"; do
       ac_safe=`echo "${dir}/soundcard.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}/soundcard.h""... $ac_c" 1>&6
-echo "configure:9298: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9301 "configure"
+echo "configure:9379: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9382 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9387: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9372,7 +9453,7 @@
  fi
   libs_x="-laudio $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-laudio\" to \$libs_x"; fi
       cat > conftest.$ac_ext <<EOF
-#line 9376 "configure"
+#line 9457 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -9399,7 +9480,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:9403: checking for TTY-related features" >&5
+echo "configure:9484: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -9415,12 +9496,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:9419: checking for tgetent in -lncurses" >&5
+echo "configure:9500: checking for tgetent in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lncurses "
 cat > conftest.$ac_ext <<EOF
-#line 9424 "configure"
+#line 9505 "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
@@ -9431,7 +9512,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9464,15 +9545,15 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:9468: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9471 "configure"
+echo "configure:9549: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9552 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9476: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9557: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9494,15 +9575,15 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:9498: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9501 "configure"
+echo "configure:9579: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9582 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9506: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9587: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9532,15 +9613,15 @@
       c_switch_site="$c_switch_site -I/usr/include/ncurses"
       ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:9536: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9539 "configure"
+echo "configure:9617: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9620 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9544: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9625: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9575,12 +9656,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:9579: checking for tgetent in -l$lib" >&5
+echo "configure:9660: checking for tgetent in -l$lib" >&5
 ac_lib_var=`echo $lib'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$lib "
 cat > conftest.$ac_ext <<EOF
-#line 9584 "configure"
+#line 9665 "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
@@ -9591,7 +9672,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9622,12 +9703,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:9626: checking for tgetent in -lcurses" >&5
+echo "configure:9707: checking for tgetent in -lcurses" >&5
 ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcurses "
 cat > conftest.$ac_ext <<EOF
-#line 9631 "configure"
+#line 9712 "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
@@ -9638,7 +9719,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9656,12 +9737,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:9660: checking for tgetent in -ltermcap" >&5
+echo "configure:9741: checking for tgetent in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltermcap "
 cat > conftest.$ac_ext <<EOF
-#line 9665 "configure"
+#line 9746 "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
@@ -9672,7 +9753,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9720,15 +9801,15 @@
 
     test -z "$with_gpm" && { ac_safe=`echo "gpm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for gpm.h""... $ac_c" 1>&6
-echo "configure:9724: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9727 "configure"
+echo "configure:9805: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9808 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9751,12 +9832,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:9755: checking for Gpm_Open in -lgpm" >&5
+echo "configure:9836: checking for Gpm_Open in -lgpm" >&5
 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgpm "
 cat > conftest.$ac_ext <<EOF
-#line 9760 "configure"
+#line 9841 "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
@@ -9767,7 +9848,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:9771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9816,17 +9897,59 @@
 
 
 echo "checking for database support" 1>&6
-echo "configure:9820: checking for database support" >&5
+echo "configure:9901: checking for database support" >&5
 
 if test "$with_database_gnudbm" != "no"; then
-  
+  for ac_hdr in ndbm.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:9908: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9911 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:9916: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+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*
+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___%'`
+  { test "$extra_verbose" = "yes" && cat << EOF
+    Defining $ac_tr_hdr
+EOF
+cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+}
+ have_ndbm_h=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+  if test "$have_ndbm_h" = "yes"; then
+    
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:9825: checking for dbm_open in -lgdbm" >&5
+echo "configure:9948: checking for dbm_open in -lgdbm" >&5
 ac_lib_var=`echo gdbm'_'dbm_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgdbm "
 cat > conftest.$ac_ext <<EOF
-#line 9830 "configure"
+#line 9953 "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
@@ -9837,7 +9960,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9857,12 +9980,13 @@
 fi
 
 
+  fi
   if test "$with_database_gnudbm" != "yes"; then
     echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9863: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9866 "configure"
+echo "configure:9987: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9990 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9885,7 +10009,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9921,10 +10045,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9925: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9928 "configure"
+echo "configure:10049: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10052 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9947,7 +10071,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9968,12 +10092,12 @@
   if test "$need_libdbm" != "no"; then
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:9972: checking for dbm_open in -ldbm" >&5
+echo "configure:10096: checking for dbm_open in -ldbm" >&5
 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldbm "
 cat > conftest.$ac_ext <<EOF
-#line 9977 "configure"
+#line 10101 "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
@@ -9984,7 +10108,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10021,10 +10145,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:10025: checking for dbopen" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10028 "configure"
+echo "configure:10149: checking for dbopen" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10152 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbopen(); below.  */
@@ -10047,7 +10171,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10175: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbopen=yes"
 else
@@ -10068,12 +10192,12 @@
   if test "$need_libdb" != "no"; then
     
 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:10072: checking for dbopen in -ldb" >&5
+echo "configure:10196: checking for dbopen in -ldb" >&5
 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldb "
 cat > conftest.$ac_ext <<EOF
-#line 10077 "configure"
+#line 10201 "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
@@ -10084,7 +10208,7 @@
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:10088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10108,7 +10232,7 @@
   if test "$with_database_berkdb" = "yes"; then
     for path in "db/db.h" "db.h"; do
 cat > conftest.$ac_ext <<EOF
-#line 10112 "configure"
+#line 10236 "configure"
 #include "confdefs.h"
 #ifdef HAVE_INTTYPES_H
 #define __BIT_TYPES_DEFINED__
@@ -10126,7 +10250,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_path="$path"; break
 else
@@ -10178,12 +10302,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:10182: checking for SOCKSinit in -lsocks" >&5
+echo "configure:10306: checking for SOCKSinit in -lsocks" >&5
 ac_lib_var=`echo socks'_'SOCKSinit | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lsocks "
 cat > conftest.$ac_ext <<EOF
-#line 10187 "configure"
+#line 10311 "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
@@ -10194,7 +10318,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:10198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10247,17 +10371,19 @@
   LIBS="-Bstatic -lut -Bdynamic $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-Bstatic -lut -Bdynamic\" to \$LIBS"; fi
 fi
 
-test -z "$with_shlib" && { ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:10253: checking for dlfcn.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10256 "configure"
-#include "confdefs.h"
-#include <dlfcn.h>
+for ac_hdr in dlfcn.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:10379: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10382 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10261: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10387: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -10272,20 +10398,28 @@
 rm -f conftest*
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  :
-else
-  echo "$ac_t""no" 1>&6
-with_shlib=no
-fi
- }
-test -z "$with_shlib" && { 
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  { test "$extra_verbose" = "yes" && cat << EOF
+    Defining $ac_tr_hdr
+EOF
+cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+}
+ have_dlfcn=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:10284: checking for dlopen in -ldl" >&5
+echo "configure:10418: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldl "
 cat > conftest.$ac_ext <<EOF
-#line 10289 "configure"
+#line 10423 "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
@@ -10296,7 +10430,97 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:10300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_DLOPEN
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_DLOPEN 1
+EOF
+}
+ DLL_LIB=dl;  with_shlib=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+ }
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
+echo $ac_n "checking for _dlopen in -lc""... $ac_c" 1>&6
+echo "configure:10463: checking for _dlopen in -lc" >&5
+ac_lib_var=`echo c'_'_dlopen | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -lc "
+cat > conftest.$ac_ext <<EOF
+#line 10468 "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 _dlopen();
+
+int main() {
+_dlopen()
+; return 0; }
+EOF
+if { (eval echo configure:10479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_DLOPEN
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_DLOPEN 1
+EOF
+}
+ DLL_LIB=;   with_shlib=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+ }
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
+echo $ac_n "checking for dlopen in -lc""... $ac_c" 1>&6
+echo "configure:10508: checking for dlopen in -lc" >&5
+ac_lib_var=`echo c'_'dlopen | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -lc "
+cat > conftest.$ac_ext <<EOF
+#line 10513 "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 dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo configure:10524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10310,27 +10534,83 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
-  LIBS="-ldl $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-ldl\" to \$LIBS"; fi
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dlopen in -lc""... $ac_c" 1>&6
-echo "configure:10318: checking for dlopen in -lc" >&5
-ac_lib_var=`echo c'_'dlopen | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lc "
-cat > conftest.$ac_ext <<EOF
-#line 10323 "configure"
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_DLOPEN
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_DLOPEN 1
+EOF
+}
+ DLL_LIB=;   with_shlib=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+ }
+test -z "$with_shlib" && { 
+echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
+echo "configure:10553: checking for shl_load in -ldld" >&5
+ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -ldld "
+cat > conftest.$ac_ext <<EOF
+#line 10558 "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 dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo configure:10334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+char shl_load();
+
+int main() {
+shl_load()
+; return 0; }
+EOF
+if { (eval echo configure:10569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_SHL_LOAD
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_SHL_LOAD 1
+EOF
+}
+ DLL_LIB=dld; with_shlib=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+ }
+test -z "$with_shlib" && { 
+echo $ac_n "checking for dld_init in -ldld""... $ac_c" 1>&6
+echo "configure:10598: checking for dld_init in -ldld" >&5
+ac_lib_var=`echo dld'_'dld_init | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -ldld "
+cat > conftest.$ac_ext <<EOF
+#line 10603 "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 dld_init();
+
+int main() {
+dld_init()
+; return 0; }
+EOF
+if { (eval echo configure:10614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10344,17 +10624,19 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
-  with_shlib=yes
-else
-  echo "$ac_t""no" 1>&6
-with_shlib=no
-fi
-
-
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_DLD_INIT
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_DLD_INIT 1
+EOF
+}
+ DLL_LIB=dld; with_shlib=yes
+else
+  echo "$ac_t""no" 1>&6
 fi
 
  }
-test -z "$with_shlib" && with_shlib=yes
 if test "$with_shlib" = "yes"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SHLIB
@@ -10364,11 +10646,111 @@
 EOF
 }
 
-  extra_objs="$extra_objs dlopen.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"dlopen.o\""
+  extra_objs="$extra_objs sysdll.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"sysdll.o\""
+ fi
+  extra_objs="$extra_objs dll.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"dll.o\""
  fi
+  test ! -z "$DLL_LIB" && LIBS="-l${DLL_LIB} $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-l${DLL_LIB}\" to \$LIBS"; fi
+  
+dll_ld="ld"
+dll_lflags="-shared"
+dll_cflags="-r"
+dll_oflags="-o "
+
+echo $ac_n "checking how to build a shared library""... $ac_c" 1>&6
+echo "configure:10664: checking how to build a shared library" >&5
+case `uname -rs` in
+	UNIX_SV*|UNIX_System_V*)
+		dll_lflags="-G"
+		dll_cflags=-Kpic
+		dll_ld="ld"
+		;;
+	BSD/OS*)
+		dll_cflags=
+		dll_lflags="-r"
+		dll_ld="shlicc2"
+		;;
+	FreeBSD*2*)
+		dll_lflags="-Bshareable"
+		dll_cflags="-fPIC -DPIC"
+		dll_ld=ld
+		;;
+	SunOS*4.*)
+ 		dll_cflags="-P"
+		dll_lflags="-dp -assert pure-text -assert nodefinitions"
+		;;
+	SunOS*5.*)
+		dll_ld="cc"
+		dll_cflags="-KPIC"
+		dll_lflags="-G"
+		dll_oflags="-W0,-y-o -W0,-y"
+		;;	
+	IRIX*5.*|IRIX*6.*)
+		dll_cflags="-KPIC"
+		;;
+	OSF1*)
+		;;
+	HP-UX*)
+		dll_ld="ld"
+		dll_lflags="-b"
+		dll_cflags="+z"
+		;;
+	SCO_SV*)
+		dll_ld="ld"
+		dll_lflags="-G"
+		dll_cflags="-Kpic"
+		;;
+	AIX*)
+		dll_lflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:\${@:.ell=.exp} -b noentry -lc"
+		dll_ld="ld"
+		;;
+	*)
+		;;
+	esac
+
+	if test "$GCC" = "yes" ; then
+		dll_cflags="-fPIC"
+		case `uname -rs` in
+		SunOS*5.*)
+			dll_ld="ld"
+			dll_oflags="-o "
+			dll_lflags="-G"
+			;;
+		SCO_SV*)
+			dll_ld="ld"
+			dll_lflags="-G"
+			dll_cflags="-b elf"
+			;;
+		FreeBSD*)
+			dll_cflags="-DDLSYM_NEEDS_UNDERSCORE -DPIC -fPIC"
+			dll_lflags="-Bshareable"
+			dll_ld=ld
+			;;
+		BSD/OS*)
+			dll_cflags=
+			dll_lflags="-r"
+			dll_ld="shlicc2"
+			;;
+		UNIX_SV*)
+			dll_cflags="-fPIC"
+			;;
+		*)
+			dll_ld="$CC"
+			dll_lflags="-shared"
+		esac
+	fi
+
+	echo "$ac_t"""lflags: $dll_lflags cflags: $dll_cflags"" 1>&6
+
+
+
+
+
   ld_dynamic_link_flags=
     case "$opsys" in
+  hpux*)  ld_dynamic_link_flags="-E" ;;
   linux*) ld_dynamic_link_flags="-rdynamic" ;;
   *) ;;
   esac
@@ -10839,10 +11221,10 @@
   echo "  --------------------------------------------------------------------"
 fi
 test "$with_xface" = yes && echo "  Compiling in support for X-Face message headers."
-test "$with_gif"   = yes && echo "  Compiling in (built in) support for GIF image conversion."
+test "$with_gif"   = yes && echo "  Compiling in support for GIF image conversion."
 test "$with_jpeg"  = yes && echo "  Compiling in support for JPEG image conversion."
 test "$with_png"   = yes && echo "  Compiling in support for PNG image conversion."
-test "$with_tiff"  = yes && echo "  Compiling in support for TIFF image conversion (not implemented)."
+test "$with_tiff"  = yes && echo "  Compiling in support for TIFF image conversion."
 case "$with_sound" in
   nas    ) echo "  Compiling in network sound (NAS) support." ;;
   native ) echo "  Compiling in native sound support." ;;
@@ -10908,8 +11290,8 @@
 echo "  INFOPATH=\"$infopath\""
 test "$use_union_type"     = yes && echo "  Using the union type for Lisp_Objects."
 test "$with_minimal_tagbits" != "no" -o "$with_gung" != "no" && \
-		echo "Using Lisp_Objects with minimal tagbits."
-test "$with_gung" != "no" && echo "Using indexed lrecord implementation."
+		echo "  Using Lisp_Objects with minimal tagbits."
+test "$with_gung" != "no" && echo "  Using indexed lrecord implementation."
 test "$debug"              = yes && echo "  Compiling in extra code for debugging."
 test "$memory_usage_stats" = yes && echo "  Compiling in code for checking XEmacs memory usage."
 test "$usage_tracking"     = yes && echo "  Compiling with usage tracking active (Sun internal)."
@@ -11045,6 +11427,10 @@
 s%@OFFIX_O@%$OFFIX_O%g
 s%@lwlib_objs@%$lwlib_objs%g
 s%@ALLOCA@%$ALLOCA%g
+s%@dll_ld@%$dll_ld%g
+s%@dll_cflags@%$dll_cflags%g
+s%@dll_oflags@%$dll_oflags%g
+s%@dll_lflags@%$dll_lflags%g
 s%@SRC_SUBDIR_DEPS@%$SRC_SUBDIR_DEPS%g
 s%@INSTALL_ARCH_DEP_SUBDIR@%$INSTALL_ARCH_DEP_SUBDIR%g
 s%@MAKE_SUBDIR@%$MAKE_SUBDIR%g
--- a/configure.in	Mon Aug 13 10:24:47 2007 +0200
+++ b/configure.in	Mon Aug 13 10:25:37 2007 +0200
@@ -362,8 +362,6 @@
 dnl core file went\".  At least we should get some useful output ...
 use_assertions="yes"
 dnl the following is set to yes or no later.
-with_gif=""
-dnl the following is set to yes or no later.
 with_toolbars=""
 with_tty=""
 use_union_type="no"
@@ -546,7 +544,7 @@
 	    * ) USAGE_ERROR(["The \`--$optname' option requires one of these values:
   \`yes', \`no', or \`default'."]) ;;
 	  esac
-	  case "$opt" in use_* ) opt="`echo $opt | sed /use/with/`" ;; esac
+	  case "$opt" in use_* ) opt="`echo $opt | sed s/use/with/`" ;; esac
           eval "$opt=\"$val\""
         ;;
 
@@ -1457,12 +1455,6 @@
   XE_ADD_OBJS(filelock.o)
 fi
 
-dnl Autodetected below
-dnl if test "$with_shlib" = "yes"; then
-dnl   AC_DEFINE(HAVE_SHLIB)
-dnl   XE_ADD_OBJS(dlopen.o)
-dnl fi
-
 dnl Choose a compiler from (in order)
 dnl --compiler, env var CC, with_gcc=no && ${NON_GNU_CC:-cc}, AC_PROG_CC
 test -n "$compiler" && CC="$compiler"
@@ -1509,7 +1501,8 @@
 #endif
 ], have_glibc=yes, have_glibc=no)
 AC_MSG_RESULT($have_glibc)
-test "$have_glibc" = "yes" && AC_DEFINE(_GNU_SOURCE)
+dnl I'm tired of pop being broken with GLIBC -slb
+dnl test "$have_glibc" = "yes" && AC_DEFINE(_GNU_SOURCE)
 
 AC_MSG_CHECKING(whether we are using SunPro C)
 AC_TRY_COMPILE([],[#ifndef __SUNPRO_C
@@ -2155,30 +2148,6 @@
   no  ) window_system=none HAVE_X_WINDOWS=no  ;;
 esac
 
-if test "$with_msw" != "no"; then
-  AC_CHECKING(for MS-Windows)
-  AC_CHECK_LIB(gdi32,main,with_msw=yes)
-  if test "$with_msw" = "yes"; then
-    AC_DEFINE(HAVE_MS_WINDOWS)
-    XE_APPEND(-lshell32 -lgdi32 -luser32, libs_system)
-    if test "$window_system" != x11; then
- 	window_system=msw
-	test "$with_scrollbars" != "no" && with_scrollbars=msw \
-	    && XE_ADD_OBJS(scrollbar-msw.o)
-	test "$with_menubars"   != "no" && with_menubars=msw \
-	    && XE_ADD_OBJS(menubar-msw.o)
-	with_dialogs=msw
-	with_toolbars=no
-    else
-	test "$with_scrollbars"   != "no" && XE_ADD_OBJS(scrollbar-msw.o)
-	test "$with_menubars"   != "no" && XE_ADD_OBJS(menubar-msw.o)
-    fi
-    const_is_losing=no
-    with_file_coding=yes
-    XE_ADD_OBJS(console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o)
-  fi
-fi
-
 if test "$with_x11" = "yes"; then
   AC_DEFINE(HAVE_X_WINDOWS)
   XE_APPEND(lwlib, MAKE_SUBDIR)
@@ -2227,6 +2196,25 @@
     echo
   fi
 
+  dnl Set up bitmaps search path.
+  dnl The original suggestion was to unconditionally to append X11/bitmaps
+  dnl to each element of $x_includes, I'm pretty sure this is the wrong
+  dnl thing to do.  We test for bitmaps and X11/bitmaps directories on each
+  dnl element and add them to BITMAPDIR if they exist.
+  bitmapdirs=
+  if test "$x_includes" != NONE; then
+    for i in $x_includes; do
+      if test -d "$i/bitmaps"; then
+	bitmapdirs="$i/bitmaps:$bitmapdirs"
+      fi
+      if test -d "$i/X11/bitmaps"; then
+	bitmapdirs="$i/X11/bitmaps:$bitmapdirs"
+      fi
+    done
+    bitmapdirs=`echo "$bitmapdirs" | sed s/.$//`
+  fi
+  test ! -z "$bitmapdirs" && AC_DEFINE_UNQUOTED(BITMAPDIR, "$bitmapdirs")
+
   dnl Autodetect defines extracted from X config by xmkmf, e.g. NARROWPROTO
   AC_CHECKING(for X defines extracted by xmkmf)
   rm -fr conftestdir
@@ -2316,6 +2304,30 @@
 
 fi dnl $with_x11 = yes
 
+if test "$with_msw" != "no"; then
+  AC_CHECKING(for MS-Windows)
+  AC_CHECK_LIB(gdi32,main,with_msw=yes)
+  if test "$with_msw" = "yes"; then
+    AC_DEFINE(HAVE_MS_WINDOWS)
+    XE_APPEND(-lshell32 -lgdi32 -luser32, libs_system)
+    if test "$window_system" != x11; then
+ 	window_system=msw
+	test "$with_scrollbars" != "no" && with_scrollbars=msw \
+	    && XE_ADD_OBJS(scrollbar-msw.o)
+	test "$with_menubars"   != "no" && with_menubars=msw \
+	    && XE_ADD_OBJS(menubar-msw.o)
+	with_dialogs=msw
+	with_toolbars=no
+    else
+	test "$with_scrollbars"   != "no" && XE_ADD_OBJS(scrollbar-msw.o)
+	test "$with_menubars"   != "no" && XE_ADD_OBJS(menubar-msw.o)
+    fi
+    const_is_losing=no
+    with_file_coding=yes
+    XE_ADD_OBJS(console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o)
+  fi
+fi
+
 test -z "$window_system" && window_system="none"
 
 if test "$window_system" = "none" ; then
@@ -2489,11 +2501,14 @@
     XE_PREPEND(-lcompface, libs_x)
   fi
 
-  dnl Built-in GIF support defaults to yes (note: this will be libraried soon)
-  test -z "$with_gif" && with_gif=yes;
+  dnl Autodetect GIFlib
+  AC_MSG_CHECKING(for giflib - no older than 3.1)
+  test -z "$with_gif" && { AC_CHECK_HEADER(gif_lib.h,        ,with_gif=no) }
+  test -z "$with_gif" && { AC_CHECK_LIB(gif, GetGifError,[:] ,with_gif=no) }
+  test -z "$with_gif" && with_gif=yes
   if test "$with_gif" = "yes"; then
     AC_DEFINE(HAVE_GIF)
-    XE_ADD_OBJS(dgif_lib.o gif_err.o gifalloc.o)
+    XE_PREPEND(-lgif, libs_x)
   fi
 
   dnl autodetect JPEG
@@ -2746,7 +2761,7 @@
   XE_COMPUTE_RUNPATH()
 fi
 
-AC_CHECK_FUNCS(cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask strcasecmp strerror tzset ulimit usleep utimes waitpid)
+AC_CHECK_FUNCS(cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf strcasecmp strerror tzset ulimit usleep utimes waitpid vsnprintf)
 
 dnl realpath is buggy on linux, decosf and aix4
 
@@ -3157,7 +3172,10 @@
 AC_CHECKING(for database support)
 
 if test "$with_database_gnudbm" != "no"; then
-  AC_CHECK_LIB(gdbm, dbm_open, with_database_gnudbm=yes have_libgdbm=yes)
+  AC_CHECK_HEADERS(ndbm.h, have_ndbm_h=yes)
+  if test "$have_ndbm_h" = "yes"; then
+    AC_CHECK_LIB(gdbm, dbm_open, with_database_gnudbm=yes have_libgdbm=yes)
+  fi
   if test "$with_database_gnudbm" != "yes"; then
     AC_CHECK_FUNC(dbm_open, with_database_gnudbm=yes)
       fi
@@ -3231,16 +3249,22 @@
 fi
 
 dnl autodetect dll support
-test -z "$with_shlib" && { AC_CHECK_HEADER(dlfcn.h, ,with_shlib=no) }
-test -z "$with_shlib" && { AC_CHECK_LIB(dl, dlopen, XE_PREPEND(-ldl, LIBS),
-			   AC_CHECK_LIB(c, dlopen, with_shlib=yes, with_shlib=no)) }
-test -z "$with_shlib" && with_shlib=yes
+AC_CHECK_HEADERS(dlfcn.h, have_dlfcn=yes)
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { AC_CHECK_LIB(dl,  dlopen,   [ AC_DEFINE(HAVE_DLOPEN) DLL_LIB=dl;  with_shlib=yes]) }
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { AC_CHECK_LIB(c,   _dlopen,  [ AC_DEFINE(HAVE_DLOPEN) DLL_LIB=;   with_shlib=yes]) }
+test -z "$with_shlib" && test ! -z "$have_dlfcn" && { AC_CHECK_LIB(c,   dlopen,   [ AC_DEFINE(HAVE_DLOPEN) DLL_LIB=;   with_shlib=yes]) }
+test -z "$with_shlib" && { AC_CHECK_LIB(dld, shl_load, [ AC_DEFINE(HAVE_SHL_LOAD) DLL_LIB=dld; with_shlib=yes]) }
+test -z "$with_shlib" && { AC_CHECK_LIB(dld, dld_init, [ AC_DEFINE(HAVE_DLD_INIT) DLL_LIB=dld; with_shlib=yes]) }
 if test "$with_shlib" = "yes"; then
   AC_DEFINE(HAVE_SHLIB)
-  XE_ADD_OBJS(dlopen.o)
+  XE_ADD_OBJS(sysdll.o)
+  XE_ADD_OBJS(dll.o)
+  test ! -z "$DLL_LIB" && XE_PREPEND(-l${DLL_LIB}, LIBS)
+  XE_MAKE_SHAREDLIB
   ld_dynamic_link_flags=
   dnl Fill this in with other values as this gets more testing
   case "$opsys" in
+  hpux*)  ld_dynamic_link_flags="-E" ;;
   linux*) ld_dynamic_link_flags="-rdynamic" ;;
   *) ;;
   esac
@@ -3505,10 +3529,10 @@
   echo "  --------------------------------------------------------------------"
 fi
 test "$with_xface" = yes && echo "  Compiling in support for X-Face message headers."
-test "$with_gif"   = yes && echo "  Compiling in (built in) support for GIF image conversion."
+test "$with_gif"   = yes && echo "  Compiling in support for GIF image conversion."
 test "$with_jpeg"  = yes && echo "  Compiling in support for JPEG image conversion."
 test "$with_png"   = yes && echo "  Compiling in support for PNG image conversion."
-test "$with_tiff"  = yes && echo "  Compiling in support for TIFF image conversion (not implemented)."
+test "$with_tiff"  = yes && echo "  Compiling in support for TIFF image conversion."
 case "$with_sound" in
   nas    ) echo "  Compiling in network sound (NAS) support." ;;
   native ) echo "  Compiling in native sound support." ;;
@@ -3574,8 +3598,8 @@
 echo "  INFOPATH=\"$infopath\""
 test "$use_union_type"     = yes && echo "  Using the union type for Lisp_Objects."
 test "$with_minimal_tagbits" != "no" -o "$with_gung" != "no" && \
-		echo "Using Lisp_Objects with minimal tagbits."
-test "$with_gung" != "no" && echo "Using indexed lrecord implementation."
+		echo "  Using Lisp_Objects with minimal tagbits."
+test "$with_gung" != "no" && echo "  Using indexed lrecord implementation."
 test "$debug"              = yes && echo "  Compiling in extra code for debugging."
 test "$memory_usage_stats" = yes && echo "  Compiling in code for checking XEmacs memory usage."
 test "$usage_tracking"     = yes && echo "  Compiling with usage tracking active (Sun internal)."
--- a/configure.usage	Mon Aug 13 10:24:47 2007 +0200
+++ b/configure.usage	Mon Aug 13 10:25:37 2007 +0200
@@ -80,15 +80,17 @@
 --with-xface (*)	Compile with support for X-Face mail header
 	  		conversion.  Requires the compface library.
 			Get it from the XEmacs FTP site.
---with-gif		Compile with support for GIF image conversion.
-			This support is built-in and defaults to `yes'.
+--with-gif (*)		Compile with support for GIF image conversion.
+			Requires GifLib 3.1 or greater.  Get it from
+			the XEmacs FTP site.
 --with-jpeg (*)		Compile with support for JPEG image conversion.
 			Requires libjpeg from the Independent JPEG Group.
 			Get it from the XEmacs FTP site.
 --with-png (*)		Compile with support for PNG image conversion.
 			Requires libpng.  Get it from the XEmacs FTP site.
---with-tiff		Compile with support for TIFF image conversion
-			(not yet implemented).
+--with-tiff (*)		Compile with support for TIFF image conversion.
+			Requires Sam Lefflier's libtiff library.
+			Get if from the XEmacs FTP site.
 
 
 TTY options:
@@ -156,9 +158,7 @@
 			used in conjunction with Mule support).
 --with-wnn (*)		Compile with support for WNN (a multi-language input method
 			used in conjunction with Mule support).
-			This is beta level code.
---with-wnn6 (*)		Compile with support for WNN version 6
-			This is alpha level code.
+--with-wnn6 (*)		Compile with support for the comercial package WNN version 6
 --with-i18n3		Compile with I18N level 3 (support for message
 			translation).  This doesn't currently work.
 --with-xfs		Compile with XFontSet support for bilingual menubar.
--- a/etc/Emacs.ad	Mon Aug 13 10:24:47 2007 +0200
+++ b/etc/Emacs.ad	Mon Aug 13 10:25:37 2007 +0200
@@ -31,11 +31,11 @@
 ! `rgb.txt', usually found in /usr/lib/X11/ or /usr/openwin/lib/X11/.
 
 ! Set the modeline colors.
-!.modeline*attributeForeground:	Black
-!.modeline*attributeBackground:	Gray75
+!Emacs.modeline*attributeForeground:	Black
+!Emacs.modeline*attributeBackground:	Gray75
 
 ! Set the color of the text cursor.
-.text-cursor*attributeBackground:	Red3
+!Emacs.text-cursor*attributeBackground:	Red3
 
 ! If you want to set the color of the mouse pointer, do this:
 ! Emacs.pointer*attributeForeground:	Black
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/README.HYPERBOLE	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,6 @@
+Hyperbole is a suite of tools for enhancing productivity.
+
+The latest working version of this package with major enhancements
+is available together with professional support exclusively from their
+developer, Altrasoft Inc.  See http://www.altrasoft.com for product
+and service details.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/README.OO-BROWSER	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,6 @@
+The OO-Browser is a tool for examining object oriented code.
+
+The latest working version of this package with major enhancements
+is available together with professional support exclusively from their
+developer, Altrasoft Inc.  See http://www.altrasoft.com for product
+and service details.
--- a/lib-src/config.values.in	Mon Aug 13 10:24:47 2007 +0200
+++ b/lib-src/config.values.in	Mon Aug 13 10:25:37 2007 +0200
@@ -53,6 +53,10 @@
 configuration "@configuration@"
 configure_input "@configure_input@"
 datadir "@datadir@"
+dll_cflags "@dll_cflags@"
+dll_ld "@dll_ld@"
+dll_lflags "@dll_lflags@"
+dll_oflags "@dll_oflags@"
 docdir "@docdir@"
 dynodump_arch "@dynodump_arch@"
 etcdir "@etcdir@"
--- a/lisp/ChangeLog	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/ChangeLog	Mon Aug 13 10:25:37 2007 +0200
@@ -1,3 +1,91 @@
+1998-03-16  SL Baur  <steve@altair.xemacs.org>
+
+	* files.el (cdpath-previous): New variable.
+	(cd): Use it.
+	From Bob Weiner <weiner@wave.altrasoft.com>
+
+1998-03-14  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* winnt.el: Removed "%t" from the beginning of
+	modeline-format. From now on, there's no nt-specifics in the modeline.
+
+1998-03-14  SL Baur  <steve@altair.xemacs.org>
+
+	* setup-paths.el (paths-setup-paths-warning): Replace occurrences
+	of `when' with `if'.
+
+1998-03-03  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* msw-glyphs.el: New file. Defines TTY-style glyphs for
+	mswindows. Must be reworked along with glyphs.el, or 
+	merged into it, after there is images support.
+
+	* dumped-lisp.el (preloaded-file-list): Dump msw-glyphs.el when
+	'mswindows. 
+
+1998-03-13  SL Baur  <steve@altair.xemacs.org>
+
+	* faces.el: fix for text cursor initialization.
+	Suggested by Kyle Jones <kyle_jones@wonderworks.com>
+	From Andy Piper <andyp@parallax.co.uk>
+
+1998-03-11  Pete Ware  <ware@cis.ohio-state.edu>
+
+	* files.el (set-auto-mode): If a mode is not fboundp, check to see 
+	if there is an existing package that handles it and warn the user
+	about that mode.
+
+1998-03-02  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* x-menubar.el (default-menubar): Greyed out "Help / Basics /
+	Installation" menu item when Installation-string is not bound.
+
+1998-03-11  SL Baur  <steve@altair.xemacs.org>
+
+	* lisp.el (forward-sexp): Fix for test for balanced sexp.
+	From Jeremiah W. James <jerry@cs.ucsb.edu>
+
+1998-03-10  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* msw-faces.el:
+	* faces.el: Fix face initialization.
+
+1998-03-10  Glynn Clements  <glynn@sensei.co.uk>
+
+	* files.el (backup-enable-predicate): fix breakage introduced 
+	by TMPDIR patch.
+
+1998-03-09  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* x-faces.el (x-init-face-from-resources): The
+	  TTY face property retrieval functions don't return
+	  specifiers, so use face-property instead.
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* mwheel.el (mwheel-install): Use portable keysyms and syntax.
+
+1998-03-09  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* x-menubar.el: Expanded documentation for
+	  option-save-faces.  Changed Options -> Browse Faces
+	  menu entry to invoke customize-face.
+
+1998-03-09  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* faces.el: Most face initialization moved out of
+	  init-other-random-faces to the top level so that the
+	  initialization happens before Xemacs is dumped.  Much
+	  of the fascist "face-differs-from-default-p or FROB!"
+	  code has been retired in favor of letting the user do
+	  what they want to do.  Face initialization code changed
+	  to use `default' specifier tag so that the settings can
+	  be overridden later if the user wishes it.
+
+1998-03-08  SL Baur  <steve@altair.xemacs.org>
+
+	* about.el (about-hackers): Update contributors list.
+
 1998-03-07  Kyle Jones  <kyle_jones@wonderworks.com>
 
 	* specifier.el: Define new specifier tag `default'.
--- a/lisp/about.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/about.el	Mon Aug 13 10:25:37 2007 +0200
@@ -1249,6 +1249,7 @@
        (print-short "Tor Arntsen" "tor@spacetec.no")
        (print-short "Marc Aurel" "4-tea-2@bong.saar.de")
        (print-short "Larry Auton" "lda@control.att.com")
+       (print-short "Larry Ayers" "layers@marktwain.net")
        (print-short "Oswald P. Backus IV" "backus@altagroup.com")
        (print-short "Mike Battaglia" "mbattagl@dsccc.com")
        (print-short "Neal Becker" "neal@ctd.comsat.com")
@@ -1324,8 +1325,10 @@
        (print-short "Benedikt Heinen" "beh@icemark.thenet.ch")
        (print-short "Stephan Herrmann" "sh@first.gmd.de")
        (print-short "August Hill" "awhill@inlink.com")
+       (print-short "Mike Hill" "mikehill@hgeng.com")
        (print-short "Charles Hines" "chuck_hines@VNET.IBM.COM")
        (print-short "Shane Holder" "holder@rsn.hp.com")
+       (print-short "Tetsuya HOYANO" "hoyano@ari.bekkoame.or.jp")
        (print-short "David Hughes" "djh@harston.cv.com")
        (print-short "Tatsuya Ichikawa" "ichikawa@hv.epson.co.jp")
        (print-short "Andrew Innes" "andrewi@harlequin.co.uk")
@@ -1377,6 +1380,7 @@
        (print-short "Michael McNamara" "mac@silicon-sorcery.com")
        (print-short "Michael Meissner" "meissner@osf.org")
        (print-short "David M. Meyer" "meyer@ns.uoregon.edu")
+       (print-short "John Mignault" "jbm@panix.com")
        (print-short "Brad Miller" "bmiller@cs.umn.edu")
        (print-short "Jeff Miller" "jmiller@smart.net")
        (print-short "John Morey" "jmorey@crl.com")
@@ -1391,6 +1395,7 @@
        (print-short "Joe Nuspl" "nuspl@sequent.com")
        (print-short "Kim Nyberg" "kny@tekla.fi")
        (print-short "David Ofelt" "ofelt@getalife.Stanford.EDU")
+       (print-short "Darryl Okahata" "darrylo@mina.sr.hp.com")
        (print-short "Alexandre Oliva" "oliva@dcc.unicamp.br")
        (print-short "Tore Olsen" "toreo@colargol.idb.hist.no")
        (print-short "Greg Onufer" "Greg.Onufer@eng.sun.com")
@@ -1412,9 +1417,11 @@
        (print-short "Russell Ritchie" "ritchier@britannia-life.co.uk")
        (print-short "Roland" "rol@darmstadt.gmd.de")
        (print-short "Mike Russell" "mjruss@rchland.vnet.ibm.com")
+       (print-short "Hajime Saitou" "hajime@jsk.t.u-tokyo.ac.jp")
        (print-short "Jan Sandquist" "etxquist@iqa.ericsson.se")
        (print-short "Marty Sasaki" "sasaki@spdcc.com")
        (print-short "SATO Daisuke" "densuke@ga2.so-net.or.jp")
+       (print-short "Kenji Sato" "ken@ny.kdd.com")
        (print-short "Mike Scheidler" "c23mts@eng.delcoelect.com")
        (print-short "Daniel Schepler" "daniel@shep13.wustl.edu")
        (print-short "Darrel Schneider" "darrel@slc.com")
@@ -1435,9 +1442,11 @@
        (print-short "Rick Tait" "rickt@gnu.ai.mit.edu")
        (print-short "Samuel Tardieu" "sam@inf.enst.fr")
        (print-short "James Thompson" "thompson@wg2.waii.com")
+       (print-short "Nobu Toge" "toge@accad1.kek.jp")
        (print-short "Raymond L. Toy" "toy@rtp.ericsson.se")
        (print-short "Remek Trzaska" "remek@npac.syr.edu")
        (print-short "TSUTOMU Nakamura" "tsutomu@rs.kyoto.omronsoft.co.jp")
+       (print-short "Stefanie Teufel" "s.teufel@ndh.net")
        (print-short "Stephen Turnbull" "turnbull@sk.tsukuba.ac.jp")
        (print-short "John Turner" "turner@xdiv.lanl.gov")
        (print-short "UENO Fumihiro" "7m2vej@ritp.ye.IHI.CO.JP")
--- a/lisp/auto-autoloads.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/auto-autoloads.el	Mon Aug 13 10:25:37 2007 +0200
@@ -1161,6 +1161,13 @@
 
 ;;;***
 
+;;;### (autoloads (mwheel-install) "mwheel" "lisp/mwheel.el")
+
+(autoload 'mwheel-install "mwheel" "\
+Enable mouse wheel support." nil nil)
+
+;;;***
+
 ;;;### (autoloads (package-admin-add-binary-package package-admin-add-single-file-package) "package-admin" "lisp/package-admin.el")
 
 (autoload 'package-admin-add-single-file-package "package-admin" "\
--- a/lisp/dumped-lisp.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/dumped-lisp.el	Mon Aug 13 10:25:37 2007 +0200
@@ -1,6 +1,7 @@
 (setq preloaded-file-list
       '("backquote" 		; needed for defsubst etc.
 	"bytecomp-runtime"	; define defsubst
+	;; "setup-paths" ; We're not ready for this
 	"packages"		; Bootstrap run-time lisp environment
 	"subr" 			; load the most basic Lisp functions
 	"replace" 		; match-string used in version.el.
@@ -170,6 +171,7 @@
 	#+x "x-win-xfree86"
 	#+x "x-win-sun"
 ;; preload the mswindows code.
+	#+mswindows "msw-glyphs"
 	#+mswindows "msw-faces"
 	#+mswindows "msw-init"
 	#+mswindows "msw-select"
--- a/lisp/faces.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/faces.el	Mon Aug 13 10:25:37 2007 +0200
@@ -1384,9 +1384,7 @@
   (loop for face in (face-list) do
 	(init-face-from-resources face 'global))
   ;; Further X frobbing.
-  (case window-system
-    (x (x-init-global-faces))
-    (mswindows (mswindows-init-global-faces)))
+  (x-init-global-faces)
   ;; for bold and the like, make the global specification be bold etc.
   ;; if the user didn't already specify a value.  These will also be
   ;; frobbed further in init-other-random-faces.
@@ -1518,101 +1516,6 @@
 	     (face-property-equal 'text-cursor 'default 'foreground device))
     (set-face-foreground 'text-cursor [default background] 'global
 			 nil 'append))
-
-  ;; Set the secondary-selection color unless already specified.
-  (unless (or (face-differs-from-default-p 'highlight device)
-	      (face-background 'highlight 'global))
-    ;; some older servers don't recognize "darkseagreen2"
-    (set-face-background 'highlight
-			 '((color . "darkseagreen2")
-			   (color . "green"))
-			 'global nil 'append)
-    (set-face-background 'highlight "gray53" 'global 'grayscale 'append))
-  (unless (or (face-differs-from-default-p 'highlight device)
-	      (face-background-pixmap 'highlight 'global))
-    (set-face-background-pixmap 'highlight [nothing] 'global 'color 'append)
-    (set-face-background-pixmap 'highlight [nothing] 'global 'grayscale 'append)
-    (set-face-background-pixmap 'highlight "gray1" 'global 'mono 'append))
-  ;; if the highlight face isn't distinguished on this device,
-  ;; at least try inverting it.
-  (unless (face-differs-from-default-p 'highlight device)
-    (invert-face 'highlight device))
-
-  ;; first time through, set the zmacs-region color if it's not already
-  ;; specified.
-  (unless (or (face-differs-from-default-p 'zmacs-region device)
-	      (face-background 'zmacs-region 'global))
-    (set-face-background 'zmacs-region "gray65" 'global 'color)
-    (set-face-background 'zmacs-region "gray65" 'global 'grayscale))
-  (unless (or (face-differs-from-default-p 'zmacs-region device)
-	      (face-background-pixmap 'zmacs-region 'global))
-    (set-face-background-pixmap 'zmacs-region [nothing] 'global 'color)
-    (set-face-background-pixmap 'zmacs-region [nothing] 'global 'grayscale)
-    (set-face-background-pixmap 'zmacs-region "gray3" 'global 'mono))
-  ;; if the zmacs-region face isn't distinguished on this device,
-  ;; at least try inverting it.
-  (unless (face-differs-from-default-p 'zmacs-region device)
-    (invert-face 'zmacs-region device))
-
-  ;; first time through, set the list-mode-item-selected color if it's
-  ;; not already specified.
-  (unless (or (face-differs-from-default-p 'list-mode-item-selected device)
-	      (face-background 'list-mode-item-selected 'global))
-    (set-face-background 'list-mode-item-selected "gray68" 'global 'color)
-    (set-face-background 'list-mode-item-selected "gray68" 'global 'grayscale)
-    (unless (face-foreground 'list-mode-item-selected 'global)
-	    (set-face-background 'list-mode-item-selected
-				 [default foreground] 'global '(mono x))
-	    (set-face-foreground 'list-mode-item-selected
-				 [default background] 'global '(mono x))))
-
-  ;; if the list-mode-item-selected face isn't distinguished on this device,
-  ;; at least try inverting it.
-  (unless (face-differs-from-default-p 'list-mode-item-selected device)
-    (invert-face 'list-mode-item-selected device))
-
-  ;; Set the primary-selection color unless already specified.
-  (unless (or (face-differs-from-default-p 'primary-selection device)
-	      (face-background 'primary-selection 'global))
-    (set-face-background 'primary-selection "gray65" 'global 'color)
-    (set-face-background 'primary-selection "gray65" 'global 'grayscale))
-  (unless (or (face-differs-from-default-p 'secondary-selection device)
-	      (face-background-pixmap 'primary-selection 'global))
-    (set-face-background-pixmap 'primary-selection "gray3" 'global 'mono))
-  ;; If the primary-selection face isn't distinguished on this device,
-  ;; at least try inverting it.
-  (unless (face-differs-from-default-p 'primary-selection device)
-    (invert-face 'primary-selection device))
-
-  ;; Set the secondary-selection color unless already specified.
-  (unless (or (face-differs-from-default-p 'secondary-selection device)
-	      (face-background 'secondary-selection 'global))
-    (set-face-background 'secondary-selection
-			 '((color . "paleturquoise")
-			   (color . "green"))
-			 'global)
-    (set-face-background 'secondary-selection "gray53" 'global
-			 'grayscale))
-  (unless (or (face-differs-from-default-p 'secondary-selection device)
-	      (face-background-pixmap 'secondary-selection 'global))
-    (set-face-background-pixmap 'secondary-selection "gray1" 'global 'mono))
-  ;; If the secondary-selection face isn't distinguished on this device,
-  ;; at least try inverting it.
-  (unless (face-differs-from-default-p 'secondary-selection device)
-    (invert-face 'secondary-selection device))
-
-  ;; Set the isearch color if unless already specified.
-  (unless (or (face-differs-from-default-p 'isearch device)
-	      (face-background 'isearch 'global))
-    ;; TTY's and some older X servers don't recognize "paleturquoise"
-    (set-face-background 'isearch
-			 '((color . "paleturquoise")
-			   (color . "green"))
-			 'global))
-  ;; if the isearch face isn't distinguished (e.g. we're not on a color
-  ;; display), at least try making it bold.
-  (unless (face-differs-from-default-p 'isearch device)
-    (set-face-font 'isearch [bold]))
   )
 
 ;; New function with 20.1, suggested by Per Abrahamsen, coded by Kyle Jones.
@@ -1660,7 +1563,7 @@
 (make-face 'bold-italic "Bold-italic text.")
 (make-face 'underline "Underlined text.")
 (or (face-differs-from-default-p 'underline)
-    (set-face-underline-p 'underline t 'global))
+    (set-face-underline-p 'underline t 'global '(default)))
 (make-face 'zmacs-region "Used on highlightes region between point and mark.")
 (make-face 'isearch "Used on region matched by isearch.")
 (make-face 'list-mode-item-selected
@@ -1676,24 +1579,64 @@
   (set-face-foreground color (symbol-name color) nil 'color))
 
 ;; Make some useful faces.  This happens very early, before creating
-;; the first non-stream device.  We initialize the tty global values here.
-;; We cannot initialize the X global values here because they depend
-;; on having already resourced the global face specs, which happens
-;; when the first X device is created.
+;; the first non-stream device.
+
+(set-face-background 'text-cursor
+		     '(((default x) . "Red3")
+		       ((default mswindows) . "Red3"))
+		     'global)
+
+;; some older servers don't recognize "darkseagreen2"
+(set-face-background 'highlight
+		     '(((default color) . "darkseagreen2")
+		       ((default color) . "green")
+		       ((default grayscale) . "gray53"))
+		     'global)
+(set-face-background-pixmap 'highlight "gray1" 'global '(default mono))
+
+(set-face-background 'zmacs-region "gray65" 'global '(default color))
+(set-face-background 'zmacs-region "gray65" 'global '(default grayscale))
+(set-face-background-pixmap 'zmacs-region "gray3" 'global '(default mono))
+
+(set-face-background 'list-mode-item-selected "gray68" 'global
+		     '(default color))
+(set-face-background 'list-mode-item-selected "gray68" 'global
+		     '(default grayscale))
+(set-face-background 'list-mode-item-selected
+		     [default foreground] 'global '(default mono))
+(set-face-foreground 'list-mode-item-selected
+		     [default background] 'global '(default mono))
+
+(set-face-background 'primary-selection "gray65" 'global '(default color))
+(set-face-background 'primary-selection "gray65" 'global '(default grayscale))
+(set-face-background-pixmap 'primary-selection "gray3" 'global '(default mono))
+
+(set-face-background 'secondary-selection
+		     '(((default color) . "paleturquoise")
+		       ((default color) . "green")
+		       ((default grayscale) . "gray53"))
+		     'global)
+(set-face-background-pixmap 'secondary-selection "gray1" 'global
+			    '(default mono))
+
+(set-face-background 'isearch
+		     '(((default color) . "paleturquoise")
+		       ((default color) . "green"))
+		     'global)
 
 (when (featurep 'tty)
-  (set-face-highlight-p 'bold                    t 'global 'tty)
-  (set-face-underline-p 'italic                  t 'global 'tty)
-  (set-face-highlight-p 'bold-italic             t 'global 'tty)
-  (set-face-underline-p 'bold-italic             t 'global 'tty)
-  (set-face-highlight-p 'highlight               t 'global 'tty)
-  (set-face-reverse-p   'text-cursor             t 'global 'tty)
-  (set-face-reverse-p   'modeline                t 'global 'tty)
-  (set-face-reverse-p   'zmacs-region            t 'global 'tty)
-  (set-face-reverse-p   'primary-selection       t 'global 'tty)
-  (set-face-underline-p 'secondary-selection     t 'global 'tty)
-  (set-face-reverse-p   'list-mode-item-selected t 'global 'tty)
-  (set-face-reverse-p   'isearch                 t 'global 'tty)
+  (set-face-highlight-p 'bold                    t 'global '(default tty))
+  (set-face-underline-p 'italic                  t 'global '(default tty))
+  (set-face-highlight-p 'bold-italic             t 'global '(default tty))
+  (set-face-underline-p 'bold-italic             t 'global '(default tty))
+  (set-face-highlight-p 'highlight               t 'global '(default tty))
+  (set-face-reverse-p   'text-cursor             t 'global '(default tty))
+  (set-face-reverse-p   'modeline                t 'global '(default tty))
+  (set-face-reverse-p   'zmacs-region            t 'global '(default tty))
+  (set-face-reverse-p   'primary-selection       t 'global '(default tty))
+  (set-face-underline-p 'secondary-selection     t 'global '(default tty))
+  (set-face-reverse-p   'list-mode-item-selected t 'global '(default tty))
+  (set-face-reverse-p   'isearch                 t 'global '(default tty))
   )
 
 ;;; faces.el ends here
--- a/lisp/files.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/files.el	Mon Aug 13 10:25:37 2007 +0200
@@ -130,11 +130,11 @@
 
 (defvar backup-enable-predicate
   '(lambda (name)
-     (not (or (string-equal "/tmp/" (substring name 0 5))
+     (not (or (string-match "^/tmp/" name)
 	      (let ((tmpdir (temp-directory)))
 		(and tmpdir
-		     (string-equal (concat tmpdir "/")
-				   (substring name 0 (1+ (length tmpdir)))))))))
+		     (string-match (concat "^" (regexp-quote tmpdir) "/")
+				   tmpdir))))))
   "Predicate that looks at a file name and decides whether to make backups.
 Called with an absolute file name as argument, it returns t to enable backup.")
 
@@ -386,24 +386,28 @@
   "Value of the CDPATH environment variable, as a list.
 Not actually set up until the first time you use it.")
 
+(defvar cdpath-previous nil
+  "Prior value of the CDPATH environment variable.")
+
 (defvar path-separator ":"
   "Character used to separate concatenated paths.")
 
-(defun parse-colon-path (cd-path)
-  "Explode a colon-separated list of paths into a string list."
-  (and cd-path
-       (let (cd-list (cd-start 0) cd-colon)
-	 (setq cd-path (concat cd-path path-separator))
-	 (while (setq cd-colon (string-match path-separator cd-path cd-start))
-	   (setq cd-list
-		 (nconc cd-list
-			(list (if (= cd-start cd-colon)
-				   nil
-				(substitute-in-file-name
-				 (file-name-as-directory
-				  (substring cd-path cd-start cd-colon)))))))
-	   (setq cd-start (+ cd-colon 1)))
-	 cd-list)))
+;; Merged with equivalent C Code.
+;(defun parse-colon-path (cd-path)
+;  "Explode a colon-separated list of paths into a string list."
+;  (and cd-path
+;       (let (cd-list (cd-start 0) cd-colon)
+;	 (setq cd-path (concat cd-path path-separator))
+;	 (while (setq cd-colon (string-match path-separator cd-path cd-start))
+;	   (setq cd-list
+;		 (nconc cd-list
+;			(list (if (= cd-start cd-colon)
+;				   nil
+;				(substitute-in-file-name
+;				 (file-name-as-directory
+;				  (substring cd-path cd-start cd-colon)))))))
+;	   (setq cd-start (+ cd-colon 1)))
+;	 cd-list)))
 
 (defun cd-absolute (dir)
   "Change current directory to given absolute file name DIR."
@@ -436,10 +440,11 @@
   (if (file-name-absolute-p dir)
       (cd-absolute (expand-file-name dir))
     ;; XEmacs
-    (if (null cd-path)
-	;;#### Unix-specific
-	(let ((trypath (parse-colon-path (getenv "CDPATH"))))
-	  (setq cd-path (or trypath (list "./")))))
+    (unless (and cd-path (equal (getenv "CDPATH") cdpath-previous))
+      ;;#### Unix-specific
+      (let ((trypath (parse-colon-path
+		      (setq cdpath-previous (getenv "CDPATH")))))
+	(setq cd-path (or trypath (list "./")))))
     (or (catch 'found
 	  (mapcar #'(lambda (x)
 		        (let ((f (expand-file-name (concat x dir))))
@@ -1382,7 +1387,19 @@
                             (setq alist nil))
                         (setq alist (cdr alist))))))
               (if mode
-                  (funcall mode))
+		  (if (not (fboundp mode))
+		      (progn
+			(if (or (not (boundp 'package-get-base))
+				(not package-get-base))
+			    (load "package-get-base"))
+			(require 'package-get)
+			(let ((name (package-get-package-provider mode)))
+			  (if name
+			      (message "Mode %s is not installed.  Download package %s" mode name)
+			    (message "Mode %s either doesn't exist or is not a known package" mode))
+			  (sit-for 2)
+			  (error "%s" mode)))
+		    (funcall mode)))
               ))))))
 
 (defvar hack-local-variables-hook nil
--- a/lisp/keydefs.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/keydefs.el	Mon Aug 13 10:25:37 2007 +0200
@@ -102,9 +102,9 @@
 (define-key global-map " " 'self-insert-command)
 
 (define-key global-map "\C-a" 'beginning-of-line)
-(define-key global-map "\C-b" 'backward-char)
+(define-key global-map "\C-b" 'backward-char-command)
 (define-key global-map "\C-e" 'end-of-line)
-(define-key global-map "\C-f" 'forward-char)
+(define-key global-map "\C-f" 'forward-char-command)
 (define-key global-map "\C-d" 'delete-char)
 (define-key global-map 'delete 'backward-or-forward-delete-char)
 (define-key global-map '(meta delete) 'backward-or-forward-kill-word)
@@ -421,8 +421,8 @@
 (define-key global-map "\C-x<" 'scroll-left)
 (define-key global-map "\C-x>" 'scroll-right)
 
-(define-key global-map "\C-v" 'scroll-up)
-(define-key global-map "\M-v" 'scroll-down)
+(define-key global-map "\C-v" 'scroll-up-command)
+(define-key global-map "\M-v" 'scroll-down-command)
 (define-key global-map "\M-\C-v" 'scroll-other-window)
 ; meta-shift-V, that is.
 (define-key global-map '(meta V) 'scroll-other-window-down)
@@ -507,14 +507,14 @@
 ;; files, but these appear to be the standard Motif and PC bindings.
 
 ;; movement by units
-(define-key global-map 'left		'backward-char)
+(define-key global-map 'left		'backward-char-command)
 (define-key global-map 'up		'previous-line)
-(define-key global-map 'right		'forward-char)
+(define-key global-map 'right		'forward-char-command)
 (define-key global-map 'down		'next-line)
 
 ;; movement by pages
-(define-key global-map 'prior		'scroll-down)
-(define-key global-map 'next		'scroll-up)
+(define-key global-map 'prior		'scroll-down-command)
+(define-key global-map 'next		'scroll-up-command)
 
 ;; movement to the limits
 (define-key global-map 'home		'beginning-of-line)
@@ -534,9 +534,9 @@
 ;; files, but these appear to be the standard Motif and PC bindings.
 
 ;; potential R6isms
-(define-key global-map 'kp-left		'backward-char)
+(define-key global-map 'kp-left		'backward-char-command)
 (define-key global-map 'kp-up		'previous-line)
-(define-key global-map 'kp-right	'forward-char)
+(define-key global-map 'kp-right	'forward-char-command)
 (define-key global-map 'kp-down		'next-line)
 
 
@@ -560,8 +560,8 @@
 (define-key global-map '(control prior)	'scroll-right)
 (define-key global-map '(control next)	'scroll-left)
 ;; potential R6isms
-(define-key global-map 'kp-prior	'scroll-down)
-(define-key global-map 'kp-next		'scroll-up)
+(define-key global-map 'kp-prior	'scroll-down-command)
+(define-key global-map 'kp-next		'scroll-up-command)
 (define-key global-map '(control kp-prior) 'scroll-right)
 (define-key global-map '(control kp-next) 'scroll-left)
 
--- a/lisp/lisp.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/lisp.el	Mon Aug 13 10:25:37 2007 +0200
@@ -63,7 +63,7 @@
   (if (and (> arg 0) (looking-at "#s("))
       (goto-char (+ (point) 2)))
   ;; XEmacs change -- don't bomb out if unbalanced sexp
-  (goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
+  (goto-char (or (scan-sexps (point) arg nil t) (buffer-end arg)))
   (if (< arg 0) (backward-prefix-chars))
   ;; XEmacs: evil hack! Skip back over #s so that structures are read
   ;; properly.  the current cheesified syntax tables just aren't up to
--- a/lisp/make-docfile.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/make-docfile.el	Mon Aug 13 10:25:37 2007 +0200
@@ -89,11 +89,13 @@
 (setq source-directory (concat default-directory "../lisp"))
 ;; (print (concat "Source directory: " source-directory))
 (load "packages.el")
+;; (load "setup-paths.el")
 
 (let (preloaded-file-list)
   (load (concat default-directory "../lisp/dumped-lisp.el"))
   ;; Add package lisp directories to load-path (for autoloads)
   ;; Add files dumped from lisp packages
+  ;(paths-setup-paths)
   (packages-find-packages package-path t t)
   (setq preloaded-file-list
 	(append preloaded-file-list packages-hardcoded-lisp))
--- a/lisp/modeline.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/modeline.el	Mon Aug 13 10:25:37 2007 +0200
@@ -75,7 +75,7 @@
 	  (start-event-window (event-window event))
 	  (start-nwindows (count-windows t))
 	  (hscroll-delta (face-width 'modeline))
-	  (start-hscroll (modeline-hscroll (event-window event)))
+;;	  (start-hscroll (modeline-hscroll (event-window event)))
 	  (start-x-pixel (event-x-pixel event))
 	  (last-timestamp 0)
 	  default-line-height
@@ -136,7 +136,7 @@
 	       ;; scroll) nore Y pos (modeline drag) have changed.
 	       (and modeline-click-swaps-buffers
 		    (= depress-line (event-y event))
-		    (= start-hscroll (modeline-hscroll start-event-window))
+;;		    (= start-hscroll (modeline-hscroll start-event-window))
 		    (modeline-swap-buffers event)))
 	      ((button-event-p event)
 	       (setq done t))
@@ -148,11 +148,11 @@
 		  drag-modeline-event-lag)
 	       nil)
 	      (t
-	       (set-modeline-hscroll start-event-window
-				     (+ (/ (- (event-x-pixel event) 
-					      start-x-pixel)
-					   hscroll-delta)
-					start-hscroll))
+;;		 (set-modeline-hscroll start-event-window
+;;				       (+ (/ (- (event-x-pixel event) 
+;;						start-x-pixel)
+;;					     hscroll-delta)
+;;					  start-hscroll))
 	       (setq last-timestamp (event-timestamp event)
 		     y (event-y-pixel event)
 		     edges (window-pixel-edges start-event-window)
--- a/lisp/msw-faces.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/msw-faces.el	Mon Aug 13 10:25:37 2007 +0200
@@ -29,9 +29,6 @@
 ;; This file does the magic to parse mswindows font names, and make sure that the
 ;; default and modeline attributes of new frames are specified enough.
 
-(defun mswindows-init-global-faces ()
-  )
-
 ;;; ensure that the default face has some reasonable fallbacks if nothing
 ;;; else is specified.
 (defun mswindows-init-device-faces (device)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/msw-glyphs.el	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,73 @@
+;;; msw-glyphs.el --- Support for glyphs in ms windows
+
+;; Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+
+;; Author: Kirill M. Katsnelson <kkm@kis.ru>
+;; Maintainer: XEmacs Development Team
+;; Keywords: extensions, internal, dumped
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Synched up with: Not in FSF.
+
+;;; Commentary:
+
+;; This file contains temporary definitions for 'mswindows glyphs.
+;; Since there currently is no image support, the glyps are defined
+;; TTY-style. This file has to be removed or reworked completely
+;; when we have images.
+
+;; This file is dumped with XEmacs.
+
+;;; Code:
+
+(eval-and-compile
+  (set-console-type-image-conversion-list
+   'mswindows
+   '(("^#define" [string :data "[xpm]"])
+     ("\\`X-Face:" [string :data "[xface]"])
+     ("\\`/\\* XPM \\*/" [string :data "[xpm]"])
+     ("\\`GIF87" [string :data "[gif]"])
+     ("\\`\377\330\340\000\020JFIF" [string :data "[jpeg]"])
+     ("" [string :data nil] 2)
+     ;; this last one is here for pointers and icons and such --
+     ;; strings are not allowed so they will be ignored.
+     ("" [nothing])))
+
+  ;; finish initializing truncation glyph -- created internally
+  ;; because it has a built-in bitmap
+  (set-glyph-image truncation-glyph "$" 'global 'mswindows)
+
+  ;; finish initializing continuation glyph -- created internally
+  ;; because it has a built-in bitmap
+  (set-glyph-image continuation-glyph "\\" 'global 'mswindows)
+
+  ;; finish initializing hscroll glyph -- created internally
+  ;; because it has a built-in bitmap
+  (set-glyph-image hscroll-glyph "$" 'global 'mswindows)
+
+  (set-glyph-image octal-escape-glyph "\\")
+  (set-glyph-image control-arrow-glyph "^")
+  (set-glyph-image invisible-text-glyph " ...")
+
+  (set-glyph-image xemacs-logo
+		   "XEmacs <Images support is due in 20.6!>"
+		   'global 'mswindows)
+)
+
+;;; msw-glyphs.el ends here
--- a/lisp/mwheel.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/mwheel.el	Mon Aug 13 10:25:37 2007 +0200
@@ -100,10 +100,7 @@
 ;;;###autoload
 (defun mwheel-install ()
   "Enable mouse wheel support."
-  (let ((mwheel-running-xemacs (string-match "XEmacs" (emacs-version)))
-	(keys (if mwheel-running-xemacs
-		  '(button4 [(shift button4)] button5 [(shift button5)])
-		'([mouse-4] [S-mouse-4] [mouse-5] [S-mouse-5]))))
+  (let ((keys '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
     ;; This condition-case is here because Emacs 19 will throw an error
     ;; if you try to define a key that it does not know about.  I for one
     ;; prefer to just unconditionally do a mwheel-install in my .emacs, so
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/setup-paths.el	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,533 @@
+;;; setup-paths.el --- setup various XEmacs paths
+
+;; Copyright (C) 1985-1986, 1990, 1992-1997 Free Software Foundation, Inc.
+;; Copyright (c) 1993, 1994 Sun Microsystems, Inc.
+;; Copyright (C) 1995 Board of Trustees, University of Illinois
+
+;; Author: Mike Sperber <sperber@informatik.uni-tuebingen.de>
+;; Maintainer: XEmacs Development Team
+;; Keywords: internal, dumped
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Synched up with: Not in FSF.
+
+;;; Commentary:
+
+;; This file is dumped with XEmacs.
+
+;; This file contains the machinery necessary to find the various
+;; paths into the XEmacs hierarchy.
+
+(defvar paths-version-control-bases '("RCS" "CVS" "SCCS")
+  "File bases associated with version control.")
+
+(defun paths-find-recursive-path (directories &optional exclude)
+  "Return a list of the directory hierarchy underneath DIRECTORIES.
+The returned list is sorted by pre-order and lexicographically."
+  (let ((path '()))
+    (while directories
+      (let ((directory (file-name-as-directory
+			(expand-file-name
+			 (car directories)))))
+	(if (file-directory-p directory)
+	    (let ((raw-dirs (directory-files directory nil "^[^-.]" nil 'dirs-only))
+		  (reverse-dirs '()))
+
+	      (while raw-dirs
+		(if (null (member (car raw-dirs) exclude))
+		    (setq reverse-dirs
+			  (cons (expand-file-name (car raw-dirs) directory)
+				reverse-dirs)))
+		(setq raw-dirs (cdr raw-dirs)))
+
+	      (let ((sub-path
+		     (paths-find-recursive-path (reverse reverse-dirs) exclude)))
+		(setq path (nconc path
+				  (list directory)
+				  sub-path))))))
+      (setq directories (cdr directories)))
+    path))
+
+(defun paths-find-recursive-load-path (directories)
+  "Construct a recursive load path underneath DIRECTORIES."
+  (paths-find-recursive-path directories paths-version-control-bases))
+
+(defun paths-emacs-root-p (directory)
+  "Check if DIRECTORY is a plausible installation root for XEmacs."
+  (or
+   ;; installed
+   (and (boundp 'emacs-version)
+	(file-directory-p
+	 (concat directory "lib/xemacs-" (construct-emacs-version))))
+   ;; in-place
+   (and 
+    (file-directory-p (concat directory "lib-src"))
+    (file-directory-p (concat directory "lisp"))
+    (file-directory-p (concat directory "src")))))
+
+(defun paths-find-emacs-root
+  (invocation-directory invocation-name)
+  "Find the run-time root of XEmacs."
+  (let ((maybe-root-1 (file-name-as-directory
+		       (expand-file-name ".." invocation-directory)))
+	(maybe-root-2 (file-name-as-directory
+		       (expand-file-name "../.." invocation-directory))))
+    (cond
+     ((paths-emacs-root-p maybe-root-1)
+      maybe-root-1)
+     ((paths-emacs-root-p maybe-root-2)
+      maybe-root-2)
+     (t
+      (let ((maybe-symlink (file-symlink-p (concat invocation-directory
+						   invocation-name))))
+	(if maybe-symlink
+	    (let ((directory (file-name-directory maybe-symlink)))
+	      (paths-find-emacs-root directory invocation-name))
+	  nil))))))
+
+(defun paths-construct-emacs-directory (root suffix base)
+  "Construct a directory name within the XEmacs hierarchy."
+  (file-name-as-directory
+   (expand-file-name 
+    (concat
+     (file-name-as-directory root)
+     suffix
+     base))))
+
+(defun paths-find-emacs-directory (roots suffix base &optional envvar default)
+  "Find a directory in the XEmacs hierarchy.
+ROOTS must be a list of installation roots.
+SUFFIX is the subdirectory from there.
+BASE is the base to look for.
+ENVVAR is the name of the environment variable that might also
+specify the directory.
+DEFAULT is a fall-back value."
+  (let ((envvar-value (and envvar (getenv envvar))))
+    (if (and envvar-value
+	     (file-directory-p envvar-value))
+	(file-name-as-directory envvar-value)
+      (catch 'gotcha
+	(while roots
+	  (let* ((root (car roots))
+		 (path (paths-construct-emacs-directory root suffix base)))
+	    ;; installed
+	    (if (file-directory-p path)
+		(throw 'gotcha path)
+	      (let ((path (paths-construct-emacs-directory root "" base)))
+		;; in-place
+		(if (file-directory-p path)
+		    (throw 'gotcha path)))))
+	  (setq roots (cdr roots)))
+	(if (and default
+		 (file-directory-p default))
+	    (file-name-as-directory default)
+	  nil)))))
+
+(defun paths-find-site-directory (roots base &optional envvar default)
+  "Find a site-specific directory in the XEmacs hierarchy."
+  (paths-find-emacs-directory roots "lib/xemacs/" base envvar default))
+
+(defun paths-find-version-directory (roots base &optional envvar default)
+  "Find a version-specific directory in the XEmacs hierarchy."
+  (paths-find-emacs-directory roots
+			      (concat "lib/xemacs-" (construct-emacs-version) "/")
+			      base
+			      envvar default))
+
+(defun paths-find-architecture-directory (roots base &optional envvar default)
+  "Find an architecture-specific directory in the XEmacs hierarchy."
+  (or
+   ;; from more to less specific
+   (paths-find-version-directory roots
+				 (concat base system-configuration)
+				 envvar default)
+   (paths-find-version-directory roots
+				 system-configuration
+				 envvar default)
+   (paths-find-version-directory roots
+				 base
+				 envvar default)))
+  
+(defvar paths-path-emacs-version nil
+  "Emacs version as it appears in paths.")
+
+(defun construct-emacs-version ()
+  "Construct the raw version number of XEmacs in the form XX.XX."
+  ;; emacs-version isn't available early, but we really don't care then
+  (if (null (boundp 'emacs-version))
+      ""
+  (or paths-path-emacs-version		; cache
+      (progn
+	(string-match "\\`[^0-9]*\\([0-9]+\\.[0-9]+\\)" emacs-version)
+	(let ((version (substring emacs-version
+				  (match-beginning 1) (match-end 1))))
+	  (if (string-match "(beta *\\([0-9]+\\))" emacs-version)
+	      (setq version (concat version
+				    "-b"
+				    (substring emacs-version
+					       (match-beginning 1) (match-end 1)))))
+	  (setq paths-path-emacs-version version)
+	  version)))))
+  
+(defun paths-find-emacs-path (roots suffix base &optional envvar default)
+  "Find a path in the XEmacs hierarchy.
+ROOTS must be a list of installation roots.
+SUFFIX is the subdirectory from there.
+BASE is the base to look for.
+ENVVAR is the name of the environment variable that might also
+specify the path.
+DEFAULT is a fall-back value."
+  (let ((envvar-value (and envvar (getenv envvar))))
+    (if (and (fboundp 'parse-colon-path) envvar-value)
+	(parse-colon-path envvar-value)
+      (let ((directory (paths-find-emacs-directory roots base suffix)))
+	(if (and directory (file-directory-p directory))
+	    (list directory)
+	  (paths-directories-which-exist default))))))
+
+(defun paths-directories-which-exist (directories)
+  "Return the directories among DIRECTORIES."
+  (let ((reverse-directories '()))
+    (while directories
+      (if (file-directory-p (car directories))
+	  (setq reverse-directories 
+		(cons (car directories)
+		      reverse-directories)))
+      (setq directories (cdr directories)))
+    (reverse reverse-directories)))
+
+(defun paths-find-site-path (roots base &optional envvar default)
+  "Find a path underneath the site hierarchy."
+  (paths-find-emacs-path roots "lib/xemacs/" base envvar default))
+
+(defun paths-find-version-path (roots base &optional envvar default)
+  "Find a path underneath the site hierarchy."
+  (paths-find-emacs-path roots
+			 (concat "lib/xemacs-" (construct-emacs-version) "/")
+			 base
+			 envvar default))
+		   
+; Packages are special ...
+
+(defun paths-find-package-path (roots)
+  "Construct the package path underneath installation roots ROOTS."
+  (let ((envvar-value (getenv "EMACSPACKAGEPATH")))
+    (if (and (fboundp 'parse-colon-path) envvar-value)
+	(parse-colon-path envvar-value)
+      (let ((base-directory (paths-find-site-directory roots "packages")))
+	(if base-directory
+	    (let ((mule-directory (and (featurep 'mule)
+				       (paths-find-site-directory roots
+								  "mule-packages"))))
+	      (append '("~/.xemacs/")
+		      '(nil)
+		      (and mule-directory
+			   (list mule-directory))
+		      (list base-directory)))
+	  configure-package-path)))))
+
+(defvar paths-package-special-bases '("etc" "info" "lisp" "lib-src" "bin")
+  "Special subdirectories of packages.")
+
+(defun paths-find-packages-in-directories (directories)
+  "Find all packages underneath directories in DIRECTORIES."
+  (paths-find-recursive-path directories
+			     (append paths-version-control-bases
+				     paths-package-special-bases)))
+
+(defun paths-split-path (path)
+  "Split PATH at NIL, return pair with two components.
+The second component is shared with PATH."
+  (let ((reverse-early '()))
+    (while (and path (null (null (car path))))
+      (setq reverse-early (cons (car path) reverse-early))
+      (setq path (cdr path)))
+    (if (null path)
+	(cons nil path)
+      (cons (reverse reverse-early) (cdr path)))))
+
+(defun paths-find-packages (package-path)
+  "Search for all packages in PACKAGE-PATH.
+PACKAGE-PATH may distinguish (by NIL-separation) between early
+and late packages.
+This returns (CONS EARLY-PACKAGES LATE-PACKAGES)."
+  (let* ((stuff (paths-split-path package-path))
+	 (early (car stuff))
+	 (late (cdr stuff)))
+    (cons (paths-find-packages-in-directories early)
+	  (paths-find-packages-in-directories late))))
+
+(defun paths-find-package-library-path (packages suffixes)
+  "Construct a path into a component of the packages hierarchy.
+PACKAGES is a list of package directories.
+SUFFIXES is a list of names of package subdirectories to look for."
+  (let ((directories
+	 (apply
+	  #'append
+	  (mapcar #'(lambda (package)
+		      (mapcar #'(lambda (suffix)
+				  (concat package suffix))
+			      suffixes))
+		  packages))))
+    (paths-directories-which-exist directories)))
+
+(defun paths-find-package-load-path (packages)
+  "Construct the load-path component for packages.
+PACKAGES is a list of package directories."
+  (paths-find-recursive-load-path
+   (paths-find-package-library-path packages '("lisp/"))))
+
+(defun paths-find-package-exec-path (packages)
+  (paths-find-package-library-path packages
+				   (list (concat "bin/" system-configuration "/")
+					 "lib-src/")))
+
+(defun paths-find-package-info-path (packages)
+  (paths-find-package-library-path packages '("info/")))
+
+(defun paths-find-package-data-path (packages)
+  (paths-find-package-library-path packages '("etc/")))
+
+(defun paths-find-emacs-roots (invocation-directory
+			       invocation-name)
+  "Find all plausible installation roots for XEmacs."
+  (let ((invocation-root
+	 (paths-find-emacs-root invocation-directory invocation-name))
+	(installation-root
+	 (if (and configure-prefix-directory
+		  (file-directory-p configure-prefix-directory))
+	     configure-prefix-directory)))
+    (append (and invocation-root
+		 (list invocation-root))
+	    (and installation-root
+		 (list installation-root)))))
+
+(defun paths-find-load-path (roots early-package-load-path late-package-load-path)
+  "Construct the load path."
+  (let ((envvar-value (getenv "EMACSLOADPATH")))
+    (if (and (fboundp 'parse-colon-path) envvar-value)
+	(parse-colon-path envvar-value)
+      (let* ((site-lisp-directory
+	      (and allow-site-lisp
+		   (paths-find-site-directory roots "site-lisp"
+					      nil
+					      configure-site-directory)))
+	     (site-lisp-load-path
+	      (and site-lisp-directory
+		   (paths-find-recursive-load-path (list site-lisp-directory))))
+	     (lisp-directory
+	      (paths-find-version-directory roots "lisp"
+					    nil
+					    configure-lisp-directory))
+	     (lisp-load-path
+	      (paths-find-recursive-load-path (list lisp-directory))))
+	(nconc early-package-load-path
+	       site-lisp-load-path
+	       late-package-load-path
+	       lisp-load-path)))))
+
+(defun paths-find-info-path (roots early-packages late-packages)
+  "Construct the info path."
+  (append
+   (paths-find-package-info-path early-packages)
+   (paths-find-package-info-path late-packages)
+   (let ((info-directory
+	  (paths-find-version-directory roots "info"
+					nil
+					(append
+					 (and configure-info-directory
+					      (list configure-info-directory))
+					 configure-info-path))))
+     (and info-directory
+	  (list info-directory)))
+   (let ((info-path-envval (getenv "INFOPATH")))
+     (if (and (fboundp 'parse-colon-path) info-path-envval)
+	 (parse-colon-path info-path-envval)))))
+
+(defun paths-find-doc-directory (roots)
+  "Find the documentation directory."
+  (paths-find-architecture-directory roots "lib-src"))
+
+(defun paths-find-lock-directory (roots)
+  "Find the lock directory."
+  (paths-find-site-path roots "lock" "EMACSLOCKDIR" configure-lock-directory))
+
+(defun paths-find-superlock-file (lock-directory)
+  "Find the superlock file."
+  (cond
+   ((null lock-directory)
+    nil)
+   ((and configure-superlock-file
+	 (file-directory-p (file-name-directory configure-superlock-file)))
+    configure-superlock-file)
+   (t
+    (expand-file-name "!!!SuperLock!!!" lock-directory))))
+
+(defun paths-find-exec-directory (roots)
+  "Find the binary directory."
+  (paths-find-architecture-directory roots "lib-src"))
+
+(defun paths-find-exec-path (roots exec-directory early-packages late-packages)
+  "Find the binary path."
+  (append
+   (let ((path-envval (getenv "PATH")))
+     (and (fboundp 'parse-colon-path) path-envval
+	  (parse-colon-path path-envval)))
+   (paths-find-package-exec-path early-packages)
+   (paths-find-package-exec-path late-packages)
+   (let ((emacspath-envval (getenv "EMACSPATH")))
+     (if (and (fboundp 'parse-colon-path) emacspath-envval)
+	 (parse-colon-path path-envval)
+       (paths-directories-which-exist configure-exec-path)))
+   (and exec-directory
+	(list exec-directory))))
+
+(defun paths-find-data-directory (roots)
+  "Find the data directory."
+  (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
+
+(defun paths-find-data-directory-list (data-directory early-packages late-packages)
+  "Find the data path."
+  (append
+   (paths-find-package-data-path early-packages)
+   (paths-find-package-data-path late-packages)
+   (list data-directory)))
+
+(defun paths-setup-paths ()
+  "Setup all the various paths.
+Call this as often as you like!"
+  ;; XEmacs -- Steven Baur says invocation directory is nil if you
+  ;; try to use XEmacs as a login shell.
+  (or invocation-directory (setq invocation-directory default-directory))
+  (if (fboundp 'abbreviate-file-name)
+      ;; No abbreviate-file-name in temacs
+      (setq invocation-directory
+	    ;; don't let /tmp_mnt/... get into the load-path or exec-path.
+	    (abbreviate-file-name invocation-directory)))
+
+  (let ((roots (paths-find-emacs-roots invocation-directory invocation-name)))
+
+    (setq package-path (paths-find-package-path roots))
+
+    (let ((stuff (paths-find-packages package-path)))
+      (setq early-packages (car stuff))
+      (setq late-packages (cdr stuff)))
+
+    (setq early-package-load-path (paths-find-package-load-path early-packages))
+    (setq late-package-load-path (paths-find-package-load-path late-packages))
+
+    (setq load-path (paths-find-load-path roots
+					  early-package-load-path
+					  late-package-load-path))
+
+    (setq info-path (paths-find-info-path roots early-packages late-packages))
+
+    (if (boundp 'lock-directory)
+	(progn
+	  (setq lock-directory (paths-find-lock-directory roots))
+	  (setq superlock-file (paths-find-superlock-file lock-directory))))
+
+    (setq exec-directory (paths-find-exec-directory roots))
+
+    (setq exec-path (paths-find-exec-path roots exec-directory
+					  early-packages late-packages))
+
+    (setq doc-directory (paths-find-doc-directory roots))
+
+    (setq data-directory (paths-find-data-directory roots))
+
+    (setq data-directory-list (paths-find-data-directory-list data-directory
+							      early-packages
+							      late-packages))))
+
+(defun paths-setup-paths-warning ()
+  (let ((lock (if (boundp 'lock-directory) lock-directory 't))
+	warnings message guess)
+    (if (and (stringp lock) (null (file-directory-p lock)))
+	(setq lock nil))
+    (cond
+     ((null (and exec-directory data-directory doc-directory load-path lock))
+      (save-excursion
+	(set-buffer (get-buffer-create " *warning-tmp*"))
+	(erase-buffer)
+	(buffer-disable-undo (current-buffer))
+	(if (null lock)           (push "lock-directory" warnings))
+	(if (null exec-directory) (push "exec-directory" warnings))
+	(if (null data-directory) (push "data-directory" warnings))
+	(if (null doc-directory)  (push "doc-directory"  warnings))
+	(if (null load-path)      (push "load-path"      warnings))
+	(cond ((cdr (cdr warnings))
+	       (setq message (apply 'format "%s, %s, and %s" warnings)))
+	      ((cdr warnings)
+	       (setq message (apply 'format "%s and %s" warnings)))
+	      (t (setq message (format "variable %s" (car warnings)))))
+	(insert "couldn't find an obvious default for " message
+		", and there were no defaults specified in paths.h when "
+		"XEmacs was built.  Perhaps some directories don't exist, "
+		"or the XEmacs executable, " (concat invocation-directory
+						     invocation-name)
+		" is in a strange place?")
+
+	(if (fboundp 'fill-region)
+	    ;; Might not be bound in the cold load environment...
+	    (let ((fill-column 76))
+	      (fill-region (point-min) (point-max))))
+	(goto-char (point-min))
+	(princ "\nWARNING:\n" 'external-debugging-output)
+	(princ (buffer-string) 'external-debugging-output)
+	(erase-buffer)
+	t)))))
+
+(defun paths-load-package-lisps (package-load-path base)
+  "Load all Lisp files of a certain name along a load path.
+BASE is the base name of the files."
+  (mapc #'(lambda (dir)
+	    (let ((file-name (expand-file-name base dir)))
+	      (if (file-exists-p file-name)
+		  (condition-case error
+		      (load file-name)
+		    (error
+		     (warn (format "Autoload error in: %s:\n\t%s"
+				   file-name
+				   (with-output-to-string
+				     (display-error error nil)))))))))
+	package-load-path))
+
+(defun paths-load-package-auto-autoloads (package-load-path)
+  "Load auto-autoload files along a load path."
+  (paths-load-package-lisps package-load-path
+			    (file-name-sans-extension autoload-file-name)))
+
+(defun paths-load-package-dumped-lisps (package-load-path)
+  "Load dumped-lisp.el files along a load path."
+  (mapc #'(lambda (dir)
+	    (let ((file-name (expand-file-name "dumped-lisp.el" dir)))
+	      (if (file-exists-p file-name)
+		  (let (package-lisp
+			;; 20.4 packages could set this
+			preloaded-file-list)
+		    (load file-name)
+		    ;; dumped-lisp.el could have set this ...
+		    (if package-lisp
+			(mapc #'(lambda (base)
+				  (load (expand-file-name base dir)))
+			      package-lisp))))))
+	package-load-path))
+
+;;; setup-paths.el ends here
--- a/lisp/simple.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/simple.el	Mon Aug 13 10:25:37 2007 +0200
@@ -1686,6 +1686,19 @@
     (switch-to-buffer buffer)))
 
 
+(defcustom signal-error-on-buffer-boundary t
+  "*Non-nil value causes XEmacs to beep or signal an error when certain interactive commands would move point past (point-min) or (point-max).
+The commands that honor this variable are
+
+forward-char-command
+backward-char-command
+next-line
+previous-line
+scroll-up-command
+scroll-down-command"
+  :type 'boolean
+  :group 'editing-basics)
+
 ;;; After 8 years of waiting ... -sb
 (defcustom next-line-add-newlines nil  ; XEmacs
   "*If non-nil, `next-line' inserts newline when the point is at end of buffer.
@@ -1694,6 +1707,72 @@
   :type 'boolean
   :group 'editing-basics)
 
+(defun forward-char-command (&optional arg buffer)
+  "Move point right ARG characters (left if ARG negative) in BUFFER.
+On attempt to pass end of buffer, stop and signal `end-of-buffer'.
+On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
+Error signaling is suppressed if `signal-error-on-buffer-boundary'
+is nil.  If BUFFER is nil, the current buffer is assumed."
+  (interactive "_p")
+  (if signal-error-on-buffer-boundary
+      (forward-char arg buffer)
+    (condition-case nil
+	(forward-char arg buffer)
+      (beginning-of-buffer nil)
+      (end-of-buffer nil))))
+
+(defun backward-char-command (&optional arg buffer)
+  "Move point left ARG characters (right if ARG negative) in BUFFER.
+On attempt to pass end of buffer, stop and signal `end-of-buffer'.
+On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
+Error signaling is suppressed if `signal-error-on-buffer-boundary'
+is nil.  If BUFFER is nil, the current buffer is assumed."
+  (interactive "_p")
+  (if signal-error-on-buffer-boundary
+      (backward-char arg buffer)
+    (condition-case nil
+	(backward-char arg buffer)
+      (beginning-of-buffer nil)
+      (end-of-buffer nil))))
+
+(defun scroll-up-command (&optional n)
+  "Scroll text of current window upward ARG lines; or near full screen if no ARG.
+A near full screen is `next-screen-context-lines' less than a full screen.
+Negative ARG means scroll downward.
+When calling from a program, supply a number as argument or nil.
+On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
+On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
+signaled.
+
+If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
+boundaries do not cause an error to be signaled."
+  (interactive "_P")
+  (if signal-error-on-buffer-boundary
+      (scroll-up n)
+    (condition-case nil
+	(scroll-up n)
+      (beginning-of-buffer nil)
+      (end-of-buffer nil))))
+
+(defun scroll-down-command (&optional n)
+  "Scroll text of current window downward ARG lines; or near full screen if no ARG.
+A near full screen is `next-screen-context-lines' less than a full screen.
+Negative ARG means scroll upward.
+When calling from a program, supply a number as argument or nil.
+On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
+On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
+signaled.
+
+If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
+boundaries do not cause an error to be signaled."
+  (interactive "_P")
+  (if signal-error-on-buffer-boundary
+      (scroll-down n)
+    (condition-case nil
+	(scroll-down n)
+      (beginning-of-buffer nil)
+      (end-of-buffer nil))))
+
 (defun next-line (arg)
   "Move cursor vertically down ARG lines.
 If there is no character in the target line exactly under the current column,
@@ -2396,6 +2475,9 @@
 The function should take a single optional argument which is a flag
 indicating whether soft newlines should be inserted.")
 
+;; defined in mule-base/mule-category.el
+(defvar word-across-newline)
+
 ;; This function is the auto-fill-function of a buffer
 ;; when Auto-Fill mode is enabled.
 ;; It returns t if it really did any work.
--- a/lisp/update-elc.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/update-elc.el	Mon Aug 13 10:25:37 2007 +0200
@@ -64,6 +64,7 @@
 
 (define-function 'defalias 'define-function)
 (load "packages.el")
+;;; (load "setup-paths.el")
 
 (let ((autol (packages-list-autoloads)))
   ;; (print (prin1-to-string autol))
@@ -87,6 +88,7 @@
 (let (preloaded-file-list site-load-packages)
   (load (concat default-directory "../lisp/dumped-lisp.el"))
   ;; At this point we need to have the package path initialized
+  ;(paths-setup-paths)
   (packages-find-packages package-path t t)
   ;; (print (prin1-to-string preloaded-file-list))
   (load (concat default-directory "../site-packages") t t)
--- a/lisp/winnt.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/winnt.el	Mon Aug 13 10:25:37 2007 +0200
@@ -44,14 +44,6 @@
 (define-key global-map [(meta backspace)] 'backward-kill-word)
 (define-key global-map [(control meta backspace)] 'backward-kill-sexp)
 
-(defconst nt-modeline-buffer-type '("%t")
-  "Modeline control for showing buffer type (binary or text).")
-
-(setq-default modeline-format
-  (cons (purecopy "")
-	(cons 'nt-modeline-buffer-type
-	      (cdr modeline-format))))
-
 ;; Ignore case on file-name completion
 (setq completion-ignore-case t)
 
--- a/lisp/x-faces.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/x-faces.el	Mon Aug 13 10:25:37 2007 +0200
@@ -545,32 +545,38 @@
 						    x-tag-set)
       (set-face-background-pixmap face bgp locale nil append))
     (when ulp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-underline-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'underline)
 						    locale
 						    tty-tag-set)
       (set-face-underline-p face ulp locale nil append))
     (when stp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-strikethru-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'strikethru)
 						    locale
 						    tty-tag-set)
       (set-face-strikethru-p face stp locale nil append))
     (when hp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-highlight-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'highlight)
 						    locale
 						    tty-tag-set)
       (set-face-highlight-p face hp locale nil append))
     (when dp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-dim-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'dim)
 						    locale
 						    tty-tag-set)
       (set-face-dim-p face dp locale nil append))
     (when bp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-blinking-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'blinking)
 						    locale
 						    tty-tag-set)
       (set-face-blinking-p face bp locale nil append))
     (when rp
-      (remove-specifier-specs-matching-tag-set-cdrs (face-reverse-p face)
+      (remove-specifier-specs-matching-tag-set-cdrs (face-property
+						     face 'reverse)
 						    locale
 						    tty-tag-set)
       (set-face-reverse-p face rp locale nil append))
--- a/lisp/x-menubar.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/x-menubar.el	Mon Aug 13 10:25:37 2007 +0200
@@ -736,7 +736,7 @@
 	:active (fboundp 'browse-url-grail)]
        )
       "-----"
-      ["Browse Faces..." edit-faces]
+      ["Browse Faces..." (customize-face nil)]
       ("Font"   :filter font-menu-family-constructor)
       ("Size"	:filter font-menu-size-constructor)
       ("Weight"	:filter font-menu-weight-constructor)
@@ -788,7 +788,8 @@
      ("Help"
       ["About XEmacs..." about-xemacs]
       ("Basics"
-       #-infodock ["Installation" describe-installation]
+       ["Installation" describe-installation
+	:active (boundp 'Installation-string)]
        ;; Tutorials.
        ,(if (featurep 'mule)
 	    ;; Mule tutorials.
@@ -1208,10 +1209,15 @@
 ;;; The Options menu
 
 (defvar options-save-faces nil
-  "if t, save-options will save all the face information.
-Set to nil to avoid this. This is recommended on XEmacs 19.15
-and above as we have a much more powerful (read: working) way 
-of changing and saving faces via cu-edit-faces.el & custom.el.")
+  "*Non-nil value means save-options will save information about faces.
+A nil value means save-options will not save face information.
+Set this non-nil only if you use M-x edit-faces to change face
+settings.  If you use M-x customize-face or the \"Browse Faces...\"
+menu entry, you will see a button in the Customize Face buffer that you
+can use to permanently save your face changes.
+
+M-x edit-faces is deprecated.  Support for it and this variable will
+be discontinued in a future release.")
 
 (defconst options-menu-saved-forms
   ;; This is really quite a kludge, but it gets the job done.
--- a/lisp/x-mouse.el	Mon Aug 13 10:24:47 2007 +0200
+++ b/lisp/x-mouse.el	Mon Aug 13 10:25:37 2007 +0200
@@ -150,7 +150,8 @@
 	      "xterm")) ; was "crosshair"
     (set-glyph-image modeline-pointer-glyph
 	  (or (x-get-resource "modeLinePointer" "Cursor" 'string device)
-	      "fleur"))
+;;	      "fleur"))
+	      "sb_v_double_arrow"))
     (set-glyph-image gc-pointer-glyph
 	  (or (x-get-resource "gcPointer" "Cursor" 'string device)
 	      "watch"))
--- a/man/ChangeLog	Mon Aug 13 10:24:47 2007 +0200
+++ b/man/ChangeLog	Mon Aug 13 10:25:37 2007 +0200
@@ -1,3 +1,13 @@
+1998-03-14  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* internals/internals.texi (GCPROing): Explain when it is
+	necessary to GCPRO function parameters.
+
+1998-03-13  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* internals/internals.texi (Writing Lisp Primitives): Updated
+	definition of For().
+
 1998-03-01  Aki Vehtari  <Aki.Vehtari@hut.fi>
 
 	* lispref/menus.texi: Use recommended forms in examples.
--- a/man/internals/internals.texi	Mon Aug 13 10:24:47 2007 +0200
+++ b/man/internals/internals.texi	Mon Aug 13 10:25:37 2007 +0200
@@ -1737,24 +1737,18 @@
        (args))
 @{
   /* This function can GC */
-  REGISTER Lisp_Object val;
-  Lisp_Object args_left;
+  Lisp_Object val = Qnil;
   struct gcpro gcpro1;
 
-  if (NILP (args))
-    return Qnil;
-
-  args_left = args;
-  GCPRO1 (args_left);
-
-  do
+  GCPRO1 (args);
+
+  while (!NILP (args))
     @{
-      val = Feval (Fcar (args_left));
+      val = Feval (XCAR (args));
       if (!NILP (val))
-        break;
-      args_left = Fcdr (args_left);
+	break;
+      args = XCDR (args);
     @}
-  while (!NILP (args_left));
 
   UNGCPRO;
   return val;
@@ -4071,12 +4065,18 @@
 @item
 The general rule to follow is that caller, not callee, @code{GCPRO}s.
 That is, you should not have to explicitly @code{GCPRO} any Lisp objects
-that are passed in as parameters, but if you create any Lisp objects
-(remember, this happens in all sorts of circumstances, e.g. with
-@code{Fcons()}, etc.), you are responsible for @code{GCPRO}ing the
-objects unless you are @emph{absolutely sure} that there's no
-possibility that a garbage-collection can occur while you need to use
-the object.  Even then, consider @code{GCPRO}ing.
+that are passed in as parameters.
+
+One exception from this rule is if you ever plan to change the parameter
+value, and store a new object in it.  In that case, you @emph{must}
+@code{GCPRO} the parameter, because otherwise the new object will not be
+protected.
+
+So, if you create any Lisp objects (remember, this happens in all sorts
+of circumstances, e.g. with @code{Fcons()}, etc.), you are responsible
+for @code{GCPRO}ing them, unless you are @emph{absolutely sure} that
+there's no possibility that a garbage-collection can occur while you
+need to use the object.  Even then, consider @code{GCPRO}ing.
 
 @item
 A garbage collection can occur whenever anything calls @code{Feval}, or
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/Makefile.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,16 @@
+subdirs=ldap base64 zlib example
+RM=@RM@
+
+all:
+	for x in $(subdirs); do ( cd $$x && make $@ ); done
+
+install clean mostlyclean:
+	for x in $(subdirs); do ( cd $$x && make $@ ); done
+
+distclean:
+	$(RM) Makefile config.*
+	for x in $(subdirs); do ( cd $$x && make $@ ); done
+
+realclean extraclean:
+	$(RM) *~ \#*
+	for x in $(subdirs); do ( cd $$x && make $@ ); done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/aclocal.m4	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,36 @@
+AC_DEFUN(XE_EMACS, [
+	dnl
+	dnl Apparently, if you run a shell window in Emacs, it sets the EMACS
+	dnl environment variable to 't'.  Lets undo the damage.
+	dnl
+	if test "${EMACS}" = "t"; then
+		EMACS=""
+	fi
+
+	AC_ARG_WITH(xemacs,           --with-xemacs             Use XEmacs to build, [ if test "${withval}" = "yes"; then EMACS=xemacs; else EMACS=${withval}; fi ])
+	AC_ARG_WITH(emacs,            --with-emacs              Use Emacs to build, [ if test "${withval}" = "yes"; then EMACS=emacs; else EMACS=${withval}; fi ])
+	AC_CHECK_PROG(EMACS, xemacs, xemacs, emacs)
+	AC_SUBST(EMACS)
+])
+
+AC_DEFUN(XE_CONFIG_VALUE, [
+	OUTPUT=./conftest-$$
+	rm -f ${OUTPUT}
+	${EMACS} -batch -eval "
+(let ((hash (config-value-hash-table))
+      (desired (split-string \"$1\")))
+  (mapcar
+     (lambda (key)
+       (message \"Checking for %S\" (intern key))
+       (if (config-value (intern key))
+          (progn
+	    (write-region (format \"%s=\\\"%s\\\"\n\" key (config-value (intern key)))
+		  	  nil \"${OUTPUT}\" t))))
+	desired))
+" 2> /dev/null > /dev/null
+	test -f ${OUTPUT} && . ${OUTPUT}
+	rm -f ${OUTPUT}
+	for ac_func in $1; do
+                :
+	done
+])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/base64/Makefile.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,37 @@
+# NOTE!!
+# The use of BLDDIR here is _BOGUS_.
+# What really needs to happen is that we should install config.h into
+# the architecture dependent directory when we really hash all this
+# out.
+
+blddir=@blddir@
+dll_cflags=@dll_cflags@
+dll_oflags=@dll_oflags@
+dll_lflags=@dll_lflags@
+dll_ld=@dll_ld@
+
+INCLUDES=-I$(blddir)/src
+CFLAGS=@CFLAGS@ $(INCLUDES)
+CC=@CC@
+RM=@RM@
+
+TARGET=base64
+
+.PHONY: clean mostlyclean distclean realclean install
+
+all: $(TARGET).ell
+
+$(TARGET).ell: $(TARGET).o
+	$(dll_ld) $(dll_oflags) $@ $(dll_lflags) $^
+
+install:
+	echo "Don't know how to install yet"
+
+clean mostlyclean:
+	$(RM) *.o $(TARGET).ell
+
+distclean: clean
+	$(RM) Makefile
+
+realclean extraclean: distclean
+	$(RM) *~ \#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/base64/base64.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,429 @@
+/* base64 interface for XEmacs.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Author: William Perry <wmperry@aventail.com> */
+
+#include <config.h>
+
+#include "lisp.h"
+#include "buffer.h"
+#include "insdel.h"
+#include "lstream.h"
+#ifdef FILE_CODING
+#include "file-coding.h"
+#endif
+
+unsigned char alphabet[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+DEFUN ("base64-encode", Fbase64_encode, 1, 5, 0, /*
+Return the base64 encoding of an object.
+OBJECT is either a string or a buffer.
+Optional arguments START and END denote buffer positions for computing the
+hash of a portion of OBJECT.  The optional CODING argument specifies the coding
+system the text is to be represented in while computing the digest.  This only
+has meaning with MULE, and defaults to the current format of the data.
+If ERROR-ME-NOT is nil, report an error if the coding system can't be
+determined.  Else assume binary coding if all else fails.
+*/
+       (object, start, end, coding, error_me_not))
+{
+	int cols,bits,char_count;
+	Lisp_Object instream, outstream,deststream;
+	Lstream *istr, *ostr, *dstr;
+	static Extbyte_dynarr *conversion_out_dynarr;
+	static Extbyte_dynarr *out_dynarr;
+	char tempbuf[1024]; /* some random amount */
+	struct gcpro gcpro1, gcpro2;
+#ifdef FILE_CODING
+	Lisp_Object conv_out_stream, coding_system;
+	Lstream *costr;
+	struct gcpro gcpro3;
+#endif
+
+	if (!conversion_out_dynarr)
+		conversion_out_dynarr = Dynarr_new (Extbyte);
+	else
+		Dynarr_reset (conversion_out_dynarr);
+
+	if (!out_dynarr)
+		out_dynarr = Dynarr_new(Extbyte);
+	else
+		Dynarr_reset (out_dynarr);
+
+	char_count = bits = cols = 0;
+
+	/* set up the in stream */
+	if (BUFFERP (object))
+	{
+		struct buffer *b = decode_buffer (object, 1);
+		Bufpos begv, endv;
+		/* Figure out where we need to get info from */
+		get_buffer_range_char (b, start, end, &begv, &endv, GB_ALLOW_NIL);
+
+		instream = make_lisp_buffer_input_stream (b, begv, endv, 0);
+	}
+	else
+	{
+		Bytecount bstart, bend;
+		CHECK_STRING (object);
+		get_string_range_byte (object, start, end, &bstart, &bend,
+							   GB_HISTORICAL_STRING_BEHAVIOR);
+		instream = make_lisp_string_input_stream (object, bstart, bend);
+	}
+	istr = XLSTREAM (instream);
+
+#ifdef FILE_CODING
+	/* Find out what format the buffer will be saved in, so we can make
+	   the digest based on what it will look like on disk */
+	if (NILP(coding))
+	{
+		if (BUFFERP(object)) 
+	    {
+			/* Use the file coding for this buffer by default */
+			coding_system = XBUFFER(object)->buffer_file_coding_system;
+	    }
+		else
+	    {
+			/* attempt to autodetect the coding of the string.  Note: this VERY hit-and-miss */
+			enum eol_type eol = EOL_AUTODETECT;
+			coding_system = Fget_coding_system(Qundecided);
+			determine_real_coding_system(istr, &coding_system, &eol);
+	    }
+		if (NILP(coding_system)) 
+			coding_system = Fget_coding_system(Qbinary);
+		else
+	    {
+			coding_system = Ffind_coding_system (coding_system);
+			if (NILP(coding_system))
+				coding_system = Fget_coding_system(Qbinary);
+	    }
+	}
+	else
+	{
+		coding_system = Ffind_coding_system (coding);
+		if (NILP(coding_system))
+	    {
+			if (NILP(error_me_not))
+				signal_simple_error("No such coding system", coding);
+			else
+				coding_system = Fget_coding_system(Qbinary); /* default to binary */
+	    }
+	}
+#endif
+
+	/* setup the out stream */
+	outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr);
+	ostr = XLSTREAM (outstream);
+	deststream = make_dynarr_output_stream((unsigned_char_dynarr *)out_dynarr);
+	dstr = XLSTREAM (deststream);
+#ifdef FILE_CODING
+	/* setup the conversion stream */
+	conv_out_stream = make_encoding_output_stream (ostr, coding_system);
+	costr = XLSTREAM (conv_out_stream);
+	GCPRO3 (instream, outstream, conv_out_stream);
+#else
+	GCPRO2 (instream, outstream);
+#endif
+
+	/* Get the data while doing the conversion */
+	while (1) {
+		int size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf));
+		int l;
+		if (!size_in_bytes)
+			break;
+		/* It does seem the flushes are necessary... */
+#ifdef FILE_CODING
+		Lstream_write (costr, tempbuf, size_in_bytes);
+		Lstream_flush (costr);
+#else
+		Lstream_write (ostr, tempbuf, size_in_bytes);
+#endif
+		Lstream_flush (ostr);
+
+		/* Update the base64 output buffer */
+		for (l = 0; l < size_in_bytes; l++) {
+			bits += Dynarr_at(conversion_out_dynarr,l);
+			char_count++;
+			if (char_count == 3) {
+				static char obuf[4];
+				obuf[0] = alphabet[(bits >> 18)];
+				obuf[1] = alphabet[(bits >> 12) & 0x3f];
+				obuf[2] = alphabet[(bits >>  6) & 0x3f];
+				obuf[3] = alphabet[bits & 0x3f];
+
+				Lstream_write(dstr,obuf,sizeof(obuf));
+				cols += 4;
+				if (cols == 72) {
+					Lstream_write(dstr,"\n",sizeof(unsigned char));
+					cols = 0;
+				}
+				bits = char_count = 0;
+			} else {
+				bits <<= 8;
+			}
+		}
+		/* reset the dynarr */
+		Lstream_rewind(ostr);
+	}
+	Lstream_close (istr);
+#ifdef FILE_CODING
+	Lstream_close (costr);
+#endif
+	Lstream_close (ostr);
+
+	if (char_count != 0) {
+		bits <<= 16 - (8 * char_count);
+		Lstream_write(dstr,&alphabet[bits >> 18],sizeof(unsigned char));
+		Lstream_write(dstr,&alphabet[(bits >> 12) & 0x3f],sizeof(unsigned char));
+		if (char_count == 1) {
+			Lstream_write(dstr,"==",2 * sizeof(unsigned char));
+		} else {
+			Lstream_write(dstr,&alphabet[(bits >> 6) & 0x3f],sizeof(unsigned char));
+			Lstream_write(dstr,"=",sizeof(unsigned char));
+		}
+	}
+#if 0
+	if (cols > 0) {
+		Lstream_write(dstr,"\n",sizeof(unsigned char));
+	}
+#endif
+	UNGCPRO;
+	Lstream_delete (istr);
+	Lstream_delete (ostr);
+#ifdef FILE_CODING
+	Lstream_delete (costr);
+#endif
+	Lstream_flush(dstr);
+	Lstream_delete(dstr);
+
+	return(make_string(Dynarr_atp(out_dynarr,0),Dynarr_length(out_dynarr)));
+}
+
+DEFUN ("base64-decode", Fbase64_decode, 1, 5, 0, /*
+Undo the base64 encoding of an object.
+OBJECT is either a string or a buffer.
+Optional arguments START and END denote buffer positions for computing the
+hash of a portion of OBJECT.  The optional CODING argument specifies the coding
+system the text is to be represented in while computing the digest.  This only
+has meaning with MULE, and defaults to the current format of the data.
+If ERROR-ME-NOT is nil, report an error if the coding system can't be
+determined.  Else assume binary coding if all else fails.
+*/
+       (object, start, end, coding, error_me_not))
+{
+    static char inalphabet[256], decoder[256];
+	int i,cols,bits,char_count,hit_eof;
+	Lisp_Object instream, outstream,deststream;
+	Lstream *istr, *ostr, *dstr;
+	static Extbyte_dynarr *conversion_out_dynarr;
+	static Extbyte_dynarr *out_dynarr;
+	char tempbuf[1024]; /* some random amount */
+	struct gcpro gcpro1, gcpro2;
+#ifdef FILE_CODING
+	Lisp_Object conv_out_stream, coding_system;
+	Lstream *costr;
+	struct gcpro gcpro3;
+#endif
+
+    for (i = (sizeof alphabet) - 1; i >= 0 ; i--) {
+		inalphabet[alphabet[i]] = 1;
+		decoder[alphabet[i]] = i;
+    }
+
+	if (!conversion_out_dynarr)
+		conversion_out_dynarr = Dynarr_new (Extbyte);
+	else
+		Dynarr_reset (conversion_out_dynarr);
+
+	if (!out_dynarr)
+		out_dynarr = Dynarr_new(Extbyte);
+	else
+		Dynarr_reset (out_dynarr);
+
+	char_count = bits = cols = hit_eof = 0;
+
+	/* set up the in stream */
+	if (BUFFERP (object))
+	{
+		struct buffer *b = decode_buffer (object, 1);
+		Bufpos begv, endv;
+		/* Figure out where we need to get info from */
+		get_buffer_range_char (b, start, end, &begv, &endv, GB_ALLOW_NIL);
+
+		instream = make_lisp_buffer_input_stream (b, begv, endv, 0);
+	}
+	else
+	{
+		Bytecount bstart, bend;
+		CHECK_STRING (object);
+		get_string_range_byte (object, start, end, &bstart, &bend,
+							   GB_HISTORICAL_STRING_BEHAVIOR);
+		instream = make_lisp_string_input_stream (object, bstart, bend);
+	}
+	istr = XLSTREAM (instream);
+
+#ifdef FILE_CODING
+	/* Find out what format the buffer will be saved in, so we can make
+	   the digest based on what it will look like on disk */
+	if (NILP(coding))
+	{
+		if (BUFFERP(object)) 
+	    {
+			/* Use the file coding for this buffer by default */
+			coding_system = XBUFFER(object)->buffer_file_coding_system;
+	    }
+		else
+	    {
+			/* attempt to autodetect the coding of the string.  Note: this VERY hit-and-miss */
+			enum eol_type eol = EOL_AUTODETECT;
+			coding_system = Fget_coding_system(Qundecided);
+			determine_real_coding_system(istr, &coding_system, &eol);
+	    }
+		if (NILP(coding_system)) 
+			coding_system = Fget_coding_system(Qbinary);
+		else
+	    {
+			coding_system = Ffind_coding_system (coding_system);
+			if (NILP(coding_system))
+				coding_system = Fget_coding_system(Qbinary);
+	    }
+	}
+	else
+	{
+		coding_system = Ffind_coding_system (coding);
+		if (NILP(coding_system))
+	    {
+			if (NILP(error_me_not))
+				signal_simple_error("No such coding system", coding);
+			else
+				coding_system = Fget_coding_system(Qbinary); /* default to binary */
+	    }
+	}
+#endif
+
+	/* setup the out stream */
+	outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr);
+	ostr = XLSTREAM (outstream);
+	deststream = make_dynarr_output_stream((unsigned_char_dynarr *)out_dynarr);
+	dstr = XLSTREAM (deststream);
+#ifdef FILE_CODING
+	/* setup the conversion stream */
+	conv_out_stream = make_encoding_output_stream (ostr, coding_system);
+	costr = XLSTREAM (conv_out_stream);
+	GCPRO3 (instream, outstream, conv_out_stream);
+#else
+	GCPRO2 (instream, outstream);
+#endif
+
+	/* Get the data while doing the conversion */
+	while (1) {
+		int size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf));
+		int l;
+		if (!size_in_bytes) {
+			hit_eof = 1;
+			break;
+		}
+		/* It does seem the flushes are necessary... */
+#ifdef FILE_CODING
+		Lstream_write (costr, tempbuf, size_in_bytes);
+		Lstream_flush (costr);
+#else
+		Lstream_write (ostr, tempbuf, size_in_bytes);
+#endif
+		Lstream_flush (ostr);
+
+		/* Update the base64 output buffer */
+		for (l = 0; l < size_in_bytes; l++) {
+			if (Dynarr_at(conversion_out_dynarr,l) == '=')
+				goto decoder_out;
+			bits += decoder[Dynarr_at(conversion_out_dynarr,l)];
+			fprintf(stderr,"%d\n",bits);
+			char_count++;
+			if (char_count == 4) {
+				static unsigned char obuf[3];
+				obuf[0] = (bits >> 16);
+				obuf[1] = (bits >> 8) & 0xff;
+				obuf[2] = (bits & 0xff);
+
+				Lstream_write(dstr,obuf,sizeof(obuf));
+				bits = char_count = 0;
+			} else {
+				bits <<= 6;
+			}
+		}
+		/* reset the dynarr */
+		Lstream_rewind(ostr);
+	}
+ decoder_out:
+	Lstream_close (istr);
+#ifdef FILE_CODING
+	Lstream_close (costr);
+#endif
+	Lstream_close (ostr);
+
+	if (hit_eof) {
+		if (char_count) {
+			error_with_frob(object,"base64-decode failed: at least %d bits truncated",((4 - char_count) * 6));
+		}
+	}
+	switch(char_count) {
+	case 1:
+		error_with_frob(object, "base64 encoding incomplete: at least 2 bits missing");
+		break;
+	case 2:
+		char_count = bits >> 10;
+		Lstream_write(dstr,&char_count,sizeof(char_count));
+		break;
+	case 3:
+	{
+		unsigned char buf[2];
+		buf[0] = (bits >> 16);
+		buf[1] = (bits >> 8) & 0xff;
+		Lstream_write(dstr,buf,sizeof(buf));
+		break;
+	}
+	}
+
+	UNGCPRO;
+	Lstream_delete (istr);
+	Lstream_delete (ostr);
+#ifdef FILE_CODING
+	Lstream_delete (costr);
+#endif
+	Lstream_flush(dstr);
+	Lstream_delete(dstr);
+
+	return(make_string(Dynarr_atp(out_dynarr,0),Dynarr_length(out_dynarr)));
+}
+
+void
+syms_of (void)
+{
+  DEFSUBR(Fbase64_encode);
+  DEFSUBR(Fbase64_decode);
+}
+
+void
+vars_of (void)
+{
+  Fprovide (intern ("base64"));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/configure.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,23 @@
+AC_PREREQ(2.12)
+AC_INIT(configure.in)
+
+XE_EMACS
+XE_CONFIG_VALUE(dll_cflags dll_ld dll_lflags dll_oflags CFLAGS CC DEFS INSTALL top_srcdir blddir)
+
+RM='rm -f'
+
+AC_SUBST(INSTALL)
+AC_SUBST(RM)
+AC_SUBST(CC)
+AC_SUBST(dll_cflags)
+AC_SUBST(dll_oflags)
+AC_SUBST(dll_lflags)
+AC_SUBST(dll_ld)
+AC_SUBST(top_srcdir)
+AC_SUBST(blddir)
+
+AC_OUTPUT(Makefile
+          ldap/Makefile
+          base64/Makefile
+ 	  example/Makefile
+   	  zlib/Makefile)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/example/Makefile.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,35 @@
+# NOTE!!
+# The use of BLDDIR here is _BOGUS_.
+# What really needs to happen is that we should install config.h into
+# the architecture dependent directory when we really hash all this
+# out.
+
+blddir=@blddir@
+dll_cflags=@dll_cflags@
+dll_oflags=@dll_oflags@
+dll_lflags=@dll_lflags@
+dll_ld=@dll_ld@
+INCLUDES=-I$(blddir)/src
+CFLAGS=@CFLAGS@ $(INCLUDES)
+CC=@CC@
+RM=@RM@
+
+TARGET=purified
+all: $(TARGET).ell
+
+.PHONY: clean mostlyclean distclean realclean install
+
+$(TARGET).ell: $(TARGET).o
+	$(dll_ld) $(dll_oflags) $@ $(dll_lflags) $^
+
+install:
+	echo "Don't know how to install yet"
+
+clean mostlyclean:
+	$(RM) *.o $(TARGET).ell
+
+distclean: clean
+	$(RM) Makefile
+
+realclean extraclean: distclean
+	$(RM) *~ \#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/example/purified.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,16 @@
+#include <config.h>
+#include "lisp.h"
+#include "emacsfns.h"
+
+DEFUN ("purifiedp", Fpurifiedp, 1, 1, 0, /*
+*/
+ (obj))
+{
+	return purified(obj) ? Qt : Qnil;
+}
+
+void
+syms_of()
+{
+	DEFSUBR(Fpurifiedp);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ldap/Makefile.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,37 @@
+# NOTE!!
+# The use of BLDDIR here is _BOGUS_.
+# What really needs to happen is that we should install config.h into
+# the architecture dependent directory when we really hash all this
+# out.
+
+blddir=@blddir@
+dll_cflags=@dll_cflags@
+dll_oflags=@dll_oflags@
+dll_lflags=@dll_lflags@
+dll_ld=@dll_ld@
+
+INCLUDES=-I$(blddir)/src
+CFLAGS=@CFLAGS@ $(INCLUDES)
+CC=@CC@
+RM=@RM@
+
+TARGET=eldap
+
+.PHONY: clean mostlyclean distclean realclean install
+
+all: $(TARGET).ell
+
+$(TARGET).ell: $(TARGET).o
+	$(dll_ld) $(dll_oflags) $@ $(dll_lflags) $^
+
+install:
+	echo "Don't know how to install yet"
+
+clean mostlyclean:
+	$(RM) *.o $(TARGET).ell
+
+distclean: clean
+	$(RM) Makefile
+
+realclean extraclean: distclean
+	$(RM) *~ \#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ldap/configure.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,23 @@
+AC_PREREQ(2.12)
+AC_INIT(configure.in)
+
+XE_EMACS
+XE_CONFIG_VALUE(dll_cflags dll_ld dll_lflags dll_oflags CFLAGS CC DEFS INSTALL top_srcdir blddir)
+
+RM='rm -f'
+
+AC_SUBST(INSTALL)
+AC_SUBST(RM)
+AC_SUBST(CC)
+AC_SUBST(dll_cflags)
+AC_SUBST(dll_oflags)
+AC_SUBST(dll_lflags)
+AC_SUBST(dll_ld)
+AC_SUBST(top_srcdir)
+AC_SUBST(blddir)
+
+AC_OUTPUT(Makefile
+          ldap/Makefile
+          base64/Makefile
+ 	  example/Makefile
+   	  zlib/Makefile)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ldap/eldap.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,462 @@
+/* LDAP client interface for XEmacs.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Author: Oscar Figueiredo */
+
+/* This file provides lisp primitives for access to an LDAP library
+   conforming to the API defined in RFC 1823.
+   It has been tested with:
+   - UMich LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/)
+   - Netscape's LDAP SDK 1.0 (http://developer.netscape.com) */
+
+
+
+#include <config.h>
+
+#if defined (HAVE_LDAP)
+
+/* The entire file is within this conditional */
+
+#include "lisp.h"
+
+#include "eldap.h"
+#include <lber.h>
+#include <ldap.h>
+
+#ifdef HAVE_NS_LDAP
+#define HAVE_LDAP_SET_OPTION 1
+#define HAVE_LDAP_GET_ERRNO 1
+#else
+#undef HAVE_LDAP_SET_OPTION
+#undef HAVE_LDAP_GET_ERRNO
+#endif
+
+static Lisp_Object Vldap_default_base;
+static Lisp_Object Vldap_default_host;
+
+/* ldap-search-internal plist keywords */
+static Lisp_Object Qhost, Qfilter, Qattributes, Qattrsonly, Qbase, Qscope,
+  Qauth, Qbinddn, Qpasswd, Qderef, Qtimelimit, Qsizelimit;
+/* Search scope limits */
+static Lisp_Object Qbase, Qonelevel, Qsubtree;
+/* Authentication methods */
+#ifdef LDAP_AUTH_KRBV41
+static Lisp_Object Qkrbv41;
+#endif
+#ifdef LDAP_AUTH_KRBV42
+static Lisp_Object Qkrbv42;
+#endif
+/* Deref policy */
+static Lisp_Object Qnever, Qalways, Qfind;
+
+DEFUN ("ldap-search-internal", Fldap_search_internal, 1, 1, 0, /*
+Perform a search on a LDAP server.
+SEARCH-PLIST is a property list describing the search request.
+Valid keys in that list are:
+  `host' is a string naming one or more (blank separated) LDAP servers to
+to try to connect to. Each host name may optionally be of the form host:port.
+  `filter' is a filter string for the search as described in RFC 1558
+  `attributes' is a list of strings indicating which attributes to retrieve
+for each matching entry. If nil return all available attributes.
+  `attrsonly' if non-nil indicates that only the attributes are retrieved, not
+the associated values.
+  `base' is the base for the search as described in RFC 1779.
+  `scope' is one of the three symbols `subtree', `base' or `onelevel'.
+  `auth' is the authentication method to use, possible values depend on
+the LDAP library XEmacs was compiled with: `simple', `krbv41' and `krbv42'.
+  `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax).
+  `passwd' is the password to use for simple authentication.
+  `deref' is one of the symbols `never', `always', `search' or `find'.
+  `timelimit' is the timeout limit for the connection in seconds.
+  `sizelimit' is the maximum number of matches to return.
+The function returns a list of matching entries.  Each entry is itself
+an alist of attribute/values.
+*/
+       (search_plist))
+{
+ /* This function calls lisp */
+
+  /* Vars for query */
+  LDAP *ld;
+  LDAPMessage *res, *e;
+  BerElement *ptr;
+  char *a;
+  int i, rc, err;
+
+  char *ldap_host = NULL;
+  char *ldap_filter = NULL;
+  char **ldap_attributes = NULL;
+  int  ldap_attrsonly = 0;
+  char *ldap_base = NULL;
+  int  ldap_scope = LDAP_SCOPE_SUBTREE;
+  int  ldap_auth = LDAP_AUTH_SIMPLE;
+  char *ldap_binddn = NULL;
+  char *ldap_passwd = NULL;
+  int  ldap_deref = LDAP_DEREF_NEVER;
+  int  ldap_timelimit = 0;
+  int  ldap_sizelimit = 0;
+
+  char **vals = NULL;
+  int  matches;
+
+  Lisp_Object list, entry, result, keyword, value;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+
+  list = entry = result = keyword = value = Qnil;
+  GCPRO5 (list, entry, result, keyword, value);
+
+
+  EXTERNAL_PROPERTY_LIST_LOOP(list, keyword, value, search_plist)
+    {
+      /* Host */
+      if (EQ (keyword, Qhost))
+        {
+          CHECK_STRING (value);
+          ldap_host = alloca (XSTRING_LENGTH (value) + 1);
+          strcpy (ldap_host, (char *)XSTRING_DATA (value));
+        }
+      /* Filter */
+      else if (EQ (keyword, Qfilter))
+        {
+          CHECK_STRING (value);
+          ldap_filter = alloca (XSTRING_LENGTH (value) + 1);
+          strcpy (ldap_filter, (char *)XSTRING_DATA (value));
+        }
+      /* Attributes */
+      else if (EQ (keyword, Qattributes))
+        {
+          if (! NILP (value))
+            {
+              Lisp_Object attr_left = value;
+              struct gcpro ngcpro1;
+
+              NGCPRO1 (attr_left);
+              CHECK_CONS (value);
+
+              ldap_attributes = alloca ((XINT (Flength (value)) + 1)*sizeof (char *));
+
+              for (i=0; !NILP (attr_left); i++) {
+                CHECK_STRING (XCAR (attr_left));
+                ldap_attributes[i] = alloca (XSTRING_LENGTH (XCAR (attr_left)) + 1);
+                strcpy(ldap_attributes[i],
+                       (char *)(XSTRING_DATA( XCAR (attr_left))));
+                attr_left = XCDR (attr_left);
+              }
+              ldap_attributes[i] = NULL;
+              NUNGCPRO;
+            }
+        }
+      /* Attributes Only */
+      else if (EQ (keyword, Qattrsonly))
+        {
+          CHECK_SYMBOL (value);
+          ldap_attrsonly = NILP (value) ? 0 : 1;
+        }
+      /* Base */
+      else if (EQ (keyword, Qbase))
+        {
+          if (!NILP (value))
+            {
+              CHECK_STRING (value);
+              ldap_base = alloca (XSTRING_LENGTH (value) + 1);
+              strcpy (ldap_base, (char *)XSTRING_DATA (value));
+            }
+        }
+      /* Scope */
+      else if (EQ (keyword, Qscope))
+        {
+          CHECK_SYMBOL (value);
+
+          if (EQ (value, Qbase))
+            ldap_scope = LDAP_SCOPE_BASE;
+          else if (EQ (value, Qonelevel))
+            ldap_scope = LDAP_SCOPE_ONELEVEL;
+          else if (EQ (value, Qsubtree))
+            ldap_scope = LDAP_SCOPE_SUBTREE;
+          else
+            signal_simple_error ("Invalid scope", value);
+        }
+      /* Authentication method */
+      else if (EQ (keyword, Qauth))
+        {
+          CHECK_SYMBOL (value);
+
+          if (EQ (value, Qsimple))
+            ldap_auth = LDAP_AUTH_SIMPLE;
+#ifdef LDAP_AUTH_KRBV41
+          else if (EQ (value, Qkrbv41))
+            ldap_auth = LDAP_AUTH_KRBV41;
+#endif
+#ifdef LDAP_AUTH_KRBV42
+          else if (EQ (value, Qkrbv42))
+            ldap_auth = LDAP_AUTH_KRBV42;
+#endif
+          else
+            signal_simple_error ("Invalid authentication method", value);
+        }
+      /* Bind DN */
+      else if (EQ (keyword, Qbinddn))
+        {
+          if (!NILP (value))
+            {
+              CHECK_STRING (value);
+              ldap_binddn = alloca (XSTRING_LENGTH (value) + 1);
+              strcpy (ldap_binddn, (char *)XSTRING_DATA (value));
+            }
+        }
+      /* Password */
+      else if (EQ (keyword, Qpasswd))
+        {
+          if (!NILP (value))
+            {
+              CHECK_STRING (value);
+              ldap_passwd = alloca (XSTRING_LENGTH (value) + 1);
+              strcpy (ldap_passwd, (char *)XSTRING_DATA (value));
+            }
+        }
+      /* Deref */
+      else if (EQ (keyword, Qderef))
+        {
+          CHECK_SYMBOL (value);
+          if (EQ (value, Qnever))
+            ldap_deref = LDAP_DEREF_NEVER;
+          else if (EQ (value, Qsearch))
+            ldap_deref = LDAP_DEREF_SEARCHING;
+          else if (EQ (value, Qfind))
+            ldap_deref = LDAP_DEREF_FINDING;
+          else if (EQ (value, Qalways))
+            ldap_deref = LDAP_DEREF_ALWAYS;
+          else
+            signal_simple_error ("Invalid deref value", value);
+        }
+      /* Timelimit */
+      else if (EQ (keyword, Qtimelimit))
+        {
+          if (!NILP (value))
+            {
+              CHECK_INT (value);
+              ldap_timelimit = XINT (value);
+            }
+        }
+      /* Sizelimit */
+      else if (EQ (keyword, Qsizelimit))
+        {
+          if (!NILP (value))
+            {
+              CHECK_INT (value);
+              ldap_sizelimit = XINT (value);
+            }
+        }
+    }
+
+  /* Use ldap-default-base if no default base was given */
+  if (ldap_base == NULL && !NILP (Vldap_default_base))
+    {
+      CHECK_STRING (Vldap_default_base);
+      ldap_base = alloca (XSTRING_LENGTH (Vldap_default_base) + 1);
+      strcpy (ldap_base, (char *)XSTRING_DATA (Vldap_default_base));
+    }
+
+  /* Use ldap-default-host if no host was given */
+  if (ldap_host == NULL && !NILP (Vldap_default_host))
+    {
+      CHECK_STRING (Vldap_default_host);
+      ldap_host = alloca (XSTRING_LENGTH (Vldap_default_host) + 1);
+      strcpy (ldap_host, (char *)XSTRING_DATA (Vldap_default_host));
+    }
+
+  if (ldap_filter == NULL)
+    error ("Empty search filter");
+
+  /* Garbage collect before connecting (if using UMich lib).
+     This is ugly, I know, but without this, the UMich LDAP library 3.3
+     frequently reports "Can't contact LDAP server".  I really need to
+     check what happens inside that lib. Anyway this should be harmless to
+     XEmacs and makes things work. */
+#if defined (HAVE_UMICH_LDAP)
+  garbage_collect_1 ();
+#endif
+
+  /* Connect to the server and bind */
+  message ("Connecting to %s...", ldap_host);
+  if ( (ld = ldap_open (ldap_host, LDAP_PORT)) == NULL )
+     signal_simple_error ("Failed connecting to host",
+                          build_string (ldap_host));
+
+#if HAVE_LDAP_SET_OPTION
+  if (ldap_set_option (ld, LDAP_OPT_DEREF, (void *)&ldap_deref) != LDAP_SUCCESS)
+    error ("Failed to set deref option");
+  if (ldap_set_option (ld, LDAP_OPT_TIMELIMIT, (void *)&ldap_timelimit) != LDAP_SUCCESS)
+    error ("Failed to set timelimit option");
+  if (ldap_set_option (ld, LDAP_OPT_SIZELIMIT, (void *)&ldap_sizelimit) != LDAP_SUCCESS)
+    error ("Failed to set sizelimit option");
+  if (ldap_set_option (ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON) != LDAP_SUCCESS)
+    error ("Failed to set referral option");
+#else /* HAVE_LDAP_SET_OPTION */
+  ld->ld_deref = ldap_deref;
+  ld->ld_timelimit = ldap_timelimit;
+  ld->ld_sizelimit = ldap_sizelimit;
+#ifdef LDAP_REFERRALS
+  ld->ld_options = LDAP_OPT_REFERRALS;
+#else /* LDAP_REFERRALS */
+  ld->ld_options = 0;
+#endif /* LDAP_REFERRALS */
+#endif /* HAVE_LDAP_SET_OPTION */
+
+  message ("Binding to %s...", ldap_host);
+  if ( (err = (ldap_bind_s (ld, ldap_binddn, ldap_passwd, ldap_auth ))) != LDAP_SUCCESS )
+    signal_simple_error ("Failed binding to the server",
+                         build_string (ldap_err2string (err)));
+
+  /* Perform the search */
+  message ("Searching with LDAP on %s...", ldap_host);
+  if ( ldap_search (ld, ldap_base, ldap_scope, ldap_filter,
+                      ldap_attributes, ldap_attrsonly) == -1)
+    {
+      ldap_unbind (ld);
+#if HAVE_LDAP_GET_ERRNO
+      signal_simple_error ("Error during LDAP search",
+                           build_string (ldap_err2string (ldap_get_lderrno (ld, NULL, NULL))));
+#else
+      signal_simple_error ("Error during LDAP search",
+                           build_string (ldap_err2string (ld->ld_errno)));
+#endif
+    }
+
+  /* Build the results list */
+  matches = 0;
+
+  while ( (rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &res))
+          == LDAP_RES_SEARCH_ENTRY )
+    {
+      matches ++;
+      e = ldap_first_entry (ld, res);
+      message ("Parsing results... %d", matches);
+      entry = Qnil;
+      for (a= ldap_first_attribute (ld, e, &ptr);
+           a != NULL;
+           a= ldap_next_attribute (ld, e, ptr) )
+        {
+          list = Fcons (build_string (a), Qnil);
+          vals = ldap_get_values (ld, e, a);
+          if (vals != NULL)
+            {
+              for (i=0; vals[i]!=NULL; i++)
+                {
+                  list = Fcons (build_string (vals[i]),
+                                list);
+                }
+            }
+          entry = Fcons (Fnreverse (list),
+                         entry);
+          ldap_value_free (vals);
+        }
+      result = Fcons (Fnreverse (entry),
+                      result);
+      ldap_msgfree (res);
+    }
+
+  if (rc == -1)
+    {
+#if HAVE_LDAP_GET_ERRNO
+      signal_simple_error ("Error retrieving result",
+                           build_string (ldap_err2string (ldap_get_lderrno (ld, NULL, NULL))));
+#else
+      signal_simple_error ("Error retrieving result",
+                           build_string (ldap_err2string (ld->ld_errno)));
+#endif
+    }
+
+  if ((rc = ldap_result2error (ld, res, 0)) != LDAP_SUCCESS)
+    {
+#if HAVE_LDAP_GET_ERRNO
+      signal_simple_error ("Error on result",
+                           build_string (ldap_err2string (ldap_get_lderrno (ld, NULL, NULL))));
+#else
+      signal_simple_error ("Error on result",
+                           build_string (ldap_err2string (ld->ld_errno)));
+#endif
+    }
+
+  ldap_msgfree (res);
+  ldap_unbind (ld);
+  message ("Done.");
+
+  result = Fnreverse (result);
+  clear_message ();
+
+  UNGCPRO;
+  return result;
+}
+
+void
+syms_of (void)
+{
+  DEFSUBR(Fldap_search_internal);
+
+  defsymbol (&Qhost, "host");
+  defsymbol (&Qfilter, "filter");
+  defsymbol (&Qattributes, "attributes");
+  defsymbol (&Qattrsonly, "attrsonly");
+  defsymbol (&Qbase, "base");
+  defsymbol (&Qscope, "scope");
+  defsymbol (&Qauth, "auth");
+  defsymbol (&Qbinddn, "binddn");
+  defsymbol (&Qpasswd, "passwd");
+  defsymbol (&Qderef, "deref");
+  defsymbol (&Qtimelimit, "timelimit");
+  defsymbol (&Qsizelimit, "sizelimit");
+  defsymbol (&Qbase, "base");
+  defsymbol (&Qonelevel, "onelevel");
+  defsymbol (&Qsubtree, "subtree");
+#ifdef LDAP_AUTH_KRBV41
+  defsymbol (&Qkrbv41, "krbv41");
+#endif
+#ifdef LDAP_AUTH_KRBV42
+  defsymbol (&Qkrbv42, "krbv42");
+#endif
+  defsymbol (&Qnever, "never");
+  defsymbol (&Qalways, "always");
+  defsymbol (&Qfind, "find");
+}
+
+void
+vars_of (void)
+{
+  Fprovide (intern ("ldap-internal"));
+
+  DEFVAR_LISP ("ldap-default-host", &Vldap_default_host /*
+Default LDAP host.
+*/ );
+
+  DEFVAR_LISP ("ldap-default-base", &Vldap_default_base /*
+Default base for LDAP searches.
+This is a string using the syntax of RFC 1779.
+For instance, "o=ACME, c=US" limits the search to the
+Acme organization in the United States.
+*/ );
+
+  Vldap_default_host =  Qnil;
+  Vldap_default_base =  Qnil;
+}
+
+#endif /* HAVE_LDAP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ldap/eldap.h	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,39 @@
+/* Definitions for the LDAP client interface for XEmacs.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Author: Oscar Figueiredo */
+
+
+#ifndef _XEMACS_ELDAP_H_
+#define _XEMACS_ELDAP_H_
+
+#ifdef HAVE_LDAP
+
+#ifdef emacs
+
+Lisp_Object Fldap_search_internal (Lisp_Object search_plist);
+
+#endif /* emacs */
+
+#endif /* HAVE_LDAP */
+
+#endif /* _XEMACS_ELDAP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/zlib/Makefile.in	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,37 @@
+# NOTE!!
+# The use of BLDDIR here is _BOGUS_.
+# What really needs to happen is that we should install config.h into
+# the architecture dependent directory when we really hash all this
+# out.
+
+blddir=@blddir@
+dll_cflags=@dll_cflags@
+dll_oflags=@dll_oflags@
+dll_lflags=@dll_lflags@
+dll_ld=@dll_ld@
+
+INCLUDES=-I$(blddir)/src
+CFLAGS=@CFLAGS@ $(INCLUDES)
+CC=@CC@
+RM=@RM@
+
+TARGET=zlib
+
+.PHONY: clean mostlyclean distclean realclean install
+
+all: $(TARGET).ell
+
+$(TARGET).ell: $(TARGET).o
+	$(dll_ld) $(dll_oflags) $@ $(dll_lflags) $^
+
+install:
+	echo "Don't know how to install yet"
+
+clean mostlyclean:
+	$(RM) *.o $(TARGET).ell
+
+distclean: clean
+	$(RM) Makefile
+
+realclean extraclean: distclean
+	$(RM) *~ \#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/zlib/zlib.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,71 @@
+/* zlib interface for XEmacs.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Author: William Perry <wmperry@aventail.com> */
+
+#include <config.h>
+
+#include "lisp.h"
+
+DEFUN ("compress", Fcompress, 1, 6, 0, /*
+Return the compressed version of an object.
+OBJECT is either a string or a buffer.
+Optional argument LEVEL specifies how much to compress - valid range is 0 - 9.
+Optional arguments START and END denote buffer positions for compressing
+a portion of OBJECT.  The optional CODING argument specifies the coding
+system the text is to be represented in while computing the digest.  This only
+has meaning with MULE, and defaults to the current format of the data.
+If ERROR-ME-NOT is nil, report an error if the coding system can't be
+determined.  Else assume binary coding if all else fails.
+*/
+       (object, level, start, end, coding, error_me_not))
+{
+	return(Qnil);
+}
+
+DEFUN ("decompress", Fdecompress, 1, 5, 0, /*
+Uncompress an object.
+OBJECT is either a string or a buffer.
+Optional arguments START and END denote buffer positions for decompressing
+a portion of OBJECT.  The optional CODING argument specifies the coding
+system the text is to be represented in while computing the digest.  This only
+has meaning with MULE, and defaults to the current format of the data.
+If ERROR-ME-NOT is nil, report an error if the coding system can't be
+determined.  Else assume binary coding if all else fails.
+*/
+       (object, start, end, coding, error_me_not))
+{
+	return(Qnil);
+}
+
+void
+syms_of (void)
+{
+  DEFSUBR(Fcompress);
+  DEFSUBR(Fdecompress);
+}
+
+void
+vars_of (void)
+{
+  Fprovide (intern ("zlib"));
+}
--- a/nt/ChangeLog	Mon Aug 13 10:24:47 2007 +0200
+++ b/nt/ChangeLog	Mon Aug 13 10:25:37 2007 +0200
@@ -1,3 +1,14 @@
+1998-02-28  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* xemacs.mak: Defined HAVE_FILE_CODING variable, an equivalent of
+	--with-file-coding configure option. Default is yes.
+
+1998-03-13  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* xemacs.mak (update-elc): Copy Installation.el to $(LISP)
+
+	* Installation.el: New file, copied by xemacs.mak during build.
+
 Fri Feb 20 21:22:34 1998  Darryl Okahata  <darrylo@sr.hp.com>
 
 	* xemacs.mak: Added entry for src/dired-msw.c.  Use of the
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nt/Installation.el	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,2 @@
+;; Installation.el for Windows
+;; This file is intentionally left blank.
--- a/nt/xemacs.mak	Mon Aug 13 10:24:47 2007 +0200
+++ b/nt/xemacs.mak	Mon Aug 13 10:25:37 2007 +0200
@@ -4,6 +4,7 @@
 HAVE_X=0
 HAVE_MSW=1
 
+HAVE_FILE_CODING=1
 HAVE_MULE=0
 HAVE_IMAGEMAGICK=0
 
@@ -24,6 +25,10 @@
 
 #------------------------------------------------------------------------------
 
+!if $(HAVE_MULE)
+HAVE_FILE_CODING=1
+!endif
+
 !if $(HAVE_X)
 
 X11R6=h:\utils\X11R6
@@ -53,6 +58,10 @@
 MULE_DEFINES=-DMULE
 !endif
 
+!if $(HAVE_FILE_CODING)
+CODING_DEFINES=-DFILE_CODING
+!endif
+
 !if $(DEBUG_XEMACS)
 DEBUG_DEFINES=-DDEBUG_XEMACS
 DEBUG_FLAGS= -debugtype:both -debug:full
@@ -67,10 +76,10 @@
 
 INCLUDES=$(X_INCLUDES) -I$(XEMACS)\nt\inc -I$(XEMACS)\src -I$(XEMACS)\lwlib -I"$(MSVCDIR)\include"
 
-DEFINES=$(X_DEFINES) $(MSW_DEFINES) $(MSW_C_DIRED_DEFINES) $(MULE_DEFINES) \
-	-DWIN32 -D_WIN32 \
-	-DWIN32_LEAN_AND_MEAN -DWINDOWSNT -Demacs -DHAVE_CONFIG_H \
-	-D_DEBUG
+DEFINES=$(X_DEFINES) $(MSW_DEFINES) $(CODING_DEFINES) $(MULE_DEFINES) \
+	$(MSW_C_DIRED_DEFINES) \
+	-DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN -DWINDOWSNT -Demacs \
+	-DHAVE_CONFIG_H -D_DEBUG
 
 OUTDIR=obj
 
@@ -309,8 +318,13 @@
  $(MSW_C_DIRED_SRC)
 !endif
 
+!if $(HAVE_FILE_CODING)
+DOC_SRC8=\
+ $(XEMACS)\src\file-coding.c
+!endif
+
 !if $(HAVE_MULE)
-DOC_SRC8=\
+DOC_SRC9=\
  $(XEMACS)\src\input-method-xlib.c \
  $(XEMACS)\src\mule.c \
  $(XEMACS)\src\mule-charset.c \
@@ -319,7 +333,7 @@
 !endif
 
 !if $(DEBUG_XEMACS)
-DOC_SRC9=\
+DOC_SRC10=\
  $(XEMACS)\src\debug.c
 !endif
 
@@ -411,6 +425,11 @@
 	$(MSW_C_DIRED_OBJ)
 !endif
 
+!if $(HAVE_FILE_CODING)
+TEMACS_CODING_OBJS=\
+	$(OUTDIR)\file-coding.obj
+!endif
+
 !if $(HAVE_MULE)
 TEMACS_MULE_OBJS=\
 	$(OUTDIR)\input-method-xlib.obj \
@@ -428,6 +447,7 @@
 TEMACS_OBJS= \
 	$(TEMACS_X_OBJS)\
 	$(TEMACS_MSW_OBJS)\
+	$(TEMACS_CODING_OBJS)\
 	$(TEMACS_MULE_OBJS)\
 	$(TEMACS_DEBUG_OBJS)\
 	$(OUTDIR)\abbrev.obj \
@@ -575,8 +595,12 @@
 	!$(LIB_SRC)\make-docfile.exe -a $(DOC) -d $(TEMACS_SRC) $(DOC_SRC7)
 	!$(LIB_SRC)\make-docfile.exe -a $(DOC) -d $(TEMACS_SRC) $(DOC_SRC8)
 	!$(LIB_SRC)\make-docfile.exe -a $(DOC) -d $(TEMACS_SRC) $(DOC_SRC9)
+	!$(LIB_SRC)\make-docfile.exe -a $(DOC) -d $(TEMACS_SRC) $(DOC_SRC10)
 
-update-elc:
+$(LISP)\Installation.el: Installation.el
+	copy Installation.el $(LISP)
+
+update-elc: $(LISP)\Installation.el
 	!$(TEMACS) -batch -l update-elc.el
 
 rebuild: $(TEMACS_DIR)\puresize-adjust.h
@@ -636,7 +660,6 @@
 	-del /s /q *.bak *.elc *.orig *.rej
 
 depend:
-	mkdepend -f xemacs.mak -p$(OUTDIR)\ -o.obj -w2048 -- $(TEMACS_CPP_FLAGS) --  $(DOC_SRC1) $(DOC_SRC2) $(DOC_SRC3) $(DOC_SRC4) $(DOC_SRC5) $(DOC_SRC6) $(DOC_SRC7) $(DOC_SRC8) $(LASTFILE_SRC)\lastfile.c $(LIB_SRC)\make-docfile.c .\runemacs.c
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 	mkdepend -f xemacs.mak -p$(OUTDIR)\ -o.obj -w9999 -- $(TEMACS_CPP_FLAGS) --  $(DOC_SRC1) $(DOC_SRC2) $(DOC_SRC3) $(DOC_SRC4) $(DOC_SRC5) $(DOC_SRC6) $(DOC_SRC7) $(DOC_SRC8) $(DOC_SRC9) $(LASTFILE_SRC)\lastfile.c $(LIB_SRC)\make-docfile.c .\runemacs.c
--- a/src/ChangeLog	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/ChangeLog	Mon Aug 13 10:25:37 2007 +0200
@@ -1,3 +1,278 @@
+1998-03-13  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* glyphs-x.c: fix for upside-down TIFFs.
+
+1998-03-14  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* fileio.c (Finsert_file_contents_internal): Removed all DOS_NT
+	specific code; rely on FILE_CODING streams instead.
+	(Fwrite_region_internal): Ditto.
+	(decide_buffer_type): Function removed.
+	(buf_decide_buffer_type): Function removed.
+	(Many places): References to DOS_NT replaced with WINDOWSNT. MSDOS- 
+	specific code removed.
+
+	* lread.c (Fload_internal): Removed ugly DOS style re-opening a
+	file in text mode. '\r' is perfectly handled in readevallop().
+
+	* redisplay.c (decode_mode_spec): Made %t decode to "T" unconditionally.
+
+	* s/windowsnt.h (FILE_CODING): Define always.
+
+1998-03-15  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* s/windowsnt.h: Added prototypes for generally used functions
+	implemented in nt.c
+
+	* fileio.c (Ffile_readable_p): Conditionalized declared never used
+	variables. 
+	(Fexpand_file_name): Ditto.
+	(check_executable): Ditto.
+
+	* lread.c (parse_integer): Eliminated a warning resulted from
+	applying unary minus to unsigned int.
+
+1998-03-15  Oscar Figueiredo  <Oscar.Figueiredo@di.epfl.ch>
+
+	* eldap.c: (Fldap_search_internal): Print error information from
+	errno when connection fails
+
+1998-03-16  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* lread.c: New macro, to avoid exposing an lstream to Lisp error
+ 	handlers.
+	(reader_nextchar): Use it.
+	(read1): Ditto.
+
+1998-03-15  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* cmds.c (Fforward_char): Dropped support for
+	  signal-error-on-buffer-boundary.  Added details to
+	  doc string.
+
+	  (Fbackward_char): Dropped support for
+	  signal-error-on-buffer-boundary by way of change to
+	  Fforward_char.  Added details to doc string.
+
+	  Definition of signal-error-on-buffer-boundary moved to
+	  lisp/simple.el.
+
+	* window.c (Fscroll_up): Dropped support for
+	  signal-error-on-buffer-boundary.  Added details to
+	  doc string.
+
+	  (Fscroll_down): Dropped support for
+	  signal-error-on-buffer-boundary.  Added details to doc
+	  string.
+
+1998-03-15  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* keydefs.el: Changed keybindings of forward-char,
+	  backward, scroll-up and scroll-down to point to their
+	  -command counterparts.
+
+	* simple.el: New functions: forwarc-char-command,
+	  backwrad-char-command, scroll-up-command,
+	  scroll-down-command which work liek their counterparts
+	  except that they honor the variable
+	  signal-error-on-buffer-boundary.
+
+	  Definition of signal-error-on-buffer-boundary received
+	  from src/cmds.c.
+
+	  defvar declaration added for word-across-newline to avoid
+	  byte-compiler warning about the free variable reference.
+
+1998-03-15  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* redisplay-tty.c (tty_clear_frame): Record that the
+	  real location of teh cursor has been moved to 0,0.
+	  Failure to do this makes the display code believe the
+	  cursor is in a place where it is not.
+
+1998-03-15  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* console.h: Added set_final_cursor_coords method to console 
+	  struct.
+
+	* console-tty.h: Added final_cursor_x and final_cursor_y
+	  slots to console struct.  Added CONSOLE_TTY_FINAL_CURSOR
+	  macros to access them.
+
+	* redisplay.c (create_text_block): No longer
+	  turn off the cursor if computing a block when
+	  cursor_in_echo_area is 0 and the echo area is
+	  inactive.  Needed so that the cursor will not be
+	  frozen in the minibuffer when cursor_in_echo_area
+	  is non-zero.
+
+	* redisplay-output.c (redisplay_move_cursor): Don't
+	  bail if we're moving the cursor in a selected
+	  minibuffer window.  Needed so that simple cursor
+	  optimization can be done in the minibuffer even when
+	  cursor_in_echo_area is non-zero.
+
+	  (redraw_cursor_in_window): Set final cursor coordinates
+	  as a special case for cursor_in_echo_area != 0, since
+	  the buffer switching between minibuffer and echo area
+	  buffer seems to confuse the normal cursor positiong
+	  code otherwise.  Set final cursor coordinates in the
+	  general case before calling output_display_line.
+
+	* redisplay-tty.c: New function tty_set_final_cursor_coords.
+
+	  (tty_output_end): Set logical cursor position to the final
+	  cursor position as specified in CONSOLE_TTY_CURSOR_{X,Y},
+	  and then go to it.
+
+	  (tty_redisplay_shutdown): Changed code to use
+	  tty_set_final_cursor_coords() to go to the bottom
+	  left of the screen instead of using cmgoto()
+
+	  (console_type_create_redisplay_tty): Declare that tty
+	  consoles have the set_final_cursor_coords method.
+
+1998-03-13  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* emacs.c (main_1): Avoid snprintf(); allocate the buffer
+	dynamically.
+
+1998-03-13  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* glyphs-x.c (png_instantiate): Added in override support
+	for png backgrounds.
+	
+1998-03-13  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* glyphs-x.c (png_instantiate): Fixed a bug that was causing
+	overruns when attempting to display transparent pngs
+
+1998-03-13  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* glyphs-x.c (png_instantiate): Fix brainfart in error handling code.
+
+1998-03-13  SL Baur  <steve@altair.xemacs.org>
+
+	* emacs.c (main_1): Guard call to snprintf.
+
+	* config.h.in: Add HAVE_SNPRINTF.
+
+1998-03-13  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* event-stream.c (init_event_stream): Initialize mswindows event
+	loop in stream mode if no other window systems available. Thanks
+	to Darryl Okahata.
+
+1998-03-04  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* alloc.c (garbage_collect_1): Removed #ifndef WINDOWSNT around
+	mark_profiling_info().
+
+1998-03-11  SL Baur  <steve@altair.xemacs.org>
+
+	* console-tty.c (Fset_console_tty_coding_system): Guard against
+	terminal-coding-system being left unitialized by a locale.
+	From Kazuyuki IENAGA <ienaga@jsys.co.jp>
+
+1998-03-11  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* config.h.in: Added in new feature check HAVE_VSNPRINT to check
+	for safe ways to deal with vsprintf and friends.
+
+	* glyphs-x.c (gif_instantiate): Changed gif support to call external
+	library Giflib 3.1.  Altered GIF/JPEG/PNG formats to use new EImage
+	format for dealing with images to better support color handling, and
+	facilitate the change to a device-neutral implementation.  Added TIFF
+	support.
+
+	* Makefile.in.in: Removed all gif related files
+
+	* emacs.c (main_1): Removed reference to init_gif_err
+	* symsinit.h: ditto
+
+	* dgif_lib.c: Removed from the source distribution
+	* gif_err.c: ditto
+	* gif_lib.h: ditto
+	* gifalloc.c: ditto
+
+Mon Mar 09 13:00:55 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* file-coding.c: warning elimination
+
+	* ntplay.c: new file. basic implementation of sound support.
+
+	* redisplay-msw.c (mswindows_update_dc): cachel bug is gone so we
+	don't need this code under cygwin.
+
+	* sheap.c: need large heap slop for byte compiling with three
+	display types.
+
+	* sound.c: eliminate warnings. enable sound under mswindows.
+
+	* s/cygwin32.h: miscellaneous updates for sound support.
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* config.h.in: Add BITMAPDIR.
+
+	* glyphs-x.c (locate_pixmap_file): Assume BITMAPDIR is a
+	colon-separated path.
+
+	* emacs.c (main_1): Initialize dll support with the path the
+	binary.
+	(make_arg_list_1): Ditto.
+
+	* sysdll.h: Add legalese.
+	* sysdll.c: Ditto.
+
+	* sysdll.c: sysdll.h needs to be included with double quotes not
+	angle brackets.
+	Use RTLD_GLOBAL as an open flag if it exists.
+
+1998-03-09  Martin Buchholz  <Martin Buchholz <martin@xemacs.org>>
+
+	* eldap.c (Fldap_search_internal): call garbage_collect_1 instead
+	of Fgarbage_collect.  The two are identical except the latter
+	generates some `fresh' garbage :)
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* keymap.c: Add symbols for mouse-4 and mouse-5.
+	(define_key_check_and_coerce_keysym): Mouse-4, Mouse-5 keysym support.
+	(syms_of_keymap): Ditto.
+
+1998-01-26  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* marker.c (print_marker): Print marker's lheader.uid.
+	(Fbuffer_has_markers_at): New function, synched with FSFmacs 20.2.
+	(Fbuffer_has_markers_at): Disabled by default.
+
+1998-01-25  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* sound.c (Fplay_sound_file): Place the result of continuable
+	error back to FILE.
+
+1998-03-09  SL Baur  <steve@altair.xemacs.org>
+
+	* emacs.c, config.h.in: New DLL support.
+	* sysdll.h, sysdll.c: New files.
+	* dll.c: renamed from dlopen.c, use interface defined in sysdll.c.
+	From William Perry <wmperry@aventail.com>
+
+	* eldap.h: Fix copyright.
+	* eldap.c: Ditto.
+
+1998-03-08  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile.in.in: Add dependencies for process-unix.o.
+
+1998-03-08  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* glyphs-x.c (write_lisp_string_to_temp_file):
+	  Don't explicitly initialize conversion_out_dynarr, because
+	  doing so may cause it to be put into read-only space
+	  and modifying it later would make XEmacs crash.
+
 1998-03-07  Kyle Jones  <kyle_jones@wonderworks.com>
 
 	* events.h: Add do_backspace_mapping parameter to
--- a/src/Makefile.in.in	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/Makefile.in.in	Mon Aug 13 10:25:37 2007 +0200
@@ -120,7 +120,7 @@
 OFFIX_O = @OFFIX_O@
 
 x_objs=balloon_help.o balloon-x.o console-x.o device-x.o event-Xt.o frame-x.o\
- glyphs-x.o objects-x.o redisplay-x.o xgccache.o xselect.o
+ glyphs-x.o objects-x.o redisplay-x.o xgccache.o xselect.o imgproc.o
 
 #ifdef AIX4
 LIBI18N = -li18n
@@ -786,6 +786,7 @@
 console-tty.o: file-coding.h
 event-Xt.o: file-coding.h
 event-stream.o: file-coding.h
+file-coding.o: config.h
 file-coding.o: buffer.h
 file-coding.o: elhash.h
 file-coding.o: file-coding.h
@@ -806,6 +807,7 @@
 mule-ccl.o: file-coding.h
 #endif
 process.o: file-coding.h
+process-unix.o: file-coding.h
 redisplay-x.o: file-coding.h
 redisplay.o: file-coding.h
 #endif
@@ -1491,8 +1493,6 @@
 device.o: systime.h
 device.o: toolbar.h
 device.o: window.h
-dgif_lib.o: config.h
-dgif_lib.o: gif_lib.h
 dialog-x.o: $(LWLIB_SRCDIR)/lwlib.h
 dialog-x.o: EmacsFrame.h
 dialog-x.o: EmacsManager.h
@@ -1916,10 +1916,6 @@
 getloadavg.o: blocktype.h
 getloadavg.o: config.h
 getloadavg.o: dynarr.h
-gif_err.o: config.h
-gif_err.o: gif_lib.h
-gifalloc.o: config.h
-gifalloc.o: gif_lib.h
 glyphs-x.o: $(LWLIB_SRCDIR)/lwlib.h
 glyphs-x.o: ${srcdir}/${etcdir}xemacs.xbm
 glyphs-x.o: bitmaps.h
@@ -1934,7 +1930,6 @@
 glyphs-x.o: dynarr.h
 glyphs-x.o: frame.h
 glyphs-x.o: frameslots.h
-glyphs-x.o: gif_lib.h
 glyphs-x.o: glyphs-x.h
 glyphs-x.o: glyphs.h
 glyphs-x.o: insdel.h
@@ -1947,6 +1942,9 @@
 glyphs-x.o: toolbar.h
 glyphs-x.o: xintrinsic.h
 glyphs-x.o: xmu.h
+glyphs-x.o: imgproc.h
+imgproc.o: imgproc.h
+imgproc.o: config.h
 glyphs.o: blocktype.h
 glyphs.o: buffer.h
 glyphs.o: bufslots.h
@@ -2316,6 +2314,23 @@
 print.o: specifier.h
 print.o: systty.h
 print.o: toolbar.h
+process-unix.o: config.h
+process-unix.o: buffer.h
+process-unix.o: commands.h
+process-unix.o: events.h
+process-unix.o: frame.h
+process-unix.o: insdel.h
+process-unix.o: lstream.h
+process-unix.o: opaque.h
+process-unix.o: process.h
+process-unix.o: procimpl.h
+process-unix.o: window.h
+process-unix.o: sysfile.h
+process-unix.o: sysproc.h
+process-unix.o: systime.h
+process-unix.o: syssignal.h
+process-unix.o: systty.h
+process-unix.o: syswait.h
 process.o: blocktype.h
 process.o: buffer.h
 process.o: bufslots.h
--- a/src/alloc.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/alloc.c	Mon Aug 13 10:25:37 2007 +0200
@@ -4473,9 +4473,7 @@
       }
 
     mark_redisplay (mark_object);
-#ifndef WINDOWSNT
     mark_profiling_info (mark_object);
-#endif
   }
 
   /* OK, now do the after-mark stuff.  This is for things that
--- a/src/cmds.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/cmds.c	Mon Aug 13 10:25:37 2007 +0200
@@ -41,16 +41,12 @@
 
 /* This is the command that set up Vself_insert_face.  */
 Lisp_Object Vself_insert_face_command;
-
-/* t means beep when movement would take point past (point-min) or */
-/* (point-max) */
-int signal_error_on_buffer_boundary;
 
 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /*
 Move point right ARG characters (left if ARG negative).
+On attempt to pass end of buffer, stop and signal `end-of-buffer'.
+On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
 On reaching end of buffer, stop and signal error.
-Error signaling is suppressed if `signal-error-on-buffer-boundary'
-is nil.  If BUFFER is nil, the current buffer is assumed.
 */
        (arg, buffer))
 {
@@ -72,18 +68,14 @@
     if (new_point < BUF_BEGV (buf))
       {
 	BUF_SET_PT (buf, BUF_BEGV (buf));
-	if (signal_error_on_buffer_boundary)
-	  Fsignal (Qbeginning_of_buffer, Qnil);
-	else
-	  return Qnil;
+	Fsignal (Qbeginning_of_buffer, Qnil);
+	return Qnil;
       }
     if (new_point > BUF_ZV (buf))
       {
 	BUF_SET_PT (buf, BUF_ZV (buf));
-	if (signal_error_on_buffer_boundary)
-	  Fsignal (Qend_of_buffer, Qnil);
-	else
-	  return Qnil;
+	Fsignal (Qend_of_buffer, Qnil);
+	return Qnil;
       }
 
     BUF_SET_PT (buf, new_point);
@@ -94,9 +86,8 @@
 
 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /*
 Move point left ARG characters (right if ARG negative).
-On attempt to pass beginning or end of buffer, stop and signal error.
-Error signaling is suppressed if `signal-error-on-buffer-boundary'
-is nil.  If BUFFER is nil, the current buffer is assumed.
+On attempt to pass end of buffer, stop and signal `end-of-buffer'.
+On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
 */
        (arg, buffer))
 {
@@ -510,10 +501,4 @@
 More precisely, a char with closeparen syntax is self-inserted.
 */ );
   Vblink_paren_function = Qnil;
-
-  DEFVAR_BOOL ("signal-error-on-buffer-boundary", &signal_error_on_buffer_boundary /*
-*t means beep when movement would take point past (point-min) or
-\(point-max).
-*/ );
-  signal_error_on_buffer_boundary = 1;
 }
--- a/src/config.h.in	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/config.h.in	Mon Aug 13 10:25:37 2007 +0200
@@ -148,6 +148,9 @@
 #undef THIS_IS_X11R5
 #undef THIS_IS_X11R6
 
+/* Where do we find bitmaps? */
+#undef BITMAPDIR
+
 /* USER_FULL_NAME returns a string that is the user's full name.
    It can assume that the variable `pw' points to the password file
    entry for this user.
@@ -194,7 +197,10 @@
 /* Use lock files to detect multiple edits of the same file? */
 #undef CLASH_DETECTION
 
-/* Have shared library support (currently only dlopen() supported?  */
+/* Have shared library support */
+#undef HAVE_DLOPEN
+#undef HAVE_SHL_LOAD
+#undef HAVE_DLD_INIT
 #undef HAVE_SHLIB
 
 #undef HAVE_LIBKSTAT
@@ -272,6 +278,7 @@
 #undef HAVE_SIGHOLD
 #undef HAVE_SIGPROCMASK
 #undef HAVE_SIGSETJMP
+#undef HAVE_SNPRINTF
 #undef HAVE_STRCASECMP
 #undef HAVE_STRERROR
 #undef HAVE_TZSET
@@ -279,7 +286,7 @@
 #undef HAVE_USLEEP
 #undef HAVE_UTIMES
 #undef HAVE_WAITPID
-
+#undef HAVE_VSNPRINTF
 #undef HAVE_SOCKETS
 #undef HAVE_SOCKADDR_SUN_LEN
 #undef HAVE_MULTICAST
--- a/src/console-tty.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/console-tty.c	Mon Aug 13 10:25:37 2007 +0200
@@ -238,8 +238,10 @@
   codesys = NILP (codesys) ?
     Vterminal_coding_system :
     Fget_coding_system (codesys);
-  set_encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
+  if (!NILP(codesys)) {
+    set_encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
 	codesys);
+  }
   return Qnil;
 }
 #endif /* MULE */
--- a/src/console-tty.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/console-tty.h	Mon Aug 13 10:25:37 2007 +0200
@@ -58,6 +58,9 @@
   int real_cursor_x;
   int real_cursor_y;
 
+  int final_cursor_x;
+  int final_cursor_y;
+
   int height;
   int width;
 
@@ -208,6 +211,8 @@
 #define CONSOLE_TTY_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->cursor_y)
 #define CONSOLE_TTY_REAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->real_cursor_x)
 #define CONSOLE_TTY_REAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->real_cursor_y)
+#define CONSOLE_TTY_FINAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->final_cursor_x)
+#define CONSOLE_TTY_FINAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->final_cursor_y)
 
 #define TTY_CM(c) (CONSOLE_TTY_DATA (c)->cm)
 #define TTY_SE(c) (CONSOLE_TTY_DATA (c)->se)
--- a/src/console.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/console.h	Mon Aug 13 10:25:37 2007 +0200
@@ -132,6 +132,7 @@
   void (*ring_bell_method) (struct device *, int volume, int pitch,
 			    int duration);
   void (*frame_redraw_cursor_method) (struct frame *f);
+  void (*set_final_cursor_coords_method) (struct frame *, int, int);
 
   /* color methods */
   int (*initialize_color_instance_method) (struct Lisp_Color_Instance *,
--- a/src/dgif_lib.c	Mon Aug 13 10:24:47 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1013 +0,0 @@
-/* Synched up with: Not in FSF. */
-
-/******************************************************************************
-*   "Gif-Lib" - Yet another gif library.				      *
-*									      *
-* Written by:  Gershon Elber			IBM PC Ver 1.1,	Aug. 1990     *
-*******************************************************************************
-* The kernel of the GIF Decoding process can be found here.		      *
-*******************************************************************************
-* History:								      *
-* 16 Jun 89 - Version 1.0 by Gershon Elber.				      *
-*  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
-******************************************************************************/
-
-#ifdef emacs
-#include <config.h>
-#endif /* emacs */
-
-#ifdef __MSDOS__
-#include <io.h>
-#include <alloc.h>
-#include <stdlib.h>
-#include <sys\stat.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif /* __MSDOS__ */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "gif_lib.h"
-#ifndef emacs
-#include "gif_hash.h"
-#endif
-
-#ifdef emacs
-void *xmalloc (size_t size);
-void *xrealloc (void *ptr, size_t size);
-#ifdef ERROR_CHECK_MALLOC
-void *xfree_1 (void *);
-#define xfree xfree_1
-#else
-void *xfree (void *);
-#endif
-#endif /* emacs */
-
-
-#define PROGRAM_NAME	"GIF_LIBRARY"
-
-#define COMMENT_EXT_FUNC_CODE	0xfe /* Extension function code for comment. */
-#define GIF_STAMP	"GIFVER"	 /* First chars in file - GIF stamp. */
-#define GIF_STAMP_LEN	sizeof(GIF_STAMP) - 1
-#define GIF_VERSION_POS	3		/* Version first character in stamp. */
-
-#define LZ_MAX_CODE	4095		/* Biggest code possible in 12 bits. */
-#define LZ_BITS		12
-
-#define FILE_STATE_READ		0x01/* 1 write, 0 read - EGIF_LIB compatible.*/
-
-#define FLUSH_OUTPUT		4096    /* Impossible code, to signal flush. */
-#define FIRST_CODE		4097    /* Impossible code, to signal first. */
-#define NO_SUCH_CODE		4098    /* Impossible code, to signal empty. */
-
-#define IS_READABLE(Private)	(!(Private->FileState & FILE_STATE_READ))
-
-typedef struct GifFilePrivateType {
-    int FileState,
-	FileHandle,			     /* Where all this data goes to! */
-	BitsPerPixel,	    /* Bits per pixel (Codes uses at list this + 1). */
-	ClearCode,				       /* The CLEAR LZ code. */
-	EOFCode,				         /* The EOF LZ code. */
-	RunningCode,		    /* The next code algorithm can generate. */
-	RunningBits,/* The number of bits required to represent RunningCode. */
-	MaxCode1,  /* 1 bigger than max. possible code, in RunningBits bits. */
-	LastCode,		        /* The code before the current code. */
-	CrntCode,				  /* Current algorithm code. */
-	StackPtr,		         /* For character stack (see below). */
-	CrntShiftState;		        /* Number of bits in CrntShiftDWord. */
-    unsigned long CrntShiftDWord;     /* For bytes decomposition into codes. */
-    long PixelCount;			       /* Number of pixels in image. */
-    FILE *File;						  /* File as stream. */
-    GifByteType Buf[256];	       /* Compressed input is buffered here. */
-    GifByteType Stack[LZ_MAX_CODE];	 /* Decoded pixels are stacked here. */
-    GifByteType Suffix[LZ_MAX_CODE+1];	       /* So we can trace the codes. */
-    unsigned int Prefix[LZ_MAX_CODE+1];
-} GifFilePrivateType;
-
-#ifndef emacs
-#ifdef SYSV
-static char *VersionStr =
-        "Gif library module,\t\tGershon Elber\n\
-	(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
-#else
-static char *VersionStr =
-	PROGRAM_NAME
-	"	IBMPC "
-	GIF_LIB_VERSION
-	"	Gershon Elber,	"
-	__DATE__ ",   " __TIME__ "\n"
-	"(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
-#endif /* SYSV */
-#endif /* !emacs */
-
-extern int _GifError;
-
-static int DGifGetWord(FILE *File, int *Word);
-static int DGifSetupDecompress(GifFileType *GifFile);
-static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
-								int LineLen);
-static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode);
-static int DGifDecompressInput(GifFilePrivateType *Private, int *Code);
-static int DGifBufferedInput(FILE *File, GifByteType *Buf,
-						     GifByteType *NextByte);
-
-/******************************************************************************
-*   Open a new gif file for read, given by its name.			      *
-*   Returns GifFileType pointer dynamically allocated which serves as the gif *
-* info record. _GifError is cleared if succesfull.			      *
-******************************************************************************/
-GifFileType *DGifOpenFileName(CONST char *FileName)
-{
-    int FileHandle;
-
-    if ((FileHandle = open(FileName, O_RDONLY
-#ifdef __MSDOS__
-			           | O_BINARY
-#endif /* __MSDOS__ */
-			                     )) == -1) {
-	_GifError = D_GIF_ERR_OPEN_FAILED;
-	return NULL;
-    }
-
-    return DGifOpenFileHandle(FileHandle);
-}
-
-/******************************************************************************
-*   Update a new gif file, given its file handle.			      *
-*   Returns GifFileType pointer dynamically allocated which serves as the gif *
-* info record. _GifError is cleared if succesfull.			      *
-******************************************************************************/
-GifFileType *DGifOpenFileHandle(int FileHandle)
-{
-    char Buf[GIF_STAMP_LEN+1];
-    GifFileType *GifFile;
-    GifFilePrivateType *Private;
-    FILE *f;
-
-#ifdef __MSDOS__
-    setmode(FileHandle, O_BINARY);	  /* Make sure it is in binary mode. */
-    f = fdopen(FileHandle, "rb");		   /* Make it into a stream: */
-    setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/
-#else
-    f = fdopen(FileHandle, "r");		   /* Make it into a stream: */
-#endif /* __MSDOS__ */
-
-    if ((GifFile = (GifFileType *) xmalloc(sizeof(GifFileType))) == NULL) {
-	_GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
-	return NULL;
-    }
-
-    memset(GifFile, '\0', sizeof(GifFileType));
-
-    if ((Private = (GifFilePrivateType *) xmalloc(sizeof(GifFilePrivateType)))
-	== NULL) {
-	_GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
-	xfree((char *) GifFile);
-	return NULL;
-    }
-    GifFile->Private = (VoidPtr) Private;
-    Private->FileHandle = FileHandle;
-    Private->File = f;
-    Private->FileState = 0;   /* Make sure bit 0 = 0 (File open for read). */
-
-    /* Lets see if this is a GIF file: */
-    if (fread(Buf, 1, GIF_STAMP_LEN, Private->File) != GIF_STAMP_LEN) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	xfree((char *) Private);
-	xfree((char *) GifFile);
-	return NULL;
-    }
-
-    /* The GIF Version number is ignored at this time. Maybe we should do    */
-    /* something more useful with it.					     */
-    Buf[GIF_STAMP_LEN] = 0;
-    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
-	_GifError = D_GIF_ERR_NOT_GIF_FILE;
-	xfree((char *) Private);
-	xfree((char *) GifFile);
-	return NULL;
-    }
-
-    if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
-	xfree((char *) Private);
-	xfree((char *) GifFile);
-	return NULL;
-    }
-
-    _GifError = 0;
-
-    return GifFile;
-}
-
-/******************************************************************************
-*   This routine should be called before any other DGif calls. Note that      *
-* this routine is called automatically from DGif file open routines.	      *
-******************************************************************************/
-int DGifGetScreenDesc(GifFileType *GifFile)
-{
-    int i, BitsPerPixel;
-    GifByteType Buf[3];
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    /* Put the screen descriptor into the file: */
-    if (DGifGetWord(Private->File, &GifFile->SWidth) == GIF_ERROR ||
-	DGifGetWord(Private->File, &GifFile->SHeight) == GIF_ERROR)
-	return GIF_ERROR;
-
-    if (fread(Buf, 1, 3, Private->File) != 3) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-    GifFile->SColorResolution = ((int) ((Buf[0] & 0x70) + 1) >> 4) + 1;
-    BitsPerPixel = (Buf[0] & 0x07) + 1;
-    GifFile->SBackGroundColor = Buf[1];
-    if (Buf[0] & 0x80) {		     /* Do we have global color map? */
-
-	GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
-
-	/* Get the global color map: */
-	for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
-	    if (fread(Buf, 1, 3, Private->File) != 3) {
-		_GifError = D_GIF_ERR_READ_FAILED;
-		return GIF_ERROR;
-	    }
-	    GifFile->SColorMap->Colors[i].Red = Buf[0];
-	    GifFile->SColorMap->Colors[i].Green = Buf[1];
-	    GifFile->SColorMap->Colors[i].Blue = Buf[2];
-	}
-    } else {
-	/* XEmacs assumes we always have a colormap */
-	GifFile->SColorMap = MakeMapObject(2, NULL);
-	GifFile->SColorMap->Colors[0].Red = 0;
-	GifFile->SColorMap->Colors[0].Green = 0;
-	GifFile->SColorMap->Colors[0].Blue = 0;
-	GifFile->SColorMap->Colors[1].Red = 0xff;
-	GifFile->SColorMap->Colors[1].Green = 0xff;
-	GifFile->SColorMap->Colors[1].Blue = 0xff;
-    }
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   This routine should be called before any attemp to read an image.         *
-******************************************************************************/
-int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type)
-{
-    GifByteType Buf;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    if (fread(&Buf, 1, 1, Private->File) != 1) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-
-    switch (Buf) {
-	case ',':
-	    *Type = IMAGE_DESC_RECORD_TYPE;
-	    break;
-	case '!':
-	    *Type = EXTENSION_RECORD_TYPE;
-	    break;
-	case ';':
-	    *Type = TERMINATE_RECORD_TYPE;
-	    break;
-	default:
-	    *Type = UNDEFINED_RECORD_TYPE;
-	    _GifError = D_GIF_ERR_WRONG_RECORD;
-	    return GIF_ERROR;
-    }
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   This routine should be called before any attemp to read an image.         *
-*   Note it is assumed the Image desc. header (',') has been read.	      *
-******************************************************************************/
-int DGifGetImageDesc(GifFileType *GifFile)
-{
-    int i, BitsPerPixel;
-    GifByteType Buf[3];
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    if (DGifGetWord(Private->File, &GifFile->Image.Left) == GIF_ERROR ||
-	DGifGetWord(Private->File, &GifFile->Image.Top) == GIF_ERROR ||
-	DGifGetWord(Private->File, &GifFile->Image.Width) == GIF_ERROR ||
-	DGifGetWord(Private->File, &GifFile->Image.Height) == GIF_ERROR)
-	return GIF_ERROR;
-    if (fread(Buf, 1, 1, Private->File) != 1) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-    BitsPerPixel = (Buf[0] & 0x07) + 1;
-    GifFile->Image.Interlace = (Buf[0] & 0x40);
-    if (Buf[0] & 0x80) {	    /* Does this image have local color map? */
-
-	if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL)
-	    FreeMapObject(GifFile->Image.ColorMap);
-
-	GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
-
-	/* Get the image local color map: */
-	for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
-	    if (fread(Buf, 1, 3, Private->File) != 3) {
-		_GifError = D_GIF_ERR_READ_FAILED;
-		return GIF_ERROR;
-	    }
-	    GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
-	    GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
-	    GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
-	}
-    }
-
-    if (GifFile->SavedImages) {
-	SavedImage	*sp;
-
-	if ((GifFile->SavedImages = (SavedImage *)xrealloc(GifFile->SavedImages,
-		    sizeof(SavedImage) * (GifFile->ImageCount + 1))) == NULL) {
-	    _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
-	    return GIF_ERROR;
-	}
-
-	sp = &GifFile->SavedImages[GifFile->ImageCount];
-	memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
-	if (GifFile->Image.ColorMap)
-	  {
-	    sp->ImageDesc.ColorMap =
-	      MakeMapObject (GifFile->Image.ColorMap->ColorCount,
-			     GifFile->Image.ColorMap->Colors);
-	  }
-	sp->RasterBits = (GifPixelType *)NULL;
-	sp->ExtensionBlockCount = 0;
-	sp->ExtensionBlocks = (ExtensionBlock *)NULL;
-    }
-
-    GifFile->ImageCount++;
-
-    Private->PixelCount = (long) GifFile->Image.Width *
-			    (long) GifFile->Image.Height;
-
-    DGifSetupDecompress(GifFile);  /* Reset decompress algorithm parameters. */
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*  Get one full scanned line (Line) of length LineLen from GIF file.	      *
-******************************************************************************/
-int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
-{
-    GifByteType *Dummy;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    if (!LineLen) LineLen = GifFile->Image.Width;
-
-#ifdef __MSDOS__
-    if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
-#else
-    if ((unsigned) (Private->PixelCount -= LineLen) > 0xffff0000) {
-#endif /* __MSDOS__ */
-	_GifError = D_GIF_ERR_DATA_TOO_BIG;
-	return GIF_ERROR;
-    }
-
-    if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
-	if (Private->PixelCount == 0) {
-	    /* We probably would not be called any more, so lets clean 	     */
-	    /* everything before we return: need to flush out all rest of    */
-	    /* image until empty block (size 0) detected. We use GetCodeNext.*/
-	    do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
-		return GIF_ERROR;
-	    while (Dummy != NULL);
-	}
-	return GIF_OK;
-    }
-    else
-	return GIF_ERROR;
-}
-
-/******************************************************************************
-* Put one pixel (Pixel) into GIF file.					      *
-******************************************************************************/
-int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel)
-{
-    GifByteType *Dummy;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-#ifdef __MSDOS__
-    if (--Private->PixelCount > 0xffff0000UL)
-#else
-    if ((unsigned) --Private->PixelCount > 0xffff0000)
-#endif /* __MSDOS__ */
-    {
-	_GifError = D_GIF_ERR_DATA_TOO_BIG;
-	return GIF_ERROR;
-    }
-
-    if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
-	if (Private->PixelCount == 0) {
-	    /* We probably would not be called any more, so lets clean 	     */
-	    /* everything before we return: need to flush out all rest of    */
-	    /* image until empty block (size 0) detected. We use GetCodeNext.*/
-	    do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
-		return GIF_ERROR;
-	    while (Dummy != NULL);
-	}
-	return GIF_OK;
-    }
-    else
-	return GIF_ERROR;
-}
-
-/******************************************************************************
-*   Get an extension block (see GIF manual) from gif file. This routine only  *
-* returns the first data block, and DGifGetExtensionNext shouldbe called      *
-* after this one until NULL extension is returned.			      *
-*   The Extension should NOT be freed by the user (not dynamically allocated).*
-*   Note it is assumed the Extension desc. header ('!') has been read.	      *
-******************************************************************************/
-int DGifGetExtension(GifFileType *GifFile, int *ExtCode,
-						    GifByteType **Extension)
-{
-    GifByteType Buf;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    if (fread(&Buf, 1, 1, Private->File) != 1) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-    *ExtCode = Buf;
-
-    return DGifGetExtensionNext(GifFile, Extension);
-}
-
-/******************************************************************************
-*   Get a following extension block (see GIF manual) from gif file. This      *
-* routine sould be called until NULL Extension is returned.		      *
-*   The Extension should NOT be freed by the user (not dynamically allocated).*
-******************************************************************************/
-int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension)
-{
-    GifByteType Buf;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (fread(&Buf, 1, 1, Private->File) != 1) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-    if (Buf > 0) {
-	*Extension = Private->Buf;           /* Use private unused buffer. */
-	(*Extension)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
-	if (fread(&((*Extension)[1]), 1, Buf, Private->File) != Buf) {
-	    _GifError = D_GIF_ERR_READ_FAILED;
-	    return GIF_ERROR;
-	}
-    }
-    else
-	*Extension = NULL;
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   This routine should be called last, to close the GIF file.		      *
-******************************************************************************/
-int DGifCloseFile(GifFileType *GifFile)
-{
-    GifFilePrivateType *Private;
-    FILE *File;
-
-    if (GifFile == NULL) return GIF_ERROR;
-
-    Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    File = Private->File;
-
-    if (GifFile->Image.ColorMap)
-      {
-	FreeMapObject(GifFile->Image.ColorMap);
-	GifFile->Image.ColorMap = 0;
-      }
-    if (GifFile->SColorMap)
-      {
-	FreeMapObject(GifFile->SColorMap);
-	GifFile->SColorMap = 0;
-      }
-    if (Private)
-      {
-	xfree((char *) Private);
-	GifFile->Private = 0;
-      }
-    if (GifFile->SavedImages)
-      {
-	FreeSavedImages(GifFile);
-	GifFile->SavedImages = 0;
-      }
-    xfree(GifFile);
-
-    if (fclose(File) != 0) {
-	_GifError = D_GIF_ERR_CLOSE_FAILED;
-	return GIF_ERROR;
-    }
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   Get 2 bytes (word) from the given file:				      *
-******************************************************************************/
-static int DGifGetWord(FILE *File, int *Word)
-{
-    unsigned char c[2];
-
-    if (fread(c, 1, 2, File) != 2) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-
-    *Word = (((unsigned int) c[1]) << 8) + c[0];
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   Get the image code in compressed form.  his routine can be called if the  *
-* information needed to be piped out as is. Obviously this is much faster     *
-* than decoding and encoding again. This routine should be followed by calls  *
-* to DGifGetCodeNext, until NULL block is returned.			      *
-*   The block should NOT be freed by the user (not dynamically allocated).    *
-******************************************************************************/
-int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock)
-{
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    *CodeSize = Private->BitsPerPixel;
-
-    return DGifGetCodeNext(GifFile, CodeBlock);
-}
-
-/******************************************************************************
-*   Continue to get the image code in compressed form. This routine should be *
-* called until NULL block is returned.					      *
-*   The block should NOT be freed by the user (not dynamically allocated).    *
-******************************************************************************/
-int DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
-{
-    GifByteType Buf;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (fread(&Buf, 1, 1, Private->File) != 1) {
-	_GifError = D_GIF_ERR_READ_FAILED;
-	return GIF_ERROR;
-    }
-
-    if (Buf > 0) {
-	*CodeBlock = Private->Buf;	       /* Use private unused buffer. */
-	(*CodeBlock)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
-	if (fread(&((*CodeBlock)[1]), 1, Buf, Private->File) != Buf) {
-	    _GifError = D_GIF_ERR_READ_FAILED;
-	    return GIF_ERROR;
-	}
-    }
-    else {
-	*CodeBlock = NULL;
-	Private->Buf[0] = 0;		   /* Make sure the buffer is empty! */
-	Private->PixelCount = 0;   /* And local info. indicate image read. */
-    }
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   Setup the LZ decompression for this image:				      *
-******************************************************************************/
-static int DGifSetupDecompress(GifFileType *GifFile)
-{
-    int i, BitsPerPixel;
-    GifByteType CodeSize;
-    unsigned int *Prefix;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    fread(&CodeSize, 1, 1, Private->File);    /* Read Code size from file. */
-    BitsPerPixel = CodeSize;
-
-    Private->Buf[0] = 0;			      /* Input Buffer empty. */
-    Private->BitsPerPixel = BitsPerPixel;
-    Private->ClearCode = (1 << BitsPerPixel);
-    Private->EOFCode = Private->ClearCode + 1;
-    Private->RunningCode = Private->EOFCode + 1;
-    Private->RunningBits = BitsPerPixel + 1;	 /* Number of bits per code. */
-    Private->MaxCode1 = 1 << Private->RunningBits;     /* Max. code + 1. */
-    Private->StackPtr = 0;		    /* No pixels on the pixel stack. */
-    Private->LastCode = NO_SUCH_CODE;
-    Private->CrntShiftState = 0;	/* No information in CrntShiftDWord. */
-    Private->CrntShiftDWord = 0;
-
-    Prefix = Private->Prefix;
-    for (i = 0; i <= LZ_MAX_CODE; i++) Prefix[i] = NO_SUCH_CODE;
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   The LZ decompression routine:					      *
-*   This version decompress the given gif file into Line of length LineLen.   *
-*   This routine can be called few times (one per scan line, for example), in *
-* order the complete the whole image.					      *
-******************************************************************************/
-static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
-								int LineLen)
-{
-    int i = 0, j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
-    GifByteType *Stack, *Suffix;
-    unsigned int *Prefix;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    StackPtr = Private->StackPtr;
-    Prefix = Private->Prefix;
-    Suffix = Private->Suffix;
-    Stack = Private->Stack;
-    EOFCode = Private->EOFCode;
-    ClearCode = Private->ClearCode;
-    LastCode = Private->LastCode;
-
-    if (StackPtr != 0) {
-	/* Let pop the stack off before continueing to read the gif file: */
-	while (StackPtr != 0 && i < LineLen) Line[i++] = Stack[--StackPtr];
-    }
-
-    while (i < LineLen) {			    /* Decode LineLen items. */
-	if (DGifDecompressInput(Private, &CrntCode) == GIF_ERROR)
-    	    return GIF_ERROR;
-
-	if (CrntCode == EOFCode) {
-	    /* Note however that usually we will not be here as we will stop */
-	    /* decoding as soon as we got all the pixel, or EOF code will    */
-	    /* not be read at all, and DGifGetLine/Pixel clean everything.   */
-	    if (i != LineLen - 1 || Private->PixelCount != 0) {
-		_GifError = D_GIF_ERR_EOF_TOO_SOON;
-		return GIF_ERROR;
-	    }
-	    i++;
-	}
-	else if (CrntCode == ClearCode) {
-	    /* We need to start over again: */
-	    for (j = 0; j <= LZ_MAX_CODE; j++) Prefix[j] = NO_SUCH_CODE;
-	    Private->RunningCode = Private->EOFCode + 1;
-	    Private->RunningBits = Private->BitsPerPixel + 1;
-	    Private->MaxCode1 = 1 << Private->RunningBits;
-	    LastCode = Private->LastCode = NO_SUCH_CODE;
-	}
-	else {
-	    /* Its regular code - if in pixel range simply add it to output  */
-	    /* stream, otherwise trace to codes linked list until the prefix */
-	    /* is in pixel range:					     */
-	    if (CrntCode < ClearCode) {
-		/* This is simple - its pixel scalar, so add it to output:   */
-		Line[i++] = CrntCode;
-	    }
-	    else {
-		/* Its a code to needed to be traced: trace the linked list  */
-		/* until the prefix is a pixel, while pushing the suffix     */
-		/* pixels on our stack. If we done, pop the stack in reverse */
-		/* (thats what stack is good for!) order to output.	     */
-		if (Prefix[CrntCode] == NO_SUCH_CODE) {
-		    /* Only allowed if CrntCode is exactly the running code: */
-		    /* In that case CrntCode = XXXCode, CrntCode or the	     */
-		    /* prefix code is last code and the suffix char is	     */
-		    /* exactly the prefix of last code!			     */
-		    if (CrntCode == Private->RunningCode - 2) {
-			CrntPrefix = LastCode;
-			Suffix[Private->RunningCode - 2] =
-			Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
-							LastCode, ClearCode);
-		    }
-		    else {
-			_GifError = D_GIF_ERR_IMAGE_DEFECT;
-			return GIF_ERROR;
-		    }
-		}
-		else
-		    CrntPrefix = CrntCode;
-
-		/* Now (if image is O.K.) we should not get an NO_SUCH_CODE  */
-		/* During the trace. As we might loop forever, in case of    */
-		/* defective image, we count the number of loops we trace    */
-		/* and stop if we got LZ_MAX_CODE. obviously we can not      */
-		/* loop more than that.					     */
-		j = 0;
-		while (j++ <= LZ_MAX_CODE &&
-		       CrntPrefix > ClearCode &&
-		       CrntPrefix <= LZ_MAX_CODE) {
-		    Stack[StackPtr++] = Suffix[CrntPrefix];
-		    CrntPrefix = Prefix[CrntPrefix];
-		}
-		if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) {
-		    _GifError = D_GIF_ERR_IMAGE_DEFECT;
-		    return GIF_ERROR;
-		}
-		/* Push the last character on stack: */
-		Stack[StackPtr++] = CrntPrefix;
-
-		/* Now lets pop all the stack into output: */
-		while (StackPtr != 0 && i < LineLen)
-		    Line[i++] = Stack[--StackPtr];
-	    }
-	    if (LastCode != NO_SUCH_CODE) {
-		Prefix[Private->RunningCode - 2] = LastCode;
-
-		if (CrntCode == Private->RunningCode - 2) {
-		    /* Only allowed if CrntCode is exactly the running code: */
-		    /* In that case CrntCode = XXXCode, CrntCode or the	     */
-		    /* prefix code is last code and the suffix char is	     */
-		    /* exactly the prefix of last code!			     */
-		    Suffix[Private->RunningCode - 2] =
-			DGifGetPrefixChar(Prefix, LastCode, ClearCode);
-		}
-		else {
-		    Suffix[Private->RunningCode - 2] =
-			DGifGetPrefixChar(Prefix, CrntCode, ClearCode);
-		}
-	    }
-	    LastCode = CrntCode;
-	}
-    }
-
-    Private->LastCode = LastCode;
-    Private->StackPtr = StackPtr;
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-* Routine to trace the Prefixes linked list until we get a prefix which is    *
-* not code, but a pixel value (less than ClearCode). Returns that pixel value.*
-* If image is defective, we might loop here forever, so we limit the loops to *
-* the maximum possible if image O.k. - LZ_MAX_CODE times.		      *
-******************************************************************************/
-static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode)
-{
-    int i = 0;
-
-    while (Code > ClearCode && i++ <= LZ_MAX_CODE) Code = Prefix[Code];
-    return Code;
-}
-
-/******************************************************************************
-*   Interface for accessing the LZ codes directly. Set Code to the real code  *
-* (12bits), or to -1 if EOF code is returned.				      *
-******************************************************************************/
-int DGifGetLZCodes(GifFileType *GifFile, int *Code)
-{
-    GifByteType *CodeBlock;
-    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
-
-    if (!IS_READABLE(Private)) {
-	/* This file was NOT open for reading: */
-	_GifError = D_GIF_ERR_NOT_READABLE;
-	return GIF_ERROR;
-    }
-
-    if (DGifDecompressInput(Private, Code) == GIF_ERROR)
-	return GIF_ERROR;
-
-    if (*Code == Private->EOFCode) {
-	/* Skip rest of codes (hopefully only NULL terminating block): */
-	do if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR)
-    	    return GIF_ERROR;
-	while (CodeBlock != NULL);
-
-	*Code = -1;
-    }
-    else if (*Code == Private->ClearCode) {
-	/* We need to start over again: */
-	Private->RunningCode = Private->EOFCode + 1;
-	Private->RunningBits = Private->BitsPerPixel + 1;
-	Private->MaxCode1 = 1 << Private->RunningBits;
-    }
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   The LZ decompression input routine:					      *
-*   This routine is responsable for the decompression of the bit stream from  *
-* 8 bits (bytes) packets, into the real codes.				      *
-*   Returns GIF_OK if read succesfully.					      *
-******************************************************************************/
-static int DGifDecompressInput(GifFilePrivateType *Private, int *Code)
-{
-    GifByteType NextByte;
-    static unsigned int CodeMasks[] = {
-	0x0000, 0x0001, 0x0003, 0x0007,
-	0x000f, 0x001f, 0x003f, 0x007f,
-	0x00ff, 0x01ff, 0x03ff, 0x07ff,
-	0x0fff
-    };
-
-    while (Private->CrntShiftState < Private->RunningBits) {
-	/* Needs to get more bytes from input stream for next code: */
-	if (DGifBufferedInput(Private->File, Private->Buf, &NextByte)
-	    == GIF_ERROR) {
-	    return GIF_ERROR;
-	}
-	Private->CrntShiftDWord |=
-		((unsigned long) NextByte) << Private->CrntShiftState;
-	Private->CrntShiftState += 8;
-    }
-    *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
-
-    Private->CrntShiftDWord >>= Private->RunningBits;
-    Private->CrntShiftState -= Private->RunningBits;
-
-    /* If code cannt fit into RunningBits bits, must raise its size. Note */
-    /* however that codes above 4095 are used for special signaling.      */
-    if (++Private->RunningCode > Private->MaxCode1 &&
-	Private->RunningBits < LZ_BITS) {
-	Private->MaxCode1 <<= 1;
-	Private->RunningBits++;
-    }
-    return GIF_OK;
-}
-
-/******************************************************************************
-*   This routines read one gif data block at a time and buffers it internally *
-* so that the decompression routine could access it.			      *
-*   The routine returns the next byte from its internal buffer (or read next  *
-* block in if buffer empty) and returns GIF_OK if succesful.		      *
-******************************************************************************/
-static int DGifBufferedInput(FILE *File, GifByteType *Buf,
-						      GifByteType *NextByte)
-{
-    if (Buf[0] == 0) {
-	/* Needs to read the next buffer - this one is empty: */
-	if (fread(Buf, 1, 1, File) != 1)
-	{
-	    _GifError = D_GIF_ERR_READ_FAILED;
-	    return GIF_ERROR;
-	}
-	if (fread(&Buf[1], 1, Buf[0], File) != Buf[0])
-	{
-	    _GifError = D_GIF_ERR_READ_FAILED;
-	    return GIF_ERROR;
-	}
-	*NextByte = Buf[1];
-	Buf[1] = 2;	   /* We use now the second place as last char read! */
-	Buf[0]--;
-    }
-    else {
-	*NextByte = Buf[Buf[1]++];
-	Buf[0]--;
-    }
-
-    return GIF_OK;
-}
-
-/******************************************************************************
-* This routine reads an entire GIF into core, hanging all its state info off  *
-* the GifFileType pointer.  Call DGifOpenFileName() or DGifOpenFileHandle()   *
-* first to initialize I/O.  Its inverse is EGifSpew().			      *
-******************************************************************************/
-int DGifSlurp(GifFileType *GifFile)
-{
-#if 0
-  int i, j, Error;
-#endif /* 0 */
-    int ImageSize;
-    GifRecordType RecordType;
-    SavedImage *sp;
-    GifByteType *ExtData;
-    int ExtCode;
-
-    /* Some versions of malloc dislike 0-length requests */
-    GifFile->SavedImages = (SavedImage *)xmalloc(sizeof(SavedImage));
-
-    do {
-	if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
-	    return(GIF_ERROR);
-
-	switch (RecordType) {
-	    case IMAGE_DESC_RECORD_TYPE:
-		if (DGifGetImageDesc(GifFile) == GIF_ERROR)
-		    return(GIF_ERROR);
-
-		sp = &GifFile->SavedImages[GifFile->ImageCount-1];
-		ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
-
-		sp->RasterBits
-		    = (GifPixelType*) xmalloc(ImageSize * sizeof(GifPixelType));
-
-		if (DGifGetLine(GifFile, sp->RasterBits, ImageSize)
-		    == GIF_ERROR)
-		    return(GIF_ERROR);
-
-		break;
-
-	    case EXTENSION_RECORD_TYPE:
-	        /* This code fails if no image_desc record has been read
-		   yet.  I don't know if that's legal, but I've seen GIFs
-		   that start with an extension record.  XEmacs doesn't use
-		   the extension records anyway, so we'll just ignore them.
-		   - dkindred@cs.cmu.edu */
-#if 0
-		if (DGifGetExtension(GifFile,&sp->Function,&ExtData)==GIF_ERROR)
-		    return(GIF_ERROR);
-		else
-		{
-		    ExtensionBlock *ep =
-		      &sp->ExtensionBlocks[sp->ExtensionBlockCount++];
-
-		    ep->ByteCount = ExtData[0];
-		    ep->Bytes = (GifByteType *)xmalloc(ep->ByteCount * sizeof(GifByteType));
-		    memcpy(ep->Bytes, ExtData, ep->ByteCount * sizeof(char));
-		}
-
-		while (ExtData != NULL) {
-		    if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
-			return(GIF_ERROR);
-		    else
-		    {
-			ExtensionBlock *ep =
-			  &sp->ExtensionBlocks[sp->ExtensionBlockCount++];
-
-			ep->ByteCount = ExtData[0];
-			ep->Bytes = (GifByteType *)xmalloc(ep->ByteCount * sizeof(GifByteType));
-			memcpy(ep->Bytes,ExtData,ep->ByteCount * sizeof(char));
-		    }
-		}
-#else
-	        /* Skip any extension blocks in the file. */
-	        if (DGifGetExtension (GifFile, &ExtCode, &ExtData)
-		    == GIF_ERROR)
-		    return GIF_ERROR;
-
-		while (ExtData != NULL) {
-		    if (DGifGetExtensionNext (GifFile, &ExtData) == GIF_ERROR)
-		        return GIF_ERROR;
-		}
-#endif
-		break;
-
-	    case TERMINATE_RECORD_TYPE:
-		break;
-
-	    default:	/* Should be trapped by DGifGetRecordType */
-		break;
-	}
-    }
-    while
-	(RecordType != TERMINATE_RECORD_TYPE);
-
-    return(GIF_OK);
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dll.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,125 @@
+/* Lisp interface to dynamic loading.
+   Copyright (C) 1998  Joshua Rowe.
+   Additional cleanup by Hrvoje Niksic.
+
+This file is part of XEmacs.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* A shared object may have the following symbols defined:
+      syms_of
+      vars_of
+      complex_vars_of
+   They are called in that order.  Each takes and returns void
+   arguments.
+
+   All of this needs lots and LOTS of work.  Some things to work on:
+
+   1) A good foreign interface.  We probably need to get rid of
+   syms_of and similar junk, and define a more normal interfacing to
+   the outside world, e.g. an init_emacs_module() function.  See below
+   for more discussion about it.  Also, we need a modules/ directory
+   with a few nice sample modules, a sample Makefile, etc. so people
+   can start hacking.
+
+   2) I'm getting coredumps very often -- practically every time I
+   compile without USE_MINIMAL_TAGBITS, and even with it sometimes.  I
+   wasn't able to resolve these.
+
+   3) All of this is sooo simple-minded.  As it gets more complex,
+   we'll have to look at how others have done similar things
+   (e.g. Perl and Zsh 3.1), to avoid botching it up.  */
+
+#include <config.h>
+#include "lisp.h"
+#include "emacsfns.h"
+#include "buffer.h"
+
+#include <stdio.h>
+#include "sysdll.h"
+#include <errno.h>
+
+
+DEFUN ("dll-open", Fdll_open, 1, 1, "FShared object: ", /*
+Load LIBRARY as a shared object file.
+
+After the LIBRARY is dynamically linked with the executable, the
+following functions are called:
+
+  syms_of(),		containing definitions of symbols and subr's;
+  vars_of(),		containing definitions of variables;
+  complex_vars_of(),	containing complex definitions of variables.
+
+After this point, any lisp symbols defined in the shared object are
+available for use.
+*/
+       (library))
+{
+  /* This function can GC */
+  dll_handle *handle;
+  char *file;
+  void (*function)();
+
+  CHECK_STRING (library);
+  library = Fexpand_file_name (library, Qnil);
+
+  file = XSTRING_DATA (library);
+  /* #### Is this right? */
+  GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (file, file);
+
+  handle = dll_open (file);
+  if (handle == NULL)
+    {
+      signal_error (Qerror,
+		    list3 (build_translated_string ("Cannot load shared library"),
+			   library, build_translated_string (dll_error (handle))));
+    }
+
+  /* #### This looks unnecessary here, because at this time one
+     initialization function is fully sufficient.  However, I am not
+     removing this support, since we may wish to add mechanisms for
+     static linking, which would have invoke these function via normal
+     paths.
+
+     #### But then this is not sufficient, because one could as well
+     honor specifier_vars_of_foo(), etc.  Maybe we should scrap it
+     after all.
+
+     #### What if one of the first two functions signal an error?
+     Should we take care to execute the other two?  My fingers are
+     getting itchy!  */
+
+  function = dll_function (handle, "syms_of");
+  if (function)
+    (*function) ();
+
+  function = dll_function (handle, "vars_of");
+  if (function)
+    (*function) ();
+
+  function = dll_function (handle, "complex_vars_of");
+  if (function)
+    (*function) ();
+
+  return Qnil;
+}
+
+void syms_of_dll ()
+{
+  DEFSUBR (Fdll_open);
+}
--- a/src/dlopen.c	Mon Aug 13 10:24:47 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/* Lisp interface to dynamic loading.
-   Copyright (C) 1998  Joshua Rowe.
-   Additional cleanup by Hrvoje Niksic.
-
-This file is part of XEmacs.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Not in FSF. */
-
-/* A shared object may have the following symbols defined:
-      syms_of
-      vars_of
-      complex_vars_of
-   They are called in that order.  Each takes and returns void
-   arguments.
-
-   All of this needs lots and LOTS of work.  Some things to work on:
-
-   1) A good foreign interface.  We probably need to get rid of
-   syms_of and similar junk, and define a more normal interfacing to
-   the outside world, e.g. an init_emacs_module() function.  See below
-   for more discussion about it.  Also, we need a modules/ directory
-   with a few nice sample modules, a sample Makefile, etc. so people
-   can start hacking.
-
-   2) Compatibility concerns.  There are systems without dynamic
-   libraries (Ultrix, to name one).  OK, scrap them, but not all
-   systems out there use the exact dlopen() interface that this file
-   uses.  Bill Perry said he had ready Makefiles for 14 or so systems
-   to do this sort of things portably.  Check it out.  Or, use Gordon
-   Matzigkeit's libtool.
-
-   3) I'm getting coredumps very often -- practically every time I
-   compile without USE_MINIMAL_TAGBITS, and even with it sometimes.  I
-   wasn't able to resolve these.
-
-   4) All of this is sooo simple-minded.  As it gets more complex,
-   we'll have to look at how others have done similar things
-   (e.g. Perl and Zsh 3.1), to avoid botching it up.  */
-
-#include <config.h>
-#include "lisp.h"
-#include "emacsfns.h"
-#include "buffer.h"
-
-#include <stdio.h>
-#include <dlfcn.h>
-#include <errno.h>
-
-
-DEFUN ("dl-open", Fdl_open, 1, 1, "FShared object: ", /*
-Load LIBRARY as a shared object file.
-
-After the LIBRARY is dynamically linked with the executable, the
-following functions are called:
-
-  syms_of(),		containing definitions of symbols and subr's;
-  vars_of(),		containing definitions of variables;
-  complex_vars_of(),	containing complex definitions of variables.
-
-After this point, any lisp symbols defined in the shared object are
-available for use.
-*/
-       (library))
-{
-  /* This function can GC */
-  void *handle;
-  char *file;
-  void (*function)();
-
-  CHECK_STRING (library);
-  library = Fexpand_file_name (library, Qnil);
-
-  file = XSTRING_DATA (library);
-  /* #### Is this right? */
-  GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (file, file);
-
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-  handle = dlopen (file, RTLD_LAZY|RTLD_GLOBAL);
-  if (handle == NULL)
-    {
-      signal_error (Qerror,
-		    list3 (build_translated_string ("Cannot load shared library"),
-			   library, build_translated_string (dlerror ())));
-    }
-
-  /* #### This looks unnecessary here, because at this time one
-     initialization function is fully sufficient.  However, I am not
-     removing this support, since we may wish to add mechanisms for
-     static linking, which would have invoke these function via normal
-     paths.
-
-     #### But then this is not sufficient, because one could as well
-     honor specifier_vars_of_foo(), etc.  Maybe we should scrap it
-     after all.
-
-     #### What if one of the first two functions signal an error?
-     Should we take care to execute the other two?  My fingers are
-     getting itchy!  */
-
-  function = dlsym (handle, "syms_of");
-  if (function)
-    (*function) ();
-
-  function = dlsym (handle, "vars_of");
-  if (function)
-    (*function) ();
-
-  function = dlsym (handle, "complex_vars_of");
-  if (function)
-    (*function) ();
-
-  return Qnil;
-}
-
-void syms_of_dlopen ()
-{
-  DEFSUBR (Fdl_open);
-}
--- a/src/eldap.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/eldap.c	Mon Aug 13 10:25:37 2007 +0200
@@ -1,5 +1,5 @@
 /* LDAP client interface for XEmacs.
-   Copyright (C) ***FIXME***
+   Copyright (C) 1998 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
 
@@ -38,6 +38,8 @@
 
 #include "lisp.h"
 
+#include <errno.h>
+
 #include "eldap.h"
 #include <lber.h>
 #include <ldap.h>
@@ -293,14 +295,15 @@
      check what happens inside that lib. Anyway this should be harmless to
      XEmacs and makes things work. */
 #if defined (HAVE_UMICH_LDAP)
-  Fgarbage_collect ();
+  garbage_collect_1 ();
 #endif
 
   /* Connect to the server and bind */
   message ("Connecting to %s...", ldap_host);
   if ( (ld = ldap_open (ldap_host, LDAP_PORT)) == NULL )
-     signal_simple_error ("Failed connecting to host",
-                          build_string (ldap_host));
+     signal_simple_error_2 ("Failed connecting to host",
+                            build_string (ldap_host),
+                            lisp_strerror (errno));
 
 #if HAVE_LDAP_SET_OPTION
   if (ldap_set_option (ld, LDAP_OPT_DEREF, (void *)&ldap_deref) != LDAP_SUCCESS)
--- a/src/eldap.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/eldap.h	Mon Aug 13 10:25:37 2007 +0200
@@ -1,5 +1,5 @@
 /* Definitions for the LDAP client interface for XEmacs.
-   Copyright (C) ***FIXME***
+   Copyright (C) 1998 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
 
--- a/src/emacs.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/emacs.c	Mon Aug 13 10:25:37 2007 +0200
@@ -333,6 +333,9 @@
 	      GetModuleFileName (NULL, full_exe_path, MAX_PATH);
 	      result = Fcons (build_ext_string (full_exe_path, FORMAT_FILENAME),
 			      result);
+#if defined(HAVE_SHLIB)
+	      (void)dll_init(full_exe_path);
+#endif
 	    }
 	  else
 #endif
@@ -844,7 +847,7 @@
 #endif
       syms_of_dired ();
 #ifdef HAVE_SHLIB
-      syms_of_dlopen ();
+      syms_of_dll ();
 #endif
       syms_of_doc ();
       syms_of_editfns ();
@@ -1531,9 +1534,6 @@
 #ifdef HAVE_TTY
   init_device_tty ();
 #endif
-#ifdef HAVE_GIF
-  init_gif_err ();
-#endif
   init_console_stream (); /* Create the first console */
 
   /* try to get the actual pathname of the exec file we are running */
@@ -1563,6 +1563,22 @@
     Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
   }
 
+#if defined(HAVE_SHLIB) && !defined(WINDOWSNT)
+  /* This is Unix only.  MS Windows NT has a library call that does
+     The Right Thing on that system.  Rumor has it, this must be
+     called for GNU dld in temacs and xemacs.  */
+  {
+    char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory)
+				+ XSTRING_LENGTH (Vinvocation_name)
+				+ 2);
+    sprintf (buf, "%s/%s", XSTRING_DATA(Vinvocation_directory),
+	     XSTRING_DATA(Vinvocation_name));
+
+    /* All we can do is cry if an error happens, so ignore it. */
+    (void)dll_init(buf);
+  }
+#endif
+
 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
   /* sun's localtime() has a bug.  it caches the value of the time
      zone rather than looking it up every time.  Since localtime() is
@@ -2355,6 +2371,16 @@
 #define SEPCHAR ':'
 #endif
 
+DEFUN ("parse-colon-path", Fparse_colon_path, 1, 1, 0, /*
+Explode a colon-separated list of paths into a string list.
+*/
+       (cd_path))
+{
+  CHECK_STRING (cd_path);
+
+  return decode_path(XSTRING_DATA(cd_path));
+}
+
 Lisp_Object
 decode_path (CONST char *path)
 {
@@ -2372,9 +2398,13 @@
       p = strchr (path, SEPCHAR);
       if (!p) p = path + strlen (path);
       lpath = Fcons (((p != path)
-                      ? make_string ((CONST Bufbyte *) path, p - path)
-                      : Qnil),
-                     lpath);
+#if 0
+		      ? Ffile_name_as_directory(make_string ((CONST Bufbyte *) path, p - path))
+#else
+		      ? make_string ((CONST Bufbyte *) path, p - path)
+#endif
+		      : Qnil),
+		     lpath);
       if (*p)
 	path = p + 1;
       else
@@ -2482,6 +2512,8 @@
   DEFSUBR (Fquantify_clear_data);
 #endif /* QUANTIFY */
 
+  DEFSUBR (Fparse_colon_path);
+
   defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
   defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
 }
--- a/src/event-stream.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/event-stream.c	Mon Aug 13 10:25:37 2007 +0200
@@ -5346,6 +5346,8 @@
 	    init_event_Xt_late ();
 #elif defined (HAVE_TTY)
 	    init_event_tty_late ();
+#elif defined (HAVE_MS_WINDOWS)
+	    init_event_mswindows_late ();
 #endif
 	  }
       init_interrupts_late ();
--- a/src/file-coding.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/file-coding.c	Mon Aug 13 10:25:37 2007 +0200
@@ -360,7 +360,7 @@
   int len = string_length (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name);
   char *codesys_name = (char *) alloca (len + 7);
   int mlen = -1;
-  char *codesys_mnemonic;
+  char *codesys_mnemonic=0;
 
   Lisp_Object codesys_name_sym, sub_codesys_obj;
 
--- a/src/fileio.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/fileio.c	Mon Aug 13 10:25:37 2007 +0200
@@ -56,28 +56,22 @@
 #ifdef WINDOWSNT
 #define NOMINMAX 1
 #include <windows.h>
+#include <direct.h>
+#include <fcntl.h>
 #include <stdlib.h>
-#include <fcntl.h>
 #endif /* not WINDOWSNT */
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 #define CORRECT_DIR_SEPS(s) \
   do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
     else unixtodos_filename (s); \
   } while (0)
-/* On Windows, drive letters must be alphabetic - on DOS, the Netware
-   redirector allows the six letters between 'Z' and 'a' as well. */
-#ifdef MSDOS
-#define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z')
-#endif
-#ifdef WINDOWSNT
 #define IS_DRIVE(x) isalpha (x)
-#endif
 /* Need to lower-case the drive letter, or else expanded
    filenames will sometimes compare inequal, because
    `expand-file-name' doesn't always down-case the drive letter.  */
 #define DRIVE_LETTER(x) (tolower (x))
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
 /* Nonzero during writing of auto-save files */
 static int auto_saving;
@@ -124,15 +118,6 @@
    are called during initialization.  */
 Lisp_Object Vdirectory_sep_char;
 
-#ifdef DOS_NT
-/* Until we can figure out how to deal with the functions in this file in
-   a civilized fashion, this will remain #ifdef'ed out. -slb */
-/* For the benefit of backwards compatability with earlier versions of
-   Emacs on DOS_NT, provide a way to disable the REPLACE option support
-   in insert-file-contents.  */
-Lisp_Object Vinsert_file_contents_allow_replace;
-#endif /* DOS_NT */
-
 /* These variables describe handlers that have "already" had a chance
    to handle the current operation.
 
@@ -461,7 +446,7 @@
   p = beg + XSTRING_LENGTH (file);
 
   while (p != beg && !IS_ANY_SEP (p[-1])
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	 /* only recognise drive specifier at beginning */
 	 && !(p[-1] == ':' && p == beg + 2)
 #endif
@@ -469,7 +454,7 @@
 
   if (p == beg)
     return Qnil;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   /* Expansion of "c:" to drive and default directory.  */
   /* (NT does the right thing.)  */
   if (p == beg + 2 && beg[1] == ':')
@@ -485,7 +470,7 @@
 	}
     }
   CORRECT_DIR_SEPS (beg);
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
   return make_string (beg, p - beg);
 }
 
@@ -513,7 +498,7 @@
   end = p = beg + XSTRING_LENGTH (file);
 
   while (p != beg && !IS_ANY_SEP (p[-1])
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	 /* only recognise drive specifier at beginning */
 	 && !(p[-1] == ':' && p == beg + 2)
 #endif
@@ -560,7 +545,7 @@
       out[size + 1] = DIRECTORY_SEP;
       out[size + 2] = '\0';
     }
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   CORRECT_DIR_SEPS (out);
 #endif
   return out;
@@ -596,7 +581,7 @@
 /*
  * Convert from directory name to filename.
  * On UNIX, it's simple: just make sure there isn't a terminating /
-
+ *
  * Value is nonzero if the string output is different from the input.
  */
 
@@ -617,15 +602,15 @@
 #else
   if (slen > 1
       && IS_DIRECTORY_SEP (dst[slen - 1])
-#ifdef DOS_NT
+#ifdef WINDOWSNT
       && !IS_ANY_SEP (dst[slen - 2])
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
       )
     dst[slen - 1] = 0;
 #endif /* APOLLO */
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   CORRECT_DIR_SEPS (dst);
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
   return 1;
 }
 
@@ -680,9 +665,9 @@
   /* !!#### does mktemp() Mule-encapsulate? */
   mktemp ((char *) data);
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   CORRECT_DIR_SEPS (XSTRING_DATA (val));
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
   return val;
 }
 
@@ -707,11 +692,12 @@
   Bufbyte *newdir, *p, *o;
   int tlen;
   Bufbyte *target;
-  struct passwd *pw;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   int drive = 0;
   int collapse_newdir = 1;
-#endif /* DOS_NT */
+#else
+  struct passwd *pw;
+#endif /* WINDOWSNT */
   int length;
   Lisp_Object handler;
 
@@ -753,18 +739,18 @@
       /* Save time in some common cases - as long as default_directory
 	 is not relative, it can be canonicalized with name below (if it
 	 is needed at all) without requiring it to be expanded now.  */
-#ifdef DOS_NT
+#ifdef WINDOWSNT
       /* Detect MSDOS file names with drive specifiers.  */
       && ! (IS_DRIVE (o[0]) && (IS_DEVICE_SEP (o[1]) && IS_DIRECTORY_SEP (o[2])))
-#ifdef WINDOWSNT
       /* Detect Windows file names in UNC format.  */
       && ! (IS_DIRECTORY_SEP (o[0]) && IS_DIRECTORY_SEP (o[1]))
-#endif
-#else /* not DOS_NT */
+
+#else /* not WINDOWSNT */
+
       /* Detect Unix absolute file names (/... alone is not absolute on
 	 DOS or Windows).  */
       && ! (IS_DIRECTORY_SEP (o[0]))
-#endif /* not DOS_NT */
+#endif /* not WINDOWSNT */
       )
     {
       struct gcpro gcpro1;
@@ -782,7 +768,7 @@
     into name should be safe during all of this, though. */
   nm = XSTRING_DATA (name);
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   /* We will force directory separators to be either all \ or /, so make
      a local copy to modify, even if there ends up being no change. */
   nm = strcpy (alloca (strlen (nm) + 1), nm);
@@ -815,16 +801,12 @@
 	}
   }
 
-#ifdef WINDOWSNT
   /* If we see "c://somedir", we want to strip the first slash after the
      colon when stripping the drive letter.  Otherwise, this expands to
      "//somedir".  */
   if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1]))
     nm++;
-#endif /* WINDOWSNT */
-#endif /* DOS_NT */
-
-#ifdef WINDOWSNT
+
   /* Discard any previous drive specifier if nm is now in UNC format. */
   if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1]))
     {
@@ -837,9 +819,6 @@
      a new string if name is already fully expanded.  */
   if (
       IS_DIRECTORY_SEP (nm[0])
-#ifdef MSDOS
-      && drive
-#endif
 #ifdef WINDOWSNT
       && (drive || IS_DIRECTORY_SEP (nm[1]))
 #endif
@@ -871,32 +850,29 @@
 	}
       if (!lose)
 	{
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	  /* Make sure directories are all separated with / or \ as
 	     desired, but avoid allocation of a new string when not
 	     required. */
 	  CORRECT_DIR_SEPS (nm);
-#ifdef WINDOWSNT
 	  if (IS_DIRECTORY_SEP (nm[1]))
 	    {
 	      if (strcmp (nm, XSTRING_DATA (name)) != 0)
 		name = build_string (nm);
 	    }
-	  else
-#endif
 	  /* drive must be set, so this is okay */
-	  if (strcmp (nm - 2, XSTRING_DATA (name)) != 0)
+	  else if (strcmp (nm - 2, XSTRING_DATA (name)) != 0)
 	    {
 	      name = make_string (nm - 2, p - nm + 2);
 	      XSTRING_DATA (name)[0] = DRIVE_LETTER (drive);
 	      XSTRING_DATA (name)[1] = ':';
 	    }
 	  return name;
-#else /* not DOS_NT */
+#else /* not WINDOWSNT */
 	  if (nm == XSTRING_DATA (name))
 	    return name;
 	  return build_string (nm);
-#endif /* not DOS_NT */
+#endif /* not WINDOWSNT */
 	}
     }
 
@@ -926,7 +902,7 @@
 	  if (!(newdir = (Bufbyte *) egetenv ("HOME")))
 	    newdir = (Bufbyte *) "";
 	  nm++;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	  collapse_newdir = 0;
 #endif
 	}
@@ -971,7 +947,7 @@
 	}
     }
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   /* On DOS and Windows, nm is absolute if a drive name was specified;
      use the drive's current directory as the prefix if needed.  */
   if (!newdir && drive)
@@ -993,17 +969,16 @@
 	  newdir[3] = 0;
 	}
     }
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
   /* Finally, if no prefix has been specified and nm is not absolute,
      then it must be expanded relative to default_directory. */
 
   if (1
-#ifndef DOS_NT
+#ifndef WINDOWSNT
       /* /... alone is not absolute on DOS and Windows. */
       && !IS_DIRECTORY_SEP (nm[0])
-#endif
-#ifdef WINDOWSNT
+#else
       && !(IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1]))
 #endif
       && !newdir)
@@ -1011,7 +986,7 @@
       newdir = XSTRING_DATA (default_directory);
     }
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   if (newdir)
     {
       /* First ensure newdir is an absolute name. */
@@ -1019,10 +994,8 @@
 	  /* Detect MSDOS file names with drive specifiers.  */
 	  ! (IS_DRIVE (newdir[0])
 	     && IS_DEVICE_SEP (newdir[1]) && IS_DIRECTORY_SEP (newdir[2]))
-#ifdef WINDOWSNT
 	  /* Detect Windows file names in UNC format.  */
 	  && ! (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
-#endif
 	  )
 	{
 	  /* Effectively, let newdir be (expand-file-name newdir cwd).
@@ -1064,7 +1037,6 @@
          (/ /server/share for UNC, nothing otherwise).  */
       if (IS_DIRECTORY_SEP (nm[0]) && collapse_newdir)
 	{
-#ifdef WINDOWSNT
 	  if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
 	    {
 	      newdir = strcpy (alloca (strlen (newdir) + 1), newdir);
@@ -1075,11 +1047,10 @@
 	      *p = 0;
 	    }
 	  else
-#endif
 	    newdir = "";
 	}
     }
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
   if (newdir)
     {
@@ -1104,14 +1075,14 @@
 
   /* Now concatenate the directory and name to new space in the stack frame */
   tlen += strlen (nm) + 1;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   /* Add reserved space for drive name.  (The Microsoft x86 compiler
      produces incorrect code if the following two lines are combined.)  */
   target = (Bufbyte *) alloca (tlen + 2);
   target += 2;
-#else  /* not DOS_NT */
+#else  /* not WINDOWSNT */
   target = (Bufbyte *) alloca (tlen);
-#endif /* not DOS_NT */
+#endif /* not WINDOWSNT */
   *target = 0;
 
   if (newdir)
@@ -1166,12 +1137,9 @@
 	}
     }
 
-#ifdef DOS_NT
-  /* At last, set drive name. */
 #ifdef WINDOWSNT
-  /* Except for network file name.  */
+  /* At last, set drive name, except for network file name.  */
   if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1])))
-#endif /* WINDOWSNT */
     {
       if (!drive) abort ();
       target -= 2;
@@ -1179,7 +1147,7 @@
       target[1] = ':';
     }
   CORRECT_DIR_SEPS (target);
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
   return make_string (target, o - target);
 }
@@ -1338,7 +1306,7 @@
 				      string);
 
   nm = XSTRING_DATA (string);
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   nm = strcpy (alloca (strlen (nm) + 1), nm);
   CORRECT_DIR_SEPS (nm);
   substituted = (strcmp (nm, XSTRING_DATA (string)) != 0);
@@ -1364,7 +1332,7 @@
 	  nm = p;
 	  substituted = 1;
 	}
-#ifdef DOS_NT
+#ifdef WINDOWSNT
       /* see comment in expand-file-name about drive specifiers */
       else if (IS_DRIVE (p[0]) && p[1] == ':'
 	       && p > nm && IS_DIRECTORY_SEP (p[-1]))
@@ -1372,7 +1340,7 @@
 	  nm = p;
 	  substituted = 1;
 	}
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
     }
 
   /* See if any variables are substituted into the string
@@ -1412,9 +1380,9 @@
 	target = (Bufbyte *) alloca (s - o + 1);
 	strncpy ((char *) target, (char *) o, s - o);
 	target[s - o] = 0;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	strupr (target); /* $home == $HOME etc.  */
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
 	/* Get variable value */
 	o = (Bufbyte *) egetenv ((char *) target);
@@ -1463,9 +1431,9 @@
 	target = (Bufbyte *) alloca (s - o + 1);
 	strncpy ((char *) target, (char *) o, s - o);
 	target[s - o] = 0;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
 	strupr (target); /* $home == $HOME etc.  */
-#endif /* DOS_NT */
+#endif /* WINDOWSNT */
 
 	/* Get variable value */
 	o = (Bufbyte *) egetenv ((char *) target);
@@ -1491,7 +1459,7 @@
 	/* don't do p[-1] if that would go off the beginning --jwz */
 	&& p != nm && p > xnm && IS_DIRECTORY_SEP (p[-1]))
       xnm = p;
-#ifdef DOS_NT
+#ifdef WINDOWSNT
     else if (IS_DRIVE (p[0]) && p[1] == ':'
 	     && p > nm && IS_DIRECTORY_SEP (p[-1]))
 	xnm = p;
@@ -1666,7 +1634,7 @@
      copyable by us. */
   input_file_statable_p = (fstat (ifd, &st) >= 0);
 
-#ifndef DOS_NT
+#ifndef WINDOWSNT
   if (out_st.st_mode != 0
       && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino)
     {
@@ -1695,13 +1663,8 @@
     }
 #endif /* S_ISREG && S_ISLNK */
 
-#ifdef MSDOS
-  /* System's default file type was set to binary by _fmode in emacs.c.  */
-  ofd = creat ((char *) XSTRING_DATA (newname), S_IREAD | S_IWRITE);
-#else /* not MSDOS */
   ofd = open( (char *) XSTRING_DATA (newname), 
 	      O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, CREAT_MODE);
-#endif /* not MSDOS */
   if (ofd < 0)
     report_file_error ("Opening output file", list1 (newname));
 
@@ -1731,19 +1694,8 @@
 			    mtime))
 	  report_file_error ("I/O error", list1 (newname));
       }
-#ifndef MSDOS
       chmod ((CONST char *) XSTRING_DATA (newname),
 	     st.st_mode & 07777);
-#else /* MSDOS */
-#if defined (__DJGPP__) && __DJGPP__ > 1
-      /* In DJGPP v2.0 and later, fstat usually returns true file mode bits,
-         and if it can't, it tells so.  Otherwise, under MSDOS we usually
-         get only the READ bit, which will make the copied file read-only,
-         so it's better not to chmod at all.  */
-      if ((_djstat_flags & _STFAIL_WRITEBIT) == 0)
-	chmod ((char *) XSTRING_DATA (newname), st.st_mode & 07777);
-#endif /* DJGPP version 2 or newer */
-#endif /* MSDOS */
     }
 
     /* We'll close it by hand */
@@ -2112,7 +2064,7 @@
   CHECK_STRING (filename);
   ptr = XSTRING_DATA (filename);
   if (IS_DIRECTORY_SEP (*ptr) || *ptr == '~'
-#ifdef DOS_NT
+#ifdef WINDOWSNT
       || (IS_DRIVE (*ptr) && ptr[1] == ':' && IS_DIRECTORY_SEP (ptr[2]))
 #endif
       )
@@ -2126,23 +2078,12 @@
 static int
 check_executable (char *filename)
 {
-#ifdef DOS_NT
-  int len = strlen (filename);
-  char *suffix;
+#ifdef WINDOWSNT
   struct stat st;
   if (stat (filename, &st) < 0)
     return 0;
-#if defined (WINDOWSNT)
   return ((st.st_mode & S_IEXEC) != 0);
-#else
-  return (S_ISREG (st.st_mode)
-	  && len >= 5
-	  && (stricmp ((suffix = filename + len-4), ".com") == 0
-	      || stricmp (suffix, ".exe") == 0
-	      || stricmp (suffix, ".bat") == 0)
-	  || (st.st_mode & S_IFMT) == S_IFDIR);
-#endif /* not WINDOWSNT */
-#else /* not DOS_NT */
+#else /* not WINDOWSNT */
 #ifdef HAVE_EACCESS
   return eaccess (filename, 1) >= 0;
 #else
@@ -2151,7 +2092,7 @@
      But Unix doesn't give us a right way to do it.  */
   return access (filename, 1) >= 0;
 #endif /* HAVE_EACCESS */
-#endif /* not DOS_NT */
+#endif /* not WINDOWSNT */
 }
 
 /* Return nonzero if file FILENAME exists and can be written.  */
@@ -2159,12 +2100,6 @@
 static int
 check_writable (CONST char *filename)
 {
-#ifdef MSDOS
-  struct stat st;
-  if (stat (filename, &st) < 0)
-    return 0;
-  return (st.st_mode & S_IWRITE || (st.st_mode & S_IFMT) == S_IFDIR);
-#else /* not MSDOS */
 #ifdef HAVE_EACCESS
   return (eaccess (filename, 2) >= 0);
 #else
@@ -2175,7 +2110,6 @@
      but would lose for directories.  */
   return (access (filename, 2) >= 0);
 #endif
-#endif /* not MSDOS */
 }
 
 DEFUN ("file-exists-p", Ffile_exists_p, 1, 1, 0, /*
@@ -2243,7 +2177,6 @@
   /* This function can GC */
   Lisp_Object abspath = Qnil;
   Lisp_Object handler;
-  int desc;
   struct gcpro gcpro1;
   GCPRO1 (abspath);
 
@@ -2256,19 +2189,21 @@
   if (!NILP (handler))
     RETURN_UNGCPRO (call2 (handler, Qfile_readable_p, abspath));
 
-#ifdef DOS_NT
+#ifdef WINDOWSNT
   /* Under MS-DOS and Windows, open does not work for directories.  */
   if (access (XSTRING_DATA (abspath), 0) == 0)
     return Qt;
   return Qnil;
-#else /* not DOS_NT */
-  desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY | OPEN_BINARY, 0);
-  UNGCPRO;
-  if (desc < 0)
-    return Qnil;
-  close (desc);
-  return Qt;
-#endif /* not DOS_NT */
+#else /* not WINDOWSNT */
+  {
+    int desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY | OPEN_BINARY, 0);
+    UNGCPRO;
+    if (desc < 0)
+      return Qnil;
+    close (desc);
+    return Qt;
+  }
+#endif /* not WINDOWSNT */
 }
 
 /* Having this before file-symlink-p mysteriously caused it to be forgotten
@@ -2303,14 +2238,6 @@
   GCPRO1 (abspath);
   dir = Ffile_name_directory (abspath);
   UNGCPRO;
-#ifdef MSDOS
-  if (!NILP (dir))
-    {
-      GCPRO1(dir);
-      dir = Fdirectory_file_name (dir);
-      UNGCPRO;
-    }
-#endif /* MSDOS */
   return (check_writable (!NILP (dir) ? (char *) XSTRING_DATA (dir)
 			  : "")
 	  ? Qt : Qnil);
@@ -2418,7 +2345,7 @@
     return call2 (handler, Qfile_accessible_directory_p,
 		  filename);
 
-#if !defined(DOS_NT)
+#if !defined(WINDOWSNT)
   if (NILP (Ffile_directory_p (filename)))
       return (Qnil);
   else
@@ -2439,7 +2366,7 @@
     UNGCPRO;
     return tem ? Qnil : Qt;
   }
-#endif /* !defined(DOS_NT) */
+#endif /* !defined(WINDOWSNT) */
 }
 
 DEFUN ("file-regular-p", Ffile_regular_p, 1, 1, 0, /*
@@ -2629,60 +2556,6 @@
 }
 
 
-#ifdef DOS_NT
-Lisp_Object Qfind_buffer_file_type;
-
-/* Return 1 if buffer is text, 0 if binary.  */
-static int
-decide_buffer_type (unsigned char * buffer, int nbytes)
-{
-  /* Buffer is binary if we find any LF chars not preceeded by CR or if
-     the buffer doesn't contain at least 1 line.  */
-  unsigned lines = 0;
-  unsigned char *p, *q;
-
-  for (p = buffer; nbytes > 0 && (q = memchr (p, '\n', nbytes)) != NULL;
-       p = q + 1 )
-    {
-      nbytes -= (q + 1 - p);
-      lines++;
-      if (q > buffer && q[-1] != '\r')
-	return 0;
-    }
-
-  /* If we haven't seen any line endings yet, return -1 (meaning type is
-     undecided) so we can examine the next bufferful as well.  */
-  return (lines > 0) ? 1 : -1;
-}
-
-/* XEmacs addition: like decide_buffer_type(), but working on a XEmacs buffer:
-   first arg is a byte index position instead of a char pointer;
-   we check each char sequentially. --marcpa */
-static int
-buf_decide_buffer_type (struct buffer *buf, Bytind start, int nbytes)
-{
-  /* Buffer is binary if we find any LF chars not preceeded by CR or if
-     the buffer doesn't contain at least 1 line.  */
-  unsigned lines = 0;
-  Bytind cur = start;
-
-  while (nbytes)
-    {
-      if (BI_BUF_FETCH_CHAR(buf, cur) == '\n')
-	{
-	  lines++;
-	  if (cur != start && BI_BUF_FETCH_CHAR(buf, cur - 1) != '\r')
-	    return 0;
-	}
-      nbytes--;
-    }
-
-  /* If we haven't seen any line endings yet, return -1 (meaning type is
-     undecided) so we can examine the next bufferful as well.  */
-  return (lines > 0) ? 1 : -1;
-}
-#endif /* DOS_NT */
-
 /* Stack sizes > 2**16 is a good way to elicit compiler bugs */
 /* #define READ_BUF_SIZE (2 << 16) */
 #define READ_BUF_SIZE (1 << 15)
@@ -2721,11 +2594,6 @@
   struct buffer *buf = current_buffer;
   Lisp_Object curbuf;
   int not_regular = 0;
-#ifdef DOS_NT
-  int crlf_conversion_required = 0;
-  unsigned crlf_count = 0;
-  unsigned lf_count = 0;
-#endif
 
   if (buf->base_buffer && ! NILP (visit))
     error ("Cannot do file visiting in an indirect buffer");
@@ -2843,19 +2711,6 @@
 	  if (XINT (end) != st.st_size)
 	    error ("Maximum buffer size exceeded");
 	}
-
-#ifdef DOS_NT
-      /* Permit old behaviour if desired.  */
-      if (NILP (Vinsert_file_contents_allow_replace) && !NILP (replace))
-	{
-	  replace = Qnil;
-	  /* Surely this was never right!  */
-	  /* XSETFASTINT (beg, 0);
-	     XSETFASTINT (end, st.st_size); */
-	  buffer_delete_range (buf, BUF_BEGV(buf), BUF_ZV(buf),
-			       !NILP (visit) ? INSDEL_NO_LOCKING : 0);
-	}
-#endif /* DOS_NT */
     }
 
   /* If requested, replace the accessible part of the buffer
@@ -2868,7 +2723,8 @@
      files may contain multibyte characters.  It holds under Windows NT
      provided we convert CRLF into LF. */
 # define FSFMACS_SPEEDY_INSERT
-#endif
+#endif /* !defined (FILE_CODING) */
+
 #ifndef FSFMACS_SPEEDY_INSERT
   if (!NILP (replace))
     {
@@ -2882,38 +2738,6 @@
       Bufpos same_at_start = BUF_BEGV (buf);
       Bufpos same_at_end = BUF_ZV (buf);
       int overlap;
-#ifdef DOS_NT
-      /* Syncing with 19.34.6 note: same_at_start_in_file and
-	 same_at_end_in_file are not in XEmacs 20.4.
-	 First try to introduce them as-is and see what happens.
-	 Might be necessary to use constructs like
-	 st.st_size - (BUF_ZV (buf) - same_at_end)
-	 instead.
-	 --marcpa
-      */
-      /* Offset into the file where discrepancy begins.  */
-      int same_at_start_in_file = 0;
-      /* Offset into the file where discrepancy ends.  */
-      int same_at_end_in_file = st.st_size;
-      /* DOS_NT only: is there a `\r' character left in the buffer? */
-      int cr_left_in_buffer = 0;
-      /* DOS_NT only: was `\n' the first character in previous bufferful?  */
-      int last_was_lf = 0;
-
-      /* Demacs 1.1.1 91/10/16 HIRANO Satoshi, MW July 1993 */
-      /* Determine file type (text/binary) from its name.
-	 Note that the buffer_file_type changes here when the file
-	 being inserted is not of the same type as the original buffer.  */
-      current_buffer->buffer_file_type = call1 (Qfind_buffer_file_type, filename);
-      if (NILP (current_buffer->buffer_file_type))
-	crlf_conversion_required = 1;
-      else if (current_buffer->buffer_file_type != Qt)
-	/* Use heuristic to decide whether file is text or binary (based
-	   on the first bufferful) if buffer-file-type is not nil or t.
-	   If no decision is made (because no line endings were ever
-	   seen) then let buffer-file-type default to nil.  */
-	crlf_conversion_required = -1;
-#endif /* DOS_NT */
 
       /* Count how many chars at the start of the file
 	 match the text at the beginning of the buffer.  */
@@ -2921,16 +2745,6 @@
 	{
 	  int nread;
 	  Bufpos bufpos;
-#ifdef DOS_NT
-	      if (cr_left_in_buffer)
-		{
-		  nread = read_allowing_quit (fd, buffer + 1, sizeof(buffer) - 1);
-		  cr_left_in_buffer = 0;
-		  if (nread >= 0)
-		    nread++;
-		}
-	      else
-#endif /* DOS_NT */
 	  nread = read_allowing_quit (fd, buffer, sizeof buffer);
 	  if (nread < 0)
 	    error ("IO error reading %s: %s",
@@ -2938,60 +2752,8 @@
 	  else if (nread == 0)
 	    break;
 	  bufpos = 0;
-#ifdef DOS_NT
-	  /* If requested, we do a simple check on the first bufferful
-	     to decide whether the file is binary or text.  (If text, we
-	     count LF and CRLF occurences to determine whether the file
-	     was in Unix or DOS format.)  */
-	  if (crlf_conversion_required < 0)
-	    {
-	      crlf_conversion_required = decide_buffer_type (buffer, nread);
-	      current_buffer->buffer_file_type =
-		crlf_conversion_required ? Qnil : Qt;
-	    }
-
-	  /* DOS_NT text files require that we ignore a `\r' before a `\n'.  */
-	  if (crlf_conversion_required > 0)
-	    while (bufpos < nread && same_at_start < BUF_ZV (buf))
-	      {
-		int filec = buffer[bufpos];
-		int bufc  = BUF_FETCH_CHAR (buf, same_at_start);
-
-		if (filec == '\n')
-		  lf_count++;
-
-		if (filec == bufc)
-		  same_at_start++, bufpos++, same_at_start_in_file++;
-		else if (filec == '\r' && bufc == '\n')
-		  {
-		    /* If the `\r' is the last character in this buffer,
-		       it will be examined with the next bufferful.  */
-		    if (bufpos == nread)
-		      {
-			buffer[0] = filec;
-			cr_left_in_buffer = 1;
-		      }
-		    else if (buffer[bufpos + 1] == bufc)
-		      {
-			bufpos += 2;
-			same_at_start_in_file += 2;
-			same_at_start++;
-			crlf_count++;
-			lf_count++;
-		      }
-		    else
-		      break;
-		  }
-		else
-		  break;
-	      }
-	  else
-#endif /* DOS_NT */
 	  while (bufpos < nread && same_at_start < BUF_ZV (buf)
 		 && BUF_FETCH_CHAR (buf, same_at_start) == buffer[bufpos])
-#ifdef DOS_NT
-	    same_at_start_in_file++,
-#endif
 	    same_at_start++, bufpos++;
 	  /* If we found a discrepancy, stop the scan.
 	     Otherwise loop around and scan the next bufferful.  */
@@ -3000,11 +2762,7 @@
 	}
       /* If the file matches the buffer completely,
 	 there's no need to replace anything.  */
-#ifdef DOS_NT
-      if (same_at_start_in_file == st.st_size)
-#else
       if (same_at_start - BUF_BEGV (buf) == st.st_size)
-#endif /* DOS_NT */
 	{
 	  close (fd);
           unbind_to (speccount, Qnil);
@@ -3021,11 +2779,7 @@
 	  Bufpos bufpos, curpos, trial;
 
 	  /* At what file position are we now scanning?  */
-#ifdef DOS_NT
-	  curpos = same_at_end_in_file;
-#else
 	  curpos = st.st_size - (BUF_ZV (buf) - same_at_end);
-#endif /* DOS_NT */
 	  /* If the entire file matches the buffer tail, stop the scan.  */
 	  if (curpos == 0)
 	    break;
@@ -3046,59 +2800,12 @@
 	  /* Scan this bufferful from the end, comparing with
 	     the Emacs buffer.  */
 	  bufpos = total_read;
-#ifdef DOS_NT
-	  /* DOS_NT text files require that we ignore a `\r' before a `\n'.  */
-	  if (crlf_conversion_required)
-#endif /* DOS_NT */
 	  /* Compare with same_at_start to avoid counting some buffer text
 	     as matching both at the file's beginning and at the end.  */
-#if !defined(DOS_NT)
 	  while (bufpos > 0 && same_at_end > same_at_start
 		 && BUF_FETCH_CHAR (buf, same_at_end - 1) ==
 		 buffer[bufpos - 1])
 	    same_at_end--, bufpos--;
-#else /* DOS_NT */
- 	  while (bufpos > 0 && same_at_end > same_at_start
-		       && same_at_end_in_file > same_at_start_in_file)
-		  {
-		    int filec = buffer[bufpos - 1];
-		    int bufc  = BUF_FETCH_CHAR (buf, same_at_end - 1);
-
-		    /* Account for `\n' in previous bufferful.  */
-		    if (last_was_lf && filec == '\r')
-		      {
-			same_at_end_in_file--, bufpos--;
-			last_was_lf = 0;
-			crlf_count++;
-		      }
-		    else if (filec == bufc)
-		      {
-			last_was_lf = 0;
-			same_at_end--, same_at_end_in_file--, bufpos--;
-			if (bufc == '\n')
-			  {
-			    lf_count++;
-			    if (bufpos <= 0)
-			      last_was_lf = 1;
-			    else if (same_at_end_in_file <= same_at_start_in_file)
-			      break;
-			    else if (buffer[bufpos - 1] == '\r')
-			      same_at_end_in_file--, bufpos--, crlf_count++;
-			  }
-		      }
-		    else
-		      {
-			last_was_lf = 0;
-			break;
-		      }
-		  }
-	      else
-		while (bufpos > 0 && same_at_end > same_at_start
-		       && same_at_end_in_file > same_at_start_in_file
- 		 && BUF_FETCH_CHAR (buf, same_at_end - 1) ==
- 		 buffer[bufpos - 1])
-		  same_at_end--, same_at_end_in_file--, bufpos--;
-#endif /* !defined(DOS_NT) */
 	  /* If we found a discrepancy, stop the scan.
 	     Otherwise loop around and scan the preceding bufferful.  */
 	  if (bufpos != 0)
@@ -3117,13 +2824,8 @@
 	same_at_end += overlap;
 
       /* Arrange to read only the nonmatching middle part of the file.  */
-#ifdef DOS_NT
-	  beg = make_int (same_at_start_in_file);
-	  end = make_int (same_at_end_in_file);
-#else
       beg = make_int (same_at_start - BUF_BEGV (buf));
       end = make_int (st.st_size - (BUF_ZV (buf) - same_at_end));
-#endif /* DOS_NT */
 
       buffer_delete_range (buf, same_at_start, same_at_end,
 			   !NILP (visit) ? INSDEL_NO_LOCKING : 0);
@@ -3192,85 +2894,6 @@
 	      saverrno = errno;
 	    break;
 	  }
-#ifdef DOS_NT
-	    /* XEmacs (--marcpa) change: FSF does buffer_insert_raw_string_1() first
-	       then checks if conversion is needed, calling lisp
-	       (find-buffer-file-type) which can call a user-function that
-	       might look at the unconverted buffer to decide if
-	       conversion is needed.
-	       I removed the possibility for lisp functions called from
-	       find-buffer-file-type to look at the buffer's content, for
-	       simplicity reasons: it is easier to do the CRLF -> LF
-	       conversion on read_buf than on buffer contents because
-	       BUF_FETCH_CHAR does not return a pointer to an unsigned
-	       char memory location, and because we must cope with bytind
-	       VS bufpos in XEmacs, thus complicating crlf_to_lf().
-	       This decision (of doing Lstream_read(), crlf_to_lf() then
-	       buffer_insert_raw_string_1()) is debatable.
-	       --marcpa
-	       */
-	    /* Following FSF note no longer apply now.  See comment above.
-	       --marcpa*/
-	    /* For compatability with earlier versions that did not support the
-	       REPLACE funtionality, we call find-buffer-file-type after inserting
-	       the contents to allow it to inspect the inserted data.  (This was
-	       not intentional usage, but proved to be quite useful.)  */
-	    if (NILP (replace))
-	      {
-		/* Demacs 1.1.1 91/10/16 HIRANO Satoshi, MW July 1993 */
-		/* Determine file type (text/binary) from its name.
-		   Note that the buffer_file_type changes here when the file
-		   being inserted is not of the same type as the original buffer.  */
-		current_buffer->buffer_file_type = call1 (Qfind_buffer_file_type, filename);
-		if (NILP (current_buffer->buffer_file_type))
-		  crlf_conversion_required = 1;
-		else if (current_buffer->buffer_file_type != Qt)
-		  /* Use heuristic to decide whether file is text or binary (based
-		     on the first bufferful) if buffer-file-type is not nil or t.
-		     If no decision is made (because no line endings were ever
-		     seen) then let buffer-file-type default to nil.  */
-		  crlf_conversion_required = -1;
-	      }
-
-	    /* If requested, we check the inserted data to decide whether the file
-	       is binary or text.  (If text, we count LF and CRLF occurences to
-	       determine whether the file was in Unix or DOS format.)  */
-	    if (crlf_conversion_required < 0)
-	      {
-		crlf_conversion_required =
-		  decide_buffer_type (read_buf, this_len);
-		current_buffer->buffer_file_type =
-		  crlf_conversion_required ? Qnil : Qt;
-	      }
-
-	    /* Demacs 1.1.1 91/10/16 HIRANO Satoshi, MW July 1993 */
-	    /* Remove CRs from CR-LFs if the file is deemed to be a text file.  */
-	    if (crlf_conversion_required)
-	      {
-		int reduced_size
-		  = this_len - crlf_to_lf (this_len, read_buf,
-					   &lf_count);
-		crlf_count += reduced_size;
-		/* XEmacs (--marcpa) change: No need for this since we havent
-		   inserted in buffer yet. */
-#if 0
-		ZV -= reduced_size;
-		Z -= reduced_size;
-		GPT -= reduced_size;
-		GAP_SIZE += reduced_size;
-		inserted -= reduced_size;
-#endif
-		this_len -= reduced_size;
-
-		/* Change buffer_file_type back to binary if Unix eol format.  */
-		if (crlf_count == 0 && lf_count > 0)
-		  current_buffer->buffer_file_type = Qt;
-	      }
-
-	    /* Make crlf_count and lf_count available for inspection.  */
-	    Fset (intern ("buffer-file-lines"), make_int (lf_count));
-	    Fset (intern ("buffer-file-dos-lines"), make_int (crlf_count));
-#endif /* DOS_NT */
 
 	cc_inserted = buffer_insert_raw_string_1 (buf, cur_point, read_buf,
 						  this_len,
@@ -3434,11 +3057,6 @@
      to protect the current_buffer from being destroyed, but the
      multiple return points make this a pain in the butt. */
 
-#ifdef DOS_NT
-  int buffer_file_type
-    = NILP (current_buffer->buffer_file_type) ? O_TEXT : O_BINARY;
-#endif /* DOS_NT */
-
 #ifdef FILE_CODING
   codesys = Fget_coding_system (codesys);
 #endif /* MULE */
@@ -3522,24 +3140,14 @@
   fn = filename;
   desc = -1;
   if (!NILP (append))
-#ifdef DOS_NT
-    desc = open ((char *) XSTRING_DATA (fn),
-                       (O_WRONLY | buffer_file_type), 0);
-#else /* not DOS_NT */
-    desc = open ((char *) XSTRING_DATA (fn), O_WRONLY | OPEN_BINARY, 0);
-#endif /* not DOS_NT */
-
+    {
+      desc = open ((char *) XSTRING_DATA (fn), O_WRONLY | OPEN_BINARY, 0);
+    }
   if (desc < 0)
     {
-#ifdef DOS_NT
-      desc = open ((char *) XSTRING_DATA (fn),
-                   (O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type),
-                   (S_IREAD | S_IWRITE));
-#else /* not DOS_NT */
       desc = open ((char *) XSTRING_DATA (fn),
                    (O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY),
 		   ((auto_saving) ? auto_save_mode_bits : CREAT_MODE));
-#endif /* DOS_NT */
     }
 
   if (desc < 0)
@@ -4286,15 +3894,9 @@
 		 if we actually auto-saved any files. */
 	      if (!auto_saved && GC_STRINGP (listfile) && listdesc < 0)
 		{
-#ifdef DOS_NT
-		  listdesc = open ((char *) XSTRING_DATA (listfile),
-				   O_WRONLY | O_TRUNC | O_CREAT | O_BINARY,
-				   S_IREAD | S_IWRITE);
-#else /* not DOS_NT */
 		  listdesc = open ((char *) XSTRING_DATA (listfile),
 				   O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
 				   CREAT_MODE);
-#endif /* not DOS_NT */
 
 		  /* Arrange to close that file whether or not we get
 		     an error. */
@@ -4465,9 +4067,6 @@
   defsymbol (&Qwrite_region, "write-region");
   defsymbol (&Qverify_visited_file_modtime, "verify-visited-file-modtime");
   defsymbol (&Qset_visited_file_modtime, "set-visited-file-modtime");
-#ifdef DOS_NT
-  defsymbol (&Qfind_buffer_file_type, "find-buffer-file-type");
-#endif /* DOS_NT */
   defsymbol (&Qcar_less_than_car, "car-less-than-car"); /* Vomitous! */
 
   defsymbol (&Qfile_name_handler_alist, "file-name-handler-alist");
@@ -4629,16 +4228,4 @@
 what the normal separator is.
 */ );
   Vdirectory_sep_char = make_char('/');
-
-#ifdef DOS_NT
-  DEFVAR_LISP ("insert-file-contents-allow-replace", &Vinsert_file_contents_allow_replace /*
-    *Allow REPLACE option of insert-file-contents to preserve markers.
-If non-nil, the REPLACE option works as described, preserving markers.
-If nil, the REPLACE option is implemented by deleting the visible region
-then inserting the file contents as if REPLACE was nil.
-
-This option is only meaningful on Windows.
-*/ );
-  Vinsert_file_contents_allow_replace = Qt;
-#endif
 }
--- a/src/gif_err.c	Mon Aug 13 10:24:47 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/* Synched up with: Not in FSF. */
-
-/*****************************************************************************
-*   "Gif-Lib" - Yet another gif library.				     *
-*									     *
-* Written by:  Gershon Elber			IBM PC Ver 0.1,	Jun. 1989    *
-******************************************************************************
-* Handle error reporting for the GIF library.				     *
-******************************************************************************
-* History:								     *
-* 17 Jun 89 - Version 1.0 by Gershon Elber.				     *
-*****************************************************************************/
-
-#ifdef emacs
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include "gif_lib.h"
-
-#define PROGRAM_NAME	"GIF_LIBRARY"
-
-int _GifError;
-
-#ifndef emacs
-#ifdef SYSV
-static char *VersionStr =
-        "Gif library module,\t\tGershon Elber\n\
-	(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
-#else
-static char *VersionStr =
-	PROGRAM_NAME
-	"	IBMPC "
-	GIF_LIB_VERSION
-	"	Gershon Elber,	"
-	__DATE__ ",   " __TIME__ "\n"
-	"(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
-#endif /* SYSV */
-#endif /* !emacs */
-
-/*****************************************************************************
-* Return the last GIF error (0 if none) and reset the error.		     *
-*****************************************************************************/
-int GifLastError(void)
-{
-    int i = _GifError;
-
-    _GifError = 0;
-
-    return i;
-}
-
-/*****************************************************************************
-* Print the last GIF error to stderr.					     *
-*****************************************************************************/
-#ifdef emacs
-CONST char *EmacsPrintGifError(void)
-#else
-void PrintGifError(void)
-#endif
-{
-    CONST char *Err;
-
-    switch(_GifError) {
-	case E_GIF_ERR_OPEN_FAILED:
-	    Err = "Failed to open given file";
-	    break;
-	case E_GIF_ERR_WRITE_FAILED:
-	    Err = "Failed to Write to given file";
-	    break;
-	case E_GIF_ERR_HAS_SCRN_DSCR:
-	    Err = "Screen Descriptor already been set";
-	    break;
-	case E_GIF_ERR_HAS_IMAG_DSCR:
-	    Err = "Image Descriptor is still active";
-	    break;
-	case E_GIF_ERR_NO_COLOR_MAP:
-	    Err = "Neither Global Nor Local color map";
-	    break;
-	case E_GIF_ERR_DATA_TOO_BIG:
-	    Err = "#Pixels bigger than Width * Height";
-	    break;
-	case E_GIF_ERR_NOT_ENOUGH_MEM:
-	    Err = "Fail to allocate required memory";
-	    break;
-	case E_GIF_ERR_DISK_IS_FULL:
-	    Err = "Write failed (disk full?)";
-	    break;
-	case E_GIF_ERR_CLOSE_FAILED:
-	    Err = "Failed to close given file";
-	    break;
-	case E_GIF_ERR_NOT_WRITEABLE:
-	    Err = "Given file was not opened for write";
-	    break;
-	case D_GIF_ERR_OPEN_FAILED:
-	    Err = "Failed to open given file";
-	    break;
-	case D_GIF_ERR_READ_FAILED:
-	    Err = "Failed to Read from given file";
-	    break;
-	case D_GIF_ERR_NOT_GIF_FILE:
-	    Err = "Given file is NOT GIF file";
-	    break;
-	case D_GIF_ERR_NO_SCRN_DSCR:
-	    Err = "No Screen Descriptor detected";
-	    break;
-	case D_GIF_ERR_NO_IMAG_DSCR:
-	    Err = "No Image Descriptor detected";
-	    break;
-	case D_GIF_ERR_NO_COLOR_MAP:
-	    Err = "Neither Global Nor Local color map";
-	    break;
-	case D_GIF_ERR_WRONG_RECORD:
-	    Err = "Wrong record type detected";
-	    break;
-	case D_GIF_ERR_DATA_TOO_BIG:
-	    Err = "#Pixels bigger than Width * Height";
-	    break;
-	case D_GIF_ERR_NOT_ENOUGH_MEM:
-	    Err = "Fail to allocate required memory";
-	    break;
-	case D_GIF_ERR_CLOSE_FAILED:
-	    Err = "Failed to close given file";
-	    break;
-	case D_GIF_ERR_NOT_READABLE:
-	    Err = "Given file was not opened for read";
-	    break;
-	case D_GIF_ERR_IMAGE_DEFECT:
-	    Err = "Image is defective, decoding aborted";
-	    break;
-	case D_GIF_ERR_EOF_TOO_SOON:
-	    Err = "Image EOF detected, before image complete";
-	    break;
-	default:
-	    Err = NULL;
-	    break;
-    }
-#ifdef emacs
-    if (Err != NULL)
-      return Err;
-    else
-      return "Unknown error";
-#else
-    if (Err != NULL)
-	fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
-    else
-	fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
-#endif
-}
-
-void init_gif_err (void);
-void
-init_gif_err (void)
-{
-  _GifError = 0;
-}
--- a/src/gif_lib.h	Mon Aug 13 10:24:47 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,284 +0,0 @@
-/* Synched up with: Not in FSF. */
-
-/******************************************************************************
-* In order to make life a little bit easier when using the GIF file format,   *
-* this library was written, and which does all the dirty work...	      *
-*									      *
-*					Written by Gershon Elber,  Jun. 1989  *
-*					Hacks by Eric S. Raymond,  Sep. 1992  *
-*******************************************************************************
-* History:								      *
-* 14 Jun 89 - Version 1.0 by Gershon Elber.				      *
-*  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
-* 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)   *
-******************************************************************************/
-
-#ifndef GIF_LIB_H
-#define GIF_LIB_H
-
-#define GIF_LIB_VERSION	" Version 2.0, "
-
-#define	GIF_ERROR	0
-#define GIF_OK		1
-
-#ifndef TRUE
-#define TRUE		1
-#define FALSE		0
-#endif
-
-#ifndef NULL
-#define NULL		0
-#endif /* NULL */
-
-#define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
-
-typedef	int		GifBooleanType;
-typedef	unsigned char	GifPixelType;
-typedef unsigned char *	GifRowType;
-typedef unsigned char	GifByteType;
-
-#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
-#define GIF_EXIT(Msg)	{ GIF_MESSAGE(Msg); exit(-3); }
-
-#ifdef SYSV
-#define VoidPtr char *
-#else
-#define VoidPtr void *
-#endif /* SYSV */
-
-typedef struct GifColorType {
-    GifByteType Red, Green, Blue;
-} GifColorType;
-
-typedef struct ColorMapObject
-{
-    int	ColorCount;
-    int BitsPerPixel;
-    GifColorType *Colors;		/* on malloc(3) heap */
-}
-ColorMapObject;
-
-typedef struct GifImageDesc {
-    int Left, Top, Width, Height,	/* Current image dimensions. */
-	Interlace;			/* Sequential/Interlaced lines. */
-    ColorMapObject *ColorMap;		/* The local color map */
-} GifImageDesc;
-
-typedef struct GifFileType {
-    int SWidth, SHeight,		/* Screen dimensions. */
-	SColorResolution, 		/* How many colors can we generate? */
-	SBackGroundColor;		/* I hope you understand this one... */
-    ColorMapObject *SColorMap;		/* NULL if not exists. */
-    int ImageCount;			/* Number of current image */
-    GifImageDesc Image;			/* Block describing current image */
-    struct SavedImage *SavedImages;	/* Use this to accumulate file state */
-    VoidPtr Private;	  		/* Don't mess with this! */
-} GifFileType;
-
-typedef enum {
-    UNDEFINED_RECORD_TYPE,
-    SCREEN_DESC_RECORD_TYPE,
-    IMAGE_DESC_RECORD_TYPE,		/* Begin with ',' */
-    EXTENSION_RECORD_TYPE,		/* Begin with '!' */
-    TERMINATE_RECORD_TYPE		/* Begin with ';' */
-} GifRecordType;
-
-/* DumpScreen2Gif routine constants identify type of window/screen to dump.  */
-/* Note all values below 1000 are reserved for the IBMPC different display   */
-/* devices (it has many!) and are compatible with the numbering TC2.0        */
-/* (Turbo C 2.0 compiler for IBM PC) gives to these devices.		     */
-typedef enum {
-    GIF_DUMP_SGI_WINDOW = 1000,
-    GIF_DUMP_X_WINDOW = 1001
-} GifScreenDumpType;
-
-/******************************************************************************
-* O.K., here are the routines one can access in order to encode GIF file:     *
-* (GIF_LIB file EGIF_LIB.C).						      *
-******************************************************************************/
-
-GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance);
-GifFileType *EGifOpenFileHandle(int GifFileHandle);
-int EGifSpew(GifFileType *GifFile);
-void EGifSetGifVersion(char *Version);
-int EGifPutScreenDesc(GifFileType *GifFile,
-	int GifWidth, int GifHeight, int GifColorRes, int GifBackGround,
-	ColorMapObject *GifColorMap);
-int EGifPutImageDesc(GifFileType *GifFile,
-	int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace,
-	ColorMapObject *GifColorMap);
-int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
-int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
-int EGifPutComment(GifFileType *GifFile, char *GifComment);
-int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen,
-							VoidPtr GifExtension);
-int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
-						   GifByteType *GifCodeBlock);
-int EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock);
-int EGifCloseFile(GifFileType *GifFile);
-
-#define	E_GIF_ERR_OPEN_FAILED	1		/* And EGif possible errors. */
-#define	E_GIF_ERR_WRITE_FAILED	2
-#define E_GIF_ERR_HAS_SCRN_DSCR	3
-#define E_GIF_ERR_HAS_IMAG_DSCR	4
-#define E_GIF_ERR_NO_COLOR_MAP	5
-#define E_GIF_ERR_DATA_TOO_BIG	6
-#define E_GIF_ERR_NOT_ENOUGH_MEM 7
-#define E_GIF_ERR_DISK_IS_FULL	8
-#define E_GIF_ERR_CLOSE_FAILED	9
-#define E_GIF_ERR_NOT_WRITEABLE	10
-
-/******************************************************************************
-* O.K., here are the routines one can access in order to decode GIF file:     *
-* (GIF_LIB file DGIF_LIB.C).						      *
-******************************************************************************/
-
-GifFileType *DGifOpenFileName(CONST char *GifFileName);
-GifFileType *DGifOpenFileHandle(int GifFileHandle);
-int DGifSlurp(GifFileType *GifFile);
-int DGifGetScreenDesc(GifFileType *GifFile);
-int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
-int DGifGetImageDesc(GifFileType *GifFile);
-int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
-int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
-int DGifGetComment(GifFileType *GifFile, char *GifComment);
-int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
-						GifByteType **GifExtension);
-int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
-int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
-						GifByteType **GifCodeBlock);
-int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
-int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
-int DGifCloseFile(GifFileType *GifFile);
-
-#define	D_GIF_ERR_OPEN_FAILED	101		/* And DGif possible errors. */
-#define	D_GIF_ERR_READ_FAILED	102
-#define	D_GIF_ERR_NOT_GIF_FILE	103
-#define D_GIF_ERR_NO_SCRN_DSCR	104
-#define D_GIF_ERR_NO_IMAG_DSCR	105
-#define D_GIF_ERR_NO_COLOR_MAP	106
-#define D_GIF_ERR_WRONG_RECORD	107
-#define D_GIF_ERR_DATA_TOO_BIG	108
-#define D_GIF_ERR_NOT_ENOUGH_MEM 109
-#define D_GIF_ERR_CLOSE_FAILED	110
-#define D_GIF_ERR_NOT_READABLE	111
-#define D_GIF_ERR_IMAGE_DEFECT	112
-#define D_GIF_ERR_EOF_TOO_SOON	113
-
-/******************************************************************************
-* O.K., here are the routines from GIF_LIB file QUANTIZE.C.		      *
-******************************************************************************/
-int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize,
-	GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
-	GifByteType *OutputBuffer, GifColorType *OutputColorMap);
-
-
-/******************************************************************************
-* O.K., here are the routines from GIF_LIB file QPRINTF.C.		      *
-******************************************************************************/
-extern int GifQuietPrint;
-
-#ifdef USE_VARARGS
-extern void GifQprintf();
-#else
-extern void GifQprintf(char *Format, ...);
-#endif /* USE_VARARGS */
-
-/******************************************************************************
-* O.K., here are the routines from GIF_LIB file GIF_ERR.C.		      *
-******************************************************************************/
-#ifdef emacs
-extern CONST char *EmacsPrintGifError(void);
-#else
-extern void PrintGifError(void);
-#endif
-extern int GifLastError(void);
-
-/******************************************************************************
-* O.K., here are the routines from GIF_LIB file DEV2GIF.C.		      *
-******************************************************************************/
-extern int DumpScreen2Gif(char *FileName,
-			  int ReqGraphDriver,
-			  int ReqGraphMode1,
-			  int ReqGraphMode2,
-			  int ReqGraphMode3);
-
-/*****************************************************************************
- *
- * Everything below this point is new after version 1.2, supporting `slurp
- * mode' for doing I/O in two big belts with all the image-bashing in core.
- *
- *****************************************************************************/
-
-/******************************************************************************
-* Color Map handling from ALLOCGIF.C					      *
-******************************************************************************/
-
-extern ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap);
-extern void FreeMapObject(ColorMapObject *Objet);
-extern ColorMapObject *UnionColorMap(ColorMapObject *ColorIn1,
-			      ColorMapObject *ColorIn2,
-			      GifPixelType ColorTransIn2[]);
-extern int BitSize(int n);
-
-/******************************************************************************
-* Support for the in-core structures allocation (slurp mode).		      *
-******************************************************************************/
-
-/* This is the in-core version of an extension record */
-typedef struct {
-    int		ByteCount;
-    GifByteType	*Bytes;		/* on malloc(3) heap */
-} ExtensionBlock;
-
-/* This holds an image header, its unpacked raster bits, and extensions */
-typedef struct SavedImage {
-    GifImageDesc	ImageDesc;
-
-    GifPixelType	*RasterBits;		/* on malloc(3) heap */
-
-    int			Function;
-    int			ExtensionBlockCount;
-    ExtensionBlock	*ExtensionBlocks;	/* on malloc(3) heap */
-} SavedImage;
-
-extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
-
-extern void MakeExtension(SavedImage *New, int Function);
-extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]);
-extern void FreeExtension(SavedImage *Image);
-
-extern SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom);
-extern void FreeSavedImages(GifFileType *GifFile);
-
-/******************************************************************************
-* The library's internal utility font					      *
-******************************************************************************/
-
-#define GIF_FONT_WIDTH	8
-#define GIF_FONT_HEIGHT	8
-extern unsigned char AsciiTable[][GIF_FONT_WIDTH];
-
-extern void DrawText(SavedImage *Image,
-		     CONST int x, CONST int y,
-		     CONST char *legend,
-		     CONST int color);
-
-extern void DrawBox(SavedImage *Image,
-		     CONST int x, CONST int y,
-		     CONST int w, CONST int d,
-		     CONST int color);
-
-void DrawRectangle(SavedImage *Image,
-		     CONST int x, CONST int y,
-		     CONST int w, CONST int d,
-		     CONST int color);
-
-extern void DrawBoxedText(SavedImage *Image,
-		     CONST int x, CONST int y,
-		     CONST char *legend,
-		     CONST int border,
-		     CONST int bg,
-		     CONST int fg);
-
-#endif /* GIF_LIB_H */
--- a/src/gifalloc.c	Mon Aug 13 10:24:47 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +0,0 @@
-/* Synched up with: Not in FSF. */
-
-/*****************************************************************************
-*   "Gif-Lib" - Yet another gif library.				     *
-*									     *
-* Written by:  Gershon Elber				Ver 0.1, Jun. 1989   *
-* Extensively hacked by: Eric S. Raymond		Ver 1.?, Sep 1992    *
-******************************************************************************
-* GIF construction tools						      *
-******************************************************************************
-* History:								     *
-* 15 Sep 92 - Version 1.0 by Eric Raymond.				     *
-*****************************************************************************/
-
-#ifdef emacs
-#include <config.h>
-
-void *xmalloc (unsigned int size);
-void *xrealloc (void *ptr, unsigned int size);
-#ifdef ERROR_CHECK_MALLOC
-void *xfree_1 (void *);
-#define xfree xfree_1
-#else
-void *xfree (void *);
-#endif
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifdef emacs
-#include <config.h>
-
-void *xmalloc (unsigned int size);
-void *xrealloc (void *ptr, unsigned int size);
-#ifdef ERROR_CHECK_MALLOC
-void *xfree_1 (void *);
-#define xfree xfree_1
-#else
-void *xfree (void *);
-#endif
-#endif
-#include "gif_lib.h"
-
-#ifndef MAX
-#define MAX(x, y)	(((x) > (y)) ? (x) : (y))
-#endif
-
-#ifndef REGISTER	/* Rigidly enforced in 20.3 */
-#define REGISTER
-#endif
-
-/******************************************************************************
-* Miscellaneous utility functions					      *
-******************************************************************************/
-
-int BitSize(int n)
-/* return smallest bitfield size n will fit in */
-{
-    REGISTER int i;
-
-    for (i = 1; i <= 8; i++)
-	if ((1 << i) >= n)
-	    break;
-    return(i);
-}
-
-
-/******************************************************************************
-* Color map object functions						      *
-******************************************************************************/
-
-ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap)
-/*
- * Allocate a color map of given size; initialize with contents of
- * ColorMap if that pointer is non-NULL.
- */
-{
-    ColorMapObject *Object;
-
-    if (ColorCount != (1 << BitSize(ColorCount)))
-	return((ColorMapObject *)NULL);
-
-    Object = (ColorMapObject *)xmalloc(sizeof(ColorMapObject));
-    if (Object == (ColorMapObject *)NULL)
-	return((ColorMapObject *)NULL);
-
-    Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
-    if (Object->Colors == (GifColorType *)NULL)
-	return((ColorMapObject *)NULL);
-
-    Object->ColorCount = ColorCount;
-    Object->BitsPerPixel = BitSize(ColorCount);
-
-    if (ColorMap)
-	memcpy((char *)Object->Colors,
-	       (char *)ColorMap, ColorCount * sizeof(GifColorType));
-
-    return(Object);
-}
-
-void FreeMapObject(ColorMapObject *Object)
-/*
- * Free a color map object
- */
-{
-    xfree(Object->Colors);
-    xfree(Object);
-}
-
-#ifdef DEBUG
-void DumpColorMap(ColorMapObject *Object, FILE *fp)
-{
-    if (Object)
-    {
-	int i, j, Len = Object->ColorCount;
-
-	for (i = 0; i < Len; i+=4) {
-	    for (j = 0; j < 4 && j < Len; j++) {
-		fprintf(fp,
-			"%3d: %02x %02x %02x   ", i + j,
-		       Object->Colors[i + j].Red,
-		       Object->Colors[i + j].Green,
-		       Object->Colors[i + j].Blue);
-	    }
-	    fprintf(fp, "\n");
-	}
-    }
-}
-#endif /* DEBUG */
-
-ColorMapObject *UnionColorMap(
-			 ColorMapObject *ColorIn1,
-			 ColorMapObject *ColorIn2,
-			 GifPixelType ColorTransIn2[])
-/*
- * Compute the union of two given color maps and return it.  If result can't 
- * fit into 256 colors, NULL is returned, the allocated union otherwise.
- * ColorIn1 is copied as it to ColorUnion, while colors from ColorIn2 are
- * copied iff they didn't exist before.  ColorTransIn2 maps the old
- * ColorIn2 into ColorUnion color map table.
- */
-{
-    int i, j, CrntSlot, RoundUpTo, NewBitSize;
-    ColorMapObject *ColorUnion;
-
-    /*
-     * Allocate table which will hold the result for sure.
-     */
-    ColorUnion
-	= MakeMapObject(MAX(ColorIn1->ColorCount,ColorIn2->ColorCount)*2,NULL);
-
-    if (ColorUnion == NULL)
-	return(NULL);
-
-    /* Copy ColorIn1 to ColorUnionSize; */
-    for (i = 0; i < ColorIn1->ColorCount; i++)
-	ColorUnion->Colors[i] = ColorIn1->Colors[i];
-    CrntSlot = ColorIn1->ColorCount;
-
-    /*
-     * Potentially obnoxious hack:
-     *
-     * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end
-     * of table 1.  This is very useful if your display is limited to
-     * 16 colors.
-     */
-    while (ColorIn1->Colors[CrntSlot-1].Red == 0
-	   && ColorIn1->Colors[CrntSlot-1].Green == 0
-	   && ColorIn1->Colors[CrntSlot-1].Red == 0)
-	CrntSlot--;
-
-    /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */
-    for (i = 0; i < ColorIn2->ColorCount && CrntSlot<=256; i++)
-    {
-	/* Let's see if this color already exists: */
-	for (j = 0; j < ColorIn1->ColorCount; j++)
-	    if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i], sizeof(GifColorType)) == 0)
-		break;
-
-	if (j < ColorIn1->ColorCount)
-	    ColorTransIn2[i] = j;	/* color exists in Color1 */
-	else
-	{
-	    /* Color is new - copy it to a new slot: */
-	    ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
-	    ColorTransIn2[i] = CrntSlot++;
-	}
-    }
-
-    if (CrntSlot > 256)
-    {
-	FreeMapObject(ColorUnion);
-	return((ColorMapObject *)NULL);
-    }
-
-    NewBitSize = BitSize(CrntSlot);
-    RoundUpTo = (1 << NewBitSize);
-
-    if (RoundUpTo != ColorUnion->ColorCount)
-    {
-	REGISTER GifColorType	*Map = ColorUnion->Colors;
-
-	/*
-	 * Zero out slots up to next power of 2.
-	 * We know these slots exist because of the way ColorUnion's
-	 * start dimension was computed.
-	 */
-	for (j = CrntSlot; j < RoundUpTo; j++)
-	    Map[j].Red = Map[j].Green = Map[j].Blue = 0;
-
-	/* perhaps we can shrink the map? */
-	if (RoundUpTo < ColorUnion->ColorCount)
-	    ColorUnion->Colors 
-		= (GifColorType *)xrealloc(Map, sizeof(GifColorType)*RoundUpTo);
-    }
-
-    ColorUnion->ColorCount = RoundUpTo;
-    ColorUnion->BitsPerPixel = NewBitSize;
-
-    return(ColorUnion);
-}
-
-void ApplyTranslation(SavedImage *Image, GifPixelType Translation[])
-/*
- * Apply a given color translation to the raster bits of an image
- */
-{
-    REGISTER int i;
-    REGISTER int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width;
-
-    for (i = 0; i < RasterSize; i++)
-	Image->RasterBits[i] = Translation[Image->RasterBits[i]];
-}
-
-/******************************************************************************
-* Extension record functions						      *
-******************************************************************************/
-
-void MakeExtension(SavedImage *New, int Function)
-{
-    New->Function = Function;
-    /*
-     * Someday we might have to deal with multiple extensions.
-     */
-}
-
-int AddExtensionBlock(SavedImage *New, int Len, char ExtData[])
-{
-    ExtensionBlock	*ep;
-
-    if (New->ExtensionBlocks == NULL)
-	New->ExtensionBlocks = (ExtensionBlock *)xmalloc(sizeof(ExtensionBlock));
-    else
-	New->ExtensionBlocks =
-	    (ExtensionBlock *)xrealloc(New->ExtensionBlocks,
-		      sizeof(ExtensionBlock) * (New->ExtensionBlockCount + 1));
-
-    if (New->ExtensionBlocks == NULL)
-	return(GIF_ERROR);
-
-    ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
-
-    if ((ep->Bytes = (GifByteType *)xmalloc(ep->ByteCount = Len)) == NULL)
-	return(GIF_ERROR);
-
-    if (ExtData)
-	memcpy(ep->Bytes, ExtData, Len);
-
-    return(GIF_OK);
-}
-
-void FreeExtension(SavedImage *Image)
-{
-    ExtensionBlock	*ep;
-
-    for (ep = Image->ExtensionBlocks;
-	 ep < Image->ExtensionBlocks + Image->ExtensionBlockCount;
-	 ep++)
-	(void) xfree((char *)ep->Bytes);
-    xfree((char *)Image->ExtensionBlocks);
-    Image->ExtensionBlocks = NULL;
-}
-
-/******************************************************************************
-* Image block allocation functions					      *
-******************************************************************************/
-SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom)
-/*
- * Append an image block to the SavedImages array  
- */
-{
-    SavedImage	*sp;
-
-    if (GifFile->SavedImages == NULL)
-	GifFile->SavedImages = (SavedImage *)xmalloc(sizeof(SavedImage));
-    else
-	GifFile->SavedImages = (SavedImage *)xrealloc(GifFile->SavedImages,
-				sizeof(SavedImage) * (GifFile->ImageCount+1));
-
-    if (GifFile->SavedImages == NULL)
-	return((SavedImage *)NULL);
-    else
-    {
-	sp = &GifFile->SavedImages[GifFile->ImageCount++];
-	memset((char *)sp, '\0', sizeof(SavedImage));
-
-	if (CopyFrom)
-	{
-	    memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
-
-	    /*
-	     * Make our own allocated copies of the heap fields in the
-	     * copied record.  This guards against potential aliasing
-	     * problems.
-	     */
-
-	    /* first, the local color map */
-	    if (sp->ImageDesc.ColorMap)
-		sp->ImageDesc.ColorMap =
-		    MakeMapObject(CopyFrom->ImageDesc.ColorMap->ColorCount,
-				  CopyFrom->ImageDesc.ColorMap->Colors);
-
-	    /* next, the raster */
-	    sp->RasterBits = (GifPixelType *)xmalloc(sizeof(GifPixelType)
-				* CopyFrom->ImageDesc.Height
-				* CopyFrom->ImageDesc.Width);
-	    memcpy(sp->RasterBits,
-		   CopyFrom->RasterBits,
-		   sizeof(GifPixelType)
-			* CopyFrom->ImageDesc.Height
-			* CopyFrom->ImageDesc.Width);
-
-	    /* finally, the extension blocks */
-	    if (sp->ExtensionBlocks)
-	    {
-		sp->ExtensionBlocks
-		    = (ExtensionBlock*)xmalloc(sizeof(ExtensionBlock)
-					      * CopyFrom->ExtensionBlockCount);
-		memcpy(sp->ExtensionBlocks,
-		   CopyFrom->ExtensionBlocks,
-		   sizeof(ExtensionBlock)
-		   	* CopyFrom->ExtensionBlockCount);
-
-		/*
-		 * For the moment, the actual blocks can take their
-		 * chances with free().  We'll fix this later. 
-		 */
-	    }
-	}
-
-	return(sp);
-    }
-}
-
-void FreeSavedImages(GifFileType *GifFile)
-{
-    SavedImage	*sp;
-
-    for (sp = GifFile->SavedImages;
-	 sp < GifFile->SavedImages + GifFile->ImageCount;
-	 sp++)
-    {
-	if (sp->ImageDesc.ColorMap)
-	  {
-	    FreeMapObject(sp->ImageDesc.ColorMap);
-	    sp->ImageDesc.ColorMap = 0;
-	  }
-
-	if (sp->RasterBits)
-	  {
-	    xfree((char *)sp->RasterBits);
-	    sp->RasterBits = 0;
-	  }
-
-	if (sp->ExtensionBlocks)
-	  {
-	    FreeExtension(sp);
-	    sp->ExtensionBlocks = 0;
-	  }
-    }
-    xfree((char *) GifFile->SavedImages);
-}
-
-
-
--- a/src/glyphs-x.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/glyphs-x.c	Mon Aug 13 10:25:37 2007 +0200
@@ -35,6 +35,10 @@
    Improved GIF/JPEG support added by Bill Perry for 19.14
    Cleanup/simplification of error handling by Ben Wing for 19.14
    Pointer/icon overhaul, more restructuring by Ben Wing for 19.14
+   GIF support changed to external GIFlib 3.1 by Jareth Hein for 20.5
+   Many changes for color work and optimizations by Jareth Hein for 20.5
+   Switch of GIF/JPEG/PNG to new EImage intermediate code by Jareth Hein for 20.5
+   TIFF code by Jareth Hein for 20.5
 
    TODO:
    Convert images.el to C and stick it in here?
@@ -53,6 +57,8 @@
 #include "insdel.h"
 #include "opaque.h"
 
+#include "imgproc.h"
+
 #include "sysfile.h"
 
 #ifdef HAVE_PNG
@@ -70,8 +76,17 @@
 #include "file-coding.h"
 #endif
 
-#define LISP_DEVICE_TO_X_SCREEN(dev)					\
-  XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev)))
+#if INTBITS == 32
+# define FOUR_BYTE_TYPE unsigned int
+#elif LONGBITS == 32
+# define FOUR_BYTE_TYPE unsigned long
+#elif SHORTBITS == 32
+# define FOUR_BYTE_TYPE unsigned short
+#else
+#error What kind of strange-ass system are we running on?
+#endif
+
+#define LISP_DEVICE_TO_X_SCREEN(dev) XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev)))
 
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm);
 Lisp_Object Qxbm;
@@ -131,6 +146,165 @@
 /*                      image instance methods                          */
 /************************************************************************/
 
+/************************************************************************/
+/* convert from a series of RGB triples to an XImage formated for the   */
+/* proper display 							*/
+/************************************************************************/
+XImage *EImage2XImage(Lisp_Object device, int width, int height, unsigned char *pic,
+		      unsigned long **pixtbl, int *pixcount, int *npixels)
+{
+  Display *dpy;
+  Colormap cmap;
+  Visual *vis;
+  XImage *outimg;
+  int depth, bitmap_pad, byte_cnt, i, j;
+  int rd,gr,bl,q;
+  unsigned char *data, *ip, *dp;
+  quant_table *qtable;
+  union {
+    FOUR_BYTE_TYPE val;
+    char cp[4];
+  } conv;
+
+  dpy = DEVICE_X_DISPLAY (XDEVICE (device));
+  cmap = DEVICE_X_COLORMAP (XDEVICE(device));
+  vis = DEVICE_X_VISUAL (XDEVICE(device));
+  depth = DEVICE_X_DEPTH(XDEVICE(device));
+
+  if (vis->class == PseudoColor) {
+    /* Quantize the image and get a histogram while we're at it.
+       Do this first to save memory */
+    qtable = EImage_build_quantable(pic, width, height, 256);
+    if (qtable == NULL) return NULL;
+  }
+
+  bitmap_pad = ((depth > 16) ? 32 :
+		(depth >  8) ? 16 :
+		8);
+  byte_cnt = bitmap_pad >> 3;
+  
+  outimg = XCreateImage (dpy, vis,
+			 depth, ZPixmap, 0, 0, width, height,
+			 bitmap_pad, 0);
+  if (!outimg) return NULL;
+
+  data = (unsigned char *) xmalloc (outimg->bytes_per_line * height);
+  if (!data) {
+    XDestroyImage(outimg);
+    return NULL;
+  }
+  outimg->data = data;
+  
+  if (vis->class == PseudoColor) {
+    unsigned long pixarray[256];
+    int n;
+    /* use our quantize table to allocate the colors */
+    *pixcount = 32;
+    *pixtbl = xnew_array (unsigned long, *pixcount);
+    *npixels = 0;
+
+    /* ### should implement a sort by popularity to assure proper allocation */
+    n = *npixels;
+    for (i = 0; i < qtable->num_active_colors; i++) {
+	XColor color;
+	int res;
+	
+	color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0;
+	color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0;
+	color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0;
+	color.flags = DoRed | DoGreen | DoBlue;
+	res = allocate_nearest_color (dpy, cmap, vis, &color);
+	if (res > 0 && res < 3)
+	  {
+	    DO_REALLOC(*pixtbl, *pixcount, n+1, unsigned long);
+	    (*pixtbl)[n] = color.pixel;
+	    n++;
+	  }
+	pixarray[i] = color.pixel;
+    }
+    *npixels = n;
+    ip = pic;
+    for (i = 0; i < height; i++) {
+      dp = data + (i * outimg->bytes_per_line);
+      for (j = 0; j < width; j++) {
+	rd = *ip++;
+	gr = *ip++;
+	bl = *ip++;
+	conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)];
+#ifdef WORDS_BIGENDIAN
+	for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
+#else
+	for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
+#endif
+      }
+    }
+    xfree(qtable);
+  } else {
+    unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
+    junk = vis->red_mask;
+    rshift = 0;
+    while ((junk & 0x1) == 0) {
+      junk = junk >> 1;
+      rshift ++;
+    }
+    rbits = 0;
+    while (junk != 0) {
+      junk = junk >> 1;
+      rbits++;
+    }
+    junk = vis->green_mask;
+    gshift = 0;
+    while ((junk & 0x1) == 0) {
+      junk = junk >> 1;
+      gshift ++;
+    }
+    gbits = 0;
+    while (junk != 0) {
+      junk = junk >> 1;
+      gbits++;
+    }
+    junk = vis->blue_mask;
+    bshift = 0;
+    while ((junk & 0x1) == 0) {
+      junk = junk >> 1;
+      bshift ++;
+    }
+    bbits = 0;
+    while (junk != 0) {
+      junk = junk >> 1;
+      bbits++;
+    }
+    ip = pic;
+    for (i = 0; i < height; i++) {
+      dp = data + (i * outimg->bytes_per_line);
+      for (j = 0; j < width; j++) {
+	if (rbits > 8)
+	  rd = *ip++ << (rbits - 8);
+	else
+	  rd = *ip++ >> (8 - rbits);
+	if (gbits > 8)
+	  gr = *ip++ << (gbits - 8);
+	else
+	  gr = *ip++ >> (8 - gbits);
+	if (bbits > 8)
+	  bl = *ip++ << (bbits - 8);
+	else
+	  bl = *ip++ >> (8 - bbits);
+
+	conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift);
+#ifdef WORDS_BIGENDIAN
+	for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
+#else
+	for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
+#endif
+      }
+    }
+  }  
+  return outimg;
+}
+
+
+
 static void
 x_print_image_instance (struct Lisp_Image_Instance *p,
 			Lisp_Object printcharfun,
@@ -340,7 +514,7 @@
 	  && !strcmp (type, "String"))
 	Vx_bitmap_file_path = decode_env_path (0, (char *) value.addr);
       Vx_bitmap_file_path = nconc2 (Vx_bitmap_file_path,
-				    (list1 (build_string (BITMAPDIR))));
+				    (decode_path (BITMAPDIR)));
     }
 
   {
@@ -440,6 +614,7 @@
   }
 }
 
+#if 0
 static void
 write_lisp_string_to_temp_file (Lisp_Object string, char *filename_out)
 {
@@ -448,7 +623,7 @@
   char tempbuf[1024]; /* some random amount */
   int fubar = 0;
   FILE *tmpfil;
-  static Extbyte_dynarr *conversion_out_dynarr = NULL;
+  static Extbyte_dynarr *conversion_out_dynarr;
   Bytecount bstart, bend;
   struct gcpro gcpro1, gcpro2;
 #ifdef FILE_CODING
@@ -539,6 +714,7 @@
     report_file_error ("Writing temp file",
 		       list1 (build_string (filename_out)));
 }
+#endif
 
 
 /************************************************************************/
@@ -1803,14 +1979,18 @@
   FILE *instream;
   /* Object that holds state info for JPEG decoding */
   struct jpeg_decompress_struct *cinfo_ptr;
+  /* EImage data */
+  unsigned char *eimage;
   /* Pixels to keep around while the image is active */
   unsigned long *pixels;
-  int npixels;
+  int npixels, pixcount;
   /* Client-side image structure */
   XImage *ximage;
   /* Tempfile to remove */
+#ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES
   char tempfile[50];
   int tempfile_needs_to_be_removed;
+#endif
 };
 
 static Lisp_Object
@@ -1826,14 +2006,12 @@
   if (data->instream)
     fclose (data->instream);
 
-  if (data->tempfile_needs_to_be_removed)
-    unlink (data->tempfile);
+  if (data->eimage) xfree (data->eimage);
 
   if (data->npixels > 0)
-    {
       XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
+  if (data->pixcount)
       xfree (data->pixels);
-    }
 
   if (data->ximage)
     {
@@ -1844,6 +2022,10 @@
         }
       XDestroyImage (data->ximage);
     }
+#if USE_TEMP_FILES_FOR_JPEG_IMAGES
+  if (data->tempfile_needs_to_be_removed)
+    unlink (data->tempfile);
+#endif
 
   return Qnil;
 }
@@ -1982,7 +2164,6 @@
   struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
   Display *dpy;
-  Screen *scr;
   Colormap cmap;
   Visual *vis;
   /* It is OK for the unwind data to be local to this function,
@@ -2005,7 +2186,6 @@
     signal_simple_error ("Not an X device", device);
 
   dpy = DEVICE_X_DISPLAY (XDEVICE (device));
-  scr = DefaultScreenOfDisplay (dpy);
   cmap = DEVICE_X_COLORMAP (XDEVICE(device));
   vis = DEVICE_X_VISUAL (XDEVICE(device));
 
@@ -2098,32 +2278,37 @@
    * See libjpeg.doc for more info.
    */
 
+#if 0
   /* Step 4: set parameters for decompression.   */
 
-  /* We request that the JPEG file be automatically quantized into
-     8-bit color in case it's not already (many JPEGs are stored in
-     24-bit color).  "Two-pass quantize" means that the colormap
-     is determined on-the-fly for this particular image rather than
-     quantizing to a supplied colormap.  We can get away with this
-     because we then use allocate_nearest_color().
-
-     #### Note of course that this is not the most color-effective
-     way of doing things -- we could quantize an image that has
-     lots of very similar colors, and eat up the colormap with these
-     (useless to other images) colors.  Unfortunately I don't think
-     there's any "general" way of maximizing the overall image
-     quality of lots of images, given that we don't know the
-     colors of the images until we come across each one.  Best we
-     could do would be various sorts of heuristics, which I don't
-     feel like dealing with now.  A better scheme would be the
-     way things are done under MS Windows, where the colormap is
-     dynamically adjusted for various applications; but that kind
-     of thing would have to be provided by X, which it isn't. */
-
-  cinfo.quantize_colors = TRUE;
-  cinfo.two_pass_quantize = TRUE;
-  cinfo.colormap = NULL;
-
+  if (vis->class == PseudoColor)
+    {
+    
+      /* We request that the JPEG file be automatically quantized into
+	 8-bit color in case it's not already (many JPEGs are stored in
+	 24-bit color).  "Two-pass quantize" means that the colormap
+	 is determined on-the-fly for this particular image rather than
+	 quantizing to a supplied colormap.  We can get away with this
+	 because we then use allocate_nearest_color().
+
+	 #### Note of course that this is not the most color-effective
+	 way of doing things -- we could quantize an image that has
+	 lots of very similar colors, and eat up the colormap with these
+	 (useless to other images) colors.  Unfortunately I don't think
+	 there's any "general" way of maximizing the overall image
+	 quality of lots of images, given that we don't know the
+	 colors of the images until we come across each one.  Best we
+	 could do would be various sorts of heuristics, which I don't
+	 feel like dealing with now.  A better scheme would be the
+	 way things are done under MS Windows, where the colormap is
+	 dynamically adjusted for various applications; but that kind
+	 of thing would have to be provided by X, which it isn't. */
+      
+      cinfo.quantize_colors = TRUE;
+      cinfo.two_pass_quantize = TRUE;
+      cinfo.colormap = NULL;
+    }
+  
   /* Step 5: Start decompressor */
 
   jpeg_start_decompress (&cinfo);
@@ -2134,22 +2319,17 @@
   /* At this point we know the size of the image and the colormap. */
 
   /* Step 5.33: Allocate the colors */
-  {
+  if (vis->class == PseudoColor) {
     int i;
-
-    /* Just in case the image contains out-of-range pixels, we go
-       ahead and allocate space for all of them. */
-    unwind.pixels = xnew_array (unsigned long, 256);
-    unwind.npixels = cinfo.actual_number_of_colors;
-
-    for (i = 0; i < 256; i++)
-      unwind.pixels[i] = 0;   /* Use a reasonable color for out of range. */
+    unwind.pixcount = 32;
+    unwind.pixels = xnew_array (unsigned long, unwind.pixcount);
+    unwind.npixels = 0;
 
     /* Allocate pixels for the various colors. */
-    for (i = 0; i < unwind.npixels; i++)
+    for (i = 0; i < cinfo.actual_number_of_colors; i++)
       {
 	XColor color;
-	int ri, gi, bi;
+	int ri, gi, bi, res;
 
 	ri = 0;
 	gi = cinfo.out_color_components > 1 ? 1 : 0;
@@ -2163,8 +2343,13 @@
 	color.blue = cinfo.colormap[bi] ? cinfo.colormap[bi][i] << 8 : 0;
 	color.flags = DoRed | DoGreen | DoBlue;
 
-	allocate_nearest_color (dpy, cmap, vis, &color);
-	unwind.pixels[i] = color.pixel;
+	res = allocate_nearest_color (dpy, cmap, vis, &color);
+	if (res > 0 && res < 3)
+	  {
+	    DO_REALLOC(unwind.pixels, unwind.pixcount, unwind.npixels+1, unsigned long);
+	    unwind.pixels[unwind.npixels] = color.pixel;
+	    unwind.npixels++;
+	  }
       }
   }
 
@@ -2182,8 +2367,7 @@
 		  (depth >  8) ? 16 :
 		  8);
 
-    unwind.ximage = XCreateImage (dpy, DefaultVisualOfScreen (scr),
-				  depth, ZPixmap, 0, 0, width, height,
+    unwind.ximage = XCreateImage (dpy, vis, depth, ZPixmap, 0, 0, width, height,
 				  bitmap_pad, 0);
 
     if (!unwind.ximage)
@@ -2241,7 +2425,72 @@
 		     unwind.pixels[(unsigned char) row_buffer[0][i]]);
       }
   }
-
+#else
+  {
+    /* Step 4: set parameters for decompression.   */
+
+    /* Now that we're using EImages, use the default of all data in 24bit color.
+       The backend routine will take care of any necessary reductions. */
+
+    /* Step 5: Start decompressor */
+    jpeg_start_decompress (&cinfo);
+
+    /* Step 6: Read in the data and put into EImage format (8bit RGB triples)*/
+
+    unwind.eimage = (unsigned char*) xmalloc (cinfo.output_width * cinfo.output_height * 3);
+    if (!unwind.eimage)
+      signal_simple_error("Unable to allocate enough memory for image", instantiator);
+
+    {
+      JSAMPARRAY row_buffer;	/* Output row buffer */
+      JSAMPLE *jp;
+      int row_stride;		/* physical row width in output buffer */
+      unsigned char *op = unwind.eimage;
+
+      /* We may need to do some setup of our own at this point before reading
+       * the data.  After jpeg_start_decompress() we have the correct scaled
+       * output image dimensions available
+       * We need to make an output work buffer of the right size.
+       */
+      /* JSAMPLEs per row in output buffer. */
+      row_stride = cinfo.output_width * cinfo.output_components;
+      /* Make a one-row-high sample array that will go away when done
+	 with image */
+      row_buffer = ((*cinfo.mem->alloc_sarray)
+		    ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1));
+
+      /* Here we use the library's state variable cinfo.output_scanline as the
+       * loop counter, so that we don't have to keep track ourselves.
+       */
+      while (cinfo.output_scanline < cinfo.output_height)
+	{
+	  int i;
+
+	  /* jpeg_read_scanlines expects an array of pointers to scanlines.
+	   * Here the array is only one element long, but you could ask for
+	   * more than one scanline at a time if that's more convenient.
+	   */
+	  (void) jpeg_read_scanlines (&cinfo, row_buffer, 1);
+	  jp = row_buffer[0];
+	  for (i = 0; i < cinfo.output_width; i++) {
+	    int clr;
+#if (BITS_IN_JSAMPLE == 8)
+	    for (clr = 0; clr < 3; clr++)
+	      *op++ = (unsigned char)*jp++;
+#else /* other option is 12 */
+	    for (clr = 0; clr < 3; clr++)
+	      *op++ = (unsigned char)(*jp++ >> 4);
+#endif
+	  }
+	}
+      unwind.ximage = EImage2XImage (device, cinfo.output_width, cinfo.output_height, unwind.eimage,
+				     &unwind.pixels, &unwind.pixcount, &unwind.npixels);
+      if (!unwind.ximage)
+	signal_simple_error("JPEG conversion failed", instantiator);
+    }
+  }
+  
+#endif
   /* Step 6.5: Create the pixmap and set up the image instance */
   init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
 				    unwind.pixels, unwind.npixels,
@@ -2260,6 +2509,7 @@
      freed right now.  They're kept around in the image instance
      structure until it's destroyed. */
   unwind.npixels = 0;
+  unwind.pixcount = 0;
 
   /* This will clean up everything else. */
   unbind_to (speccount, Qnil);
@@ -2268,12 +2518,12 @@
 #endif /* HAVE_JPEG */
 
 #ifdef HAVE_GIF
-
+/* #define USE_TEMP_FILES_FOR_GIF_IMAGES */
 /**********************************************************************
  *                               GIF                                  *
  **********************************************************************/
 
-#include "gif_lib.h" /* This is in our own source tree */
+#include <gif_lib.h>
 
 static void
 gif_validate (Lisp_Object instantiator)
@@ -2301,16 +2551,19 @@
 {
   Display *dpy;
   Colormap cmap;
+  unsigned char *eimage;
   /* Object that holds the decoded data from a GIF file */
   GifFileType *giffile;
   /* Pixels to keep around while the image is active */
   unsigned long *pixels;
-  int npixels;
+  int npixels, pixcount;
   /* Client-side image structure */
   XImage *ximage;
+#ifdef USE_TEMP_FILES_FOR_GIF_IMAGES
   /* Tempfile to remove */
   char tempfile[50];
   int tempfile_needs_to_be_removed;
+#endif
 };
 
 static Lisp_Object
@@ -2321,14 +2574,19 @@
 
   free_opaque_ptr (unwind_obj);
   if (data->giffile)
-    DGifCloseFile (data->giffile);
+    {
+      DGifCloseFile (data->giffile);
+      GifFree(data->giffile);
+    }
+  if (data->eimage) xfree(data->eimage);
+#ifdef USE_TEMP_FILES_FOR_GIF_IMAGES
   if (data->tempfile_needs_to_be_removed)
     unlink (data->tempfile);
+#endif
   if (data->npixels > 0)
-    {
-      XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
-      xfree (data->pixels);
-    }
+    XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
+  if (data->pixcount > 0)
+    xfree (data->pixels);
   if (data->ximage)
     {
       if (data->ximage->data)
@@ -2342,6 +2600,46 @@
   return Qnil;
 }
 
+#ifndef USE_TEMP_FILES_FOR_GIF_IMAGES
+typedef struct gif_memory_storage
+{
+  Extbyte *bytes;		/* The data       */
+  Extcount len;			/* How big is it? */
+  int index;			/* Where are we?  */
+} gif_memory_storage;
+
+static size_t gif_read_from_memory(GifByteType *buf, size_t size, VoidPtr data)
+{
+  gif_memory_storage *mem = (gif_memory_storage*)data;
+
+  if (size > (mem->len - mem->index))
+    return -1;
+  memcpy(buf, mem->bytes + mem->index, size);
+  mem->index = mem->index + size;
+  return size;
+}
+
+static int gif_memory_close(VoidPtr data)
+{
+  return 0;
+}
+
+#endif
+struct gif_error_struct
+{
+  char *err_str;		/* return the error string */
+  jmp_buf setjmp_buffer;	/* for return to caller */
+};
+
+static void gif_error_func(CONST char *err_str, VoidPtr error_ptr)
+{
+  struct gif_error_struct *error_data = (struct gif_error_struct*)error_ptr;
+
+  /* return to setjmp point */
+  error_data->err_str = err_str;
+  longjmp (error_data->setjmp_buffer, 1);
+}
+
 static void
 gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
 		 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
@@ -2350,7 +2648,6 @@
   struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
   Display *dpy;
-  Screen *scr;
   Colormap cmap;
   Visual *vis;
   /* It is OK for the unwind data to be local to this function,
@@ -2358,12 +2655,16 @@
      stack frame is still valid. */
   struct gif_unwind_data unwind;
   int speccount = specpdl_depth ();
-
+#ifndef USE_TEMP_FILES_FOR_GIF_IMAGES
+  gif_memory_storage mem_struct;
+  struct gif_error_struct gif_err;
+  Extbyte *bytes;
+  Extcount len;
+#endif
   if (!DEVICE_X_P (XDEVICE (device)))
     signal_simple_error ("Not an X device", device);
 
   dpy = DEVICE_X_DISPLAY (XDEVICE (device));
-  scr = DefaultScreenOfDisplay (dpy);
   cmap = DEVICE_X_COLORMAP (XDEVICE(device));
   vis = DEVICE_X_VISUAL (XDEVICE(device));
 
@@ -2374,34 +2675,45 @@
 
   /* 1. Now decode the data. */
 
-  /* #### The GIF routines currently require that you read from a file,
-     so write out to a temp file.  We should change this. */
   {
     Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
 
     assert (!NILP (data));
 
+    if (!(unwind.giffile = GifSetup()))
+      signal_simple_error ("Insufficent memory to instantiate GIF image", instantiator);
+
+    /* set up error facilities */
+    if (setjmp(gif_err.setjmp_buffer)) {
+      /* An error was signaled. No clean up is needed, as unwind handles that
+	 for us.  Just pass the error along. */
+      Lisp_Object errstring;
+      errstring = build_string (gif_err.err_str);
+      signal_simple_error_2 ("GIF decoding error", errstring, instantiator);
+    }
+    GifSetErrorFunc(unwind.giffile, (Gif_error_func)gif_error_func, (VoidPtr)&gif_err);
+    
+#ifdef USE_TEMP_FILES_FOR_GIF_IMAGES
     write_lisp_string_to_temp_file (data, unwind.tempfile);
     unwind.tempfile_needs_to_be_removed = 1;
-
+    DGifOpenFileName (unwind.giffile, unwind.tempfile);
+#else
+    GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
+    mem_struct.bytes = bytes;
+    mem_struct.len = len;
+    mem_struct.index = 0;
+    GifSetReadFunc(unwind.giffile, gif_read_from_memory, (VoidPtr)&mem_struct);
+    GifSetCloseFunc(unwind.giffile, gif_memory_close, (VoidPtr)&mem_struct);
+    DGifInitRead(unwind.giffile);
+#endif
     /* Then slurp the image into memory, decoding along the way.
        The result is the image in a simple one-byte-per-pixel
        format (#### the GIF routines only support 8-bit GIFs,
        it appears). */
-    unwind.giffile = DGifOpenFileName (unwind.tempfile);
-    if (unwind.giffile == NULL)
-      {
-      gif_decode_error:
-	signal_simple_error ("Unable to decode GIF",
-			     build_string (EmacsPrintGifError ()));
-      }
-    /* DGifSlurp() doesn't handle interlaced files. */
-    /* Actually, it does, sort of.  It just sets the Interlace flag
-       and stores RasterBits in interlaced order.  We handle that below. */
-    if (DGifSlurp (unwind.giffile) != GIF_OK)
-      goto gif_decode_error;
+    DGifSlurp (unwind.giffile);
   }
 
+#if 0
   /* 2. Now allocate the colors for the image. */
   {
     int i;
@@ -2409,7 +2721,7 @@
     /* Just in case the image contains out-of-range pixels, we go
        ahead and allocate space for all of them. */
     unwind.pixels = xnew_array (unsigned long, 256);
-    unwind.npixels = cmo->ColorCount;
+    unwind.npixels = 0;
 
     for (i = 0; i < 256; i++)
       unwind.pixels[i] = 0;   /* Use a reasonable color for out of range. */
@@ -2417,6 +2729,7 @@
     /* Allocate pixels for the various colors. */
     for (i = 0; i < cmo->ColorCount; i++)
       {
+	int res;
 	XColor color;
 
 	color.red = cmo->Colors[i].Red << 8;
@@ -2424,8 +2737,12 @@
 	color.blue = cmo->Colors[i].Blue << 8;
 	color.flags = DoRed | DoGreen | DoBlue;
 
-	allocate_nearest_color (dpy, cmap, vis, &color);
-	unwind.pixels[i] = color.pixel;
+	res = allocate_nearest_color (dpy, cmap, vis, &color);
+	if (res > 0 && res < 3)
+	  {
+	    unwind.pixels[unwind.npixels] = color.pixel;
+	    unwind.npixels++;
+	  }
       }
   }
 
@@ -2499,7 +2816,59 @@
 	row += interlace ? InterlacedJumps[pass] : 1;
       }
   }
-
+#else
+  /* 3. Now create the EImage */
+  {
+    ColorMapObject *cmo = unwind.giffile->SColorMap;
+    int height = unwind.giffile->SHeight;
+    int width = unwind.giffile->SWidth;
+    int i, j, row, pass, interlace;
+    unsigned char *eip;
+    /* interlaced gifs have rows in this order:
+       0, 8, 16, ..., 4, 12, 20, ..., 2, 6, 10, ..., 1, 3, 5, ...  */
+    static int InterlacedOffset[] = { 0, 4, 2, 1 };
+    static int InterlacedJumps[] = { 8, 8, 4, 2 };
+
+    unwind.eimage = (unsigned char*) xmalloc (width * height * 3);
+    if (!unwind.eimage)
+      signal_simple_error("Unable to allocate enough memory for image", instantiator);
+
+    /* write the data in EImage format (8bit RGB triples) */
+
+    /* Note: We just use the first image in the file and ignore the rest.
+             We check here that that image covers the full "screen" size.
+	     I don't know whether that's always the case.
+             -dkindred@cs.cmu.edu  */
+    if (unwind.giffile->SavedImages[0].ImageDesc.Height != height
+	|| unwind.giffile->SavedImages[0].ImageDesc.Width != width
+	|| unwind.giffile->SavedImages[0].ImageDesc.Left != 0
+	|| unwind.giffile->SavedImages[0].ImageDesc.Top != 0)
+      signal_simple_error ("First image in GIF file is not full size",
+			   instantiator);
+
+    interlace = unwind.giffile->SavedImages[0].ImageDesc.Interlace;
+    pass = 0;
+    row = interlace ? InterlacedOffset[pass] : 0;
+    eip = unwind.eimage;
+    for (i = 0; i < height; i++)
+      {
+	if (interlace && row >= height)
+	  row = InterlacedOffset[++pass];
+	eip = unwind.eimage + (row * width * 3);
+	for (j = 0; j < width; j++) {
+	  unsigned char pixel = unwind.giffile->SavedImages[0].RasterBits[(i * width) + j];
+	  *eip++ = cmo->Colors[pixel].Red;
+	  *eip++ = cmo->Colors[pixel].Green;
+	  *eip++ = cmo->Colors[pixel].Blue;
+	}
+	row += interlace ? InterlacedJumps[pass] : 1;
+      }
+    unwind.ximage = EImage2XImage (device, width, height, unwind.eimage,
+				   &unwind.pixels, &unwind.pixcount, &unwind.npixels);
+    if (!unwind.ximage)
+      signal_simple_error("GIF conversion failed", instantiator);
+  }
+#endif
   /* 4. Now create the pixmap and set up the image instance */
   init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
 				    unwind.pixels, unwind.npixels,
@@ -2508,6 +2877,7 @@
      freed right now.  They're kept around in the image instance
      structure until it's destroyed. */
   unwind.npixels = 0;
+  unwind.pixcount = 0;
   unbind_to (speccount, Qnil);
 }
 
@@ -2538,7 +2908,7 @@
   return IMAGE_COLOR_PIXMAP_MASK;
 }
 
-#if !defined (USE_TEMP_FILES_FOR_PNG_IMAGES) && (PNG_LIBPNG_VER >= 87)
+#ifndef USE_TEMP_FILES_FOR_PNG_IMAGES
 struct png_memory_storage
 {
   Extbyte *bytes;		/* The data       */
@@ -2547,7 +2917,7 @@
 };
 
 static void png_read_from_memory(png_structp png_ptr, png_bytep data,
-				 png_uint_32 length)
+				 png_size_t length)
 {
    struct png_memory_storage *tbr =
      (struct png_memory_storage *) png_get_io_ptr (png_ptr);
@@ -2557,20 +2927,48 @@
    memcpy(data,tbr->bytes + tbr->index,length);
    tbr->index = tbr->index + length;
 }
-#endif /* !USE_TEMP_FILES_FOR_PNG_IMAGESS || PNG_LIBPNG_VER >= 87 */
+#endif /* !USE_TEMP_FILES_FOR_PNG_IMAGES */
+
+struct png_error_struct
+{
+  CONST char *err_str;
+  jmp_buf setjmp_buffer;	/* for return to caller */
+};
+
+/* jh 98/03/12 - #### AARRRGH! libpng includes jmp_buf inside its own
+   structure, and there are cases where the size can be different from
+   between inside the libarary, and inside the code!  To do an end run
+   around this, use our own error functions, and don't rely on things
+   passed in the png_ptr to them.  This is an ugly hack and must
+   go away when the lisp engine is threaded! */
+static struct png_error_struct png_err_stct;
+
+static void png_error_func(png_structp png_ptr, png_const_charp message)
+{
+  png_err_stct.err_str = message;
+  longjmp (png_err_stct.setjmp_buffer, 1);
+}
+
+static void png_warning_func(png_structp png_ptr, png_const_charp message)
+{
+  warn_when_safe (Qpng, Qinfo, "%s", message);
+}
 
 struct png_unwind_data
 {
   Display *dpy;
   Colormap cmap;
   FILE *instream;
-  png_struct *png_ptr;
-  png_info *info_ptr;
+  unsigned char *eimage;
+  png_structp png_ptr;
+  png_infop info_ptr;
   unsigned long *pixels;
-  int npixels;
+  int npixels, pixcount;
   XImage *ximage;
+#ifdef USE_TEMP_FILES_FOR_PNG_IMAGESS
   char tempfile[50];
   int tempfile_needs_to_be_removed;
+#endif
 };
 
 static Lisp_Object
@@ -2581,17 +2979,16 @@
 
   free_opaque_ptr (unwind_obj);
   if (data->png_ptr)
-    png_read_destroy (data->png_ptr, data->info_ptr, (png_info *) NULL);
+    png_destroy_read_struct (&(data->png_ptr), &(data->info_ptr), (png_infopp)NULL);
   if (data->instream)
     fclose (data->instream);
-  if (data->tempfile_needs_to_be_removed)
-    unlink (data->tempfile);
   if (data->npixels > 0)
-    {
-      XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
-      xfree (data->pixels);
-    }
-
+    XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
+  if (data->pixcount > 0)
+    xfree (data->pixels);
+
+  if (data->eimage)
+    xfree (data->eimage);
   if (data->ximage)
     {
       if (data->ximage->data)
@@ -2601,27 +2998,13 @@
 	}
       XDestroyImage (data->ximage);
     }
-
+#ifdef USE_TEMP_FILES_FOR_PNG_IMAGES
+  if (data->tempfile_needs_to_be_removed)
+    unlink (data->tempfile);
+#endif
   return Qnil;
 }
 
-/* This doesn't appear to be used. */
-#if 0
-#define get_png_val(p) _get_png_val (&(p), info_ptr.bit_depth)
-png_uint_16
-_get_png_val (png_byte **pp, int bit_depth)
-{
-  png_uint_16 c = 0;
-
-  if (bit_depth == 16) {
-    c = (*((*pp)++)) << 8;
-  }
-  c |= (*((*pp)++));
-
-  return c;
-}
-#endif
-
 static void
 png_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
 		 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
@@ -2636,8 +3019,8 @@
   int speccount = specpdl_depth ();
 
   /* PNG variables */
-  png_struct *png_ptr;
-  png_info *info_ptr;
+  png_structp png_ptr;
+  png_infop info_ptr;
 
   if (!DEVICE_X_P (XDEVICE (device)))
     signal_simple_error ("Not an X device", device);
@@ -2646,9 +3029,18 @@
   cmap = DEVICE_X_COLORMAP (XDEVICE(device));
   vis = DEVICE_X_VISUAL (XDEVICE(device));
 
-  png_ptr  = xnew (png_struct);
-  info_ptr = xnew (png_info);
-
+  /* Initialize all PNG structures */
+  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (void*)&png_err_stct,
+				   png_error_func, png_warning_func);
+  if (!png_ptr)
+    signal_simple_error("Error obtaining memory for png_read", instantiator);
+  info_ptr = png_create_info_struct(png_ptr);
+  if (!info_ptr)
+    {
+      png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+      signal_simple_error("Error obtaining memory for png_read", instantiator);
+    }
+  
   memset (&unwind, 0, sizeof (unwind));
   unwind.png_ptr = png_ptr;
   unwind.info_ptr = info_ptr;
@@ -2661,45 +3053,21 @@
      this file, example.c from the libpng 0.81 distribution, and the
      pngtopnm sources. -WMP-
      */
-#if defined (USE_TEMP_FILES_FOR_PNG_IMAGES) || (PNG_LIBPNG_VER < 87)
-  /* Write out to a temp file - we really should take the time to
-     write appropriate memory bound IO stuff, but I am just trying
-     to get the stupid thing working right now.
-     */
-  {
-    Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
-
-    assert (!NILP (data));
-
-    write_lisp_string_to_temp_file (data, unwind.tempfile);
-    unwind.tempfile_needs_to_be_removed = 1;
-
-    if ((unwind.instream = fopen (unwind.tempfile, "rb")) == NULL)
-      report_file_error ("Opening PNG temp file",
-			 list1 (build_string (unwind.tempfile)));
-  }
-#else
-  /* Nothing */
-#endif
+  /* It has been further modified to handle the API changes for 0.96,
+     and is no longer usable for previous versions. jh
+  */
 
   /* Set the jmp_buf reurn context for png_error ... if this returns !0, then
      we ran into a problem somewhere, and need to clean up after ourselves. */
-  if (setjmp (png_ptr->jmpbuf))
+  if (setjmp (png_err_stct.setjmp_buffer))
     {
-      /* Am I doing enough here?  I think so, since most things happen
-         in png_unwind */
-      png_read_destroy (png_ptr, info_ptr, (png_info *) NULL);
-      signal_simple_error ("Error decoding PNG", instantiator);
+      /* Something blew up: just display the error (cleanup happens in the unwind) */
+      signal_simple_error_2 ("Error decoding PNG",
+			     build_string(png_err_stct.err_str),
+			     instantiator);
     }
 
-  /* Initialize all PNG structures */
-  png_info_init (info_ptr);
-  png_read_init (png_ptr);
-
   /* Initialize the IO layer and read in header information */
-#if defined (USE_TEMP_FILES_FOR_PNG_IMAGES) || (PNG_LIBPNG_VER < 87)
-  png_init_io (png_ptr, unwind.instream);
-#else
   {
     Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
     Extbyte *bytes;
@@ -2709,18 +3077,17 @@
     assert (!NILP (data));
 
     /* #### This is a definite problem under Mule due to the amount of
-       stack data it might allocate.  Need to be able to convert and
-       write out to a file. */
+       stack data it might allocate.  Need to think about using Lstreams */
     GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
     tbr.bytes = bytes;
     tbr.len = len;
     tbr.index = 0;
     png_set_read_fn(png_ptr,(void *) &tbr, png_read_from_memory);
   }
-#endif
 
   png_read_info (png_ptr, info_ptr);
 
+#if 0
   /* set up the transformations you want.  Note that these are
      all optional.  Only call them if you want them */
   /* tell libpng to strip 16 bit depth files down to 8 bits */
@@ -2743,12 +3110,11 @@
     png_color static_color_cube[216];
 
     /* Wow, allocate all the memory.  Truly, exciting. */
-    unwind.pixels = xnew_array (unsigned long, 256);
+    unwind.pixcount = 32;
+    unwind.pixels = xnew_array (unsigned long, unwind.pixcount);
     png_pixels    = xnew_array (png_byte, linesize * height);
     row_pointers  = xnew_array (png_byte *, height);
 
-    for (y = 0; y < 256; y++)
-      unwind.pixels[y] = 0;
     for (y = 0; y < height; y++)
       row_pointers[y] = png_pixels + (linesize * y);
 
@@ -2770,8 +3136,9 @@
     }
 #endif
 
-    if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
-	(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA))
+    if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
+	 (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
+	(vis->class == PseudoColor))
       {
 	if (!(info_ptr->valid & PNG_INFO_PLTE))
 	  {
@@ -2796,28 +3163,39 @@
     /* Ok, now we go and allocate all the colors */
     if (info_ptr->valid & PNG_INFO_PLTE)
       {
-	unwind.npixels = info_ptr->num_palette;
-	for (y = 0; y < unwind.npixels; y++)
+	unwind.npixels = 0;
+	for (y = 0; y < info_ptr->num_palette; y++)
 	  {
+	    int res;
 	    color.red = info_ptr->palette[y].red << 8;
 	    color.green = info_ptr->palette[y].green << 8;
 	    color.blue = info_ptr->palette[y].blue << 8;
 	    color.flags = DoRed | DoGreen | DoBlue;
-	    allocate_nearest_color (dpy, cmap, vis, &color);
-	    unwind.pixels[y] = color.pixel;
+	    res = allocate_nearest_color (dpy, cmap, vis, &color);
+	    if (res > 0 && res < 3)
+	      {
+		DO_REALLOC(unwind.pixels, unwind.pixcount, unwind.npixels+1, unsigned long);
+		unwind.pixels[unwind.npixels] = color.pixel;
+		unwind.npixels++;
+	      }
 	  }
       }
     else
       {
-	unwind.npixels = 216;
+	unwind.npixels = 0;
 	for (y = 0; y < 216; y++)
 	  {
+	    int res;
 	    color.red = static_color_cube[y].red << 8;
 	    color.green = static_color_cube[y].green << 8;
 	    color.blue = static_color_cube[y].blue << 8;
 	    color.flags = DoRed|DoGreen|DoBlue;
-	    allocate_nearest_color (dpy, cmap, vis, &color);
-	    unwind.pixels[y] = color.pixel;
+	    res = allocate_nearest_color (dpy, cmap, vis, &color);
+	    if (res > 0 && res < 3)
+	      {
+		unwind.pixels[unwind.npixels] = color.pixel;
+		unwind.npixels++;
+	      }
 	  }
       }
 
@@ -2877,6 +3255,105 @@
     xfree (row_pointers);
     xfree (png_pixels);
   }
+#else
+  {
+    int height = info_ptr->height;
+    int width = info_ptr->width;
+    int y;
+    unsigned char **row_pointers;
+
+    /* Wow, allocate all the memory.  Truly, exciting. */
+    unwind.eimage = xnew_array_and_zero (unsigned char, width * height * 3);
+    /* libpng expects that the image buffer passed in contains a
+       picture to draw on top of if the png has any transparencies.
+       This could be a good place to pass that in... */
+    
+    row_pointers  = xnew_array (png_byte *, height);
+
+    for (y = 0; y < height; y++)
+      row_pointers[y] = unwind.eimage + (width * 3 * y);
+
+    /* Now that we're using EImage, ask for 8bit RGB triples for any type
+       of image*/
+    /* convert palatte images to full RGB */
+    if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+      png_set_expand(png_ptr);
+    /* send grayscale images to RGB too */
+    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
+        info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+      png_set_gray_to_rgb(png_ptr);
+    /* we can't handle alpha values */
+    if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+      png_set_strip_alpha(png_ptr);
+    /* rip out any transparancy layers/colors */
+    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+        png_set_expand(png_ptr);
+	png_set_strip_alpha(png_ptr);
+    }
+    /* tell libpng to strip 16 bit depth files down to 8 bits */
+    if (info_ptr->bit_depth == 16)
+      png_set_strip_16 (png_ptr);
+    /* if the image is < 8 bits, pad it out */
+    if (info_ptr->bit_depth < 8) {
+      if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)
+	png_set_expand(png_ptr);
+      else
+	png_set_packing (png_ptr);
+    }
+
+#if 1 /* tests? or permanent? */
+    {
+      /* if the png specifies a background chunk, go ahead and
+	 use it */
+      png_color_16 my_background, *image_background;
+    
+      /* ### how do I get the background of the current frame? */
+      my_background.red = 0x7fff;
+      my_background.green = 0x7fff;
+      my_background.blue = 0x7fff;
+
+      if (png_get_bKGD(png_ptr, info_ptr, &image_background))
+	png_set_background(png_ptr, image_background,
+			   PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+      else 
+	png_set_background(png_ptr, &my_background,
+			   PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+    }
+#endif
+    png_read_image (png_ptr, row_pointers);
+    png_read_end (png_ptr, info_ptr);
+    
+#ifdef PNG_SHOW_COMMENTS
+    /* ####
+     * I turn this off by default now, because the !%^@#!% comments
+     * show up every time the image is instantiated, which can get
+     * really really annoying.  There should be some way to pass this
+     * type of data down into the glyph code, where you can get to it
+     * from lisp anyway. - WMP
+     */
+    {
+      int i;
+
+      for (i = 0 ; i < info_ptr->num_text ; i++)
+	{
+	  /* How paranoid do I have to be about no trailing NULLs, and
+	     using (int)info_ptr->text[i].text_length, and strncpy and a temp
+	     string somewhere? */
+
+	  warn_when_safe (Qpng, Qinfo, "%s - %s",
+			  info_ptr->text[i].key,
+			  info_ptr->text[i].text);
+	}
+    }
+#endif
+
+    xfree (row_pointers);
+    unwind.ximage = EImage2XImage (device, width, height, unwind.eimage,
+				   &unwind.pixels, &unwind.pixcount, &unwind.npixels);
+    if (!unwind.ximage)
+      signal_simple_error("PNG conversion failed", instantiator);
+  }
+#endif
 
   init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
 				    unwind.pixels, unwind.npixels,
@@ -2884,6 +3361,7 @@
 
   /* This will clean up everything else. */
   unwind.npixels = 0;
+  unwind.pixcount = 0;
   unbind_to (speccount, Qnil);
 }
 
@@ -2891,6 +3369,7 @@
 
 
 #ifdef HAVE_TIFF
+#include "tiffio.h"
 
 /**********************************************************************
  *                             TIFF                                   *
@@ -2904,8 +3383,7 @@
 static Lisp_Object
 tiff_normalize (Lisp_Object inst, Lisp_Object console_type)
 {
-  signal_simple_error ("No TIFF support yet", inst);
-  return Qnil;
+  return simple_image_type_normalize (inst, console_type, Qtiff);
 }
 
 static int
@@ -2914,12 +3392,280 @@
   return IMAGE_COLOR_PIXMAP_MASK;
 }
 
+struct tiff_unwind_data
+{
+  Display *dpy;
+  Colormap cmap;
+  unsigned char *eimage;
+  /* Object that holds the decoded data from a TIFF file */
+  TIFF *tiff;
+  /* Pixels to keep around while the image is active */
+  unsigned long *pixels;
+  int npixels,pixcount;
+  /* Client-side image structure */
+  XImage *ximage;
+};
+
+static Lisp_Object
+tiff_instantiate_unwind (Lisp_Object unwind_obj)
+{
+  struct tiff_unwind_data *data =
+    (struct tiff_unwind_data *) get_opaque_ptr (unwind_obj);
+
+  free_opaque_ptr (unwind_obj);
+  if (data->tiff)
+    {
+      TIFFClose(data->tiff);
+    }
+  if (data->eimage)
+    xfree(data->eimage);
+  if (data->npixels > 0)
+    XFreeColors (data->dpy, data->cmap, data->pixels, data->npixels, 0L);
+  if (data->pixcount)
+    xfree (data->pixels);
+  if (data->ximage)
+    {
+      if (data->ximage->data)
+        {
+	  xfree (data->ximage->data);
+          data->ximage->data = 0;
+        }
+      XDestroyImage (data->ximage);
+    }
+
+  return Qnil;
+}
+
+typedef struct tiff_memory_storage
+{
+  Extbyte *bytes;		/* The data       */
+  Extcount len;			/* How big is it? */
+  int index;			/* Where are we?  */
+} tiff_memory_storage;
+
+static size_t tiff_memory_read(thandle_t data, tdata_t buf, tsize_t size)
+{
+  tiff_memory_storage *mem = (tiff_memory_storage*)data;
+
+  if (size > (mem->len - mem->index))
+    return -1;
+  memcpy(buf, mem->bytes + mem->index, size);
+  mem->index = mem->index + size;
+  return size;
+}
+
+static size_t tiff_memory_write(thandle_t data, tdata_t buf, tsize_t size)
+{
+  abort();
+}
+
+static toff_t tiff_memory_seek(thandle_t data, toff_t off, int whence)
+{
+  tiff_memory_storage *mem = (tiff_memory_storage*)data;
+  int newidx;
+  switch(whence) {
+  case SEEK_SET:
+    newidx = off;
+    break;
+  case SEEK_END:
+    newidx = mem->len + off;
+    break;
+  case SEEK_CUR:
+    newidx = mem->index + off;
+    break;
+  default:
+    fprintf(stderr,"Eh? invalid seek mode in tiff_memory_seek\n");
+    return -1;
+  }
+
+  if ((newidx > mem->len) || (newidx < 0))
+    return -1;
+  
+  mem->index = newidx;
+  return newidx;
+}
+
+static int tiff_memory_close(thandle_t data)
+{
+  return 0;
+}
+
+static int tiff_map_noop(thandle_t data, tdata_t* pbase, toff_t* psize)
+{
+  return 0;
+}
+
+static void tiff_unmap_noop(thandle_t data, tdata_t pbase, toff_t psize)
+{
+  return;
+}
+
+static toff_t tiff_memory_size(thandle_t data)
+{
+  tiff_memory_storage *mem = (tiff_memory_storage*)data;
+  return mem->len;
+}
+
+struct tiff_error_struct
+{
+#if HAVE_VSNPRINTF
+  char err_str[256];
+#else
+  char err_str[1024];		/* return the error string */
+#endif
+  jmp_buf setjmp_buffer;	/* for return to caller */
+};
+
+/* jh 98/03/12 - ###This struct for passing data to the error functions
+   is an ugly hack caused by the fact that libtiff (as of v3.4) doesn't
+   have any place to store error func data.  This should be rectified
+   before XEmacs gets threads! */
+static struct tiff_error_struct tiff_err_data;
+
+static void tiff_error_func(CONST char *module, CONST char *fmt, ...)
+{
+  va_list vargs;
+
+  va_start (vargs, fmt);
+#if HAVE_VSNPRINTF
+  vsnprintf(tiff_err_data.err_str, 255, fmt, vargs);
+#else
+  /* pray this doesn't overflow... */
+  vsprintf(tiff_err_data.err_str, fmt, vargs);
+#endif
+  va_end(vargs);
+  /* return to setjmp point */
+  longjmp (tiff_err_data.setjmp_buffer, 1);
+}
+
+static void tiff_warning_func(CONST char *module, CONST char *fmt, ...)
+{
+  va_list vargs;
+#if HAVE_VSNPRINTF
+  char warn_str[256];
+#else
+  char warn_str[1024];
+#endif
+
+  va_start (vargs, fmt);
+#if HAVE_VSNPRINTF
+  vsnprintf(warn_str, 255, fmt, vargs);
+#else
+  vsprintf(warn_str, fmt, vargs);
+#endif
+  va_end(vargs);
+  warn_when_safe (Qtiff, Qinfo, "%s - %s",
+		  module, warn_str);
+}
+
 static void
 tiff_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
 		  Lisp_Object pointer_fg, Lisp_Object pointer_bg,
 		  int dest_mask, Lisp_Object domain)
 {
-  abort ();
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
+  Colormap cmap;
+  Display *dpy;
+  tiff_memory_storage mem_struct;
+  /* It is OK for the unwind data to be local to this function,
+     because the unwind-protect is always executed when this
+     stack frame is still valid. */
+  struct tiff_unwind_data unwind;
+  int speccount = specpdl_depth ();
+
+  if (!DEVICE_X_P (XDEVICE (device)))
+    signal_simple_error ("Not an X device", device);
+
+  dpy = DEVICE_X_DISPLAY (XDEVICE (device));
+  cmap = DEVICE_X_COLORMAP (XDEVICE(device));
+
+  memset (&unwind, 0, sizeof (unwind));
+  unwind.dpy = dpy;
+  unwind.cmap = cmap;
+  record_unwind_protect (tiff_instantiate_unwind, make_opaque_ptr (&unwind));
+  
+  /* set up error facilities */
+  if (setjmp(tiff_err_data.setjmp_buffer)) {
+    /* An error was signaled. No clean up is needed, as unwind handles that
+       for us.  Just pass the error along. */
+    Lisp_Object errstring;
+    errstring = build_string (tiff_err_data.err_str);
+    signal_simple_error_2 ("TIFF decoding error", errstring, instantiator);
+  }
+  TIFFSetErrorHandler((TIFFErrorHandler)tiff_error_func);
+  TIFFSetWarningHandler((TIFFErrorHandler)tiff_warning_func);
+  {
+    Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
+    Extbyte *bytes;
+    Extcount len;
+
+    uint32 width, height;
+    uint32 *raster;
+    unsigned char *ep;
+
+    assert (!NILP (data));
+
+    /* #### This is a definite problem under Mule due to the amount of
+       stack data it might allocate.  Think about Lstreams... */
+    GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
+    mem_struct.bytes = bytes;
+    mem_struct.len = len;
+    mem_struct.index = 0;
+
+    unwind.tiff = TIFFClientOpen("memfile", "r", &mem_struct,
+				 (TIFFReadWriteProc)tiff_memory_read,
+				 (TIFFReadWriteProc)tiff_memory_write,
+				 tiff_memory_seek, tiff_memory_close, tiff_memory_size,
+				 tiff_map_noop, tiff_unmap_noop);
+    if (!unwind.tiff)
+      signal_simple_error ("Insufficent memory to instantiate TIFF image", instantiator);
+
+    TIFFGetField(unwind.tiff, TIFFTAG_IMAGEWIDTH, &width);
+    TIFFGetField(unwind.tiff, TIFFTAG_IMAGELENGTH, &height);
+    unwind.eimage = xmalloc(width * height * 3);
+
+    /* ### This is little more than proof-of-concept/function testing.
+       It needs to be reimplimented via scanline reads for both memory
+       compactness. */
+    raster = (uint32*) _TIFFmalloc(width * height * sizeof (uint32));
+    if (raster != NULL) {
+  int i,j;
+      uint32 *rp;
+      ep = unwind.eimage;
+      rp = raster;
+      if (TIFFReadRGBAImage(unwind.tiff, width, height, raster, 0)) {
+	for (i = height - 1;  i >= 0; i--) {
+	  /* This is to get around weirdness in the libtiff library where properly
+	     made TIFFs will come out upside down.  libtiff bug or jhod-brainlock? */
+	  rp = raster + (i * width);
+	  for (j = 0; j < width; j++) {
+	    *ep++ = (unsigned char)TIFFGetR(*rp);
+	    *ep++ = (unsigned char)TIFFGetG(*rp);
+	    *ep++ = (unsigned char)TIFFGetB(*rp);
+	    rp++;
+	  }
+	}
+      }
+      _TIFFfree(raster);
+    } else
+      signal_simple_error ("Unable to allocate memory for TIFFReadRGBA", instantiator);
+
+    unwind.ximage = EImage2XImage (device, width, height, unwind.eimage,
+				   &unwind.pixels, &unwind.pixcount, &unwind.npixels);
+    if (!unwind.ximage)
+      signal_simple_error("TIFF conversion failed", instantiator);    
+  }
+  /* Now create the pixmap and set up the image instance */
+  init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
+				    unwind.pixels, unwind.npixels,
+				    instantiator);
+  /* Now that we've succeeded, we don't want the pixels
+     freed right now.  They're kept around in the image instance
+     structure until it's destroyed. */
+  unwind.npixels = 0;
+  unwind.pixcount = 0;
+  unbind_to (speccount, Qnil);
 }
 
 #endif /* HAVE_TIFF */
--- a/src/glyphs.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/glyphs.h	Mon Aug 13 10:25:37 2007 +0200
@@ -342,6 +342,8 @@
       Lisp_Object fg, bg; /* foreground and background colors,
 			     if this is a colorized mono-pixmap
 			     or a pointer */
+      Lisp_Object auxdata;    /* list or Qnil: any additional data
+				 to be seen from lisp */
     } pixmap; /* used for pointers as well */
     struct
     {
@@ -371,6 +373,7 @@
 #define IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y(i) ((i)->u.pixmap.hotspot_y)
 #define IMAGE_INSTANCE_PIXMAP_FG(i) ((i)->u.pixmap.fg)
 #define IMAGE_INSTANCE_PIXMAP_BG(i) ((i)->u.pixmap.bg)
+#define IMAGE_INSTANCE_PIXMAP_AUXDATA(i) ((i)->u.pixmap.auxdata)
 
 #define XIMAGE_INSTANCE_DEVICE(i) \
   IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (i))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imgproc.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,526 @@
+/* Image processing functions
+   Copyright (C) 1998 Jareth Hein
+
+This file is a part of XEmacs
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Original author: Jareth Hein */
+
+/* Parts of this file are based on code from Sam Leffler's tiff library,
+   with the original copywrite displayed here:
+
+   Copyright (c) 1988-1997 Sam Leffler
+   Copyright (c) 1991-1997 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. */
+
+/* Quantizing code based off of the paper 
+   Color Image Quantization for Frame Buffer Display, Paul Heckbert,
+   Siggraph '82 proceedings, pp. 297-307 */
+
+#include "config.h"
+#include "lisp.h"
+#include "imgproc.h"
+
+static void get_histogram(quant_table *qt, unsigned char *pic,
+			  int width, int height, Colorbox* box)
+{
+  register unsigned char *inptr;
+  register int red, green, blue;
+  register unsigned int j, i;
+
+  box->rmin = box->gmin = box->bmin = 999;
+  box->rmax = box->gmax = box->bmax = -1;
+  box->total = width * height;
+
+  {
+ register int *ptr = &(qt->histogram[0][0][0]);
+  for (i = B_LEN*B_LEN*B_LEN; i-- > 0;)
+    *ptr++ = 0;
+  }
+  inptr = pic;
+  for (i = 0; i < height; i++) {
+    for (j = width; j-- > 0;) {
+      red = *inptr++ >> COLOR_SHIFT;
+      green = *inptr++ >> COLOR_SHIFT;
+      blue = *inptr++ >> COLOR_SHIFT;
+      if (red < box->rmin)
+	box->rmin = red;
+      if (red > box->rmax)
+	box->rmax = red;
+      if (green < box->gmin)
+	box->gmin = green;
+      if (green > box->gmax)
+	box->gmax = green;
+      if (blue < box->bmin)
+	box->bmin = blue;
+      if (blue > box->bmax)
+	box->bmax = blue;
+      qt->histogram[red][green][blue]++;
+    }
+  }
+}
+
+static Colorbox *
+largest_box(quant_table *qt)
+{
+  register Colorbox *p, *b;
+  register int size;
+
+  b = NULL;
+  size = -1;
+  for (p = qt->usedboxes; p != NULL; p = p->next)
+    if ((p->rmax > p->rmin || p->gmax > p->gmin ||
+	 p->bmax > p->bmin) &&  p->total > size)
+      size = (b = p)->total;
+  return (b);
+}
+
+static void
+shrinkbox(quant_table *qt, Colorbox* box)
+{
+  register int *histp, ir, ig, ib;
+
+  if (box->rmax > box->rmin) {
+    for (ir = box->rmin; ir <= box->rmax; ++ir)
+      for (ig = box->gmin; ig <= box->gmax; ++ig) {
+	histp = &(qt->histogram[ir][ig][box->bmin]);
+	for (ib = box->bmin; ib <= box->bmax; ++ib)
+	  if (*histp++ != 0) {
+	    box->rmin = ir;
+	    goto have_rmin;
+	  }
+      }
+  have_rmin:
+    if (box->rmax > box->rmin)
+      for (ir = box->rmax; ir >= box->rmin; --ir)
+	for (ig = box->gmin; ig <= box->gmax; ++ig) {
+	  histp = &(qt->histogram[ir][ig][box->bmin]);
+	  ib = box->bmin;
+	  for (; ib <= box->bmax; ++ib)
+	    if (*histp++ != 0) {
+	      box->rmax = ir;
+	      goto have_rmax;
+	    }
+	}
+  }
+ have_rmax:
+  if (box->gmax > box->gmin) {
+    for (ig = box->gmin; ig <= box->gmax; ++ig)
+      for (ir = box->rmin; ir <= box->rmax; ++ir) {
+	histp = &(qt->histogram[ir][ig][box->bmin]);
+	for (ib = box->bmin; ib <= box->bmax; ++ib)
+	  if (*histp++ != 0) {
+	    box->gmin = ig;
+	    goto have_gmin;
+	  }
+      }
+  have_gmin:
+    if (box->gmax > box->gmin)
+      for (ig = box->gmax; ig >= box->gmin; --ig)
+	for (ir = box->rmin; ir <= box->rmax; ++ir) {
+	  histp = &(qt->histogram[ir][ig][box->bmin]);
+	  ib = box->bmin;
+	  for (; ib <= box->bmax; ++ib)
+	    if (*histp++ != 0) {
+	      box->gmax = ig;
+	      goto have_gmax;
+	    }
+	}
+  }
+ have_gmax:
+  if (box->bmax > box->bmin) {
+    for (ib = box->bmin; ib <= box->bmax; ++ib)
+      for (ir = box->rmin; ir <= box->rmax; ++ir) {
+	histp = &(qt->histogram[ir][box->gmin][ib]);
+	for (ig = box->gmin; ig <= box->gmax; ++ig) {
+	  if (*histp != 0) {
+	    box->bmin = ib;
+	    goto have_bmin;
+	  }
+	  histp += B_LEN;
+	}
+      }
+  have_bmin:
+    if (box->bmax > box->bmin)
+      for (ib = box->bmax; ib >= box->bmin; --ib)
+	for (ir = box->rmin; ir <= box->rmax; ++ir) {
+	  histp = &(qt->histogram[ir][box->gmin][ib]);
+	  ig = box->gmin;
+	  for (; ig <= box->gmax; ++ig) {
+	    if (*histp != 0) {
+	      box->bmax = ib;
+	      goto have_bmax;
+	    }
+	    histp += B_LEN;
+	  }
+	}
+  }
+ have_bmax:
+  ;
+}
+
+static void
+splitbox(quant_table *qt, Colorbox* ptr)
+{
+  int		hist2[B_LEN];
+  int		first, last;
+  register Colorbox	*new;
+  register int	*iptr, *histp;
+  register int	i, j;
+  register int	ir,ig,ib;
+  register int sum, sum1, sum2;
+  enum { RED, GREEN, BLUE } axis;
+
+  /*
+   * See which axis is the largest, do a histogram along that
+   * axis.  Split at median point.  Contract both new boxes to
+   * fit points and return
+   */
+  i = ptr->rmax - ptr->rmin;
+  if (i >= ptr->gmax - ptr->gmin  && i >= ptr->bmax - ptr->bmin)
+    axis = RED;
+  else if (ptr->gmax - ptr->gmin >= ptr->bmax - ptr->bmin)
+    axis = GREEN;
+  else
+    axis = BLUE;
+  /* get histogram along longest axis */
+  switch (axis) {
+  case RED:
+    histp = &hist2[ptr->rmin];
+    for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) {
+      *histp = 0;
+      for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) {
+	iptr = &(qt->histogram[ir][ig][ptr->bmin]);
+	for (ib = ptr->bmin; ib <= ptr->bmax; ++ib)
+	  *histp += *iptr++;
+      }
+      histp++;
+    }
+    first = ptr->rmin;
+    last = ptr->rmax;
+    break;
+  case GREEN:
+    histp = &hist2[ptr->gmin];
+    for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) {
+      *histp = 0;
+      for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) {
+	iptr = &(qt->histogram[ir][ig][ptr->bmin]);
+	for (ib = ptr->bmin; ib <= ptr->bmax; ++ib)
+	  *histp += *iptr++;
+      }
+      histp++;
+    }
+    first = ptr->gmin;
+    last = ptr->gmax;
+    break;
+  case BLUE:
+    histp = &hist2[ptr->bmin];
+    for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) {
+      *histp = 0;
+      for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) {
+	iptr = &(qt->histogram[ir][ptr->gmin][ib]);
+	for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) {
+	  *histp += *iptr;
+	  iptr += B_LEN;
+	}
+      }
+      histp++;
+    }
+    first = ptr->bmin;
+    last = ptr->bmax;
+    break;
+  }
+  /* find median point */
+  sum2 = ptr->total / 2;
+  histp = &hist2[first];
+  sum = 0;
+  for (i = first; i <= last && (sum += *histp++) < sum2; ++i)
+    ;
+  if (i == first)
+    i++;
+
+  /* Create new box, re-allocate points */
+  new = qt->freeboxes;
+  qt->freeboxes = new->next;
+  if (qt->freeboxes)
+    qt->freeboxes->prev = NULL;
+  if (qt->usedboxes)
+    qt->usedboxes->prev = new;
+  new->next = qt->usedboxes;
+  qt->usedboxes = new;
+
+  histp = &hist2[first];
+  for (sum1 = 0, j = first; j < i; j++)
+    sum1 += *histp++;
+  for (sum2 = 0, j = i; j <= last; j++)
+    sum2 += *histp++;
+  new->total = sum1;
+  ptr->total = sum2;
+
+  new->rmin = ptr->rmin;
+  new->rmax = ptr->rmax;
+  new->gmin = ptr->gmin;
+  new->gmax = ptr->gmax;
+  new->bmin = ptr->bmin;
+  new->bmax = ptr->bmax;
+  switch (axis) {
+  case RED:
+    new->rmax = i-1;
+    ptr->rmin = i;
+    break;
+  case GREEN:
+    new->gmax = i-1;
+    ptr->gmin = i;
+    break;
+  case BLUE:
+    new->bmax = i-1;
+    ptr->bmin = i;
+    break;
+  }
+  shrinkbox(qt, new);
+  shrinkbox(qt, ptr);
+}
+
+
+static C_cell *
+create_colorcell(quant_table *qt, int num_colors, int red, int green, int blue)
+{
+  register int ir, ig, ib, i;
+  register C_cell *ptr;
+  int mindist, next_n;
+  register int tmp, dist, n;
+
+  ir = red >> (COLOR_DEPTH-C_DEPTH);
+  ig = green >> (COLOR_DEPTH-C_DEPTH);
+  ib = blue >> (COLOR_DEPTH-C_DEPTH);
+  ptr = (C_cell *)xmalloc(sizeof (C_cell));
+  *(qt->ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
+  ptr->num_ents = 0;
+
+  /*
+   * Step 1: find all colors inside this cell, while we're at
+   *	   it, find distance of centermost point to furthest corner
+   */
+  mindist = 99999999;
+  for (i = 0; i < num_colors; ++i) {
+    if (qt->rm[i]>>(COLOR_DEPTH-C_DEPTH) != ir  ||
+	qt->gm[i]>>(COLOR_DEPTH-C_DEPTH) != ig  ||
+	qt->bm[i]>>(COLOR_DEPTH-C_DEPTH) != ib)
+      continue;
+    ptr->entries[ptr->num_ents][0] = i;
+    ptr->entries[ptr->num_ents][1] = 0;
+    ++ptr->num_ents;
+    tmp = qt->rm[i] - red;
+    if (tmp < (MAX_COLOR/C_LEN/2))
+      tmp = MAX_COLOR/C_LEN-1 - tmp;
+    dist = tmp*tmp;
+    tmp = qt->gm[i] - green;
+    if (tmp < (MAX_COLOR/C_LEN/2))
+      tmp = MAX_COLOR/C_LEN-1 - tmp;
+    dist += tmp*tmp;
+    tmp = qt->bm[i] - blue;
+    if (tmp < (MAX_COLOR/C_LEN/2))
+      tmp = MAX_COLOR/C_LEN-1 - tmp;
+    dist += tmp*tmp;
+    if (dist < mindist)
+      mindist = dist;
+  }
+
+  /*
+   * Step 3: find all points within that distance to cell.
+   */
+  for (i = 0; i < num_colors; ++i) {
+    if (qt->rm[i] >> (COLOR_DEPTH-C_DEPTH) == ir  &&
+	qt->gm[i] >> (COLOR_DEPTH-C_DEPTH) == ig  &&
+	qt->bm[i] >> (COLOR_DEPTH-C_DEPTH) == ib)
+      continue;
+    dist = 0;
+    if ((tmp = red - qt->rm[i]) > 0 ||
+	(tmp = qt->rm[i] - (red + MAX_COLOR/C_LEN-1)) > 0 )
+      dist += tmp*tmp;
+    if ((tmp = green - qt->gm[i]) > 0 ||
+	(tmp = qt->gm[i] - (green + MAX_COLOR/C_LEN-1)) > 0 )
+      dist += tmp*tmp;
+    if ((tmp = blue - qt->bm[i]) > 0 ||
+	(tmp = qt->bm[i] - (blue + MAX_COLOR/C_LEN-1)) > 0 )
+      dist += tmp*tmp;
+    if (dist < mindist) {
+      ptr->entries[ptr->num_ents][0] = i;
+      ptr->entries[ptr->num_ents][1] = dist;
+      ++ptr->num_ents;
+    }
+  }
+
+  /*
+   * Sort color cells by distance, use cheap exchange sort
+   */
+  for (n = ptr->num_ents - 1; n > 0; n = next_n) {
+    next_n = 0;
+    for (i = 0; i < n; ++i)
+      if (ptr->entries[i][1] > ptr->entries[i+1][1]) {
+	tmp = ptr->entries[i][0];
+	ptr->entries[i][0] = ptr->entries[i+1][0];
+	ptr->entries[i+1][0] = tmp;
+	tmp = ptr->entries[i][1];
+	ptr->entries[i][1] = ptr->entries[i+1][1];
+	ptr->entries[i+1][1] = tmp;
+	next_n = i;
+      }
+  }
+  return (ptr);
+}
+
+static int
+map_colortable(quant_table *qt, int num_colors)
+{
+  register int *histp = &(qt->histogram[0][0][0]);
+  register C_cell *cell;
+  register int j, tmp, d2, dist;
+  int ir, ig, ib, i;
+
+  for (ir = 0; ir < B_LEN; ++ir)
+    for (ig = 0; ig < B_LEN; ++ig)
+      for (ib = 0; ib < B_LEN; ++ib, histp++) {
+	if (*histp == 0) {
+	  *histp = -1;
+	  continue;
+	}
+	cell = *(qt->ColorCells +
+		 (((ir>>(B_DEPTH-C_DEPTH)) << C_DEPTH*2) +
+		  ((ig>>(B_DEPTH-C_DEPTH)) << C_DEPTH) +
+		  (ib>>(B_DEPTH-C_DEPTH))));
+	if (cell == NULL )
+	  cell = create_colorcell(qt, num_colors,
+				  ir << COLOR_SHIFT,
+				  ig << COLOR_SHIFT,
+				  ib << COLOR_SHIFT);
+	if (cell == NULL) /* memory exhausted! punt! */
+	  return -1;
+	dist = 9999999;
+	for (i = 0; i < cell->num_ents &&
+	       dist > cell->entries[i][1]; ++i) {
+	  j = cell->entries[i][0];
+	  d2 = qt->rm[j] - (ir << COLOR_SHIFT);
+	  d2 *= d2;
+	  tmp = qt->gm[j] - (ig << COLOR_SHIFT);
+	  d2 += tmp*tmp;
+	  tmp = qt->bm[j] - (ib << COLOR_SHIFT);
+	  d2 += tmp*tmp;
+	  if (d2 < dist) {
+	    dist = d2;
+	    *histp = j;
+	  }
+	}
+      }
+  return 0;
+}
+
+quant_table *EImage_build_quantable(unsigned char *eimage, int width, int height, int num_colors)
+{
+  quant_table *qt;
+  Colorbox *box_list, *ptr;
+  int i,res;
+
+  qt = (quant_table*)xmalloc(sizeof(quant_table));
+  if (qt == NULL) return NULL;
+
+  assert (num_colors < 257 && num_colors > 2);
+  /*
+   * STEP 1:  create empty boxes
+   */
+  qt->usedboxes = NULL;
+  box_list = qt->freeboxes = (Colorbox *)xmalloc(num_colors*sizeof (Colorbox));
+  qt->freeboxes[0].next = &(qt->freeboxes[1]);
+  qt->freeboxes[0].prev = NULL;
+  for (i = 1; i < num_colors-1; ++i) {
+    qt->freeboxes[i].next = &(qt->freeboxes[i+1]);
+    qt->freeboxes[i].prev = &(qt->freeboxes[i-1]);
+  }
+  qt->freeboxes[num_colors-1].next = NULL;
+  qt->freeboxes[num_colors-1].prev = &(qt->freeboxes[num_colors-2]);
+
+  /*
+   * STEP 2: get histogram, initialize first box
+   */
+  ptr = qt->freeboxes;
+  qt->freeboxes = ptr->next;
+  if (qt->freeboxes)
+    qt->freeboxes->prev = NULL;
+  ptr->next = qt->usedboxes;
+  qt->usedboxes = ptr;
+  if (ptr->next)
+    ptr->next->prev = ptr;
+  get_histogram(qt, eimage, width, height, ptr);
+
+  /*
+   * STEP 3: continually subdivide boxes until no more free
+   * boxes remain or until all colors assigned.
+   */
+  while (qt->freeboxes != NULL) {
+    ptr = largest_box(qt);
+    if (ptr != NULL)
+      splitbox(qt, ptr);
+    else
+      qt->freeboxes = NULL;
+  }
+
+  /*
+   * STEP 4: assign colors to all boxes
+   */
+  for (i = 0, ptr = qt->usedboxes; ptr != NULL; ++i, ptr = ptr->next) {
+    qt->rm[i] = ((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2;
+    qt->gm[i] = ((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2;
+    qt->bm[i] = ((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2;
+    qt->um[i] = ptr->total;
+  }
+  qt->num_active_colors = i;
+
+  /* We're done with the boxes now */
+  xfree(box_list);
+  qt->freeboxes = qt->usedboxes = NULL;
+
+  /*
+   * STEP 5: scan histogram and map all values to closest color
+   */
+  /* 5a: create cell list as described in Heckbert */
+  qt->ColorCells = (C_cell **)xmalloc(C_LEN*C_LEN*C_LEN*sizeof (C_cell*));
+  memset(qt->ColorCells, 0, C_LEN*C_LEN*C_LEN*sizeof (C_cell*));
+  /* 5b: create mapping from truncated pixel space to color
+     table entries */
+  res = map_colortable(qt, num_colors);
+
+  /* 5c: done with ColorCells */
+  for (i = 0; i < C_LEN*C_LEN*C_LEN; i++) if (qt->ColorCells[i]) xfree(qt->ColorCells[i]);
+  xfree(qt->ColorCells);
+  
+  if (res) {
+    /* we failed in memory allocation, so clean up an leave */
+    xfree(qt);
+    return NULL;
+  }
+  
+  return qt;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imgproc.h	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,62 @@
+/* Image processing aux functions header file
+   Copyright (C) 1998 Jareth Hein
+
+This file is a part of XEmacs
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+/* Original author: Jareth Hein */
+
+#define	MAX_CMAP_SIZE	256
+#define	COLOR_DEPTH	8
+#define	MAX_COLOR	256
+
+#define	B_DEPTH		5		/* # bits/pixel to use */
+#define	B_LEN		(1L<<B_DEPTH)
+
+#define	C_DEPTH		2
+#define	C_LEN		(1L<<C_DEPTH)	/* # cells/color to use */
+
+#define	COLOR_SHIFT	(COLOR_DEPTH-B_DEPTH)
+
+typedef	struct colorbox {
+	struct	colorbox *next, *prev;
+	int	rmin, rmax;
+	int	gmin, gmax;
+	int	bmin, bmax;
+	int	total;
+} Colorbox;
+
+typedef struct {
+	int	num_ents;
+	int	entries[MAX_CMAP_SIZE][2];
+} C_cell;
+
+typedef struct {
+  unsigned short rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; /* map values */
+  int um[MAX_CMAP_SIZE]; /* usage counts for each mapentry */
+  int histogram[B_LEN][B_LEN][B_LEN]; 
+  int num_active_colors;
+  Colorbox *freeboxes; /* used and freed internally */
+  Colorbox *usedboxes; /* used and freed internally */
+  C_cell **ColorCells; /* used and freed internally */
+} quant_table;
+
+#define QUANT_GET_COLOR(qt,r,g,b) (qt->histogram[r>>COLOR_SHIFT][g>>COLOR_SHIFT][b>>COLOR_SHIFT])
+
+quant_table *EImage_build_quantable(unsigned char *eimage, int width, int height, int num_colors);
--- a/src/keymap.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/keymap.c	Mon Aug 13 10:25:37 2007 +0200
@@ -244,8 +244,9 @@
 #endif
 Lisp_Object Qmenu_selection;
 /* Emacs compatibility */
-Lisp_Object Qdown_mouse_1, Qdown_mouse_2, Qdown_mouse_3;
-Lisp_Object Qmouse_1, Qmouse_2, Qmouse_3;
+Lisp_Object Qdown_mouse_1, Qdown_mouse_2, Qdown_mouse_3, Qdown_mouse_4,
+  Qdown_mouse_5;
+Lisp_Object Qmouse_1, Qmouse_2, Qmouse_3, Qmouse_4, Qmouse_5;
 
 /* Kludge kludge kludge */
 Lisp_Object QLFD, QTAB, QRET, QESC, QDEL, QSPC, QBS;
@@ -1367,12 +1368,20 @@
 	*keysym = Qbutton2;
       else if (EQ(*keysym, Qdown_mouse_3))
 	*keysym = Qbutton3;
+      else if (EQ(*keysym, Qdown_mouse_4))
+	*keysym = Qbutton4;
+      else if (EQ(*keysym, Qdown_mouse_5))
+	*keysym = Qbutton5;
       else if (EQ(*keysym, Qmouse_1))
 	*keysym = Qbutton1up;
       else if (EQ(*keysym, Qmouse_2))
 	*keysym = Qbutton2up;
       else if (EQ(*keysym, Qmouse_3))
 	*keysym = Qbutton3up;
+      else if (EQ(*keysym, Qmouse_4))
+	*keysym = Qbutton4up;
+      else if (EQ(*keysym, Qmouse_5))
+	*keysym = Qbutton5up;
     }
 }
 
@@ -4303,9 +4312,13 @@
   defsymbol (&Qmouse_1, "mouse-1");
   defsymbol (&Qmouse_2, "mouse-2");
   defsymbol (&Qmouse_3, "mouse-3");
+  defsymbol (&Qmouse_4, "mouse-4");
+  defsymbol (&Qmouse_5, "mouse-5");
   defsymbol (&Qdown_mouse_1, "down-mouse-1");
   defsymbol (&Qdown_mouse_2, "down-mouse-2");
   defsymbol (&Qdown_mouse_3, "down-mouse-3");
+  defsymbol (&Qdown_mouse_4, "down-mouse-4");
+  defsymbol (&Qdown_mouse_5, "down-mouse-5");
   defsymbol (&Qmenu_selection, "menu-selection");
   defsymbol (&QLFD, "LFD");
   defsymbol (&QTAB, "TAB");
--- a/src/lisp.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/lisp.h	Mon Aug 13 10:25:37 2007 +0200
@@ -502,6 +502,12 @@
   Dynarr_declare (unsigned char);
 } unsigned_char_dynarr;
 
+typedef unsigned long unsigned_long;
+typedef struct
+{
+  Dynarr_declare (unsigned long);
+} unsigned_long_dynarr;
+
 typedef struct
 {
   Dynarr_declare (int);
--- a/src/lread.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/lread.c	Mon Aug 13 10:25:37 2007 +0200
@@ -207,6 +207,12 @@
 static int saved_doc_string_position;
 #endif
 
+/* When errors are signaled, the actual readcharfun should not be used
+   as an argument if it is an lstream, so that lstreams don't escape
+   to the Lisp level.  */
+#define READCHARFUN_MAYBE(x) (LSTREAMP (x)					\
+			      ? (build_string ("internal input stream"))	\
+			      : (x))
 
 
 static DOESNT_RETURN
@@ -569,9 +575,6 @@
   static Lisp_Object last_file_loaded;
   int pure_usage = 0;
 /*#endif*/
-#ifdef DOS_NT
-  int dosmode = O_TEXT;
-#endif /* DOS_NT */
   struct stat s1, s2;
   GCPRO3 (file, newer, found);
 
@@ -673,30 +676,6 @@
 
       if (!memcmp (".elc", foundstr + foundlen - 4, 4))
 	reading_elc = 1;
-
-#ifdef DOS_NT
-  /* The file was opened as binary, because that's what we'll
-     encounter most of the time.  If we're loading a .el, we need
-     to reopen it in text mode. */
-      if (!reading_elc)
-	{
-	  /* #### I would simply call _setmode (fd, O_RDONLY | O_TEXT).
-	     This is ok on NT but maybe breaks DOS. Is there
-	     any "DOS" still alive? - kkm */
-	  close (fd);
-	  fd = open (foundstr, O_RDONLY | O_TEXT);
-	  if (fd < 0)
-	    {
-	      if (NILP (no_error))
-		signal_file_error ("Cannot open load file", file);
-	      else
-		{
-		  UNGCPRO;
-		  return Qnil;
-		}
-	    }
-	}	  
-#endif /* DOS_NT */
     }
 
 #define PRINT_LOADING_MESSAGE(done) do {				\
@@ -980,11 +959,7 @@
 	  if (mode >= 0)
 	    fd = access (fn, mode);
 	  else
-#ifdef DOS_NT
-	    fd = open (fn, O_RDONLY | O_BINARY, 0);
-#else
 	    fd = open (fn, O_RDONLY | OPEN_BINARY, 0);
-#endif
 
 	  if (fd >= 0)
 	    {
@@ -993,10 +968,7 @@
 		*storeptr = build_string (fn);
 	      UNGCPRO;
 
-/* XXX FIX ME
-   Not sure about this on NT yet.  Do nothing for now.
-   --marcpa */
-#ifndef DOS_NT
+#ifndef WINDOWSNT
 	      /* If we actually opened the file, set close-on-exec flag
 		 on the new descriptor so that subprocesses can't whack
 		 at it.  */
@@ -1908,10 +1880,11 @@
     }
 
   {
-    Lisp_Object result = make_int ((negativland) ? -num : num);
+    int int_result = negativland ? -(int)num : (int)num;
+    Lisp_Object result = make_int (int_result);
     if (num && ((XINT (result) < 0) != negativland))
       goto overflow;
-    if (XINT (result) != ((negativland) ? -num : num))
+    if (XINT (result) != int_result)
       goto overflow;
     return result;
   }
@@ -2117,13 +2090,7 @@
   QUIT;
   c = readchar (readcharfun);
   if (c < 0)
-    {
-      if (LSTREAMP (readcharfun))
-	signal_error (Qend_of_file,
-		      list1 (build_string ("internal input stream")));
-      else
-	signal_error (Qend_of_file, list1 (readcharfun));
-    }
+    signal_error (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
 
   switch (c)
     {
@@ -2537,7 +2504,7 @@
 	/* Evil GNU Emacs "character" (ie integer) syntax */
 	c = readchar (readcharfun);
 	if (c < 0)
-	  return Fsignal (Qend_of_file, list1 (readcharfun));
+	  return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
 
 	if (c == '\\')
 	  c = read_escape (readcharfun);
@@ -2573,7 +2540,7 @@
 	    QUIT;
 	  }
 	if (c < 0)
-	  return Fsignal (Qend_of_file, list1 (readcharfun));
+	  return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
 
 	/* If purifying, and string starts with \ newline,
 	   return zero instead.  This is for doc strings
--- a/src/marker.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/marker.c	Mon Aug 13 10:25:37 2007 +0200
@@ -64,21 +64,23 @@
 static void
 print_marker (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
 {
+  struct Lisp_Marker *marker = XMARKER (obj);
+  char buf[200];
+
   if (print_readably)
-    error ("printing unreadable object #<marker>");
-      
+    error ("printing unreadable object #<marker 0x%x>", marker);
+
   write_c_string (GETTEXT ("#<marker "), printcharfun);
-  if (!(XMARKER (obj)->buffer))
+  if (!marker->buffer)
     write_c_string (GETTEXT ("in no buffer"), printcharfun);
   else
     {
-      char buf[200];
-      sprintf (buf, "at %d", marker_position (obj));
+      sprintf (buf, "at %d in ", marker_position (obj));
       write_c_string (buf, printcharfun);
-      write_c_string (" in ", printcharfun);
-      print_internal (XMARKER (obj)->buffer->name, printcharfun, 0);
+      print_internal (marker->buffer->name, printcharfun, 0);
     }
-  write_c_string (">", printcharfun);
+  sprintf (buf, " 0x%x>", marker);
+  write_c_string (buf, printcharfun);
 }
 
 static int
@@ -254,7 +256,7 @@
         marker_prev (BUF_MARKERS (b)) = m;
       BUF_MARKERS (b) = m;
     }
-  
+
   return marker;
 }
 
@@ -445,6 +447,46 @@
   return type;
 }
 
+/* #### What is the possible use of this?  It looks quite useless to
+   me, because there is no way to find *which* markers are positioned
+   at POSITION.  Additional bogosity bonus: (buffer-has-markers-at
+   (point)) will always return t because of the `point-marker'.  The
+   same goes for the position of mark.  Bletch!
+
+   Someone should discuss this with Stallman, but I don't have the
+   stomach.  In fact, this function sucks so badly that I'm disabling
+   it by default (although I've debugged it).  If you want to use it,
+   use extents instead.  --hniksic */
+#if 0
+xxDEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, 1, 1, 0, /*
+Return t if there are markers pointing at POSITION in the current buffer.
+*/
+       (position))
+{
+  struct Lisp_Marker *marker;
+  Memind pos;
+
+  /* A small optimization trick: convert POS to memind now, rather
+     than converting every marker's memory index to bufpos.  */
+  pos = bytind_to_memind (current_buffer,
+			  get_buffer_pos_byte (current_buffer, position,
+					       GB_COERCE_RANGE));
+
+  for (marker = BUF_MARKERS (current_buffer);
+       marker;
+       marker = marker_next (marker))
+    {
+      /* We use marker->memind, so we don't have to go through the
+         unwieldy operation of creating a Lisp_Object for
+         marker_position() every time around.  */
+      if (marker->memind == pos)
+	return Qt;
+    }
+
+  return Qnil;
+}
+#endif /* 0 */
+
 #ifdef MEMORY_USAGE_STATS
 
 int
@@ -476,6 +518,9 @@
   DEFSUBR (Fcopy_marker);
   DEFSUBR (Fmarker_insertion_type);
   DEFSUBR (Fset_marker_insertion_type);
+#if 0 /* FSFmacs crock */
+  DEFSUBR (Fbuffer_has_markers_at);
+#endif
 }
 
 void init_buffer_markers (struct buffer *b);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ntplay.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,56 @@
+/* Sound in windows nt XEmacs.
+   Copyright (C) 1998 Andy Piper.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.*/
+
+#include <windows.h>
+#undef CONST
+#include <config.h>
+
+#ifdef __CYGWIN32__
+extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
+#endif
+
+void play_sound_file (char *sound_file, int volume);
+void play_sound_file (char *sound_file, int volume)
+{
+  DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME;
+  char* dst=0;
+#ifdef __CYGWIN32__
+  CYGWIN_WIN32_PATH(sound_file, dst);
+  sound_file=dst;
+#endif
+  if (PlaySound(sound_file, NULL, flags)==FALSE)
+    {
+      perror(sound_file);
+    }
+  return;
+}
+
+/* Call "linux_play_data_or_file" with the appropriate parameters for
+   playing pre-loaded data */
+void play_sound_data (unsigned char *data, int length, int volume);
+void play_sound_data (unsigned char *data, int length, int volume)
+{
+  DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT;
+  if (PlaySound(data, NULL, flags)==FALSE)
+    {
+      perror("couldn't play sound file");
+    }
+  return;
+}
--- a/src/redisplay-msw.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/redisplay-msw.c	Mon Aug 13 10:25:37 2007 +0200
@@ -217,7 +217,7 @@
   if (!NILP (font))
     SelectObject(hdc, FONT_INSTANCE_MSWINDOWS_HFONT (XFONT_INSTANCE (font)));
 
-#if defined(DEBUG_XEMACS) || defined(__CYGWIN32__)
+#if defined(DEBUG_XEMACS) 
   /* evil kludge! - #### do we need this? - cygwin does for some
      reason --andyp */
   if (!NILP (fg) && !COLOR_INSTANCEP (fg))
--- a/src/redisplay-output.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/redisplay-output.c	Mon Aug 13 10:25:37 2007 +0200
@@ -750,13 +750,14 @@
   extern int cursor_in_echo_area;
 
   /*
-   * Bail if cursor_in_echo_area is non-zero and we're fiddling
-   * with the cursor in a minibuffer window, since that is a
-   * special case that is handled elsewhere and this function
-   * need not handle it.  Return 1 so the caller will assume we
+   * Bail if cursor_in_echo_area is non-zero and we're fiddling with
+   * the cursor in a non-active minibuffer window, since that is a
+   * special case that is handled elsewhere and this function need
+   * not handle it.  Return 1 so the caller will assume we
    * succeeded.
    */
-  if (cursor_in_echo_area && MINI_WINDOW_P (w))
+  if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
+      w != XWINDOW (FRAME_SELECTED_WINDOW (f)))
     return 1;
 
   if (y < 0 || y >= Dynarr_length (cla))
@@ -926,10 +927,17 @@
   struct display_line *dl;
   struct display_block *db;
   struct rune *rb;
+  extern int cursor_in_echo_area;
 
   int x = w->last_point_x[CURRENT_DISP];
   int y = w->last_point_y[CURRENT_DISP];
 
+  if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
+      !echo_area_active (f) && minibuf_level == 0)
+    {
+      MAYBE_DEVMETH (d, set_final_cursor_coords, (f, w->pixel_top, 0));
+    }
+
   if (y < 0 || y >= Dynarr_length (dla))
     return;
 
@@ -949,6 +957,9 @@
      cursor. */
   if (rb->cursor_type == CURSOR_ON)
     {
+      MAYBE_DEVMETH (d, set_final_cursor_coords,
+		     (f, dl->ypos - 1, rb->xpos));
+
       if (run_end_begin_meths)
 	DEVMETH (d, output_begin, (d));
 
--- a/src/redisplay-tty.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/redisplay-tty.c	Mon Aug 13 10:25:37 2007 +0200
@@ -183,10 +183,21 @@
 {
   struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
 
+  CONSOLE_TTY_CURSOR_X (c) = CONSOLE_TTY_FINAL_CURSOR_X (c);
+  CONSOLE_TTY_CURSOR_Y (c) = CONSOLE_TTY_FINAL_CURSOR_Y (c);
   FORCE_CURSOR_UPDATE (c);
   Lstream_flush (XLSTREAM (CONSOLE_TTY_DATA (c)->outstream));
 }
 
+static void
+tty_set_final_cursor_coords (struct frame *f, int y, int x)
+{
+  struct console *c = XCONSOLE (FRAME_CONSOLE (f));
+
+  CONSOLE_TTY_FINAL_CURSOR_X (c) = x;
+  CONSOLE_TTY_FINAL_CURSOR_Y (c) = y;
+}
+
 /*****************************************************************************
  tty_output_display_block
 
@@ -547,6 +558,8 @@
   if (TTY_SE (c).clr_frame)
     {
       OUTPUT1 (c, TTY_SE (c).clr_frame);
+      CONSOLE_TTY_REAL_CURSOR_X (c) = 0;
+      CONSOLE_TTY_REAL_CURSOR_Y (c) = 0;
 #ifdef NOT_SURE
       FRAME_CURSOR_X (f) = 0;
       FRAME_CURSOR_Y (f) = 0;
@@ -956,7 +969,7 @@
 			    f->height, f->width, 1);
 
 	  /* And then stick the cursor there. */
-	  cmgoto (f, f->height, 0);
+	  tty_set_final_cursor_coords (f, f->height, 0);
 	  tty_output_end (XDEVICE (dev));
 	}
     }
@@ -1543,4 +1556,5 @@
   CONSOLE_HAS_METHOD (tty, output_end);
   CONSOLE_HAS_METHOD (tty, flash);
   CONSOLE_HAS_METHOD (tty, ring_bell);
+  CONSOLE_HAS_METHOD (tty, set_final_cursor_coords);
 }
--- a/src/redisplay.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/redisplay.c	Mon Aug 13 10:25:37 2007 +0200
@@ -247,6 +247,7 @@
 static void generate_modeline (struct window *w, struct display_line *dl,
 			       int type);
 static int ensure_modeline_generated (struct window *w, int type);
+#ifdef MODELINE_IS_SCROLLABLE
 static void generate_formatted_string_db (Lisp_Object format_str,
 					  Lisp_Object result_str,
 					  struct window *w,
@@ -261,6 +262,20 @@
 					 Lisp_Object elt,
 					 int depth, int max_pixsize,
 					 face_index findex, int type);
+#else /* MODELINE_IS_SCROLLABLE */
+static void generate_formatted_string_db (Lisp_Object format_str,
+					  Lisp_Object result_str,
+					  struct window *w,
+					  struct display_line *dl,
+					  struct display_block *db,
+					  face_index findex, int min_pixpos,
+					  int max_pixpos, int type);
+static Charcount generate_fstring_runes (struct window *w, pos_data *data,
+					 Charcount pos, Charcount min_pos,
+					 Charcount max_pos, Lisp_Object elt,
+					 int depth, int max_pixsize,
+					 face_index findex, int type);
+#endif /* not MODELINE_IS_SCROLLABLE */
 static prop_block_dynarr *add_emchar_rune (pos_data *data);
 static prop_block_dynarr *add_bufbyte_string_runes (pos_data *data,
 						    Bufbyte *c_string,
@@ -1907,15 +1922,10 @@
     end_glyph_width = GLYPH_CACHEL_WIDTH (w, CONT_GLYPH_INDEX);
   data.max_pixpos -= end_glyph_width;
 
-  if (cursor_in_echo_area)
-    {
-      if (MINI_WINDOW_P (w) && echo_area_active (f))
-	{
-	  data.bi_cursor_bufpos = BI_BUF_ZV (b);
-	  data.cursor_type = CURSOR_ON;
-	}
-      else
-	data.cursor_type = NO_CURSOR;
+  if (cursor_in_echo_area && MINI_WINDOW_P (w) && echo_area_active (f))
+    {
+      data.bi_cursor_bufpos = BI_BUF_ZV (b);
+      data.cursor_type = CURSOR_ON;
     }
   else if (MINI_WINDOW_P (w) && !active_minibuffer)
     data.cursor_type = NO_CURSOR;
@@ -3565,17 +3575,26 @@
   else
     ypos_adj = 0;
 
+#ifdef MODELINE_IS_SCROLLABLE
   generate_formatted_string_db (b->modeline_format,
 				b->generated_modeline_string, w, dl, db,
 				MODELINE_INDEX, min_pixpos, max_pixpos, type,
 				1 /* generate a modeline */);
-  
+#else
+  generate_formatted_string_db (b->modeline_format,
+                                b->generated_modeline_string, w, dl, db,
+                                MODELINE_INDEX, min_pixpos, max_pixpos, type);
+#endif /* not MODELINE_IS_SCROLLABLE */
+
   /* The modeline is at the bottom of the gutters.  We have to wait to
      set this until we've generated teh modeline in order to account
      for any embedded faces. */
   dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
 }
 
+/* This define is for the experimental horizontal modeline scrolling. It's not
+   functionnal for 20.5, but might be for 21.1 */
+#ifdef MODELINE_IS_SCROLLABLE
 static void
 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str,
 			      struct window *w, struct display_line *dl,
@@ -3716,9 +3735,9 @@
 	    INC_CHARPTR (cur_pos);
 	  pos += 1;
 	}
-      else /* Maybe add something */
-	{
-	  if (*cur_pos)
+      else /* pos > 0, things will be visible */
+	{
+	  if (*cur_pos) /* some stuff to add */
 	    {
 	      CONST Bufbyte *old_cur_pos = cur_pos;
 	      int succeeded;
@@ -3733,11 +3752,15 @@
 		  data->bytepos += cur_pos - old_cur_pos;
 		}
 	    }
+	  /* no characters to add */
+	  /* If there 's room enough, add space */
 	  else if (data->pixpos + data->blank_width <= data->max_pixpos)
 	    {
 	      add_blank_rune (data, NULL, 0);
+	      pos += 1;
 	    }
-	  else /* pretend to add something */
+	  /* otherwise, just pretend we added something */
+	  else
 	    {
 	      if (*cur_pos)
 		INC_CHARPTR (cur_pos);
@@ -4014,6 +4037,7 @@
 		max_pos = pos - lim;
 	      else
 		max_pos = min (max_pos, pos - lim);
+	      no_limit = 0;
 	    }
           else if (lim > 0)
             {
@@ -4030,7 +4054,6 @@
               if (lim > min_pos)
                 min_pos = lim;
             }
-	  no_limit = 0;
           goto tail_recurse;
         }
       else if (STRINGP (car) || CONSP (car))
@@ -4112,6 +4135,500 @@
 
   return pos;
 }
+#else /* MODELINE_IS_SCROLLABLE */
+static void
+generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str,
+                              struct window *w, struct display_line *dl,
+                              struct display_block *db, face_index findex,
+                              int min_pixpos, int max_pixpos, int type)
+{
+  struct frame *f = XFRAME (w->frame);
+  struct device *d = XDEVICE (f->device);
+
+  pos_data data;
+  int c_pixpos;
+
+  memset (&data, 0, sizeof (data));
+  data.d = d;
+  data.db = db;
+  data.dl = dl;
+  data.findex = findex;
+  data.pixpos = min_pixpos;
+  data.max_pixpos = max_pixpos;
+  data.cursor_type = NO_CURSOR;
+  data.last_charset = Qunbound;
+  data.last_findex = DEFAULT_INDEX;
+  data.result_str = result_str;
+  data.is_modeline = 1;
+  XSETWINDOW (data.window, w);
+
+  Dynarr_reset (formatted_string_extent_dynarr);
+  Dynarr_reset (formatted_string_extent_start_dynarr);
+  Dynarr_reset (formatted_string_extent_end_dynarr);
+
+  /* This recursively builds up the modeline. */
+  generate_fstring_runes (w, &data, 0, 0, -1, format_str, 0,
+                          max_pixpos - min_pixpos, findex, type);
+
+  if (Dynarr_length (db->runes))
+    {
+      struct rune *rb =
+        Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
+      c_pixpos = rb->xpos + rb->width;
+    }
+  else
+    c_pixpos = min_pixpos;
+
+  /* If we don't reach the right side of the window, add a blank rune
+     to make up the difference.  This usually only occurs if the
+     modeline face is using a proportional width font or a fixed width
+     font of a different size from the default face font. */
+
+  if (c_pixpos < max_pixpos)
+    {
+      data.pixpos = c_pixpos;
+      data.blank_width = max_pixpos - data.pixpos;
+
+      add_blank_rune (&data, NULL, 0);
+    }
+
+  /* Now create the result string and frob the extents into it. */
+  if (!NILP (result_str))
+    {
+      int elt;
+      Bytecount len;
+      Bufbyte *strdata;
+      struct buffer *buf = XBUFFER (WINDOW_BUFFER (w));
+
+      detach_all_extents (result_str);
+      resize_string (XSTRING (result_str), -1,
+                     data.bytepos - XSTRING_LENGTH (result_str));
+
+      strdata = XSTRING_DATA (result_str);
+
+      for (elt = 0, len = 0; elt < Dynarr_length (db->runes); elt++)
+        {
+          if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
+            {
+              len += (set_charptr_emchar
+                      (strdata + len, Dynarr_atp (db->runes,
+                                                  elt)->object.chr.ch));
+            }
+        }
+
+      for (elt = 0; elt < Dynarr_length (formatted_string_extent_dynarr);
+           elt++)
+        {
+          Lisp_Object extent = Qnil;
+          Lisp_Object child;
+
+          XSETEXTENT (extent, Dynarr_at (formatted_string_extent_dynarr, elt));
+          child = Fgethash (extent, buf->modeline_extent_table, Qnil);
+          if (NILP (child))
+            {
+              child = Fmake_extent (Qnil, Qnil, result_str);
+              Fputhash (extent, child, buf->modeline_extent_table);
+            }
+          Fset_extent_parent (child, extent);
+          set_extent_endpoints
+            (XEXTENT (child),
+             Dynarr_at (formatted_string_extent_start_dynarr, elt),
+             Dynarr_at (formatted_string_extent_end_dynarr, elt),
+             result_str);
+        }
+    }
+}
+
+static Charcount
+add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str,
+                                Charcount pos, Charcount min_pos, Charcount max_pos)
+{
+  /* This function has been Mule-ized. */
+  Charcount end;
+  CONST Bufbyte *cur_pos = str;
+  struct display_block *db = data->db;
+
+  data->blank_width = space_width (XWINDOW (data->window));
+  while (Dynarr_length (db->runes) < pos)
+    add_blank_rune (data, NULL, 0);
+
+  end = (Dynarr_length (db->runes) +
+         bytecount_to_charcount (str, strlen ((CONST char *) str)));
+  if (max_pos != -1)
+    end = min (max_pos, end);
+
+  while (pos < end && *cur_pos)
+    {
+      CONST Bufbyte *old_cur_pos = cur_pos;
+      int succeeded;
+
+      data->ch = charptr_emchar (cur_pos);
+      succeeded = (add_emchar_rune (data) != ADD_FAILED);
+      INC_CHARPTR (cur_pos);
+      if (succeeded)
+        {
+          pos++;
+          data->modeline_charpos++;
+          data->bytepos += cur_pos - old_cur_pos;
+        }
+    }
+
+  while (Dynarr_length (db->runes) < min_pos &&
+         (data->pixpos + data->blank_width <= data->max_pixpos))
+    add_blank_rune (data, NULL, 0);
+
+  return Dynarr_length (db->runes);
+}
+
+/* #### Urk!  Should also handle begin-glyphs and end-glyphs in
+   modeline extents. */
+static Charcount
+add_glyph_to_fstring_db_runes (pos_data *data, Lisp_Object glyph,
+                               Charcount pos, Charcount min_pos, Charcount max_pos)
+{
+  /* This function has been Mule-ized. */
+  Charcount end;
+  struct display_block *db = data->db;
+  struct glyph_block gb;
+
+  data->blank_width = space_width (XWINDOW (data->window));
+  while (Dynarr_length (db->runes) < pos)
+    add_blank_rune (data, NULL, 0);
+
+  end = Dynarr_length (db->runes) + 1;
+  if (max_pos != -1)
+    end = min (max_pos, end);
+
+  gb.glyph = glyph;
+  gb.extent = Qnil;
+  add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
+  pos++;
+
+  while (Dynarr_length (db->runes) < pos &&
+         (data->pixpos + data->blank_width <= data->max_pixpos))
+    add_blank_rune (data, NULL, 0);
+
+  return Dynarr_length (db->runes);
+}
+
+/* If max_pos is == -1, it is considered to be infinite.  The same is
+   true of max_pixsize. */
+#define SET_CURRENT_MODE_CHARS_PIXSIZE                                  \
+  if (Dynarr_length (data->db->runes))                                  \
+    cur_pixsize = data->pixpos - Dynarr_atp (data->db->runes, 0)->xpos; \
+  else                                                                  \
+    cur_pixsize = 0;
+
+/* Note that this function does "positions" in terms of characters and
+   not in terms of columns.  This is necessary to make the formatting
+   work correctly when proportional width fonts are used in the
+   modeline. */
+static Charcount
+generate_fstring_runes (struct window *w, pos_data *data, Charcount pos,
+                        Charcount min_pos, Charcount max_pos,
+                        Lisp_Object elt, int depth, int max_pixsize,
+                        face_index findex, int type)
+{
+  /* This function has been Mule-ized. */
+  /* #### The other losing things in this function are:
+
+     -- C zero-terminated-string lossage.
+     -- Non-printable characters should be converted into something
+        appropriate (e.g. ^F) instead of blindly being printed anyway.
+   */
+
+tail_recurse:
+  if (depth > 10)
+    goto invalid;
+
+  depth++;
+
+  if (STRINGP (elt))
+    {
+      /* A string.  Add to the display line and check for %-constructs
+         within it. */
+
+      Bufbyte *this = XSTRING_DATA (elt);
+
+      while ((pos < max_pos || max_pos == -1) && *this)
+        {
+          Bufbyte *last = this;
+
+          while (*this && *this != '%')
+            this++;
+
+          if (this != last)
+            {
+              /* The string is just a string. */
+              Charcount size =
+                bytecount_to_charcount (last, this - last) + pos;
+              Charcount tmp_max = (max_pos == -1 ? size : min (size, max_pos));
+
+              pos = add_string_to_fstring_db_runes (data, last, pos, pos,
+                                                    tmp_max);
+            }
+          else /* *this == '%' */
+            {
+              Charcount spec_width = 0;
+
+              this++; /* skip over '%' */
+
+              /* We can't allow -ve args due to the "%-" construct.
+               * Argument specifies minwidth but not maxwidth
+               * (maxwidth can be specified by
+               * (<negative-number> . <stuff>) modeline elements)
+               */
+              while (isdigit (*this))
+                {
+                  spec_width = spec_width * 10 + (*this - '0');
+                  this++;
+                }
+              spec_width += pos;
+
+              if (*this == 'M')
+                {
+                  pos = generate_fstring_runes (w, data, pos, spec_width,
+                                                max_pos, Vglobal_mode_string,
+                                                depth, max_pixsize, findex,
+                                                type);
+                }
+              else if (*this == '-')
+                {
+                  Charcount num_to_add;
+
+                  if (max_pixsize < 0)
+                    num_to_add = 0;
+                  else if (max_pos != -1)
+                    num_to_add = max_pos - pos;
+                  else
+                    {
+                      int cur_pixsize;
+                      int dash_pixsize;
+                      Bufbyte ch = '-';
+                      SET_CURRENT_MODE_CHARS_PIXSIZE;
+
+                      dash_pixsize =
+                        redisplay_text_width_string (w, findex, &ch, Qnil, 0,
+                                                     1);
+
+                      num_to_add = (max_pixsize - cur_pixsize) / dash_pixsize;
+                      num_to_add++;
+                    }
+
+                  while (num_to_add--)
+                    pos = add_string_to_fstring_db_runes
+                      (data, (CONST Bufbyte *) "-", pos, pos, max_pos);
+                }
+              else if (*this != 0)
+                {
+                  Bufbyte *str;
+                  Emchar ch = charptr_emchar (this);
+                  decode_mode_spec (w, ch, type);
+
+                  str = Dynarr_atp (mode_spec_bufbyte_string, 0);
+                  pos = add_string_to_fstring_db_runes (data,str, pos, pos,
+                                                        max_pos);
+                }
+
+              /* NOT this++.  There could be any sort of character at
+                 the current position. */
+              INC_CHARPTR (this);
+            }
+
+          if (max_pixsize > 0)
+            {
+              int cur_pixsize;
+              SET_CURRENT_MODE_CHARS_PIXSIZE;
+
+              if (cur_pixsize >= max_pixsize)
+                break;
+            }
+        }
+    }
+  else if (SYMBOLP (elt))
+    {
+      /* A symbol: process the value of the symbol recursively
+         as if it appeared here directly. */
+      Lisp_Object tem = symbol_value_in_buffer (elt, w->buffer);
+
+      if (!UNBOUNDP (tem))
+        {
+          /* If value is a string, output that string literally:
+             don't check for % within it.  */
+          if (STRINGP (tem))
+            {
+              pos =
+                add_string_to_fstring_db_runes
+                (data, XSTRING_DATA (tem), pos, min_pos, max_pos);
+            }
+          /* Give up right away for nil or t.  */
+          else if (!EQ (tem, elt))
+            {
+              elt = tem;
+              goto tail_recurse;
+            }
+        }
+    }
+  else if (CONSP (elt))
+    {
+      /* A cons cell: four distinct cases.
+       * If first element is a string or a cons, process all the elements
+       * and effectively concatenate them.
+       * If first element is a negative number, truncate displaying cdr to
+       * at most that many characters.  If positive, pad (with spaces)
+       * to at least that many characters.
+       * If first element is a symbol, process the cadr or caddr recursively
+       * according to whether the symbol's value is non-nil or nil.
+       * If first element is a face, process the cdr recursively
+       * without altering the depth.
+       */
+      Lisp_Object car, tem;
+
+      car = XCAR (elt);
+      if (SYMBOLP (car))
+        {
+          elt = XCDR (elt);
+          if (!CONSP (elt))
+            goto invalid;
+          tem = symbol_value_in_buffer (car, w->buffer);
+          /* elt is now the cdr, and we know it is a cons cell.
+             Use its car if CAR has a non-nil value.  */
+          if (!UNBOUNDP (tem))
+            {
+              if (!NILP (tem))
+                {
+                  elt = XCAR (elt);
+                  goto tail_recurse;
+                }
+            }
+          /* Symbol's value is nil (or symbol is unbound)
+           * Get the cddr of the original list
+           * and if possible find the caddr and use that.
+           */
+          elt = XCDR (elt);
+          if (NILP (elt))
+            ;
+          else if (!CONSP (elt))
+            goto invalid;
+          else
+            {
+              elt = XCAR (elt);
+              goto tail_recurse;
+            }
+        }
+      else if (INTP (car))
+        {
+          Charcount lim = XINT (car);
+
+          elt = XCDR (elt);
+
+          if (lim < 0)
+            {
+              /* Negative int means reduce maximum width.
+               * DO NOT change MIN_PIXPOS here!
+               * (20 -10 . foo) should truncate foo to 10 col
+               * and then pad to 20.
+               */
+              if (max_pos == -1)
+                max_pos = pos - lim;
+              else
+                max_pos = min (max_pos, pos - lim);
+            }
+          else if (lim > 0)
+            {
+              /* Padding specified.  Don't let it be more than
+               * current maximum.
+               */
+              lim += pos;
+              if (max_pos != -1 && lim > max_pos)
+                lim = max_pos;
+              /* If that's more padding than already wanted, queue it.
+               * But don't reduce padding already specified even if
+               * that is beyond the current truncation point.
+               */
+              if (lim > min_pos)
+                min_pos = lim;
+            }
+          goto tail_recurse;
+        }
+      else if (STRINGP (car) || CONSP (car))
+        {
+          int limit = 50;
+          /* LIMIT is to protect against circular lists.  */
+          while (CONSP (elt) && --limit > 0
+                 && (pos < max_pos || max_pos == -1))
+            {
+              pos = generate_fstring_runes (w, data, pos, pos, max_pos,
+                                            XCAR (elt), depth,
+                                            max_pixsize, findex, type);
+              elt = XCDR (elt);
+            }
+        }
+      else if (EXTENTP (car))
+        {
+          struct extent *ext = XEXTENT (car);
+
+          if (EXTENT_LIVE_P (ext))
+            {
+              face_index old_findex = data->findex;
+              Lisp_Object face;
+              Lisp_Object font_inst;
+              face_index new_findex;
+              Bytecount start = data->bytepos;
+
+              face = extent_face (ext);
+              if (FACEP (face))
+                {
+                  /* #### needs to merge faces, sigh */
+                  /* #### needs to handle list of faces */
+                  new_findex = get_builtin_face_cache_index (w, face);
+                  /* !!#### not right; needs to compute the max height of
+                     all the charsets */
+                  font_inst = WINDOW_FACE_CACHEL_FONT (w, new_findex,
+                                                       Vcharset_ascii);
+
+                  data->dl->ascent = max (data->dl->ascent,
+                                          XFONT_INSTANCE (font_inst)->ascent);
+                  data->dl->descent = max (data->dl->descent,
+                                           XFONT_INSTANCE (font_inst)->
+                                           descent);
+                }
+              else
+                new_findex = old_findex;
+
+              data->findex = new_findex;
+              pos = generate_fstring_runes (w, data, pos, pos, max_pos,
+                                            XCDR (elt), depth - 1,
+                                            max_pixsize, new_findex, type);
+              data->findex = old_findex;
+              Dynarr_add (formatted_string_extent_dynarr, ext);
+              Dynarr_add (formatted_string_extent_start_dynarr, start);
+              Dynarr_add (formatted_string_extent_end_dynarr, data->bytepos);
+            }
+        }
+    }
+  else if (GLYPHP (elt))
+    {
+      pos = add_glyph_to_fstring_db_runes (data, elt, pos, pos, max_pos);
+    }
+  else
+    {
+    invalid:
+      pos =
+        add_string_to_fstring_db_runes
+          (data, (CONST Bufbyte *) GETTEXT ("*invalid*"), pos, min_pos,
+           max_pos);
+    }
+
+  if (min_pos > pos)
+    {
+      add_string_to_fstring_db_runes (data, (CONST Bufbyte *) "", pos, min_pos,
+                                      -1);
+    }
+
+  return pos;
+}
+#endif /* not MODELINE_IS_SCROLLABLE */
 
 /* The caller is responsible for freeing the returned string. */
 Bufbyte *
@@ -4126,11 +4643,16 @@
   db = get_display_block_from_line (dl, TEXT);
   Dynarr_reset (db->runes);
 
+#ifdef MODELINE_IS_SCROLLABLE
   /* D. Verna Feb. 1998.
      Currently, only update_frame_title can make us come here. This is not 
      to build a modeline */
   generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0,
 				-1, type, 0 /* not a modeline */);
+#else /* not MODELINE_IS_SCROLLABLE */
+  generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0,
+                                -1, type);
+#endif /* not MODELINE_IS_SCROLLABLE */
 
   Dynarr_reset (formatted_string_emchar_dynarr);
   while (elt < Dynarr_length (db->runes))
@@ -5908,11 +6430,8 @@
 
       /* indicate TEXT or BINARY */
     case 't':
-#ifdef DOS_NT
-      str = NILP (b->buffer_file_type) ? "T" : "B";
-#else /* not DOS_NT */
+      /* #### NT does not use this any more. Now what? */
       str = "T";
-#endif /* not DOS_NT */
       break;
 
       /* print percent of buffer above top of window, or Top, Bot or All */
--- a/src/s/cygwin32.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/s/cygwin32.h	Mon Aug 13 10:25:37 2007 +0200
@@ -78,6 +78,8 @@
 #endif
 extern void cygwin32_win32_to_posix_path_list(const char*, char*);
 extern int cygwin32_win32_to_posix_path_list_buf_size(const char*);
+extern void cygwin32_posix_to_win32_path_list(const char*, char*);
+extern int cygwin32_posix_to_win32_path_list_buf_size(const char*);
 struct timeval;
 struct timezone;
 extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
@@ -97,10 +99,8 @@
 #define ORDINARY_LINK
 #endif
 
-#define C_SWITCH_SYSTEM -Wno-sign-compare -Wno-implicit
-#undef MOD_ALT
-#undef MOD_CONTROL
-#undef MOD_SHIFT
+#define C_SWITCH_SYSTEM -Wno-sign-compare -Wno-implicit -fno-caller-saves
+#define LIBS_SYSTEM -lwinmm
 
 #define SIF_TRACKPOS	0x0010
 #define FW_BLACK	FW_HEAVY
@@ -114,6 +114,10 @@
 #define CBF_FAIL_POKES		0x10000
 #define CBF_FAIL_REQUESTS	0x20000
 #define SZDDESYS_TOPIC		"System"
+#define SND_ASYNC		1
+#define SND_NODEFAULT		2
+#define SND_MEMORY		4
+#define SND_FILENAME		0x2000L
 
 #define TEXT_START -1
 #define TEXT_END -1
@@ -126,6 +130,8 @@
 #ifndef HAVE_SOCKETS
 #define HAVE_SOCKETS
 #endif
+#define OBJECTS_SYSTEM	ntplay.o
+#define HAVE_NATIVE_SOUND
 
 #ifndef CYGWIN_B19
 #define TMPF_FIXED_PITCH	0x01
@@ -221,18 +227,17 @@
 /* We'll support either convention on NT.  */
 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
-
-/* The null device on Windows NT. */
 #define EXEC_SUFFIXES   ".exe:.com:.bat:.cmd:"
 
-#define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
-
 /* We need a little extra space, see ../../lisp/loadup.el */
 #define SYSTEM_PURESIZE_EXTRA 15000
 
 #define CYGWIN_CONV_PATH(src, dst) \
 dst = alloca (cygwin32_win32_to_posix_path_list_buf_size(src)); \
 cygwin32_win32_to_posix_path_list(src, dst)
+#define CYGWIN_WIN32_PATH(src, dst) \
+dst = alloca (cygwin32_posix_to_win32_path_list_buf_size(src)); \
+cygwin32_posix_to_win32_path_list(src, dst)
 
 /*
  * stolen from usg.
@@ -258,6 +263,7 @@
 
 #define PTY_TTY_NAME_SPRINTF				\
   {							\
+    extern char* ptsname(int);				\
     char *ptyname;					\
 							\
     if (!(ptyname = ptsname (fd)))			\
--- a/src/s/windowsnt.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/s/windowsnt.h	Mon Aug 13 10:25:37 2007 +0200
@@ -125,6 +125,9 @@
 #define DIRECTORY_SEP XINT (Vdirectory_sep_char)
 #endif
 
+/* XEmacs file I/O for DOS text files requires FILE_CODING */
+#define FILE_CODING
+
 #define DIRECTORY_SEP '\\'
 
 /* Define this to be the separator between devices and paths */
@@ -281,6 +284,11 @@
 #define abort	win32_abort
 #endif
 
+/* Random global functions called everywhere. Implemented in nt.c */
+void dostounix_filename (char *p);
+void unixtodos_filename (char *p);
+char *getwd (char *dir);
+
 /* Setitimer is emulated */
 #define HAVE_SETITIMER
 
--- a/src/sheap.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/sheap.c	Mon Aug 13 10:25:37 2007 +0200
@@ -26,10 +26,10 @@
 
 #ifdef MULE
 #define STATIC_HEAP_BASE	0x600000
-#define STATIC_HEAP_SLOP	0x30000
+#define STATIC_HEAP_SLOP	0x40000
 #else
 #define STATIC_HEAP_BASE	0x500000
-#define STATIC_HEAP_SLOP	0x30000
+#define STATIC_HEAP_SLOP	0x40000
 #endif
 #define STATIC_HEAP_SIZE \
 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
--- a/src/sound.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/sound.c	Mon Aug 13 10:25:37 2007 +0200
@@ -99,9 +99,11 @@
 	     to open the file, and use report_file_error() if it
 	     fails.  --hniksic */
 	  if (NILP (Ffile_exists_p (file)))
-	    signal_simple_continuable_error ("File does not exist", file);
+	    file =
+	      signal_simple_continuable_error ("File does not exist", file);
 	  else
-	    signal_simple_continuable_error ("File is unreadable", file);
+	    file =
+	      signal_simple_continuable_error ("File is unreadable", file);
 	}
     }
   UNGCPRO;
@@ -285,11 +287,11 @@
 #ifdef HAVE_NAS_SOUND
   if (DEVICE_CONNECTED_TO_NAS_P (d) && STRINGP (sound))
     {
-      Extbyte *soundext;
+      CONST Extbyte *soundext;
       Extcount soundextlen;
 
       GET_STRING_BINARY_DATA_ALLOCA (sound, soundext, soundextlen);
-      if (nas_play_sound_data (soundext, soundextlen, vol))
+      if (nas_play_sound_data ((char*)soundext, soundextlen, vol))
 	return Qnil;
     }
 #endif /* HAVE_NAS_SOUND */
@@ -298,13 +300,13 @@
   if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
       && STRINGP (sound))
     {
-      Extbyte *soundext;
+      CONST Extbyte *soundext;
       Extcount soundextlen;
 
       GET_STRING_BINARY_DATA_ALLOCA (sound, soundext, soundextlen);
       /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */
       stop_interrupts ();
-      play_sound_data (soundext, soundextlen, vol);
+      play_sound_data ((char*)soundext, soundextlen, vol);
       start_interrupts ();
       QUIT;
       return Qnil;
@@ -420,7 +422,7 @@
 static void
 init_native_sound (struct device *d)
 {
-  if (DEVICE_TTY_P (d) || DEVICE_STREAM_P (d))
+  if (DEVICE_TTY_P (d) || DEVICE_STREAM_P (d) || DEVICE_MSWINDOWS_P(d))
     DEVICE_ON_CONSOLE_P (d) = 1;
 #ifdef HAVE_X_WINDOWS
   else
--- a/src/symsinit.h	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/symsinit.h	Mon Aug 13 10:25:37 2007 +0200
@@ -349,7 +349,6 @@
 void init_event_tty_late (void);
 void init_event_mswindows_late (void);
 void init_event_unixoid (void);
-void init_gif_err (void);
 void init_lread (void);
 void init_macros (void);
 /* Not named init_process in order to avoid conflict with NS 3.3 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sysdll.c	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,215 @@
+/* sysdll.c --- system dependent support for dynamic linked libraries
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   Author:  William Perry <wmperry@aventail.com>
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include "sysdll.h"
+
+/* This whole file is conditional upon HAVE_DLL */
+#ifdef HAVE_SHLIB
+
+/* Thankfully, most systems follow the ELFish dlopen() method.
+** HAVE__DLOPEN is lame, but SCO has their dl* functions as _dl*, and
+** unless you include dlfcn.h you don't get the macros to mask them, and
+** autoconf fails to find them.
+**
+** Anybody who wants to use this on SCO needs to have their configure.in
+** look for _dlopen() as well as dlopen()
+*/
+#if defined(HAVE_DLOPEN) || defined(HAVE__DLOPEN)
+#include <dlfcn.h>
+
+#ifndef RTLD_LAZY
+#define RTLD_LAZY 1
+#endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
+
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+int dll_init(CONST char *arg) {
+  return(0);
+}
+
+dll_handle dll_open(CONST char *fname) {
+  return((dll_handle)dlopen(fname,RTLD_LAZY|RTLD_GLOBAL));
+}
+
+int dll_close(dll_handle h) {
+  return(dlclose((void *)h));
+}
+
+dll_func dll_function(dll_handle h,CONST char *n) {
+#ifdef DLSYM_NEEDS_UNDERSCORE
+    char buf[1024];
+    *buf = '_';
+    (void)strcpy(buf + 1, n);
+    n = buf;
+#endif
+  return((dll_func)dlsym((void *)h,n));
+}
+
+dll_var dll_variable(dll_handle h,CONST char *n) {
+  return((dll_var)dlsym((void *)h,n));
+}
+
+CONST char *dll_error(dll_handle h) {
+#ifdef HAVE_DLERROR
+  return((CONST char *)dl_error());
+#else
+  return("Shared library error");
+#endif
+}
+
+#elif defined(HAVE_SHL_LOAD)
+/* This is the HP/UX version */
+#include <dl.h>
+int dll_init(CONST char *arg) {
+  return(0);
+}
+
+dll_handle dll_open(CONST char *fname) {
+  return((dll_handle)shl_load(fname,BIND_DEFERRED,0L));
+}
+
+int dll_close(dll_handle h) {
+  return (shl_unload((shl_t)h));
+}
+
+dll_func dll_function(dll_handle h,CONST char *n) {
+  long handle = 0L;
+
+  if (shl_findsym(&(shl_t)h,n,TYPE_PROCEDURE,&handle))
+    return(NULL);
+
+  return((dll_func)handle);
+}
+
+dll_var dll_variable(dll_handle h,CONST char *n) {
+  long handle = 0L;
+
+  if (shl_findsym(&(shl_t)h,n,TYPE_DATA,&handle))
+    return(NULL);
+
+  return((dll_var)handle);
+}
+
+CONST char *dll_error(dll_handle h) {
+  return("Generic shared library error");
+}
+
+#elif defined(HAVE_INIT_DLD)
+#include <dld.h>
+int dll_init(CONST char *arg) {
+  char *real_exe = dld_find_executable(arg);
+  int rc;
+
+  rc = dld_init(real_exe);
+  if (rc) {
+    dld_perror (exe);
+    return(-1);
+  }
+  return(0);
+}
+
+dll_handle dll_open(CONST char *fname) {
+  rc = dld_link(fname);
+  if (rc) {
+    return (NULL);
+  }
+  return((dll_handle)1);
+}
+
+int dll_close(dll_handle h) {
+  /* *sigh* DLD is pretty lame and doesn't return a handle that you can use
+  ** later on to free the file - you have to remember the filename and
+  ** use that as the unlinker.  We should eventually keep a linked list
+  ** of loaded modules and then use the node pointer as the unique id
+  ** for the shared library.  Wheeee.  But not now.
+  */
+  return(1);
+}
+
+DLL_FUNC dll_function(dll_handle h,CONST char *n) {
+  return (dld_get_func(n));
+}
+
+DLL_FUNC dll_variable(dll_handle h,CONST char *n) {
+  return (dld_get_symbol(n));
+}
+#elif defined(_WINDOWS) || defined(WIN32)
+int dll_init(CONST char *arg) {
+  return(0);
+}
+
+dll_handle dll_open(CONST char *fname) {
+  return((dll_handle)LoadLibrary(fname));
+}
+
+int dll_close(dll_handle h) {
+  return(FreeLibrary(h));
+}
+
+dll_func dll_function(dll_handle h,CONST char *n) {
+  return((dll_func)GetProcAddress(h,n));
+}
+
+dll_func dll_variable(dll_handle h,CONST char *n) {
+  return((dll_func)GetProcAddress(h,n));
+}
+
+CONST char *dll_error(dll_handle h) {
+  return("Windows DLL Error");
+}
+#else
+/* Catchall if we don't know about this systems method of dynamic loading */
+int dll_init(CONST char *arg) {
+  return(-1);
+}
+
+dll_handle dll_open(CONST char *fname) {
+  return(NULL);
+}
+
+int dll_close(dll_handle h) {
+  return(0);
+}
+
+dll_func dll_function(dll_handle h,CONST char *n) {
+  return(NULL);
+}
+
+dll_func dll_variable(dll_handle h,CONST char *n) {
+  return(NULL);
+}
+
+CONST char *dll_error(dll_handle h) {
+  return("Shared libraries not implemented on this system.");
+}
+#endif /* System conditionals */
+
+#endif /* HAVE_SHLIB */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sysdll.h	Mon Aug 13 10:25:37 2007 +0200
@@ -0,0 +1,53 @@
+/* sysdll.h --- system dependent support for dynamic linked libraries
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   Author:  William Perry <wmperry@aventail.com>
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef _SYSDLL_H
+#define _SYSDLL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(WIN32)
+#define DLLEXPORT __declspec(dllexport)
+#elif defined(_WINDOWS)
+#define DLLEXPORT FAR PASCAL _EXPORT
+#else
+#define DLLEXPORT
+#endif
+
+typedef void * dll_handle;
+typedef void * dll_func;
+typedef void * dll_var;
+
+int dll_init(CONST char *);
+int dll_shutdown(void);
+dll_handle dll_open(CONST char *);
+int dll_close(dll_handle);
+dll_func dll_function(dll_handle,CONST char *);
+dll_var dll_variable(dll_handle,CONST char *);
+CONST char *dll_error(dll_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYSDLL_H */
--- a/src/window.c	Mon Aug 13 10:24:47 2007 +0200
+++ b/src/window.c	Mon Aug 13 10:25:37 2007 +0200
@@ -4071,23 +4071,18 @@
 
 }
 
-extern int signal_error_on_buffer_boundary;
-
 DEFUN ("scroll-up", Fscroll_up, 0, 1, "_P", /*
 Scroll text of current window upward ARG lines; or near full screen if no ARG.
 A near full screen is `next-screen-context-lines' less than a full screen.
 Negative ARG means scroll downward.
 When calling from a program, supply a number as argument or nil.
-
-If `signal-error-on-buffer-boundary' is nil, the usual error and
-loss of zmacs region is suppressed when moving past end of buffer.
+On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
+On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
+signaled.
 */
        (n))
 {
-  Error_behavior errb =
-    signal_error_on_buffer_boundary ? ERROR_ME : ERROR_ME_NOT;
-
-  window_scroll (Fselected_window (Qnil), n, 1, errb);
+  window_scroll (Fselected_window (Qnil), n, 1, ERROR_ME);
   return Qnil;
 }
 
@@ -4096,16 +4091,13 @@
 A near full screen is `next-screen-context-lines' less than a full screen.
 Negative ARG means scroll upward.
 When calling from a program, supply a number as argument or nil.
-
-If `signal-error-on-buffer-boundary' is nil, the usual error and
-loss of zmacs region is suppressed when moving past end of buffer.
+On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
+On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
+signaled.
 */
        (n))
 {
-  Error_behavior errb =
-    signal_error_on_buffer_boundary ? ERROR_ME : ERROR_ME_NOT;
-
-  window_scroll (Fselected_window (Qnil), n, -1, errb);
+  window_scroll (Fselected_window (Qnil), n, -1, ERROR_ME);
   return Qnil;
 }
 
@@ -5566,13 +5558,17 @@
   DEFSUBR (Fwindow_pixel_height);
   DEFSUBR (Fwindow_pixel_width);
   DEFSUBR (Fwindow_hscroll);
+#ifdef MODELINE_IS_SCROLLABLE
   DEFSUBR (Fmodeline_hscroll);
+#endif /* MODELINE_IS_SCROLLABLE */
 #if 0 /* bogus crock */
   DEFSUBR (Fwindow_redisplay_end_trigger);
   DEFSUBR (Fset_window_redisplay_end_trigger);
 #endif
   DEFSUBR (Fset_window_hscroll);
+#ifdef MODELINE_IS_SCROLLABLE
   DEFSUBR (Fset_modeline_hscroll);
+#endif /* MODELINE_IS_SCROLLABLE */
   DEFSUBR (Fwindow_pixel_edges);
   DEFSUBR (Fwindow_point);
   DEFSUBR (Fwindow_start);
--- a/version.sh	Mon Aug 13 10:24:47 2007 +0200
+++ b/version.sh	Mon Aug 13 10:25:37 2007 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
-emacs_major_version=20
-emacs_minor_version=5
-emacs_beta_version=30
-xemacs_codename="Moxoto"
+emacs_major_version=21
+emacs_minor_version=0
+emacs_beta_version=31
+xemacs_codename="Myotonic"