changeset 251:677f6a0ee643 r20-5b24

Import from CVS: tag r20-5b24
author cvs
date Mon, 13 Aug 2007 10:19:59 +0200
parents f385a461c9aa
children afb15df44434
files CHANGES-beta ChangeLog Makefile.in PROBLEMS configure configure.in etc/NEWS lib-src/make-docfile.c lisp/ChangeLog lisp/byte-optimize.el lisp/bytecomp-runtime.el lisp/cmdloop.el lisp/cus-dep.el lisp/help.el lisp/hyper-apropos.el lisp/keymap.el lisp/loaddefs.el lisp/loadup.el lisp/text-mode.el lisp/undo-stack.el src/ChangeLog src/Makefile.in.in src/alloc.c src/buffer.c src/callproc.c src/casetab.c src/chartab.c src/config.h.in src/console-msw.h src/console-stream.c src/console.h src/data.c src/dlopen.c src/doc.c src/elhash.c src/emacs.c src/eval.c src/event-msw.c src/event-stream.c src/fileio.c src/glyphs-x.c src/gmalloc.c src/gui.c src/gui.h src/lisp.h src/lread.c src/mem-limits.h src/menubar-msw.c src/menubar.c src/menubar.h src/mule-ccl.c src/objects-msw.c src/print.c src/process.c src/redisplay-msw.c src/redisplay-tty.c src/redisplay-x.c src/redisplay.c src/s/cygwin32.h src/search.c src/sheap.c src/signal.c src/symbols.c src/sysdep.c src/sysfile.h src/systime.h src/unexcw.c src/unexelf.c src/window.c src/window.h version.sh
diffstat 71 files changed, 5016 insertions(+), 3192 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES-beta	Mon Aug 13 10:19:12 2007 +0200
+++ b/CHANGES-beta	Mon Aug 13 10:19:59 2007 +0200
@@ -1,4 +1,13 @@
 							-*- indented-text -*-
+to 20.5 beta24 "Kaghani"
+-- source commentary censored
+-- Miscellaneous MS Windows patches from Kirill Katsnelson
+-- Miscellaneous MS Windows patches from Jonathan Harris
+-- Miscellaneous patches from Martin Buchholz and Hrvoje Niksic
+-- Cygwin patches courtesy of Andy Piper
+-- Fix for integer 0 plist problem on Linux courtesy of Olivier Galibert
+-- Miscellaneous bug fixes
+
 to 20.5 beta23 "Jining Grey"
 -- MS Windows DnD stuffs courtesy of Jonathon Harris
 -- Miscellaneous bug fixes
--- a/ChangeLog	Mon Aug 13 10:19:12 2007 +0200
+++ b/ChangeLog	Mon Aug 13 10:19:59 2007 +0200
@@ -1,3 +1,18 @@
+1998-02-09  SL Baur  <steve@altair.xemacs.org>
+
+	* XEmacs 20.5-beta24 is released.
+
+Wed Jan 28 13:41:22 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* configure.in: add mule-coding target which defines MULE_CODING,
+	nothing uses it as yet. add gif objects to msw support. define
+	const_is_losing=no for msw. make msw not selected if tty selected.
+ 	add -lshell32 for dnd support. check for a.out.h rather than
+	coff.h
+
+	* lib-src/make-docfile.c: add cygwin support and generalise the
+	remaining open calls. IMHO this should really include sysfile.h.
+
 1998-02-03  SL Baur  <steve@altair.xemacs.org>
 
 	* XEmacs 20.5-beta23 is released.
--- a/Makefile.in	Mon Aug 13 10:19:12 2007 +0200
+++ b/Makefile.in	Mon Aug 13 10:19:59 2007 +0200
@@ -230,7 +230,7 @@
 ## instead, we have written out explicit code in the `install' targets.
 COPYDIR = ${srcdir}/etc ${srcdir}/lisp
 COPYDESTS = ${etcdir} ${lispdir}
-GENERATED_HEADERS = src/paths.h src/Emacs.ad.h src/puresize-adjust.h src/config.h lwlib/config.h
+GENERATED_HEADERS = src/paths.h src/Emacs.ad.h src/puresize-adjust.h src/config.h lwlib/config.h src/sheap-adjust.h
 GENERATED_LISP = lisp/finder-inf.el
 
 all:	${GENERATED_HEADERS} ${MAKE_SUBDIR} ${GENERATED_LISP}
@@ -340,6 +340,12 @@
 	 echo "  	Automatically generated by XEmacs */" ; \
 	 echo "#define PURESIZE_ADJUSTMENT 0") > $@
 
+src/sheap-adjust.h:
+	@echo "Resetting \`src/sheap-adjust.h'."; \
+	(echo "/*	Do not edit this file!" ; \
+	 echo "  	Automatically generated by XEmacs */" ; \
+	 echo "#define SHEAP_ADJUSTMENT 0") > $@
+
 src: @SRC_SUBDIR_DEPS@ FRC.src
 pkg-src/tree-x: pkg-src/FRC.tree-x
 lib-src: FRC.lib-src
--- a/PROBLEMS	Mon Aug 13 10:19:12 2007 +0200
+++ b/PROBLEMS	Mon Aug 13 10:19:59 2007 +0200
@@ -401,6 +401,16 @@
 is to define the environment variable OPENWINHOME, even if you must set
 it to `/usr/openwin'.
 
+** Under Linux, you get "too many arguments to function `getpgrp'".
+
+You have probably installed LessTiff under `/usr/local' and `libXm.so'
+could not be found when linking `getpgrp()' test program, making XEmacs
+think that `getpgrp()' takes an argument. Try adding `/usr/local/lib'
+in `/etc/ld.so.conf' and run `ldconfig'. Then run XEmacs's `configure'
+again.  As with all problems of this type, reading the config.log file
+generated from configure and seeing the log of how the test failed can
+prove enlightening.
+
 
 * Problems with running XEmacs
 ==============================
--- a/configure	Mon Aug 13 10:19:12 2007 +0200
+++ b/configure	Mon Aug 13 10:19:59 2007 +0200
@@ -234,6 +234,7 @@
 with_menubars=''
 with_scrollbars=''
 with_dialogs=''
+with_mule_coding=''
 const_is_losing='yes'
 puresize=''
 cflags='UNSPECIFIED'
@@ -243,6 +244,7 @@
 with_system_malloc='default'
 native_sound_lib=''
 use_assertions="yes"
+with_gif=""
 with_toolbars=""
 with_tty=""
 use_union_type="no"
@@ -309,7 +311,10 @@
 	with_gpm	| \
 	with_xpm	| \
 	with_xface	| \
-	with_imagick	| \
+	with_gif	| \
+	with_jpeg	| \
+	with_png	| \
+	with_tiff	| \
 	with_session	| \
 	with_xmu	| \
 	with_quantify	| \
@@ -318,6 +323,7 @@
 	with_xfs	| \
 	with_i18n3	| \
 	with_mule	| \
+	with_mule_coding	| \
 	with_canna	| \
 	with_wnn	| \
 	with_wnn6	| \
@@ -630,7 +636,7 @@
 
 if test -z "$configuration"; then
   echo $ac_n "checking "host system type"""... $ac_c" 1>&6
-echo "configure:634: checking "host system type"" >&5
+echo "configure:640: checking "host system type"" >&5
     if configuration=`${CONFIG_SHELL-/bin/sh} $srcdir/config.guess | \
     sed 's/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/'` ; then
     echo "$ac_t""$configuration" 1>&6
@@ -644,7 +650,7 @@
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:648: checking whether ln -s works" >&5
+echo "configure:654: checking whether ln -s works" >&5
 
 rm -f conftestdata
 if ln -s X conftestdata 2>/dev/null
@@ -821,7 +827,7 @@
 
 
 echo "checking "the configuration name"" 1>&6
-echo "configure:825: checking "the configuration name"" >&5
+echo "configure:831: checking "the configuration name"" >&5
 internal_configuration=`echo $configuration | sed 's/-\(workshop\)//'`
 if canonical=`$srcdir/config.sub "$internal_configuration"` ; then : ; else
   exit $?
@@ -1292,7 +1298,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:1302: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1318,7 +1324,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:1328: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1363,7 +1369,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:1373: 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 +1381,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1379 "configure"
+#line 1385 "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:1389: \"$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 +1405,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:1409: 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:1414: 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:1421: \"$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 +1431,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:1435: 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 +1460,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:1464: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1480,7 +1486,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:1490: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1525,7 +1531,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:1535: 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 +1543,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1541 "configure"
+#line 1547 "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:1551: \"$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 +1567,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:1571: 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:1576: 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:1583: \"$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 +1593,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:1597: 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 +1622,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:1626: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1642,7 +1648,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:1652: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1687,7 +1693,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:1697: 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 +1705,11 @@
 cross_compiling=no
 
 cat > conftest.$ac_ext <<EOF
-#line 1703 "configure"
+#line 1709 "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:1713: \"$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 +1729,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:1733: 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:1738: 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:1745: \"$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 +1755,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:1759: 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 +1788,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:1792: 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 +1801,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 1805 "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:1811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -1812,13 +1818,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1816 "configure"
+#line 1822 "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:1828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -1841,9 +1847,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:1851: checking for AIX" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1853 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -1870,9 +1876,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:1880: checking for GNU libc" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1882 "configure"
 #include "confdefs.h"
 #include <features.h>
 int main() {
@@ -1884,7 +1890,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1888: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1894: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_glibc=yes
 else
@@ -1905,9 +1911,9 @@
 
 
 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:1915: checking whether we are using SunPro C" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1917 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1918,7 +1924,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   __sunpro_c=yes
 else
@@ -2194,7 +2200,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2198: checking for dynodump" >&5
+echo "configure:2204: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2292,19 +2298,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:2302: 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"
+#line 2307 "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
+if { (eval echo configure:2314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -2402,7 +2408,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:2406: checking for $ac_word" >&5
+echo "configure:2412: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -2455,7 +2461,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:2459: checking for a BSD compatible install" >&5
+echo "configure:2465: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
   IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
@@ -2506,7 +2512,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:2510: checking for $ac_word" >&5
+echo "configure:2516: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -2537,15 +2543,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2541: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2544 "configure"
+echo "configure:2547: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2550 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2549: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2555: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2578,15 +2584,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2582: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2585 "configure"
+echo "configure:2588: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2591 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2590: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2596: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2615,19 +2621,19 @@
 fi
 done
 
-for ac_hdr in linux/version.h kstat.h sys/pstat.h inttypes.h sys/un.h coff.h
+for ac_hdr in linux/version.h kstat.h sys/pstat.h inttypes.h sys/un.h a.out.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2623: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2626 "configure"
+echo "configure:2629: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2632 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2657,10 +2663,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:2661: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2664 "configure"
+echo "configure:2667: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2670 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -2676,7 +2682,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:2680: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -2700,10 +2706,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2704: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2707 "configure"
+echo "configure:2710: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2713 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2711,7 +2717,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2715: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2728,7 +2734,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 2732 "configure"
+#line 2738 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2746,7 +2752,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 2750 "configure"
+#line 2756 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2764,7 +2770,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 2768 "configure"
+#line 2774 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2775,7 +2781,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:2785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   :
 else
@@ -2800,10 +2806,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2804: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2807 "configure"
+echo "configure:2810: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2813 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2812,7 +2818,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2816: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2822: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2836,10 +2842,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:2840: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2843 "configure"
+echo "configure:2846: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2849 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2851,7 +2857,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:2855: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2861: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -2876,9 +2882,9 @@
 
 
 echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6
-echo "configure:2880: checking for struct utimbuf" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2882 "configure"
+echo "configure:2886: checking for struct utimbuf" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2888 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -2897,7 +2903,7 @@
 static struct utimbuf x; x.actime = x.modtime;
 ; return 0; }
 EOF
-if { (eval echo configure:2901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2907: \"$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
@@ -2917,10 +2923,10 @@
 rm -f conftest*
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2921: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2924 "configure"
+echo "configure:2927: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2930 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2937,7 +2943,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:2941: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2947: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -2959,10 +2965,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2963: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2966 "configure"
+echo "configure:2969: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2972 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2993,10 +2999,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2997: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3000 "configure"
+echo "configure:3003: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3006 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3027,10 +3033,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3031: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3034 "configure"
+echo "configure:3037: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3040 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3066,10 +3072,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3070: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3073 "configure"
+echo "configure:3076: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3079 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3100,10 +3106,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3104: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3107 "configure"
+echo "configure:3110: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3113 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3135,9 +3141,9 @@
 
 
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:3139: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3141 "configure"
+echo "configure:3145: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3147 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3153,7 +3159,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:3157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -3175,10 +3181,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:3179: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3182 "configure"
+echo "configure:3185: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3188 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -3186,7 +3192,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:3190: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -3210,10 +3216,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:3214: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3217 "configure"
+echo "configure:3220: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3223 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -3221,7 +3227,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:3225: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -3244,10 +3250,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:3248: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3251 "configure"
+echo "configure:3254: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3257 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -3257,7 +3263,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:3261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -3283,10 +3289,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3287: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3290 "configure"
+echo "configure:3293: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3296 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3335,7 +3341,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3339: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3345: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3360,7 +3366,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:3364: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:3370: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -3385,12 +3391,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3389: checking whether byte ordering is bigendian" >&5
+echo "configure:3395: 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 3394 "configure"
+#line 3400 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3401,11 +3407,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3405: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3411: \"$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 3409 "configure"
+#line 3415 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3416,7 +3422,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -3433,7 +3439,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 3437 "configure"
+#line 3443 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -3446,7 +3452,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:3450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -3472,10 +3478,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:3476: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3479 "configure"
+echo "configure:3482: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3485 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3486,7 +3492,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -3513,10 +3519,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3517: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3520 "configure"
+echo "configure:3523: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3526 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3527,7 +3533,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -3548,10 +3554,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3552: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3555 "configure"
+echo "configure:3558: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3561 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3562,7 +3568,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -3583,10 +3589,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:3587: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3590 "configure"
+echo "configure:3593: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3596 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3597,7 +3603,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3607: \"$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
@@ -3618,10 +3624,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:3622: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3625 "configure"
+echo "configure:3628: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3631 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3632,7 +3638,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3642: \"$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
@@ -3654,7 +3660,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:3658: checking for long file names" >&5
+echo "configure:3664: 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:
@@ -3701,12 +3707,12 @@
 
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:3705: checking for sin in -lm" >&5
+echo "configure:3711: 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 3710 "configure"
+#line 3716 "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
@@ -3717,7 +3723,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:3721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3727: \"$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
@@ -3759,14 +3765,14 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 3763 "configure"
+#line 3769 "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:3770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3776: \"$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
@@ -3783,7 +3789,7 @@
 rm -f conftest*
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:3787: checking type of mail spool file locking" >&5
+echo "configure:3793: 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
@@ -3807,12 +3813,12 @@
 
 
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:3811: checking for kstat_open in -lkstat" >&5
+echo "configure:3817: 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 3816 "configure"
+#line 3822 "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
@@ -3823,7 +3829,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:3827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3833: \"$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
@@ -3857,12 +3863,12 @@
 
 
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:3861: checking for kvm_read in -lkvm" >&5
+echo "configure:3867: 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 3866 "configure"
+#line 3872 "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
@@ -3873,7 +3879,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:3877: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3883: \"$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
@@ -3907,12 +3913,12 @@
 
 
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:3911: checking for cma_open in -lpthreads" >&5
+echo "configure:3917: 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 3916 "configure"
+#line 3922 "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
@@ -3923,7 +3929,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:3927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3933: \"$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
@@ -3959,7 +3965,7 @@
 fi
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:3963: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:3969: 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;
@@ -3970,7 +3976,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:3974: checking for \"-z ignore\" linker flag" >&5
+echo "configure:3980: 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 ;;
@@ -3980,7 +3986,7 @@
 
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:3984: checking "for specified window system"" >&5
+echo "configure:3990: checking "for specified window system"" >&5
 
 if test "$with_x11" != "no"; then
     test "$x_includes $x_libraries" != "NONE NONE" && \
@@ -4010,7 +4016,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:4014: checking for X" >&5
+echo "configure:4020: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -4070,12 +4076,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 4074 "configure"
+#line 4080 "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:4079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4085: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4144,14 +4150,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4148 "configure"
+#line 4154 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:4155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4161: \"$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.
@@ -4260,17 +4266,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:4264: checking whether -R must be followed by a space" >&5
+echo "configure:4270: 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 4267 "configure"
+#line 4273 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:4274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -4286,14 +4292,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 4290 "configure"
+#line 4296 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:4297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -4329,12 +4335,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:4333: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:4339: 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 4338 "configure"
+#line 4344 "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
@@ -4345,7 +4351,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4355: \"$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
@@ -4369,12 +4375,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:4373: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:4379: 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 4378 "configure"
+#line 4384 "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
@@ -4385,7 +4391,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4395: \"$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
@@ -4414,10 +4420,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:4418: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4421 "configure"
+echo "configure:4424: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4427 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -4440,7 +4446,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -4461,12 +4467,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:4465: checking for gethostbyname in -lnsl" >&5
+echo "configure:4471: 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 4470 "configure"
+#line 4476 "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
@@ -4477,7 +4483,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:4481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4487: \"$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
@@ -4507,10 +4513,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:4511: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4514 "configure"
+echo "configure:4517: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4520 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -4533,7 +4539,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -4556,12 +4562,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:4560: checking "$xe_msg_checking"" >&5
+echo "configure:4566: 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 4565 "configure"
+#line 4571 "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
@@ -4572,7 +4578,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:4576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4582: \"$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
@@ -4596,10 +4602,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:4600: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4603 "configure"
+echo "configure:4606: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4609 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -4622,7 +4628,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -4643,12 +4649,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:4647: checking for remove in -lposix" >&5
+echo "configure:4653: 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 4652 "configure"
+#line 4658 "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
@@ -4659,7 +4665,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:4663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4669: \"$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
@@ -4683,10 +4689,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:4687: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4690 "configure"
+echo "configure:4693: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4696 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -4709,7 +4715,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -4730,12 +4736,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:4734: checking for shmat in -lipc" >&5
+echo "configure:4740: 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 4739 "configure"
+#line 4745 "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
@@ -4746,7 +4752,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:4750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4756: \"$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
@@ -4780,12 +4786,12 @@
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   
 echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:4784: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:4790: 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 4789 "configure"
+#line 4795 "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
@@ -4796,7 +4802,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:4800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4806: \"$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
@@ -4831,24 +4837,24 @@
   no  ) window_system=none HAVE_X_WINDOWS=no  ;;
 esac
 
-if test "$window_system" = "none"; then
+if test "$window_system" = "none" && test -z "$with_tty"; then
   echo "checking for MS-Windows" 1>&6
-echo "configure:4837: checking for MS-Windows" >&5
+echo "configure:4843: checking for MS-Windows" >&5
   
 echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
-echo "configure:4840: checking for main in -lgdi32" >&5
+echo "configure:4846: 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 4845 "configure"
+#line 4851 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4852: \"$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_lib_$ac_lib_var=yes"
 else
@@ -4877,7 +4883,7 @@
 EOF
 }
 
-    libs_system="$libs_system -lgdi32 -luser32" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lgdi32 -luser32\" to \$libs_system"; fi
+    libs_system="$libs_system -lshell32 -lgdi32 -luser32" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lshell32 -lgdi32 -luser32\" to \$libs_system"; fi
     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\""
@@ -4888,8 +4894,10 @@
     with_dialogs=msw
     with_toolbars=no
     with_tty=no
-    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\""
+    const_is_losing=no
+    #with_mule_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 gif_err.o gifalloc.o dgif_lib.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 gif_err.o gifalloc.o dgif_lib.o\""
  fi
   fi
 fi
@@ -4992,7 +5000,7 @@
   fi
 
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:4996: checking for X defines extracted by xmkmf" >&5
+echo "configure:5004: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -5024,15 +5032,15 @@
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:5028: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5031 "configure"
+echo "configure:5036: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5039 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5036: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5044: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5056,12 +5064,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:5060: checking for XOpenDisplay in -lX11" >&5
+echo "configure:5068: 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 5065 "configure"
+#line 5073 "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
@@ -5072,7 +5080,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5084: \"$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
@@ -5097,12 +5105,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:5101: checking "$xe_msg_checking"" >&5
+echo "configure:5109: 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 5106 "configure"
+#line 5114 "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
@@ -5113,7 +5121,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:5117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5125: \"$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
@@ -5140,12 +5148,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:5144: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:5152: 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 5149 "configure"
+#line 5157 "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
@@ -5156,7 +5164,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:5160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5168: \"$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
@@ -5179,12 +5187,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:5183: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:5191: 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 5188 "configure"
+#line 5196 "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
@@ -5195,7 +5203,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5207: \"$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
@@ -5218,14 +5226,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:5222: checking the version of X11 being used" >&5
+echo "configure:5230: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 5224 "configure"
+#line 5232 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     main(int c, char* v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:5229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:5237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -5249,15 +5257,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5253: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5256 "configure"
+echo "configure:5261: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5264 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5261: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5269: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5288,7 +5296,7 @@
 
 
     echo $ac_n "checking for XFree86""... $ac_c" 1>&6
-echo "configure:5292: checking for XFree86" >&5
+echo "configure:5300: checking for XFree86" >&5
   if test -d "/usr/X386/include" -o \
           -f "/etc/XF86Config"    -o \
 	  -f "/etc/X11/XF86Config" -o \
@@ -5308,12 +5316,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:5312: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:5320: 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 5317 "configure"
+#line 5325 "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
@@ -5324,7 +5332,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:5328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5336: \"$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
@@ -5363,19 +5371,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:5367: checking for main in -lXbsd" >&5
+echo "configure:5375: 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 5372 "configure"
+#line 5380 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5387: \"$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
@@ -5409,7 +5417,7 @@
   fi
   for feature in tooltalk cde offix session \
                  menubars scrollbars toolbars dialogs xim xmu \
-                 imagick xface xpm
+                 tiff png jpeg gif xface xpm
   do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
        echo "configure: warning: --with-$feature ignored:  Not valid without X support" 1>&2
@@ -5434,7 +5442,7 @@
 esac
 
 echo "checking for session-management option" 1>&6
-echo "configure:5438: checking for session-management option" >&5;
+echo "configure:5446: checking for session-management option" >&5;
 if test "$with_session" != "no"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SESSION
@@ -5449,15 +5457,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:5453: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5456 "configure"
+echo "configure:5461: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5464 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5461: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5480,12 +5488,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:5484: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:5492: 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 5489 "configure"
+#line 5497 "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
@@ -5496,7 +5504,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:5500: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5508: \"$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
@@ -5556,15 +5564,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:5560: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5563 "configure"
+echo "configure:5568: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5571 "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:5568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5576: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5593,12 +5601,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:5597: checking "$xe_msg_checking"" >&5
+echo "configure:5605: 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 5602 "configure"
+#line 5610 "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
@@ -5609,7 +5617,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:5613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5621: \"$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
@@ -5658,15 +5666,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:5662: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5665 "configure"
+echo "configure:5670: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5673 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5670: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5678: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5689,12 +5697,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:5693: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:5701: 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 5698 "configure"
+#line 5706 "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
@@ -5705,7 +5713,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:5709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5717: \"$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
@@ -5745,13 +5753,13 @@
 if test "$with_x11" = "yes"; then
 
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:5749: checking for X11 graphics libraries" >&5
+echo "configure:5757: checking for X11 graphics libraries" >&5
 
     echo $ac_n "checking for Xpm - no older than 3.4f""... $ac_c" 1>&6
-echo "configure:5752: checking for Xpm - no older than 3.4f" >&5
+echo "configure:5760: checking for Xpm - no older than 3.4f" >&5
   xe_check_libs=-lXpm
   test -z "$with_xpm" && { cat > conftest.$ac_ext <<EOF
-#line 5755 "configure"
+#line 5763 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
   int main(int c, char **v) {
@@ -5761,7 +5769,7 @@
 		  0 ;
   }
 EOF
-if { (eval echo configure:5765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:5773: \"$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;
@@ -5799,15 +5807,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:5803: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5806 "configure"
+echo "configure:5811: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5814 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5819: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5830,12 +5838,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:5834: checking for UnGenFace in -lcompface" >&5
+echo "configure:5842: 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 5839 "configure"
+#line 5847 "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
@@ -5846,7 +5854,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:5850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5858: \"$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
@@ -5880,17 +5888,115 @@
     libs_x="-lcompface $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lcompface\" to \$libs_x"; fi
   fi
 
-    test "$with_imagick" != "no" && { ac_safe=`echo "magick/magick.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for magick/magick.h""... $ac_c" 1>&6
-echo "configure:5886: checking for magick/magick.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5889 "configure"
-#include "confdefs.h"
-#include <magick/magick.h>
+    test -z "$with_gif" && with_gif=yes;
+  if test "$with_gif" = "yes"; then
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_GIF
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_GIF 1
+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
+  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:5909: checking for jpeglib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5912 "configure"
+#include "confdefs.h"
+#include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5894: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5917: \"$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_jpeg=no
+fi
+ }
+  test -z "$with_jpeg" && { 
+echo $ac_n "checking for jpeg_destroy_decompress in -ljpeg""... $ac_c" 1>&6
+echo "configure:5940: 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 5945 "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 jpeg_destroy_decompress();
+
+int main() {
+jpeg_destroy_decompress()
+; return 0; }
+EOF
+if { (eval echo configure:5956: \"$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_jpeg=no
+fi
+
+ }
+  test -z "$with_jpeg" && with_jpeg=yes
+  if test "$with_jpeg" = "yes"; then
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_JPEG
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_JPEG 1
+EOF
+}
+
+    libs_x="-ljpeg $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-ljpeg\" to \$libs_x"; fi
+  fi
+
+    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:5992: checking for png.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5995 "configure"
+#include "confdefs.h"
+#include <png.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:6000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5908,258 +6014,78 @@
   :
 else
   echo "$ac_t""no" 1>&6
-ac_safe=`echo "X11/magick/magick.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for X11/magick/magick.h""... $ac_c" 1>&6
-echo "configure:5914: checking for X11/magick/magick.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5917 "configure"
-#include "confdefs.h"
-#include <X11/magick/magick.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5922: \"$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
-  { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining MAGICK_HEADERS_ARE_UNDER_X11
-EOF
-cat >> confdefs.h <<\EOF
-#define MAGICK_HEADERS_ARE_UNDER_X11 1
-EOF
-}
-
-else
-  echo "$ac_t""no" 1>&6
-with_imagick=no
-fi
-
+with_png=no
 fi
  }
-  test "$with_imagick" != "no" && {
-            z_libs=""
-    
-echo $ac_n "checking for inflateInit_ in -lz""... $ac_c" 1>&6
-echo "configure:5956: checking for inflateInit_ in -lz" >&5
-ac_lib_var=`echo z'_'inflateInit_ | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lz "
-cat > conftest.$ac_ext <<EOF
-#line 5961 "configure"
-#include "confdefs.h"
+  test -z "$with_png" && { echo $ac_n "checking for pow""... $ac_c" 1>&6
+echo "configure:6022: checking for pow" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6025 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char pow(); below.  */
+#include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char inflateInit_();
+char pow();
 
 int main() {
-inflateInit_()
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_pow) || defined (__stub___pow)
+choke me
+#else
+pow();
+#endif
+
 ; return 0; }
 EOF
-if { (eval echo configure:5972: \"$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
-  z_libs="$z_libs -lz" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lz\" to \$z_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for inflateInit_ in -lgz""... $ac_c" 1>&6
-echo "configure:5990: checking for inflateInit_ in -lgz" >&5
-ac_lib_var=`echo gz'_'inflateInit_ | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lgz "
-cat > conftest.$ac_ext <<EOF
-#line 5995 "configure"
+if { (eval echo configure:6048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_pow=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_pow=no"
+fi
+rm -f conftest*
+
+if eval "test \"`echo '$ac_cv_func_'pow`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+with_png=no
+fi
+ }
+  if test "$with_png" != "no"; then
+    for extra_libs in "" "-lz" "-lgz"; do
+      
+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:6073: 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 6078 "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 inflateInit_();
-
-int main() {
-inflateInit_()
-; return 0; }
-EOF
-if { (eval echo configure:6006: \"$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
-  z_libs="$z_libs -lgz" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lgz\" to \$z_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-fi
-
-
-
-    imagick_libs=""
-    
-echo $ac_n "checking for XDPSPixelsPerPoint in -ldps""... $ac_c" 1>&6
-echo "configure:6033: checking for XDPSPixelsPerPoint in -ldps" >&5
-ac_lib_var=`echo dps'_'XDPSPixelsPerPoint | sed 'y%./+-%__p_%'`
-
-xe_check_libs="-ldpstk -ldps "
-cat > conftest.$ac_ext <<EOF
-#line 6038 "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 XDPSPixelsPerPoint();
+char png_read_image();
 
 int main() {
-XDPSPixelsPerPoint()
-; return 0; }
-EOF
-if { (eval echo configure:6049: \"$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
-  imagick_libs="$imagick_libs -ldpstk -ldps" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ldpstk -ldps\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for FPX_SetToolkitMemoryLimit in -lfpx""... $ac_c" 1>&6
-echo "configure:6071: checking for FPX_SetToolkitMemoryLimit in -lfpx" >&5
-ac_lib_var=`echo fpx'_'FPX_SetToolkitMemoryLimit | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lfpx "
-cat > conftest.$ac_ext <<EOF
-#line 6076 "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 FPX_SetToolkitMemoryLimit();
-
-int main() {
-FPX_SetToolkitMemoryLimit()
+png_read_image()
 ; return 0; }
 EOF
-if { (eval echo configure:6087: \"$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
-  imagick_libs="$imagick_libs -lfpx" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lfpx\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for DF24getdims in -ldf""... $ac_c" 1>&6
-echo "configure:6109: checking for DF24getdims in -ldf" >&5
-ac_lib_var=`echo df'_'DF24getdims | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -ldf "
-cat > conftest.$ac_ext <<EOF
-#line 6114 "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 DF24getdims();
-
-int main() {
-DF24getdims()
-; return 0; }
-EOF
-if { (eval echo configure:6125: \"$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
-  imagick_libs="$imagick_libs -ldf" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ldf\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for jbg_dec_init in -ljbig""... $ac_c" 1>&6
-echo "configure:6147: checking for jbg_dec_init in -ljbig" >&5
-ac_lib_var=`echo jbig'_'jbg_dec_init | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -ljbig "
-cat > conftest.$ac_ext <<EOF
-#line 6152 "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 jbg_dec_init();
-
-int main() {
-jbg_dec_init()
-; return 0; }
-EOF
-if { (eval echo configure:6163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6089: \"$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
@@ -6173,147 +6099,51 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
-  imagick_libs="$imagick_libs -ljbig" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ljbig\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:6185: checking for jpeg_read_header in -ljpeg" >&5
-ac_lib_var=`echo jpeg'_'jpeg_read_header | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -ljpeg "
-cat > conftest.$ac_ext <<EOF
-#line 6190 "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 jpeg_read_header();
-
-int main() {
-jpeg_read_header()
-; return 0; }
-EOF
-if { (eval echo configure:6201: \"$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
-  imagick_libs="$imagick_libs -ljpeg" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ljpeg\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for OpenMPEG in -lmpeg""... $ac_c" 1>&6
-echo "configure:6223: checking for OpenMPEG in -lmpeg" >&5
-ac_lib_var=`echo mpeg'_'OpenMPEG | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lmpeg "
-cat > conftest.$ac_ext <<EOF
-#line 6228 "configure"
+  png_libs="-lpng $extra_libs" with_png=yes; break
+else
+  echo "$ac_t""no" 1>&6
+:
+fi
+
+
+    done
+  fi
+  test -z "$with_png" && with_png=no
+  if test "$with_png" = "yes"; then
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_PNG
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_PNG 1
+EOF
+}
+
+    libs_x="$png_libs $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"$png_libs\" to \$libs_x"; fi
+  fi
+
+    if test "$with_tiff" != no; then
+    for extra_libs in "" "-lz" "-lgz"; do
+      
+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:6131: 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 6136 "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 OpenMPEG();
-
-int main() {
-OpenMPEG()
-; return 0; }
-EOF
-if { (eval echo configure:6239: \"$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
-  imagick_libs="$imagick_libs -lmpeg" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lmpeg\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-echo $ac_n "checking for TT_Init_FreeType in -lttf""... $ac_c" 1>&6
-echo "configure:6261: checking for TT_Init_FreeType in -lttf" >&5
-ac_lib_var=`echo ttf'_'TT_Init_FreeType | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lttf "
-cat > conftest.$ac_ext <<EOF
-#line 6266 "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 TT_Init_FreeType();
+char TIFFReadScanline();
 
 int main() {
-TT_Init_FreeType()
+TIFFReadScanline()
 ; return 0; }
 EOF
-if { (eval echo configure:6277: \"$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
-  imagick_libs="$imagick_libs -lttf" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lttf\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-    
-xe_msg_checking="for png_create_read_struct in -lpng"
-test -n "$z_libs" && xe_msg_checking="$xe_msg_checking using extra libs $z_libs"
-echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6301: checking "$xe_msg_checking"" >&5
-ac_lib_var=`echo png'_'png_create_read_struct | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lpng $z_libs"
-cat > conftest.$ac_ext <<EOF
-#line 6306 "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 png_create_read_struct();
-
-int main() {
-png_create_read_struct()
-; return 0; }
-EOF
-if { (eval echo configure:6317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6147: \"$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
@@ -6327,152 +6157,36 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
-  imagick_libs="$imagick_libs -lpng" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lpng\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
+  tiff_libs="-ltiff $extra_libs" with_tiff=yes; break
+else
+  echo "$ac_t""no" 1>&6
+:
+fi
+
+
+    done
+  fi
+  test -z "$with_tiff" && with_tiff=no
+  if test "$with_tiff" = "yes"; then
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_TIFF
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_TIFF 1
+EOF
+}
+
+    libs_x="$tiff_libs $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"$tiff_libs\" to \$libs_x"; fi
+  fi
     
-echo $ac_n "checking for TIFFOpen in -ltiff""... $ac_c" 1>&6
-echo "configure:6339: checking for TIFFOpen in -ltiff" >&5
-ac_lib_var=`echo tiff'_'TIFFOpen | sed 'y%./+-%__p_%'`
-
-xe_check_libs="$z_libs -ltiff "
-cat > conftest.$ac_ext <<EOF
-#line 6344 "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 TIFFOpen();
-
-int main() {
-TIFFOpen()
-; return 0; }
-EOF
-if { (eval echo configure:6355: \"$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
-  imagick_libs="$imagick_libs -ltiff" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ltiff\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-xe_msg_checking="for TIFFOpen in -ltiff"
-test -n "-ljpeg $z_libs" && xe_msg_checking="$xe_msg_checking using extra libs -ljpeg $z_libs"
-echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6375: checking "$xe_msg_checking"" >&5
-ac_lib_var=`echo tiff'_'TIFFOpen | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -ltiff -ljpeg $z_libs"
-cat > conftest.$ac_ext <<EOF
-#line 6380 "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 TIFFOpen();
-
-int main() {
-TIFFOpen()
-; return 0; }
-EOF
-if { (eval echo configure:6391: \"$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
-  imagick_libs="$imagick_libs -ltiff -ljpeg" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-ltiff -ljpeg\" to \$imagick_libs"; fi
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-fi
-
-
-    imagick_libs="$imagick_libs $z_libs" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"$z_libs\" to \$imagick_libs"; fi
-    libs_x="$libs_x $imagick_libs" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"$imagick_libs\" to \$libs_x"; fi
-  }
-  test -z "$with_imagick" && { 
-echo $ac_n "checking for MogrifyImage in -lMagick""... $ac_c" 1>&6
-echo "configure:6419: checking for MogrifyImage in -lMagick" >&5
-ac_lib_var=`echo Magick'_'MogrifyImage | sed 'y%./+-%__p_%'`
-
-xe_check_libs=" -lMagick "
-cat > conftest.$ac_ext <<EOF
-#line 6424 "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 MogrifyImage();
-
-int main() {
-MogrifyImage()
-; return 0; }
-EOF
-if { (eval echo configure:6435: \"$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_imagick=no
-fi
-
- }
-  test -z "$with_imagick" && with_imagick=yes
-  if test "$with_imagick" = "yes"; then
-    { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining HAVE_IMAGEMAGICK
-EOF
-cat >> confdefs.h <<\EOF
-#define HAVE_IMAGEMAGICK 1
-EOF
-}
-
-    libs_x="-lMagick $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lMagick\" to \$libs_x"; fi
-  fi
-
     
 echo $ac_n "checking for XawScrollbarSetThumb in -lXaw""... $ac_c" 1>&6
-echo "configure:6471: checking for XawScrollbarSetThumb in -lXaw" >&5
+echo "configure:6185: 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 6476 "configure"
+#line 6190 "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
@@ -6483,7 +6197,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:6487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6201: \"$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
@@ -6507,15 +6221,15 @@
                     
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:6511: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6514 "configure"
+echo "configure:6225: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6228 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6233: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6532,12 +6246,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:6536: checking for XmStringFree in -lXm" >&5
+echo "configure:6250: 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 6541 "configure"
+#line 6255 "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
@@ -6548,7 +6262,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:6552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6266: \"$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
@@ -6800,12 +6514,27 @@
 fi
 
 
-test -z "$with_mule" && with_mule=no
-
+test -z "$with_mule" && with_mule=no 
+test -z "$with_mule_coding" && with_mule_coding=no
+
+
+if test "$with_mule_coding" = "yes" && test "$with_mule" = "no"; then
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining MULE_CODING
+EOF
+cat >> confdefs.h <<\EOF
+#define MULE_CODING 1
+EOF
+}
+
+  extra_objs="$extra_objs mule-coding.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"mule-coding.o\""
+ fi
+fi
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:6809: checking for Mule-related features" >&5
+echo "configure:6538: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -6814,6 +6543,14 @@
 EOF
 }
 
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining MULE_CODING
+EOF
+cat >> confdefs.h <<\EOF
+#define MULE_CODING 1
+EOF
+}
+
   extra_objs="$extra_objs mule.o mule-ccl.o mule-charset.o mule-coding.o" &&  if test "$extra_verbose" = "yes"; then
    echo "    xemacs will be linked with \"mule.o mule-ccl.o mule-charset.o mule-coding.o\""
  fi
@@ -6822,15 +6559,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6826: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6829 "configure"
+echo "configure:6563: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6566 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6834: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6571: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6861,12 +6598,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:6865: checking for strerror in -lintl" >&5
+echo "configure:6602: 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 6870 "configure"
+#line 6607 "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
@@ -6877,7 +6614,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:6881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6618: \"$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
@@ -6910,19 +6647,19 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:6914: checking for Mule input methods" >&5
+echo "configure:6651: 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:6918: checking for XIM" >&5
+echo "configure:6655: checking for XIM" >&5
     
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:6921: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:6658: 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 6926 "configure"
+#line 6663 "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
@@ -6933,7 +6670,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:6937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6674: \"$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
@@ -6998,15 +6735,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:7002: checking for XFontSet" >&5
+echo "configure:6739: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:7005: checking for XmbDrawString in -lX11" >&5
+echo "configure:6742: 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 7010 "configure"
+#line 6747 "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
@@ -7017,7 +6754,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:7021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6758: \"$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
@@ -7057,15 +6794,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:7061: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7064 "configure"
+echo "configure:6798: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6801 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7069: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6806: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7090,10 +6827,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7094: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7097 "configure"
+echo "configure:6831: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6834 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7116,7 +6853,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7145,12 +6882,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:7149: checking for crypt in -lcrypt" >&5
+echo "configure:6886: 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 7154 "configure"
+#line 6891 "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
@@ -7161,7 +6898,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:7165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6902: \"$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
@@ -7195,12 +6932,12 @@
   fi
     test -z "$with_wnn" && { 
 echo $ac_n "checking for jl_dic_list_e in -lwnn""... $ac_c" 1>&6
-echo "configure:7199: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:6936: 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 7204 "configure"
+#line 6941 "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
@@ -7211,7 +6948,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:7215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6952: \"$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
@@ -7248,12 +6985,12 @@
  fi
     
 echo $ac_n "checking for jl_fi_dic_list in -lwnn""... $ac_c" 1>&6
-echo "configure:7252: checking for jl_fi_dic_list in -lwnn" >&5
+echo "configure:6989: 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 7257 "configure"
+#line 6994 "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
@@ -7264,7 +7001,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:7268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7005: \"$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
@@ -7296,15 +7033,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:7300: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7303 "configure"
+echo "configure:7037: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7040 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7308: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7327,12 +7064,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:7331: checking for RkBgnBun in -lRKC" >&5
+echo "configure:7068: 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 7336 "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
@@ -7343,7 +7080,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:7347: \"$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
@@ -7366,12 +7103,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:7370: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:7107: 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 7375 "configure"
+#line 7112 "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
@@ -7382,7 +7119,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:7386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7123: \"$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
@@ -7431,12 +7168,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:7435: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:7172: 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 7440 "configure"
+#line 7177 "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
@@ -7447,7 +7184,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:7451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7188: \"$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
@@ -7520,10 +7257,10 @@
 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
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7524: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7527 "configure"
+echo "configure:7261: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7264 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7546,7 +7283,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7583,10 +7320,10 @@
     for ac_func in realpath
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7587: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7590 "configure"
+echo "configure:7324: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7327 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7609,7 +7346,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7642,16 +7379,16 @@
 esac
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:7646: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7648 "configure"
+echo "configure:7383: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7385 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:7655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7392: \"$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
@@ -7671,16 +7408,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:7675: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7677 "configure"
+echo "configure:7412: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7414 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:7684: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7421: \"$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
@@ -7700,11 +7437,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:7704: checking whether localtime caches TZ" >&5
+echo "configure:7441: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 7708 "configure"
+#line 7445 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -7739,7 +7476,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:7743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -7768,9 +7505,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday cannot accept two arguments""... $ac_c" 1>&6
-echo "configure:7772: checking whether gettimeofday cannot accept two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7774 "configure"
+echo "configure:7509: checking whether gettimeofday cannot accept two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7511 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -7792,7 +7529,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 else
@@ -7814,19 +7551,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:7818: checking for inline" >&5
+echo "configure:7555: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 7823 "configure"
+#line 7560 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:7830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -7876,17 +7613,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:7880: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7883 "configure"
+echo "configure:7617: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7620 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:7890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -7910,10 +7647,10 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:7914: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7917 "configure"
+echo "configure:7651: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7654 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -7936,7 +7673,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:7940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -7975,10 +7712,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:7979: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7982 "configure"
+echo "configure:7716: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7719 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -8002,10 +7739,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:8006: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8009 "configure"
+echo "configure:7743: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7746 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8028,7 +7765,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8058,10 +7795,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:8062: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8065 "configure"
+echo "configure:7799: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7802 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -8080,7 +7817,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:8084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -8108,15 +7845,15 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:8112: checking for vfork.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8115 "configure"
+echo "configure:7849: checking for vfork.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7852 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7857: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8144,10 +7881,10 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:8148: checking for working vfork" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8151 "configure"
+echo "configure:7885: checking for working vfork" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7888 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -8242,7 +7979,7 @@
   }
 }
 EOF
-if { (eval echo configure:8246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_vfork_works=yes
 else
@@ -8267,10 +8004,10 @@
 
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:8271: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8274 "configure"
+echo "configure:8008: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8011 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -8280,7 +8017,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:8284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -8307,10 +8044,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8311: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8314 "configure"
+echo "configure:8048: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8051 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8333,7 +8070,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8361,10 +8098,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:8365: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8368 "configure"
+echo "configure:8102: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8105 "configure"
 #include "confdefs.h"
 
 /*
@@ -8419,7 +8156,7 @@
 }
 
 EOF
-if { (eval echo configure:8423: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -8445,10 +8182,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:8449: checking for working mmap" >&5
+echo "configure:8186: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 8452 "configure"
+#line 8189 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -8481,7 +8218,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:8485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   have_mmap=yes
 else
@@ -8515,15 +8252,15 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:8519: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8522 "configure"
+echo "configure:8256: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8259 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8527: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8264: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8566,15 +8303,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:8570: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8573 "configure"
+echo "configure:8307: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8310 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8578: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8606,10 +8343,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:8610: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8613 "configure"
+echo "configure:8347: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8350 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -8632,7 +8369,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -8647,15 +8384,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:8651: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8654 "configure"
+echo "configure:8388: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8391 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8659: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8396: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8672,15 +8409,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:8676: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8679 "configure"
+echo "configure:8413: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8416 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8684: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8705,9 +8442,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:8709: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:8446: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 8711 "configure"
+#line 8448 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -8718,7 +8455,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:8722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8459: \"$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
@@ -8749,10 +8486,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:8753: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8756 "configure"
+echo "configure:8490: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8493 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -8775,7 +8512,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_msgget=yes"
 else
@@ -8790,15 +8527,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:8794: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8797 "configure"
+echo "configure:8531: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8534 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8539: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8815,15 +8552,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:8819: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8822 "configure"
+echo "configure:8556: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8559 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8564: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8861,15 +8598,15 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:8865: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8868 "configure"
+echo "configure:8602: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8605 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8896,15 +8633,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:8900: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8903 "configure"
+echo "configure:8637: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8640 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8937,15 +8674,15 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:8941: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8944 "configure"
+echo "configure:8678: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8681 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8686: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8975,7 +8712,7 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:8979: checking "for sound support"" >&5
+echo "configure:8716: checking "for sound support"" >&5
 case "$with_sound" in
   native | both ) with_native_sound=yes;;
   nas    | no   ) with_native_sound=no;;
@@ -8986,15 +8723,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:8990: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8993 "configure"
+echo "configure:8727: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8730 "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:8998: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9042,12 +8779,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:9046: checking for ALopenport in -laudio" >&5
+echo "configure:8783: 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 9051 "configure"
+#line 8788 "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
@@ -9058,7 +8795,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:9062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8799: \"$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
@@ -9089,12 +8826,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:9093: checking for AOpenAudio in -lAlib" >&5
+echo "configure:8830: 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 9098 "configure"
+#line 8835 "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
@@ -9105,7 +8842,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:9109: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8846: \"$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
@@ -9143,15 +8880,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:9147: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9150 "configure"
+echo "configure:8884: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8887 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9221,7 +8958,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 9225 "configure"
+#line 8962 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -9248,7 +8985,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:9252: checking for TTY-related features" >&5
+echo "configure:8989: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -9264,12 +9001,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:9268: checking for tgetent in -lncurses" >&5
+echo "configure:9005: 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 9273 "configure"
+#line 9010 "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
@@ -9280,7 +9017,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9021: \"$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
@@ -9313,15 +9050,15 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:9317: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9320 "configure"
+echo "configure:9054: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9057 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9325: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9343,15 +9080,15 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:9347: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9350 "configure"
+echo "configure:9084: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9087 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9355: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9092: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9381,15 +9118,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:9385: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9388 "configure"
+echo "configure:9122: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9125 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9393: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9130: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9424,12 +9161,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:9428: checking for tgetent in -l$lib" >&5
+echo "configure:9165: 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 9433 "configure"
+#line 9170 "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
@@ -9440,7 +9177,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9181: \"$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
@@ -9471,12 +9208,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:9475: checking for tgetent in -lcurses" >&5
+echo "configure:9212: 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 9480 "configure"
+#line 9217 "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
@@ -9487,7 +9224,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9228: \"$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
@@ -9505,12 +9242,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:9509: checking for tgetent in -ltermcap" >&5
+echo "configure:9246: 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 9514 "configure"
+#line 9251 "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
@@ -9521,7 +9258,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9262: \"$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
@@ -9569,15 +9306,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:9573: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9576 "configure"
+echo "configure:9310: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9313 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9581: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9318: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9600,12 +9337,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:9604: checking for Gpm_Open in -lgpm" >&5
+echo "configure:9341: 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 9609 "configure"
+#line 9346 "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
@@ -9616,7 +9353,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:9620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9357: \"$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
@@ -9665,17 +9402,17 @@
 
 
 echo "checking for database support" 1>&6
-echo "configure:9669: checking for database support" >&5
+echo "configure:9406: checking for database support" >&5
 
 if test "$with_database_gnudbm" != "no"; then
   
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:9674: checking for dbm_open in -lgdbm" >&5
+echo "configure:9411: 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 9679 "configure"
+#line 9416 "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
@@ -9686,7 +9423,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9427: \"$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
@@ -9708,10 +9445,10 @@
 
   if test "$with_database_gnudbm" != "yes"; then
     echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9712: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9715 "configure"
+echo "configure:9449: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9452 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9734,7 +9471,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9770,10 +9507,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9774: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9777 "configure"
+echo "configure:9511: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9514 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9796,7 +9533,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9817,12 +9554,12 @@
   if test "$need_libdbm" != "no"; then
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:9821: checking for dbm_open in -ldbm" >&5
+echo "configure:9558: 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 9826 "configure"
+#line 9563 "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
@@ -9833,7 +9570,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9574: \"$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
@@ -9870,10 +9607,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:9874: checking for dbopen" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9877 "configure"
+echo "configure:9611: checking for dbopen" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9614 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbopen(); below.  */
@@ -9896,7 +9633,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbopen=yes"
 else
@@ -9917,12 +9654,12 @@
   if test "$need_libdb" != "no"; then
     
 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:9921: checking for dbopen in -ldb" >&5
+echo "configure:9658: 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 9926 "configure"
+#line 9663 "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
@@ -9933,7 +9670,7 @@
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:9937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9674: \"$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
@@ -9957,7 +9694,7 @@
   if test "$with_database_berkdb" = "yes"; then
     for path in "db/db.h" "db.h"; do
 cat > conftest.$ac_ext <<EOF
-#line 9961 "configure"
+#line 9698 "configure"
 #include "confdefs.h"
 #ifdef HAVE_INTTYPES_H
 #define __BIT_TYPES_DEFINED__
@@ -9975,7 +9712,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:9716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_path="$path"; break
 else
@@ -10027,12 +9764,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:10031: checking for SOCKSinit in -lsocks" >&5
+echo "configure:9768: 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 10036 "configure"
+#line 9773 "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
@@ -10043,7 +9780,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:10047: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9784: \"$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
@@ -10553,8 +10290,10 @@
   echo "  --------------------------------------------------------------------"
 fi
 test "$with_xface" = yes && echo "  Compiling in support for X-Face message headers."
-test "$with_imagick"  = yes && echo "  Compiling in support for ImageMagick image conversion."
-test "$with_imagick" = yes && echo "   Using $imagick_libs for graphics libraries."
+test "$with_gif"   = yes && echo "  Compiling in (built 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)."
 case "$with_sound" in
   nas    ) echo "  Compiling in network sound (NAS) support." ;;
   native ) echo "  Compiling in native sound support." ;;
@@ -10570,6 +10309,7 @@
 test "$with_gpm"      = yes && echo "  Compiling in support for GPM (General Purpose Mouse)."
 
 test "$with_mule"     = yes && echo "  Compiling in Mule (multi-lingual) support."
+test "$with_mule_coding"     = yes && echo "  Compiling in Mule coding support."
 test "$with_xim"      != no && echo "  Compiling in XIM (X11R5+ I18N input method) support."
 test "$with_xim" = motif    && echo "    Using Motif to provide XIM support."
 test "$with_xim" = xlib     && echo "    Using raw Xlib to provide XIM support."
--- a/configure.in	Mon Aug 13 10:19:12 2007 +0200
+++ b/configure.in	Mon Aug 13 10:19:59 2007 +0200
@@ -344,6 +344,7 @@
 with_menubars=''
 with_scrollbars=''
 with_dialogs=''
+with_mule_coding=''
 const_is_losing='yes'
 puresize=''
 cflags='UNSPECIFIED'
@@ -357,6 +358,7 @@
 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=""
@@ -456,7 +458,10 @@
 	with_gpm	| \
 	with_xpm	| \
 	with_xface	| \
-	with_imagick	| \
+	with_gif	| \
+	with_jpeg	| \
+	with_png	| \
+	with_tiff	| \
 	with_session	| \
 	with_xmu	| \
 	with_quantify	| \
@@ -465,6 +470,7 @@
 	with_xfs	| \
 	with_i18n3	| \
 	with_mule	| \
+	with_mule_coding	| \
 	with_canna	| \
 	with_wnn	| \
 	with_wnn6	| \
@@ -1938,7 +1944,7 @@
 dnl checks for header files
 AC_CHECK_HEADERS(mach/mach.h sys/stropts.h sys/timeb.h sys/time.h unistd.h)
 AC_CHECK_HEADERS(utime.h locale.h libgen.h fcntl.h ulimit.h)
-AC_CHECK_HEADERS(linux/version.h kstat.h sys/pstat.h inttypes.h sys/un.h coff.h)
+AC_CHECK_HEADERS(linux/version.h kstat.h sys/pstat.h inttypes.h sys/un.h a.out.h)
 AC_HEADER_SYS_WAIT
 AC_HEADER_STDC
 AC_HEADER_TIME
@@ -2113,19 +2119,21 @@
   no  ) window_system=none HAVE_X_WINDOWS=no  ;;
 esac
 
-if test "$window_system" = "none"; then
+if test "$window_system" = "none" && test -z "$with_tty"; then
   AC_CHECKING(for MS-Windows)
   AC_CHECK_LIB(gdi32,main,have_msw=yes)
   if test "$have_msw" = "yes"; then
     AC_DEFINE(HAVE_MS_WINDOWS)
-    XE_APPEND(-lgdi32 -luser32, libs_system)
+    XE_APPEND(-lshell32 -lgdi32 -luser32, libs_system)
     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
     with_tty=no
-    XE_ADD_OBJS(console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o)
+    const_is_losing=no
+    #with_mule_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 gif_err.o gifalloc.o dgif_lib.o)
   fi
 fi
 
@@ -2274,7 +2282,7 @@
   fi
   for feature in tooltalk cde offix session \
                  menubars scrollbars toolbars dialogs xim xmu \
-                 imagick xface xpm
+                 tiff png jpeg gif xface xpm
   do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
        AC_MSG_WARN([--with-$feature ignored:  Not valid without X support])
@@ -2411,36 +2419,50 @@
     XE_PREPEND(-lcompface, libs_x)
   fi
 
-  dnl autodetect ImageMagick
-  test "$with_imagick" != "no" && { AC_CHECK_HEADER(magick/magick.h, ,AC_CHECK_HEADER(X11/magick/magick.h,AC_DEFINE(MAGICK_HEADERS_ARE_UNDER_X11),with_imagick=no)) }
-  test "$with_imagick" != "no" && {
-    dnl check the appropriate libraries for ImageMagick
-    dnl First, let's check libz or libgz for png...
-    z_libs=""
-    AC_CHECK_LIB(z, inflateInit_, XE_APPEND(-lz, z_libs),
-      AC_CHECK_LIB(gz, inflateInit_, XE_APPEND(-lgz, z_libs)))
-
-    imagick_libs=""
-    AC_CHECK_LIB(dps, XDPSPixelsPerPoint, XE_APPEND(-ldpstk -ldps, imagick_libs),,,-ldpstk)
-    AC_CHECK_LIB(fpx, FPX_SetToolkitMemoryLimit, XE_APPEND(-lfpx, imagick_libs))
-    AC_CHECK_LIB(df, DF24getdims, XE_APPEND(-ldf, imagick_libs))
-    AC_CHECK_LIB(jbig, jbg_dec_init, XE_APPEND(-ljbig, imagick_libs))
-    AC_CHECK_LIB(jpeg, jpeg_read_header, XE_APPEND(-ljpeg, imagick_libs))
-    AC_CHECK_LIB(mpeg, OpenMPEG, XE_APPEND(-lmpeg, imagick_libs))
-    AC_CHECK_LIB(ttf, TT_Init_FreeType, XE_APPEND(-lttf, imagick_libs))
-    AC_CHECK_LIB(png, png_create_read_struct, XE_APPEND(-lpng, imagick_libs),,$z_libs)
-    AC_CHECK_LIB(tiff, TIFFOpen, XE_APPEND(-ltiff, imagick_libs),
-      AC_CHECK_LIB(tiff, TIFFOpen, XE_APPEND(-ltiff -ljpeg, imagick_libs),,-ljpeg $z_libs),,$z_libs)
-    XE_APPEND($z_libs, imagick_libs)
-    XE_APPEND($imagick_libs, libs_x)
-  }
-  test -z "$with_imagick" && { AC_CHECK_LIB(Magick, MogrifyImage,[:],with_imagick=no) }
-  test -z "$with_imagick" && with_imagick=yes
-  if test "$with_imagick" = "yes"; then
-    AC_DEFINE(HAVE_IMAGEMAGICK)
-    XE_PREPEND(-lMagick, libs_x)
+  dnl Built-in GIF support defaults to yes (note: this will be libraried soon)
+  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)
+  fi
+
+  dnl autodetect JPEG
+  test -z "$with_jpeg" && { AC_CHECK_HEADER(jpeglib.h,                    ,with_jpeg=no) }
+  test -z "$with_jpeg" && { AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,[:],with_jpeg=no) }
+  test -z "$with_jpeg" && with_jpeg=yes
+  if test "$with_jpeg" = "yes"; then
+    AC_DEFINE(HAVE_JPEG)
+    XE_PREPEND(-ljpeg, libs_x)
   fi
 
+  dnl autodetect PNG
+  test -z "$with_png" && { AC_CHECK_HEADER(png.h, , with_png=no) }
+  test -z "$with_png" && { AC_CHECK_FUNC(pow,     , with_png=no) }
+  if test "$with_png" != "no"; then
+    for extra_libs in "" "-lz" "-lgz"; do
+      AC_CHECK_LIB(png, png_read_image,
+	png_libs="-lpng $extra_libs" with_png=yes; break,[:],$extra_libs)
+    done
+  fi
+  test -z "$with_png" && with_png=no
+  if test "$with_png" = "yes"; then
+    AC_DEFINE(HAVE_PNG)
+    XE_PREPEND($png_libs, libs_x)
+  fi
+
+  dnl autodetect TIFF
+  if test "$with_tiff" != no; then
+    for extra_libs in "" "-lz" "-lgz"; do
+      AC_CHECK_LIB(tiff, TIFFReadScanline, 
+        tiff_libs="-ltiff $extra_libs" with_tiff=yes; break, [:], $extra_libs)
+    done
+  fi
+  test -z "$with_tiff" && with_tiff=no
+  if test "$with_tiff" = "yes"; then
+    AC_DEFINE(HAVE_TIFF)
+    XE_PREPEND($tiff_libs, libs_x)
+  fi
+    
   dnl Autodetect -lXaw
   AC_CHECK_LIB(Xaw, XawScrollbarSetThumb, have_xaw=yes, have_xaw=no)
   dnl if test "$have_xaw" = "yes"; then
@@ -2540,7 +2562,8 @@
 dnl Mule-dependent options
 dnl ----------------------
 
-test -z "$with_mule" && with_mule=no
+test -z "$with_mule" && with_mule=no 
+test -z "$with_mule_coding" && with_mule_coding=no
 
 dnl if test "$with_mule" = "yes" && test ! -d "$srcdir/lisp/mule"; then
 dnl	echo "Attempt to Build with Mule without Mule/Lisp"
@@ -2549,9 +2572,15 @@
 dnl	exit 1
 dnl fi
 
+if test "$with_mule_coding" = "yes" && test "$with_mule" = "no"; then
+  AC_DEFINE(MULE_CODING)
+  XE_ADD_OBJS(mule-coding.o)
+fi
+
 if test "$with_mule" = "yes" ; then
   AC_CHECKING(for Mule-related features)
   AC_DEFINE(MULE)
+  AC_DEFINE(MULE_CODING)
   XE_ADD_OBJS(mule.o mule-ccl.o mule-charset.o mule-coding.o)
 
   dnl Use -lintl to get internationalized strerror for Mule
@@ -3369,8 +3398,10 @@
   echo "  --------------------------------------------------------------------"
 fi
 test "$with_xface" = yes && echo "  Compiling in support for X-Face message headers."
-test "$with_imagick"  = yes && echo "  Compiling in support for ImageMagick image conversion."
-test "$with_imagick" = yes && echo "   Using $imagick_libs for graphics libraries."
+test "$with_gif"   = yes && echo "  Compiling in (built 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)."
 case "$with_sound" in
   nas    ) echo "  Compiling in network sound (NAS) support." ;;
   native ) echo "  Compiling in native sound support." ;;
@@ -3386,6 +3417,7 @@
 test "$with_gpm"      = yes && echo "  Compiling in support for GPM (General Purpose Mouse)."
 
 test "$with_mule"     = yes && echo "  Compiling in Mule (multi-lingual) support."
+test "$with_mule_coding"     = yes && echo "  Compiling in Mule coding support."
 test "$with_xim"      != no && echo "  Compiling in XIM (X11R5+ I18N input method) support."
 test "$with_xim" = motif    && echo "    Using Motif to provide XIM support."
 test "$with_xim" = xlib     && echo "    Using raw Xlib to provide XIM support."
--- a/etc/NEWS	Mon Aug 13 10:19:12 2007 +0200
+++ b/etc/NEWS	Mon Aug 13 10:19:59 2007 +0200
@@ -102,6 +102,18 @@
 or the native C libraries support Japanese localization.  This has
 been available since 20.3, only it hasn't been announced before.
 
+** In Text mode, now only blank lines separate paragraphs.
+This makes it possible to get the full benefit of Adaptive Fill mode
+in Text mode, and other modes derived from it (such as Mail mode).
+TAB in Text mode now runs the command indent-relative; this
+makes a practical difference only when you use indented paragraphs.
+
+As a result, the old Indented Text mode is now identical to Text mode,
+and is an alias for it.
+
+If you want spaces at the beginning of a line to start a paragraph,
+use the new mode, Paragraph Indent Text mode.
+
 
 * Lisp and internal changes in XEmacs 20.5
 ==========================================
@@ -111,10 +123,6 @@
 -DUSE_MINIMAL_TAGBITS to test.  With this change, the maximum buffer
 size on 32-bit machines is bumped from 128M to 1G.
 
-** The internal image code now uses the ImageMagick library as an
-interface to various image-related functions.  You still need the
-other libraries to build the image support, though.
-
 ** The XEmacs hashtables now have a consistent read/print syntax.
 This means that a hashtable will be readably printed in a
 structure-like form:
--- a/lib-src/make-docfile.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/lib-src/make-docfile.c	Mon Aug 13 10:19:59 2007 +0200
@@ -52,7 +52,7 @@
 
 #include <sys/param.h>
 
-#ifdef MSDOS
+#if defined(MSDOS) || defined(__CYGWIN32__)
 #include <fcntl.h>
 #endif /* MSDOS */
 #ifdef WINDOWSNT
@@ -61,12 +61,16 @@
 #include <direct.h>
 #endif /* WINDOWSNT */
 
-#ifdef DOS_NT
+#if defined(DOS_NT) || defined(__CYGWIN32__)
 #define READ_TEXT "rt"
 #define READ_BINARY "rb"
+#define WRITE_BINARY "wb"
+#define APPEND_BINARY "ab"
 #else  /* not DOS_NT */
 #define READ_TEXT "r"
 #define READ_BINARY "r"
+#define WRITE_BINARY "w"
+#define APPEND_BINARY "a"
 #endif /* not DOS_NT */
 
 #ifdef MSDOS
@@ -143,7 +147,7 @@
   if (!fp) {
     if (!extra_elcs) {
       return NULL;
-    } else if (!(fp = fopen(extra_elcs, "r"))) {
+    } else if (!(fp = fopen(extra_elcs, READ_BINARY))) {
       /* It is not an error if this file doesn't exist. */
       /*fatal("error opening site package file list", 0);*/
       return NULL;
@@ -200,12 +204,12 @@
   i = 1;
   if (argc > i + 1 && !strcmp (argv[i], "-o"))
     {
-      outfile = fopen (argv[i + 1], "w");
+      outfile = fopen (argv[i + 1], WRITE_BINARY);
       i += 2;
     }
   if (argc > i + 1 && !strcmp (argv[i], "-a"))
     {
-      outfile = fopen (argv[i + 1], "a");
+      outfile = fopen (argv[i + 1], APPEND_BINARY);
       i += 2;
     }
   if (argc > i + 1 && !strcmp (argv[i], "-d"))
--- a/lisp/ChangeLog	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/ChangeLog	Mon Aug 13 10:19:59 2007 +0200
@@ -1,3 +1,69 @@
+1998-02-09  SL Baur  <steve@altair.xemacs.org>
+
+	* package-get-base.el (package-get-base): Updated.
+
+	* keymap.el: PC-ize.
+
+1998-02-08  Karl M. Hegbloom  <karlheg@bittersweet.inetarena.com>
+
+	* hyper-apropos.el (hyper-apropos-get-doc): Print the `loaded
+	from' on a fresh line.
+
+1998-02-08  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* help.el (help-maybe-pretty-print-value): prin1, not princ the
+	object.
+
+1998-02-09  SL Baur  <steve@altair.xemacs.org>
+
+	* undo-stack.el: PC-ize.
+
+	* cmdloop.el: PC-ize.
+
+1998-02-08  SL Baur  <steve@altair.xemacs.org>
+
+	* bytecomp-runtime.el: PC-ize.
+
+	* byte-optimize.el: Prolog fixup.  PC-ize.
+
+	* cus-dep.el: Spelling fix.
+
+	* text-mode.el: Synch with Emacs 20.2.  (Original ChangeLog
+	entries follow).
+
+1997-08-29  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+	* text-mode.el (text-mode-hook-identify): New function,
+	put on text-mode-hook.  Set text-mode-variant here.
+	(text-mode): Don't set it here.
+
+1997-08-27  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+	* text-mode.el (text-mode-hook): New defvar.
+	(text-mode-variant): New variable.
+	(text-mode): Set that variable locally.
+	(toggle-text-mode-auto-fill): New command.
+
+1997-06-15  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+	* text-mode.el (text-mode): Let all-white lines separate paragraphs.
+	
+1997-06-11  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+	* text-mode.el (paragraph-indent-text-mode):
+	Renamed from spaced-text-mode.
+	(text-mode-map): Bind TAB to indent-relative.
+	(indented-text-mode-map): Variable deleted.
+	(indented-text-mode): Now an alias for text-mode.
+
+1998-02-05  SL Baur  <steve@altair.xemacs.org>
+
+	* loadup.el: test-atoms debugging stuffs removed.
+
+1998-02-03  Martin Buchholz  <Martin Buchholz <martin@xemacs.org>>
+
+	* lisp/loaddefs.el (completion-ignored-extensions): Add ".class"
+
 1997-12-30  Colin Rafferty  <colin@xemacs.org>
 
 	* help.el (describe-beta): Made it use `locate-data-file'.
--- a/lisp/byte-optimize.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/byte-optimize.el	Mon Aug 13 10:19:59 2007 +0200
@@ -27,168 +27,166 @@
 
 ;;; Commentary:
 
-;;; ========================================================================
-;;; "No matter how hard you try, you can't make a racehorse out of a pig.
-;;; You can, however, make a faster pig."
-;;;
-;;; Or, to put it another way, the emacs byte compiler is a VW Bug.  This code
-;;; makes it be a VW Bug with fuel injection and a turbocharger...  You're 
-;;; still not going to make it go faster than 70 mph, but it might be easier
-;;; to get it there.
-;;;
+;; ========================================================================
+;; "No matter how hard you try, you can't make a racehorse out of a pig.
+;; You can, however, make a faster pig."
+;;
+;; Or, to put it another way, the emacs byte compiler is a VW Bug.  This code
+;; makes it be a VW Bug with fuel injection and a turbocharger...  You're 
+;; still not going to make it go faster than 70 mph, but it might be easier
+;; to get it there.
+;;
 
-;;; TO DO:
-;;;
-;;; (apply '(lambda (x &rest y) ...) 1 (foo))
-;;;
-;;; maintain a list of functions known not to access any global variables
-;;; (actually, give them a 'dynamically-safe property) and then
-;;;   (let ( v1 v2 ... vM vN ) <...dynamically-safe...> )  ==>
-;;;   (let ( v1 v2 ... vM ) vN <...dynamically-safe...> )
-;;; by recursing on this, we might be able to eliminate the entire let.
-;;; However certain variables should never have their bindings optimized
-;;; away, because they affect everything.
-;;;   (put 'debug-on-error 'binding-is-magic t)
-;;;   (put 'debug-on-abort 'binding-is-magic t)
-;;;   (put 'debug-on-next-call 'binding-is-magic t)
-;;;   (put 'mocklisp-arguments 'binding-is-magic t)
-;;;   (put 'inhibit-quit 'binding-is-magic t)
-;;;   (put 'quit-flag 'binding-is-magic t)
-;;;   (put 't 'binding-is-magic t)
-;;;   (put 'nil 'binding-is-magic t)
-;;; possibly also
-;;;   (put 'gc-cons-threshold 'binding-is-magic t)
-;;;   (put 'track-mouse 'binding-is-magic t)
-;;; others?
-;;;
-;;; Simple defsubsts often produce forms like
-;;;    (let ((v1 (f1)) (v2 (f2)) ...)
-;;;       (FN v1 v2 ...))
-;;; It would be nice if we could optimize this to 
-;;;    (FN (f1) (f2) ...)
-;;; but we can't unless FN is dynamically-safe (it might be dynamically
-;;; referring to the bindings that the lambda arglist established.)
-;;; One of the uncountable lossages introduced by dynamic scope...
-;;;
-;;; Maybe there should be a control-structure that says "turn on 
-;;; fast-and-loose type-assumptive optimizations here."  Then when
-;;; we see a form like (car foo) we can from then on assume that
-;;; the variable foo is of type cons, and optimize based on that.
-;;; But, this won't win much because of (you guessed it) dynamic 
-;;; scope.  Anything down the stack could change the value.
-;;; (Another reason it doesn't work is that it is perfectly valid
-;;; to call car with a null argument.)  A better approach might
-;;; be to allow type-specification of the form
-;;;   (put 'foo 'arg-types '(float (list integer) dynamic))
-;;;   (put 'foo 'result-type 'bool)
-;;; It should be possible to have these types checked to a certain
-;;; degree.
-;;;
-;;; collapse common subexpressions
-;;;
-;;; It would be nice if redundant sequences could be factored out as well,
-;;; when they are known to have no side-effects:
-;;;   (list (+ a b c) (+ a b c))   -->  a b add c add dup list-2
-;;; but beware of traps like
-;;;   (cons (list x y) (list x y))
-;;;
-;;; Tail-recursion elimination is not really possible in Emacs Lisp.
-;;; Tail-recursion elimination is almost always impossible when all variables
-;;; have dynamic scope, but given that the "return" byteop requires the
-;;; binding stack to be empty (rather than emptying it itself), there can be
-;;; no truly tail-recursive Emacs Lisp functions that take any arguments or
-;;; make any bindings.
-;;;
-;;; Here is an example of an Emacs Lisp function which could safely be
-;;; byte-compiled tail-recursively:
-;;;
-;;;  (defun tail-map (fn list)
-;;;    (cond (list
-;;;           (funcall fn (car list))
-;;;           (tail-map fn (cdr list)))))
-;;;
-;;; However, if there was even a single let-binding around the COND,
-;;; it could not be byte-compiled, because there would be an "unbind"
-;;; byte-op between the final "call" and "return."  Adding a 
-;;; Bunbind_all byteop would fix this.
-;;;
-;;;   (defun foo (x y z) ... (foo a b c))
-;;;   ... (const foo) (varref a) (varref b) (varref c) (call 3) END: (return)
-;;;   ... (varref a) (varbind x) (varref b) (varbind y) (varref c) (varbind z) (goto 0) END: (unbind-all) (return)
-;;;   ... (varref a) (varset x) (varref b) (varset y) (varref c) (varset z) (goto 0) END: (return)
-;;;
-;;; this also can be considered tail recursion:
-;;;
-;;;   ... (const foo) (varref a) (call 1) (goto X) ... X: (return)
-;;; could generalize this by doing the optimization
-;;;   (goto X) ... X: (return)  -->  (return)
-;;;
-;;; But this doesn't solve all of the problems: although by doing tail-
-;;; recursion elimination in this way, the call-stack does not grow, the
-;;; binding-stack would grow with each recursive step, and would eventually
-;;; overflow.  I don't believe there is any way around this without lexical
-;;; scope.
-;;;
-;;; Wouldn't it be nice if Emacs Lisp had lexical scope.
-;;;
-;;; Idea: the form (lexical-scope) in a file means that the file may be 
-;;; compiled lexically.  This proclamation is file-local.  Then, within 
-;;; that file, "let" would establish lexical bindings, and "let-dynamic"
-;;; would do things the old way.  (Or we could use CL "declare" forms.)
-;;; We'd have to notice defvars and defconsts, since those variables should
-;;; always be dynamic, and attempting to do a lexical binding of them
-;;; should simply do a dynamic binding instead.
-;;; But!  We need to know about variables that were not necessarily defvarred
-;;; in the file being compiled (doing a boundp check isn't good enough.)
-;;; Fdefvar() would have to be modified to add something to the plist.
-;;;
-;;; A major disadvantage of this scheme is that the interpreter and compiler 
-;;; would have different semantics for files compiled with (dynamic-scope).  
-;;; Since this would be a file-local optimization, there would be no way to
-;;; modify the interpreter to obey this (unless the loader was hacked 
-;;; in some grody way, but that's a really bad idea.)
-;;;
-;;; HA! HA! HA!  RMS removed the following paragraph from his version of
-;;; byte-opt.el, proving once again his stubborn refusal to accept any
-;;; developments in computer science that occurred after the late 1970's.
-;;;
-;;; Really the Right Thing is to make lexical scope the default across
-;;; the board, in the interpreter and compiler, and just FIX all of 
-;;; the code that relies on dynamic scope of non-defvarred variables.
+;; TO DO:
+;;
+;; (apply '(lambda (x &rest y) ...) 1 (foo))
+;;
+;; maintain a list of functions known not to access any global variables
+;; (actually, give them a 'dynamically-safe property) and then
+;;   (let ( v1 v2 ... vM vN ) <...dynamically-safe...> )  ==>
+;;   (let ( v1 v2 ... vM ) vN <...dynamically-safe...> )
+;; by recursing on this, we might be able to eliminate the entire let.
+;; However certain variables should never have their bindings optimized
+;; away, because they affect everything.
+;;   (put 'debug-on-error 'binding-is-magic t)
+;;   (put 'debug-on-abort 'binding-is-magic t)
+;;   (put 'debug-on-next-call 'binding-is-magic t)
+;;   (put 'mocklisp-arguments 'binding-is-magic t)
+;;   (put 'inhibit-quit 'binding-is-magic t)
+;;   (put 'quit-flag 'binding-is-magic t)
+;;   (put 't 'binding-is-magic t)
+;;   (put 'nil 'binding-is-magic t)
+;; possibly also
+;;   (put 'gc-cons-threshold 'binding-is-magic t)
+;;   (put 'track-mouse 'binding-is-magic t)
+;; others?
+;;
+;; Simple defsubsts often produce forms like
+;;    (let ((v1 (f1)) (v2 (f2)) ...)
+;;       (FN v1 v2 ...))
+;; It would be nice if we could optimize this to 
+;;    (FN (f1) (f2) ...)
+;; but we can't unless FN is dynamically-safe (it might be dynamically
+;; referring to the bindings that the lambda arglist established.)
+;; One of the uncountable lossages introduced by dynamic scope...
+;;
+;; Maybe there should be a control-structure that says "turn on 
+;; fast-and-loose type-assumptive optimizations here."  Then when
+;; we see a form like (car foo) we can from then on assume that
+;; the variable foo is of type cons, and optimize based on that.
+;; But, this won't win much because of (you guessed it) dynamic 
+;; scope.  Anything down the stack could change the value.
+;; (Another reason it doesn't work is that it is perfectly valid
+;; to call car with a null argument.)  A better approach might
+;; be to allow type-specification of the form
+;;   (put 'foo 'arg-types '(float (list integer) dynamic))
+;;   (put 'foo 'result-type 'bool)
+;; It should be possible to have these types checked to a certain
+;; degree.
+;;
+;; collapse common subexpressions
+;;
+;; It would be nice if redundant sequences could be factored out as well,
+;; when they are known to have no side-effects:
+;;   (list (+ a b c) (+ a b c))   -->  a b add c add dup list-2
+;; but beware of traps like
+;;   (cons (list x y) (list x y))
+;;
+;; Tail-recursion elimination is not really possible in Emacs Lisp.
+;; Tail-recursion elimination is almost always impossible when all variables
+;; have dynamic scope, but given that the "return" byteop requires the
+;; binding stack to be empty (rather than emptying it itself), there can be
+;; no truly tail-recursive Emacs Lisp functions that take any arguments or
+;; make any bindings.
+;;
+;; Here is an example of an Emacs Lisp function which could safely be
+;; byte-compiled tail-recursively:
+;;
+;;  (defun tail-map (fn list)
+;;    (cond (list
+;;           (funcall fn (car list))
+;;           (tail-map fn (cdr list)))))
+;;
+;; However, if there was even a single let-binding around the COND,
+;; it could not be byte-compiled, because there would be an "unbind"
+;; byte-op between the final "call" and "return."  Adding a 
+;; Bunbind_all byteop would fix this.
+;;
+;;   (defun foo (x y z) ... (foo a b c))
+;;   ... (const foo) (varref a) (varref b) (varref c) (call 3) END: (return)
+;;   ... (varref a) (varbind x) (varref b) (varbind y) (varref c) (varbind z) (goto 0) END: (unbind-all) (return)
+;;   ... (varref a) (varset x) (varref b) (varset y) (varref c) (varset z) (goto 0) END: (return)
+;;
+;; this also can be considered tail recursion:
+;;
+;;   ... (const foo) (varref a) (call 1) (goto X) ... X: (return)
+;; could generalize this by doing the optimization
+;;   (goto X) ... X: (return)  -->  (return)
+;;
+;; But this doesn't solve all of the problems: although by doing tail-
+;; recursion elimination in this way, the call-stack does not grow, the
+;; binding-stack would grow with each recursive step, and would eventually
+;; overflow.  I don't believe there is any way around this without lexical
+;; scope.
+;;
+;; Wouldn't it be nice if Emacs Lisp had lexical scope.
+;;
+;; Idea: the form (lexical-scope) in a file means that the file may be 
+;; compiled lexically.  This proclamation is file-local.  Then, within 
+;; that file, "let" would establish lexical bindings, and "let-dynamic"
+;; would do things the old way.  (Or we could use CL "declare" forms.)
+;; We'd have to notice defvars and defconsts, since those variables should
+;; always be dynamic, and attempting to do a lexical binding of them
+;; should simply do a dynamic binding instead.
+;; But!  We need to know about variables that were not necessarily defvarred
+;; in the file being compiled (doing a boundp check isn't good enough.)
+;; Fdefvar() would have to be modified to add something to the plist.
+;;
+;; A major disadvantage of this scheme is that the interpreter and compiler 
+;; would have different semantics for files compiled with (dynamic-scope).  
+;; Since this would be a file-local optimization, there would be no way to
+;; modify the interpreter to obey this (unless the loader was hacked 
+;; in some grody way, but that's a really bad idea.)
+;;
+;; Opinions are mixed on the following paragraph.  -slb.
+;;
+;; Really the Right Thing is to make lexical scope the default across
+;; the board, in the interpreter and compiler, and just FIX all of 
+;; the code that relies on dynamic scope of non-defvarred variables.
 
 ;; Other things to consider:
 
-;;;;; Associative math should recognize subcalls to identical function:
-;;;(disassemble (lambda (x) (+ (+ (foo) 1) (+ (bar) 2))))
-;;;;; This should generate the same as (1+ x) and (1- x)
+;; Associative math should recognize subcalls to identical function:
+;;(disassemble (lambda (x) (+ (+ (foo) 1) (+ (bar) 2))))
+;; This should generate the same as (1+ x) and (1- x)
 
-;;;(disassemble (lambda (x) (cons (+ x 1) (- x 1))))
-;;;;; An awful lot of functions always return a non-nil value.  If they're
-;;;;; error free also they may act as true-constants.
+;;(disassemble (lambda (x) (cons (+ x 1) (- x 1))))
+;; An awful lot of functions always return a non-nil value.  If they're
+;; error free also they may act as true-constants.
 
-;;;(disassemble (lambda (x) (and (point) (foo))))
-;;;;; When 
-;;;;;   - all but one arguments to a function are constant
-;;;;;   - the non-constant argument is an if-expression (cond-expression?)
-;;;;; then the outer function can be distributed.  If the guarding
-;;;;; condition is side-effect-free [assignment-free] then the other
-;;;;; arguments may be any expressions.  Since, however, the code size
-;;;;; can increase this way they should be "simple".  Compare:
+;;(disassemble (lambda (x) (and (point) (foo))))
+;; When 
+;;   - all but one arguments to a function are constant
+;;   - the non-constant argument is an if-expression (cond-expression?)
+;; then the outer function can be distributed.  If the guarding
+;; condition is side-effect-free [assignment-free] then the other
+;; arguments may be any expressions.  Since, however, the code size
+;; can increase this way they should be "simple".  Compare:
 
-;;;(disassemble (lambda (x) (eq (if (point) 'a 'b) 'c)))
-;;;(disassemble (lambda (x) (if (point) (eq 'a 'c) (eq 'b 'c))))
+;;(disassemble (lambda (x) (eq (if (point) 'a 'b) 'c)))
+;;(disassemble (lambda (x) (if (point) (eq 'a 'c) (eq 'b 'c))))
 
-;;;;; (car (cons A B)) -> (progn B A)
-;;;(disassemble (lambda (x) (car (cons (foo) 42))))
+;; (car (cons A B)) -> (progn B A)
+;;(disassemble (lambda (x) (car (cons (foo) 42))))
 
-;;;;; (cdr (cons A B)) -> (progn A B)
-;;;(disassemble (lambda (x) (cdr (cons 42 (foo)))))
+;; (cdr (cons A B)) -> (progn A B)
+;;(disassemble (lambda (x) (cdr (cons 42 (foo)))))
 
-;;;;; (car (list A B ...)) -> (progn B ... A)
-;;;(disassemble (lambda (x) (car (list (foo) 42 (bar)))))
+;; (car (list A B ...)) -> (progn B ... A)
+;;(disassemble (lambda (x) (car (list (foo) 42 (bar)))))
 
-;;;;; (cdr (list A B ...)) -> (progn A (list B ...))
-;;;(disassemble (lambda (x) (cdr (list 42 (foo) (bar)))))
+;; (cdr (list A B ...)) -> (progn A (list B ...))
+;;(disassemble (lambda (x) (cdr (list 42 (foo) (bar)))))
 
 
 ;;; Code:
--- a/lisp/bytecomp-runtime.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/bytecomp-runtime.el	Mon Aug 13 10:19:59 2007 +0200
@@ -189,8 +189,6 @@
 ;;; Interface to file-local byte-compiler parameters.
 ;;; Redefined in bytecomp.el.
 
-;;; The great RMS speaketh:
-;;;
 ;;; I nuked this because it's not a good idea for users to think of
 ;;; using it.  These options are a matter of installation preference,
 ;;; and have nothing to do with particular source files; it's a
--- a/lisp/cmdloop.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/cmdloop.el	Mon Aug 13 10:19:59 2007 +0200
@@ -260,9 +260,8 @@
   :type 'number
   :group 'keyboard)
 
-;That damn RMS went off and implemented something differently, after
-;we had already implemented it.  We can't support both properly until
-;we have Lisp magic variables.
+;;; This is implemented differently in GNU Emacs.
+;;; We can't support both properly until we have Lisp magic variables.
 ;(defvar suggest-key-bindings t
 ;  "*FSFmacs equivalent of `teach-extended-commands-*'.
 ;Provided for compatibility only.
--- a/lisp/cus-dep.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/cus-dep.el	Mon Aug 13 10:19:59 2007 +0200
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1997 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>, then
-;;         Richar Stallman <rms@gnu.ai.mit.edu>, then
+;;         Richard Stallman <rms@gnu.ai.mit.edu>, then
 ;;         Hrvoje Niksic <hniksic@srce.hr>       (rewritten for XEmacs)
 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
 ;; Keywords: internal
--- a/lisp/help.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/help.el	Mon Aug 13 10:19:59 2007 +0200
@@ -1160,7 +1160,7 @@
 		   (pp-internal object "\n")
 		   (terpri))
 	       (cl-prettyprint object)))))
-     (format "\n%s\n" object))))
+     (format "\n%S\n" object))))
 
 (defun describe-variable (variable)
   "Display the full documentation of VARIABLE (a symbol)."
--- a/lisp/hyper-apropos.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/hyper-apropos.el	Mon Aug 13 10:19:59 2007 +0200
@@ -712,9 +712,9 @@
 					       (lambda   . "Lisp "))))
 				  desc
 				  (case symtype
-				    ((autoload) (format ", (autoloaded from \"%s\")"
+				    ((autoload) (format ",\n(autoloaded from \"%s\")"
 							(nth 1 newsym)))
-				    ((bytecode) (format ", (loaded from \"%s\")"
+				    ((bytecode) (format ",\n(loaded from \"%s\")"
 							(symbol-file symbol)))))
 		     local (current-local-map)
 		     global (current-global-map)
--- a/lisp/keymap.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/keymap.el	Mon Aug 13 10:19:59 2007 +0200
@@ -199,7 +199,7 @@
       (define-key (current-local-map) key nil)))
 
 
-;; Yet more RMS brain-death.
+;; brain-death.
 (defun minor-mode-key-binding (key &optional accept-default)
   "Find the visible minor mode bindings of KEY.
 Return an alist of pairs (MODENAME . BINDING), where MODENAME is
--- a/lisp/loaddefs.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/loaddefs.el	Mon Aug 13 10:19:59 2007 +0200
@@ -94,7 +94,7 @@
 		'(".o" ".elc" "~" ".bin" ".lbin" ".fasl"
 		  ".dvi" ".toc" ".log" ".aux" ".a" ".ln"
 		  ".lof" ".blg" ".bbl" ".glo" ".idx" ".lot" ".fmt"
-		  ".diff" ".oi"))))
+		  ".diff" ".oi" ".class"))))
 
 
 (setq debug-ignored-errors
--- a/lisp/loadup.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/loadup.el	Mon Aug 13 10:19:59 2007 +0200
@@ -72,18 +72,6 @@
 	(setq load-warn-when-source-newer t ; Used to be set to nil at the end
 	      load-warn-when-source-only  t) ; Set to nil at the end
 
-	;; Inserted for debugging.  Something is corrupting a single symbol
-	;; somewhere to have an integer 0 property list.  -slb 6/28/1997.
-	(defun test-atoms ()
-	  (mapatoms
-	   #'(lambda (symbol)
-	       (condition-case nil
-		   (get symbol 'custom-group)
-		 (t (princ
-		     (format "Bad plist in %s, %s\n"
-			     (symbol-name symbol)
-			     (prin1-to-string (object-plist symbol)))))))))
-
 	;; garbage collect after loading every file in an attempt to
 	;; minimize the size of the dumped image (if we don't do this,
 	;; there will be lots of extra space in the data segment filled
@@ -97,7 +85,6 @@
 	    (if full-path
 		(prog1
 		  (load full-path)
-		  ;; '(test-atoms)
 		  '(garbage-collect))
 	      (external-debugging-output (format "\nLoad file %s: not found\n"
 						 file))
@@ -160,12 +147,9 @@
 ;; purify-flag is nil if called from loadup-el.el.
 (when purify-flag
   (message "Finding pointers to doc strings...")
-  ;; (test-atoms) ; Debug -- Doesn't happen here
   (Snarf-documentation "DOC")
-  ;; (test-atoms) ; Debug -- Doesn't happen here
   (message "Finding pointers to doc strings...done")
   (Verify-documentation)
-  ;; (test-atoms) ; Debug -- Doesn't happen here
   )
 
 ;; Note: You can cause additional libraries to be preloaded
@@ -184,12 +168,9 @@
     (message "Dumping under the name xemacs")
     ;; This is handled earlier in the build process.
     ;; (condition-case () (delete-file "xemacs") (file-error nil))
-    (test-atoms)
     (when (fboundp 'really-free)
       (really-free))
-    (test-atoms)
     (dump-emacs "xemacs" "temacs")
-    (test-atoms)
     (kill-emacs))
 
 (when (member "run-temacs" command-line-args)
--- a/lisp/text-mode.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/text-mode.el	Mon Aug 13 10:19:59 2007 +0200
@@ -22,7 +22,7 @@
 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ;; 02111-1307, USA.
 
-;;; Synched up with: FSF 19.34.
+;;; Synched up with: FSF 20.2.
 
 ;;; Commentary:
 
@@ -33,6 +33,12 @@
 
 ;;; Code:
 
+(defvar text-mode-hook nil
+  "Normal hook run when entering Text mode and many related modes.")
+
+(defvar text-mode-variant nil
+  "Non-nil if this buffer's major mode is a variant of Text mode.")
+
 (defvar text-mode-syntax-table nil
   "Syntax table used while in text mode.")
 
@@ -58,71 +64,76 @@
   ;; XEmacs change
   (set-keymap-name text-mode-map 'text-mode-map)
   (define-key text-mode-map "\e\t" 'ispell-complete-word)
-  (define-key text-mode-map "\t" 'tab-to-tab-stop)
+  (define-key text-mode-map "\t" 'indent-relative)
   (define-key text-mode-map "\es" 'center-line)
   (define-key text-mode-map "\eS" 'center-paragraph))
 
 
-;(defun non-saved-text-mode ()
-;  "Like text-mode, but delete auto save file when file is saved for real."
-;  (text-mode)
-;  (make-local-variable 'delete-auto-save-files)
-;  (setq delete-auto-save-files t))
+(defun text-mode ()
+  "Major mode for editing text written for humans to read.
+In this mode, paragraphs are delimited only by blank or white lines.
+You can thus get the full benefit of adaptive filling
+ (see the variable `adaptive-fill-mode').
+\\{text-mode-map}
+Turning on Text mode runs the normal hook `text-mode-hook'."
+  (interactive)
+  (kill-all-local-variables)
+  (use-local-map text-mode-map)
+  (setq local-abbrev-table text-mode-abbrev-table)
+  (set-syntax-table text-mode-syntax-table)
+  (make-local-variable 'paragraph-start)
+  (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter))
+  (make-local-variable 'paragraph-separate)
+  (setq paragraph-separate paragraph-start)
+  (setq mode-name "Text")
+  (setq major-mode 'text-mode)
+  (run-hooks 'text-mode-hook))
 
-(defun text-mode ()
-  "Major mode for editing text intended for humans to read.
+(defun paragraph-indent-text-mode ()
+  "Major mode for editing text, with leading spaces starting a paragraph.
+In this mode, you do not need blank lines between paragraphs
+when the first line of the following paragraph starts with whitespace.
 Special commands:
 \\{text-mode-map}
-Turning on Text mode calls the value of the variable `text-mode-hook',
-if that value is non-nil."
+Turning on Paragraph-Indent Text mode runs the normal hooks
+`text-mode-hook' and `paragraph-indent-text-mode-hook'."
   (interactive)
   (kill-all-local-variables)
   (use-local-map text-mode-map)
-  (setq mode-name "Text")
-  (setq major-mode 'text-mode)
+  (setq mode-name "Parindent")
+  (setq major-mode 'paragraph-indent-text-mode)
   (setq local-abbrev-table text-mode-abbrev-table)
   (set-syntax-table text-mode-syntax-table)
-  (run-hooks 'text-mode-hook))
+  (run-hooks 'text-mode-hook 'paragraph-indent-text-mode-hook))
 
-(defvar indented-text-mode-map ()
-  "Keymap for Indented Text mode.
-All the commands defined in Text mode are inherited unless overridden.")
+(defalias 'indented-text-mode 'text-mode)
 
-(if indented-text-mode-map
-    ()
-  ;; Make different definition for TAB before the one in text-mode-map, but
-  ;; share the rest.
-  ;; XEmacs change
-  (setq indented-text-mode-map (make-sparse-keymap))
-  (set-keymap-name indented-text-mode-map 'indented-text-mode-map)
-  (set-keymap-parents indented-text-mode-map (list text-mode-map))
-  (define-key indented-text-mode-map "\t" 'indent-relative))
+(defun text-mode-hook-identify ()
+  "Mark that this mode has run `text-mode-hook'.
+This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
+  (make-local-variable 'text-mode-variant)
+  (setq text-mode-variant t))
+
+(add-hook 'text-mode-hook 'text-mode-hook-identify)
 
-(defun indented-text-mode ()
-  "Major mode for editing text with indented paragraphs.
-In this mode, paragraphs are delimited only by blank lines.
-You can thus get the benefit of adaptive filling
- (see the variable `adaptive-fill-mode').
-\\{indented-text-mode-map}
-Turning on `indented-text-mode' calls the value of the variable
-`text-mode-hook', if that value is non-nil."
+(defun toggle-text-mode-auto-fill ()
+  "Toggle whether to use Auto Fill in Text mode and related modes.
+This command affects all buffers that use modes related to Text mode,
+both existing buffers and buffers that you subsequently create."
   (interactive)
-  (kill-all-local-variables)
-  (use-local-map text-mode-map)
-  (define-abbrev-table 'text-mode-abbrev-table ())
-  (setq local-abbrev-table text-mode-abbrev-table)
-  (set-syntax-table text-mode-syntax-table)
-  (make-local-variable 'indent-line-function)
-  (setq indent-line-function 'indent-relative-maybe)
-  (make-local-variable 'paragraph-start)
-  (setq paragraph-start (concat "$\\|" page-delimiter))
-  (make-local-variable 'paragraph-separate)
-  (setq paragraph-separate paragraph-start)
-  (use-local-map indented-text-mode-map)
-  (setq mode-name "Indented Text")
-  (setq major-mode 'indented-text-mode)
-  (run-hooks 'text-mode-hook 'indented-text-mode-hook))
-
+  (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook)))
+	(buffers (buffer-list)))
+    (if enable-mode
+	(add-hook 'text-mode-hook 'turn-on-auto-fill)
+      (remove-hook 'text-mode-hook 'turn-on-auto-fill))
+    (while buffers
+      (with-current-buffer (car buffers)
+	(if text-mode-variant
+	    (auto-fill-mode (if enable-mode 1 0))))
+      (setq buffers (cdr buffers)))
+    (message "Auto Fill %s in Text modes"
+	     (if enable-mode "enabled" "disabled"))))
+
 (defun center-paragraph ()
   "Center each nonblank line in the paragraph at or after point.
 See `center-line' for more info."
--- a/lisp/undo-stack.el	Mon Aug 13 10:19:12 2007 +0200
+++ b/lisp/undo-stack.el	Mon Aug 13 10:19:59 2007 +0200
@@ -190,8 +190,7 @@
 
 ;;; FMH! FMH! FMH!  This object-oriented stuff doesn't really work
 ;;; properly without built-in structures (vectors suck) and without
-;;; public and private functions and fields.  Bogons descend on
-;;; RMS for not believing in any of this.
+;;; public and private functions and fields.
 
 (defsubst undoable-stack-max (stack)
   (aref stack 1))
--- a/src/ChangeLog	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/ChangeLog	Mon Aug 13 10:19:59 2007 +0200
@@ -1,3 +1,229 @@
+1998-02-09  SL Baur  <steve@altair.xemacs.org>
+
+	* data.c (Fold_eq): PC-ize.
+
+	* chartab.c: PC-ize.
+
+	* window.c (toplevel): PC-ize.
+	(syms_of_window): Ditto.
+
+	* search.c (Freplace_match): PC-ize.
+
+	* lread.c: PC-ize.
+
+	* buffer.c (Fbuffer_enable_undo): PC-ize.
+	(Fbuffer_disable_undo): ditto.
+
+	* eval.c (return_from_signal): PC-ize.
+
+	* casetab.c: PC-ize.
+
+	* callproc.c (Fcall_process_internal): PC-ize.
+
+1998-02-02  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* gui.h (struct gui_item): Menu item, submenu or GUI button
+	properties are abstracted into this new structure.
+	Added prototypes for the following functions
+
+	* gui.c (gui_item_init): New function
+	(gui_item_add_keyval_pair): Ditto
+	(gui_parse_item_keywords): Ditto
+	(gui_item_active_p): Ditto
+	(gui_item_included_p): Ditto
+	(gui_item_display_flush_left): Ditto
+	(gui_item_display_flush_right): Ditto. The above listen new
+	functions manipulate on properties common to menu items and GUI
+	buttons. 
+
+	* menubar.c (current_frame_menubar): Moved from menubar-msw.c
+	(menu_parse_submenu_keywords): New function
+	(Fmenu_find_real_submenu): Ditto, lisp accessible. The last two
+	functions operate on menu properties stored in struct gui_item,
+	but are specific to menus only.
+
+	* menubar.h: Prototypes for the above functions.
+
+	* menubar-msw.c: Modified to utilize struct gui_item instead of
+	plists, to reduce garbage. Suggested by Ben Wing.
+	Unreachable menus are fixed.
+
+1998-01-03  Kirill M. Katsnelson  <kkm@kis.ru>
+
+	* menubar-msw.c (allocate_menu_item_id): Added third parameter to
+	hash, suffix. Menus tend to put non-localizable items into suffix
+	with empty name.
+	(update_frame_menubar_maybe): top_level_menu is now set here.
+	(mswindows_popup_menu): Ditto. It was incorrect to set it from
+	populate.
+	(vars_of_menubar_mswindows): Fprovide ('mswindows-menubar) removed:
+	(featurep (and 'mswindows 'menubars)) tests the same.
+	(mswindows_update_frame_menubars): update_..._maybe () now called
+	only if frame->menubar_changed is set. Is it right to patch
+	menubar.c instead?
+
+1998-02-08  Jonathan Harris  <jhar@tardis.ed.ac.uk>
+
+	* objects-msw.c:
+	  Updated color database to X11R6. Also added support for
+	  "#RRRGGGBBB" and "#RRRRGGGGBBBB" in addition to "#RRGGBB".
+
+1998-02-08  Jonathan Harris  <jhar@tardis.ed.ac.uk>
+
+	* console.h:
+	* console-stream.c:
+	* redisplay.c:
+	* redisplay-msw.c:
+	* redisplay-tty.c:
+	* redisplay-x.c:
+	  Added the frame as a parameter to the text_width device
+	  method.
+
+	* redisplay-msw.c:
+	  Support for proportional fonts.
+
+1998-02-07  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* window.c (map_windows): Don't return the value of map_windows_1.
+	(map_windows): If F is NULL, map through all the windows.
+	(mark_windows_in_use): Use map_windows(); made it static.
+	(mark_windows_in_use_closure): New function.
+
+1998-02-01  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* alloc.c (Fpurecopy): Check for non-`nil'-ness instead of
+	checking for Vobarray.
+
+	* dlopen.c (Fdl_open): Indirect FUNCTION explicitly, for clarity.
+
+	* elhash.c: Removed broken hashtable_hash().
+
+1998-01-28  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* symbols.c (Fintern): Use Qt instead of the actual obarray.
+	(init_symbols_once_early): Ditto.
+
+1998-01-27  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* lisp.h (DO_REALLOC): Name the variable `do_realloc_newsize'
+	instead of `newsize', to avoid name collisions.
+
+1998-01-26  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* print.c (print_symbol): Be more wary about the contents of
+	Vprint_gensym_alist.
+
+1998-02-06  SL Baur  <steve@altair.xemacs.org>
+
+	* emacs.c (Frun_emacs_from_temacs): Disable largely meaning-free
+	purity/impurity summary.  Compile with -DREPORT_PURE_USAGE to get
+	it back.
+
+	* process.c (create_process): Unused variable elimination.
+
+	* lread.c (Fload_internal): Compiler warning suppression.
+
+	* alloc.c (report_pure_usage): Remove unused variable.
+
+Wed Jan 28 13:41:22 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* Makefile.in.in: add support for sheap-adjust.h generation for
+	static heap. 
+
+Wed Jan 28 13:41:22 1998  Andy Piper  <andyp@parallax.co.uk>
+
+	* Makefile.in.in: add sheap-adjust.h support, basically copied
+	from puresize-adjust.h. predicate sheap.o on HEAP_IN_DATA. fix
+	xemacs target slightly to not be a single shell command, this
+	fixes an obscure bug in cygwin gmake.
+
+	* alloc.c (report_pure_usage): call sheap_adjust_h if HEAP_IN_DATA
+	is defined.
+
+	* sysfile.h: add abstracted OPEN_BINARY, OPEN_TEXT etc defines. On
+	Unix these are all 0 and have no effect. On systems defining
+	O_BINARY these use it. WINDOWSNT is currently unaffected because
+	there are individual #ifdefs in each source file, but with this
+	change they could be removed.
+
+	* emacs.c:
+	* doc.c:
+	* lread.c:
+	* process.c: generalize open() calls with OPEN_BINARY. Does
+	nothing under Unix.
+
+	* emacs.c: predicate inclusion of windows.h on WINDOWSNT not
+	_WIN32.
+
+	* process.c:
+	* sysdep.c:
+	* signal.c: predicate SIGIO stuff also on !BROKEN_SIGIO, this is
+	required for building on cygwin32 b19 which has SIGIO that only
+	works on sockets.
+
+	* fileio.c:
+	* event-stream.c: generalize open() calls with OPEN_BINARY. Does
+	nothing under Unix. Use open() instead of creat() to make this
+	possible. use CREAT_MODE from sysfile.h
+
+	* config.h.in: add MULE_CODING, currently not used. add support
+	for HAVE_A_OUT_H.
+
+	* elhash.c:
+	* menubar-msw.c:
+	* mule-ccl.c:
+	* device-msw.c: warning elimination.
+
+	* event-msw.c: add undeclared Dde calls for cygwin.
+
+	* redisplay-msw.c: warning elimination under mule.
+
+	* gmalloc.c: make initalize() really do that. If HEAP_IN_DATA is
+	defined catch free() & realloc() calls with addresses in the data
+	space. __morecore calls more_static_core for temacs, when dumped
+	switches to sbrk().
+
+	* console-msw.h: undef CONST after windows.h inclusion since this
+	defines CONST. #ifdef out shellapi under cygwin.
+
+	* device-msw.c: include sysdep.h
+
+	* objects-msw.c: add dummy mswindows_font_spec_matches_charset and
+	mswindows_find_charset_font so that we can build with mule.
+
+	* mem-limits: return -1 for get_lim_data() when HEAP_IN_DATA is
+	defined.
+
+	* sheap.c: new file. defines sheap_adjust_h and more_static_core
+	so that data space can be used by gmalloc before dumping when
+	HEAP_IN_DATA is defined. beef up error message about what to do if
+	sheap space runs out.
+
+	* sysdep.c: make start_of_data reurn something sensible for
+	HEAP_IN_DATA.
+
+	* systime.h: don't use itimer stuff on cygwin b19.
+
+	* unexcw.c: new file. Full unexec() support for cygwin using the
+	HEAP_IN_DATA setup provided by sheap.c and friends. No run-time
+	remapping is performed. This could be generalized to support many
+	platforms that use COFF. you need a.out.h from my website to build
+	this. cygwin b19 will have this.
+
+	* s/cygwin32.h: fixed commentary. compile in unexcw.o for dumping
+	support. removed irrelevent things. define BROKEN_SIGIO. remove
+	include of windows.h. add correct process support defines, process
+	support might work when non-blocking io is implemented in cygwin.
+
+1998-02-02  P. E. Jareth Hein  <jareth@camelot-soft.com>
+
+	* glyphs.c: Removed ImageMagick support, re-instituted the previous
+	support for JPEG, GIF and PNG with the new color system.
+
+1998-02-05  Olivier Galibert  <galibert@pobox.com>
+
+	* unexelf.c: Fix alignment problems on Linux.
+
 1998-02-01  Kyle Jones  <kyle_jones@wonderworks.com>
 
 	* redisplay.c (redisplay_window): After outputting
--- a/src/Makefile.in.in	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/Makefile.in.in	Mon Aug 13 10:19:59 2007 +0200
@@ -95,6 +95,7 @@
 vpath paths.h
 vpath Emacs.ad.h
 vpath puresize-adjust.h
+vpath sheap-adjust.h
 #else
 VPATH=@srcdir@
 #endif
@@ -126,6 +127,10 @@
 X11_libs= $(LIBX11_LIBS) $(libx11_intl) $(LIBI18N)
 #endif /* HAVE_X_WINDOWS */
 
+#ifdef HEAP_IN_DATA
+sheap_obj=sheap.o
+#endif
+
 ## -Demacs is needed to make some files produce the correct version
 ## for use in Emacs.
 
@@ -172,7 +177,7 @@
  macros.o marker.o md5.o minibuf.o objects.o opaque.o\
  print.o process.o profile.o pure.o\
  rangetab.o redisplay.o redisplay-output.o regex.o\
- search.o signal.o sound.o\
+ search.o $(sheap_obj) signal.o sound.o\
  specifier.o strftime.o symbols.o syntax.o sysdep.o\
  undo.o $(x_objs) widget.o window.o
 
@@ -299,8 +304,8 @@
 	@if test -f $@;        then if test -f SATISFIED; then \
 		./xemacs -batch -vanilla -f list-load-path-shadows; fi; \
 		$(RM) SATISFIED; exit 0; fi; \
-	 if test -f SATISFIED; then $(RM) SATISFIED; exit 1; fi; \
-	 $(RECURSIVE_MAKE) $@;
+	if test -f SATISFIED; then $(RM) SATISFIED; exit 1; fi; \
+	$(RECURSIVE_MAKE) $@;
 
 FRC.update-elc.stamp :
 
@@ -550,7 +555,7 @@
 paths.h: ${srcdir}/paths.h.in
 Emacs.ad.h: ${srcdir}/${etcdir}Emacs.ad
 
-config.h puresize-adjust.h paths.h Emacs.ad.h :
+config.h puresize-adjust.h sheap-adjust.h paths.h Emacs.ad.h :
 	@echo "The file $@ needs to be re-generated."
 	@echo "Please run a make in the top level directory."
 	@echo "Consult the file \`INSTALL' for instructions for building XEmacs."
@@ -615,7 +620,7 @@
 .PHONY: mostlyclean clean distclean realclean versionclean extraclean
 mostlyclean:
 	$(RM) temacs puremacs quantmacs prefix-args depend.* *.o *.i \
-	  core puresize-adjust.h
+	  core puresize-adjust.h sheap-adjust.h
 clean: mostlyclean versionclean
 	$(RM) libextcli* update-elc.stamp
 ## This is used in making a distribution.
@@ -873,6 +878,8 @@
 redisplay-tty.o: mule-charset.h
 redisplay-x.o: mule-charset.h
 redisplay-x.o: mule-coding.h
+redisplay-msw.o: mule-charset.h
+redisplay-msw.o: mule-ccl.h
 redisplay.o: mule-charset.h
 redisplay.o: mule-coding.h
 regex.o: mule-charset.h
@@ -2316,6 +2323,8 @@
 search.o: opaque.h
 search.o: regex.h
 search.o: syntax.h
+sheap.o: sheap-adjust.h
+sheap.o: config.h
 signal.o: blocktype.h
 signal.o: config.h
 signal.o: conslots.h
--- a/src/alloc.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/alloc.c	Mon Aug 13 10:19:59 2007 +0200
@@ -178,6 +178,10 @@
 /* Non-zero means defun should do purecopy on the function definition */
 int purify_flag;
 
+#ifdef HEAP_IN_DATA
+extern void sheap_adjust_h();
+#endif
+
 extern Lisp_Object pure[];/* moved to pure.c to speed incremental linking */
 
 #define PUREBEG ((unsigned char *) pure)
@@ -2803,7 +2807,7 @@
 	     * Vpure_uninterned_symbol_table, which is itself
 	     * staticpro'd.
 	     */
-	    if (EQ (XSYMBOL (obj)->obarray, Vobarray))
+	    if (!NILP (XSYMBOL (obj)->obarray))
 	      return obj;
 	    Fputhash (obj, obj, Vpure_uninterned_symbol_table);
 	    return obj;
@@ -2848,6 +2852,9 @@
                get_PURESIZE()+pure_lossage, (long) get_PURESIZE());
       if (die_if_pure_storage_exceeded) {
 	puresize_adjust_h (get_PURESIZE() + pure_lossage);
+#ifdef HEAP_IN_DATA
+	sheap_adjust_h();
+#endif
 	rc = -1;
       }
     }
@@ -2855,7 +2862,7 @@
     {
       int lost = (get_PURESIZE() - pureptr) / 1024;
       char buf[200];
-      extern Lisp_Object Vemacs_beta_version;
+      /* extern Lisp_Object Vemacs_beta_version; */
       /* This used to be NILP(Vemacs_beta_version) ? 512 : 4; */
 #ifndef PURESIZE_SLOP
 #define PURESIZE_SLOP 0
@@ -2869,6 +2876,9 @@
         sprintf (buf + strlen (buf), " -- %dk wasted", lost);
 	if (die_if_pure_storage_exceeded) {
 	  puresize_adjust_h (pureptr + slop);
+#ifdef HEAP_IN_DATA
+	  sheap_adjust_h();
+#endif
 	  rc = -1;
 	}
       }
--- a/src/buffer.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/buffer.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1162,7 +1162,7 @@
 */
        (buffer))
 {
-  /* Allowing nil is an RMSism */
+  /* Allowing nil is an Emacs-ism */
   struct buffer *real_buf = decode_buffer (buffer, 1);
   real_buf->undo_list = Qt;
   return Qnil;
@@ -1174,7 +1174,7 @@
 */
        (buffer))
 {
-  /* Allowing nil is an RMSism */
+  /* Allowing nil is an Emacs-ism */
   struct buffer *real_buf = decode_buffer (buffer, 1);
   if (EQ (real_buf->undo_list, Qt))
     real_buf->undo_list = Qnil;
--- a/src/callproc.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/callproc.c	Mon Aug 13 10:19:59 2007 +0200
@@ -235,9 +235,7 @@
     current_dir = Funhandled_file_name_directory (current_dir);
     current_dir = expand_and_dir_to_file (current_dir, Qnil);
 #if 0
-  /* I don't know how RMS intends this crock of shit to work, but it
-     breaks everything in the presence of ange-ftp-visited files, so
-     fuck it. */
+    /* reportedly causes problems with ange-ftp-visited-files */
     if (NILP (Ffile_accessible_directory_p (current_dir)))
       report_file_error ("Setting current directory",
                          Fcons (current_buffer->directory, Qnil));
@@ -318,7 +316,7 @@
     report_file_error ("Searching for program", Fcons (args[0], Qnil));
   new_argv[0] = (char *) XSTRING_DATA (path);
 
-  filefd = open ((char *) XSTRING_DATA (infile), O_RDONLY, 0);
+  filefd = open ((char *) XSTRING_DATA (infile), O_RDONLY | OPEN_BINARY, 0);
   if (filefd < 0)
     report_file_error ("Opening process input file", Fcons (infile, Qnil));
 
@@ -354,7 +352,7 @@
 #ifndef MSDOS
   if (INTP (buffer))
     {
-      fd[1] = open (NULL_DEVICE, O_WRONLY, 0);
+      fd[1] = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY, 0);
       fd[0] = -1;
     }
   else
@@ -440,7 +438,7 @@
       }
 #else /* not MSDOS */
     if (NILP (error_file))
-      fd_error = open (NULL_DEVICE, O_WRONLY);
+      fd_error = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY);
     else if (STRINGP (error_file))
       {
 #ifdef DOS_NT
@@ -448,8 +446,9 @@
 			 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
 			 S_IREAD | S_IWRITE);
 #else  /* not DOS_NT */
-	fd_error =
-	  creat ((CONST char *) XSTRING_DATA (error_file), 0666);
+	fd_error = open (XSTRING_DATA (error_file),
+			 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
+			 CREAT_MODE);
 #endif /* not DOS_NT */
       }
 
--- a/src/casetab.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/casetab.c	Mon Aug 13 10:19:59 2007 +0200
@@ -20,8 +20,8 @@
 Boston, MA 02111-1307, USA.  */
 
 /* Synched up with: FSF 19.28.  Between FSF 19.28 and 19.30, casetab.c
-   was rewritten to use junky RMS char tables.  Meanwhile I rewrote it
-   to use more logical char tables.  RMS also discards the "list of four
+   was rewritten to use junky char tables.  Meanwhile I rewrote it
+   to use more logical char tables.  Emacs also discards the "list of four
    tables" format and instead stuffs the other tables as "extra slots"
    in the downcase table.  I've kept the four-lists format for now. */
 
--- a/src/chartab.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/chartab.c	Mon Aug 13 10:19:59 2007 +0200
@@ -79,7 +79,7 @@
    4) case tables
    5) keyboard-translate-table?
 
-   We do the very non-Stallman-esque thing of actually providing an
+   We provide an
    abstract type to generalize the Emacs vectors and Mule
    vectors-of-vectors goo.
    */
--- a/src/config.h.in	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/config.h.in	Mon Aug 13 10:19:59 2007 +0200
@@ -171,7 +171,7 @@
 #undef HAVE_LINUX_VERSION_H
 #undef HAVE_INTTYPES_H
 #undef HAVE_SYS_UN_H
-#undef HAVE_COFF_H
+#undef HAVE_A_OUT_H
 #undef STDC_HEADERS
 #undef TIME_WITH_SYS_TIME
 #undef WORDS_BIGENDIAN
@@ -298,9 +298,17 @@
    This enables graphical display of X-face headers in mail/news messages */
 #undef HAVE_XFACE
 
-/* Compile in support for ImageMagick (all image formats) */
-#undef HAVE_IMAGEMAGICK
-#undef MAGICK_HEADERS_ARE_UNDER_X11
+/* Compile in support for JPEG images */
+#undef HAVE_JPEG
+
+/* Compile in support for TIFF images */
+#undef HAVE_TIFF
+
+/* Compile in support for GIF images */
+#undef HAVE_GIF
+
+/* Compile in support for PNG images */
+#undef HAVE_PNG
 
 /* Do you have the Xmu library?
    This should always be the case except on losing HP-UX systems. */
@@ -413,6 +421,9 @@
    if you're working with ASCII files. */
 #undef MULE
 
+/* Define this if you want Mule coding support */
+#undef MULE_CODING
+
 /* Do we want to use X window input methods for use with Mule? (requires X11R5)
    If so, use raw Xlib or higher level Motif interface? */
 #undef HAVE_XIM
--- a/src/console-msw.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/console-msw.h	Mon Aug 13 10:19:59 2007 +0200
@@ -33,10 +33,14 @@
 #define _XEMACS_CONSOLE_MSW_H_
 
 #include "console.h"
-
+#ifdef CONST			/* I suspect this is safe */
+#undef CONST
+#endif
 #include "windows.h"
 #include "ddeml.h"	/* DDE management library */
+#ifndef __CYGWIN32__
 #include "shellapi.h"	/* FileManager/Explorer drag and drop */
+#endif
 
 /*
  * XXX FIXME: The following X modifier defs in events-mod.h clash with win32
--- a/src/console-stream.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/console-stream.c	Mon Aug 13 10:19:59 2007 +0200
@@ -178,8 +178,8 @@
 
 
 static int
-stream_text_width (struct face_cachel *cachel, CONST Emchar *str,
-		   Charcount len)
+stream_text_width (struct frame *f, struct face_cachel *cachel,
+		   CONST Emchar *str, Charcount len)
 {
   return len;
 }
--- a/src/console.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/console.h	Mon Aug 13 10:19:59 2007 +0200
@@ -115,7 +115,7 @@
   /* redisplay methods */
   int (*left_margin_width_method) (struct window *);
   int (*right_margin_width_method) (struct window *);
-  int (*text_width_method) (struct face_cachel *cachel,
+  int (*text_width_method) (struct frame *f, struct face_cachel *cachel,
 			    CONST Emchar *str, Charcount len);
   void (*output_display_block_method) (struct window *, struct display_line *,
 				       int, int, int, int, int, int, int);
--- a/src/data.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/data.c	Mon Aug 13 10:19:59 2007 +0200
@@ -233,8 +233,7 @@
 */
        (obj1, obj2))
 {
-  /* The miscreant responsible for this blasphemy is known as
-     Richard M. Stallman, and he will burn in hell for it. */
+  /* #### blasphemy */
   return HACKEQ_UNSAFE (obj1, obj2) ? Qt : Qnil;
 }
 
--- a/src/dlopen.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/dlopen.c	Mon Aug 13 10:19:59 2007 +0200
@@ -113,21 +113,15 @@
 
   function = dlsym (handle, "syms_of");
   if (function)
-    {
-      function ();
-    }
+    (*function) ();
 
   function = dlsym (handle, "vars_of");
   if (function)
-    {
-      function ();
-    }
+    (*function) ();
 
   function = dlsym (handle, "complex_vars_of");
   if (function)
-    {
-      function ();
-    }
+    (*function) ();
 
   return Qnil;
 }
--- a/src/doc.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/doc.c	Mon Aug 13 10:19:59 2007 +0200
@@ -215,7 +215,7 @@
     name_reloc = file;
 
   fd = open (name_nonreloc ? name_nonreloc :
-	     (char *) XSTRING_DATA (name_reloc), O_RDONLY, 0);
+	     (char *) XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0);
   if (fd < 0)
     {
 #ifndef CANNOT_DUMP
@@ -228,7 +228,7 @@
 	  strcpy (name_nonreloc, "../lib-src/");
 	  strcat (name_nonreloc, (char *) XSTRING_DATA (file));
 
-	  fd = open (name_nonreloc, O_RDONLY, 0);
+	  fd = open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0);
 	}
 #endif /* CANNOT_DUMP */
 
@@ -446,7 +446,7 @@
 
   strcat (name, (char *) XSTRING_DATA (filename));
 
-  fd = open (name, O_RDONLY, 0);
+  fd = open (name, O_RDONLY | OPEN_BINARY, 0);
   if (fd < 0)
     report_file_error ("Opening doc string file",
 		       Fcons (build_string (name), Qnil));
--- a/src/elhash.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/elhash.c	Mon Aug 13 10:19:59 2007 +0200
@@ -51,10 +51,10 @@
 static Lisp_Object mark_hashtable (Lisp_Object, void (*) (Lisp_Object));
 static void print_hashtable (Lisp_Object, Lisp_Object, int);
 static int hashtable_equal (Lisp_Object t1, Lisp_Object t2, int depth);
-static unsigned long hashtable_hash (Lisp_Object obj, int depth);
 DEFINE_LRECORD_IMPLEMENTATION ("hashtable", hashtable,
                                mark_hashtable, print_hashtable, 0,
-			       hashtable_equal, hashtable_hash,
+			       /* #### Implement hashtable_hash()! */
+			       hashtable_equal, 0,
 			       struct hashtable);
 
 static Lisp_Object
@@ -93,7 +93,7 @@
 };
 
 static int
-hashtable_equal_mapper (void *key, void *contents, void *arg)
+hashtable_equal_mapper (CONST void *key, void *contents, void *arg)
 {
   struct hashtable_equal_closure *closure =
     (struct hashtable_equal_closure *)arg;
@@ -123,10 +123,12 @@
 
   /* The objects are `equal' if they are of the same type, so return 0
      if types or test functions are not the same.  Obviously, the
-     number of elements must be equal, too.  */
+     number of elements must be equal, too.  #### table->fullness is
+     broken, so we cannot use it.  */
   if ((table1->test_function != table2->test_function)
       || (table1->type != table2->type)
-      || (table1->fullness != table2->fullness))
+      /*|| (table1->fullness != table2->fullness))*/
+      )
     return 0;
 
   closure.depth = depth + 1;
@@ -136,67 +138,6 @@
   return closure.equal;
 }
 
-/* Hashtable hash function.  This hashes 5 key-value pairs.  For EQ
-   hashtables, keys are used as the hash value themselves, whereas
-   values are hashed with internal_hash().  For EQUAL hashtables, both
-   keys and values are hashed properly.  EQL tables are handled as
-   necessary.  All of this should make the hash function compatible
-   with hashtable_equal().  The elements hashed are the first five
-   mapped over by maphash().  */
-
-struct hashtable_hash_closure
-{
-  struct hashtable *table;
-  int depth;
-  unsigned long hash;
-  int count;
-};
-
-/* Needed for tests.  */
-static int lisp_object_eql_equal (CONST void *x1, CONST void *x2);
-static int lisp_object_equal_equal (CONST void *x1, CONST void *x2);
-
-static int
-hashtable_hash_mapper (void *key, void *contents, void *arg)
-{
-  struct hashtable_hash_closure *closure =
-    (struct hashtable_hash_closure *)arg;
-  Lisp_Object valuetem, keytem;
-  unsigned long keyhash;
-
-  CVOID_TO_LISP (keytem, key);
-  CVOID_TO_LISP (valuetem, contents);
-
-  if (!closure->table->test_function)
-    /* For eq, use key itself as hash.  */
-    keyhash = LISP_HASH (keytem);
-  else if (closure->table->test_function == lisp_object_eql_equal)
-    /* The same as eq, unless the key is float.  */
-    keyhash = (FLOATP (keytem)
-	       ? internal_hash (keytem, closure->depth) : LISP_HASH (keytem));
-  else
-    /* equal: hash the key properly. */
-    keyhash = internal_hash (keytem, closure->depth);
-
-  closure->hash = HASH3 (closure->hash, keyhash,
-			 internal_hash (valuetem, closure->depth));
-  return (++closure->count > 5) ? 1 : 0;
-}
-
-static unsigned long
-hashtable_hash (Lisp_Object obj, int depth)
-{
-  struct hashtable_hash_closure closure;
-
-  closure.table = XHASHTABLE (obj);
-  closure.depth = depth + 1;
-  closure.hash = 0;
-  closure.count = 0;
-
-  elisp_maphash (hashtable_hash_mapper, obj, &closure);
-  return closure.hash;
-}
-
 /* Printing hashtables.
 
    This is non-trivial, because we use a readable structure-style
@@ -227,7 +168,7 @@
 };
 
 static int
-print_hashtable_data_mapper (void *key, void *contents, void *arg)
+print_hashtable_data_mapper (CONST void *key, void *contents, void *arg)
 {
   Lisp_Object keytem, valuetem;
   struct print_hashtable_data_closure *closure =
@@ -264,6 +205,10 @@
 		  printcharfun);
 }
 
+/* Needed for tests.  */
+static int lisp_object_eql_equal (CONST void *x1, CONST void *x2);
+static int lisp_object_equal_equal (CONST void *x1, CONST void *x2);
+
 static void
 print_hashtable (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
 {
--- a/src/emacs.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/emacs.c	Mon Aug 13 10:19:59 2007 +0200
@@ -58,7 +58,7 @@
 #endif
 #endif
 
-#if defined (_WIN32)
+#if defined (WINDOWSNT)
 #include <windows.h>
 #endif
 
@@ -608,7 +608,7 @@
       {
 	close (0);
 	close (1);
-	if (open (term, O_RDWR, 2) < 0)
+	if (open (term, O_RDWR | OPEN_BINARY, 2) < 0)
 	  fatal ("%s: %s", term, strerror (errno));
 	dup (0);
 	if (! isatty (0))
@@ -1825,7 +1825,7 @@
   unbind_to (0, Qnil); /* this closes loadup.el */
   purify_flag = 0;
   run_temacs_argc = nargs + 1;
-#ifdef DEBUG_XEMACS
+#ifdef REPORT_PURE_USAGE
   report_pure_usage (1, 0);
 #else
   report_pure_usage (0, 0);
--- a/src/eval.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/eval.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1840,7 +1840,7 @@
 static Lisp_Object
 return_from_signal (Lisp_Object value)
 {
-#if 1 /* RMS Claims: */
+#if 1
   /* Most callers are not prepared to handle gc if this
      returns.  So, since this feature is not very useful,
      take it out.  */
--- a/src/event-msw.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/event-msw.c	Mon Aug 13 10:19:59 2007 +0200
@@ -55,6 +55,12 @@
 
 #include "events-mod.h"
 
+#ifdef BROKEN_CYGWIN
+int WINAPI      DdeCmpStringHandles (HSZ, HSZ);
+HDDEDATA WINAPI DdeCreateDataHandle (DWORD, LPBYTE, DWORD, DWORD, HSZ,
+				     UINT, UINT);
+#endif
+
 #ifdef HAVE_MENUBARS
 #define ADJR_MENUFLAG TRUE
 #else
@@ -82,7 +88,6 @@
 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
 static int mswindows_current_layout_has_AltGr (void);
 
-
 static struct event_stream *mswindows_event_stream;
 
 /*
@@ -661,7 +666,6 @@
 	}
       DdeFreeDataHandle (hdata); 
       return (HDDEDATA) DDE_FNOTPROCESSED;
-
     default: 
       return (HDDEDATA) NULL; 
     } 
--- a/src/event-stream.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/event-stream.c	Mon Aug 13 10:19:59 2007 +0200
@@ -86,6 +86,7 @@
 
 #include "sysdep.h"		/* init_poll_for_quit() */
 #include "syssignal.h"		/* SIGCHLD, etc. */
+#include "sysfile.h"
 #include "systime.h"		/* to set Vlast_input_time */
 
 #include "events-mod.h"
@@ -4810,7 +4811,9 @@
       int fd;
 
       file = Fexpand_file_name (file, Qnil);
-      fd = creat ((char *) XSTRING_DATA (file), 0666);
+      fd = open ((char*) XSTRING_DATA (file),
+		 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
+		 CREAT_MODE);
       if (fd < 0)
 	error ("Unable to create dribble file");
       Vdribble_file = make_filedesc_output_stream (fd, 0, 0, LSTR_CLOSING);
--- a/src/fileio.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/fileio.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1655,7 +1655,7 @@
   else if (stat ((CONST char *) XSTRING_DATA (newname), &out_st) < 0)
     out_st.st_mode = 0;
 
-  ifd = interruptible_open ((char *) XSTRING_DATA (filename), O_RDONLY, 0);
+  ifd = interruptible_open ((char *) XSTRING_DATA (filename), O_RDONLY | OPEN_BINARY, 0);
   if (ifd < 0)
     report_file_error ("Opening input file", list1 (filename));
 
@@ -1698,7 +1698,8 @@
   /* 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 = creat ((char *) XSTRING_DATA (newname), 0666);
+  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));
@@ -2260,7 +2261,7 @@
     return Qt;
   return Qnil;
 #else /* not DOS_NT */
-  desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY, 0);
+  desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY | OPEN_BINARY, 0);
   UNGCPRO;
   if (desc < 0)
     return Qnil;
@@ -2774,7 +2775,7 @@
       (stat ((char *) XSTRING_DATA (filename), &st) < 0)
 #else /* APOLLO */
       /* Don't even bother with interruptible_open.  APOLLO sucks. */
-      ((fd = open ((char *) XSTRING_DATA (filename), O_RDONLY, 0)) < 0
+      ((fd = open ((char *) XSTRING_DATA (filename), O_RDONLY | OPEN_BINARY, 0)) < 0
        || fstat (fd, &st) < 0)
 #endif /* APOLLO */
       )
@@ -2819,7 +2820,7 @@
   if (fd < 0)
     {
       if ((fd = interruptible_open ((char *) XSTRING_DATA (filename),
-				    O_RDONLY, 0)) < 0)
+				    O_RDONLY | OPEN_BINARY, 0)) < 0)
 	goto badopen;
     }
 
@@ -3524,7 +3525,7 @@
     desc = open ((char *) XSTRING_DATA (fn),
                        (O_WRONLY | buffer_file_type), 0);
 #else /* not DOS_NT */
-    desc = open ((char *) XSTRING_DATA (fn), O_WRONLY, 0);
+    desc = open ((char *) XSTRING_DATA (fn), O_WRONLY | OPEN_BINARY, 0);
 #endif /* not DOS_NT */
 
   if (desc < 0)
@@ -3534,8 +3535,9 @@
                    (O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type),
                    (S_IREAD | S_IWRITE));
 #else /* not DOS_NT */
-      desc = creat ((char *) XSTRING_DATA (fn),
-		    ((auto_saving) ? auto_save_mode_bits : 0666));
+      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 */
     }
 
@@ -4288,7 +4290,9 @@
 				   O_WRONLY | O_TRUNC | O_CREAT | O_BINARY,
 				   S_IREAD | S_IWRITE);
 #else /* not DOS_NT */
-		  listdesc = creat ((char *) XSTRING_DATA (listfile), 0666);
+		  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
--- a/src/glyphs-x.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/glyphs-x.c	Mon Aug 13 10:19:59 2007 +0200
@@ -37,14 +37,12 @@
    Pointer/icon overhaul, more restructuring by Ben Wing for 19.14
 
    TODO:
-   ImageMagick support
    Convert images.el to C and stick it in here?
  */
 
 #include <config.h>
-#include <setjmp.h>
 #include "lisp.h"
-
+#include "lstream.h"
 #include "console-x.h"
 #include "glyphs-x.h"
 #include "objects-x.h"
@@ -57,17 +55,20 @@
 
 #include "sysfile.h"
 
-#ifdef HAVE_IMAGEMAGICK
-#define _XOS_H_
-#ifdef MAGICK_HEADERS_ARE_UNDER_X11
-#include <X11/magick/magick.h>
+#ifdef HAVE_PNG
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <png.h>
+#ifdef __cplusplus
+}
+#endif
 #else
-#include <magick/magick.h>
+#include <setjmp.h>
 #endif
-/*#include <image.h>*/
-/*#include <assert.h>*/
-
-#define OLDCOMPAT /* allow lisp code using the old names to still function */
+
+#ifdef MULE
+#include "mule-coding.h"
 #endif
 
 #define LISP_DEVICE_TO_X_SCREEN(dev)					\
@@ -90,20 +91,24 @@
 Lisp_Object Qxface;
 #endif
 
-#ifdef HAVE_IMAGEMAGICK
-DEFINE_IMAGE_INSTANTIATOR_FORMAT (imagick);
-Lisp_Object Qimagick;
-
-#ifdef OLDCOMPAT /* old compatibility */
+#ifdef HAVE_TIFF
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (tiff);
-DEFINE_IMAGE_INSTANTIATOR_FORMAT (png);
-DEFINE_IMAGE_INSTANTIATOR_FORMAT (gif);
+Lisp_Object Qtiff;
+#endif
+
+#ifdef HAVE_JPEG
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
-Lisp_Object Qtiff;
-Lisp_Object Qpng;
-Lisp_Object Qgif;
 Lisp_Object Qjpeg;
 #endif
+
+#ifdef HAVE_GIF
+DEFINE_IMAGE_INSTANTIATOR_FORMAT (gif);
+Lisp_Object Qgif;
+#endif
+
+#ifdef HAVE_PNG
+DEFINE_IMAGE_INSTANTIATOR_FORMAT (png);
+Lisp_Object Qpng;
 #endif
 
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (cursor_font);
@@ -439,26 +444,36 @@
 static void
 write_lisp_string_to_temp_file (Lisp_Object string, char *filename_out)
 {
-  Extbyte *bytes;
-  Extcount len;
-  FILE *stream;
-
-  /* #### 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. */
-  GET_STRING_BINARY_DATA_ALLOCA (string, bytes, len);
-
-  /* Write out to a temporary file ... */
+  Lisp_Object instream, outstream;
+  Lstream *istr, *ostr;
+  char tempbuf[1024]; /* some random amount */
+  int fubar = 0;
+  FILE *tmpfil;
+  static Extbyte_dynarr *conversion_out_dynarr = NULL;
+  Bytecount bstart, bend;
+  struct gcpro gcpro1, gcpro2;
+#ifdef MULE
+  Lisp_Object conv_out_stream;
+  Lstream *costr;
+  struct gcpro gcpro3;
+#endif
+
+  /* This function can GC */
+  if (!conversion_out_dynarr)
+    conversion_out_dynarr = Dynarr_new (Extbyte);
+  else
+    Dynarr_reset (conversion_out_dynarr);
+
+  /* Create the temporary file ... */
   sprintf (filename_out, "/tmp/emacs%d.XXXXXX", (int) getpid ());
   mktemp (filename_out);
-  stream = fopen (filename_out, "w");
-  if (!stream)
+  tmpfil = fopen (filename_out, "w");
+  if (!tmpfil)
     {
-    temp_file_error:
-      if (stream)
+      if (tmpfil)
 	{
 	  int old_errno = errno;
-	  fclose (stream);
+	  fclose (tmpfil);
 	  unlink (filename_out);
 	  errno = old_errno;
 	}
@@ -466,14 +481,63 @@
 			 list1 (build_string (filename_out)));
     }
 
-  if (fwrite (bytes, len, 1, stream) != 1)
-    goto temp_file_error;
-
-  if (fclose (stream) != 0)
-    {
-      stream = 0;
-      goto temp_file_error;
-    }
+  CHECK_STRING (string);
+  get_string_range_byte (string, Qnil, Qnil, &bstart, &bend,
+			 GB_HISTORICAL_STRING_BEHAVIOR);
+  instream = make_lisp_string_input_stream (string, bstart, bend);
+  istr = XLSTREAM (instream);
+  /* setup the out stream */
+  outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr);
+  ostr = XLSTREAM (outstream);
+#ifdef MULE
+  /* setup the conversion stream */
+  conv_out_stream = make_encoding_output_stream (ostr, Fget_coding_system(Qbinary));
+  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));
+    if (!size_in_bytes)
+      break;
+    /* It does seem the flushes are necessary... */
+#ifdef MULE
+    Lstream_write (costr, tempbuf, size_in_bytes);
+    Lstream_flush (costr);
+#else
+    Lstream_write (ostr, tempbuf, size_in_bytes);
+#endif
+    Lstream_flush (ostr);
+    if (fwrite ((unsigned char *)Dynarr_atp(conversion_out_dynarr, 0),
+		Dynarr_length(conversion_out_dynarr), 1, tmpfil) != 1)
+      {
+	fubar = 1;
+	break;
+      }
+    /* reset the dynarr */
+    Lstream_rewind(ostr);
+  }
+  
+  if (fclose (tmpfil) != 0)
+    fubar = 1;
+  Lstream_close (istr);
+#ifdef MULE
+  Lstream_close (costr);
+#endif
+  Lstream_close (ostr);
+  
+  UNGCPRO;
+  Lstream_delete (istr);
+  Lstream_delete (ostr);
+#ifdef MULE
+  Lstream_delete (costr);
+#endif
+  if (fubar)
+    report_file_error ("Writing temp file",
+		       list1 (build_string (filename_out)));
 }
 
 
@@ -1383,8 +1447,6 @@
     signal_simple_error ("Not an X device", device);
 
   dpy = DEVICE_X_DISPLAY (XDEVICE (device));
-  cmap = DEVICE_X_COLORMAP (XDEVICE(device));
-  depth = DEVICE_X_DEPTH (XDEVICE(device));
   xs = DefaultScreenOfDisplay (dpy);
 
   if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
@@ -1399,6 +1461,26 @@
 			      | IMAGE_POINTER_MASK);
   force_mono = (type != IMAGE_COLOR_PIXMAP);
 
+#if 0
+  /* Although I haven't found it documented yet, it appears that pointers are
+     always colored via the default window colormap... Sigh.  However, with
+     the current color structure, this will blow the doors off as things aren't set up
+     to differenciate between two colormaps per console.  AARGH! */
+  if (type == IMAGE_POINTER)
+    {
+      cmap = DefaultColormap(dpy, DefaultScreen(dpy));
+      depth = DefaultDepthOfScreen (xs);
+    }
+  else
+    {
+      cmap = DEVICE_X_COLORMAP (XDEVICE(device));
+      depth = DEVICE_X_DEPTH (XDEVICE(device));
+    }
+#else
+  cmap = DEVICE_X_COLORMAP (XDEVICE(device));
+  depth = DEVICE_X_DEPTH (XDEVICE(device));
+#endif
+
   x_initialize_pixmap_image_instance (ii, type);
 
   assert (!NILP (data));
@@ -1675,148 +1757,915 @@
 #endif /* HAVE_XPM */
 
 
-#ifdef HAVE_IMAGEMAGICK
+#ifdef HAVE_JPEG
+
 /**********************************************************************
- *                             ImageMagick                            *
+ *                             JPEG                                   *
  **********************************************************************/
-JMP_BUF imagick_jump;
-Lisp_Object imagick_err; /* slightly hackish way to return a proper error message */
-
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <jpeglib.h>
+#include <jerror.h>
+#ifdef __cplusplus
+}
+#endif
+
+/*#define USE_TEMP_FILES_FOR_JPEG_IMAGES 1*/
 static void
-imagick_validate (Lisp_Object instantiator)
-{
-	file_or_data_must_be_present (instantiator);
-}
-
-static void
-imagick_error_handler (const char *message,const char *qualifier)
+jpeg_validate (Lisp_Object instantiator)
 {
-  /* ImageMagick defaults to exiting on errors, which is an anti-thing.
-   * Dump the info into imagick_err, and jmp back */
-  if (qualifier != NULL)
-    imagick_err = emacs_doprnt_string_c((CONST Bufbyte *) GETTEXT ("ImageMagick error: %s (%s)"),
-					Qnil, -1, message, qualifier);
-  else
-    imagick_err = emacs_doprnt_string_c((CONST Bufbyte *) GETTEXT ("ImageMagick error: %s"),
-					Qnil, -1, message);
-  LONGJMP(imagick_jump,1);
-}
-
-static void
-imagick_warning_handler (const char *message,const char *qualifier)
-{
-  if (qualifier != NULL)
-    warn_when_safe(Qimagick, Qwarning, "ImageMagick warning: %s (%s)",message,qualifier);
-  else
-    warn_when_safe(Qimagick, Qwarning, "ImageMagick warning: %s",message);
+  file_or_data_must_be_present (instantiator);
 }
 
 static Lisp_Object
-imagick_normalize (Lisp_Object inst, Lisp_Object console_type)
+jpeg_normalize (Lisp_Object inst, Lisp_Object console_type)
 {
-	return simple_image_type_normalize (inst, console_type, Qimagick);
+  return simple_image_type_normalize (inst, console_type, Qjpeg);
 }
 
 static int
-imagick_possible_dest_types (void)
+jpeg_possible_dest_types (void)
 {
-	return IMAGE_COLOR_PIXMAP_MASK;
+  return IMAGE_COLOR_PIXMAP_MASK;
 }
 
-struct imagick_unwind_data
+/* To survive the otherwise baffling complexity of making sure
+   everything gets cleaned up in the presence of an error, we
+   use an unwind_protect(). */
+
+struct jpeg_unwind_data
 {
-	Display *dpy;
-	Colormap cmap;
-	FILE *instream;
-	Image *image;
-	XImage *ximage;
-	unsigned long *pixels;
-	unsigned long npixels;
-	char tempfile[50];
-	int tempfile_needs_to_be_removed;
+  Display *dpy;
+  Colormap cmap;
+  /* Stream that we need to close */
+  FILE *instream;
+  /* Object that holds state info for JPEG decoding */
+  struct jpeg_decompress_struct *cinfo_ptr;
+  /* Pixels to keep around while the image is active */
+  unsigned long *pixels;
+  int npixels;
+  /* Client-side image structure */
+  XImage *ximage;
+  /* Tempfile to remove */
+  char tempfile[50];
+  int tempfile_needs_to_be_removed;
 };
 
 static Lisp_Object
-imagick_instantiate_unwind (Lisp_Object unwind_obj)
+jpeg_instantiate_unwind (Lisp_Object unwind_obj)
+{
+  struct jpeg_unwind_data *data =
+    (struct jpeg_unwind_data *) get_opaque_ptr (unwind_obj);
+
+  free_opaque_ptr (unwind_obj);
+  if (data->cinfo_ptr)
+    jpeg_destroy_decompress (data->cinfo_ptr);
+
+  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);
+    }
+
+  if (data->ximage)
+    {
+      if (data->ximage->data)
+        {
+	  xfree (data->ximage->data);
+          data->ximage->data = 0;
+        }
+      XDestroyImage (data->ximage);
+    }
+
+  return Qnil;
+}
+
+/*
+ * ERROR HANDLING:
+ *
+ * The JPEG library's standard error handler (jerror.c) is divided into
+ * several "methods" which you can override individually.  This lets you
+ * adjust the behavior without duplicating a lot of code, which you might
+ * have to update with each future release.
+ *
+ * Our example here shows how to override the "error_exit" method so that
+ * control is returned to the library's caller when a fatal error occurs,
+ * rather than calling exit() as the standard error_exit method does.
+ *
+ * We use C's setjmp/longjmp facility to return control.  This means that the
+ * routine which calls the JPEG library must first execute a setjmp() call to
+ * establish the return point.  We want the replacement error_exit to do a
+ * longjmp().  But we need to make the setjmp buffer accessible to the
+ * error_exit routine.  To do this, we make a private extension of the
+ * standard JPEG error handler object.  (If we were using C++, we'd say we
+ * were making a subclass of the regular error handler.)
+ *
+ * Here's the extended error handler struct:
+ */
+
+struct my_jpeg_error_mgr
 {
-	struct imagick_unwind_data *data =
-		(struct imagick_unwind_data *) get_opaque_ptr (unwind_obj);
- 
-	free_opaque_ptr (unwind_obj);
-	if (data->instream)
-		fclose (data->instream);
-	if (data->tempfile_needs_to_be_removed)
-		unlink (data->tempfile);
-
-	if (data->image) {
-		DestroyImage(data->image);
-	}
-
-	if (data->ximage) {
-		if (data->ximage->data) {
-			xfree (data->ximage->data);
-			data->ximage->data = NULL;
-		}
-		XDestroyImage (data->ximage);
-	}
-
-	if (data->npixels > 0) {
-	  XFreeColors(data->dpy, data->cmap, data->pixels, data->npixels, 0L);
-	  xfree (data->pixels);
-	}
- 
-	return Qnil;
+  struct jpeg_error_mgr pub;	/* "public" fields */
+  jmp_buf setjmp_buffer;	/* for return to caller */
+};
+
+#if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61)
+METHODDEF(void)
+#else
+METHODDEF void
+#endif
+our_init_source (j_decompress_ptr cinfo) {
+}
+
+#if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61)
+METHODDEF(boolean)
+#else
+METHODDEF boolean
+#endif
+our_fill_input_buffer (j_decompress_ptr cinfo) {
+  /* Insert a fake EOI marker */
+  struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src;
+  static JOCTET buffer[2];
+
+  buffer[0] = (JOCTET) 0xFF;
+  buffer[1] = (JOCTET) JPEG_EOI;
+
+  src->next_input_byte = buffer;
+  src->bytes_in_buffer = 2;
+  return TRUE;
 }
 
+#if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61)
+METHODDEF(void)
+#else
+METHODDEF void
+#endif
+our_skip_input_data (j_decompress_ptr cinfo, long num_bytes) {
+  struct jpeg_source_mgr *src = NULL;
+
+  src = (struct jpeg_source_mgr *) cinfo->src;
+
+  if (!src) {
+    return;
+  } else if (num_bytes > src->bytes_in_buffer) {
+    ERREXIT(cinfo, JERR_INPUT_EOF);
+    /*NOTREACHED*/
+  }
+
+  src->bytes_in_buffer -= num_bytes;
+  src->next_input_byte += num_bytes;
+}
+
+#if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61)
+METHODDEF(void)
+#else
+METHODDEF void
+#endif
+our_term_source (j_decompress_ptr cinfo) {
+}
+
+typedef struct {
+  struct jpeg_source_mgr pub;
+} our_jpeg_source_mgr;
+
 static void
-imagick_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
-					 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
-					 int dest_mask, Lisp_Object domain)
+jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len)
+{
+  struct jpeg_source_mgr *src = NULL;
+
+  if (cinfo->src == NULL) {	/* first time for this JPEG object? */
+    cinfo->src = (struct jpeg_source_mgr *)
+      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+				  sizeof(our_jpeg_source_mgr));
+    src = (struct jpeg_source_mgr *) cinfo->src;
+    src->next_input_byte = data;
+  }
+  src = (struct jpeg_source_mgr *) cinfo->src;
+  src->init_source = our_init_source;
+  src->fill_input_buffer = our_fill_input_buffer;
+  src->skip_input_data = our_skip_input_data;
+  src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
+  src->term_source = our_term_source;
+  src->bytes_in_buffer = len;
+  src->next_input_byte = data;
+}
+
+#if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61)
+METHODDEF(void)
+#else
+METHODDEF void
+#endif
+my_jpeg_error_exit (j_common_ptr cinfo)
+{
+  /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
+  struct my_jpeg_error_mgr *myerr = (struct my_jpeg_error_mgr *) cinfo->err;
+
+  /* Return control to the setjmp point */
+  longjmp (myerr->setjmp_buffer, 1);
+}
+
+/* The code in this routine is based on example.c from the JPEG library
+   source code and from gif_instantiate() */
+static void
+jpeg_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+		  Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+		  int dest_mask, Lisp_Object domain)
 {
   struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
   Display *dpy;
   Screen *scr;
-  Visual *visual;
   Colormap cmap;
-  Dimension depth;
-  struct imagick_unwind_data unwind;
-  int speccount;
-  ImageInfo image_info;
-
-  /* ImageMagick variables */
-
-  /* Basic error checking */
+  Visual *vis;
+  /* 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 jpeg_unwind_data unwind;
+  int speccount = specpdl_depth ();
+
+  /* This struct contains the JPEG decompression parameters and pointers to
+   * working space (which is allocated as needed by the JPEG library).
+   */
+  struct jpeg_decompress_struct cinfo;
+  /* We use our private extension JPEG error handler.
+   * Note that this struct must live as long as the main JPEG parameter
+   * struct, to avoid dangling-pointer problems.
+   */
+  struct my_jpeg_error_mgr jerr;
+
   if (!DEVICE_X_P (XDEVICE (device)))
     signal_simple_error ("Not an X device", device);
 
   dpy = DEVICE_X_DISPLAY (XDEVICE (device));
   scr = DefaultScreenOfDisplay (dpy);
-  depth = DEVICE_X_DEPTH (XDEVICE (device));
-  visual = DEVICE_X_VISUAL (XDEVICE (device));
   cmap = DEVICE_X_COLORMAP (XDEVICE(device));
-
-  /* Set up the unwind */
+  vis = DEVICE_X_VISUAL (XDEVICE(device));
+
+  /* Step -1: First record our unwind-protect, which will clean up after
+     any exit, normal or not */
+
   memset (&unwind, 0, sizeof (unwind));
   unwind.dpy = dpy;
   unwind.cmap = cmap;
-  speccount = specpdl_depth();
-  record_unwind_protect(imagick_instantiate_unwind,make_opaque_ptr(&unwind));
-
-  /* Set up error handlers */
-  if (SETJMP(imagick_jump)) 
+  record_unwind_protect (jpeg_instantiate_unwind, make_opaque_ptr (&unwind));
+
+#ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES
+  /* Step 0: Write out to a temp file.
+
+     The JPEG routines require you to read from a file unless
+     you provide your own special input handlers, which I don't
+     feel like doing. */
+  {
+    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;
+
+    /* VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
+     * requires it in order to read binary files.
+     */
+
+    if ((unwind.instream = fopen (unwind.tempfile, "r")) == NULL)
+      report_file_error ("Opening JPEG temp file",
+			 list1 (build_string (unwind.tempfile)));
+  }
+#endif
+
+  /* Step 1: allocate and initialize JPEG decompression object */
+
+  /* We set up the normal JPEG error routines, then override error_exit. */
+  cinfo.err = jpeg_std_error (&jerr.pub);
+  jerr.pub.error_exit = my_jpeg_error_exit;
+
+  /* Establish the setjmp return context for my_error_exit to use. */
+  if (setjmp (jerr.setjmp_buffer))
     {
-      /* signal error GCPROs it's arguments */
-      signal_error(Qerror, list2(imagick_err, instantiator));
+      /* If we get here, the JPEG code has signaled an error.
+       * We need to clean up the JPEG object, close the input file, and return.
+       */
+
+      {
+	Lisp_Object errstring;
+	char buffer[JMSG_LENGTH_MAX];
+
+	/* Create the message */
+	(*cinfo.err->format_message) ((j_common_ptr) &cinfo, buffer);
+	errstring = build_string (buffer);
+
+	signal_simple_error_2 ("JPEG decoding error",
+			       errstring, instantiator);
+      }
+    }
+
+  /* Now we can initialize the JPEG decompression object. */
+  jpeg_create_decompress (&cinfo);
+  unwind.cinfo_ptr = &cinfo;
+
+  /* Step 2: specify data source (eg, a file) */
+
+#ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES
+  jpeg_stdio_src (&cinfo, unwind.instream);
+#else
+  {
+    Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
+    Extbyte *bytes;
+    Extcount len;
+
+    /* #### 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. */
+    GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
+    jpeg_memory_src (&cinfo, bytes, len);
+  }
+#endif
+
+  /* Step 3: read file parameters with jpeg_read_header() */
+
+  jpeg_read_header (&cinfo, TRUE);
+  /* We can ignore the return value from jpeg_read_header since
+   *   (a) suspension is not possible with the stdio data source, and
+   *   (b) we passed TRUE to reject a tables-only JPEG file as an error.
+   * See libjpeg.doc for more info.
+   */
+
+  /* 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;
+
+  /* Step 5: Start decompressor */
+
+  jpeg_start_decompress (&cinfo);
+  /* We can ignore the return value since suspension is not possible
+   * with the stdio data source.
+   */
+
+  /* At this point we know the size of the image and the colormap. */
+
+  /* Step 5.33: Allocate the colors */
+  {
+    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. */
+
+    /* Allocate pixels for the various colors. */
+    for (i = 0; i < unwind.npixels; i++)
+      {
+	XColor color;
+	int ri, gi, bi;
+
+	ri = 0;
+	gi = cinfo.out_color_components > 1 ? 1 : 0;
+	bi = cinfo.out_color_components > 2 ? 2 : 0;
+
+	/* Ok... apparently, an entry of cinfo.colormap can be NULL if
+	   there are no bits of that color in the image.  How incredibly
+	   gross.  Wouldn't it be nice to have exceptions!? */
+	color.red = cinfo.colormap[ri] ? cinfo.colormap[ri][i] << 8 : 0;
+	color.green = cinfo.colormap[gi] ? cinfo.colormap[gi][i] << 8 : 0;
+	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;
+      }
+  }
+
+  /* Step 5.66: Create the image */
+  {
+    int height = cinfo.output_height;
+    int width = cinfo.output_width;
+    int depth;
+    int bitmap_pad;
+
+    depth = DEVICE_X_DEPTH(XDEVICE(device));
+
+    /* first get bitmap_pad (from XPM) */
+    bitmap_pad = ((depth > 16) ? 32 :
+		  (depth >  8) ? 16 :
+		  8);
+
+    unwind.ximage = XCreateImage (dpy, DefaultVisualOfScreen (scr),
+				  depth, ZPixmap, 0, 0, width, height,
+				  bitmap_pad, 0);
+
+    if (!unwind.ximage)
+      signal_simple_error ("Unable to create X image struct", instantiator);
+
+    /* now that bytes_per_line must have been set properly alloc data */
+    unwind.ximage->data =
+      (char *) xmalloc (unwind.ximage->bytes_per_line * height);
+  }
+
+  /* Step 6: Read in the data and put into image */
+  {
+    JSAMPARRAY row_buffer;	/* Output row buffer */
+    int row_stride;		/* physical row width in output buffer */
+
+    /* 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, as well as the output colormap
+     * if we asked for color quantization.
+     * In this example, we need to make an output work buffer of the right size.
+     */
+    /* JSAMPLEs per row in output buffer.
+       Since we asked for quantized output, cinfo.output_components
+       will always be 1. */
+    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;
+	int scanline = cinfo.output_scanline;
+
+	/* 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);
+
+	for (i = 0; i < cinfo.output_width; i++)
+	  XPutPixel (unwind.ximage, i, scanline,
+		     /* Let's make sure we avoid getting bit like
+			what happened for GIF's.  It's probably the
+			case that JSAMPLE's are unsigned chars as
+			opposed to chars, but you never know.
+
+			(They could even be shorts if the library
+			was compiled with 12-bit samples -- ####
+			We should deal with this possibility) */
+		     unwind.pixels[(unsigned char) row_buffer[0][i]]);
+      }
+  }
+
+  /* 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,
+				    instantiator);
+
+  /* Step 7: Finish decompression */
+
+  jpeg_finish_decompress (&cinfo);
+  /* We can ignore the return value since suspension is not possible
+   * with the stdio data source.
+   */
+
+  /* And we're done!
+
+     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;
+
+  /* This will clean up everything else. */
+  unbind_to (speccount, Qnil);
+}
+
+#endif /* HAVE_JPEG */
+
+#ifdef HAVE_GIF
+
+/**********************************************************************
+ *                               GIF                                  *
+ **********************************************************************/
+
+#include "gif_lib.h" /* This is in our own source tree */
+
+static void
+gif_validate (Lisp_Object instantiator)
+{
+  file_or_data_must_be_present (instantiator);
+}
+
+static Lisp_Object
+gif_normalize (Lisp_Object inst, Lisp_Object console_type)
+{
+  return simple_image_type_normalize (inst, console_type, Qgif);
+}
+
+static int
+gif_possible_dest_types (void)
+{
+  return IMAGE_COLOR_PIXMAP_MASK;
+}
+
+/* To survive the otherwise baffling complexity of making sure
+   everything gets cleaned up in the presence of an error, we
+   use an unwind_protect(). */
+
+struct gif_unwind_data
+{
+  Display *dpy;
+  Colormap cmap;
+  /* 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;
+  /* Client-side image structure */
+  XImage *ximage;
+  /* Tempfile to remove */
+  char tempfile[50];
+  int tempfile_needs_to_be_removed;
+};
+
+static Lisp_Object
+gif_instantiate_unwind (Lisp_Object unwind_obj)
+{
+  struct gif_unwind_data *data =
+    (struct gif_unwind_data *) get_opaque_ptr (unwind_obj);
+
+  free_opaque_ptr (unwind_obj);
+  if (data->giffile)
+    DGifCloseFile (data->giffile);
+  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);
+    }
+  if (data->ximage)
+    {
+      if (data->ximage->data)
+        {
+	  xfree (data->ximage->data);
+          data->ximage->data = 0;
+        }
+      XDestroyImage (data->ximage);
     }
-  
-  SetErrorHandler(imagick_error_handler);
-  SetWarningHandler(imagick_warning_handler);
-
-  /* Write out to a temp file - not sure if ImageMagick supports the
-  ** notion of an abstract 'data source' right now.
-  ** JH: It doesn't as of 3.9.3
-  */
+
+  return Qnil;
+}
+
+static void
+gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+		 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+		 int dest_mask, Lisp_Object domain)
+{
+  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,
+     because the unwind-protect is always executed when this
+     stack frame is still valid. */
+  struct gif_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));
+  scr = DefaultScreenOfDisplay (dpy);
+  cmap = DEVICE_X_COLORMAP (XDEVICE(device));
+  vis = DEVICE_X_VISUAL (XDEVICE(device));
+
+  memset (&unwind, 0, sizeof (unwind));
+  unwind.dpy = dpy;
+  unwind.cmap = cmap;
+  record_unwind_protect (gif_instantiate_unwind, make_opaque_ptr (&unwind));
+
+  /* 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));
+
+    write_lisp_string_to_temp_file (data, unwind.tempfile);
+    unwind.tempfile_needs_to_be_removed = 1;
+
+    /* 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;
+  }
+
+  /* 2. Now allocate the colors for the image. */
+  {
+    int i;
+    ColorMapObject *cmo = unwind.giffile->SColorMap;
+    /* 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;
+
+    for (i = 0; i < 256; i++)
+      unwind.pixels[i] = 0;   /* Use a reasonable color for out of range. */
+
+    /* Allocate pixels for the various colors. */
+    for (i = 0; i < cmo->ColorCount; i++)
+      {
+	XColor color;
+
+	color.red = cmo->Colors[i].Red << 8;
+	color.green = cmo->Colors[i].Green << 8;
+	color.blue = cmo->Colors[i].Blue << 8;
+	color.flags = DoRed | DoGreen | DoBlue;
+
+	allocate_nearest_color (dpy, cmap, vis, &color);
+	unwind.pixels[i] = color.pixel;
+      }
+  }
+
+  /* 3. Now create the image */
+  {
+    int height = unwind.giffile->SHeight;
+    int width = unwind.giffile->SWidth;
+    int depth;
+    int bitmap_pad;
+    int i, j, row, pass, interlace;
+    /* 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 };
+
+    depth = DEVICE_X_DEPTH(XDEVICE(device));
+
+    /* first get bitmap_pad (from XPM) */
+    bitmap_pad = ((depth > 16) ? 32 :
+		  (depth >  8) ? 16 :
+		  8);
+
+    unwind.ximage = XCreateImage (dpy, vis,
+				  depth, ZPixmap, 0, 0, width, height,
+				  bitmap_pad, 0);
+
+    if (!unwind.ximage)
+      signal_simple_error ("Unable to create X image struct", instantiator);
+
+    /* now that bytes_per_line must have been set properly alloc data */
+    unwind.ximage->data =
+      (char *) xmalloc (unwind.ximage->bytes_per_line * height);
+
+    /* write the data --
+       #### XPutPixel() is a client-side-only function but could
+       still be slow.  Another possibility is to just convert to
+       XPM format and use the Xpm routines, which optimize this
+       stuff; but it's doubtful that this will be faster in the
+       long run, what with all the XPM overhead.  If this proves
+       to be a bottleneck here, maybe we should just copy the
+       optimization routines from XPM (they're in turn mostly
+       copied from the Xlib source code). */
+
+    /* 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;
+    for (i = 0; i < height; i++)
+      {
+	if (interlace && row >= height)
+	  row = InterlacedOffset[++pass];
+
+	for (j = 0; j < width; j++)
+	  XPutPixel (unwind.ximage, j, row,
+		     unwind.pixels[(unsigned char)
+				  /* incorrect signed declaration
+				     of RasterBits[] */
+				  (unwind.giffile->SavedImages[0].
+				   RasterBits[i * width + j])]);
+
+	row += interlace ? InterlacedJumps[pass] : 1;
+      }
+  }
+
+  /* 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,
+				    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;
+  unbind_to (speccount, Qnil);
+}
+
+#endif /* HAVE_GIF */
+
+
+#ifdef HAVE_PNG
+/* #define USE_TEMP_FILES_FOR_PNG_IMAGES 1 */
+
+/**********************************************************************
+ *                             PNG                                    *
+ **********************************************************************/
+static void
+png_validate (Lisp_Object instantiator)
+{
+  file_or_data_must_be_present (instantiator);
+}
+
+static Lisp_Object
+png_normalize (Lisp_Object inst, Lisp_Object console_type)
+{
+  return simple_image_type_normalize (inst, console_type, Qpng);
+}
+
+static int
+png_possible_dest_types (void)
+{
+  return IMAGE_COLOR_PIXMAP_MASK;
+}
+
+#if !defined (USE_TEMP_FILES_FOR_PNG_IMAGES) && (PNG_LIBPNG_VER >= 87)
+struct png_memory_storage
+{
+  Extbyte *bytes;		/* The data       */
+  Extcount len;			/* How big is it? */
+  int index;			/* Where are we?  */
+};
+
+static void png_read_from_memory(png_structp png_ptr, png_bytep data,
+				 png_uint_32 length)
+{
+   struct png_memory_storage *tbr =
+     (struct png_memory_storage *) png_get_io_ptr (png_ptr);
+
+   if (length > (tbr->len - tbr->index))
+     png_error (png_ptr, (png_const_charp) "Read Error");
+   memcpy(data,tbr->bytes + tbr->index,length);
+   tbr->index = tbr->index + length;
+}
+#endif /* !USE_TEMP_FILES_FOR_PNG_IMAGESS || PNG_LIBPNG_VER >= 87 */
+
+struct png_unwind_data
+{
+  Display *dpy;
+  Colormap cmap;
+  FILE *instream;
+  png_struct *png_ptr;
+  png_info *info_ptr;
+  unsigned long *pixels;
+  int npixels;
+  XImage *ximage;
+  char tempfile[50];
+  int tempfile_needs_to_be_removed;
+};
+
+static Lisp_Object
+png_instantiate_unwind (Lisp_Object unwind_obj)
+{
+  struct png_unwind_data *data =
+    (struct png_unwind_data *) get_opaque_ptr (unwind_obj);
+
+  free_opaque_ptr (unwind_obj);
+  if (data->png_ptr)
+    png_read_destroy (data->png_ptr, data->info_ptr, (png_info *) 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);
+    }
+
+  if (data->ximage)
+    {
+      if (data->ximage->data)
+	{
+	  xfree (data->ximage->data);
+	  data->ximage->data = 0;
+	}
+      XDestroyImage (data->ximage);
+    }
+
+  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,
+		 int dest_mask, Lisp_Object domain)
+{
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
+  Display *dpy;
+  Colormap cmap;
+  Visual *vis;
+  struct png_unwind_data unwind;
+  int speccount = specpdl_depth ();
+
+  /* PNG variables */
+  png_struct *png_ptr;
+  png_info *info_ptr;
+
+  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));
+  vis = DEVICE_X_VISUAL (XDEVICE(device));
+
+  png_ptr  = xnew (png_struct);
+  info_ptr = xnew (png_info);
+
+  memset (&unwind, 0, sizeof (unwind));
+  unwind.png_ptr = png_ptr;
+  unwind.info_ptr = info_ptr;
+  unwind.dpy = dpy;
+  unwind.cmap = cmap;
+
+  record_unwind_protect (png_instantiate_unwind, make_opaque_ptr (&unwind));
+
+  /* This code is a mixture of stuff from Ben's GIF/JPEG stuff from
+     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);
 
@@ -1826,156 +2675,254 @@
     unwind.tempfile_needs_to_be_removed = 1;
 
     if ((unwind.instream = fopen (unwind.tempfile, "rb")) == NULL)
-      report_file_error ("Opening ImageMagick temp file",
+      report_file_error ("Opening PNG temp file",
 			 list1 (build_string (unwind.tempfile)));
   }
-
-  /* Initialize structures and read in the image */
-  GetImageInfo(&image_info);
-  strcpy(image_info.filename,unwind.tempfile);
-  unwind.image = ReadImage(&image_info);
-
-  if (unwind.image == (Image *) NULL) {
-    signal_simple_error ("Unable to read image.",instantiator);
-  }
-
-#if 1
-  /*
-   * For now, force dithering everything, and deal with all images as if they
-   * were PseudoClass images
-   */
-  if (unwind.image->class != PseudoClass) {
-    QuantizeInfo quantize_info;
-    GetQuantizeInfo(&quantize_info);
-    quantize_info.number_colors=256;
-    quantize_info.tree_depth=8;
-    quantize_info.dither=True;
-    quantize_info.colorspace=RGBColorspace;
-    QuantizeImage(&quantize_info, unwind.image);
-    SyncImage(unwind.image);
-    /* #### It would probably be a good idea to sort the colormap by popularity,
-     * so that in case we run out of entries in the map, it will likely be on
-     * the less used colors
-     */
-  } else {
-    CompressColormap(unwind.image);
-    SyncImage(unwind.image);
-  }
-  
+#else
+  /* Nothing */
 #endif
 
-#if 0
-  DescribeImage(unwind.image,stderr,1);
-#endif
-
-  unwind.ximage = XCreateImage(dpy, visual, depth,
-			       (depth == 1) ? XYPixmap : ZPixmap,
-			       0, 0,
-			       unwind.image->columns,
-			       unwind.image->rows,
-			       XBitmapPad(dpy), 0);
-
-  if (!unwind.ximage) {
-    signal_simple_error("Unable to allocate XImage structure",
-			instantiator);
-  }
-
-  unwind.ximage->data = (char *) xmalloc(unwind.ximage->bytes_per_line *
-					 unwind.ximage->height);
-
-  if (unwind.ximage->data == (char *)NULL) {
-    signal_simple_error("Unable to allocate XImage data information",
-			instantiator);
+  /* 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))
+    {
+      /* 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);
+    }
+
+  /* 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;
+    Extcount len;
+    struct png_memory_storage tbr; /* Data to be read */
+
+    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. */
+    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);
   }
-
-  
-  /*
-  ** First pull out all of the colors used, and create a lookup for them
-  */
-
-  if (unwind.image->class == PseudoClass) {
-    int i;
-
-    unwind.npixels = unwind.image->colors;
-    unwind.pixels = xmalloc(unwind.npixels * sizeof(unsigned long));
-    for (i = 0; i < unwind.npixels; i++) {
-      XColor color;
-      /* ImageMagic uses 8bit values for colors, whilst X expects 16bits */
-      color.red = unwind.image->colormap[i].red << 8;
-      color.green = unwind.image->colormap[i].green << 8;
-      color.blue = unwind.image->colormap[i].blue << 8;
-      color.flags = DoRed | DoGreen | DoBlue;
-      allocate_nearest_color (dpy, cmap, visual, &color);
-      unwind.pixels[i] = color.pixel;
-    }
-  }
-  
-  /*
-  ** Need to pull the data from the 'Image' structure in
-  ** unwind.image and convert it to an 'XImage' in unwind.ximage
-  */
+#endif
+
+  png_read_info (png_ptr, info_ptr);
+
+  /* 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 */
+  if (info_ptr->bit_depth == 16)
+    png_set_strip_16 (png_ptr);
+  if (info_ptr->bit_depth < 8)
+    png_set_packing (png_ptr);
+  /* ##### Perhaps some way to specify the screen gamma should be in here? */
+
   {
-    int i,j,x,b;
-    unsigned int bytes_per_pixel, scanline_pad;
-    unsigned long pixval;
-    unsigned char *q, *pixar;
-    RunlengthPacket *p;
-
-    q = (unsigned char *) unwind.ximage->data;
-    x  = 0;
-    p = unwind.image->pixels;
-    scanline_pad = unwind.ximage->bytes_per_line -
-      ((unwind.ximage->width * unwind.ximage->bits_per_pixel) >> 3);
-
-    /* Convert to multi-byte color-mapped X image. */
-    bytes_per_pixel=unwind.ximage->bits_per_pixel >> 3;
-
-    pixar = (unsigned char *) alloca (bytes_per_pixel);
-
-    for (i=0; i < unwind.image->packets; i++) {
-      if (unwind.image->class == PseudoClass) 
-	pixval = unwind.pixels[p->index];
+    int height = info_ptr->height;
+    int width = info_ptr->width;
+    int depth = info_ptr->bit_depth;
+    int linesize = max (info_ptr->bit_depth >> 3, 1) * width;
+    int bitmap_pad;
+    int y;
+    XColor color;
+    png_byte *png_pixels;
+    png_byte **row_pointers;
+    png_color static_color_cube[216];
+
+    /* Wow, allocate all the memory.  Truly, exciting. */
+    unwind.pixels = xnew_array (unsigned long, 256);
+    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);
+
+    /*  #### This is where we should handle transparency, but I am unsure of
+	how exactly to get that information right now, in a safe manner. */
+#if 0
+    {
+      png_color_16 current_background;
+
+      /* Some appropriate magic should go here to get the current
+	 buffers (device?)  background color and convert it to a
+	 png_color_16 struct */
+      if (info_ptr->valid & PNG_INFO_bKGD)
+	png_set_background (png_ptr, &(info_ptr->background), PNG_GAMMA_FILE,
+			    1, 1.0);
       else
+	png_set_background (png_ptr, &current_background, PNG_GAMMA_SCREEN,
+			    0, 1.0);
+    }
+#endif
+
+    if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
+	(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA))
+      {
+	if (!(info_ptr->valid & PNG_INFO_PLTE))
+	  {
+	    for (y = 0; y < 216; y++)
+	      {
+		static_color_cube[y].red = (y % 6) * 255.0 / 5;
+		static_color_cube[y].green = ((y / 6) % 6) * 255.0 / 5;
+		static_color_cube[y].blue = (y / 36) * 255.0 / 5;
+	      }
+	    png_set_dither (png_ptr, static_color_cube, 216, 216, NULL, 1);
+	  }
+	else
+	  {
+	    png_set_dither (png_ptr, info_ptr->palette, info_ptr->num_palette,
+			    info_ptr->num_palette, info_ptr->hist, 1);
+	  }
+      }
+
+    png_read_image (png_ptr, row_pointers);
+    png_read_end (png_ptr, info_ptr);
+
+    /* 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++)
+	  {
+	    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;
+	  }
+      }
+    else
+      {
+	unwind.npixels = 216;
+	for (y = 0; y < 216; y++)
+	  {
+	    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;
+	  }
+      }
+
+#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++)
 	{
-	  /* ### NOW what? */
-	  pixval = 0;
+	  /* 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);
 	}
-
-      for (b=0; b < bytes_per_pixel; b++) {
-	if (unwind.ximage->bitmap_bit_order == LSBFirst) 
-	  pixar[b] = (unsigned char)pixval;
-	else
-	  pixar[bytes_per_pixel - 1 - b] = (unsigned char)pixval;
-	pixval>>=8;
-      }
-
-      for (j=0; j <= ((int) p->length); j++) {
-	for (b=0; b < bytes_per_pixel; b++) 
-	  *q++= pixar[b];
-	x++;
-	if (x == unwind.ximage->width) {
-	  x=0;
-	  q+=scanline_pad;
-	}
-      }
-      p++;
     }
+#endif
+
+    /* Now create the image */
+
+    depth = DEVICE_X_DEPTH(XDEVICE(device));
+
+    /* first get bitmap_pad (from XPM) */
+    bitmap_pad = ((depth > 16) ? 32 :
+		  (depth >  8) ? 16 :
+		  8);
+
+    unwind.ximage = XCreateImage (dpy, vis,
+				  depth, ZPixmap, 0, 0, width, height,
+				  bitmap_pad, 0);
+
+    if (!unwind.ximage)
+      signal_simple_error ("Unable to create X image struct",
+			   instantiator);
+
+    /* now that bytes_per_line must have been set properly alloc data */
+    unwind.ximage->data = (char *) xmalloc (unwind.ximage->bytes_per_line *
+					    height);
+
+    {
+      int i, j;
+      for (i = 0; i < height; i++)
+	for (j = 0; j < width; j++)
+	  XPutPixel (unwind.ximage, j, i,
+		     unwind.pixels[png_pixels[i * width + j]]);
+    }
+
+    xfree (row_pointers);
+    xfree (png_pixels);
   }
 
   init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
 				    unwind.pixels, unwind.npixels,
 				    instantiator);
 
-  /* And we are done!
-  ** 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.
-  */
+  /* This will clean up everything else. */
   unwind.npixels = 0;
   unbind_to (speccount, Qnil);
 }
 
-#endif /* HAVE_IMAGEMAGICK */
+#endif /* HAVE_PNG */
+
+
+#ifdef HAVE_TIFF
+
+/**********************************************************************
+ *                             TIFF                                   *
+ **********************************************************************/
+static void
+tiff_validate (Lisp_Object instantiator)
+{
+  file_or_data_must_be_present (instantiator);
+}
+
+static Lisp_Object
+tiff_normalize (Lisp_Object inst, Lisp_Object console_type)
+{
+  signal_simple_error ("No TIFF support yet", inst);
+  return Qnil;
+}
+
+static int
+tiff_possible_dest_types (void)
+{
+  return IMAGE_COLOR_PIXMAP_MASK;
+}
+
+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 ();
+}
+
+#endif /* HAVE_TIFF */
 
 
 #ifdef HAVE_XFACE
@@ -2882,55 +3829,52 @@
   IIFORMAT_VALID_KEYWORD (font, Q_foreground, check_valid_string);
   IIFORMAT_VALID_KEYWORD (font, Q_background, check_valid_string);
 
-#ifdef HAVE_IMAGEMAGICK
-  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (imagick, "imagick");
-
-  IIFORMAT_HAS_METHOD (imagick, validate);
-  IIFORMAT_HAS_METHOD (imagick, normalize);
-  IIFORMAT_HAS_METHOD (imagick, possible_dest_types);
-  IIFORMAT_HAS_METHOD (imagick, instantiate);
-
-  IIFORMAT_VALID_KEYWORD (imagick, Q_data, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (imagick, Q_file, check_valid_string);
-
-#ifdef OLDCOMPAT /* old graphics compatibility */
-#define IIFORMAT_USES_METHOD(format, source, m) \
-  (format##_image_instantiator_methods->m##_method = source##_##m)
-
+#ifdef HAVE_JPEG
+  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (jpeg, "jpeg");
+
+  IIFORMAT_HAS_METHOD (jpeg, validate);
+  IIFORMAT_HAS_METHOD (jpeg, normalize);
+  IIFORMAT_HAS_METHOD (jpeg, possible_dest_types);
+  IIFORMAT_HAS_METHOD (jpeg, instantiate);
+
+  IIFORMAT_VALID_KEYWORD (jpeg, Q_data, check_valid_string);
+  IIFORMAT_VALID_KEYWORD (jpeg, Q_file, check_valid_string);
+#endif
+
+#ifdef HAVE_GIF
+  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (gif, "gif");
+
+  IIFORMAT_HAS_METHOD (gif, validate);
+  IIFORMAT_HAS_METHOD (gif, normalize);
+  IIFORMAT_HAS_METHOD (gif, possible_dest_types);
+  IIFORMAT_HAS_METHOD (gif, instantiate);
+
+  IIFORMAT_VALID_KEYWORD (gif, Q_data, check_valid_string);
+  IIFORMAT_VALID_KEYWORD (gif, Q_file, check_valid_string);
+#endif
+
+#ifdef HAVE_PNG
+  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (png, "png");
+
+  IIFORMAT_HAS_METHOD (png, validate);
+  IIFORMAT_HAS_METHOD (png, normalize);
+  IIFORMAT_HAS_METHOD (png, possible_dest_types);
+  IIFORMAT_HAS_METHOD (png, instantiate);
+
+  IIFORMAT_VALID_KEYWORD (png, Q_data, check_valid_string);
+  IIFORMAT_VALID_KEYWORD (png, Q_file, check_valid_string);
+#endif
+
+#ifdef HAVE_TIFF
   INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tiff, "tiff");
-  IIFORMAT_USES_METHOD (tiff, imagick, validate);
-  IIFORMAT_USES_METHOD (tiff, imagick, normalize);
-  IIFORMAT_USES_METHOD (tiff, imagick, possible_dest_types);
-  IIFORMAT_USES_METHOD (tiff, imagick, instantiate);
+
+  IIFORMAT_HAS_METHOD (tiff, validate);
+  IIFORMAT_HAS_METHOD (tiff, normalize);
+  IIFORMAT_HAS_METHOD (tiff, possible_dest_types);
+  IIFORMAT_HAS_METHOD (tiff, instantiate);
+
   IIFORMAT_VALID_KEYWORD (tiff, Q_data, check_valid_string);
   IIFORMAT_VALID_KEYWORD (tiff, Q_file, check_valid_string);
-
-  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (png, "png");
-  IIFORMAT_USES_METHOD (png, imagick, validate);
-  IIFORMAT_USES_METHOD (png, imagick, normalize);
-  IIFORMAT_USES_METHOD (png, imagick, possible_dest_types);
-  IIFORMAT_USES_METHOD (png, imagick, instantiate);
-  IIFORMAT_VALID_KEYWORD (png, Q_data, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (png, Q_file, check_valid_string);
-
-  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (gif, "gif");
-  IIFORMAT_USES_METHOD (gif, imagick, validate);
-  IIFORMAT_USES_METHOD (gif, imagick, normalize);
-  IIFORMAT_USES_METHOD (gif, imagick, possible_dest_types);
-  IIFORMAT_USES_METHOD (gif, imagick, instantiate);
-  IIFORMAT_VALID_KEYWORD (gif, Q_data, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (gif, Q_file, check_valid_string);
-
-  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (jpeg, "jpeg");
-  IIFORMAT_USES_METHOD (jpeg, imagick, validate);
-  IIFORMAT_USES_METHOD (jpeg, imagick, normalize);
-  IIFORMAT_USES_METHOD (jpeg, imagick, possible_dest_types);
-  IIFORMAT_USES_METHOD (jpeg, imagick, instantiate);
-  IIFORMAT_VALID_KEYWORD (jpeg, Q_data, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (jpeg, Q_file, check_valid_string);
-
-#endif /* old compat */
-
 #endif
 
 #ifdef HAVE_XPM
@@ -2976,6 +3920,22 @@
 void
 vars_of_glyphs_x (void)
 {
+#ifdef HAVE_JPEG
+  Fprovide (Qjpeg);
+#endif
+
+#ifdef HAVE_GIF
+  Fprovide (Qgif);
+#endif
+
+#ifdef HAVE_PNG
+  Fprovide (Qpng);
+#endif
+
+#ifdef HAVE_TIFF
+  Fprovide (Qtiff);
+#endif
+
 #ifdef HAVE_XPM
   Fprovide (Qxpm);
 
@@ -2993,17 +3953,6 @@
   Vxpm_color_symbols = Qnil; /* initialized in x-faces.el */
 #endif
 
-#ifdef HAVE_IMAGEMAGICK
-  Fprovide (Qimagick);
-
-#ifdef OLDCOMPAT
-  Fprovide (Qtiff);
-  Fprovide (Qpng);
-  Fprovide (Qgif);
-  Fprovide (Qjpeg);
-#endif
-#endif
-
 #ifdef HAVE_XFACE
   Fprovide (Qxface);
 #endif
--- a/src/gmalloc.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/gmalloc.c	Mon Aug 13 10:19:59 2007 +0200
@@ -402,7 +402,23 @@
 #endif
 
 /* How to really get more memory.  */
+#ifdef HEAP_IN_DATA
+/* once dumped, free() & realloc() on static heap space will fail */
+#define PURE_DATA(x) \
+((static_heap_dumped && (char*)x >= static_heap_base \
+  && (char*)x <= (static_heap_base + static_heap_size) ) ? 1 : 0)
+extern int initialized;
+extern int purify_flag;
+extern char* static_heap_base;
+extern char* static_heap_ptr;
+extern char* static_heap_dumped;
+extern unsigned long static_heap_size;
+extern __ptr_t more_static_core __P ((ptrdiff_t __size));
+__ptr_t (*__morecore) __P ((ptrdiff_t __size)) = more_static_core;
+#else
 __ptr_t (*__morecore) __P ((ptrdiff_t __size)) = __default_morecore;
+#define PURE_DATA(x) 0
+#endif
 
 /* Debugging hook for `malloc'.  */
 __ptr_t (*__malloc_hook) __P ((__malloc_size_t __size));
@@ -465,19 +481,30 @@
 static int
 initialize ()
 {
+#ifdef HEAP_IN_DATA
+  if (static_heap_dumped && __morecore == more_static_core)
+    {
+      __morecore = __default_morecore;
+    }
+#endif
   heapsize = HEAP / BLOCKSIZE;
   _heapinfo = (malloc_info *) align (heapsize * sizeof (malloc_info));
   if (_heapinfo == NULL)
     return 0;
   memset (_heapinfo, 0, heapsize * sizeof (malloc_info));
+  memset (_fraghead, 0, BLOCKLOG * sizeof (struct list));
   _heapinfo[0].free.size = 0;
   _heapinfo[0].free.next = _heapinfo[0].free.prev = 0;
   _heapindex = 0;
+  _heaplimit = 0;
   _heapbase = (char *) _heapinfo;
 
   /* Account for the _heapinfo block itself in the statistics.  */
   _bytes_used = heapsize * sizeof (malloc_info);
   _chunks_used = 1;
+  _chunks_free=0;
+  _bytes_free=0;
+  _aligned_blocks=0;
 
   __malloc_initialized = 1;
   return 1;
@@ -936,6 +963,11 @@
   if (ptr == NULL)
     return;
 
+  if (PURE_DATA(ptr))
+    {
+      return;
+    }
+
   for (l = _aligned_blocks; l != NULL; l = l->next)
     if (l->aligned == ptr)
       {
@@ -1112,7 +1144,14 @@
   int type;
   __malloc_size_t block, blocks, oldlimit;
 
-  if (size == 0)
+  if (PURE_DATA(ptr))
+    {
+      result = malloc (size);
+      memcpy(result, ptr, size);
+      return result;
+    }
+  
+  else if (size == 0)
     {
       free (ptr);
       return malloc (0);
--- a/src/gui.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/gui.c	Mon Aug 13 10:19:59 2007 +0200
@@ -23,8 +23,8 @@
 /* Synched up with: Not in FSF. */
 
 #include <config.h>
+#include "lisp.h"
 #include "gui.h"
-#include "lisp.h"
 
 Lisp_Object Q_active, Q_suffix, Q_keys, Q_style, Q_selected;
 Lisp_Object Q_filter, Q_config, Q_included;
@@ -63,6 +63,237 @@
   return 0;
 }
 
+/* 
+ * Initialize the gui_item structure by setting all (GC-protected)
+ * fields to their default values. The defaults are t for :active and
+ * :included values, and nil for others.
+ */
+void
+gui_item_init (struct gui_item *pgui_item)
+{
+  pgui_item->name = Qnil;
+  pgui_item->callback = Qnil;
+  pgui_item->suffix = Qnil;
+  pgui_item->active = Qt;
+  pgui_item->included = Qt;
+  pgui_item->config = Qunbound;
+  pgui_item->filter = Qnil;
+  pgui_item->style = Qnil;
+  pgui_item->selected = Qnil;
+  pgui_item->keys = Qnil;
+}
+
+/*
+ * Add a value VAL associated with keyword KEY into PGUI_ITEM
+ * structure. If KEY is not a keyword, or is an unknown keyword, then
+ * error is signaled.
+ */
+void 
+gui_item_add_keyval_pair (struct gui_item *pgui_item,
+			  Lisp_Object key, Lisp_Object val)
+{
+  if (!KEYWORDP (key))
+    error ("Not a keyword %S in gui item %S", key, pgui_item->name);
+
+  if (EQ (key, Q_suffix))
+    pgui_item->suffix = val;
+  else if (EQ (key, Q_active))
+    pgui_item->active = val;
+  else if (EQ (key, Q_included))
+    pgui_item->included = val;
+  else if (EQ (key, Q_config))
+    pgui_item->config = val;
+  else if (EQ (key, Q_filter))
+    pgui_item->filter = val;
+  else if (EQ (key, Q_style))
+    pgui_item->style = val;
+  else if (EQ (key, Q_selected))
+    pgui_item->selected = val;
+  else if (EQ (key, Q_keys))
+    pgui_item->keys = val;
+  else
+    error ("Unknown keyword %S in gui item %S", key, pgui_item->name);
+}
+
+/*
+ * ITEM is a lisp vector, describing a menu item or a button. The
+ * function extracts the description of the item into the PGUI_ITEM
+ * structure.
+ */
+void
+gui_parse_item_keywords (Lisp_Object item, struct gui_item *pgui_item)
+{
+  int length, plist_p;
+  Lisp_Object *contents;
+
+  CHECK_VECTOR (item);
+  length = XVECTOR_LENGTH (item);
+  contents = XVECTOR_DATA (item);
+
+  if (length < 3)
+    signal_simple_error ("GUI item descriptors must be at least 3 elts long", item);
+
+  /* length 3:		[ "name" callback active-p ]
+     length 4:		[ "name" callback active-p suffix ]
+     		   or	[ "name" callback keyword  value  ]
+     length 5+:		[ "name" callback [ keyword value ]+ ]
+  */
+  plist_p = (length >= 5 || KEYWORDP (contents [2]));
+
+  pgui_item->name = contents [0];
+  pgui_item->callback = contents [1];
+
+  if (!plist_p)
+    /* the old way */
+    {
+      pgui_item->active = contents [2];
+      if (length == 4)
+	pgui_item->suffix = contents [3];
+    }
+  else
+    /* the new way */
+    {
+      int i;
+      if (length & 1)
+	signal_simple_error (
+		"GUI item descriptor has an odd number of keywords and values",
+			     item);
+
+      for (i = 2; i < length;)
+	{
+	  Lisp_Object key = contents [i++];
+	  Lisp_Object val = contents [i++];
+	  gui_item_add_keyval_pair (pgui_item, key, val);
+	}
+    }    
+}
+
+/*
+ * Decide whether a GUI item is active by evaluating its :active form
+ * if any
+ */
+int
+gui_item_active_p (CONST struct gui_item *pgui_item)
+{
+  /* This function can call lisp */
+  
+  /* Shortcut to avoid evaluating Qt each time */
+  return (EQ (pgui_item->active, Qt)
+	  || !NILP (Feval (pgui_item->active)));
+}
+
+/*
+ * Decide whether a GUI item is included by evaluating its :included
+ * form if given, and testing its :config form against supplied CONFLIST
+ * configuration variable
+ */
+int
+gui_item_included_p (CONST struct gui_item *pgui_item, Lisp_Object conflist)
+{
+  /* This function can call lisp */
+
+  /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */
+  if (!EQ (pgui_item->included, Qt)
+      && NILP (Feval (pgui_item->included)))
+    return 0;
+
+  /* Do :config if conflist is given */
+  if (!NILP (conflist) && !NILP (pgui_item->config)
+      && NILP (Fmemq (pgui_item->config, conflist)))
+    return 0;
+
+  return 1;
+}
+
+static DOESNT_RETURN
+signal_too_long_error (Lisp_Object name)
+{
+  error ("GUI item %s produces too long displayable string", name);
+}
+
+/*
+ * Format "left flush" display portion of an item into BUF, guarded by 
+ * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating 
+ * null character, so actual maximum size of buffer consumed is
+ * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
+ * signaled.
+ * Return value is the offset to the terminating null character into the
+ * buffer.
+ */
+unsigned int
+gui_item_display_flush_left  (CONST struct gui_item *pgui_item,
+			      char* buf, unsigned int buf_len)
+{
+  unsigned int consumed;
+
+  /* Copy item name first */
+  CHECK_STRING (pgui_item->name);
+  if (XSTRING_LENGTH (pgui_item->name) > buf_len)
+    signal_too_long_error (pgui_item->name);
+  strcpy (buf, XSTRING_DATA (pgui_item->name));
+  buf += (consumed = XSTRING_LENGTH (pgui_item->name));
+  buf_len -= consumed;
+
+  /* Add space and suffix text, if there is a suffix */
+  if (!NILP (pgui_item->suffix))
+    {
+      if (XSTRING_LENGTH (pgui_item->suffix) + 1 > buf_len)
+	signal_too_long_error (pgui_item->name);
+      *(buf++) = ' ';
+      strcpy (buf, XSTRING_DATA (pgui_item->suffix));
+      consumed += XSTRING_LENGTH (pgui_item->suffix) + 1;
+    }
+
+  return consumed;
+}
+
+/*
+ * Format "right flush" display portion of an item into BUF, guarded by 
+ * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating 
+ * null character, so actual maximum size of buffer consumed is
+ * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
+ * signaled.
+ * Return value is the offset to the terminating null character into the
+ * buffer.
+ */
+unsigned int
+gui_item_display_flush_right (CONST struct gui_item *pgui_item,
+			      char* buf, unsigned int buf_len)
+{
+  *buf = 0;
+
+  /* Have keys? */
+  if (!menubar_show_keybindings)
+    return 0;
+
+  /* Try :keys first */
+  if (!NILP (pgui_item->keys))
+    {
+      CHECK_STRING (pgui_item->keys);
+      if (XSTRING_LENGTH (pgui_item->keys) > buf_len)
+	signal_too_long_error (pgui_item->name);
+      strcpy (buf, XSTRING_DATA (pgui_item->keys));
+      return XSTRING_LENGTH (pgui_item->keys);
+    }
+
+  /* See if we can derive keys out of callback symbol */
+  if (SYMBOLP (pgui_item->callback))
+    {
+      char buf2 [1024];
+      unsigned int len;
+
+      where_is_to_char (pgui_item->callback, buf2);
+      len = strlen (buf2);
+      if (len > buf_len)
+	signal_too_long_error (pgui_item->name);
+      strcpy (buf, buf2);
+      return len;
+    }
+
+  /* No keys - no right flush display */
+  return 0;
+}
+
 #endif /* HAVE_POPUPS */
 
 void
--- a/src/gui.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/gui.h	Mon Aug 13 10:19:59 2007 +0200
@@ -30,6 +30,37 @@
 #ifdef HAVE_POPUPS
 int separator_string_p (CONST char *s);
 extern int popup_up_p;
+
+/* This structure describes gui button,
+   menu item or submenu properties */
+struct gui_item
+{
+  Lisp_Object name;		/* String */
+  Lisp_Object callback;		/* Symbol or form */
+  Lisp_Object suffix;		/* String */
+  Lisp_Object active;		/* Form */
+  Lisp_Object included;		/* Form */
+  Lisp_Object config;		/* Anything EQable */
+  Lisp_Object filter;		/* Form */
+  Lisp_Object style;		/* Symbol */
+  Lisp_Object selected;		/* Form */
+  Lisp_Object keys;		/* String */
+};
+#define GUI_ITEM_LAST_GCPROED keys
+#define GUI_ITEM_GCPRO_COUNT \
+  (slot_offset(struct gui_item, GUI_ITEM_LAST_GCPROED) / sizeof(Lisp_Object) + 1)
+
+void gui_item_init (struct gui_item *pgui_item);
+void gui_item_add_keyval_pair (struct gui_item *pgui_item,
+			       Lisp_Object key, Lisp_Object val);
+void gui_parse_item_keywords (Lisp_Object item, struct gui_item *pgui_item);
+int  gui_item_active_p (CONST struct gui_item *pgui_item);
+int  gui_item_included_p (CONST struct gui_item *pgui_item, Lisp_Object into);
+unsigned int gui_item_display_flush_left  (CONST struct gui_item *pgui_item,
+					   char* buf, unsigned int buf_len);
+unsigned int gui_item_display_flush_right (CONST struct gui_item *pgui_item,
+					   char* buf, unsigned int buf_len);
+
 #endif /* HAVE_POPUPS */
 
 #endif /* _XEMACS_GUI_H_ */
--- a/src/lisp.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/lisp.h	Mon Aug 13 10:19:59 2007 +0200
@@ -195,15 +195,15 @@
   /* Dammit! Macros suffer from dynamic scope! */		\
   /* We demand inline functions! */				\
   int do_realloc_needed_size = (needed_size);			\
-  int newsize = 0;						\
+  int do_realloc_newsize = 0;					\
   while ((sizevar) < (do_realloc_needed_size)) {		\
-    newsize = 2*(sizevar);					\
-    if (newsize < 32)						\
-      newsize = 32;						\
-    (sizevar) = newsize;					\
+    do_realloc_newsize = 2*(sizevar);				\
+    if (do_realloc_newsize < 32)				\
+      do_realloc_newsize = 32;					\
+    (sizevar) = do_realloc_newsize;				\
   }								\
-  if (newsize)							\
-    XREALLOC_ARRAY (basevar, type, newsize);			\
+  if (do_realloc_newsize)					\
+    XREALLOC_ARRAY (basevar, type, do_realloc_newsize);		\
 } while (0)
 
 #ifdef ERROR_CHECK_MALLOC
--- a/src/lread.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/lread.c	Mon Aug 13 10:19:59 2007 +0200
@@ -51,15 +51,14 @@
 Lisp_Object Qvariable_documentation;
 #define LISP_BACKQUOTES
 #ifdef LISP_BACKQUOTES
-/* FSFmacs says:
-
+/*
    Nonzero means inside a new-style backquote
    with no surrounding parentheses.
    Fread initializes this to zero, so we need not specbind it
    or worry about what happens to it when there is an error.
 
-   But this is fucking typical Stallman bogosity.  Nested
-   backquotes are perfectly legal and fail utterly with
+XEmacs:
+   Nested backquotes are perfectly legal and fail utterly with
    this silliness. */
 static int new_backquote_flag, old_backquote_flag;
 Lisp_Object Qbackquote, Qbacktick, Qcomma, Qcomma_at, Qcomma_dot;
@@ -154,12 +153,12 @@
 /* An array describing all known built-in structure types */
 static structure_type_dynarr *the_structure_type_dynarr;
 
-#if 0 /* FSFmacs defun hack */
+#if 0 /* FSF defun hack */
 /* When nonzero, read conses in pure space */
 static int read_pure;
 #endif
 
-#if 0 /* FSFmacs bogosity */
+#if 0 /* FSF stuff */
 /* For use within read-from-string (this reader is non-reentrant!!)  */
 static int read_from_string_index;
 static int read_from_string_limit;
@@ -174,8 +173,8 @@
    correctly because there's no stack of remembered #@-quoted-strings
    and those strings don't generally appear in the file in the same
    order as their #$ references. (Yes, that is amazingly stupid too.
-   WHY IN THE FUCKING HELL CAN'T RMS EVER IMPLEMENT ANYTHING IN A SANE
-   WAY?  It would be trivially easy to always encode the #@ string
+
+   It would be trivially easy to always encode the #@ string
    [which is a comment, anyway] in the middle of the (#$ . INT) cons
    reference.  That way, it would be really easy to implement
    load-force-doc-string in a non-kludgy way by just retrieving the
@@ -585,7 +584,7 @@
       last_file_loaded = file;
       pure_usage = purespace_usage ();
     }
-/*#endif /* DEBUG_XEMACS */
+/*#endif / * DEBUG_XEMACS */
 
   /* If file name is magic, call the handler.  */
   handler = Ffind_file_name_handler (file, Qload);
@@ -836,7 +835,7 @@
 	message ("Loading %s ...done (%d)", XSTRING_DATA (file),
 		 purespace_usage() - pure_usage);
     }
-/*#endif /* DEBUG_XEMACS */
+/*#endif / * DEBUG_XEMACS */
 
   if (!noninteractive)
     PRINT_LOADING_MESSAGE ("done");
@@ -986,7 +985,7 @@
 #ifdef DOS_NT
 	    fd = open (fn, O_RDONLY | O_BINARY, 0);
 #else
-	    fd = open (fn, O_RDONLY, 0);
+	    fd = open (fn, O_RDONLY | OPEN_BINARY, 0);
 #endif
 
 	  if (fd >= 0)
--- a/src/mem-limits.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/mem-limits.h	Mon Aug 13 10:19:59 2007 +0200
@@ -129,6 +129,22 @@
 /* Number of bytes of writable memory we can expect to be able to get */
 extern unsigned int lim_data;
 
+#ifdef HEAP_IN_DATA
+extern unsigned long static_heap_size;
+extern int initialized;
+static void
+get_lim_data (void)
+{
+  if (!initialized)
+    {
+      lim_data = -1; /* static_heap_size; */
+    }
+  else
+    {
+      lim_data = -1;
+    }
+}
+#else
 #ifdef NO_LIM_DATA
 static void
 get_lim_data (void)
@@ -159,7 +175,7 @@
 }
 
 #else /* not USG */
-#if defined( WINDOWSNT ) || defined (__CYGWIN32__)
+#if defined( WINDOWSNT )
 
 static void
 get_lim_data (void)
@@ -206,5 +222,6 @@
 #endif /* not WINDOWSNT */
 #endif /* not USG */
 #endif /* not NO_LIM_DATA */
+#endif /* not HEAP_IN_DATA */
 
 #endif /* _XEMACS_MEM_LIMITS_H_ */
--- a/src/menubar-msw.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/menubar-msw.c	Mon Aug 13 10:19:59 2007 +0200
@@ -101,303 +101,44 @@
 /* Current menubar or popup hashtable. gcpro'ed */
 static Lisp_Object current_hashtable;
 
-/* Bound by menubar.el */
-static Lisp_Object Qfind_menu_item;
-
 /* This is used to allocate unique ids to menu items.
    Items ids are in MENU_ITEM_ID_MIN to MENU_ITEM_ID_MAX.
    Allocation checks that the item is not already in
    the TOP_LEVEL_MENU */
-/* #### defines go to gui-msw.h */
+
+/* #### defines go to gui-msw.h, as the range is shared with toolbars
+   (If only toolbars will be implemented as common controls) */
 #define MENU_ITEM_ID_MIN 0x8000
 #define MENU_ITEM_ID_MAX 0xFFFF
 #define MENU_ITEM_ID_BITS(x) ((x) & 0x7FFF | 0x8000)
 static HMENU top_level_menu;
 
-/* ============= THIS STUFF MIGHT GO SOMEWHERE ELSE ================= */
-
-/* All these functions are windows sys independent, and are candidates
-   to go to lisp code instead */
-
-/*
- * DESCRIPTOR is a list in the form ({:keyword value}+ rest...).
- * This function extracts all the key-value pairs into the newly
- * created plist, and returns pointer to REST. Original list is not
- * modified (heaven save!)
- */
-Lisp_Object
-gui_parse_menu_keywords (Lisp_Object descriptor, Lisp_Object *plist)
-{
-  Lisp_Object pair, key, val;
-  *plist = Qnil;
-  LIST_LOOP (pair, descriptor)
-    {
-      if (!CONSP(pair))
-	signal_simple_error ("Mailformed gui entity descriptor", descriptor);
-      key = XCAR(pair);
-      if (!KEYWORDP (key))
-	return pair;
-      pair = XCDR (pair);
-      if (!CONSP(pair))
-	signal_simple_error ("Mailformed gui entity descriptor", descriptor);
-      val = XCAR (pair);
-      internal_plist_put (plist, key, val);
-    }
-  return pair;
-}
-
-/*
- * DESC is a vector describing a menu item. The function returns menu
- * item name in NAME, callback form in CALLBACK, and all key-values
- * pairs in PLIST. For old-style vectors, the plist is faked.
- */
-void
-gui_parse_button_descriptor (Lisp_Object desc, Lisp_Object *name, 
-			     Lisp_Object *callback, Lisp_Object *plist)
-{
-  int length = XVECTOR_LENGTH (desc);
-  Lisp_Object *contents = XVECTOR_DATA (desc);
-  int plist_p;
-
-  *name = Qnil;
-  *callback = Qnil;
-  *plist = Qnil;
-
-  if (length < 3)
-    signal_simple_error ("Button descriptors must be at least 3 long", desc);
-
-  /* length 3:		[ "name" callback active-p ]
-     length 4:		[ "name" callback active-p suffix ]
-     		   or	[ "name" callback keyword  value  ]
-     length 5+:		[ "name" callback [ keyword value ]+ ]
-   */
-  plist_p = (length >= 5 || KEYWORDP (contents [2]));
-
-  *name = contents [0];
-  *callback = contents [1];
-
-  if (!plist_p)
-    /* the old way */
-    {
-      internal_plist_put (plist, Q_active, contents [2]);
-      if (length == 4)
-	internal_plist_put (plist, Q_suffix, contents [3]);
-    }
-  else
-    /* the new way */
-    {
-      int i;
-      if (length & 1)
-	signal_simple_error (
-		"Button descriptor has an odd number of keywords and values",
-			     desc);
-
-      for (i = 2; i < length;)
-	{
-	  Lisp_Object key = contents [i++];
-	  Lisp_Object val = contents [i++];
-	  if (!KEYWORDP (key))
-	    signal_simple_error_2 ("Not a keyword", key, desc);
-	  internal_plist_put (plist, key, val);
-	}
-    }    
-}
-
-/*
- * Given PLIST of key-value pairs for a menu item or button, consult
- * :included and :config properties (the latter against
- * CONFLIST). Return value is non-zero when item should *not* appear.
- */
-int
-gui_plist_says_item_excluded (Lisp_Object plist, Lisp_Object conflist)
-{
-  Lisp_Object tem;
-  /* This function can call lisp */
+#define MAX_MENUITEM_LENGTH 128
 
-  /* Evaluate :included first */
-  tem = internal_plist_get (plist, Q_included);
-  if (!UNBOUNDP (tem))
-    {
-      tem = Feval (tem);
-      if (NILP (tem))
-	return 1;
-    }
-
-  /* Do :config if conflist is given */
-  if (!NILP (conflist))
-    {
-      tem = internal_plist_get (plist, Q_config);
-      if (!UNBOUNDP (tem))
-	{
-	  tem = Fmemq (tem, conflist);
-	  if (NILP (tem))
-	    return 1;
-	}
-    }
-
-  return 0;
-}
-    
-/*
- * Given PLIST of key-value pairs for a menu item or button, consult
- * :active property. Return non-zero if the item is *inactive*
- */
-int
-gui_plist_says_item_inactive (Lisp_Object plist)
-{
-  Lisp_Object tem;
-  /* This function can call lisp */
-
-  tem = internal_plist_get (plist, Q_active);
-  if (!UNBOUNDP (tem))
-    {
-      tem = Feval (tem);
-      if (NILP (tem))
-	return 1;
-    }
-
-  return 0;
-}
-
-/*
- * Given PLIST of key-value pairs for a menu item or button, evaluate
- * the form which is the value of :filter property. Filter function
- * given DESC as argument. If there's no :filter property, DESC is
- * returned, otherwise the value returned by the filter function is
- * returned. 
- */
-Lisp_Object
-gui_plist_apply_filter (Lisp_Object plist, Lisp_Object desc)
-{
-  Lisp_Object tem;
-  /* This function can call lisp */
-
-  tem = internal_plist_get (plist, Q_filter);
-  if (UNBOUNDP (tem))
-    return desc;
-  else
-    return call1 (tem, desc);
-}
-
-/*
- * This is tricky because there's no menu item styles in Windows, only
- * states: Each item may be given no checkmark, radio or check
- * mark. This function returns required mark style as determined by
- * PLIST. Return value is the value of :style property if the item is
- * :seleted, or nil otherwise
- */
-Lisp_Object
-gui_plist_get_current_style (Lisp_Object plist)
-{
-  Lisp_Object style, selected;
-  style = internal_plist_get (plist, Q_style);
-  if (UNBOUNDP (style) || NILP(style))
-    return Qnil;
-
-  selected = internal_plist_get (plist, Q_selected);
-  if (UNBOUNDP (selected) || NILP(Feval(selected)))
-    return Qnil;
-
-  return style;
-}
-
-Lisp_Object
-current_frame_menubar (CONST struct frame* f)
-{
-  struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
-  return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
-}
-
-/* ============ END IF STUFF THAT MIGHT GO SOMEWHERE ELSE =============== */
-
-/* Change these together */
-#define MAX_MENUITEM_LENGTH 128
-#define DISPLAYABLE_MAX_MENUITEM_LENGTH "128"
-
-static void 
-signal_item_too_long (Lisp_Object name)
-{
-    signal_simple_error ("Menu item is longer than "
-			 DISPLAYABLE_MAX_MENUITEM_LENGTH
-			 " characters", name);
-}
-
-/* #### If this function returned (FLUSHLEFT . FLUSHRIGHT) it also
-   could be moved above that line - it becomes window system
-   independant */
 /*
  * This returns Windows-style menu item string:
  * "Left Flush\tRight Flush"
  */
-static CONST char*
-plist_get_menu_item_name (Lisp_Object name, Lisp_Object callback, Lisp_Object plist)
+static char*
+displayable_menu_item (struct gui_item* pgui_item)
 {
   /* We construct the name in a static buffer. That's fine, beause
      menu items longer than 128 chars are probably programming errors,
      and better be caught than displayed! */
   
-  static char buf[MAX_MENUITEM_LENGTH];
-  char* p = buf;
-  int buf_left = MAX_MENUITEM_LENGTH - 1;
-  Lisp_Object tem;
-
-  /* Get name first */
-  buf_left -= XSTRING_LENGTH (name);
-  if (buf_left < 0)
-    signal_item_too_long (name);
-  strcpy (p, XSTRING_DATA (name));
-  p += XSTRING_LENGTH (name);
+  static char buf[MAX_MENUITEM_LENGTH+2];
+  unsigned int ll, lr;
 
-  /* Have suffix? */
-  tem = internal_plist_get (plist, Q_suffix);
-  if (!UNBOUNDP (tem))
-    {
-      if (!STRINGP (tem))
-	signal_simple_error (":suffix must be a string", tem);
-      buf_left -= XSTRING_LENGTH (tem) + 1;
-      if (buf_left < 0)
-	signal_item_too_long (name);
-      *p++ = ' ';
-      strcpy (p, XSTRING_DATA (tem));
-      p += XSTRING_LENGTH (tem);
-    }
+  /* Left flush part of the string */
+  ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH);
 
-  /* Have keys? */
-  if (menubar_show_keybindings)
-    {
-      static char buf2 [1024];
-      buf2[0] = 0;
+  /* Right flush part */
+  assert (MAX_MENUITEM_LENGTH > ll + 1);
+  lr = gui_item_display_flush_right (pgui_item, buf + ll + 1,
+				     MAX_MENUITEM_LENGTH - ll - 1);
+  if (lr)
+    buf [ll] = '\t';
 
-      tem = internal_plist_get (plist, Q_keys);
-      if (!UNBOUNDP (tem))
-	{
-	  if (!STRINGP (tem))
-	    signal_simple_error (":keys must be a string", tem);
-	  if (XSTRING_LENGTH (tem) > sizeof (buf2) - 1)
-	    signal_item_too_long (name);
-	  strcpy (buf2, XSTRING_DATA (tem));
-	}
-      else if (SYMBOLP (callback))
-	{
-	  /* #### Warning, dependency here on current_buffer and point */
-	  /* #### I've borrowed this warning along with this code from
-	     menubar-x.c. What does that mean? -- kkm */
-	  where_is_to_char (callback, buf2);
-	}
-
-      if (buf2 [0])
-	{
-	  int n = strlen (buf2) + 1;
-	  buf_left -= n;
-	  if (buf_left < 0)
-	    signal_item_too_long (name);
-	  *p++ = '\t';
-	  strcpy (p, buf2);
-	  p += n-1;
-	}
-    }
-  
-  *p = 0;
   return buf;
 }
 
@@ -416,10 +157,11 @@
  * the hashtable rather than abandon it.
  */
 static Lisp_Object
-allocate_menu_item_id (Lisp_Object path, Lisp_Object name)
+allocate_menu_item_id (Lisp_Object path, Lisp_Object name, Lisp_Object suffix)
 {
-  UINT id = MENU_ITEM_ID_BITS (HASH2 (internal_hash (path, 0),
-				      internal_hash (name, 0)));
+  UINT id = MENU_ITEM_ID_BITS (HASH3 (internal_hash (path, 0),
+				      internal_hash (name, 0),
+				      internal_hash (suffix, 0)));
   do {
       id = MENU_ITEM_ID_BITS (id + 1);
   } while (GetMenuState (top_level_menu, id, MF_BYCOMMAND) != 0xFFFFFFFF);
@@ -429,12 +171,7 @@
 static HMENU
 create_empty_popup_menu (void)
 {
-  HMENU submenu = CreatePopupMenu ();
-  /* #### It seems that really we do not need "(empty)" at this stage */
-#if 0
-  AppendMenu (submenu, MF_STRING | MF_GRAYED, EMPTY_ITEM_ID, EMPTY_ITEM_NAME);
-#endif
-  return submenu;
+  return CreatePopupMenu ();
 }
 
 static void
@@ -473,10 +210,8 @@
   else if (VECTORP (item))
     {
       /* An ordinary item - hash its name and callback form. */
-      Lisp_Object plist, name, callback;
-      gui_parse_button_descriptor (item, &name, &callback, &plist);
-      return HASH2 (internal_hash (name, 0),
-		    internal_hash (callback, 0));
+      return HASH2 (internal_hash (XVECTOR_DATA(item)[0], 0),
+		    internal_hash (XVECTOR_DATA(item)[1], 0));
     }
  
   /* An error - will be caught later */
@@ -488,7 +223,6 @@
 			Lisp_Object hash_tab, Lisp_Object item, int flush_right)
 {
   MENUITEMINFO item_info;
-  struct gcpro gcpro1, gcpro2;
 
   item_info.cbSize = sizeof (item_info);
   item_info.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
@@ -511,20 +245,23 @@
   else if (CONSP (item))
     {
       /* Submenu */
-      Lisp_Object subname = XCAR (item);
-      Lisp_Object plist;
       HMENU submenu;
-	
-      if (!STRINGP (subname))
+      struct gui_item gui_item;
+      struct gcpro gcpro1;
+
+      gui_item_init (&gui_item);
+      GCPRO1 (gui_item);
+      gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;
+
+      menu_parse_submenu_keywords (item, &gui_item);
+
+      if (!STRINGP (gui_item.name))
 	signal_simple_error ("Menu name (first element) must be a string", item);
 
-      item = gui_parse_menu_keywords (XCDR (item), &plist);
-      GCPRO1 (plist);
-
-      if (gui_plist_says_item_excluded (plist, Vmenubar_configuration))
+      if (!gui_item_included_p (&gui_item, Vmenubar_configuration))
 	return;
 
-      if (gui_plist_says_item_inactive (plist))
+      if (!gui_item_active_p (&gui_item))
 	item_info.fState = MFS_GRAYED;
       /* Temptation is to put 'else' right here. Although, the
 	 displayed item won't have an arrow indicating that it is a
@@ -532,46 +269,50 @@
       submenu = create_empty_popup_menu();
 
       item_info.fMask |= MIIM_SUBMENU;
-      item_info.dwTypeData = plist_get_menu_item_name (subname, Qnil, plist);
+      item_info.dwTypeData = displayable_menu_item (&gui_item);
       item_info.hSubMenu = submenu;
 
-      UNGCPRO; /* plist */
-
       if (!(item_info.fState & MFS_GRAYED))
 	{
 	  /* Now add the full submenu path as a value to the hash table,
 	     keyed by menu handle */
 	  if (NILP(path))
-	    path = list1 (subname);
-	  else {
-	    Lisp_Object arg[2];
-	    arg[0] = path;
-	    arg[1] = list1 (subname);
-	    GCPRO1 (arg[1]);
-	    path = Fappend (2, arg);
-	    UNGCPRO; /* arg[1] */
-	  }
+	    /* list1 cannot GC */
+	    path = list1 (gui_item.name);
+	  else
+	    {
+	      Lisp_Object arg[2] = { path, list1 (gui_item.name) };
+	      /* Fappend gcpro'es its arg */
+	      path = Fappend (2, arg);
+	    }
 
-	  GCPRO1 (path);
+	  /* Fputhash GCPRO'es PATH */
 	  Fputhash (hmenu_to_lisp_object (submenu), path, hash_tab);
-	  UNGCPRO; /* path */
 	}
+      UNGCPRO; /* gui_item */
     } 
   else if (VECTORP (item))
     {
       /* An ordinary item */
-      Lisp_Object plist, name, callback, style, id;
-      
-      gui_parse_button_descriptor (item, &name, &callback, &plist);
-      GCPRO2 (plist, callback);
+      Lisp_Object style, id;
+      struct gui_item gui_item;
+      struct gcpro gcpro1;
 
-      if (gui_plist_says_item_excluded (plist, Vmenubar_configuration))
+      gui_item_init (&gui_item);
+      GCPRO1 (gui_item);
+      gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;
+
+      gui_parse_item_keywords (item, &gui_item);
+
+      if (!gui_item_included_p (&gui_item, Vmenubar_configuration))
 	return;
 
-      if (gui_plist_says_item_inactive (plist))
-	item_info.fState |= MFS_GRAYED;
+      if (!gui_item_active_p (&gui_item))
+	item_info.fState = MFS_GRAYED;
 
-      style = gui_plist_get_current_style (plist);
+      style = (NILP (gui_item.selected) || NILP (Feval (gui_item.selected))
+	       ? Qnil : gui_item.style);
+
       if (EQ (style, Qradio))
 	{
 	  item_info.fType |= MFT_RADIOCHECK;
@@ -582,18 +323,19 @@
 	  item_info.fState |= MFS_CHECKED;
 	}
 
-      id = allocate_menu_item_id (path, name);
-      Fputhash (id, callback, hash_tab);
-      
-      UNGCPRO; /* plist, callback */
+      id = allocate_menu_item_id (path, gui_item.name,
+				  gui_item.suffix);
+      Fputhash (id, gui_item.callback, hash_tab);
 
       item_info.wID = (UINT) XINT(id);
       item_info.fType |= MFT_STRING;
-      item_info.dwTypeData = plist_get_menu_item_name (name, callback, plist);
+      item_info.dwTypeData = displayable_menu_item (&gui_item);
+
+      UNGCPRO; /* gui_item */
     }
   else
     {
-      signal_simple_error ("Ill-constructed menu descriptor", item);
+      signal_simple_error ("Mailformed menu item descriptor", item);
     }
 
   if (flush_right)
@@ -614,13 +356,18 @@
  * Return value is the menu checksum.
  */
 static unsigned long
-populate_or_checksum_helper (HMENU menu, Lisp_Object path, Lisp_Object descriptor,
+populate_or_checksum_helper (HMENU menu, Lisp_Object path, Lisp_Object desc,
 			     Lisp_Object hash_tab, int bar_p, int populate_p)
 {
-  Lisp_Object menu_name, plist, item_desc;
+  Lisp_Object item_desc;
   int deep_p, flush_right;
   struct gcpro gcpro1;
   unsigned long checksum = 0;
+  struct gui_item gui_item;
+
+  gui_item_init (&gui_item);
+  GCPRO1 (gui_item);
+  gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;
 
   /* Will initially contain only "(empty)" */
   if (populate_p)
@@ -629,33 +376,20 @@
   /* PATH set to nil indicates top-level popup or menubar */
   deep_p = !NILP (path);
 
-  if (!deep_p)
-    top_level_menu = menu;
+  /* Fetch keywords prepending the item list */
+  desc = menu_parse_submenu_keywords (desc, &gui_item);
 
-  if (!CONSP(descriptor))
-    signal_simple_error ("Menu descriptor must be a list", descriptor);
+  /* Check that menu name is specified when expected */
+  if (NILP (gui_item.name) && deep_p)
+    signal_simple_error ("Menu must have a name", desc);
 
-  if (STRINGP (XCAR (descriptor)))
-    {
-      menu_name = XCAR (descriptor);
-      descriptor = XCDR (descriptor);
-    }
-  else
-    {
-      menu_name = Qnil;
-      if (deep_p) /* Not a popup or bar */
-	signal_simple_error ("Menu must have a name", descriptor);
-    }
+  /* Apply filter if specified */
+  if (!NILP (gui_item.filter))
+    desc = call1 (gui_item.filter, desc);
 
-  /* Fetch keywords prepending the item list */
-  descriptor = gui_parse_menu_keywords (descriptor, &plist);
-  GCPRO1 (plist);
-  descriptor = gui_plist_apply_filter (plist, descriptor);
-  UNGCPRO; /* plist */
-  
-  /* Loop thru the descriptor's CDR and add items for each entry */
+  /* Loop thru the desc's CDR and add items for each entry */
   flush_right = 0;
-  EXTERNAL_LIST_LOOP (item_desc, descriptor)
+  EXTERNAL_LIST_LOOP (item_desc, desc)
     {
       if (NILP (XCAR (item_desc)))
 	{
@@ -681,47 +415,30 @@
       /* Add the header to the popup, if told so. The same as in X - an
 	 insensitive item, and a separator (Seems to me, there were
 	 two separators in X... In Windows this looks ugly, anywats. */
-      if (!bar_p && !deep_p && popup_menu_titles && !NILP(menu_name))
+      if (!bar_p && !deep_p && popup_menu_titles && !NILP(gui_item.name))
 	{
+	  CHECK_STRING (gui_item.name);
 	  InsertMenu (menu, 0, MF_BYPOSITION | MF_STRING | MF_DISABLED,
-		      0, XSTRING_DATA(menu_name));
+		      0, XSTRING_DATA(gui_item.name));
 	  InsertMenu (menu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
 	  SetMenuDefaultItem (menu, 0, MF_BYPOSITION);
 	}
     }
+  UNGCPRO; /* gui_item */
   return checksum;
 }
 
 static void
-populate_menu (HMENU menu, Lisp_Object path, Lisp_Object descriptor,
+populate_menu (HMENU menu, Lisp_Object path, Lisp_Object desc,
 			     Lisp_Object hash_tab, int bar_p)
 {
-  populate_or_checksum_helper (menu, path, descriptor, hash_tab, bar_p, 1);
+  populate_or_checksum_helper (menu, path, desc, hash_tab, bar_p, 1);
 }
 
 static unsigned long
-checksum_menu (Lisp_Object descriptor)
-{
-  return populate_or_checksum_helper (NULL, Qnil, descriptor, Qunbound, 0, 0);
-}
-
-static Lisp_Object
-find_menu (Lisp_Object desc, Lisp_Object path)
+checksum_menu (Lisp_Object desc)
 {
-  /* #### find-menu-item is not what's required here. 
-     Need to write this in C, or improve lisp */
-  if (!NILP (path))
-    {
-      desc = call2 (Qfind_menu_item, desc, path);
-      /* desc is (supposed to be) (ITEM . PARENT). Supposed
-         to signal but sometimes manages to return nil */
-      if (!NILP(desc))
-	{
-	  CHECK_CONS (desc);
-	  desc = XCAR (desc);
-	}
-    }
-  return desc;
+  return populate_or_checksum_helper (NULL, Qnil, desc, Qunbound, 0, 0);
 }
 
 static void
@@ -733,6 +450,8 @@
 		      ? symbol_value_in_buffer (Qcurrent_menubar, w->buffer)
 		      : Qnil);
 
+  top_level_menu = menubar;
+
   if (NILP (desc) && menubar != NULL)
     {
       /* Menubar has gone */
@@ -842,13 +561,9 @@
 
   /* Now find a desc chunk for it. If none, then probably menu open
      hook has played too much games around stuff */
-  desc = current_menudesc;
-  if (!NILP (path))
-    {
-      desc = find_menu (desc, path);
-      if (NILP (desc))
-	signal_simple_error ("This menu does not exist any more", path);
-    }
+  desc = Fmenu_find_real_submenu (current_menudesc, path);
+  if (NILP (desc))
+    signal_simple_error ("This menu does not exist any more", path);
 
   /* Now, stuff it */
   /* DESC may be generated by filter, so we have to gcpro it */
@@ -862,6 +577,10 @@
 unsafe_handle_wm_initmenu_1 (struct frame* f)
 {
   /* This function can call lisp */
+
+  /* NOTE: This is called for the bar only, WM_INITMENU
+     for popups is filtered out */
+
   /* #### - this menubar update mechanism is expensively anti-social and
      the activate-menubar-hook is now mostly obsolete. */
 
@@ -878,20 +597,6 @@
   return Qt;
 }
 
-#ifdef KKM_DOES_NOT_LIKE_UNDOCS_SOMETIMES
-
-/* #### This may become wrong in future Windows */
-
-static Lisp_Object
-unsafe_handle_wm_exitmenuloop_1 (struct frame* f)
-{
-  if (!NILP (current_tracking_popup))
-    prune_menubar (f);
-  return Qt;
-}
-
-#endif
-
 /*
  * Return value is Qt if we have dispatched the command,
  * or Qnil if id has not been mapped to a callback.
@@ -924,7 +629,8 @@
   else if (CONSP (command))
       funcsym = Qeval;
   else
-    signal_simple_error ("Illegal callback", command);
+    signal_simple_error ("Callback must be either evallable form or a symbol",
+			 command);
 
   XSETFRAME (frame, f);
   enqueue_misc_user_event (frame, funcsym, command);
@@ -959,14 +665,6 @@
   return unsafe_handle_wm_initmenu_1 (wm_initmenu_frame);
 }
 
-#ifdef KKM_DOES_NOT_LIKE_UNDOCS_SOMETIMES
-static Lisp_Object
-unsafe_handle_wm_exitmenuloop (Lisp_Object u_n_u_s_e_d)
-{
-  return unsafe_handle_wm_exitmenuloop_1 (wm_initmenu_frame);
-}
-#endif
-
 Lisp_Object
 mswindows_handle_wm_initmenupopup (HMENU hmenu, struct frame* frm)
 {
@@ -988,15 +686,12 @@
   return Qt;
 }
 
+/* #### This function goes away. Removing it now may
+   interfere with pending patch 980128-jhar */
 Lisp_Object
 mswindows_handle_wm_exitmenuloop (struct frame* f)
 {
-#ifdef KKM_DOES_NOT_LIKE_UNDOCS_SOMETIMES
-  wm_initmenu_frame = f;
-  return mswindows_protect_modal_loop (unsafe_handle_wm_exitmenuloop, Qnil);
-#else
   return Qt;
-#endif
 }
 
 
@@ -1007,7 +702,13 @@
 static void
 mswindows_update_frame_menubars (struct frame* f)
 {
-  update_frame_menubar_maybe (f);
+  /* #### KLUDGE. menubar.c calls us when the following
+     condition is true:
+	(f->menubar_changed || f->windows_changed)
+     Is that much really necessary?
+     */
+  if (f->menubar_changed)
+    update_frame_menubar_maybe (f);
 }
 
 static void
@@ -1060,6 +761,7 @@
   current_hashtable = Fmake_hashtable (make_int(10), Qequal);
   menu = create_empty_popup_menu();
   Fputhash (hmenu_to_lisp_object (menu), Qnil, current_hashtable);
+  top_level_menu = menu;
   
   ok = TrackPopupMenu (menu,
 		       TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
@@ -1086,7 +788,6 @@
 void
 syms_of_menubar_mswindows (void)
 {
-  defsymbol (&Qfind_menu_item, "find-menu-item");
 }
 
 void
@@ -1106,5 +807,3 @@
   staticpro (&current_menudesc);
   staticpro (&current_hashtable);
 
-  Fprovide (intern ("mswindows-menubars"));
-}
--- a/src/menubar.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/menubar.c	Mon Aug 13 10:19:59 2007 +0200
@@ -30,6 +30,7 @@
 #include "buffer.h"
 #include "device.h"
 #include "frame.h"
+#include "gui.h"
 #include "menubar.h"
 #include "redisplay.h"
 #include "window.h"
@@ -93,6 +94,112 @@
   update_frame_menubars (f);
 }
 
+Lisp_Object
+current_frame_menubar (CONST struct frame* f)
+{
+  struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
+  return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
+}
+
+Lisp_Object
+menu_parse_submenu_keywords (Lisp_Object desc, struct gui_item* pgui_item)
+{
+  /* Menu descriptor should be a list */
+  CHECK_CONS (desc);
+  
+  /* First element may be menu name, although can be omitted.
+     Let's think that if stuff begins with anything than a keyword
+     or a list (submenu), this is a menu name, expected to be a stirng */
+  if (!KEYWORDP (XCAR (desc)) && !CONSP (XCAR (desc)))
+    {
+      CHECK_STRING (XCAR (desc));
+      pgui_item->name = XCAR (desc);
+      desc = XCDR (desc);
+      if (!NILP (desc))
+	CHECK_CONS (desc);
+    }
+
+  /* Walk along all key-value pairs */
+  while (!NILP(desc) && KEYWORDP (XCAR (desc)))
+    {
+      Lisp_Object key, val;
+      key = XCAR (desc);
+      desc = XCDR (desc);
+      CHECK_CONS (desc);
+      val = XCAR (desc);
+      desc = XCDR (desc);
+      if (!NILP (desc))
+	CHECK_CONS (desc);
+      gui_item_add_keyval_pair (pgui_item, key, val);
+    }
+
+  /* Return the rest - supposed to be a list of items */
+  return desc;
+}
+
+DEFUN ("menu-find-real-submenu", Fmenu_find_real_submenu, 2, 2, 0, /*
+Find a submenu descriptor within DESC by following PATH.
+This function finds a submenu descriptor, either from the description
+DESC or generated by a filter within DESC. The function regards :config
+and :included keywords in the DESC, and expands submenus along the
+PATH using :filter functions. Return value is a descriptor for the
+submenu, NOT expanded and NOT checked against :config and :included.
+Also, individual menu items are not looked for, only submenus.
+
+See also 'find-menu-item'
+*/
+       (desc, path))
+{
+  Lisp_Object path_entry, submenu_desc, submenu;
+  struct gcpro gcpro1;
+  struct gui_item gui_item;
+
+  gui_item_init (&gui_item);
+  GCPRO1 (gui_item);
+  gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;
+  
+  EXTERNAL_LIST_LOOP (path_entry, path)
+    {
+      /* Verify that DESC describes a menu, not single item */
+      if (!CONSP (desc))
+	RETURN_UNGCPRO (Qnil);
+
+      /* Parse this menu */
+      desc = menu_parse_submenu_keywords (desc, &gui_item);
+
+      /* Check that this (sub)menu is active */
+      if (!gui_item_active_p (&gui_item))
+	RETURN_UNGCPRO (Qnil);
+
+      /* Apply :filter */
+      if (!NILP (gui_item.filter))
+	desc = call1 (gui_item.filter, desc);
+
+      /* Find the next menu on the path inside this one */
+      EXTERNAL_LIST_LOOP (submenu_desc, desc)
+	{
+	  submenu = XCAR (submenu_desc);
+	  if (CONSP (submenu)
+	      && STRINGP (XCAR (submenu))
+	      && !NILP (Fstring_equal (XCAR (submenu), XCAR (path_entry))))
+	    {
+	      desc = submenu;
+	      goto descend;
+	    }
+	}
+      /* Submenu not found */
+      RETURN_UNGCPRO (Qnil);
+			  
+    descend:
+      /* Prepare for the next iteration */
+      gui_item_init (&gui_item);
+    }
+
+  /* We have successfully descended down the end of the path */
+  UNGCPRO;
+  return desc;
+}
+
 DEFUN ("popup-menu", Fpopup_menu, 1, 2, 0, /*
 Pop up the given menu.
 A menu description is a list of menu items, strings, and submenus.
@@ -239,6 +346,7 @@
   defsymbol (&Qcurrent_menubar, "current-menubar");
   DEFSUBR (Fpopup_menu);
   DEFSUBR (Fnormalize_menu_item_name);
+  DEFSUBR (Fmenu_find_real_submenu);
 }
 
 void
--- a/src/menubar.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/menubar.h	Mon Aug 13 10:19:59 2007 +0200
@@ -29,6 +29,11 @@
 
 void update_frame_menubars (struct frame *f);
 void free_frame_menubars (struct frame *f);
+Lisp_Object menu_parse_submenu_keywords (Lisp_Object desc,
+					 struct gui_item* pgui_item);
+Lisp_Object current_frame_menubar (CONST struct frame* f);
+
+Lisp_Object Fmenu_find_real_submenu (Lisp_Object desc, Lisp_Object path);
 
 #endif /* HAVE_MENUBARS */
 
--- a/src/mule-ccl.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/mule-ccl.c	Mon Aug 13 10:19:59 2007 +0200
@@ -533,8 +533,9 @@
   int code = -1; /* init to illegal value,  */
   int field1, field2;
   Lisp_Object *ccl_prog = ccl->prog;
-  unsigned char *src = source, *src_end = src + src_bytes;
+  CONST unsigned char *src = source, *src_end = src + src_bytes;
   int jump_address = 0; /* shut up the compiler */
+
   int i, j, op;
   int stack_idx = 0;
   /* For the moment, we only support depth 256 of stack.  */ 
--- a/src/objects-msw.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/objects-msw.c	Mon Aug 13 10:19:59 2007 +0200
@@ -48,7 +48,6 @@
 #include "device.h"
 #include "insdel.h"
 
-#include "windows.h"
 #ifdef __CYGWIN32__
 #define stricmp strcasecmp
 #endif
@@ -59,706 +58,732 @@
   COLORREF colorref;
 } colormap_t;
 
+/* Colors from X11R6 "XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp" */
 static CONST colormap_t mswindows_X_color_map[] = 
 {
-  {"Black"			, PALETTERGB (  0,  0,  0)},
-  {"Gray0"			, PALETTERGB (  0,  0,  0)},
-  {"Grey0"			, PALETTERGB (  0,  0,  0)},
-  {"Transparent"			, PALETTERGB (  0,  0,  1)},
-  {"NavyBlue"			, PALETTERGB (  0,  0,128)},
-  {"navy"			, PALETTERGB (  0,  0,128)},
-  {"blue4"			, PALETTERGB (  0,  0,139)},
-  {"MediumBlue"			, PALETTERGB (  0,  0,205)},
-  {"blue3"			, PALETTERGB (  0,  0,205)},
-  {"blue2"			, PALETTERGB (  0,  0,238)},
-  {"Blue"			, PALETTERGB (  0,  0,255)},
-  {"blue1"			, PALETTERGB (  0,  0,255)},
-  {"DarkGreen"			, PALETTERGB (  0, 86, 45)},
-  {"DeepSkyBlue4"			, PALETTERGB (  0,104,139)},
-  {"turquoise4"			, PALETTERGB (  0,134,139)},
-  {"green4"			, PALETTERGB (  0,139,  0)},
-  {"SpringGreen4"			, PALETTERGB (  0,139, 69)},
-  {"cyan4"			, PALETTERGB (  0,139,139)},
-  {"MediumAquamarine"			, PALETTERGB (  0,147,143)},
-  {"DeepSkyBlue3"			, PALETTERGB (  0,154,205)},
-  {"DarkTurquoise"			, PALETTERGB (  0,166,166)},
-  {"LimeGreen"			, PALETTERGB (  0,175, 20)},
-  {"DeepSkyBlue2"			, PALETTERGB (  0,178,238)},
-  {"DeepSkyBlue"			, PALETTERGB (  0,191,255)},
-  {"DeepSkyBlue1"			, PALETTERGB (  0,191,255)},
-  {"turquoise3"			, PALETTERGB (  0,197,205)},
-  {"green3"			, PALETTERGB (  0,205,  0)},
-  {"SpringGreen3"			, PALETTERGB (  0,205,102)},
-  {"cyan3"			, PALETTERGB (  0,205,205)},
-  {"MediumTurquoise"			, PALETTERGB (  0,210,210)},
-  {"turquoise2"			, PALETTERGB (  0,229,238)},
-  {"green2"			, PALETTERGB (  0,238,  0)},
-  {"SpringGreen2"			, PALETTERGB (  0,238,118)},
-  {"cyan2"			, PALETTERGB (  0,238,238)},
-  {"turquoise1"			, PALETTERGB (  0,245,255)},
-  {"MediumSpringGreen"			, PALETTERGB (  0,250,154)},
-  {"Green"			, PALETTERGB (  0,255,  0)},
-  {"green1"			, PALETTERGB (  0,255,  0)},
-  {"SpringGreen"			, PALETTERGB (  0,255,127)},
-  {"SpringGreen1"			, PALETTERGB (  0,255,127)},
-  {"Cyan"			, PALETTERGB (  0,255,255)},
-  {"cyan1"			, PALETTERGB (  0,255,255)},
-  {"Gray1"			, PALETTERGB (  3,  3,  3)},
-  {"Grey1"			, PALETTERGB (  3,  3,  3)},
-  {"Gray2"			, PALETTERGB (  5,  5,  5)},
-  {"Grey2"			, PALETTERGB (  5,  5,  5)},
-  {"Gray3"			, PALETTERGB (  8,  8,  8)},
-  {"Grey3"			, PALETTERGB (  8,  8,  8)},
-  {"Gray4"			, PALETTERGB ( 10, 10, 10)},
-  {"Grey4"			, PALETTERGB ( 10, 10, 10)},
-  {"Gray5"			, PALETTERGB ( 13, 13, 13)},
-  {"Grey5"			, PALETTERGB ( 13, 13, 13)},
-  {"Gray6"			, PALETTERGB ( 15, 15, 15)},
-  {"Grey6"			, PALETTERGB ( 15, 15, 15)},
-  {"DodgerBlue4"			, PALETTERGB ( 16, 78,139)},
-  {"Gray7"			, PALETTERGB ( 18, 18, 18)},
-  {"Grey7"			, PALETTERGB ( 18, 18, 18)},
-  {"Gray8"			, PALETTERGB ( 20, 20, 20)},
-  {"Grey8"			, PALETTERGB ( 20, 20, 20)},
-  {"Gray9"			, PALETTERGB ( 23, 23, 23)},
-  {"Grey9"			, PALETTERGB ( 23, 23, 23)},
-  {"DodgerBlue3"			, PALETTERGB ( 24,116,205)},
-  {"MidnightBlue"			, PALETTERGB ( 25, 25,112)},
-  {"Turquoise"			, PALETTERGB ( 25,204,223)},
-  {"Gray10"			, PALETTERGB ( 26, 26, 26)},
-  {"Grey10"			, PALETTERGB ( 26, 26, 26)},
-  {"Gray11"			, PALETTERGB ( 28, 28, 28)},
-  {"Grey11"			, PALETTERGB ( 28, 28, 28)},
-  {"DodgerBlue2"			, PALETTERGB ( 28,134,238)},
-  {"DodgerBlue"			, PALETTERGB ( 30,144,255)},
-  {"DodgerBlue1"			, PALETTERGB ( 30,144,255)},
-  {"Gray12"			, PALETTERGB ( 31, 31, 31)},
-  {"Grey12"			, PALETTERGB ( 31, 31, 31)},
-  {"LightSeaGreen"			, PALETTERGB ( 32,178,170)},
-  {"Gray13"			, PALETTERGB ( 33, 33, 33)},
-  {"Grey13"			, PALETTERGB ( 33, 33, 33)},
-  {"Indigo2"			, PALETTERGB ( 33,136,104)},
-  {"CornflowerBlue"			, PALETTERGB ( 34, 34,152)},
-  {"ForestGreen"			, PALETTERGB ( 34,139, 34)},
-  {"Gray14"			, PALETTERGB ( 36, 36, 36)},
-  {"Grey14"			, PALETTERGB ( 36, 36, 36)},
-  {"Gray15"			, PALETTERGB ( 38, 38, 38)},
-  {"Grey15"			, PALETTERGB ( 38, 38, 38)},
-  {"RoyalBlue4"			, PALETTERGB ( 39, 64,139)},
-  {"Gray16"			, PALETTERGB ( 41, 41, 41)},
-  {"Grey16"			, PALETTERGB ( 41, 41, 41)},
-  {"Gray17"			, PALETTERGB ( 43, 43, 43)},
-  {"Grey17"			, PALETTERGB ( 43, 43, 43)},
-  {"Gray18"			, PALETTERGB ( 46, 46, 46)},
-  {"Grey18"			, PALETTERGB ( 46, 46, 46)},
-  {"SeaGreen"			, PALETTERGB ( 46,139, 87)},
-  {"SeaGreen4"			, PALETTERGB ( 46,139, 87)},
-  {"DarkSlateGray"			, PALETTERGB ( 47, 79, 79)},
-  {"DarkSlateGrey"			, PALETTERGB ( 47, 79, 79)},
-  {"Gray19"			, PALETTERGB ( 48, 48, 48)},
-  {"Grey19"			, PALETTERGB ( 48, 48, 48)},
-  {"MediumForestGreen"			, PALETTERGB ( 50,129, 75)},
-  {"Aquamarine"			, PALETTERGB ( 50,191,193)},
-  {"YellowGreen"			, PALETTERGB ( 50,216, 56)},
-  {"Gray20"			, PALETTERGB ( 51, 51, 51)},
-  {"Grey20"			, PALETTERGB ( 51, 51, 51)},
-  {"MediumSeaGreen"			, PALETTERGB ( 52,119,102)},
-  {"Gray21"			, PALETTERGB ( 54, 54, 54)},
-  {"Grey21"			, PALETTERGB ( 54, 54, 54)},
-  {"SteelBlue4"			, PALETTERGB ( 54,100,139)},
-  {"Gray22"			, PALETTERGB ( 56, 56, 56)},
-  {"Grey22"			, PALETTERGB ( 56, 56, 56)},
-  {"DarkSlateBlue"			, PALETTERGB ( 56, 75,102)},
-  {"RoyalBlue3"			, PALETTERGB ( 58, 95,205)},
-  {"Gray23"			, PALETTERGB ( 59, 59, 59)},
-  {"Grey23"			, PALETTERGB ( 59, 59, 59)},
-  {"Gray24"			, PALETTERGB ( 61, 61, 61)},
-  {"Grey24"			, PALETTERGB ( 61, 61, 61)},
-  {"Gray25"			, PALETTERGB ( 64, 64, 64)},
-  {"Grey25"			, PALETTERGB ( 64, 64, 64)},
-  {"RoyalBlue"			, PALETTERGB ( 65,105,225)},
-  {"Gray26"			, PALETTERGB ( 66, 66, 66)},
-  {"Grey26"			, PALETTERGB ( 66, 66, 66)},
-  {"RoyalBlue2"			, PALETTERGB ( 67,110,238)},
-  {"SeaGreen3"			, PALETTERGB ( 67,205,128)},
-  {"Gray27"			, PALETTERGB ( 69, 69, 69)},
-  {"Grey27"			, PALETTERGB ( 69, 69, 69)},
-  {"chartreuse4"			, PALETTERGB ( 69,139,  0)},
-  {"aquamarine4"			, PALETTERGB ( 69,139,116)},
-  {"SteelBlue"			, PALETTERGB ( 70,130,180)},
-  {"SlateBlue4"			, PALETTERGB ( 71, 60,139)},
-  {"Gray28"			, PALETTERGB ( 71, 71, 71)},
-  {"Grey28"			, PALETTERGB ( 71, 71, 71)},
-  {"RoyalBlue1"			, PALETTERGB ( 72,118,255)},
-  {"Gray29"			, PALETTERGB ( 74, 74, 74)},
-  {"Grey29"			, PALETTERGB ( 74, 74, 74)},
-  {"SkyBlue4"			, PALETTERGB ( 74,112,139)},
-  {"Indigo"			, PALETTERGB ( 75,  0,130)},
-  {"Gray30"			, PALETTERGB ( 77, 77, 77)},
-  {"Grey30"			, PALETTERGB ( 77, 77, 77)},
-  {"SeaGreen2"			, PALETTERGB ( 78,238,148)},
-  {"Gray31"			, PALETTERGB ( 79, 79, 79)},
-  {"Grey31"			, PALETTERGB ( 79, 79, 79)},
-  {"SteelBlue3"			, PALETTERGB ( 79,148,205)},
-  {"Gray32"			, PALETTERGB ( 82, 82, 82)},
-  {"Grey32"			, PALETTERGB ( 82, 82, 82)},
-  {"DarkSlateGray4"			, PALETTERGB ( 82,139,139)},
-  {"CadetBlue4"			, PALETTERGB ( 83,134,139)},
-  {"DimGray"			, PALETTERGB ( 84, 84, 84)},
-  {"DimGrey"			, PALETTERGB ( 84, 84, 84)},
-  {"Gray33"			, PALETTERGB ( 84, 84, 84)},
-  {"Grey33"			, PALETTERGB ( 84, 84, 84)},
-  {"PaleGreen4"			, PALETTERGB ( 84,139, 84)},
-  {"SeaGreen1"			, PALETTERGB ( 84,255,159)},
-  {"purple4"			, PALETTERGB ( 85, 26,139)},
-  {"DarkOliveGreen"			, PALETTERGB ( 85, 86, 47)},
-  {"Gray34"			, PALETTERGB ( 87, 87, 87)},
-  {"Grey34"			, PALETTERGB ( 87, 87, 87)},
-  {"Gray35"			, PALETTERGB ( 89, 89, 89)},
-  {"Grey35"			, PALETTERGB ( 89, 89, 89)},
-  {"Gray36"			, PALETTERGB ( 92, 92, 92)},
-  {"Grey36"			, PALETTERGB ( 92, 92, 92)},
-  {"SteelBlue2"			, PALETTERGB ( 92,172,238)},
-  {"MediumPurple4"			, PALETTERGB ( 93, 71,139)},
-  {"Gray37"			, PALETTERGB ( 94, 94, 94)},
-  {"Grey37"			, PALETTERGB ( 94, 94, 94)},
-  {"CadetBlue"			, PALETTERGB ( 95,146,158)},
-  {"LightSkyBlue4"			, PALETTERGB ( 96,123,139)},
-  {"Gray38"			, PALETTERGB ( 97, 97, 97)},
-  {"Grey38"			, PALETTERGB ( 97, 97, 97)},
-  {"Gray39"			, PALETTERGB ( 99, 99, 99)},
-  {"Grey39"			, PALETTERGB ( 99, 99, 99)},
-  {"SteelBlue1"			, PALETTERGB ( 99,184,255)},
-  {"Gray40"			, PALETTERGB (102,102,102)},
-  {"Grey40"			, PALETTERGB (102,102,102)},
-  {"PaleTurquoise4"			, PALETTERGB (102,139,139)},
-  {"chartreuse3"			, PALETTERGB (102,205,  0)},
-  {"aquamarine3"			, PALETTERGB (102,205,170)},
-  {"DarkOrchid4"			, PALETTERGB (104, 34,139)},
-  {"LightBlue4"			, PALETTERGB (104,131,139)},
-  {"SlateBlue3"			, PALETTERGB (105, 89,205)},
-  {"Gray41"			, PALETTERGB (105,105,105)},
-  {"Grey41"			, PALETTERGB (105,105,105)},
-  {"OliveDrab4"			, PALETTERGB (105,139, 34)},
-  {"DarkSeaGreen4"			, PALETTERGB (105,139,105)},
-  {"SlateBlue"			, PALETTERGB (106, 90,205)},
-  {"MediumSlateBlue"			, PALETTERGB (106,106,141)},
-  {"IndianRed"			, PALETTERGB (107, 57, 57)},
-  {"Gray42"			, PALETTERGB (107,107,107)},
-  {"Grey42"			, PALETTERGB (107,107,107)},
-  {"OliveDrab"			, PALETTERGB (107,142, 35)},
-  {"SlateGray4"			, PALETTERGB (108,123,139)},
-  {"SkyBlue3"			, PALETTERGB (108,166,205)},
-  {"Gray43"			, PALETTERGB (110,110,110)},
-  {"Grey43"			, PALETTERGB (110,110,110)},
-  {"LightSteelBlue4"			, PALETTERGB (110,123,139)},
-  {"DarkOliveGreen4"			, PALETTERGB (110,139, 61)},
-  {"Gray44"			, PALETTERGB (112,112,112)},
-  {"Grey44"			, PALETTERGB (112,112,112)},
-  {"SlateGray"			, PALETTERGB (112,128,144)},
-  {"SlateGrey"			, PALETTERGB (112,128,144)},
-  {"SkyBlue"			, PALETTERGB (114,159,255)},
-  {"Gray45"			, PALETTERGB (115,115,115)},
-  {"Grey45"			, PALETTERGB (115,115,115)},
-  {"PaleGreen"			, PALETTERGB (115,222,120)},
-  {"Gray46"			, PALETTERGB (117,117,117)},
-  {"Grey46"			, PALETTERGB (117,117,117)},
-  {"chartreuse2"			, PALETTERGB (118,238,  0)},
-  {"aquamarine2"			, PALETTERGB (118,238,198)},
-  {"LightSlateGray"			, PALETTERGB (119,136,153)},
-  {"LightSlateGrey"			, PALETTERGB (119,136,153)},
-  {"Gray47"			, PALETTERGB (120,120,120)},
-  {"Grey47"			, PALETTERGB (120,120,120)},
-  {"DarkSlateGray3"			, PALETTERGB (121,205,205)},
-  {"MediumOrchid4"			, PALETTERGB (122, 55,139)},
-  {"SlateBlue2"			, PALETTERGB (122,103,238)},
-  {"Gray48"			, PALETTERGB (122,122,122)},
-  {"Grey48"			, PALETTERGB (122,122,122)},
-  {"LightCyan4"			, PALETTERGB (122,139,139)},
-  {"CadetBlue3"			, PALETTERGB (122,197,205)},
-  {"LightSteelBlue"			, PALETTERGB (124,152,211)},
-  {"PaleGreen3"			, PALETTERGB (124,205,124)},
-  {"LawnGreen"			, PALETTERGB (124,252,  0)},
-  {"purple3"			, PALETTERGB (125, 38,205)},
-  {"Gray49"			, PALETTERGB (125,125,125)},
-  {"Grey49"			, PALETTERGB (125,125,125)},
-  {"Gray"			, PALETTERGB (126,126,126)},
-  {"Grey"			, PALETTERGB (126,126,126)},
-  {"SkyBlue2"			, PALETTERGB (126,192,238)},
-  {"Gray50"			, PALETTERGB (127,127,127)},
-  {"Grey50"			, PALETTERGB (127,127,127)},
-  {"chartreuse"			, PALETTERGB (127,255,  0)},
-  {"chartreuse1"			, PALETTERGB (127,255,  0)},
-  {"aquamarine1"			, PALETTERGB (127,255,212)},
-  {"Gray51"			, PALETTERGB (130,130,130)},
-  {"Grey51"			, PALETTERGB (130,130,130)},
-  {"SlateBlue1"			, PALETTERGB (131,111,255)},
-  {"honeydew4"			, PALETTERGB (131,139,131)},
-  {"azure4"			, PALETTERGB (131,139,139)},
-  {"LightSlateBlue"			, PALETTERGB (132,112,255)},
-  {"Gray52"			, PALETTERGB (133,133,133)},
-  {"Grey52"			, PALETTERGB (133,133,133)},
-  {"Gray53"			, PALETTERGB (135,135,135)},
-  {"Grey53"			, PALETTERGB (135,135,135)},
-  {"LightSkyBlue"			, PALETTERGB (135,206,250)},
-  {"SkyBlue1"			, PALETTERGB (135,206,255)},
-  {"MediumPurple3"			, PALETTERGB (137,104,205)},
-  {"BlueViolet"			, PALETTERGB (138, 43,226)},
-  {"Gray54"			, PALETTERGB (138,138,138)},
-  {"Grey54"			, PALETTERGB (138,138,138)},
-  {"red4"			, PALETTERGB (139,  0,  0)},
-  {"magenta4"			, PALETTERGB (139,  0,139)},
-  {"DeepPink4"			, PALETTERGB (139, 10, 80)},
-  {"firebrick4"			, PALETTERGB (139, 26, 26)},
-  {"maroon4"			, PALETTERGB (139, 28, 98)},
-  {"DarkOrchid"			, PALETTERGB (139, 32,139)},
-  {"VioletRed4"			, PALETTERGB (139, 34, 82)},
-  {"brown4"			, PALETTERGB (139, 35, 35)},
-  {"OrangeRed4"			, PALETTERGB (139, 37,  0)},
-  {"tomato4"			, PALETTERGB (139, 54, 38)},
-  {"IndianRed4"			, PALETTERGB (139, 58, 58)},
-  {"HotPink4"			, PALETTERGB (139, 58, 98)},
-  {"coral4"			, PALETTERGB (139, 62, 47)},
-  {"DarkOrange4"			, PALETTERGB (139, 69,  0)},
-  {"SaddleBrown"			, PALETTERGB (139, 69, 19)},
-  {"chocolate4"			, PALETTERGB (139, 69, 19)},
-  {"sienna4"			, PALETTERGB (139, 71, 38)},
-  {"PaleVioletRed4"			, PALETTERGB (139, 71, 93)},
-  {"orchid4"			, PALETTERGB (139, 71,137)},
-  {"salmon4"			, PALETTERGB (139, 76, 57)},
-  {"LightSalmon4"			, PALETTERGB (139, 87, 66)},
-  {"orange4"			, PALETTERGB (139, 90,  0)},
-  {"tan4"			, PALETTERGB (139, 90, 43)},
-  {"LightPink4"			, PALETTERGB (139, 95,101)},
-  {"pink4"			, PALETTERGB (139, 99,108)},
-  {"DarkGoldenrod4"			, PALETTERGB (139,101,  8)},
-  {"plum4"			, PALETTERGB (139,102,139)},
-  {"goldenrod4"			, PALETTERGB (139,105, 20)},
-  {"RosyBrown4"			, PALETTERGB (139,105,105)},
-  {"burlywood4"			, PALETTERGB (139,115, 85)},
-  {"gold4"			, PALETTERGB (139,117,  0)},
-  {"PeachPuff4"			, PALETTERGB (139,119,101)},
-  {"NavajoWhite4"			, PALETTERGB (139,121, 94)},
-  {"thistle4"			, PALETTERGB (139,123,139)},
-  {"bisque4"			, PALETTERGB (139,125,107)},
-  {"MistyRose4"			, PALETTERGB (139,125,123)},
-  {"wheat4"			, PALETTERGB (139,126,102)},
-  {"LightGoldenrod4"			, PALETTERGB (139,129, 76)},
-  {"AntiqueWhite4"			, PALETTERGB (139,131,120)},
-  {"LavenderBlush4"			, PALETTERGB (139,131,134)},
-  {"khaki4"			, PALETTERGB (139,134, 78)},
-  {"seashell4"			, PALETTERGB (139,134,130)},
-  {"cornsilk4"			, PALETTERGB (139,136,120)},
-  {"LemonChiffon4"			, PALETTERGB (139,137,112)},
-  {"snow4"			, PALETTERGB (139,137,137)},
-  {"yellow4"			, PALETTERGB (139,139,  0)},
-  {"LightYellow4"			, PALETTERGB (139,139,122)},
-  {"ivory4"			, PALETTERGB (139,139,131)},
-  {"Gray55"			, PALETTERGB (140,140,140)},
-  {"Grey55"			, PALETTERGB (140,140,140)},
-  {"LightSkyBlue3"			, PALETTERGB (141,182,205)},
-  {"DarkSlateGray2"			, PALETTERGB (141,238,238)},
-  {"Firebrick"			, PALETTERGB (142, 35, 35)},
-  {"CadetBlue2"			, PALETTERGB (142,229,238)},
-  {"Maroon"			, PALETTERGB (143,  0, 82)},
-  {"Gray56"			, PALETTERGB (143,143,143)},
-  {"Grey56"			, PALETTERGB (143,143,143)},
-  {"DarkSeaGreen"			, PALETTERGB (143,188,143)},
-  {"PaleGreen2"			, PALETTERGB (144,238,144)},
-  {"purple2"			, PALETTERGB (145, 44,238)},
-  {"Gray57"			, PALETTERGB (145,145,145)},
-  {"Grey57"			, PALETTERGB (145,145,145)},
-  {"MediumPurple"			, PALETTERGB (147,112,219)},
-  {"DarkViolet"			, PALETTERGB (148,  0,211)},
-  {"Gray58"			, PALETTERGB (148,148,148)},
-  {"Grey58"			, PALETTERGB (148,148,148)},
-  {"Sienna"			, PALETTERGB (150, 82, 45)},
-  {"Gray59"			, PALETTERGB (150,150,150)},
-  {"Grey59"			, PALETTERGB (150,150,150)},
-  {"PaleTurquoise3"			, PALETTERGB (150,205,205)},
-  {"DarkSlateGray1"			, PALETTERGB (151,255,255)},
-  {"CadetBlue1"			, PALETTERGB (152,245,255)},
-  {"Gray60"			, PALETTERGB (153,153,153)},
-  {"Grey60"			, PALETTERGB (153,153,153)},
-  {"DarkOrchid3"			, PALETTERGB (154, 50,205)},
-  {"LightBlue3"			, PALETTERGB (154,192,205)},
-  {"OliveDrab3"			, PALETTERGB (154,205, 50)},
-  {"PaleGreen1"			, PALETTERGB (154,255,154)},
-  {"purple1"			, PALETTERGB (155, 48,255)},
-  {"DarkSeaGreen3"			, PALETTERGB (155,205,155)},
-  {"Violet"			, PALETTERGB (156, 62,206)},
-  {"Gray61"			, PALETTERGB (156,156,156)},
-  {"Grey61"			, PALETTERGB (156,156,156)},
-  {"Gray62"			, PALETTERGB (158,158,158)},
-  {"Grey62"			, PALETTERGB (158,158,158)},
-  {"MediumPurple2"			, PALETTERGB (159,121,238)},
-  {"SlateGray3"			, PALETTERGB (159,182,205)},
-  {"purple"			, PALETTERGB (160, 32,240)},
-  {"Gray63"			, PALETTERGB (161,161,161)},
-  {"Grey63"			, PALETTERGB (161,161,161)},
-  {"LightSteelBlue3"			, PALETTERGB (162,181,205)},
-  {"DarkOliveGreen3"			, PALETTERGB (162,205, 90)},
-  {"Gray64"			, PALETTERGB (163,163,163)},
-  {"Grey64"			, PALETTERGB (163,163,163)},
-  {"LightSkyBlue2"			, PALETTERGB (164,211,238)},
-  {"Brown"			, PALETTERGB (165, 42, 42)},
-  {"Gray65"			, PALETTERGB (166,166,166)},
-  {"Grey65"			, PALETTERGB (166,166,166)},
-  {"Gray66"			, PALETTERGB (168,168,168)},
-  {"Grey66"			, PALETTERGB (168,168,168)},
-  {"LightGray"			, PALETTERGB (168,168,168)},
-  {"LightGrey"			, PALETTERGB (168,168,168)},
-  {"MediumPurple1"			, PALETTERGB (171,130,255)},
-  {"Gray67"			, PALETTERGB (171,171,171)},
-  {"Grey67"			, PALETTERGB (171,171,171)},
-  {"Gray68"			, PALETTERGB (173,173,173)},
-  {"Grey68"			, PALETTERGB (173,173,173)},
-  {"LightBlue"			, PALETTERGB (173,216,230)},
-  {"GreenYellow"			, PALETTERGB (173,255, 47)},
-  {"PaleTurquoise2"			, PALETTERGB (174,238,238)},
-  {"PaleTurquoise"			, PALETTERGB (175,238,238)},
-  {"Gray69"			, PALETTERGB (176,176,176)},
-  {"Grey69"			, PALETTERGB (176,176,176)},
-  {"PowderBlue"			, PALETTERGB (176,224,230)},
-  {"LightSkyBlue1"			, PALETTERGB (176,226,255)},
-  {"DarkOrchid2"			, PALETTERGB (178, 58,238)},
-  {"LightBlue2"			, PALETTERGB (178,223,238)},
-  {"Khaki"			, PALETTERGB (179,179,126)},
-  {"Gray70"			, PALETTERGB (179,179,179)},
-  {"Grey70"			, PALETTERGB (179,179,179)},
-  {"OliveDrab2"			, PALETTERGB (179,238, 58)},
-  {"MediumOrchid3"			, PALETTERGB (180, 82,205)},
-  {"LightCyan3"			, PALETTERGB (180,205,205)},
-  {"DarkSeaGreen2"			, PALETTERGB (180,238,180)},
-  {"Gray71"			, PALETTERGB (181,181,181)},
-  {"Grey71"			, PALETTERGB (181,181,181)},
-  {"DarkGoldenrod"			, PALETTERGB (184,134, 11)},
-  {"Gray72"			, PALETTERGB (184,184,184)},
-  {"Grey72"			, PALETTERGB (184,184,184)},
-  {"SlateGray2"			, PALETTERGB (185,211,238)},
-  {"MediumOrchid"			, PALETTERGB (186, 85,211)},
-  {"Gray73"			, PALETTERGB (186,186,186)},
-  {"Grey73"			, PALETTERGB (186,186,186)},
-  {"PaleTurquoise1"			, PALETTERGB (187,255,255)},
-  {"RosyBrown"			, PALETTERGB (188,143,143)},
-  {"LightSteelBlue2"			, PALETTERGB (188,210,238)},
-  {"DarkOliveGreen2"			, PALETTERGB (188,238,104)},
-  {"DarkKhaki"			, PALETTERGB (189,183,107)},
-  {"Gray74"			, PALETTERGB (189,189,189)},
-  {"Grey74"			, PALETTERGB (189,189,189)},
-  {"DarkOrchid1"			, PALETTERGB (191, 62,255)},
-  {"Gray75"			, PALETTERGB (191,191,191)},
-  {"Grey75"			, PALETTERGB (191,191,191)},
-  {"LightBlue1"			, PALETTERGB (191,239,255)},
-  {"OliveDrab1"			, PALETTERGB (192,255, 62)},
-  {"honeydew3"			, PALETTERGB (193,205,193)},
-  {"azure3"			, PALETTERGB (193,205,205)},
-  {"DarkSeaGreen1"			, PALETTERGB (193,255,193)},
-  {"Gray76"			, PALETTERGB (194,194,194)},
-  {"Grey76"			, PALETTERGB (194,194,194)},
-  {"Gray77"			, PALETTERGB (196,196,196)},
-  {"Grey77"			, PALETTERGB (196,196,196)},
-  {"Plum"			, PALETTERGB (197, 72,155)},
-  {"SlateGray1"			, PALETTERGB (198,226,255)},
-  {"MediumVioletRed"			, PALETTERGB (199, 21,133)},
-  {"Gray78"			, PALETTERGB (199,199,199)},
-  {"Grey78"			, PALETTERGB (199,199,199)},
-  {"Gray79"			, PALETTERGB (201,201,201)},
-  {"Grey79"			, PALETTERGB (201,201,201)},
-  {"LightSteelBlue1"			, PALETTERGB (202,225,255)},
-  {"DarkOliveGreen1"			, PALETTERGB (202,255,112)},
-  {"Gray80"			, PALETTERGB (204,204,204)},
-  {"Grey80"			, PALETTERGB (204,204,204)},
-  {"red3"			, PALETTERGB (205,  0,  0)},
-  {"magenta3"			, PALETTERGB (205,  0,205)},
-  {"DeepPink3"			, PALETTERGB (205, 16,118)},
-  {"firebrick3"			, PALETTERGB (205, 38, 38)},
-  {"maroon3"			, PALETTERGB (205, 41,144)},
-  {"VioletRed3"			, PALETTERGB (205, 50,120)},
-  {"brown3"			, PALETTERGB (205, 51, 51)},
-  {"OrangeRed3"			, PALETTERGB (205, 55,  0)},
-  {"tomato3"			, PALETTERGB (205, 79, 57)},
-  {"IndianRed3"			, PALETTERGB (205, 85, 85)},
-  {"coral3"			, PALETTERGB (205, 91, 69)},
-  {"HotPink3"			, PALETTERGB (205, 96,144)},
-  {"DarkOrange3"			, PALETTERGB (205,102,  0)},
-  {"chocolate3"			, PALETTERGB (205,102, 29)},
-  {"sienna3"			, PALETTERGB (205,104, 57)},
-  {"PaleVioletRed3"			, PALETTERGB (205,104,137)},
-  {"orchid3"			, PALETTERGB (205,105,201)},
-  {"salmon3"			, PALETTERGB (205,112, 84)},
-  {"LightSalmon3"			, PALETTERGB (205,129, 98)},
-  {"orange3"			, PALETTERGB (205,133,  0)},
-  {"peru"			, PALETTERGB (205,133, 63)},
-  {"tan3"			, PALETTERGB (205,133, 63)},
-  {"LightPink3"			, PALETTERGB (205,140,149)},
-  {"pink3"			, PALETTERGB (205,145,158)},
-  {"DarkGoldenrod3"			, PALETTERGB (205,149, 12)},
-  {"plum3"			, PALETTERGB (205,150,205)},
-  {"goldenrod3"			, PALETTERGB (205,155, 29)},
-  {"RosyBrown3"			, PALETTERGB (205,155,155)},
-  {"burlywood3"			, PALETTERGB (205,170,125)},
-  {"gold3"			, PALETTERGB (205,173,  0)},
-  {"PeachPuff3"			, PALETTERGB (205,175,149)},
-  {"NavajoWhite3"			, PALETTERGB (205,179,139)},
-  {"thistle3"			, PALETTERGB (205,181,205)},
-  {"bisque3"			, PALETTERGB (205,183,158)},
-  {"MistyRose3"			, PALETTERGB (205,183,181)},
-  {"wheat3"			, PALETTERGB (205,186,150)},
-  {"LightGoldenrod3"			, PALETTERGB (205,190,112)},
-  {"AntiqueWhite3"			, PALETTERGB (205,192,176)},
-  {"LavenderBlush3"			, PALETTERGB (205,193,197)},
-  {"seashell3"			, PALETTERGB (205,197,191)},
-  {"khaki3"			, PALETTERGB (205,198,115)},
-  {"cornsilk3"			, PALETTERGB (205,200,177)},
-  {"LemonChiffon3"			, PALETTERGB (205,201,165)},
-  {"snow3"			, PALETTERGB (205,201,201)},
-  {"yellow3"			, PALETTERGB (205,205,  0)},
-  {"LightYellow3"			, PALETTERGB (205,205,180)},
-  {"ivory3"			, PALETTERGB (205,205,193)},
-  {"Gray81"			, PALETTERGB (207,207,207)},
-  {"Grey81"			, PALETTERGB (207,207,207)},
-  {"VioletRed"			, PALETTERGB (208, 32,144)},
-  {"MediumOrchid2"			, PALETTERGB (209, 95,238)},
-  {"MediumGoldenrod"			, PALETTERGB (209,193,102)},
-  {"Gray82"			, PALETTERGB (209,209,209)},
-  {"Grey82"			, PALETTERGB (209,209,209)},
-  {"LightCyan2"			, PALETTERGB (209,238,238)},
-  {"chocolate"			, PALETTERGB (210,105, 30)},
-  {"tan"			, PALETTERGB (210,180,140)},
-  {"Gray83"			, PALETTERGB (212,212,212)},
-  {"Grey83"			, PALETTERGB (212,212,212)},
-  {"Gray84"			, PALETTERGB (214,214,214)},
-  {"Grey84"			, PALETTERGB (214,214,214)},
-  {"Thistle"			, PALETTERGB (216,191,216)},
-  {"Gray85"			, PALETTERGB (217,217,217)},
-  {"Grey85"			, PALETTERGB (217,217,217)},
-  {"orchid"			, PALETTERGB (218,112,214)},
-  {"goldenrod"			, PALETTERGB (218,165, 32)},
-  {"Gold"			, PALETTERGB (218,170,  0)},
-  {"PaleVioletRed"			, PALETTERGB (219,112,147)},
-  {"Gray86"			, PALETTERGB (219,219,219)},
-  {"Grey86"			, PALETTERGB (219,219,219)},
-  {"Crimson"			, PALETTERGB (220, 20, 60)},
-  {"gainsboro"			, PALETTERGB (220,220,220)},
-  {"burlywood"			, PALETTERGB (222,184,135)},
-  {"Gray87"			, PALETTERGB (222,222,222)},
-  {"Grey87"			, PALETTERGB (222,222,222)},
-  {"MediumOrchid1"			, PALETTERGB (224,102,255)},
-  {"Gray88"			, PALETTERGB (224,224,224)},
-  {"Grey88"			, PALETTERGB (224,224,224)},
-  {"honeydew2"			, PALETTERGB (224,238,224)},
-  {"azure2"			, PALETTERGB (224,238,238)},
-  {"LightCyan"			, PALETTERGB (224,255,255)},
-  {"LightCyan1"			, PALETTERGB (224,255,255)},
-  {"Gray89"			, PALETTERGB (227,227,227)},
-  {"Grey89"			, PALETTERGB (227,227,227)},
-  {"Gray90"			, PALETTERGB (229,229,229)},
-  {"Grey90"			, PALETTERGB (229,229,229)},
-  {"lavender"			, PALETTERGB (230,230,250)},
-  {"Gray91"			, PALETTERGB (232,232,232)},
-  {"Grey91"			, PALETTERGB (232,232,232)},
-  {"DarkSalmon"			, PALETTERGB (233,150,122)},
-  {"Salmon"			, PALETTERGB (233,150,122)},
-  {"Gray92"			, PALETTERGB (235,235,235)},
-  {"Grey92"			, PALETTERGB (235,235,235)},
-  {"Gray93"			, PALETTERGB (237,237,237)},
-  {"Grey93"			, PALETTERGB (237,237,237)},
-  {"red2"			, PALETTERGB (238,  0,  0)},
-  {"magenta2"			, PALETTERGB (238,  0,238)},
-  {"DeepPink2"			, PALETTERGB (238, 18,137)},
-  {"firebrick2"			, PALETTERGB (238, 44, 44)},
-  {"maroon2"			, PALETTERGB (238, 48,167)},
-  {"VioletRed2"			, PALETTERGB (238, 58,140)},
-  {"brown2"			, PALETTERGB (238, 59, 59)},
-  {"OrangeRed2"			, PALETTERGB (238, 64,  0)},
-  {"tomato2"			, PALETTERGB (238, 92, 66)},
-  {"IndianRed2"			, PALETTERGB (238, 99, 99)},
-  {"coral2"			, PALETTERGB (238,106, 80)},
-  {"HotPink2"			, PALETTERGB (238,106,167)},
-  {"DarkOrange2"			, PALETTERGB (238,118,  0)},
-  {"chocolate2"			, PALETTERGB (238,118, 33)},
-  {"sienna2"			, PALETTERGB (238,121, 66)},
-  {"PaleVioletRed2"			, PALETTERGB (238,121,159)},
-  {"orchid2"			, PALETTERGB (238,122,233)},
-  {"salmon2"			, PALETTERGB (238,130, 98)},
-  {"LightSalmon2"			, PALETTERGB (238,149,114)},
-  {"orange2"			, PALETTERGB (238,154,  0)},
-  {"tan2"			, PALETTERGB (238,154, 73)},
-  {"LightPink2"			, PALETTERGB (238,162,173)},
-  {"pink2"			, PALETTERGB (238,169,184)},
-  {"DarkGoldenrod2"			, PALETTERGB (238,173, 14)},
-  {"plum2"			, PALETTERGB (238,174,238)},
-  {"goldenrod2"			, PALETTERGB (238,180, 34)},
-  {"RosyBrown2"			, PALETTERGB (238,180,180)},
-  {"burlywood2"			, PALETTERGB (238,197,145)},
-  {"gold2"			, PALETTERGB (238,201,  0)},
-  {"PeachPuff2"			, PALETTERGB (238,203,173)},
-  {"NavajoWhite2"			, PALETTERGB (238,207,161)},
-  {"thistle2"			, PALETTERGB (238,210,238)},
-  {"bisque2"			, PALETTERGB (238,213,183)},
-  {"MistyRose2"			, PALETTERGB (238,213,210)},
-  {"wheat2"			, PALETTERGB (238,216,174)},
-  {"LightGoldenrod2"			, PALETTERGB (238,220,130)},
-  {"LightGoldenrod"			, PALETTERGB (238,221,130)},
-  {"AntiqueWhite2"			, PALETTERGB (238,223,204)},
-  {"LavenderBlush2"			, PALETTERGB (238,224,229)},
-  {"seashell2"			, PALETTERGB (238,229,222)},
-  {"khaki2"			, PALETTERGB (238,230,133)},
-  {"PaleGoldenrod"			, PALETTERGB (238,232,170)},
-  {"cornsilk2"			, PALETTERGB (238,232,205)},
-  {"LemonChiffon2"			, PALETTERGB (238,233,191)},
-  {"snow2"			, PALETTERGB (238,233,233)},
-  {"yellow2"			, PALETTERGB (238,238,  0)},
-  {"LightYellow2"			, PALETTERGB (238,238,209)},
-  {"ivory2"			, PALETTERGB (238,238,224)},
-  {"LightCoral"			, PALETTERGB (240,128,128)},
-  {"Gray94"			, PALETTERGB (240,240,240)},
-  {"Grey94"			, PALETTERGB (240,240,240)},
-  {"AliceBlue"			, PALETTERGB (240,248,255)},
-  {"honeydew"			, PALETTERGB (240,255,240)},
-  {"honeydew1"			, PALETTERGB (240,255,240)},
-  {"azure"			, PALETTERGB (240,255,255)},
-  {"azure1"			, PALETTERGB (240,255,255)},
-  {"Gray95"			, PALETTERGB (242,242,242)},
-  {"Grey95"			, PALETTERGB (242,242,242)},
-  {"SandyBrown"			, PALETTERGB (244,164, 96)},
-  {"Wheat"			, PALETTERGB (245,222,179)},
-  {"beige"			, PALETTERGB (245,245,220)},
-  {"Gray96"			, PALETTERGB (245,245,245)},
-  {"Grey96"			, PALETTERGB (245,245,245)},
-  {"WhiteSmoke"			, PALETTERGB (245,245,245)},
-  {"MintCream"			, PALETTERGB (245,255,250)},
-  {"Gray97"			, PALETTERGB (247,247,247)},
-  {"Grey97"			, PALETTERGB (247,247,247)},
-  {"GhostWhite"			, PALETTERGB (248,248,255)},
-  {"AntiqueWhite"			, PALETTERGB (250,235,215)},
-  {"linen"			, PALETTERGB (250,240,230)},
-  {"LightGoldenrodYellow"			, PALETTERGB (250,250,210)},
-  {"Gray98"			, PALETTERGB (250,250,250)},
-  {"Grey98"			, PALETTERGB (250,250,250)},
-  {"Gray99"			, PALETTERGB (252,252,252)},
-  {"Grey99"			, PALETTERGB (252,252,252)},
-  {"OldLace"			, PALETTERGB (253,245,230)},
-  {"Red"			, PALETTERGB (255,  0,  0)},
-  {"red1"			, PALETTERGB (255,  0,  0)},
-  {"Magenta"			, PALETTERGB (255,  0,255)},
-  {"magenta1"			, PALETTERGB (255,  0,255)},
-  {"DeepPink"			, PALETTERGB (255, 20,147)},
-  {"DeepPink1"			, PALETTERGB (255, 20,147)},
-  {"firebrick1"			, PALETTERGB (255, 48, 48)},
-  {"maroon1"			, PALETTERGB (255, 52,179)},
-  {"VioletRed1"			, PALETTERGB (255, 62,150)},
-  {"brown1"			, PALETTERGB (255, 64, 64)},
-  {"OrangeRed"			, PALETTERGB (255, 69,  0)},
-  {"OrangeRed1"			, PALETTERGB (255, 69,  0)},
-  {"tomato"			, PALETTERGB (255, 99, 71)},
-  {"tomato1"			, PALETTERGB (255, 99, 71)},
-  {"HotPink"			, PALETTERGB (255,105,180)},
-  {"IndianRed1"			, PALETTERGB (255,106,106)},
-  {"HotPink1"			, PALETTERGB (255,110,180)},
-  {"Coral"			, PALETTERGB (255,114, 86)},
-  {"coral1"			, PALETTERGB (255,114, 86)},
-  {"DarkOrange1"			, PALETTERGB (255,127,  0)},
-  {"chocolate1"			, PALETTERGB (255,127, 36)},
-  {"sienna1"			, PALETTERGB (255,130, 71)},
-  {"PaleVioletRed1"			, PALETTERGB (255,130,171)},
-  {"orchid1"			, PALETTERGB (255,131,250)},
-  {"Orange"			, PALETTERGB (255,135,  0)},
-  {"DarkOrange"			, PALETTERGB (255,140,  0)},
-  {"salmon1"			, PALETTERGB (255,140,105)},
-  {"LightSalmon"			, PALETTERGB (255,160,122)},
-  {"LightSalmon1"			, PALETTERGB (255,160,122)},
-  {"orange1"			, PALETTERGB (255,165,  0)},
-  {"tan1"			, PALETTERGB (255,165, 79)},
-  {"LightPink1"			, PALETTERGB (255,174,185)},
-  {"Pink"			, PALETTERGB (255,181,197)},
-  {"pink1"			, PALETTERGB (255,181,197)},
-  {"LightPink"			, PALETTERGB (255,182,193)},
-  {"DarkGoldenrod1"			, PALETTERGB (255,185, 15)},
-  {"plum1"			, PALETTERGB (255,187,255)},
-  {"goldenrod1"			, PALETTERGB (255,193, 37)},
-  {"RosyBrown1"			, PALETTERGB (255,193,193)},
-  {"burlywood1"			, PALETTERGB (255,211,155)},
-  {"gold1"			, PALETTERGB (255,215,  0)},
-  {"PeachPuff"			, PALETTERGB (255,218,185)},
-  {"PeachPuff1"			, PALETTERGB (255,218,185)},
-  {"NavajoWhite"			, PALETTERGB (255,222,173)},
-  {"NavajoWhite1"			, PALETTERGB (255,222,173)},
-  {"thistle1"			, PALETTERGB (255,225,255)},
-  {"moccasin"			, PALETTERGB (255,228,181)},
-  {"bisque"			, PALETTERGB (255,228,196)},
-  {"bisque1"			, PALETTERGB (255,228,196)},
-  {"MistyRose"			, PALETTERGB (255,228,225)},
-  {"MistyRose1"			, PALETTERGB (255,228,225)},
-  {"wheat1"			, PALETTERGB (255,231,186)},
-  {"BlanchedAlmond"			, PALETTERGB (255,235,205)},
-  {"LightGoldenrod1"			, PALETTERGB (255,236,139)},
-  {"PapayaWhip"			, PALETTERGB (255,239,213)},
-  {"AntiqueWhite1"			, PALETTERGB (255,239,219)},
-  {"LavenderBlush"			, PALETTERGB (255,240,245)},
-  {"LavenderBlush1"			, PALETTERGB (255,240,245)},
-  {"seashell"			, PALETTERGB (255,245,238)},
-  {"seashell1"			, PALETTERGB (255,245,238)},
-  {"khaki1"			, PALETTERGB (255,246,143)},
-  {"cornsilk"			, PALETTERGB (255,248,220)},
-  {"cornsilk1"			, PALETTERGB (255,248,220)},
-  {"LemonChiffon"			, PALETTERGB (255,250,205)},
-  {"LemonChiffon1"			, PALETTERGB (255,250,205)},
-  {"FloralWhite"			, PALETTERGB (255,250,240)},
-  {"snow"			, PALETTERGB (255,250,250)},
-  {"snow1"			, PALETTERGB (255,250,250)},
-  {"Yellow"			, PALETTERGB (255,255,  0)},
-  {"yellow1"			, PALETTERGB (255,255,  0)},
-  {"LightYellow"			, PALETTERGB (255,255,224)},
-  {"LightYellow1"			, PALETTERGB (255,255,224)},
-  {"ivory"			, PALETTERGB (255,255,240)},
-  {"ivory1"			, PALETTERGB (255,255,240)},
-  {"Gray100"			, PALETTERGB (255,255,255)},
-  {"Grey100"			, PALETTERGB (255,255,255)},
-  {"White"			, PALETTERGB (255,255,255)}
+  {"snow"			, PALETTERGB (255, 250, 250) },
+  {"GhostWhite"			, PALETTERGB (248, 248, 255) },
+  {"WhiteSmoke"			, PALETTERGB (245, 245, 245) },
+  {"gainsboro"			, PALETTERGB (220, 220, 220) },
+  {"FloralWhite"		, PALETTERGB (255, 250, 240) },
+  {"OldLace"			, PALETTERGB (253, 245, 230) },
+  {"linen"			, PALETTERGB (250, 240, 230) },
+  {"AntiqueWhite"		, PALETTERGB (250, 235, 215) },
+  {"PapayaWhip"			, PALETTERGB (255, 239, 213) },
+  {"BlanchedAlmond"		, PALETTERGB (255, 235, 205) },
+  {"bisque"			, PALETTERGB (255, 228, 196) },
+  {"PeachPuff"			, PALETTERGB (255, 218, 185) },
+  {"NavajoWhite"		, PALETTERGB (255, 222, 173) },
+  {"moccasin"			, PALETTERGB (255, 228, 181) },
+  {"cornsilk"			, PALETTERGB (255, 248, 220) },
+  {"ivory"			, PALETTERGB (255, 255, 240) },
+  {"LemonChiffon"		, PALETTERGB (255, 250, 205) },
+  {"seashell"			, PALETTERGB (255, 245, 238) },
+  {"honeydew"			, PALETTERGB (240, 255, 240) },
+  {"MintCream"			, PALETTERGB (245, 255, 250) },
+  {"azure"			, PALETTERGB (240, 255, 255) },
+  {"AliceBlue"			, PALETTERGB (240, 248, 255) },
+  {"lavender"			, PALETTERGB (230, 230, 250) },
+  {"LavenderBlush"		, PALETTERGB (255, 240, 245) },
+  {"MistyRose"			, PALETTERGB (255, 228, 225) },
+  {"white"			, PALETTERGB (255, 255, 255) },
+  {"black"			, PALETTERGB (0, 0, 0) },
+  {"DarkSlateGray"		, PALETTERGB (47, 79, 79) },
+  {"DarkSlateGrey"		, PALETTERGB (47, 79, 79) },
+  {"DimGray"			, PALETTERGB (105, 105, 105) },
+  {"DimGrey"			, PALETTERGB (105, 105, 105) },
+  {"SlateGray"			, PALETTERGB (112, 128, 144) },
+  {"SlateGrey"			, PALETTERGB (112, 128, 144) },
+  {"LightSlateGray"		, PALETTERGB (119, 136, 153) },
+  {"LightSlateGrey"		, PALETTERGB (119, 136, 153) },
+  {"gray"			, PALETTERGB (190, 190, 190) },
+  {"grey"			, PALETTERGB (190, 190, 190) },
+  {"LightGrey"			, PALETTERGB (211, 211, 211) },
+  {"LightGray"			, PALETTERGB (211, 211, 211) },
+  {"MidnightBlue"		, PALETTERGB (25, 25, 112) },
+  {"navy"			, PALETTERGB (0, 0, 128) },
+  {"NavyBlue"			, PALETTERGB (0, 0, 128) },
+  {"CornflowerBlue"		, PALETTERGB (100, 149, 237) },
+  {"DarkSlateBlue"		, PALETTERGB (72, 61, 139) },
+  {"SlateBlue"			, PALETTERGB (106, 90, 205) },
+  {"MediumSlateBlue"		, PALETTERGB (123, 104, 238) },
+  {"LightSlateBlue"		, PALETTERGB (132, 112, 255) },
+  {"MediumBlue"			, PALETTERGB (0, 0, 205) },
+  {"RoyalBlue"			, PALETTERGB (65, 105, 225) },
+  {"blue"			, PALETTERGB (0, 0, 255) },
+  {"DodgerBlue"			, PALETTERGB (30, 144, 255) },
+  {"DeepSkyBlue"		, PALETTERGB (0, 191, 255) },
+  {"SkyBlue"			, PALETTERGB (135, 206, 235) },
+  {"LightSkyBlue"		, PALETTERGB (135, 206, 250) },
+  {"SteelBlue"			, PALETTERGB (70, 130, 180) },
+  {"LightSteelBlue"		, PALETTERGB (176, 196, 222) },
+  {"LightBlue"			, PALETTERGB (173, 216, 230) },
+  {"PowderBlue"			, PALETTERGB (176, 224, 230) },
+  {"PaleTurquoise"		, PALETTERGB (175, 238, 238) },
+  {"DarkTurquoise"		, PALETTERGB (0, 206, 209) },
+  {"MediumTurquoise"		, PALETTERGB (72, 209, 204) },
+  {"turquoise"			, PALETTERGB (64, 224, 208) },
+  {"cyan"			, PALETTERGB (0, 255, 255) },
+  {"LightCyan"			, PALETTERGB (224, 255, 255) },
+  {"CadetBlue"			, PALETTERGB (95, 158, 160) },
+  {"MediumAquamarine"		, PALETTERGB (102, 205, 170) },
+  {"aquamarine"			, PALETTERGB (127, 255, 212) },
+  {"DarkGreen"			, PALETTERGB (0, 100, 0) },
+  {"DarkOliveGreen"		, PALETTERGB (85, 107, 47) },
+  {"DarkSeaGreen"		, PALETTERGB (143, 188, 143) },
+  {"SeaGreen"			, PALETTERGB (46, 139, 87) },
+  {"MediumSeaGreen"		, PALETTERGB (60, 179, 113) },
+  {"LightSeaGreen"		, PALETTERGB (32, 178, 170) },
+  {"PaleGreen"			, PALETTERGB (152, 251, 152) },
+  {"SpringGreen"		, PALETTERGB (0, 255, 127) },
+  {"LawnGreen"			, PALETTERGB (124, 252, 0) },
+  {"green"			, PALETTERGB (0, 255, 0) },
+  {"chartreuse"			, PALETTERGB (127, 255, 0) },
+  {"MediumSpringGreen"		, PALETTERGB (0, 250, 154) },
+  {"GreenYellow"		, PALETTERGB (173, 255, 47) },
+  {"LimeGreen"			, PALETTERGB (50, 205, 50) },
+  {"YellowGreen"		, PALETTERGB (154, 205, 50) },
+  {"ForestGreen"		, PALETTERGB (34, 139, 34) },
+  {"OliveDrab"			, PALETTERGB (107, 142, 35) },
+  {"DarkKhaki"			, PALETTERGB (189, 183, 107) },
+  {"khaki"			, PALETTERGB (240, 230, 140) },
+  {"PaleGoldenrod"		, PALETTERGB (238, 232, 170) },
+  {"LightGoldenrodYellow"	, PALETTERGB (250, 250, 210) },
+  {"LightYellow"		, PALETTERGB (255, 255, 224) },
+  {"yellow"			, PALETTERGB (255, 255, 0) },
+  {"gold"			, PALETTERGB (255, 215, 0) },
+  {"LightGoldenrod"		, PALETTERGB (238, 221, 130) },
+  {"goldenrod"			, PALETTERGB (218, 165, 32) },
+  {"DarkGoldenrod"		, PALETTERGB (184, 134, 11) },
+  {"RosyBrown"			, PALETTERGB (188, 143, 143) },
+  {"IndianRed"			, PALETTERGB (205, 92, 92) },
+  {"SaddleBrown"		, PALETTERGB (139, 69, 19) },
+  {"sienna"			, PALETTERGB (160, 82, 45) },
+  {"peru"			, PALETTERGB (205, 133, 63) },
+  {"burlywood"			, PALETTERGB (222, 184, 135) },
+  {"beige"			, PALETTERGB (245, 245, 220) },
+  {"wheat"			, PALETTERGB (245, 222, 179) },
+  {"SandyBrown"			, PALETTERGB (244, 164, 96) },
+  {"tan"			, PALETTERGB (210, 180, 140) },
+  {"chocolate"			, PALETTERGB (210, 105, 30) },
+  {"firebrick"			, PALETTERGB (178, 34, 34) },
+  {"brown"			, PALETTERGB (165, 42, 42) },
+  {"DarkSalmon"			, PALETTERGB (233, 150, 122) },
+  {"salmon"			, PALETTERGB (250, 128, 114) },
+  {"LightSalmon"		, PALETTERGB (255, 160, 122) },
+  {"orange"			, PALETTERGB (255, 165, 0) },
+  {"DarkOrange"			, PALETTERGB (255, 140, 0) },
+  {"coral"			, PALETTERGB (255, 127, 80) },
+  {"LightCoral"			, PALETTERGB (240, 128, 128) },
+  {"tomato"			, PALETTERGB (255, 99, 71) },
+  {"OrangeRed"			, PALETTERGB (255, 69, 0) },
+  {"red"			, PALETTERGB (255, 0, 0) },
+  {"HotPink"			, PALETTERGB (255, 105, 180) },
+  {"DeepPink"			, PALETTERGB (255, 20, 147) },
+  {"pink"			, PALETTERGB (255, 192, 203) },
+  {"LightPink"			, PALETTERGB (255, 182, 193) },
+  {"PaleVioletRed"		, PALETTERGB (219, 112, 147) },
+  {"maroon"			, PALETTERGB (176, 48, 96) },
+  {"MediumVioletRed"		, PALETTERGB (199, 21, 133) },
+  {"VioletRed"			, PALETTERGB (208, 32, 144) },
+  {"magenta"			, PALETTERGB (255, 0, 255) },
+  {"violet"			, PALETTERGB (238, 130, 238) },
+  {"plum"			, PALETTERGB (221, 160, 221) },
+  {"orchid"			, PALETTERGB (218, 112, 214) },
+  {"MediumOrchid"		, PALETTERGB (186, 85, 211) },
+  {"DarkOrchid"			, PALETTERGB (153, 50, 204) },
+  {"DarkViolet"			, PALETTERGB (148, 0, 211) },
+  {"BlueViolet"			, PALETTERGB (138, 43, 226) },
+  {"purple"			, PALETTERGB (160, 32, 240) },
+  {"MediumPurple"		, PALETTERGB (147, 112, 219) },
+  {"thistle"			, PALETTERGB (216, 191, 216) },
+  {"snow1"			, PALETTERGB (255, 250, 250) },
+  {"snow2"			, PALETTERGB (238, 233, 233) },
+  {"snow3"			, PALETTERGB (205, 201, 201) },
+  {"snow4"			, PALETTERGB (139, 137, 137) },
+  {"seashell1"			, PALETTERGB (255, 245, 238) },
+  {"seashell2"			, PALETTERGB (238, 229, 222) },
+  {"seashell3"			, PALETTERGB (205, 197, 191) },
+  {"seashell4"			, PALETTERGB (139, 134, 130) },
+  {"AntiqueWhite1"		, PALETTERGB (255, 239, 219) },
+  {"AntiqueWhite2"		, PALETTERGB (238, 223, 204) },
+  {"AntiqueWhite3"		, PALETTERGB (205, 192, 176) },
+  {"AntiqueWhite4"		, PALETTERGB (139, 131, 120) },
+  {"bisque1"			, PALETTERGB (255, 228, 196) },
+  {"bisque2"			, PALETTERGB (238, 213, 183) },
+  {"bisque3"			, PALETTERGB (205, 183, 158) },
+  {"bisque4"			, PALETTERGB (139, 125, 107) },
+  {"PeachPuff1"			, PALETTERGB (255, 218, 185) },
+  {"PeachPuff2"			, PALETTERGB (238, 203, 173) },
+  {"PeachPuff3"			, PALETTERGB (205, 175, 149) },
+  {"PeachPuff4"			, PALETTERGB (139, 119, 101) },
+  {"NavajoWhite1"		, PALETTERGB (255, 222, 173) },
+  {"NavajoWhite2"		, PALETTERGB (238, 207, 161) },
+  {"NavajoWhite3"		, PALETTERGB (205, 179, 139) },
+  {"NavajoWhite4"		, PALETTERGB (139, 121, 94) },
+  {"LemonChiffon1"		, PALETTERGB (255, 250, 205) },
+  {"LemonChiffon2"		, PALETTERGB (238, 233, 191) },
+  {"LemonChiffon3"		, PALETTERGB (205, 201, 165) },
+  {"LemonChiffon4"		, PALETTERGB (139, 137, 112) },
+  {"cornsilk1"			, PALETTERGB (255, 248, 220) },
+  {"cornsilk2"			, PALETTERGB (238, 232, 205) },
+  {"cornsilk3"			, PALETTERGB (205, 200, 177) },
+  {"cornsilk4"			, PALETTERGB (139, 136, 120) },
+  {"ivory1"			, PALETTERGB (255, 255, 240) },
+  {"ivory2"			, PALETTERGB (238, 238, 224) },
+  {"ivory3"			, PALETTERGB (205, 205, 193) },
+  {"ivory4"			, PALETTERGB (139, 139, 131) },
+  {"honeydew1"			, PALETTERGB (240, 255, 240) },
+  {"honeydew2"			, PALETTERGB (224, 238, 224) },
+  {"honeydew3"			, PALETTERGB (193, 205, 193) },
+  {"honeydew4"			, PALETTERGB (131, 139, 131) },
+  {"LavenderBlush1"		, PALETTERGB (255, 240, 245) },
+  {"LavenderBlush2"		, PALETTERGB (238, 224, 229) },
+  {"LavenderBlush3"		, PALETTERGB (205, 193, 197) },
+  {"LavenderBlush4"		, PALETTERGB (139, 131, 134) },
+  {"MistyRose1"			, PALETTERGB (255, 228, 225) },
+  {"MistyRose2"			, PALETTERGB (238, 213, 210) },
+  {"MistyRose3"			, PALETTERGB (205, 183, 181) },
+  {"MistyRose4"			, PALETTERGB (139, 125, 123) },
+  {"azure1"			, PALETTERGB (240, 255, 255) },
+  {"azure2"			, PALETTERGB (224, 238, 238) },
+  {"azure3"			, PALETTERGB (193, 205, 205) },
+  {"azure4"			, PALETTERGB (131, 139, 139) },
+  {"SlateBlue1"			, PALETTERGB (131, 111, 255) },
+  {"SlateBlue2"			, PALETTERGB (122, 103, 238) },
+  {"SlateBlue3"			, PALETTERGB (105, 89, 205) },
+  {"SlateBlue4"			, PALETTERGB (71, 60, 139) },
+  {"RoyalBlue1"			, PALETTERGB (72, 118, 255) },
+  {"RoyalBlue2"			, PALETTERGB (67, 110, 238) },
+  {"RoyalBlue3"			, PALETTERGB (58, 95, 205) },
+  {"RoyalBlue4"			, PALETTERGB (39, 64, 139) },
+  {"blue1"			, PALETTERGB (0, 0, 255) },
+  {"blue2"			, PALETTERGB (0, 0, 238) },
+  {"blue3"			, PALETTERGB (0, 0, 205) },
+  {"blue4"			, PALETTERGB (0, 0, 139) },
+  {"DodgerBlue1"		, PALETTERGB (30, 144, 255) },
+  {"DodgerBlue2"		, PALETTERGB (28, 134, 238) },
+  {"DodgerBlue3"		, PALETTERGB (24, 116, 205) },
+  {"DodgerBlue4"		, PALETTERGB (16, 78, 139) },
+  {"SteelBlue1"			, PALETTERGB (99, 184, 255) },
+  {"SteelBlue2"			, PALETTERGB (92, 172, 238) },
+  {"SteelBlue3"			, PALETTERGB (79, 148, 205) },
+  {"SteelBlue4"			, PALETTERGB (54, 100, 139) },
+  {"DeepSkyBlue1"		, PALETTERGB (0, 191, 255) },
+  {"DeepSkyBlue2"		, PALETTERGB (0, 178, 238) },
+  {"DeepSkyBlue3"		, PALETTERGB (0, 154, 205) },
+  {"DeepSkyBlue4"		, PALETTERGB (0, 104, 139) },
+  {"SkyBlue1"			, PALETTERGB (135, 206, 255) },
+  {"SkyBlue2"			, PALETTERGB (126, 192, 238) },
+  {"SkyBlue3"			, PALETTERGB (108, 166, 205) },
+  {"SkyBlue4"			, PALETTERGB (74, 112, 139) },
+  {"LightSkyBlue1"		, PALETTERGB (176, 226, 255) },
+  {"LightSkyBlue2"		, PALETTERGB (164, 211, 238) },
+  {"LightSkyBlue3"		, PALETTERGB (141, 182, 205) },
+  {"LightSkyBlue4"		, PALETTERGB (96, 123, 139) },
+  {"SlateGray1"			, PALETTERGB (198, 226, 255) },
+  {"SlateGray2"			, PALETTERGB (185, 211, 238) },
+  {"SlateGray3"			, PALETTERGB (159, 182, 205) },
+  {"SlateGray4"			, PALETTERGB (108, 123, 139) },
+  {"LightSteelBlue1"		, PALETTERGB (202, 225, 255) },
+  {"LightSteelBlue2"		, PALETTERGB (188, 210, 238) },
+  {"LightSteelBlue3"		, PALETTERGB (162, 181, 205) },
+  {"LightSteelBlue4"		, PALETTERGB (110, 123, 139) },
+  {"LightBlue1"			, PALETTERGB (191, 239, 255) },
+  {"LightBlue2"			, PALETTERGB (178, 223, 238) },
+  {"LightBlue3"			, PALETTERGB (154, 192, 205) },
+  {"LightBlue4"			, PALETTERGB (104, 131, 139) },
+  {"LightCyan1"			, PALETTERGB (224, 255, 255) },
+  {"LightCyan2"			, PALETTERGB (209, 238, 238) },
+  {"LightCyan3"			, PALETTERGB (180, 205, 205) },
+  {"LightCyan4"			, PALETTERGB (122, 139, 139) },
+  {"PaleTurquoise1"		, PALETTERGB (187, 255, 255) },
+  {"PaleTurquoise2"		, PALETTERGB (174, 238, 238) },
+  {"PaleTurquoise3"		, PALETTERGB (150, 205, 205) },
+  {"PaleTurquoise4"		, PALETTERGB (102, 139, 139) },
+  {"CadetBlue1"			, PALETTERGB (152, 245, 255) },
+  {"CadetBlue2"			, PALETTERGB (142, 229, 238) },
+  {"CadetBlue3"			, PALETTERGB (122, 197, 205) },
+  {"CadetBlue4"			, PALETTERGB (83, 134, 139) },
+  {"turquoise1"			, PALETTERGB (0, 245, 255) },
+  {"turquoise2"			, PALETTERGB (0, 229, 238) },
+  {"turquoise3"			, PALETTERGB (0, 197, 205) },
+  {"turquoise4"			, PALETTERGB (0, 134, 139) },
+  {"cyan1"			, PALETTERGB (0, 255, 255) },
+  {"cyan2"			, PALETTERGB (0, 238, 238) },
+  {"cyan3"			, PALETTERGB (0, 205, 205) },
+  {"cyan4"			, PALETTERGB (0, 139, 139) },
+  {"DarkSlateGray1"		, PALETTERGB (151, 255, 255) },
+  {"DarkSlateGray2"		, PALETTERGB (141, 238, 238) },
+  {"DarkSlateGray3"		, PALETTERGB (121, 205, 205) },
+  {"DarkSlateGray4"		, PALETTERGB (82, 139, 139) },
+  {"aquamarine1"		, PALETTERGB (127, 255, 212) },
+  {"aquamarine2"		, PALETTERGB (118, 238, 198) },
+  {"aquamarine3"		, PALETTERGB (102, 205, 170) },
+  {"aquamarine4"		, PALETTERGB (69, 139, 116) },
+  {"DarkSeaGreen1"		, PALETTERGB (193, 255, 193) },
+  {"DarkSeaGreen2"		, PALETTERGB (180, 238, 180) },
+  {"DarkSeaGreen3"		, PALETTERGB (155, 205, 155) },
+  {"DarkSeaGreen4"		, PALETTERGB (105, 139, 105) },
+  {"SeaGreen1"			, PALETTERGB (84, 255, 159) },
+  {"SeaGreen2"			, PALETTERGB (78, 238, 148) },
+  {"SeaGreen3"			, PALETTERGB (67, 205, 128) },
+  {"SeaGreen4"			, PALETTERGB (46, 139, 87) },
+  {"PaleGreen1"			, PALETTERGB (154, 255, 154) },
+  {"PaleGreen2"			, PALETTERGB (144, 238, 144) },
+  {"PaleGreen3"			, PALETTERGB (124, 205, 124) },
+  {"PaleGreen4"			, PALETTERGB (84, 139, 84) },
+  {"SpringGreen1"		, PALETTERGB (0, 255, 127) },
+  {"SpringGreen2"		, PALETTERGB (0, 238, 118) },
+  {"SpringGreen3"		, PALETTERGB (0, 205, 102) },
+  {"SpringGreen4"		, PALETTERGB (0, 139, 69) },
+  {"green1"			, PALETTERGB (0, 255, 0) },
+  {"green2"			, PALETTERGB (0, 238, 0) },
+  {"green3"			, PALETTERGB (0, 205, 0) },
+  {"green4"			, PALETTERGB (0, 139, 0) },
+  {"chartreuse1"		, PALETTERGB (127, 255, 0) },
+  {"chartreuse2"		, PALETTERGB (118, 238, 0) },
+  {"chartreuse3"		, PALETTERGB (102, 205, 0) },
+  {"chartreuse4"		, PALETTERGB (69, 139, 0) },
+  {"OliveDrab1"			, PALETTERGB (192, 255, 62) },
+  {"OliveDrab2"			, PALETTERGB (179, 238, 58) },
+  {"OliveDrab3"			, PALETTERGB (154, 205, 50) },
+  {"OliveDrab4"			, PALETTERGB (105, 139, 34) },
+  {"DarkOliveGreen1"		, PALETTERGB (202, 255, 112) },
+  {"DarkOliveGreen2"		, PALETTERGB (188, 238, 104) },
+  {"DarkOliveGreen3"		, PALETTERGB (162, 205, 90) },
+  {"DarkOliveGreen4"		, PALETTERGB (110, 139, 61) },
+  {"khaki1"			, PALETTERGB (255, 246, 143) },
+  {"khaki2"			, PALETTERGB (238, 230, 133) },
+  {"khaki3"			, PALETTERGB (205, 198, 115) },
+  {"khaki4"			, PALETTERGB (139, 134, 78) },
+  {"LightGoldenrod1"		, PALETTERGB (255, 236, 139) },
+  {"LightGoldenrod2"		, PALETTERGB (238, 220, 130) },
+  {"LightGoldenrod3"		, PALETTERGB (205, 190, 112) },
+  {"LightGoldenrod4"		, PALETTERGB (139, 129, 76) },
+  {"LightYellow1"		, PALETTERGB (255, 255, 224) },
+  {"LightYellow2"		, PALETTERGB (238, 238, 209) },
+  {"LightYellow3"		, PALETTERGB (205, 205, 180) },
+  {"LightYellow4"		, PALETTERGB (139, 139, 122) },
+  {"yellow1"			, PALETTERGB (255, 255, 0) },
+  {"yellow2"			, PALETTERGB (238, 238, 0) },
+  {"yellow3"			, PALETTERGB (205, 205, 0) },
+  {"yellow4"			, PALETTERGB (139, 139, 0) },
+  {"gold1"			, PALETTERGB (255, 215, 0) },
+  {"gold2"			, PALETTERGB (238, 201, 0) },
+  {"gold3"			, PALETTERGB (205, 173, 0) },
+  {"gold4"			, PALETTERGB (139, 117, 0) },
+  {"goldenrod1"			, PALETTERGB (255, 193, 37) },
+  {"goldenrod2"			, PALETTERGB (238, 180, 34) },
+  {"goldenrod3"			, PALETTERGB (205, 155, 29) },
+  {"goldenrod4"			, PALETTERGB (139, 105, 20) },
+  {"DarkGoldenrod1"		, PALETTERGB (255, 185, 15) },
+  {"DarkGoldenrod2"		, PALETTERGB (238, 173, 14) },
+  {"DarkGoldenrod3"		, PALETTERGB (205, 149, 12) },
+  {"DarkGoldenrod4"		, PALETTERGB (139, 101, 8) },
+  {"RosyBrown1"			, PALETTERGB (255, 193, 193) },
+  {"RosyBrown2"			, PALETTERGB (238, 180, 180) },
+  {"RosyBrown3"			, PALETTERGB (205, 155, 155) },
+  {"RosyBrown4"			, PALETTERGB (139, 105, 105) },
+  {"IndianRed1"			, PALETTERGB (255, 106, 106) },
+  {"IndianRed2"			, PALETTERGB (238, 99, 99) },
+  {"IndianRed3"			, PALETTERGB (205, 85, 85) },
+  {"IndianRed4"			, PALETTERGB (139, 58, 58) },
+  {"sienna1"			, PALETTERGB (255, 130, 71) },
+  {"sienna2"			, PALETTERGB (238, 121, 66) },
+  {"sienna3"			, PALETTERGB (205, 104, 57) },
+  {"sienna4"			, PALETTERGB (139, 71, 38) },
+  {"burlywood1"			, PALETTERGB (255, 211, 155) },
+  {"burlywood2"			, PALETTERGB (238, 197, 145) },
+  {"burlywood3"			, PALETTERGB (205, 170, 125) },
+  {"burlywood4"			, PALETTERGB (139, 115, 85) },
+  {"wheat1"			, PALETTERGB (255, 231, 186) },
+  {"wheat2"			, PALETTERGB (238, 216, 174) },
+  {"wheat3"			, PALETTERGB (205, 186, 150) },
+  {"wheat4"			, PALETTERGB (139, 126, 102) },
+  {"tan1"			, PALETTERGB (255, 165, 79) },
+  {"tan2"			, PALETTERGB (238, 154, 73) },
+  {"tan3"			, PALETTERGB (205, 133, 63) },
+  {"tan4"			, PALETTERGB (139, 90, 43) },
+  {"chocolate1"			, PALETTERGB (255, 127, 36) },
+  {"chocolate2"			, PALETTERGB (238, 118, 33) },
+  {"chocolate3"			, PALETTERGB (205, 102, 29) },
+  {"chocolate4"			, PALETTERGB (139, 69, 19) },
+  {"firebrick1"			, PALETTERGB (255, 48, 48) },
+  {"firebrick2"			, PALETTERGB (238, 44, 44) },
+  {"firebrick3"			, PALETTERGB (205, 38, 38) },
+  {"firebrick4"			, PALETTERGB (139, 26, 26) },
+  {"brown1"			, PALETTERGB (255, 64, 64) },
+  {"brown2"			, PALETTERGB (238, 59, 59) },
+  {"brown3"			, PALETTERGB (205, 51, 51) },
+  {"brown4"			, PALETTERGB (139, 35, 35) },
+  {"salmon1"			, PALETTERGB (255, 140, 105) },
+  {"salmon2"			, PALETTERGB (238, 130, 98) },
+  {"salmon3"			, PALETTERGB (205, 112, 84) },
+  {"salmon4"			, PALETTERGB (139, 76, 57) },
+  {"LightSalmon1"		, PALETTERGB (255, 160, 122) },
+  {"LightSalmon2"		, PALETTERGB (238, 149, 114) },
+  {"LightSalmon3"		, PALETTERGB (205, 129, 98) },
+  {"LightSalmon4"		, PALETTERGB (139, 87, 66) },
+  {"orange1"			, PALETTERGB (255, 165, 0) },
+  {"orange2"			, PALETTERGB (238, 154, 0) },
+  {"orange3"			, PALETTERGB (205, 133, 0) },
+  {"orange4"			, PALETTERGB (139, 90, 0) },
+  {"DarkOrange1"		, PALETTERGB (255, 127, 0) },
+  {"DarkOrange2"		, PALETTERGB (238, 118, 0) },
+  {"DarkOrange3"		, PALETTERGB (205, 102, 0) },
+  {"DarkOrange4"		, PALETTERGB (139, 69, 0) },
+  {"coral1"			, PALETTERGB (255, 114, 86) },
+  {"coral2"			, PALETTERGB (238, 106, 80) },
+  {"coral3"			, PALETTERGB (205, 91, 69) },
+  {"coral4"			, PALETTERGB (139, 62, 47) },
+  {"tomato1"			, PALETTERGB (255, 99, 71) },
+  {"tomato2"			, PALETTERGB (238, 92, 66) },
+  {"tomato3"			, PALETTERGB (205, 79, 57) },
+  {"tomato4"			, PALETTERGB (139, 54, 38) },
+  {"OrangeRed1"			, PALETTERGB (255, 69, 0) },
+  {"OrangeRed2"			, PALETTERGB (238, 64, 0) },
+  {"OrangeRed3"			, PALETTERGB (205, 55, 0) },
+  {"OrangeRed4"			, PALETTERGB (139, 37, 0) },
+  {"red1"			, PALETTERGB (255, 0, 0) },
+  {"red2"			, PALETTERGB (238, 0, 0) },
+  {"red3"			, PALETTERGB (205, 0, 0) },
+  {"red4"			, PALETTERGB (139, 0, 0) },
+  {"DeepPink1"			, PALETTERGB (255, 20, 147) },
+  {"DeepPink2"			, PALETTERGB (238, 18, 137) },
+  {"DeepPink3"			, PALETTERGB (205, 16, 118) },
+  {"DeepPink4"			, PALETTERGB (139, 10, 80) },
+  {"HotPink1"			, PALETTERGB (255, 110, 180) },
+  {"HotPink2"			, PALETTERGB (238, 106, 167) },
+  {"HotPink3"			, PALETTERGB (205, 96, 144) },
+  {"HotPink4"			, PALETTERGB (139, 58, 98) },
+  {"pink1"			, PALETTERGB (255, 181, 197) },
+  {"pink2"			, PALETTERGB (238, 169, 184) },
+  {"pink3"			, PALETTERGB (205, 145, 158) },
+  {"pink4"			, PALETTERGB (139, 99, 108) },
+  {"LightPink1"			, PALETTERGB (255, 174, 185) },
+  {"LightPink2"			, PALETTERGB (238, 162, 173) },
+  {"LightPink3"			, PALETTERGB (205, 140, 149) },
+  {"LightPink4"			, PALETTERGB (139, 95, 101) },
+  {"PaleVioletRed1"		, PALETTERGB (255, 130, 171) },
+  {"PaleVioletRed2"		, PALETTERGB (238, 121, 159) },
+  {"PaleVioletRed3"		, PALETTERGB (205, 104, 137) },
+  {"PaleVioletRed4"		, PALETTERGB (139, 71, 93) },
+  {"maroon1"			, PALETTERGB (255, 52, 179) },
+  {"maroon2"			, PALETTERGB (238, 48, 167) },
+  {"maroon3"			, PALETTERGB (205, 41, 144) },
+  {"maroon4"			, PALETTERGB (139, 28, 98) },
+  {"VioletRed1"			, PALETTERGB (255, 62, 150) },
+  {"VioletRed2"			, PALETTERGB (238, 58, 140) },
+  {"VioletRed3"			, PALETTERGB (205, 50, 120) },
+  {"VioletRed4"			, PALETTERGB (139, 34, 82) },
+  {"magenta1"			, PALETTERGB (255, 0, 255) },
+  {"magenta2"			, PALETTERGB (238, 0, 238) },
+  {"magenta3"			, PALETTERGB (205, 0, 205) },
+  {"magenta4"			, PALETTERGB (139, 0, 139) },
+  {"orchid1"			, PALETTERGB (255, 131, 250) },
+  {"orchid2"			, PALETTERGB (238, 122, 233) },
+  {"orchid3"			, PALETTERGB (205, 105, 201) },
+  {"orchid4"			, PALETTERGB (139, 71, 137) },
+  {"plum1"			, PALETTERGB (255, 187, 255) },
+  {"plum2"			, PALETTERGB (238, 174, 238) },
+  {"plum3"			, PALETTERGB (205, 150, 205) },
+  {"plum4"			, PALETTERGB (139, 102, 139) },
+  {"MediumOrchid1"		, PALETTERGB (224, 102, 255) },
+  {"MediumOrchid2"		, PALETTERGB (209, 95, 238) },
+  {"MediumOrchid3"		, PALETTERGB (180, 82, 205) },
+  {"MediumOrchid4"		, PALETTERGB (122, 55, 139) },
+  {"DarkOrchid1"		, PALETTERGB (191, 62, 255) },
+  {"DarkOrchid2"		, PALETTERGB (178, 58, 238) },
+  {"DarkOrchid3"		, PALETTERGB (154, 50, 205) },
+  {"DarkOrchid4"		, PALETTERGB (104, 34, 139) },
+  {"purple1"			, PALETTERGB (155, 48, 255) },
+  {"purple2"			, PALETTERGB (145, 44, 238) },
+  {"purple3"			, PALETTERGB (125, 38, 205) },
+  {"purple4"			, PALETTERGB (85, 26, 139) },
+  {"MediumPurple1"		, PALETTERGB (171, 130, 255) },
+  {"MediumPurple2"		, PALETTERGB (159, 121, 238) },
+  {"MediumPurple3"		, PALETTERGB (137, 104, 205) },
+  {"MediumPurple4"		, PALETTERGB (93, 71, 139) },
+  {"thistle1"			, PALETTERGB (255, 225, 255) },
+  {"thistle2"			, PALETTERGB (238, 210, 238) },
+  {"thistle3"			, PALETTERGB (205, 181, 205) },
+  {"thistle4"			, PALETTERGB (139, 123, 139) },
+  {"gray0"			, PALETTERGB (0, 0, 0) },
+  {"grey0"			, PALETTERGB (0, 0, 0) },
+  {"gray1"			, PALETTERGB (3, 3, 3) },
+  {"grey1"			, PALETTERGB (3, 3, 3) },
+  {"gray2"			, PALETTERGB (5, 5, 5) },
+  {"grey2"			, PALETTERGB (5, 5, 5) },
+  {"gray3"			, PALETTERGB (8, 8, 8) },
+  {"grey3"			, PALETTERGB (8, 8, 8) },
+  {"gray4"			, PALETTERGB (10, 10, 10) },
+  {"grey4"			, PALETTERGB (10, 10, 10) },
+  {"gray5"			, PALETTERGB (13, 13, 13) },
+  {"grey5"			, PALETTERGB (13, 13, 13) },
+  {"gray6"			, PALETTERGB (15, 15, 15) },
+  {"grey6"			, PALETTERGB (15, 15, 15) },
+  {"gray7"			, PALETTERGB (18, 18, 18) },
+  {"grey7"			, PALETTERGB (18, 18, 18) },
+  {"gray8"			, PALETTERGB (20, 20, 20) },
+  {"grey8"			, PALETTERGB (20, 20, 20) },
+  {"gray9"			, PALETTERGB (23, 23, 23) },
+  {"grey9"			, PALETTERGB (23, 23, 23) },
+  {"gray10"			, PALETTERGB (26, 26, 26) },
+  {"grey10"			, PALETTERGB (26, 26, 26) },
+  {"gray11"			, PALETTERGB (28, 28, 28) },
+  {"grey11"			, PALETTERGB (28, 28, 28) },
+  {"gray12"			, PALETTERGB (31, 31, 31) },
+  {"grey12"			, PALETTERGB (31, 31, 31) },
+  {"gray13"			, PALETTERGB (33, 33, 33) },
+  {"grey13"			, PALETTERGB (33, 33, 33) },
+  {"gray14"			, PALETTERGB (36, 36, 36) },
+  {"grey14"			, PALETTERGB (36, 36, 36) },
+  {"gray15"			, PALETTERGB (38, 38, 38) },
+  {"grey15"			, PALETTERGB (38, 38, 38) },
+  {"gray16"			, PALETTERGB (41, 41, 41) },
+  {"grey16"			, PALETTERGB (41, 41, 41) },
+  {"gray17"			, PALETTERGB (43, 43, 43) },
+  {"grey17"			, PALETTERGB (43, 43, 43) },
+  {"gray18"			, PALETTERGB (46, 46, 46) },
+  {"grey18"			, PALETTERGB (46, 46, 46) },
+  {"gray19"			, PALETTERGB (48, 48, 48) },
+  {"grey19"			, PALETTERGB (48, 48, 48) },
+  {"gray20"			, PALETTERGB (51, 51, 51) },
+  {"grey20"			, PALETTERGB (51, 51, 51) },
+  {"gray21"			, PALETTERGB (54, 54, 54) },
+  {"grey21"			, PALETTERGB (54, 54, 54) },
+  {"gray22"			, PALETTERGB (56, 56, 56) },
+  {"grey22"			, PALETTERGB (56, 56, 56) },
+  {"gray23"			, PALETTERGB (59, 59, 59) },
+  {"grey23"			, PALETTERGB (59, 59, 59) },
+  {"gray24"			, PALETTERGB (61, 61, 61) },
+  {"grey24"			, PALETTERGB (61, 61, 61) },
+  {"gray25"			, PALETTERGB (64, 64, 64) },
+  {"grey25"			, PALETTERGB (64, 64, 64) },
+  {"gray26"			, PALETTERGB (66, 66, 66) },
+  {"grey26"			, PALETTERGB (66, 66, 66) },
+  {"gray27"			, PALETTERGB (69, 69, 69) },
+  {"grey27"			, PALETTERGB (69, 69, 69) },
+  {"gray28"			, PALETTERGB (71, 71, 71) },
+  {"grey28"			, PALETTERGB (71, 71, 71) },
+  {"gray29"			, PALETTERGB (74, 74, 74) },
+  {"grey29"			, PALETTERGB (74, 74, 74) },
+  {"gray30"			, PALETTERGB (77, 77, 77) },
+  {"grey30"			, PALETTERGB (77, 77, 77) },
+  {"gray31"			, PALETTERGB (79, 79, 79) },
+  {"grey31"			, PALETTERGB (79, 79, 79) },
+  {"gray32"			, PALETTERGB (82, 82, 82) },
+  {"grey32"			, PALETTERGB (82, 82, 82) },
+  {"gray33"			, PALETTERGB (84, 84, 84) },
+  {"grey33"			, PALETTERGB (84, 84, 84) },
+  {"gray34"			, PALETTERGB (87, 87, 87) },
+  {"grey34"			, PALETTERGB (87, 87, 87) },
+  {"gray35"			, PALETTERGB (89, 89, 89) },
+  {"grey35"			, PALETTERGB (89, 89, 89) },
+  {"gray36"			, PALETTERGB (92, 92, 92) },
+  {"grey36"			, PALETTERGB (92, 92, 92) },
+  {"gray37"			, PALETTERGB (94, 94, 94) },
+  {"grey37"			, PALETTERGB (94, 94, 94) },
+  {"gray38"			, PALETTERGB (97, 97, 97) },
+  {"grey38"			, PALETTERGB (97, 97, 97) },
+  {"gray39"			, PALETTERGB (99, 99, 99) },
+  {"grey39"			, PALETTERGB (99, 99, 99) },
+  {"gray40"			, PALETTERGB (102, 102, 102) },
+  {"grey40"			, PALETTERGB (102, 102, 102) },
+  {"gray41"			, PALETTERGB (105, 105, 105) },
+  {"grey41"			, PALETTERGB (105, 105, 105) },
+  {"gray42"			, PALETTERGB (107, 107, 107) },
+  {"grey42"			, PALETTERGB (107, 107, 107) },
+  {"gray43"			, PALETTERGB (110, 110, 110) },
+  {"grey43"			, PALETTERGB (110, 110, 110) },
+  {"gray44"			, PALETTERGB (112, 112, 112) },
+  {"grey44"			, PALETTERGB (112, 112, 112) },
+  {"gray45"			, PALETTERGB (115, 115, 115) },
+  {"grey45"			, PALETTERGB (115, 115, 115) },
+  {"gray46"			, PALETTERGB (117, 117, 117) },
+  {"grey46"			, PALETTERGB (117, 117, 117) },
+  {"gray47"			, PALETTERGB (120, 120, 120) },
+  {"grey47"			, PALETTERGB (120, 120, 120) },
+  {"gray48"			, PALETTERGB (122, 122, 122) },
+  {"grey48"			, PALETTERGB (122, 122, 122) },
+  {"gray49"			, PALETTERGB (125, 125, 125) },
+  {"grey49"			, PALETTERGB (125, 125, 125) },
+  {"gray50"			, PALETTERGB (127, 127, 127) },
+  {"grey50"			, PALETTERGB (127, 127, 127) },
+  {"gray51"			, PALETTERGB (130, 130, 130) },
+  {"grey51"			, PALETTERGB (130, 130, 130) },
+  {"gray52"			, PALETTERGB (133, 133, 133) },
+  {"grey52"			, PALETTERGB (133, 133, 133) },
+  {"gray53"			, PALETTERGB (135, 135, 135) },
+  {"grey53"			, PALETTERGB (135, 135, 135) },
+  {"gray54"			, PALETTERGB (138, 138, 138) },
+  {"grey54"			, PALETTERGB (138, 138, 138) },
+  {"gray55"			, PALETTERGB (140, 140, 140) },
+  {"grey55"			, PALETTERGB (140, 140, 140) },
+  {"gray56"			, PALETTERGB (143, 143, 143) },
+  {"grey56"			, PALETTERGB (143, 143, 143) },
+  {"gray57"			, PALETTERGB (145, 145, 145) },
+  {"grey57"			, PALETTERGB (145, 145, 145) },
+  {"gray58"			, PALETTERGB (148, 148, 148) },
+  {"grey58"			, PALETTERGB (148, 148, 148) },
+  {"gray59"			, PALETTERGB (150, 150, 150) },
+  {"grey59"			, PALETTERGB (150, 150, 150) },
+  {"gray60"			, PALETTERGB (153, 153, 153) },
+  {"grey60"			, PALETTERGB (153, 153, 153) },
+  {"gray61"			, PALETTERGB (156, 156, 156) },
+  {"grey61"			, PALETTERGB (156, 156, 156) },
+  {"gray62"			, PALETTERGB (158, 158, 158) },
+  {"grey62"			, PALETTERGB (158, 158, 158) },
+  {"gray63"			, PALETTERGB (161, 161, 161) },
+  {"grey63"			, PALETTERGB (161, 161, 161) },
+  {"gray64"			, PALETTERGB (163, 163, 163) },
+  {"grey64"			, PALETTERGB (163, 163, 163) },
+  {"gray65"			, PALETTERGB (166, 166, 166) },
+  {"grey65"			, PALETTERGB (166, 166, 166) },
+  {"gray66"			, PALETTERGB (168, 168, 168) },
+  {"grey66"			, PALETTERGB (168, 168, 168) },
+  {"gray67"			, PALETTERGB (171, 171, 171) },
+  {"grey67"			, PALETTERGB (171, 171, 171) },
+  {"gray68"			, PALETTERGB (173, 173, 173) },
+  {"grey68"			, PALETTERGB (173, 173, 173) },
+  {"gray69"			, PALETTERGB (176, 176, 176) },
+  {"grey69"			, PALETTERGB (176, 176, 176) },
+  {"gray70"			, PALETTERGB (179, 179, 179) },
+  {"grey70"			, PALETTERGB (179, 179, 179) },
+  {"gray71"			, PALETTERGB (181, 181, 181) },
+  {"grey71"			, PALETTERGB (181, 181, 181) },
+  {"gray72"			, PALETTERGB (184, 184, 184) },
+  {"grey72"			, PALETTERGB (184, 184, 184) },
+  {"gray73"			, PALETTERGB (186, 186, 186) },
+  {"grey73"			, PALETTERGB (186, 186, 186) },
+  {"gray74"			, PALETTERGB (189, 189, 189) },
+  {"grey74"			, PALETTERGB (189, 189, 189) },
+  {"gray75"			, PALETTERGB (191, 191, 191) },
+  {"grey75"			, PALETTERGB (191, 191, 191) },
+  {"gray76"			, PALETTERGB (194, 194, 194) },
+  {"grey76"			, PALETTERGB (194, 194, 194) },
+  {"gray77"			, PALETTERGB (196, 196, 196) },
+  {"grey77"			, PALETTERGB (196, 196, 196) },
+  {"gray78"			, PALETTERGB (199, 199, 199) },
+  {"grey78"			, PALETTERGB (199, 199, 199) },
+  {"gray79"			, PALETTERGB (201, 201, 201) },
+  {"grey79"			, PALETTERGB (201, 201, 201) },
+  {"gray80"			, PALETTERGB (204, 204, 204) },
+  {"grey80"			, PALETTERGB (204, 204, 204) },
+  {"gray81"			, PALETTERGB (207, 207, 207) },
+  {"grey81"			, PALETTERGB (207, 207, 207) },
+  {"gray82"			, PALETTERGB (209, 209, 209) },
+  {"grey82"			, PALETTERGB (209, 209, 209) },
+  {"gray83"			, PALETTERGB (212, 212, 212) },
+  {"grey83"			, PALETTERGB (212, 212, 212) },
+  {"gray84"			, PALETTERGB (214, 214, 214) },
+  {"grey84"			, PALETTERGB (214, 214, 214) },
+  {"gray85"			, PALETTERGB (217, 217, 217) },
+  {"grey85"			, PALETTERGB (217, 217, 217) },
+  {"gray86"			, PALETTERGB (219, 219, 219) },
+  {"grey86"			, PALETTERGB (219, 219, 219) },
+  {"gray87"			, PALETTERGB (222, 222, 222) },
+  {"grey87"			, PALETTERGB (222, 222, 222) },
+  {"gray88"			, PALETTERGB (224, 224, 224) },
+  {"grey88"			, PALETTERGB (224, 224, 224) },
+  {"gray89"			, PALETTERGB (227, 227, 227) },
+  {"grey89"			, PALETTERGB (227, 227, 227) },
+  {"gray90"			, PALETTERGB (229, 229, 229) },
+  {"grey90"			, PALETTERGB (229, 229, 229) },
+  {"gray91"			, PALETTERGB (232, 232, 232) },
+  {"grey91"			, PALETTERGB (232, 232, 232) },
+  {"gray92"			, PALETTERGB (235, 235, 235) },
+  {"grey92"			, PALETTERGB (235, 235, 235) },
+  {"gray93"			, PALETTERGB (237, 237, 237) },
+  {"grey93"			, PALETTERGB (237, 237, 237) },
+  {"gray94"			, PALETTERGB (240, 240, 240) },
+  {"grey94"			, PALETTERGB (240, 240, 240) },
+  {"gray95"			, PALETTERGB (242, 242, 242) },
+  {"grey95"			, PALETTERGB (242, 242, 242) },
+  {"gray96"			, PALETTERGB (245, 245, 245) },
+  {"grey96"			, PALETTERGB (245, 245, 245) },
+  {"gray97"			, PALETTERGB (247, 247, 247) },
+  {"grey97"			, PALETTERGB (247, 247, 247) },
+  {"gray98"			, PALETTERGB (250, 250, 250) },
+  {"grey98"			, PALETTERGB (250, 250, 250) },
+  {"gray99"			, PALETTERGB (252, 252, 252) },
+  {"grey99"			, PALETTERGB (252, 252, 252) },
+  {"gray100"			, PALETTERGB (255, 255, 255) },
+  {"grey100"			, PALETTERGB (255, 255, 255) },
+  {"DarkGrey"			, PALETTERGB (169, 169, 169) },
+  {"DarkGray"			, PALETTERGB (169, 169, 169) },
+  {"DarkBlue"			, PALETTERGB (0, 0, 139) },
+  {"DarkCyan"			, PALETTERGB (0, 139, 139) },
+  {"DarkMagenta"		, PALETTERGB (139, 0, 139) },
+  {"DarkRed"			, PALETTERGB (139, 0, 0) },
+  {"LightGreen"			, PALETTERGB (144, 238, 144) }
 };
 
 static int
 hexval (char c) 
 {
-  if (c >= 'a' && c <= 'f')
+  /* assumes ASCII and isxdigit(c) */
+  if (c >= 'a')
     return c-'a' + 10;
-  else if (c >= 'A' && c <= 'Z')
+  else if (c >= 'A')
     return c-'A' + 10;
   else
     return c-'0';
 }
 
-    
 static COLORREF
 mswindows_string_to_color(CONST char *name)
 {
   int i;
-  unsigned int r, g, b;
-  
+
   if (*name == '#')
-  {
-    /* numeric names look like "#RRGGBB" */
-    /* XXX accept other formats? */
-    if (strlen(name)!=7)
-      return (-1);
-    for (i=1; i<7; i++)
-      {
-	if (!isxdigit(name[i]))
-	  return(-1);
-      }
-    r = hexval(name[1]) * 16 + hexval(name[2]);
-    g = hexval(name[3]) * 16 + hexval(name[4]);
-    b = hexval(name[5]) * 16 + hexval(name[6]);
-    return (PALETTERGB (r, g, b));
-  }
-  else
-  {
-    for(i=0; i<(sizeof(mswindows_X_color_map)/sizeof(colormap_t)); i++)
-      if (!stricmp(name, mswindows_X_color_map[i].name))
-	return (mswindows_X_color_map[i].colorref);
-  }
+    {
+      /* numeric names look like "#RRGGBB", "#RRRGGGBBB" or "#RRRRGGGGBBBB" */
+      unsigned int r, g, b;
+  
+      for (i=1; i<strlen(name); i++)
+	{
+	  if (!isxdigit (name[i]))
+	    return(-1);
+	}
+      if (strlen(name)==7)
+	{
+	  r = hexval (name[1]) * 16 + hexval (name[2]);
+	  g = hexval (name[3]) * 16 + hexval (name[4]);
+	  b = hexval (name[5]) * 16 + hexval (name[6]);
+	  return (PALETTERGB (r, g, b));
+	}
+      else if (strlen(name)==10)
+	{
+	  r = hexval (name[1]) * 16 + hexval (name[2]);
+	  g = hexval (name[4]) * 16 + hexval (name[5]);
+	  b = hexval (name[7]) * 16 + hexval (name[8]);
+	  return (PALETTERGB (r, g, b));
+	}
+      else if (strlen(name)==13)
+	{
+	  r = hexval (name[1]) * 16 + hexval (name[2]);
+	  g = hexval (name[5]) * 16 + hexval (name[6]);
+	  b = hexval (name[9]) * 16 + hexval (name[10]);
+	  return (PALETTERGB (r, g, b));
+	}
+    }
+  else if (*name)	/* Can't be an empty string */
+    {
+      char *nospaces = alloca (strlen (name)+1);
+      char *c=nospaces;
+      while (*name)
+	if (*name != ' ')
+	  *(c++) = *(name++);
+	else
+	  name++;
+      *c = '\0';
+
+      for(i=0; i<(sizeof (mswindows_X_color_map) / sizeof (colormap_t)); i++)
+	if (!stricmp (nospaces, mswindows_X_color_map[i].name))
+	  return (mswindows_X_color_map[i].colorref);
+    }
   return(-1);
 }
 
@@ -798,7 +823,7 @@
   char buf[32];
   COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c);
   sprintf (buf, " %06ld=(%04X,%04X,%04X)", color & 0xffffff,
-	   GetRValue(color)<<8, GetGValue(color)<<8, GetBValue(color)<<8);
+	   GetRValue(color)*257, GetGValue(color)*257, GetBValue(color)*257);
   write_c_string (buf, printcharfun);
 }
 
@@ -831,10 +856,6 @@
 mswindows_color_instance_rgb_components (struct Lisp_Color_Instance *c)
 {
   COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c);
-  /* This used to say GetXValue(color)<<8, but that made, e.g. white
-     show as (#xff00 #xff00 #xff00) instead of (#xffff #xffff #xffff).
-     This slightly kludgier variant gives the expected results for
-     black and white, while hopefully not introducing too much error.  */
   return list3 (make_int (GetRValue (color) * 257),
 		make_int (GetGValue (color) * 257),
 		make_int (GetBValue (color) * 257));
@@ -1082,6 +1103,31 @@
   return list1 (build_string ("Courier New:Regular:10"));
 }
 
+#ifdef MULE
+
+static int
+mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset,
+			     CONST Bufbyte *nonreloc, Lisp_Object reloc,
+			     Bytecount offset, Bytecount length)
+{
+  /* XXX Implement me */
+  if (UNBOUNDP (charset))
+    return 1;
+  
+  return 1;
+}
+
+/* find a font spec that matches font spec FONT and also matches
+   (the registry of) CHARSET. */
+static Lisp_Object
+mswindows_find_charset_font (Lisp_Object device, Lisp_Object font,
+		     Lisp_Object charset)
+{
+  /* XXX Implement me */
+  return build_string ("Courier New:Regular:10");
+}
+
+#endif /* MULE */
 
 
 /************************************************************************/
--- a/src/print.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/print.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1361,7 +1361,13 @@
 	  else
 	    {
 	      if (CONSP (Vprint_gensym_alist))
-		XSETINT (tem, XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
+		{
+		  /* Vprint_gensym_alist is exposed to Lisp, so we
+                     have to be careful.  */
+		  CHECK_CONS (XCAR (Vprint_gensym_alist));
+		  CHECK_INT (XCDR (XCAR (Vprint_gensym_alist)));
+		  XSETINT (tem, XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
+		}
 	      else
 		XSETINT (tem, 1);
 	      Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist);
--- a/src/process.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/process.c	Mon Aug 13 10:19:59 2007 +0200
@@ -619,7 +619,7 @@
 #else /* no PTY_OPEN */
 #ifdef IRIS
 	/* Unusual IRIS code */
- 	*ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0);
+ 	*ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY | OPEN_BINARY, 0);
  	if (fd < 0)
  	  return -1;
 	if (fstat (fd, &stb) < 0)
@@ -634,9 +634,9 @@
 	else
 	  failed_count = 0;
 #ifdef O_NONBLOCK
-	fd = open (pty_name, O_RDWR | O_NONBLOCK, 0);
+	fd = open (pty_name, O_RDWR | O_NONBLOCK | OPEN_BINARY, 0);
 #else
-	fd = open (pty_name, O_RDWR | O_NDELAY, 0);
+	fd = open (pty_name, O_RDWR | O_NDELAY | OPEN_BINARY, 0);
 #endif
 #endif /* not IRIS */
 #endif /* no PTY_OPEN */
@@ -829,15 +829,15 @@
       /* You're "supposed" to now open the slave in the child.
 	 On some systems, we can open it here; this allows for
 	 better error checking. */
-#ifndef USG
+#if !defined(USG)
       /* On USG systems it does not work to open the pty's tty here
 	       and then close and reopen it in the child.  */
 #ifdef O_NOCTTY
       /* Don't let this terminal become our controlling terminal
 	 (in case we don't have one).  */
-      forkout = forkin = open (pty_name, O_RDWR | O_NOCTTY, 0);
+      forkout = forkin = open (pty_name, O_RDWR | O_NOCTTY | OPEN_BINARY, 0);
 #else
-      forkout = forkin = open (pty_name, O_RDWR, 0);
+      forkout = forkin = open (pty_name, O_RDWR | OPEN_BINARY, 0);
 #endif
       if (forkin < 0)
 	goto io_failure;
@@ -870,7 +870,7 @@
   {
     /* child_setup must clobber environ on systems with true vfork.
        Protect it from permanent change.  */
-    char **save_environ = environ;
+    /* char **save_environ = environ;*/
 
 #ifdef EMACS_BTL
     /* when performance monitoring is on, turn it off before the vfork(),
@@ -938,7 +938,7 @@
 	    /* I wonder if close (open (pty_name, ...)) would work?  */
 	    if (xforkin >= 0)
 	      close (xforkin);
-	    xforkout = xforkin = open (pty_name, O_RDWR, 0);
+	    xforkout = xforkin = open (pty_name, O_RDWR | OPEN_BINARY, 0);
 	    if (xforkin < 0)
 	      {
 		write (1, "Couldn't open the pty terminal ", 31);
@@ -1024,7 +1024,7 @@
       cadillac_start_logging ();	/* #### rename me */
 #endif
 
-    environ = save_environ;
+    /*    environ = save_environ;*/
   }
 
   if (pid < 0)
@@ -1277,7 +1277,9 @@
     {
 #ifdef TRY_AGAIN
       if (count++ > 10) break;
-      h_errno = 0;
+#ifndef BROKEN_CYGWIN
+      h_errno = 0; 
+#endif
 #endif
       /* Some systems can't handle SIGIO/SIGALARM in gethostbyname. */
       slow_down_interrupts ();
@@ -3048,7 +3050,7 @@
   else
     {
       close (XPROCESS (proc)->outfd);
-      XPROCESS (proc)->outfd = open (NULL_DEVICE, O_WRONLY, 0);
+      XPROCESS (proc)->outfd = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY, 0);
     }
 
   return process;
--- a/src/redisplay-msw.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/redisplay-msw.c	Mon Aug 13 10:19:59 2007 +0200
@@ -46,6 +46,10 @@
 #include "window.h"
 
 #include "windows.h"
+#ifdef MULE
+#include "mule-ccl.h"
+#include "mule-charset.h"
+#endif
 
 /* MSWINDOWS_DIVIDER_LINE_WIDTH is the width of the line drawn in the gutter.
    MSWINDOWS_DIVIDER_SPACING is the amount of blank space on each side of the line.
@@ -60,6 +64,8 @@
 /*
  * Random forward delarations
  */
+static void mswindows_update_dc (HDC hdc, Lisp_Object font, Lisp_Object fg,
+				 Lisp_Object bg, Lisp_Object bg_pmap);
 static void mswindows_clear_region (Lisp_Object locale, face_index findex,
 			      int x, int y, int width, int height);
 static void mswindows_output_vertical_divider (struct window *w, int clear);
@@ -181,53 +187,58 @@
 
 static int
 mswindows_text_width_single_run (HDC hdc, struct face_cachel *cachel,
-			   textual_run *run)
+				 textual_run *run)
 {
   Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
   struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
   SIZE size;
 
-#if 0	/* XXX HACK: mswindows_text_width is broken and will pass in a NULL hdc */
-  if (!fi->proportional_p)
-#else
   if (!fi->proportional_p || !hdc)
-#endif
     return (fi->width * run->len);
   else
     {
-      assert(run->dimension == 1);	/* XXX FIXME! */
-      GetTextExtentPoint32(hdc, run->ptr, run->len, &size);
+      assert(run->dimension == 1);	/* #### FIXME! */
+      mswindows_update_dc (hdc, font_inst, Qnil, Qnil, Qnil);
+      GetTextExtentPoint32 (hdc, run->ptr, run->len, &size);
       return(size.cx);
     }
 }
 
 
 /*****************************************************************************
- mswindows_update_gc
+ mswindows_update_dc
 
- Given a number of parameters munge the GC so it has those properties.
+ Given a number of parameters munge the DC so it has those properties.
  ****************************************************************************/
 static void
-mswindows_update_gc (HDC hdc, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
-	       Lisp_Object bg_pmap, Lisp_Object lwidth)
+mswindows_update_dc (HDC hdc, Lisp_Object font, Lisp_Object fg,
+		     Lisp_Object bg, Lisp_Object bg_pmap)
 {
   if (!NILP (font))
-    SelectObject(hdc, (XFONT_INSTANCE (font))->data);
+    SelectObject(hdc, FONT_INSTANCE_MSWINDOWS_HFONT (XFONT_INSTANCE (font)));
 
-  /* evil kludge! - XXX do we need this? */
+#ifdef DEBUG_XEMACS
+  /* evil kludge! - #### do we need this? */
   if (!NILP (fg) && !COLOR_INSTANCEP (fg))
     {
-      fprintf (stderr, "Help! mswindows_update_gc got a bogus fg value! fg = ");
-      debug_print (fg);
+      /* this break under mule */
+#if 0 
+      fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! fg = ");
+      debug_print (fg); 
+#endif
       fg = Qnil;
       }
 
   if (!NILP (bg) && !COLOR_INSTANCEP (bg))
     {
-      fprintf (stderr, "Help! mswindows_update_gc got a bogus fg value! bg = ");
-      debug_print (bg);
+      /* this break under mule */
+#if 0 
+      fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! bg = ");
+      debug_print (bg); 
+#endif
       bg = Qnil;
       }
+#endif
 
   if (!NILP (fg))
     SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (fg)));
@@ -254,14 +265,6 @@
 	}
     }
 #endif
-
-#if 0	/* XXX FIXME */
-  if (!NILP (lwidth))
-    {
-      gcv.line_width = XINT (lwidth);
-      mask |= GCLineWidth;
-    }
-#endif
 }
 
 
@@ -297,8 +300,8 @@
     bg_pmap = Qnil;
 
   /* #### This deals only with solid colors */
-  mswindows_update_gc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
-		       cachel->background, Qnil, Qnil);  
+  mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
+		       cachel->background, Qnil);
   ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
 }
 
@@ -352,20 +355,17 @@
 		   (bar_p
 		   ? rb->findex
 		   : get_builtin_face_cache_index (w, Vtext_cursor_face)));
-  mswindows_update_gc (hdc, font, cachel->foreground,
-		       cachel->background, Qnil, Qnil);
-  ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE,
-	      &rect, p_char, n_char, NULL);
+  mswindows_update_dc (hdc, font, cachel->foreground,
+		       cachel->background, Qnil);
+  ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL);
 
   if (focus && bar_p)
     {
       rect.right = rect.left + (EQ (bar, Qt) ? 1 : 2);
       cachel = WINDOW_FACE_CACHEL (w,
 		 get_builtin_face_cache_index (w, Vtext_cursor_face));
-      mswindows_update_gc (hdc, Qnil, Qnil,
-			   cachel->background, Qnil, Qnil);
-      ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE,
-		  &rect, NULL, 0, NULL);
+      mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil);
+      ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL);
     }
   else if (!focus)
     {
@@ -382,9 +382,9 @@
 
       cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? rb->findex
 				       : get_builtin_face_cache_index (w, Vdefault_face)));
-      mswindows_update_gc (hdc, Qnil, cachel->foreground,
-			   cachel->background, Qnil, Qnil);
-      ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
+      mswindows_update_dc (hdc, Qnil, cachel->foreground,
+			   cachel->background, Qnil);
+      ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
 		  &rect, p_char, n_char, NULL);
     }
 }
@@ -422,7 +422,7 @@
   struct frame *f = XFRAME (w->frame);
   /* struct device *d = XDEVICE (f->device);*/
   Lisp_Object window = Qnil;
-  HDC hdc;
+  HDC hdc = FRAME_MSWINDOWS_DC (f);
   int clip_end;
   Lisp_Object bg_pmap;
   int len = Dynarr_length (buf);
@@ -433,7 +433,6 @@
   struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
 
   XSETWINDOW (window, w);
-  hdc = FRAME_MSWINDOWS_DC(f);
 
 #if 0	/* XXX: FIXME? */
   /* We can't work out the width before we've set the font in the DC */
@@ -472,9 +471,8 @@
       if (EQ (font, Vthe_null_font_instance))
 	continue;
 
-      mswindows_update_gc (hdc, font, cachel->foreground,
-			   NILP(bg_pmap) ? cachel->background : Qnil,
-			   Qnil, Qnil);
+      mswindows_update_dc (hdc, font, cachel->foreground,
+			   NILP(bg_pmap) ? cachel->background : Qnil, Qnil);
 
       this_width = mswindows_text_width_single_run (hdc, cachel, runs + i);
 
@@ -502,8 +500,7 @@
  * to by PRC, and paints only the intersection
  */
 static void
-mswindows_redisplay_deadbox_maybe (struct window *w,
-				   CONST RECT* prc)
+mswindows_redisplay_deadbox_maybe (struct window *w, CONST RECT* prc)
 {
   int sbh = window_scrollbar_height (w);
   int sbw = window_scrollbar_width (w);
@@ -682,7 +679,7 @@
   UINT edge;
 
   color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
-  mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
+  mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
 
   if (XINT (w->modeline_shadow_thickness) < 0)
     shadow_width = -shadow_width;
@@ -696,7 +693,7 @@
   else
     edge = EDGE_RAISED;
     
-  DrawEdge (FRAME_MSWINDOWS_DC(f), &rect, edge, BF_RECT);
+  DrawEdge (FRAME_MSWINDOWS_DC (f), &rect, edge, BF_RECT);
 }
 
 
@@ -865,14 +862,7 @@
 		  else
 		    {
 		      Dynarr_add (buf, rb->object.chr.ch);
-#if 0
-		      mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos,
-					 rb->width, findex, 1,
-					 cursor_start, cursor_width,
-				         cursor_height);
-#else
 		      mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
-#endif
 		      Dynarr_reset (buf);
 		    }
 
@@ -941,10 +931,10 @@
 
 		      if (rb->cursor_type == CURSOR_ON)
 			mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
-		      else
+		      else /* #### redisplay-x passes -1 as the width: why ? */
 			mswindows_output_string (w, dl, buf, xpos,
 					   rb->object.dglyph.xoffset,
-					   start_pixpos, -1, findex);
+					   start_pixpos, rb->width, findex);
 		      Dynarr_reset (buf);
 		    }
 		    break;
@@ -1038,10 +1028,10 @@
 
   /* Draw the divider line */
   color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
-  mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
-  ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
+  mswindows_update_dc (FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil);
+  ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
   if (shadow_width)
-    DrawEdge (FRAME_MSWINDOWS_DC(f), &rect,
+    DrawEdge (FRAME_MSWINDOWS_DC (f), &rect,
 	      shadow_width==1 ? BDR_RAISEDINNER : EDGE_RAISED,
 	      BF_TOP|BF_RIGHT|BF_LEFT);
 }
@@ -1052,24 +1042,22 @@
 
  Given a string and a face, return the string's length in pixels when
  displayed in the font associated with the face.
- XXX FIXME: get redisplay_text_width_emchar_string() etc to pass in the
- window so we can get hold of the window's frame's gc
  ****************************************************************************/
 static int
-mswindows_text_width (struct face_cachel *cachel, CONST Emchar *str,
-		Charcount len)
+mswindows_text_width (struct frame *f, struct face_cachel *cachel,
+		      CONST Emchar *str, Charcount len)
 {
   int width_so_far = 0;
   unsigned char *text_storage = (unsigned char *) alloca (2 * len);
   textual_run *runs = alloca_array (textual_run, len);
   int nruns;
   int i;
-  HDC hdc=NULL;	/* XXXXX FIXME! only works for non-proportional fonts! */
 
   nruns = separate_textual_runs (text_storage, runs, str, len);
 
   for (i = 0; i < nruns; i++)
-    width_so_far += mswindows_text_width_single_run (hdc, cachel, runs + i);
+    width_so_far += mswindows_text_width_single_run (FRAME_MSWINDOWS_DC (f),
+						     cachel, runs + i);
 
   return width_so_far;
 }
@@ -1148,7 +1136,8 @@
 	      bcolor = FACE_BACKGROUND (Vdefault_face, locale);
 	    }
 
-	  mswindows_update_gc (FRAME_MSWINDOWS_DC(f), Qnil, fcolor, bcolor, background_pixmap, Qnil);
+	  mswindows_update_dc (FRAME_MSWINDOWS_DC (f),
+			       Qnil, fcolor, bcolor, background_pixmap);
       }
 
       /* XX FIXME: Get brush from background_pixmap here */
@@ -1159,8 +1148,8 @@
     {
       Lisp_Object color = (w ? WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
 			   FACE_BACKGROUND (Vdefault_face, locale));
-      mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
-      ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
+      mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
+      ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
     }
 
 #ifdef HAVE_SCROLLBARS
--- a/src/redisplay-tty.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/redisplay-tty.c	Mon Aug 13 10:19:59 2007 +0200
@@ -105,7 +105,7 @@
  considered to be fixed width.  In other words, we just return len.
  ****************************************************************************/
 static int
-tty_text_width (struct face_cachel *cachel, CONST Emchar *str,
+tty_text_width (struct frame *f, struct face_cachel *cachel, CONST Emchar *str,
 		Charcount len)
 {
   return emchar_string_displayed_columns (str, len);
--- a/src/redisplay-x.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/redisplay-x.c	Mon Aug 13 10:19:59 2007 +0200
@@ -259,7 +259,7 @@
    */
 
 static int
-x_text_width (struct face_cachel *cachel, CONST Emchar *str,
+x_text_width (struct frame *f, struct face_cachel *cachel, CONST Emchar *str,
 	      Charcount len)
 {
   int width_so_far = 0;
@@ -814,7 +814,7 @@
   XSETWINDOW (window, w);
 
   if (width < 0)
-    width = x_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
+    width = x_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
   height = dl->ascent + dl->descent - dl->clip;
 
   /* Regularize the variables passed in. */
--- a/src/redisplay.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/redisplay.c	Mon Aug 13 10:19:59 2007 +0200
@@ -516,8 +516,8 @@
   ensure_face_cachel_complete (WINDOW_FACE_CACHEL (w, findex), window,
 			       charsets);
   return DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (WINDOW_FRAME (w)))),
-		  text_width, (WINDOW_FACE_CACHEL (w, findex),
-			       str, len));
+		  text_width, (XFRAME (WINDOW_FRAME (w)),
+			       WINDOW_FACE_CACHEL (w, findex), str, len));
 }
 
 static Emchar_dynarr *rtw_emchar_dynarr;
@@ -563,7 +563,7 @@
   XSETFRAME (frame, f);
   ensure_face_cachel_complete (&cachel, frame, charsets);
   return DEVMETH (XDEVICE (FRAME_DEVICE (f)),
-		  text_width, (&cachel, Dynarr_atp (rtw_emchar_dynarr, 0),
+		  text_width, (f, &cachel, Dynarr_atp (rtw_emchar_dynarr, 0),
 			       Dynarr_length (rtw_emchar_dynarr)));
 }
 
--- a/src/s/cygwin32.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/s/cygwin32.h	Mon Aug 13 10:19:59 2007 +0200
@@ -37,37 +37,35 @@
  * unnecessary. Also make sure your HOME path is unix style -
  * i.e. without a drive letter.
  *
- * once you have done this, configure and make. The
- * undump phase will fail but that is to be expected. To run you need
- * to set EMACSLOADPATH, EMACSDOC, EMACSDATA etc appropriately and then do:
- * temacs -batch -l loadup.el run-temacs
- * 
- * What I want to do
+ * once you have done this, configure and make. If you want unexec
+ * support you need to download coff.h from my web page or use cygwin
+ * b19. You probably want to build with mule support since this
+ * addresses crlf issues in a sensible way.
+ *
+ * What I want to do:
  *
  * the fileio stuff merely uses the unix system calls this means that
  * the mount type of your fs will determine how files are edited. This
  * is fine except in the instance that you want to convert one to the
  * other. In this instance I would like to bring the buffer_file_type
- * code into the picture without all the other windows-nt cruft.
+ * code into the picture without all the other windows-nt
+ * cruft. Apparently the best way to do this is use the mule coding
+ * stuff.
  *
- * Also the undumped version should be able to do path guessing, I
- * don't know why it doesn't currently.
- *
- * Ideally a dumped version would be done but I'm not sure I am up to
- * the task.
+ * process support needs fixing although basic support works (a la
+ * make-docfile)
  *
  * Andy Piper <andyp@parallax.co.uk> 8/1/98 
- * http://parallax.co.uk/~andyp
- */
+ * http://www.parallax.co.uk/~andyp */
 
-
-/* Need the win32 api */
+/* cheesy way to determine cygwin version */
 #ifndef NOT_C_CODE
-#ifdef CONST
-#undef CONST
-#endif 
-
-#include <windows.h> 
+#include <signal.h>
+#ifdef SIGIO
+#define CYGWIN_B19
+#else
+#define BROKEN_CYGWIN
+#endif
 #endif
 
 #ifdef HAVE_MS_WINDOWS
@@ -88,16 +86,32 @@
 #define FW_BLACK	FW_HEAVY
 #define FW_ULTRABOLD	FW_EXTRABOLD
 #define FW_ULTRALIGHT	FW_EXTRALIGHT
-#define TMPF_FIXED_PITCH	0x01
 #define VK_APPS			0x5D
-#define SIGPROF	0
-#define NO_LIM_DATA
+#define APPCMD_FILTERINITS	0x20L
+#define CBF_FAIL_SELFCONNECTIONS 0x1000
+#define CBF_SKIP_ALLNOTIFICATIONS	0x3C0000
+#define CBF_FAIL_ADVISES	0x4000
+#define CBF_FAIL_POKES		0x10000
+#define CBF_FAIL_REQUESTS	0x20000
+#define SZDDESYS_TOPIC		"System"
 
 #define TEXT_START -1
 #define TEXT_END -1
 #define DATA_END -1
-#define RUN_TIME_REMAP
+#define HEAP_IN_DATA
 #define UNEXEC "unexcw.o"
+#define BROKEN_SIGIO
+#define PROCESS_IO_BLOCKING 
+#define strnicmp strncasecmp
+#ifndef HAVE_SOCKETS
+#define HAVE_SOCKETS
+#endif
+
+#ifndef CYGWIN_B19
+#define TMPF_FIXED_PITCH	0x01
+#define SIGPROF	0
+#define SIGWINCH 0
+#endif
 
 #undef MAIL_USE_SYSTEM_LOCK
 
@@ -159,22 +173,6 @@
 
 #define NOMULTIPLEJOBS
 
-/* Letter to use in finding device name of first pty,
-  if system supports pty's.  'a' means it is /dev/ptya0  */
-
-#define FIRST_PTY_LETTER 'a'
-
-/*
- *      Define HAVE_PTYS if the system supports pty devices.
- */
-
-/* #define HAVE_PTYS */
-
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF". */
-
-#define COFF 1
-
 /* define MAIL_USE_FLOCK if the mailer uses flock
    to interlock access to /usr/spool/mail/$USER.
    The alternative is that a lock file named
@@ -199,26 +197,49 @@
 /* Define this to be the separator between devices and paths */
 #define DEVICE_SEP ':'
 
-#define SIGWINCH NSIG
-
 /* 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 NULL_DEVICE     "NUL:"
 #define EXEC_SUFFIXES   ".exe:.com:.bat:.cmd:"
 
 #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
 
-/* For integration with MSDOS support.  
-#define getdisk()               (_getdrive () - 1)
-#define getdefdir(_drv, _buf)   _getdcwd (_drv, _buf, MAXPATHLEN)
-*/
-
-/* Defines size_t and alloca ().  */
-
 /* We need a little extra space, see ../../lisp/loadup.el */
 #define SYSTEM_PURESIZE_EXTRA 15000
 
+/*
+ * stolen from usg.
+ */
+#define HAVE_PTYS
+#define FIRST_PTY_LETTER 'z'
+
+/* Pseudo-terminal support under SVR4 only loops to deal with errors. */
+
+#define PTY_ITERATION for (i = 0; i < 1; i++)
+
+/* This sets the name of the master side of the PTY. */
+
+#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
+
+/* This sets the name of the slave side of the PTY.  On SysVr4,
+   grantpt(3) forks a subprocess, so keep sigchld_handler() from
+   intercepting that death.  If any child but grantpt's should die
+   within, it should be caught after EMACS_UNBLOCK_SIGNAL. */
+
+#define PTY_OPEN \
+   fd = open (pty_name, O_RDWR | O_NONBLOCK | OPEN_BINARY, 0)
+
+#define PTY_TTY_NAME_SPRINTF				\
+  {							\
+    char *ptyname;					\
+							\
+    if (!(ptyname = ptsname (fd)))			\
+      { close (fd); return -1; }			\
+    strncpy (pty_name, ptyname, sizeof (pty_name));	\
+    pty_name[sizeof (pty_name) - 1] = 0;		\
+  }
+
 /* ============================================================ */
+
--- a/src/search.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/search.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1808,8 +1808,7 @@
       CHECK_STRING (string);
       if (!EQ (last_thing_searched, Qt))
 	error ("last thing matched was not a string");
-      /* Damn you RMS!  You are going to burn in hell for your
-	 antipathy towards data abstraction.  If the match data
+      /* If the match data
 	 were abstracted into a special "match data" type instead
 	 of the typical half-assed "let the implementation be
 	 visible" form it's in, we could extend it to include
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sheap.c	Mon Aug 13 10:19:59 2007 +0200
@@ -0,0 +1,119 @@
+/* Static Heap management routines for XEmacs.
+   Copyright (C) 1994, 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.*/
+
+#include "config.h"
+#include <stdio.h>
+#include <lisp.h>
+#include <stddef.h>
+#include "sheap-adjust.h"
+
+#ifdef MULE
+#define STATIC_HEAP_BASE	0x500000
+#define STATIC_HEAP_SLOP	0x30000
+#else
+#define STATIC_HEAP_BASE	0x400000
+#define STATIC_HEAP_SLOP	0x20000
+#endif
+#define STATIC_HEAP_SIZE \
+(STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
+#define BLOCKSIZE	(1<<12)
+#define ALLOC_UNIT (BLOCKSIZE-1)
+#define ALLOC_MASK ~((unsigned long)(ALLOC_UNIT))
+#define ALIGN_ALLOC(addr) ((((unsigned long)addr) + ALLOC_UNIT) & ALLOC_MASK)
+
+char	static_heap_buffer[STATIC_HEAP_SIZE]={0};
+char*	static_heap_base=static_heap_buffer;
+char*	static_heap_ptr=static_heap_buffer;
+unsigned long	static_heap_size=STATIC_HEAP_SIZE;
+int 	static_heap_initialized=0;
+int 	static_heap_dumped=0;
+
+void* more_static_core ( ptrdiff_t increment )
+{
+  int size = (int) increment;
+  void *result;
+  
+  if (!static_heap_initialized)
+    {
+      if (((unsigned long) static_heap_base & ~VALMASK) != 0)
+	{
+	  printf ("error: The heap was allocated in upper memory.\n");
+	  exit (-1);
+	}
+      static_heap_base=(char*)ALIGN_ALLOC(static_heap_buffer);
+      static_heap_ptr=static_heap_base;
+      static_heap_size=STATIC_HEAP_SIZE - 
+	(static_heap_base-static_heap_buffer);
+#ifdef __CYGWIN32__
+      sbrk(BLOCKSIZE);		/* force space for fork to work */
+#endif
+      static_heap_initialized=1;
+    }
+  
+  result = static_heap_ptr;
+
+  /* we don't need to align - handled by gmalloc.  */
+
+  if (size < 0) 
+    {
+      if (static_heap_ptr + size < static_heap_base)
+	{
+	  return 0;
+	}
+    }
+  else 
+    {
+      if (static_heap_ptr + size >= static_heap_base + static_heap_size)
+	{
+	  printf(
+
+"\nRequested %d bytes, static heap exhausted!  base is %p,\n
+current ptr is %p. You have exhausted the static heap, if\n
+you want to run temacs, adjust sheap-adjust.h to 0 or a +ve\n
+number.  If you are dumping then STATIC_HEAP_SLOP is too\n
+small.  Generally you should *not* try to run temacs with a\n
+static heap, you should dump first.", size,
+static_heap_base, static_heap_ptr);
+
+	  exit(-1);
+	  return 0;
+	}
+    }
+  static_heap_ptr += size;
+  
+  return result;
+}
+
+void
+sheap_adjust_h ()
+{
+  FILE *stream = fopen ("sheap-adjust.h", "w");
+
+  if (stream == NULL)
+    report_file_error ("Opening sheap adjustment file",
+		       Fcons (build_string ("sheap-adjust.h"), Qnil));
+
+  fprintf (stream,
+	   "/*\tDo not edit this file!\n"
+	   "\tAutomatically generated by XEmacs */\n"
+	   "# define SHEAP_ADJUSTMENT (%d)\n",
+	   ((static_heap_ptr - static_heap_buffer) - STATIC_HEAP_BASE));
+  fclose (stream);
+}
--- a/src/signal.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/signal.c	Mon Aug 13 10:19:59 2007 +0200
@@ -598,7 +598,7 @@
 {
   if (!interrupts_initted)
     return;
-#ifdef SIGIO
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
   unrequest_sigio ();
 #endif
   stop_async_timeouts ();
@@ -609,7 +609,7 @@
 {
   if (!interrupts_initted)
     return;
-#ifdef SIGIO
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
   request_sigio ();
 #endif
   start_async_timeouts ();
--- a/src/symbols.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/symbols.c	Mon Aug 13 10:19:59 2007 +0200
@@ -104,13 +104,7 @@
 
   ((markobj) (sym->value));
   ((markobj) (sym->function));
-  /* DON'T mark through ->obarray slot.  Since the slot is not visible
-     from Lisp, it would be wrong not to gc an obarray vector only
-     because there are symbols pointing to it.  This is safe, because
-     we only check the nil-ness of the object.  An implication of this
-     is that, when the obarray vector is gc-ed, its symbols are still
-     considered "interned" for printing purposes -- but it's probably
-     no big deal.  */
+  /* No need to mark through ->obarray, because it only holds nil or t.  */
   /*((markobj) (sym->obarray));*/
   XSETSTRING (pname, sym->name);
   ((markobj) (pname));
@@ -201,7 +195,12 @@
   if (purify_flag && ! purified (str))
     str = make_pure_pname (XSTRING_DATA (str), len, 0);
   sym = Fmake_symbol (str);
-  XSYMBOL (sym)->obarray = obarray;
+  /* FSFmacs places OBARRAY here, but it is pointless because we do
+     not mark through this slot, so it is not usable later (because
+     the obarray might have been collected).  Marking through the
+     ->obarray slot is an even worse idea, because it would keep
+     obarrays from being collected because of symbols pointed to them.  */
+  XSYMBOL (sym)->obarray = Qt;
 
   if (SYMBOLP (*ptr))
     symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr);
@@ -3174,7 +3173,7 @@
     hash %= OBARRAY_SIZE;
     tem = &XVECTOR_DATA (Vobarray)[hash];
     *tem = Qnil;
-    XSYMBOL (Qnil)->obarray = Vobarray;
+    XSYMBOL (Qnil)->obarray = Qt;
   }
 
   {
--- a/src/sysdep.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/sysdep.c	Mon Aug 13 10:19:59 2007 +0200
@@ -885,7 +885,7 @@
 /*                       SIGIO control                    */
 /* ------------------------------------------------------ */
 
-#ifdef SIGIO
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
 
 static void
 init_sigio_on_device (struct device *d)
@@ -1659,7 +1659,7 @@
   if (DEVICE_TTY_P (d))
     tty_init_sys_modes_on_device (d);
 #endif
-#ifdef SIGIO
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
   if (!DEVICE_STREAM_P (d))
     {
       init_sigio_on_device (d);
@@ -1870,7 +1870,7 @@
 #endif
   if (DEVICE_STREAM_P (d))
     fflush (CONSOLE_STREAM_DATA (XCONSOLE (DEVICE_CONSOLE (d)))->outfd);
-#ifdef SIGIO
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
   if (!DEVICE_STREAM_P (d))
     {
       unrequest_sigio_on_device (d);
@@ -2119,7 +2119,11 @@
    * we don't sweat the handful of bytes that might lose.
    */
   extern char **environ;
-
+#ifdef HEAP_IN_DATA
+  extern char* static_heap_base;
+  if (!initialized)
+    return static_heap_base;
+#endif
   return((char *) &environ);
 #else
   extern int data_start;
@@ -2208,7 +2212,7 @@
       hostname_size <<= 1;
       hostname = (char *) alloca (hostname_size);
     }
-# if defined( HAVE_SOCKETS) && !defined(__CYGWIN32__)
+# if defined( HAVE_SOCKETS) && !defined(BROKEN_CYGWIN)
   /* Turn the hostname into the official, fully-qualified hostname.
      Don't do this if we're going to dump; this can confuse system
      libraries on some machines and make the dumped emacs core dump. */
--- a/src/sysfile.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/sysfile.h	Mon Aug 13 10:19:59 2007 +0200
@@ -35,8 +35,9 @@
 #include <sys/stat.h>
 #include <sys/param.h>
 
-#if NeXT
-/* what is needed from here?  Do others need it too? */
+#if defined (NeXT) || defined(__CYGWIN32__)
+/* what is needed from here?  Do others need it too? 
+ O_BINARY is in here under cygwin. */
 # include <sys/fcntl.h>
 #endif /* NeXT */
 
@@ -71,6 +72,55 @@
 #define O_RDWR 2
 #endif
 
+/* file opening defaults */
+#ifndef OPEN_BINARY
+#ifdef O_BINARY
+#define OPEN_BINARY	O_BINARY
+#else
+#define OPEN_BINARY	(0)
+#endif
+#endif
+
+#ifndef OPEN_TEXT
+#ifdef O_TEXT
+#define OPEN_TEXT	O_TEXT
+#else
+#define OPEN_TEXT	(0)
+#endif
+#endif
+
+#ifndef CREAT_MODE
+#ifdef WINDOWSNT
+#define CREAT_MODE	(S_IREAD | S_IWRITE)
+#else
+#define CREAT_MODE	(0666)
+#endif
+#endif
+
+#ifndef READ_TEXT
+#ifdef O_TEXT
+#define READ_TEXT "rt"
+#else
+#define READ_TEXT "r"
+#endif
+#endif
+
+#ifndef READ_BINARY
+#ifdef O_BINARY
+#define READ_BINARY "rb"
+#else
+#define READ_BINARY "r"
+#endif
+#endif
+
+#ifndef WRITE_BINARY
+#ifdef O_BINARY
+#define WRITE_BINARY "wb"
+#else
+#define WRITE_BINARY "w"
+#endif
+#endif
+
 /* if system does not have symbolic links, it does not have lstat.
    In that case, use ordinary stat instead.  */
 
--- a/src/systime.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/systime.h	Mon Aug 13 10:19:59 2007 +0200
@@ -224,7 +224,7 @@
 extern void get_process_times (double *user_time, double *system_time,
 			       double *real_time);
 
-#ifdef _WIN32
+#if defined(WINDOWSNT) || defined(BROKEN_CYGWIN)
 
 /* setitimer emulation for Win32 (see nt.c) */
 
@@ -240,6 +240,6 @@
 #define ITIMER_REAL 1
 #define ITIMER_PROF 2
 
-#endif /* _WIN32 */
+#endif /* WINDOWSNT */
 
 #endif /* _XEMACS_SYSTIME_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/unexcw.c	Mon Aug 13 10:19:59 2007 +0200
@@ -0,0 +1,419 @@
+/* unexec for GNU Emacs on Cygwin32.
+   Copyright (C) 1994, 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.
+
+*/
+
+/* This is a complete rewrite, some code snarfed from unexnt.c and
+   unexec.c, Andy Piper (andyp@parallax.co.uk) 13-1-98 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <config.h>
+#include <string.h>
+#include "sysfile.h"
+#define PERROR(arg) perror(arg);exit(-1) 
+
+#ifndef HAVE_A_OUT_H
+unexec (char *, char *, void *, void *,	void *)
+{
+  PERROR("cannot unexec() a.out.h not installed");
+}
+#else
+
+#undef CONST
+#include <windows.h>
+#include <a.out.h>
+
+#define ALLOC_UNIT 0xFFFF
+#define ALLOC_MASK ~((unsigned long)(ALLOC_UNIT))
+#define ALIGN_ALLOC(addr) \
+((((unsigned long)addr) + ALLOC_UNIT) & ALLOC_MASK)
+
+/* To prevent zero-initialized variables from being placed into the bss
+   section, use non-zero values to represent an uninitialized state.  */
+#define UNINIT_PTR ((void *) 0xF0A0F0A0)
+#define UNINIT_LONG (0xF0A0F0A0L)
+
+static void get_section_info (int a_out, char* a_name);
+static void copy_executable_and_dump_data_section (int a_out, int a_new);
+static void dup_file_area(int a_out, int a_new, long size);
+#if 0
+static void write_int_to_bss(int a_out, int a_new, void* va, void* newval);
+#endif
+
+/* Cached info about the .data section in the executable.  */
+void* data_start_va = UNINIT_PTR;
+unsigned long  data_size = UNINIT_LONG;
+
+/* Cached info about the .bss section in the executable.  */
+void* bss_start = UNINIT_PTR;
+unsigned long  bss_size = UNINIT_LONG;
+FILHDR f_hdr;
+PEAOUTHDR f_ohdr;
+SCNHDR f_data, f_bss, f_text, f_idata;
+
+#define PERROR(arg) perror(arg);exit(-1) 
+#define CHECK_AOUT_POS(a) \
+if (lseek(a_out, 0, SEEK_CUR) != a) \
+{ \
+  printf("we are at %lx, should be at %lx\n", \
+	 lseek(a_out, 0, SEEK_CUR), a); \
+  exit(-1); \
+}
+
+/* Dump out .data and .bss sections into a new executable.  */
+void unexec (char *out_name, char *in_name, void *start_data, 
+	     void * d1,	void * d2)
+{
+  /* ugly nt hack - should be in lisp */
+  int a_new, a_out = -1;
+  char new_name[MAX_PATH], a_name[MAX_PATH];
+  char *ptr;
+  
+  /* Make sure that the input and output filenames have the
+     ".exe" extension...patch them up if they don't.  */
+  strcpy (a_name, in_name);
+  ptr = a_name + strlen (a_name) - 4;
+  if (strcmp (ptr, ".exe"))
+    strcat (a_name, ".exe");
+
+  strcpy (new_name, out_name);
+  ptr = new_name + strlen (new_name) - 4;
+  if (strcmp (ptr, ".exe"))
+    strcat (new_name, ".exe");
+
+  /* We need to round off our heap to NT's allocation unit (64KB).  */
+  /* round_heap (get_allocation_unit ()); */
+
+  if (a_name && (a_out = open (a_name, O_RDONLY | OPEN_BINARY)) < 0)
+    {
+      PERROR (a_name);
+    }
+
+  if ((a_new = open (new_name, O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
+		     CREAT_MODE)) < 0)
+    {
+      PERROR (new_name);
+    }
+
+  /* Get the interesting section info, like start and size of .bss...  */
+  get_section_info (a_out, a_name);
+
+  copy_executable_and_dump_data_section (a_out, a_new);
+
+  close(a_out);
+  close(a_new);
+}
+
+/* Flip through the executable and cache the info necessary for dumping.  */
+static void get_section_info (int a_out, char* a_name)
+{
+  extern int my_ebss;
+  /* From lastfile.c  */
+  extern char my_edata[];
+
+  if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
+    {
+      PERROR (a_name);
+    }
+
+  if (f_hdr.e_magic != DOSMAGIC) 
+    {
+      PERROR("unknown exe header");
+    }
+
+  /* Check the NT header signature ...  */
+  if (f_hdr.nt_signature != NT_SIGNATURE) 
+    {
+      PERROR("invalid nt header");
+    }
+
+  /* Flip through the sections for .data and .bss ...  */
+  if (f_hdr.f_opthdr > 0)
+    {
+      if (read (a_out, &f_ohdr, AOUTSZ) != AOUTSZ)
+	{
+	  PERROR (a_name);
+	}
+    }
+  /* Loop through .data & .bss section headers, copying them in */
+  lseek (a_out, sizeof (f_hdr) + f_hdr.f_opthdr, 0);
+
+  if (read (a_out, &f_text, sizeof (f_text)) != sizeof (f_text)
+      &&
+      strcmp (f_text.s_name, ".text"))
+    {
+      PERROR ("no .text section");
+    }
+
+  /* The .bss section.  */
+  if (read (a_out, &f_bss, sizeof (f_bss)) != sizeof (f_bss)
+      &&
+      strcmp (f_bss.s_name, ".bss"))
+    {
+      PERROR ("no .bss section");
+    }
+
+  bss_start = (void *) ((char*)f_ohdr.ImageBase + f_bss.s_vaddr);
+  bss_size = (unsigned long)((char*)&my_ebss-(char*)bss_start);
+  
+  /* must keep bss data that we want to be blank as blank */
+  printf("found bss - keeping %lx of %lx bytes\n", bss_size, f_ohdr.bsize);
+
+  /* The .data section.  */
+  if (read (a_out, &f_data, sizeof (f_data)) != sizeof (f_data)
+      &&
+      strcmp (f_data.s_name, ".data"))
+    {
+      PERROR ("no .data section");
+    }
+
+  /* The .data section.  */
+  data_start_va = (void *) ((char*)f_ohdr.ImageBase + f_data.s_vaddr);
+
+  /* We want to only write Emacs data back to the executable,
+     not any of the library data (if library data is included,
+     then a dumped Emacs won't run on system versions other
+     than the one Emacs was dumped on).  */
+  data_size = (unsigned long)my_edata - (unsigned long)data_start_va;
+
+  /* The .idata section.  */
+  if (read (a_out, &f_idata, sizeof (f_idata)) != sizeof (f_idata)
+      &&
+      strcmp (f_idata.s_name, ".idata"))
+    {
+      PERROR ("no .idata section");
+    }
+}
+
+/* The dump routines.  */
+
+static void
+copy_executable_and_dump_data_section (int a_out, int a_new)
+{
+  long size=0;
+  unsigned long new_data_size, new_bss_size, f_data_s_vaddr,
+    file_sz_change, f_data_s_scnptr, bss_padding;
+  int i;
+  void* empty_space;
+  extern int static_heap_dumped;
+  SCNHDR section;
+  /* calculate new sizes f_ohdr.dsize is the total initalized data
+     size on disk which is f_data.s_size + f_idata.s_size. 
+     f_ohdr.data_start is the base addres of all data and so should 
+     not be changed. *.s_vaddr is the virtual address of the start
+     of the section normalzed from f_ohdr.ImageBase. *.s_paddr
+     appears to be the number of bytes in the section actually used
+     (whereas *.s_size is aligned).
+
+     bsize is now 0 since subsumed into .data
+     dsize is dsize + (f_data.s_vaddr - f_bss.s_vaddr)
+     f_data.s_vaddr is f_bss.s_vaddr
+     f_data.s_size is new dsize maybe.
+     what about s_paddr & s_scnptr?  */
+  /* this is the amount the file increases in size */
+  new_bss_size=f_data.s_vaddr - f_bss.s_vaddr;
+  file_sz_change=new_bss_size;
+  new_data_size=f_ohdr.dsize + new_bss_size;
+  f_data_s_scnptr = f_data.s_scnptr;
+  f_data_s_vaddr = f_data.s_vaddr;
+  f_data.s_vaddr = f_bss.s_vaddr;
+  f_data.s_paddr += new_bss_size;
+
+  if (f_data.s_size + f_idata.s_size != f_ohdr.dsize)
+    {
+      printf("section size doesn't tally with dsize %lx != %lx\n", 
+	     f_data.s_size + f_idata.s_size, f_ohdr.dsize);
+    }
+  f_data.s_size += new_bss_size;
+  lseek (a_new, 0, SEEK_SET);
+  /* write file header */
+  f_hdr.f_symptr += file_sz_change;
+  f_hdr.f_nscns--;
+  printf("writing file header\n");
+  if (write(a_new, &f_hdr, sizeof(f_hdr)) != sizeof(f_hdr))
+    {
+      PERROR("failed to write file header");
+    }
+  /* write optional header fixing dsize & bsize*/
+  printf("writing optional header\n");
+  printf("new data size is %lx, >= %lx\n", new_data_size,
+	 f_ohdr.dsize + f_ohdr.bsize);
+  if (new_data_size < f_ohdr.dsize + f_ohdr.bsize )
+    {
+      PERROR("new data size is < approx");
+    }
+  f_ohdr.dsize=new_data_size;
+  f_ohdr.bsize=0;
+  if (write(a_new, &f_ohdr, sizeof(f_ohdr)) != sizeof(f_ohdr))
+    {
+      PERROR("failed to write optional header");
+    }
+  /* write text as is */
+  printf("writing text header (unchanged)\n");
+
+  if (write(a_new, &f_text, sizeof(f_text)) != sizeof(f_text))
+    {
+      PERROR("failed to write text header");
+    }
+
+  /* write new data header */
+  printf("writing .data header\n");
+
+  if (write(a_new, &f_data, sizeof(f_data)) != sizeof(f_data))
+    {
+      PERROR("failed to write data header");
+    }
+  
+  printf("writing .idata header\n");
+  f_idata.s_scnptr += file_sz_change;
+  if (f_idata.s_lnnoptr != 0) f_idata.s_lnnoptr += file_sz_change;
+  if (f_idata.s_relptr != 0) f_idata.s_relptr += file_sz_change;
+  if (write(a_new, &f_idata, sizeof(f_idata)) != sizeof(f_idata))
+    {
+      PERROR("failed to write idata header");
+    }
+  
+  /* copy other section headers adjusting the file offset */
+  for (i=0; i<(f_hdr.f_nscns-3); i++)
+    {
+      if (read (a_out, &section, sizeof (section)) != sizeof (section))
+	{
+	  PERROR ("no .data section");
+	}
+      
+      section.s_scnptr += file_sz_change;
+      if (section.s_lnnoptr != 0) section.s_lnnoptr += file_sz_change;
+      if (section.s_relptr != 0) section.s_relptr += file_sz_change;
+
+      if (write(a_new, &section, sizeof(section)) != sizeof(section))
+	{
+	  PERROR("failed to write data header");
+	}
+    }
+
+  /* dump bss to maintain offsets */
+  memset(&f_bss, 0, sizeof(f_bss));
+  if (write(a_new, &f_bss, sizeof(f_bss)) != sizeof(f_bss))
+    {
+      PERROR("failed to write bss header");
+    }
+  
+  size=lseek(a_new, 0, SEEK_CUR);
+  CHECK_AOUT_POS(size);
+
+  /* copy eveything else until start of data */
+  size = f_data_s_scnptr - lseek (a_out, 0, SEEK_CUR);
+
+  printf ("copying executable up to data section ... %lx bytes\n", 
+	  size);
+  dup_file_area(a_out, a_new, size);
+
+  CHECK_AOUT_POS(f_data_s_scnptr);
+
+  /* dump bss + padding between sections */
+  printf ("dumping .bss into executable... %lx bytes\n", bss_size);
+  if (write(a_new, bss_start, bss_size) != (int)bss_size)
+    {
+      PERROR("failed to write bss section");
+    }
+
+  /* pad, needs to be zero */
+  bss_padding = new_bss_size - bss_size;
+  printf ("padding .bss ... %lx bytes\n", bss_padding);
+  empty_space = malloc(bss_padding);
+  memset(empty_space, 0, bss_padding);
+  if (write(a_new, empty_space, bss_padding) != (int)bss_padding)
+    {
+      PERROR("failed to write bss section");
+    }
+  free(empty_space);
+
+  /* tell dumped version not to free pure heap */
+  static_heap_dumped = 1;
+  /* Get a pointer to the raw data in our address space.  */
+  printf ("dumping .data section... %lx bytes\n", data_size);
+  if (write(a_new, data_start_va, data_size) != (int)data_size)
+    {
+      PERROR("failed to write data section");
+    }
+  /* were going to use free again ... */
+  static_heap_dumped = 0;
+  
+  size = lseek(a_out, f_data_s_scnptr + data_size, SEEK_SET);
+  size = f_idata.s_scnptr - size;
+  dup_file_area(a_out, a_new, size);
+
+  //  lseek(a_out, f_idata.s_scnptr, SEEK_CUR);
+  CHECK_AOUT_POS(f_idata.s_scnptr);
+  /* now dump - idata don't need to do this cygwin ds is in .data! */
+  printf ("dumping .idata section... %lx bytes\n", f_idata.s_size);
+
+  dup_file_area(a_out,a_new,f_idata.s_size);
+
+  /* write rest of file */
+  printf ("writing rest of file\n");
+  size = lseek(a_out, 0, SEEK_END);
+  size = size - (f_idata.s_scnptr + f_idata.s_size); /* length remaining in a_out */
+  lseek(a_out, f_idata.s_scnptr + f_idata.s_size, SEEK_SET);
+
+  dup_file_area(a_out, a_new, size);
+}
+
+/*
+ * copy from aout to anew
+ */
+static void dup_file_area(int a_out, int a_new, long size)
+{
+  char page[BUFSIZ];
+  long n;
+  for (; size > 0; size -= sizeof (page))
+    {
+      n = size > sizeof (page) ? sizeof (page) : size;
+      if (read (a_out, page, n) != n || write (a_new, page, n) != n)
+	{
+	  PERROR ("dump_out()");
+	}
+    }
+}
+
+#if 0
+static void write_int_to_bss(int a_out, int a_new, void* va, void* newval)
+{
+  int cpos;
+
+  cpos = lseek(a_new, 0, SEEK_CUR);
+  if (va < bss_start || va > bss_start + f_data.s_size)
+    {
+      PERROR("address not in data space\n");
+    }
+  lseek(a_new, f_data.s_scnptr + ((unsigned long)va - 
+				  (unsigned long)bss_start), SEEK_SET);
+  if (write(a_new, newval, sizeof(int)) != (int)sizeof(int))
+    {
+      PERROR("failed to write int value");
+    }
+  lseek(a_new, cpos, SEEK_SET);
+}
+#endif
+
+#endif /* HAVE_A_OUT_H */
--- a/src/unexelf.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/unexelf.c	Mon Aug 13 10:19:59 2007 +0200
@@ -680,7 +680,7 @@
   if (n < 0)
     fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0);
 
-  NEW_PROGRAM_H (n).p_filesz += new_data2_size;
+  NEW_PROGRAM_H (n).p_filesz = new_bss_addr - NEW_PROGRAM_H (n).p_vaddr;
   NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;
 
 #if 0 /* Maybe allow section after data2 - does this ever happen? */
--- a/src/window.c	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/window.c	Mon Aug 13 10:19:59 2007 +0200
@@ -1373,7 +1373,7 @@
   return ncol;
 }
 
-#if 0 /* bogus RMS crock */
+#if 0 /* bogus crock */
 
 xxDEFUN ("window-redisplay-end-trigger",
 	 Fwindow_redisplay_end_trigger, 0, 1, 0, /*
@@ -4289,6 +4289,7 @@
   for (; !NILP (window); window = XWINDOW (window)->next)
     {
       struct window *w = XWINDOW (window);
+
       if (!NILP (w->vchild))
 	retval = map_windows_1 (w->vchild, mapfun, closure);
       else if (!NILP (w->hchild))
@@ -4299,20 +4300,33 @@
 	return retval;
     }
 
-  return 0;
+  return retval;
 }
 
 /* Map MAPFUN over the windows in F.  CLOSURE is passed to each
-   invocation of MAPFUN.  If any invocation of MAPFUN returns non-zero,
-   the mapping is halted and the value returned is the return value
-   of map_windows().  Otherwise, map_windows() maps over all windows
-   in F and returns 0. */
-
-int
+   invocation of MAPFUN.  If any invocation of MAPFUN returns
+   non-zero, the mapping is halted.  Otherwise, map_windows() maps
+   over all windows in F.
+
+   If MAPFUN create or delete windows, the behaviour is undefined.  */
+
+void
 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
 	     void *closure)
 {
-  return map_windows_1 (FRAME_ROOT_WINDOW (f), mapfun, closure);
+  if (f)
+    map_windows_1 (FRAME_ROOT_WINDOW (f), mapfun, closure);
+  else
+    {
+      Lisp_Object frmcons, devcons, concons;
+
+      FRAME_LOOP_NO_BREAK(frmcons, devcons, concons)
+	{
+	  if (map_windows_1 (FRAME_ROOT_WINDOW (XFRAME (XCAR (frmcons))),
+			     mapfun, closure))
+	    return;
+	}
+    }
 }
 
 
@@ -4626,24 +4640,18 @@
   return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil;
 }
 
-/*
- * There are getting to be a lot of functions which traverse the
- * window structure doing various things.  It may be worth writing a
- * generic map-windows function.
- * #### I just did.  Feel free to rewrite. --ben
- */
-void
-mark_windows_in_use (Lisp_Object window, int mark)
+static int
+mark_windows_in_use_closure (struct window *w, void *closure)
 {
-  for (; !NILP (window) ; window = XWINDOW (window)->next)
-    {
-      XWINDOW (window)->config_mark = mark;
-
-      if (!NILP (XWINDOW (window)->vchild))
-	mark_windows_in_use (XWINDOW (window)->vchild, mark);
-      else if (!NILP (XWINDOW (window)->hchild))
-	mark_windows_in_use (XWINDOW (window)->hchild, mark);
-    }
+  int mark = *(int *)closure;
+  w->config_mark = mark;
+  return 0;
+}
+
+static void
+mark_windows_in_use (struct frame *f, int mark)
+{
+  map_windows (f, mark_windows_in_use_closure, &mark);
 }
 
 /* Lisp_Object return value so it can be used in record_unwind_protect() */
@@ -4771,7 +4779,7 @@
       begin_dont_check_for_quit ();
       record_unwind_protect (free_window_configuration, old_window_config);
 
-      mark_windows_in_use (f->root_window, 1);
+      mark_windows_in_use (f, 1);
 
       previous_frame_width = FRAME_WIDTH (f);
       previous_frame_height = FRAME_HEIGHT (f);
@@ -5326,7 +5334,7 @@
   DEFSUBR (Fwindow_pixel_height);
   DEFSUBR (Fwindow_pixel_width);
   DEFSUBR (Fwindow_hscroll);
-#if 0 /* bogus RMS crock */
+#if 0 /* bogus crock */
   DEFSUBR (Fwindow_redisplay_end_trigger);
   DEFSUBR (Fset_window_redisplay_end_trigger);
 #endif
--- a/src/window.h	Mon Aug 13 10:19:12 2007 +0200
+++ b/src/window.h	Mon Aug 13 10:19:59 2007 +0200
@@ -380,7 +380,6 @@
 int buffer_window_count (struct buffer *b, struct frame *f);
 int buffer_window_mru (struct window *w);
 void check_frame_size (struct frame *frame, int *rows, int *cols);
-void mark_windows_in_use (Lisp_Object window, int mark);
 struct window *decode_window (Lisp_Object window);
 struct window *find_window_by_pixel_pos (unsigned int pix_x,
 					 unsigned int pix_y,
@@ -395,9 +394,9 @@
 void set_window_display_buffer (struct window *w, struct buffer *b);
 void update_frame_window_mirror (struct frame *f);
 
-int map_windows (struct frame *f,
-		 int (*mapfun) (struct window *w, void *closure),
-		 void *closure);
+void map_windows (struct frame *f,
+		  int (*mapfun) (struct window *w, void *closure),
+		  void *closure);
 void some_window_value_changed (Lisp_Object specifier, struct window *w,
 				Lisp_Object oldval);
 
--- a/version.sh	Mon Aug 13 10:19:12 2007 +0200
+++ b/version.sh	Mon Aug 13 10:19:59 2007 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
 emacs_major_version=20
 emacs_minor_version=5
-emacs_beta_version=23
-xemacs_codename="Jining Grey"
+emacs_beta_version=24
+xemacs_codename="Kaghani"