changeset 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 301b9ebbdf3b
children 12e008d41344
files CHANGES-beta ChangeLog INSTALL Makefile.in.in PROBLEMS aclocal.m4 config.guess config.sub configure configure.in configure.usage etc/NEWS lib-src/ChangeLog lib-src/Makefile.in.in lib-src/b2m.c lib-src/ellcc.c lib-src/etags.c lib-src/fakemail.c lib-src/getopt.c lib-src/getopt.h lib-src/gnuclient.c lib-src/gnuserv.c lib-src/gnuserv.h lib-src/hexl.c lib-src/make-docfile.c lib-src/make-dump-id.c lib-src/mmencode.c lib-src/movemail.c lib-src/ootags.c lib-src/pop.c lib-src/profile.c lib-src/run.c lib-src/run.h lib-src/run.rc lib-src/wakeup.c lib-src/yow.c lisp/ChangeLog lisp/apropos.el lisp/auto-autoloads.el lisp/autoload.el lisp/buff-menu.el lisp/build-report.el lisp/cl-macs.el lisp/cl-seq.el lisp/cl.el lisp/cmdloop.el lisp/code-files.el lisp/code-process.el lisp/compat.el lisp/cus-dep.el lisp/cus-edit.el lisp/cus-file.el lisp/cus-start.el lisp/custom-load.el lisp/custom.el lisp/dumped-lisp.el lisp/etags.el lisp/faces.el lisp/files.el lisp/find-paths.el lisp/finder.el lisp/font-lock.el lisp/info.el lisp/isearch-mode.el lisp/itimer.el lisp/msw-select.el lisp/mule/mule-category.el lisp/mule/mule-x-init.el lisp/package-get.el lisp/package-info.el lisp/package-ui.el lisp/packages.el lisp/printer.el lisp/process.el lisp/rect.el lisp/select.el lisp/simple.el lisp/startup.el lisp/toolbar.el lisp/x-faces.el lisp/x-misc.el lisp/x-mouse.el lisp/x-scrollbar.el lisp/x-select.el lwlib/ChangeLog lwlib/config.h.in lwlib/lwlib-Xaw.c lwlib/lwlib.c lwlib/xlwcheckbox.c lwlib/xlwgauge.c lwlib/xlwgauge.h lwlib/xlwgaugeP.h lwlib/xlwmenu.c lwlib/xlwradio.c lwlib/xlwradio.h lwlib/xlwradioP.h man/ChangeLog man/Makefile man/internals/internals.texi man/lispref/glyphs.texi man/lispref/gutter.texi man/lispref/loading.texi man/lispref/mule.texi man/lispref/postgresql.texi man/make-stds.texi man/new-users-guide/edit.texi man/new-users-guide/modes.texi man/new-users-guide/region.texi man/xemacs-faq.texi man/xemacs/abbrevs.texi man/xemacs/basic.texi man/xemacs/buffers.texi man/xemacs/building.texi man/xemacs/calendar.texi man/xemacs/cmdargs.texi man/xemacs/custom.texi man/xemacs/glossary.texi man/xemacs/gnu.texi man/xemacs/help.texi man/xemacs/keystrokes.texi man/xemacs/menus.texi man/xemacs/misc.texi man/xemacs/new.texi man/xemacs/packages.texi man/xemacs/programs.texi man/xemacs/search.texi man/xemacs/sending.texi man/xemacs/startup.texi man/xemacs/trouble.texi man/xemacs/xemacs.texi modules/base64/Makefile modules/ldap/Makefile modules/sample/Makefile modules/zlib/Makefile nt/ChangeLog nt/Makefile.cygwin nt/config.h nt/config.inc.samp nt/inc/arpa/inet.h nt/inc/netdb.h nt/inc/netinet/in.h nt/inc/pwd.h nt/inc/sys/dir.h nt/inc/sys/file.h nt/inc/sys/ioctl.h nt/inc/sys/param.h nt/inc/sys/socket.h nt/inc/sys/time.h nt/inc/unistd.h nt/runemacs.c nt/xemacs.mak nt/xemacs.rc src/ChangeLog src/Makefile.in.in src/alloca.c src/balloon_help.c src/buffer.c src/bytecode.c src/callproc.c src/casetab.c src/cm.c src/config.h.in src/console-msw.c src/console-msw.h src/console-stream.c src/console.h src/data.c src/device-msw.c src/device-x.c src/device.c src/device.h src/dgif_lib.c src/dialog-msw.c src/dired-msw.c src/dired.c src/doprnt.c src/dumper.c src/editfns.c src/elhash.c src/elhash.h src/emacs.c src/eval.c src/event-Xt.c src/event-msw.c src/event-stream.c src/events.c src/fileio.c src/fns.c src/frame-msw.c src/frame.c src/general.c src/getloadavg.c src/gif_io.c src/glyphs-msw.c src/glyphs-widget.c src/glyphs-x.c src/glyphs.c src/glyphs.h src/gpmevent.c src/gui-msw.c src/hash.c src/inline.c src/insdel.c src/lisp.h src/lread.c src/lrecord.h src/lstream.c src/m/arm.h src/m/delta.h src/m/intel386.h src/m/nh3000.h src/m/nh4000.h src/m/s390.h src/m/sequent.h src/m/template.h src/m/windowsnt.h src/mem-limits.h src/menubar-msw.c src/mule-canna.c src/mule-mcpath.c src/mule-mcpath.h src/mule-wnnfns.c src/ndir.h src/nt.c src/nt.h src/ntheap.h src/ntplay.c src/ntproc.c src/objects-x.c src/postgresql.c src/postgresql.h src/print.c src/process-nt.c src/process-unix.c src/process.c src/process.h src/realpath.c src/redisplay-msw.c src/redisplay-tty.c src/redisplay.c src/s/cygwin32.h src/s/decosf4-0.h src/s/freebsd.h src/s/mingw32.h src/s/msdos.h src/s/windows95.h src/s/windowsnt.h src/scrollbar-msw.c src/select-msw.c src/select-x.c src/select.c src/select.h src/sheap.c src/signal.c src/sound.c src/specifier.c src/strftime.c src/symsinit.h src/syscommctrl.h src/sysdep.c src/sysdep.h src/sysdir.h src/sysdll.c src/sysdll.h src/sysfile.h src/sysfloat.h src/sysproc.h src/syspwd.h src/syssignal.h src/systime.h src/systty.h src/syswindows.h src/unexalpha.c src/unexcw.c src/unexec.c src/unexnt.c src/vm-limit.c src/window.c tests/ChangeLog tests/automated/database-tests.el version.sh
diffstat 281 files changed, 9099 insertions(+), 6913 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES-beta	Mon Aug 13 11:18:12 2007 +0200
+++ b/CHANGES-beta	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,23 @@
+to 21.2.35 "Nike"
+-- You now again build XEmacs in a directory containing a predefined
+   CPP symbol -- Martin Buchholz
+-- Minor fixes for Postgres integration -- Martin Buchholz
+-- Many fixes for DEC OSF 4.0 -- Martin Buchholz
+-- More C++ compilation support (for quality control) -- Martin Buchholz
+-- XEmacs can now be built with XFree86 4.0 -- Martin Buchholz
+-- Fix lots of byte-compiler warnings -- Martin Buchholz
+-- Many documentation fixes -- Adrian Aichner
+-- support for S390 has been added -- Andreas Jaeger, Martin Schwidefsky
+-- clean up Windows includes/defines -- Ben Wing
+-- numerous configure/GCC-warning fixes -- Martin Buchholz
+-- generalize selection support to arbitrary types -- Alastair Houghton
+-- MS Windows printer improvements -- Kirill Katsnelson
+-- MinGW fixes -- Craig Lanning
+-- NT process fixes -- Mixe Alexander, Adrian Aichner
+-- new key-value weak hashtable type -- Andy Piper/Olivier Galibert
+-- migrate .emacs to .xemacs/init.el -- Mike Sperber
+-- new file compat.el for cleaner compatibility functions -- Ben Wing
+
 to 21.2.34 "Molpe"
 -- Lots of changes to GUI, Windows, font-lock code, Ben Wing
 -- Lots of changes to GUI, Windows code, Andy Piper
--- a/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,135 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-13  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: --with-menubars=yes should not be an error.
+
+	* configure.in: "compiling in support for Athena" message was
+	sometimes lying.
+
+2000-07-12  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: Rewrite xmkmf symbol detection to avoid
+	redefinition of symbols we've already defined.
+	Also, handle xmkmf symbols with values other than 1.
+
+2000-07-12  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: 
+	Make sure Unix98 socklen_t is defined.
+	Use ANSI C mode `-std1' with DEC C instead of `-std'.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: 
+	Replace SMART_INCLUDE with a dumber, but more reliable method.
+2000-07-10  Martin Buchholz  <martin@xemacs.org>
+
+	* modules/zlib/Makefile: 
+	* modules/sample/Makefile: 
+	* modules/ldap/Makefile: 
+	* modules/base64/Makefile: 
+	* Makefile.in.in: 
+	rm -f ==> $(RM)
+	define SHELL=/bin/sh
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: PostgreSQL rewrite.
+	- Don't look for postgreSQL in /usr/local.
+	- Simplify detection code.
+	- Don't use SMART_INCLUDE.
+	- Don't autodetect if --with-postgresql=no.
+
+2000-07-08  Ben Wing  <ben@xemacs.org>
+
+	* configure.usage: addl doc for graphics libs, with-msw.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* configure.in: sh builtin `test' uses `=', not `=='.
+
+2000-07-08  Ben Wing  <ben@xemacs.org>
+
+	* configure.in: add -lcomdlg32 for cygwin.
+	
+2000-07-05  Craig Lanning  <lanning@scra.org>
+
+	* aclocal.m4 (can_build_shared):
+	First pass at module support for cygwin and mingw.
+	
+	* configure:
+	* configure (xe_check_libs):
+	* configure (acfindx):
+	* configure (ac_x_includes):
+	* configure (ac_x_libraries):
+	* configure (ac_cv_lib_dnet_dnet_ntoa):
+	* configure (xe_msg_checking):
+	* configure (xe_runpath_dir):
+	* configure (xetest):
+	* configure (ac_err):
+	* configure (ac_safe):
+	* configure (with_xmu):
+	* configure (bitmapdir):
+	* configure (with_xauth):
+	* configure (libs_xauth):
+	* configure (with_cde):
+	* configure (with_ldap):
+	* configure (with_ldap_krbdes):
+	* configure (save_c_switch_site):
+	* configure (with_postgresql):
+	* configure (with_xface):
+	* configure (with_jpeg):
+	* configure (with_png):
+	* configure (with_tiff):
+	* configure (athena_lib):
+	* configure (have_motif):
+	* configure (all_widgets):
+	* configure (with_xim):
+	* configure (with_xfs):
+	* configure (with_wnn):
+	* configure (with_canna):
+	* configure (extra_objs):
+	* configure (ac_cv_c_inline):
+	* configure (have_esd_config):
+	* configure (c_switch_site):
+	* configure (with_ncurses):
+	* configure (with_gpm):
+	* configure (xealias):
+	* configure (xehost_os):
+	* configure (can_build_shared):
+	* configure (xcldf):
+	* configure (LTLD):
+	* configure (ld_dynamic_link_flags):
+	* configure (Mail):
+	* configure.in:
+	* configure.in (after_morecore_hook_exists):
+	* configure.in (xetest):
+	* configure.in (emacs_cv_localtime_cache):
+	* configure.in (Mail):
+        * configure.in:
+	Clean up configure support for cygwin and mingw.
+
+2000-06-27 Darryl Okahata <darrylo@soco.agilent.com>
+
+	* PROBLEMS: Document broken native audio for recent patches and
+	  releases of HP-UX.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* Makefile.in.in (install-arch-dep):
+	WINDOWSNT -> WIN32_NATIVE.
+	__CYGWIN32__ -> CYGWIN.
+
+2000-06-01  Andreas Jaeger  <aj@suse.de>
+
+	* configure.in: Recognize s390.
+
+	* config.guess: New version from GNU config archive.
+	* config.sub: Likewise.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/INSTALL	Mon Aug 13 11:18:12 2007 +0200
+++ b/INSTALL	Mon Aug 13 11:19:21 2007 +0200
@@ -292,7 +292,7 @@
 of the relocating allocator.  Turning on --rel-alloc will allow XEmacs
 to return unused memory to the operating system, thereby reducing its
 memory footprint.  However, it may make XEmacs runs more slowly,
-especially if your system's `mmap' implemntation is missing or
+especially if your system's `mmap' implementation is missing or
 inefficient.  Generally, it's best to go with the default
 configuration for your system.  You can tweak this based on how you
 use XEmacs, and the memory and cpu resources available on your system.
@@ -320,7 +320,7 @@
 contains the results of the compile and link tests used by configure.
 
 The `--with-mule' option enables (MUlti-Lingual Emacs) support, needed
-to suport non-Latin-1 (including Asian) languages.  The Mule support
+to support non-Latin-1 (including Asian) languages.  The Mule support
 is not yet as stable or efficient as the `Latin1' support.   Enabling
 Mule support requires the mule-base package installed prior to
 building XEmacs.  The following options require Mule support:
@@ -639,8 +639,8 @@
 	`/usr/local/lib/xemacs-VERSION/CONFIGURATION-NAME/modules'
 	(where VERSION and CONFIGURATION-NAME are as described above).
 	By their very nature, dynamic loadable modules are architecture-
-	dependant, and care should be taken not to set this directory
-	to a system- or architecture-independant directory.
+	dependent, and care should be taken not to set this directory
+	to a system- or architecture-independent directory.
 
 Remember that you must specify any variable values you need each time
 you run `make' in the top directory.  If you run `make' once to build
--- a/Makefile.in.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/Makefile.in.in	Mon Aug 13 11:19:21 2007 +0200
@@ -299,19 +299,19 @@
 
 FRC.lisp.auto.autoloads.el:
 lisp/auto-autoloads.el:	FRC.lisp.auto.autoloads.el
-	rm -f lisp/auto-autoloads.el
+	$(RM) lisp/auto-autoloads.el
 	${blddir}/src/${PROGNAME} -batch -vanilla \
 		-l autoload -f batch-update-directory lisp
 	${blddir}/src/${PROGNAME} -batch -vanilla \
 		-f batch-byte-compile lisp/auto-autoloads.el
-	@rm -f lisp/auto-autoloads.el~
+	@$(RM) lisp/auto-autoloads.el~
 #ifdef MULE
-	rm -f lisp/mule/auto-autoloads.el
+	$(RM) lisp/mule/auto-autoloads.el
 	${blddir}/src/${PROGNAME} -batch -vanilla \
 		-l autoload -f batch-update-directory lisp/mule
 	${blddir}/src/${PROGNAME} -batch -vanilla \
 		-f batch-byte-compile lisp/mule/auto-autoloads.el
-	@rm -f lisp/mule/auto-autoloads.el~
+	@$(RM) lisp/mule/auto-autoloads.el~
 #endif
 
 FRC.lisp.custom.load.el:
@@ -439,18 +439,18 @@
 #ifdef PDUMP
 	${INSTALL_DATA} src/${PROGNAME}.dmp ${bindir}/${PROGNAME}-${version}-`src/${PROGNAME} -sd`.dmp
 #endif
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	${INSTALL_PROGRAM} src/${PROGNAME} ${bindir}/${PROGNAME}
 	-chmod 0755 ${bindir}/${PROGNAME}
 #else
 	${INSTALL_PROGRAM} src/${PROGNAME} ${bindir}/${PROGNAME}-${version}
 	-chmod 0755 ${bindir}/${PROGNAME}-${version}
-# ifdef __CYGWIN32__
+# ifdef CYGWIN
 	cd ${bindir} && $(RM) ./${PROGNAME} && ${LN_S} ${PROGNAME}-${version}.exe ./${PROGNAME}
 # else
 	cd ${bindir} && $(RM) ./${PROGNAME} && ${LN_S} ${PROGNAME}-${version} ./${PROGNAME}
-# endif /* __CYGWIN32__ */
-#endif /* WINDOWSNT */
+# endif /* CYGWIN */
+#endif /* WIN32_NATIVE */
 	if test "${prefix}" != "${exec_prefix}"; then \
 	  $(MAKEPATH) ${exec_prefix}/lib/${instvardir}; \
 	  for dir in \
--- a/PROBLEMS	Mon Aug 13 11:18:12 2007 +0200
+++ b/PROBLEMS	Mon Aug 13 11:19:21 2007 +0200
@@ -1458,6 +1458,60 @@
     add mod2 = Mode_switch
     EOF
 
+
+*** XEmacs dumps core at startup when native audio is used.  Native
+audio does not work with recent versions of HP-UX.
+
+Under HP-UX 10.20 and later (e.g., HP-UX 11.XX), with native audio
+enabled, the dumped XEmacs binary ("xemacs") core dumps at startup if
+recent versions of the libAlib.sl audio shared library is used.  Note
+that "temacs" will run, but "xemacs" will dump core.  This, of course,
+causes the XEmacs build to fail.  If GNU malloc is enabled, a stack
+trace will show XEmacs to have crashed in the "first" call to malloc().
+
+This bug currently exists in all versions of XEmacs, when the undump
+mechanism is used.  It is not known if using the experimental portable
+dumper will allow native audio to work.
+
+**** Cause:
+
+Recent versions of the HP-UX 10.20 (and later) audio shared library (in
+/opt/audio/lib), pulls in the libdce shared library, which pulls in a
+thread (libcma) library.  This prevents the HP-UX undump() routine (in
+unexhp9k800.c) from properly working.  What's happening is that some
+initialization routines are being called in the libcma library, *BEFORE*
+main() is called, and these initialization routines are calling
+malloc().  Unfortunately, in order for the undumper to work, XEmacs must
+adjust (move upwards) the sbrk() value *BEFORE* the first call to
+malloc(); if malloc() is called before XEmacs has properly adjusted sbrk
+(which is what is happening), dumped memory that is being used by
+XEmacs, is improperly re-allocated for use by malloc() and the dumped
+memory is corrupted.  This causes XEmacs to die an horrible death.
+
+It is believed that versions of the audio library past December 1998
+will trigger this problem.  Under HP-UX 10.20, you probably have to
+install audio library patches to encounter this.  It's probable that
+recent "fresh, out-of-the-box" HP-UX 11.XX workstations also have this
+problem.  For HP-UX 10.20, it's believed that audio patch PHSS_17121 (or
+a superceeding one, like PHSS_17554, PHSS_17971, PHSS_18777, PHSS_21481,
+or PHSS_21662, etc.) will trigger this.
+
+To check if your audio library will cause problems for XEmacs, run
+"chatr /opt/audio/lib/libAlib.sl".  If "libdce" appears in the displayed
+shared library list, XEmacs will probably encounter problems if audio is
+enabled.
+
+**** Workaround:
+
+Don't enable native audio.  Re-run configure without native audio
+support.
+
+If your site supports it, try using NAS (Network Audio Support).
+
+Try using the experimental portable dumper.  It may work, or it may
+not.
+
+
 *** `Pid xxx killed due to text modification or page I/O error'
 
 On HP-UX, you can get that error when the Emacs executable is on an NFS
--- a/aclocal.m4	Mon Aug 13 11:18:12 2007 +0200
+++ b/aclocal.m4	Mon Aug 13 11:19:21 2007 +0200
@@ -101,6 +101,9 @@
     # like `-m68040'.
     dll_cflags='-m68020 -resident32 -malways-restore-a4'
     ;;
+  *cygwin* | *mingw* )
+    # PIC is the default
+    ;;
   *)
     dll_cflags='-fPIC'
     ;;
--- a/config.guess	Mon Aug 13 11:18:12 2007 +0200
+++ b/config.guess	Mon Aug 13 11:19:21 2007 +0200
@@ -1,8 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
 #   Free Software Foundation, Inc.
-#
+
+version='2000-05-30'
+
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -23,8 +25,7 @@
 # the same distribution terms that you use for the rest of that program.
 
 # Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-# Please send patches to <autoconf-patches@gnu.org>.
+# Please send patches to <config-patches@gnu.org>.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
@@ -37,6 +38,46 @@
 # (but try to keep the structure clean).
 #
 
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of this system.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
 # Use $HOST_CC if defined. $CC may point to a cross-compiler
 if test x"$CC_FOR_BUILD" = x; then
   if test x"$HOST_CC" != x; then
@@ -68,6 +109,43 @@
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-cbm ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format.
+	if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep __ELF__ >/dev/null
+	then
+	    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+	    # Return netbsd for either.  FIX?
+	    os=netbsd
+	else
+	    os=netbsdelf
+	fi
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
     alpha:OSF1:*:*)
 	if test $UNAME_RELEASE = "V4.0"; then
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -77,41 +155,51 @@
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
 	.globl main
+	.align 4
 	.ent main
 main:
-	.frame \$30,0,\$26,0
-	.prologue 0
-	.long 0x47e03d80 # implver $0
-	lda \$2,259
-	.long 0x47e20c21 # amask $2,$1
-	srl \$1,8,\$2
-	sll \$2,2,\$2
-	sll \$0,3,\$0
-	addl \$1,\$0,\$0
-	addl \$2,\$0,\$0
-	ret \$31,(\$26),1
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
 	.end main
 EOF
 	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 	if test "$?" = 0 ; then
-		./$dummy
-		case "$?" in
-			7)
+		case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 		esac
 	fi
 	rm -f $dummy.s $dummy
@@ -129,9 +217,6 @@
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-cbm-sysv4
 	exit 0;;
-    amiga:NetBSD:*:*)
-      echo m68k-cbm-netbsd${UNAME_RELEASE}
-      exit 0 ;;
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -162,9 +247,6 @@
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit 0;;
-    arm32:NetBSD:*:*)
-	echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     SR2?01:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
 	exit 0;;
@@ -221,15 +303,12 @@
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
 	exit 0 ;;
-    atari*:NetBSD:*:*)
-	echo m68k-atari-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     atari*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor 
+    # "atarist" or "atariste" at least should have a processor
     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
     # to the lowercase version "mint" (or "freemint").  Finally
     # the system name "TOS" denotes a system which is actually not
@@ -253,15 +332,9 @@
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
         echo m68k-unknown-mint${UNAME_RELEASE}
         exit 0 ;;
-    sun3*:NetBSD:*:*)
-	echo m68k-sun-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     sun3*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    mac68k:NetBSD:*:*)
-	echo m68k-apple-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -274,9 +347,6 @@
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
 	exit 0 ;;
-    macppc:NetBSD:*:*)
-        echo powerpc-apple-netbsd${UNAME_RELEASE}
-        exit 0 ;;
     RISC*:Mach:*:*)
 	echo mips-dec-mach_bsd4.3
 	exit 0 ;;
@@ -292,6 +362,7 @@
     mips:*:*:UMIPS | mips:*:*:RISCos)
 	sed 's/^	//' << EOF >$dummy.c
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -331,7 +402,7 @@
     AViiON:dgux:*:*)
         # DG/UX returns AViiON for all architectures
         UNAME_PROCESSOR=`/usr/bin/uname -p`
-	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110]
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
 	       [ ${TARGET_BINARY_INTERFACE}x = x ]
@@ -408,7 +479,7 @@
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
 	echo romp-ibm-bsd4.4
 	exit 0 ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
 	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
 	exit 0 ;;                           # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
@@ -429,6 +500,8 @@
 	    9000/[34]?? )         HP_ARCH=m68k ;;
 	    9000/[678][0-9][0-9])
               sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
               #include <stdlib.h>
               #include <unistd.h>
 
@@ -553,10 +626,13 @@
 	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
 	exit 0 ;;
     CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE}
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*T3E:*:*:*)
-	echo alpha-cray-unicosmk${UNAME_RELEASE}
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY-2:*:*:*)
 	echo cray2-cray-unicos
@@ -569,13 +645,10 @@
     F301:UNIX_System_V:*:*)
        echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
        exit 0 ;;
-    hp3[0-9][05]:NetBSD:*:*)
-	echo m68k-hp-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     sparc*:BSD/OS:*:*)
@@ -585,17 +658,8 @@
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
-	if test -x /usr/bin/objformat; then
-	    if test "elf" = "`/usr/bin/objformat`"; then
-		echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
-		exit 0
-	    fi
-	fi
 	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:NetBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
 	exit 0 ;;
@@ -644,6 +708,10 @@
 		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
 		exit 0
 		;;
+	  elf_i?86)
+		echo "${UNAME_MACHINE}-pc-linux"
+		exit 0
+		;;
 	  i?86coff)
 		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
 		exit 0
@@ -657,7 +725,7 @@
 		exit 0
 		;;
 	  elf32arm*)
-		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
 		exit 0
 		;;
 	  armelf_linux*)
@@ -668,7 +736,7 @@
 		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
 		exit 0
 		;;
-	  elf32ppc)
+	  elf32ppc | elf32ppclinux)
 		# Determine Lib Version
 		cat >$dummy.c <<EOF
 #include <features.h>
@@ -695,51 +763,65 @@
 			if test "$?" = 0 ; then
 				LIBC="libc1"
 			fi
-		fi	
+		fi
 		rm -f $dummy.c $dummy
 		echo powerpc-unknown-linux-gnu${LIBC}
 		exit 0
 		;;
+	  shelf_linux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
 	esac
 
 	if test "${UNAME_MACHINE}" = "alpha" ; then
-		sed 's/^	//'  <<EOF >$dummy.s
-		.globl main
-		.ent main
-	main:
-		.frame \$30,0,\$26,0
-		.prologue 0
-		.long 0x47e03d80 # implver $0
-		lda \$2,259
-		.long 0x47e20c21 # amask $2,$1
-		srl \$1,8,\$2
-		sll \$2,2,\$2
-		sll \$0,3,\$0
-		addl \$1,\$0,\$0
-		addl \$2,\$0,\$0
-		ret \$31,(\$26),1
-		.end main
+		cat <<EOF >$dummy.s
+			.data
+		\$Lformat:
+			.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+			.text
+			.globl main
+			.align 4
+			.ent main
+		main:
+			.frame \$30,16,\$26,0
+			ldgp \$29,0(\$27)
+			.prologue 1
+			.long 0x47e03d80 # implver \$0
+			lda \$2,-1
+			.long 0x47e20c21 # amask \$2,\$1
+			lda \$16,\$Lformat
+			mov \$0,\$17
+			not \$1,\$18
+			jsr \$26,printf
+			ldgp \$29,0(\$26)
+			mov 0,\$16
+			jsr \$26,exit
+			.end main
 EOF
 		LIBC=""
 		$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 		if test "$?" = 0 ; then
-			./$dummy
-			case "$?" in
-			7)
+			case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 			esac
 
 			objdump --private-headers $dummy | \
@@ -753,6 +835,7 @@
 	elif test "${UNAME_MACHINE}" = "mips" ; then
 	  cat >$dummy.c <<EOF
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -768,6 +851,8 @@
 EOF
 	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
 	  rm -f $dummy.c $dummy
+	elif test "${UNAME_MACHINE}" = "s390"; then
+	  echo s390-ibm-linux && exit 0
 	else
 	  # Either a pre-BFD a.out linker (linux-gnuoldld)
 	  # or one that does not give us useful --help.
@@ -789,6 +874,7 @@
 	  cat >$dummy.c <<EOF
 #include <features.h>
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -860,7 +946,11 @@
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
 	exit 0 ;;
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
     pc:*:*:*)
+	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
 	echo i386-pc-msdosdjgpp
@@ -974,8 +1064,26 @@
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
     *:QNX:*:4*)
-	echo i386-qnx-qnx${UNAME_VERSION}
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-W:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
 	exit 0 ;;
 esac
 
@@ -1116,6 +1224,47 @@
     esac
 fi
 
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
 
 exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/config.sub	Mon Aug 13 11:18:12 2007 +0200
+++ b/config.sub	Mon Aug 13 11:19:21 2007 +0200
@@ -1,6 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script, version 1.1.
-#   Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+
+version='2000-05-31'
+
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # can handle that machine.  It does not imply ALL GNU software can.
@@ -25,6 +29,9 @@
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+# Written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.
+#
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
@@ -45,30 +52,61 @@
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
-if [ x$1 = x ]
-then
-	echo Configuration name missing. 1>&2
-	echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
-	echo "or     $0 ALIAS" 1>&2
-	echo where ALIAS is a recognized configuration type. 1>&2
-	exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
 
-# First pass through any local machine types.
-case $1 in
-	*local*)
-		echo $1
-		exit 0
-		;;
-	*)
-	;;
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
 esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  linux-gnu*)
+  nto-qnx* | linux-gnu*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -169,15 +207,18 @@
 	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
 		| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
 		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
 		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
-		| alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
 		| we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
 		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
 		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
 		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
 		| mips64vr5000 | miprs64vr5000el | mcore \
 		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
-		| thumb | d10v | fr30)
+		| thumb | d10v | fr30 | avr)
 		basic_machine=$basic_machine-unknown
 		;;
 	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
@@ -201,8 +242,11 @@
 	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
 	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
 	      | xmp-* | ymp-* \
-	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
-	      | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
 	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
 	      | clipper-* | orion-* \
 	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
@@ -210,9 +254,10 @@
 	      | mips64el-* | mips64orion-* | mips64orionel-* \
 	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
 	      | mipstx39-* | mipstx39el-* | mcore-* \
-	      | f301-* | armv*-* | t3e-* \
+	      | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
 	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
-	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* )
+	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+	      | bs2000-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
@@ -464,9 +509,6 @@
 		basic_machine=i386-unknown
 		os=-mingw32
 		;;
-	i386-qnx | qnx)
-		basic_machine=i386-qnx
-		;;
 	iris | iris4d)
 		basic_machine=mips-sgi
 		case $os in
@@ -513,6 +555,10 @@
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
 	monitor)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -585,6 +631,9 @@
 	np1)
 		basic_machine=np1-gould
 		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
 	op50n-* | op60c-*)
 		basic_machine=hppa1.1-oki
 		os=-proelf
@@ -617,7 +666,7 @@
 	pentium | p5 | k5 | k6 | nexen)
 		basic_machine=i586-pc
 		;;
-	pentiumpro | p6 | 6x86)
+	pentiumpro | p6 | 6x86 | athlon)
 		basic_machine=i686-pc
 		;;
 	pentiumii | pentium2)
@@ -626,7 +675,7 @@
 	pentium-* | p5-* | k5-* | k6-* | nexen-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	pentiumpro-* | p6-* | 6x86-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-*)
@@ -729,6 +778,10 @@
 	sun386 | sun386i | roadrunner)
 		basic_machine=i386-sun
 		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
 	symmetry)
 		basic_machine=i386-sequent
 		os=-dynix
@@ -918,12 +971,25 @@
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -rhapsody* | -opened* | -openstep* | -oskit*)
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
 	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
-	      | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 		;;
 	-mac*)
 		os=`echo $os | sed -e 's|mac|macos|'`
@@ -940,6 +1006,9 @@
 	-opened*)
 		os=-openedition
 		;;
+	-wince*)
+		os=-wince
+		;;
 	-osfrose*)
 		os=-osfrose
 		;;
@@ -964,6 +1033,9 @@
 	-ns2 )
 	        os=-nextstep2
 		;;
+	-nsk)
+		os=-nsk
+		;;
 	# Preserve the version number of sinix5.
 	-sinix5.*)
 		os=`echo $os | sed -e 's|sinix|sysv|'`
@@ -977,9 +1049,6 @@
 	-oss*)
 		os=-sysv3
 		;;
-        -qnx)
-		os=-qnx4
-		;;
 	-svr4)
 		os=-sysv4
 		;;
@@ -1230,3 +1299,11 @@
 esac
 
 echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/configure	Mon Aug 13 11:18:12 2007 +0200
+++ b/configure	Mon Aug 13 11:19:21 2007 +0200
@@ -718,16 +718,17 @@
 
 		"with_menubars"   | \
 	"with_scrollbars" | \
-	"with_dialogs" | \
+	"with_dialogs"    | \
 	"with_widgets" )
 	  case "$val" in
 	    l | lu | luc | luci | lucid )		val=lucid  ;;
 	    m | mo | mot | moti | motif )		val=motif  ;;
 	    a | at | ath | athe | athen | athena )	val=athena ;;
-	    n | no | non | none )			val=no ;;
+	    n | no | non | none )			val=no     ;;
+	    y | ye | yes )				val=yes    ;;
 	    * ) (echo "$progname: Usage error:"
 echo " " "The \`--$optname' option must have one of these values:
-  \`lucid', \`motif', \`athena', or \`no'."
+  \`lucid', \`motif', \`athena', \`yes', or \`no'."
 echo "  Use \`$progname --help' to show usage.") >&2 && exit 1 ;;
 	  esac
 	  eval "$opt=\"$val\""
@@ -829,7 +830,7 @@
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:833: checking whether ln -s works" >&5
+echo "configure:834: checking whether ln -s works" >&5
 
 rm -f conftestdata
 if ln -s X conftestdata 2>/dev/null
@@ -1094,7 +1095,7 @@
 
 
 echo $ac_n "checking "host system type"""... $ac_c" 1>&6
-echo "configure:1098: checking "host system type"" >&5
+echo "configure:1099: checking "host system type"" >&5
 internal_configuration=`echo $configuration | sed 's/-\(workshop\)//'`
 canonical=`${CONFIG_SHELL-/bin/sh} $srcdir/config.sub "$internal_configuration"`
 configuration=`echo "$configuration" | sed 's/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/'`
@@ -1126,6 +1127,7 @@
   clipper-*        ) machine=clipper ;;
   arm*             ) machine=arm ;;
   ns32k-*          ) machine=ns32000 ;;
+  s390-*           ) machine=s390 ;;
 esac
 
 case "$canonical" in
@@ -1589,7 +1591,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:1593: checking for $ac_word" >&5
+echo "configure:1595: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1616,7 +1618,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:1620: checking for $ac_word" >&5
+echo "configure:1622: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1664,7 +1666,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1668: checking for $ac_word" >&5
+echo "configure:1670: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1693,7 +1695,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1697: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1699: 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'
@@ -1706,12 +1708,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 1710 "configure"
+#line 1712 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -1739,19 +1741,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:1743: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1745: 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:1748: checking whether we are using GNU C" >&5
+echo "configure:1750: 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:1755: \"$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:1757: \"$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
@@ -1769,7 +1771,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1773: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1775: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1802,7 +1804,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:1806: checking for $ac_word" >&5
+echo "configure:1808: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1829,7 +1831,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:1833: checking for $ac_word" >&5
+echo "configure:1835: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1877,7 +1879,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1881: checking for $ac_word" >&5
+echo "configure:1883: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -1906,7 +1908,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1910: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1912: 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'
@@ -1919,12 +1921,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 1923 "configure"
+#line 1925 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -1952,19 +1954,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:1956: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1958: 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:1961: checking whether we are using GNU C" >&5
+echo "configure:1963: 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:1968: \"$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:1970: \"$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
@@ -1982,7 +1984,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1986: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1988: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -2015,7 +2017,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:2019: checking for $ac_word" >&5
+echo "configure:2021: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2042,7 +2044,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:2046: checking for $ac_word" >&5
+echo "configure:2048: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2090,7 +2092,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2094: checking for $ac_word" >&5
+echo "configure:2096: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2119,7 +2121,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2123: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2125: 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'
@@ -2132,12 +2134,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 2136 "configure"
+#line 2138 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -2165,19 +2167,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:2169: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2171: 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:2174: checking whether we are using GNU C" >&5
+echo "configure:2176: 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:2181: \"$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:2183: \"$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
@@ -2195,7 +2197,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:2199: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2201: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -2232,7 +2234,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:2236: checking how to run the C preprocessor" >&5
+echo "configure:2238: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2245,13 +2247,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2249 "configure"
+#line 2251 "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:2255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2257: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2262,13 +2264,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2266 "configure"
+#line 2268 "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:2272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2279,13 +2281,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2283 "configure"
+#line 2285 "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:2289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2291: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2311,9 +2313,9 @@
 
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:2315: checking for AIX" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2317 "configure"
+echo "configure:2317: checking for AIX" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2319 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -2338,111 +2340,12 @@
 rm -f conftest*
 
  
-cat > $srcdir/conffoo.h <<EOF
-#define CONFFOO 1
-EOF
-echo $ac_n "checking for a working inclusion macro""... $ac_c" 1>&6
-echo "configure:2346: checking for a working inclusion macro" >&5
+
+echo $ac_n "checking for GNU libc""... $ac_c" 1>&6
+echo "configure:2346: checking for GNU libc" >&5
 cat > conftest.$ac_ext <<EOF
 #line 2348 "configure"
 #include "confdefs.h"
-
-int main() {
-
-#define SMART_INCLUDE(path,file) <path/file>
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE (CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-
-; return 0; }
-EOF
-if { (eval echo configure:2360: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-   echo "$ac_t""direct" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining SMART_INCLUDE_INDIRECTIONS = 0
-EOF
-cat >> confdefs.h <<\EOF
-#define SMART_INCLUDE_INDIRECTIONS 0
-EOF
-}
- 
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 2375 "configure"
-#include "confdefs.h"
-
-int main() {
-
-#define GLUE_INCLUDE(path,file)  <##path##/##file##>
-#define SMART_INCLUDE(path,file) GLUE_INCLUDE(path,file)
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE(CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-
-; return 0; }
-EOF
-if { (eval echo configure:2388: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-   echo "$ac_t""simple" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining SMART_INCLUDE_INDIRECTIONS = 1
-EOF
-cat >> confdefs.h <<\EOF
-#define SMART_INCLUDE_INDIRECTIONS 1
-EOF
-}
- 
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 2403 "configure"
-#include "confdefs.h"
-
-int main() {
-
-#define GLUE_INCLUDE_2(path,file)  <##path##/##file##>
-#define GLUE_INCLUDE_1(path,file) GLUE_INCLUDE_2(path,file)
-#define SMART_INCLUDE(path,file) GLUE_INCLUDE_1(path,file)
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE (CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-
-; return 0; }
-EOF
-if { (eval echo configure:2417: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-   echo "$ac_t""double" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining SMART_INCLUDE_INDIRECTIONS = 2
-EOF
-cat >> confdefs.h <<\EOF
-#define SMART_INCLUDE_INDIRECTIONS 2
-EOF
-}
- 
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  { echo "configure: error: Cannot define a proper SMART_INCLUDE macro. Please report." 1>&2; exit 1; }
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-rm -f $srcdir/conffoo.h
-
-
-
-echo $ac_n "checking for GNU libc""... $ac_c" 1>&6
-echo "configure:2443: checking for GNU libc" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2445 "configure"
-#include "confdefs.h"
 #include <features.h>
 int main() {
 
@@ -2453,7 +2356,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2457: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2360: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_glibc=yes
 else
@@ -2530,7 +2433,7 @@
 esac
 
 cat > conftest.$ac_ext <<EOF
-#line 2534 "configure"
+#line 2437 "configure"
 #include "confdefs.h"
 int main () {
 #if defined __SUNPRO_C
@@ -2542,7 +2445,7 @@
 #endif
 }
 EOF
-if { (eval echo configure:2546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:2449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -2744,7 +2647,7 @@
   start_files=
   libs_standard=
   unexec=
-  lib_gcc=	
+  lib_gcc=
 fi
 
 test "$extra_verbose" = "yes" && \
@@ -2758,7 +2661,7 @@
 
 test "$ordinary_link" = "no" -a -z "$libs_standard" && libs_standard="-lc"
 
-test "$__DECC" = "yes" && c_switch_site="$c_switch_site -std" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-std\" to \$c_switch_site"; fi
+test "$__DECC" = "yes" && c_switch_site="$c_switch_site -std1" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-std1\" to \$c_switch_site"; fi
 
 if test "$cflags_specified" = "no"; then
       if   test "$GCC" = "yes"; then
@@ -2778,7 +2681,7 @@
 
 if test "$GCC" = "yes"; then
 echo $ac_n "checking for buggy gcc versions""... $ac_c" 1>&6
-echo "configure:2782: checking for buggy gcc versions" >&5
+echo "configure:2685: checking for buggy gcc versions" >&5
 GCC_VERSION=`$CC --version`
 case `uname -s`:`uname -m`:$GCC_VERSION in
 		    *:sun4*:2.8.1|*:sun4*:egcs-2.90.*)
@@ -2901,7 +2804,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2905: checking for dynodump" >&5
+echo "configure:2808: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2939,12 +2842,12 @@
   done
   
 echo $ac_n "checking for terminateAndUnload in -lC""... $ac_c" 1>&6
-echo "configure:2943: checking for terminateAndUnload in -lC" >&5
+echo "configure:2846: checking for terminateAndUnload in -lC" >&5
 ac_lib_var=`echo C'_'terminateAndUnload | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lC "
 cat > conftest.$ac_ext <<EOF
-#line 2948 "configure"
+#line 2851 "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
@@ -2955,7 +2858,7 @@
 terminateAndUnload()
 ; return 0; }
 EOF
-if { (eval echo configure:2959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3063,7 +2966,7 @@
 
 if test "$add_runtime_path" = "yes"; then
       echo $ac_n "checking "for runtime libraries flag"""... $ac_c" 1>&6
-echo "configure:3067: checking "for runtime libraries flag"" >&5
+echo "configure:2970: checking "for runtime libraries flag"" >&5
   case "$opsys" in
     sol2 ) dash_r="-R" ;;
     decosf* | linux* | irix*) dash_r="-rpath " ;;
@@ -3085,14 +2988,14 @@
   done
 fi
         cat > conftest.$ac_ext <<EOF
-#line 3089 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:3096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 2992 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -3194,10 +3097,10 @@
 fi
 after_morecore_hook_exists=yes
 echo $ac_n "checking for malloc_set_state""... $ac_c" 1>&6
-echo "configure:3198: checking for malloc_set_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3201 "configure"
+echo "configure:3101: checking for malloc_set_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3104 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_set_state(); below.  */
@@ -3220,7 +3123,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_malloc_set_state=yes"
 else
@@ -3240,16 +3143,16 @@
 fi
 
 echo $ac_n "checking whether __after_morecore_hook exists""... $ac_c" 1>&6
-echo "configure:3244: checking whether __after_morecore_hook exists" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3246 "configure"
+echo "configure:3147: checking whether __after_morecore_hook exists" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3149 "configure"
 #include "confdefs.h"
 extern void (* __after_morecore_hook)();
 int main() {
 __after_morecore_hook = 0
 ; return 0; }
 EOF
-if { (eval echo configure:3253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3305,7 +3208,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:3309: checking for $ac_word" >&5
+echo "configure:3212: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -3360,7 +3263,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:3364: checking for a BSD compatible install" >&5
+echo "configure:3267: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
   IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
@@ -3414,7 +3317,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:3418: checking for $ac_word" >&5
+echo "configure:3321: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -3446,15 +3349,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3450: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3453 "configure"
+echo "configure:3353: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3356 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3458: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3361: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3484,10 +3387,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:3488: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3491 "configure"
+echo "configure:3391: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3394 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -3503,7 +3406,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:3507: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -3527,10 +3430,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3531: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3534 "configure"
+echo "configure:3434: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3437 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3538,7 +3441,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3542: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3555,7 +3458,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 3559 "configure"
+#line 3462 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3573,7 +3476,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 3577 "configure"
+#line 3480 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3591,7 +3494,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 3595 "configure"
+#line 3498 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3602,7 +3505,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:3509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -3628,10 +3531,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3632: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3635 "configure"
+echo "configure:3535: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3538 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -3640,7 +3543,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:3644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3547: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -3664,10 +3567,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:3668: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3671 "configure"
+echo "configure:3571: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3574 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3679,7 +3582,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:3683: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -3704,9 +3607,9 @@
 
 
 echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6
-echo "configure:3708: checking for struct utimbuf" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3710 "configure"
+echo "configure:3611: checking for struct utimbuf" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3613 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3725,7 +3628,7 @@
 static struct utimbuf x; x.actime = x.modtime;
 ; return 0; }
 EOF
-if { (eval echo configure:3729: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3632: \"$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
@@ -3745,10 +3648,10 @@
 rm -f conftest*
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3749: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3752 "configure"
+echo "configure:3652: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3655 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3765,7 +3668,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3769: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3672: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3787,10 +3690,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3791: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3794 "configure"
+echo "configure:3694: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3697 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3821,10 +3724,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3825: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3828 "configure"
+echo "configure:3728: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3731 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3855,10 +3758,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3859: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3862 "configure"
+echo "configure:3762: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3765 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3894,10 +3797,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3898: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3901 "configure"
+echo "configure:3801: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3804 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3928,10 +3831,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3932: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3935 "configure"
+echo "configure:3835: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3838 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3962,10 +3865,10 @@
 fi
 
 echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
-echo "configure:3966: checking for ssize_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3969 "configure"
+echo "configure:3869: checking for ssize_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3872 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3996,10 +3899,71 @@
 fi
 
 
+echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
+echo "configure:3904: checking for socklen_t" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3906 "configure"
+#include "confdefs.h"
+#include <sys/socket.h>
+socklen_t x;
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:3915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  echo "$ac_t""yes" 1>&6
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+cat > conftest.$ac_ext <<EOF
+#line 3924 "configure"
+#include "confdefs.h"
+#include <sys/socket.h>
+int accept (int, struct sockaddr *, size_t *);
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:3933: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+echo "$ac_t""size_t" 1>&6
+{ test "$extra_verbose" = "yes" && cat << \EOF
+    Defining socklen_t = size_t
+EOF
+cat >> confdefs.h <<\EOF
+#define socklen_t size_t
+EOF
+}
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+echo "$ac_t""int" 1>&6
+{ test "$extra_verbose" = "yes" && cat << \EOF
+    Defining socklen_t = int
+EOF
+cat >> confdefs.h <<\EOF
+#define socklen_t int
+EOF
+}
+
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:4001: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 4003 "configure"
+echo "configure:3965: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3967 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -4015,7 +3979,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:4019: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3983: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -4037,10 +4001,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:4041: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4044 "configure"
+echo "configure:4005: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4008 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -4048,7 +4012,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:4052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -4072,10 +4036,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:4076: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4079 "configure"
+echo "configure:4040: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4043 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -4083,7 +4047,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:4087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -4106,10 +4070,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:4110: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4113 "configure"
+echo "configure:4074: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4077 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -4119,7 +4083,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:4123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -4145,10 +4109,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:4149: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4152 "configure"
+echo "configure:4113: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4116 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4197,7 +4161,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4201: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -4222,7 +4186,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:4226: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:4190: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -4247,12 +4211,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:4251: checking whether byte ordering is bigendian" >&5
+echo "configure:4215: 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 4256 "configure"
+#line 4220 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4263,11 +4227,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4267: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4231: \"$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 4271 "configure"
+#line 4235 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4278,7 +4242,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -4295,7 +4259,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 4299 "configure"
+#line 4263 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -4308,7 +4272,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:4312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -4335,10 +4299,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:4339: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4342 "configure"
+echo "configure:4303: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4306 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4349,7 +4313,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -4377,10 +4341,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:4381: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4384 "configure"
+echo "configure:4345: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4348 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4391,7 +4355,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -4413,10 +4377,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:4417: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4420 "configure"
+echo "configure:4381: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4384 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4427,7 +4391,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -4449,10 +4413,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:4453: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4456 "configure"
+echo "configure:4417: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4420 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4463,7 +4427,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4431: \"$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
@@ -4485,10 +4449,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:4489: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4492 "configure"
+echo "configure:4453: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4456 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4499,7 +4463,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4467: \"$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
@@ -4522,7 +4486,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:4526: checking for long file names" >&5
+echo "configure:4490: 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:
@@ -4568,10 +4532,10 @@
 
 
 echo $ac_n "checking for sin""... $ac_c" 1>&6
-echo "configure:4572: checking for sin" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4575 "configure"
+echo "configure:4536: checking for sin" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4539 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char sin(); below.  */
@@ -4594,7 +4558,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_sin=yes"
 else
@@ -4612,12 +4576,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:4616: checking for sin in -lm" >&5
+echo "configure:4580: 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 4621 "configure"
+#line 4585 "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
@@ -4628,7 +4592,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:4632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4672,14 +4636,14 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 4676 "configure"
+#line 4640 "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:4683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_INVERSE_HYPERBOLIC
@@ -4696,14 +4660,14 @@
 rm -f conftest*
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:4700: checking type of mail spool file locking" >&5
+echo "configure:4664: checking type of mail spool file locking" >&5
 for ac_func in lockf flock
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4704: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4707 "configure"
+echo "configure:4668: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4671 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4726,7 +4690,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4756,6 +4720,12 @@
 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
 test -z "$mail_locking" -a "$mail_use_locking" = "yes" && mail_locking=locking
+if   test -z "$mail_locking"; then
+  case "$opsys" in cygwin* | mingw*)
+    mail_locking=pop ;;
+  esac
+fi
+
 if   test "$mail_locking" = "lockf"; then { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MAIL_LOCK_LOCKF
 EOF
@@ -4780,6 +4750,9 @@
 EOF
 }
 
+elif test "$mail_locking" = "pop"; then
+  with_pop=yes
+  mail_locking=
 else mail_locking="dot-locking"; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MAIL_LOCK_DOT
 EOF
@@ -4799,12 +4772,12 @@
 case "$opsys" in decosf*)
   
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:4803: checking for cma_open in -lpthreads" >&5
+echo "configure:4776: 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 4808 "configure"
+#line 4781 "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
@@ -4815,7 +4788,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4851,7 +4824,7 @@
 esac
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:4855: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:4828: 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;
@@ -4863,7 +4836,7 @@
 if test "$opsys" = "sol2"; then
   if test "$os_release" -ge 56; then
     echo $ac_n "checking for \"-z ignore\" linker flag""... $ac_c" 1>&6
-echo "configure:4867: checking for \"-z ignore\" linker flag" >&5
+echo "configure:4840: 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 ;;
@@ -4874,7 +4847,7 @@
 
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:4878: checking "for specified window system"" >&5
+echo "configure:4851: checking "for specified window system"" >&5
 
 if test "$with_x11" != "no"; then
     test "$x_includes $x_libraries" != "NONE NONE" && \
@@ -4907,7 +4880,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:4911: checking for X" >&5
+echo "configure:4884: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -4967,12 +4940,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 4971 "configure"
+#line 4944 "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:4976: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5041,14 +5014,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5045 "configure"
+#line 5018 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:5052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -5157,17 +5130,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:5161: checking whether -R must be followed by a space" >&5
+echo "configure:5134: 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 5164 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:5171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 5137 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:5144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -5183,14 +5156,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 5187 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:5194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 5160 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:5167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -5226,12 +5199,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:5230: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:5203: 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 5235 "configure"
+#line 5208 "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
@@ -5242,7 +5215,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:5246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5266,12 +5239,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:5270: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:5243: 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 5275 "configure"
+#line 5248 "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
@@ -5282,7 +5255,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:5286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5311,10 +5284,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:5315: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5318 "configure"
+echo "configure:5288: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5291 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -5337,7 +5310,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -5358,12 +5331,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:5362: checking for gethostbyname in -lnsl" >&5
+echo "configure:5335: 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 5367 "configure"
+#line 5340 "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
@@ -5374,7 +5347,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:5378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5351: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5404,10 +5377,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:5408: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5411 "configure"
+echo "configure:5381: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5384 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -5430,7 +5403,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -5453,12 +5426,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:5457: checking "$xe_msg_checking"" >&5
+echo "configure:5430: 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 5462 "configure"
+#line 5435 "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
@@ -5469,7 +5442,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:5473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5493,10 +5466,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:5497: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5500 "configure"
+echo "configure:5470: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5473 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -5519,7 +5492,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -5540,12 +5513,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:5544: checking for remove in -lposix" >&5
+echo "configure:5517: 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 5549 "configure"
+#line 5522 "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
@@ -5556,7 +5529,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:5560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5580,10 +5553,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:5584: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5587 "configure"
+echo "configure:5557: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5560 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -5606,7 +5579,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -5627,12 +5600,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:5631: checking for shmat in -lipc" >&5
+echo "configure:5604: 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 5636 "configure"
+#line 5609 "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
@@ -5643,7 +5616,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:5647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5679,12 +5652,12 @@
 xe_msg_checking="for IceConnectionNumber in -lICE"
 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:5683: checking "$xe_msg_checking"" >&5
+echo "configure:5656: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lICE $X_EXTRA_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5688 "configure"
+#line 5661 "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
@@ -5695,7 +5668,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:5699: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5864,7 +5837,7 @@
 
 
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:5868: checking for X defines extracted by xmkmf" >&5
+echo "configure:5841: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -5879,32 +5852,47 @@
     cd ..
     rm -fr conftestdir
     for word in $xmkmf_defines; do
-      case "$word" in
-	-D*=* ) ;;
-	-D* ) word=`echo '' $word | sed -e 's:^ *-D::'`
-	      { test "$extra_verbose" = "yes" && cat << EOF
-    Defining $word
-EOF
-cat >> confdefs.h <<EOF
-#define $word 1
-EOF
-}
- ;;
+      case "$word" in -D* )
+	sym=`echo '' $word | sed -e 's:^ *-D::' -e 's:=.*::'`
+	case "$word" in
+	  -D*=* ) val=`echo '' $word | sed -e 's:^.*=::'` ;;
+	  *     ) val=1 ;;
+	esac
+	if grep "^#define $sym " confdefs.h >/dev/null; then :; else
+	  if test "$val" = "1"
+	    then { test "$extra_verbose" = "yes" && cat << EOF
+    Defining $sym
+EOF
+cat >> confdefs.h <<EOF
+#define $sym 1
+EOF
+}
+
+	    else { test "$extra_verbose" = "yes" && cat << EOF
+    Defining $sym = $val
+EOF
+cat >> confdefs.h <<EOF
+#define $sym $val
+EOF
+}
+
+	  fi
+	fi  ;;
       esac
     done
   fi
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:5900: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5903 "configure"
+echo "configure:5888: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5891 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5896: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5928,12 +5916,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:5932: checking for XOpenDisplay in -lX11" >&5
+echo "configure:5920: 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 5937 "configure"
+#line 5925 "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
@@ -5944,7 +5932,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5969,12 +5957,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:5973: checking "$xe_msg_checking"" >&5
+echo "configure:5961: 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 5978 "configure"
+#line 5966 "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
@@ -5985,7 +5973,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:5989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6012,12 +6000,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:6016: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:6004: 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 6021 "configure"
+#line 6009 "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
@@ -6028,7 +6016,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:6032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6051,12 +6039,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:6055: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:6043: 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 6060 "configure"
+#line 6048 "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
@@ -6067,7 +6055,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:6071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6090,14 +6078,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:6094: checking the version of X11 being used" >&5
+echo "configure:6082: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 6096 "configure"
+#line 6084 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:6101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:6089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -6121,10 +6109,10 @@
   for ac_func in XConvertCase
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6125: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6128 "configure"
+echo "configure:6113: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6116 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6147,7 +6135,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6139: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6179,15 +6167,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6183: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6186 "configure"
+echo "configure:6171: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6174 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6179: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6218,7 +6206,7 @@
 
 
     echo $ac_n "checking for XFree86""... $ac_c" 1>&6
-echo "configure:6222: checking for XFree86" >&5
+echo "configure:6210: checking for XFree86" >&5
   if test -d "/usr/X386/include" -o \
           -f "/etc/XF86Config"    -o \
 	  -f "/etc/X11/XF86Config" -o \
@@ -6238,12 +6226,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:6242: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:6230: 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 6247 "configure"
+#line 6235 "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
@@ -6254,7 +6242,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:6258: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6293,19 +6281,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:6297: checking for main in -lXbsd" >&5
+echo "configure:6285: 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 6302 "configure"
+#line 6290 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:6309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6342,22 +6330,22 @@
 fi 
 if test "$with_msw" != "no"; then
   echo "checking for MS-Windows" 1>&6
-echo "configure:6346: checking for MS-Windows" >&5
+echo "configure:6334: checking for MS-Windows" >&5
   
 echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
-echo "configure:6349: checking for main in -lgdi32" >&5
+echo "configure:6337: 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 6354 "configure"
+#line 6342 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:6361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6387,7 +6375,7 @@
 }
 
     install_pp="$blddir/lib-src/installexe.sh"
-    libs_system="$libs_system -lshell32 -lgdi32 -luser32 -lcomctl32 -lwinspool" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lshell32 -lgdi32 -luser32 -lcomctl32 -lwinspool\" to \$libs_system"; fi
+    libs_system="$libs_system -lshell32 -lgdi32 -luser32 -lcomdlg32 -lcomctl32 -lwinspool" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lshell32 -lgdi32 -luser32 -lcomdlg32 -lcomctl32 -lwinspool\" to \$libs_system"; fi
     test "$with_dragndrop" != no && dragndrop_proto="$dragndrop_proto msw" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"msw\" to \$dragndrop_proto"; fi
     if test "$window_system" != x11; then
  	window_system=msw
@@ -6423,12 +6411,12 @@
  fi
     fi
         cat > conftest.$ac_ext <<EOF
-#line 6427 "configure"
+#line 6415 "configure"
 #include "confdefs.h"
 #include <fcntl.h>
     int main() { return (open("/dev/windows", O_RDONLY, 0) > 0)? 0 : 1; }
 EOF
-if { (eval echo configure:6432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:6420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_MSG_SELECT
@@ -6503,7 +6491,7 @@
 esac
 
 echo "checking for WM_COMMAND option" 1>&6
-echo "configure:6507: checking for WM_COMMAND option" >&5;
+echo "configure:6495: checking for WM_COMMAND option" >&5;
 if test "$with_wmcommand" != "no"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_WMCOMMAND
@@ -6518,15 +6506,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:6522: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6525 "configure"
+echo "configure:6510: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6513 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6530: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6549,12 +6537,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:6553: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:6541: 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 6558 "configure"
+#line 6546 "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
@@ -6565,7 +6553,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:6569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6610,15 +6598,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:6614: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6617 "configure"
+echo "configure:6602: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6605 "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:6622: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6654,12 +6642,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:6658: checking "$xe_msg_checking"" >&5
+echo "configure:6646: 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 6663 "configure"
+#line 6651 "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
@@ -6670,7 +6658,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:6674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6727,15 +6715,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:6731: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6734 "configure"
+echo "configure:6719: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6722 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6727: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6758,12 +6746,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:6762: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:6750: 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 6767 "configure"
+#line 6755 "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
@@ -6774,7 +6762,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:6778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6843,7 +6831,7 @@
 fi
 
 echo $ac_n "checking if drag and drop API is needed""... $ac_c" 1>&6
-echo "configure:6847: checking if drag and drop API is needed" >&5
+echo "configure:6835: checking if drag and drop API is needed" >&5
 if test "$with_dragndrop" != "no" ; then
   if test -n "$dragndrop_proto" ; then
     with_dragndrop=yes
@@ -6864,18 +6852,18 @@
 fi
 
 echo "checking for LDAP" 1>&6
-echo "configure:6868: checking for LDAP" >&5
+echo "configure:6856: checking for LDAP" >&5
 test -z "$with_ldap" && { ac_safe=`echo "ldap.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ldap.h""... $ac_c" 1>&6
-echo "configure:6871: checking for ldap.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6874 "configure"
+echo "configure:6859: checking for ldap.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6862 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6879: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6898,15 +6886,15 @@
  }
 test -z "$with_ldap" && { ac_safe=`echo "lber.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for lber.h""... $ac_c" 1>&6
-echo "configure:6902: checking for lber.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6905 "configure"
+echo "configure:6890: checking for lber.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6893 "configure"
 #include "confdefs.h"
 #include <lber.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6930,12 +6918,12 @@
 if test "$with_ldap" != "no"; then
   
 echo $ac_n "checking for ldap_search in -lldap""... $ac_c" 1>&6
-echo "configure:6934: checking for ldap_search in -lldap" >&5
+echo "configure:6922: checking for ldap_search in -lldap" >&5
 ac_lib_var=`echo ldap'_'ldap_search | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap "
 cat > conftest.$ac_ext <<EOF
-#line 6939 "configure"
+#line 6927 "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
@@ -6946,7 +6934,7 @@
 ldap_search()
 ; return 0; }
 EOF
-if { (eval echo configure:6950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6971,12 +6959,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber" && xe_msg_checking="$xe_msg_checking using extra libs -llber"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6975: checking "$xe_msg_checking"" >&5
+echo "configure:6963: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber"
 cat > conftest.$ac_ext <<EOF
-#line 6980 "configure"
+#line 6968 "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
@@ -6987,7 +6975,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:6991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7012,12 +7000,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber -lkrb" && xe_msg_checking="$xe_msg_checking using extra libs -llber -lkrb"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:7016: checking "$xe_msg_checking"" >&5
+echo "configure:7004: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber -lkrb"
 cat > conftest.$ac_ext <<EOF
-#line 7021 "configure"
+#line 7009 "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
@@ -7028,7 +7016,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:7032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7053,12 +7041,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber -lkrb -ldes" && xe_msg_checking="$xe_msg_checking using extra libs -llber -lkrb -ldes"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:7057: checking "$xe_msg_checking"" >&5
+echo "configure:7045: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber -lkrb -ldes"
 cat > conftest.$ac_ext <<EOF
-#line 7062 "configure"
+#line 7050 "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
@@ -7069,7 +7057,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:7073: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7120,10 +7108,10 @@
   for ac_func in ldap_set_option ldap_get_lderrno ldap_result2error ldap_parse_result
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7124: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7127 "configure"
+echo "configure:7112: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7115 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7146,7 +7134,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7175,135 +7163,22 @@
 
 fi
 
-echo "checking for PostgreSQL" 1>&6
-echo "configure:7180: checking for PostgreSQL" >&5
-postgres_h_path=""
-postgres_includes_found=no
-save_c_switch_site="$c_switch_site"
-
 if test "$with_postgresql" != "no"; then
-	ac_safe=`echo "libpq-fe.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:7188: checking for libpq-fe.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7191 "configure"
-#include "confdefs.h"
-#include <libpq-fe.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7196: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  postgres_includes_found=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-fi
-
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/local/pgsql/include"; then
-	c_switch_site="$c_switch_site -I/usr/local/pgsql/include"
-	ac_safe=`echo "libpq-fe.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:7223: checking for libpq-fe.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7226 "configure"
-#include "confdefs.h"
-#include <libpq-fe.h>
+  echo "checking for PostgreSQL" 1>&6
+echo "configure:7169: checking for PostgreSQL" >&5
+
+  for header_dir in "" "pgsql/" "postgresql/"; do
+    ac_safe=`echo "${header_dir}libpq-fe.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for ${header_dir}libpq-fe.h""... $ac_c" 1>&6
+echo "configure:7174: checking for ${header_dir}libpq-fe.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7177 "configure"
+#include "confdefs.h"
+#include <${header_dir}libpq-fe.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  postgres_includes_found=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-	if test "$postgres_includes_found" != "yes"; then
-		postgres_h_path="/usr/local/pgsql/include"
-	fi
-	c_switch_site="$save_c_switch_site"
-fi
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/include/pgsql"; then
-	c_switch_site="$c_switch_site -I/usr/include/pgsql"
-	ac_safe=`echo "libpq-fe.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:7261: checking for libpq-fe.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7264 "configure"
-#include "confdefs.h"
-#include <libpq-fe.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7269: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  postgres_includes_found=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-	if test "$postgres_includes_found" = "yes"; then
-		postgres_h_path="pgsql"
-	fi
-		c_switch_site="$save_c_switch_site"
-	fi
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/include/postgresql"; then
-	c_switch_site="$c_switch_site -I/usr/include/postgresql"
-	ac_safe=`echo "libpq-fe.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:7299: checking for libpq-fe.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7302 "configure"
-#include "confdefs.h"
-#include <libpq-fe.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7307: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7318,26 +7193,21 @@
 rm -f conftest*
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  postgres_includes_found=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-	if test "$postgres_includes_found" = "yes"; then
-		postgres_h_path="postgresql"
-fi
-	c_switch_site="$save_c_switch_site"
-fi
-
-if test "$postgres_includes_found" = "yes"; then
-	
+  libpq_fe_h_file=${header_dir}libpq-fe.h; break
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  done
+
+  test -n "$libpq_fe_h_file" && { 
 echo $ac_n "checking for PQconnectdb in -lpq""... $ac_c" 1>&6
-echo "configure:7336: checking for PQconnectdb in -lpq" >&5
+echo "configure:7206: checking for PQconnectdb in -lpq" >&5
 ac_lib_var=`echo pq'_'PQconnectdb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpq "
 cat > conftest.$ac_ext <<EOF
-#line 7341 "configure"
+#line 7211 "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
@@ -7348,37 +7218,45 @@
 PQconnectdb()
 ; return 0; }
 EOF
-if { (eval echo configure:7352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-xe_check_libs=""
-
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
-  echo "$ac_t""yes" 1>&6
-  with_postgresql=yes
-else
-  echo "$ac_t""no" 1>&6
-with_postgresql=no
-fi
-
-
-fi
-if test "$with_postgresql" = "yes"; then
-	
+if { (eval echo configure:7222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  have_libpq=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+ }
+
+  if test -n "$libpq_fe_h_file" -a "$have_libpq" = "yes"; then
+    with_postgresql=yes
+    { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_POSTGRESQL
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_POSTGRESQL 1
+EOF
+}
+
+    
 echo $ac_n "checking for PQconnectStart in -lpq""... $ac_c" 1>&6
-echo "configure:7377: checking for PQconnectStart in -lpq" >&5
+echo "configure:7255: checking for PQconnectStart in -lpq" >&5
 ac_lib_var=`echo pq'_'PQconnectStart | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpq "
 cat > conftest.$ac_ext <<EOF
-#line 7382 "configure"
+#line 7260 "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
@@ -7389,49 +7267,22 @@
 PQconnectStart()
 ; return 0; }
 EOF
-if { (eval echo configure:7393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-xe_check_libs=""
-
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
-  echo "$ac_t""yes" 1>&6
-  with_postgresqlv7=yes
-else
-  echo "$ac_t""no" 1>&6
-with_postgresqlv7=no
-fi
-
-
-fi
-if test "$with_postgresql" = "yes"; then
-	if test -n "$postgres_h_path"; then
-		{ test "$extra_verbose" = "yes" && cat << EOF
-    Defining POSTGRES_H_PATH = $postgres_h_path
-EOF
-cat >> confdefs.h <<EOF
-#define POSTGRES_H_PATH $postgres_h_path
-EOF
-}
-
-	fi
-	{ test "$extra_verbose" = "yes" && cat << \EOF
-    Defining HAVE_POSTGRESQL
-EOF
-cat >> confdefs.h <<\EOF
-#define HAVE_POSTGRESQL 1
-EOF
-}
-
-	if test "$with_postgresqlv7" = "yes"; then
-		{ test "$extra_verbose" = "yes" && cat << \EOF
+if { (eval echo configure:7271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  with_postgresqlv7=yes;
+                 { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_POSTGRESQLV7
 EOF
 cat >> confdefs.h <<\EOF
@@ -7439,25 +7290,40 @@
 EOF
 }
 
-	fi
-	LIBS="-lpq $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lpq\" to \$LIBS"; fi
-	extra_objs="$extra_objs postgresql.o" &&  if test "$extra_verbose" = "yes"; then
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining LIBPQ_FE_H_FILE = "$libpq_fe_h_file"
+EOF
+cat >> confdefs.h <<EOF
+#define LIBPQ_FE_H_FILE "$libpq_fe_h_file"
+EOF
+}
+
+    LIBS="-lpq $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lpq\" to \$LIBS"; fi
+    extra_objs="$extra_objs postgresql.o" &&  if test "$extra_verbose" = "yes"; then
    echo "    xemacs will be linked with \"postgresql.o\""
  fi
+  elif test "$with_postgresql" = "yes"; then
+    { echo "Error:" "Required PostgreSQL support cannot be provided.  Check --site-prefixes." >&2; exit 1; }
+  fi
 fi
 
 
 if test "$window_system" != "none"; then
   echo "checking for graphics libraries" 1>&6
-echo "configure:7453: checking for graphics libraries" >&5
+echo "configure:7319: checking for graphics libraries" >&5
 
     xpm_problem=""
   if test -z "$with_xpm"; then
     echo $ac_n "checking for Xpm - no older than 3.4f""... $ac_c" 1>&6
-echo "configure:7458: checking for Xpm - no older than 3.4f" >&5
+echo "configure:7324: checking for Xpm - no older than 3.4f" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 7461 "configure"
+#line 7327 "configure"
 #include "confdefs.h"
 #define XPM_NUMBERS
 #include <X11/xpm.h>
@@ -7466,7 +7332,7 @@
       XpmIncludeVersion != XpmLibraryVersion() ? 1 :
       XpmIncludeVersion < 30406 ? 2 : 0 ;}
 EOF
-if { (eval echo configure:7470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:7336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ./conftest dummy_arg; xpm_status=$?;
       if test "$xpm_status" = "0"; then
@@ -7508,17 +7374,17 @@
 
     libs_x="-lXpm $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lXpm\" to \$libs_x"; fi
     echo $ac_n "checking for \"FOR_MSW\" xpm""... $ac_c" 1>&6
-echo "configure:7512: checking for \"FOR_MSW\" xpm" >&5
+echo "configure:7378: checking for \"FOR_MSW\" xpm" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 7515 "configure"
+#line 7381 "configure"
 #include "confdefs.h"
 
 int main() {
 XpmCreatePixmapFromData()
 ; return 0; }
 EOF
-if { (eval echo configure:7522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   xpm_for_msw=no
 else
@@ -7544,15 +7410,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:7548: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7551 "configure"
+echo "configure:7414: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7417 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7556: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7422: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7575,12 +7441,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:7579: checking for UnGenFace in -lcompface" >&5
+echo "configure:7445: 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 7584 "configure"
+#line 7450 "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
@@ -7591,7 +7457,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:7595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7643,12 +7509,12 @@
       if test "$with_png $with_tiff" != "no no"; then
     
 echo $ac_n "checking for inflate in -lc""... $ac_c" 1>&6
-echo "configure:7647: checking for inflate in -lc" >&5
+echo "configure:7513: checking for inflate in -lc" >&5
 ac_lib_var=`echo c'_'inflate | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lc "
 cat > conftest.$ac_ext <<EOF
-#line 7652 "configure"
+#line 7518 "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
@@ -7659,7 +7525,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:7663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7678,12 +7544,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lz""... $ac_c" 1>&6
-echo "configure:7682: checking for inflate in -lz" >&5
+echo "configure:7548: checking for inflate in -lz" >&5
 ac_lib_var=`echo z'_'inflate | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lz "
 cat > conftest.$ac_ext <<EOF
-#line 7687 "configure"
+#line 7553 "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
@@ -7694,7 +7560,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:7698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7713,12 +7579,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lgz""... $ac_c" 1>&6
-echo "configure:7717: checking for inflate in -lgz" >&5
+echo "configure:7583: checking for inflate in -lgz" >&5
 ac_lib_var=`echo gz'_'inflate | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgz "
 cat > conftest.$ac_ext <<EOF
-#line 7722 "configure"
+#line 7588 "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
@@ -7729,7 +7595,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:7733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7759,15 +7625,15 @@
 
     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:7763: checking for jpeglib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7766 "configure"
+echo "configure:7629: checking for jpeglib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7632 "configure"
 #include "confdefs.h"
 #include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7771: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7790,12 +7656,12 @@
  }
   test -z "$with_jpeg" && { 
 echo $ac_n "checking for jpeg_destroy_decompress in -ljpeg""... $ac_c" 1>&6
-echo "configure:7794: checking for jpeg_destroy_decompress in -ljpeg" >&5
+echo "configure:7660: 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 7799 "configure"
+#line 7665 "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
@@ -7806,7 +7672,7 @@
 jpeg_destroy_decompress()
 ; return 0; }
 EOF
-if { (eval echo configure:7810: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7842,10 +7708,10 @@
 
     png_problem=""
   test -z "$with_png" && { echo $ac_n "checking for pow""... $ac_c" 1>&6
-echo "configure:7846: checking for pow" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7849 "configure"
+echo "configure:7712: checking for pow" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7715 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pow(); below.  */
@@ -7868,7 +7734,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_pow=yes"
 else
@@ -7889,15 +7755,15 @@
  }
   test -z "$with_png" && { ac_safe=`echo "png.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for png.h""... $ac_c" 1>&6
-echo "configure:7893: checking for png.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7896 "configure"
+echo "configure:7759: checking for png.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7762 "configure"
 #include "confdefs.h"
 #include <png.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7901: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7767: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7920,12 +7786,12 @@
  }
   test -z "$with_png" && { 
 echo $ac_n "checking for png_read_image in -lpng""... $ac_c" 1>&6
-echo "configure:7924: checking for png_read_image in -lpng" >&5
+echo "configure:7790: checking for png_read_image in -lpng" >&5
 ac_lib_var=`echo png'_'png_read_image | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpng "
 cat > conftest.$ac_ext <<EOF
-#line 7929 "configure"
+#line 7795 "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
@@ -7936,7 +7802,7 @@
 png_read_image()
 ; return 0; }
 EOF
-if { (eval echo configure:7940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7959,10 +7825,10 @@
  }
   if test -z "$with_png"; then
     echo $ac_n "checking for workable png version information""... $ac_c" 1>&6
-echo "configure:7963: checking for workable png version information" >&5
+echo "configure:7829: checking for workable png version information" >&5
     xe_check_libs="-lpng -lz"
     cat > conftest.$ac_ext <<EOF
-#line 7966 "configure"
+#line 7832 "configure"
 #include "confdefs.h"
 #include <png.h>
     int main(int c, char **v) {
@@ -7970,7 +7836,7 @@
     if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING) != 0) return 1;
     return (PNG_LIBPNG_VER < 10002) ? 2 : 0 ;}
 EOF
-if { (eval echo configure:7974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:7840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ./conftest dummy_arg; png_status=$?;
       if test "$png_status" = "0"; then
@@ -8013,15 +7879,15 @@
 
     test -z "$with_tiff" && { ac_safe=`echo "tiffio.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tiffio.h""... $ac_c" 1>&6
-echo "configure:8017: checking for tiffio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8020 "configure"
+echo "configure:7883: checking for tiffio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7886 "configure"
 #include "confdefs.h"
 #include <tiffio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7891: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8044,12 +7910,12 @@
  }
   test -z "$with_tiff" && { 
 echo $ac_n "checking for TIFFClientOpen in -ltiff""... $ac_c" 1>&6
-echo "configure:8048: checking for TIFFClientOpen in -ltiff" >&5
+echo "configure:7914: checking for TIFFClientOpen in -ltiff" >&5
 ac_lib_var=`echo tiff'_'TIFFClientOpen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltiff "
 cat > conftest.$ac_ext <<EOF
-#line 8053 "configure"
+#line 7919 "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
@@ -8060,7 +7926,7 @@
 TIFFClientOpen()
 ; return 0; }
 EOF
-if { (eval echo configure:8064: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8099,10 +7965,10 @@
 if test "$with_x11" = "yes"; then
 
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:8103: checking for X11 graphics libraries" >&5
+echo "configure:7969: checking for X11 graphics libraries" >&5
 
   echo "checking for the Athena widgets" 1>&6
-echo "configure:8106: checking for the Athena widgets" >&5
+echo "configure:7972: checking for the Athena widgets" >&5
 
     case "$with_athena" in
         "xaw" | "")	athena_variant=Xaw	athena_3d=no  ;;
@@ -8116,12 +7982,12 @@
     if test "$athena_3d" = "no"; then
     
 echo $ac_n "checking for XawScrollbarSetThumb in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8120: checking for XawScrollbarSetThumb in -l$athena_variant" >&5
+echo "configure:7986: checking for XawScrollbarSetThumb in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'XawScrollbarSetThumb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8125 "configure"
+#line 7991 "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
@@ -8132,7 +7998,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:8136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8148,12 +8014,12 @@
   echo "$ac_t""yes" 1>&6
           
 echo $ac_n "checking for threeDClassRec in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8152: checking for threeDClassRec in -l$athena_variant" >&5
+echo "configure:8018: checking for threeDClassRec in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8157 "configure"
+#line 8023 "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
@@ -8164,7 +8030,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8034: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8195,12 +8061,12 @@
   else
         
 echo $ac_n "checking for threeDClassRec in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8199: checking for threeDClassRec in -l$athena_variant" >&5
+echo "configure:8065: checking for threeDClassRec in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8204 "configure"
+#line 8070 "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
@@ -8211,7 +8077,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8229,12 +8095,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for threeDClassRec in -lXaw""... $ac_c" 1>&6
-echo "configure:8233: checking for threeDClassRec in -lXaw" >&5
+echo "configure:8099: checking for threeDClassRec in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXaw "
 cat > conftest.$ac_ext <<EOF
-#line 8238 "configure"
+#line 8104 "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
@@ -8245,7 +8111,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8276,15 +8142,15 @@
     if test "$athena_3d" = "no"; then
     ac_safe=`echo "X11/Xaw/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8280: checking for X11/Xaw/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8283 "configure"
+echo "configure:8146: checking for X11/Xaw/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8149 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8288: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8154: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8304,15 +8170,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "X11/Xaw/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/XawInit.h""... $ac_c" 1>&6
-echo "configure:8308: checking for X11/Xaw/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8311 "configure"
+echo "configure:8174: checking for X11/Xaw/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8177 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8316: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8338,15 +8204,15 @@
   else
             ac_safe=`echo "X11/$athena_variant/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/$athena_variant/XawInit.h""... $ac_c" 1>&6
-echo "configure:8342: checking for X11/$athena_variant/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8345 "configure"
+echo "configure:8208: checking for X11/$athena_variant/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8211 "configure"
 #include "confdefs.h"
 #include <X11/$athena_variant/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8350: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8216: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8363,15 +8229,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "X11/$athena_variant/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/$athena_variant/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8367: checking for X11/$athena_variant/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8370 "configure"
+echo "configure:8233: checking for X11/$athena_variant/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8236 "configure"
 #include "confdefs.h"
 #include <X11/$athena_variant/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8241: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8399,15 +8265,15 @@
         if test -z "$athena_h_path"; then
       ac_safe=`echo "$athena_variant/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $athena_variant/XawInit.h""... $ac_c" 1>&6
-echo "configure:8403: checking for $athena_variant/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8406 "configure"
+echo "configure:8269: checking for $athena_variant/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8272 "configure"
 #include "confdefs.h"
 #include <$athena_variant/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8411: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8277: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8424,15 +8290,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "$athena_variant/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $athena_variant/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8428: checking for $athena_variant/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8431 "configure"
+echo "configure:8294: checking for $athena_variant/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8297 "configure"
 #include "confdefs.h"
 #include <$athena_variant/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8461,15 +8327,15 @@
         if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
       ac_safe=`echo "X11/Xaw3d/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw3d/XawInit.h""... $ac_c" 1>&6
-echo "configure:8465: checking for X11/Xaw3d/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8468 "configure"
+echo "configure:8331: checking for X11/Xaw3d/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8334 "configure"
 #include "confdefs.h"
 #include <X11/Xaw3d/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8473: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8339: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8486,15 +8352,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "X11/Xaw3d/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw3d/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8490: checking for X11/Xaw3d/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8493 "configure"
+echo "configure:8356: checking for X11/Xaw3d/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8359 "configure"
 #include "confdefs.h"
 #include <X11/Xaw3d/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8364: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8526,15 +8392,15 @@
         if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
       ac_safe=`echo "Xaw3d/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xaw3d/XawInit.h""... $ac_c" 1>&6
-echo "configure:8530: checking for Xaw3d/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8533 "configure"
+echo "configure:8396: checking for Xaw3d/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8399 "configure"
 #include "confdefs.h"
 #include <Xaw3d/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8538: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8551,15 +8417,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "Xaw3d/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xaw3d/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8555: checking for Xaw3d/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8558 "configure"
+echo "configure:8421: checking for Xaw3d/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8424 "configure"
 #include "confdefs.h"
 #include <Xaw3d/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8563: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8429: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8591,15 +8457,15 @@
             if test -z "$athena_h_path"; then
       ac_safe=`echo "X11/Xaw/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/ThreeD.h""... $ac_c" 1>&6
-echo "configure:8595: checking for X11/Xaw/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8598 "configure"
+echo "configure:8461: checking for X11/Xaw/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8464 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8603: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8634,15 +8500,15 @@
 
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:8638: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8641 "configure"
+echo "configure:8504: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8507 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8512: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8659,12 +8525,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:8663: checking for XmStringFree in -lXm" >&5
+echo "configure:8529: 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 8668 "configure"
+#line 8534 "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
@@ -8675,7 +8541,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:8679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8704,9 +8570,9 @@
 
   if test "$have_motif" = "yes"; then
         echo $ac_n "checking for Lesstif""... $ac_c" 1>&6
-echo "configure:8708: checking for Lesstif" >&5
+echo "configure:8574: checking for Lesstif" >&5
     cat > conftest.$ac_ext <<EOF
-#line 8710 "configure"
+#line 8576 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 #ifdef LESSTIF_VERSION
@@ -8760,11 +8626,83 @@
 
         libs_x="-l$athena_lib $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-l$athena_lib\" to \$libs_x"; fi
 
-            { test "$extra_verbose" = "yes" && cat << EOF
-    Defining ATHENA_H_PATH = $athena_h_path
-EOF
-cat >> confdefs.h <<EOF
-#define ATHENA_H_PATH $athena_h_path
+                    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Scrollbar_h_ = "$athena_h_path/Scrollbar.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Scrollbar_h_ "$athena_h_path/Scrollbar.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Dialog_h_ = "$athena_h_path/Dialog.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Dialog_h_ "$athena_h_path/Dialog.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Form_h_ = "$athena_h_path/Form.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Form_h_ "$athena_h_path/Form.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Command_h_ = "$athena_h_path/Command.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Command_h_ "$athena_h_path/Command.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Label_h_ = "$athena_h_path/Label.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Label_h_ "$athena_h_path/Label.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_LabelP_h_ = "$athena_h_path/LabelP.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_LabelP_h_ "$athena_h_path/LabelP.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_Toggle_h_ = "$athena_h_path/Toggle.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_Toggle_h_ "$athena_h_path/Toggle.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_ToggleP_h_ = "$athena_h_path/ToggleP.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_ToggleP_h_ "$athena_h_path/ToggleP.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_AsciiText_h_ = "$athena_h_path/AsciiText.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_AsciiText_h_ "$athena_h_path/AsciiText.h"
+EOF
+}
+
+    { test "$extra_verbose" = "yes" && cat << EOF
+    Defining ATHENA_XawInit_h_ = "$athena_h_path/XawInit.h"
+EOF
+cat >> confdefs.h <<EOF
+#define ATHENA_XawInit_h_ "$athena_h_path/XawInit.h"
 EOF
 }
 
@@ -8785,6 +8723,7 @@
 EOF
 }
 
+    need_athena="yes"
 
     if test "$athena_3d" = "yes"; then
       { test "$extra_verbose" = "yes" && cat << \EOF
@@ -9039,7 +8978,7 @@
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:9043: checking for Mule-related features" >&5
+echo "configure:8982: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -9064,15 +9003,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9068: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9071 "configure"
+echo "configure:9007: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9010 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9076: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9015: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9103,12 +9042,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:9107: checking for strerror in -lintl" >&5
+echo "configure:9046: 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 9112 "configure"
+#line 9051 "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
@@ -9119,7 +9058,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:9123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9152,18 +9091,18 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:9156: checking for Mule input methods" >&5
+echo "configure:9095: checking for Mule input methods" >&5
         case "$with_xim" in "" | "yes" )
     echo "checking for XIM" 1>&6
-echo "configure:9159: checking for XIM" >&5
+echo "configure:9098: checking for XIM" >&5
     
 echo $ac_n "checking for XOpenIM in -lX11""... $ac_c" 1>&6
-echo "configure:9162: checking for XOpenIM in -lX11" >&5
+echo "configure:9101: checking for XOpenIM in -lX11" >&5
 ac_lib_var=`echo X11'_'XOpenIM | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 "
 cat > conftest.$ac_ext <<EOF
-#line 9167 "configure"
+#line 9106 "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
@@ -9174,7 +9113,7 @@
 XOpenIM()
 ; return 0; }
 EOF
-if { (eval echo configure:9178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9198,12 +9137,12 @@
         if test "$have_motif $have_lesstif" = "yes no"; then
       
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:9202: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:9141: 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 9207 "configure"
+#line 9146 "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
@@ -9214,7 +9153,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:9218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9279,15 +9218,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:9283: checking for XFontSet" >&5
+echo "configure:9222: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:9286: checking for XmbDrawString in -lX11" >&5
+echo "configure:9225: 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 9291 "configure"
+#line 9230 "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
@@ -9298,7 +9237,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:9302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9338,15 +9277,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:9342: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9345 "configure"
+echo "configure:9281: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9284 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9350: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9371,10 +9310,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9375: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9378 "configure"
+echo "configure:9314: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9317 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9397,7 +9336,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -9426,12 +9365,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:9430: checking for crypt in -lcrypt" >&5
+echo "configure:9369: 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 9435 "configure"
+#line 9374 "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
@@ -9442,7 +9381,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:9446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9477,12 +9416,12 @@
     if test -z "$with_wnn" -o "$with_wnn" = "yes"; then
     
 echo $ac_n "checking for jl_dic_list_e in -lwnn""... $ac_c" 1>&6
-echo "configure:9481: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:9420: 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 9486 "configure"
+#line 9425 "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
@@ -9493,7 +9432,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:9497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9511,12 +9450,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for jl_dic_list_e in -lwnn4""... $ac_c" 1>&6
-echo "configure:9515: checking for jl_dic_list_e in -lwnn4" >&5
+echo "configure:9454: checking for jl_dic_list_e in -lwnn4" >&5
 ac_lib_var=`echo wnn4'_'jl_dic_list_e | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn4 "
 cat > conftest.$ac_ext <<EOF
-#line 9520 "configure"
+#line 9459 "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
@@ -9527,7 +9466,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:9531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9545,12 +9484,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for jl_dic_list_e in -lwnn6""... $ac_c" 1>&6
-echo "configure:9549: checking for jl_dic_list_e in -lwnn6" >&5
+echo "configure:9488: checking for jl_dic_list_e in -lwnn6" >&5
 ac_lib_var=`echo wnn6'_'jl_dic_list_e | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn6 "
 cat > conftest.$ac_ext <<EOF
-#line 9554 "configure"
+#line 9493 "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
@@ -9561,7 +9500,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:9565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9579,12 +9518,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dic_list_e in -lwnn6_fromsrc""... $ac_c" 1>&6
-echo "configure:9583: checking for dic_list_e in -lwnn6_fromsrc" >&5
+echo "configure:9522: checking for dic_list_e in -lwnn6_fromsrc" >&5
 ac_lib_var=`echo wnn6_fromsrc'_'dic_list_e | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn6_fromsrc "
 cat > conftest.$ac_ext <<EOF
-#line 9588 "configure"
+#line 9527 "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
@@ -9595,7 +9534,7 @@
 dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:9599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9643,12 +9582,12 @@
     if test "$with_wnn6" != "no"; then
       
 echo $ac_n "checking for jl_fi_dic_list in -l$libwnn""... $ac_c" 1>&6
-echo "configure:9647: checking for jl_fi_dic_list in -l$libwnn" >&5
+echo "configure:9586: checking for jl_fi_dic_list in -l$libwnn" >&5
 ac_lib_var=`echo $libwnn'_'jl_fi_dic_list | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$libwnn "
 cat > conftest.$ac_ext <<EOF
-#line 9652 "configure"
+#line 9591 "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
@@ -9659,7 +9598,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:9663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9694,15 +9633,15 @@
   if test "$with_canna" != "no"; then
     ac_safe=`echo "canna/jrkanji.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/jrkanji.h""... $ac_c" 1>&6
-echo "configure:9698: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9701 "configure"
+echo "configure:9637: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9640 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9706: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9729,15 +9668,15 @@
     c_switch_site="$c_switch_site -I/usr/local/canna/include"
     ac_safe=`echo "canna/jrkanji.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/jrkanji.h""... $ac_c" 1>&6
-echo "configure:9733: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9736 "configure"
+echo "configure:9672: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9675 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9741: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9765,15 +9704,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:9769: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9772 "configure"
+echo "configure:9708: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9711 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9716: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9796,12 +9735,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:9800: checking for RkBgnBun in -lRKC" >&5
+echo "configure:9739: 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 9805 "configure"
+#line 9744 "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
@@ -9812,7 +9751,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:9816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9835,12 +9774,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:9839: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:9778: 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 9844 "configure"
+#line 9783 "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
@@ -9851,7 +9790,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:9855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9900,12 +9839,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:9904: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:9843: 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 9909 "configure"
+#line 9848 "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
@@ -9916,7 +9855,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:9920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10002,6 +9941,67 @@
 for ac_func in cbrt closedir dup2 eaccess fmod fpathconf frexp ftime getaddrinfo gethostname getnameinfo getpagesize gettimeofday getcwd getpt getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf stpcpy strcasecmp strerror tzset ulimit usleep utimes waitpid vsnprintf fsync ftruncate umask
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:9945: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9948 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:9971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  { test "$extra_verbose" = "yes" && cat << EOF
+    Defining $ac_tr_func
+EOF
+cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+}
+ 
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
+extra_objs="$extra_objs realpath.o" &&  if test "$extra_verbose" = "yes"; then
+   echo "    xemacs will be linked with \"realpath.o\""
+ fi
+
+for ac_func in getloadavg
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:10006: checking for $ac_func" >&5
 
 cat > conftest.$ac_ext <<EOF
@@ -10056,67 +10056,6 @@
 done
 
 
-extra_objs="$extra_objs realpath.o" &&  if test "$extra_verbose" = "yes"; then
-   echo "    xemacs will be linked with \"realpath.o\""
- fi
-
-for ac_func in getloadavg
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:10067: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10070 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char $ac_func();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:10093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_$ac_func=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  { test "$extra_verbose" = "yes" && cat << EOF
-    Defining $ac_tr_func
-EOF
-cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-}
- 
-else
-  echo "$ac_t""no" 1>&6
-fi
-done
-
-
 if test "$ac_cv_func_getloadavg" != "yes"
 then
   extra_objs="$extra_objs getloadavg.o" &&  if test "$extra_verbose" = "yes"; then
@@ -10125,12 +10064,12 @@
 
     
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:10129: checking for kstat_open in -lkstat" >&5
+echo "configure:10068: 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 10134 "configure"
+#line 10073 "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
@@ -10141,7 +10080,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:10145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10175,12 +10114,12 @@
 
     
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:10179: checking for kvm_read in -lkvm" >&5
+echo "configure:10118: 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 10184 "configure"
+#line 10123 "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
@@ -10191,7 +10130,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:10195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -10225,16 +10164,16 @@
 fi
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:10229: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 10231 "configure"
+echo "configure:10168: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 10170 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:10238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -10254,16 +10193,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:10258: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 10260 "configure"
+echo "configure:10197: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 10199 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:10267: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10206: \"$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
@@ -10283,11 +10222,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:10287: checking whether localtime caches TZ" >&5
+echo "configure:10226: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 10291 "configure"
+#line 10230 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -10322,7 +10261,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:10326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -10352,9 +10291,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday accepts one or two arguments""... $ac_c" 1>&6
-echo "configure:10356: checking whether gettimeofday accepts one or two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 10358 "configure"
+echo "configure:10295: checking whether gettimeofday accepts one or two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 10297 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -10375,7 +10314,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""two" 1>&6
 else
@@ -10397,19 +10336,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:10401: checking for inline" >&5
+echo "configure:10340: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 10406 "configure"
+#line 10345 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:10413: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -10449,17 +10388,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:10453: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10456 "configure"
+echo "configure:10392: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10395 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:10463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -10483,10 +10422,10 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:10487: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10490 "configure"
+echo "configure:10426: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10429 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -10514,7 +10453,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:10518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -10553,10 +10492,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:10557: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10560 "configure"
+echo "configure:10496: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10499 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -10580,10 +10519,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:10584: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10587 "configure"
+echo "configure:10523: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10526 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -10606,7 +10545,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -10636,10 +10575,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:10640: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10643 "configure"
+echo "configure:10579: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10582 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -10658,7 +10597,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:10662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -10687,15 +10626,15 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:10691: checking for vfork.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10694 "configure"
+echo "configure:10630: checking for vfork.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10633 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -10723,10 +10662,10 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:10727: checking for working vfork" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10730 "configure"
+echo "configure:10666: checking for working vfork" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10669 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -10821,7 +10760,7 @@
   }
 }
 EOF
-if { (eval echo configure:10825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_vfork_works=yes
 else
@@ -10847,10 +10786,10 @@
 
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:10851: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10854 "configure"
+echo "configure:10790: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10793 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -10860,7 +10799,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:10864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -10888,10 +10827,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:10892: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10895 "configure"
+echo "configure:10831: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10834 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -10914,7 +10853,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -10942,10 +10881,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:10946: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10949 "configure"
+echo "configure:10885: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10888 "configure"
 #include "confdefs.h"
 
 /*
@@ -11000,7 +10939,7 @@
 }
 
 EOF
-if { (eval echo configure:11004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -11027,10 +10966,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:11031: checking for working mmap" >&5
+echo "configure:10970: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 11034 "configure"
+#line 10973 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -11063,7 +11002,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:11067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:11006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   have_mmap=yes
 else
@@ -11089,9 +11028,9 @@
 if test "$rel_alloc $have_mmap" = "default yes"; then
   if test "$doug_lea_malloc" = "yes"; then
         echo $ac_n "checking for M_MMAP_THRESHOLD""... $ac_c" 1>&6
-echo "configure:11093: checking for M_MMAP_THRESHOLD" >&5
+echo "configure:11032: checking for M_MMAP_THRESHOLD" >&5
     cat > conftest.$ac_ext <<EOF
-#line 11095 "configure"
+#line 11034 "configure"
 #include "confdefs.h"
 #include <malloc.h>
 int main() {
@@ -11103,7 +11042,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:11046: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   rel_alloc=no; echo "$ac_t""yes" 1>&6;
 else
@@ -11128,15 +11067,15 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:11132: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11135 "configure"
+echo "configure:11071: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11074 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11140: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11179,15 +11118,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:11183: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11186 "configure"
+echo "configure:11122: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11125 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11130: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11219,10 +11158,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:11223: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11226 "configure"
+echo "configure:11162: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11165 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -11245,7 +11184,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -11260,15 +11199,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:11264: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11267 "configure"
+echo "configure:11203: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11206 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11285,15 +11224,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:11289: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11292 "configure"
+echo "configure:11228: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11231 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11236: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11318,9 +11257,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:11322: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:11261: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 11324 "configure"
+#line 11263 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -11331,7 +11270,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:11335: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SOCKADDR_SUN_LEN
@@ -11349,9 +11288,9 @@
 fi
 rm -f conftest*
       echo $ac_n "checking "for ip_mreq struct in netinet/in.h"""... $ac_c" 1>&6
-echo "configure:11353: checking "for ip_mreq struct in netinet/in.h"" >&5
+echo "configure:11292: checking "for ip_mreq struct in netinet/in.h"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 11355 "configure"
+#line 11294 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -11361,7 +11300,7 @@
 static struct ip_mreq x;
 ; return 0; }
 EOF
-if { (eval echo configure:11365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_MULTICAST
@@ -11392,10 +11331,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:11396: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11399 "configure"
+echo "configure:11335: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11338 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -11418,7 +11357,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_msgget=yes"
 else
@@ -11433,15 +11372,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:11437: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11440 "configure"
+echo "configure:11376: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11379 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11384: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11458,15 +11397,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:11462: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11465 "configure"
+echo "configure:11401: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11404 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11470: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11409: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11504,15 +11443,15 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:11508: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11511 "configure"
+echo "configure:11447: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11450 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11516: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11539,15 +11478,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:11543: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11546 "configure"
+echo "configure:11482: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11485 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11490: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11580,15 +11519,15 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:11584: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11587 "configure"
+echo "configure:11523: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11526 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11592: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11531: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11618,22 +11557,22 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:11622: checking "for sound support"" >&5
+echo "configure:11561: checking "for sound support"" >&5
 test -z "$with_native_sound" -a -n "$native_sound_lib" && with_native_sound=yes
 
 if test "$with_native_sound" != "no"; then
     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:11629: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11632 "configure"
+echo "configure:11568: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11571 "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:11637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11576: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11681,12 +11620,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:11685: checking for ALopenport in -laudio" >&5
+echo "configure:11624: 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 11690 "configure"
+#line 11629 "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
@@ -11697,7 +11636,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:11701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -11728,12 +11667,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:11732: checking for AOpenAudio in -lAlib" >&5
+echo "configure:11671: 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 11737 "configure"
+#line 11676 "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
@@ -11744,7 +11683,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:11748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -11782,15 +11721,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:11786: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11789 "configure"
+echo "configure:11725: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11728 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11794: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11733: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11826,6 +11765,13 @@
     done
   fi
 
+    if test -z "$sound_found"; then
+    if test "$with_msw" = "yes"; then
+    sound_found=yes
+    native_sound_lib=
+    fi
+  fi
+
   test "$sound_found" = "yes" && with_native_sound=yes
 fi
 
@@ -11844,15 +11790,15 @@
 if test "$with_nas_sound" != "no"; then
   ac_safe=`echo "audio/audiolib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for audio/audiolib.h""... $ac_c" 1>&6
-echo "configure:11848: checking for audio/audiolib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11851 "configure"
+echo "configure:11794: checking for audio/audiolib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11797 "configure"
 #include "confdefs.h"
 #include <audio/audiolib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11856: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11870,12 +11816,12 @@
   
     
 echo $ac_n "checking for AuOpenServer in -laudio""... $ac_c" 1>&6
-echo "configure:11874: checking for AuOpenServer in -laudio" >&5
+echo "configure:11820: checking for AuOpenServer in -laudio" >&5
 ac_lib_var=`echo audio'_'AuOpenServer | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -laudio "
 cat > conftest.$ac_ext <<EOF
-#line 11879 "configure"
+#line 11825 "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
@@ -11886,7 +11832,7 @@
 AuOpenServer()
 ; return 0; }
 EOF
-if { (eval echo configure:11890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -11925,7 +11871,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 11929 "configure"
+#line 11875 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -11956,7 +11902,7 @@
   # Extract the first word of "esd-config", so it can be a program name with args.
 set dummy esd-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:11960: checking for $ac_word" >&5
+echo "configure:11906: checking for $ac_word" >&5
 
 if test -n "$have_esd_config"; then
   ac_cv_prog_have_esd_config="$have_esd_config" # Let the user override the test.
@@ -11985,10 +11931,10 @@
     c_switch_site="$c_switch_site `esd-config --cflags`" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"`esd-config --cflags`\" to \$c_switch_site"; fi
     LIBS="`esd-config --libs` $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"`esd-config --libs`\" to \$LIBS"; fi
     echo $ac_n "checking for esd_play_stream""... $ac_c" 1>&6
-echo "configure:11989: checking for esd_play_stream" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11992 "configure"
+echo "configure:11935: checking for esd_play_stream" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11938 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char esd_play_stream(); below.  */
@@ -12011,7 +11957,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_esd_play_stream=yes"
 else
@@ -12062,7 +12008,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:12066: checking for TTY-related features" >&5
+echo "configure:12012: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -12078,12 +12024,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:12082: checking for tgetent in -lncurses" >&5
+echo "configure:12028: 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 12087 "configure"
+#line 12033 "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
@@ -12094,7 +12040,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:12098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12127,15 +12073,15 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:12131: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12134 "configure"
+echo "configure:12077: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12080 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12085: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12157,15 +12103,15 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:12161: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12164 "configure"
+echo "configure:12107: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12110 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12195,15 +12141,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:12199: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12202 "configure"
+echo "configure:12145: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12148 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12153: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12238,12 +12184,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:12242: checking for tgetent in -l$lib" >&5
+echo "configure:12188: 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 12247 "configure"
+#line 12193 "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
@@ -12254,7 +12200,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:12258: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12285,12 +12231,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:12289: checking for tgetent in -lcurses" >&5
+echo "configure:12235: 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 12294 "configure"
+#line 12240 "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
@@ -12301,7 +12247,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:12305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12319,12 +12265,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:12323: checking for tgetent in -ltermcap" >&5
+echo "configure:12269: 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 12328 "configure"
+#line 12274 "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
@@ -12335,7 +12281,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:12339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12383,15 +12329,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:12387: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12390 "configure"
+echo "configure:12333: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12336 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12395: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12414,12 +12360,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:12418: checking for Gpm_Open in -lgpm" >&5
+echo "configure:12364: 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 12423 "configure"
+#line 12369 "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
@@ -12430,7 +12376,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:12434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12480,20 +12426,20 @@
 
 test "$with_database_gdbm $with_database_dbm $with_database_berkdb" \
   != "no no no" && echo "checking for database support" 1>&6
-echo "configure:12484: checking for database support" >&5
+echo "configure:12430: checking for database support" >&5
 
 if test "$with_database_gdbm $with_database_dbm" != "no no"; then
   ac_safe=`echo "ndbm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ndbm.h""... $ac_c" 1>&6
-echo "configure:12489: checking for ndbm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12492 "configure"
+echo "configure:12435: checking for ndbm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12438 "configure"
 #include "confdefs.h"
 #include <ndbm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12497: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12443: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12523,12 +12469,12 @@
 if test "$with_database_gdbm" != "no"; then
   
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:12527: checking for dbm_open in -lgdbm" >&5
+echo "configure:12473: 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 12532 "configure"
+#line 12478 "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
@@ -12539,7 +12485,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:12543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12567,10 +12513,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:12571: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12574 "configure"
+echo "configure:12517: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12520 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -12593,7 +12539,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -12612,12 +12558,12 @@
 
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:12616: checking for dbm_open in -ldbm" >&5
+echo "configure:12562: 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 12621 "configure"
+#line 12567 "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
@@ -12628,7 +12574,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:12632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12669,10 +12615,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for Berkeley db.h""... $ac_c" 1>&6
-echo "configure:12673: checking for Berkeley db.h" >&5
+echo "configure:12619: checking for Berkeley db.h" >&5
   for header in "db/db.h" "db.h"; do
     cat > conftest.$ac_ext <<EOF
-#line 12676 "configure"
+#line 12622 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12694,7 +12640,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12698: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_file="$header"; break
 else
@@ -12710,9 +12656,9 @@
 
   if test "$with_database_berkdb" != "no"; then
     echo $ac_n "checking for Berkeley DB version""... $ac_c" 1>&6
-echo "configure:12714: checking for Berkeley DB version" >&5
+echo "configure:12660: checking for Berkeley DB version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 12716 "configure"
+#line 12662 "configure"
 #include "confdefs.h"
 #include <$db_h_file>
 #if DB_VERSION_MAJOR > 1
@@ -12731,10 +12677,10 @@
 rm -f conftest*
 
     echo $ac_n "checking for $dbfunc""... $ac_c" 1>&6
-echo "configure:12735: checking for $dbfunc" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12738 "configure"
+echo "configure:12681: checking for $dbfunc" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12684 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $dbfunc(); below.  */
@@ -12757,7 +12703,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$dbfunc=yes"
 else
@@ -12776,12 +12722,12 @@
 
     
 echo $ac_n "checking for $dbfunc in -ldb""... $ac_c" 1>&6
-echo "configure:12780: checking for $dbfunc in -ldb" >&5
+echo "configure:12726: checking for $dbfunc in -ldb" >&5
 ac_lib_var=`echo db'_'$dbfunc | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldb "
 cat > conftest.$ac_ext <<EOF
-#line 12785 "configure"
+#line 12731 "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
@@ -12792,7 +12738,7 @@
 $dbfunc()
 ; return 0; }
 EOF
-if { (eval echo configure:12796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12856,12 +12802,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:12860: checking for SOCKSinit in -lsocks" >&5
+echo "configure:12806: 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 12865 "configure"
+#line 12811 "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
@@ -12872,7 +12818,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:12876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12927,19 +12873,22 @@
 
 if test "$with_modules" != "no"; then
   echo "checking for module support" 1>&6
-echo "configure:12931: checking for module support" >&5
-
-    ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
+echo "configure:12877: checking for module support" >&5
+
+    if test "$with_msw" = "yes"; then
+    have_dl=yes;
+  else
+        ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:12935: checking for dlfcn.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12938 "configure"
+echo "configure:12884: checking for dlfcn.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12887 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12955,14 +12904,14 @@
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   
-    
+      
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:12961: checking for dlopen in -ldl" >&5
+echo "configure:12910: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldl "
 cat > conftest.$ac_ext <<EOF
-#line 12966 "configure"
+#line 12915 "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
@@ -12973,7 +12922,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:12977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -12992,12 +12941,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for dlopen in -lc""... $ac_c" 1>&6
-echo "configure:12996: checking for dlopen in -lc" >&5
+echo "configure:12945: checking for dlopen in -lc" >&5
 ac_lib_var=`echo c'_'dlopen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lc "
 cat > conftest.$ac_ext <<EOF
-#line 13001 "configure"
+#line 12950 "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
@@ -13008,7 +12957,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:13012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -13035,8 +12984,8 @@
   echo "$ac_t""no" 1>&6
 fi
 
-  if test -n "$have_dl"; then
-    { test "$extra_verbose" = "yes" && cat << \EOF
+    if test -n "$have_dl"; then
+      { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_DLOPEN
 EOF
 cat >> confdefs.h <<\EOF
@@ -13044,15 +12993,15 @@
 EOF
 }
 
-  else
-    
+    else
+      
 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:13051: checking for shl_load in -ldld" >&5
+echo "configure:13000: checking for shl_load in -ldld" >&5
 ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldld "
 cat > conftest.$ac_ext <<EOF
-#line 13056 "configure"
+#line 13005 "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
@@ -13063,7 +13012,7 @@
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo configure:13067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -13078,7 +13027,7 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
   libdl=dld have_dl=yes;
-      { test "$extra_verbose" = "yes" && cat << \EOF
+        { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SHL_LOAD
 EOF
 cat >> confdefs.h <<\EOF
@@ -13090,12 +13039,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for dld_init in -ldld""... $ac_c" 1>&6
-echo "configure:13094: checking for dld_init in -ldld" >&5
+echo "configure:13043: checking for dld_init in -ldld" >&5
 ac_lib_var=`echo dld'_'dld_init | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldld "
 cat > conftest.$ac_ext <<EOF
-#line 13099 "configure"
+#line 13048 "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
@@ -13106,7 +13055,7 @@
 dld_init()
 ; return 0; }
 EOF
-if { (eval echo configure:13110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -13121,7 +13070,7 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
   echo "$ac_t""yes" 1>&6
   libdl=dld have_dl=yes;
-      { test "$extra_verbose" = "yes" && cat << \EOF
+        { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_DLD_INIT
 EOF
 cat >> confdefs.h <<\EOF
@@ -13137,8 +13086,8 @@
 fi
 
 
-  fi
-
+    fi
+  fi 
   if test -n "$have_dl"; then
         
 dll_ld=
@@ -13151,7 +13100,7 @@
 xealias=$internal_configuration
 
 echo "checking how to build dynamic libraries for ${xehost}" 1>&6
-echo "configure:13155: checking how to build dynamic libraries for ${xehost}" >&5
+echo "configure:13104: checking how to build dynamic libraries for ${xehost}" >&5
 # Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts.
 case "$xehost" in
 *-*-linux-gnu*) ;;
@@ -13179,9 +13128,9 @@
   XEGCC=yes
 else
   echo $ac_n "checking checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:13183: checking checking whether we are using GNU C" >&5
+echo "configure:13132: checking checking whether we are using GNU C" >&5
   cat > conftest.$ac_ext <<EOF
-#line 13185 "configure"
+#line 13134 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -13203,7 +13152,7 @@
 fi
 
 echo $ac_n "checking how to produce PIC code""... $ac_c" 1>&6
-echo "configure:13207: checking how to produce PIC code" >&5
+echo "configure:13156: checking how to produce PIC code" >&5
 wl=
 
 can_build_shared=yes
@@ -13224,6 +13173,9 @@
     # like `-m68040'.
     dll_cflags='-m68020 -resident32 -malways-restore-a4'
     ;;
+  *cygwin* | *mingw* )
+    # PIC is the default
+    ;;
   *)
     dll_cflags='-fPIC'
     ;;
@@ -13296,18 +13248,18 @@
   
   # Check to make sure the dll_cflags actually works.
   echo $ac_n "checking if PIC flag ${dll_cflags} really works""... $ac_c" 1>&6
-echo "configure:13300: checking if PIC flag ${dll_cflags} really works" >&5
+echo "configure:13252: checking if PIC flag ${dll_cflags} really works" >&5
   save_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $dll_cflags -DPIC"
   cat > conftest.$ac_ext <<EOF
-#line 13304 "configure"
+#line 13256 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:13311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     # On HP-UX, the stripped-down bundled CC doesn't accept +Z, but also
@@ -13338,7 +13290,7 @@
 xldf=
 xcldf=
 echo $ac_n "checking if C compiler can produce shared libraries""... $ac_c" 1>&6
-echo "configure:13342: checking if C compiler can produce shared libraries" >&5
+echo "configure:13294: checking if C compiler can produce shared libraries" >&5
 if test "$XEGCC" = yes; then
   xcldf="-shared"
   xldf="-shared"
@@ -13389,14 +13341,14 @@
   xe_libs=
   ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
   cat > conftest.$ac_ext <<EOF
-#line 13393 "configure"
+#line 13345 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:13400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cc_produces_so=yes
 else
@@ -13421,7 +13373,7 @@
   if test "$XEGCC" = yes; then
     # Check if gcc -print-prog-name=ld gives a path.
     echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:13425: checking for ld used by GCC" >&5
+echo "configure:13377: checking for ld used by GCC" >&5
     ac_prog=`($CC -print-prog-name=ld) 2>&5`
     case "$ac_prog" in
     # Accept absolute paths.
@@ -13446,7 +13398,7 @@
     esac
   else
     echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:13450: checking for GNU ld" >&5
+echo "configure:13402: checking for GNU ld" >&5
   fi
 
   if test -z "$LTLD"; then
@@ -13484,7 +13436,7 @@
 
 # Check to see if it really is or isn't GNU ld.
 echo $ac_n "checking if the linker is GNU ld""... $ac_c" 1>&6
-echo "configure:13488: checking if the linker is GNU ld" >&5
+echo "configure:13440: checking if the linker is GNU ld" >&5
 # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 if $LTLD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
   xe_gnu_ld=yes
@@ -13512,7 +13464,7 @@
   # OK - only NOW do we futz about with ld.
   # See if the linker supports building shared libraries.
   echo $ac_n "checking whether the linker supports shared libraries""... $ac_c" 1>&6
-echo "configure:13516: checking whether the linker supports shared libraries" >&5
+echo "configure:13468: checking whether the linker supports shared libraries" >&5
   dll_ld=$CC
   dll_ldflags=$LDFLAGS
   ld_shlibs=yes
@@ -13727,10 +13679,10 @@
     for ac_func in dlerror _dlerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:13731: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13734 "configure"
+echo "configure:13683: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13686 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -13753,7 +13705,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:13757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -13792,11 +13744,11 @@
 fi
 
 cat > conftest.$ac_ext <<EOF
-#line 13796 "configure"
+#line 13748 "configure"
 #include "confdefs.h"
 int main(int c,char *v[]){return 0;}
 EOF
-if { (eval echo configure:13800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:13752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -14443,7 +14395,7 @@
     echo "    - Handling WM_COMMAND properly."
   fi
 fi
-if test "$have_xaw" = "yes"; then
+if test "$need_athena" = "yes"; then
   echo "  Compiling in support for the Athena widget set:"
   echo "    - Athena headers location:                    $athena_h_path"
   echo "    - Athena library to link:                     $athena_lib"
@@ -14536,12 +14488,8 @@
 test "$with_ldap" = yes && echo "  Compiling in support for LDAP."
 if test "$with_postgresql" = yes; then
   echo "  Compiling in support for PostgreSQL."
-  if test "$with_postgresqlv7" = yes; then
-    echo "    - Using PostgreSQL V7 bindings."
-  fi
-  if test -n "$postgres_h_path"; then
-    echo "    - PostgreSQL headers location:  $postgres_h_path"
-  fi
+  echo "    - Using PostgreSQL header file:  $libpq_fe_h_file"
+  test "$with_postgresqlv7" = yes && echo "    - Using PostgreSQL V7 bindings."
 fi
 
 echo "
@@ -14564,7 +14512,7 @@
 test "$with_pop" = yes && echo "  Compiling in support for POP mail retrieval."
 test "$with_kerberos" = yes && echo "  Compiling in support for Kerberos POP authentication."
 test "$with_hesiod" = yes && echo "  Compiling in support for Hesiod POP server access."
-echo "  Compiling in support for \"$mail_locking\" mail spool file locking method."
+test -n "$mail_locking" && echo "  Compiling in support for \"$mail_locking\" mail spool file locking method."
 
 echo "
 Other Features:"
--- a/configure.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/configure.in	Mon Aug 13 11:19:21 2007 +0200
@@ -787,15 +787,16 @@
 	dnl Has the user specified the toolkit(s) to use for GUI elements?
 	"with_menubars"   | \
 	"with_scrollbars" | \
-	"with_dialogs" | \
+	"with_dialogs"    | \
 	"with_widgets" )
 	  case "$val" in
 	    l | lu | luc | luci | lucid )		val=lucid  ;;
 	    m | mo | mot | moti | motif )		val=motif  ;;
 	    a | at | ath | athe | athen | athena )	val=athena ;;
-	    n | no | non | none )			val=no ;;
+	    n | no | non | none )			val=no     ;;
+	    y | ye | yes )				val=yes    ;;
 	    * ) USAGE_ERROR(["The \`--$optname' option must have one of these values:
-  \`lucid', \`motif', \`athena', or \`no'."]) ;;
+  \`lucid', \`motif', \`athena', \`yes', or \`no'."]) ;;
 	  esac
 	  eval "$opt=\"$val\""
 	;;
@@ -1092,6 +1093,7 @@
   clipper-*        ) machine=clipper ;;
   arm*             ) machine=arm ;;
   ns32k-*          ) machine=ns32000 ;;
+  s390-*           ) machine=s390 ;;
 esac
 
 dnl Straightforward OS determination
@@ -1653,37 +1655,7 @@
 
 AC_AIX dnl Defines _ALL_SOURCE on AIX.
 
-dnl Determine which SMART_INCLUDE macro will work for this system
-cat > $srcdir/conffoo.h <<EOF
-#define CONFFOO 1
-EOF
-AC_MSG_CHECKING(for a working inclusion macro)
-AC_TRY_COMPILE(,[
-#define SMART_INCLUDE(path,file) <path/file>
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE (CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-], [ AC_MSG_RESULT(direct); AC_DEFINE(SMART_INCLUDE_INDIRECTIONS,0) ],
-AC_TRY_COMPILE(,[
-#define GLUE_INCLUDE(path,file)  <##path##/##file##>
-#define SMART_INCLUDE(path,file) GLUE_INCLUDE(path,file)
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE(CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-], [ AC_MSG_RESULT(simple); AC_DEFINE(SMART_INCLUDE_INDIRECTIONS,1) ],
-AC_TRY_COMPILE(,[
-#define GLUE_INCLUDE_2(path,file)  <##path##/##file##>
-#define GLUE_INCLUDE_1(path,file) GLUE_INCLUDE_2(path,file)
-#define SMART_INCLUDE(path,file) GLUE_INCLUDE_1(path,file)
-#define CONFFOO_H_PATH $srcdir
-#define CONFFOO_INCLUDE(file) SMART_INCLUDE (CONFFOO_H_PATH,file)
-#include CONFFOO_INCLUDE(conffoo.h)
-], [ AC_MSG_RESULT(double); AC_DEFINE(SMART_INCLUDE_INDIRECTIONS,2) ],
-  AC_MSG_ERROR([Cannot define a proper SMART_INCLUDE macro. Please report.]))))
-rm -f $srcdir/conffoo.h
-
-
-dnl We want feature macros defined here and in config.h.in, so that
+dnl We want feature macros defined here *and* in config.h.in, so that
 dnl the compilation environment at configure time and compile time agree.
 
 AC_MSG_CHECKING(for GNU libc)
@@ -1859,7 +1831,7 @@
   start_files=
   libs_standard=
   unexec=
-  lib_gcc=	
+  lib_gcc=
 fi
 
 dnl For debugging...
@@ -1881,8 +1853,8 @@
 test "$ordinary_link" = "no" -a -z "$libs_standard" && libs_standard="-lc"
 
 dnl Compiler-specific hacks
-dnl DEC C requires -std
-test "$__DECC" = "yes" && XE_APPEND(-std, c_switch_site)
+dnl DEC C `-std1' means ANSI C mode
+test "$__DECC" = "yes" && XE_APPEND(-std1, c_switch_site)
 
 dnl Calculalate value of CFLAGS:
 dnl Use either command line flag, environment var, or autodetection
@@ -2378,6 +2350,19 @@
 AC_TYPE_OFF_T
 AC_CHECK_TYPE(ssize_t, int)
 
+dnl check for Unix98 socklen_t
+AC_MSG_CHECKING(for socklen_t)
+AC_TRY_COMPILE([#include <sys/socket.h>
+socklen_t x;
+],[],[AC_MSG_RESULT(yes)],[
+AC_TRY_COMPILE([#include <sys/socket.h>
+int accept (int, struct sockaddr *, size_t *);
+],[],[
+AC_MSG_RESULT(size_t)
+AC_DEFINE(socklen_t,size_t)], [
+AC_MSG_RESULT(int)
+AC_DEFINE(socklen_t,int)])])
+
 AC_MSG_CHECKING(for struct timeval)
 AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -2441,9 +2426,18 @@
 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
 test -z "$mail_locking" -a "$mail_use_locking" = "yes" && mail_locking=locking
+if   test -z "$mail_locking"; then
+  case "$opsys" in cygwin* | mingw*)
+    mail_locking=pop ;;
+  esac
+fi
+
 if   test "$mail_locking" = "lockf"; then AC_DEFINE(MAIL_LOCK_LOCKF)
 elif test "$mail_locking" = "flock"; then AC_DEFINE(MAIL_LOCK_FLOCK)
 elif test "$mail_locking" = "locking"; then AC_DEFINE(MAIL_LOCK_LOCKING)
+elif test "$mail_locking" = "pop"; then
+  with_pop=yes
+  mail_locking=
 else mail_locking="dot-locking"; AC_DEFINE(MAIL_LOCK_DOT)
 fi
 test "$mail_locking" = "lockf" -a "$ac_cv_func_lockf" != "yes" && \
@@ -2621,10 +2615,19 @@
     cd ..
     rm -fr conftestdir
     for word in $xmkmf_defines; do
-      case "$word" in
-	-D*=* ) ;;
-	-D* ) word=`echo '' $word | sed -e 's:^ *-D::'`
-	      AC_DEFINE_UNQUOTED($word) ;;
+      case "$word" in -D* )
+	sym=`echo '' $word | sed -e 's:^ *-D::' -e 's:=.*::'`
+	case "$word" in
+	  -D*=* ) val=`echo '' $word | sed -e 's:^.*=::'` ;;
+	  *     ) val=1 ;;
+	esac
+dnl Avoid re-AC_DEFINE-ing xmkmf symbols we've already defined above.
+	if grep "^#define $sym " confdefs.h >/dev/null; then :; else
+	  if test "$val" = "1"
+	    then AC_DEFINE_UNQUOTED($sym)
+	    else AC_DEFINE_UNQUOTED($sym,$val)
+	  fi
+	fi  ;;
       esac
     done
   fi
@@ -2712,7 +2715,7 @@
   if test "$with_msw" = "yes"; then
     AC_DEFINE(HAVE_MS_WINDOWS)
     install_pp="$blddir/lib-src/installexe.sh"
-    XE_APPEND(-lshell32 -lgdi32 -luser32 -lcomctl32 -lwinspool, libs_system)
+    XE_APPEND(-lshell32 -lgdi32 -luser32 -lcomdlg32 -lcomctl32 -lwinspool, libs_system)
     test "$with_dragndrop" != no && XE_APPEND(msw, dragndrop_proto)
     if test "$window_system" != x11; then
  	window_system=msw
@@ -2945,67 +2948,35 @@
 fi
 
 dnl Autodetect PostgreSQL
-dnl The default installation location (non-Linux) is /usr/local/pgsql;
-dnl  a different prefix can be selected at build/install time.  If PostgreSQL
-dnl  is installed into a different prefix, that prefix must be specified in
-dnl  in the --site-prefixes flag.
-dnl The default RPM-based Linux installation location is /usr.
-AC_CHECKING(for PostgreSQL)
-postgres_h_path=""
-postgres_includes_found=no
-save_c_switch_site="$c_switch_site"
-
-dnl First, test standard location and site prefixes only:
+dnl On many Linux systems, PostgreSQL is packaged to be installed in /usr;
+dnl in this case, configure will easily detect it there.
+dnl
+dnl If PostgreSQL is installed into a different prefix,
+dnl (such as the default /usr/local/pgsql when building from source),
+dnl that prefix must be specified using the --site-prefixes flag.
 if test "$with_postgresql" != "no"; then
-	AC_CHECK_HEADER(libpq-fe.h,postgres_includes_found=yes)
-fi
-
-dnl Otherwise, test different known headers locations on linux:
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/local/pgsql/include"; then
-	c_switch_site="$c_switch_site -I/usr/local/pgsql/include"
-	AC_CHECK_HEADER(libpq-fe.h,postgres_includes_found=yes)
-	if test "$postgres_includes_found" != "yes"; then
-		postgres_h_path="/usr/local/pgsql/include"
-	fi
-	c_switch_site="$save_c_switch_site"
-fi
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/include/pgsql"; then
-	c_switch_site="$c_switch_site -I/usr/include/pgsql"
-	AC_CHECK_HEADER(libpq-fe.h,postgres_includes_found=yes)
-	if test "$postgres_includes_found" = "yes"; then
-		postgres_h_path="pgsql"
-	fi
-		c_switch_site="$save_c_switch_site"
-	fi
-if test "$postgres_includes_found" = "no" -a "$with_postgresql" != "no" -a \
-	-d "/usr/include/postgresql"; then
-	c_switch_site="$c_switch_site -I/usr/include/postgresql"
-	AC_CHECK_HEADER(libpq-fe.h,postgres_includes_found=yes)
-	if test "$postgres_includes_found" = "yes"; then
-		postgres_h_path="postgresql"
-fi
-	c_switch_site="$save_c_switch_site"
-fi
-
-dnl Finally, check if we can link with libpq:
-if test "$postgres_includes_found" = "yes"; then
-	AC_CHECK_LIB(pq,PQconnectdb,with_postgresql=yes,with_postgresql=no)
-fi
-if test "$with_postgresql" = "yes"; then
-	AC_CHECK_LIB(pq,PQconnectStart,with_postgresqlv7=yes,with_postgresqlv7=no)
-fi
-if test "$with_postgresql" = "yes"; then
-	if test -n "$postgres_h_path"; then
-		AC_DEFINE_UNQUOTED(POSTGRES_H_PATH, $postgres_h_path)
-	fi
-	AC_DEFINE(HAVE_POSTGRESQL)
-	if test "$with_postgresqlv7" = "yes"; then
-		AC_DEFINE(HAVE_POSTGRESQLV7)
-	fi
-	XE_PREPEND(-lpq, LIBS)
-	XE_ADD_OBJS(postgresql.o)
+  AC_CHECKING(for PostgreSQL)
+
+dnl Look for these standard header file locations, known to be used on Linux
+  for header_dir in "" "pgsql/" "postgresql/"; do
+    AC_CHECK_HEADER(${header_dir}libpq-fe.h,
+                    libpq_fe_h_file=${header_dir}libpq-fe.h; break)
+  done
+
+  test -n "$libpq_fe_h_file" && { AC_CHECK_LIB(pq,PQconnectdb,have_libpq=yes) }
+
+  if test -n "$libpq_fe_h_file" -a "$have_libpq" = "yes"; then
+    with_postgresql=yes
+    AC_DEFINE(HAVE_POSTGRESQL)
+    AC_CHECK_LIB(pq,PQconnectStart, [
+                 with_postgresqlv7=yes;
+                 AC_DEFINE(HAVE_POSTGRESQLV7)])
+    AC_DEFINE_UNQUOTED(LIBPQ_FE_H_FILE, "$libpq_fe_h_file")
+    XE_PREPEND(-lpq, LIBS)
+    XE_ADD_OBJS(postgresql.o)
+  elif test "$with_postgresql" = "yes"; then
+    XE_DIE("Required PostgreSQL support cannot be provided.  Check --site-prefixes.")
+  fi
 fi
 
 dnl ----------------------
@@ -3306,12 +3277,24 @@
     dnl Add the Athena widget library we located earlier
     XE_PREPEND(-l$athena_lib, libs_x)
 
-    dnl Export the path for lwlib, used to build and include the headers
-    dnl from the right place later on.
-    AC_DEFINE_UNQUOTED(ATHENA_H_PATH, $athena_h_path)
+    dnl Tell lwlib where to find the Athena header files.
+    dnl Many people have tried to create a `smart' way of doing this,
+    dnl but all have failed.  Before changing the following ugly definitions,
+    dnl consult the veterans of many a battle.
+    AC_DEFINE_UNQUOTED(ATHENA_Scrollbar_h_,"$athena_h_path/Scrollbar.h")
+    AC_DEFINE_UNQUOTED(ATHENA_Dialog_h_,"$athena_h_path/Dialog.h")
+    AC_DEFINE_UNQUOTED(ATHENA_Form_h_,"$athena_h_path/Form.h")
+    AC_DEFINE_UNQUOTED(ATHENA_Command_h_,"$athena_h_path/Command.h")
+    AC_DEFINE_UNQUOTED(ATHENA_Label_h_,"$athena_h_path/Label.h")
+    AC_DEFINE_UNQUOTED(ATHENA_LabelP_h_,"$athena_h_path/LabelP.h")
+    AC_DEFINE_UNQUOTED(ATHENA_Toggle_h_,"$athena_h_path/Toggle.h")
+    AC_DEFINE_UNQUOTED(ATHENA_ToggleP_h_,"$athena_h_path/ToggleP.h")
+    AC_DEFINE_UNQUOTED(ATHENA_AsciiText_h_,"$athena_h_path/AsciiText.h")
+    AC_DEFINE_UNQUOTED(ATHENA_XawInit_h_,"$athena_h_path/XawInit.h")
 
     AC_DEFINE(LWLIB_USES_ATHENA)
     AC_DEFINE(NEED_ATHENA)
+    need_athena="yes"
 
     if test "$athena_3d" = "yes"; then
       AC_DEFINE(HAVE_ATHENA_3D)
@@ -3820,6 +3803,14 @@
     done
   fi
 
+  dnl Win32 Native uses native sound
+  if test -z "$sound_found"; then
+    if test "$with_msw" = "yes"; then
+    sound_found=yes
+    native_sound_lib=
+    fi
+  fi
+
   test "$sound_found" = "yes" && with_native_sound=yes
 fi
 
@@ -4067,20 +4058,25 @@
 if test "$with_modules" != "no"; then
   AC_CHECKING(for module support)
 
-  dnl Find headers and libraries
-  AC_CHECK_HEADER(dlfcn.h, [
-    AC_CHECK_LIB(dl, dlopen, [ have_dl=yes libdl=dl], [
-    AC_CHECK_LIB(c,  dlopen, [ have_dl=yes ])])])
-  if test -n "$have_dl"; then
-    AC_DEFINE(HAVE_DLOPEN)
+  dnl Check for MS-Windows
+  if test "$with_msw" = "yes"; then
+    have_dl=yes;
   else
-    AC_CHECK_LIB(dld, shl_load, [
-      libdl=dld have_dl=yes;
-      AC_DEFINE(HAVE_SHL_LOAD)], [
-    AC_CHECK_LIB(dld, dld_init, [
-      libdl=dld have_dl=yes;
-      AC_DEFINE(HAVE_DLD_INIT)])])
-  fi
+    dnl Find headers and libraries
+    AC_CHECK_HEADER(dlfcn.h, [
+      AC_CHECK_LIB(dl, dlopen, [ have_dl=yes libdl=dl], [
+      AC_CHECK_LIB(c,  dlopen, [ have_dl=yes ])])])
+    if test -n "$have_dl"; then
+      AC_DEFINE(HAVE_DLOPEN)
+    else
+      AC_CHECK_LIB(dld, shl_load, [
+        libdl=dld have_dl=yes;
+        AC_DEFINE(HAVE_SHL_LOAD)], [
+        AC_CHECK_LIB(dld, dld_init, [
+        libdl=dld have_dl=yes;
+        AC_DEFINE(HAVE_DLD_INIT)])])
+    fi
+  fi dnl end !MS-Windows
 
   if test -n "$have_dl"; then
     dnl XE_SHLIB_STUFF (in aclocal.m4) defines $can_build_shared
@@ -4537,7 +4533,7 @@
     echo "    - Handling WM_COMMAND properly."
   fi
 fi
-if test "$have_xaw" = "yes"; then
+if test "$need_athena" = "yes"; then
   echo "  Compiling in support for the Athena widget set:"
   echo "    - Athena headers location:                    $athena_h_path"
   echo "    - Athena library to link:                     $athena_lib"
@@ -4630,12 +4626,8 @@
 test "$with_ldap" = yes && echo "  Compiling in support for LDAP."
 if test "$with_postgresql" = yes; then
   echo "  Compiling in support for PostgreSQL."
-  if test "$with_postgresqlv7" = yes; then
-    echo "    - Using PostgreSQL V7 bindings."
-  fi
-  if test -n "$postgres_h_path"; then
-    echo "    - PostgreSQL headers location:  $postgres_h_path"
-  fi
+  echo "    - Using PostgreSQL header file:  $libpq_fe_h_file"
+  test "$with_postgresqlv7" = yes && echo "    - Using PostgreSQL V7 bindings."
 fi
 
 echo "
@@ -4658,7 +4650,7 @@
 test "$with_pop" = yes && echo "  Compiling in support for POP mail retrieval."
 test "$with_kerberos" = yes && echo "  Compiling in support for Kerberos POP authentication."
 test "$with_hesiod" = yes && echo "  Compiling in support for Hesiod POP server access."
-echo "  Compiling in support for \"$mail_locking\" mail spool file locking method."
+test -n "$mail_locking" && echo "  Compiling in support for \"$mail_locking\" mail spool file locking method."
 
 echo "
 Other Features:"
--- a/configure.usage	Mon Aug 13 11:18:12 2007 +0200
+++ b/configure.usage	Mon Aug 13 11:19:21 2007 +0200
@@ -9,34 +9,40 @@
 
 Options marked with a (*) are auto-detected.
 
+Many features require external packages to be installed first.
+Get them from ftp://ftp.xemacs.org/pub/xemacs/aux.
+
 Use colons (or quoted spaces) to separate directory names in option
 values which are PATHs (i.e. lists of directories).
 
+The results of configure tests are saved in config.log, which is useful
+for diagnosing problems.
+
+
 General options:
 
 --help                  Issue this usage message.
---verbose               Display the results of configure tests.
---extra-verbose         Display even more information, useful for debugging.
+--verbose               Accepted but ignored.
+--extra-verbose         Display more information, useful for debugging.
 
 
 Compilation options:
 
---compiler=prog         C compiler to use.
+--compiler=PROG         C compiler to use
 --with-gcc (*)          Use GCC to compile XEmacs.
---without-gcc           Don't use GCC to compile XEmacs.
 --cflags=FLAGS          Compiler flags (such as -O)
---cpp=prog              C preprocessor to use (e.g. /usr/ccs/lib/cpp or cc -E)
+--cpp=PROG              C preprocessor to use (e.g. /usr/ccs/lib/cpp or cc -E)
 --cppflags=FLAGS        C preprocessor flags (e.g. -I/foo or -Dfoo=bar)
 --libs=LIBS             Additional libraries (e.g. -lfoo)
 --ldflags=FLAGS         Additional linker flags (e.g. -L/foo)
---site-includes=PATH    List of directories to search first for header files.
---site-libraries=PATH   List of directories to search first for libraries.
+--site-includes=PATH    List of directories to search first for header files
+--site-libraries=PATH   List of directories to search first for libraries
 --site-prefixes=PATH    List of directories to search for include/ and lib/
                         subdirectories, just after 'site-includes' and
-                        'site-libraries'.
+                        'site-libraries'
 --site-runtime-libraries=PATH
                         List of ALL directories to search for dynamically
-                        linked libraries at run time.
+                        linked libraries at run time
 --dynamic=yes           Link dynamically if supported by system.
 --dynamic=no            Force static linking on systems where dynamic
                         linking is the default.
@@ -47,19 +53,19 @@
 Installation options:
 
 --prefix=DIR            Install files below DIR.  Defaults to `/usr/local'.
---with-prefix		Compile the value of --prefix into the executable.
-                        Defaults to `yes'.
---without-prefix        Don't compile the value of --prefix into the executable.
+--with-prefix=no        Don't compile the value of --prefix into the
+                        executable.
 
 
 Window-system options:
 
 --with-x11 (*)          Support the X Window System.
---without-x11           Don't support X.
 --x-includes=DIR        Search for X header files in DIR.
 --x-libraries=DIR       Search for X libraries in DIR.
---without-toolbars      Don't compile with any toolbar support.
---without-wmcommand     Compile without realized leader window which will
+--with-msw (*)          Support MS Windows as a window system (only under
+                        Cygwin and MinGW).
+--with-toolbars=no      Don't compile with any toolbar support.
+--with-wmcommand=no     Compile without realized leader window which will
                         keep the WM_COMMAND property.
 --with-athena=TYPE      Use TYPE Athena widgets
                         (xaw, 3d, next, 95, or xpm)
@@ -74,59 +80,59 @@
 --with-widgets=TYPE     Use TYPE widgets (motif, athena, or no).
                         Motif widgets will be used if Motif can be found.
                         Other widget types are currently unsupported.
---with-dragndrop (*)    Compile in the generic drag and drop API. This is
+--with-dragndrop        Compile in the generic drag and drop API. This is
                         automatically added if one of the drag and drop
                         protocols is found (currently CDE, OffiX, MSWindows).
                         *WARNING*  The Drag'n'drop support is under development
                                    and is considered experimental.
---with-cde (*)          Compile in support for CDE drag and drop.
---with-offix (*)        Compile in support for OffiX drag and drop.
+--with-cde              Compile in support for CDE drag and drop.
+--with-offix            Compile in support for OffiX drag and drop.
                         *WARNING*  If you compile in OffiX, you may not be
                                    able to use multiple X displays success-
                                    fully.  If the two servers are from
                                    different vendors, the results may be
                                    unpredictable.
---without-xmu (*)       For those unfortunates whose vendors don't ship Xmu.
+--with-xmu=no (*)       For those unfortunates whose vendors don't ship Xmu.
 --external-widget       Compile with external widget support.
 
 
-TTY options:
+TTY (character terminal) options:
 
---without-tty           Don't support TTY-s.
+--with-tty=no           Don't support ttys.
 --with-ncurses (*)      Use the ncurses library for tty support.
---with-gpm (*)          Compile in support for General Purpose Mouse.
+--with-gpm (*)          Compile in GPM mouse support for ttys.
 
 
 Image options:
 
---with-xpm (*)          Compile with support for XPM files.
-                        It is highly recommended that you obtain XPM
-                        (version 3.4h or better) if you don't already
-                        have it.  Get it from the XEmacs FTP site.
---with-xface (*)        Compile with support for X-Face mail header
-                        conversion.  Requires the compface library.
-                        Get it from the XEmacs FTP site.
---without-gif           Compile without the built-in support for GIF image
-                        conversion.
---with-jpeg (*)         Compile with support for JPEG image conversion.
-                        Requires libjpeg from the Independent JPEG Group.
-                        Get it from the XEmacs FTP site.
---with-png (*)          Compile with support for PNG image conversion.
-                        Requires libpng.  Get it from the XEmacs FTP site.
---with-tiff (*)         Compile with support for TIFF image conversion.
-                        Requires Sam Lefflier's libtiff library.
-                        Get if from the XEmacs FTP site.
+--with-xpm (*)          Compile with support for XPM images.  PRACTICALLY
+                        REQUIRED.  Although this library is nonstandard and
+                        a real hassle to build, many basic things (e.g.
+                        toolbars) depend on it, and you will run into
+                        many problems without it.
+--with-png (*)          Compile with support for PNG images.  Recommended
+                        because the images on the About page are not viewable
+                        without it.
+--with-jpeg (*)         Compile with support for JPEG images.  Useful if
+                        you are using a mail, news reader, or web browser
+                        in XEmacs, so that JPEG images can be displayed.
+--with-tiff (*)         Compile with support for TIFF images.  Possibly
+                        useful, for the same reason as JPEG images.
+--with-xface (*)        Compile with support for X-Face mail headers.
+                        Requires the compface package.  Of doubtful
+                        usefulness.
+--with-gif=no           Compile without the (builtin) support for GIF images.
 
 
 Sound options:
 
 --with-sound=TYPE,[TYPE],... Compile with native sound support.
-			Valid types are `native', `nas' and `esd'.
-			Prefix a type with 'no' to disable.
-			The first option can be `none' or `all'.
-			`none' is a synonym for `nonative,nonas,noesd'.
-			`all' is a synonym for native,nas,esd or `all'.
-			The default is to autodetect all sound support.
+                        Valid types are `native', `nas' and `esd'.
+                        Prefix a type with 'no' to disable.
+                        The first option can be `none' or `all'.
+                        `none' is a synonym for `nonative,nonas,noesd'.
+                        `all' is a synonym for native,nas,esd or `all'.
+                        The default is to autodetect all sound support.
 --native-sound-lib=LIB  Native sound support library.  Needed on Suns
                         with --with-sound=both because both sound libraries
                         are called libaudio.
@@ -137,10 +143,8 @@
 --with-database=TYPE (*) Compile with database support.  Valid types are
                         `no' or a comma-separated list of one or more
                         of `berkdb' and either `dbm' or `gnudbm'.
---with-ldap (*)         Compile with support for the LDAP protocol (requires
-                        installed LDAP libraries on the system).
---with-postgresql (*)	Compile with support for the PostgreSQL RDBMS (requires
-			installed PostreSQL libraries on the system).
+--with-ldap (*)         Compile with support for the LDAP protocol.
+--with-postgresql (*)   Compile with support for the PostgreSQL RDBMS.
 
 
 Mail options:
@@ -148,9 +152,9 @@
 --mail-locking=TYPE (*) Specify the locking to be used by movemail to prevent
                         concurrent updates of mail spool files. Valid types
                         are `lockf', `flock', and `dot'.
---with-pop              support POP for mail retrieval
---with-kerberos         support Kerberos-authenticated POP
---with-hesiod           support Hesiod to get the POP server host
+--with-pop              Support POP for mail retrieval.
+--with-kerberos         Support Kerberos-authenticated POP.
+--with-hesiod           Support Hesiod to get the POP server host.
 
 
 Additional features:
@@ -160,8 +164,8 @@
                         development environment.
 --with-socks            Compile with support for SOCKS (an Internet proxy).
 --with-dnet (*)         Compile with support for DECnet.
---with-modules		Compile in experimental support for dynamically
-			loaded libraries (Dynamic Shared Objects).
+--with-modules          Compile in experimental support for dynamically
+                        loaded libraries (Dynamic Shared Objects).
 --with-site-lisp=yes    Allow for a site-lisp directory in the XEmacs hierarchy
                         searched before the installation packages.
 --with-site-modules=no  Disable site-modules directory in the XEmacs hierarchy,
@@ -183,9 +187,9 @@
                         and localdir files in case run-time searching
                         for them fails.
 --moduledir=DIR         Directory to install dynamic modules in.
---pdump			New, experimental, non-working, don't-sue-me-if-
-			your-house-collapses-and-your-wife-goes-away,
-			portable dumper.
+--pdump                 New, experimental, non-working, don't-sue-me-if-
+                        your-house-collapses-and-your-wife-leaves-you,
+                        portable dumper.
 
 Internationalization options:
 
@@ -204,8 +208,7 @@
                         used in conjunction with Mule support).
 --with-wnn (*)          Compile with support for WNN (a multi-language input
                         method used in conjunction with Mule support).
---with-wnn6 (*)         Compile with support for the comercial package WNN
-                        version 6
+--with-wnn6 (*)         Compile with support for the commercial package WNN6.
 --with-i18n3            Compile with I18N level 3 (support for message
                         translation).  This doesn't currently work.
 --with-xfs              Compile with XFontSet support for bilingual menubar.
@@ -263,17 +266,18 @@
 unsuccessful after disturbing the status quo, it removes config.status.
 
 The configure script also recognizes some environment variables, each
-of which is equivalent to a corresponding configure flag.  A specified
-configure flag always overrides the environment variable.
+of which is equivalent to a corresponding configure flag.  Configure
+flags take precedence over environment variables, if both are specified.
 
-envvar      configure flag
------       --------------
-CC          --compiler
-CPP         --cpp
-CFLAGS      --cflags
-CPPFLAGS    --cppflags
-LDFLAGS     --ldflags
-LIBS        --libs
-LD_RUN_PATH --site-runtime-libraries
+environment   corresponding
+variable      configure flag
+-----------   --------------
+CC            --compiler
+CPP           --cpp
+CFLAGS        --cflags
+CPPFLAGS      --cppflags
+LDFLAGS       --ldflags
+LIBS          --libs
+LD_RUN_PATH   --site-runtime-libraries
 
 For more details on the install process, consult the INSTALL file.
--- a/etc/NEWS	Mon Aug 13 11:18:12 2007 +0200
+++ b/etc/NEWS	Mon Aug 13 11:19:21 2007 +0200
@@ -205,22 +205,42 @@
 binary kit, set the `mail-lock-method' variable at startup, or the
 EMACSLOCKMETHOD environment variable.
 
+** Init file will move to ~/.xemacs/init.el.
+
+If `~/.xemacs/init.el' exists, XEmacs will prefer it over `~/.emacs'
+as an init file.  The file may be byte-compiled as
+`~/.xemacs/init.elc'.
+
+Future versions of XEmacs will stop supporting `~/.emacs' as an init
+file.  XEmacs offers automatic migration upon startup.
+
+** Custom file will move to ~/.xemacs/custom.el.
+
+Whereas customize settings were formerly stored in the regular init
+file, XEmacs now prefers them to be in a separate file
+`~/.xemacs/custom.el', completely under automatic control.  This
+change goes with the migration of the init file, and XEmacs offers
+automatic migration upon startup.
+
+** Init file may be called .emacs.el.
+
+For the time being, like in GNU Emacs 20.4 and on, you can now name
+the XEmacs init file `.emacs.el'.  Formerly the name had to be
+`.emacs'.  If you use the name `.emacs.el', you can byte-compile the
+file in the usual way.
+
+If both `.emacs' and `.emacs.el' exist, the latter file is the one
+that is used.
+
 ** New command-line switches -user-init-file and -user-init-directory.
 These can be used to specify alternate locations for what is normally
 ~/.emacs and ~/.xemacs.
 
 Moreover, -user <user> (which used to only work in unpredictable ways)
-is now equivalent to
--user-init-file ~<user>/.emacs -user-init-directory ~<user>/.xemacs.
-
-** Init file may be called .emacs.el.
-
-Like in GNU Emacs 20.4 and on, you can now name the XEmacs init file
-`.emacs.el'.  Formerly the name had to be `.emacs'.  If you use the
-name `.emacs.el', you can byte-compile the file in the usual way.
-
-If both `.emacs' and `.emacs.el' exist, the latter file is the one
-that is used.
+is now equivalent to -user-init-file ~<user>/.xemacs/init.el
+-user-init-directory ~<user>/.xemacs.  or -user-init-file
+~<user>/.emacs -user-init-directory ~<user>/.xemacs, whichever init
+file comes first.
 
 ** New variable `mswindows-meta-activates-menu'.
 If you set this variable to nil then pressing and releasing the Alt
--- a/lib-src/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,100 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-12  Martin Buchholz  <martin@xemacs.org>
+
+	* gnuserv.c:
+	(handle_internet_request): 
+	(handle_unix_request): 
+	(internet_init): 
+	Use socklen_t instead of int or size_t.
+
+2000-07-11  Martin Buchholz  <martin@xemacs.org>
+
+	* hexl.c (usage): Use full ANSI C prototypes.
+
+2000-07-05  Craig Lanning  <lanning@scra.org>
+
+	* Makefile.in.in (INSTALL_DATA):
+	* Makefile.in.in (UTILITIES):
+	* Makefile.in.in (GETOPTDEPS):
+	* Makefile.in.in (i):
+	mingw support: don't try to build gnuclient, add
+        support for building and installing minitar
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* Makefile.in.in (INSTALLABLES_BASE):
+	* Makefile.in.in (ootags_args):
+	* Makefile.in.in (yow):
+	Build i.exe.
+	Don't build run*.exe.
+	
+	* b2m.c:
+	* b2m.c (main):
+	* ellcc.c (main):
+	* etags.c:
+	* etags.c (main):
+	* etags.c (get_compressor_from_suffix):
+	* etags.c (process_file):
+	* etags.c (readline_internal):
+	* etags.c (etags_getcwd):
+	* etags.c (relative_filename):
+	* etags.c (absolute_filename):
+	* etags.c (filename_is_absolute):
+	* etags.c (canonicalize_filename):
+	* fakemail.c:
+	* fakemail.c (make_file_preface):
+	* getopt.c:
+	* getopt.h:
+	* gnuclient.c:
+	* gnuclient.c (filename_expand):
+	* gnuserv.h:
+	* gnuserv.h (PATCHLEVEL):
+	* hexl.c:
+	* hexl.c (main):
+	* make-docfile.c:
+	* make-docfile.c (APPEND_BINARY):
+	* make-docfile.c (main):
+	* make-dump-id.c:
+	* mmencode.c:
+	* mmencode.c (fromqp):
+	* mmencode.c (main):
+	* movemail.c:
+	* movemail.c (main):
+	* movemail.c (popmail):
+	* ootags.c:
+	* ootags.c (main):
+	* ootags.c (readline_internal):
+	* ootags.c (etags_getcwd):
+	* ootags.c (absolute_filename):
+	* ootags.c (filename_is_absolute):
+	* ootags.c (canonicalize_filename):
+	* pop.c:
+	* pop.c (DONT_ENCAPSULATE):
+	* pop.c (pop_open):
+	* pop.c (socket_connection):
+	* pop.c (pop_trash):
+	* profile.c (gettimeofday):
+	* wakeup.c:
+	* yow.c (rootrelativepath):
+	Remove MSDOS support, converting to WIN32_NATIVE where necessary.
+	WINDOWSNT -> WIN32_NATIVE.
+	__CYGWIN32__ -> CYGWIN.
+	DOS_NT -> WIN32_NATIVE.
+	Remove unused NO_SHORTNAMES.
+	Changes for removed nt\inc.
+
+2000-06-07  Ben Wing  <ben@xemacs.org>
+
+	* run.c, run.h, run.rc: Removed.  We no longer need these for
+	building runxemacs.exe, and it's questionable at best whether
+	rungnuclient.exe was ever used or is even needed.  The correct
+	solution is just to make gnuclient.exe a windows program and
+	use the gnuattach script to run 'i gnuclient.exe'.  Not that
+	gnuclient currently works under Windows native in any case.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/lib-src/Makefile.in.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/Makefile.in.in	Mon Aug 13 11:19:21 2007 +0200
@@ -75,33 +75,25 @@
 
 ## Things that a user might actually run,
 ## which should be installed in bindir.
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 INSTALLABLES_BASE = etags ctags b2m ootags
 #else
 INSTALLABLES_BASE = etags ctags b2m gnuclient ootags
 #endif
 INSTALLABLE_SCRIPTS = rcs-checkin gnudoit gnuattach
 #ifdef HAVE_SHLIB
-#ifdef HAVE_MS_WINDOWS
-INSTALLABLES = $(INSTALLABLES_BASE) runxemacs rungnuclient ellcc
-#else
 INSTALLABLES = $(INSTALLABLES_BASE) ellcc
-#endif
-#else
-#ifdef HAVE_MS_WINDOWS
-INSTALLABLES = $(INSTALLABLES_BASE) runxemacs rungnuclient
 #else
 INSTALLABLES = $(INSTALLABLES_BASE)
 #endif
-#endif
 
 
 ## Things that Emacs runs internally, or during the build process,
 ## which should not be installed in bindir.
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 UTILITIES= make-path wakeup profile make-docfile digest-doc \
-	sorted-doc movemail cvtmail yow hexl \
-	mmencode
+	sorted-doc movemail cvtmail yow i hexl \
+	mmencode minitar
 #else
 UTILITIES= make-path wakeup profile make-docfile digest-doc \
 	sorted-doc movemail cvtmail fakemail yow hexl \
@@ -290,7 +282,7 @@
 
 regex.o: ${srcdir}/../src/regex.c ${top_srcdir}/src/regex.h
 	$(CC) -c `echo $(cflags) | sed 's/-Demacs/ /'` \
-		-DINHIBIT_STRING_HEADER ${top_srcdir}/src/regex.c
+	-DINHIBIT_STRING_HEADER ${top_srcdir}/src/regex.c
 
 etags_args = $(cflags) -DVERSION='"${version}"' ${srcdir}/etags.c \
 	$(GETOPTOBJS) regex.o $(ldflags)
@@ -305,23 +297,6 @@
 ellcc: ${ellcc_deps}
 	$(CC) ${ellcc_args} -o $@
 
-run_args = $(cflags) -DVERSION='"${version}"' ${srcdir}/run.c \
-	$(ldflags) -Wl,--subsystem,windows -e _mainCRTStartup
-run_deps = ${srcdir}/run.c ${srcdir}/run.h ${srcdir}/run.rc \
-	${srcdir}/../nt/xemacs.ico ${srcdir}/../nt/file.ico \
-	${srcdir}/../nt/lisp.ico
-
-run: ${run_deps}
-	windres --include-dir ${srcdir}/../nt -i run.rc -o run_res.o
-	$(CC) run_res.o ${run_args} -o $@
-	strip $@.exe
-
-runxemacs: run
-	cp run.exe $@.exe
-
-rungnuclient: run
-	cp run.exe $@.exe
-
 ootags_args = $(cflags) -DVERSION='"${version}"' ${srcdir}/ootags.c \
 	$(GETOPTOBJS) regex.o $(ldflags)
 ootags_deps = ${srcdir}/ootags.c $(GETOPTDEPS) regex.o ../src/config.h
@@ -366,6 +341,12 @@
 yow: ${srcdir}/yow.c ../src/paths.h
 	$(CC) $(cflags) ${srcdir}/yow.c $(ldflags) -o $@
 
+i: ${srcdir}/i.c
+	$(CC) $(cflags) ${srcdir}/i.c $(ldflags) -o $@
+
+minitar: ${srcdir}/../nt/minitar.c
+	$(CC) $(cflags) ${srcdir}/../nt/minitar.c $(ldflags) -lz -o $@
+
 hexl: ${srcdir}/hexl.c
 	$(CC) $(cflags) ${srcdir}/hexl.c $(ldflags) -o $@
 
--- a/lib-src/b2m.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/b2m.c	Mon Aug 13 11:19:21 2007 +0200
@@ -30,7 +30,7 @@
 #include <string.h>
 #include <time.h>
 #include <sys/types.h>
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
 #include <fcntl.h>
 #endif
 
@@ -88,17 +88,12 @@
   char *labels = NULL, *p, *today;
   struct linebuffer data;
 
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
   _fmode = O_BINARY;		/* all of files are treated as binary files */
-#if __DJGPP__ > 1
   if (!isatty (fileno (stdout)))
     setmode (fileno (stdout), O_BINARY);
   if (!isatty (fileno (stdin)))
     setmode (fileno (stdin), O_BINARY);
-#else /* not __DJGPP__ > 1 */
-  (stdout)->_flag &= ~_IOTEXT;
-  (stdin)->_flag &= ~_IOTEXT;
-#endif /* not __DJGPP__ > 1 */
 #endif
   progname = argv[0];
 
--- a/lib-src/ellcc.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/ellcc.c	Mon Aug 13 11:19:21 2007 +0200
@@ -149,7 +149,7 @@
   prog_argc = argc;
   prog_argv = argv;
 
-#if defined(MSDOS) || defined(WINDOWSNT)
+#if defined(WIN32_NATIVE)
   tmp = strrchr (argv[0], '\\');
   if (tmp != (char *)0)
     tmp++;
--- a/lib-src/etags.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/etags.c	Mon Aug 13 11:19:21 2007 +0200
@@ -59,48 +59,29 @@
 # define _GNU_SOURCE 1		/* enables some compiler checks on GNU */
 #endif
 
-#ifdef MSDOS
-# undef MSDOS
-# define MSDOS TRUE
-# include <fcntl.h>
-# include <sys/param.h>
-# include <io.h>
-# ifndef HAVE_CONFIG_H
-#   define DOS_NT
-#   include <sys/config.h>
-# endif
-#else
-# define MSDOS FALSE
-#endif /* MSDOS */
-
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 # include <stdlib.h>
 # include <fcntl.h>
 # include <string.h>
 # include <direct.h>
 # include <io.h>
 # define MAXPATHLEN _MAX_PATH
-# ifdef HAVE_CONFIG_H
-#   undef HAVE_NTGUI
-# else
-#   define DOS_NT
-# endif /* not HAVE_CONFIG_H */
 # ifndef HAVE_GETCWD
 #   define HAVE_GETCWD
 # endif /* undef HAVE_GETCWD */
-#else /* !WINDOWSNT */
+#else /* !WIN32_NATIVE */
 # ifdef STDC_HEADERS
 #  include <stdlib.h>
 #  include <string.h>
 # else
     extern char *getenv ();
 # endif
-#endif /* !WINDOWSNT */
+#endif /* !WIN32_NATIVE */
 
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #else
-# if defined (HAVE_GETCWD) && !WINDOWSNT
+# if defined (HAVE_GETCWD) && !defined (WIN32_NATIVE)
     extern char *getcwd (char *buf, size_t size);
 # endif
 #endif /* HAVE_UNISTD_H */
@@ -889,9 +870,9 @@
   bool got_err;
 #endif
 
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   _fmode = O_BINARY;   /* all of files are treated as binary files */
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 
   progname = argv[0];
   nincluded_files = 0;
@@ -1075,12 +1056,12 @@
       if (streq (tagfile, "-"))
 	{
 	  tagf = stdout;
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	  /* Switch redirected `stdout' to binary mode (setting `_fmode'
 	     doesn't take effect until after `stdout' is already open). */
 	  if (!isatty (fileno (stdout)))
 	    setmode (fileno (stdout), O_BINARY);
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 	}
       else
 	tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
@@ -1210,7 +1191,7 @@
   char *slash, *suffix;
 
   /* This relies on FN to be after canonicalize_filename,
-     so we don't need to consider backslashes on DOS_NT.  */
+     so we don't need to consider backslashes on WIN32_NATIVE.  */
   slash = etags_strrchr (file, '/');
   suffix = etags_strrchr (file, '.');
   if (suffix == NULL || suffix < slash)
@@ -1220,13 +1201,13 @@
   suffix += 1;
   /* Let those poor souls who live with DOS 8+3 file name limits get
      some solace by treating foo.cgz as if it were foo.c.gz, etc.
-     Only the first do loop is run if not MSDOS */
+ */
   do
     {
       for (compr = compressors; compr->suffix != NULL; compr++)
 	if (streq (compr->suffix, suffix))
 	  return compr;
-      if (!MSDOS)
+      if (1) /* !MSDOS */
 	break;			/* do it only once: not really a loop */
       if (extptr != NULL)
 	*extptr = ++suffix;
@@ -1373,22 +1354,7 @@
 	      compressed_name = concat (file, ".", compr->suffix);
 	      if (stat (compressed_name, &stat_buf) != 0)
 		{
-		  if (MSDOS)
-		    {
-		      char *suf = compressed_name + strlen (file);
-		      size_t suflen = strlen (compr->suffix) + 1;
-		      for ( ; suf[1]; suf++, suflen--)
-			{
-			  memmove (suf, suf + 1, suflen);
-			  if (stat (compressed_name, &stat_buf) == 0)
-			    {
-			      real_name = compressed_name;
-			      break;
-			    }
-			}
-		      if (real_name != NULL)
-			break;
-		    } /* MSDOS */
+		  /* XEmacs: delete MSDOS code */
 		  free (compressed_name);
 		  compressed_name = NULL;
 		}
@@ -5031,7 +4997,7 @@
 	  if (p > buffer && p[-1] == '\r')
 	    {
 	      p -= 1;
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	     /* Assume CRLF->LF translation will be performed by Emacs
 		when loading this file, so CRs won't appear in the buffer.
 		It would be cleaner to compensate within Emacs;
@@ -5287,19 +5253,6 @@
   return path;
 
 #else /* not HAVE_GETCWD */
-#ifdef MSDOS
-  char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS.  */
-
-  getwd (path);
-
-  for (p = path; *p != '\0'; p++)
-    if (*p == '\\')
-      *p = '/';
-    else
-      *p = lowcase (*p);
-
-  return strdup (path);
-#else /* not MSDOS */
   linebuffer path;
   FILE *pipe;
 
@@ -5310,7 +5263,6 @@
   pclose (pipe);
 
   return path.buffer;
-#endif /* not MSDOS */
 #endif /* not HAVE_GETCWD */
 }
 
@@ -5330,7 +5282,7 @@
   while (*fp++ == *dp++)
     continue;
   fp--, dp--;			/* back to the first differing char */
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   if (fp == afn && afn[0] != '/') /* cannot build a relative name */
     return afn;
 #endif
@@ -5364,7 +5316,7 @@
 
   if (filename_is_absolute (file))
     res = savestr (file);
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   /* We don't support non-absolute file names with a drive
      letter, like `d:NAME' (it's too much hassle).  */
   else if (file[1] == ':')
@@ -5388,8 +5340,8 @@
 	      while (cp >= res && !filename_is_absolute (cp));
 	      if (cp < res)
 		cp = slashp;	/* the absolute name begins with "/.." */
-#ifdef DOS_NT
-	      /* Under MSDOS and NT we get `d:/NAME' as absolute
+#ifdef WIN32_NATIVE
+	      /* Under Windows we get `d:/NAME' as absolute
 		 file name, so the luser could say `d:/../NAME'.
 		 We silently treat this as `d:/NAME'.  */
 	      else if (cp[0] != '/')
@@ -5444,7 +5396,7 @@
      char *fn;
 {
   return (fn[0] == '/'
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	  || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
 #endif
 	  );
@@ -5455,7 +5407,7 @@
 canonicalize_filename (fn)
      register char *fn;
 {
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   /* Canonicalize drive letter case.  */
   if (islower (fn[0]) && fn[1] == ':')
     fn[0] = toupper (fn[0]);
--- a/lib-src/fakemail.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/fakemail.c	Mon Aug 13 11:19:21 2007 +0200
@@ -46,14 +46,6 @@
   return 1;
 }
 #else /* not BSD 4.2 (or newer) */
-#ifdef MSDOS
-int
-main (int argc, char *argv[])
-{
-  return 0;
-}
-#else /* not MSDOS */
-/* This conditional contains all the rest of the file.  */
 
 /* These are defined in config in some versions. */
 
@@ -322,7 +314,7 @@
   /* the_date has an unwanted newline at the end */
   date_length = strlen (the_date) - 1;
   the_date[date_length] = '\0';
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   temp = "(null)";
 #else
   temp = cuserid ((char *) NULL);
@@ -673,5 +665,4 @@
   return close_the_streams ();
 }
 
-#endif /* not MSDOS */
 #endif /* not BSD 4.2 (or newer) */
--- a/lib-src/getopt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/getopt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -73,7 +73,7 @@
 #endif
 #endif
 
-#if defined (WIN32) && !defined (__CYGWIN32__)
+#if defined (WIN32_NATIVE) && !defined (CYGWIN)
 /* It's not Unix, really.  See?  Capital letters.  */
 #include <windows.h>
 #undef getpid
--- a/lib-src/getopt.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/getopt.h	Mon Aug 13 11:19:21 2007 +0200
@@ -98,7 +98,7 @@
 #define required_argument	1
 #define optional_argument	2
 
-#if defined (__GNU_LIBRARY__) || defined (__cplusplus)
+#if defined (__GNU_LIBRARY__) || defined (__cplusplus) || defined (CYGWIN)
 /* Many other libraries have conflicting prototypes for getopt, with
    differences in the consts, in stdlib.h.  To avoid compilation
    errors, only prototype getopt for the GNU C library.  */
--- a/lib-src/gnuclient.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/gnuclient.c	Mon Aug 13 11:19:21 2007 +0200
@@ -27,6 +27,17 @@
  Please mail bugs and suggestions to the XEmacs maintainer.
 */
 
+/* #### This file should be a windows-mode, not console-mode program under
+   Windows. (i.e. its entry point should be WinMain.) gnuattach functionality,
+   to the extent it's used at all, should be retrieved using a script that
+   calls the i.exe wrapper program, to obtain stdio handles.
+
+   #### For that matter, both the functionality of gnuclient and gnuserv
+   should be merged into XEmacs itself using a -remote arg, just like
+   Netscape and other modern programs.
+
+   --ben */
+
 /*
  * This file incorporates new features added by Bob Weiner <weiner@mot.com>,
  * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
@@ -48,7 +59,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#define DONT_ENCAPSULATE
 #include <sysfile.h>
 
 #ifdef HAVE_STRING_H
@@ -190,7 +200,7 @@
        /* Absolute (unix-style) pathname.  Do nothing */
        strcat (fullpath, filename);
      }
-#ifdef  __CYGWIN32__
+#ifdef  CYGWIN
   else if (filename[0] && filename[0] == '\\' &&
            filename[1] && filename[1] == '\\')
     {
--- a/lib-src/gnuserv.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/gnuserv.c	Mon Aug 13 11:19:21 2007 +0200
@@ -15,8 +15,8 @@
  Please mail bugs and suggestions to the author at the above address.
 */
 
-/* HISTORY 
- * 11-Nov-1990		bristor@simba	
+/* HISTORY
+ * 11-Nov-1990		bristor@simba
  *    Added EOT stuff.
  */
 
@@ -84,7 +84,7 @@
 ipc_exit (int stat)
 {
   msgctl (ipc_qid,IPC_RMID,0);
-  
+
   if  (ipc_wpid != 0)
     kill (ipc_wpid, SIGKILL);
 
@@ -102,7 +102,7 @@
 } /* ipc_handle_signal */
 
 
-/* 
+/*
   ipc_spawn_watchdog -- spawn a watchdog task to clean up the message queue should the
 			server process die.
 */
@@ -190,7 +190,7 @@
   msgctl (ipc_qid, IPC_STAT, &msg_st);
   strncpy (buf, msgp->mtext, len);
   buf[len] = '\0';		/* terminate */
-  
+
   printf ("%d %s", ipc_qid, buf);
   fflush (stdout);
 
@@ -210,7 +210,7 @@
 
   /* read in "n/m:" (n=client fd, m=message length) */
 
-  while (offset < (GSERV_BUFSZ-1) && 
+  while (offset < (GSERV_BUFSZ-1) &&
 	 ((len = read (0, buf + offset, 1)) > 0) &&
 	 buf[offset] != ':')
     {
@@ -237,7 +237,7 @@
 	  exit (1);
 	}
 
-      /* Send this string off, but only if we have enough space */ 
+      /* Send this string off, but only if we have enough space */
 
       if (GSERV_BUFSZ > total)
 	{
@@ -291,7 +291,7 @@
   int len;
 
   printf("%d ",s);
-  
+
   /* read until we get a newline or no characters */
   while ((len = recv(s,buf,GSERV_BUFSZ-1,0)) > 0) {
     buf[len] = '\0';
@@ -309,7 +309,7 @@
     fprintf(stderr,"%s: unable to recv\n",progname);
     exit(1);
   } /* if */
-  
+
 } /* echo_request */
 
 
@@ -327,7 +327,7 @@
   int result_len;
 
   /* read in "n/m:" (n=client fd, m=message length) */
-  while (offset < GSERV_BUFSZ && 
+  while (offset < GSERV_BUFSZ &&
 	 ((len = read(0,buf+offset,1)) > 0) &&
 	 buf[offset] != ':') {
     offset += len;
@@ -338,7 +338,7 @@
     fprintf(stderr,"%s: unable to read\n",progname);
     exit(1);
   }
-      
+
   /* parse the response from emacs, getting client fd & result length */
   buf[offset] = '\0';
   sscanf(buf,"%d/%d", &s, &result_len);
@@ -371,7 +371,7 @@
   /* send the newline */
   buf[1] = '\0';
   send_string(s,buf);
-  close(s); 
+  close(s);
 
 } /* handle_response */
 #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
@@ -390,9 +390,9 @@
 # include <X11/Xauth.h>
 
 static Xauth *server_xauth = NULL;
-#endif 
+#endif
 
-static int 
+static int
 timed_read (int fd, char *buf, int max, int timeout, int one_line)
 {
   fd_set rmask;
@@ -400,13 +400,13 @@
   char c = 0;
   int nbytes = 0;
   int r;
-  
+
   tv.tv_sec = timeout;
   tv.tv_usec = 0;
 
   FD_ZERO(&rmask);
   FD_SET(fd, &rmask);
-  
+
   do
     {
       r = select(fd + 1, &rmask, NULL, NULL, &tv);
@@ -444,8 +444,8 @@
 
   return nbytes;
 }
-	
-	
+
+
 
 /*
   permitted -- return whether a given host is allowed to connect to the server.
@@ -456,7 +456,7 @@
   int key;
   struct entry *entry;
 
-  char auth_protocol[128]; 
+  char auth_protocol[128];
   char buf[1024];
   int  auth_data_len;
 
@@ -465,17 +465,17 @@
       /* we are checking permission on a real connection */
 
       /* Read auth protocol name */
-  
+
       if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0)
 	return FALSE;
 
       if (strcmp (auth_protocol, DEFAUTH_NAME) &&
 	  strcmp (auth_protocol, MCOOKIE_NAME))
 	{
-	  printf ("authentication protocol (%s) from client is invalid...\n", 
+	  printf ("authentication protocol (%s) from client is invalid...\n",
 		  auth_protocol);
 	  printf ("... Was the client an old version of gnuclient/gnudoit?\004\n");
-      
+
 	  return FALSE;
 	}
 
@@ -493,17 +493,17 @@
 
 	  if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len)
 	    return FALSE;
-      
+
 #ifdef AUTH_MAGIC_COOKIE
 	  if (server_xauth && server_xauth->data &&
 	      !memcmp(buf, server_xauth->data, auth_data_len))
 	    {
 	      return TRUE;
 	    }
-#else 
+#else
 	  printf ("client tried Xauth, but server is not compiled with Xauth\n");
 #endif
-      
+
       /*
        * auth failed, but allow this to fall through to the GNU_SECURE
        * protocol....
@@ -512,7 +512,7 @@
 	  printf ("Xauth authentication failed, trying GNU_SECURE auth...\004\n");
 
 	}
-    
+
       /* Other auth protocols go here, and should execute only if the
        * auth_protocol name matches.
        */
@@ -521,30 +521,30 @@
 
 
   /* Now, try the old GNU_SECURE stuff... */
-  
+
   /* First find the hash key */
   key = HASH(host_addr) % TABLE_SIZE;
-  
+
   /* Now check the chain for that hash key */
   for(entry=permitted_hosts[key]; entry != NULL; entry=entry->next)
-    if (host_addr == entry->host_addr) 
+    if (host_addr == entry->host_addr)
       return(TRUE);
-  
+
   return(FALSE);
 
 } /* permitted */
 
 
-/* 
+/*
   add_host -- add the given host to the list of permitted hosts, provided it isn't
               already there.
-*/	
+*/
 static void
 add_host (u_long host_addr)
 {
   int key;
   struct entry *new_entry;
-  
+
   if (!permitted(host_addr, -1))
     {
       if ((new_entry = (struct entry *) malloc(sizeof(struct entry))) == NULL) {
@@ -578,7 +578,7 @@
   char hostname[HOSTNAMSZ];
   u_int host_addr;
   int i, hosts=0;
-  
+
   /* Make sure every entry is null */
   for (i=0; i<TABLE_SIZE; i++)
     permitted_hosts[i] = NULL;
@@ -587,25 +587,25 @@
 
   if ((host_addr = internet_addr(hostname)) == -1)
     {
-      fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP", 
+      fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP",
 	      progname,hostname);
       exit(1);
     } /* if */
 
 #ifdef AUTH_MAGIC_COOKIE
-  
-  server_xauth = XauGetAuthByAddr (FamilyInternet, 
+
+  server_xauth = XauGetAuthByAddr (FamilyInternet,
 				   sizeof(host_addr), (char *)&host_addr,
-				   strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN, 
+				   strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN,
 				   strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
   hosts++;
 
 #endif /* AUTH_MAGIC_COOKIE */
-  
+
 
 #if 0 /* Don't even want to allow access from the local host by default */
   add_host(host_addr);					/* add local host */
-#endif 
+#endif
 
   if (((file_name = getenv("GNU_SECURE")) != NULL &&    /* security file  */
        (host_file = fopen(file_name,"r")) != NULL))	/* opened ok */
@@ -635,12 +635,12 @@
   struct sockaddr_in server;	/* for local socket address */
   char *ptr;			/* ptr to return from getenv */
 
-  if (setup_table() == 0) 
+  if (setup_table() == 0)
     return -1;
 
   /* clear out address structure */
-  memset((char *)&server,0,sizeof(struct sockaddr_in));
-  
+  memset (&server, '\0', sizeof (server));
+
   /* Set up address structure for the listen socket. */
   server.sin_family = AF_INET;
   server.sin_addr.s_addr = INADDR_ANY;
@@ -654,7 +654,7 @@
     server.sin_port = htons(DEFAULT_PORT+getuid());
   else
     server.sin_port = sp->s_port;
-  
+
   /* Create the listen socket. */
   if ((ls = socket (AF_INET,SOCK_STREAM, 0)) == -1)
     {
@@ -662,7 +662,7 @@
       fprintf(stderr,"%s: unable to create socket\n",progname);
       exit(1);
     } /* if */
-  
+
   /* Bind the listen address to the socket. */
   if (bind(ls,(struct sockaddr *) &server,sizeof(struct sockaddr_in)) == -1)
     {
@@ -672,7 +672,7 @@
     } /* if */
 
   /* Initiate the listen on the socket so remote users
-   * can connect. 
+   * can connect.
    */
   if (listen(ls,20) == -1)
     {
@@ -694,10 +694,10 @@
 handle_internet_request (int ls)
 {
   int s;
-  size_t addrlen = sizeof(struct sockaddr_in);
+  socklen_t addrlen = sizeof (struct sockaddr_in);
   struct sockaddr_in peer;	/* for peer socket address */
 
-  memset((char *)&peer,0,sizeof(struct sockaddr_in));
+  memset (&peer, '\0', sizeof (peer));
 
   if ((s = accept(ls,(struct sockaddr *)&peer, &addrlen)) == -1)
     {
@@ -705,7 +705,7 @@
       fprintf(stderr,"%s: unable to accept\n",progname);
       exit(1);
     } /* if */
-    
+
   /* Check that access is allowed - if not return crud to the client */
   if (!permitted(peer.sin_addr.s_addr, s))
     {
@@ -717,7 +717,7 @@
     } /* if */
 
   echo_request(s);
-  
+
 } /* handle_internet_request */
 #endif /* INTERNET_DOMAIN_SOCKETS */
 
@@ -732,7 +732,7 @@
 {
   int ls;			/* socket descriptor */
   struct sockaddr_un server; 	/* unix socket address */
-  int bindlen;
+  socklen_t bindlen;
 
   if ((ls = socket(AF_UNIX,SOCK_STREAM, 0)) < 0)
     {
@@ -772,7 +772,7 @@
 #else
   bindlen = strlen (server.sun_path) + sizeof (server.sun_family);
 #endif
- 
+
   if (bind(ls,(struct sockaddr *)&server,bindlen) < 0)
     {
       perror(progname);
@@ -791,7 +791,7 @@
   /* #### there are also better ways of dealing with this when
      sigvec() is present. */
 #if  defined (HAVE_SIGPROCMASK)
-  {						
+  {
   sigset_t _mask;
   sigemptyset (&_mask);
   sigaddset (&_mask, SIGPIPE);
@@ -814,7 +814,7 @@
 handle_unix_request (int ls)
 {
   int s;
-  size_t len = sizeof(struct sockaddr_un);
+  socklen_t len = sizeof (struct sockaddr_un);
   struct sockaddr_un server; 	/* for unix socket address */
 
   server.sun_family = AF_UNIX;
@@ -826,7 +826,7 @@
     } /* if */
 
   echo_request(s);
-  
+
 } /* handle_unix_request */
 #endif /* UNIX_DOMAIN_SOCKETS */
 
@@ -883,8 +883,8 @@
       FD_SET(uls, &rmask);
     if (ils >= 0)
       FD_SET(ils, &rmask);
-    
-    if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask, 
+
+    if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask,
 	       (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0)
       {
 	perror(progname);
--- a/lib-src/gnuserv.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/gnuserv.h	Mon Aug 13 11:19:21 2007 +0200
@@ -36,18 +36,13 @@
 
 #define USE_TMPDIR
 
-#define NO_SHORTNAMES
-
 #define PATCHLEVEL 2
 
 #define NO_SHORTNAMES
 /* gnuserv should not be compiled using SOCKS */
 #define DO_NOT_SOCKSIFY
+#define DONT_ENCAPSULATE
 #include <config.h>
-#undef read
-#undef write
-#undef open
-#undef close
 #undef signal
 
 /* Define the communication method between server and clients:
@@ -174,7 +169,7 @@
  */
 #ifndef DONT_USE_LITOUT
 #if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS)
-#if !defined(MSDOS) && !defined(BSD4_1)
+#if !defined(BSD4_1)
 #define USE_LITOUT
 #endif
 #endif
--- a/lib-src/hexl.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/hexl.c	Mon Aug 13 11:19:21 2007 +0200
@@ -4,14 +4,16 @@
 
 #include <stdio.h>
 #include <ctype.h>
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <io.h>
 #include <fcntl.h>
 #endif
 
 #if __STDC__ || defined(STDC_HEADERS)
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <string.h>
 #endif
 
@@ -142,7 +144,7 @@
 	{
 	  char buf[18];
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  _setmode (_fileno (stdout), O_BINARY);
 #endif
 	  for (;;)
@@ -185,7 +187,7 @@
 	}
       else
 	{
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  _setmode (_fileno (fp), O_BINARY);
 #endif
 	  address = 0;
@@ -242,7 +244,7 @@
 }
 
 void
-usage ()
+usage (void)
 {
   (void) fprintf (stderr, "usage: %s [-de] [-iso]\n", progname);
   exit (1);
--- a/lib-src/make-docfile.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/make-docfile.c	Mon Aug 13 11:19:21 2007 +0200
@@ -46,40 +46,38 @@
 #include <errno.h>
 #if __STDC__ || defined(STDC_HEADERS)
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <ctype.h>
 #endif
 
-#if defined(MSDOS) || defined(__CYGWIN32__)
+#ifdef CYGWIN
 #include <fcntl.h>
-#endif /* MSDOS */
-#ifdef WINDOWSNT
+#endif
+#ifdef WIN32_NATIVE
 #include <direct.h>
 #include <fcntl.h>
 #include <io.h>
 #include <stdlib.h>
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
+#ifndef WIN32_NATIVE
 #include <sys/param.h>
+#endif /* not WIN32_NATIVE */
 
-#if defined(DOS_NT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
 #define READ_TEXT "rt"
 #define READ_BINARY "rb"
 #define WRITE_BINARY "wb"
 #define APPEND_BINARY "ab"
-#else  /* not DOS_NT */
+#else  /* not WIN32_NATIVE */
 #define READ_TEXT "r"
 #define READ_BINARY "r"
 #define WRITE_BINARY "w"
 #define APPEND_BINARY "a"
-#endif /* not DOS_NT */
-
-#ifdef MSDOS
-/* s/msdos.h defines this as sys_chdir, but we're not linking with the
-   file where that function is defined.  */
-#undef chdir
-#endif
+#endif /* not WIN32_NATIVE */
 
 /* Stdio stream for output to the DOC file.  */
 static FILE *outfile;
@@ -191,19 +189,10 @@
   outfile = stdout;
 
   /* Don't put CRs in the DOC file.  */
-#ifdef MSDOS
-  _fmode = O_BINARY;
-#if 0  /* Suspicion is that this causes hanging.
-	  So instead we require people to use -o on MSDOS.  */
-  (stdout)->_flag &= ~_IOTEXT;
-  _setmode (fileno (stdout), O_BINARY);
-#endif
-  outfile = 0;
-#endif /* MSDOS */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   _fmode = O_BINARY;
   _setmode (fileno (stdout), O_BINARY);
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   /* If first two args are -o FILE, output to FILE.  */
   i = 1;
--- a/lib-src/make-dump-id.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/make-dump-id.c	Mon Aug 13 11:19:21 2007 +0200
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #include "../src/systime.h"
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <sys/timeb.h>
 
 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95).  */
--- a/lib-src/mmencode.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/mmencode.c	Mon Aug 13 11:19:21 2007 +0200
@@ -385,7 +385,7 @@
                         putc(c1<<4 | c2, outfile);
                     }
                 } else {
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
                     if (*s == '\n')
                         putc('\r', outfile);	/* insert CR for binary-mode write */
 #endif
@@ -442,7 +442,8 @@
 OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
 WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
 */
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
+#include <io.h>
 #include <fcntl.h>
 #endif
 
@@ -487,7 +488,7 @@
                     exit(-1);
             }
         } else {
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
             if (encode)
                 fp = fopen(argv[i], "rb");
             else
@@ -497,16 +498,16 @@
             } /* else */
 #else
             fp = fopen(argv[i], "r");
-#endif /* MSDOS */
+#endif /* WIN32_NATIVE */
             if (!fp) {
                 perror(argv[i]);
                 exit(-1);
             }
         }
     }
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
     if (fp == stdin) setmode(fileno(fp), O_BINARY);
-#endif /* MSDOS */
+#endif /* WIN32_NATIVE */
     if (which == BASE64) {
         if (encode) {
             to64(fp, fpo, portablenewlines);
--- a/lib-src/movemail.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/movemail.c	Mon Aug 13 11:19:21 2007 +0200
@@ -69,7 +69,7 @@
 #include <errno.h>
 #include "../src/sysfile.h"
 #include "../src/syswait.h"
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #include "../src/systime.h"
 #endif
 #include <stdlib.h>
@@ -87,10 +87,6 @@
 char * strerror (int errnum);
 #endif /* HAVE_STRERROR */
 
-#ifdef MSDOS
-#undef access
-#endif /* MSDOS */
-
 #ifndef DIRECTORY_SEP
 #define DIRECTORY_SEP '/'
 #endif
@@ -98,7 +94,7 @@
 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
 #endif
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #undef access
 #undef unlink
 #define fork() 0
@@ -110,7 +106,7 @@
    properly - make sure it does before you enable this! */
 #define DISABLE_DIRECT_ACCESS
 #include <io.h>
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #if defined (HAVE_UNISTD_H)
 #include <unistd.h>
@@ -343,7 +339,7 @@
       exit (retcode);
     }
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   setuid (getuid ());
 #endif
 #endif /* MAIL_USE_POP */
@@ -709,7 +705,7 @@
 
 #ifdef MAIL_USE_POP
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
@@ -718,7 +714,7 @@
 #include <winsock.h>
 #endif
 #include <stdio.h>
-#include <pwd.h>
+#include "../src/syspwd.h"
 
 #define POP_ERROR 	(-1)
 #define POP_RETRIEVED (0)
@@ -774,7 +770,7 @@
       error ("Error in open: %s, %s", strerror (errno), outfile);
       return (1);
     }
-#if !defined(__CYGWIN32__) && !defined(WINDOWSNT)
+#if !defined(CYGWIN) && !defined(WIN32_NATIVE)
   fchown (mbfi, getuid (), (gid_t) -1);
 #endif
 
--- a/lib-src/ootags.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/ootags.c	Mon Aug 13 11:19:21 2007 +0200
@@ -64,31 +64,18 @@
 # define DEBUG FALSE
 #endif
 
-#ifdef MSDOS
-# include <fcntl.h>
-# include <sys/param.h>
-# include <io.h>
-# ifndef HAVE_CONFIG_H
-#   define DOS_NT
-#   include <sys/config.h>
-# endif
-#endif /* MSDOS */
-
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 # include <stdlib.h>
 # include <fcntl.h>
 # include <string.h>
 # include <io.h>
 # define MAXPATHLEN _MAX_PATH
-# ifdef HAVE_CONFIG_H
-#   undef HAVE_NTGUI
-# else
-#   define DOS_NT
+# ifndef HAVE_CONFIG_H
 #   define HAVE_GETCWD
 # endif /* not HAVE_CONFIG_H */
-#endif /* WINDOWSNT */
-
-#if !defined (WINDOWSNT) && defined (STDC_HEADERS)
+#endif /* WIN32_NATIVE */
+
+#if !defined (WIN32_NATIVE) && defined (STDC_HEADERS)
 #include <stdlib.h>
 #include <string.h>
 #endif
@@ -870,9 +857,9 @@
   bool got_err;
 #endif
 
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   _fmode = O_BINARY;   /* all of files are treated as binary files */
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 
   progname = argv[0];
   nincluded_files = 0;
@@ -1064,12 +1051,12 @@
       if (streq (tagfile, "-"))
 	{
 	  tagf = stdout;
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	  /* Switch redirected `stdout' to binary mode (setting `_fmode'
 	     doesn't take effect until after `stdout' is already open). */
 	  if (!isatty (fileno (stdout)))
 	    setmode (fileno (stdout), O_BINARY);
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 	}
       else
 	tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
@@ -4960,7 +4947,7 @@
 	  if (p > buffer && p[-1] == '\r')
 	    {
 	      p -= 1;
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	     /* Assume CRLF->LF translation will be performed by Emacs
 		when loading this file, so CRs won't appear in the buffer.
 		It would be cleaner to compensate within Emacs;
@@ -5216,19 +5203,6 @@
   return path;
 
 #else /* not HAVE_GETCWD */
-#ifdef MSDOS
-  char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS.  */
-
-  getwd (path);
-
-  for (p = path; *p != '\0'; p++)
-    if (*p == '\\')
-      *p = '/';
-    else
-      *p = lowcase (*p);
-
-  return strdup (path);
-#else /* not MSDOS */
   linebuffer path;
   FILE *pipe;
 
@@ -5239,7 +5213,6 @@
   pclose (pipe);
 
   return path.buffer;
-#endif /* not MSDOS */
 #endif /* not HAVE_GETCWD */
 }
 
@@ -5289,7 +5262,7 @@
 
   if (filename_is_absolute (file))
     res = savestr (file);
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   /* We don't support non-absolute file names with a drive
      letter, like `d:NAME' (it's too much hassle).  */
   else if (file[1] == ':')
@@ -5313,8 +5286,8 @@
 	      while (cp >= res && !filename_is_absolute (cp));
 	      if (cp < res)
 		cp = slashp;	/* the absolute name begins with "/.." */
-#ifdef DOS_NT
-	      /* Under MSDOS and NT we get `d:/NAME' as absolute
+#ifdef WIN32_NATIVE
+	      /* Under Windows we get `d:/NAME' as absolute
 		 file name, so the luser could say `d:/../NAME'.
 		 We silently treat this as `d:/NAME'.  */
 	      else if (cp[0] != '/')
@@ -5369,7 +5342,7 @@
      char *fn;
 {
   return (fn[0] == '/'
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 	  || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
 #endif
 	  );
@@ -5380,7 +5353,7 @@
 canonicalize_filename (fn)
      register char *fn;
 {
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   for (; *fn != '\0'; fn++)
     if (*fn == '\\')
       *fn = '/';
--- a/lib-src/pop.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/pop.c	Mon Aug 13 11:19:21 2007 +0200
@@ -21,6 +21,7 @@
 
 #ifdef HAVE_CONFIG_H
 #define NO_SHORTNAMES	/* Tell config not to load remap.h */
+#define DONT_ENCAPSULATE
 #include <config.h>
 #else
 #define MAIL_USE_POP
@@ -28,16 +29,8 @@
 
 #ifdef MAIL_USE_POP
 
-#ifdef HAVE_CONFIG_H
-/* Cancel these substitutions made in config.h */
-#undef open
-#undef read
-#undef write
-#undef close
-#endif
-
 #include <sys/types.h>
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <winsock.h>
 #undef SOCKET_ERROR
 #define RECV(s,buf,len,flags) recv(s,buf,len,flags)
@@ -67,16 +60,22 @@
 extern struct servent *hes_getservbyname (/* char *, char * */);
 #endif
 
-#include <pwd.h>
+#include "../src/syspwd.h"
+#ifndef WIN32_NATIVE
 #include <netdb.h>
+#endif
 #include <errno.h>
 #include <stdio.h>
 
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <sys/stat.h>
+#ifndef WIN32_NATIVE
 #include <sys/file.h>
+#endif
 #include "../src/syswait.h"
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #include "../src/systime.h"
 #endif
 #include <stdlib.h>
@@ -103,7 +102,7 @@
 #endif /* ! KRB5 */
 #endif /* KERBEROS */
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #if !defined(HAVE_H_ERRNO) || !defined(HAVE_CONFIG_H)
 extern int h_errno;
 #endif
@@ -123,7 +122,7 @@
 #define ERROR_MAX 80		/* a pretty arbitrary size */
 #define POP_PORT 110
 #define KPOP_PORT 1109
-#if defined(WINDOWSNT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
 #define POP_SERVICE "pop3"	/* we don't want the POP2 port! */
 #else
 #define POP_SERVICE "pop"
@@ -184,7 +183,7 @@
       username = getenv ("USER");
       if (! (username && *username))
 	{
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 	  username = getlogin ();
 	  if (! (username && *username))
 	    {
@@ -253,7 +252,7 @@
  
   if ((! password) && (! DONT_NEED_PASSWORD))
     {
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
       if (! (flags & POP_NO_GETPASS))
 	{
 	  password = getpass ("Enter POP password:");
@@ -932,7 +931,7 @@
   return (ret);
 }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 static int have_winsock = 0;
 #endif
 
@@ -977,7 +976,7 @@
 
   int try_count = 0;
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   {
     WSADATA winsockData;
     if (WSAStartup (0x101, &winsockData) == 0)
@@ -1482,7 +1481,7 @@
 	}
     }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   if (have_winsock)
     WSACleanup ();
 #endif
--- a/lib-src/profile.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/profile.c	Mon Aug 13 11:19:21 2007 +0200
@@ -41,7 +41,7 @@
 static int watch_not_started = 1; /* flag */
 static char time_string[30];
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <sys/timeb.h>
 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95).  */
 void 
--- a/lib-src/run.c	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,715 +0,0 @@
-/* run -- Wrapper program for console mode programs under Windows(TM)
- * Copyright (C) 1998  Charles S. Wilson
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-/*
- * This program is based on the runemacs.c distributed with XEmacs 21.0
- *
- * Simple program to start gnu-win32 X11 programs (and native XEmacs) 
- * with its console window hidden.
- *
- * This program is provided purely for convenience, since most users will
- * use XEmacs in windowing (GUI) mode, and will not want to have an extra
- * console window lying around. Ditto for desktop shortcuts to gnu-win32 
- * X11 executables.
- */
-
-
-#define WIN32
-
-#include <windows.h>
-#include <string.h>
-#include <malloc.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "run.h"
-
-#if defined(__CYGWIN__)
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/cygwin.h>
- #include <sys/unistd.h>
-WinMainCRTStartup() { mainCRTStartup(); }
-#else
- #include <direct.h>
-#endif
-
-
-char buffer[1024];
-
-int WINAPI
-WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
-{
-   int wait_for_child = FALSE;
-   int compact_invocation = FALSE;
-   DWORD ret_code = 0;
-
-
-   char execname[FILENAME_MAX];
-   char execpath[MAX_PATH];
-   char* argv[MAX_ARGS+1]; /* leave extra slot for compact_invocation argv[0] */
-   int argc;
-   int i;
-   char exec[MAX_PATH + FILENAME_MAX + 100];
-   char cmdline2[MAX_ARGS * MAX_PATH];
-
-#ifdef Debug
-   int j;
-#endif
-
-   compact_invocation = get_exec_name_and_path(execname,execpath);
-
-   if (compact_invocation)
-   {
-      argv[0] = execname;
-      argc = parse_cmdline_to_arg_array(&(argv[1]),cmdline);
-      argc++;
-   }
-   else
-   {
-      argc = parse_cmdline_to_arg_array(argv,cmdline);
-      if (argc >= 1)
-         strcpy(execname,argv[0]);
-   }
-   /* at this point, execpath is defined, as are argv[] and execname */   
-#ifdef DEBUG
-   j = sprintf(buffer,"\nexecname : %s\nexecpath : %s\n",execname,execpath);
-   for (i = 0; i < argc; i++)
-      j += sprintf(buffer+j,"argv[%d]\t: %s\n",i,argv[i]);
-   Trace((buffer));
-#endif
-
-   if (execname == NULL)
-      error("you must supply a program name to run");
-
-#if defined(__CYGWIN__)
-   /* this insures that we search for symlinks before .exe's */
-   if (compact_invocation)
-      strip_exe(execname);
-#endif
-
-   process_execname(exec,execname,execpath);
-   Trace(("exec\t%s\nexecname\t%s\nexecpath\t%s\n",
-         exec,execname,execpath));
-
-   wait_for_child = build_cmdline(cmdline2,exec,argc,argv);
-   Trace((cmdline2));
-
-   xemacs_special(exec);
-   ret_code = start_child(cmdline2,wait_for_child);
-   if (compact_invocation)
-      for (i = 1; i < argc; i++) // argv[0] was not malloc'ed
-         free(argv[i]);
-   else
-      for (i = 0; i < argc; i++)
-         free(argv[i]);
-   return (int) ret_code;
-}
-int start_child(char* cmdline, int wait_for_child)
-{
-   STARTUPINFO start;
-   SECURITY_ATTRIBUTES sec_attrs;
-   PROCESS_INFORMATION child;
-   int retval;
-
-   memset (&start, 0, sizeof (start));
-   start.cb = sizeof (start);
-   start.dwFlags = STARTF_USESHOWWINDOW;
-   start.wShowWindow = SW_HIDE;
-      
-   sec_attrs.nLength = sizeof (sec_attrs);
-   sec_attrs.lpSecurityDescriptor = NULL;
-   sec_attrs.bInheritHandle = FALSE;
-
-   if (CreateProcess (NULL, cmdline, &sec_attrs, NULL, TRUE, 0,
-                      NULL, NULL, &start, &child))
-   {
-      if (wait_for_child)
-      {
-         WaitForSingleObject (child.hProcess, INFINITE);
-         GetExitCodeProcess (child.hProcess, &retval);
-      }
-      CloseHandle (child.hThread);
-      CloseHandle (child.hProcess);
-   }
-   else
-      error("could not start %s",cmdline);
-   return retval;
-}
-void xemacs_special(char* exec)
-{
-  /*
-   * if we're trying to run xemacs, AND this file was in %emacs_dir%\bin,
-   * then set emacs_dir environment variable 
-   */
-   char* p;
-   char* p2;
-   char exec2[MAX_PATH + FILENAME_MAX + 100];
-#if defined(__CYGWIN__)
-   char tmp[MAX_PATH + FILENAME_MAX + 100];
-#endif
-   strcpy(exec2,exec);
-   /* this depends on short-circuit evaluation */
-   if ( ((p = strrchr(exec2,'\\')) && stricmp(p,"\\xemacs") == 0) ||
-        ((p = strrchr(exec2,'/')) && stricmp(p,"/xemacs") == 0) ||
-        ((p = strrchr(exec2,'\\')) && stricmp(p,"\\xemacs.exe") == 0) ||
-        ((p = strrchr(exec2,'/')) && stricmp(p,"/xemacs.exe") == 0) )
-   {
-      if ( ((p2 = strrchr(p, '\\')) && stricmp(p2, "\\bin") == 0) ||
-           ((p2 = strrchr(p, '/')) && stricmp(p2, "/bin") == 0) )
-      {
-         *p2 = '\0';   
-#if defined(__CYGWIN__)
-         CYGWIN_CONV_TO_POSIX_PATH((exec2,tmp));
-         strcpy(exec2,tmp);
-#else /* NATIVE xemacs DOS-style paths with forward slashes */
-         for (p = exec2; *p; p++)
-            if (*p == '\\') *p = '/';
-#endif
-         SetEnvironmentVariable ("emacs_dir", exec2);
-      }
-   }
-}
-int build_cmdline(char* new_cmdline, char* exec, int argc, char* argv[])
-{
-   int retval = FALSE;
-   int first_arg = 1;
-   int i;
-   int char_cnt = 0;
-   /*
-    * look for "-wait" as first true argument; we'll apply that ourselves
-    */
-   if ((argc >= 2) && (stricmp(argv[1],"-wait") == 0))
-   {
-      retval = TRUE;
-      first_arg++;
-   }
-
-   char_cnt = strlen(exec);
-   for (i = first_arg; i < argc; i++)
-      char_cnt += strlen(argv[i]);
-   if (char_cnt > MAX_ARGS*MAX_PATH) /* then we ran out of room */
-      error("command line too long -\n%s",new_cmdline);
-   
-   strcpy(new_cmdline,exec);
-   for (i = first_arg; i < argc; i++)
-   {
-      strcat(new_cmdline," ");
-      strcat(new_cmdline,argv[i]);
-   }
-   return retval;
-}
-/* process exec_arg : if it
- * NATIVE:
- *  1) starts with '\\' or '/', it's a root-path and leave it alone
- *  2) starts with 'x:\\' or 'x:/', it's a root-path and leave it alone
- *  3) starts with '.\\' or './', two possible meanings:
- *       1) exec is in the current directory
- *       2) exec in same directory as this program
- *  4) otherwise, search path (and _prepend_ "." to the path!!!)
- *  5) convert all '/' to '\\'
- * CYGWIN
- *  1) starts with '\\' or '/', it's a root-path and leave it alone
- *  2) starts with 'x:\\' or 'x:/', it's a root-path and leave it alone
- *  3) starts with '.\\' or './', two possible meanings:
- *       1) exec is in the current directory
- *       2) exec in same directory as this program
- *  4) otherwise, search path (and _prepend_ "." to the path!!!)
- *  5) convert to cygwin-style path to resolve symlinks within the pathspec
- *  6) check filename: if it's a symlink, resolve it by peeking inside
- *  7) convert to win32-style path+filename since we're using Windows 
- *       createProcess() to launch
- */
-void process_execname(char *exec, const char* execname,const char* execpath )
-{
-   char* orig_pathlist;
-   char* pathlist;
-   char exec_tmp[MAX_PATH + FILENAME_MAX + 100];
-   char exec_tmp2[MAX_PATH + FILENAME_MAX + 100];
-   char buf[MAX_PATH + FILENAME_MAX + 100];
-   int i,j;
-
-   /* 
-    * STARTS WITH / or \ 
-    * execpath NOT used
-    */
-   if ((execname[0] == '\\') || (execname[0] == '/'))
-   {
-#if defined(__CYGWIN__)
-      strcpy(exec_tmp,execname);
-#else    
-      exec_tmp[0] = ((char) (_getdrive() + ((int) 'A') - 1));
-      exec_tmp[1] = ':';
-      exec_tmp[2] = '\0';
-      strcat(exec_tmp,execname);
-#endif
-      Trace(("/ -\nexec_tmp\t%s\nexecname\t%s\nexecpath\t%s\n",
-             exec_tmp,execname,execpath));
-      if (! fileExistsMulti(exec_tmp2,NULL,exec_tmp,exts,NUM_EXTENSIONS) )
-      {
-          j = 0;
-          for (i = 0; i < NUM_EXTENSIONS; i++)
-              j += sprintf(buf + j," [%d]: %s\n",i+1,exts[i]);
-          error("Couldn't locate %s\nI tried appending the following "
-                "extensions: \n%s",exec_tmp,buf);
-      }
-      Trace((exec_tmp2));
-   }
-   /* 
-    * STARTS WITH x:\ or x:/
-    * execpath NOT used
-    */
-    else if ((strlen(execname) > 3) && // avoid boundary errors
-       (execname[1] == ':') &&
-       ((execname[2] == '\\') || (execname[2] == '/')))
-   {
-      strcpy(exec_tmp,execname);       
-      Trace(("x: -\nexec_tmp\t%s\nexecname\t%s\nexecpath\t%s\n",
-             exec_tmp,execname,execpath));
-      if (! fileExistsMulti(exec_tmp2,NULL,exec_tmp,exts,NUM_EXTENSIONS) )
-      {
-          j = 0;
-          for (i = 0; i < NUM_EXTENSIONS; i++)
-              j += sprintf(buf + j," [%d]: %s\n",i+1,exts[i]);
-          error("Couldn't locate %s\nI tried appending the following "
-                "extensions: \n%s",exec_tmp,buf);
-      }
-      Trace((exec_tmp2));
-   }
-   /* 
-    * STARTS WITH ./ or .\
-    */
-   else if ((execname[0] == '.') &&
-            ((execname[1] == '\\') || (execname[1] == '/')))
-   {
-      if (((char*) getcwd(exec_tmp,MAX_PATH))==NULL)
-         error("can't find current working directory");
-      if (! fileExistsMulti(exec_tmp2,exec_tmp,&(execname[2]),
-                            exts,NUM_EXTENSIONS) )
-          if (! fileExistsMulti(exec_tmp2,execpath,&(execname[2]),
-                                exts,NUM_EXTENSIONS) )
-          {
-              j = 0;
-              for (i = 0; i < NUM_EXTENSIONS; i++)
-                  j += sprintf(buf + j," [%d]: %s\n",i+1,exts[i]);
-              error("Couldn't locate %s\n"
-                    "I looked in the following directories:\n [1]: %s\n [2]: %s\n"
-                    "I also tried appending the following "
-                    "extensions: \n%s",execname,exec_tmp,execpath,buf);
-          }
-      Trace((exec_tmp2));
-   }
-   /*
-    * OTHERWISE, SEARCH PATH (prepend '.' and run.exe's directory)
-    * can't use fileExistsMulti because we want to search entire path
-    * for exts[0], then for exts[1], etc.
-    */
-   else
-   {
-      orig_pathlist = getenv("PATH");
-      if ((pathlist = malloc (strlen(orig_pathlist)
-                              + strlen(".") 
-                              + strlen(execpath)+ 3)) == NULL)
-         error("internal error - out of memory");
-      strcpy(pathlist,".");
-      strcat(pathlist,SEP_CHARS);
-      strcat(pathlist,execpath);
-      strcat(pathlist,SEP_CHARS);
-      strcat(pathlist,orig_pathlist);
-
-      Trace((pathlist));
-      for (i = 0; i < NUM_EXTENSIONS; i++)
-      {
-          strcpy(exec_tmp,execname);
-          strcat(exec_tmp,exts[i]);
-          pfopen(exec_tmp2,exec_tmp,pathlist);
-          if (fileExists(NULL,NULL,exec_tmp2))
-              break;
-          exec_tmp2[0] = '\0';
-      }
-      Trace(("exec_tmp\t%s\npathlist\t%s\n",exec_tmp2,pathlist));
-
-      free(pathlist);
-      if (exec_tmp2[0] == '\0')
-      {
-          j = 0;
-          for (i = 0; i < NUM_EXTENSIONS; i++)
-              j += sprintf(buf + j," [%d]: %s\n",i+1,exts[i]);
-          error("Couldn't find %s anywhere.\n"
-                "I even looked in the PATH \n"
-                "I also tried appending the following "
-                "extensions: \n%s",execname,buf);
-      }
-   }
-/*
- * At this point, we know that exec_tmp2 contains a filename
- * and we know that exec_tmp2 exists.
- */
-#if defined(__CYGWIN__)
-   {
-      struct stat stbuf;
-      char sym_link_name[MAX_PATH+1];
-      char real_name[MAX_PATH+1];
-      char dummy[MAX_PATH+1];
-
-      strcpy(exec_tmp,exec_tmp2);
-
-      CYGWIN_CONV_TO_POSIX_PATH((exec_tmp,sym_link_name));
-      Trace((sym_link_name));
-      
-      if (lstat(sym_link_name, &stbuf) == 0)
-      {
-         if ((stbuf.st_mode & S_IFLNK) == S_IFLNK)
-         {
-	    if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1)
-               error("problem reading symbolic link for %s",exec_tmp);
-            else
-            {
-                // if realname starts with '/' it's a rootpath 
-                if (real_name[0] == '/')
-                    strcpy(exec_tmp2,real_name);
-                else // otherwise, it's relative to the symlink's location
-                {
-                   CYGWIN_SPLIT_PATH((sym_link_name,exec_tmp2,dummy));
-                   if (!endsWith(exec_tmp2,PATH_SEP_CHAR_STR))
-                      strcat(exec_tmp2,PATH_SEP_CHAR_STR);
-                   strcat(exec_tmp2,real_name);
-                }
-            }
-         }
-         else /* NOT a symlink */
-            strcpy(exec_tmp2, sym_link_name);
-      }
-      else
-         error("can't locate executable - %s",sym_link_name);
-   }
-   CYGWIN_CONV_TO_FULL_WIN32_PATH((exec_tmp2,exec));
-#else					
-   strcpy (exec, exec_tmp2);
-#endif  
-}
-int endsWith(const char* s1, const char* s2)
-{
-    int len1;
-    int len2;
-    int retval = FALSE;
-    len1 = strlen(s1);
-    len2 = strlen(s2);
-    if (len1 - len2 >= 0)
-        if (stricmp(&(s1[len1-len2]),s2) == 0)
-            retval = TRUE;
-    return retval;
-}void strip_exe(char* s)
-{
-   if ((strlen(s) > 4) && // long enough to have .exe extension
-       // second part not evaluated (short circuit) if exec_arg too short
-       (stricmp(&(s[strlen(s)-4]),".exe") == 0))
-      s[strlen(s)-4] = '\0';
-}
-void error(char* fmt, ...)
-{
-   char buf[4096];
-   int j;
-   va_list args;
-   va_start(args, fmt);
-   j =   sprintf(buf,    "Error: ");
-   j += vsprintf(buf + j,fmt,args);
-   j +=  sprintf(buf + j,"\n");
-   va_end(args);
-   MessageBox(NULL, buf, "Run.exe", MB_ICONSTOP);
-   exit(1);
-}
-void message(char* fmt, ...)
-{
-   char buf[10000];
-   int j;
-   va_list args;
-   va_start(args, fmt);
-   j = vsprintf(buf,fmt,args);
-   j +=  sprintf(buf + j,"\n");
-   va_end(args);
-   MessageBox(NULL, buf, "Run.exe Message", MB_ICONSTOP);
-}
-void Trace_(char* fmt, ...)
-{
-   char buf[10000];
-   int j;
-   va_list args;
-   va_start(args, fmt);
-   j = vsprintf(buf,fmt,args);
-   j +=  sprintf(buf + j,"\n");
-   va_end(args);
-   MessageBox(NULL, buf, "Run.exe DEBUG", MB_ICONSTOP);
-}
-/*
- * Uses system info to determine the path used to invoke run
- * Also attempts to deduce the target execname if "compact_invocation"
- * method was used.
- *
- * returns TRUE if compact_invocation method was used
- *   (and target execname was deduced successfully)
- * otherwise returns FALSE, and execname == run or run.exe
- */
-int get_exec_name_and_path(char* execname, char* execpath)
-{
-   char modname[MAX_PATH];
-   char* tmp_execname;
-   char* p;
-   int retval = FALSE;
-
-   if (!GetModuleFileName (NULL, modname, MAX_PATH))
-      error("internal error - can't find my own name");
-   if ((p = strrchr (modname, '\\')) == NULL)
-      error("internal error - my own name has no path\n%s",modname);
-   tmp_execname = p + 1;
-   p[0] = '\0';
-   // if invoked by a name like "runxemacs" then strip off
-   // the "run" and let "xemacs" be execname.
-   // To check for this, make that:
-   //   1) first three chars are "run"
-   //   2) but the string doesn't end there, or start ".exe"
-   // Also, set "compact_invocation" TRUE
-   if ( ((tmp_execname[0] == 'r') || (tmp_execname[0] == 'R')) &&
-        ((tmp_execname[1] == 'u') || (tmp_execname[1] == 'U')) &&
-        ((tmp_execname[2] == 'n') || (tmp_execname[2] == 'N')) &&
-        ((tmp_execname[3] != '.') && (tmp_execname[3] != '\0')) )
-   {
-      tmp_execname += 3;
-      retval = TRUE;
-   }
-   else
-      tmp_execname = NULL;
-
-   if (tmp_execname == NULL)
-      strcpy(execname,"");
-   else
-      strcpy(execname,tmp_execname);
-#if defined(__CYGWIN__)
-   CYGWIN_CONV_TO_POSIX_PATH((modname,execpath));
-#else
-   strcpy(execpath,modname);
-#endif
-   return retval;
-}
-/*
- * works like strtok, but:
- * double quotes (") suspends tokenizing until closing " reached
- * CYGWIN ONLY:
- *   additionally, backslash escapes next character, even if that
- *   next character is a delimiter. Or a double quote.
- *   WARNING: this means that backslash may NOT be a delimiter 
- */
-char* my_strtok(char* s, const char* delim, char** lasts)
-{
-   char *spanp;
-   int c, sc;
-   char *tok;
-   
-   if ((s == NULL) && ((s = *lasts) == NULL))
-      return NULL;
-   /* Skip leading delimiters */
-cont:
-   c = *s++;
-   for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
-      if (c == sc)
-         goto cont;
-   }
-   if (c == 0) {		/* no non-delimiter characters */
-      *lasts = NULL;
-      return (NULL);
-   }
-   tok = s - 1;
-   /*
-    * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
-    * Note that delim must have one NUL; we stop if we see that, too.
-    * If we see a double quote, continue until next double quote, then
-    *   start scanning for delimiters again.
-    * CYGWIN ONLY: if we see a backslash, just copy next character -
-    *   don't consider it as a delimiter even if it is in delim string.
-    */
-   for (;;) {
-      /* if this c is ", then scan until we find next " */
-      if (c == '\"')
-         while ((c = *s++) != '\"')
-            if (c == 0) /* oops, forgot to close the ", clean up & return */
-            {
-               s = NULL;
-               *lasts = s;
-               return (tok);
-            }
-#if defined(__CYGWIN__)
-      if (c == '\\')
-      {
-         c = *s++; /* skip the backslash */
-         if (c == 0) /* if escaped character is end-of-string, clean up & return */
-         {
-            s = NULL;
-            *lasts = s;
-            return (tok);
-         }
-         c = *s++; /* otherwise, skip the escaped character */
-      }
-#endif   
-      spanp = (char *)delim;
-      do {
-         if ((sc = *spanp++) == c) {
-            if (c == 0)
-               s = NULL;
-            else
-               s[-1] = 0;
-            *lasts = s;
-            return (tok);
-         }
-      } while (sc != 0);
-      c = *s++;
-   }
-   /* NOTREACHED */
-}
-int parse_cmdline_to_arg_array(char* argv[MAX_ARGS], char* cmdline)
-{
-   char seps[] = " \t\n";
-   char* token;
-   int argc = 0;
-   char* lasts;
-
-   token = my_strtok(cmdline, seps, &lasts);
-   while ((token != NULL) && (argc < MAX_ARGS))
-   {
-      if ((argv[argc] = malloc(strlen(token)+1)) == NULL)
-      {
-         error("internal error - out of memory");
-      }
-      strcpy(argv[argc++],token);
-      token = my_strtok(NULL,seps,&lasts);
-   }
-   if (argc >= MAX_ARGS)
-      error("too many arguments on commandline\n%s",cmdline);
-   return argc;
-}
-/* Taken from pfopen.c by David Engel (5-Jul-97).
- * Original comments appear below. Superseded by next comment block.
- *
- *  Written and released to the public domain by David Engel.
- *
- *  This function attempts to open a file which may be in any of
- *  several directories.  It is particularly useful for opening
- *  configuration files.  For example, PROG.EXE can easily open
- *  PROG.CFG (which is kept in the same directory) by executing:
- *
- *      cfg_file = pfopen("PROG.CFG", "r", getenv("PATH"));
- *
- *  NULL is returned if the file can't be opened.
- */
-
-/*
- * This function attempts to locate a file which may be in any of
- * several directories. Unlike the original pfopen, it does not
- * return a FILE pointer to the opened file, but rather returns
- * the fully-qualified filename of the first match found. Returns
- * empty string if not found.
- */
-char *pfopen(char *retval, const char *name, const char *dirs)
-{
-    char *ptr;
-    char *tdirs;
-    char returnval[MAX_PATH + FILENAME_MAX + 100];
-    int foundit = FALSE;
-    
-    returnval[0] = '\0';
-
-    if (dirs == NULL || dirs[0] == '\0')
-        return NULL;
-
-    if ((tdirs = malloc(strlen(dirs)+1)) == NULL)
-        return NULL;
-
-    strcpy(tdirs, dirs);
-
-    for (ptr = strtok(tdirs, SEP_CHARS); (foundit == FALSE) && ptr != NULL;
-         ptr = strtok(NULL, SEP_CHARS))
-    {
-       foundit = fileExists(returnval,ptr,name);
-    }
-
-    free(tdirs);
-    if (!foundit)
-        retval[0] = '\0';
-    else
-        strcpy(retval,returnval);
-    return retval;
-}
-int fileExistsMulti(char* fullname, const char* path, 
-                    const char* name_noext, const char* exts[],
-                    const int extcnt)
-{
-    char tryName[MAX_PATH + FILENAME_MAX];
-    int i = 0;
-    int retval = FALSE;
-    fullname[0] = '\0';
-    for (i = 0; i < extcnt; i++)
-    {
-        strcpy(tryName,name_noext);
-        strcat(tryName,exts[i]);
-        if (fileExists(fullname, path, tryName) == TRUE)
-        {
-            retval = TRUE;
-            break;
-        }
-        fullname[0] = '\0';
-    }
-    return retval;
-}
-int fileExists(char* fullname, const char* path, const char* name)
-{
-   int retval = FALSE;
-   FILE* file;
-   size_t len;
-   char work[FILENAME_MAX];
-   char work2[MAX_PATH + FILENAME_MAX + 100];
-   if (path != NULL)
-   {
-      strcpy(work, path);
-      len = strlen(work);
-      if (len && work[len-1] != '/' && work[len-1] != '\\')
-         strcat(work, PATH_SEP_CHAR_STR);
-   }
-   else
-      work[0]='\0';
-   
-   strcat(work, name);
-#if defined(__CYGWIN__)
-   CYGWIN_CONV_TO_POSIX_PATH((work, work2)); 
-#else
-   strcpy(work2,work);
-#endif
-
-#ifdef DEBUGALL
-   Trace(("looking for...\t%s\n",work2));
-#endif
-
-   file = fopen(work2, "rb");
-   if (file != NULL)
-   {
-      if (fullname != NULL)
-         strcpy(fullname,work2);
-      retval = TRUE;
-      fclose(file);
-   }
-   return retval;
-}
--- a/lib-src/run.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-// #define DEBUG
-// #define DEBUGALL
-
-// B19 - egcs automatically defines CYGWIN32 but not CYGWIN
-// B20 - egcs automatically defines both CYGWIN32 and CYGWIN
-// Bfuture - (???) defines CYGWIN but not CYGWIN32
-#if defined(__CYGWIN32__)
-#if !defined(__CYGWIN__)
- #define B19
- #define __CYGWIN__
-#else
- #define B20
-#endif
-#else
-#if defined(__CYGWIN__)
- #define B21
-#endif
-#endif
-// Now: use __CYGWIN__ to represent any version
-// distinguish using B19, B20, or B21
-
-#if defined(__CYGWIN__)
-#ifdef B19
-#define CYGWIN_ATTACH_HANDLE_TO_FD(a)      cygwin32_attach_handle_to_fd      a
-#define CYGWIN_CONV_TO_FULL_POSIX_PATH(a)  cygwin32_conv_to_full_posix_path  a 
-#define CYGWIN_CONV_TO_FULL_WIN32_PATH(a)  cygwin32_conv_to_full_win32_path  a
-#define CYGWIN_CONV_TO_POSIX_PATH(a)       cygwin32_conv_to_posix_path       a
-#define CYGWIN_CONV_TO_WIN32_PATH(a)       cygwin32_conv_to_win32_path       a
-#define CYGWIN_DETACH_DLL(a)               cygwin32_detach_dll               a
-#define CYGWIN_GETSHARED(a)                cygwin32_getshared                a
-#define CYGWIN_INTERNAL(a)                 cygwin32_internal                 a
-#define CYGWIN_POSIX_PATH_LIST_P(a)        cygwin32_posix_path_list_p        a
-#define CYGWIN_POSIX_TO_WIN32_PATH_LIST(a) cygwin32_posix_to_win32_path_list a
-#define CYGWIN_POSIX_TO_WIN32_PATH_LIST_BUF_SIZE(a) cygwin32_posix_to_win32_path_list_buf_size a
-#define CYGWIN_SPLIT_PATH(a)               cygwin32_split_path               a
-#define CYGWIN_WIN32_TO_POSIX_PATH_LIST(a) cygwin32_win32_to_posix_path_list a
-#define CYGWIN_WIN32_TO_POSIX_PATH_LIST_BUF_SIZE(a) cygwin32_win32_to_posix_path_list_buf_size a
-#define CYGWIN_WINPID_TO_PID(a)            cygwin32_winpid_to_pid            a
-#else
-#define CYGWIN_ATTACH_HANDLE_TO_FD(a)      cygwin_attach_handle_to_fd      a
-#define CYGWIN_CONV_TO_FULL_POSIX_PATH(a)  cygwin_conv_to_full_posix_path  a 
-#define CYGWIN_CONV_TO_FULL_WIN32_PATH(a)  cygwin_conv_to_full_win32_path  a
-#define CYGWIN_CONV_TO_POSIX_PATH(a)       cygwin_conv_to_posix_path       a
-#define CYGWIN_CONV_TO_WIN32_PATH(a)       cygwin_conv_to_win32_path       a
-#define CYGWIN_DETACH_DLL(a)               cygwin_detach_dll               a
-#define CYGWIN_GETSHARED(a)                cygwin_getshared                a
-#define CYGWIN_INTERNAL(a)                 cygwin_internal                 a
-#define CYGWIN_POSIX_PATH_LIST_P(a)        cygwin_posix_path_list_p        a
-#define CYGWIN_POSIX_TO_WIN32_PATH_LIST(a) cygwin_posix_to_win32_path_list a
-#define CYGWIN_POSIX_TO_WIN32_PATH_LIST_BUF_SIZE(a) cygwin_posix_to_win32_path_list_buf_size a
-#define CYGWIN_SPLIT_PATH(a)               cygwin_split_path               a
-#define CYGWIN_WIN32_TO_POSIX_PATH_LIST(a) cygwin_win32_to_posix_path_list a
-#define CYGWIN_WIN32_TO_POSIX_PATH_LIST_BUF_SIZE(a) cygwin_win32_to_posix_path_list_buf_size a
-#define CYGWIN_WINPID_TO_PID(a)            cygwin_winpid_to_pid            a
-#endif
-#endif
-
-#if defined(__CYGWIN__)
- #define PATH_SEP_CHAR_STR "/"
- #define SEP_CHARS ":"
-#else
- #define PATH_SEP_CHAR_STR "\\"
- #define SEP_CHARS ";"
-#endif
-
-#ifndef RC_INVOKED
-
-#define MAX_ARGS 20
-
-#ifdef DEBUG
- #define Trace(x)   Trace_ x
-#else
- #define Trace(x)
-#endif
-
-#define NUM_EXTENSIONS 2
-const char* exts[NUM_EXTENSIONS] = { "", ".exe" };
-
-char* pfopen(char *retval, const char *name, const char *dirs);
-void error(char* fmt, ...);
-void message(char* fmt, ...);
-void Trace_(char* fmt, ...);
-int get_exec_name_and_path(char* execname, char* execpath);
-char* my_strtok(char* s, const char* delim, char** lasts);
-int parse_cmdline_to_arg_array(char* argv[MAX_ARGS], char* cmdline);
-void strip_exe(char* s);
-int start_child(char* cmdline, int wait_for_child);
-void xemacs_special(char* exec);
-int build_cmdline(char* new_cmdline, char* exec, int argc, char* argv[]);
-void process_execname(char *exec, const char* execname, const char* execpath);
-int fileExists(char* fullname, const char* path, const char* name);
-int endsWith(const char* s1, const char* s2);
-int fileExistsMulti(char* fullname, const char* path, 
-                    const char* name_noext, const char* exts[],
-                    const int extcnt);
-
-#endif /* RC_INVOKED */
-
-
-
--- a/lib-src/run.rc	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-XEmacs ICON PRELOAD "xemacs.ico"
-XEmacsFile ICON "file.ico"
-XEmacsLisp ICON "lisp.ico"
-
-#include <windows.h>
-#include "run.h"
-
-1 VERSIONINFO 
-FILEVERSION 1, 1, 4, 0
-PRODUCTVERSION 1, 1, 4, 0
-FILEOS VOS_NT_WINDOWS32
-FILETYPE VFT_APP
-FILESUBTYPE 0
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
-  BLOCK "04090000"
-  BEGIN
-   VALUE "CompanyName", "Charles S. Wilson\000"
-   VALUE "FileDescription", "Runs console-mode programs sans console.\000"
-   VALUE "FileVersion", "1.1.4\000"
-   VALUE "InternalName", "run\000"
-   VALUE "LegalCopyright", "Copyright © 1998 Charles S. Wilson\000"
-   VALUE "OriginalFilename", "run.exe\000"
-   VALUE "ProductName","run\000"
-   VALUE "ProductVersion","1.1.4\000"
-   VALUE "GPL Copyleft", "Released under the GNU General Public License version 2 --------------------------------------- This program is free software; you can redistribute it and/or modify it under the termms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. --------------------------------------- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. --------------------------------------- You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\000"
-  END
- END
-END
--- a/lib-src/wakeup.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/wakeup.c	Mon Aug 13 11:19:21 2007 +0200
@@ -4,20 +4,22 @@
 
 #if __STDC__ || defined(STDC_HEADERS)
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#endif
 
 #include <stdio.h>
 #include <sys/types.h>
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef sleep
 #define sleep(t) Sleep ((t) * 1000)
 #define getppid() (0)
 #undef HAVE_SYS_TIME_H
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
--- a/lib-src/yow.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lib-src/yow.c	Mon Aug 13 11:19:21 2007 +0200
@@ -33,7 +33,7 @@
 void yow (FILE *fp);
 void setup_yow (FILE *fp);
 
-#ifdef MSDOS
+#ifdef WIN32_NATIVE
 #define rootrelativepath(rel) \
 ({\
     static char res[BUFSIZE], *p;\
--- a/lisp/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,281 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-18 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.el (selection-coercible-types): Initialise.
+
+2000-07-18 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.el (own-clipboard): Bug fix.
+
+2000-07-17  Mike Sperber  <mike@xemacs.org>
+
+	* cus-edit.el (custom-migrate-custom-file): Save init file before
+	continuing.
+
+2000-07-16  Mike Sperber  <mike@xemacs.org>
+
+	* startup.el (load-init-file): Remove silly call to
+	`load-user-custom-file`.
+	(maybe-migrate-user-init-file): Minor fixes.
+
+2000-07-16  Martin Buchholz  <martin@xemacs.org>
+
+	* apropos.el (apropos-documentation-check-doc-file): 
+	`doc' variable should be let-bound, as was presumably intended.
+
+	* cus-edit.el (custom-variable-reset-saved): 
+	(custom-variable-reset-standard): 
+	Remove unused variable comment-widget.  Twice.
+
+	* toolbar.el (toolbar-blank-press-function): 
+	Add a real defvar with initial value nil and proper docstring.
+	(press-toolbar-button): No need to check for boundp-ness anymore.
+
+	* rect.el (open-rectangle-line): Remove useless (let) form.
+	Add defvar for pending-delete-mode.
+
+	* info.el (Info-find-node): This function needs an autoload cookie.
+
+	* mule/mule-x-init.el (x-use-halfwidth-roman-font): 
+	Use let* since the second form referred to the first.
+
+2000-07-16  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* msw-select.el (mswindows-paste-clipboard): Use `get-clipboard'
+	instead of removed `mswindows-get-clipboard'.
+
+
+2000-07-15 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.el (select-convert-from-text): New.
+	* select.el (select-convert-from-length): New.
+	* select.el (select-convert-from-integer): New.
+	* select.el (select-convert-from-identity): New.
+	* select.el (select-convert-from-filename): New.
+	* select.el (selection-converter-in-alist): Use them.
+	New converter functions for X.
+
+	* select.el (get-selection): Removed comment.
+
+	* select.el (own-selection): Removed append code - I thought
+	I'd already done this, but apparently not...
+
+	* select.el: Changed comment about TIMESTAMP.
+
+	* select.el (select-convert-in): New.
+	* select.el (select-convert-out): New.
+	New functions that get used by select.c.
+
+	* select.el (select-buffer-killed-default): New.
+	* select.el (select-buffer-killed-text): New.
+	* select.el (selection-buffer-killed-alist): New.
+	New list and functions that get called if a relevant selection
+	exists and a buffer gets killed.
+
+	* select.el (select-convert-to-targets):
+	* select.el (select-convert-to-identity): Removed.
+	* select.el (select-convert-from-identity): Removed.
+	* select.el (select-converter-out-alist):
+	Removed _EMACS_INTERNAL selection type.
+
+	* x-select.el (xselect-kill-buffer-hook): Removed.
+	* x-select.el (xselect-kill-buffer-hook-1): Removed.
+	Removed this X-specific nonesense. Use the generic support
+	in select.el instead.
+
+2000-07-15  Martin Buchholz  <martin@xemacs.org>
+
+	* mule/mule-category.el (defined-category-hashtable): 
+	Use make-hash-table instead of make-hashtable
+
+	* buff-menu.el: Byte-compiler warning fix.
+
+	* isearch-mode.el (isearch-highlight-all-cleanup): 
+	Remove unused variable `isearch-highlight-all-start'.
+
+	* etags.el (add-to-tag-completion-table): Byte-compiler warning fix.
+
+	* itimer.el (itimer-edit-mode): Byte-compiler warning fixes.
+
+	* cus-dep.el (Custom-make-dependencies): 
+	Add autoload cookie for custom-add-loads to generated custom-load.el.
+
+	* autoload.el (autoload-package-name): Warning suppression.
+	Move defvar prior to first use.
+
+	* custom.el: Add autoload for custom-declare-face.
+	Allow `xemacs -no-autoloads -l bytecomp -f batch-byte-compile ...'
+	* cl.el (cl-hack-byte-compiler): 
+	Allow `xemacs -no-autoloads -l bytecomp -f batch-byte-compile ...'
+	to work properly.
+
+2000-07-08  Mike Sperber  <mike@xemacs.org>
+
+	* startup.el (load-home-init-file): Added variable.
+	(maybe-migrate-user-init-file): Added.
+	(load-user-init-file): Load custom file if different from init
+	file.
+
+	* dumped-lisp.el (preloaded-file-list): Added "cus-file" before
+	"startup."
+
+	* cus-edit.el (custom-migrate-custom-file): Added for migration.
+	Moved `custom-file'-related code to cus-file.el.
+
+	* cus-file.el: New file.
+
+2000-04-01  Mike Sperber  <mike@xemacs.org>
+
+	* packages.el (packages-find-package-directories): Added support
+	for external package hierarchies with in-place installations.
+
+	* find-paths.el (paths-root-in-place-p): Added.
+	(paths-find-emacs-directory): Added support for external
+	directories with in-place installations.
+	(paths-find-site-directory): Ditto.
+
+	* startup.el (find-user-init-file): Also look for
+	~/.xemacs/init.elc? in preference to ~/.emacs.
+
+2000-07-12 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.el (own-selection):
+	* select.el (own-clipboard): Changed `append' parameter to
+	`how-to-use' parameter.
+	* select.el (own-selection): Removed icky append code.
+	* select.el (own-selection, get-selection): Removed extra type
+	checking.
+	* select.el (selection-appender-alist):
+	* select.el (selection-converter-{in|out}-alist): Initialise.
+	* select.el (select-append-to-*): New.
+	* select.el (select-convert-from-*): New.  New functions to append
+	data and convert data from external type.
+
+2000-07-12  Stef Epardaud  <stef@lunatech.com>
+
+	* font-lock.el: Javadoc enhancements.
+
+2000-07-06  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
+
+	* printer.el (generic-print-region): Compose job name from buffer
+	name.
+
+2000-07-06  Yoshiki Hayashi  <yoshiki@xemacs.org>
+
+	* font-lock.el (font-lock-fontify-pending-extents): Call
+	font-lock-fontify-region instead of font-lock-fontify-buffer
+	to avoid unnecessary progress gauges.
+
+2000-07-06  Craig Lanning  <lanning@scra.org>
+
+	* custom-load.el (faces):
+
+        * finder.el (finder-compile-keywords): from Dan Holmsand, make sure
+        dir is a regex.
+
+        * process.el (call-process-internal): from Dan Holmsand, use binary
+        coding systems so that jka-compr works.
+
+2000-07-07  Ben Wing  <ben@xemacs.org>
+
+	* font-lock.el: Undo previous change.  Unfortunately, some
+	files actually use the variables directly in their init code
+	without quoting them.
+
+2000-07-07  Ben Wing  <ben@xemacs.org>
+
+	* font-lock.el (defvar font-lock-*-face): Removed.
+
+	* font-lock.el (font-lock-apply-highlight): Bind these face vars
+	only when necessary.
+
+2000-06-30  Charles G Waldman  <cgw@alum.mit.edu>
+	
+	* cl-macs.el: fix cl-transform-function-property kludge
+	so that it does not require a random feature.
+
+2000-06-09  Karl M. Hegbloom  <karlheg@bittersweet.inetarena.com>
+
+	* files.el (auto-mode-alist): allow .make extension for Makefiles,
+	as in Linux kernel "Rules.make".
+
+2000-06-29  Gunnar Evermann  <ge204@eng.cam.ac.uk>
+
+	* build-report.el (build-report): Add autoload cookie.
+
+2000-06-21  Charles G Waldman  <cgw@alum.mit.edu>
+
+	* package-ui.el (defgroup pui):  Correct a misspelling
+	(pui-toggle-package-delete):  Change `seleted' to `selected'
+	
+2000-06-12  Jan Vroonhof  <vroonhof@math.ethz.ch>
+
+	* package-get.el (package-get-update-base):	
+	(package-get): Use insert-file-contents-literally always.
+	(package-get-maybe-save-index):
+	Force coding system for writing to binary.
+
+2000-06-08  Mike Alexander  <mta@arbortext.com>
+
+	* code-process.el (call-process-region): If there is no coding
+	system for the process on process-coding-system-alist use the
+	coding system of the buffer containing the region.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* cmdloop.el (command-error):
+	If debug-on-error and noninteractive, output backtrace.
+
+	* files.el (file-relative-name):
+	Remove MSDOS references.
+
+	* simple.el (line-number): New function, due to non-obvious
+	behavior/usage of count-lines.
+
+	* simple.el (count-lines): document non-obvious usage to get
+	line number.
+
+2000-06-11  Ben Wing  <ben@xemacs.org>
+
+	* faces.el ((featurep 'xpm)):
+	* x-faces.el (x-init-face-from-resources):
+	* x-faces.el (x-init-frame-faces):
+	* x-misc.el (x-init-specifier-from-resources):
+	* x-misc.el (x-get-resource-and-bogosity-check):
+	* x-misc.el (x-get-resource-and-maybe-bogosity-check):
+	* x-mouse.el (x-init-pointer-shape):
+	* x-scrollbar.el (x-init-scrollbar-from-resources):
+	Add sixth argument to x-get-resource calls so as to issue warnings
+	rather than errors on bogus arguments.
+
+2000-06-05  Ben Wing  <ben@xemacs.org>
+
+	* compat.el: new file.  provides a clean, non-intrusive way to
+	define compatibility functions.
+
+	* process.el (shell-quote-argument): temporary fix for lack
+	of nt-quote-process-args.  #### I need to put back the overall
+	structure of that mechanism but redo the guts of it using the
+	extra intelligence in the C code.
+
+2000-05-28  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* package-info.el (pi-md5sum): Calculate MD5 sum just like
+	`package-get' does in package-get.el, instead of using external
+	"md5sum" program.
+
+	* package-get.el (package-get): Insert package file literally to
+	make checksum calculation work.
+
+2000-04-18  Hrvoje Niksic  <hniksic@iskon.hr>
+
+	* code-files.el (convert-mbox-coding-system): Deleted.
+	(file-coding-system-alist): Removed reference to
+	convert-mbox-coding-system.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
@@ -226,7 +504,7 @@
 	* gutter-items.el (make-search-dialog):
 	Change to new callback-ex api.
 
-2000-04-26  Björn Torkelsson  <torkel@hpc2n.umu.se>
+2000-04-26  Bjrn Torkelsson  <torkel@hpc2n.umu.se>
 
 	* help.el: (describe-installation): decode-coding-string is not
 	defined in a non MULE environment.
--- a/lisp/apropos.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/apropos.el	Mon Aug 13 11:19:21 2007 +0200
@@ -377,7 +377,7 @@
 ;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name.
 
 (defun apropos-documentation-check-doc-file ()
-  (let (type symbol (sepa 2) sepb beg end)
+  (let (type symbol (sepa 2) sepb beg end doc)
     (insert ?\^_)
     (backward-char)
     (insert-file-contents (concat doc-directory internal-doc-file-name))
--- a/lisp/auto-autoloads.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/auto-autoloads.el	Mon Aug 13 11:19:21 2007 +0200
@@ -1,6 +1,80 @@
 ;;; DO NOT MODIFY THIS FILE
 (if (featurep 'lisp-autoloads) (error "Already loaded"))
 
+;;;### (autoloads nil "abbrev" "lisp/abbrev.el")
+
+;;;***
+
+;;;### (autoloads (about-xemacs) "about" "lisp/about.el")
+
+(autoload 'about-xemacs "about" "\
+Describe the True Editor and its minions." t nil)
+
+;;;***
+
+;;;### (autoloads (set-modified-alist modify-alist remove-alist set-alist del-alist put-alist vassoc) "alist" "lisp/alist.el")
+
+(autoload 'vassoc "alist" "\
+Search VALIST for a vector whose first element is equal to KEY.
+See also `assoc'." nil nil)
+
+(autoload 'put-alist "alist" "\
+Modify ALIST to set VALUE to ITEM.
+If there is a pair whose car is ITEM, replace its cdr by VALUE.
+If there is not such pair, create new pair (ITEM . VALUE) and
+return new alist whose car is the new pair and cdr is ALIST.
+[tomo's ELIS like function]" nil nil)
+
+(autoload 'del-alist "alist" "\
+If there is a pair whose key is ITEM, delete it from ALIST.
+[tomo's ELIS emulating function]" nil nil)
+
+(autoload 'set-alist "alist" "\
+Modify a alist indicated by SYMBOL to set VALUE to ITEM." nil nil)
+
+(autoload 'remove-alist "alist" "\
+Remove ITEM from the alist indicated by SYMBOL." nil nil)
+
+(autoload 'modify-alist "alist" "\
+Modify alist DEFAULT into alist MODIFIER." nil nil)
+
+(autoload 'set-modified-alist "alist" "\
+Modify a value of a symbol SYM into alist MODIFIER.
+The symbol SYM should be alist. If it is not bound,
+its value regard as nil." nil nil)
+
+;;;***
+
+;;;### (autoloads (apropos-documentation apropos-value apropos apropos-command) "apropos" "lisp/apropos.el")
+
+(fset 'command-apropos 'apropos-command)
+
+(autoload 'apropos-command "apropos" "\
+Shows commands (interactively callable functions) that match REGEXP.
+With optional prefix ARG or if `apropos-do-all' is non-nil, also show
+variables." t nil)
+
+(autoload 'apropos "apropos" "\
+Show all bound symbols whose names match REGEXP.
+With optional prefix ARG or if `apropos-do-all' is non-nil, also show unbound
+symbols and key bindings, which is a little more time-consuming.
+Returns list of symbols and documentation found." t nil)
+
+(autoload 'apropos-value "apropos" "\
+Show all symbols whose value's printed image matches REGEXP.
+With optional prefix ARG or if `apropos-do-all' is non-nil, also looks
+at the function and at the names and values of properties.
+Returns list of symbols and values found." t nil)
+
+(autoload 'apropos-documentation "apropos" "\
+Show symbols whose documentation contain matches for REGEXP.
+With optional prefix ARG or if `apropos-do-all' is non-nil, also use
+documentation that is not stored in the documentation file and show key
+bindings.
+Returns list of symbols and documentation found." t nil)
+
+;;;***
+
 ;;;### (autoloads (batch-update-one-directory batch-update-directory batch-update-autoloads update-autoloads-from-directory update-autoloads-here update-file-autoloads generate-file-autoloads) "autoload" "lisp/autoload.el")
 
 (autoload 'generate-file-autoloads "autoload" "\
@@ -46,6 +120,30 @@
 
 ;;;***
 
+;;;### (autoloads nil "buff-menu" "lisp/buff-menu.el")
+
+(defvar list-buffers-directory nil)
+
+(make-variable-buffer-local 'list-buffers-directory)
+
+;;;***
+
+;;;### (autoloads (build-report) "build-report" "lisp/build-report.el")
+
+(autoload 'build-report "build-report" "\
+Initializes a fresh mail composition buffer using `compose-mail'
+with the contents of XEmacs Installation file and excerpts from XEmacs
+make output and errors and leaves point at the beginning of the mail text.
+ See also
+`compose-mail', `mail-user-agent',
+`build-report-destination',
+`build-report-keep-regexp',
+`build-report-delete-regexp',
+`build-report-make-output-file' and
+`build-report-installation-file'." t nil)
+
+;;;***
+
 ;;;### (autoloads (batch-byte-recompile-directory batch-byte-recompile-directory-norecurse batch-byte-compile-one-file batch-byte-compile display-call-tree byte-compile-sexp byte-compile compile-defun byte-compile-buffer byte-compile-and-load-file byte-compile-file byte-recompile-file byte-recompile-directory byte-force-recompile) "bytecomp" "lisp/bytecomp.el")
 
 (autoload 'byte-force-recompile "bytecomp" "\
@@ -138,6 +236,610 @@
 
 ;;;***
 
+;;;### (autoloads (compiler-macroexpand define-compiler-macro ignore-file-errors ignore-errors assert check-type typep deftype cl-struct-setf-expander defstruct define-modify-macro callf2 callf letf* letf rotatef shiftf remf cl-do-pop psetf setf get-setf-method defsetf define-setf-method declare the locally multiple-value-setq multiple-value-bind lexical-let* lexical-let symbol-macrolet macrolet labels flet progv psetq do-all-symbols do-symbols dotimes dolist do* do loop return-from return block etypecase typecase ecase case load-time-value eval-when destructuring-bind function* defmacro* defun* cl-compile-time-init) "cl-macs" "lisp/cl-macs.el")
+
+(autoload 'cl-compile-time-init "cl-macs" nil nil nil)
+
+(autoload 'defun* "cl-macs" "\
+(defun* NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.
+Like normal `defun', except ARGLIST allows full Common Lisp conventions,
+and BODY is implicitly surrounded by (block NAME ...)." nil 'macro)
+
+(autoload 'defmacro* "cl-macs" "\
+(defmacro* NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.
+Like normal `defmacro', except ARGLIST allows full Common Lisp conventions,
+and BODY is implicitly surrounded by (block NAME ...)." nil 'macro)
+
+(autoload 'function* "cl-macs" "\
+(function* SYMBOL-OR-LAMBDA): introduce a function.
+Like normal `function', except that if argument is a lambda form, its
+ARGLIST allows full Common Lisp conventions." nil 'macro)
+
+(autoload 'destructuring-bind "cl-macs" nil nil 'macro)
+
+(autoload 'eval-when "cl-macs" "\
+(eval-when (WHEN...) BODY...): control when BODY is evaluated.
+If `compile' is in WHEN, BODY is evaluated when compiled at top-level.
+If `load' is in WHEN, BODY is evaluated when loaded after top-level compile.
+If `eval' is in WHEN, BODY is evaluated when interpreted or at non-top-level." nil 'macro)
+
+(autoload 'load-time-value "cl-macs" "\
+Like `progn', but evaluates the body at load time.
+The result of the body appears to the compiler as a quoted constant." nil 'macro)
+
+(autoload 'case "cl-macs" "\
+(case EXPR CLAUSES...): evals EXPR, chooses from CLAUSES on that value.
+Each clause looks like (KEYLIST BODY...).  EXPR is evaluated and compared
+against each key in each KEYLIST; the corresponding BODY is evaluated.
+If no clause succeeds, case returns nil.  A single atom may be used in
+place of a KEYLIST of one atom.  A KEYLIST of `t' or `otherwise' is
+allowed only in the final clause, and matches if no other keys match.
+Key values are compared by `eql'." nil 'macro)
+
+(autoload 'ecase "cl-macs" "\
+(ecase EXPR CLAUSES...): like `case', but error if no case fits.
+`otherwise'-clauses are not allowed." nil 'macro)
+
+(autoload 'typecase "cl-macs" "\
+(typecase EXPR CLAUSES...): evals EXPR, chooses from CLAUSES on that value.
+Each clause looks like (TYPE BODY...).  EXPR is evaluated and, if it
+satisfies TYPE, the corresponding BODY is evaluated.  If no clause succeeds,
+typecase returns nil.  A TYPE of `t' or `otherwise' is allowed only in the
+final clause, and matches if no other keys match." nil 'macro)
+
+(autoload 'etypecase "cl-macs" "\
+(etypecase EXPR CLAUSES...): like `typecase', but error if no case fits.
+`otherwise'-clauses are not allowed." nil 'macro)
+
+(autoload 'block "cl-macs" "\
+(block NAME BODY...): define a lexically-scoped block named NAME.
+NAME may be any symbol.  Code inside the BODY forms can call `return-from'
+to jump prematurely out of the block.  This differs from `catch' and `throw'
+in two respects:  First, the NAME is an unevaluated symbol rather than a
+quoted symbol or other form; and second, NAME is lexically rather than
+dynamically scoped:  Only references to it within BODY will work.  These
+references may appear inside macro expansions, but not inside functions
+called from BODY." nil 'macro)
+
+(autoload 'return "cl-macs" "\
+(return [RESULT]): return from the block named nil.
+This is equivalent to `(return-from nil RESULT)'." nil 'macro)
+
+(autoload 'return-from "cl-macs" "\
+(return-from NAME [RESULT]): return from the block named NAME.
+This jumps out to the innermost enclosing `(block NAME ...)' form,
+returning RESULT from that form (or nil if RESULT is omitted).
+This is compatible with Common Lisp, but note that `defun' and
+`defmacro' do not create implicit blocks as they do in Common Lisp." nil 'macro)
+
+(autoload 'loop "cl-macs" "\
+(loop CLAUSE...): The Common Lisp `loop' macro.
+Valid clauses are:
+  for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
+  for VAR in LIST by FUNC, for VAR on LIST by FUNC, for VAR = INIT then EXPR,
+  for VAR across ARRAY, repeat NUM, with VAR = INIT, while COND, until COND,
+  always COND, never COND, thereis COND, collect EXPR into VAR,
+  append EXPR into VAR, nconc EXPR into VAR, sum EXPR into VAR,
+  count EXPR into VAR, maximize EXPR into VAR, minimize EXPR into VAR,
+  if COND CLAUSE [and CLAUSE]... else CLAUSE [and CLAUSE...],
+  unless COND CLAUSE [and CLAUSE]... else CLAUSE [and CLAUSE...],
+  do EXPRS..., initially EXPRS..., finally EXPRS..., return EXPR,
+  finally return EXPR, named NAME." nil 'macro)
+
+(autoload 'do "cl-macs" "\
+The Common Lisp `do' loop.
+Format is: (do ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil 'macro)
+
+(autoload 'do* "cl-macs" "\
+The Common Lisp `do*' loop.
+Format is: (do* ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil 'macro)
+
+(autoload 'dolist "cl-macs" "\
+(dolist (VAR LIST [RESULT]) BODY...): loop over a list.
+Evaluate BODY with VAR bound to each `car' from LIST, in turn.
+Then evaluate RESULT to get return value, default nil." nil 'macro)
+
+(autoload 'dotimes "cl-macs" "\
+(dotimes (VAR COUNT [RESULT]) BODY...): loop a certain number of times.
+Evaluate BODY with VAR bound to successive integers from 0, inclusive,
+to COUNT, exclusive.  Then evaluate RESULT to get return value, default
+nil." nil 'macro)
+
+(autoload 'do-symbols "cl-macs" "\
+(dosymbols (VAR [OBARRAY [RESULT]]) BODY...): loop over all symbols.
+Evaluate BODY with VAR bound to each interned symbol, or to each symbol
+from OBARRAY." nil 'macro)
+
+(autoload 'do-all-symbols "cl-macs" nil nil 'macro)
+
+(autoload 'psetq "cl-macs" "\
+(psetq SYM VAL SYM VAL ...): set SYMs to the values VALs in parallel.
+This is like `setq', except that all VAL forms are evaluated (in order)
+before assigning any symbols SYM to the corresponding values." nil 'macro)
+
+(autoload 'progv "cl-macs" "\
+(progv SYMBOLS VALUES BODY...): bind SYMBOLS to VALUES dynamically in BODY.
+The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
+Each SYMBOL in the first list is bound to the corresponding VALUE in the
+second list (or made unbound if VALUES is shorter than SYMBOLS); then the
+BODY forms are executed and their result is returned.  This is much like
+a `let' form, except that the list of symbols can be computed at run-time." nil 'macro)
+
+(autoload 'flet "cl-macs" "\
+(flet ((FUNC ARGLIST BODY...) ...) FORM...): make temporary function defns.
+This is an analogue of `let' that operates on the function cell of FUNC
+rather than its value cell.  The FORMs are evaluated with the specified
+function definitions in place, then the definitions are undone (the FUNCs
+go back to their previous definitions, or lack thereof)." nil 'macro)
+
+(autoload 'labels "cl-macs" "\
+(labels ((FUNC ARGLIST BODY...) ...) FORM...): make temporary func bindings.
+This is like `flet', except the bindings are lexical instead of dynamic.
+Unlike `flet', this macro is fully compliant with the Common Lisp standard." nil 'macro)
+
+(autoload 'macrolet "cl-macs" "\
+(macrolet ((NAME ARGLIST BODY...) ...) FORM...): make temporary macro defns.
+This is like `flet', but for macros instead of functions." nil 'macro)
+
+(autoload 'symbol-macrolet "cl-macs" "\
+(symbol-macrolet ((NAME EXPANSION) ...) FORM...): make symbol macro defns.
+Within the body FORMs, references to the variable NAME will be replaced
+by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...)." nil 'macro)
+
+(autoload 'lexical-let "cl-macs" "\
+(lexical-let BINDINGS BODY...): like `let', but lexically scoped.
+The main visible difference is that lambdas inside BODY will create
+lexical closures as in Common Lisp." nil 'macro)
+
+(autoload 'lexical-let* "cl-macs" "\
+(lexical-let* BINDINGS BODY...): like `let*', but lexically scoped.
+The main visible difference is that lambdas inside BODY will create
+lexical closures as in Common Lisp." nil 'macro)
+
+(autoload 'multiple-value-bind "cl-macs" "\
+(multiple-value-bind (SYM SYM...) FORM BODY): collect multiple return values.
+FORM must return a list; the BODY is then executed with the first N elements
+of this list bound (`let'-style) to each of the symbols SYM in turn.  This
+is analogous to the Common Lisp `multiple-value-bind' macro, using lists to
+simulate true multiple return values.  For compatibility, (values A B C) is
+a synonym for (list A B C)." nil 'macro)
+
+(autoload 'multiple-value-setq "cl-macs" "\
+(multiple-value-setq (SYM SYM...) FORM): collect multiple return values.
+FORM must return a list; the first N elements of this list are stored in
+each of the symbols SYM in turn.  This is analogous to the Common Lisp
+`multiple-value-setq' macro, using lists to simulate true multiple return
+values.  For compatibility, (values A B C) is a synonym for (list A B C)." nil 'macro)
+
+(autoload 'locally "cl-macs" nil nil 'macro)
+
+(autoload 'the "cl-macs" nil nil 'macro)
+
+(autoload 'declare "cl-macs" nil nil 'macro)
+
+(autoload 'define-setf-method "cl-macs" "\
+(define-setf-method NAME ARGLIST BODY...): define a `setf' method.
+This method shows how to handle `setf's to places of the form (NAME ARGS...).
+The argument forms ARGS are bound according to ARGLIST, as if NAME were
+going to be expanded as a macro, then the BODY forms are executed and must
+return a list of five elements: a temporary-variables list, a value-forms
+list, a store-variables list (of length one), a store-form, and an access-
+form.  See `defsetf' for a simpler way to define most setf-methods." nil 'macro)
+
+(autoload 'defsetf "cl-macs" "\
+(defsetf NAME FUNC): define a `setf' method.
+This macro is an easy-to-use substitute for `define-setf-method' that works
+well for simple place forms.  In the simple `defsetf' form, `setf's of
+the form (setf (NAME ARGS...) VAL) are transformed to function or macro
+calls of the form (FUNC ARGS... VAL).  Example: (defsetf aref aset).
+Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
+Here, the above `setf' call is expanded by binding the argument forms ARGS
+according to ARGLIST, binding the value form VAL to STORE, then executing
+BODY, which must return a Lisp form that does the necessary `setf' operation.
+Actually, ARGLIST and STORE may be bound to temporary variables which are
+introduced automatically to preserve proper execution order of the arguments.
+Example: (defsetf nth (n x) (v) (list 'setcar (list 'nthcdr n x) v))." nil 'macro)
+
+(autoload 'get-setf-method "cl-macs" "\
+Return a list of five values describing the setf-method for PLACE.
+PLACE may be any Lisp form which can appear as the PLACE argument to
+a macro like `setf' or `incf'." nil nil)
+
+(autoload 'setf "cl-macs" "\
+(setf PLACE VAL PLACE VAL ...): set each PLACE to the value of its VAL.
+This is a generalized version of `setq'; the PLACEs may be symbolic
+references such as (car x) or (aref x i), as well as plain symbols.
+For example, (setf (cadar x) y) is equivalent to (setcar (cdar x) y).
+The return value is the last VAL in the list." nil 'macro)
+
+(autoload 'psetf "cl-macs" "\
+(psetf PLACE VAL PLACE VAL ...): set PLACEs to the values VALs in parallel.
+This is like `setf', except that all VAL forms are evaluated (in order)
+before assigning any PLACEs to the corresponding values." nil 'macro)
+
+(autoload 'cl-do-pop "cl-macs" nil nil nil)
+
+(autoload 'remf "cl-macs" "\
+(remf PLACE TAG): remove TAG from property list PLACE.
+PLACE may be a symbol, or any generalized variable allowed by `setf'.
+The form returns true if TAG was found and removed, nil otherwise." nil 'macro)
+
+(autoload 'shiftf "cl-macs" "\
+(shiftf PLACE PLACE... VAL): shift left among PLACEs.
+Example: (shiftf A B C) sets A to B, B to C, and returns the old A.
+Each PLACE may be a symbol, or any generalized variable allowed by `setf'." nil 'macro)
+
+(autoload 'rotatef "cl-macs" "\
+(rotatef PLACE...): rotate left among PLACEs.
+Example: (rotatef A B C) sets A to B, B to C, and C to A.  It returns nil.
+Each PLACE may be a symbol, or any generalized variable allowed by `setf'." nil 'macro)
+
+(autoload 'letf "cl-macs" "\
+(letf ((PLACE VALUE) ...) BODY...): temporarily bind to PLACEs.
+This is the analogue of `let', but with generalized variables (in the
+sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
+VALUE, then the BODY forms are executed.  On exit, either normally or
+because of a `throw' or error, the PLACEs are set back to their original
+values.  Note that this macro is *not* available in Common Lisp.
+As a special case, if `(PLACE)' is used instead of `(PLACE VALUE)',
+the PLACE is not modified before executing BODY." nil 'macro)
+
+(autoload 'letf* "cl-macs" "\
+(letf* ((PLACE VALUE) ...) BODY...): temporarily bind to PLACEs.
+This is the analogue of `let*', but with generalized variables (in the
+sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
+VALUE, then the BODY forms are executed.  On exit, either normally or
+because of a `throw' or error, the PLACEs are set back to their original
+values.  Note that this macro is *not* available in Common Lisp.
+As a special case, if `(PLACE)' is used instead of `(PLACE VALUE)',
+the PLACE is not modified before executing BODY." nil 'macro)
+
+(autoload 'callf "cl-macs" "\
+(callf FUNC PLACE ARGS...): set PLACE to (FUNC PLACE ARGS...).
+FUNC should be an unquoted function name.  PLACE may be a symbol,
+or any generalized variable allowed by `setf'." nil 'macro)
+
+(autoload 'callf2 "cl-macs" "\
+(callf2 FUNC ARG1 PLACE ARGS...): set PLACE to (FUNC ARG1 PLACE ARGS...).
+Like `callf', but PLACE is the second argument of FUNC, not the first." nil 'macro)
+
+(autoload 'define-modify-macro "cl-macs" "\
+(define-modify-macro NAME ARGLIST FUNC): define a `setf'-like modify macro.
+If NAME is called, it combines its PLACE argument with the other arguments
+from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" nil 'macro)
+
+(autoload 'defstruct "cl-macs" "\
+(defstruct (NAME OPTIONS...) (SLOT SLOT-OPTS...)...): define a struct type.
+This macro defines a new Lisp data type called NAME, which contains data
+stored in SLOTs.  This defines a `make-NAME' constructor, a `copy-NAME'
+copier, a `NAME-p' predicate, and setf-able `NAME-SLOT' accessors." nil 'macro)
+
+(autoload 'cl-struct-setf-expander "cl-macs" nil nil nil)
+
+(autoload 'deftype "cl-macs" "\
+(deftype NAME ARGLIST BODY...): define NAME as a new data type.
+The type name can then be used in `typecase', `check-type', etc." nil 'macro)
+
+(autoload 'typep "cl-macs" "\
+Check that OBJECT is of type TYPE.
+TYPE is a Common Lisp-style type specifier." nil nil)
+
+(autoload 'check-type "cl-macs" "\
+Verify that FORM is of type TYPE; signal an error if not.
+STRING is an optional description of the desired type." nil 'macro)
+
+(autoload 'assert "cl-macs" "\
+Verify that FORM returns non-nil; signal an error if not.
+Second arg SHOW-ARGS means to include arguments of FORM in message.
+Other args STRING and ARGS... are arguments to be passed to `error'.
+They are not evaluated unless the assertion fails.  If STRING is
+omitted, a default message listing FORM itself is used." nil 'macro)
+
+(autoload 'ignore-errors "cl-macs" "\
+Execute FORMS; if an error occurs, return nil.
+Otherwise, return result of last FORM." nil 'macro)
+
+(autoload 'ignore-file-errors "cl-macs" "\
+Execute FORMS; if an error of type `file-error' occurs, return nil.
+Otherwise, return result of last FORM." nil 'macro)
+
+(autoload 'define-compiler-macro "cl-macs" "\
+(define-compiler-macro FUNC ARGLIST BODY...): Define a compiler-only macro.
+This is like `defmacro', but macro expansion occurs only if the call to
+FUNC is compiled (i.e., not interpreted).  Compiler macros should be used
+for optimizing the way calls to FUNC are compiled; the form returned by
+BODY should do the same thing as a call to the normal function called
+FUNC, though possibly more efficiently.  Note that, like regular macros,
+compiler macros are expanded repeatedly until no further expansions are
+possible.  Unlike regular macros, BODY can decide to \"punt\" and leave the
+original function call alone by declaring an initial `&whole foo' parameter
+and then returning foo." nil 'macro)
+
+(autoload 'compiler-macroexpand "cl-macs" nil nil nil)
+
+;;;***
+
+;;;### (autoloads (batch-remove-old-elc) "cleantree" "lisp/cleantree.el")
+
+(autoload 'batch-remove-old-elc "cleantree" nil nil nil)
+
+;;;***
+
+;;;### (autoloads (config-value config-value-hash-table) "config" "lisp/config.el")
+
+(autoload 'config-value-hash-table "config" "\
+Return hash table of configuration parameters and their values." nil nil)
+
+(autoload 'config-value "config" "\
+Return the value of the configuration parameter CONFIG_SYMBOL." nil nil)
+
+;;;***
+
+;;;### (autoloads (Custom-make-dependencies) "cus-dep" "lisp/cus-dep.el")
+
+(autoload 'Custom-make-dependencies "cus-dep" "\
+Extract custom dependencies from .el files in SUBDIRS.
+SUBDIRS is a list of directories.  If it is nil, the command-line
+arguments are used.  If it is a string, only that directory is
+processed.  This function is especially useful in batch mode.
+
+Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" t nil)
+
+;;;***
+
+;;;### (autoloads (custom-migrate-custom-file customize-menu-create custom-menu-create custom-save-all customize-save-customized customize-browse custom-buffer-create-other-window custom-buffer-create customize-apropos-groups customize-apropos-faces customize-apropos-options customize-apropos customize-saved customize-customized customize-face-other-window customize-face customize-option-other-window customize-changed-options customize-variable customize-other-window customize customize-save-variable customize-set-variable customize-set-value) "cus-edit" "lisp/cus-edit.el")
+
+(autoload 'customize-set-value "cus-edit" "\
+Set VARIABLE to VALUE.  VALUE is a Lisp object.
+
+If VARIABLE has a `variable-interactive' property, that is used as if
+it were the arg to `interactive' (which see) to interactively read the value.
+
+If VARIABLE has a `custom-type' property, it must be a widget and the
+`:prompt-value' property of that widget will be used for reading the value.
+
+If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
+
+(autoload 'customize-set-variable "cus-edit" "\
+Set the default for VARIABLE to VALUE.  VALUE is a Lisp object.
+
+If VARIABLE has a `custom-set' property, that is used for setting
+VARIABLE, otherwise `set-default' is used.
+
+The `customized-value' property of the VARIABLE will be set to a list
+with a quoted VALUE as its sole list member.
+
+If VARIABLE has a `variable-interactive' property, that is used as if
+it were the arg to `interactive' (which see) to interactively read the value.
+
+If VARIABLE has a `custom-type' property, it must be a widget and the
+`:prompt-value' property of that widget will be used for reading the value.
+
+If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
+
+(autoload 'customize-save-variable "cus-edit" "\
+Set the default for VARIABLE to VALUE, and save it for future sessions.
+If VARIABLE has a `custom-set' property, that is used for setting
+VARIABLE, otherwise `set-default' is used.
+
+The `customized-value' property of the VARIABLE will be set to a list
+with a quoted VALUE as its sole list member.
+
+If VARIABLE has a `variable-interactive' property, that is used as if
+it were the arg to `interactive' (which see) to interactively read the value.
+
+If VARIABLE has a `custom-type' property, it must be a widget and the
+`:prompt-value' property of that widget will be used for reading the value.
+
+If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
+
+(autoload 'customize "cus-edit" "\
+Select a customization buffer which you can use to set user options.
+User options are structured into \"groups\".
+The default group is `Emacs'." t nil)
+
+(defalias 'customize-group 'customize)
+
+(autoload 'customize-other-window "cus-edit" "\
+Customize SYMBOL, which must be a customization group." t nil)
+
+(defalias 'customize-group-other-window 'customize-other-window)
+
+(defalias 'customize-option 'customize-variable)
+
+(autoload 'customize-variable "cus-edit" "\
+Customize SYMBOL, which must be a user option variable." t nil)
+
+(autoload 'customize-changed-options "cus-edit" "\
+Customize all user option variables whose default values changed recently.
+This means, in other words, variables defined with a `:version' keyword." t nil)
+
+(defalias 'customize-variable-other-window 'customize-option-other-window)
+
+(autoload 'customize-option-other-window "cus-edit" "\
+Customize SYMBOL, which must be a user option variable.
+Show the buffer in another window, but don't select it." t nil)
+
+(autoload 'customize-face "cus-edit" "\
+Customize SYMBOL, which should be a face name or nil.
+If SYMBOL is nil, customize all faces." t nil)
+
+(autoload 'customize-face-other-window "cus-edit" "\
+Show customization buffer for FACE in other window." t nil)
+
+(autoload 'customize-customized "cus-edit" "\
+Customize all user options set since the last save in this session." t nil)
+
+(autoload 'customize-saved "cus-edit" "\
+Customize all already saved user options." t nil)
+
+(autoload 'customize-apropos "cus-edit" "\
+Customize all user options matching REGEXP.
+If ALL is `options', include only options.
+If ALL is `faces', include only faces.
+If ALL is `groups', include only groups.
+If ALL is t (interactively, with prefix arg), include options which are not
+user-settable, as well as faces and groups." t nil)
+
+(autoload 'customize-apropos-options "cus-edit" "\
+Customize all user options matching REGEXP.
+With prefix arg, include options which are not user-settable." t nil)
+
+(autoload 'customize-apropos-faces "cus-edit" "\
+Customize all user faces matching REGEXP." t nil)
+
+(autoload 'customize-apropos-groups "cus-edit" "\
+Customize all user groups matching REGEXP." t nil)
+
+(autoload 'custom-buffer-create "cus-edit" "\
+Create a buffer containing OPTIONS.
+Optional NAME is the name of the buffer.
+OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
+SYMBOL is a customization option, and WIDGET is a widget for editing
+that option." nil nil)
+
+(autoload 'custom-buffer-create-other-window "cus-edit" "\
+Create a buffer containing OPTIONS.
+Optional NAME is the name of the buffer.
+OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
+SYMBOL is a customization option, and WIDGET is a widget for editing
+that option." nil nil)
+
+(autoload 'customize-browse "cus-edit" "\
+Create a tree browser for the customize hierarchy." t nil)
+
+(autoload 'customize-save-customized "cus-edit" "\
+Save all user options which have been set in this session." t nil)
+
+(autoload 'custom-save-all "cus-edit" "\
+Save all customizations in `custom-file'." nil nil)
+
+(autoload 'custom-menu-create "cus-edit" "\
+Create menu for customization group SYMBOL.
+The menu is in a format applicable to `easy-menu-define'." nil nil)
+
+(autoload 'customize-menu-create "cus-edit" "\
+Return a customize menu for customization group SYMBOL.
+If optional NAME is given, use that as the name of the menu.
+Otherwise the menu will be named `Customize'.
+The format is suitable for use with `easy-menu-define'." nil nil)
+
+(autoload 'custom-migrate-custom-file "cus-edit" "\
+Migrate custom file from home directory." nil nil)
+
+;;;***
+
+;;;### (autoloads (custom-reset-faces custom-theme-reset-faces custom-theme-face-value custom-theme-set-faces custom-set-faces custom-set-face-update-spec custom-declare-face) "cus-face" "lisp/cus-face.el")
+
+(autoload 'custom-declare-face "cus-face" "\
+Like `defface', but FACE is evaluated as a normal argument." nil nil)
+
+(autoload 'custom-set-face-update-spec "cus-face" "\
+Customize the FACE for display types matching DISPLAY, merging
+  in the new items from PLIST" nil nil)
+
+(autoload 'custom-set-faces "cus-face" "\
+Initialize faces according to user preferences.
+This asociates the setting with the USER theme.
+The arguments should be a list where each entry has the form:
+
+  (FACE SPEC [NOW [COMMENT]])
+
+SPEC will be stored as the saved value for FACE.  If NOW is present
+and non-nil, FACE will also be created according to SPEC.
+COMMENT is a string comment about FACE.
+
+See `defface' for the format of SPEC." nil nil)
+
+(autoload 'custom-theme-set-faces "cus-face" "\
+Initialize faces according to settings specified by args.
+Records the settings as belonging to THEME.
+
+See `custom-set-faces' for a description of the arguments ARGS." nil nil)
+
+(autoload 'custom-theme-face-value "cus-face" "\
+Return spec of FACE in THEME if the THEME modifies the
+FACE.  Nil otherwise." nil nil)
+
+(autoload 'custom-theme-reset-faces "cus-face" nil nil nil)
+
+(autoload 'custom-reset-faces "cus-face" "\
+Reset the value of the face to values previously defined.
+Assosiate this setting with the 'user' theme.
+
+ARGS is defined as for `custom-theme-reset-faces'" nil nil)
+
+;;;***
+
+;;;### (autoloads (make-custom-file-name) "cus-file" "lisp/cus-file.el")
+
+(defconst custom-file-base "custom.el" "\
+Base of file name for storing customization information.")
+
+(defvar custom-file nil "\
+File used for storing customization information.
+If you change this from the default you need to
+explicitly load that file for the settings to take effect.")
+
+(autoload 'make-custom-file-name "cus-file" "\
+Construct the default custom file name from the init file name.
+If FORCE-NEW is non-nil, force post-migration location." nil nil)
+
+;;;***
+
+;;;### (autoloads (disassemble) "disass" "lisp/disass.el")
+
+(autoload 'disassemble "disass" "\
+Print disassembled code for OBJECT in (optional) BUFFER.
+OBJECT can be a symbol defined as a function, or a function itself
+\(a lambda expression or a compiled-function object).
+If OBJECT is not already compiled, we compile it, but do not
+redefine OBJECT if it is a symbol." t nil)
+
+;;;***
+
+;;;### (autoloads (standard-display-european standard-display-underline standard-display-graphic standard-display-g1 standard-display-ascii standard-display-default standard-display-8bit make-display-table describe-current-display-table) "disp-table" "lisp/disp-table.el")
+
+(autoload 'describe-current-display-table "disp-table" "\
+Describe the display table in use in the selected window and buffer." t nil)
+
+(autoload 'make-display-table "disp-table" "\
+Return a new, empty display table." nil nil)
+
+(autoload 'standard-display-8bit "disp-table" "\
+Display characters in the range L to H literally." nil nil)
+
+(autoload 'standard-display-default "disp-table" "\
+Display characters in the range L to H using the default notation." nil nil)
+
+(autoload 'standard-display-ascii "disp-table" "\
+Display character C using printable string S." nil nil)
+
+(autoload 'standard-display-g1 "disp-table" "\
+Display character C as character SC in the g1 character set.
+This function assumes that your terminal uses the SO/SI characters;
+it is meaningless for an X frame." nil nil)
+
+(autoload 'standard-display-graphic "disp-table" "\
+Display character C as character GC in graphics character set.
+This function assumes VT100-compatible escapes; it is meaningless for an
+X frame." nil nil)
+
+(autoload 'standard-display-underline "disp-table" "\
+Display character C as character UC plus underlining." nil nil)
+
+(autoload 'standard-display-european "disp-table" "\
+Toggle display of European characters encoded with ISO 8859.
+When enabled, characters in the range of 160 to 255 display not
+as octal escapes, but as accented characters.
+With prefix argument, enable European character display iff arg is positive." t nil)
+
+;;;***
+
+;;;### (autoloads nil "easymenu" "lisp/easymenu.el")
+
+;;;***
+
 ;;;### (autoloads (pop-tag-mark tags-apropos list-tags tags-query-replace tags-search tags-loop-continue next-file tag-complete-symbol find-tag-other-window find-tag find-tag-at-point visit-tags-table) "etags" "lisp/etags.el")
 
 (autoload 'visit-tags-table "etags" "\
@@ -276,95 +978,123 @@
 (defcustom font-lock-maximum-size (* 250 1024) "*If non-nil, the maximum size for buffers for fontifying.\nOnly buffers less than this can be fontified when Font Lock mode is turned on.\nIf nil, means size is irrelevant.\nIf a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),\nwhere MAJOR-MODE is a symbol or t (meaning the default).  For example:\n ((c++-mode . 256000) (c-mode . 256000) (rmail-mode . 1048576))\nmeans that the maximum size is 250K for buffers in `c++-mode' or `c-mode', one\nmegabyte for buffers in `rmail-mode', and size is irrelevant otherwise." :type '(choice (const :tag "none" nil) (integer :tag "size") (repeat :menu-tag "mode specific" :tag "mode specific" :value ((t)) (cons :tag "Instance" (radio :tag "Mode" (const :tag "all" t) (symbol :tag "name")) (radio :tag "Size" (const :tag "none" nil) (integer :tag "size"))))) :group 'font-lock)
 
 (defvar font-lock-keywords nil "\
-A list of the keywords to highlight.
-Each element should be of the form:
+A list defining the keywords for `font-lock-mode' to highlight.
+
+ FONT-LOCK-KEYWORDS := List of FONT-LOCK-FORM's.
+
+ FONT-LOCK-FORM     :== MATCHER
+                      | (MATCHER . MATCH)
+                      | (MATCHER . FACE-FORM)
+                      | (MATCHER . HIGHLIGHT)
+                      | (MATCHER HIGHLIGHT ...)
+                      | (eval . FORM)
+
+ MATCHER            :== A string containing a regexp.
+                      | A variable containing a regexp to search for.
+                      | A function to call to make the search.
+                        It is called with one arg, the limit of the search,
+                        and should leave MATCH results in the XEmacs global
+                        match data.
+
+ MATCH              :== An integer match subexpression number from MATCHER.
+
+ FACE-FORM           :== The symbol naming a defined face.
+                      | Expression whos value is the face name to use.  If you
+                        want FACE-FORM to be a symbol that evaluates to a face,
+                        use a form like \"(progn sym)\".
+
+ HIGHLIGHT          :== MATCH-HIGHLIGHT
+                      | MATCH-ANCHORED
+
+ FORM               :== Expression returning a FONT-LOCK-FORM, evaluated when
+                        the FONT-LOCK-FORM is first used in a buffer.  This
+                        feature can be used to provide a FONT-LOCK-FORM that
+                        can only be generated when Font Lock mode is actually
+                        turned on.
+
+ MATCH-HIGHLIGHT    :== (MATCH FACE-FORM OVERRIDE LAXMATCH)
+
+ OVERRIDE           :== t        - overwrite existing fontification
+                      | 'keep    - only parts not already fontified are
+                                   highlighted.
+                      | 'prepend - merge faces, this fontification has
+                                   precedence over existing
+                      | 'append  - merge faces, existing fontification has
+                                   precedence over
+                                   this face.
+
+ LAXMATCH           :== If non-nil, no error is signalled if there is no MATCH
+                        in MATCHER.
+
+ MATCH-ANCHORED     :== (ANCHOR-MATCHER PRE-MATCH-FORM \\
+                                          POST-MATCH-FORM MATCH-HIGHLIGHT ...)
 
- MATCHER
- (MATCHER . MATCH)
- (MATCHER . FACENAME)
- (MATCHER . HIGHLIGHT)
- (MATCHER HIGHLIGHT ...)
- (eval . FORM)
+ ANCHOR-MATCHER     :== Like a MATCHER, except that the limit of the search
+                        defaults to the end of the line after PRE-MATCH-FORM
+                        is evaluated.  However, if PRE-MATCH-FORM returns a
+                        position greater than the end of the line, that
+                        position is used as the limit of the search.  It is
+                        generally a bad idea to return a position greater than
+                        the end of the line, i.e., cause the ANCHOR-MATCHER
+                        search to span lines.
+
+ PRE-MATCH-FORM     :== Evaluated before the ANCHOR-MATCHER is used, therefore
+                        can be used to initialize before, ANCHOR-MATCHER is
+                        used.  Typically, PRE-MATCH-FORM is used to move to
+                        some position relative to the original MATCHER, before
+                        starting with the ANCHOR-MATCHER.
+
+ POST-MATCH-FORM    :== Like PRE-MATCH-FORM, but used to clean up after the
+                        ANCHOR-MATCHER.  It might be used to move, before
+                        resuming with MATCH-ANCHORED's parent's MATCHER.
+
+For example, an element of the first form highlights (if not already highlighted):
+
+  \"\\\\<foo\\\\>\"                    Discrete occurrences of \"foo\" in the value
+                                 of the variable `font-lock-keyword-face'.
 
-where HIGHLIGHT should be either MATCH-HIGHLIGHT or MATCH-ANCHORED.
+  (\"fu\\\\(bar\\\\)\" . 1)            Substring \"bar\" within all occurrences of
+                                 \"fubar\" in the value of
+                                 `font-lock-keyword-face'.
+
+  (\"fubar\" . fubar-face)         Occurrences of \"fubar\" in the value of
+                                 `fubar-face'.
+
+  (\"foo\\\\|bar\" 0 foo-bar-face t) Occurrences of either \"foo\" or \"bar\" in the
+                                 value of `foo-bar-face', even if already
+                                 highlighted.
 
-FORM is an expression, whose value should be a keyword element,
-evaluated when the keyword is (first) used in a buffer.  This feature
-can be used to provide a keyword that can only be generated when Font
-Lock mode is actually turned on.
+  (fubar-match 1 fubar-face)     The first subexpression within all
+                                 occurrences of whatever the function
+                                 `fubar-match' finds and matches in the value
+                                 of `fubar-face'.
+
+  (\"\\\\<anchor\\\\>\" (0 anchor-face) (\"\\\\<item\\\\>\" nil nil (0 item-face)))
+   -------------- ---------------  ------------ --- --- -------------
+       |            |               |            |   |          |
+   MATCHER          |         ANCHOR-MATCHER     |   +------+ MATCH-HIGHLIGHT
+             MATCH-HIGHLIGHT                 PRE-MATCH-FORM |
+                                                           POST-MATCH-FORM
+
+  Discrete occurrences of \"anchor\" in the value of `anchor-face', and
+  subsequent discrete occurrences of \"item\" (on the same line) in the value
+  of `item-face'.  (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil.
+  Therefore \"item\" is initially searched for starting from the end of the
+  match of \"anchor\", and searching for subsequent instance of \"anchor\"
+  resumes from where searching for \"item\" concluded.)
 
 For highlighting single items, typically only MATCH-HIGHLIGHT is required.
-However, if an item or (typically) items is to be highlighted following the
-instance of another item (the anchor) then MATCH-ANCHORED may be required.
-
-MATCH-HIGHLIGHT should be of the form:
-
- (MATCH FACENAME OVERRIDE LAXMATCH)
-
-Where MATCHER can be either the regexp to search for, a variable
-containing the regexp to search for, or the function to call to make
-the search (called with one argument, the limit of the search).  MATCH
-is the subexpression of MATCHER to be highlighted.  FACENAME is either
-a symbol naming a face, or an expression whose value is the face name
-to use.  If you want FACENAME to be a symbol that evaluates to a face,
-use a form like \"(progn sym)\".
-
-OVERRIDE and LAXMATCH are flags.  If OVERRIDE is t, existing fontification may
-be overwritten.  If `keep', only parts not already fontified are highlighted.
-If `prepend' or `append', existing fontification is merged with the new, in
-which the new or existing fontification, respectively, takes precedence.
-If LAXMATCH is non-nil, no error is signalled if there is no MATCH in MATCHER.
-
-For example, an element of the form highlights (if not already highlighted):
-
- \"\\\\\\=<foo\\\\\\=>\"		Discrete occurrences of \"foo\" in the value of the
-			variable `font-lock-keyword-face'.
- (\"fu\\\\(bar\\\\)\" . 1)	Substring \"bar\" within all occurrences of \"fubar\" in
-			the value of `font-lock-keyword-face'.
- (\"fubar\" . fubar-face)	Occurrences of \"fubar\" in the value of `fubar-face'.
- (\"foo\\\\|bar\" 0 foo-bar-face t)
-			Occurrences of either \"foo\" or \"bar\" in the value
-			of `foo-bar-face', even if already highlighted.
-
-MATCH-ANCHORED should be of the form:
-
- (MATCHER PRE-MATCH-FORM POST-MATCH-FORM MATCH-HIGHLIGHT ...)
-
-Where MATCHER is as for MATCH-HIGHLIGHT with one exception; see below.
-PRE-MATCH-FORM and POST-MATCH-FORM are evaluated before the first, and after
-the last, instance MATCH-ANCHORED's MATCHER is used.  Therefore they can be
-used to initialize before, and cleanup after, MATCHER is used.  Typically,
-PRE-MATCH-FORM is used to move to some position relative to the original
-MATCHER, before starting with MATCH-ANCHORED's MATCHER.  POST-MATCH-FORM might
-be used to move, before resuming with MATCH-ANCHORED's parent's MATCHER.
-
-For example, an element of the form highlights (if not already highlighted):
-
- (\"\\\\\\=<anchor\\\\\\=>\" (0 anchor-face) (\"\\\\\\=<item\\\\\\=>\" nil nil (0 item-face)))
-
- Discrete occurrences of \"anchor\" in the value of `anchor-face', and subsequent
- discrete occurrences of \"item\" (on the same line) in the value of `item-face'.
- (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil.  Therefore \"item\" is
- initially searched for starting from the end of the match of \"anchor\", and
- searching for subsequent instance of \"anchor\" resumes from where searching
- for \"item\" concluded.)
-
-The above-mentioned exception is as follows.  The limit of the MATCHER search
-defaults to the end of the line after PRE-MATCH-FORM is evaluated.
-However, if PRE-MATCH-FORM returns a position greater than the position after
-PRE-MATCH-FORM is evaluated, that position is used as the limit of the search.
-It is generally a bad idea to return a position greater than the end of the
-line, i.e., cause the MATCHER search to span lines.
-
-Note that the MATCH-ANCHORED feature is experimental; in the future, we may
-replace it with other ways of providing this functionality.
+However, if an item or (typically) several items are to be highlighted
+following the instance of another item (the anchor) then MATCH-ANCHORED may be
+required.
 
 These regular expressions should not match text which spans lines.  While
-\\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating
-when you edit the buffer does not, since it considers text one line at a time.
+\\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating when you
+edit the buffer does not, since it considers text one line at a time.
 
-Be very careful composing regexps for this list;
-the wrong pattern can dramatically slow things down!")
+Be very careful composing regexps for this list; the wrong pattern can
+dramatically slow things down!
+")
 
 (make-variable-buffer-local 'font-lock-keywords)
 
@@ -427,6 +1157,50 @@
 
 ;;;***
 
+;;;### (autoloads (font-menu-weight-constructor font-menu-size-constructor font-menu-family-constructor reset-device-font-menus) "font-menu" "lisp/font-menu.el")
+
+(defcustom font-menu-ignore-scaled-fonts nil "*If non-nil, then the font menu will try to show only bitmap fonts." :type 'boolean :group 'font-menu)
+
+(defcustom font-menu-this-frame-only-p nil "*If non-nil, then changing the default font from the font menu will only\naffect one frame instead of all frames." :type 'boolean :group 'font-menu)
+
+(fset 'install-font-menus 'reset-device-font-menus)
+
+(autoload 'reset-device-font-menus "font-menu" "\
+Generates the `Font', `Size', and `Weight' submenus for the Options menu.
+This is run the first time that a font-menu is needed for each device.
+If you don't like the lazy invocation of this function, you can add it to
+`create-device-hook' and that will make the font menus respond more quickly
+when they are selected for the first time.  If you add fonts to your system, 
+or if you change your font path, you can call this to re-initialize the menus." nil nil)
+
+(autoload 'font-menu-family-constructor "font-menu" nil nil nil)
+
+(autoload 'font-menu-size-constructor "font-menu" nil nil nil)
+
+(autoload 'font-menu-weight-constructor "font-menu" nil nil nil)
+
+;;;***
+
+;;;### (autoloads (x-font-build-cache font-default-size-for-device font-default-encoding-for-device font-default-registry-for-device font-default-family-for-device font-default-object-for-device font-default-font-for-device font-create-object) "font" "lisp/font.el")
+
+(autoload 'font-create-object "font" nil nil nil)
+
+(autoload 'font-default-font-for-device "font" nil nil nil)
+
+(autoload 'font-default-object-for-device "font" nil nil nil)
+
+(autoload 'font-default-family-for-device "font" nil nil nil)
+
+(autoload 'font-default-registry-for-device "font" nil nil nil)
+
+(autoload 'font-default-encoding-for-device "font" nil nil nil)
+
+(autoload 'font-default-size-for-device "font" nil nil nil)
+
+(autoload 'x-font-build-cache "font" nil nil nil)
+
+;;;***
+
 ;;;### (autoloads (gnuserv-start gnuserv-running-p) "gnuserv" "lisp/gnuserv.el")
 
 (defcustom gnuserv-frame nil "*The frame to be used to display all edited files.\nIf nil, then a new frame is created for each file edited.\nIf t, then the currently selected frame will be used.\nIf a function, then this will be called with a symbol `x' or `tty' as the\nonly argument, and its return value will be interpreted as above." :tag "Gnuserv Frame" :type '(radio (const :tag "Create new frame each time" nil) (const :tag "Use selected frame" t) (function-item :tag "Use main Emacs frame" gnuserv-main-frame-function) (function-item :tag "Use visible frame, otherwise create new" gnuserv-visible-frame-function) (function-item :tag "Create special Gnuserv frame and use it" gnuserv-special-frame-function) (function :tag "Other")) :group 'gnuserv :group 'frames)
@@ -1132,718 +1906,5 @@
 (autoload 'x-win-init-xfree86 "x-win-xfree86" nil nil nil)
 
 ;;;***
-
-;;;### (autoloads nil "abbrev" "lisp\\abbrev.el")
-
-;;;***
-
-;;;### (autoloads (about-xemacs) "about" "lisp\\about.el")
-
-(autoload 'about-xemacs "about" "\
-Describe the True Editor and its minions." t nil)
-
-;;;***
-
-;;;### (autoloads (set-modified-alist modify-alist remove-alist set-alist del-alist put-alist vassoc) "alist" "lisp\\alist.el")
-
-(autoload 'vassoc "alist" "\
-Search VALIST for a vector whose first element is equal to KEY.
-See also `assoc'." nil nil)
-
-(autoload 'put-alist "alist" "\
-Modify ALIST to set VALUE to ITEM.
-If there is a pair whose car is ITEM, replace its cdr by VALUE.
-If there is not such pair, create new pair (ITEM . VALUE) and
-return new alist whose car is the new pair and cdr is ALIST.
-[tomo's ELIS like function]" nil nil)
-
-(autoload 'del-alist "alist" "\
-If there is a pair whose key is ITEM, delete it from ALIST.
-[tomo's ELIS emulating function]" nil nil)
-
-(autoload 'set-alist "alist" "\
-Modify a alist indicated by SYMBOL to set VALUE to ITEM." nil nil)
-
-(autoload 'remove-alist "alist" "\
-Remove ITEM from the alist indicated by SYMBOL." nil nil)
-
-(autoload 'modify-alist "alist" "\
-Modify alist DEFAULT into alist MODIFIER." nil nil)
-
-(autoload 'set-modified-alist "alist" "\
-Modify a value of a symbol SYM into alist MODIFIER.
-The symbol SYM should be alist. If it is not bound,
-its value regard as nil." nil nil)
-
-;;;***
-
-;;;### (autoloads (apropos-documentation apropos-value apropos apropos-command) "apropos" "lisp\\apropos.el")
-
-(fset 'command-apropos 'apropos-command)
-
-(autoload 'apropos-command "apropos" "\
-Shows commands (interactively callable functions) that match REGEXP.
-With optional prefix ARG or if `apropos-do-all' is non-nil, also show
-variables." t nil)
-
-(autoload 'apropos "apropos" "\
-Show all bound symbols whose names match REGEXP.
-With optional prefix ARG or if `apropos-do-all' is non-nil, also show unbound
-symbols and key bindings, which is a little more time-consuming.
-Returns list of symbols and documentation found." t nil)
-
-(autoload 'apropos-value "apropos" "\
-Show all symbols whose value's printed image matches REGEXP.
-With optional prefix ARG or if `apropos-do-all' is non-nil, also looks
-at the function and at the names and values of properties.
-Returns list of symbols and values found." t nil)
-
-(autoload 'apropos-documentation "apropos" "\
-Show symbols whose documentation contain matches for REGEXP.
-With optional prefix ARG or if `apropos-do-all' is non-nil, also use
-documentation that is not stored in the documentation file and show key
-bindings.
-Returns list of symbols and documentation found." t nil)
-
-;;;***
-
-;;;### (autoloads nil "buff-menu" "lisp\\buff-menu.el")
-
-(defvar list-buffers-directory nil)
-
-(make-variable-buffer-local 'list-buffers-directory)
-
-;;;***
-
-;;;### (autoloads (compiler-macroexpand define-compiler-macro ignore-file-errors ignore-errors assert check-type typep deftype cl-struct-setf-expander defstruct define-modify-macro callf2 callf letf* letf rotatef shiftf remf cl-do-pop psetf setf get-setf-method defsetf define-setf-method declare the locally multiple-value-setq multiple-value-bind lexical-let* lexical-let symbol-macrolet macrolet labels flet progv psetq do-all-symbols do-symbols dotimes dolist do* do loop return-from return block etypecase typecase ecase case load-time-value eval-when destructuring-bind function* defmacro* defun* cl-compile-time-init) "cl-macs" "lisp\\cl-macs.el")
-
-(autoload 'cl-compile-time-init "cl-macs" nil nil nil)
-
-(autoload 'defun* "cl-macs" "\
-(defun* NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.
-Like normal `defun', except ARGLIST allows full Common Lisp conventions,
-and BODY is implicitly surrounded by (block NAME ...)." nil 'macro)
-
-(autoload 'defmacro* "cl-macs" "\
-(defmacro* NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.
-Like normal `defmacro', except ARGLIST allows full Common Lisp conventions,
-and BODY is implicitly surrounded by (block NAME ...)." nil 'macro)
-
-(autoload 'function* "cl-macs" "\
-(function* SYMBOL-OR-LAMBDA): introduce a function.
-Like normal `function', except that if argument is a lambda form, its
-ARGLIST allows full Common Lisp conventions." nil 'macro)
-
-(autoload 'destructuring-bind "cl-macs" nil nil 'macro)
-
-(autoload 'eval-when "cl-macs" "\
-(eval-when (WHEN...) BODY...): control when BODY is evaluated.
-If `compile' is in WHEN, BODY is evaluated when compiled at top-level.
-If `load' is in WHEN, BODY is evaluated when loaded after top-level compile.
-If `eval' is in WHEN, BODY is evaluated when interpreted or at non-top-level." nil 'macro)
-
-(autoload 'load-time-value "cl-macs" "\
-Like `progn', but evaluates the body at load time.
-The result of the body appears to the compiler as a quoted constant." nil 'macro)
-
-(autoload 'case "cl-macs" "\
-(case EXPR CLAUSES...): evals EXPR, chooses from CLAUSES on that value.
-Each clause looks like (KEYLIST BODY...).  EXPR is evaluated and compared
-against each key in each KEYLIST; the corresponding BODY is evaluated.
-If no clause succeeds, case returns nil.  A single atom may be used in
-place of a KEYLIST of one atom.  A KEYLIST of `t' or `otherwise' is
-allowed only in the final clause, and matches if no other keys match.
-Key values are compared by `eql'." nil 'macro)
-
-(autoload 'ecase "cl-macs" "\
-(ecase EXPR CLAUSES...): like `case', but error if no case fits.
-`otherwise'-clauses are not allowed." nil 'macro)
-
-(autoload 'typecase "cl-macs" "\
-(typecase EXPR CLAUSES...): evals EXPR, chooses from CLAUSES on that value.
-Each clause looks like (TYPE BODY...).  EXPR is evaluated and, if it
-satisfies TYPE, the corresponding BODY is evaluated.  If no clause succeeds,
-typecase returns nil.  A TYPE of `t' or `otherwise' is allowed only in the
-final clause, and matches if no other keys match." nil 'macro)
-
-(autoload 'etypecase "cl-macs" "\
-(etypecase EXPR CLAUSES...): like `typecase', but error if no case fits.
-`otherwise'-clauses are not allowed." nil 'macro)
-
-(autoload 'block "cl-macs" "\
-(block NAME BODY...): define a lexically-scoped block named NAME.
-NAME may be any symbol.  Code inside the BODY forms can call `return-from'
-to jump prematurely out of the block.  This differs from `catch' and `throw'
-in two respects:  First, the NAME is an unevaluated symbol rather than a
-quoted symbol or other form; and second, NAME is lexically rather than
-dynamically scoped:  Only references to it within BODY will work.  These
-references may appear inside macro expansions, but not inside functions
-called from BODY." nil 'macro)
-
-(autoload 'return "cl-macs" "\
-(return [RESULT]): return from the block named nil.
-This is equivalent to `(return-from nil RESULT)'." nil 'macro)
-
-(autoload 'return-from "cl-macs" "\
-(return-from NAME [RESULT]): return from the block named NAME.
-This jumps out to the innermost enclosing `(block NAME ...)' form,
-returning RESULT from that form (or nil if RESULT is omitted).
-This is compatible with Common Lisp, but note that `defun' and
-`defmacro' do not create implicit blocks as they do in Common Lisp." nil 'macro)
-
-(autoload 'loop "cl-macs" "\
-(loop CLAUSE...): The Common Lisp `loop' macro.
-Valid clauses are:
-  for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
-  for VAR in LIST by FUNC, for VAR on LIST by FUNC, for VAR = INIT then EXPR,
-  for VAR across ARRAY, repeat NUM, with VAR = INIT, while COND, until COND,
-  always COND, never COND, thereis COND, collect EXPR into VAR,
-  append EXPR into VAR, nconc EXPR into VAR, sum EXPR into VAR,
-  count EXPR into VAR, maximize EXPR into VAR, minimize EXPR into VAR,
-  if COND CLAUSE [and CLAUSE]... else CLAUSE [and CLAUSE...],
-  unless COND CLAUSE [and CLAUSE]... else CLAUSE [and CLAUSE...],
-  do EXPRS..., initially EXPRS..., finally EXPRS..., return EXPR,
-  finally return EXPR, named NAME." nil 'macro)
-
-(autoload 'do "cl-macs" "\
-The Common Lisp `do' loop.
-Format is: (do ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil 'macro)
-
-(autoload 'do* "cl-macs" "\
-The Common Lisp `do*' loop.
-Format is: (do* ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil 'macro)
-
-(autoload 'dolist "cl-macs" "\
-(dolist (VAR LIST [RESULT]) BODY...): loop over a list.
-Evaluate BODY with VAR bound to each `car' from LIST, in turn.
-Then evaluate RESULT to get return value, default nil." nil 'macro)
-
-(autoload 'dotimes "cl-macs" "\
-(dotimes (VAR COUNT [RESULT]) BODY...): loop a certain number of times.
-Evaluate BODY with VAR bound to successive integers from 0, inclusive,
-to COUNT, exclusive.  Then evaluate RESULT to get return value, default
-nil." nil 'macro)
-
-(autoload 'do-symbols "cl-macs" "\
-(dosymbols (VAR [OBARRAY [RESULT]]) BODY...): loop over all symbols.
-Evaluate BODY with VAR bound to each interned symbol, or to each symbol
-from OBARRAY." nil 'macro)
-
-(autoload 'do-all-symbols "cl-macs" nil nil 'macro)
-
-(autoload 'psetq "cl-macs" "\
-(psetq SYM VAL SYM VAL ...): set SYMs to the values VALs in parallel.
-This is like `setq', except that all VAL forms are evaluated (in order)
-before assigning any symbols SYM to the corresponding values." nil 'macro)
-
-(autoload 'progv "cl-macs" "\
-(progv SYMBOLS VALUES BODY...): bind SYMBOLS to VALUES dynamically in BODY.
-The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
-Each SYMBOL in the first list is bound to the corresponding VALUE in the
-second list (or made unbound if VALUES is shorter than SYMBOLS); then the
-BODY forms are executed and their result is returned.  This is much like
-a `let' form, except that the list of symbols can be computed at run-time." nil 'macro)
-
-(autoload 'flet "cl-macs" "\
-(flet ((FUNC ARGLIST BODY...) ...) FORM...): make temporary function defns.
-This is an analogue of `let' that operates on the function cell of FUNC
-rather than its value cell.  The FORMs are evaluated with the specified
-function definitions in place, then the definitions are undone (the FUNCs
-go back to their previous definitions, or lack thereof)." nil 'macro)
-
-(autoload 'labels "cl-macs" "\
-(labels ((FUNC ARGLIST BODY...) ...) FORM...): make temporary func bindings.
-This is like `flet', except the bindings are lexical instead of dynamic.
-Unlike `flet', this macro is fully compliant with the Common Lisp standard." nil 'macro)
-
-(autoload 'macrolet "cl-macs" "\
-(macrolet ((NAME ARGLIST BODY...) ...) FORM...): make temporary macro defns.
-This is like `flet', but for macros instead of functions." nil 'macro)
-
-(autoload 'symbol-macrolet "cl-macs" "\
-(symbol-macrolet ((NAME EXPANSION) ...) FORM...): make symbol macro defns.
-Within the body FORMs, references to the variable NAME will be replaced
-by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...)." nil 'macro)
-
-(autoload 'lexical-let "cl-macs" "\
-(lexical-let BINDINGS BODY...): like `let', but lexically scoped.
-The main visible difference is that lambdas inside BODY will create
-lexical closures as in Common Lisp." nil 'macro)
-
-(autoload 'lexical-let* "cl-macs" "\
-(lexical-let* BINDINGS BODY...): like `let*', but lexically scoped.
-The main visible difference is that lambdas inside BODY will create
-lexical closures as in Common Lisp." nil 'macro)
-
-(autoload 'multiple-value-bind "cl-macs" "\
-(multiple-value-bind (SYM SYM...) FORM BODY): collect multiple return values.
-FORM must return a list; the BODY is then executed with the first N elements
-of this list bound (`let'-style) to each of the symbols SYM in turn.  This
-is analogous to the Common Lisp `multiple-value-bind' macro, using lists to
-simulate true multiple return values.  For compatibility, (values A B C) is
-a synonym for (list A B C)." nil 'macro)
-
-(autoload 'multiple-value-setq "cl-macs" "\
-(multiple-value-setq (SYM SYM...) FORM): collect multiple return values.
-FORM must return a list; the first N elements of this list are stored in
-each of the symbols SYM in turn.  This is analogous to the Common Lisp
-`multiple-value-setq' macro, using lists to simulate true multiple return
-values.  For compatibility, (values A B C) is a synonym for (list A B C)." nil 'macro)
-
-(autoload 'locally "cl-macs" nil nil 'macro)
-
-(autoload 'the "cl-macs" nil nil 'macro)
-
-(autoload 'declare "cl-macs" nil nil 'macro)
-
-(autoload 'define-setf-method "cl-macs" "\
-(define-setf-method NAME ARGLIST BODY...): define a `setf' method.
-This method shows how to handle `setf's to places of the form (NAME ARGS...).
-The argument forms ARGS are bound according to ARGLIST, as if NAME were
-going to be expanded as a macro, then the BODY forms are executed and must
-return a list of five elements: a temporary-variables list, a value-forms
-list, a store-variables list (of length one), a store-form, and an access-
-form.  See `defsetf' for a simpler way to define most setf-methods." nil 'macro)
-
-(autoload 'defsetf "cl-macs" "\
-(defsetf NAME FUNC): define a `setf' method.
-This macro is an easy-to-use substitute for `define-setf-method' that works
-well for simple place forms.  In the simple `defsetf' form, `setf's of
-the form (setf (NAME ARGS...) VAL) are transformed to function or macro
-calls of the form (FUNC ARGS... VAL).  Example: (defsetf aref aset).
-Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
-Here, the above `setf' call is expanded by binding the argument forms ARGS
-according to ARGLIST, binding the value form VAL to STORE, then executing
-BODY, which must return a Lisp form that does the necessary `setf' operation.
-Actually, ARGLIST and STORE may be bound to temporary variables which are
-introduced automatically to preserve proper execution order of the arguments.
-Example: (defsetf nth (n x) (v) (list 'setcar (list 'nthcdr n x) v))." nil 'macro)
-
-(autoload 'get-setf-method "cl-macs" "\
-Return a list of five values describing the setf-method for PLACE.
-PLACE may be any Lisp form which can appear as the PLACE argument to
-a macro like `setf' or `incf'." nil nil)
-
-(autoload 'setf "cl-macs" "\
-(setf PLACE VAL PLACE VAL ...): set each PLACE to the value of its VAL.
-This is a generalized version of `setq'; the PLACEs may be symbolic
-references such as (car x) or (aref x i), as well as plain symbols.
-For example, (setf (cadar x) y) is equivalent to (setcar (cdar x) y).
-The return value is the last VAL in the list." nil 'macro)
-
-(autoload 'psetf "cl-macs" "\
-(psetf PLACE VAL PLACE VAL ...): set PLACEs to the values VALs in parallel.
-This is like `setf', except that all VAL forms are evaluated (in order)
-before assigning any PLACEs to the corresponding values." nil 'macro)
-
-(autoload 'cl-do-pop "cl-macs" nil nil nil)
-
-(autoload 'remf "cl-macs" "\
-(remf PLACE TAG): remove TAG from property list PLACE.
-PLACE may be a symbol, or any generalized variable allowed by `setf'.
-The form returns true if TAG was found and removed, nil otherwise." nil 'macro)
-
-(autoload 'shiftf "cl-macs" "\
-(shiftf PLACE PLACE... VAL): shift left among PLACEs.
-Example: (shiftf A B C) sets A to B, B to C, and returns the old A.
-Each PLACE may be a symbol, or any generalized variable allowed by `setf'." nil 'macro)
-
-(autoload 'rotatef "cl-macs" "\
-(rotatef PLACE...): rotate left among PLACEs.
-Example: (rotatef A B C) sets A to B, B to C, and C to A.  It returns nil.
-Each PLACE may be a symbol, or any generalized variable allowed by `setf'." nil 'macro)
-
-(autoload 'letf "cl-macs" "\
-(letf ((PLACE VALUE) ...) BODY...): temporarily bind to PLACEs.
-This is the analogue of `let', but with generalized variables (in the
-sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
-VALUE, then the BODY forms are executed.  On exit, either normally or
-because of a `throw' or error, the PLACEs are set back to their original
-values.  Note that this macro is *not* available in Common Lisp.
-As a special case, if `(PLACE)' is used instead of `(PLACE VALUE)',
-the PLACE is not modified before executing BODY." nil 'macro)
-
-(autoload 'letf* "cl-macs" "\
-(letf* ((PLACE VALUE) ...) BODY...): temporarily bind to PLACEs.
-This is the analogue of `let*', but with generalized variables (in the
-sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
-VALUE, then the BODY forms are executed.  On exit, either normally or
-because of a `throw' or error, the PLACEs are set back to their original
-values.  Note that this macro is *not* available in Common Lisp.
-As a special case, if `(PLACE)' is used instead of `(PLACE VALUE)',
-the PLACE is not modified before executing BODY." nil 'macro)
-
-(autoload 'callf "cl-macs" "\
-(callf FUNC PLACE ARGS...): set PLACE to (FUNC PLACE ARGS...).
-FUNC should be an unquoted function name.  PLACE may be a symbol,
-or any generalized variable allowed by `setf'." nil 'macro)
-
-(autoload 'callf2 "cl-macs" "\
-(callf2 FUNC ARG1 PLACE ARGS...): set PLACE to (FUNC ARG1 PLACE ARGS...).
-Like `callf', but PLACE is the second argument of FUNC, not the first." nil 'macro)
-
-(autoload 'define-modify-macro "cl-macs" "\
-(define-modify-macro NAME ARGLIST FUNC): define a `setf'-like modify macro.
-If NAME is called, it combines its PLACE argument with the other arguments
-from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" nil 'macro)
-
-(autoload 'defstruct "cl-macs" "\
-(defstruct (NAME OPTIONS...) (SLOT SLOT-OPTS...)...): define a struct type.
-This macro defines a new Lisp data type called NAME, which contains data
-stored in SLOTs.  This defines a `make-NAME' constructor, a `copy-NAME'
-copier, a `NAME-p' predicate, and setf-able `NAME-SLOT' accessors." nil 'macro)
-
-(autoload 'cl-struct-setf-expander "cl-macs" nil nil nil)
-
-(autoload 'deftype "cl-macs" "\
-(deftype NAME ARGLIST BODY...): define NAME as a new data type.
-The type name can then be used in `typecase', `check-type', etc." nil 'macro)
-
-(autoload 'typep "cl-macs" "\
-Check that OBJECT is of type TYPE.
-TYPE is a Common Lisp-style type specifier." nil nil)
-
-(autoload 'check-type "cl-macs" "\
-Verify that FORM is of type TYPE; signal an error if not.
-STRING is an optional description of the desired type." nil 'macro)
-
-(autoload 'assert "cl-macs" "\
-Verify that FORM returns non-nil; signal an error if not.
-Second arg SHOW-ARGS means to include arguments of FORM in message.
-Other args STRING and ARGS... are arguments to be passed to `error'.
-They are not evaluated unless the assertion fails.  If STRING is
-omitted, a default message listing FORM itself is used." nil 'macro)
-
-(autoload 'ignore-errors "cl-macs" "\
-Execute FORMS; if an error occurs, return nil.
-Otherwise, return result of last FORM." nil 'macro)
-
-(autoload 'ignore-file-errors "cl-macs" "\
-Execute FORMS; if an error of type `file-error' occurs, return nil.
-Otherwise, return result of last FORM." nil 'macro)
-
-(autoload 'define-compiler-macro "cl-macs" "\
-(define-compiler-macro FUNC ARGLIST BODY...): Define a compiler-only macro.
-This is like `defmacro', but macro expansion occurs only if the call to
-FUNC is compiled (i.e., not interpreted).  Compiler macros should be used
-for optimizing the way calls to FUNC are compiled; the form returned by
-BODY should do the same thing as a call to the normal function called
-FUNC, though possibly more efficiently.  Note that, like regular macros,
-compiler macros are expanded repeatedly until no further expansions are
-possible.  Unlike regular macros, BODY can decide to \"punt\" and leave the
-original function call alone by declaring an initial `&whole foo' parameter
-and then returning foo." nil 'macro)
-
-(autoload 'compiler-macroexpand "cl-macs" nil nil nil)
-
-;;;***
-
-;;;### (autoloads (batch-remove-old-elc) "cleantree" "lisp\\cleantree.el")
-
-(autoload 'batch-remove-old-elc "cleantree" nil nil nil)
-
-;;;***
-
-;;;### (autoloads (config-value config-value-hash-table) "config" "lisp\\config.el")
-
-(autoload 'config-value-hash-table "config" "\
-Return hash table of configuration parameters and their values." nil nil)
-
-(autoload 'config-value "config" "\
-Return the value of the configuration parameter CONFIG_SYMBOL." nil nil)
-
-;;;***
-
-;;;### (autoloads (Custom-make-dependencies) "cus-dep" "lisp\\cus-dep.el")
-
-(autoload 'Custom-make-dependencies "cus-dep" "\
-Extract custom dependencies from .el files in SUBDIRS.
-SUBDIRS is a list of directories.  If it is nil, the command-line
-arguments are used.  If it is a string, only that directory is
-processed.  This function is especially useful in batch mode.
-
-Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" t nil)
-
-;;;***
-
-;;;### (autoloads (customize-menu-create custom-menu-create custom-save-all customize-save-customized customize-browse custom-buffer-create-other-window custom-buffer-create customize-apropos-groups customize-apropos-faces customize-apropos-options customize-apropos customize-saved customize-customized customize-face-other-window customize-face customize-option-other-window customize-changed-options customize-variable customize-other-window customize customize-save-variable customize-set-variable customize-set-value) "cus-edit" "lisp\\cus-edit.el")
-
-(autoload 'customize-set-value "cus-edit" "\
-Set VARIABLE to VALUE.  VALUE is a Lisp object.
-
-If VARIABLE has a `variable-interactive' property, that is used as if
-it were the arg to `interactive' (which see) to interactively read the value.
-
-If VARIABLE has a `custom-type' property, it must be a widget and the
-`:prompt-value' property of that widget will be used for reading the value.
-
-If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
-
-(autoload 'customize-set-variable "cus-edit" "\
-Set the default for VARIABLE to VALUE.  VALUE is a Lisp object.
-
-If VARIABLE has a `custom-set' property, that is used for setting
-VARIABLE, otherwise `set-default' is used.
-
-The `customized-value' property of the VARIABLE will be set to a list
-with a quoted VALUE as its sole list member.
-
-If VARIABLE has a `variable-interactive' property, that is used as if
-it were the arg to `interactive' (which see) to interactively read the value.
-
-If VARIABLE has a `custom-type' property, it must be a widget and the
-`:prompt-value' property of that widget will be used for reading the value.
-
-If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
-
-(autoload 'customize-save-variable "cus-edit" "\
-Set the default for VARIABLE to VALUE, and save it for future sessions.
-If VARIABLE has a `custom-set' property, that is used for setting
-VARIABLE, otherwise `set-default' is used.
-
-The `customized-value' property of the VARIABLE will be set to a list
-with a quoted VALUE as its sole list member.
-
-If VARIABLE has a `variable-interactive' property, that is used as if
-it were the arg to `interactive' (which see) to interactively read the value.
-
-If VARIABLE has a `custom-type' property, it must be a widget and the
-`:prompt-value' property of that widget will be used for reading the value.
-
-If given a prefix (or a COMMENT argument), also prompt for a comment." t nil)
-
-(autoload 'customize "cus-edit" "\
-Select a customization buffer which you can use to set user options.
-User options are structured into \"groups\".
-The default group is `Emacs'." t nil)
-
-(defalias 'customize-group 'customize)
-
-(autoload 'customize-other-window "cus-edit" "\
-Customize SYMBOL, which must be a customization group." t nil)
-
-(defalias 'customize-group-other-window 'customize-other-window)
-
-(defalias 'customize-option 'customize-variable)
-
-(autoload 'customize-variable "cus-edit" "\
-Customize SYMBOL, which must be a user option variable." t nil)
-
-(autoload 'customize-changed-options "cus-edit" "\
-Customize all user option variables whose default values changed recently.
-This means, in other words, variables defined with a `:version' keyword." t nil)
-
-(defalias 'customize-variable-other-window 'customize-option-other-window)
-
-(autoload 'customize-option-other-window "cus-edit" "\
-Customize SYMBOL, which must be a user option variable.
-Show the buffer in another window, but don't select it." t nil)
-
-(autoload 'customize-face "cus-edit" "\
-Customize SYMBOL, which should be a face name or nil.
-If SYMBOL is nil, customize all faces." t nil)
-
-(autoload 'customize-face-other-window "cus-edit" "\
-Show customization buffer for FACE in other window." t nil)
-
-(autoload 'customize-customized "cus-edit" "\
-Customize all user options set since the last save in this session." t nil)
-
-(autoload 'customize-saved "cus-edit" "\
-Customize all already saved user options." t nil)
-
-(autoload 'customize-apropos "cus-edit" "\
-Customize all user options matching REGEXP.
-If ALL is `options', include only options.
-If ALL is `faces', include only faces.
-If ALL is `groups', include only groups.
-If ALL is t (interactively, with prefix arg), include options which are not
-user-settable, as well as faces and groups." t nil)
-
-(autoload 'customize-apropos-options "cus-edit" "\
-Customize all user options matching REGEXP.
-With prefix arg, include options which are not user-settable." t nil)
-
-(autoload 'customize-apropos-faces "cus-edit" "\
-Customize all user faces matching REGEXP." t nil)
-
-(autoload 'customize-apropos-groups "cus-edit" "\
-Customize all user groups matching REGEXP." t nil)
-
-(autoload 'custom-buffer-create "cus-edit" "\
-Create a buffer containing OPTIONS.
-Optional NAME is the name of the buffer.
-OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
-SYMBOL is a customization option, and WIDGET is a widget for editing
-that option." nil nil)
-
-(autoload 'custom-buffer-create-other-window "cus-edit" "\
-Create a buffer containing OPTIONS.
-Optional NAME is the name of the buffer.
-OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
-SYMBOL is a customization option, and WIDGET is a widget for editing
-that option." nil nil)
-
-(autoload 'customize-browse "cus-edit" "\
-Create a tree browser for the customize hierarchy." t nil)
-
-(defcustom custom-file "~/.emacs" "File used for storing customization information.\nIf you change this from the default \"~/.emacs\" you need to\nexplicitly load that file for the settings to take effect." :type 'file :group 'customize)
-
-(autoload 'customize-save-customized "cus-edit" "\
-Save all user options which have been set in this session." t nil)
-
-(autoload 'custom-save-all "cus-edit" "\
-Save all customizations in `custom-file'." nil nil)
-
-(autoload 'custom-menu-create "cus-edit" "\
-Create menu for customization group SYMBOL.
-The menu is in a format applicable to `easy-menu-define'." nil nil)
-
-(autoload 'customize-menu-create "cus-edit" "\
-Return a customize menu for customization group SYMBOL.
-If optional NAME is given, use that as the name of the menu.
-Otherwise the menu will be named `Customize'.
-The format is suitable for use with `easy-menu-define'." nil nil)
-
-;;;***
-
-;;;### (autoloads (custom-reset-faces custom-theme-reset-faces custom-theme-face-value custom-theme-set-faces custom-set-faces custom-set-face-update-spec custom-declare-face) "cus-face" "lisp\\cus-face.el")
-
-(autoload 'custom-declare-face "cus-face" "\
-Like `defface', but FACE is evaluated as a normal argument." nil nil)
-
-(autoload 'custom-set-face-update-spec "cus-face" "\
-Customize the FACE for display types matching DISPLAY, merging
-  in the new items from PLIST" nil nil)
-
-(autoload 'custom-set-faces "cus-face" "\
-Initialize faces according to user preferences.
-This asociates the setting with the USER theme.
-The arguments should be a list where each entry has the form:
-
-  (FACE SPEC [NOW [COMMENT]])
-
-SPEC will be stored as the saved value for FACE.  If NOW is present
-and non-nil, FACE will also be created according to SPEC.
-COMMENT is a string comment about FACE.
-
-See `defface' for the format of SPEC." nil nil)
-
-(autoload 'custom-theme-set-faces "cus-face" "\
-Initialize faces according to settings specified by args.
-Records the settings as belonging to THEME.
-
-See `custom-set-faces' for a description of the arguments ARGS." nil nil)
-
-(autoload 'custom-theme-face-value "cus-face" "\
-Return spec of FACE in THEME if the THEME modifies the
-FACE.  Nil otherwise." nil nil)
-
-(autoload 'custom-theme-reset-faces "cus-face" nil nil nil)
-
-(autoload 'custom-reset-faces "cus-face" "\
-Reset the value of the face to values previously defined.
-Assosiate this setting with the 'user' theme.
-
-ARGS is defined as for `custom-theme-reset-faces'" nil nil)
-
-;;;***
-
-;;;### (autoloads (disassemble) "disass" "lisp\\disass.el")
-
-(autoload 'disassemble "disass" "\
-Print disassembled code for OBJECT in (optional) BUFFER.
-OBJECT can be a symbol defined as a function, or a function itself
-\(a lambda expression or a compiled-function object).
-If OBJECT is not already compiled, we compile it, but do not
-redefine OBJECT if it is a symbol." t nil)
-
-;;;***
-
-;;;### (autoloads (standard-display-european standard-display-underline standard-display-graphic standard-display-g1 standard-display-ascii standard-display-default standard-display-8bit make-display-table describe-current-display-table) "disp-table" "lisp\\disp-table.el")
-
-(autoload 'describe-current-display-table "disp-table" "\
-Describe the display table in use in the selected window and buffer." t nil)
-
-(autoload 'make-display-table "disp-table" "\
-Return a new, empty display table." nil nil)
-
-(autoload 'standard-display-8bit "disp-table" "\
-Display characters in the range L to H literally." nil nil)
-
-(autoload 'standard-display-default "disp-table" "\
-Display characters in the range L to H using the default notation." nil nil)
-
-(autoload 'standard-display-ascii "disp-table" "\
-Display character C using printable string S." nil nil)
-
-(autoload 'standard-display-g1 "disp-table" "\
-Display character C as character SC in the g1 character set.
-This function assumes that your terminal uses the SO/SI characters;
-it is meaningless for an X frame." nil nil)
-
-(autoload 'standard-display-graphic "disp-table" "\
-Display character C as character GC in graphics character set.
-This function assumes VT100-compatible escapes; it is meaningless for an
-X frame." nil nil)
-
-(autoload 'standard-display-underline "disp-table" "\
-Display character C as character UC plus underlining." nil nil)
-
-(autoload 'standard-display-european "disp-table" "\
-Toggle display of European characters encoded with ISO 8859.
-When enabled, characters in the range of 160 to 255 display not
-as octal escapes, but as accented characters.
-With prefix argument, enable European character display iff arg is positive." t nil)
-
-;;;***
-
-;;;### (autoloads nil "easymenu" "lisp\\easymenu.el")
-
-;;;***
-
-;;;### (autoloads (font-menu-weight-constructor font-menu-size-constructor font-menu-family-constructor reset-device-font-menus) "font-menu" "lisp\\font-menu.el")
-
-(defcustom font-menu-ignore-scaled-fonts nil "*If non-nil, then the font menu will try to show only bitmap fonts." :type 'boolean :group 'font-menu)
-
-(defcustom font-menu-this-frame-only-p nil "*If non-nil, then changing the default font from the font menu will only\naffect one frame instead of all frames." :type 'boolean :group 'font-menu)
-
-(fset 'install-font-menus 'reset-device-font-menus)
-
-(autoload 'reset-device-font-menus "font-menu" "\
-Generates the `Font', `Size', and `Weight' submenus for the Options menu.
-This is run the first time that a font-menu is needed for each device.
-If you don't like the lazy invocation of this function, you can add it to
-`create-device-hook' and that will make the font menus respond more quickly
-when they are selected for the first time.  If you add fonts to your system, 
-or if you change your font path, you can call this to re-initialize the menus." nil nil)
-
-(autoload 'font-menu-family-constructor "font-menu" nil nil nil)
-
-(autoload 'font-menu-size-constructor "font-menu" nil nil nil)
-
-(autoload 'font-menu-weight-constructor "font-menu" nil nil nil)
-
-;;;***
-
-;;;### (autoloads (x-font-build-cache font-default-size-for-device font-default-encoding-for-device font-default-registry-for-device font-default-family-for-device font-default-object-for-device font-default-font-for-device font-create-object) "font" "lisp\\font.el")
-
-(autoload 'font-create-object "font" nil nil nil)
-
-(autoload 'font-default-font-for-device "font" nil nil nil)
-
-(autoload 'font-default-object-for-device "font" nil nil nil)
-
-(autoload 'font-default-family-for-device "font" nil nil nil)
-
-(autoload 'font-default-registry-for-device "font" nil nil nil)
-
-(autoload 'font-default-encoding-for-device "font" nil nil nil)
-
-(autoload 'font-default-size-for-device "font" nil nil nil)
-
-(autoload 'x-font-build-cache "font" nil nil nil)
-
-;;;***
 
 (provide 'lisp-autoloads)
--- a/lisp/autoload.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/autoload.el	Mon Aug 13 11:19:21 2007 +0200
@@ -87,6 +87,8 @@
 (defvar generate-autoload-section-trailer "\n;;;***\n"
   "String which indicates the end of the section of autoloads for a file.")
 
+(defvar autoload-package-name nil)
+
 ;;; Forms which have doc-strings which should be printed specially.
 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
 ;;; the doc-string in FORM.
@@ -540,8 +542,6 @@
 	  (goto-char (point-max))
 	  (insert "\n(provide '" sym ")\n")))))
 
-(defvar autoload-package-name nil)
-
 ;; #### this function is almost identical, but subtly different,
 ;; from batch-update-autoloads.  Steve, it's your responsibility to
 ;; clean this up.  The two should be merged, but I'm not sure what
--- a/lisp/buff-menu.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/buff-menu.el	Mon Aug 13 11:19:21 2007 +0200
@@ -356,6 +356,8 @@
 
 
 
+(eval-when-compile (autoload 'visit-tags-table "etags"))
+
 (defun Buffer-menu-visit-tags-table ()
   "Visit the tags table in the buffer on this line.  See `visit-tags-table'."
   (interactive)
--- a/lisp/build-report.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/build-report.el	Mon Aug 13 11:19:21 2007 +0200
@@ -151,6 +151,7 @@
     (defalias 'mime-edit-insert-binary-file
       'mime-editor/insert-binary-file)))
 
+;;;###autoload
 (defun build-report (&rest args)
   "Initializes a fresh mail composition buffer using `compose-mail'
 with the contents of XEmacs Installation file and excerpts from XEmacs
--- a/lisp/cl-macs.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cl-macs.el	Mon Aug 13 11:19:21 2007 +0200
@@ -81,7 +81,7 @@
 	 #'(lambda (n p f)
 	     (list 'put (list 'quote n) (list 'quote p)
 		   (list 'function (cons 'lambda f))))))
-   (car (or features (setq features (list 'cl-kludge))))))
+   'xemacs))
 
 
 ;;; Initialization.
--- a/lisp/cl-seq.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cl-seq.el	Mon Aug 13 11:19:21 2007 +0200
@@ -65,6 +65,23 @@
 ;;; this file independent from cl-macs.
 
 (defmacro cl-parsing-keywords (kwords other-keys &rest body)
+  "Helper macro for functions with keyword arguments.
+This is a temporary solution, until keyword arguments are natively supported.
+Declare your function ending with (... &rest cl-keys), then wrap the
+function body in a call to `cl-parsing-keywords'.
+
+KWORDS is a list of keyword definitions.  Each definition should be
+either a keyword or a list (KEYWORD DEFAULT-VALUE).  In the former case,
+the default value is nil.  The keywords are available in BODY as the name
+of the keyword, minus its initial colon and prepended with `cl-'.
+
+OTHER-KEYS specifies other keywords that are accepted but ignored.  It
+is either the value 't' (ignore all other keys, equivalent to the
+&allow-other-keys argument declaration in Common Lisp) or a list in the
+same format as KWORDS.  If keywords are given that are not in KWORDS
+and not allowed by OTHER-KEYS, an error will normally be signalled; but
+the caller can override this by specifying a non-nil value for the
+keyword :allow-other-keys (which defaults to t)."
   (cons
    'let*
    (cons (mapcar
--- a/lisp/cl.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cl.el	Mon Aug 13 11:19:21 2007 +0200
@@ -750,6 +750,8 @@
 (defun cl-hack-byte-compiler ()
   (if (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form))
       (progn
+	(when (not (fboundp 'cl-compile-time-init))
+	  (load "cl-macs" nil t))
 	(cl-compile-time-init)   ; in cl-macs.el
 	(setq cl-hacked-flag t))))
 
--- a/lisp/cmdloop.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cmdloop.el	Mon Aug 13 11:19:21 2007 +0200
@@ -130,9 +130,10 @@
   :group 'editing-basics)
 
 (defun command-error (error-object)
-  (let ((inhibit-quit t)
-	(debug-on-error nil)
-	(etype (car-safe error-object)))
+  (let* ((old-debug-on-error debug-on-error)
+	 (inhibit-quit t)
+	 (debug-on-error nil)
+	 (etype (car-safe error-object)))
     (setq quit-flag nil)
     (setq standard-output t)
     (setq standard-input t)
@@ -161,7 +162,12 @@
 
     (if (noninteractive)
         (progn
-          (message "%s exiting." emacs-program-name)
+	  (if old-debug-on-error
+	      (progn
+		(message "Backtrace:\n\n")
+		(backtrace)
+		(message "\n")))
+          (message "%s exiting\n." emacs-program-name)
           (kill-emacs -1)))
     t))
 
--- a/lisp/code-files.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/code-files.el	Mon Aug 13 11:19:21 2007 +0200
@@ -68,7 +68,13 @@
     ("TUTORIAL\\.\\(?:hr\\|pl\\|ro\\)\\'" . iso-8859-2)
     ;; ("\\.\\(el\\|emacs\\|info\\(-[0-9]+\\)?\\|texi\\)$" . iso-2022-8)
     ;; ("\\(ChangeLog\\|CHANGES-beta\\)$" . iso-2022-8)
-    ("/spool/mail/.*$" . convert-mbox-coding-system))
+
+    ;; This idea is totally broken, and the code didn't work anyway.
+    ;; Mailboxes should be decoded by mail clients, who actually know
+    ;; how to deal with them.  Otherwise, their contents should be
+    ;; treated as `binary'.
+    ;("/spool/mail/.*$" . convert-mbox-coding-system)
+    )
   "Alist to decide a coding system to use for a file I/O operation.
 The format is ((PATTERN . VAL) ...),
 where PATTERN is a regular expression matching a file name,
@@ -191,22 +197,12 @@
 	    ((find-coding-system codesys))
 	    ))))
 
-(defun convert-mbox-coding-system (filename visit start end)
-  "Decoding function for Unix mailboxes.
-Does separate detection and decoding on each message, since each
-message might be in a different encoding."
-  (let ((buffer-read-only nil))
-    (save-restriction
-      (narrow-to-region start end)
-      (goto-char (point-min))
-      (while (not (eobp))
-	(let ((start (point))
-	      end)
-	  (forward-char 1)
-	  (if (re-search-forward "^From" nil 'move)
-	      (beginning-of-line))
-	  (setq end (point))
-	  (decode-coding-region start end 'undecided))))))
+;; This is completely broken, not only in implementation (does not
+;; understand MIME), but in concept -- such high-level decoding should
+;; be done by mail readers, not by IO code!
+
+;(defun convert-mbox-coding-system (filename visit start end)
+;...
 
 (defun find-coding-system-magic-cookie ()
   "Look for the coding-system magic cookie in the current buffer.\n"
--- a/lisp/code-process.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/code-process.el	Mon Aug 13 11:19:21 2007 +0200
@@ -125,6 +125,9 @@
 	    (cond ((consp ret)
 		   (setq cs-r (car ret)
 			 cs-w (cdr ret)))
+		  ((null ret)
+		   (setq cs-r buffer-file-coding-system
+			 cs-w buffer-file-coding-system))
 		  ((find-coding-system ret)
 		   (setq cs-r ret
 			 cs-w ret))))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/compat.el	Mon Aug 13 11:19:21 2007 +0200
@@ -0,0 +1,198 @@
+;;; compat.el --- Mechanism for non-intrusively providing compatibility funs.
+
+;; Copyright (C) 2000 Ben Wing.
+
+;; Author: Ben Wing <ben@xemacs.org>
+;; Maintainer: Ben Wing
+;; Keywords: internal
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Synched up with: Not in FSF.
+
+;;; Authorship:
+
+; Written May 2000 by Ben Wing.
+
+;;; Commentary:
+
+;; Typical usage:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 1. Wrap modules that define compatibility functions like this:     ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;(compat-define-group 'fsf-compat)
+
+;(compat-define-functions 'fsf-compat
+
+;(defun overlayp (object)
+;  "Return t if OBJECT is an overlay."
+;  (and (extentp object)
+;       (extent-property object 'overlay)))
+
+;(defun make-overlay (beg end &optional buffer front-advance rear-advance)
+;  ...)
+
+;...
+
+;) ;; end of (compat-define-group 'fsf-compat)
+
+;;;; overlay.el ends here
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 2. Wrap modules that use the compatibility functions like this:    ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;(compat 'fsf-compat
+
+;(defun random-module-my-fun (bar baz)
+;  (if (fboundp 'overlays-in) (overlays-in bar baz)))
+
+;...
+
+;) ;; end of (compat 'fsf-compat)
+
+;;;; random-module.el ends here
+
+
+(defun compat-hash-table (group)
+  (get group 'compat-table))
+
+(defun compat-make-hash-table (group)
+  (put group 'compat-table (make-hash-table)))
+
+(defmacro compat-define-group (group)
+  "Define GROUP as a group of compatibility functions.
+Individual functions are defined using `compat-define-functions'.
+Once defined, the functions can be used by wrapping your code in the
+`compat' macro.
+
+If GROUP is already defined, nothing happens."
+  (let ((group (eval group)))
+    (or (hash-table-p (compat-hash-table group))
+	(compat-make-hash-table group))))
+
+(defmacro compat-clear-functions (group)
+  "Clear all defined functions and macros out of GROUP."
+  (let ((group (eval group)))
+    (clrhash (compat-hash-table group))))
+
+(defmacro compat-define-functions (group &rest body)
+  "Define compatibility functions in GROUP.
+You should simply wrap this around the code that defines the functions.
+Any functions and macros defined at top level using `defun' or `defmacro'
+will be noticed and added to GROUP.  Other top-level code will be executed
+normally.  All code and definitions in this group can safely reference any
+other functions in this group -- the code is effectively wrapped in a
+`compat' call.  You can call `compat-define-functions' more than once, if
+necessary, for a single group.
+
+What actually happens is that the functions and macros defined here are in
+fact defined using names prefixed with GROUP.  To use these functions,
+wrap any calling code with the `compat' macro, which lexically renames
+the function and macro calls appropriately."
+  (let ((group (eval group)))
+    (let (fundef
+	  (body-tail body))
+      (while body-tail
+	(setq fundef (car body-tail))
+	(when (and (consp fundef) (eq (car fundef) 'defun))
+	  (puthash (second fundef) (third fundef) (compat-hash-table group)))
+	(when (and (consp fundef) (eq (car fundef) 'defmacro))
+	  (puthash (second fundef) (third fundef) (compat-hash-table group)))
+	(setq body-tail (cdr body-tail))))
+    (let (fundef
+	  (body-tail body)
+	  result)
+      (while body-tail
+	(setq fundef (car body-tail))
+	(push
+	 (cond ((and (consp fundef) (eq (car fundef) 'defun))
+		(nconc (list 'defun
+			      (intern (concat (symbol-name group) "-"
+					      (symbol-name (second fundef))))
+			      (third fundef))
+			(nthcdr 3 fundef)))
+	       ((and (consp fundef) (eq (car fundef) 'defmacro))
+		(nconc (list 'defmacro
+			      (intern (concat (symbol-name group) "-"
+					      (symbol-name (second fundef))))
+			      (third fundef))
+			(nthcdr 3 fundef)))
+	       (t fundef))
+	 result)
+	(setq body-tail (cdr body-tail)))
+      (nconc (list 'compat (list 'quote group)) (nreverse result)))))
+
+(defvar compat-active-groups nil)
+
+(defun compat-fboundp (groups fun)
+  "T if FUN is either `fboundp' or one of the compatibility funs in GROUPS.
+GROUPS is a list of compatibility groups as defined using
+`compat-define-group'."
+  (or (fboundp fun)
+      (block nil
+	(mapcar #'(lambda (group)
+		    (if (gethash fun (compat-hash-table group))
+			(return t)))
+		groups))))
+
+(defmacro compat (group &rest body)
+  "Make use of compatibility functions and macros in GROUP.
+You should simply wrap this around the code that uses the functions
+and macros in GROUP.  Typically, a call to `compat' should be placed
+at the top of an ELisp module, with the closing parenthesis at the
+bottom; use this in place of a `require' statement.  Wrapped code can
+be either function or macro definitions or other ELisp code, and
+wrapped function or macro definitions need not be at top level.  All
+calls to the compatibility functions or macros will be noticed anywhere
+within the wrapped code.  Calls to `fboundp' within the wrapped code
+will also behave correctly when called on compatibility functions and
+macros, even though they would return nil elsewhere (including in code
+in other modules called dynamically from the wrapped code).
+
+The functions and macros define in GROUP are actually defined under
+prefixed names, to avoid namespace clashes and bad interactions with
+other code that calls `fboundp'.  All calls inside of the wrapped code
+to the compatibility functions and macros in GROUP are lexically
+mapped to the prefixed names.  Since this is a lexical mapping, code
+in other modules that is called by functions in this module will not
+be affected."
+  (let ((group (eval group))
+	defs)
+    (maphash
+     #'(lambda (fun args)
+	 (push
+	  (list fun args
+		(nconc
+		 (list 'list
+		       (list 'quote 
+			     (intern (concat (symbol-name group) "-"
+					     (symbol-name fun)))))
+		 args))
+	  defs))
+     (compat-hash-table group))
+    ;; it would be cleaner to use `lexical-let' instead of `let', but that
+    ;; causes function definitions to have obnoxious, unreadable junk in
+    ;; them.  #### Move `lexical-let' into C!!!
+    `(let ((compat-active-groups (cons ',group compat-active-groups)))
+       (macrolet ((fboundp (fun) `(compat-fboundp ',compat-active-groups ,fun))
+		  ,@defs)
+	 ,@body))))
--- a/lisp/cus-dep.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cus-dep.el	Mon Aug 13 11:19:21 2007 +0200
@@ -158,7 +158,8 @@
 	      (with-temp-file cusload-file
 		(insert ";;; " cusload-base-file
 			" --- automatically extracted custom dependencies\n"
-			"\n;;; Code:\n\n")
+			"\n;;; Code:\n\n"
+			"(autoload 'custom-add-loads \"cus-load\")\n\n")
 		(mapatoms
 		 (lambda (sym)
 		   (let ((members (get sym 'custom-group))
--- a/lisp/cus-edit.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cus-edit.el	Mon Aug 13 11:19:21 2007 +0200
@@ -55,6 +55,7 @@
 
 (require 'cus-load)
 (require 'cus-start)
+(require 'cus-file)
 
 ;; Huh?  This looks dirty!
 (put 'custom-define-hook 'custom-type 'hook)
@@ -2225,7 +2226,6 @@
   "Restore the saved value for the variable being edited by WIDGET."
   (let* ((symbol (widget-value widget))
 	 (set (or (get symbol 'custom-set) 'set-default))
-	 (comment-widget (widget-get widget :comment-widget))
 	 (value (get symbol 'saved-value))
 	 (comment (get symbol 'saved-variable-comment)))
     (cond ((or value comment)
@@ -2244,8 +2244,7 @@
 (defun custom-variable-reset-standard (widget)
   "Restore the standard setting for the variable being edited by WIDGET."
   (let* ((symbol (widget-value widget))
-	 (set (or (get symbol 'custom-set) 'set-default))
-	 (comment-widget (widget-get widget :comment-widget)))
+	 (set (or (get symbol 'custom-set) 'set-default)))
     (if (get symbol 'standard-value)
 	(funcall set symbol (eval (car (get symbol 'standard-value))))
       (signal 'error (list "No standard setting known for variable" symbol)))
@@ -3239,15 +3238,6 @@
       (widget-put widget :custom-state found)))
   (custom-magic-reset widget))
 
-;;; The `custom-save-all' Function.
-;;;###autoload
-(defcustom custom-file "~/.emacs"
-  "File used for storing customization information.
-If you change this from the default \"~/.emacs\" you need to
-explicitly load that file for the settings to take effect."
-  :type 'file
-  :group 'customize)
-
 (defun custom-save-delete (symbol)
   "Delete the call to SYMBOL form in `custom-file'.
 Leave point at the location of the call, or after the last expression."
@@ -3594,6 +3584,19 @@
   (run-hooks 'custom-mode-hook))
 
 
+;;;###autoload
+(defun custom-migrate-custom-file (new-custom-file-name)
+  "Migrate custom file from home directory."
+  (mapc 'custom-save-delete
+	'(custom-load-themes custom-reset-variables
+			     custom-set-variables
+			     custom-set-faces
+			     custom-reset-faces))
+  (with-current-buffer (find-file-noselect custom-file)
+    (save-buffer))
+  (setq custom-file new-custom-file-name)
+  (custom-save-all))
+
 ;;; The End.
 
 (provide 'cus-edit)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/cus-file.el	Mon Aug 13 11:19:21 2007 +0200
@@ -0,0 +1,59 @@
+;;; cus-file.el --- Manage location of the customize init file
+
+;; Copyright (C) 2000 by Free Software Foundation, Inc.
+
+;; Author: Mike Sperber <mike@xemacs.org>
+;; Keywords: internal
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;;; Synched up with: Not in FSF
+
+;;; Commentary:
+
+;; This file manages the location of the custom init file without
+;; loading all of the custom code itself.
+
+
+;;; Code:
+(provide 'cus-file)
+
+;;;###autoload
+(defconst custom-file-base "custom.el"
+  "Base of file name for storing customization information.")
+
+;;;###autoload
+(defvar custom-file nil
+  "File used for storing customization information.
+If you change this from the default you need to
+explicitly load that file for the settings to take effect.")
+
+;;;###autoload
+(defun make-custom-file-name (init-file &optional force-new)
+  "Construct the default custom file name from the init file name.
+If FORCE-NEW is non-nil, force post-migration location."
+  (let* ((init-file (or init-file user-init-file))
+	 (init-file-directory (file-name-directory init-file)))
+    (if (or force-new
+	    (string= init-file-directory
+		     (expand-file-name
+		      (file-name-as-directory user-init-directory))))
+	(expand-file-name custom-file-base user-init-directory)
+      init-file)))
+
+;;; cus-file.el ends here
--- a/lisp/cus-start.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/cus-start.el	Mon Aug 13 11:19:21 2007 +0200
@@ -60,6 +60,7 @@
 	     (visible-bell sound boolean)
 	     (x-allow-sendevents x boolean)
 	     (zmacs-regions editing-basics boolean)
+	     (load-home-init-file installation boolean)
 	     ;; integer
 	     (auto-save-interval auto-save integer)
 	     (bell-volume sound integer)
--- a/lisp/custom-load.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/custom-load.el	Mon Aug 13 11:19:21 2007 +0200
@@ -2,6 +2,8 @@
 
 ;;; Code:
 
+(autoload 'custom-add-loads "cus-load")
+
 (custom-add-loads 'extensions '("auto-show" "wid-edit"))
 (custom-add-loads 'info-faces '("info"))
 (custom-add-loads 'custom-buffer '("cus-edit"))
@@ -15,7 +17,7 @@
 (custom-add-loads 'menu '("menubar-items"))
 (custom-add-loads 'minibuffer '("simple" "minibuf"))
 (custom-add-loads 'log-message '("simple"))
-(custom-add-loads 'environment '("frame" "keydefs" "minibuf" "modeline" "window-xemacs" "menubar" "gutter" "toolbar-items" "cus-edit" "gnuserv" "sound" "x-init"))
+(custom-add-loads 'environment '("frame" "keydefs" "minibuf" "modeline" "window-xemacs" "menubar" "gutter" "x-init" "toolbar-items" "cus-edit" "gnuserv" "sound"))
 (custom-add-loads 'sound '("sound"))
 (custom-add-loads 'pui '("package-ui"))
 (custom-add-loads 'terminals '("gnuserv"))
@@ -43,7 +45,7 @@
 (custom-add-loads 'comm '("ldap"))
 (custom-add-loads 'backup '("files"))
 (custom-add-loads 'frames '("frame" "window-xemacs" "gui" "gnuserv"))
-(custom-add-loads 'customize '("cus-edit" "wid-edit"))
+(custom-add-loads 'customize '("wid-edit" "cus-edit"))
 (custom-add-loads 'custom-browse '("cus-edit"))
 (custom-add-loads 'abbrev '("abbrev" "files"))
 (custom-add-loads 'programming '("cus-edit"))
@@ -60,8 +62,8 @@
 (custom-add-loads 'files '("files"))
 (custom-add-loads 'build '("build-report"))
 (custom-add-loads 'font-lock '("font-lock"))
-(custom-add-loads 'external '("process2" "cus-edit"))
-(custom-add-loads 'development '("process2" "lisp-mode" "cus-edit"))
+(custom-add-loads 'external '("process" "cus-edit"))
+(custom-add-loads 'development '("process" "lisp-mode" "cus-edit"))
 (custom-add-loads 'gnuserv '("gnuserv"))
 (custom-add-loads 'gutter '("gutter" "gutter-items"))
 (custom-add-loads 'fill-comments '("simple"))
@@ -71,16 +73,16 @@
 (custom-add-loads 'fill '("simple" "fill"))
 (custom-add-loads 'custom-magic-faces '("cus-edit"))
 (custom-add-loads 'display '("toolbar" "scrollbar" "auto-show"))
-(custom-add-loads 'faces '("faces" "font" "cus-edit" "font-lock" "hyper-apropos" "info" "wid-edit"))
+(custom-add-loads 'faces '("faces" "cus-edit" "font-lock" "font" "hyper-apropos" "info" "wid-edit"))
 (custom-add-loads 'emacs '("faces" "help" "files" "cus-edit" "package-get"))
-(custom-add-loads 'processes '("process2" "gnuserv"))
+(custom-add-loads 'processes '("process" "gnuserv"))
 (custom-add-loads 'hyper-apropos '("hyper-apropos"))
 (custom-add-loads 'wp '("printer" "cus-edit"))
 (custom-add-loads 'vc '("files"))
 (custom-add-loads 'isearch '("isearch-mode"))
 (custom-add-loads 'font-lock-faces '("font-lock"))
 (custom-add-loads 'modeline '("modeline"))
-(custom-add-loads 'editing '("simple" "abbrev" "fill" "mouse" "dragdrop" "cus-edit"))
+(custom-add-loads 'editing '("simple" "abbrev" "fill" "mouse" "cus-edit" "dragdrop"))
 (custom-add-loads 'matching '("simple" "isearch-mode" "hyper-apropos"))
 (custom-add-loads 'i18n '("cus-edit"))
 (custom-add-loads 'info '("toolbar-items" "info"))
--- a/lisp/custom.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/custom.el	Mon Aug 13 11:19:21 2007 +0200
@@ -38,10 +38,10 @@
 ;;; Code:
 
 (eval-when-compile
-  (load "cl-macs"))
+  (load "cl-macs" nil t))
 
-(if (not (fboundp 'defun*))
-    (autoload 'defun* "cl-macs"))
+(autoload 'custom-declare-face "cus-face")
+(autoload 'defun* "cl-macs")
 
 (require 'widget)
 
--- a/lisp/dumped-lisp.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/dumped-lisp.el	Mon Aug 13 11:19:21 2007 +0200
@@ -49,6 +49,7 @@
 ;; After fixing, eos/loaddefs-eos and loaddefs appear identical?!!
 ;; So just make loaddefs-eos go away...
 ;;(pureload (if (featurep 'sparcworks) "eos/loaddefs-eos" "loaddefs"))
+	"cus-file"
 	"startup"		; For initialization of
 				;  `emacs-user-extension-dir'
 	"misc"
--- a/lisp/etags.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/etags.el	Mon Aug 13 11:19:21 2007 +0200
@@ -505,6 +505,7 @@
 			    ((string-match "\\.scm\\'" filename)
 			     'scheme-mode)
 			    (t nil)))
+      (defvar c-mode-syntax-table)
       (set-syntax-table (cond ((and (eq file-type 'c-mode)
 				    c-mode-syntax-table)
 			       c-mode-syntax-table)
--- a/lisp/faces.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/faces.el	Mon Aug 13 11:19:21 2007 +0200
@@ -1761,7 +1761,8 @@
 			(and 
 			 (featurep 'x)
 			 (x-get-resource "backgroundToolBarColor"
-					 "BackgroundToolBarColor" 'string))
+					 "BackgroundToolBarColor" 'string
+					 nil nil 'warn))
 
 			(face-background 'toolbar))))
 	   (purecopy '("foregroundToolBarColor"
@@ -1769,7 +1770,8 @@
 			(and 
 			 (featurep 'x)
 			 (x-get-resource "foregroundToolBarColor"
-					 "ForegroundToolBarColor" 'string))
+					 "ForegroundToolBarColor" 'string
+					 nil nil 'warn))
 			(face-foreground 'toolbar))))
 	   )))
 
--- a/lisp/files.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/files.el	Mon Aug 13 11:19:21 2007 +0200
@@ -1206,7 +1206,7 @@
     ("\\.m4\\'" . autoconf-mode)
     ("configure\\.in\\'" . autoconf-mode)
     ("\\.ml\\'" . lisp-mode)
-    ("\\.ma?k\\'" . makefile-mode)
+    ("\\.ma?ke?\\'" . makefile-mode)
     ("[Mm]akefile\\(\\.\\|\\'\\)" . makefile-mode)
     ("\\.X\\(defaults\\|environment\\|resources\\|modmap\\)\\'" . xrdb-mode)
     ;; #### The following three are Unix-specific (but do we care?)
@@ -2083,9 +2083,8 @@
   "Convert FILENAME to be relative to DIRECTORY (default: default-directory).
 This function returns a relative file name which is equivalent to FILENAME
 when used with that default directory as the default.
-If this is impossible (which can happen on MSDOS and Windows
-when the file name and directory use different drive names)
-then it returns FILENAME."
+If this is impossible (which can happen on MS Windows when the file name
+and directory use different drive names) then it returns FILENAME."
   (save-match-data
     (let ((fname (expand-file-name filename)))
       (setq directory (file-name-as-directory
--- a/lisp/find-paths.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/find-paths.el	Mon Aug 13 11:19:21 2007 +0200
@@ -109,6 +109,10 @@
     (paths-file-readable-directory-p (paths-construct-path (list directory "lisp")))
     (paths-file-readable-directory-p (paths-construct-path (list directory "etc"))))))
 
+(defun paths-root-in-place-p (root)
+  "Check if ROOT is an in-place installation root for XEmacs."
+  (paths-file-readable-directory-p (paths-construct-path (list root "lisp"))))
+
 (defun paths-chase-symlink (file-name)
   "Chase a symlink until the bitter end."
       (let ((maybe-symlink (file-symlink-p file-name)))
@@ -159,7 +163,8 @@
      base))))
 
 (defun paths-find-emacs-directory (roots suffix base
-				   &optional envvar default keep-suffix)
+				   &optional envvar default keep-suffix
+				   	     in-place-external)
   "Find a directory in the XEmacs hierarchy.
 ROOTS must be a list of installation roots.
 SUFFIX is the subdirectory from there.
@@ -168,7 +173,9 @@
 specify the directory.
 DEFAULT is the preferred value.
 If KEEP-SUFFIX is non-nil, the suffix must be respected in searching
-the directory."
+the directory.
+If IN-PLACE-EXTERNAL is non-nil, the directory might be found outside
+an in-place root-hierarchy."
   (let ((preferred-value (or (and envvar (getenv envvar))
 			     default)))
     (if (and preferred-value
@@ -176,28 +183,39 @@
 	(file-name-as-directory preferred-value)
       (catch 'gotcha
 	(while roots
-	  (let* ((root (car roots))
-		 ;; installed
-		 (path (paths-construct-emacs-directory root suffix base)))
-	    (if (paths-file-readable-directory-p path)
-		(throw 'gotcha path)
-	      ;; in-place
-	      (if (null keep-suffix)
-		  (let ((path (paths-construct-emacs-directory root "" base)))
-		    (if (paths-file-readable-directory-p path)
-			(throw 'gotcha path))))))
+	  (let ((root (car roots)))
+	    ;; installed
+	    (let ((path (paths-construct-emacs-directory root suffix base)))
+	      (if (paths-file-readable-directory-p path)
+		  (throw 'gotcha path)))
+	    ;; in-place
+	    (if (null keep-suffix)
+		(let ((path (paths-construct-emacs-directory root "" base)))
+		  (if (paths-file-readable-directory-p path)
+		      (throw 'gotcha path))))
+	    (if (and in-place-external
+		     (paths-root-in-place-p root))
+		(let ((path (paths-construct-emacs-directory
+			     (paths-construct-path '("..") root)
+			     "" base)))
+		  (if (paths-file-readable-directory-p path)
+		      (throw 'gotcha path)))))
 	  (setq roots (cdr roots)))
 	nil))))
 
-(defun paths-find-site-directory (roots base &optional envvar default)
-  "Find a site-specific directory in the XEmacs hierarchy."
+(defun paths-find-site-directory (roots base &optional envvar default in-place-external)
+  "Find a site-specific directory in the XEmacs hierarchy.
+If IN-PLACE-EXTERNAL is non-nil, the directory might be found outside
+an in-place root-hierarchy."
   (paths-find-emacs-directory roots
 			      (file-name-as-directory
 			       (paths-construct-path (list
 						      "lib"
 						      emacs-program-name)))
 			      base
-			      envvar default))
+			      envvar default
+			      nil
+			      in-place-external))
 
 (defun paths-find-version-directory (roots base
 				     &optional envvar default enforce-version)
--- a/lisp/finder.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/finder.el	Mon Aug 13 11:19:21 2007 +0200
@@ -150,7 +150,9 @@
     (let ((processed nil)
 	  (directory-abbrev-alist
 	   (append
-	    (mapcar (function (lambda (dir) (cons dir "")))
+           (mapcar (function (lambda (dir)
+                               (cons (concat "^" (regexp-quote dir))
+                                     "")))
 		    finder-abbreviate-directory-list)
 	    directory-abbrev-alist))
 	  (using-load-path))
--- a/lisp/font-lock.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/font-lock.el	Mon Aug 13 11:19:21 2007 +0200
@@ -580,25 +580,55 @@
 
 ;; #### barf gag retch.  Horrid FSF lossage that we need to
 ;; keep around for compatibility with font-lock-keywords that
-;; forget to properly quote their faces.
+;; forget to properly quote their faces.  I tried just let-binding
+;; them when we eval the face expression, but that failes because
+;; some	files actually use the variables directly in their init code
+;; without quoting them. --ben
 (defvar font-lock-comment-face 'font-lock-comment-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-doc-string-face 'font-lock-doc-string-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-string-face 'font-lock-string-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-keyword-face 'font-lock-keyword-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-function-name-face 'font-lock-function-name-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-variable-name-face 'font-lock-variable-name-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-type-face 'font-lock-type-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-reference-face 'font-lock-reference-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 (defvar font-lock-preprocessor-face 'font-lock-preprocessor-face
-  "Don't even think of using this.")
+  "This variable should not be set.
+It is present only for horrid FSF compatibility reasons.
+The corresponding face should be set using `edit-faces' or the
+`set-face-*' functions.")
 
 (defconst font-lock-face-list
   '(font-lock-comment-face
@@ -1177,10 +1207,12 @@
 ;;			(if (or change-was-deletion (bobp)
 ;;				(= (preceding-char) ?\n))
 ;;			    (buffer-syntactic-context-flush-cache))
-			(if (and (= beg (point-min))
-				 (= end (point-max)))
-			    (font-lock-fontify-buffer)
-			  (font-lock-fontify-region beg end)))
+			;; #### This creates some unnecessary progress gauges.
+;;			(if (and (= beg (point-min))
+;;				 (= end (point-max)))
+;;			    (font-lock-fontify-buffer)
+;;			  (font-lock-fontify-region beg end)))
+			(font-lock-fontify-region beg end))
 		    font-lock-range-table)))))))
      font-lock-pending-extent-table)))
 
@@ -2490,7 +2522,7 @@
 	 (list
 
 	  ;; Javadoc tags
-	  '("@\\(author\\|exception\\|throws\\|deprecated\\|param\\|return\\|see\\|since\\|version\\)\\s "
+	  '("@\\(author\\|deprecated\\|exception\\|throws\\|param\\|return\\|see\\|since\\|version\\|serial\\|serialData\\|serialField\\)\\s "
 	    0 font-lock-keyword-face t)
 
 	  ;; Doc tag - Parameter identifiers
--- a/lisp/info.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/info.el	Mon Aug 13 11:19:21 2007 +0200
@@ -592,6 +592,7 @@
 	  (bury-buffer (find-file-noselect (car f))))
       (setq f (cdr f)))))
 
+;;;###autoload
 (defun Info-find-node (filename &optional nodename no-going-back tryfile line)
   "Go to an info node specified as separate FILENAME and NODENAME.
 Look for a plausible filename, or if not found then look for URL's and
--- a/lisp/isearch-mode.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/isearch-mode.el	Mon Aug 13 11:19:21 2007 +0200
@@ -1883,8 +1883,7 @@
   ;; buffer.
   (mapc #'delete-extent isearch-highlight-extents)
   (setq isearch-highlight-extents nil)
-  (setq isearch-highlight-all-start nil
-	isearch-window-end nil
+  (setq isearch-window-end nil
 	isearch-highlight-last-string nil))
 
 (defun isearch-highlight-all-update ()
--- a/lisp/itimer.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/itimer.el	Mon Aug 13 11:19:21 2007 +0200
@@ -505,7 +505,7 @@
 	tab-stop-list '(22 32 40 60 67))
   (abbrev-mode 0)
   (auto-fill-mode 0)
-  (buffer-flush-undo (current-buffer))
+  (buffer-disable-undo (current-buffer))
   (use-local-map itimer-edit-map)
   (set-syntax-table emacs-lisp-mode-syntax-table))
 
@@ -714,15 +714,20 @@
 	(unwind-protect
 	    (condition-case condition-data
 		(save-match-data
+		  ;; Suppress warnings - see comment below.
+		  (defvar last-event-time)
+		  (defvar next-wakeup)
+		  (defvar itimer)
+		  (defvar itimers)
+		  (defvar time-elapsed)
 		  (let* ((current-itimer itimer)
 			 (quit-flag nil)
 			 (inhibit-quit nil)
 			 ;; for FSF Emacs timer.el emulation under XEmacs.
 			 ;; eldoc expect this to be done, apparently.
 			 (this-command nil)
-			 ;; bind these variables so that the
-			 ;; itimer function can't screw with
-			 ;; them.
+			 ;; bind these variables so that the itimer
+			 ;; function can't screw with them.
 			 last-event-time next-wakeup
 			 itimer itimers time-elapsed)
 		    (if (itimer-uses-arguments current-itimer)
--- a/lisp/msw-select.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/msw-select.el	Mon Aug 13 11:19:21 2007 +0200
@@ -38,7 +38,7 @@
   (interactive "*")
   (setq last-command nil)
   (setq this-command 'yank) ; so that yank-pop works.
-  (let ((clip (mswindows-get-clipboard)) (s (mark-marker)) (e (point-marker)))
+  (let ((clip (get-clipboard)) (s (mark-marker)) (e (point-marker)))
     (or clip (error "there is no text on the clipboard"))
     (if s
 	(if mouse-track-rectangle-p
--- a/lisp/mule/mule-category.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/mule/mule-category.el	Mon Aug 13 11:19:21 2007 +0200
@@ -35,7 +35,7 @@
 
 ;;; Code:
 
-(defvar defined-category-hashtable (make-hashtable 50))
+(defvar defined-category-hashtable (make-hash-table :size 50))
 
 (defun define-category (designator doc-string)
   "Make a new category whose designator is DESIGNATOR.
--- a/lisp/mule/mule-x-init.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/mule/mule-x-init.el	Mon Aug 13 11:19:21 2007 +0200
@@ -40,16 +40,16 @@
 occupy exactly twice the screen space of ASCII (`halfwidth')
 characters.  On many systems, e.g. Sun CDE systems, this can only be
 achieved by using a national variant roman font to display ASCII."
-  (let ((charset-font-width
-	 (lambda (charset)
-	   (font-instance-width
-	    (face-font-instance 'default (selected-device) charset))))
+  (let* ((charset-font-width
+	  (lambda (charset)
+	    (font-instance-width
+	     (face-font-instance 'default (selected-device) charset))))
 
-	(twice-as-wide
-	 (lambda (cs1 cs2)
-	   (let ((width1 (funcall charset-font-width cs1))
-		 (width2 (funcall charset-font-width cs2)))
-	     (and width1 width2 (eq (+ width1 width1) width2))))))
+	 (twice-as-wide
+	  (lambda (cs1 cs2)
+	    (let ((width1 (funcall charset-font-width cs1))
+		  (width2 (funcall charset-font-width cs2)))
+	      (and width1 width2 (eq (+ width1 width1) width2))))))
 
     (when (eq 'x (device-type))
       (condition-case nil
--- a/lisp/package-get.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/package-get.el	Mon Aug 13 11:19:21 2007 +0200
@@ -373,7 +373,8 @@
 	(unless (and location (file-writable-p location))
 	  (setq location package-get-user-index-filename))
 	(when (y-or-n-p (concat "Update package index in " location "? "))
-	  (write-file location))))))
+	  (let ((coding-system-for-write 'binary))
+	    (write-file location)))))))
 
 
 ;;;###autoload
@@ -399,7 +400,7 @@
         (save-excursion
           (set-buffer buf)
           (erase-buffer buf)
-          (insert-file-contents-internal db-file)
+          (insert-file-contents-literally db-file)
           (package-get-update-base-from-buffer buf)
 	  (if (file-remote-p db-file)
 	      (package-get-maybe-save-index db-file)))
@@ -844,9 +845,7 @@
       ;; Doing it with XEmacs removes the need for an external md5 program
       (message "Validating checksum for `%s'..." package) (sit-for 0)
       (with-temp-buffer
-	;; What ever happened to i-f-c-literally
-	(let (file-name-handler-alist)
-	  (insert-file-contents-internal full-package-filename))
+	(insert-file-contents-literally full-package-filename)
 	(if (not (string= (md5 (current-buffer))
 			  (package-get-info-prop this-package
 						 'md5sum)))
--- a/lisp/package-info.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/package-info.el	Mon Aug 13 11:19:21 2007 +0200
@@ -48,12 +48,11 @@
 ;      (setq result (md5 (current-buffer))))
 ;    result))
 
+;;; APA: Stolen from package-get in package-get.el
 (defun pi-md5sum (file)
   (with-temp-buffer
-    (call-process "md5sum" file t)
-    (goto-char (point-min))
-    (looking-at "[a-z0-9]+")
-    (buffer-substring (match-beginning 0) (match-end 0))))
+	(insert-file-contents-literally file)
+	(md5 (current-buffer))))
 
 (defun pi-update-key (key value)
   (save-excursion
--- a/lisp/package-ui.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/package-ui.el	Mon Aug 13 11:19:21 2007 +0200
@@ -31,7 +31,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defgroup pui nil
-  "Conventient interface to the package system."
+  "Convenient interface to the package system."
   :group 'package-tools
   :tag "Package User interface"
   :prefix "pui-")
@@ -309,7 +309,7 @@
 	      (delete pkg-sym pui-deleted-packages))
       (setq pui-deleted-packages
 	    (cons pkg-sym pui-deleted-packages))
-      (setq pui-seleted-packages
+      (setq pui-selected-packages
 	    (delete pkg-sym pui-selected-packages)))
     (pui-update-package-display extent pkg-sym)
     ))
--- a/lisp/packages.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/packages.el	Mon Aug 13 11:19:21 2007 +0200
@@ -350,7 +350,7 @@
   ;; make sure paths-find-version-directory and paths-find-site-directory
   ;; don't both pick up version-independent directories ...
   (let ((version-directory (paths-find-version-directory roots base nil nil t))
-	(site-directory (paths-find-site-directory roots base)))
+	(site-directory (paths-find-site-directory roots base nil nil t)))
     (paths-uniq-append
      (and version-directory (list version-directory))
      (and site-directory (list site-directory)))))
--- a/lisp/printer.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/printer.el	Mon Aug 13 11:19:21 2007 +0200
@@ -159,15 +159,17 @@
 	       (progn
 		 (setq d (make-device 'msprinter printer-name))
 		 (setq f (make-frame
-			  '(name "Test!"
-				 menubar-visible-p nil
-				 has-modeline-p nil
-				 default-toolbar-visible-p nil
-				 default-gutter-visible-p nil
-				 minibuffer none
-				 modeline-shadow-thickness 0
-				 vertical-scrollbar-visible-p nil
-				 horizontal-scrollbar-visible-p nil)
+			  (list* 'name (concat (substitute ?_ ?. 
+							   (buffer-name buf))
+					       " - XEmacs")
+				 '(menubar-visible-p nil
+				   has-modeline-p nil
+				   default-toolbar-visible-p nil
+				   default-gutter-visible-p nil
+				   minibuffer none
+				   modeline-shadow-thickness 0
+				   vertical-scrollbar-visible-p nil
+				   horizontal-scrollbar-visible-p nil))
 			  d))
 		 (let* ((w (frame-root-window f))
 			(vertdpi (cdr (device-system-metric d 'device-dpi)))
--- a/lisp/process.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/process.el	Mon Aug 13 11:19:21 2007 +0200
@@ -105,8 +105,10 @@
 	      (setq infile (expand-file-name infile))
 	      (setq inbuf (generate-new-buffer "*call-process*"))
 	      (with-current-buffer inbuf
-		(insert-file-contents-internal infile nil nil nil nil
-					       coding-system-for-read)))
+               ;; Make sure this works with jka-compr
+               (let ((file-name-handler-alist nil))
+                 (insert-file-contents-internal infile nil nil nil nil
+                                                'binary))))
 	    (let ((stderr (if (consp buffer) (second buffer) t)))
 	      (if (consp buffer) (setq buffer (car buffer)))
 	      (setq buffer
@@ -429,8 +431,14 @@
 
 (defun shell-quote-argument (argument)
   "Quote an argument for passing as argument to an inferior shell."
-  (if (eq system-type 'windows-nt)
-      (nt-quote-process-args (list shell-file-name argument))
+  (if (and (eq system-type 'windows-nt)
+	   ;; #### this is a temporary hack.  a better solution needs
+	   ;; futzing with the c code.  i'll do this shortly.
+	   (let ((progname (downcase (file-name-nondirectory
+				      shell-file-name))))
+	     (or (equal progname "command.com")
+		 (equal progname "cmd.exe"))))
+      argument
     ;; Quote everything except POSIX filename characters.
     ;; This should be safe enough even for really weird shells.
     (let ((result "") (start 0) end)
--- a/lisp/rect.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/rect.el	Mon Aug 13 11:19:21 2007 +0200
@@ -273,12 +273,10 @@
 
 
 (defun open-rectangle-line (startcol endcol fill)
-  (let (spaces)
-    (when (= (move-to-column startcol (or fill 'coerce)) startcol)
-      (unless (and (not fill)
-		   (= (point) (point-at-eol)))
-	(indent-to endcol)))
-    ))
+  (when (= (move-to-column startcol (or fill 'coerce)) startcol)
+    (unless (and (not fill)
+		 (= (point) (point-at-eol)))
+      (indent-to endcol))))
 
 ;;;###autoload
 (defun open-rectangle (start end &optional fill)
@@ -308,6 +306,7 @@
 
 When called from a program, the rectangle's corners are START and END."
   (interactive "*r\nsString rectangle: ")
+  (defvar pending-delete-mode)
   (apply-on-rectangle 'string-rectangle-line start end string
                       (and (boundp 'pending-delete-mode) pending-delete-mode)))
 
--- a/lisp/select.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/select.el	Mon Aug 13 11:19:21 2007 +0200
@@ -105,24 +105,33 @@
 		    (get-selection type (cdr data-type))
 		  (signal (car err) (cdr err)))))
 	   (get-selection-internal type data-type))))
-    (when (and (consp text) (symbolp (car text)))
-      (setq text (cdr text)))
-    (when (not (stringp text))
-      (error "Selection is not a string: %S" text))
     text))
 
 ;; FSFmacs calls this `x-set-selection', and reverses the
 ;; first two arguments (duh ...).  This order is more logical.
-(defun own-selection (data &optional type append)
+(defun own-selection (data &optional type how-to-add data-type)
   "Make a window-system selection of type TYPE and value DATA.
 The argument TYPE (default `PRIMARY') says which selection,
-and DATA specifies the contents.  DATA may be a string,
-a symbol, an integer (or a cons of two integers or list of two integers).
-If APPEND is non-nil, append the data to the existing selection data.
+and DATA specifies the contents.  DATA may be any lisp data type
+that can be converted using the function corresponding to DATA-TYPE
+in `select-converter-alist'---strings are the usual choice, but
+other types may be permissible depending on the DATA-TYPE parameter
+(if DATA-TYPE is not supplied, the default behaviour is window
+system specific, but strings are always accepted).
+HOW-TO-ADD may be any of the following:
+
+  'replace-all or nil -- replace all data in the selection.
+  'replace-existing   -- replace data for specified DATA-TYPE only.
+  'append or t        -- append data to existing DATA-TYPE data.
+
+DATA-TYPE is the window-system specific data type identifier
+(see `register-selection-data-type' for more information).
 
 The selection may also be a cons of two markers pointing to the same buffer,
 or an overlay.  In these cases, the selection is considered to be the text
-between the markers *at whatever time the selection is examined*.
+between the markers *at whatever time the selection is examined* (note
+that the window system clipboard does not necessarily duplicate this
+behaviour - it doesn't on mswindows for example).
 Thus, editing done in the buffer after you specify the selection
 can alter the effective value of the selection.
 
@@ -138,32 +147,13 @@
     ;; "This is for temporary compatibility with pre-release Emacs 19."
 					;(if (stringp type)
 					;    (setq type (intern type)))
-    (or (valid-simple-selection-p data)
-	(and (vectorp data)
-	     (let ((valid t)
-		   (i (1- (length data))))
-	       (while (>= i 0)
-		 (or (valid-simple-selection-p (aref data i))
-		     (setq valid nil))
-		 (setq i (1- i)))
-	       valid))
-	(signal 'error (list "invalid selection" data)))
     (or type (setq type 'PRIMARY))
-    (flet ((own-selection-1
-	    (type data append)
-	    (when append
-	      (unless (stringp data)
-		;; kludge!
-		(setq data (select-convert-to-text type 'STRING data))
-		(if (stringp data)
-		    (setq data (concat (get-selection type) data)))))
-	    (own-selection-internal type data)))
-      (if (null data)
-	  (disown-selection-internal type)
-	(own-selection-1 type data append)
-	(when (and (eq type 'PRIMARY)
-		   selection-sets-clipboard)
-	  (own-selection-internal 'CLIPBOARD data append))))
+    (if (null data)
+	(disown-selection-internal type)
+      (own-selection-internal type data how-to-add data-type)
+      (when (and (eq type 'PRIMARY)
+		 selection-sets-clipboard)
+	 (own-selection-internal 'CLIPBOARD data how-to-add data-type)))
     (cond ((eq type 'PRIMARY)
 	   (setq primary-selection-extent
 		 (select-make-extent-for-selection
@@ -176,7 +166,7 @@
   ;; when behaving as the latter, we better not set it, or we will
   ;; cause unwanted sticky-region behavior in kill-region and friends.
   (if (interactive-p)
-      (setq zmacs-region-stays t))
+  (setq zmacs-region-stays t))
   data)
 
 (defun dehilight-selection (selection)
@@ -200,9 +190,9 @@
 
 (setq lost-selection-hooks 'dehilight-selection)
 
-(defun own-clipboard (string &optional append)
+(defun own-clipboard (string &optional push)
   "Paste the given string to the window system Clipboard.
-If APPEND is non-nil, append the string to the existing contents."
+See `interprogram-cut-function' for more information."
   (own-selection string 'CLIPBOARD))
 
 (defun disown-selection (&optional secondary-p)
@@ -306,6 +296,9 @@
 
 ;; moved from x-select.el
 (defun valid-simple-selection-p (data)
+  "An obsolete function that tests whether something was a valid simple
+selection using the old XEmacs selection support. You shouldn't use this
+any more, because just about anything could be a valid selection now."
   (or (stringp data)
       ;FSFmacs huh?? (symbolp data)
       (integerp data)
@@ -367,11 +360,31 @@
       (disown-selection nil)
       )))
 
+
 ;;; Functions to convert the selection into various other selection
-;;; types.  Every selection type that emacs handles is implemented
-;;; this way, except for TIMESTAMP, which is a special case. These are
-;;; all moved from x-select.el
+;;; types.
+
+;; These two functions get called by C code...
+(defun select-convert-in (selection type value)
+  "Attempt to convert the specified external VALUE to the specified DATA-TYPE,
+for the specified SELECTION. Return nil if this is impossible, or a
+suitable internal representation otherwise."
+  (when value
+    (let ((handler-fn (cdr (assq type selection-converter-in-alist))))
+      (when handler-fn
+	(apply handler-fn (list selection type value))))))
 
+(defun select-convert-out (selection type value)
+  "Attempt to convert the specified internal VALUE for the specified DATA-TYPE
+and SELECTION. Return nil if this is impossible, or a suitable external
+representation otherwise."
+  (when value
+    (let ((handler-fn (cdr (assq type selection-converter-out-alist))))
+      (when handler-fn
+	(apply handler-fn (list selection type value))))))
+
+;; The rest of the functions on this "page" are conversion handlers,
+;; append handlers and buffer-kill handlers.
 (defun select-convert-to-text (selection type value)
   (cond ((stringp value)
 	 value)
@@ -397,6 +410,10 @@
 	     (buffer-substring (car value) (cdr value)))))
 	(t nil)))
 
+(defun select-convert-from-text (selection type value)
+  (when (stringp value)
+    value))
+
 (defun select-convert-to-string (selection type value)
   (let ((outval (select-convert-to-text selection type value)))
     ;; force the string to be not in Compound Text format.
@@ -427,6 +444,9 @@
 	(cons (ash value -16) (logand value 65535))
       nil)))
 
+(defun select-convert-from-length (selection type value)
+  (select-convert-to-length selection type value))
+
 (defun select-convert-to-targets (selection type value)
   ;; return a vector of atoms, but remove duplicates first.
   (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
@@ -434,8 +454,6 @@
     (while rest
       (cond ((memq (car rest) (cdr rest))
 	     (setcdr rest (delq (car rest) (cdr rest))))
-	    ((eq (car (cdr rest)) '_EMACS_INTERNAL)  ; shh, it's a secret
-	     (setcdr rest (cdr (cdr rest))))
 	    (t
 	     (setq rest (cdr rest)))))
     (apply 'vector all)))
@@ -458,6 +476,10 @@
 			       (error "selection is in a killed buffer"))))
 	(t nil)))
 
+(defun select-convert-from-filename (selection type value)
+  (when (stringp value)
+    value))
+
 (defun select-convert-to-charpos (selection type value)
   (let (a b tmp)
     (cond ((cond ((extentp value)
@@ -575,13 +597,127 @@
   (and (integerp value)
        (cons (ash value -16) (logand value 65535))))
 
+;; Can convert from the following integer representations
+;;
+;;    integer
+;;    (integer . integer)
+;;    (integer integer)
+;;    (list [integer|(integer . integer)]*)
+;;    (vector [integer|(integer . integer)]*)
+;;
+;; Cons'd integers get cleaned up a little.
+
+(defun select-convert-from-integer (selection type value)
+  (cond ((integerp value)		; Integer
+	 value)
+	
+	((and (consp value)		; (integer . integer)
+	      (integerp (car value))
+	      (integerp (cdr value)))
+	 (if (eq (car value) 0)
+	     (cdr value)
+	   (if (and (eq (car value) -1)
+		    (< (cdr value) 0))
+	       (cdr value)
+	     value)))
+	
+	((and (listp value)		; (integer integer)
+	      (eq (length value) 2)
+	      (integerp (car value))
+	      (integerp (cadr value)))
+	 (if (eq (car value) 0)
+	     (cadr value)
+	   (if (and (eq (car value) -1)
+		    (< (cdr value) 0))
+	       (- (cadr value))
+	     (cons (car value) (cadr value)))))
+	
+	((listp value)			; list
+	 (if (cdr value)
+	     (mapcar '(lambda (x)
+			(select-convert-from-integer selection type x))
+		     value)
+	   (select-convert-from-integer selection type (car value))))
+	
+	((vectorp value)		; vector
+	 (if (eq (length value) 1)
+	     (select-convert-from-integer selection type (aref value 0))
+	   (mapvector '(lambda (x)
+			(select-convert-from-integer selection type x))
+		     value)))
+	
+	(t nil)
+	))
+
 (defun select-convert-to-atom (selection type value)
   (and (symbolp value) value))
 
-(defun select-convert-to-identity (selection type value) ; used internally
-  (vector value))
+;;; CF_xxx conversions
+(defun select-convert-from-cf-text (selection type value)
+  (replace-in-string (if (string-match "\0" value)
+			 (substring value 0 (match-beginning 0))
+		       value)
+		     "\\(\r\n\\|\n\r\\)" "\n" t))
+
+(defun select-convert-to-cf-text (selection type value)
+  (let ((text (select-convert-to-text selection type value)))
+    (concat (replace-in-string text "\n" "\r\n" t) "\0")))
+
+;;; Appenders
+(defun select-append-to-text (selection type value1 value2)
+  (let ((text1 (select-convert-to-text selection 'STRING value1))
+	(text2 (select-convert-to-text selection 'STRING value2)))
+    (if (and text1 text2)
+	(concat text1 text2)
+      nil)))
+
+(defun select-append-to-string (selection type value1 value2)
+  (select-append-to-text selection type value1 value2))
+
+(defun select-append-to-compound-text (selection type value1 value2)
+  (select-append-to-text selection type value1 value2))
+
+(defun select-append-to-cf-text (selection type value1 value2)
+  (let ((text1 (select-convert-from-cf-text selection 'CF_TEXT value1))
+	(text2 (select-convert-from-cf-text selection 'CF_TEXT value2)))
+    (if (and text1 text2)
+	(select-convert-to-cf-text selection type (concat text1 text2))
+      nil)))
 
-(setq selection-converter-alist
+(defun select-append-default (selection type value1 value2)
+;; This appender gets used if the type is "nil" - i.e. default.
+;; It should probably have more cases implemented than it does - e.g.
+;; appending numbers to strings, etc...
+  (cond ((and (stringp value1) (stringp value2))
+	 (select-append-to-string selection 'STRING value1 value2))
+	(t nil)))
+
+;;; Buffer kill handlers
+
+;; #### Should this function take the text *out* of the buffer that's
+;; being killed? Or should it do what the original code did and just
+;; destroy the selection?
+(defun select-buffer-killed-default (selection type value buffer)
+;; This handler gets used if the type is "nil".
+  (cond ((extentp value)
+	 (unless (eq (extent-object value) buffer)
+	   value))
+	((markerp value)
+	 (unless (eq (marker-buffer value) buffer)
+	   value))
+	((and (consp value)
+	      (markerp (car value))
+	      (markerp (cdr value)))
+	 (unless (or (eq (marker-buffer (car value)) buffer)
+		     (eq (marker-buffer (cdr value)) buffer))
+	   value))
+	(t value)))
+
+(defun select-buffer-killed-text (selection type value buffer)
+  (select-buffer-killed-default selection type value buffer))
+	
+;; Types listed in here can be selections of XEmacs
+(setq selection-converter-out-alist
       '((TEXT . select-convert-to-text)
 	(STRING . select-convert-to-string)
 	(COMPOUND_TEXT . select-convert-to-compound-text)
@@ -600,7 +736,46 @@
 	(NAME . select-convert-to-name)
 	(ATOM . select-convert-to-atom)
 	(INTEGER . select-convert-to-integer)
-	(_EMACS_INTERNAL . select-convert-to-identity)
+	(CF_TEXT . select-convert-to-cf-text)
+	))
+
+;; Types listed here can be selections foreign to XEmacs
+(setq selection-converter-in-alist
+      '(; Specific types that get handled by generic converters
+	(COMPOUND_TEXT . select-convert-from-text)
+	(SOURCE_LOC . select-convert-from-text)
+	(OWNER_OS . select-convert-from-text)
+	(HOST_NAME . select-convert-from-text)
+	(USER . select-convert-from-text)
+	(CLASS . select-convert-from-text)
+	(NAME . select-convert-from-text)
+	; Generic types
+	(INTEGER . select-convert-from-integer)
+	(TEXT . select-convert-from-text)
+	(STRING . select-convert-from-text)
+	(LENGTH . select-convert-from-length)
+	(FILE_NAME . select-convert-from-filename)
+	(CF_TEXT . select-convert-from-cf-text)
 	))
 
+;; Types listed here can be appended by own-selection
+(setq selection-appender-alist
+      '((nil . select-append-default)
+	(TEXT . select-append-to-text)
+	(STRING . select-append-to-string)
+	(COMPOUND_TEXT . select-append-to-compound-text)
+	(CF_TEXT . select-append-to-cf-text)
+	))
+
+;; Types listed here have buffer-kill handlers
+(setq selection-buffer-killed-alist
+      '((nil . select-buffer-killed-default)
+	(TEXT . select-buffer-killed-text)
+	(STRING . select-buffer-killed-text)
+	(COMPOUND_TEXT . select-buffer-killed-text)
+	(CF_TEXT . select-buffer-killed-text)))
+
+;; Lists of types that are coercible (can be converted to other types)
+(setq selection-coercible-types '(TEXT STRING COMPOUND_TEXT))
+
 ;;; select.el ends here
--- a/lisp/simple.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/simple.el	Mon Aug 13 11:19:21 2007 +0200
@@ -719,9 +719,18 @@
 		 (message "Line %d" buffer-line)))))))
   (setq zmacs-region-stays t))
 
-;;; Bob Weiner, Altrasoft, 02/12/1998
-;;; Added the 3rd arg in `count-lines' to conditionalize the counting of
-;;; collapsed lines.
+;; new in XEmacs 21.2 (not in FSF).
+(defun line-number (&optional pos respect-narrowing)
+  "Return the line number of POS (defaults to point).
+If RESPECT-NARROWING is non-nil, then the narrowed line number is returned;
+otherwise, the absolute line number is returned.  The returned line can always
+be given to `goto-line' to get back to the current line."
+  (if (and pos (/= pos (point)))
+      (save-excursion
+	(goto-char pos)
+	(line-number nil respect-narrowing))
+    (1+ (count-lines (if respect-narrowing (point-min) 1) (point-at-bol)))))
+
 (defun count-lines (start end &optional ignore-invisible-lines-flag)
   "Return number of lines between START and END.
 This is usually the number of newlines between them,
@@ -729,7 +738,13 @@
 and the greater of them is not at the start of a line.
 
 With optional IGNORE-INVISIBLE-LINES-FLAG non-nil, lines collapsed with
-selective-display are excluded from the line count."
+selective-display are excluded from the line count.
+
+NOTE: The expression to return the current line number is not obvious:
+
+(1+ (count-lines 1 (point-at-bol)))
+
+See also `line-number'."
   (save-excursion
     (save-restriction
       (narrow-to-region start end)
--- a/lisp/startup.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/startup.el	Mon Aug 13 11:19:21 2007 +0200
@@ -107,17 +107,30 @@
 (defvar user-init-directory-base ".xemacs"
   "Base of directory where user-installed init files may go.")
 
-(defvar user-init-file-base-list (append
-				  '(".emacs.elc" ".emacs.el" ".emacs")
-				  (and (eq system-type 'windows-nt)
-				       '("_emacs.elc" "_emacs.el" "_emacs")))
-  "List of allowed init files.  The first one found takes precedence.")
-
 (defvar user-init-directory
   (file-name-as-directory
    (paths-construct-path (list "~" user-init-directory-base)))
   "Directory where user-installed init files may go.")
 
+(defvar user-init-file-base "init.el"
+  "Default name of the user init file if uncompiled.
+This should be used for migration purposes only.")
+
+(defvar user-init-file-base-list '("init.elc" "init.el")
+  "List of allowed init files in the user's init directory.
+The first one found takes precedence.")
+
+(defvar user-home-init-file-base-list
+  (append '(".emacs.elc" ".emacs.el" ".emacs")
+	  (and (eq system-type 'windows-nt)
+	       '("_emacs.elc" "_emacs.el" "_emacs")))
+  "List of allowed init files in the user's home directory.
+The first one found takes precedence.")
+
+(defvar load-home-init-file nil
+  "Non-nil if XEmacs should load the init file from the home directory.
+Otherwise, XEmacs will offer migration to the init directory.")
+
 (defvar load-user-init-file-p t
   "Non-nil if XEmacs should load the user's init file.")
 
@@ -447,6 +460,9 @@
       (when window-setup-hook
 	(run-hooks 'window-setup-hook))
       (setq window-setup-hook nil))
+
+    (if load-user-init-file-p
+	(maybe-migrate-user-init-file))
     ;;####FSFmacs junk
     ;;      (or menubar-bindings-done
     ;;	  (precompute-menubar-bindings))
@@ -530,10 +546,13 @@
  	    (string= arg "-user"))
 	(let* ((user (pop args))
 	       (home-user (concat "~" user)))
-	  (setq user-init-file (find-user-init-file home-user)
-		user-init-directory (file-name-as-directory
+	  (setq user-init-directory (file-name-as-directory
 				     (paths-construct-path
-				      (list home-user user-init-directory-base))))))
+				      (list home-user user-init-directory-base))))
+	  (setq user-init-file
+		(find-user-init-file user-init-directory home-user))
+	  (setq custom-file
+		(make-custom-file-name user-init-file))))
        ((string= arg "-debug-init")
 	(setq init-file-debug t))
        ((string= arg "-unmapped")
@@ -637,20 +656,88 @@
 	    (setq term (substring term 0 hyphend))
 	  (setq term nil))))))
 
-(defun find-user-init-file (&optional directory)
+(defun find-user-init-directory-init-file (&optional init-directory)
+  "Determine the user's init file if in the init directory."
+  (let ((init-directory (or init-directory user-init-directory)))
+    (catch 'found
+      (dolist (file user-init-file-base-list)
+	(let ((expanded (expand-file-name file init-directory)))
+	  (when (file-exists-p expanded)
+	    (throw 'found expanded)))))))
+
+(defun find-user-home-directory-init-file (&optional home-directory)
+  "Determine the user's init file if in the home directory."
+  (let ((home-directory (or home-directory "~")))
+    (catch 'found
+      (dolist (file user-home-init-file-base-list)
+	(let ((expanded (expand-file-name file home-directory)))
+	  (when (file-exists-p expanded)
+	    (throw 'found expanded))))
+      nil)))
+
+(defun find-user-init-file (&optional init-directory home-directory)
   "Determine the user's init file."
-  (unless directory
-    (setq directory "~"))
-  (dolist (file user-init-file-base-list)
-    (let ((expanded (paths-construct-path (list directory file))))
-      (when (file-exists-p expanded)
-	(return expanded)))))
+  (if load-home-init-file
+      (find-user-home-directory-init-file home-directory)
+    (or (find-user-init-directory-init-file init-directory)
+	(find-user-home-directory-init-file home-directory))))
+
+(defun maybe-migrate-user-init-file ()
+  "Ask user if she wants to migrate the init file(s) to new location."
+  (if (and (not load-home-init-file)
+	   (not (find-user-init-directory-init-file user-init-directory))
+	   (file-exists-p user-init-file))
+      (if (with-output-to-temp-buffer (help-buffer-name nil)
+	    (progn
+	      (princ "XEmacs recommends that the initialization code in
+")
+	      (princ user-init-file)
+	      (princ "
+be migrated to the ")
+	      (princ user-init-directory)
+	      (princ " directory.  XEmacs can
+perform the migration automatically.
+
+After the migration, init.el/init.elc holds user-written
+initialization code.  Moreover the customize settings will be in
+custom.el.
+
+If you choose not to do this now, XEmacs will not ask you this
+question in the future.  However, you can still make XEmacs
+perform the migration at any time with M-x migrate-user-init-file.")
+	      (show-temp-buffer-in-current-frame standard-output)
+	      (yes-or-no-p-minibuf (concat "Migrate init file to "
+					   user-init-directory
+					   "? "))))
+	  (migrate-user-init-file)
+	(customize-save-variable 'load-home-init-file t))))
+
+(defun migrate-user-init-file ()
+  "Migrate the init file from the home directory."
+  (interactive)
+  (if (not (file-exists-p user-init-directory))
+      (progn
+	(message "Creating %s directory..." user-init-directory)
+	(make-directory user-init-directory)))
+  (message "Migrating custom file...")
+  (custom-migrate-custom-file (make-custom-file-name user-init-file
+						     'force-new))
+  (message "Moving init file...")
+  (rename-file user-init-file
+	       (expand-file-name user-init-file-base
+				 user-init-directory))
+  (message "Migration done."))
 
 (defun load-user-init-file ()
-  "This function actually reads the init file, .emacs."
+  "This function actually reads the init file."
   (if (or user-init-file
-          (setq user-init-file (find-user-init-file)))
+          (setq user-init-file (find-user-init-file user-init-directory)))
       (load user-init-file t t t))
+  (if (not custom-file)
+      (setq custom-file (make-custom-file-name user-init-file)))
+  (if (and (not (string= custom-file user-init-file))
+	   (file-exists-p custom-file))
+      (load custom-file t t t))
   (unless inhibit-default-init
     (let ((inhibit-startup-message nil))
       ;; Users are supposed to be told their rights.
@@ -678,8 +765,9 @@
 	 (if (eq init-file-debug t) 'startup init-file-debug)))
     (let ((debug-on-error debug-on-error-initial))
       (if (and load-user-init-file-p init-file-debug)
-	  ;; Do this without a condition-case if the user wants to debug.
-	  (load-user-init-file)
+	  (progn
+	    ;; Do this without a condition-case if the user wants to debug.
+	    (load-user-init-file))
 	(condition-case error
 	    (progn
 	      (if load-user-init-file-p
--- a/lisp/toolbar.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/toolbar.el	Mon Aug 13 11:19:21 2007 +0200
@@ -123,6 +123,9 @@
 (defvar last-pressed-toolbar-button nil)
 (defvar toolbar-active nil)
 
+(defvar toolbar-blank-press-function nil
+  "Function to call if a blank area of the toolbar is pressed.")
+
 ;;
 ;; It really sucks that we also have to tie onto
 ;; default-mouse-motion-handler to make sliding buttons work right.
@@ -143,9 +146,8 @@
 	  (setq last-pressed-toolbar-button button))
       ;; Added by Bob Weiner, Motorola Inc., 10/6/95, to handle
       ;; presses on blank portions of toolbars.
-      (and (boundp 'toolbar-blank-press-function)
-	   (functionp toolbar-blank-press-function)
-	   (funcall toolbar-blank-press-function event)))))
+      (when (functionp toolbar-blank-press-function)
+	(funcall toolbar-blank-press-function event)))))
 
 (defun release-and-activate-toolbar-button (event)
   "Release a toolbar button and activate its callback.
--- a/lisp/x-faces.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/x-faces.el	Mon Aug 13 11:19:21 2007 +0200
@@ -492,11 +492,13 @@
 	     (or (null locale) (eq locale 'global)))
 	(progn
 	  (or fn (setq fn (x-get-resource
-			   "font" "Font" 'string locale)))
+			   "font" "Font" 'string locale nil 'warn)))
 	  (or fg (setq fg (x-get-resource
-			   "foreground" "Foreground" 'string locale)))
+			   "foreground" "Foreground" 'string locale nil
+			   'warn)))
 	  (or bg (setq bg (x-get-resource
-			   "background" "Background" 'string locale)))))
+			   "background" "Background" 'string locale nil
+			   'warn)))))
     ;;
     ;; "*cursorColor: foo" is equivalent to setting the background of the
     ;; text-cursor face.
@@ -504,7 +506,8 @@
     (if (and (eq (face-name face) 'text-cursor)
 	     (or (null locale) (eq locale 'global)))
 	(setq bg (or (x-get-resource
-		      "cursorColor" "CursorColor" 'string locale) bg)))
+		      "cursorColor" "CursorColor" 'string locale nil 'warn)
+		     bg)))
     ;; #### should issue warnings?  I think this should be
     ;; done when the instancing actually happens, but I'm not
     ;; sure how it should actually be dealt with.
@@ -735,7 +738,8 @@
   ;; If reverseVideo was specified, swap the foreground and background
   ;; of the default and modeline faces.
   ;;
-  (cond ((car (x-get-resource "reverseVideo" "ReverseVideo" 'boolean frame))
+  (cond ((car (x-get-resource "reverseVideo" "ReverseVideo" 'boolean frame
+			      nil 'warn))
 	 ;; First make sure the modeline has fg and bg, inherited from the
 	 ;; current default face - for the case where only one is specified,
 	 ;; so that invert-face doesn't do something weird.
--- a/lisp/x-misc.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/x-misc.el	Mon Aug 13 11:19:21 2007 +0200
@@ -66,7 +66,7 @@
 	  (let* ((name (caar resource-list))
 		 (class (cdar resource-list))
 		 (resource
-		  (x-get-resource name class type locale nil t)))
+		  (x-get-resource name class type locale nil 'warn)))
 	    (if resource
 		(progn
 		  (add-spec-to-specifier specifier resource locale)
@@ -75,12 +75,12 @@
 
 (defun x-get-resource-and-bogosity-check (name class type &optional locale)
   (x-bogosity-check-resource name class type)
-  (x-get-resource name class type locale nil t))
+  (x-get-resource name class type locale nil 'warn))
 
 (defun x-get-resource-and-maybe-bogosity-check (name class type &optional
 						     locale)
   (if (eq locale 'global)
       (x-bogosity-check-resource name class type))
-  (x-get-resource name class type locale nil t))
+  (x-get-resource name class type locale nil 'warn))
 
 ;;; x-misc.el ends here
--- a/lisp/x-mouse.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/x-mouse.el	Mon Aug 13 11:19:21 2007 +0200
@@ -100,41 +100,48 @@
   (if x-pointers-initialized  ; only do it when the first device is created
       nil
     (set-glyph-image text-pointer-glyph
-	  (or (x-get-resource "textPointer" "Cursor" 'string device)
+	  (or (x-get-resource "textPointer" "Cursor" 'string device nil 'warn)
 	      "xterm"))
     (set-glyph-image selection-pointer-glyph
-	  (or (x-get-resource "selectionPointer" "Cursor" 'string device)
+	  (or (x-get-resource "selectionPointer" "Cursor" 'string device
+			      nil 'warn)
 	      "top_left_arrow"))
     (set-glyph-image nontext-pointer-glyph
-	  (or (x-get-resource "spacePointer" "Cursor" 'string device)
+	  (or (x-get-resource "spacePointer" "Cursor" 'string device nil 'warn)
 	      "xterm")) ; was "crosshair"
     (set-glyph-image modeline-pointer-glyph
-	  (or (x-get-resource "modeLinePointer" "Cursor" 'string device)
+	  (or (x-get-resource "modeLinePointer" "Cursor" 'string device
+			      nil 'warn)
 ;;	      "fleur"))
 	      "sb_v_double_arrow"))
     (set-glyph-image gc-pointer-glyph
-	  (or (x-get-resource "gcPointer" "Cursor" 'string device)
+	  (or (x-get-resource "gcPointer" "Cursor" 'string device nil 'warn)
 	      "watch"))
     (when (featurep 'scrollbar)
       (set-glyph-image
        scrollbar-pointer-glyph
-       (or (x-get-resource "scrollbarPointer" "Cursor" 'string device)
+       (or (x-get-resource "scrollbarPointer" "Cursor" 'string device
+			   nil 'warn)
 	   "top_left_arrow")))
     (set-glyph-image busy-pointer-glyph
-	  (or (x-get-resource "busyPointer" "Cursor" 'string device)
+	  (or (x-get-resource "busyPointer" "Cursor" 'string device nil 'warn)
 	      "watch"))
     (set-glyph-image toolbar-pointer-glyph
-	  (or (x-get-resource "toolBarPointer" "Cursor" 'string device)
+	  (or (x-get-resource "toolBarPointer" "Cursor" 'string device
+			      nil 'warn)
 	      "left_ptr"))
     (set-glyph-image divider-pointer-glyph
-	  (or (x-get-resource "dividerPointer" "Cursor" 'string device)
+	  (or (x-get-resource "dividerPointer" "Cursor" 'string device
+			      nil 'warn)
 	      "sb_h_double_arrow"))
     (let ((fg
-	   (x-get-resource "pointerColor" "Foreground" 'string device)))
+	   (x-get-resource "pointerColor" "Foreground" 'string device
+			   nil 'warn)))
       (and fg
 	   (set-face-foreground 'pointer fg)))
     (let ((bg
-	   (x-get-resource "pointerBackground" "Background" 'string device)))
+	   (x-get-resource "pointerBackground" "Background" 'string device
+			   nil 'warn)))
       (and bg
 	   (set-face-background 'pointer bg)))
     (setq x-pointers-initialized t))
--- a/lisp/x-scrollbar.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/x-scrollbar.el	Mon Aug 13 11:19:21 2007 +0200
@@ -80,7 +80,7 @@
   ;; Now do ScrollBarPlacement.scrollBarPlacement
   (let ((case-fold-search t)
 	(resval (x-get-resource "ScrollBarPlacement" "scrollBarPlacement"
-				'string locale)))
+				'string locale nil 'warn)))
     (cond
      ((null resval))
      ((string-match "^top[_-]left$" resval)
--- a/lisp/x-select.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/lisp/x-select.el	Mon Aug 13 11:19:21 2007 +0200
@@ -88,36 +88,6 @@
 ;(setq x-sent-selection-hooks 'x-notice-selection-failures)
 
 
-;;; Selections in killed buffers
-;;; this function is called by kill-buffer as if it were on the
-;;; kill-buffer-hook (though it isn't really).
-
-(defun xselect-kill-buffer-hook ()
-  ;; Probably the right thing is to write a C function to return a list
-  ;; of the selections which emacs owns, since it could conceivably own
-  ;; a user-defined selection type that we've never heard of.
-  (xselect-kill-buffer-hook-1 'PRIMARY)
-  (xselect-kill-buffer-hook-1 'SECONDARY)
-  (xselect-kill-buffer-hook-1 'CLIPBOARD))
-
-(defun xselect-kill-buffer-hook-1 (selection)
-  (let (value)
-    (if (and (selection-owner-p selection)
-	     (setq value (get-selection-internal selection '_EMACS_INTERNAL))
-	     ;; The _EMACS_INTERNAL selection type has a converter registered
-	     ;; for it that does no translation.  This only works if emacs is
-	     ;; requesting the selection from itself.  We could have done this
-	     ;; by writing a C function to return the raw selection data, and
-	     ;; that might be the right way to do this, but this was easy.
-	     (or (and (consp value)
-		      (markerp (car value))
-		      (eq (current-buffer) (marker-buffer (car value))))
-		 (and (extent-live-p value)
-		      (eq (current-buffer) (extent-object value)))
-                 (and (extentp value) (not (extent-live-p value)))))
-	(disown-selection-internal selection))))
-
-
 ;;; Cut Buffer support
 
 ;;; FSF name x-get-cut-buffer
--- a/lwlib/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,27 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* xlwcheckbox.c:
+	* xlwgauge.h:
+	* xlwgaugeP.h:
+	* xlwradio.h:
+	* xlwradioP.h:
+	* xlwgauge.c:
+	* config.h.in:
+	* xlwradio.c:
+	* lwlib-Xaw.c:
+	Replace SMART_INCLUDE with a dumber, but more reliable method.
+
+	* xlwmenu.c (parameterize_string): Fix C++ compilation warnings.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* lwlib-Xaw.c (xaw_create_label): add sanity check on arg limit.
+	(xaw_update_one_value): fix crash due to incorrect arg count.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/lwlib/config.h.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/config.h.in	Mon Aug 13 11:19:21 2007 +0200
@@ -29,12 +29,18 @@
 #undef NEED_ATHENA
 #undef NEED_LUCID
 
-/* The path to the Athena widgets - the usual value is `X11/Xaw' */
-#undef ATHENA_H_PATH
-#ifdef ATHENA_H_PATH
-# define ATHENA_INCLUDE(file) SMART_INCLUDE (ATHENA_H_PATH,file)
-#else
-# define ATHENA_INCLUDE(file) <file>
-#endif
+/* The exact path to the Athena header files depends on which `flavor'
+   of Athena is being used - hence configure defines them for us. */
+
+#undef ATHENA_Scrollbar_h_
+#undef ATHENA_Dialog_h_
+#undef ATHENA_Form_h_
+#undef ATHENA_Command_h_
+#undef ATHENA_Label_h_
+#undef ATHENA_LabelP_h_
+#undef ATHENA_Toggle_h_
+#undef ATHENA_ToggleP_h_
+#undef ATHENA_AsciiText_h_
+#undef ATHENA_XawInit_h_
 
 #endif /* _LWLIB_CONFIG_H_ */
--- a/lwlib/lwlib-Xaw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/lwlib-Xaw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -33,21 +33,21 @@
 #include <X11/Shell.h>
 
 #ifdef LWLIB_SCROLLBARS_ATHENA
-#include ATHENA_INCLUDE(Scrollbar.h)
+#include ATHENA_Scrollbar_h_
 #endif
 #ifdef LWLIB_DIALOGS_ATHENA
-#include ATHENA_INCLUDE(Dialog.h)
-#include ATHENA_INCLUDE(Form.h)
-#include ATHENA_INCLUDE(Command.h)
-#include ATHENA_INCLUDE(Label.h)
+#include ATHENA_Dialog_h_
+#include ATHENA_Form_h_
+#include ATHENA_Command_h_
+#include ATHENA_Label_h_
 #endif
 #ifdef LWLIB_WIDGETS_ATHENA
-#include ATHENA_INCLUDE(Toggle.h)
+#include ATHENA_Toggle_h_
 #include "xlwradio.h"
 #include "xlwcheckbox.h"
 #include "xlwgauge.h"
 #ifndef NEED_MOTIF
-#include ATHENA_INCLUDE(AsciiText.h)
+#include ATHENA_AsciiText_h_
 #endif
 #endif
 #include <X11/Xatom.h>
@@ -230,7 +230,7 @@
       Arg al [2];
       String buf = 0;
       XtSetArg (al [0], XtNstring, &buf);
-      XtGetValues (widget, al, 2);
+      XtGetValues (widget, al, 1);
 
       if (val->value)
 	{
@@ -791,6 +791,8 @@
   /* Do it again for arguments that have no effect until the widget is realized. */
   ac = 0;
   lw_add_value_args_to_args (val, al, &ac);
+  if (ac > 20)
+    abort (); /* #### need assert macro in lwlib */
   XtSetValues (label, al, ac);
 
   return label;
--- a/lwlib/lwlib.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/lwlib.c	Mon Aug 13 11:19:21 2007 +0200
@@ -508,7 +508,7 @@
   return (s1 && s2) ? strcmp (s1, s2) : s1 ? False : !!s2;
 }
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 static change_type
 max (change_type i1, change_type i2)
 {
--- a/lwlib/xlwcheckbox.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwcheckbox.c	Mon Aug 13 11:19:21 2007 +0200
@@ -38,7 +38,7 @@
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
-#include ATHENA_INCLUDE(XawInit.h)
+#include ATHENA_XawInit_h_
 #include "../src/xmu.h"
 #include "xlwcheckboxP.h"
 
--- a/lwlib/xlwgauge.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwgauge.c	Mon Aug 13 11:19:21 2007 +0200
@@ -52,7 +52,7 @@
 #include <X11/IntrinsicP.h>
 #include <X11/Xatom.h>
 #include <X11/StringDefs.h>
-#include ATHENA_INCLUDE(XawInit.h)
+#include ATHENA_XawInit_h_
 #include "xlwgaugeP.h"
 #include "../src/xmu.h"
 #ifdef HAVE_XMU
--- a/lwlib/xlwgauge.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwgauge.h	Mon Aug 13 11:19:21 2007 +0200
@@ -42,7 +42,7 @@
  *
  ***********************************************************************/
 
-#include ATHENA_INCLUDE(Label.h)
+#include ATHENA_Label_h_
 
 /* Resources:
 
--- a/lwlib/xlwgaugeP.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwgaugeP.h	Mon Aug 13 11:19:21 2007 +0200
@@ -40,7 +40,7 @@
  ***********************************************************************/
 
 #include "xlwgauge.h"
-#include ATHENA_INCLUDE(LabelP.h)
+#include ATHENA_LabelP_h_
 
 /* New fields for the Gauge widget class record */
 
--- a/lwlib/xlwmenu.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwmenu.c	Mon Aug 13 11:19:21 2007 +0200
@@ -516,23 +516,21 @@
     0, XtRImmediate, 0 }
 };
 
-/*
- *    This function looks through string searching for parameter
- *    inserts of the form:
- *    %[padding]1
- *    padding is space (' ') or dash ('-') characters meaning
- *    padding to the left or right of the inserted parameter.
- *    In essence all %1 strings are replaced by value in the return
- *    value (which the caller is expected to free).
- *    %% means insert one % (like printf).
- *    %1 means insert value.
- *    %-1 means insert value followed by one space. The latter is
- *    not inserted if value is a zero length string.
- */
+/* This function searches STRING for parameter inserts of the form:
+       %[padding]1
+   padding is either space (' ') or dash ('-') meaning
+   padding to the left or right of the inserted parameter.
+   In essence, all %1 strings are replaced by VALUE in the return value.
+   The caller is expected to free the return value using XtFree().
+   %% means insert one % (like printf).
+   %1 means insert VALUE.
+   %-1 means insert VALUE followed by one space. The latter is
+   not inserted if VALUE is a zero length string.
+*/
 static char*
 parameterize_string (const char *string, const char *value)
 {
-  char *percent;
+  const char *percent;
   char *result;
   unsigned int done = 0;
   unsigned int ntimes;
@@ -541,24 +539,25 @@
     {
       result = XtMalloc(1);
       result[0] = '\0';
-      return (result);
+      return result;
     }
 
   if (!value)
     value = "";
 
-  for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%'));
+  for (ntimes = 1, percent = string;
+       (percent = strchr (percent, '%'));
        ntimes++)
-    result = &percent[1];
+    percent++;
 
   result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4);
   result[0] = '\0';
 
-  while ((percent = strchr(string, '%')))
+  while ((percent = strchr (string, '%')))
     {
       unsigned int left_pad;
       unsigned int right_pad;
-      char *p;
+      const char *p;
 
       if (percent[1] == '%')
 	{	/* it's a real % */
--- a/lwlib/xlwradio.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwradio.c	Mon Aug 13 11:19:21 2007 +0200
@@ -53,7 +53,7 @@
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
-#include ATHENA_INCLUDE(XawInit.h)
+#include ATHENA_XawInit_h_
 #include "../src/xmu.h"
 #include "xlwradioP.h"
 
--- a/lwlib/xlwradio.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwradio.h	Mon Aug 13 11:19:21 2007 +0200
@@ -42,7 +42,7 @@
  *
  ***********************************************************************/
 
-#include ATHENA_INCLUDE(Toggle.h)
+#include ATHENA_Toggle_h_
 
 /* Resources:
 
--- a/lwlib/xlwradioP.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/lwlib/xlwradioP.h	Mon Aug 13 11:19:21 2007 +0200
@@ -32,7 +32,7 @@
 #define _XawRadioP_h
 
 #include "xlwradio.h"
-#include ATHENA_INCLUDE(ToggleP.h)
+#include ATHENA_ToggleP_h_
 
 /***********************************************************************
  *
--- a/man/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,63 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-10  Martin Buchholz  <martin@xemacs.org>
+
+	* Makefile: rm -f ==> $(RM)
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* lispref/postgresql.texi: 
+	- Don't mention ".so" extension.
+	- Make installation instructions more generic.
+	- Mention M-x describe-installation.
+
+2000-07-08  Ben Wing  <ben@xemacs.org>
+
+	* xemacs-faq.texi (Q6.4.1): Update the perennial nonstart under
+	Windows problem with binary locs and latest info.
+
+2000-06-17  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* lispref/glyphs.texi: Fix trivial typos.
+	* lispref/gutter.texi: Ditto.
+	* lispref/loading.texi: Ditto.
+	* lispref/postgresql.texi: Ditto.
+
+2000-06-14  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* internals/internals.texi (Markers and Extents): Fix trivial typo.
+
+2000-06-11  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* make-stds.texi: Fix trivial typos.
+	* xemacs-faq.texi: Ditto.
+	* internals/internals.texi: Ditto.
+	* new-users-guide/edit.texi: Ditto.
+	* new-users-guide/modes.texi: Ditto.
+	* new-users-guide/region.texi: Ditto.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* xemacs-faq.texi (Q6.1.2):
+	* xemacs-faq.texi (Q6.1.5):
+	* xemacs-faq.texi (Q6.1.6):
+	Corrections for Cygwin, MinGW.
+
+2000-06-07  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* xemacs/basic.texi: Fix trivial typos.
+	* xemacs/buffers.texi: Fix trivial typos.
+	* xemacs/building.texi: Ditto.
+	* xemacs/glossary.texi: Ditto.
+	* xemacs/gnu.texi: Ditto.
+	* xemacs/help.texi: Ditto.
+	* xemacs/keystrokes.texi: Ditto.
+	* xemacs/programs.texi: Ditto.
+	* xemacs/search.texi: Ditto.
+	* xemacs/sending.texi: Ditto.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/man/Makefile	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/Makefile	Mon Aug 13 11:19:21 2007 +0200
@@ -22,6 +22,7 @@
 SHELL    = /bin/sh
 MAKEINFO = makeinfo
 TEXI2DVI = texi2dvi
+RM = rm -f
 
 .SUFFIXES:
 .SUFFIXES: .info .texi .dvi
@@ -290,11 +291,11 @@
 
 .PHONY: mostlyclean clean distclean realclean extraclean
 mostlyclean:
-	rm -f *.toc *.aux *.log *.op *.cp *.cps *.fn *.fns
-	rm -f *.ky *.kys *.pg *.pgs *.tp *.tps *.vr *.vrs
+	$(RM) *.toc *.aux *.log *.op *.cp *.cps *.fn *.fns
+	$(RM) *.ky *.kys *.pg *.pgs *.tp *.tps *.vr *.vrs
 clean: mostlyclean
-	rm -f core *.dvi
+	$(RM) core *.dvi
 distclean: clean
 realclean: distclean
 extraclean: distclean
-	rm -f *~ \#* */*~ */\#*
+	$(RM) *~ \#* */*~ */\#*
--- a/man/internals/internals.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/internals/internals.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -7123,7 +7123,7 @@
 buffer positions in them as integers, and every time text is inserted or
 deleted, these positions must be updated.  In order to minimize the
 amount of shuffling that needs to be done, the positions in markers and
-extents (there's one per marker, two per extent) and stored in Meminds.
+extents (there's one per marker, two per extent) are stored in Meminds.
 This means that they only need to be moved when the text is physically
 moved in memory; since the gap structure tries to minimize this, it also
 minimizes the number of marker and extent indices that need to be
@@ -7611,7 +7611,7 @@
 other encoded/decoded data has been written out.  This is not used for
 charset CCL programs.
 
-REGISTER: 0..7  -- refered by RRR or rrr
+REGISTER: 0..7  -- referred by RRR or rrr
 
 OPERATOR BIT FIELD (27-bit): XXXXXXXXXXXXXXX RRR TTTTT
         TTTTT (5-bit): operator type
--- a/man/lispref/glyphs.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/lispref/glyphs.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -187,7 +187,7 @@
 modeline, etc.  Do an apropos over @code{*-pointer-glyph} to find all of
 them. (Note also that you can temporarily set the mouse pointer to some
 specific shape by using @code{set-frame-pointer}, which takes an image
-instace, as obtained from calling @code{glyph-image-instance} on a glyph
+instance, as obtained from calling @code{glyph-image-instance} on a glyph
 of type @code{pointer} -- either one of the above-mentioned variables or
 one you created yourself.  (See below for what it means to create a
 glyph of type @code{pointer}.)  This pointer will last only until the
--- a/man/lispref/gutter.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/lispref/gutter.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -96,7 +96,7 @@
 
 Valid gutter-size instantiators are either integers or the special
 symbol @code{autodetect}. If a gutter-size is set to @code{autodetect}
-them the size of the gutter will be adjusted to just accomodate the
+them the size of the gutter will be adjusted to just accommodate the
 gutters contents. @code{autodetect} only works for top and bottom
 gutters.
 @end defun
@@ -117,7 +117,7 @@
 
 Valid gutter-visible instantiators are t, nil or a list of symbols.  If
 a gutter-visible instantiator is set to a list of symbols, and the
-correspondong gutter specification is a property-list strings, then
+corresponding gutter specification is a property-list strings, then
 elements of the gutter specification will only be visible if the
 corresponding symbol occurs in the gutter-visible instantiator.
 @end defun
--- a/man/lispref/loading.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/lispref/loading.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -199,7 +199,7 @@
 function to search through @code{load-path}.) It searches for
 @var{filename} through @var{path-list}, expanded by one of the optional
 @var{suffixes} (string of suffixes separated by @samp{:}s), checking for
-access @var{mode} (0|1|2|4 = exists|executable|writeable|readable),
+access @var{mode} (0|1|2|4 = exists|executable|writable|readable),
 default readable.
 
 @code{locate-file} keeps hash tables of the directories it searches
--- a/man/lispref/mule.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/lispref/mule.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -791,7 +791,7 @@
 where @var{I} is an intermediate character or characters in the range
 0x20 - 0x3F, and @var{F}, from the range 0x30-0x7Fm is the final
 character identifying this charset.  (Final characters in the range
-0x30-0x3F are reserved for private use and will never have a publically
+0x30-0x3F are reserved for private use and will never have a publicly
 registered meaning.)
 
   Then that register is @dfn{invoked} to either GL or GR, either
--- a/man/lispref/postgresql.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/lispref/postgresql.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -23,19 +23,22 @@
 @comment  node-name,  next,  previous,  up
 @section Building XEmacs with PostgreSQL support
 
-XEmacs PostgreSQL support requires linking to the PostgreSQL libpq.so
+XEmacs PostgreSQL support requires linking to the PostgreSQL libpq
 library.  Describing how to build and install PostgreSQL is beyond the
-scope of this document, see the PostgreSQL manual for details.
+scope of this document.  See the PostgreSQL manual for details.
 
 If you have installed XEmacs from one of the binary kits on
 (@url{ftp://ftp.xemacs.org/}), or are using an XEmacs binary from a CD
-ROM, you should have XEmacs PostgreSQL support by default.  If you are
-building XEmacs from source on a Linux system with PostgreSQL installed
-into the default location, it should be autodetected when you run
-configure.  If you have installed PostgreSQL into its non-Linux default
-location, @file{/usr/local/pgsql}, you must specify
+ROM, you may have XEmacs PostgreSQL support by default.  @code{M-x
+describe-installation} will tell you if you do.
+
+If you are building XEmacs from source, you need to install PostgreSQL
+first.  On some systems, PostgreSQL will come pre-installed in /usr.  In
+this case, it should be autodetected when you run configure.  If
+PostgreSQL is installed into its default location,
+@file{/usr/local/pgsql}, you must specify
 @code{--site-prefixes=/usr/local/pgsql} when you run configure.  If
-you installed PostgreSQL into another location, use that instead of
+PostgreSQL is installed into another location, use that instead of
 @file{/usr/local/pgsql} when specifying @code{--site-prefixes}.
 
 As of XEmacs 21.2, PostgreSQL versions 6.5.3 and 7.0 are supported.
@@ -46,9 +49,9 @@
 @comment  node-name,  next,  previous,  up
 @section XEmacs PostgreSQL libpq API
 
-XEmacs PostgreSQL API is intended to be a policy-free, low-level binding
-to libpq.  The intent is to provide all the basic functionality and then
-let high level Lisp code decide its own policies.
+The XEmacs PostgreSQL API is intended to be a policy-free, low-level
+binding to libpq.  The intent is to provide all the basic functionality
+and then let high level Lisp code decide its own policies.
 
 This documentation assumes that the reader has knowledge of SQL, but
 requires no prior knowledge of libpq.
@@ -806,7 +809,7 @@
 @end defun
 
 @defun PQsetenvPoll conn
-Check an asynchronous enviroment variables transfer for completion.
+Check an asynchronous environment variables transfer for completion.
 @var{conn} A database connection object.
 
 Compatibility note: this function is only available with libpq-7.0.
--- a/man/make-stds.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/make-stds.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -507,7 +507,7 @@
 @item srcdir
 The directory for the sources being compiled.  The value of this
 variable is normally inserted by the @code{configure} shell script.
-(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.)
+(If you are using Autoconf, use @samp{srcdir = @@srcdir@@}.)
 @end table
 
 For example:
--- a/man/new-users-guide/edit.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/new-users-guide/edit.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -137,7 +137,7 @@
 Move the cursor forward one word (@code{forward-word}).
 @item M-b
 @findex backward-word
-Move the cursor backword one word (@code{backward-word}).
+Move the cursor backward one word (@code{backward-word}).
 @item M-<
 Move the cursor to the top of the buffer (@code{beginning-of-buffer}).
 @item M->
--- a/man/new-users-guide/modes.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/new-users-guide/modes.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -228,7 +228,7 @@
 @item line-number-mode
 @cindex line-number-mode
 After you enable this mode, the line number at which your cursor is
-present will be displayed continously in the mode line. 
+present will be displayed continuously in the mode line. 
 
 @item blink-paren
 @cindex blink-paren
--- a/man/new-users-guide/region.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/new-users-guide/region.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -217,7 +217,7 @@
 contents. This command will also prompt you for a buffer name.
 @item M-x insert-buffer
 Insert contents of specified buffer into current buffer at point. This
-command will prompt you for a buffername which you want to be copied
+command will prompt you for a buffer name which you want to be copied
 into the current buffer at the location of the cursor.
 @item M-x append-to-file
 This command will prompt you for a filename and append the region to
--- a/man/xemacs-faq.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs-faq.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -7,7 +7,7 @@
 @finalout
 @titlepage
 @title XEmacs FAQ
-@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2000/04/26 07:18:27 $
+@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2000/07/08 09:14:11 $
 @sp 1
 @author Tony Rossini <rossini@@biostat.washington.edu>
 @author Ben Wing <ben@@xemacs.org>
@@ -1011,7 +1011,7 @@
 @example
 Emacs*XlwMenu.resourceLabels:                   True
 Emacs*XlwMenu.file.labelString:                 Fichier
-Emacs*XlwMenu.openInOtherWindow.labelString:    In anderem Fenster offnen
+Emacs*XlwMenu.openInOtherWindow.labelString: 	In anderem Fenster oeffnen
 @end example
 
 The name of the resource is derived from the non-localized entry by
@@ -6210,8 +6210,10 @@
 @node Q6.1.2, Q6.1.3, Q6.1.1, MS Windows
 @unnumberedsubsec Q6.1.2: What compiler do I need to compile XEmacs?
 
-You need Visual C++ 4.2 or 5.0, with the exception of the Cygwin port,
-which uses Gcc.
+You need Visual C++ 4.2, 5.0, or 6.0, with the exception of the Cygwin
+port, which uses Gcc.  There is also a MINGW32 port of XEmacs (using
+Gcc, but using native libraries rather than the Cygwin libraries).  ####
+More information about this should be provided.
 
 
 @node Q6.1.3, Q6.1.4, Q6.1.2, MS Windows
@@ -6241,8 +6243,8 @@
 from;
 
 @item
-CYGWIN32 needs to be set to tty for process support
-work. e.g. CYGWIN32=tty;
+CYGWIN needs to be set to tty for process support work. e.g. CYGWIN=tty;
+(use CYGWIN32=tty under b19 and older.)
 
 @item
 picking up some other grep or other unix like tools can kill configure;
@@ -6266,16 +6268,56 @@
 @uref{http://sourceware.cygnus.com/cygwin/}
 
 You will need version b19 or later.
-
-You will also need the X libraries.  There are libraries at
+The latest current version is 1.1.1.
+Other common versions you will see are b20.1.
+
+Another location, one of the mirror sites of the site just mentioned,
+is usually a last faster:
+
+@uref{ftp://ftp.freesoftware.com/pub/sourceware/cygwin/}
+
+You can obtain the latest version (currently 1.1.1) from the
+@samp{latest/} subdirectory of either of the above two just-mentioned
+URL's.
+
+@strong{WARNING: The version of GCC supplied under @samp{latest/}, as of
+June 6th, 2000, does not appear to work.  It generates loads of spurious
+preprocessor warnings and errors, which makes it impossible to compile
+XEmacs with it.}
+
+You will also need the X libraries.  You can get them on the XEmacs FTP
+site at
+
+@uref{ftp://ftp.xemacs.org/pub/xemacs/aux/cygwin/}
+
+You will find b19 and b20 versions of the X libraries, plus b19 and b20
+versions of stuff that should go into @samp{/usr/local/}, donated by
+Andy Piper.  This includes pre-built versions of various graphics libraries,
+such as PNG, JPEG, TIFF, and XPM. (Remember, GIF support is built-in to
+XEmacs.)
+
+(X libraries for v1 and beyond of Cygwin can be found on the Cygwin site
+itself -- look in the @samp{xfree/} subdirectory.)
+
+@emph{NOTE:} There are two versions of the XPM library provided in
+Andy's packets.  Once is for building with X support, and the other for
+building without.  The X version should work if you're building with
+both X and Windows support.  The two files are called @file{libXpm-X.a}
+and @file{libXpm-noX.a} respectively, and you must symlink the
+appropriate one to @file{libXpm.a}. @strong{CAREFUL:} By default, the
+non-X version is symlinked in.  If you then configure XEmacs with X,
+you won't run into problems until you start compiling @file{events.c},
+at which point you'll get strange and decidedly non-obvious errors.
+
+Please see @uref{http://www.xemacs.freeserve.co.uk/} (Andy Piper's home
+page) for more information.
+
+BTW There are also libraries at
 @iftex
 @*
 @end iftex
 @uref{http://dao.gsfc.nasa.gov/software/grads/win32/X11R6.3/}, but
-these are not b19 compatible.  You can get b19 X11R6.3 binaries, as
-well as pre-built ncurses and graphic libraries, from:
-
-@uref{ftp://ftp.parallax.co.uk/pub/andyp/}.
+these are not b19 compatible, and may in fact be native-compiled.
 
 
 @node Q6.2.1, Q6.2.2, Q6.1.6, MS Windows
@@ -6456,12 +6498,19 @@
 executable. In this instance XEmacs will fail to start without any
 explanation. Note that this is extremely machine specific.
 
-Work is being done on fixes for 21.1.* that will make more intelligent
-guesses about which memory addresses will be free and so this should
-cure the problem for most people.
+21.1.10 includes a fix for this that makes more intelligent guesses
+about which memory addresses will be free, and this should cure the
+problem for most people.  Unfortunately, no binary is yet available for
+this version.  Check back periodically at
+
+@uref{ftp://ftp.xemacs.org/pub/xemacs/binaries/}.
 
 21.2 implements "portable dumping" which will eliminate the problem
-altogether.
+altogether.  You might have better luck with the 21.2 beta binary,
+available at
+
+@uref{ftp://ftp.xemacs.org/pub/xemacs/beta/binaries/}.
+
 
 @node Current Events,  , MS Windows, Top
 @unnumbered 7 What the Future Holds
--- a/man/xemacs/abbrevs.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/abbrevs.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -257,9 +257,10 @@
 minibuffer and reads the specified file, defining abbrevs according to
 its contents.  @kbd{M-x quietly-read-abbrev-file} is the same but does
 not display a message in the echo area; it is actually useful primarily
-in the @file{.emacs} file.  If you give an empty argument to either of
-these functions, the file name Emacs uses is the value of the variable
-@code{abbrev-file-name}, which is by default @code{"~/.abbrev_defs"}.
+in the init file.  @xref{Init File}. If you give an empty argument to
+either of these functions, the file name Emacs uses is the value of the
+variable @code{abbrev-file-name}, which is by default
+@code{"~/.abbrev_defs"}.
 
 @vindex save-abbrevs
   Emacs offers to save abbrevs automatically if you have changed any of
--- a/man/xemacs/basic.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/basic.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -14,7 +14,7 @@
 the @b{Help} menu.
 
 XEmacs comes with many translations of tutorial.  If your XEmacs is with
-MULE and you set up language environment correctly, XEmacs choses right
+MULE and you set up language environment correctly, XEmacs chooses right
 tutorial when available (@pxref{Language Environments}).  If you want
 specific translation, give @kbd{C-h t} a prefix argument, like @kbd{C-u
 C-h t}.
--- a/man/xemacs/buffers.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/buffers.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -248,7 +248,7 @@
 @item C-d
 Like @kbd{d} but move up afterwards instead of down.
 @item s
-Request to save the buffer.  An @samp{S} befor the buffer name on a line
+Request to save the buffer.  An @samp{S} before the buffer name on a line
 indicates the request.  Requested saves actually take place when you use
 the @kbd{x} command.  You can request both saving and deletion for the
 same buffer.
--- a/man/xemacs/building.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/building.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -480,7 +480,7 @@
 you can switch buffers, visit files, and perform any other editing
 operations.  However, the debugger is a recursive editing level
 (@pxref{Recursive Edit}); it is a good idea to return to the backtrace
-buffer and explictly exit the debugger when you don't want to use it any
+buffer and explicitly exit the debugger when you don't want to use it any
 more.  Exiting the debugger kills the backtrace buffer.
 
 @cindex current stack frame
--- a/man/xemacs/calendar.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/calendar.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -571,10 +571,10 @@
 for how daylight savings time is determined.
 
   As a user, you might find it convenient to set the calendar location
-variables for your usual physical location in your @file{.emacs} file.
-And when you install Emacs on a machine, you can create a
-@file{default.el} file which sets them properly for the typical location
-of most users of that machine.  @xref{Init File}.
+variables for your usual physical location in your init file.  And when
+you install Emacs on a machine, you can create a @file{default.el} file
+which sets them properly for the typical location of most users of that
+machine.  @xref{Init File}.
 
 @node Lunar Phases, Other Calendars, Sunrise/Sunset, Calendar/Diary
 @subsection Phases of the Moon
@@ -1051,10 +1051,10 @@
 few days as well; the variable @code{number-of-diary-entries} specifies
 how many days to include (@pxref{Customization}).
 
-  If you put @code{(diary)} in your @file{.emacs} file, this
+  If you put @code{(diary)} in your init file, this
 automatically displays a window with the day's diary entries, when you
-enter Emacs.  The mode line of the displayed window shows the date and
-any holidays that fall on that date.
+enter Emacs.  @xref{Init File}.  The mode line of the displayed window
+shows the date and any holidays that fall on that date.
 
 @findex diary-mail-entries
 @vindex diary-mail-days
@@ -1403,7 +1403,7 @@
 @code{t}, calling up the calendar automatically displays the diary
 entries for the current date as well.  The diary dates appear only if
 the current date is visible.  If you add both of the following lines to
-your @file{.emacs} file:@refill
+your init file:@refill
 
 @example
 (setq view-diary-entries-initially t)
@@ -1411,7 +1411,8 @@
 @end example
 
 @noindent
-this displays both the calendar and diary windows whenever you start Emacs.
+this displays both the calendar and diary windows whenever you start
+Emacs.  @xref{Init File}.
 
 @vindex view-calendar-holidays-initially
   Similarly, if you set the variable
@@ -1585,12 +1586,14 @@
 
   For example, suppose you want to add Bastille Day, celebrated in
 France on July 14.  You can do this by adding the following line
-to your @file{.emacs} file:
+to your init file:
 
 @smallexample
 (setq other-holidays '((holiday-fixed 7 14 "Bastille Day")))
 @end smallexample
 
+@xref{Init File}.
+
 @noindent
 The holiday form @code{(holiday-fixed 7 14 "Bastille Day")} specifies the
 fourteenth day of the seventh month (July).
@@ -2061,13 +2064,15 @@
 @cindex sorting diary entries
   If you use the fancy diary display, you can use the normal hook
 @code{list-diary-entries-hook} to sort each day's diary entries by their
-time of day.  Add this line to your @file{.emacs} file:
+time of day.  Add this line to your init file:
 
 @findex sort-diary-entries
 @example
 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
 @end example
 
+@xref{Init File}.
+
 @noindent
 For each day, this sorts diary entries that begin with a recognizable
 time of day according to their times.  Diary entries without times come
--- a/man/xemacs/cmdargs.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/cmdargs.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -139,7 +139,7 @@
 
 @item -no-init-file
 @itemx -q
-Do not load your Emacs init file @file{~/.emacs}.
+Do not load your Emacs init file.  @xref{Init File}.
 
 @item -no-site-file
 Do not load the site-specific init file @file{lisp/site-start.el}.
@@ -156,7 +156,8 @@
 This is equivalent to @samp{-q -no-site-file -no-early-packages}.
 
 @item -user-init-file @var{file}
-Load @var{file} as your Emacs init file instead of @file{~/.emacs}.
+Load @var{file} as your Emacs init file instead of
+@file{~/.xemacs/init.el}/@file{~/.emacs}.
 
 @item -user-init-directory @var{directory}
 Use @var{directory} as the location of your early package hierarchies
@@ -164,9 +165,10 @@
 
 @item -user @var{user}
 @itemx -u @var{user}
-Equivalent to
-@samp{-user-init-file ~@var{user}/.emacs -user-init-directory ~@var{user}/.xemacs}.
-
+Equivalent to @samp{-user-init-file ~@var{user}/.xemacs/init.el
+-user-init-directory ~@var{user}/.xemacs}, or @samp{-user-init-file
+~@var{user}/.emacs -user-init-directory ~@var{user}/.xemacs}.  whichever
+init file comes first.  @xref{Init File}.
 
 @end table
 
--- a/man/xemacs/custom.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/custom.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -7,12 +7,12 @@
 behavior of Emacs in minor ways.
 
   All kinds of customization affect only the particular Emacs job that you
-do them in.  They are completely lost when you kill the Emacs job, and have
-no effect on other Emacs jobs you may run at the same time or later.  The
-only way an Emacs job can affect anything outside of it is by writing a
-file; in particular, the only way to make a customization `permanent' is to
-put something in your @file{.emacs} file or other appropriate file to do the
-customization in each session.  @xref{Init File}.
+do them in.  They are completely lost when you kill the Emacs job, and
+have no effect on other Emacs jobs you may run at the same time or
+later.  The only way an Emacs job can affect anything outside of it is
+by writing a file; in particular, the only way to make a customization
+`permanent' is to put something in your init file or other appropriate
+file to do the customization in each session.  @xref{Init File}.
 
 @menu
 * Minor Modes::     Each minor mode is one feature you can turn on
@@ -26,8 +26,7 @@
                      By changing them, you can "redefine keys".
 * Syntax::          The syntax table controls how words and expressions
                      are parsed.
-* Init File::       How to write common customizations in the @file{.emacs} 
-                     file.
+* Init File::       How to write common customizations in the init file.
 * Audible Bell::    Changing how Emacs sounds the bell.
 * Faces::           Changing the fonts and colors of a region of text.
 * Frame Components::  Controlling the presence and positions of the
@@ -387,10 +386,10 @@
 @cindex saving option value
   Setting the option changes its value in the current Emacs session;
 @dfn{saving} the value changes it for future sessions as well.  This
-works by writing code into your @file{~/.emacs} file so as to set the
-option variable again each time you start Emacs.  To save the option,
-invoke @samp{[State]} and select the @samp{Save for Future Sessions}
-operation.
+works by writing code into your init file so as to set the option
+variable again each time you start Emacs.  @xref{Init File}.  To save
+the option, invoke @samp{[State]} and select the @samp{Save for Future
+Sessions} operation.
 
   You can also restore the option to its standard value by invoking
 @samp{[State]} and selecting the @samp{Reset} operation.  There are
@@ -750,7 +749,7 @@
 list.  That is inappropriate.  Whether you use Auto Fill mode or not is
 a matter of personal taste, not a matter of the contents of particular
 files.  If you want to use Auto Fill, set up major mode hooks with your
-@file{.emacs} file to turn it on (when appropriate) for you alone
+file file to turn it on (when appropriate) for you alone
 (@pxref{Init File}).  Don't try to use a local variable list that would
 impose your taste on everyone working with the file.
 
@@ -912,7 +911,7 @@
 code to do this, because @code{insert-kbd-macro} writes the Lisp code for you.
 Then save the file.  You can load the file with @code{load-file}
 (@pxref{Lisp Libraries}).  If the file you save in is your initialization file
-@file{~/.emacs} (@pxref{Init File}), then the macro will be defined each
+(@pxref{Init File}), then the macro will be defined each
 time you run Emacs.
 
   If you give @code{insert-kbd-macro} a prefix argument, it creates
@@ -1155,7 +1154,7 @@
 @findex define-key
 @findex substitute-key-definition
   The most general way to modify a keymap is the function
-@code{define-key}, used in Lisp code (such as your @file{.emacs} file).
+@code{define-key}, used in Lisp code (such as your init file).
 @code{define-key} takes three arguments: the keymap, the key to modify
 in it, and the new definition.  @xref{Init File}, for an example.
 @code{substitute-key-definition} is used similarly; it takes three
@@ -1327,13 +1326,15 @@
 
   The direct mechanism for disabling a command is to have a non-@code{nil}
 @code{disabled} property on the Lisp symbol for the command.  These
-properties are normally set by the user's @file{.emacs} file with
+properties are normally set by the user's init file with
 Lisp expressions such as:
 
 @example
 (put 'delete-region 'disabled t)
 @end example
 
+@xref{Init File}.
+
   If the value of the @code{disabled} property is a string, that string
 is included in the message printed when the command is used:
 
@@ -1344,9 +1345,9 @@
 
 @findex disable-command
 @findex enable-command
-  You can disable a command either by editing the @file{.emacs} file
+  You can disable a command either by editing the init file
 directly or with the command @kbd{M-x disable-command}, which edits the
-@file{.emacs} file for you.  @xref{Init File}.
+init file for you.  @xref{Init File}.
 
   When you attempt to invoke a disabled command interactively in Emacs,
 a window is displayed containing the command's name, its
@@ -1355,7 +1356,7 @@
 enable it and execute, or cancel it.  If you decide to enable the
 command, you are asked whether to do this permanently or just for the
 current session.  Enabling permanently works by automatically editing
-your @file{.emacs} file.  You can use @kbd{M-x enable-command} at any
+your init file.  You can use @kbd{M-x enable-command} at any
 time to enable any command permanently.
 
   Whether a command is disabled is independent of what key is used to
@@ -1532,22 +1533,23 @@
 and some English to explain that string if necessary.
 
 @node Init File
-@section The Init File, .emacs
+@section The Init File
 @cindex init file
 @cindex Emacs initialization file
 @cindex key rebinding, permanent
 @cindex rebinding keys, permanently
 
-  When you start Emacs, it normally loads the file @file{.emacs} in your
-home directory.  This file, if it exists, should contain Lisp code.  It
-is called your initialization file or @dfn{init file}.  Use the command
-line switch @samp{-q} to tell Emacs whether to load an
-init file (@pxref{Entering Emacs}).  Use the command line switch
-@samp{-user-init-file} (@pxref{Command Switches}) to tell Emacs to load
-a different file instead of @file{~/.emacs}.
-
-When the @file{.emacs} file is read, the variable @code{user-init-file}
-says which init file was loaded.
+  When you start Emacs, it normally loads either @file{.xemacs/init.el}
+or the file @file{.emacs} (whichever comes first) in your home directory.
+This file, if it exists, should contain Lisp code.  It is called your
+initialization file or @dfn{init file}.  Use the command line switch
+@samp{-q} to tell Emacs whether to load an init file (@pxref{Entering
+Emacs}).  Use the command line switch @samp{-user-init-file}
+(@pxref{Command Switches}) to tell Emacs to load a different file
+instead of @file{~/.xemacs/init.el}/@file{~/.emacs}.
+
+When the init file is read, the variable @code{user-init-file} says
+which init file was loaded.
 
   At some sites there is a @dfn{default init file}, which is the
 library named @file{default.el}, found via the standard search path for
@@ -1557,10 +1559,8 @@
 first; if it sets @code{inhibit-default-init} non-@code{nil}, then
 @file{default} is not loaded.
 
-  If you have a large amount of code in your @file{.emacs} file, you
-should move it into another file named @file{@var{something}.el},
-byte-compile it (@pxref{Lisp Libraries}), and load that file from your
-@file{.emacs} file using @code{load}.
+  If you have a large amount of code in your init file, you should
+byte-compile it to @file{~/.xemacs/init.elc} or @file{~/.emacs.elc}.
 
 @menu
 * Init Syntax::     Syntax of constants in Emacs Lisp.
@@ -1571,7 +1571,7 @@
 @node Init Syntax
 @subsection Init File Syntax
 
-  The @file{.emacs} file contains one or more Lisp function call
+  The init file contains one or more Lisp function call
 expressions.  Each consists of a function name followed by
 arguments, all surrounded by parentheses.  For example, @code{(setq
 fill-column 60)} represents a call to the function @code{setq} which is
@@ -1579,7 +1579,7 @@
 
   The second argument to @code{setq} is an expression for the new value
 of the variable.  This can be a constant, a variable, or a function call
-expression.  In @file{.emacs}, constants are used most of the time.
+expression.  In the init file, constants are used most of the time.
 They can be:
 
 @table @asis
@@ -1813,16 +1813,16 @@
 
 @vindex term-file-prefix
   The library's name is constructed by concatenating the value of the
-variable @code{term-file-prefix} and the terminal type.  Your @file{.emacs}
+variable @code{term-file-prefix} and the terminal type.  Your init
 file can prevent the loading of the terminal-specific library by setting
-@code{term-file-prefix} to @code{nil}.
+@code{term-file-prefix} to @code{nil}.  @xref{Init File}.
 
 @vindex term-setup-hook
   The value of the variable @code{term-setup-hook}, if not @code{nil}, is
 called as a function of no arguments at the end of Emacs initialization,
-after both your @file{.emacs} file and any terminal-specific library have
-been read.  You can set the value in the @file{.emacs} file to override
-part of any of the terminal-specific libraries and to define
+after both your init file and any terminal-specific library have been
+read.  @xref{Init File}.  You can set the value in the init file to
+override part of any of the terminal-specific libraries and to define
 initializations for terminals that do not have a library.@refill
 
 @node Audible Bell
--- a/man/xemacs/glossary.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/glossary.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -568,7 +568,7 @@
 @item Read-only Buffer
 A read-only buffer is one whose text you are not allowed to change.
 Normally Emacs makes buffers read-only when they contain text which
-has a special significance to Emacs, such asDired buffers.
+has a special significance to Emacs, such as Dired buffers.
 Visiting a file that is write-protected also makes a read-only buffer.
 @xref{Buffers}.
 
--- a/man/xemacs/gnu.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/gnu.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -191,7 +191,7 @@
 With Unix, the price of sources puts this out of consideration for most
 businesses.  With GNU this will be easy.  It is still possible for there to
 be no available competent person, but this problem cannot be blamed on
-distibution arrangements.  GNU does not eliminate all the world's problems,
+distribution arrangements.  GNU does not eliminate all the world's problems,
 only some of them.
 
 Meanwhile, the users who know nothing about computers need handholding:
--- a/man/xemacs/help.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/help.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -57,7 +57,7 @@
 @table @kbd
 @item C-h a @var{regexp} @key{RET}
 Display a list of functions and variables whose names match @var{regexp}
-(@code{heper-apropos}).
+(@code{hyper-apropos}).
 @item C-h A @var{regexp}
 Show all commands whose names contain matches for @var{regexp}
 (@code{command-apropos}).
@@ -224,7 +224,7 @@
 (@code{command-apropos}).
 
 @item M-x apropos @var{regexp}
-Show all symbols whose names comtain matches for @var{regexp}.
+Show all symbols whose names contain matches for @var{regexp}.
 @end table
 
   A more sophisticated sort of question to ask is, ``What are the
--- a/man/xemacs/keystrokes.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/keystrokes.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -143,7 +143,7 @@
 Release the middle mouse button, while pressing @key{CTRL} and
 @key{META}. 
 @end table
-@cindex shift modifer
+@cindex shift modifier
   Note: As you define keystrokes, you can use the @kbd{shift} key only
 as a modifier with characters that do not have a second keysym on the
 same key, such as @kbd{backspace} and @kbd{tab}.  It is an error to
@@ -163,7 +163,7 @@
 schematic representation of a complete key sequence is as follows:
 
 @example
-  [(modifier .. modifer keysym) ... (modifier .. modifier keysym)]
+  [(modifier .. modifier keysym) ... (modifier .. modifier keysym)]
 @end example
 
   Here are some examples of complete key sequences:
--- a/man/xemacs/menus.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/menus.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -345,19 +345,19 @@
 alternate binding before the command executes.
 
 @item Syntax Highlighting
-You can customize your @code{.emacs} file to include the font-lock 
-mode so that when you select this item, the comments will be 
-displayed in one face, strings in another, reserved words in another, 
-and so on. When @b{Fonts} is selected, different parts of the program 
-will appear in different Fonts. When @b{Colors} is selected, then the 
-program will be displayed in different colors. Selecting @b{None} 
-causes the program to appear in just one Font and Color. Selecting 
-@b{Less} resets the Fonts and Colors to a fast, minimal set of 
-decorations. Selecting @b{More} resets the Fonts and Colors to a larger 
-set of decorations. For example, if @b{Less} is selected (which is the 
-default setting) then you might have all comments in green color. 
-Whereas, if @b{More} is selected then a function name in the comments 
-themselves might appear in a different Color or Font.@refill
+You can customize your init file to include the font-lock mode so that
+when you select this item, the comments will be displayed in one face,
+strings in another, reserved words in another, and so on. @xref{Init
+File}.  When @b{Fonts} is selected, different parts of the program will
+appear in different Fonts. When @b{Colors} is selected, then the program
+will be displayed in different colors. Selecting @b{None} causes the
+program to appear in just one Font and Color. Selecting @b{Less} resets
+the Fonts and Colors to a fast, minimal set of decorations. Selecting
+@b{More} resets the Fonts and Colors to a larger set of decorations. For
+example, if @b{Less} is selected (which is the default setting) then you
+might have all comments in green color.  Whereas, if @b{More} is
+selected then a function name in the comments themselves might appear in
+a different Color or Font.@refill
 
 @item Paren Highlighting
 After selecting @b{Blink} from this item, if you place the cursor 
@@ -390,7 +390,7 @@
 
 @item Save Options
 Selecting this item will save the current settings of your Options 
-menu to your @code{.emacs} file.
+menu to your init file.  @xref{Init File}.
 @end table
 
 @node Buffers Menu
--- a/man/xemacs/misc.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/misc.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -192,7 +192,7 @@
 specify a directory, the directories in the list @code{exec-path} are
 searched; this list is initialized based on the @code{PATH} environment
 variable when you start XEmacs.  You can override either or both of these
-default initializations in your @file{.emacs} file.@refill
+default initializations in your init file. @xref{Init File}.@refill
 
   When you use @kbd{M-!} and @kbd{M-|}, XEmacs has to wait until the
 shell command completes.  You can quit with @kbd{C-g}; that terminates
@@ -740,7 +740,7 @@
 (viper-mode)
 @end example
 
-in your @file{.emacs} file.
+in your init file.  @xref{Init File}.
 
 Viper comes with a separate manual that is provided standard
 with the XEmacs distribution.
--- a/man/xemacs/new.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/new.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -13,21 +13,23 @@
 XEmacs has a new vi emulation mode called evi mode.  To
 start evi mode in Emacs, type the command @kbd{M-x evi}.  If you want
 Emacs to automatically put you in evi-mode all the time, include this
-line in your @file{.emacs} file:
+line in your init file:
 @example
 (setq term-setup-hook 'evi)
 @end example
 @xref{evi Mode} for a brief discussion.
+@xref{Init File}.
 @end ignore
 
 @item 
 XEmacs has a new vi emulation mode called ``viper'' mode.  To start
 viper mode in XEmacs, type the command @kbd{M-x viper-mode}.  If you
 want XEmacs to automatically put you in viper-mode all the time, include
-this line in your @file{.emacs} file:
+this line in your init file:
 @example
 (viper-mode)
 @end example
+@xref{Init File}.
 
 @item
 Earlier versions of Emacs only allowed keybindings to ASCII character
@@ -267,7 +269,9 @@
        ))
 @end example
 
-Of particular interest for use in @file{.emacs} files are:
+Alternatively, use @file{.xemacs/init.el} for an init file.  @xref{Init File}.
+
+Of particular interest for use in  files are:
 
 @itemize @bullet
 @findex add-menu
--- a/man/xemacs/packages.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/packages.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -134,13 +134,15 @@
 already have some or all of the packages on a local disk, such as a
 CDROM.  If you want to install from a local disk, you must first tell
 XEmacs where to find the package binaries.  This is done by adding a line
-like the following to your @file{.emacs} file:
+like the following to your init file:
 
 @example
 (setq package-get-remote (cons (list nil "/my/path/to/package/binaries")
                                package-get-remote))
 @end example
 
+@xref{Init File}.
+
 Here, you'd change @file{/my/path/to/package/binaries} to be the path
 to your local package binaries.  Next, restart XEmacs, and you're ready
 to go (advanced users can just re-evaluate the sexp).
--- a/man/xemacs/programs.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/programs.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -45,7 +45,7 @@
                          There are editing commands to operate on them.
 * Grinding::            Adjusting indentation to show the nesting.
 * Matching::            Insertion of a close-delimiter flashes matching open.
-* Comments::            Inserting, illing and aligning comments.
+* Comments::            Inserting, filling and aligning comments.
 * Balanced Editing::    Inserting two matching parentheses at once, etc.
 * Lisp Completion::     Completion on symbol names in Lisp code.
 * Documentation::       Getting documentation of functions you plan to call.
--- a/man/xemacs/search.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/search.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -77,7 +77,7 @@
 within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s}, or @kbd{C-y}).
 
   Sometimes you search for @samp{FOO} and find it, but were actually
-looking for a different occurance of it.  To move to the next occurrence
+looking for a different occurence of it.  To move to the next occurrence
 of the search string, type another @kbd{C-s}.  Do this as often as
 necessary.  If you overshoot, you can cancel some @kbd{C-s}
 characters with @key{DEL}.
--- a/man/xemacs/sending.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/sending.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -235,9 +235,9 @@
 command @code{M-x merge-mail-aliases}.  The @code{rebuild-mail-aliases}
 command is similar, but deletes existing aliases first.
 
-@vindex mail-alias-seperator-string
+@vindex mail-alias-separator-string
 If you want multiple addresses separated by a string other than @samp{,}
-(a comma), then set the variable @code{mail-alias-seperator-string} to
+(a comma), then set the variable @code{mail-alias-separator-string} to
 it.  This has to be a comma bracketed by whitespace if you want any kind
  of reasonable behavior.
 
--- a/man/xemacs/startup.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/startup.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -63,8 +63,9 @@
 very front, late ones somewhere in the middle, and last hierarchies are
 (you guessed it) last.
 
-By default, XEmacs expects an early package hierarchy in the a
-subdirectory @file{.xemacs} of the user's home directory.
+By default, XEmacs expects an early package hierarchy in the
+subdirectory @file{.xemacs/xemacs-packages} of the user's home
+directory.
 
 Moreover, XEmacs expects late hierarchies in the subdirectories
 @file{site-packages}, @file{mule-packages}, and @file{xemacs-packages}
@@ -77,7 +78,7 @@
 By default, XEmacs does not have a pre-configured last package
 hierarchy.  Last hierarchies are primarily for using package hierarchies
 of outdated versions of XEmacs as a fallback option.  For example, it is
-possible to run XEmacs 21.0 with the 20.4 package hierarchy as a last
+possible to run XEmacs 21 with the 20.4 package hierarchy as a last
 hierarchy.
 
 It is possible to specify at configure-time the location of the various
--- a/man/xemacs/trouble.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/trouble.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -332,12 +332,13 @@
 it happen again, you can report at least that.
 
   Check whether any programs you have loaded into the Lisp world, including
-your @file{.emacs} file, set any variables that may affect the functioning
-of Emacs.  Also, see whether the problem happens in a freshly started Emacs
-without loading your @file{.emacs} file (start Emacs with the @code{-q} switch
-to prevent loading the init file).  If the problem does @var{not} occur
-then, it is essential that we know the contents of any programs that you
-must load into the Lisp world in order to cause the problem to occur.
+your init file, set any variables that may affect the functioning of
+Emacs.  @xref{Init File}.  Also, see whether the problem happens in a
+freshly started Emacs without loading your init file (start Emacs with
+the @code{-q} switch to prevent loading the init file).  If the problem
+does @var{not} occur then, it is essential that we know the contents of
+any programs that you must load into the Lisp world in order to cause
+the problem to occur.
 
   If the problem does depend on an init file or other Lisp programs that
 are not part of the standard Emacs system, then you should make sure it is
@@ -378,15 +379,15 @@
 (open-termscript "~/termscript")
 @end example
 
-@noindent
-using @kbd{Meta-@key{ESC}} or from the @samp{*scratch*} buffer just
-after starting Emacs.  From then on, all output from Emacs to the terminal
-will be written in the specified termscript file as well, until the Emacs
-process is killed.  If the problem happens when Emacs starts up, put this
-expression into your @file{.emacs} file so that the termscript file will
-be open when Emacs displays the screen for the first time.  Be warned:
-it is often difficult, and sometimes impossible, to fix a terminal-dependent
-bug without access to a terminal of the type that stimulates the bug.@refill
+@noindent using @kbd{Meta-@key{ESC}} or from the @samp{*scratch*} buffer
+just after starting Emacs.  From then on, all output from Emacs to the
+terminal will be written in the specified termscript file as well, until
+the Emacs process is killed.  If the problem happens when Emacs starts
+up, put this expression into your init file so that the termscript file
+will be open when Emacs displays the screen for the first time.
+@xref{Init File}. Be warned: it is often difficult, and sometimes
+impossible, to fix a terminal-dependent bug without access to a terminal
+of the type that stimulates the bug.@refill
 
 The newsgroup @samp{comp.emacs.xemacs} may be used for bug reports,
 other discussions and requests for assistance.  
--- a/man/xemacs/xemacs.texi	Mon Aug 13 11:18:12 2007 +0200
+++ b/man/xemacs/xemacs.texi	Mon Aug 13 11:19:21 2007 +0200
@@ -551,8 +551,7 @@
                      By changing them, you can "redefine keys".
 * Syntax::          The syntax table controls how words and expressions
                      are parsed.
-* Init File::       How to write common customizations in the @file{.emacs} 
-                     file.
+* Init File::       How to write common customizations in the init file.
 * Audible Bell::    Changing how XEmacs sounds the bell. 
 * Faces::           Changing the fonts and colors of a region of text. 
 * X Resources::	    X resources controlling various aspects of the
@@ -586,7 +585,7 @@
 * Entry: Syntax Entry.    What the syntax table records for each character.
 * Change: Syntax Change.  How to change the information.
 
-The Init File, @file{~/.emacs}
+The Init File
 
 * Init Syntax::     Syntax of constants in Emacs Lisp.
 * Init Examples::   How to do some things with an init file.
--- a/modules/base64/Makefile	Mon Aug 13 11:18:12 2007 +0200
+++ b/modules/base64/Makefile	Mon Aug 13 11:19:21 2007 +0200
@@ -1,5 +1,4 @@
 #
-# Sample makefile for a simple Emacs module.
 # This is slightly more complicated than would normally be the case,
 # as this makefile has been tailored to work in the Emacs source tree.
 # For samples of how to compile modules outside of the source tree
@@ -8,6 +7,8 @@
 # 'installed'.
 #
 
+SHELL=/bin/sh
+RM=rm -f
 CC=../../lib-src/ellcc
 CFLAGS=-I. -I../../src
 LD=$(CC) --mode=link
@@ -28,7 +29,7 @@
 distclean: clean
 
 clean:
-	rm -f $(MODNAME).ell $(OBJS) base64_i.o base64_i.c
+	$(RM) $(MODNAME).ell $(OBJS) base64_i.o base64_i.c
 
 $(MODNAME).ell: $(OBJS) base64_i.o
 	$(LD) --mod-output=$@ $(OBJS) base64_i.o
--- a/modules/ldap/Makefile	Mon Aug 13 11:18:12 2007 +0200
+++ b/modules/ldap/Makefile	Mon Aug 13 11:19:21 2007 +0200
@@ -1,5 +1,4 @@
 #
-# Sample makefile for a simple Emacs module.
 # This is slightly more complicated than would normally be the case,
 # as this makefile has been tailored to work in the Emacs source tree.
 # For samples of how to compile modules outside of the source tree
@@ -8,6 +7,8 @@
 # 'installed'.
 #
 
+SHELL=/bin/sh
+RM=rm -f
 CC=../../lib-src/ellcc
 CFLAGS=-I. -I../../src
 LD=$(CC) --mode=link
@@ -28,7 +29,7 @@
 distclean: clean
 
 clean:
-	rm -f $(MODNAME).ell $(OBJS) eldap_i.o eldap_i.c
+	$(RM) $(MODNAME).ell $(OBJS) eldap_i.o eldap_i.c
 
 $(MODNAME).ell: $(OBJS) eldap_i.o
 	$(LD) --mod-output=$@ $(OBJS) eldap_i.o
--- a/modules/sample/Makefile	Mon Aug 13 11:18:12 2007 +0200
+++ b/modules/sample/Makefile	Mon Aug 13 11:19:21 2007 +0200
@@ -8,6 +8,8 @@
 # 'installed'.
 #
 
+SHELL=/bin/sh
+RM=rm -f
 CC=../../lib-src/ellcc
 CFLAGS=-I. -I../../src
 LD=$(CC) --mode=link
@@ -28,7 +30,7 @@
 distclean: clean
 
 clean:
-	rm -f $(MODNAME).ell $(OBJS) sample_i.o sample_i.c
+	$(RM) $(MODNAME).ell $(OBJS) sample_i.o sample_i.c
 
 $(MODNAME).ell: $(OBJS) sample_i.o
 	$(LD) --mod-output=$@ $(OBJS) sample_i.o
--- a/modules/zlib/Makefile	Mon Aug 13 11:18:12 2007 +0200
+++ b/modules/zlib/Makefile	Mon Aug 13 11:19:21 2007 +0200
@@ -8,6 +8,8 @@
 # 'installed'.
 #
 
+SHELL=/bin/sh
+RM=rm -f
 CC=../../lib-src/ellcc
 CFLAGS=-I. -I../../src
 LD=$(CC) --mode=link
@@ -28,7 +30,7 @@
 distclean: clean
 
 clean:
-	rm -f $(MODNAME).ell $(OBJS) zlib_i.o zlib_i.c
+	$(RM) $(MODNAME).ell $(OBJS) zlib_i.o zlib_i.c
 
 $(MODNAME).ell: $(OBJS) zlib_i.o
 	$(LD) --mod-output=$@ $(OBJS) zlib_i.o
--- a/nt/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/nt/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,61 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-14  IKEYAMA Tomonori  <tomonori@suiyokai.org>
+
+	* config.h: Import C++ compilation stuff from src/config.h.
+
+2000-07-05  Craig Lanning  <lanning@scra.org>
+
+        * xemacs.rc: Uppercase the id's so that windres will work.
+
+2000-07-05  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
+
+	* xemacs.mak (TEMACS_LIBS): Added comdlg32.lib
+
+2000-06-12  Ben Wing  <ben@xemacs.org>
+
+	* config.h (ENCAPSULATE_STAT):
+	Always encapsulate stat/fstat.  Also suggested by Mike Alexander
+	<mike.alexander@xemacs.org>.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* config.h:
+	* config.h (HAVE_GETPAGESIZE):
+	* config.h (HAVE_GETTIMEOFDAY):
+	corrections to go along with removed nt/inc.
+	removed HAVE_FEP.
+	
+	* config.inc.samp:
+	correct graphics lib paths to agree with binaries provided in
+	ftp aux dir.
+	
+	* xemacs.mak (DEPEND):
+	* xemacs.mak (DEFINES):
+	* xemacs.mak (LIB_SRC_DEFINES):
+	* xemacs.mak (minitar):
+	* xemacs.mak (TEMACS_LFLAGS):
+	* xemacs.mak (tags):
+	* xemacs.mak (all):
+	* xemacs.mak (install):
+	WINDOWSNT -> WIN32_NATIVE.
+	Don't build run*.exe.
+	comments about required ^^.
+	Added setargv.obj to the list of linked entities,
+	  causing automatic wildcarding of filenames given on the
+	  command line. (As usual, enclose in double quotes to avoid
+	  this.)
+	
+2000-06-07  Ben Wing  <ben@xemacs.org>
+
+	* runemacs.c: Removed.  No longer necessary.
+
+	* Makefile.cygwin: Removed.
+
+	* inc\*: Removed.  At long-fucking-last!
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
@@ -361,7 +419,7 @@
 
 	* XEmacs 21.2.16 is released
 
-1999-05-14  Adrian Aichner  &lt;adrian@xemacs.org&gt;
+1999-05-14  Adrian Aichner  <adrian@xemacs.org>
 
 	* xemacs.mak (GUNG_HO): Explicitly default to 0.
 	Fix some comment typos.
--- a/nt/Makefile.cygwin	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-MSW_LIBS	=-luser32 -lgdi32 -lcomdlg32
-LDFLAGS		=-Wl,--subsystem,windows
-CFLAGS		=-g
-
-bindir		=/usr/local/bin
-
-INSTALL = /usr/local/src/xemacs-21.0-b42/lib-src/installexe.sh /d/cygnus/h-i386-cygwin32/bin/install -c
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_DATA = ${INSTALL} -m 644
-
-runemacs.exe:	runemacs.o
-		$(CC) $(LDFLAGS) runemacs.o $(MSW_LIBS) -o $@
-
-install:	runemacs.exe
-		$(INSTALL_PROGRAM) runemacs.exe $(bindir)
--- a/nt/config.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/nt/config.h	Mon Aug 13 11:19:21 2007 +0200
@@ -157,7 +157,7 @@
 #undef WORDS_BIGENDIAN
 #undef TIME_WITH_SYS_TIME
 
-#define HAVE_SYS_TIME_H
+#undef HAVE_SYS_TIME_H
 #define HAVE_LOCALE_H
 #ifdef HAVE_X_WINDOWS
 #define HAVE_X11_LOCALE_H
@@ -230,7 +230,10 @@
 #undef HAVE_FREXP
 #undef HAVE_FTIME
 #undef HAVE_GETHOSTNAME
-#undef HAVE_GETPAGESIZE
+
+#define HAVE_GETPAGESIZE
+#define getpagesize() 4096
+
 #define HAVE_GETTIMEOFDAY
 #define HAVE_GETWD
 #undef HAVE_LOGB
@@ -559,10 +562,8 @@
 #define ENCAPSULATE_OPEN
 #define ENCAPSULATE_FOPEN
 #define ENCAPSULATE_MKDIR
-
-#if defined (WIN32) && defined (USE_IME)
-#define HAVE_FEP
-#endif
+#define ENCAPSULATE_STAT
+#define ENCAPSULATE_FSTAT
 
 #if defined (HAVE_SOCKS) && !defined (DO_NOT_SOCKSIFY)
 #define accept Raccept
@@ -601,6 +602,21 @@
 
 #endif /* compiler understands #pragma warning*/
 
+#ifndef NOT_C_CODE /* Actually means C or C++ */
+# if defined (__cplusplus)
+/* Avoid C++ keywords used as ordinary C identifiers */
+#  define class c_class
+#  define new   c_new
+#  define this  c_this
+#  define catch c_catch
+#  define not   c_not
+
+#  define EXTERN_C extern "C"
+# else /* C code */
+#  define EXTERN_C extern
+# endif
+#endif /* C or C++ */
+
 #define enum_field(enumeration_type) unsigned int
 
 /* We want to avoid saving the signal mask if possible, because
--- a/nt/config.inc.samp	Mon Aug 13 11:18:12 2007 +0200
+++ b/nt/config.inc.samp	Mon Aug 13 11:19:21 2007 +0200
@@ -23,7 +23,7 @@
 # Set this to enable XPM support (virtually mandatory), and specify
 # the directory containing xpm.
 HAVE_XPM=1
-XPM_DIR=f:\src\xpm-3.4k
+XPM_DIR=c:\src\xpm-3.4k
 
 # Set this to enable GIF support.
 HAVE_GIF=1
@@ -31,16 +31,16 @@
 # Set this to enable PNG support (virtually mandatory), and specify
 # the directories containing png and zlib.
 HAVE_PNG=1
-PNG_DIR=f:\src\libpng-1.0.3
-ZLIB_DIR=f:\src\zlib
+PNG_DIR=c:\src\libpng-1.0.5
+ZLIB_DIR=c:\src\zlib-1.1.3
 
 # Set this to enable TIFF support, and specify the directory containing tiff.
 HAVE_TIFF=0
 TIFF_DIR=
 
 # Set this to enable JPEG support, and specify the directory containing jpeg.
-HAVE_JPEG=0
-JPEG_DIR=
+HAVE_JPEG=1
+JPEG_DIR=c:\src\jpeg-6b
 
 # Set this to enable XFace support, and specify the directory containing
 # compface.
--- a/nt/inc/arpa/inet.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-/* null version of <arpa/inet.h> - <sys/socket.h> has everything */
--- a/nt/inc/netdb.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-/* null version of <netdb.h> - <sys/socket.h> has everything */
--- a/nt/inc/netinet/in.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-/* null version of <netinet/in.h> - <sys/socket.h> has everything */
--- a/nt/inc/pwd.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#ifndef _PWD_H_
-#define _PWD_H_
-/*
- * pwd.h doesn't exist on NT, so we put together our own.
- */
-
-struct passwd {
-    char *pw_name;
-    char *pw_passwd;
-    int   pw_uid;
-    int   pw_gid;
-    int   pw_quota;
-    char *pw_gecos;
-    char *pw_dir;
-    char *pw_shell;
-};
-
-#endif /* _PWD_H_ */
--- a/nt/inc/sys/dir.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/* This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: FSF 19.30. */
-
-/*
-	<dir.h> -- definitions for 4.2BSD-compatible directory access
-
-	last edit:	09-Jul-1983	D A Gwyn
-*/
-
-#ifdef VMS
-#ifndef FAB$C_BID
-#include <fab.h>
-#endif
-#ifndef NAM$C_BID
-#include <nam.h>
-#endif
-#ifndef RMS$_SUC
-#include <rmsdef.h>
-#endif
-#include "vms-dir.h"
-#endif /* VMS */
-
-#define DIRBLKSIZ	512		/* size of directory block */
-#ifdef VMS
-#define MAXNAMLEN	(DIR$S_NAME + 7) /* 80 plus room for version #.  */
-#define MAXFULLSPEC	NAM$C_MAXRSS /* Maximum full spec */
-#else
-#ifdef WINDOWSNT
-#define MAXNAMLEN	255
-#else  /* not WINDOWSNT */
-#define MAXNAMLEN	15		/* maximum filename length */
-#endif /* not WINDOWSNT */
-#endif /* VMS */
-	/* NOTE:  MAXNAMLEN must be one less than a multiple of 4 */
-
-struct direct				/* data from readdir() */
-	{
-	long		d_ino;		/* inode number of entry */
-	unsigned short	d_reclen;	/* length of this record */
-	unsigned short	d_namlen;	/* length of string in d_name */
-	char		d_name[MAXNAMLEN+1];	/* name of file */
-	};
-
-typedef struct
-	{
-	int	dd_fd;			/* file descriptor */
-	int	dd_loc;			/* offset in block */
-	int	dd_size;		/* amount of valid data */
-	char	dd_buf[DIRBLKSIZ];	/* directory block */
-	}	DIR;			/* stream data from opendir() */
-
-DIR *opendir (const char *filename);
-void closedir (DIR *dirp);
-struct direct *readdir (DIR *dirp);
-struct direct *readdirver (DIR *dirp);
-long telldir (DIR *dirp);
-void seekdir (DIR *dirp, long loc);
-
-#define rewinddir( dirp )	seekdir( dirp, 0L )
--- a/nt/inc/sys/file.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * sys\file.h doesn't exist on NT - only needed for these constants
- */
-
-#define F_OK 0
-#ifdef X_OK
-#undef X_OK
-#endif
-#define X_OK 1
-#define W_OK 2
-#define R_OK 4
--- a/nt/inc/sys/ioctl.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-/*
- * sys\ioctl.h doesn't exist on NT...rather than including it conditionally
- * in many of the source files, we just extend the include path so that the
- * compiler will pick this up empty header instead.
- */
--- a/nt/inc/sys/param.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#ifndef _PARAM_H_
-#define _PARAM_H_
-
-/*
- * sys\param.h doesn't exist on NT, so we'll make one.
- */
-
-#define NBPG 4096
-
-#endif /* _PARAM_H_ */
--- a/nt/inc/sys/socket.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* Workable version of <sys/socket.h> based on winsock.h */
-
-#ifndef _SOCKET_H_
-#define _SOCKET_H_
-
-/* defeat the multiple include protection */
-#ifdef _WINSOCKAPI_
-#undef _WINSOCKAPI_
-#endif
-
-#if 0 /* What's wrong with winsock.h version ? - kkm */
-/* avoid clashing with our version of FD_SET if already defined */
-#ifdef FD_SET
-#undef FD_SET
-#undef FD_CLR
-#undef FD_ISSET
-#undef FD_ZERO
-#endif
-
-/* allow us to provide our own version of fd_set */
-#define fd_set ws_fd_set
-#endif /* 0 */
-
-/* avoid duplicate definition of timeval */
-#if defined(HAVE_TIMEVAL) && !defined(__MINGW32__)
-#define timeval ws_timeval
-#endif
-
-#include <winsock.h>
-
-#if 0 /* What's wrong with winsock.h version ? - kkm */
-/* revert to our version of FD_SET */
-#undef FD_SET
-#undef FD_CLR
-#undef FD_ISSET
-#undef FD_ZERO
-#undef fd_set
-#include "nt.h"
-#endif /* 0 */
-
-#ifdef HAVE_TIMEVAL
-#undef timeval
-#endif
-
-/* map winsock error codes to standard names */
-#define EWOULDBLOCK             WSAEWOULDBLOCK
-#define EINPROGRESS             WSAEINPROGRESS
-#define EALREADY                WSAEALREADY
-#define ENOTSOCK                WSAENOTSOCK
-#define EDESTADDRREQ            WSAEDESTADDRREQ
-#define EMSGSIZE                WSAEMSGSIZE
-#define EPROTOTYPE              WSAEPROTOTYPE
-#define ENOPROTOOPT             WSAENOPROTOOPT
-#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
-#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
-#define EOPNOTSUPP              WSAEOPNOTSUPP
-#define EPFNOSUPPORT            WSAEPFNOSUPPORT
-#define EAFNOSUPPORT            WSAEAFNOSUPPORT
-#define EADDRINUSE              WSAEADDRINUSE
-#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
-#define ENETDOWN                WSAENETDOWN
-#define ENETUNREACH             WSAENETUNREACH
-#define ENETRESET               WSAENETRESET
-#define ECONNABORTED            WSAECONNABORTED
-#define ECONNRESET              WSAECONNRESET
-#define ENOBUFS                 WSAENOBUFS
-#define EISCONN                 WSAEISCONN
-#define ENOTCONN                WSAENOTCONN
-#define ESHUTDOWN               WSAESHUTDOWN
-#define ETOOMANYREFS            WSAETOOMANYREFS
-#define ETIMEDOUT               WSAETIMEDOUT
-#define ECONNREFUSED            WSAECONNREFUSED
-#define ELOOP                   WSAELOOP
-/* #define ENAMETOOLONG            WSAENAMETOOLONG */
-#define EHOSTDOWN               WSAEHOSTDOWN
-#define EHOSTUNREACH            WSAEHOSTUNREACH
-/* #define ENOTEMPTY               WSAENOTEMPTY */
-#define EPROCLIM                WSAEPROCLIM
-#define EUSERS                  WSAEUSERS
-#define EDQUOT                  WSAEDQUOT
-#define ESTALE                  WSAESTALE
-#define EREMOTE                 WSAEREMOTE
-
-#endif /* _SOCKET_H_ */
-
-/* end of socket.h */
--- a/nt/inc/sys/time.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * sys/time.h doesn't exist on NT
- */
-
-#include <time.h>
-
-#ifdef __MINGW32__
-#include <winsock.h>
-#else
-struct timeval 
-  {
-    long tv_sec;	/* seconds */
-    long tv_usec;	/* microseconds */
-  };
-#endif
-
-struct timezone 
-  {
-    int	tz_minuteswest;	/* minutes west of Greenwich */
-    int	tz_dsttime;	/* type of dst correction */
-  };
-
-#ifndef HAVE_X_WINDOWS
-/* X11R6 on NT provides the single parameter version of this command */
-void gettimeofday (struct timeval *, struct timezone *);
-#endif
-
-/* end of sys/time.h */
--- a/nt/inc/unistd.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-/* Fake unistd.h: config.h already provides most of the relevant things. */
--- a/nt/runemacs.c	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
-  Simple program to start Emacs with its console window hidden.
-
-  This program is provided purely for convenience, since most users will
-  use Emacs in windowing (GUI) mode, and will not want to have an extra
-  console window lying around.  */
-
-/*
-   You may want to define this if you want to be able to install updated
-   emacs binaries even when other users are using the current version.
-   The problem with some file servers (notably Novell) is that an open
-   file cannot be overwritten, deleted, or even renamed.  So if someone
-   is running emacs.exe already, you cannot install a newer version.
-   By defining CHOOSE_NEWEST_EXE, you can name your new emacs.exe
-   something else which matches "emacs*.exe", and runemacs will
-   automatically select the newest emacs executeable in the bin directory.
-   (So you'll probably be able to delete the old version some hours/days
-   later).
-*/
-
-/* #define CHOOSE_NEWEST_EXE */
-
-#define WIN32
-
-#include <windows.h>
-#include <string.h>
-#include <malloc.h>
-
-#if defined(__CYGWIN32__)
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-
-int WINAPI
-WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
-{
-  STARTUPINFO start;
-  SECURITY_ATTRIBUTES sec_attrs;
-  SECURITY_DESCRIPTOR sec_desc;
-  PROCESS_INFORMATION child;
-  int wait_for_child = FALSE;
-  DWORD ret_code = 0;
-  char *new_cmdline;
-  char *basename;
-  char *p;
-  char modname[MAX_PATH];
-
-  if (!GetModuleFileName (NULL, modname, MAX_PATH))
-    goto error;
-  if ((p = strrchr (modname, '\\')) == NULL)
-    goto error;
-
-  basename = alloca(strlen(p) + 1);
-  strcpy (basename, p + 1);
-  
-  *p = 0;
-
-  new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1);
-  strcpy (new_cmdline, modname);
-
-#ifdef CHOOSE_NEWEST_EXE
-  {
-    /* Silly hack to allow new versions to be installed on
-       server even when current version is in use. */
-
-    char * best_name = alloca (MAX_PATH + 1);
-    FILETIME best_time = {0,0};
-    WIN32_FIND_DATA wfd;
-    HANDLE fh;
-    p = new_cmdline + strlen (new_cmdline);
-    strcpy (p, "\\xemacs*.exe ");
-    fh = FindFirstFile (new_cmdline, &wfd);
-    if (fh == INVALID_HANDLE_VALUE)
-      goto error;
-    do
-      {
-        if (wfd.ftLastWriteTime.dwHighDateTime > best_time.dwHighDateTime
-            || (wfd.ftLastWriteTime.dwHighDateTime == best_time.dwHighDateTime
-                && wfd.ftLastWriteTime.dwLowDateTime > best_time.dwLowDateTime))
-          {
-            best_time = wfd.ftLastWriteTime;
-            strcpy (best_name, wfd.cFileName);
-          }
-      }
-    while (FindNextFile (fh, &wfd));
-    FindClose (fh);
-    *p++ = '\\';
-    strcpy (p, best_name);
-    strcat (p, " ");
-  }
-#else
-#if defined(__CYGWIN32__)
-  {
-    struct stat stbuf;
-    char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1];
-    
-    strcpy(sym_link_name, new_cmdline);
-    if (strcmp(basename, "rungnuclient.exe") == 0)
-      strcat(new_cmdline, "\\gnuclient.exe ");
-    else if (strcmp(basename, "runemacs.exe") == 0)
-      {
-        strcat(sym_link_name, "\\xemacs");
-          
-        if (lstat(sym_link_name, &stbuf) == 0)
-          {
-            if ((stbuf.st_mode & S_IFLNK) == S_IFLNK)
-              {
-                if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1)
-                  {
-                    MessageBox (NULL, "Error reading symbolic link for xemacs",
-                                "Error", MB_ICONSTOP);
-                    return 1;
-                  }
-                else
-                  {
-                    strcat(new_cmdline, "\\");
-                    strcat(new_cmdline, real_name);
-                    strcat(new_cmdline, " ");
-                  }
-              }
-            else
-              strcat(new_cmdline, "\\xemacs ");
-          }
-        else
-          {
-            MessageBox (NULL, "can't locate XEmacs executable",
-                        "Error", MB_ICONSTOP);
-            return 1;
-          }
-      }
-  }
-#else					
-  if (strcmp(basename, "rungnuclient.exe") == 0)
-    strcat (new_cmdline, "\\gnuclient.exe ");
-  else 
-    strcat (new_cmdline, "\\xemacs.exe ");
-#endif
-#endif
-
-  /* Append original arguments if any; first look for -wait as first
-     argument, and apply that ourselves.  */
-  if (strncmp (cmdline, "-wait", 5) == 0)
-    {
-      wait_for_child = TRUE;
-      cmdline += 5;
-    }
-  strcat (new_cmdline, cmdline);
-
-  /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin".  */
-  if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0)
-    {
-      *p = 0;
-      for (p = modname; *p; p++)
-	if (*p == '\\') *p = '/';
-      SetEnvironmentVariable ("emacs_dir", modname);
-    }
-
-  memset (&start, 0, sizeof (start));
-  start.cb = sizeof (start);
-  start.dwFlags = STARTF_USESHOWWINDOW;
-  start.wShowWindow = SW_HIDE;
-
-  sec_attrs.nLength = sizeof (sec_attrs);
-  sec_attrs.lpSecurityDescriptor = NULL;
-  sec_attrs.bInheritHandle = FALSE;
-
-  if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, 0,
-		     NULL, NULL, &start, &child))
-    {
-      if (wait_for_child)
-	{
-	  WaitForSingleObject (child.hProcess, INFINITE);
-	  GetExitCodeProcess (child.hProcess, &ret_code);
-	}
-      CloseHandle (child.hThread);
-      CloseHandle (child.hProcess);
-    }
-  else
-    goto error;
-  return (int) ret_code;
-
-error:
-  MessageBox (NULL, "Could not start XEmacs or gnuclient.", "Error", MB_ICONSTOP);
-  return 1;
-}
--- a/nt/xemacs.mak	Mon Aug 13 11:18:12 2007 +0200
+++ b/nt/xemacs.mak	Mon Aug 13 11:19:21 2007 +0200
@@ -297,6 +297,9 @@
 ! if [if not exist $(OUTDIR)\nul mkdir "$(OUTDIR)"]
 ! endif
 # generate an nmake-readable version of depend
+# #### here, it doesn't seem to matter if we double ^'s!
+# results are the same with all single ^ and all double ^^!
+# see comment below.
 ! if [perl -p -e "s/^\x23ifdef (.+)/!if defined($$1)/; s/^\x23e/!e/;" \
 	-e "s/([\s=^])([\w\d\.\-^]+\.[ch^])/$$1$(SRC:\=\\)\\$$2/g;" \
 	-e "s/^(.+)\.o:(.+)/$(OUTDIR:\=\\)\\$$1.obj:$$2 $(NT:\=\\)\\config.inc/;" \
@@ -455,7 +458,7 @@
 DEFINES=$(X_DEFINES) $(MSW_DEFINES) $(MULE_DEFINES) \
 	$(TAGBITS_DEFINES) $(LRECORD_DEFINES) $(UNION_DEFINES) \
 	$(DUMPER_DEFINES) $(MALLOC_DEFINES) $(QUICK_DEFINES) \
-	-DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN -DWINDOWSNT -Demacs \
+	-DWIN32_LEAN_AND_MEAN -DWIN32_NATIVE -Demacs \
 	-DHAVE_CONFIG_H $(PROGRAM_DEFINES) $(PATH_DEFINES)
 
 #------------------------------------------------------------------------------
@@ -481,7 +484,7 @@
 
 # lib-src programs
 
-LIB_SRC_DEFINES = -DHAVE_CONFIG_H -DWIN32 -DWINDOWSNT
+LIB_SRC_DEFINES = -DHAVE_CONFIG_H -DWIN32_NATIVE
 
 #
 # Creating config.values to be used by config.el
@@ -549,18 +552,6 @@
 
 #------------------------------------------------------------------------------
 
-# runxemacs proglet
-
-RUNEMACS = $(SRC)\runxemacs.exe
-
-$(RUNEMACS): $(LIB_SRC)\run.c $(LIB_SRC)\run.res
-	$(CCV) -I$(LIB_SRC) $(CFLAGS) -Fe$@ -Fo$(LIB_SRC) -Fd$(LIB_SRC)\ $** kernel32.lib user32.lib -link -incremental:no
-
-$(LIB_SRC)\run.res: $(LIB_SRC)\run.rc
-	rc -I$(LIB_SRC) -Fo$@ $**
-
-#------------------------------------------------------------------------------
-
 # dump-id.c file that contains the dump id
 
 $(SRC)\dump-id.c : $(LIB_SRC)/make-dump-id.exe 
@@ -824,12 +815,12 @@
 TEMACS_BROWSE=$(TEMACS_DIR)\temacs.bsc
 TEMACS_SRC=$(SRC)
 TEMACS_LIBS=$(LASTFILE) $(LWLIB) $(X_LIBS) $(MSW_LIBS) \
- oldnames.lib kernel32.lib user32.lib gdi32.lib advapi32.lib \
+ oldnames.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib \
  shell32.lib wsock32.lib winmm.lib winspool.lib ole32.lib uuid.lib $(LIBC_LIB)
 TEMACS_LFLAGS=-nologo $(LIBRARIES) $(DEBUG_FLAGS) -base:0x1000000\
  -stack:0x800000 $(TEMACS_ENTRYPOINT) -subsystem:windows\
  -pdb:$(TEMACS_DIR)\temacs.pdb -map:$(TEMACS_DIR)\temacs.map \
- -heap:0x00100000 -nodefaultlib -incremental:no
+ -heap:0x00100000 -nodefaultlib -incremental:no setargv.obj
 TEMACS_CPP_FLAGS=-c \
  $(CFLAGS) $(INCLUDES) $(DEFINES) $(DEBUG_DEFINES) \
  -DEMACS_MAJOR_VERSION=$(emacs_major_version) \
@@ -1104,8 +1095,10 @@
 	cd $(XEMACS)
 	$(DEL) TAGS
 	set PATH=lib-src;%PATH%
-# argh!!! we need two ^^'s to get one ^, but only before a backslash.
-# i have no idea why.  probably some obscure nmake quoting convention.
+# we need to double ^, but only before backslash!  Doubling it elsewhere
+# causes problems.  I don't understand this -- CMD.EXE uses ^ as a quoting
+# convention of sorts, but appears to leave it alone inside of double quotes,
+# even before \.  Could this be nmake interference?
 	etags -a -r "/[ 	]*DEF\(VAR\|INE\)_[A-Z_]+[ 	]*([ 	]*\"\([^^\"]+\)\"/\2/" src\*.c src\*.h lwlib\*.c lwlib\*.h lib-src\*.c lib-src\*.h
 	etags -a -l none -r "/^(def\(var\|un\|alias\|const\|macro\|subst\|struct\|face\|group\|custom\|ine-\(function\|compiler-macro\|[a-z-]+alias\)\)[ 	]+'?\([^ 	]+\)/\3/" $(tagslisp)\*.el
 
@@ -1370,7 +1363,7 @@
 
 # use this rule to build the complete system
 all:	installation $(OUTDIR)\nul $(LASTFILE) $(LWLIB) \
-	$(LIB_SRC_TOOLS) $(RUNEMACS) $(TEMACS) update-elc $(DOC) $(PROGNAME) \
+	$(LIB_SRC_TOOLS) $(TEMACS) update-elc $(DOC) $(PROGNAME) \
 	update-auto-and-custom info
 
 temacs: $(LASTFILE) $(TEMACS)
@@ -1387,7 +1380,6 @@
 	@copy $(LIB_SRC)\DOC "$(INSTALL_DIR)\$(EMACS_CONFIGURATION)"
 	@copy $(CONFIG_VALUES) "$(INSTALL_DIR)\$(EMACS_CONFIGURATION)"
 	@copy $(SRC)\xemacs.exe "$(INSTALL_DIR)\$(EMACS_CONFIGURATION)"
-	@copy $(RUNEMACS) "$(INSTALL_DIR)\$(EMACS_CONFIGURATION)"
 	@xcopy /e /q $(XEMACS)\etc  "$(INSTALL_DIR)\etc\"
 	@xcopy /e /q $(XEMACS)\info "$(INSTALL_DIR)\info\"
 	@xcopy /e /q $(XEMACS)\lisp "$(INSTALL_DIR)\lisp\"
--- a/nt/xemacs.rc	Mon Aug 13 11:18:12 2007 +0200
+++ b/nt/xemacs.rc	Mon Aug 13 11:19:21 2007 +0200
@@ -2,6 +2,6 @@
 101    DUMP      "xemacs.dmp"
 #endif
 
-XEmacs icon preload "xemacs.ico"
-XEmacsFile icon "File.ico"
-XEmacsLisp icon "Lisp.ico"
+XEmacs ICON PRELOAD "xemacs.ico"
+XEmacsFile ICON "File.ico"
+XEmacsLisp ICON "Lisp.ico"
--- a/src/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,953 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-07-19  Martin Buchholz  <martin@xemacs.org>
+
+	* select-x.c (x_handle_selection_request): 
+	Text selected in xemacs and pasted into xterm failed to appear.
+	Spelling fixes and cosmetic changes.
+
+2000-07-18  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
+
+	* event-msw.c (mswindows_drain_windows_queue): Correctly check for
+	XEmacs frame (fix for doubling chars in dialog boxes).
+
+2000-07-17 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.c (select_convert_in, select_convert_out):
+	Don't call intern() every time.
+
+	* select.c (Qselect_convert_in, Qselect_convert_out): New.
+	* select.c (vars_of_select): Initialise them.
+
+2000-07-18 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.c (selection-coercible-types): New.
+
+	* select.c (own-selection-internal):
+	* select.c (get-selection-internal):
+	MULE bug fix - these should default to COMPOUND_TEXT and not
+	STRING for MULE. I think.
+
+	* select.c (select_convert_out): Use selection-coercible-types
+	to find types that we can attempt to perform coercions on.
+
+2000-07-18  Martin Buchholz  <martin@xemacs.org>
+
+	* mule-wnnfns.c:
+	* mule-canna.c:
+	Add coding: cookie to identify encoding.
+
+	* mule-canna.c (CANNA_mode_keys): make static.
+	Use proper prototypes, even for functions of no arguments.
+	Remove external prototype for Fding().
+
+	* symsinit.h: Add missing prototype for reinit_vars_of_mule_wnn.
+
+	* select.c (syms_of_select): Add missing DEFSUBR.
+
+2000-07-18 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.c (get_selection_internal, own_selection_internal):
+	Make the type default to STRING, rather than placing a nil type
+	into Vselection_alist.
+
+2000-07-17 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* gpmevent.c (tty_selection_exists_p):
+	* gpmevent.c (tty_own_selection):
+	Updated parameter lists.
+
+2000-07-15 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* select.h (selection-alist): Removed declaration.
+
+	* select.h (get_local_selection):
+	* select.c (get_local_selection):
+	Made static.
+
+	* select.h (convert_selection): Removed declaration.
+	* select.c (convert_selection): Removed.
+	This function belongs in Lisp.
+
+	* select.h (select_convert_in): Declare.
+	* select.h (select_convert_out): Declare.
+	* select.c (select_convert_in): New.
+	* select.c (select_convert_out): New.
+	New conversion functions for other files to call.
+
+	* select.h (select_notify_buffer_kill): Declare.
+	* select.c (select_notify_buffer_kill): New.
+	New functions that get called from kill-buffer.
+
+	* buffer.c (kill-buffer): Call select_notify_buffer_kill, rather than
+	X-specific lisp code.
+
+	* select.h: Declare some of the lisp-visible functions for
+	external use.
+
+	* select.c (clean_local_selection_data): Removed. This was
+	a disgusting function, and previously should have been in
+	select-x.c in any case. The functionality is now provided
+	in select-convert-from-integer (select.el).
+
+	* select.c (available-selection-types): Fixed stupidity where
+	INTEGER and ATOM got added twice. Also add STRING when we see an
+	extent.
+
+	* select.c (get-selection-internal): Removed symbol stripping. No
+	longer causes conversion when data comes from the internal cache.
+
+	* select.c (syms_of_select): Added new functions.
+
+	* select-x.c (motif_clipboard_cb): Use select_convert_out. Rewrote
+	error checking - previously this called abort!
+	
+	* select-x.c (x_own_selection): Changed comment.
+	
+	* select-x.c (x_handle_selection_request): Use select_convert_out.
+	Don't mess with selection-alist; it's an internal variable of select.c.
+	
+	* select-x.c (x_get_foreign_selection): Use select_convert_in.
+	
+	* select-x.c (x_handle_selection_clear): Use get-selection-timestamp,
+	rather than messing with selection-alist.
+	
+	* select-msw.c (mswindows_get_foreign_selection):
+	Use TO_INTERNAL_FORMAT rather than hacking.
+
+2000-07-14  Martin Buchholz  <martin@xemacs.org>
+
+	* process-unix.c (unix_open_multicast_group):
+	(unix_open_multicast_group): Remove useless casts.
+
+2000-07-13  Martin Buchholz  <martin@xemacs.org>
+
+	* sound.c (Fplay_sound): Fix `unused variable' warning.
+
+	* emacs.c (main): Use correct type for _environ on SCO5.
+
+2000-07-12 Alastair J. Houghton <ajhoughton@lineone.net>
+
+	* console.h (own_selection_method):
+	* console.h (selection_exists_p_method):
+	* console.h (available_selection_types_method): New.
+	* console.h (register_selection_data_type_method): New.
+	* console.h (selection_data_type_name): New.
+	
+	* console-msw.h (mswindows_destroy_selection): Declare it.  New
+	function & alist to track GlobalAlloc()'d handles that need
+	releasing when the clipboard data gets replaced or emptied.
+
+	* event-msw.c (mswindows_wnd_proc): Call it.
+
+	* lisp.h, general.c (Qappend): New symbol representing a
+	`how-to-add' mode.
+	
+	* select.c (own-selection-internal):
+	* select.c (selection-exists-p):
+	* select.c (available-selection-types): New.
+	* select.c (register-selection-data-type): New.
+	* select.c (selection-data-type-name): New.  New functions to deal
+	with device-specific selection data formats.
+	* select.c (selection-converter-out-alist): Renamed.
+	* select.c (selection-converter-in-alist): New.
+	* select.c (selection-appender-alist): New.  Added new alists.
+	* select.c (syms_of_select, vars_of_select): Added new symbols &
+	variables.
+	* select.c (get_local_selection): Split.
+	* select.c: Removed spurious type checking - selections may now be
+	of any type, not just strings.
+	* select.c (own-selection-internal):
+
+	* select.h, select.c (convert_selection): New. Created
+	convert_selection() function based on get_local_selection().
+	* select.h, select.c (QCF_*): New symbols representing mswindows
+	clipboard formats.
+	* select.h, select.c (Qreplace_all, Qreplace_existing): New
+	symbols representing `how-to-add' modes.
+
+	* select-msw.c (x_sym_p): New.
+	* select-msw.c (symbol_to_ms_cf): New.
+	* select-msw.c (ms_cf_to_symbol): New. New functions to deal with
+	symbols & clipboard formats. Can also handle string names.
+	* select-msw.c (mswindows_own_selection):
+	* select-msw.c (mswindows_selection_exists_p):
+	Added `data-type' parameter. Use it.
+	* select-msw.c (mswindows_available_selection_types): New.
+	* select-msw.c (mswindows_register_selection_data_type): New.
+	* select-msw.c (mswindows_selection_data_type_name): New.
+	* select-msw.c (mswindows_own_selection):
+	* select-msw.c (mswindows_get_foreign_selection):
+	* select-msw.c (mswindows_selection_exists_p):	Rewrote.
+	* select-msw.c (console_create_select_mswindows): Added new methods.
+	* select-msw.c (mswindows_destroy_selection): New.
+	* select-msw.c (Vhandle_alist): New list.
+	* select-msw.c (mswindows_own_selection):
+
+	* select-x.c (x_own_selection):
+	* select-x.c (x_selection_exists_p):
+	* select-x.c: Added some comments about maybe using new
+	functionality.
+	* select-x.c (x_own_selection):
+
+	* specifier.c: Remove definition of Qappend (now in general.c)
+	* specifier.c (syms_of_specifier): Remove Qappend.
+
+2000-07-12  Martin Buchholz  <martin@xemacs.org>
+
+	* config.h.in: Add socklen_t.
+
+	* s/decosf4-0.h: No special compiler flags needed or desired.
+	In particular, undefine _BSD for DEC OSF 4.0.
+
+2000-07-07  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
+
+	* redisplay-msw.c (msprinter_frame_output_end): Added.
+	(console_type_create_redisplay_mswindows): Referred the above.
+
+	* frame.c (setup_frame_without_minibuffer): Do not create a
+	default minibuffer frame on a printer device.
+
+	* frame-msw.c (apply_dc_geometry): Added.
+	(msprinter_start_page): 
+	(msprinter_init_frame_3): 
+	(msprinter_eject_page): Use it.
+
+	* console-msw.h (struct msprinter_frame): Added pix_left and top,
+	and removed residual duplex and orientation properties.
+
+2000-07-11  Martin Buchholz  <martin@xemacs.org>
+
+	* eval.c (function_argcount): Work around a DEC CC compiler bug.
+
+	* unexalpha.c: Remove system prototypes from C sources!
+
+2000-07-09  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* eval.c: Remove references to M-x edit-options in DEFUNs for
+	`defvar' and `defconst'.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* config.h.in: Remove SMART_INCLUDE hackery.
+	
+	PostgreSQL hacking:
+	* config.h.in: Don't use SMART_INCLUDE.
+
+	* postgresql.h: Include libpq-fe.h here.  Fix typo.
+	* inline.c: Simply #include "postgresql.h"
+	* postgresql.c:
+	- Don't use SMART_INCLUDE
+	- Use simply "const".
+	- Use standard doc string conventions.
+	- Use correct type for result of PQstatus.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* glyphs-x.c (x_xface_instantiate): Fix C++ compilation warnings.
+
+	C++ compilation changes.
+	* config.h.in (EXTERN_C): Define.
+	* config.h.in (not): This is also a C++ keyword.
+	* unexalpha.c (DEFAULT_ENTRY_ADDRESS): Enable C++ compilation.
+	* cm.c: Use EXTERN_C.
+	* redisplay-tty.c: Use EXTERN_C.
+	* sysdep.c: Use EXTERN_C.  Remove Gould support.
+
+2000-07-09  Martin Buchholz  <martin@xemacs.org>
+
+	* general.c: Remove duplicate definition for Qfunction.
+
+2000-07-08  Ben Wing  <ben@xemacs.org>
+
+	* device-msw.c (msprinter_init_device):
+	* device-msw.c (sync_printer_with_devmode):
+	* device-msw.c (handle_devmode_changes):
+	* device-msw.c (print_dialog_worker):
+	* device-msw.c (Fmsprinter_apply_settings):
+	* device-msw.c (hash_devmode):
+	* device-msw.c (Fmsprinter_settings_despecialize):
+	use Qmswindows_tstr, not Qctext.
+	
+	* vm-limit.c (check_memory_limits):
+	avoid infinite loop printing warning messages.
+
+2000-07-05  Craig Lanning  <lanning@scra.org>
+
+        * Makefile.in.in: Add support for including the Windows resources
+        when building with the cygwin and mingw targets.
+
+        * buffer.c: from Dan Holmsand, on Windows $PWD is most likely either
+        not set or not correct.
+        (directory_is_current_directory): Don't compile for WIN32_NATIVE.
+        (init_initial_directory): Don't try to use $PWD on the
+        WIN32_NATIVE target.
+
+        * s\cygwin32.h:
+	[[Add -mwindows to eliminate console window.]] not required --ben
+        (HAVE_NATIVE_SOUND): removed; now handled by configure.
+        (MAIL_USE_POP): removed; now handled by configure.
+
+        * s\mingw32.h: [[Add -mwindows to eliminate console window.]] not in
+	C_SWITCH_SYSTEM or it will affect lib-src progs. --ben
+        (HAVE_NATIVE_SOUND): removed; now handled by configure.
+        (MAIL_USE_POP): removed; now handled by configure.
+        (ENCAPSULATE_STAT): from Dan Holmsand, added.
+        (ENCAPSULATE_FSTAT): from Dan Holmsand, added.
+        (DIRECTORY_SEP): from Dan Holmsand, use lisp variable instead of
+        constant string.
+        (HAVE_TIMEVAL): from Dan Holmsand, added; struct timeval is picked
+        up from <winsock.h> via systime.h.
+        (HAVE_GETPAGESIZE): from Dan Holmsand, added.
+        (getpagesize): from Dan Holmsand, added.
+        Added #endif which was left dangling by Ben's mega patch; added
+        comment to help prevent this in the future.
+
+        * sysdll.c: added #include <windows.h> for WIN32_NATIVE case.
+
+2000-07-05  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
+
+	* console-msw.h (struct mswindows_device): Removed unnecessary
+	cached device geometry values.
+	Added update_tick and an accessor macro.
+	(Lisp_Devmode): Added lrecord declaration. 
+	(struct msprinter_device): Contain devmode as a Lisp object.
+	Added mswindows_get_selected_frame_hwnd();
+
+	* console.h (struct console_methods): Indentation nitpicking.
+
+	* device-msw.c (mswindows_init_device): Do not initialize geometry
+	cache. Initialize update tick.
+	(mswindows_device_system_metrics): Ask the device for its geometry.
+	(global_free_2_maybe): 
+	(devmode_to_hglobal): 
+	(handle_printer_changes): 
+	(ensure_not_printing): 
+	(print_dialog_worker): 
+	(Fmsprinter_print_setup_dialog): 
+	(Fmsprinter_print_dialog): 
+	(plist_get_margin): 
+	(plist_set_margin): 
+	(Fmsprinter_page_setup_dialog): Added functions.
+	(sync_printer_with_devmode): 
+	(handle_devmode_changes): 
+	(Fmsprinter_get_settings): 
+	(Fmsprinter_select_settings): 
+	(Fmsprinter_apply_settings):
+	(allocate_devmode): 
+	(Fmsprinter_settings_copy): 
+	(Fmsprinter_settings_despecialize): 
+	(print_devmode): 
+	(finalize_devmode): 
+	(equal_devmode): 
+	(hash_devmode): Added functions
+	(syms_of_device_mswindows): Init devmode lrecord class.
+
+	* device.h: Added an exfun for find-device.
+
+	* event-msw.c (mswindows_wnd_proc): Do not update the cached
+	geometry; although, recreate the device compatible DC.
+
+	* frame-msw.c (mswindows_get_selected_frame_hwnd): Added.
+	(msprinter_init_frame_3):
+	(msprinter_frame_property): 
+	(msprinter_internal_frame_property_p):
+	(msprinter_frame_properties): 
+	(msprinter_set_frame_properties): Removed 'orientation and 'duplex
+	print job properties (will move to device settings).
+
+	* lisp.h: Added symbols.
+
+	* general.c (syms_of_general): Declared them.
+
+	* hash.c (string_hash): Added.
+
+	* lrecord.h (lrecord_type): Added devmode lrecord type.
+
+2000-07-02  Mike Sperber <mike@xemacs.org>
+
+	* s/freebsd.h (INTERRUPTIBLE_OPEN): open *is* interruptible on
+	FreeBSD 4.0.
+
+2000-06-07  MORIOKA Tomohiko  <tomo@etl.go.jp>
+
+	* doprnt.c (emacs_doprnt_1): Fix problem with %0XXd for a negative
+	integer.
+
+2000-06-07  MORIOKA Tomohiko  <tomo@urania.m17n.org>
+
+	* data.c (Fstring_to_number): Don't recognize floating point if
+	base is not 10.
+
+2000-06-22  Martin Buchholz  <martin@xemacs.org>
+
+	* glyphs-widget.c (tab_control_query_geometry):
+	(widget_query_geometry):
+	(button_query_geometry):
+	* glyphs.c (text_query_geometry):
+	Enforce type correctness.
+
+2000-06-18  Martin Buchholz  <martin@xemacs.org>
+
+	* s/decosf4-0.h (_etext): Use portable _etext instead of etext.
+	* s/decosf4-0.h (_edata): Use portable _edata instead of edata.
+
+2000-06-17  Martin Buchholz  <martin@xemacs.org>
+
+	* s/decosf4-0.h: Never #include "/usr/include/FOO.h" because this
+	conflicts with gcc's fixincluded version of FOO.h.
+
+	* glyphs.h (image_instance_geometry): Remove trailing `,'
+
+2000-06-08  Mike Alexander  <mta@arbortext.com>
+
+        (MAX_SHOVE_BUFFER_SIZE): Change to 512 to match stream buffer size
+        (shove_thread): Don't write the same output twice
+        (make_ntpipe_output_stream): Increase priority of shove thread
+        (ntpipe_shove_writer): Call SwitchToThread to give shove thread a
+        chance to run
+        (ntpipe_shove_closer): Don't delete the pipe until we're done with
+        it.
+
+2000-06-12  Ben Wing  <ben@xemacs.org>
+
+	* s\mingw32.h (sigset):
+	* s\windowsnt.h (sigset):
+	rename msw_ to mswindows_ for consistency with general convention.
+
+2000-06-12  Ben Wing  <ben@xemacs.org>
+
+	* console-msw.c:
+	* console-msw.c (mswindows_get_console_hwnd):
+	* console-msw.c (mswindows_ensure_console_allocated):
+	* console-msw.c (mswindows_hide_console):
+	* console-msw.c (mswindows_show_console):
+	* console-msw.c (mswindows_ensure_console_buffered):
+	* console-msw.c (mswindows_output_console_string):
+	* console-msw.c (mswindows_windows9x_p):
+	* console-msw.h:
+	* device-msw.c (mswindows_get_workspace_coords):
+	* device-msw.c (mswindows_device_system_metrics):
+	* dialog-msw.c (mswindows_popup_dialog_box):
+	* event-msw.c (mswindows_wnd_proc):
+	* frame-msw.c (mswindows_size_frame_internal):
+	* menubar-msw.c (mswindows_translate_menu_or_dialog_item):
+	* menubar-msw.c (displayable_menu_item):
+	* menubar-msw.c (mswindows_char_is_accelerator):
+	* nt.c:
+	* nt.c (mswindows_sigset):
+	* nt.c (mswindows_sigrelse):
+	* nt.c (mswindows_sigpause):
+	* nt.c (mswindows_raise):
+	* nt.c (timer_proc):
+	* ntproc.c:
+	* ntproc.c (find_child_console):
+	* ntproc.c (sys_kill):
+	* print.c:
+	* print.c (std_handle_out_external):
+	* process-nt.c (find_child_console):
+	* process-nt.c (send_signal_the_95_way):
+	* process-nt.c (ensure_console_window_exists):
+	* process-nt.c (nt_create_process):
+	* syssignal.h:
+	rename msw_ to mswindows_ for consistency with general convention.
+
+	* emacs.c:
+	* dumper.c:
+	include nt.h, not syswindows.h.
+
+	* nt.c (mswindows_fstat):
+	* nt.c (mswindows_stat):
+	prefix mswindows_ instead of attempting to directly override the
+	library functions.  fix declarations.
+	
+	* nt.h:
+	include syswindows.h.  move some sysdep.h stuff here.
+	
+	* ntheap.h:
+	include syswindows.h, not <windows.h>.
+
+	* ntplay.c:
+	clean up headers.
+	
+	* sysdep.c:
+	clean up headers.
+	
+	* sysdep.c (sys_fstat):
+	* sysdep.c (sys_stat):
+	call mswindows versions when appropriate.
+	
+	* sysdep.h:
+	move mswin decls to nt.h.
+	
+	* syswindows.h:
+	add long comment describing appropriate use of the various windows
+	headers.
+
+2000-06-11  Ben Wing  <ben@xemacs.org>
+
+	* device-x.c: Correct doc string for sixth arg of x-get-resource.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* Makefile.in.in (release):
+	Correction to make sure xemacs.exe always dumped when correct.
+	
+	* alloca.c:
+	* balloon_help.c:
+	[[[[3]]]]: Conditionalize on actual problem, not WINDOWSNT.
+	
+	* buffer.c (set_buffer_internal):
+	[[[[2]]]]: Remove HAVE_FEP code.
+
+	* buffer.c (init_initial_directory):
+	[3].
+	
+	* bytecode.c:
+	[[[[4]]]]: limits.h standardly included in lisp.h; remove from
+	individual files.
+	
+	* callproc.c:
+	* callproc.c (call_process_cleanup):
+	* callproc.c (Fold_call_process_internal):
+	* callproc.c (child_setup):
+	* callproc.c (getenv_internal):
+	* callproc.c (init_callproc):
+	* callproc.c (vars_of_callproc):
+	[[[[1]]]]: WINDOWSNT -> WIN32_NATIVE.
+	__CYGWIN32__ -> CYGWIN.
+	DOS_NT -> WIN32_NATIVE.
+	Remove MSDOS support/references, converting to WIN32_NATIVE
+	  where correct.
+	__MINGW32__ -> MINGW.
+	Fix windows.h includes.
+	Remove bogus HAVE_NTGUI.
+
+	* config.h.in:
+	[2].
+	
+	* console-msw.c:
+	mswindows_message_outputted added for use in allowing startup
+	errors on the console to be seen.
+	
+	* console-msw.c (msw_ensure_console_allocated):
+	* console-msw.c (msw_output_console_string):
+	* console-msw.c (DHEADER):
+	* console-msw.c (DOPAQUE_DATA):
+	* console-msw.c (DEVENT):
+	* console-msw.c (DCONS):
+	* console-msw.c (DCONSCDR):
+	* console-msw.c (DSTRING):
+	* console-msw.c (DVECTOR):
+	* console-msw.c (DSYMBOL):
+	* console-msw.c (DSYMNAME):
+	Fix warnings.
+	
+	* console-stream.c (stream_init_console):
+	Fix text/binary problems.
+	
+	* device-msw.c:
+	* device-msw.c (mswindows_finish_init_device):
+	* device-msw.c (mswindows_delete_device):
+	[1].
+	
+	* device.c (handle_asynch_device_change):
+	[3].
+	
+	* dgif_lib.c:
+	* dgif_lib.c (DGifOpenFileName):
+	* dgif_lib.c (DGifOpenFileHandle):
+	* dgif_lib.c (DGifGetLine):
+	* dgif_lib.c (DGifGetPixel):
+	Added config.h/lisp.h, fix up includes.
+	[1].
+	
+	* dired-msw.c:
+	[4].
+	
+	* dired.c:
+	* dired.c (file_name_completion):
+	* dired.c (Ffile_attributes):
+	* dired.c (syms_of_dired):
+	[1].
+	
+	* dumper.c:
+	* dumper.c (pdump_file_unmap):
+	* dumper.c (pdump_load):
+	[1].
+	
+	* editfns.c:
+	* editfns.c (Ftemp_directory):
+	* editfns.c (user_login_name):
+	* editfns.c (Fuser_real_login_name):
+	* editfns.c (get_home_directory):
+	[1].
+	
+	* elhash.c (finish_marking_weak_hash_tables):
+	[[[[5]]]]: Fix GCC warnings.
+	
+	* emacs.c:
+	* emacs.c (mswindows_handle_hardware_exceptions):
+	* emacs.c (make_arg_list_1):
+	* emacs.c (main_1):
+	* emacs.c (Fkill_emacs):
+	* emacs.c (Fdump_emacs):
+	[1].
+	Fix problems with nested crashes, add long comment.
+	
+	* event-Xt.c (init_event_Xt_late):
+	[1].
+	
+	* event-msw.c:
+	* event-msw.c (mswindows_dde_callback):
+	* event-msw.c (mswindows_handle_sticky_modifiers):
+	* event-msw.c (mswindows_wnd_proc):
+	[1].
+	[5].
+	
+	* events.c (character_to_event):
+	[1].
+	
+	* fileio.c:
+	* fileio.c (Ffile_name_directory):
+	* fileio.c (Ffile_name_nondirectory):
+	* fileio.c (directory_file_name):
+	* fileio.c (Fexpand_file_name):
+	* fileio.c (Fsubstitute_in_file_name):
+	* fileio.c (Ffile_name_absolute_p):
+	* fileio.c (check_executable):
+	* fileio.c (Ffile_readable_p):
+	* fileio.c (Ffile_accessible_directory_p):
+	* fileio.c (Ffile_modes):
+	* fileio.c (Funix_sync):
+	* fileio.c (vars_of_fileio):
+	[1]. [4].
+
+	[[[[7]]]]: Move CORRECT_DIR_SEPS to s\windowsnt.h.
+	
+	Expand getdefdir defn.
+	Fix bogus rename() comment.
+
+	[[[[6]]]]: Fix Windows includes w.r.t. removed nt\inc.  Attempt
+	to use standard XEmacs include files, e.g. sysfile.h, rather
+	than system-specific includes.
+	
+	* fns.c:
+	* fns.c (Fsubseq):
+	[5]. [6].
+	
+	* frame.c (vars_of_frame):
+	[1].
+	
+	* getloadavg.c:
+	* getloadavg.c (getloadavg):
+	[1]. [6].
+	#ifdef XEMACS not defined on Cygwin.  Remove this; no need for it.
+	(We don't use it elsewhere in the code; just add a comment.)
+	
+	* gif_io.c:
+	[6].
+	Add config.h.
+	
+	* glyphs-msw.c:
+	* glyphs-msw.c (mswindows_resource_instantiate):
+	[1].
+	
+	* glyphs-x.c (x_native_layout_instantiate):
+	[5].
+	
+	* gui-msw.c (Fmswindows_shell_execute):
+	[1].
+	
+	* insdel.c:
+	[4].
+	
+	* lisp.h:
+	[4]. [5].
+	
+	* lread.c (locate_file_in_directory_mapper):
+	[1].
+	
+	* lstream.c:
+	[4].
+	
+	* mem-limits.h:
+	* mem-limits.h (get_lim_data):
+	[1].
+	
+	* menubar-msw.c:
+	[4].
+	
+	* ndir.h:
+	[1].
+	
+	* nt.c:
+	* nt.c (getwd):
+	* nt.c (closedir):
+	* nt.c (rva_to_section):
+	* nt.c (mswindows_executable_type):
+	[1]. [6].
+	Fix closedir() defn.
+	
+	* nt.h:
+	[[[[8]]]]: *_OK defs moved to sysfile.h.
+	
+	* ntproc.c:
+	[6]. [7].
+	
+	* objects-x.c:
+	[4].
+	
+	* print.c:
+	* print.c (std_handle_out_external):
+	[1]. [4].
+	
+	* process-nt.c:
+	* process-nt.c (nt_create_process):
+	[6].
+	try to fix process quoting somewhat.
+	
+	* process-unix.c (unix_create_process):
+	[1].
+	
+	* process.c:
+	* process.c (vars_of_process):
+	Add Vnull_device.
+	
+	* process.h:
+	[1].
+	
+	* realpath.c:
+	* realpath.c (xrealpath):
+	[1].
+	
+	* redisplay-tty.c (init_tty_for_redisplay):
+	[3].
+	
+	* redisplay.c:
+	[4]. [6].
+	
+	* scrollbar-msw.c:
+	[4].
+	
+	* sheap.c:
+	* sheap.c (more_static_core):
+	* sheap.c (report_sheap_usage):
+	[5]. [6].
+	
+	* signal.c:
+	* signal.c (alarm_signal):
+	[1]. [6]. 
+	
+	* sound.c:
+	[6].
+	
+	* strftime.c:
+	* strftime.c (zone_name):
+	[1]. [5].
+	
+	* symsinit.h (init_sunpro):
+	[1].
+	
+	* syscommctrl.h:
+	commctrl.h not in Cygwin b20.1.
+	
+	* sysdep.c:
+	* sysdep.c (endif):
+	* sysdep.c (sys_subshell):
+	* sysdep.c (init_baud_rate):
+	* sysdep.c (emacs_get_tty):
+	* sysdep.c (emacs_set_tty):
+	* sysdep.c (tty_init_sys_modes_on_device):
+	* sysdep.c (init_system_name):
+	* sysdep.c (sys_open):
+	* sysdep.c (interruptible_open):
+	* sysdep.c (sys_fopen):
+	* sysdep.c (sys_mkdir):
+	* sysdep.c (sys_rename):
+	* sysdep.c (get_process_times_1):
+	[1]. [6].
+	
+	* sysdep.h:
+	[1].
+	
+	* sysdir.h:
+	* sysdir.h (DIRENTRY_NONEMPTY):
+	[1]. [6].
+	
+	* sysdll.c (dll_init):
+	* sysdll.h:
+	[1].
+		
+	* sysfile.h:
+	[1]. [6]. [8].
+	added text/binary defs.
+	
+	* sysfloat.h:
+	[1].
+	
+	* sysproc.h:
+	* sysproc.h (EDESTADDRREQ):
+	* sysproc.h (poll_fds_for_input):
+	[1]. [6].
+	
+	* syspwd.h:
+	[6].
+	
+	* syssignal.h:
+	[1].
+	
+	* systime.h:
+	[1]. [6].
+	
+	* systty.h:
+	[1].
+	
+	* syswindows.h:
+	[1].
+	Always define WIN32_LEAN_AND_MEAN.
+	
+	* unexcw.c (unexec):
+	[5].
+	
+	* unexec.c:
+	* unexec.c (copy_text_and_data):
+	* unexec.c (adjust_lnnoptrs):
+	[1].
+	
+	* unexnt.c:
+	* unexnt.c (_start):
+	[1].
+	
+2000-06-07  Ben Wing  <ben@xemacs.org>
+
+	* mule-mcpath.c, mule-mcpath.h: Removed.  Old, crufty code that
+	was used only as a model.  We've long since extracted any useful
+	logic or code out of this. (I just did an exhaustive search.)
+
+	* s\msdos.h: Removed.
+
+	* s\windows95.h: Removed.
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* s\cygwin32.h:
+	[1]. [5].
+	Don't use extern with fun defs.
+	
+	* s\mingw32.h:
+	[1]. [7].
+	Remove nt\inc include.
+	Remove getdisk, getdefdir. (The former is unused, the latter
+	expanded in fileio.h.)
+	
+	* s\windowsnt.h:
+	* s\windowsnt.h (WIN32_NATIVE):
+	* s\windowsnt.h (HAVE_STRCASECMP):
+	[1]. [7].
+	Add long comment about preprocessor changes.
+	Remove getdisk, getdefdir. (The former is unused, the latter
+	expanded in fileio.h.)
+
+2000-06-10  Ben Wing  <ben@xemacs.org>
+
+	* m\arm.h:
+	* m\delta.h:
+	* m\intel386.h:
+	* m\sequent.h:
+	* m\template.h:
+	* m\windowsnt.h:
+	[1].
+	Remove bogus/unused NO_SOCK_SIGIO.
+	
+2000-06-08  Hrvoje Niksic  <hniksic@iskon.hr>
+
+	* lisp.h (set_string_char): Call set_string_byte with a Bufbyte,
+	not an Emchar.
+
+2000-06-04  Mike Sperber <mike@xemacs.org>
+
+	* casetab.c (set_case_table): For `set-standard-case-table',
+	actually deposit the new case tables where the rest of XEmacs can
+	see them.
+
+2000-06-05  Yoshiki Hayashi <yoshiki@xemacs.org>
+
+	* data.c (Faset): Don't cast XCHAR() to unsigned char.
+
+2000-06-05  Ben Wing  <ben@xemacs.org>
+
+	* callproc.c (child_setup): Don't do close_load_descs() under
+	MS Windows.  Put in a comment explaining why.
+
+2000-05-28  Adrian Aichner  <aichner@ecf.teradyne.com>
+
+	* process-nt.c: Reverting patch "Fixing nt_create_process for MKS
+	Toolkit shell" which breaks `kill-compilation' on Windows NT
+	native, retaining STDERR handling improvements.
+
+2000-06-01  Andreas Jaeger  <aj@suse.de>
+
+	* s/s390.h: Support for S390, based on a patch by Martin
+	Schwidefsky <schwidefsky@de.ibm.com>.
+
+2000-05-30  Andy Piper  <andy@xemacs.org>
+
+	* window.c (allocate_window): 
+	(make_dummy_parent): 
+	(Fset_window_configuration): use new hashtable type.
+
+	* glyphs.h (IMAGE_UNSPECIFIED_GEOMETRY): 
+	(struct image_instantiator_methods): 
+	(struct Lisp_Image_Instance): make instance geometry signed.
+
+	* glyphs.c (instantiate_image_instantiator): 
+	(image_instance_query_geometry): 
+	(image_instance_layout): 
+	(image_instance_layout): 
+	(query_string_geometry): 
+	(text_query_geometry): 
+	(image_instantiate): 
+	(image_instantiate): 
+	(cache_subwindow_instance_in_frame_maybe): 
+	(subwindow_query_geometry): make instance geometry signed.
+
+	* glyphs-widget.c (widget_query_geometry): 
+	(widget_layout): 
+	(button_query_geometry): 
+	(tree_view_query_geometry): 
+	(tab_control_query_geometry): 
+	(layout_query_geometry): 
+	(layout_layout): 
+	(native_layout_layout): make instance geometry signed.
+
+2000-05-29  Olivier Galibert  <galibert@pobox.com>
+
+	* lisp.h: Add Qfull_assoc symbol and WEAK_LIST_FULL_ASSOC
+	constant.
+
+	* general.c (syms_of_general): Add Qfull_assoc symbol.
+
+	* data.c (finish_marking_weak_lists): Mark full-assoc lists
+	correctly.
+	(decode_weak_list_type): Decode full-assoc type.
+	(encode_weak_list_type): Encode full-assoc type.
+	(Fmake_weak_list): Update doc string.
+
+2000-05-30  Andy Piper  <andy@xemacs.org>
+
+	* elhash.h (hash_table_weakness): new KEY_VALUE weak hashtable.
+
+	* elhash.c (print_hash_table): new KEY_VALUE weak hashtable.
+	(decode_hash_table_weakness): ditto.
+	(Fhash_table_weakness): ditto.
+	(Fhash_table_type): ditto.
+	(finish_marking_weak_hash_tables): ditto.
+	(hash_table_weakness_validate): ditto.
+	(syms_of_elhash): ditto.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/src/Makefile.in.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/Makefile.in.in	Mon Aug 13 11:19:21 2007 +0200
@@ -138,6 +138,10 @@
 sheap_obj=sheap.o
 #endif
 
+#if defined(MINGW) || defined(CYGWIN)
+res_obj=xemacs_res.o
+#endif
+
 ## -Demacs is needed to make some files produce the correct version
 ## for use in Emacs.
 
@@ -191,7 +195,7 @@
  rangetab.o redisplay.o redisplay-output.o regex.o\
  search.o select.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
+ undo.o $(x_objs) widget.o window.o $(res_obj)
 
 obj_rtl = $(objs:.o=.c.rtl)
 
@@ -342,6 +346,7 @@
 		./${PROGNAME} -batch -vanilla -f list-load-path-shadows; fi; \
 		$(RM) SATISFIED; exit 0; fi; \
 	if test -f SATISFIED; then $(RM) SATISFIED; exit 1; fi; \
+	@$(RM) $@; \
 	$(RECURSIVE_MAKE) $@;
 #else
 	@$(RM) $@
@@ -689,6 +694,9 @@
 	$(CC) -c -Demacs $(sound_cflags) $(cflags) ${srcdir}/hpplay.c
 #endif /* HAVE_NATIVE_SOUND */
 
+xemacs_res.o: ${srcdir}/../nt/xemacs.rc
+	windres --include-dir ${srcdir}/../nt -i ${srcdir}/../nt/xemacs.rc -o $@
+
 ## System-specific programs to be made.
 ## ${other_files}, $(objects_system) and $(objects_machine)
 ## select which of these should be compiled.  */
--- a/src/alloca.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/alloca.c	Mon Aug 13 11:19:21 2007 +0200
@@ -86,7 +86,7 @@
 # endif
 #endif
 
-#ifndef WINDOWSNT
+#ifndef NULL
 #define	NULL	0
 #endif
 
@@ -103,7 +103,7 @@
 #ifndef emacs
 #define malloc xmalloc
 #endif
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 extern pointer malloc ();
 #else
 extern void *malloc();
--- a/src/balloon_help.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/balloon_help.c	Mon Aug 13 11:19:21 2007 +0200
@@ -44,7 +44,7 @@
 
 #include "balloon_help.h"
 
-#ifndef WINDOWSNT
+#ifndef max
 #define max(x,y) (x>y?x:y)
 #endif
 
--- a/src/buffer.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/buffer.c	Mon Aug 13 11:19:21 2007 +0200
@@ -84,6 +84,7 @@
 #ifdef REGION_CACHE_NEEDS_WORK
 #include "region-cache.h"
 #endif
+#include "select.h"     /* for select_notify_buffer_kill */
 #include "specifier.h"
 #include "syntax.h"
 #include "sysdep.h"	/* for getwd */
@@ -1220,15 +1221,13 @@
 
       /* Then run the hooks.  */
       run_hook (Qkill_buffer_hook);
-#ifdef HAVE_X_WINDOWS
-      /* If an X selection was in this buffer, disown it.
-	 We could have done this by simply adding this function to the
-	 kill-buffer-hook, but the user might mess that up.
-	 */
-      if (EQ (Vwindow_system, Qx))
-	call0 (intern ("xselect-kill-buffer-hook"));
-      /* #### generalize me! */
-#endif /* HAVE_X_WINDOWS */
+
+      /* Inform the selection code that a buffer just got killed.
+	 We do this in C because (a) it's faster, and (b) it needs
+         to access data internal to select.c that can't be seen from
+         Lisp (so the Lisp code would just call into C anyway. */
+      select_notify_buffer_kill (buf);
+      
       unbind_to (speccount, Qnil);
       UNGCPRO;
       b = XBUFFER (buf);        /* Hypothetical relocating GC. */
@@ -1481,20 +1480,6 @@
   current_buffer = b;
   invalidate_current_column ();   /* invalidate indentation cache */
 
-#ifdef HAVE_FEP
-  if (!noninteractive && initialized)
-    {
-      extern Lisp_Object Ffep_force_on (), Ffep_force_off (), Ffep_get_mode ();
-
-      old_buf->fep_mode = Ffep_get_mode ();
-
-      if (!NILP (current_buffer->fep_mode))
-	Ffep_force_on ();
-      else
-	Ffep_force_off ();
-  }
-#endif /* HAVE_FEP */
-
   if (old_buf)
     {
       /* Put the undo list back in the base buffer, so that it appears
@@ -3114,6 +3099,7 @@
   }
 }
 
+#ifndef WIN32_NATIVE
 /* Is PWD another name for `.' ? */
 static int
 directory_is_current_directory (Extbyte *pwd)
@@ -3133,23 +3119,29 @@
 	  && dotstat.st_dev == pwdstat.st_dev
 	  && pwd_internal_len < MAXPATHLEN);
 }
+#endif
 
 void
 init_initial_directory (void)
 {
   /* This function can GC */
 
+#ifndef WIN32_NATIVE
   Extbyte *pwd;
+#endif
 
   initial_directory[0] = 0;
 
   /* If PWD is accurate, use it instead of calling getcwd.  This is faster
      when PWD is right, and may avoid a fatal error.  */
+#ifndef WIN32_NATIVE
   if ((pwd = (Extbyte *) getenv ("PWD")) != NULL
       && directory_is_current_directory (pwd))
     strcpy (initial_directory, (char *) pwd);
-  else if (getcwd (initial_directory, MAXPATHLEN) == NULL)
-    fatal ("`getcwd' failed: %s\n", strerror (errno));
+  else
+#endif
+    if (getcwd (initial_directory, MAXPATHLEN) == NULL)
+      fatal ("`getcwd' failed: %s\n", strerror (errno));
 
   /* Make sure pwd is DIRECTORY_SEP-terminated.
      Maybe this should really use some standard subroutine
@@ -3164,16 +3156,8 @@
       }
   }
 
-  /* XEmacs change: store buffer's default directory
-     using preferred (i.e. as defined at compile-time)
-     directory separator. --marcpa */
-#ifdef DOS_NT
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-       else unixtodos_filename (s); \
-  } while (0)
-
-  CORRECT_DIR_SEPS(initial_directory);
+#ifdef CORRECT_DIR_SEPS
+  CORRECT_DIR_SEPS (initial_directory);
 #endif
 }
 
--- a/src/bytecode.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/bytecode.c	Mon Aug 13 11:19:21 2007 +0200
@@ -56,8 +56,6 @@
 #include "opaque.h"
 #include "syntax.h"
 
-#include <limits.h>
-
 EXFUN (Ffetch_bytecode, 1);
 
 Lisp_Object Qbyte_code, Qcompiled_functionp, Qinvalid_byte_code;
--- a/src/callproc.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/callproc.c	Mon Aug 13 11:19:21 2007 +0200
@@ -41,19 +41,19 @@
 #include "syssignal.h" /* Always include before systty.h */
 #include "systty.h"
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define _P_NOWAIT 1	/* from process.h */
 #include "nt.h"
 #endif
 
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 /* When we are starting external processes we need to know whether they
    take binary input (no conversion) or text input (\n is converted to
    \r\n).  Similarly for output: if newlines are written as \r\n then it's
    text process output, otherwise it's binary.  */
 Lisp_Object Vbinary_process_input;
 Lisp_Object Vbinary_process_output;
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 
 Lisp_Object Vshell_file_name;
 
@@ -74,7 +74,7 @@
 int synch_process_retcode;
 
 /* Clean up when exiting Fcall_process_internal.
-   On MSDOS, delete the temporary file on any kind of termination.
+   On Windows, delete the temporary file on any kind of termination.
    On Unix, kill the process and any children on termination by signal.  */
 
 /* Nonzero if this is termination due to exit.  */
@@ -113,7 +113,7 @@
     /* #### "c-G" -- need non-consing Single-key-description */
     message ("Waiting for process to die...(type C-g again to kill it instantly)");
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
     {
       HANDLE pHandle = OpenProcess (PROCESS_ALL_ACCESS, 0, pid);
       if (pHandle == NULL)
@@ -180,7 +180,7 @@
   Lisp_Object infile, buffer, current_dir, display, path;
   int fd[2];
   int filefd;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   HANDLE pHandle;
 #endif
   int pid;
@@ -349,13 +349,13 @@
     else if (STRINGP (error_file))
       {
 	fd_error = open ((const char *) XSTRING_DATA (error_file),
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 			 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
 			 S_IREAD | S_IWRITE
-#else  /* not DOS_NT */
+#else  /* not WIN32_NATIVE */
 			 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
 			 CREAT_MODE
-#endif /* not DOS_NT */
+#endif /* not WIN32_NATIVE */
 			 );
       }
 
@@ -369,7 +369,7 @@
       }
 
     fork_error = Qnil;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
     pid = child_setup (filefd, fd1, fd_error, new_argv,
                        (char *) XSTRING_DATA (current_dir));
     if (!INTP (buffer))
@@ -389,7 +389,7 @@
     /* Close STDERR into the parent process.  We no longer need it. */
     if (fd_error >= 0)
       close (fd_error);
-#else  /* not WINDOWSNT */
+#else  /* not WIN32_NATIVE */
     pid = fork ();
 
     if (pid == 0)
@@ -410,7 +410,7 @@
     if (fd_error >= 0)
       close (fd_error);
 
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 
     environ = save_environ;
 
@@ -424,7 +424,7 @@
   if (!NILP (fork_error))
     signal_error (Qfile_error, fork_error);
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   if (pid < 0)
     {
       if (fd[0] >= 0)
@@ -502,7 +502,7 @@
 	  break;
 
 #if 0
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
        /* Until we pull out of MULE things like
 	  make_decoding_input_stream(), we do the following which is
 	  less elegant. --marcpa */
@@ -542,7 +542,7 @@
 
     QUIT;
     /* Wait for it to terminate, unless it already has.  */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
     wait_for_termination (pHandle);
 #else
     wait_for_termination (pid);
@@ -602,7 +602,7 @@
    a decent error from within the child, this should be verified as an
    executable directory by the parent.  */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 int
 #else
 void
@@ -612,21 +612,38 @@
 {
   char **env;
   char *pwd;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   int cpid;
   HANDLE handles[4];
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #ifdef SET_EMACS_PRIORITY
   if (emacs_priority != 0)
     nice (- emacs_priority);
 #endif
 
-#if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT)
+  /* Under Windows, we are not in a child process at all, so we should
+     not close handles inherited from the parent -- we are the parent
+     and doing so will screw up all manner of things!  Similarly, most
+     of the rest of the cleanup done in this function is not done
+     under Windows.
+
+     #### This entire child_setup() function is an utter and complete
+     piece of shit.  I would rewrite it, at the very least splitting
+     out the Windows and non-Windows stuff into two completely
+     different functions; but instead I'm trying to make it go away
+     entirely, using the Lisp definition in process.el.  What's left
+     is to fix up the routines in event-msw.c (and in event-Xt.c and
+     event-tty.c) to allow for stream devices to be handled correctly.
+     There isn't much to do, in fact, and I'll fix it shortly.  That
+     way, the Lisp definition can be used non-interactively too. */
+#if !defined (NO_SUBPROCESSES) && !defined (WIN32_NATIVE)
   /* Close Emacs's descriptors that this process should not have.  */
   close_process_descs ();
 #endif /* not NO_SUBPROCESSES */
+#ifndef WIN32_NATIVE
   close_load_descs ();
+#endif
 
   /* Note that use of alloca is always safe here.  It's obvious for systems
      that do not have true vfork or that have true (stack) alloca.
@@ -721,10 +738,10 @@
     *new_env = 0;
   }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   prepare_standard_handles (in, out, err, handles);
   set_process_dir (current_dir);
-#else  /* not WINDOWSNT */
+#else  /* not WIN32_NATIVE */
   /* Make sure that in, out, and err are not actually already in
      descriptors zero, one, or two; this could happen if Emacs is
      started with its standard in, out, or error closed, as might
@@ -755,13 +772,13 @@
     for (fd=3; fd<=64; fd++)
       close (fd);
   }
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 
 #ifdef vipc
   something missing here;
 #endif /* vipc */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Spawn the child.  (See ntproc.c:Spawnve).  */
   cpid = spawnve (_P_NOWAIT, new_argv[0], (const char* const*)new_argv,
 		  (const char* const*)env);
@@ -770,7 +787,7 @@
     report_file_error ("Spawning child process", Qnil);
   reset_standard_handles (in, out, err, handles);
   return cpid;
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
   /* execvp does not accept an environment arg so the only way
      to pass this environment is to set environ.  Our caller
      is responsible for restoring the ambient value of environ.  */
@@ -779,7 +796,7 @@
 
   stdout_out ("Can't exec program %s\n", new_argv[0]);
   _exit (1);
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 }
 
 static int
@@ -797,12 +814,12 @@
       if (STRINGP (entry)
 	  && XSTRING_LENGTH (entry) > varlen
 	  && XSTRING_BYTE (entry, varlen) == '='
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  /* NT environment variables are case insensitive.  */
 	  && ! memicmp (XSTRING_DATA (entry), var, varlen)
-#else  /* not WINDOWSNT */
+#else  /* not WIN32_NATIVE */
 	  && ! memcmp (XSTRING_DATA (entry), var, varlen)
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 	  )
 	{
 	  *value    = XSTRING_DATA   (entry) + (varlen + 1);
@@ -875,10 +892,10 @@
 
   {
     /* Initialize shell-file-name from environment variables or best guess. */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
     const char *shell = egetenv ("COMSPEC");
     if (!shell) shell = "\\WINNT\\system32\\cmd.exe";
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
     const char *shell = egetenv ("SHELL");
     if (!shell) shell = "/bin/sh";
 #endif
@@ -914,7 +931,7 @@
 vars_of_callproc (void)
 {
   /* This function can GC */
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   DEFVAR_LISP ("binary-process-input", &Vbinary_process_input /*
 *If non-nil then new subprocesses are assumed to take binary input.
 */ );
@@ -924,7 +941,7 @@
 *If non-nil then new subprocesses are assumed to produce binary output.
 */ );
   Vbinary_process_output = Qnil;
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 
   DEFVAR_LISP ("shell-file-name", &Vshell_file_name /*
 *File name to load inferior shells from.
--- a/src/casetab.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/casetab.c	Mon Aug 13 11:19:21 2007 +0200
@@ -189,7 +189,8 @@
 set_case_table (Lisp_Object table, int standard)
 {
   Lisp_Object down, up, canon, eqv, tail = table;
-  struct buffer *buf = current_buffer;
+  struct buffer *buf =
+    standard ? XBUFFER(Vbuffer_defaults) : current_buffer;
 
   check_case_table (table);
 
@@ -242,19 +243,17 @@
       Vmirror_ascii_eqv_table = make_mirror_trt_table (eqv);
 #endif
     }
-  else
-    {
-      buf->downcase_table = down;
-      buf->upcase_table = up;
-      buf->case_canon_table = canon;
-      buf->case_eqv_table = eqv;
+  buf->downcase_table = down;
+  buf->upcase_table = up;
+  buf->case_canon_table = canon;
+  buf->case_eqv_table = eqv;
 #ifdef MULE
-      buf->mirror_downcase_table = make_mirror_trt_table (down);
-      buf->mirror_upcase_table = make_mirror_trt_table (up);
-      buf->mirror_case_canon_table = make_mirror_trt_table (canon);
-      buf->mirror_case_eqv_table = make_mirror_trt_table (eqv);
+  buf->mirror_downcase_table = make_mirror_trt_table (down);
+  buf->mirror_upcase_table = make_mirror_trt_table (up);
+  buf->mirror_case_canon_table = make_mirror_trt_table (canon);
+  buf->mirror_case_eqv_table = make_mirror_trt_table (eqv);
 #endif
-    }
+
   return table;
 }
 
--- a/src/cm.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/cm.c	Mon Aug 13 11:19:21 2007 +0200
@@ -33,14 +33,8 @@
 
 #define	EXPENSIVE 2000
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern char *tgoto (const char *cm, int hpos, int vpos);
-extern void tputs (const char *, int, void (*)(int));
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C char *tgoto (const char *cm, int hpos, int vpos);
+EXTERN_C int tputs (const char *, int, void (*)(int));
 
 static void cmgoto_for_real (struct console *c, int row, int col);
 
--- a/src/config.h.in	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/config.h.in	Mon Aug 13 11:19:21 2007 +0200
@@ -43,33 +43,6 @@
 #endif
 #endif /* C code */
 
-
-/* Use SMART_INCLUDE to generate #include statements with variable paths.
-
-   #### WARNING: NEVER EVER PUT A SPACE BETWEEN THE ARGUMENTS OF THE
-   `SMART_INCLUDE' MACRO: when the simple (direct version) is defined, you
-   would end up with a space in your header filename.
-
-   Since the effect of macro expansion in #include statements is underspecified
-   in the C standard, and rarely used in source code, different compilers need
-   different implementations of SMART_INCLUDE (e.g. gcc 2.5.8 and AIX xlc).
-*/
-#undef SMART_INCLUDE_INDIRECTIONS
-
-#if SMART_INCLUDE_INDIRECTIONS == 0
-# define SMART_INCLUDE(path,file) <path/file>
-#elif SMART_INCLUDE_INDIRECTIONS == 1
-# define GLUE_INCLUDE(path,file) <##path##/##file##>
-# define SMART_INCLUDE(path,file) GLUE_INCLUDE(path,file)
-#elif SMART_INCLUDE_INDIRECTIONS == 2
-# define GLUE_INCLUDE_2(path,file) <##path##/##file##>
-# define GLUE_INCLUDE_1(path,file) GLUE_INCLUDE_2(path,file)
-# define SMART_INCLUDE(path,file) GLUE_INCLUDE_1(path,file)
-#else
-# error SMART_INCLUDE_INDIRECTIONS was not properly defined by configure
-#endif
-
-
 /* Use this to add code in a structured way to FSF-maintained source
    files so as to make it obvious where XEmacs changes are. */
 #define XEMACS 1
@@ -420,16 +393,10 @@
 /* Does the library define ldap_parse_result () ? */
 #undef HAVE_LDAP_PARSE_RESULT
 
-/* Do we wish to link against the PostgreSQL RDBMS run-time library?
- */
+/* Do we have PostgreSQL RDBMS support? */
 #undef HAVE_POSTGRESQL
 #undef HAVE_POSTGRESQLV7
-#undef POSTGRES_H_PATH
-#if defined POSTGRES_H_PATH
-# define POSTGRES_INCLUDE(file) SMART_INCLUDE (POSTGRES_H_PATH,file)
-#else
-# define POSTGRES_INCLUDE(file) <file>
-#endif
+#undef LIBPQ_FE_H_FILE /* main PostgreSQL header file */
 
 /* Do you have the Xauth library present?  This will add some extra
    functionality to gnuserv. */
@@ -597,6 +564,7 @@
 #undef off_t
 #undef uid_t
 #undef gid_t
+#undef socklen_t
 
 /* If defined, use unions instead of ints.  A few systems (DEC Alpha)
    seem to require this, probably because something with the int
@@ -797,10 +765,6 @@
 #  define CANNA_PURESIZE 0
 #endif /* not CANNA */
 
-#if (defined (MSDOS) && defined (FEPCTRL)) || (defined (WIN32) && defined (USE_IME))
-#define HAVE_FEP
-#endif
-
 #if defined (HAVE_SOCKS) && !defined (DO_NOT_SOCKSIFY)
 #define accept Raccept
 #define bind Rbind
@@ -839,13 +803,20 @@
 # define INLINE_HEADER inline extern
 #endif
 
-#if defined (__cplusplus) && !defined (NOT_C_CODE)
+#ifndef NOT_C_CODE /* Actually means C or C++ */
+# if defined (__cplusplus)
 /* Avoid C++ keywords used as ordinary C identifiers */
-#define class c_class
-#define new   c_new
-#define this  c_this
-#define catch c_catch
-#endif /* C++ */
+#  define class c_class
+#  define new   c_new
+#  define this  c_this
+#  define catch c_catch
+#  define not   c_not
+
+#  define EXTERN_C extern "C"
+# else /* C code */
+#  define EXTERN_C extern
+# endif
+#endif /* C or C++ */
 
 /* Strictly speaking, only int or unsigned int are valid types in a
    bitfield.  In practice, we would like to use enums as bitfields.
--- a/src/console-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/console-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -83,7 +83,7 @@
   return 1;
 }
 
-static HWND msw_console_hwnd = 0;
+static HWND mswindows_console_hwnd = 0;
 
 #define KLUDGE_BUFSIZE 1024 /* buffer size for console window titles */
 
@@ -125,15 +125,15 @@
 } 
 
 HWND
-msw_get_console_hwnd (void)
+mswindows_get_console_hwnd (void)
 {
-  if (!msw_console_hwnd)
-    msw_console_hwnd = GetConsoleHwnd ();
-  return msw_console_hwnd;
+  if (!mswindows_console_hwnd)
+    mswindows_console_hwnd = GetConsoleHwnd ();
+  return mswindows_console_hwnd;
 }
 
-int
-msw_ensure_console_allocated (void)
+static int
+mswindows_ensure_console_allocated (void)
 {
   HWND fgwin = GetForegroundWindow ();
   /* stupid mswin api won't let you create the console window
@@ -174,15 +174,15 @@
 }
 
 void
-msw_hide_console (void)
+mswindows_hide_console (void)
 {
-  ShowWindow (msw_get_console_hwnd (), SW_HIDE);
+  ShowWindow (mswindows_get_console_hwnd (), SW_HIDE);
 }
 
 void
-msw_show_console (void)
+mswindows_show_console (void)
 {
-  HWND hwnd = msw_get_console_hwnd ();
+  HWND hwnd = mswindows_get_console_hwnd ();
   ShowWindow (hwnd, SW_SHOWNA);
 
   /* I tried to raise the window to the top without activating
@@ -195,41 +195,44 @@
 		SWP_NOACTIVATE);
 }
 
-static int msw_console_buffered = 0;
-HANDLE msw_console_buffer;
+static int mswindows_console_buffered = 0;
+HANDLE mswindows_console_buffer;
 
 static void
-msw_ensure_console_buffered (void)
+mswindows_ensure_console_buffered (void)
 {
-  if (!msw_console_buffered)
+  if (!mswindows_console_buffered)
     {
       COORD new_size;
 
       new_size.X = 80;
       new_size.Y = 1000;
-      msw_ensure_console_allocated ();
-      msw_console_buffer =
+      mswindows_ensure_console_allocated ();
+      mswindows_console_buffer =
 	CreateConsoleScreenBuffer (GENERIC_WRITE, 0, NULL,
 				   CONSOLE_TEXTMODE_BUFFER, NULL);
-      SetConsoleScreenBufferSize (msw_console_buffer, new_size);
-      SetConsoleActiveScreenBuffer (msw_console_buffer);
-      msw_console_buffered = 1;
+      SetConsoleScreenBufferSize (mswindows_console_buffer, new_size);
+      SetConsoleActiveScreenBuffer (mswindows_console_buffer);
+      mswindows_console_buffered = 1;
     }
 }
 
+int mswindows_message_outputted;
+
 int
-msw_output_console_string (CONST Extbyte *str, Extcount len)
+mswindows_output_console_string (CONST Extbyte *str, Extcount len)
 {
   DWORD num_written;
 
-  msw_ensure_console_buffered ();
-  msw_show_console ();
-  return WriteConsole (msw_console_buffer, str, len, &num_written, NULL);
+  mswindows_message_outputted = 1;
+  mswindows_ensure_console_buffered ();
+  mswindows_show_console ();
+  return WriteConsole (mswindows_console_buffer, str, len, &num_written, NULL);
 }
 
 /* Determine if running on Windows 9x and not NT */
 int
-msw_windows9x_p (void)
+mswindows_windows9x_p (void)
 {
   return GetVersion () & 0x80000000;
 }
@@ -242,54 +245,63 @@
  * Intended for use in the MSVC "Watch" window which doesn't like
  * the aborts that the error_check_foo() functions can make.
  */
+struct lrecord_header *DHEADER (Lisp_Object obj);
 struct lrecord_header *
 DHEADER (Lisp_Object obj)
 {
   return LRECORDP (obj) ? XRECORD_LHEADER (obj) : NULL;
 }
 
+void *DOPAQUE_DATA (Lisp_Object obj);
 void *
 DOPAQUE_DATA (Lisp_Object obj)
 {
   return OPAQUEP (obj) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL;
 }
 
+Lisp_Event *DEVENT (Lisp_Object obj);
 Lisp_Event *
 DEVENT (Lisp_Object obj)
 {
   return EVENTP (obj) ? XEVENT (obj) : NULL;
 }
 
+Lisp_Cons *DCONS (Lisp_Object obj);
 Lisp_Cons *
 DCONS (Lisp_Object obj)
 {
   return CONSP (obj) ? XCONS (obj) : NULL;
 }
 
+Lisp_Cons *DCONSCDR (Lisp_Object obj);
 Lisp_Cons *
 DCONSCDR (Lisp_Object obj)
 {
   return (CONSP (obj) && CONSP (XCDR (obj))) ? XCONS (XCDR (obj)) : 0;
 }
 
+Bufbyte *DSTRING (Lisp_Object obj);
 Bufbyte *
 DSTRING (Lisp_Object obj)
 {
   return STRINGP (obj) ? XSTRING_DATA (obj) : NULL;
 }
 
+Lisp_Vector *DVECTOR (Lisp_Object obj);
 Lisp_Vector *
 DVECTOR (Lisp_Object obj)
 {
   return VECTORP (obj) ? XVECTOR (obj) : NULL;
 }
 
+Lisp_Symbol *DSYMBOL (Lisp_Object obj);
 Lisp_Symbol *
 DSYMBOL (Lisp_Object obj)
 {
   return SYMBOLP (obj) ? XSYMBOL (obj) : NULL;
 }
 
+Bufbyte *DSYMNAME (Lisp_Object obj);
 Bufbyte *
 DSYMNAME (Lisp_Object obj)
 {
--- a/src/console-msw.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/console-msw.h	Mon Aug 13 11:19:21 2007 +0200
@@ -46,7 +46,7 @@
 #define XEMACS_CONTROL_CLASS "XEmacsControl"
 
 /*
- * Console
+ * Consoles
  */
 
 DECLARE_CONSOLE_TYPE (mswindows);
@@ -59,43 +59,64 @@
 DECLARE_CONSOLE_TYPE (msprinter);
 
 /*
- * Device
+ * Printer settings, aka devmode
+ */
+
+typedef struct Lisp_Devmode
+{
+  struct lcrecord_header header;
+  
+  /* Pointer to the DEVMODE structure */
+  DEVMODE* devmode;
+
+  /* Full printer name. It can be longer than devmode->dmDeviceName
+     can accomodate, so need to keep it separately */
+  char* printer_name;
+
+  /* Printer device this object is currently selected in, or Qnil
+     if not selected */
+  Lisp_Object device;
+
+} Lisp_Devmode;
+
+
+DECLARE_LRECORD (devmode, Lisp_Devmode);
+#define XDEVMODE(x) XRECORD (x, devmode, Lisp_Devmode)
+#define XSETDEVMODE(x, p) XSETRECORD (x, p, devmode)
+#define DEVMODEP(x) RECORDP (x, devmode)
+#define CHECK_DEVMODE(x) CHECK_RECORD (x, devmode)
+#define CONCHECK_DEVMODE(x) CONCHECK_RECORD (x, devmode)
+
+#define DEVMODE_SIZE(dm) ((dm)->dmSize + (dm)->dmDriverExtra)
+#define XDEVMODE_SIZE(x) ((x)->devmode ? DEVMODE_SIZE((x)->devmode) : 0)
+
+/*
+ * Devices
  */
 
 #define MSW_FONTSIZE (LF_FACESIZE*4+12)
 
 struct mswindows_device
 {
-  int logpixelsx, logpixelsy;
-  int planes, cells;
-  int horzres, vertres;		/* Size in pixels */
-  int horzsize, vertsize;	/* Size in mm */
-  int bitspixel;
   Lisp_Object fontlist;		/* List of strings, device fonts */
   HDC hcdc;			/* Compatible DC */
+  DWORD update_tick;		/* Used when device is modified through
+				   Windows mwssages, see WM_DISPLAYCHANGE
+				   in event-msw.c */
 };
 
 #define DEVICE_MSWINDOWS_DATA(d) DEVICE_TYPE_DATA (d, mswindows)
-#define DEVICE_MSWINDOWS_LOGPIXELSX(d) 	(DEVICE_MSWINDOWS_DATA (d)->logpixelsx)
-#define DEVICE_MSWINDOWS_LOGPIXELSY(d) 	(DEVICE_MSWINDOWS_DATA (d)->logpixelsy)
-#define DEVICE_MSWINDOWS_PLANES(d) 	(DEVICE_MSWINDOWS_DATA (d)->planes)
-#define DEVICE_MSWINDOWS_CELLS(d) 	(DEVICE_MSWINDOWS_DATA (d)->cells)
-#define DEVICE_MSWINDOWS_HORZRES(d) 	(DEVICE_MSWINDOWS_DATA (d)->horzres)
-#define DEVICE_MSWINDOWS_VERTRES(d) 	(DEVICE_MSWINDOWS_DATA (d)->vertres)
-#define DEVICE_MSWINDOWS_HORZSIZE(d) 	(DEVICE_MSWINDOWS_DATA (d)->horzsize)
-#define DEVICE_MSWINDOWS_VERTSIZE(d) 	(DEVICE_MSWINDOWS_DATA (d)->vertsize)
-#define DEVICE_MSWINDOWS_BITSPIXEL(d) 	(DEVICE_MSWINDOWS_DATA (d)->bitspixel)
-#define DEVICE_MSWINDOWS_FONTLIST(d) 	(DEVICE_MSWINDOWS_DATA (d)->fontlist)
-#define DEVICE_MSWINDOWS_HCDC(d)	(DEVICE_MSWINDOWS_DATA (d)->hcdc)
+#define DEVICE_MSWINDOWS_FONTLIST(d)    (DEVICE_MSWINDOWS_DATA (d)->fontlist)
+#define DEVICE_MSWINDOWS_HCDC(d)        (DEVICE_MSWINDOWS_DATA (d)->hcdc)
+#define DEVICE_MSWINDOWS_UPDATE_TICK(d) (DEVICE_MSWINDOWS_DATA (d)->update_tick)
 
 struct msprinter_device
 {
   HDC hdc, hcdc;		/* Printer and the comp. DCs */
   HANDLE hprinter;
+  char* name;
+  Lisp_Object devmode;
   Lisp_Object fontlist;
-  char* name;
-  DEVMODE *devmode, *devmode_mirror;
-  size_t devmode_size;
 };
 
 #define DEVICE_MSPRINTER_DATA(d) DEVICE_TYPE_DATA (d, msprinter)
@@ -105,20 +126,12 @@
 #define DEVICE_MSPRINTER_FONTLIST(d) 	(DEVICE_MSPRINTER_DATA (d)->fontlist)
 #define DEVICE_MSPRINTER_NAME(d) 	(DEVICE_MSPRINTER_DATA (d)->name)
 #define DEVICE_MSPRINTER_DEVMODE(d) 	(DEVICE_MSPRINTER_DATA (d)->devmode)
-#define DEVICE_MSPRINTER_DEVMODE_MIRROR(d) \
-	(DEVICE_MSPRINTER_DATA (d)->devmode_mirror)
-#define DEVICE_MSPRINTER_DEVMODE_SIZE(d) \
-	(DEVICE_MSPRINTER_DATA (d)->devmode_size)
 
 #define CONSOLE_TYPESYM_MSPRINTER_P(typesym) EQ (typesym, Qmsprinter)
 #define DEVICE_MSPRINTER_P(dev) CONSOLE_TYPESYM_MSPRINTER_P (DEVICE_TYPE (dev))
 #define CHECK_MSPRINTER_DEVICE(z) CHECK_DEVICE_TYPE (z, msprinter)
 #define CONCHECK_MSPRINTER_DEVICE(z) CONCHECK_DEVICE_TYPE (z, msprinter)
 
-/* Printer functions in device-msw.c */
-DEVMODE* msprinter_get_devmode_copy (struct device *d);
-void msprinter_apply_devmode (struct device *d, DEVMODE *devmode);
-
 /* Printer functions in frame-msw.c */
 void msprinter_start_page (struct frame *f);
 
@@ -141,7 +154,7 @@
   } while (0)
 
 /*
- * Frame
+ * Frames
  */
 typedef struct
 {
@@ -243,7 +256,7 @@
   int left_margin, top_margin,		/* All in twips */
     right_margin, bottom_margin;
   int charheight, charwidth;		/* As per proplist or -1 if not gven */
-  Lisp_Object orientation, duplex;	/* nil for printer's default */
+  int pix_left, pix_top;		/* Calculated in init_frame_*, VP offset */
   int job_started : 1;
   int page_started : 1;
 };
@@ -255,10 +268,10 @@
 #define FRAME_MSPRINTER_BOTTOM_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->bottom_margin)
 #define FRAME_MSPRINTER_JOB_STARTED(f)	 (FRAME_MSPRINTER_DATA (f)->job_started)
 #define FRAME_MSPRINTER_PAGE_STARTED(f)	 (FRAME_MSPRINTER_DATA (f)->page_started)
-#define FRAME_MSPRINTER_ORIENTATION(f)	 (FRAME_MSPRINTER_DATA (f)->orientation)
-#define FRAME_MSPRINTER_DUPLEX(f)	 (FRAME_MSPRINTER_DATA (f)->duplex)
 #define FRAME_MSPRINTER_CHARWIDTH(f)	 (FRAME_MSPRINTER_DATA (f)->charheight)
 #define FRAME_MSPRINTER_CHARHEIGHT(f)	 (FRAME_MSPRINTER_DATA (f)->charwidth)
+#define FRAME_MSPRINTER_PIXLEFT(f)	 (FRAME_MSPRINTER_DATA (f)->pix_left)
+#define FRAME_MSPRINTER_PIXTOP(f)	 (FRAME_MSPRINTER_DATA (f)->pix_top)
 
 /*
  * Events
@@ -286,6 +299,7 @@
 void mswindows_redraw_exposed_area (struct frame *f, int x, int y, 
 				    int width, int height);
 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest);
+HWND mswindows_get_selected_frame_hwnd (void);
 void mswindows_enqueue_magic_event (HWND hwnd, UINT msg);
 
 /* win32 DDE management library */
@@ -325,17 +339,17 @@
 extern Lisp_Object Vmswindows_frame_being_created;
 extern Lisp_Object mswindows_frame_being_created;
 
-void msw_get_workspace_coords (RECT *rc);
+void mswindows_get_workspace_coords (RECT *rc);
 
-HWND msw_get_console_hwnd (void);
-void msw_hide_console (void);
-void msw_show_console (void);
-int msw_output_console_string (CONST Extbyte *str, Extcount len);
+HWND mswindows_get_console_hwnd (void);
+void mswindows_hide_console (void);
+void mswindows_show_console (void);
+int mswindows_output_console_string (CONST Extbyte *str, Extcount len);
 
 Lisp_Object mswindows_enumerate_fonts (HDC hdc);
 
-int msw_char_is_accelerator (struct frame *f, Emchar ch);
-Bytecount msw_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
+int mswindows_char_is_accelerator (struct frame *f, Emchar ch);
+Bytecount mswindows_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
 					     Bytecount maxlen, Emchar *accel,
 					     Lisp_Object error_name);
 
@@ -348,7 +362,7 @@
 Lisp_Object mswindows_handle_gui_wm_command (struct frame* f,
 					     HWND ctrl, LPARAM id);
 
-int msw_windows9x_p (void);
+int mswindows_windows9x_p (void);
 
 
 void mswindows_output_last_error (char *frob);
--- a/src/console-stream.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/console-stream.c	Mon Aug 13 11:19:21 2007 +0200
@@ -69,7 +69,9 @@
     {
       CHECK_STRING (tty);
       stream_con->in = stream_con->out = stream_con->err =
-	fopen ((char *) XSTRING_DATA (tty), "r+");
+	/* #### We don't currently do coding-system translation on
+	   this descriptor. */
+	fopen ((char *) XSTRING_DATA (tty), READ_PLUS_TEXT);
       if (!stream_con->in)
 	error ("Unable to open tty %s", XSTRING_DATA (tty));
     }
--- a/src/console.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/console.h	Mon Aug 13 11:19:21 2007 +0200
@@ -91,13 +91,22 @@
   void (*delete_device_method) (struct device *);
   void (*mark_device_method) (struct device *);
   void (*asynch_device_change_method) (void);
-  Lisp_Object (*device_system_metrics_method) (struct device *, enum device_metrics);
+  Lisp_Object (*device_system_metrics_method) (struct device *,
+                                               enum device_metrics);
   unsigned int (*device_implementation_flags_method) (void);
-  Lisp_Object (*own_selection_method)(Lisp_Object selection_name, Lisp_Object selection_value);
-  void (*disown_selection_method)(Lisp_Object selection_name, Lisp_Object timeval);
-    Lisp_Object (*get_foreign_selection_method) (Lisp_Object selection_symbol,
-						 Lisp_Object target_type);
-  Lisp_Object (*selection_exists_p_method)(Lisp_Object selection_name);
+  Lisp_Object (*own_selection_method)(Lisp_Object selection_name,
+                                      Lisp_Object selection_value,
+                                      Lisp_Object how_to_add,
+                                      Lisp_Object selection_type);
+  void (*disown_selection_method)(Lisp_Object selection_name,
+                                  Lisp_Object timeval);
+  Lisp_Object (*get_foreign_selection_method) (Lisp_Object selection_symbol,
+                                               Lisp_Object target_type);
+  Lisp_Object (*selection_exists_p_method)(Lisp_Object selection_name,
+                                           Lisp_Object selection_type);
+  Lisp_Object (*available_selection_types_method)(Lisp_Object selection_name);
+  Lisp_Object (*register_selection_data_type_method)(Lisp_Object type_name);
+  Lisp_Object (*selection_data_type_name_method)(Lisp_Object type);
 
   /* frame methods */
   Lisp_Object *device_specific_frame_props;
--- a/src/data.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/data.c	Mon Aug 13 11:19:21 2007 +0200
@@ -770,7 +770,7 @@
     {
       CHECK_CHAR_COERCE_INT (newval);
       if (idx >= XSTRING_CHAR_LENGTH (array)) goto range_error;
-      set_string_char (XSTRING (array), idx, (unsigned char) XCHAR (newval));
+      set_string_char (XSTRING (array), idx, XCHAR (newval));
       bump_string_modiff (array);
     }
   else
@@ -1064,7 +1064,7 @@
     p++;
 
 #ifdef LISP_FLOAT_TYPE
-  if (isfloat_string (p))
+  if (isfloat_string (p) && b == 10)
     return make_float (atof (p));
 #endif /* LISP_FLOAT_TYPE */
 
@@ -1744,6 +1744,23 @@
 		}
 	      break;
 
+	    case WEAK_LIST_FULL_ASSOC:
+	      if (!CONSP (elem))
+		{
+		  /* just leave bogus elements there */
+		  need_to_mark_cons = 1;
+		  need_to_mark_elem = 1;
+		}
+	      else if (marked_p (XCAR (elem)) ||
+		       marked_p (XCDR (elem)))
+		{
+		  need_to_mark_cons = 1;
+		  /* We still need to mark elem and XCAR (elem);
+		     marking elem does both */
+		  need_to_mark_elem = 1;
+		}
+	      break;
+
 	    default:
 	      abort ();
 	    }
@@ -1884,6 +1901,7 @@
   if (EQ (symbol, Qold_assoc))	 return WEAK_LIST_ASSOC;  /* EBOLA ALERT! */
   if (EQ (symbol, Qkey_assoc))	 return WEAK_LIST_KEY_ASSOC;
   if (EQ (symbol, Qvalue_assoc)) return WEAK_LIST_VALUE_ASSOC;
+  if (EQ (symbol, Qfull_assoc))  return WEAK_LIST_FULL_ASSOC;
 
   signal_simple_error ("Invalid weak list type", symbol);
   return WEAK_LIST_SIMPLE; /* not reached */
@@ -1898,6 +1916,7 @@
     case WEAK_LIST_ASSOC:       return Qassoc;
     case WEAK_LIST_KEY_ASSOC:   return Qkey_assoc;
     case WEAK_LIST_VALUE_ASSOC: return Qvalue_assoc;
+    case WEAK_LIST_FULL_ASSOC:  return Qfull_assoc;
     default:
       abort ();
     }
@@ -1936,6 +1955,8 @@
 		and the car is not pointed to.
 `value-assoc'	Objects in the list disappear if they are conses
 		and the cdr is not pointed to.
+`full-assoc'	Objects in the list disappear if they are conses
+		and neither the car nor the cdr is pointed to.
 */
        (type))
 {
--- a/src/device-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/device-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -40,7 +40,11 @@
 #include "frame.h"
 #include "sysdep.h"
 
-#if !(defined (__CYGWIN32__) || defined(__MINGW32__))
+/* #### Andy, these includes might break cygwin compilation - kkm*/
+#include <commdlg.h>
+#include <winspool.h>
+
+#if !(defined (CYGWIN) || defined(MINGW))
 # include <objbase.h>	/* For CoInitialize */
 #endif
 
@@ -62,7 +66,10 @@
 Lisp_Object Vmswindows_get_true_file_attributes;
 
 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
+Lisp_Object Qdevmodep;
 
+static Lisp_Object allocate_devmode (DEVMODE* src_devmode, int do_copy,
+				     char* src_name, struct device *d);
 
 /************************************************************************/
 /*                               helpers                                */
@@ -99,7 +106,6 @@
 		index2 < 0 ? Qnil : make_int (GetDeviceCaps (hdc, index2)));
 }
 
-
 
 /************************************************************************/
 /*                          display methods                             */
@@ -119,20 +125,9 @@
   d->device_data = xnew_and_zero (struct mswindows_device);
   hdc = CreateCompatibleDC (NULL);
   assert (hdc!=NULL);
-  DEVICE_MSWINDOWS_LOGPIXELSX(d) =  GetDeviceCaps(hdc, LOGPIXELSX);
-  DEVICE_MSWINDOWS_LOGPIXELSY(d) =  GetDeviceCaps(hdc, LOGPIXELSY);
-  DEVICE_MSWINDOWS_PLANES(d) = GetDeviceCaps(hdc, PLANES);
-  /* #### SIZEPALETTE only valid if RC_PALETTE bit set in RASTERCAPS,
-     what should we return for a non-palette-based device? */
-  DEVICE_MSWINDOWS_CELLS(d) = GetDeviceCaps(hdc, SIZEPALETTE);
-  DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES);
-  DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES);
-  DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE);
-  DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE);
-  DEVICE_MSWINDOWS_BITSPIXEL(d) = GetDeviceCaps(hdc, BITSPIXEL);
+  DEVICE_MSWINDOWS_HCDC(d) = hdc;
   DEVICE_MSWINDOWS_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
-  
-  DEVICE_MSWINDOWS_HCDC(d) = hdc;
+  DEVICE_MSWINDOWS_UPDATE_TICK (d) = GetTickCount ();
 
   /* Register the main window class */
   wc.cbSize = sizeof (WNDCLASSEX);
@@ -176,7 +171,7 @@
   /* Initialize DDE management library and our related globals. We execute a
    * dde Open("file") by simulating a drop, so this depends on dnd support. */
 #ifdef HAVE_DRAGNDROP
-# if !(defined(__CYGWIN32__) || defined(__MINGW32__))
+# if !(defined(CYGWIN) || defined(MINGW))
   CoInitialize (NULL);
 # endif
 
@@ -206,17 +201,17 @@
   DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_service);
   DdeUninitialize (mswindows_dde_mlid);
 
-# if !(defined(__CYGWIN32__) || defined(__MINGW32__))
+# if !(defined(CYGWIN) || defined(MINGW))
   CoUninitialize ();
 # endif
 #endif
 
   DeleteDC (DEVICE_MSWINDOWS_HCDC(d));
-  free (d->device_data);
+  xfree (d->device_data);
 }
 
 void
-msw_get_workspace_coords (RECT *rc)
+mswindows_get_workspace_coords (RECT *rc)
 {
   SystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
 }
@@ -231,28 +226,32 @@
 mswindows_device_system_metrics (struct device *d,
 				 enum device_metrics m)
 {
+  const HDC hdc = DEVICE_MSWINDOWS_HCDC(d);
+
   switch (m)
     {
     case DM_size_device:
-      return Fcons (make_int (DEVICE_MSWINDOWS_HORZRES(d)),
-		    make_int (DEVICE_MSWINDOWS_VERTRES(d)));
+      return Fcons (make_int (GetDeviceCaps (hdc, HORZRES)),
+		    make_int (GetDeviceCaps (hdc, VERTRES)));
       break;
     case DM_device_dpi:
-      return Fcons (make_int (DEVICE_MSWINDOWS_LOGPIXELSX(d)),
-		    make_int (DEVICE_MSWINDOWS_LOGPIXELSY(d)));
+      return Fcons (make_int (GetDeviceCaps (hdc, LOGPIXELSX)),
+		    make_int (GetDeviceCaps (hdc, LOGPIXELSY)));
       break;
     case DM_size_device_mm:
-      return Fcons (make_int (DEVICE_MSWINDOWS_HORZSIZE(d)),
-		    make_int (DEVICE_MSWINDOWS_VERTSIZE(d)));
+      return Fcons (make_int (GetDeviceCaps (hdc, HORZSIZE)),
+		    make_int (GetDeviceCaps (hdc, VERTSIZE)));
       break;
     case DM_num_bit_planes:
       /* this is what X means by bitplanes therefore we ought to be
          consistent. num planes is always 1 under mswindows and
          therefore useless */
-      return make_int (DEVICE_MSWINDOWS_BITSPIXEL(d));
+      return make_int (GetDeviceCaps (hdc, BITSPIXEL));
       break;
     case DM_num_color_cells:
-      return make_int (DEVICE_MSWINDOWS_CELLS(d));
+      /* #### SIZEPALETTE only valid if RC_PALETTE bit set in RASTERCAPS,
+         what should we return for a non-palette-based device? */
+      return make_int (GetDeviceCaps (hdc, SIZEPALETTE));
       break;
 
       /*** Colors ***/
@@ -291,7 +290,7 @@
     case DM_size_workspace:
       {
 	RECT rc;
-	msw_get_workspace_coords (&rc);
+	mswindows_get_workspace_coords (&rc);
 	return Fcons (make_int (rc.right - rc.left),
 		      make_int (rc.bottom - rc.top));
       }
@@ -299,7 +298,7 @@
     case DM_offset_workspace:
       {
 	RECT rc;
-	msw_get_workspace_coords (&rc);
+	mswindows_get_workspace_coords (&rc);
 	return Fcons (make_int (rc.left), make_int (rc.top));
       }
 
@@ -335,7 +334,7 @@
 
 
 /************************************************************************/
-/*                          printer methods                             */
+/*                          printer helpers                             */
 /************************************************************************/
 
 static void
@@ -344,58 +343,119 @@
   signal_simple_error ("Failed to open printer", DEVICE_CONNECTION (d));
 }
 
-static void
-msprinter_init_device (struct device *d, Lisp_Object props)
+
+/* Helper function */
+static int
+msprinter_init_device_internal (struct device *d, char* printer_name)
 {
-  char* printer_name;
-
-  DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
-
-  CHECK_STRING (DEVICE_CONNECTION (d));
-
-  TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d),
-		      C_STRING_ALLOCA, printer_name,
-		      Qctext);
-
-  d->device_data = xnew_and_zero (struct msprinter_device);
-
   DEVICE_MSPRINTER_NAME(d) = xstrdup (printer_name);
 
   if (!OpenPrinter (printer_name, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
     {
       DEVICE_MSPRINTER_HPRINTER (d) = NULL;
-      signal_open_printer_error (d);
+      return 0;
     }
 
   DEVICE_MSPRINTER_HDC (d) = CreateDC ("WINSPOOL", printer_name,
 				       NULL, NULL);
   if (DEVICE_MSPRINTER_HDC (d) == NULL)
-    signal_open_printer_error (d);
+    return 0;
 
   DEVICE_MSPRINTER_HCDC(d) =
     CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d));
 
-  /* Determinie DEVMODE size and store the default DEVMODE */
-  DEVICE_MSPRINTER_DEVMODE_SIZE(d) =
-    DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
-			printer_name, NULL, NULL, 0);
-  if (DEVICE_MSPRINTER_DEVMODE_SIZE(d) <= 0)
-    signal_open_printer_error (d);
+  DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
+		      * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
+		      > 1) ? Qcolor : Qmono;
+  return 1;
+}
+
+static void
+msprinter_delete_device_internal (struct device *d)
+{
+  if (DEVICE_MSPRINTER_HPRINTER (d))
+    ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
+  if (DEVICE_MSPRINTER_HDC (d))
+    DeleteDC (DEVICE_MSPRINTER_HDC (d));
+  if (DEVICE_MSPRINTER_HCDC (d))
+    DeleteDC (DEVICE_MSPRINTER_HCDC (d));
+  if (DEVICE_MSPRINTER_NAME (d))
+    xfree (DEVICE_MSPRINTER_NAME (d));
+
+  DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
+}
 
-  DEVICE_MSPRINTER_DEVMODE(d) =
-    (DEVMODE*) xmalloc (DEVICE_MSPRINTER_DEVMODE_SIZE(d));
-  DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
-		      printer_name, DEVICE_MSPRINTER_DEVMODE(d),
-		      NULL, DM_OUT_BUFFER);
+static int msprinter_reinit_device (struct device *d, char* devname)
+{
+  msprinter_delete_device_internal (d);
+  return msprinter_init_device_internal (d, devname);
+}
+
+
+/************************************************************************/
+/*                          printer methods                             */
+/************************************************************************/
+
+static void
+msprinter_init_device (struct device *d, Lisp_Object props)
+{
+  char* printer_name;
+  DEVMODE *pdm;
+  size_t dm_size;
+
+  d->device_data = xnew_and_zero (struct msprinter_device);
+
+  DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
+  DEVICE_MSPRINTER_DEVMODE(d) = Qnil;
 
   /* We do not use printer fon list as we do with the display
      device. Rather, we allow GDI to pick the closest match to the
      display font. */
   DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
 
-  DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
-		      * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
-		      > 1) ? Qcolor : Qmono;
+  CHECK_STRING (DEVICE_CONNECTION (d));
+
+  TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d),
+		      C_STRING_ALLOCA, printer_name,
+		      Qmswindows_tstr);
+
+  if (!msprinter_init_device_internal (d, printer_name))
+    signal_open_printer_error (d);
+    
+  /* Determinie DEVMODE size and store the default DEVMODE */
+  dm_size = DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
+				printer_name, NULL, NULL, 0);
+  if (dm_size <= 0)
+    signal_open_printer_error (d);
+
+  pdm = (DEVMODE*) xmalloc (dm_size);
+  DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
+		      printer_name, pdm,
+		      NULL, DM_OUT_BUFFER);
+
+  assert (DEVMODE_SIZE (pdm) <= dm_size);
+
+  DEVICE_MSPRINTER_DEVMODE(d) = 
+    allocate_devmode (pdm, 0, printer_name, d);
+
+}
+
+static void
+msprinter_delete_device (struct device *d)
+{
+  if (d->device_data)
+    {
+      msprinter_delete_device_internal (d);
+
+      /* Disassociate the selected devmode with the device */
+      if (!NILP (DEVICE_MSPRINTER_DEVMODE (d)))
+	{
+	  XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d))->device = Qnil;
+	  DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
+	}
+
+      xfree (d->device_data);
+    }
 }
 
 static Lisp_Object
@@ -434,31 +494,10 @@
 }
 
 static void
-msprinter_delete_device (struct device *d)
-{
-  if (d->device_data)
-    {
-      if (DEVICE_MSPRINTER_HPRINTER (d))
-	ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
-      if (DEVICE_MSPRINTER_HDC (d))
-	DeleteDC (DEVICE_MSPRINTER_HDC (d));
-      if (DEVICE_MSPRINTER_HCDC (d))
-	DeleteDC (DEVICE_MSPRINTER_HCDC (d));
-      if (DEVICE_MSPRINTER_NAME (d))
-	free (DEVICE_MSPRINTER_NAME (d));
-      if (DEVICE_MSPRINTER_DEVMODE (d))
-	free (DEVICE_MSPRINTER_DEVMODE (d));
-      if (DEVICE_MSPRINTER_DEVMODE_MIRROR (d))
-	free (DEVICE_MSPRINTER_DEVMODE_MIRROR (d));
-
-      free (d->device_data);
-    }
-}
-
-static void
 msprinter_mark_device (struct device *d)
 {
   mark_object (DEVICE_MSPRINTER_FONTLIST (d));
+  mark_object (DEVICE_MSPRINTER_DEVMODE (d));
 }
 
 static unsigned int
@@ -469,60 +508,644 @@
 	  | XDEVIMPF_NO_AUTO_REDISPLAY
 	  | XDEVIMPF_FRAMELESS_OK );
 }
-
 
 /************************************************************************/
-/*                      printer external functions                      */
+/*                      printer Lisp subroutines                        */
 /************************************************************************/
 
-/* 
- * Return a copy of default DEVMODE. The copy returned is in
- * a static buffer which will be overwritten by next call.
- */
-DEVMODE*
-msprinter_get_devmode_copy (struct device *d)
+static void
+global_free_2_maybe (HGLOBAL hg1, HGLOBAL hg2)
+{
+  if (hg1 != NULL)
+    GlobalFree (hg1);
+  if (hg2 != NULL)
+    GlobalFree (hg2);
+}
+
+static HGLOBAL
+devmode_to_hglobal (Lisp_Devmode *ldm)
+{
+  HGLOBAL hg = GlobalAlloc (GHND, XDEVMODE_SIZE (ldm));
+  memcpy (GlobalLock (hg), ldm->devmode, XDEVMODE_SIZE (ldm));
+  GlobalUnlock (hg);
+  return hg;
+}
+
+/* Returns 0 if the printer has been deleted due to a fatal I/O error,
+   1 otherwise. */
+static int
+sync_printer_with_devmode (struct device* d, DEVMODE* devmode_in,
+			   DEVMODE* devmode_out, char* devname)
 {
-  assert (DEVICE_MSPRINTER_P (d));
+  /* Change connection if the device changed */
+  if (devname != NULL
+      && stricmp (devname, DEVICE_MSPRINTER_NAME(d)) != 0)
+    {
+      Lisp_Object new_connection = build_ext_string (devname, Qmswindows_tstr);
+      struct gcpro gcpro1;
+
+      GCPRO1 (new_connection);
+      DEVICE_CONNECTION (d) = Qnil;
+      if (!NILP (Ffind_device (new_connection, Qmsprinter)))
+	{
+	  /* We are in trouble - second msprinter for the same device.
+	     Nothing wrong on the Windows side, just forge a unique
+	     connection name. Use the memory address of d as a unique
+	     suffix. */
+	  char* new_connext = alloca (strlen (devname + 11));
+	  sprintf (new_connext, "%s:%X", devname, d->header.uid);
+	  new_connection = build_ext_string (devname, Qmswindows_tstr);
+	}
+      DEVICE_CONNECTION (d) = new_connection;
+      UNGCPRO;
+
+      /* Reinitialize printer. The device can pop off in process */
+      if (!msprinter_reinit_device (d, devname))
+	{
+	  /* Kaboom! */
+	  delete_device_internal (d, 1, 0, 1);
+	  return 0;
+	}
+    }
+
+  /* Apply the new devmode to the printer */
+  DocumentProperties (NULL,
+		      DEVICE_MSPRINTER_HPRINTER(d),
+		      DEVICE_MSPRINTER_NAME(d),
+		      devmode_out, devmode_in,
+		      DM_IN_BUFFER | DM_OUT_BUFFER);
 
-  if (DEVICE_MSPRINTER_DEVMODE_MIRROR(d) == NULL)
-    DEVICE_MSPRINTER_DEVMODE_MIRROR(d) = 
-      (DEVMODE*) xmalloc (DEVICE_MSPRINTER_DEVMODE_SIZE(d));
+  /* #### ResetDC fails sometimes, Bill only knows why.
+     The solution below looks more like a workaround to me,
+     although it might be fine. --kkm */
+  if (ResetDC (DEVICE_MSPRINTER_HDC (d), devmode_out) == NULL)
+    {
+      DeleteDC (DEVICE_MSPRINTER_HDC (d));
+      DEVICE_MSPRINTER_HDC (d) =
+	CreateDC ("WINSPOOL", DEVICE_MSPRINTER_NAME(d), NULL, devmode_out);
+    }
+ 
+  return 1;
+}
+
+static void
+handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode)
+{
+  DEVNAMES* devnames = (DEVNAMES*) GlobalLock (hDevNames);
+  char *new_name = devnames ? (char*)devnames + devnames->wDeviceOffset : NULL;
+  DEVMODE* devmode = (DEVMODE*) GlobalLock (hDevMode);
+
+  /* Size and name may have changed */
+  ldm->devmode = xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
+  if (new_name)
+    {
+      if (ldm->printer_name)
+	xfree (ldm->printer_name);
+      ldm->printer_name = xstrdup (new_name);
+    }
 
-  memcpy (DEVICE_MSPRINTER_DEVMODE_MIRROR(d),
-	  DEVICE_MSPRINTER_DEVMODE(d),
-	  DEVICE_MSPRINTER_DEVMODE_SIZE(d));
+  if (!NILP (ldm->device))
+    {
+      /* Apply the new devmode to the printer and get a compete one back */
+      struct device *d = XDEVICE (ldm->device);
+      if (!sync_printer_with_devmode (d, devmode, ldm->devmode, new_name))
+	{
+	  global_free_2_maybe (hDevNames, hDevMode);
+	  error ("Printer device initialization I/O error, device deleted.");
+	}
+    }
+  else
+    {
+      /* Just copy the devmode structure */
+      memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode));
+    }
+}
 
-  return DEVICE_MSPRINTER_DEVMODE_MIRROR(d);
+static void
+ensure_not_printing (struct device *d)
+{
+  if (!NILP (DEVICE_FRAME_LIST (d)))
+  {
+    Lisp_Object device;
+    XSETDEVICE (device, d);
+    signal_simple_error ("Cannot change settings while print job is active",
+			 device);
+  }
+}
+
+static Lisp_Devmode *
+decode_devmode (Lisp_Object dev)
+{
+  if (DEVMODEP (dev))
+    return XDEVMODE (dev);
+  else
+    {
+      struct device* d = decode_device (dev);
+      Lisp_Object device;
+      XSETDEVICE (device, d);
+      CHECK_MSPRINTER_DEVICE (device);
+      ensure_not_printing (d);
+      return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
+    }
 }
 
 /*
- * Apply settings from the DEVMODE. The settings are considered
- * incremental to the default DEVMODE, so that changes in the
- * passed structure supercede parameters of the printer.
- *
- * The passed structure is overwritten by the fuction call;
- * complete printer settings are returned.
+ * DEV can be either a printer or devmode
+ * PRINT_P is non-zero for the Print dialog, zero for the
+ *         Page Setup dialog
  */
-void
-msprinter_apply_devmode (struct device *d, DEVMODE *devmode)
+static Lisp_Object
+print_dialog_worker (Lisp_Object dev, int print_p)
+{
+  Lisp_Devmode *ldm = decode_devmode (dev);
+  PRINTDLG pd;
+
+  memset (&pd, 0, sizeof (pd));
+  pd.lStructSize = sizeof (pd);
+  pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
+  pd.hDevMode = devmode_to_hglobal (ldm);
+  pd.Flags = (PD_NOSELECTION | PD_USEDEVMODECOPIESANDCOLLATE
+	      | (print_p ? 0 : PD_PRINTSETUP));
+  pd.nMinPage = 0;
+  pd.nMaxPage = 0xFFFF;
+
+  if (!PrintDlg (&pd))
+    {
+      global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+      return Qnil;
+    }
+
+  handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
+
+  /* Finally, build the resulting plist */
+  {
+    Lisp_Object result = Qnil;
+    struct gcpro gcpro1;
+    GCPRO1 (result);
+
+    /* Do consing in reverse order.
+       Number of copies */
+    if (print_p)
+      result = Fcons (Qcopies, Fcons (make_int (pd.nCopies), result));
+
+    /* Page range */
+    if (print_p && (pd.Flags & PD_PAGENUMS))
+      {
+	result = Fcons (Qto_page, Fcons (make_int (pd.nToPage), result));
+	result = Fcons (Qfrom_page, Fcons (make_int (pd.nFromPage), result));
+      }
+
+    /* Device name */
+    result = Fcons (Qname,
+		    Fcons (build_ext_string (ldm->printer_name,
+					     Qmswindows_tstr),
+			   result));
+    UNGCPRO;
+
+    global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+    return result;
+  }
+}
+
+DEFUN ("msprinter-print-setup-dialog", Fmsprinter_print_setup_dialog, 1, 1, 0, /*
+Invoke Windows standard Printer Setup dialog.
+This dialog is usually invoked when the user selects the Printer Setup
+command.
+
+DEVICE must be either an 'msprinter device, or a printer settings
+object. The function brings up the Printer Setup dialog, where the user
+can select a different printer and/or change printer options.
+Connection name can change as a result of selecting a different printer
+device.  If a printer is specified, then changes are stored into the
+settings object currently selected into that printer.  If a settings
+object is supplied, then changes are recorded into it, and, it it is
+selected into a printer, then changes are propagated to that printer
+too.
+
+Return value is nil if the user has canceled the dialog.  Otherwise, it
+is a new plist, with the following properties:
+  name       Printer device name, even if unchanged by the user.
+
+The printer device is destroyed and an error is signaled if new printer
+is selected by the user, but cannot be initialized.
+
+See also `msprinter-print-dialog' and `msprinter-page-setup-dialog'.
+*/
+	(device))
+{
+  return print_dialog_worker (device, 0);
+}
+
+DEFUN ("msprinter-print-dialog", Fmsprinter_print_dialog, 1, 1, 0, /*
+Invoke Windows standard Print dialog.
+This dialog is usually invoked when the user selects the Print command.
+After the user presses OK, the program should start actual printout.
+
+DEVICE must be either an 'msprinter device, or a printer settings
+object. The function brings up the Print dialog, where the user can
+select a different printer and/or change printer options. Connection
+name can change as a result of selecting a different printer device.  If
+a printer is specified, then changes are stored into the settings object
+currently selected into that printer.  If a settings object is supplied,
+then changes are recorded into it, and, it it is selected into a
+printer, then changes are propagated to that printer 
+too.
+
+Return value is nil if the user has canceled the dialog.  Otherwise, it
+is a new plist, with the following properties:
+  name       Printer device name, even if unchanged by the user.
+  from-page  First page to print, 1-based. If not specified by the user,
+             then this value is not included in the plist.
+  to-page    Last page to print, inclusive, 1-based. If not specified by
+             the user, then this value is not included in the plist.
+  copies     Number of copies to print.  Always returned.
+
+The DEVICE is destroyed and an error is signaled in case of
+initialization problem with the new printer.
+
+See also `msprinter-setup-print-dialog' and
+`msprinter-page-setup-dialog'.
+*/
+	(device))
 {
-  assert (DEVICE_MSPRINTER_P (d));
+  return print_dialog_worker (device, 1);
+}
+
+
+static int
+plist_get_margin (Lisp_Object plist, Lisp_Object prop)
+{
+  Lisp_Object val = Fplist_get (plist, prop, make_int (1440));
+  if (!INTP (val))
+    signal_simple_error ("Margin value must be an integer", val);
+
+  return MulDiv (XINT (val), 100, 144);
+}
+
+static Lisp_Object
+plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
+{
+  Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 2450 : 100));
+  return Fcons (prop, Fcons (val, plist));
+}
+
+DEFUN ("msprinter-page-setup-dialog", Fmsprinter_page_setup_dialog, 1, 2, 0, /*
+Invoke Windows standard Page Setup dialog.
+This dialog is usually invoked in response to Page Setup command, and
+used to chose such parameters as page orientation, print margins etc.
+Note that this dialog contains the "Printer" button, which invokes
+Printer Setup dialog (see `msprinter-print-setup-dialog') so that the
+user can update the printer options or even select a different printer
+as well.
+
+DEVICE must be either an 'msprinter device, or a printer settings
+object. The function brings up the Page Setup dialog, where the user
+can select a different printer and/or change printer options.
+Connection name can change as a result of selecting a different printer
+device.  If a printer is specified, then changes are stored into the
+settings object currently selected into that printer.  If a settings
+object is supplied, then changes are recorded into it, and, it it is
+selected into a printer, then changes are propagated to that printer
+too.
+
+PLIST is a plist of job properties;
+see `default-msprinter-frame-plist' for the complete list.  The plist
+is used to initialize the dialog.
+
+Return value is nil if the user has canceled the dialog.  Otherwise,
+it is a new plist, containing the new list of properties.
+
+The DEVICE is destroyed and an error is signaled in case of
+initialization problem with the new printer.
+
+See also `msprinter-print-setup-dialog' and `msprinter-print-dialog'.
+*/
+       (device, plist))
+{
+  Lisp_Devmode *ldm = decode_devmode (device);
+  PAGESETUPDLG pd;
+
+  memset (&pd, 0, sizeof (pd));
+  pd.lStructSize = sizeof (pd);
+  pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
+  pd.Flags = PSD_MARGINS;
+  pd.rtMargin.left   = plist_get_margin (plist, Qleft_margin);
+  pd.rtMargin.top    = plist_get_margin (plist, Qtop_margin);
+  pd.rtMargin.right  = plist_get_margin (plist, Qright_margin);
+  pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin);
+  pd.hDevMode = devmode_to_hglobal (ldm);
+
+  if (!PageSetupDlg (&pd))
+    {
+      global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+      return Qnil;
+    }
+
+  if (pd.hDevMode)
+    handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
+
+  /* Finally, build the resulting plist */
+  {
+    Lisp_Object result = Qnil;
+    int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS;
+    result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom, mm_p);
+    result = plist_set_margin (result, Qright_margin, pd.rtMargin.right, mm_p);
+    result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p);
+    result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p);
+    return result;
+  }
+}
+
+DEFUN ("msprinter-get-settings", Fmsprinter_get_settings, 1, 1, 0, /*
+Return the settings object currently used by DEVICE.
+The object returned is not a copy, but rather a pointer to the
+original one. Use `msprinter-settings-copy' to create a copy of it.
+*/
+	(device))
+{
+  struct device *d = decode_device (device);
+  XSETDEVICE (device, d);
+  CHECK_MSPRINTER_DEVICE (device);
+  return DEVICE_MSPRINTER_DEVMODE (d);
+}
+
+DEFUN ("msprinter-select-settings", Fmsprinter_select_settings, 2, 2, 0, /*
+Select SETTINGS object into a DEVICE.
+The settings from the settings object are immediately applied to the
+printer, possibly changing even the target printer itself, and all
+future changes are applied synchronously to the printer device and the
+selected printer object, until a different settings object is selected
+into the same printer.
+
+A settings object can be selected to no more than one printer at a time.
+
+If the supplied settings object is not specialized, it is specialized
+for the printer immediately upon selection. The object can be
+despecialized after it is unselected by calling the function
+`msprinter-settings-despecialize'. 
+
+Return value is the previously selected settings object.
+*/
+	(device, settings))
+{
+  Lisp_Devmode *ldm;
+  struct device *d = decode_device (device);
+
+  struct gcpro gcpro1;
+  GCPRO1 (settings);
 
-  DocumentProperties (NULL,
-		      DEVICE_MSPRINTER_HPRINTER(d),
-		      DEVICE_MSPRINTER_NAME(d),
-		      devmode, devmode,
-		      DM_IN_BUFFER | DM_OUT_BUFFER);
+  XSETDEVICE (device, d);
+  CHECK_MSPRINTER_DEVICE (device);
+  CHECK_DEVMODE (settings);
+  ldm = XDEVMODE (settings);
+
+  if (!NILP (ldm->device))
+    signal_simple_error ("The object is currently selected into a device",
+			 settings);
+
+  /* If the object being selected is de-specialized, then its
+     size is perhaps not enough to receive the new devmode. We can ask
+     for printer's devmode size here, because despecialized settings
+     cannot force switching to a different printer, as they supply no
+     printer name at all. */
+  if (ldm->printer_name == NULL)
+    {
+      size_t dm_size =
+	DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
+			    DEVICE_MSPRINTER_NAME(d), NULL, NULL, 0);
+      if (dm_size <= 0)
+	signal_simple_error ("Unable to specialize settings, printer error",
+			     device);
+
+      assert (XDEVMODE_SIZE (ldm) <= dm_size);
+      ldm->devmode = xrealloc (ldm->devmode, dm_size);
+    }
+
+  /* If we bail out on signal here, no damage is done, except that
+     the stirage for the DEVMODE structure might be reallocated to
+     hold a larger one - not a big deal */
+  if (!sync_printer_with_devmode (d, ldm->devmode, ldm->devmode,
+				  ldm->printer_name))
+    error ("Printer device initialization I/O error, device deleted.");
+
+  if (ldm->printer_name == NULL)
+    ldm->printer_name = xstrdup (DEVICE_MSPRINTER_NAME(d));
+
+  {
+    Lisp_Object old_mode = DEVICE_MSPRINTER_DEVMODE (d);
+    ldm->device = device;
+    XDEVMODE (old_mode)->device = Qnil;
+    DEVICE_MSPRINTER_DEVMODE (d) = settings;
+    UNGCPRO;
+    return old_mode;
+  }
+}
+
+DEFUN ("msprinter-apply-settings", Fmsprinter_apply_settings, 2, 2, 0, /*
+Apply settings from a SETTINGS object to a 'msprinter DEVICE.
+The settings from the settings object are immediately applied to the
+printer, possibly changing even the target printer itself. The SETTING
+object is not modified, unlike `msprinter-select-settings', and the
+supplied object is not changed.  The changes are immediately recorded
+into the settings object which is currently selected into the printer
+device.
+
+Return value is the currently selected settings object.
+*/
+	(device, settings))
+{
+  Lisp_Devmode *ldm_current, *ldm_new;
+  struct device *d = decode_device (device);
+
+  struct gcpro gcpro1;
+  GCPRO1 (settings);
+
+  XSETDEVICE (device, d);
+  CHECK_MSPRINTER_DEVICE (device);
+  CHECK_DEVMODE (settings);
+  ldm_new = XDEVMODE (settings);
+  ldm_current = XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
+
+  /* If the supplied devmode is not specialized, then the current
+     devmode size will always be sufficient, as the printer does
+     not change.  If it is specialized, we must reallocate the cuttent
+     devmode storage to match with the supplied one, as it has the right
+     size for the new printer, if it is going to change.  The correct
+     way is to use the largest of the two though, to keep the old
+     contents unchanged in case of preliminary exit.
+  */
+  if (ldm_new->printer_name)
+    ldm_current->devmode =
+      (DEVMODE*) xrealloc (ldm_current->devmode,
+			   max (XDEVMODE_SIZE (ldm_new),
+				XDEVMODE_SIZE (ldm_current)));
+
+  if (!sync_printer_with_devmode (d, ldm_new->devmode,
+				  ldm_current->devmode,
+				  ldm_new->printer_name))
+    error ("Printer device initialization I/O error, device deleted.");
+  
+  if (ldm_new->printer_name != NULL)
+    {
+      xfree (ldm_current->printer_name);
+      ldm_current->printer_name = xstrdup (ldm_new->printer_name);
+    }
+
+  return DEVICE_MSPRINTER_DEVMODE (d);
+}
+
+/************************************************************************/
+/*                                devmode                               */
+/************************************************************************/
 
-  /* #### ResetDC fails sometimes, Bill only know s why.
-     The solution below looks more like a workaround to me,
-     although it might be fine. --kkm */
-  if (ResetDC (DEVICE_MSPRINTER_HDC (d), devmode) == NULL)
+static void
+print_devmode (Lisp_Object obj, Lisp_Object printcharfun,
+	       int escapeflag)
+{
+  char buf[100];
+  Lisp_Devmode *dm = XDEVMODE (obj);
+  if (print_readably)
+    error ("printing unreadable object #<msprinter-settings 0x%x>",
+           dm->header.uid);
+  write_c_string ("#<msprinter-settings", printcharfun);
+  if (dm->printer_name)
+    {
+      write_c_string (" for \"", printcharfun);
+      write_c_string (dm->printer_name, printcharfun);
+      write_c_string ("\"", printcharfun);
+    }
+  if (!NILP (dm->device))
+    {
+      write_c_string (" (currently on ", printcharfun);
+      print_internal (dm->device, printcharfun, 0);
+      write_c_string (")", printcharfun);
+    }
+  sprintf (buf, " 0x%x>", dm->header.uid);
+  write_c_string (buf, printcharfun);
+}
+
+static void
+finalize_devmode (void *header, int for_disksave)
+{
+  Lisp_Devmode *dm = (Lisp_Devmode *) header;
+
+  if (for_disksave)
     {
-      DeleteDC (DEVICE_MSPRINTER_HDC (d));
-      DEVICE_MSPRINTER_HDC (d) =
-	CreateDC ("WINSPOOL", DEVICE_MSPRINTER_NAME(d), NULL, devmode);
+      Lisp_Object devmode;
+      XSETDEVMODE (devmode, dm);
+      signal_simple_error (
+        "Cannot dump XEmacs containing an msprinter-settings object",
+	devmode);
     }
+
+  assert (NILP (dm->device));
+
+  if (dm->printer_name)
+    xfree (dm->printer_name);
+}
+
+static int
+equal_devmode (Lisp_Object obj1, Lisp_Object obj2, int depth)
+{
+  Lisp_Devmode *dm1 = XDEVMODE (obj1);
+  Lisp_Devmode *dm2 = XDEVMODE (obj2);
+
+  if ((dm1->devmode != NULL) != (dm1->devmode != NULL))
+    return 0;
+  if (dm1->devmode == NULL)
+    return 1;
+  if (memcmp (dm1->devmode, dm2->devmode, XDEVMODE_SIZE (dm1)) != 0)
+    return 0;
+  if (dm1->printer_name == NULL || dm2->printer_name == NULL)
+    return 1;
+  return stricmp (dm1->printer_name, dm2->printer_name) == 0;
+}
+
+static unsigned long
+hash_devmode (Lisp_Object obj, int depth)
+{
+  Lisp_Devmode *dm = XDEVMODE (obj);
+
+  return HASH3 (XDEVMODE_SIZE (dm),
+		dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm))
+		: 0,
+		dm->printer_name ? string_hash (dm->printer_name) : 0);
+}
+
+DEFINE_LRECORD_IMPLEMENTATION ("msprinter-settings", devmode,
+			       0/*mark*/, print_devmode, finalize_devmode,
+			       equal_devmode, hash_devmode, 0/*description*/,
+			       Lisp_Devmode);
+static Lisp_Object
+allocate_devmode (DEVMODE* src_devmode, int do_copy,
+		  char* src_name, struct device *d)
+{
+  Lisp_Devmode *dm;
+  Lisp_Object ob;
+
+  dm = alloc_lcrecord_type (Lisp_Devmode, &lrecord_devmode);
+
+  if (d)
+    XSETDEVICE (dm->device, d);
+  else
+    dm->device = Qnil;
+
+  dm->printer_name = src_name ? xstrdup (src_name) : NULL;
+
+  if (src_devmode != NULL && do_copy)
+    {
+      dm->devmode = (DEVMODE*) xmalloc (DEVMODE_SIZE (src_devmode));
+      memcpy (dm->devmode, src_devmode, DEVMODE_SIZE (src_devmode));
+    }
+  else
+    {
+      dm->devmode = src_devmode;
+    }
+
+  XSETDEVMODE (ob, dm);
+  return ob;
+}
+
+DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /*
+Create and returns an exact copy of a printer settings object.
+*/
+       (settings))
+{
+  Lisp_Devmode *dm;
+
+  CHECK_DEVMODE (settings);
+  dm = XDEVMODE (settings);
+
+  return allocate_devmode (dm->devmode, 1, dm->printer_name, NULL);
+}
+
+DEFUN ("msprinter-settings-despecialize", Fmsprinter_settings_despecialize, 1, 1, 0, /*
+Erase printer-specific settings from a printer settings object.
+*/
+       (settings))
+{
+  Lisp_Devmode *ldm;
+  DEVMODE *dm;
+
+  CHECK_DEVMODE (settings);
+  ldm = XDEVMODE (settings);
+
+  if (!NILP (ldm->device))
+    signal_simple_error ("The object is currently selected into a device",
+			 settings);
+
+  dm = ldm->devmode;
+
+  /* #### TODO. Either remove references to device specific bins,
+     paper sizes etc, or signal an error of they are present. */
+
+  dm->dmDriverExtra = 0;
+  dm->dmDeviceName[0] = '\0';
+
+  if (ldm->printer_name)
+    xfree (ldm->printer_name);
+
+  return Qnil;
 }
 
 
@@ -533,6 +1156,17 @@
 void
 syms_of_device_mswindows (void)
 {
+  INIT_LRECORD_IMPLEMENTATION (devmode);
+
+  DEFSUBR (Fmsprinter_print_setup_dialog);
+  DEFSUBR (Fmsprinter_print_dialog);
+  DEFSUBR (Fmsprinter_page_setup_dialog);
+  DEFSUBR (Fmsprinter_get_settings);
+  DEFSUBR (Fmsprinter_select_settings);
+  DEFSUBR (Fmsprinter_apply_settings);
+  DEFSUBR (Fmsprinter_settings_copy);
+  DEFSUBR (Fmsprinter_settings_despecialize);
+
   defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win");
   defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win");
 }
--- a/src/device-x.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/device-x.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1362,7 +1362,7 @@
 The sixth arg NOERROR, if non-nil, means do not signal an error if a
   bogus resource specification was retrieved (e.g. if a non-integer was
   given when an integer was requested).  In this case, a warning is issued
-  instead.
+  instead, unless NOERROR is t, in which case no warning is issued.
 
 The resource names passed to this function are looked up relative to the
 locale.
--- a/src/device.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/device.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1200,12 +1200,12 @@
   /* reset the flag to 0 unless another notification occurred while
      we were processing this one.  Block SIGWINCH during this
      check to prevent a possible race condition. */
-#ifndef WINDOWSNT
+#ifdef SIGWINCH
   EMACS_BLOCK_SIGNAL (SIGWINCH);
 #endif
   if (old_asynch_device_change_pending == asynch_device_change_pending)
     asynch_device_change_pending = 0;
-#ifndef WINDOWSNT
+#ifdef SIGWINCH
   EMACS_UNBLOCK_SIGNAL (SIGWINCH);
 #endif
 }
--- a/src/device.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/device.h	Mon Aug 13 11:19:21 2007 +0200
@@ -335,6 +335,7 @@
 
 EXFUN (Fdevice_console, 1);
 EXFUN (Fdevice_name, 1);
+EXFUN (Ffind_device, 2);
 EXFUN (Fmake_device, 3);
 EXFUN (Fselected_device, 1);
 
--- a/src/dgif_lib.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/dgif_lib.c	Mon Aug 13 11:19:21 2007 +0200
@@ -11,23 +11,10 @@
 * 19 Feb 98 - Version 1.2 by Jareth Hein (Support for user specified I/O)     *
 ******************************************************************************/
 
-#ifdef __MSDOS__
-#include <io.h>
-#include <alloc.h>
-#include <stdlib.h>
-#include <sys\stat.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif /* __MSDOS__ */
+#include <config.h>
+#include "lisp.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
+#include "sysfile.h"
 
 #include "gifrlib.h"
 
@@ -52,11 +39,11 @@
     FILE *f;
 
     if ((f = fopen(FileName, 
-#ifdef __MSDOS__
+#ifdef WIN32_NATIVE
 			     "rb"
 #else
 		             "r"
-#endif /* __MSDOS__ */
+#endif /* WIN32_NATIVE */
 			                     )) == NULL)
 	GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED);
 
@@ -73,13 +60,13 @@
 {
     FILE *f;
 
-#ifdef __MSDOS__
+#ifdef WIN32_NATIVE
     setmode(FileHandle, O_BINARY);	  /* Make sure it is in binary mode. */
     f = fdopen(FileHandle, "rb");		   /* Make it into a stream: */
     setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/
 #else
     f = fdopen(FileHandle, "r");		   /* Make it into a stream: */
-#endif /* __MSDOS__ */
+#endif /* WIN32_NATIVE */
 
     GifStdIOInit(GifFile, f, -1);
     DGifInitRead(GifFile);
@@ -277,11 +264,11 @@
 
     if (!LineLen) LineLen = GifFile->Image.Width;
 
-#if defined(__MSDOS__) || defined(__GNUC__)
+#if defined(WIN32_NATIVE) || defined(__GNUC__)
     if ((Private->PixelCount -= LineLen) > 0xffff0000UL)
 #else
     if ((Private->PixelCount -= LineLen) > 0xffff0000)
-#endif /* __MSDOS__ */
+#endif /* WIN32_NATIVE */
     {    
 	GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG);
     }
@@ -310,11 +297,11 @@
 	GifInternError(GifFile, D_GIF_ERR_NOT_READABLE);
     }
 
-#if defined(__MSDOS__) || defined(__GNUC__)
+#if defined(WIN32_NATIVE) || defined(__GNUC__)
     if (--Private->PixelCount > 0xffff0000UL)
 #else
     if (--Private->PixelCount > 0xffff0000)
-#endif /* __MSDOS__ */
+#endif /* WIN32_NATIVE */
     {
 	GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG);
     }
--- a/src/dialog-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/dialog-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -389,7 +389,7 @@
 
 	  memcpy (trans, XSTRING_DATA (ctext), XSTRING_LENGTH (ctext) + 1);
 	  translen =
-	    msw_translate_menu_or_dialog_item (trans,
+	    mswindows_translate_menu_or_dialog_item (trans,
 					       XSTRING_LENGTH (ctext),
 					       2 * XSTRING_LENGTH (ctext) + 3,
 					       &accel_unused,
--- a/src/dired-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/dired-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -75,11 +75,10 @@
 #include "buffer.h"
 #include "regex.h"
 
-#include "sysfile.h"
 #include "sysdir.h"
 #include "sysproc.h"
+#include "sysfile.h"
 
-#include <limits.h>
 #include <time.h>
 
 #include <winsock.h>		/* To make nt.h happy */
--- a/src/dired.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/dired.c	Mon Aug 13 11:19:21 2007 +0200
@@ -303,11 +303,11 @@
 
   CHECK_STRING (file);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Filename completion on Windows ignores case, since Windows
      filesystems do.  */
   specbind (Qcompletion_ignore_case, Qt);
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #ifdef FILE_SYSTEM_CASE
   file = FILE_SYSTEM_CASE (file);
@@ -508,7 +508,7 @@
 
 
 /* The *pwent() functions do not exist on NT */
-#ifndef  WINDOWSNT
+#ifndef  WIN32_NATIVE
 
 static Lisp_Object user_name_completion (Lisp_Object user,
                                          int all_flag,
@@ -707,7 +707,7 @@
     return Qt;
   return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize));
 }
-#endif   /* ! defined WINDOWSNT */
+#endif   /* ! defined WIN32_NATIVE */
 
 
 Lisp_Object
@@ -796,7 +796,7 @@
   directory = Ffile_name_directory (filename);
 #endif
 
-#ifdef MSDOS
+#if 0 /* #### shouldn't this apply to WIN32_NATIVE and maybe CYGWIN? */
   {
     char *tmpnam = (char *) XSTRING_DATA (Ffile_name_nondirectory (filename));
     int l = strlen (tmpnam);
@@ -810,7 +810,7 @@
 	s.st_mode |= S_IEXEC;
       }
   }
-#endif /* MSDOS */
+#endif
 
   switch (s.st_mode & S_IFMT)
     {
@@ -873,7 +873,7 @@
   DEFSUBR (Fdirectory_files);
   DEFSUBR (Ffile_name_completion);
   DEFSUBR (Ffile_name_all_completions);
-#ifndef  WINDOWSNT
+#ifndef  WIN32_NATIVE
   DEFSUBR (Fuser_name_completion);
   DEFSUBR (Fuser_name_completion_1);
   DEFSUBR (Fuser_name_all_completions);
--- a/src/doprnt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/doprnt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -657,16 +657,21 @@
 		  long_to_string (constructed_spec + strlen (constructed_spec),
 				  spec->precision);
 		}
-	      sprintf (constructed_spec + strlen (constructed_spec), "%c", ch);
 
 	      /* sprintf the mofo */
 	      /* we have to use separate calls to sprintf(), rather than
 		 a single big conditional, because of the different types
 		 of the arguments */
 	      if (strchr (double_converters, ch))
-		sprintf (text_to_print, constructed_spec, arg.d);
+		{
+		  sprintf (constructed_spec + strlen (constructed_spec),
+			   "%c", ch);
+		  sprintf (text_to_print, constructed_spec, arg.d);
+		}
 	      else if (strchr (unsigned_int_converters, ch))
 		{
+		  sprintf (constructed_spec + strlen (constructed_spec),
+			   "%c", ch);
 		  if (spec->l_flag)
 		    sprintf (text_to_print, constructed_spec, arg.ul);
 		  else
@@ -674,6 +679,12 @@
 		}
 	      else
 		{
+		  if (spec->zero_flag && spec->minwidth)
+		    sprintf (constructed_spec + strlen (constructed_spec),
+			     "0%d%c", spec->minwidth, ch);
+		  else
+		    sprintf (constructed_spec + strlen (constructed_spec),
+			     "%c", ch);
 		  if (spec->l_flag)
 		    sprintf (text_to_print, constructed_spec, arg.l);
 		  else
--- a/src/dumper.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/dumper.c	Mon Aug 13 11:19:21 2007 +0200
@@ -22,6 +22,7 @@
 
 #include <config.h>
 #include "lisp.h"
+
 #include "dump-id.h"
 #include "specifier.h"
 #include "alloc.h"
@@ -30,10 +31,8 @@
 #include "console-stream.h"
 #include "dumper.h"
 
-#ifdef WINDOWSNT
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-#define PATH_MAX MAXPATHLEN
+#ifdef WIN32_NATIVE
+#include "nt.h"
 #else
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
@@ -107,7 +106,7 @@
 char *pdump_start, *pdump_end;
 static size_t pdump_length;
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 // Handle for the dump file
 HANDLE pdump_hFile = INVALID_HANDLE_VALUE;
 // Handle for the file mapping object for the dump file
@@ -1110,7 +1109,7 @@
   return 1;
 }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 /* Free the mapped file if we decide we don't want it after all */
 static void pdump_file_unmap(void)
 {
@@ -1198,7 +1197,7 @@
   return 1;
 }
 
-#else /* !WINDOWSNT */
+#else /* !WIN32_NATIVE */
 
 static void *pdump_mallocadr;
 
@@ -1247,7 +1246,7 @@
   close (pdump_fd);
   return 1;
 }
-#endif /* !WINDOWSNT */
+#endif /* !WIN32_NATIVE */
 
 
 static int pdump_file_try(char *exe_path)
@@ -1292,9 +1291,9 @@
 int pdump_load(const char *argv0)
 {
   char exe_path[PATH_MAX];
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   GetModuleFileName (NULL, exe_path, PATH_MAX);  
-#else /* !WINDOWSNT */
+#else /* !WIN32_NATIVE */
   char *w;
   const char *dir, *p;
 
@@ -1355,7 +1354,7 @@
 	  path = p+1;	    
 	}
     }
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   if (pdump_file_try (exe_path))
     {
@@ -1363,7 +1362,7 @@
       return 1;
     }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   if (pdump_resource_get ())
     {
       if (pdump_load_check ())
--- a/src/editfns.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/editfns.c	Mon Aug 13 11:19:21 2007 +0200
@@ -28,9 +28,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "buffer.h"
 #include "commands.h"
@@ -606,20 +603,20 @@
 
 DEFUN ("temp-directory", Ftemp_directory, 0, 0, 0, /*
 Return the pathname to the directory to use for temporary files.
-On NT/MSDOS, this is obtained from the TEMP or TMP environment variables,
+On MS Windows, this is obtained from the TEMP or TMP environment variables,
 defaulting to / if they are both undefined.
 On Unix it is obtained from TMPDIR, with /tmp as the default
 */
        ())
 {
   char *tmpdir;
-#if defined(WINDOWSNT) || defined(MSDOS)
+#if defined(WIN32_NATIVE)
   tmpdir = getenv ("TEMP");
   if (!tmpdir)
     tmpdir = getenv ("TMP");
   if (!tmpdir)
     tmpdir = "/";
-#else /* WINDOWSNT || MSDOS */
+#else /* WIN32_NATIVE */
  tmpdir = getenv ("TMPDIR");
  if (!tmpdir)
    tmpdir = "/tmp";
@@ -681,7 +678,7 @@
       char *user_name = getenv ("LOGNAME");
       if (!user_name)
 	user_name = getenv (
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 			    "USERNAME" /* it's USERNAME on NT */
 #else
 			    "USER"
@@ -692,7 +689,7 @@
       else
 	{
 	  struct passwd *pw = getpwuid (geteuid ());
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
 	  /* Since the Cygwin environment may not have an /etc/passwd,
 	     return "unknown" instead of the null if the username
 	     cannot be determined.
@@ -716,14 +713,7 @@
   struct passwd *pw = getpwuid (getuid ());
   /* #### - I believe this should return nil instead of "unknown" when pw==0 */
 
-#ifdef MSDOS
-  /* We let the real user name default to "root" because that's quite
-     accurate on MSDOG and because it lets Emacs find the init file.
-     (The DVX libraries override the Djgpp libraries here.)  */
-  Lisp_Object tem = build_string (pw ? pw->pw_name : "root");/* no gettext */
-#else
   Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */
-#endif
   return tem;
 }
 
@@ -840,7 +830,7 @@
     {
       if ((cached_home_directory = (Extbyte *) getenv("HOME")) == NULL)
 	{
-#if defined(WINDOWSNT) && !defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE)
 	  char *homedrive, *homepath;
 
 	  if ((homedrive = getenv("HOMEDRIVE")) != NULL &&
@@ -880,7 +870,7 @@
 	      output_home_warning = 1;
 # endif
 	    }
-#else	/* !WINDOWSNT */
+#else	/* !WIN32_NATIVE */
 	  /*
 	   * Unix, typically.
 	   * Using "/" isn't quite right, but what should we do?
@@ -889,7 +879,7 @@
 	   */
 	  cached_home_directory = (Extbyte *) "/";
 	  output_home_warning = 1;
-#endif	/* !WINDOWSNT */
+#endif	/* !WIN32_NATIVE */
 	}
       if (initialized && output_home_warning)
 	{
--- a/src/elhash.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/elhash.c	Mon Aug 13 11:19:21 2007 +0200
@@ -29,13 +29,14 @@
 
 Lisp_Object Qhash_tablep;
 static Lisp_Object Qhashtable, Qhash_table;
-static Lisp_Object Qweakness, Qvalue;
+static Lisp_Object Qweakness, Qvalue, Qkey_value;
 static Lisp_Object Vall_weak_hash_tables;
 static Lisp_Object Qrehash_size, Qrehash_threshold;
 static Lisp_Object Q_size, Q_test, Q_weakness, Q_rehash_size, Q_rehash_threshold;
 
 /* obsolete as of 19990901 in xemacs-21.2 */
-static Lisp_Object Qweak, Qkey_weak, Qvalue_weak, Qnon_weak, Q_type;
+static Lisp_Object Qweak, Qkey_weak, Qvalue_weak, Qkey_value_weak;
+static Lisp_Object Qnon_weak, Q_type;
 
 typedef struct hentry
 {
@@ -354,6 +355,7 @@
 	       (ht->weakness == HASH_TABLE_WEAK	      ? "t"     :
 		ht->weakness == HASH_TABLE_KEY_WEAK   ? "key"   :
 		ht->weakness == HASH_TABLE_VALUE_WEAK ? "value" :
+		ht->weakness == HASH_TABLE_KEY_VALUE_WEAK ? "key-value" :
 		"you-d-better-not-see-this"));
       write_c_string (buf, printcharfun);
     }
@@ -542,12 +544,14 @@
   if (EQ (value, Qnil))		return 1;
   if (EQ (value, Qt))		return 1;
   if (EQ (value, Qkey))		return 1;
+  if (EQ (value, Qkey_value))		return 1;
   if (EQ (value, Qvalue))	return 1;
 
   /* Following values are obsolete as of 19990901 in xemacs-21.2 */
   if (EQ (value, Qnon_weak))	return 1;
   if (EQ (value, Qweak))	return 1;
   if (EQ (value, Qkey_weak))	return 1;
+  if (EQ (value, Qkey_value_weak))	return 1;
   if (EQ (value, Qvalue_weak))	return 1;
 
   maybe_signal_simple_error ("Invalid hash table weakness",
@@ -561,12 +565,14 @@
   if (EQ (obj, Qnil))	     return HASH_TABLE_NON_WEAK;
   if (EQ (obj, Qt))	     return HASH_TABLE_WEAK;
   if (EQ (obj, Qkey))        return HASH_TABLE_KEY_WEAK;
+  if (EQ (obj, Qkey_value))        return HASH_TABLE_KEY_VALUE_WEAK;
   if (EQ (obj, Qvalue))      return HASH_TABLE_VALUE_WEAK;
 
   /* Following values are obsolete as of 19990901 in xemacs-21.2 */
   if (EQ (obj, Qnon_weak))   return HASH_TABLE_NON_WEAK;
   if (EQ (obj, Qweak))	     return HASH_TABLE_WEAK;
   if (EQ (obj, Qkey_weak))   return HASH_TABLE_KEY_WEAK;
+  if (EQ (obj, Qkey_value_weak))   return HASH_TABLE_KEY_VALUE_WEAK;
   if (EQ (obj, Qvalue_weak)) return HASH_TABLE_VALUE_WEAK;
 
   signal_simple_error ("Invalid hash table weakness", obj);
@@ -800,7 +806,8 @@
 Keyword :rehash-threshold must be a float between 0.0 and 1.0,
 and specifies the load factor of the hash table which triggers enlarging.
 
-Non-standard keyword :weakness can be `nil' (default), `t', `key' or `value'.
+Non-standard keyword :weakness can be `nil' (default), `t', `key', `value'
+or `key-value'.
 
 A weak hash table is one whose pointers do not count as GC referents:
 for any key-value pair in the hash table, if the only remaining pointer
@@ -820,6 +827,12 @@
 unmarked outside of weak hash tables.  The pair will remain in the
 hash table if the value is pointed to by something other than a weak
 hash table, even if the key is not.
+
+A key-value-weak hash table is similar to a fully-weak hash table except
+that a key-value pair will be removed only if the value and the key remain
+unmarked outside of weak hash tables.  The pair will remain in the
+hash table if the value or key are pointed to by something other than a weak
+hash table, even if the other is not.
 */
        (int nargs, Lisp_Object *args))
 {
@@ -1117,6 +1130,7 @@
     {
     case HASH_TABLE_WEAK:	return Qt;
     case HASH_TABLE_KEY_WEAK:	return Qkey;
+    case HASH_TABLE_KEY_VALUE_WEAK:	return Qkey_value;
     case HASH_TABLE_VALUE_WEAK:	return Qvalue;
     default:			return Qnil;
     }
@@ -1133,6 +1147,7 @@
     {
     case HASH_TABLE_WEAK:	return Qweak;
     case HASH_TABLE_KEY_WEAK:	return Qkey_weak;
+    case HASH_TABLE_KEY_VALUE_WEAK:	return Qkey_value_weak;
     case HASH_TABLE_VALUE_WEAK:	return Qvalue_weak;
     default:			return Qnon_weak;
     }
@@ -1266,6 +1281,17 @@
 		MARK_OBJ (e->key);
 	  break;
 
+	case HASH_TABLE_KEY_VALUE_WEAK:
+	  for (; e < sentinel; e++)
+	    if (!HENTRY_CLEAR_P (e))
+	      {
+		if (marked_p (e->value))
+		  MARK_OBJ (e->key);
+		else if (marked_p (e->key))
+		  MARK_OBJ (e->value);
+	      }
+	  break;
+
 	case HASH_TABLE_KEY_CAR_WEAK:
 	  for (; e < sentinel; e++)
 	    if (!HENTRY_CLEAR_P (e))
@@ -1458,11 +1484,13 @@
   defsymbol (&Qhashtable, "hashtable");
   defsymbol (&Qweakness, "weakness");
   defsymbol (&Qvalue, "value");
+  defsymbol (&Qkey_value, "key-value");
   defsymbol (&Qrehash_size, "rehash-size");
   defsymbol (&Qrehash_threshold, "rehash-threshold");
 
   defsymbol (&Qweak, "weak");             /* obsolete */
   defsymbol (&Qkey_weak, "key-weak");     /* obsolete */
+  defsymbol (&Qkey_value_weak, "key-value-weak");     /* obsolete */
   defsymbol (&Qvalue_weak, "value-weak"); /* obsolete */
   defsymbol (&Qnon_weak, "non-weak");     /* obsolete */
 
--- a/src/elhash.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/elhash.h	Mon Aug 13 11:19:21 2007 +0200
@@ -38,6 +38,7 @@
   HASH_TABLE_NON_WEAK,
   HASH_TABLE_KEY_WEAK,
   HASH_TABLE_VALUE_WEAK,
+  HASH_TABLE_KEY_VALUE_WEAK,
   HASH_TABLE_KEY_CAR_WEAK,
   HASH_TABLE_VALUE_CAR_WEAK,
   HASH_TABLE_WEAK
--- a/src/emacs.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/emacs.c	Mon Aug 13 11:19:21 2007 +0200
@@ -206,8 +206,8 @@
 #include TT_C_H_FILE
 #endif
 
-#if defined (WINDOWSNT)
-#include <windows.h>
+#if defined (WIN32_NATIVE)
+#include "nt.h"
 #endif
 
 /* For PATH_EXEC */
@@ -526,7 +526,9 @@
     return EXCEPTION_CONTINUE_SEARCH;
 
   /* I don't know if this filter is still wrapped in the outer __try, but
-     it doesn't hurt to have another one. --ben */
+     it doesn't hurt to have another one. --ben
+     And it lets us control more exactly what we really want to do in such
+     a situation. */
   __try
     {
       fatal_error_in_progress++;
@@ -558,7 +560,38 @@
     }
   /* VC++ documentation says that
      GetExceptionCode() cannot be called inside the filter itself. */
-  __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {}
+
+  /*  __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {}
+
+     The line above is original.  Unfortunately, when an error is tripped
+     inside of the handler (e.g. during Fbacktrace()), and the handler for
+     the handler is invoked, it correctly notices that something is amiss
+     and it should just return -- but it returns EXCEPTION_CONTINUE_SEARCH,
+     which causes the debugger to be invoked debugging the handler code in
+     this function -- and WITH THE STACK UNWOUND so that you see main()
+     calling mswindows_handle_hardware_exceptions(), calling Fbacktrace(),
+     and a crash a couple of frames in -- AND NO SIGN OF THE ORIGINAL CRASH!
+
+     There's some real weirdness going on in the stack handling -- unlike
+     in Unix, where further crashes just keep adding to the stack, it seems
+     that under the structured-exception-handling, the stack can actually
+     bounce back and forth between the full stack at the location of the
+     exception and the unwound stack at the place where the __try clause was
+     established.  I don't completely understand it.  What I do know is that
+     returning EXCEPTION_EXECUTE_HANDLER on nested crash has the effect of
+     aborting execution of the handler and going back to the outer filter
+     function, which returns EXCEPTION_CONTINUE_SEARCH and everything is
+     hunky-dorey -- your debugger sees a crash at the right location with
+     the right stack.
+
+     I'm leaving in the trickier Unix-like code in the handler; someone who
+     understands better than me how the stack works in these handlers could
+     fix it up more.  As it is, it works pretty well, so I'm not likely to
+     touch it more. --ben
+  */
+
+  __except (EXCEPTION_EXECUTE_HANDLER) {}
+  
 
   /* pretend we didn't handle this, so that the debugger is invoked and/or
      the normal GPF box appears. */
@@ -599,7 +632,7 @@
     {
       if (i == 0 || i > skip_args)
 	{
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  if (i == 0)
 	    {
 	      /* Do not trust to what crt0 has stuffed into argv[0] */
@@ -697,15 +730,6 @@
 # undef RUN_TIME_REMAP
 #endif
 
-#if defined (MULE) && defined (MSDOS) && defined (EMX)
-/* Setup all of files be input/output'ed with binary translation mode. */
-asm ("	.text");
-asm ("L_setbinmode:");
-asm ("	movl	$1, __fmode_bin");
-asm ("	ret");
-asm ("	.stabs	\"___CTOR_LIST__\", 23, 0, 0, L_setbinmode");
-#endif
-
 /* Test whether the next argument in ARGV matches SSTR or a prefix of
    LSTR (at least MINLEN characters).  If so, then if VALPTR is non-null
    (the argument is supposed to have a value) store in *VALPTR either
@@ -827,7 +851,7 @@
 
   sort_args (argc, argv);
 
-#if (defined (MSDOS) && defined (EMX)) || defined (WIN32) || defined (_SCO_DS)
+#if defined (WIN32_NATIVE) || defined (_SCO_DS)
   environ = envp;
 #endif
 
@@ -860,15 +884,6 @@
     memory_warnings (0, malloc_warning);
 #endif	/* not SYSTEM_MALLOC */
 
-#ifdef MSDOS
-  /* We do all file input/output as binary files.  When we need to translate
-     newlines, we do that manually.  */
-  _fmode = O_BINARY;
-  (stdin) ->_flag &= ~_IOTEXT;
-  (stdout)->_flag &= ~_IOTEXT;
-  (stderr)->_flag &= ~_IOTEXT;
-#endif /* MSDOS */
-
 #ifdef SET_EMACS_PRIORITY
   if (emacs_priority != 0)
     nice (-emacs_priority);
@@ -1289,7 +1304,7 @@
 #ifdef HAVE_MSW_C_DIRED
       syms_of_dired_mswindows ();
 #endif
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       syms_of_ntproc ();
 #endif
 #endif	/* HAVE_MS_WINDOWS */
@@ -1342,7 +1357,7 @@
 #endif
 
 #ifdef HAVE_GPM
-	  syms_of_gpmevent ();
+      syms_of_gpmevent ();
 #endif
 
 #ifdef HAVE_POSTGRESQL
@@ -1629,7 +1644,7 @@
 #ifdef HAVE_SHLIB
       vars_of_module ();
 #endif
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       vars_of_nt ();
       vars_of_ntproc ();
 #endif
@@ -1747,7 +1762,7 @@
 #endif
 
 #ifdef HAVE_GPM
-	  vars_of_gpmevent ();
+      vars_of_gpmevent ();
 #endif
 
       /* Now initialize any specifier variables.  We do this later
@@ -2017,7 +2032,7 @@
   init_initial_directory();		/* get the directory to use for the
 					   "*scratch*" buffer, etc. */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /*
    * For Win32, call init_environment() now, so that environment/registry
    * variables will be properly entered into Vprocess_environment.
@@ -2032,16 +2047,10 @@
 			   first because many of the functions below
 			   call egetenv() to get environment variables. */
   init_lread ();	/* Set up the Lisp reader. */
-#ifdef MSDOS
-  /* Call early 'cause init_environment needs it.  */
-  init_dosfns ();
-  /* Set defaults for several environment variables.  */
-  init_environment (argc, argv, skip_args);
-#endif
   init_cmdargs (argc, argv, skip_args);	/* Create list Vcommand_line_args */
   init_buffer ();	/* Set default directory of *scratch* buffer */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   init_ntproc();
 #endif
 
@@ -2097,7 +2106,7 @@
     Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
   }
 
-#if defined(HAVE_SHLIB) && !defined(WINDOWSNT)
+#if defined(HAVE_SHLIB) && !defined(WIN32_NATIVE)
   /* This is Unix only.  MS Windows NT has a library call that does
      The Right Thing on that system.  Rumor has it, this must be
      called for GNU dld in temacs and xemacs.  */
@@ -2531,7 +2540,7 @@
 
 	 06/20/96 robertl@dgii.com */
       {
-	extern char *_environ;
+	extern char **_environ;
 	if ((unsigned) environ == 0)
 	  environ=_environ;
       }
@@ -2639,7 +2648,7 @@
 	 be too dangerous), and if we get a crash somewhere within
 	 this loop, we'll still autosave and won't try this again. */
 
-      LIST_LOOP_DELETING(concons, nextcons, Vconsole_list)
+      LIST_LOOP_DELETING (concons, nextcons, Vconsole_list)
 	{
 	  /* There is very little point in deleting the stream console.
 	     It uses stdio, which should flush any buffered output and
@@ -2653,6 +2662,14 @@
 
   UNGCPRO;
 
+#ifdef HAVE_MS_WINDOWS
+  /* If we displayed a message on the console and we're exiting due to
+     init error, then we must allow the user to see this message. */
+  if (mswindows_message_outputted && INTP (arg) && XINT (arg) != 0)
+    Fmswindows_message_box (build_string ("Initialization error"),
+			    Qnil, Qnil);
+#endif
+
   shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0);
 
 #if defined(GNU_MALLOC)
@@ -2869,18 +2886,6 @@
 
   UNGCPRO;
 
-#if defined (MSDOS) && defined (EMX)
-  {
-    int fd = open ((char *) XSTRING_DATA (intoname),
-                   O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
-    if (!fd) {
-      error ("Failure operating on %s", XSTRING_DATA (intoname));
-    } else {
-      _core (fd);
-      close (fd);
-    }
-  }
-#else /* not MSDOS and EMX */
   {
     char *intoname_ext;
     char *symname_ext;
@@ -2917,7 +2922,6 @@
 #endif
 #endif /* not PDUMP */
   }
-#endif /* not MSDOS and EMX */
 
   purify_flag = opurify;
 
@@ -3056,7 +3060,7 @@
 
 #undef abort	/* avoid infinite #define loop... */
 
-#if defined (WINDOWSNT) && defined (DEBUG_XEMACS)
+#if defined (WIN32_NATIVE) && defined (DEBUG_XEMACS)
 #define enter_debugger() DebugBreak ()
 #else
 #define enter_debugger()
--- a/src/eval.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/eval.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1057,7 +1057,7 @@
  buffer-local values are not affected.
 INITVALUE and DOCSTRING are optional.
 If DOCSTRING starts with *, this variable is identified as a user option.
- This means that M-x set-variable and M-x edit-options recognize it.
+ This means that M-x set-variable recognizes it.
 If INITVALUE is missing, SYMBOL's value is not set.
 
 In lisp-interaction-mode defvar is treated as defconst.
@@ -1107,7 +1107,7 @@
  buffer-local values are not affected.
 DOCSTRING is optional.
 If DOCSTRING starts with *, this variable is identified as a user option.
- This means that M-x set-variable and M-x edit-options recognize it.
+ This means that M-x set-variable recognizes it.
 
 Note: do not use `defconst' for user options in libraries that are not
  normally loaded, since it is useful for users to be able to specify
@@ -3315,9 +3315,11 @@
 
   if (SUBRP (function))
     {
-      return function_min_args_p ?
-	Fsubr_min_args (function):
-	Fsubr_max_args (function);
+      /* Using return with the ?: operator tickles a DEC CC compiler bug. */
+      if (function_min_args_p)
+	return Fsubr_min_args (function);
+      else
+	return Fsubr_max_args (function);
    }
   else if (COMPILED_FUNCTIONP (function))
     {
--- a/src/event-Xt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/event-Xt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -3220,7 +3220,7 @@
   XSetErrorHandler (x_error_handler);
   XSetIOErrorHandler (x_IO_error_handler);
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   XtAppAddInput (Xt_app_con, signal_event_pipe[0],
 		 (XtPointer) (XtInputReadMask /* | XtInputExceptMask */),
 		 Xt_what_callback, 0);
--- a/src/event-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/event-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -69,13 +69,13 @@
 #ifdef HAVE_MSG_SELECT
 #include "sysfile.h"
 #include "console-tty.h"
-#elif defined(__CYGWIN32__)
+#elif defined(CYGWIN)
 typedef unsigned int SOCKET;
 #endif
 #include <io.h>
 #include <errno.h>
 
-#if !(defined(__CYGWIN32__) || defined(__MINGW32__))
+#if !(defined(CYGWIN) || defined(MINGW))
 # include <shlobj.h>	/* For IShellLink */
 #endif
 
@@ -471,7 +471,7 @@
 #define NTPIPE_SHOVE_STREAM_DATA(stream) \
   LSTREAM_TYPE_DATA (stream, ntpipe_shove)
 
-#define MAX_SHOVE_BUFFER_SIZE 128
+#define MAX_SHOVE_BUFFER_SIZE 512
 
 struct ntpipe_shove_stream
 {
@@ -505,15 +505,18 @@
       InterlockedIncrement (&s->idle_p);
       WaitForSingleObject (s->hev_thread, INFINITE);
 
-      if (s->die_p)
-	break;
-
-      /* Write passed buffer */
-      if (!WriteFile (s->hpipe, s->buffer, s->size, &bytes_written, NULL)
-	  || bytes_written != s->size)
+      /* Write passed buffer if any */
+      if (s->size > 0)
 	{
-	  s->error_p = TRUE;
-	  InterlockedIncrement (&s->die_p);
+         if (!WriteFile (s->hpipe, s->buffer, s->size, &bytes_written, NULL)
+             || bytes_written != s->size)
+           {
+             s->error_p = TRUE;
+             InterlockedIncrement (&s->die_p);
+           }
+         /* Set size to zero so we won't write it again if the closer sets
+            die_p and kicks us */
+         s->size = 0;
 	}
 
       if (s->die_p)
@@ -546,6 +549,15 @@
       return Qnil;
     }
 
+  /* Set the priority of the thread higher so we don't end up waiting
+     on it to send things. */
+  if (!SetThreadPriority (s->hthread, THREAD_PRIORITY_HIGHEST))
+    {
+      CloseHandle (s->hthread);
+      Lstream_delete (lstr);
+      return Qnil;
+    }
+
   /* hev_thread is an auto-reset event, initially nonsignaled */
   s->hev_thread = CreateEvent (NULL, FALSE, FALSE, NULL);
 
@@ -586,6 +598,9 @@
   /* Start output */
   InterlockedDecrement (&s->idle_p);
   SetEvent (s->hev_thread);
+  /* Give it a chance to run -- this dramatically improves performance
+     of things like crypt. */
+  (void) SwitchToThread ();
   return size;
 }
 
@@ -604,14 +619,18 @@
   /* Force thread stop */
   InterlockedIncrement (&s->die_p);
 
-  /* Close pipe handle, possibly breaking it */
-  CloseHandle (s->hpipe);
-
-  /* Thread will end upon unblocking */
+  /* Thread will end upon unblocking.  If it's already unblocked this will
+     do nothing, but the thread won't look at die_p until it's written any
+     pending output. */
   SetEvent (s->hev_thread);
 
   /* Wait while thread terminates */
   WaitForSingleObject (s->hthread, INFINITE);
+
+  /* Close pipe handle, possibly breaking it */
+  CloseHandle (s->hpipe);
+
+  /* Close the thread handle */
   CloseHandle (s->hthread);
 
   /* Destroy the event */
@@ -1251,14 +1270,20 @@
 
   while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
     {
-      /* We have to translate messages that are not sent to the main
-         window. This is so that key presses work ok in things like
-         edit fields. However, we *musn't* translate message for the
-         main window as this is handled in the wnd proc.
+      /* We have to translate messages that are not sent to an XEmacs
+         frame. This is so that key presses work ok in things like
+         edit fields. However, we *musn't* translate message for XEmacs
+         frames as this is handled in the wnd proc.
          We also have to avoid generating paint magic events for windows
 	 that aren't XEmacs frames */
-      if (GetWindowLong (msg.hwnd, GWL_STYLE) & (WS_CHILD|WS_POPUP))
+      /* GetClassName will truncate a longer class name. By adding one
+	 extra character, we are forcing textual comparison to fail
+	 if the name is longer than XEMACS_CLASS */
+      char class_name_buf [sizeof (XEMACS_CLASS) + 2] = "";
+      GetClassName (msg.hwnd, class_name_buf, sizeof (class_name_buf) - 1);
+      if (stricmp (class_name_buf, XEMACS_CLASS) != 0)
 	{
+	  /* Not an XEmacs frame */
 	  TranslateMessage (&msg);
 	}
       else if (msg.message == WM_PAINT)
@@ -1270,8 +1295,8 @@
 	  assert (msg.wParam == 0);
 
 	  /* Queue a magic event for handling when safe */
-	  msframe = FRAME_MSWINDOWS_DATA (
-					  XFRAME (mswindows_find_frame (msg.hwnd)));
+	  msframe =
+	    FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (msg.hwnd)));
 	  if (!msframe->paint_pending)
 	    {
 	      msframe->paint_pending = 1;
@@ -1600,7 +1625,7 @@
 	  if (*end)
 	    return DDE_FNOTPROCESSED;
 
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
 	  filename = alloca (cygwin32_win32_to_posix_path_list_buf_size (cmd) + 5);
 	  strcpy (filename, "file:");
 	  cygwin32_win32_to_posix_path_list (cmd, filename+5);
@@ -1755,7 +1780,7 @@
 	 This means that we need to distinguish between an
 	 auto-repeated key and a key pressed and released a bunch
 	 of times. */
-      else if (downp && !keyp ||
+      else if ((downp && !keyp) ||
 	       (downp && keyp && last_downkey &&
 		(wParam != last_downkey ||
 		 /* the "previous key state" bit indicates autorepeat */
@@ -1810,24 +1835,24 @@
     }						\
 } while (0)
 
-      if (wParam == VK_CONTROL && (lParam & 0x1000000)
+      if ((wParam == VK_CONTROL && (lParam & 0x1000000))
 	  || wParam == VK_RCONTROL)
 	FROB (XEMSW_RCONTROL);
-      if (wParam == VK_CONTROL && !(lParam & 0x1000000)
+      if ((wParam == VK_CONTROL && !(lParam & 0x1000000))
 	  || wParam == VK_LCONTROL)
 	FROB (XEMSW_LCONTROL);
 
-      if (wParam == VK_SHIFT && (lParam & 0x1000000)
+      if ((wParam == VK_SHIFT && (lParam & 0x1000000))
 	  || wParam == VK_RSHIFT)
 	FROB (XEMSW_RSHIFT);
-      if (wParam == VK_SHIFT && !(lParam & 0x1000000)
+      if ((wParam == VK_SHIFT && !(lParam & 0x1000000))
 	  || wParam == VK_LSHIFT)
 	FROB (XEMSW_LSHIFT);
 
-      if (wParam == VK_MENU && (lParam & 0x1000000)
+      if ((wParam == VK_MENU && (lParam & 0x1000000))
 	  || wParam == VK_RMENU)
 	FROB (XEMSW_RMENU);
-      if (wParam == VK_MENU && !(lParam & 0x1000000)
+      if ((wParam == VK_MENU && !(lParam & 0x1000000))
 	  || wParam == VK_LMENU)
 	FROB (XEMSW_LMENU);
     }
@@ -1889,6 +1914,8 @@
 
 #ifdef DEBUG_XEMACS
 
+#if 0
+
 static void
 output_modifier_keyboard_state (void)
 {
@@ -1919,6 +1946,8 @@
 	      keymap[VK_RSHIFT] & 0x1 ? 1 : 0);
 }
 
+#endif
+
 /* try to debug the stuck-alt-key problem.
 
  #### this happens only inconsistently, and may only happen when using
@@ -1971,7 +2000,7 @@
  * The windows procedure for the window class XEMACS_CLASS
  */
 LRESULT WINAPI
-mswindows_wnd_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+mswindows_wnd_proc (HWND hwnd, UINT message_, WPARAM wParam, LPARAM lParam)
 {
   /* Note: Remember to initialize emacs_event and event before use.
      This code calls code that can GC. You must GCPRO before calling such code. */
@@ -1983,13 +2012,16 @@
   struct mswindows_frame* msframe;
 
   assert (!GetWindowLong (hwnd, GWL_USERDATA));
-  switch (message)
+  switch (message_)
     {
     case WM_DESTROYCLIPBOARD:
       /* We own the clipboard and someone else wants it.  Delete our
 	 cached copy of the clipboard contents so we'll ask for it from
-	 Windows again when someone does a paste. */
-      handle_selection_clear(QCLIPBOARD);
+	 Windows again when someone does a paste, and destroy any memory
+         objects we hold on the clipboard that are not in the list of types
+         that Windows will delete itself. */
+      mswindows_destroy_selection (QCLIPBOARD);
+      handle_selection_clear (QCLIPBOARD);
       break;
 
     case WM_ERASEBKGND:
@@ -2016,7 +2048,7 @@
 	if (mswindows_debug_events)
 	  {
 	    stderr_out ("%s wparam=%d lparam=%d\n",
-			message == WM_KEYUP ? "WM_KEYUP" : "WM_SYSKEYUP",
+			message_ == WM_KEYUP ? "WM_KEYUP" : "WM_SYSKEYUP",
 			wParam, (int)lParam);
 	    output_alt_keyboard_state ();
 	  }	    
@@ -2037,7 +2069,7 @@
 	  }
 
 	if (should_set_keymap)
-	  //	    && (message != WM_SYSKEYUP
+	  //	    && (message_ != WM_SYSKEYUP
 	  //	|| NILP (Vmenu_accelerator_enabled)))
 	  SetKeyboardState (keymap);
 
@@ -2073,7 +2105,7 @@
 	if (mswindows_debug_events)
 	  {
 	    stderr_out ("%s wparam=%d lparam=%d\n",
-			message == WM_KEYDOWN ? "WM_KEYDOWN" : "WM_SYSKEYDOWN",
+			message_ == WM_KEYDOWN ? "WM_KEYDOWN" : "WM_SYSKEYDOWN",
 			wParam, (int)lParam);
 	    output_alt_keyboard_state ();
 	  }	    
@@ -2087,7 +2119,7 @@
 	    GetKeyboardState (keymap_sticky);
 	    if (keymap_sticky[VK_MENU] & 0x80)
 	      {
-		message = WM_SYSKEYDOWN;
+		message_ = WM_SYSKEYDOWN;
 		/* We have to set the "context bit" so that the
 		   TranslateMessage() call below that generates the
 		   SYSCHAR message does its thing; see the documentation
@@ -2118,7 +2150,7 @@
 	    int got_accelerator = 0;
 	  
 	    msg.hwnd = hwnd;
-	    msg.message = message;
+	    msg.message = message_;
 	    msg.wParam = wParam;
 	    msg.lParam = lParam;
 	    msg.time = GetMessageTime();
@@ -2139,7 +2171,7 @@
 	      }
 
 	    if (!NILP (Vmenu_accelerator_enabled) &&
-		!(mods & XEMACS_MOD_SHIFT) && message == WM_SYSKEYDOWN)
+		!(mods & XEMACS_MOD_SHIFT) && message_ == WM_SYSKEYDOWN)
 	      potential_accelerator = 1;
 
 	    /* Remove shift modifier from an ascii character */
@@ -2186,7 +2218,7 @@
 		    ++mswindows_quit_chars_count;
 		  }
 		else if (potential_accelerator && !got_accelerator &&
-			 msw_char_is_accelerator (frame, ch))
+			 mswindows_char_is_accelerator (frame, ch))
 		  {
 		    got_accelerator = 1;
 		    break;
@@ -2218,7 +2250,7 @@
       /* Real middle mouse button has nothing to do with emulated one:
 	 if one wants to exercise fingers playing chords on the mouse,
 	 he is allowed to do that! */
-      mswindows_enqueue_mouse_button_event (hwnd, message,
+      mswindows_enqueue_mouse_button_event (hwnd, message_,
 					    MAKEPOINTS (lParam), GetMessageTime());
       break;
 
@@ -2533,21 +2565,31 @@
     case WM_DISPLAYCHANGE:
       {
 	struct device *d;
+	DWORD message_tick = GetMessageTime ();
 
 	fobj = mswindows_find_frame (hwnd);
 	frame = XFRAME (fobj);
 	d = XDEVICE (FRAME_DEVICE (frame));
 
-	DEVICE_MSWINDOWS_HORZRES(d) = LOWORD (lParam);
-	DEVICE_MSWINDOWS_VERTRES(d) = HIWORD (lParam);
-	DEVICE_MSWINDOWS_BITSPIXEL(d) = wParam;
-	break;
+	/* Do this only once per message. XEmacs can receive this message
+	   through as many frames as it currently has open. Message time
+	   will be the same for all these messages. Despite extreme
+	   efficiency, the code below has about one in 4 billion
+	   probability that the HDC is not recreated, provided that
+	   XEmacs is running sufficiently longer than 52 days. */
+	if (DEVICE_MSWINDOWS_UPDATE_TICK(d) != message_tick)
+	  {
+	    DEVICE_MSWINDOWS_UPDATE_TICK(d) = message_tick;
+	    DeleteDC (DEVICE_MSWINDOWS_HCDC(d));
+	    DEVICE_MSWINDOWS_HCDC(d) = CreateCompatibleDC (NULL);
+	  }
       }
+      break;
 
       /* Misc magic events which only require that the frame be identified */
     case WM_SETFOCUS:
     case WM_KILLFOCUS:
-      mswindows_enqueue_magic_event (hwnd, message);
+      mswindows_enqueue_magic_event (hwnd, message_);
       break;
 
     case WM_WINDOWPOSCHANGING:
@@ -2696,7 +2738,7 @@
 	  break;
 #endif
 
-	return DefWindowProc (hwnd, message, wParam, lParam);
+	return DefWindowProc (hwnd, message_, wParam, lParam);
 	/* Bite me - a spurious command. This used to not be able to
 	   happen but with the introduction of widgets its now
 	   possible. */
@@ -2796,7 +2838,7 @@
 	    DragQueryFile ((HANDLE) wParam, i, fname, len+1);
 
 	    /* May be a shell link aka "shortcut" - replace fname if so */
-#if !(defined(__CYGWIN32__) || defined(__MINGW32__))
+#if !(defined(CYGWIN) || defined(MINGW))
 	    /* cygwin doesn't define this COM stuff */
 	    if (!stricmp (fname + strlen (fname) - 4, ".LNK"))
 	      {
@@ -2833,7 +2875,7 @@
 	      }
 #endif
 
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
 	    filename = xmalloc (cygwin32_win32_to_posix_path_list_buf_size (fname) + 5);
 	    strcpy (filename, "file:");
 	    cygwin32_win32_to_posix_path_list (fname, filename+5);
@@ -2858,7 +2900,7 @@
 
     defproc:
     default:
-      return DefWindowProc (hwnd, message, wParam, lParam);
+      return DefWindowProc (hwnd, message_, wParam, lParam);
     }
   return (0);
 }
--- a/src/event-stream.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/event-stream.c	Mon Aug 13 11:19:21 2007 +0200
@@ -4120,7 +4120,7 @@
 	       soon as a command other than self-insert-command is executed.
 
 	       Programmers can also use the `self-insert-defer-undo'
-	       property to install that behaviour on functions other
+	       property to install that behavior on functions other
 	       than `self-insert-command', or to change the magic
 	       number 20 to something else.  #### DOCUMENT THIS!  */
 
--- a/src/events.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/events.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1009,7 +1009,7 @@
 	      k = QKbackspace;
 	      m &= ~XEMACS_MOD_CONTROL;
 	    }
-#endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
+#endif /* defined(HAVE_TTY) && !defined(CYGWIN) */
 	  break;
 	}
       if (c >= 'A' && c <= 'Z') c -= 'A'-'a';
@@ -1018,7 +1018,7 @@
   else if (do_backspace_mapping &&
 	   CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char))
     k = QKbackspace;
-#endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
+#endif /* defined(HAVE_TTY) && !defined(CYGWIN) */
   else if (c == 127)
     k = QKdelete;
   else if (c == ' ')
--- a/src/fileio.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/fileio.c	Mon Aug 13 11:19:21 2007 +0200
@@ -24,7 +24,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "events.h"
@@ -54,24 +53,13 @@
 #endif /* HPUX_PRE_8_0 */
 #endif /* HPUX */
 
-#ifdef WINDOWSNT
-#define NOMINMAX 1
-#include <direct.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#endif /* not WINDOWSNT */
-
-#ifdef WINDOWSNT
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-    else unixtodos_filename (s); \
-  } while (0)
+#ifdef WIN32_NATIVE
 #define IS_DRIVE(x) isalpha (x)
 /* Need to lower-case the drive letter, or else expanded
    filenames will sometimes compare inequal, because
    `expand-file-name' doesn't always down-case the drive letter.  */
 #define DRIVE_LETTER(x) tolower (x)
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 int lisp_to_time (Lisp_Object, time_t *);
 Lisp_Object time_to_lisp (time_t);
@@ -432,7 +420,7 @@
   p = beg + XSTRING_LENGTH (file);
 
   while (p != beg && !IS_ANY_SEP (p[-1])
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	 /* only recognize drive specifier at beginning */
 	 && !(p[-1] == ':' && p == beg + 2)
 #endif
@@ -440,14 +428,14 @@
 
   if (p == beg)
     return Qnil;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Expansion of "c:" to drive and default directory.  */
   /* (NT does the right thing.)  */
   if (p == beg + 2 && beg[1] == ':')
     {
       /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir.  */
       Bufbyte *res = (Bufbyte*) alloca (MAXPATHLEN + 1);
-      if (getdefdir (toupper (*beg) - 'A' + 1, (char *)res))
+      if (_getdcwd (toupper (*beg) - 'A' + 1, (char *)res, MAXPATHLEN))
 	{
 	  char *c=((char *) res) + strlen ((char *) res);
 	  if (!IS_DIRECTORY_SEP (*c))
@@ -459,7 +447,7 @@
 	  p = beg + strlen ((char *) beg);
 	}
     }
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
   return make_string (beg, p - beg);
 }
 
@@ -487,7 +475,7 @@
   end = p = beg + XSTRING_LENGTH (file);
 
   while (p != beg && !IS_ANY_SEP (p[-1])
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	 /* only recognize drive specifier at beginning */
 	 && !(p[-1] == ':' && p == beg + 2)
 #endif
@@ -589,9 +577,9 @@
   strcpy (dst, src);
   if (slen > 1
       && IS_DIRECTORY_SEP (dst[slen - 1])
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       && !IS_ANY_SEP (dst[slen - 2])
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
       )
     dst[slen - 1] = 0;
   return 1;
@@ -758,15 +746,15 @@
   Bufbyte *newdir, *p, *o;
   int tlen;
   Bufbyte *target;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   int drive = 0;
   int collapse_newdir = 1;
 #else
   struct passwd *pw;
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
   int length;
   Lisp_Object handler;
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
   char *user;
 #endif
 
@@ -808,18 +796,18 @@
       /* Save time in some common cases - as long as default_directory
 	 is not relative, it can be canonicalized with name below (if it
 	 is needed at all) without requiring it to be expanded now.  */
-#ifdef WINDOWSNT
-      /* Detect MSDOS file names with drive specifiers.  */
+#ifdef WIN32_NATIVE
+      /* Detect Windows file names with drive specifiers.  */
       && ! (IS_DRIVE (o[0]) && (IS_DEVICE_SEP (o[1]) && IS_DIRECTORY_SEP (o[2])))
       /* Detect Windows file names in UNC format.  */
       && ! (IS_DIRECTORY_SEP (o[0]) && IS_DIRECTORY_SEP (o[1]))
 
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
 
       /* Detect Unix absolute file names (/... alone is not absolute on
-	 DOS or Windows).  */
+	 Windows).  */
       && ! (IS_DIRECTORY_SEP (o[0]))
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
       )
     {
       struct gcpro gcpro1;
@@ -837,7 +825,7 @@
     into name should be safe during all of this, though. */
   nm = XSTRING_DATA (name);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* We will force directory separators to be either all \ or /, so make
      a local copy to modify, even if there ends up being no change. */
   nm = strcpy ((char *)alloca (strlen ((char *)nm) + 1), (char *)nm);
@@ -875,14 +863,14 @@
      "//somedir".  */
   if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1]))
     nm++;
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   /* If nm is absolute, look for /./ or /../ sequences; if none are
      found, we can probably return right away.  We will avoid allocating
      a new string if name is already fully expanded.  */
   if (
       IS_DIRECTORY_SEP (nm[0])
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       && (drive || IS_DIRECTORY_SEP (nm[1]))
 #endif
       )
@@ -913,7 +901,7 @@
 	}
       if (!lose)
 	{
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  /* Make sure directories are all separated with / or \ as
 	     desired, but avoid allocation of a new string when not
 	     required. */
@@ -931,11 +919,11 @@
 	      XSTRING_DATA (name)[1] = ':';
 	    }
 	  return name;
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
 	  if (nm == XSTRING_DATA (name))
 	    return name;
 	  return build_string ((char *) nm);
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 	}
     }
 
@@ -972,7 +960,7 @@
 				Qfile_name);
 
 	  nm++;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  collapse_newdir = 0;
 #endif
 	}
@@ -991,7 +979,7 @@
 	     multiple user profiles users defined, each with its HOME.
 	     Therefore, the following should be reworked to handle
 	     this case.  */
-#ifdef  WINDOWSNT
+#ifdef  WIN32_NATIVE
 	  /* Now if the file given is "~foo/file" and HOME="c:/", then
 	     we want the file to be named "c:/file" ("~foo" becomes
 	     "c:/").  The variable o has "~foo", so we can use the
@@ -1000,8 +988,8 @@
 	  newdir = (Bufbyte *) get_home_directory();
 	  dostounix_filename (newdir);
 	  nm += strlen(o) + 1;
-#else  /* not WINDOWSNT */
-#ifdef __CYGWIN32__
+#else  /* not WIN32_NATIVE */
+#ifdef CYGWIN
 	  if ((user = user_login_name (NULL)) != NULL)
 	    {
 	      /* Does the user login name match the ~name? */
@@ -1013,7 +1001,7 @@
 	    }
           if (! newdir)
             {
-#endif /* __CYGWIN32__ */
+#endif /* CYGWIN */
 	  /* Jamie reports that getpwnam() can get wedged by SIGIO/SIGALARM
 	     occurring in it. (It can call select()). */
 	  slow_down_interrupts ();
@@ -1024,17 +1012,17 @@
 	      newdir = (Bufbyte *) pw -> pw_dir;
 	      nm = p;
 	    }
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
 	    }
 #endif
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 
 	  /* If we don't find a user of that name, leave the name
 	     unchanged; don't move nm forward to p.  */
 	}
     }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* On DOS and Windows, nm is absolute if a drive name was specified;
      use the drive's current directory as the prefix if needed.  */
   if (!newdir && drive)
@@ -1043,7 +1031,7 @@
       if (!IS_DIRECTORY_SEP (nm[0]))
 	{
 	  newdir = alloca (MAXPATHLEN + 1);
-	  if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
+	  if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN))
 	    newdir = NULL;
 	}
       if (!newdir)
@@ -1056,13 +1044,13 @@
 	  newdir[3] = 0;
 	}
     }
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   /* Finally, if no prefix has been specified and nm is not absolute,
      then it must be expanded relative to default_directory. */
 
   if (1
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
       /* /... alone is not absolute on DOS and Windows. */
       && !IS_DIRECTORY_SEP (nm[0])
 #else
@@ -1073,12 +1061,12 @@
       newdir = XSTRING_DATA (default_directory);
     }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   if (newdir)
     {
       /* First ensure newdir is an absolute name. */
       if (
-	  /* Detect MSDOS file names with drive specifiers.  */
+	  /* Detect Windows file names with drive specifiers.  */
 	  ! (IS_DRIVE (newdir[0])
 	     && IS_DEVICE_SEP (newdir[1]) && IS_DIRECTORY_SEP (newdir[2]))
 	  /* Detect Windows file names in UNC format.  */
@@ -1108,7 +1096,7 @@
 	  newdir = alloca (MAXPATHLEN + 1);
 	  if (drive)
 	    {
-	      if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
+	      if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN))
 		newdir = "/";
 	    }
 	  else
@@ -1139,7 +1127,7 @@
 	    newdir = "";
 	}
     }
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   if (newdir)
     {
@@ -1147,7 +1135,7 @@
 	 just // (an incomplete UNC name).  */
       length = strlen ((char *) newdir);
       if (length > 1 && IS_DIRECTORY_SEP (newdir[length - 1])
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  && !(length == 2 && IS_DIRECTORY_SEP (newdir[0]))
 #endif
 	  )
@@ -1164,14 +1152,14 @@
 
   /* Now concatenate the directory and name to new space in the stack frame */
   tlen += strlen ((char *) nm) + 1;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Add reserved space for drive name.  (The Microsoft x86 compiler
      produces incorrect code if the following two lines are combined.)  */
   target = (Bufbyte *) alloca (tlen + 2);
   target += 2;
-#else  /* not WINDOWSNT */
+#else  /* not WIN32_NATIVE */
   target = (Bufbyte *) alloca (tlen);
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
   *target = 0;
 
   if (newdir)
@@ -1220,7 +1208,7 @@
 	    ++o;
 	  p += 3;
 	}
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       /* if drive is set, we're not dealing with an UNC, so
 	 multiple dir-seps are redundant (and reportedly cause trouble
 	 under win95) */
@@ -1233,7 +1221,7 @@
 	}
     }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* At last, set drive name, except for network file name.  */
   if (drive)
     {
@@ -1246,7 +1234,7 @@
       assert (IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]));
     }
   CORRECT_DIR_SEPS (target);
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
   return make_string (target, o - target);
 }
@@ -1428,12 +1416,12 @@
   for (p = nm; p != endp; p++)
     {
       if ((p[0] == '~'
-#if defined (WINDOWSNT) || defined (__CYGWIN32__)
+#if defined (WIN32_NATIVE) || defined (CYGWIN)
 	   /* // at start of file name is meaningful in WindowsNT systems */
 	   || (IS_DIRECTORY_SEP (p[0]) && p - 1 != nm)
-#else /* not (WINDOWSNT || __CYGWIN32__) */
+#else /* not (WIN32_NATIVE || CYGWIN) */
 	   || IS_DIRECTORY_SEP (p[0])
-#endif /* not (WINDOWSNT || __CYGWIN32__) */
+#endif /* not (WIN32_NATIVE || CYGWIN) */
 	   )
 	  && p != nm
 	  && (IS_DIRECTORY_SEP (p[-1])))
@@ -1441,7 +1429,7 @@
 	  nm = p;
 	  substituted = 1;
 	}
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       /* see comment in expand-file-name about drive specifiers */
       else if (IS_DRIVE (p[0]) && p[1] == ':'
 	       && p > nm && IS_DIRECTORY_SEP (p[-1]))
@@ -1449,7 +1437,7 @@
 	  nm = p;
 	  substituted = 1;
 	}
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
     }
 
   /* See if any variables are substituted into the string
@@ -1489,9 +1477,9 @@
 	target = (Bufbyte *) alloca (s - o + 1);
 	strncpy ((char *) target, (char *) o, s - o);
 	target[s - o] = 0;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	strupr (target); /* $home == $HOME etc.  */
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 	/* Get variable value */
 	o = (Bufbyte *) egetenv ((char *) target);
@@ -1540,9 +1528,9 @@
 	target = (Bufbyte *) alloca (s - o + 1);
 	strncpy ((char *) target, (char *) o, s - o);
 	target[s - o] = 0;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	strupr (target); /* $home == $HOME etc.  */
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 	/* Get variable value */
 	o = (Bufbyte *) egetenv ((char *) target);
@@ -1559,16 +1547,16 @@
 
   for (p = xnm; p != x; p++)
     if ((p[0] == '~'
-#if defined (WINDOWSNT)
+#if defined (WIN32_NATIVE)
 	 || (IS_DIRECTORY_SEP (p[0]) && p - 1 != xnm)
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
 	 || IS_DIRECTORY_SEP (p[0])
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 	 )
 	/* don't do p[-1] if that would go off the beginning --jwz */
 	&& p != nm && p > xnm && IS_DIRECTORY_SEP (p[-1]))
       xnm = p;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
     else if (IS_DRIVE (p[0]) && p[1] == ':'
 	     && p > nm && IS_DIRECTORY_SEP (p[-1]))
 	xnm = p;
@@ -1743,7 +1731,7 @@
      copyable by us. */
   input_file_statable_p = (fstat (ifd, &st) >= 0);
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   if (out_st.st_mode != 0
       && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino)
     {
@@ -1981,13 +1969,10 @@
 				  INTP (ok_if_already_exists), 0);
 
 /* Syncing with FSF 19.34.6 note: FSF does not have conditional code for
-   WINDOWSNT here; I've removed it.  --marcpa */
-
-    /* FSFmacs only calls rename() here under BSD 4.1, and calls
-       link() and unlink() otherwise, but that's bogus.  Sometimes
-       rename() succeeds where link()/unlink() fail, and we have
-       configure check for rename() and emulate using link()/unlink()
-       if necessary. */
+   WIN32_NATIVE here; I've removed it.  --marcpa */
+
+  /* We have configure check for rename() and emulate using
+     link()/unlink() if necessary. */
   if (0 > rename ((char *) XSTRING_DATA (filename),
 		  (char *) XSTRING_DATA (newname)))
     {
@@ -2052,10 +2037,10 @@
 /* But FSF #defines link as sys_link which is supplied in nt.c. We can't do
    that because sysfile.h defines sys_link depending on ENCAPSULATE_LINK.
    Reverted to previous behavior pending a working fix. (jhar) */
-#if defined(WINDOWSNT)
+#if defined(WIN32_NATIVE)
   /* Windows does not support this operation.  */
   report_file_error ("Adding new name", Flist (2, &filename));
-#else /* not defined(WINDOWSNT) */
+#else /* not defined(WIN32_NATIVE) */
 
   unlink ((char *) XSTRING_DATA (newname));
   if (0 > link ((char *) XSTRING_DATA (filename),
@@ -2064,7 +2049,7 @@
       report_file_error ("Adding new name",
 			 list2 (filename, newname));
     }
-#endif /* defined(WINDOWSNT) */
+#endif /* defined(WIN32_NATIVE) */
 
   UNGCPRO;
   return Qnil;
@@ -2166,7 +2151,7 @@
   CHECK_STRING (filename);
   ptr = XSTRING_DATA (filename);
   return (IS_DIRECTORY_SEP (*ptr) || *ptr == '~'
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  || (IS_DRIVE (*ptr) && ptr[1] == ':' && IS_DIRECTORY_SEP (ptr[2]))
 #endif
 	  ) ? Qt : Qnil;
@@ -2177,12 +2162,12 @@
 static int
 check_executable (char *filename)
 {
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   struct stat st;
   if (stat (filename, &st) < 0)
     return 0;
   return ((st.st_mode & S_IEXEC) != 0);
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
 #ifdef HAVE_EACCESS
   return eaccess (filename, 1) >= 0;
 #else
@@ -2191,7 +2176,7 @@
      But Unix doesn't give us a right way to do it.  */
   return access (filename, 1) >= 0;
 #endif /* HAVE_EACCESS */
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 }
 
 /* Return nonzero if file FILENAME exists and can be written.  */
@@ -2284,14 +2269,14 @@
   if (!NILP (handler))
     RETURN_UNGCPRO (call2 (handler, Qfile_readable_p, abspath));
 
-#if defined(WINDOWSNT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
   /* Under MS-DOS and Windows, open does not work for directories.  */
   UNGCPRO;
   if (access (XSTRING_DATA (abspath), 0) == 0)
     return Qt;
   else
     return Qnil;
-#else /* not WINDOWSNT */
+#else /* not WIN32_NATIVE */
   {
     int desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY | OPEN_BINARY, 0);
     UNGCPRO;
@@ -2300,7 +2285,7 @@
     close (desc);
     return Qt;
   }
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 }
 
 /* Having this before file-symlink-p mysteriously caused it to be forgotten
@@ -2445,7 +2430,7 @@
     return call2 (handler, Qfile_accessible_directory_p,
 		  filename);
 
-#if !defined(WINDOWSNT)
+#if !defined(WIN32_NATIVE)
   if (NILP (Ffile_directory_p (filename)))
       return (Qnil);
   else
@@ -2466,7 +2451,7 @@
     UNGCPRO;
     return tem ? Qnil : Qt;
   }
-#endif /* !defined(WINDOWSNT) */
+#endif /* !defined(WIN32_NATIVE) */
 }
 
 DEFUN ("file-regular-p", Ffile_regular_p, 1, 1, 0, /*
@@ -2526,10 +2511,10 @@
     return Qnil;
   /* Syncing with FSF 19.34.6 note: not in FSF, #if 0'ed out here. */
 #if 0
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   if (check_executable (XSTRING_DATA (abspath)))
     st.st_mode |= S_IEXEC;
-#endif /* DOS_NT */
+#endif /* WIN32_NATIVE */
 #endif /* 0 */
 
   return make_int (st.st_mode & 07777);
@@ -2603,7 +2588,7 @@
 */
        ())
 {
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   sync ();
 #endif
   return Qnil;
@@ -4311,7 +4296,7 @@
 on other platforms, it is initialized so that Lisp code can find out
 what the normal separator is.
 */ );
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   Vdirectory_sep_char = make_char ('\\');
 #else
   Vdirectory_sep_char = make_char ('/');
--- a/src/fns.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/fns.c	Mon Aug 13 11:19:21 2007 +0200
@@ -36,10 +36,7 @@
 
 #include "lisp.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
+#include "sysfile.h"
 
 #include "buffer.h"
 #include "bytecode.h"
@@ -992,7 +989,11 @@
       return result;
     }
   else
-    abort (); /* unreachable, since Flength (sequence) did not get an error */
+    {
+      abort (); /* unreachable, since Flength (sequence) did not get
+                   an error */
+      return Qnil;
+    }
 }
 
 
--- a/src/frame-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/frame-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -81,6 +81,21 @@
 /*-----                    DISPLAY FRAME                          -----*/
 /*---------------------------------------------------------------------*/
 
+HWND
+mswindows_get_selected_frame_hwnd (void)
+{
+  Lisp_Object frame, device;
+
+  device = Ffind_device (Qnil, Qmswindows);
+  if (NILP (device))
+    return NULL;
+  frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
+  if (NILP (frame))
+    return NULL;
+
+  return FRAME_MSWINDOWS_HANDLE (XFRAME (frame));
+}
+
 static void
 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
 {
@@ -638,7 +653,7 @@
   not restrictive since this will happen later anyway in WM_SIZE.  We
   have to do this after adjusting the rect to account for menubar
   etc. */
-  msw_get_workspace_coords (&ws_rect);
+  mswindows_get_workspace_coords (&ws_rect);
   pixel_width = rect.right - rect.left;
   pixel_height = rect.bottom - rect.top;
   if (pixel_width > ws_rect.right - ws_rect.left)
@@ -718,6 +733,20 @@
 /*-----                    PRINTER FRAME                          -----*/
 /*---------------------------------------------------------------------*/
 
+/*
+ * With some drvier/os combination (I discovered this with HP drviers
+ * under W2K), DC geometry is reset upon StartDoc and EndPage
+ * calls. This is called every time one of these calls is made.
+ */
+static void
+apply_dc_geometry (struct frame* f)
+{
+  HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
+  SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
+  SetViewportOrgEx (hdc, FRAME_MSPRINTER_PIXLEFT(f),
+		    FRAME_MSPRINTER_PIXTOP(f), NULL);
+}
+
 void
 msprinter_start_page (struct frame *f)
 {
@@ -725,6 +754,7 @@
     {
       FRAME_MSPRINTER_PAGE_STARTED (f) = 1;
       StartPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
+      apply_dc_geometry (f);
     }
 }
 
@@ -764,10 +794,6 @@
   /* Negative for "uinspecified" */
   FRAME_MSPRINTER_CHARWIDTH(f) = -1;
   FRAME_MSPRINTER_CHARHEIGHT(f) = -1;
-
-  /* nil is for "system default" for these properties. */
-  FRAME_MSPRINTER_ORIENTATION(f) = Qnil;
-  FRAME_MSPRINTER_DUPLEX(f) = Qnil;
 }
 
 static void
@@ -778,39 +804,6 @@
   HDC hdc;
   int frame_left, frame_top, frame_width, frame_height;
 
-  /* Change printer parameters */
-  {
-    DEVMODE* devmode = msprinter_get_devmode_copy (device);
-    devmode->dmFields = 0;
-
-    if (!NILP (FRAME_MSPRINTER_ORIENTATION(f)))
-      {
-	devmode->dmFields = DM_ORIENTATION;
-	if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qportrait))
-	  devmode->dmOrientation = DMORIENT_PORTRAIT;
-	else if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qlandscape))
-	  devmode->dmOrientation = DMORIENT_LANDSCAPE;
-	else
-	  abort();
-      }
-
-    if (!NILP (FRAME_MSPRINTER_DUPLEX(f)))
-      {
-	devmode->dmFields = DM_DUPLEX;
-	if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qnone))
-	  devmode->dmDuplex = DMDUP_SIMPLEX;
-	if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qvertical))
-	  devmode->dmDuplex = DMDUP_VERTICAL;
-	if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qhorizontal))
-	  devmode->dmDuplex = DMDUP_HORIZONTAL;
-	else
-	  abort();
-      }
-
-    assert (!FRAME_MSPRINTER_PAGE_STARTED (f));
-    msprinter_apply_devmode (device, devmode);
-  }
-
   /* DC might be recreated in msprinter_apply_devmode,
      so do not initialize until now */
   hdc = DEVICE_MSPRINTER_HDC (device);
@@ -874,10 +867,8 @@
     change_frame_size (f, rows, columns, 0);
   }
 
-  /* Apply DC geometry */
-  SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
-  SetViewportOrgEx (hdc, frame_left, frame_top, NULL);
-  SetWindowOrgEx (hdc, 0, 0, NULL);
+  FRAME_MSPRINTER_PIXLEFT(f) = frame_left;
+  FRAME_MSPRINTER_PIXTOP(f) = frame_top;
 
   /* Start print job */
   di.cbSize = sizeof (di);
@@ -891,6 +882,8 @@
   if (StartDoc (hdc, &di) <= 0)
     error ("Cannot start print job");
 
+  apply_dc_geometry (f);
+
   /* Finish frame setup */
   FRAME_MSPRINTER_JOB_STARTED (f) = 1;
   FRAME_VISIBLE_P(f) = 0;
@@ -899,12 +892,6 @@
 static void
 msprinter_mark_frame (struct frame *f)
 {
-  /* NOTE: These need not be marked as long as we allow only c-defined
-     symbols for their values.  Although, marking these is safer than
-     expensive.  [I know a proof to the theorem postulating that a
-     gator is longer than greener. Ask me. -- kkm] */
-  mark_object (FRAME_MSPRINTER_ORIENTATION (f));
-  mark_object (FRAME_MSPRINTER_DUPLEX (f));
 }
 
 static void
@@ -934,10 +921,6 @@
     return make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f));
   else if (EQ (Qbottom_margin, property))
     return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f));
-  else if (EQ (Qorientation, property))
-    return FRAME_MSPRINTER_ORIENTATION(f);
-  else if (EQ (Qduplex, property))
-    return FRAME_MSPRINTER_DUPLEX(f);
   else
     return Qunbound;
 }
@@ -946,16 +929,13 @@
 msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property)
 {
   return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) ||
-	  EQ (Qright_margin, property) || EQ (Qbottom_margin, property) ||
-	  EQ (Qorientation, property) || EQ (Qduplex, property));
+	  EQ (Qright_margin, property) || EQ (Qbottom_margin, property));
 }
 
 static Lisp_Object
 msprinter_frame_properties (struct frame *f)
 {
   Lisp_Object props = Qnil;
-  props = cons3 (Qorientation, FRAME_MSPRINTER_ORIENTATION(f), props);
-  props = cons3 (Qduplex, FRAME_MSPRINTER_DUPLEX(f), props);
   props = cons3 (Qbottom_margin,
 		 make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f)), props);
   props = cons3 (Qright_margin,
@@ -1022,29 +1002,6 @@
 	      CHECK_NATNUM (val);
 	      FRAME_MSPRINTER_BOTTOM_MARGIN(f) = XINT (val);
 	    }
-	  else if (EQ (prop, Qorientation))
-	    {
-	      maybe_error_if_job_active (f);
-	      CHECK_SYMBOL (val);
-	      if (!NILP(val) &&
-		  !EQ (val, Qportrait) &&
-		  !EQ (val, Qlandscape))
-		signal_simple_error ("Page orientation can only be "
-				     "'portrait or 'landscape", val);
-	      FRAME_MSPRINTER_ORIENTATION(f) = val;
-	    }
-	  else if (EQ (prop, Qduplex))
-	    {
-	      maybe_error_if_job_active (f);
-	      CHECK_SYMBOL (val);
-	      if (!NILP(val) &&
-		  !EQ (val, Qnone) &&
-		  !EQ (val, Qvertical) &&
-		  !EQ (val, Qhorizontal))
-		signal_simple_error ("Duplex can only be 'none, "
-				     "'vertical or 'horizontal", val);
-	      FRAME_MSPRINTER_DUPLEX(f) = val;
-	    }
 	}
     }
 }
@@ -1064,6 +1021,7 @@
     {
       FRAME_MSPRINTER_PAGE_STARTED (f) = 0;
       EndPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
+      apply_dc_geometry (f);
     }
 }
 
@@ -1212,17 +1170,6 @@
 	  (setq default-frame-plist '(height 55 'width 80)
 		default-msprinter-frame-plist '(height nil 'width nil))
 
-
-  orientation                   Printer page orientation. Can be 'nil,
-				indicating system default, 'portrait
-				or 'landscape.
-
-  duplex			Duplex printing mode, subject to printer
-				support. Can be 'nil for the device default,
-				'none for simplex printing, 'vertical or
-				'horizontal for duplex page bound along
-				the corresponding page direction.
-
 See also `default-frame-plist', which specifies properties which apply
 to all frames, not just mswindows frames.
 */ );
--- a/src/frame.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/frame.c	Mon Aug 13 11:19:21 2007 +0200
@@ -268,7 +268,9 @@
 	      FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame))))
     error ("frame and minibuffer must be on the same console");
 
-  if (NILP (mini_window))
+  /* Do not create a default minibuffer frame on printer devices.  */
+  if (NILP (mini_window)
+      && DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (f))))
     {
       struct console *con = XCONSOLE (FRAME_CONSOLE (f));
       /* Use default-minibuffer-frame if possible.  */
@@ -283,8 +285,13 @@
     }
 
   /* Install the chosen minibuffer window, with proper buffer.  */
-  store_minibuf_frame_prop (f, mini_window);
-  Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
+  if (!NILP (mini_window))
+    {
+      store_minibuf_frame_prop (f, mini_window);
+      Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
+    }
+  else
+    f->minibuffer_window = Qnil;
 }
 
 /* Make a frame containing only a minibuffer window.  */
@@ -3409,7 +3416,7 @@
 */ );
 /* #### I would change this unilaterally but for the wrath of the Kyles
 of the world. */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   Vframe_title_format = build_string ("%b - XEmacs");
 #else
   Vframe_title_format = build_string ("%S: %b");
--- a/src/general.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/general.c	Mon Aug 13 11:19:21 2007 +0200
@@ -36,6 +36,7 @@
 Lisp_Object Qafter;
 Lisp_Object Qall;
 Lisp_Object Qand;
+Lisp_Object Qappend;
 Lisp_Object Qassoc;
 Lisp_Object Qat;
 Lisp_Object Qautodetect;
@@ -59,6 +60,7 @@
 Lisp_Object Qcolumns;
 Lisp_Object Qcommand;
 Lisp_Object Qconsole;
+Lisp_Object Qcopies;
 Lisp_Object Qcritical;
 Lisp_Object Qctext;
 Lisp_Object Qcursor;
@@ -84,6 +86,8 @@
 Lisp_Object Qfile_name;
 Lisp_Object Qfont;
 Lisp_Object Qframe;
+Lisp_Object Qfrom_page;
+Lisp_Object Qfull_assoc;
 Lisp_Object Qfuncall;
 Lisp_Object Qfunction;
 Lisp_Object Qgap_overhead;
@@ -178,6 +182,7 @@
 Lisp_Object Qtoolbar;
 Lisp_Object Qtop;
 Lisp_Object Qtop_margin;
+Lisp_Object Qto_page;
 Lisp_Object Qtty;
 Lisp_Object Qtype;
 Lisp_Object Qundecided;
@@ -202,6 +207,7 @@
   defsymbol (&Qafter, "after");
   defsymbol (&Qall, "all");
   defsymbol (&Qand, "and");
+  defsymbol (&Qappend, "append");
   defsymbol (&Qassoc, "assoc");
   defsymbol (&Qat, "at");
   defsymbol (&Qautodetect, "autodetect");
@@ -225,6 +231,7 @@
   defsymbol (&Qcolumns, "columns");
   defsymbol (&Qcommand, "command");
   defsymbol (&Qconsole, "console");
+  defsymbol (&Qcopies, "copies");
   defsymbol (&Qcritical, "critical");
   defsymbol (&Qctext, "ctext");
   defsymbol (&Qcursor, "cursor");
@@ -250,6 +257,9 @@
   defsymbol (&Qfile_name, "file-name");
   defsymbol (&Qfont, "font");
   defsymbol (&Qframe, "frame");
+  defsymbol (&Qfrom_page, "from-page");
+  defsymbol (&Qfunction, "function");
+  defsymbol (&Qfull_assoc, "full-assoc");
   defsymbol (&Qfuncall, "funcall");
   defsymbol (&Qfunction, "function");
   defsymbol (&Qgap_overhead, "gap-overhead");
@@ -344,6 +354,7 @@
   defsymbol (&Qtoolbar, "toolbar");
   defsymbol (&Qtop, "top");
   defsymbol (&Qtop_margin, "top-margin");
+  defsymbol (&Qto_page, "to-page");
   defsymbol (&Qtty, "tty");
   defsymbol (&Qtype, "type");
   defsymbol (&Qundecided, "undecided");
--- a/src/getloadavg.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/getloadavg.c	Mon Aug 13 11:19:21 2007 +0200
@@ -44,7 +44,6 @@
    convex
    DGUX
    hpux
-   MSDOS			No-op for MSDOS.
    NeXT
    sgi
    sequent			Sequent Dynix 3.x.x (BSD)
@@ -52,7 +51,7 @@
    sony_news                    NEWS-OS (works at least for 4.1C)
    UMAX
    UMAX4_3
-   WIN32			No-op for Windows95/NT.
+   WIN32_NATIVE			No-op for Windows95/NT.
    __linux__			Linux: assumes /proc filesystem mounted.
    				Support from Michael K. Johnson.
    __NetBSD__			NetBSD: assumes /kern filesystem mounted.
@@ -69,8 +68,11 @@
 #include <config.h>
 #endif
 
-#ifndef WINDOWSNT
-#ifndef __CYGWIN32__
+#include "lisp.h"
+#include "sysfile.h" /* for encapsulated open, close, read, write */
+
+#ifndef WIN32_NATIVE
+#ifndef CYGWIN
 
 #include <sys/types.h>
 
@@ -81,10 +83,6 @@
 #include <sys/param.h>
 #endif
 
-#ifdef XEMACS
-#include "lisp.h"
-#include "sysfile.h" /* for encapsulated open, close, read, write */
-#endif /* XEMACS */
 
 /* Exclude all the code except the test program at the end
    if the system has its own `getloadavg' function.
@@ -110,11 +108,9 @@
 #define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
 #endif
 
-#ifdef XEMACS
 #if defined (HAVE_KSTAT_H)
 #include <kstat.h>
 #endif /* HAVE_KSTAT_H */
-#endif /* XEMACS */
 
 #if !defined (BSD) && defined (ultrix)
 /* Ultrix behaves like BSD on Vaxen.  */
@@ -457,11 +453,9 @@
 #include <sys/dg_sys_info.h>
 #endif
 
-#ifdef XEMACS
 #if defined (HAVE_SYS_PSTAT_H)
 #include <sys/pstat.h>
 #endif /* HAVE_SYS_PSTAT_H (on HPUX) */
-#endif /* XEMACS */
 
 #if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
 #include <fcntl.h>
@@ -779,7 +773,7 @@
        : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
 #endif	/* OSF_MIPS */
 
-#if !defined (LDAV_DONE) && (defined (MSDOS) || defined (WIN32))
+#if !defined (LDAV_DONE) && defined (WIN32_NATIVE)
 #define LDAV_DONE
 
   /* A faithful emulation is going to have to be saved for a rainy day.  */
@@ -787,7 +781,7 @@
     {
       loadavg[elem] = 0.0;
     }
-#endif  /* MSDOS */
+#endif  /* WIN32_NATIVE */
 
 #if !defined (LDAV_DONE) && defined (OSF_ALPHA)
 #define LDAV_DONE
@@ -978,4 +972,4 @@
 }
 
 #endif /*__GNUWIN32__*/
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
--- a/src/gif_io.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/gif_io.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1,7 +1,11 @@
+#include <config.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include "gifrlib.h"
 #include "sysfile.h"
 
--- a/src/glyphs-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/glyphs-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1140,7 +1140,7 @@
 #define OIC_BANG            32515
 #define OIC_NOTE            32516
 #define OIC_WINLOGO         32517
-#if defined (__CYGWIN32__) && CYGWIN_VERSION_DLL_MAJOR < 21
+#if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21
 #define LR_SHARED           0x8000
 #endif
 #endif
@@ -1289,7 +1289,7 @@
       TO_EXTERNAL_FORMAT (LISP_STRING, file,
 			  C_STRING_ALLOCA, f,
 			  Qfile_name);
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
       CYGWIN_WIN32_PATH (f, fname);
 #else
       fname = f;
--- a/src/glyphs-widget.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/glyphs-widget.c	Mon Aug 13 11:19:21 2007 +0200
@@ -375,7 +375,7 @@
    provided then use the widget text to calculate sizes. */
 static void 
 widget_query_geometry (Lisp_Object image_instance, 
-		       unsigned int* width, unsigned int* height,
+		       int* width, int* height,
 		       enum image_instance_geometry disp, Lisp_Object domain)
 {
   Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
@@ -410,7 +410,7 @@
 						   domain));
 	  else 
 	    {
-	      unsigned int w, h;
+	      int w, h;
 	      
 	      /* Then if we are allowed to resize the widget, make the
 		 size the same as the text dimensions. */
@@ -442,7 +442,7 @@
 
 static int 
 widget_layout (Lisp_Object image_instance, 
-	       unsigned int width, unsigned int height, Lisp_Object domain)
+	       int width, int height, Lisp_Object domain)
 {
   Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
   struct image_instantiator_methods* meths;
@@ -698,11 +698,11 @@
    depending on the type of button. */
 static void
 button_query_geometry (Lisp_Object image_instance, 
-		       unsigned int* width, unsigned int* height,
+		       int* width, int* height,
 		       enum image_instance_geometry disp, Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
-  unsigned int w, h;
+  int w, h;
   query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
 			 IMAGE_INSTANCE_WIDGET_FACE (ii),
 			 &w, &h, 0, domain);
@@ -724,7 +724,7 @@
 /* tree-view geometry - get the height right */
 static void
 tree_view_query_geometry (Lisp_Object image_instance, 
-			  unsigned int* width, unsigned int* height,
+			  int* width, int* height,
 			  enum image_instance_geometry disp, Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
@@ -751,7 +751,7 @@
    items and text therin in the tab control. */
 static void
 tab_control_query_geometry (Lisp_Object image_instance, 
-			    unsigned int* width, unsigned int* height,
+			    int* width, int* height,
 			    enum image_instance_geometry disp, Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
@@ -761,7 +761,7 @@
 
   LIST_LOOP (rest, items)
     {
-      unsigned int h, w;
+      int h, w;
 
       query_string_geometry (XGUI_ITEM (XCAR (rest))->name,
 			     IMAGE_INSTANCE_WIDGET_FACE (ii),
@@ -995,14 +995,14 @@
 /* Query the geometry of a layout widget. We assume that we can only
    get here if the size is not already fixed. */
 static void
-layout_query_geometry (Lisp_Object image_instance, unsigned int* width,
-		       unsigned int* height, enum image_instance_geometry disp,
+layout_query_geometry (Lisp_Object image_instance, int* width,
+		       int* height, enum image_instance_geometry disp,
 		       Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii), rest;
   int maxph = 0, maxpw = 0, nitems = 0, ph_adjust = 0;
-  unsigned int gheight, gwidth;
+  int gheight, gwidth;
 
   /* If we are not initialized then we won't have any children. */
   if (!IMAGE_INSTANCE_INITIALIZED (ii))
@@ -1082,14 +1082,14 @@
 
 int
 layout_layout (Lisp_Object image_instance, 
-	       unsigned int width, unsigned int height, Lisp_Object domain)
+	       int width, int height, Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object rest;
   Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
   int x, y, maxph = 0, maxpw = 0, nitems = 0,
     horiz_spacing, vert_spacing, ph_adjust = 0;
-  unsigned int gheight, gwidth;
+  int gheight, gwidth;
 
   /* If we are not initialized then we won't have any children. */
   if (!IMAGE_INSTANCE_INITIALIZED (ii))
@@ -1215,7 +1215,7 @@
 /* Layout subwindows if they are real subwindows. */
 static int
 native_layout_layout (Lisp_Object image_instance,
-		      unsigned int width, unsigned int height,
+		      int width, int height,
 		      Lisp_Object domain)
 {
   Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
--- a/src/glyphs-x.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/glyphs-x.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1670,7 +1670,8 @@
 {
   Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
   int i, stattis;
-  char *p, *bits, *bp;
+  char *bits, *bp;
+  const char *p;
   const char * volatile emsg = 0;
   const char * volatile dstring;
 
@@ -2547,8 +2548,6 @@
 			     Lisp_Object pointer_fg, Lisp_Object pointer_bg,
 			     int dest_mask, Lisp_Object domain)
 {
-  Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
-
   x_widget_instantiate (image_instance, instantiator, pointer_fg,
 			pointer_bg, dest_mask, domain, "layout", 0);
 }
--- a/src/glyphs.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/glyphs.c	Mon Aug 13 11:19:21 2007 +0200
@@ -724,10 +724,8 @@
   IMAGE_INSTANCE_LAYOUT_CHANGED (p) = 0;
   IMAGE_INSTANCE_DIRTYP (p) = 0;
 
-  assert ( XIMAGE_INSTANCE_HEIGHT (ii) 
-	      != IMAGE_UNSPECIFIED_GEOMETRY
-	      && XIMAGE_INSTANCE_WIDTH (ii) 
-	      != IMAGE_UNSPECIFIED_GEOMETRY);
+  assert ( XIMAGE_INSTANCE_HEIGHT (ii) >= 0 
+	   && XIMAGE_INSTANCE_WIDTH (ii) >= 0 );
 
   ERROR_CHECK_IMAGE_INSTANCE (ii);
 
@@ -1895,7 +1893,7 @@
    special function then just return the width and / or height. */
 void
 image_instance_query_geometry (Lisp_Object image_instance,
-			       unsigned int* width, unsigned int* height,
+			       int* width, int* height,
 			       enum image_instance_geometry disp,
 			       Lisp_Object domain)
 {
@@ -1930,8 +1928,7 @@
    want to specifiy something (layout widgets). */
 void
 image_instance_layout (Lisp_Object image_instance,
-		       unsigned int width, unsigned int height,
-		       Lisp_Object domain)
+		       int width, int height, Lisp_Object domain)
 {
   Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object type;
@@ -1951,8 +1948,8 @@
       ||
       height == IMAGE_UNSPECIFIED_GEOMETRY)
     {
-      unsigned int dwidth = IMAGE_UNSPECIFIED_GEOMETRY,
-	  dheight = IMAGE_UNSPECIFIED_GEOMETRY;
+      int dwidth = IMAGE_UNSPECIFIED_GEOMETRY;
+      int dheight = IMAGE_UNSPECIFIED_GEOMETRY;
 
       /* Get the desired geometry. */
       if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry))
@@ -2161,8 +2158,7 @@
    helper that is used elsewhere for calculating text geometry. */
 void
 query_string_geometry (Lisp_Object string, Lisp_Object face,
-		       unsigned int* width, unsigned int* height,
-		       unsigned int* descent, Lisp_Object domain)
+		       int* width, int* height, int* descent, Lisp_Object domain)
 {
   struct font_metric_info fm;
   unsigned char charsets[NUM_LEADING_BYTES];
@@ -2250,11 +2246,11 @@
 
 static void
 text_query_geometry (Lisp_Object image_instance,
-		     unsigned int* width, unsigned int* height,
+		     int* width, int* height,
 		     enum image_instance_geometry disp, Lisp_Object domain)
 {
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
-  unsigned int descent = 0;
+  int descent = 0;
 
   query_string_geometry (IMAGE_INSTANCE_TEXT_STRING (ii),
 			 IMAGE_INSTANCE_FACE (ii),
@@ -3015,13 +3011,16 @@
     }
   else
     {
-      Lisp_Object instance;
-      Lisp_Object subtable;
+      Lisp_Object instance = Qnil;
+      Lisp_Object subtable = Qnil;
       Lisp_Object ls3 = Qnil;
       Lisp_Object pointer_fg = Qnil;
       Lisp_Object pointer_bg = Qnil;
       Lisp_Object governing_domain =
 	get_image_instantiator_governing_domain (instantiator, domain);
+      struct gcpro gcpro1;
+      
+      GCPRO1 (instance);
 
       /* We have to put subwindow, widget and text image instances in
 	 a per-window cache so that we can see the same glyph in
@@ -3146,7 +3145,7 @@
 		    DOMAIN_FRAME (domain)));
 #endif
       ERROR_CHECK_IMAGE_INSTANCE (instance);
-      return instance;
+      RETURN_UNGCPRO (instance);
     }
 
   abort ();
@@ -4150,8 +4149,7 @@
 cache_subwindow_instance_in_frame_maybe (Lisp_Object instance)
 {
   Lisp_Image_Instance* ii = XIMAGE_INSTANCE (instance);
-  if (image_instance_type_to_mask (IMAGE_INSTANCE_TYPE (ii))
-      & (IMAGE_WIDGET_MASK | IMAGE_SUBWINDOW_MASK))
+  if (!NILP (DOMAIN_FRAME (IMAGE_INSTANCE_DOMAIN (ii))))
     {
       struct frame* f = DOMAIN_XFRAME (IMAGE_INSTANCE_DOMAIN (ii));
       XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))
@@ -4531,8 +4529,8 @@
 /* This is just a backup in case no-one has assigned a suitable geometry. 
    #### It should really query the enclose window for geometry. */
 static void
-subwindow_query_geometry (Lisp_Object image_instance, unsigned int* width,
-			  unsigned int* height, enum image_instance_geometry disp,
+subwindow_query_geometry (Lisp_Object image_instance, int* width,
+			  int* height, enum image_instance_geometry disp,
 			  Lisp_Object domain)
 {
   if (width)	*width = 20;
--- a/src/glyphs.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/glyphs.h	Mon Aug 13 11:19:21 2007 +0200
@@ -91,10 +91,11 @@
   IMAGE_GEOMETRY,
   IMAGE_DESIRED_GEOMETRY,
   IMAGE_MIN_GEOMETRY,
-  IMAGE_MAX_GEOMETRY,
-  IMAGE_UNSPECIFIED_GEOMETRY = ~0
+  IMAGE_MAX_GEOMETRY
 };
 
+#define IMAGE_UNSPECIFIED_GEOMETRY -1
+
 #define WIDGET_BORDER_HEIGHT 4
 #define WIDGET_BORDER_WIDTH 4
 
@@ -168,15 +169,14 @@
    instance. Actual geometry is stored in the appropriate slots in the
    image instance. */
   void (*query_geometry_method) (Lisp_Object image_instance,
-				 unsigned int* width, unsigned int* height,
+				 int* width, int* height,
 				 enum image_instance_geometry disp,
 				 Lisp_Object domain);
 
   /* Layout the instance and its children bounded by the provided
      dimensions. Returns success or failure. */
   int (*layout_method) (Lisp_Object image_instance,
-			unsigned int width, unsigned int height,
-			Lisp_Object domain);
+			int width, int height, Lisp_Object domain);
 };
 
 /***** Calling an image-instantiator method *****/
@@ -359,14 +359,14 @@
 			 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
 			 int dest_mask, Lisp_Object domain);
 void image_instance_query_geometry (Lisp_Object image_instance,
-				    unsigned int* width, unsigned int* height,
+				    int* width, int* height,
 				    enum image_instance_geometry disp,
 				    Lisp_Object domain);
 void image_instance_layout (Lisp_Object image_instance,
-			    unsigned int width, unsigned int height,
+			    int width, int height,
 			    Lisp_Object domain);
 int layout_layout (Lisp_Object image_instance,
-		   unsigned int width, unsigned int height,
+		   int width, int height,
 		   Lisp_Object domain);
 int invalidate_glyph_geometry_maybe (Lisp_Object glyph_or_ii, struct window* w);
 
@@ -530,7 +530,7 @@
   Lisp_Object parent;
   enum image_instance_type type;
   unsigned int x_offset, y_offset;	/* for layout purposes */
-  unsigned int width, height, margin_width;
+  int width, height, margin_width;
   unsigned long display_hash; /* Hash value representing the structure
 				 of the image_instance when it was
 				 last displayed. */
@@ -980,8 +980,8 @@
 						  Lisp_Object property,
 						  Lisp_Object locale));
 void query_string_geometry ( Lisp_Object string, Lisp_Object face,
-			     unsigned int* width, unsigned int* height,
-			     unsigned int* descent, Lisp_Object domain);
+			     int* width, int* height, int* descent, 
+			     Lisp_Object domain);
 Lisp_Object query_string_font (Lisp_Object string,
 			       Lisp_Object face, Lisp_Object domain);
 Lisp_Object add_glyph_animated_timeout (EMACS_INT tickms, Lisp_Object device);
--- a/src/gpmevent.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/gpmevent.c	Mon Aug 13 11:19:21 2007 +0200
@@ -309,7 +309,7 @@
 }
 
 static Lisp_Object
-tty_selection_exists_p (Lisp_Object selection)
+tty_selection_exists_p (Lisp_Object selection, Lisp_Object selection_type)
 {
 	return (Qt);
 }
@@ -317,7 +317,8 @@
 
 #if 0
 static Lisp_Object
-tty_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
+tty_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
+		   Lisp_Object how_to_add, Lisp_Object selection_type)
 {
 	/* There is no way to do this cleanly - the GPM selection
 	** 'protocol' (actually the TIOCLINUX ioctl) requires a start and
--- a/src/gui-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/gui-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -133,7 +133,7 @@
       TO_EXTERNAL_FORMAT (LISP_STRING, current_dir,
 			  C_STRING_ALLOCA, f,
 			  Qfile_name);
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
       CYGWIN_WIN32_PATH (f, path);
 #else
       path = f;
@@ -145,7 +145,7 @@
       TO_EXTERNAL_FORMAT (LISP_STRING, document,
 			  C_STRING_ALLOCA, f,
 			  Qfile_name);
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
       CYGWIN_WIN32_PATH (f, doc);
 #else
       doc = f;
--- a/src/hash.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/hash.c	Mon Aug 13 11:19:21 2007 +0200
@@ -52,6 +52,25 @@
   return h;
 }
 
+unsigned long
+string_hash (const char *xv)
+{
+  unsigned int h = 0;
+  unsigned const char *x = (unsigned const char *) xv;
+
+  if (!x) return 0;
+
+  while (*x)
+    {
+      unsigned int g;
+      h = (h << 4) + *x++;
+      if ((g = h & 0xf0000000) != 0)
+	h = (h ^ (g >> 24)) ^ g;
+    }
+
+  return h;
+}
+
 /* Return a suitable size for a hash table, with at least SIZE slots. */
 static size_t
 hash_table_size (size_t requested_size)
--- a/src/inline.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/inline.c	Mon Aug 13 11:19:21 2007 +0200
@@ -69,7 +69,6 @@
 #endif
 
 #ifdef HAVE_POSTGRESQL
-#include POSTGRES_INCLUDE (libpq-fe.h)
 #include "postgresql.h"
 #endif
 
--- a/src/insdel.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/insdel.c	Mon Aug 13 11:19:21 2007 +0200
@@ -200,7 +200,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "device.h"
--- a/src/lisp.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/lisp.h	Mon Aug 13 11:19:21 2007 +0200
@@ -41,6 +41,7 @@
 #include <stdarg.h>
 #include <stddef.h>		/* offsetof */
 #include <sys/types.h>
+#include <limits.h>
 
 /* ---- Dynamic arrays ---- */
 
@@ -220,7 +221,7 @@
 #ifdef USE_ASSERTIONS
 /* Highly dubious kludge */
 /*   (thanks, Jamie, I feel better now -- ben) */
-DECLARE_DOESNT_RETURN (assert_failed (const char *, int, const char *));
+void assert_failed (const char *, int, const char *);
 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
 #else
@@ -944,7 +945,7 @@
 #define string_byte_addr(s, i) (&((s)->data[i]))
 #define set_string_length(s, len) ((void) ((s)->size = (len)))
 #define set_string_data(s, ptr) ((void) ((s)->data = (ptr)))
-#define set_string_byte(s, i, c) ((void) ((s)->data[i] = (c)))
+#define set_string_byte(s, i, b) ((void) ((s)->data[i] = (b)))
 
 void resize_string (Lisp_String *s, Bytecount pos, Bytecount delta);
 
@@ -966,7 +967,7 @@
 # define string_char_length(s) string_length (s)
 # define string_char(s, i) ((Emchar) string_byte (s, i))
 # define string_char_addr(s, i) string_byte_addr (s, i)
-# define set_string_char(s, i, c) set_string_byte (s, i, c)
+# define set_string_char(s, i, c) set_string_byte (s, i, (Bufbyte)c)
 
 #endif /* not MULE */
 
@@ -1179,7 +1180,7 @@
 
 #else
 
-#define XCHAR(x) XCHARVAL (x)
+#define XCHAR(x) ((Emchar)XCHARVAL (x))
 
 #endif
 
@@ -1388,7 +1389,10 @@
   /* element disappears if it's a cons and its car is unmarked. */
   WEAK_LIST_KEY_ASSOC,
   /* element disappears if it's a cons and its cdr is unmarked. */
-  WEAK_LIST_VALUE_ASSOC
+  WEAK_LIST_VALUE_ASSOC,
+  /* element disappears if it's a cons and neither its car nor
+     its cdr is marked. */
+  WEAK_LIST_FULL_ASSOC
 };
 
 struct weak_list
@@ -1612,7 +1616,7 @@
 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
 
 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj))
-unsigned long string_hash (const void *xv);
+unsigned long string_hash (const char *xv);
 unsigned long memory_hash (const void *xv, size_t size);
 unsigned long internal_hash (Lisp_Object obj, int depth);
 unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
@@ -2059,6 +2063,7 @@
 
 /* Defined in console-msw.c */
 EXFUN (Fmswindows_message_box, 3);
+extern int mswindows_message_outputted;
 
 /* Defined in data.c */
 DECLARE_DOESNT_RETURN (c_write_error (Lisp_Object));
@@ -2796,7 +2801,7 @@
 
 extern Lisp_Object Q_style, Qabort, Qactually_requested;
 extern Lisp_Object Qactivate_menubar_hook;
-extern Lisp_Object Qafter, Qall, Qand;
+extern Lisp_Object Qafter, Qall, Qand, Qappend;
 extern Lisp_Object Qarith_error, Qarrayp, Qassoc, Qat, Qautodetect, Qautoload;
 extern Lisp_Object Qbackground, Qbackground_pixmap, Qbad_variable, Qbefore;
 extern Lisp_Object Qbeginning_of_buffer, Qbig5, Qbinary;
@@ -2811,8 +2816,8 @@
 extern Lisp_Object Qcoding_system_error;
 extern Lisp_Object Qcolor, Qcolor_pixmap_image_instance_p;
 extern Lisp_Object Qcolumns, Qcommand, Qcommandp, Qcompletion_ignore_case;
-extern Lisp_Object Qconsole, Qconsole_live_p, Qconst_specifier, Qcr, Qcritical;
-extern Lisp_Object Qcrlf, Qctext, Qcurrent_menubar, Qctext, Qcursor;
+extern Lisp_Object Qconsole, Qconsole_live_p, Qconst_specifier, Qcopies, Qcr;
+extern Lisp_Object Qcritical, Qcrlf, Qctext, Qcurrent_menubar, Qctext, Qcursor;
 extern Lisp_Object Qcyclic_variable_indirection, Qdata, Qdead, Qdecode;
 extern Lisp_Object Qdefault, Qdefun, Qdelete, Qdelq, Qdevice, Qdevice_live_p;
 extern Lisp_Object Qdialog;
@@ -2826,7 +2831,8 @@
 extern Lisp_Object Qfile_name, Qfile_error;
 extern Lisp_Object Qfont, Qforce_g0_on_output, Qforce_g1_on_output;
 extern Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output, Qforeground;
-extern Lisp_Object Qformat, Qframe, Qframe_live_p, Qfuncall, Qfunction;
+extern Lisp_Object Qformat, Qframe, Qframe_live_p, Qfrom_page, Qfull_assoc;
+extern Lisp_Object Qfuncall, Qfunction;
 extern Lisp_Object Qgap_overhead, Qgeneric, Qgeometry, Qglobal, Qheight;
 extern Lisp_Object Qhelp, Qhighlight, Qhorizontal, Qicon;
 extern Lisp_Object Qicon_glyph_p, Qid, Qidentity, Qignore, Qimage, Qinfo;
@@ -2872,10 +2878,10 @@
 extern Lisp_Object Qspecifier, Qstandard_input, Qstandard_output, Qstart_open;
 extern Lisp_Object Qstream, Qstring, Qstring_lessp, Qsubwindow;
 extern Lisp_Object Qsubwindow_image_instance_p;
-extern Lisp_Object Qsymbol, Qsyntax, Qt, Qterminal, Qtest, Qtext;
-extern Lisp_Object Qtext_image_instance_p, Qthis_command, Qtimeout, Qtimestamp;
-extern Lisp_Object Qtoolbar, Qtop, Qtop_margin, Qtop_level;
-extern Lisp_Object Qtrue_list_p, Qtty, Qtype;
+extern Lisp_Object Qsymbol, Qsyntax, Qt, Qterminal, Qtest;
+extern Lisp_Object Qtext, Qtext_image_instance_p, Qthis_command, Qtimeout;
+extern Lisp_Object Qtimestamp, Qtoolbar, Qtop, Qtop_margin, Qtop_level;
+extern Lisp_Object Qto_page, Qtrue_list_p, Qtty, Qtype;
 extern Lisp_Object Qunbound, Qundecided, Qundefined, Qunderflow_error;
 extern Lisp_Object Qunderline, Qunimplemented, Quser_files_and_directories;
 extern Lisp_Object Qvalue_assoc, Qvalues;
--- a/src/lread.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/lread.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1029,7 +1029,7 @@
 	  if (closure->storeptr)
 	    *closure->storeptr = build_string (fn);
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 	  /* If we actually opened the file, set close-on-exec flag
 	     on the new descriptor so that subprocesses can't whack
 	     at it.  */
--- a/src/lrecord.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/lrecord.h	Mon Aug 13 11:19:21 2007 +0200
@@ -186,6 +186,7 @@
   lrecord_type_ldap,
   lrecord_type_pgconn,
   lrecord_type_pgresult,
+  lrecord_type_devmode,
   lrecord_type_count /* must be last */
 };
 
--- a/src/lstream.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/lstream.c	Mon Aug 13 11:19:21 2007 +0200
@@ -26,7 +26,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "insdel.h"
--- a/src/m/arm.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/arm.h	Mon Aug 13 11:19:21 2007 +0200
@@ -87,12 +87,7 @@
 #define TEXT_START 0
 #endif /* USG */
 
-
-#ifdef MSDOS
-#define NO_REMAP
-#endif
-
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define VIRT_ADDR_VARIES
 #define DATA_END 	get_data_end ()
 #define DATA_START 	get_data_start ()
--- a/src/m/delta.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/delta.h	Mon Aug 13 11:19:21 2007 +0200
@@ -74,20 +74,6 @@
 
 #define NO_REMAP
 
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- *
- * You'd think this would go in an operating-system description file,
- * but since it only occurs on some, but not all, BSD systems, the
- * reasonable place to select for it is in the machine description
- * file.
- */
-
-/* #define NO_SOCK_SIGIO */
-
 
 /* Machine specific stuff */
 #define HAVE_PTYS
--- a/src/m/intel386.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/intel386.h	Mon Aug 13 11:19:21 2007 +0200
@@ -152,10 +152,6 @@
 #endif /* USG */
 #endif /* not XENIX */
 
-#ifdef MSDOS
-#define NO_REMAP
-#endif
-
 #ifdef linux
 /* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */
 /* we cannot get the maximum address for brk */
--- a/src/m/nh3000.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/nh3000.h	Mon Aug 13 11:19:21 2007 +0200
@@ -78,17 +78,3 @@
    code will not be sharable; but that's better than failing completely.  */
 
 #define NO_REMAP
-
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- *
- * You'd think this would go in an operating-system description file,
- * but since it only occurs on some, but not all, BSD systems, the
- * reasonable place to select for it is in the machine description
- * file.
- */
-
-/* #define NO_SOCK_SIGIO */
--- a/src/m/nh4000.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/nh4000.h	Mon Aug 13 11:19:21 2007 +0200
@@ -77,17 +77,3 @@
    code will not be sharable; but that's better than failing completely.  */
 
 #define NO_REMAP
-
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- *
- * You'd think this would go in an operating-system description file,
- * but since it only occurs on some, but not all, BSD systems, the
- * reasonable place to select for it is in the machine description
- * file.
- */
-
-/* #define NO_SOCK_SIGIO */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/m/s390.h	Mon Aug 13 11:19:21 2007 +0200
@@ -0,0 +1,34 @@
+/* machine description file for IBM S390
+   Copyright (C) 1987 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+GNU Emacs 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.
+
+GNU Emacs 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 GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+/* Say this machine is a s390 */
+
+#ifndef s390
+#define s390
+#endif
+
+/* Data type of load average, as read out of kmem.  */
+
+#define LOAD_AVE_TYPE long
+
+/* Convert that into an integer that is 100 for a load average of 1.0  */
+
+#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
--- a/src/m/sequent.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/sequent.h	Mon Aug 13 11:19:21 2007 +0200
@@ -131,6 +131,7 @@
  * config.h (or elsewhere) to decide when (not) to use SIGIO.
  */
 
+/* Note: This definition not used under XEmacs */
 #define NO_SOCK_SIGIO
 
 /* Define how to search all pty names.
--- a/src/m/template.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/template.h	Mon Aug 13 11:19:21 2007 +0200
@@ -69,21 +69,6 @@
 
 #define NO_REMAP
 
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- *
- * You'd think this would go in an operating-system description file,
- * but since it only occurs on some, but not all, BSD systems, the
- * reasonable place to select for it is in the machine description
- * file.
- */
-
-#define NO_SOCK_SIGIO
-
-
 /* After adding support for a new system, modify the large case
    statement in the `configure' script to recognize reasonable
    configuration names, and add a description of the system to
--- a/src/m/windowsnt.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/m/windowsnt.h	Mon Aug 13 11:19:21 2007 +0200
@@ -89,20 +89,6 @@
 
 /* #define NO_REMAP */
 
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- *
- * You'd think this would go in an operating-system description file,
- * but since it only occurs on some, but not all, BSD systems, the
- * reasonable place to select for it is in the machine description
- * file.
- */
-
-/* #define NO_SOCK_SIGIO */
-
 /* After adding support for a new system, modify the large case
    statement in the `configure' script to recognize reasonable
    configuration names, and add a description of the system to
--- a/src/mem-limits.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/mem-limits.h	Mon Aug 13 11:19:21 2007 +0200
@@ -38,10 +38,6 @@
 #include <ulimit.h>
 #endif
 
-#ifdef MSDOS
-#include <dpmi.h>
-#endif
-
 /* Some systems need this before <sys/resource.h>.  */
 #include <sys/types.h>
 
@@ -70,16 +66,14 @@
 
 #ifndef BSD4_2
 #ifndef USG
-#ifndef MSDOS
-#ifndef WINDOWSNT
-#ifndef __CYGWIN32__
+#ifndef WIN32_NATIVE
+#ifndef CYGWIN
 #if defined(__linux__) && defined(powerpc)	/*Added Kaoru Fukui*/
 #else						/*Added Kaoru Fukui*/
 #include <sys/vlimit.h>
 #endif				/*Added by Fukui*/
-#endif /* not __CYGWIN32__ */
-#endif /* not WINDOWSNT */
-#endif /* not MSDOS */
+#endif /* not CYGWIN */
+#endif /* not WIN32_NATIVE */
 #endif /* not USG */
 #else /* if BSD4_2 */
 #include <sys/time.h>
@@ -96,7 +90,7 @@
 typedef char *POINTER;
 #endif
 
-#ifndef __CYGWIN32__
+#ifndef CYGWIN
 typedef unsigned long SIZE;
 #endif
 
@@ -169,7 +163,7 @@
 }
 
 #else /* not USG */
-#if defined( WINDOWSNT )
+#if defined( WIN32_NATIVE )
 
 static void
 get_lim_data (void)
@@ -181,22 +175,11 @@
 #else
 #if !defined (BSD4_2) && !defined (__osf__)
 
-#ifdef MSDOS
-void
-get_lim_data (void)
-{
-  _go32_dpmi_meminfo info;
-
-  _go32_dpmi_get_free_memory_information (&info);
-  lim_data = info.available_memory;
-}
-#else /* not MSDOS */
 static void
 get_lim_data (void)
 {
   lim_data = vlimit (LIM_DATA, -1);
 }
-#endif /* not MSDOS */
 
 #else /* BSD4_2 */
 
@@ -213,7 +196,7 @@
 #endif
 }
 #endif /* BSD4_2 */
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 #endif /* not USG */
 #endif /* not NO_LIM_DATA */
 #endif /* not HEAP_IN_DATA */
--- a/src/menubar-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/menubar-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -78,7 +78,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "commands.h"
@@ -126,7 +125,7 @@
    of not hitting an error, maxlen should be >= 2*len + 3. */
 
 Bytecount
-msw_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
+mswindows_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
 				   Bytecount maxlen, Emchar *accel,
 				   Lisp_Object error_name)
 {
@@ -209,7 +208,7 @@
   /* Left flush part of the string */
   ll = gui_item_display_flush_left (gui_item, buf, MAX_MENUITEM_LENGTH);
 
-  ll = msw_translate_menu_or_dialog_item ((Bufbyte *) buf, ll,
+  ll = mswindows_translate_menu_or_dialog_item ((Bufbyte *) buf, ll,
 					  MAX_MENUITEM_LENGTH, accel,
 					  XGUI_ITEM (gui_item)->name);
 
@@ -668,7 +667,7 @@
 }
 
 int
-msw_char_is_accelerator (struct frame *f, Emchar ch)
+mswindows_char_is_accelerator (struct frame *f, Emchar ch)
 {
   Lisp_Object hash = FRAME_MSWINDOWS_MENU_HASH_TABLE (f);
 
--- a/src/mule-canna.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/mule-canna.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1,4 +1,4 @@
-/* CANNA interface
+/* CANNA interface -*- coding: euc-jp -*-
 
    Copyright (C) 1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
@@ -190,6 +190,7 @@
 
 static Lisp_Object storeResults (unsigned char *, int, jrKanjiStatus *);
 static Lisp_Object kanjiYomiList (int, int);
+static Lisp_Object CANNA_mode_keys (void);
 
 #ifdef CANNA_MULE
 static void m2c (unsigned char *, int, unsigned char *);
@@ -326,10 +327,9 @@
 }
 
 /* For whatever reason, calling Fding directly from libCanna loses */
-static void call_Fding()
+static void
+call_Fding (void)
 {
-  extern Lisp_Object Fding();
-
   Fding (Qnil, Qnil, Qnil);
 }
 
@@ -421,8 +421,7 @@
     }
   else
     {
-      extern void (*jrBeepFunc)();
-      Lisp_Object CANNA_mode_keys ();
+      extern void (*jrBeepFunc) (void);
 
       jrBeepFunc = call_Fding;
 
@@ -535,7 +534,7 @@
   return val;
 }
 
-Lisp_Object
+static Lisp_Object
 CANNA_mode_keys (void)
 {
 #define CANNAWORKBUFSIZE 32
--- a/src/mule-mcpath.c	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,306 +0,0 @@
-/* Support for Non-ASCII Path Name
-   Copyright (C) 1985, 1986, 1992, 1993, 1995 Free Software Foundation, Inc.
-   Copyright (C) 1995 Sun Microsystems, Inc.
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Mule 2.3.   Not in FSF. */
-
-/* mcpath.h should be included in config.h */
-#include <config.h>
-#include "lisp.h"
-
-#include "sysfile.h"
-#include "buffer.h"
-#include "mule.h"
-
-Lisp_Object Qpathname_coding_system = 0;
-
-static void
-mcpath_encode_code (Lisp_Coding_System *cp)
-{
-  Lisp_Object coding_system;
-
-  coding_system = Fsymbol_value (Qpathname_coding_system);
-
-  mule_encode_code (coding_system, cp);
-  CODE_CNTL (cp) |= CC_END;
-}
-
-static int
-mule_encode_path_1 (unsigned char *src, unsigned int srcsize,
-		    unsigned char *dst, unsigned int dstsize)
-{
-  Lisp_Coding_System code;
-
-  mcpath_encode_code (&code);
-  if (CODE_TYPE (&code) > MULE_AUTOCONV)
-    {
-      unsigned char *buf;
-
-					/* get_conversion_buffer () is not */
-					/* re-entrant. */
-      buf = (unsigned char *) alloca (MULE_ENCODE_BUF_SIZE (srcsize, &code));
-      if (buf)
-	{
-	  int len;
-	  Lisp_Object dummy = Qnil;
-
-	  len = mule_encode (&code, src, buf, srcsize, &dummy);
-	  if (!CODE_CHAR (&code) && len <= dstsize)
-	    {
-	      memcpy (dst, buf, len);
-	      return len;
-	    }
-	}
-    }
-  return -1;				/* use original */
-}
-
-static unsigned char *
-mule_decode_path_1 (unsigned char *src, unsigned char *dst,
-		    unsigned int dstsize)
-{
-  Lisp_Coding_System code;
-
-  mcpath_encode_code (&code);
-  if (CODE_TYPE (&code) > MULE_AUTOCONV)
-    {
-      int len;
-      unsigned char *buf;
-
-      len = strlen (src) + 1;		/* + 1 for '\0' */
-
-					/* get_conversion_buffer () is not */
-					/* re-entrant. */
-      buf = (unsigned char *) alloca (MULE_DECODE_BUF_SIZE (len, &code));
-      if (buf)
-	{
-	  CODE_CNTL (&code) |= CC_END;
-	  len = mule_decode (&code, src, buf, len);
-	  if (!CODE_CHAR (&code) && len <= dstsize)
-	    {
-	      memcpy (dst, buf, len);	/* len should include '\0' */
-	      return dst;
-	    }
-	}
-    }
-  return src;
-}
-
-static unsigned char *
-mule_decode_path (unsigned char *path, unsigned char ext_path[MC_MAXPATHLEN])
-{
-  return
-    (Qpathname_coding_system
-     ? mule_decode_path_1 (path, ext_path, MC_MAXPATHLEN)
-     : path);				/* in case of before initialization */
-}
-
-static unsigned char *
-mule_encode_path (unsigned char *path, unsigned char *encode_buffer,
-		  unsigned int size)
-{
-  int len;
-
-  len = mule_encode_path_1 (path, strlen (path), encode_buffer, size);
-  if (len > 0)
-    path = encode_buffer;
-#ifdef MSDOS
-  /* convert the MSDOS style path delimiter to the UNIX style.  Note
-     that now the code is *internal*, so we can simply compare each
-     character with '\\'.  And this operation will alter the contents
-     of Lisp Object, PATH. */
-  {
-    unsigned char *p = path;
-
-    while (*p)
-      {
-	if (*p == '\\')
-	  *p = '/';
-	p++;
-      }
-  }
-#endif /* MSDOS */
-  return path;
-}
-
-#if 0 /* example of how they do it (similar junk deleted) ... */
-
-int
-mc_creat (unsigned char *path, int mode)
-{
-  unsigned char buffer[MC_MAXPATHLEN];
-  return creat (mule_decode_path (path, buffer), mode);
-}
-
-int
-mc_readlink (unsigned char *path, unsigned char *buf, int size)
-{
-  unsigned char buffer[MC_MAXPATHLEN], buffer2[MAXPATHLEN];
-  int nread;
-
-  nread = readlink (mule_decode_path (path, buffer), buffer2, MAXPATHLEN);
-  if (nread > 0)
-    {
-      int len;
-      unsigned char *p;
-
-      len = mule_encode_path_1 (buffer2, nread, buffer, sizeof (buffer));
-      if (0 <= len && len <= size)
-	{
-	  memcpy (buf, buffer, len);
-	  return len;
-	}
-    }
-  return -1;
-}
-
-int
-mc_chdir (unsigned char *path)
-{
-  unsigned char buffer[MC_MAXPATHLEN];
-
-  path = mule_decode_path (path, buffer);
-
-#ifdef MSDOS
-  if ((path[0] != 0) && (path[1] == ':'))
-    {
-      int drive = (tolower (path[0]) - 'a');
-      if (getdisk () != drive)
-	setdisk (drive);
-    }
-
-  /* If path != "/" and path != "a:/" and path ends with slash, remove
-     it. */
-  {
-    int len = strlen (path);
-
-    if (strcmp (path + 1, ":/") && (len > 1) && (path[len - 1] == '/'))
-      {
-	if (path != buffer)	/* It is not good to modify original path. */
-	  {
-	    memcpy (buffer, path, len - 1); /* no need to copy last /. */
-	    path = buffer;
-	  }
-	path[len - 1] = 0;
-      }
-  }
-#endif /* MSDOS */
-
-  return chdir (path);
-}
-
-#ifdef MSDOS
-#ifndef HAVE_GETWD
-unsigned char *
-mc_getcwd (unsigned char *null, size_t size)
-{
-  unsigned char buffer[MAXPATHLEN];
-  unsigned char *path;
-
-  path = (unsigned char *) getcwd ((char *)buffer, MAXPATHLEN);
-  if (path)
-    {
-      /* here, should be (path == buffer). */
-      path = (unsigned char *) xmalloc (MC_MAXPATHLEN);	/* MSDOS */
-      if (path)
-	{
-	  int len;
-	  int buffer_length = strlen (buffer) + 1;
-
-	  len = mule_encode_path_1 (buffer, buffer_length, path, MC_MAXPATHLEN);
-	  if (len < 0)
-	    {
-	      /* conversion failed.  use value that is returned from system. */
-	      memcpy (path, buffer, buffer_length);
-	    }
-	}
-    }
-  return path;
-}
-#else /* HAVE_GETWD */
-unsigned char *
-mc_getwd (unsigned char path[])
-{
-  unsigned char *p;
-
-  p = getwd (path);
-  if (p)
-    {
-      unsigned char buffer[MC_MAXPATHLEN];
-      int len;
-
-      len = mule_encode_path_1 (path, strlen (path) + 1, buffer, sizeof buffer);
-      if (len > 0)
-	{
-	  memcpy (path, buffer, len);
-	}
-    }
-  return p;
-}
-#endif /* HAVE_GETWD */
-#endif /* MSDOS */
-
-/* In callproc.c, execvp() is called like this:
- * 	execvp (new_argv[0], new_argv);
- * following implement depends this.
- */
-#ifndef NO_MC_EXECVP
-void
-mc_execvp (unsigned char *path, unsigned char *argv[])
-{
-  unsigned char buffer[MC_MAXPATHLEN];
-  argv[0] = path = mule_decode_path (path, buffer);
-  execvp (path, argv);
-}
-#endif /* !NO_MC_EXECVP */
-
-static DIRENTRY mcpath_directory_entry;
-DIRENTRY *
-mc_readdir (DIR *d)
-{
-  SYSTEM_DIRENTRY *sp;
-  DIRENTRY *dp = &mcpath_directory_entry;
-
-  sp = readdir (d);
-  if (!sp) return 0;
-
-#ifndef MSDOS
-  dp->d_ino = sp->d_ino;
-#endif /* MSDOS */
-  {				/* copy d_name with conversion. */
-    int len;
-
-    len = mule_encode_path_1 (sp->d_name, NAMLEN (sp),
-			      dp->d_name, sizeof (dp->d_name) - 1);
-    if (len < 0)
-      {
-	len = NAMLEN (sp);
-#ifdef MCPATH_ASSERT
-	assert (len < sizeof (dp->d_name));
-#endif
-	memcpy (dp->d_name, sp->d_name, len);
-      }
-    dp->d_name[len] = 0;
-  }
-  return dp;
-}
-
-#endif /* 0 */
-
--- a/src/mule-mcpath.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* Support for Non-ASCII Path Name
-   Copyright (C) 1985, 1986, 1995 Free Software Foundation, Inc.
-   Copyright (C) 1995 Sun Microsystems, Inc.
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Mule 2.3.  Not in FSF. */
-
-/* This part cannot be surround with #ifdef emacs, because it is needed */
-/* during generate xmakefile. */
-#ifndef MCPATH
-# define MCPATH
-#endif /* !MCPATH */
-
-/* not to confuse while compiling etc/*.c */
-#ifdef emacs
-#ifdef MCPATH
-#  ifndef _MCPATH_H			/* enable to include twice */
-
-#if 1
-
-/* !!! This page is copied from dired.c except that DIRENTRY is
-   changed to SYSTEM_DIRENTRY.  Don't modify this page. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-/* The d_nameln member of a struct dirent includes the '\0' character
-   on some systems, but not on others.  What's worse, you can't tell
-   at compile-time which one it will be, since it really depends on
-   the sort of system providing the filesystem you're reading from,
-   not the system you are running on.  Paul Eggert
-   <eggert@bi.twinsun.com> says this occurs when Emacs is running on a
-   SunOS 4.1.2 host, reading a directory that is remote-mounted from a
-   Solaris 2.1 host and is in a native Solaris 2.1 filesystem.
-
-   Since applying strlen to the name always works, we'll just do that.  */
-#define NAMLEN(p) strlen (p->d_name)
-
-#ifdef SYSV_SYSTEM_DIR
-
-#include <dirent.h>
-#define SYSTEM_DIRENTRY struct dirent
-
-#else /* not SYSV_SYSTEM_DIR */
-
-#ifdef NONSYSTEM_DIR_LIBRARY
-#include "ndir.h"
-#else /* not NONSYSTEM_DIR_LIBRARY */
-#ifdef MSDOS
-#include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif
-#endif /* not NONSYSTEM_DIR_LIBRARY */
-
-#ifndef MSDOS
-#define SYSTEM_DIRENTRY struct direct
-
-extern DIR *opendir ();
-extern struct direct *readdir ();
-
-#endif /* not MSDOS */
-#endif /* not SYSV_SYSTEM_DIR */
-#endif
-
-				/* maximum buffer size to do conversion. */
-#define MCPATH_BUFSIZ(s) (((s) * 3) + 256)
-#define MC_MAXPATHLEN MCPATH_BUFSIZ (MAXPATHLEN)
-
-#define DIRENTRY struct mcpath_direntry
-struct mcpath_direntry
-{
-				/* emacs 19.28 uses d_ino and d_name. */
-#ifndef MSDOS
-  int d_ino;
-#endif /* not MSDOS */
-  unsigned char d_name [MCPATH_BUFSIZ (MAXNAMLEN) + 1];
-};
--- a/src/mule-wnnfns.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/mule-wnnfns.c	Mon Aug 13 11:19:21 2007 +0200
@@ -1,4 +1,4 @@
-/*
+/* -*- coding: iso-2022-jp -*-
    Copyright (C) 1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
 
--- a/src/ndir.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/ndir.h	Mon Aug 13 11:19:21 2007 +0200
@@ -27,11 +27,11 @@
 #define INCLUDED_ndir_h_
 
 #define DIRBLKSIZ	512		/* size of directory block */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define MAXNAMLEN	255
-#else  /* not WINDOWSNT */
+#else  /* not WIN32_NATIVE */
 #define MAXNAMLEN	15		/* maximum filename length */
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 	/* NOTE:  MAXNAMLEN must be one less than a multiple of 4 */
 
 struct direct				/* data from readdir() */
--- a/src/nt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/nt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -25,8 +25,6 @@
 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
 
 #include <config.h>
-
-#undef signal
 #define getwd _getwd
 #include "lisp.h"
 #undef getwd
@@ -35,22 +33,12 @@
 #include "syssignal.h"
 #include "sysproc.h"
 #include "sysfile.h"
-
-#include <ctype.h>
-#include <direct.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <io.h>
-#include <pwd.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include "syspwd.h"
+#include "sysdir.h"
 
 #include "syswindows.h"
 
 #include "nt.h"
-#include <sys/dir.h>
 #include "ntheap.h"
 
 
@@ -1075,16 +1063,22 @@
   return dirp;
 }
 
-void
+int
 closedir (DIR *dirp)
 {
+  BOOL retval;
+
   /* If we have a find-handle open, close it.  */
   if (dir_find_handle != INVALID_HANDLE_VALUE)
     {
-      FindClose (dir_find_handle);
+      retval = FindClose (dir_find_handle);
       dir_find_handle = INVALID_HANDLE_VALUE;
     }
   xfree (dirp);
+  if (retval)
+    return 0;
+  else
+    return -1;
 }
 
 struct direct *
@@ -1236,7 +1230,7 @@
 }
 #else
 
-#if defined(__MINGW32__) && CYGWIN_VERSION_DLL_MAJOR <= 21
+#if defined(MINGW) && CYGWIN_VERSION_DLL_MAJOR <= 21
 #define LowPart u.LowPart
 #define HighPart u.HighPart
 #endif
@@ -1310,7 +1304,7 @@
   return ret;
 }
 #endif
-#if defined(__MINGW32__) && CYGWIN_VERSION_DLL_MAJOR <= 21
+#if defined(MINGW) && CYGWIN_VERSION_DLL_MAJOR <= 21
 #undef LowPart
 #undef HighPart
 #endif
@@ -1391,22 +1385,16 @@
 
 #endif
 
-/* stat has been fixed since MSVC 5.0.
-   Oh, and do not encapsulater stat for non-MS compilers, too */
-/* #### popineau@ese-metz.fr says they still might be broken.
-   Oh well... Let's add that `1 ||' condition.... --kkm */
 /* #### aichner@ecf.teradyne.com reported that with the library
    provided stat/fstat, (file-exist "d:\\tmp\\") =>> nil,
    (file-exist "d:\\tmp") =>> t, when d:\tmp exists. Whenever
    we opt to use non-encapsulated stat(), this should serve as
    a compatibility test. --kkm */
 
-#if 1 || defined(_MSC_VER) && _MSC_VER < 1100
-
 /* Since stat is encapsulated on Windows NT, we need to encapsulate
    the equally broken fstat as well. */
-int _cdecl
-fstat (int handle, struct stat *buffer)
+int
+mswindows_fstat (int handle, struct stat *buffer)
 {
   int ret;
   BY_HANDLE_FILE_INFORMATION lpFileInfo;
@@ -1441,7 +1429,7 @@
    replace it with our own.  This also allows us to calculate consistent
    inode values without hacks in the main Emacs code. */
 int
-stat (const char * path, struct stat * buf)
+mswindows_stat (const char * path, struct stat * buf)
 {
   char * name;
   WIN32_FIND_DATA wfd;
@@ -1627,7 +1615,6 @@
 
   return 0;
 }
-#endif /* defined(_MSC_VER) && _MSC_VER < 1100 */
 
 /* From callproc.c  */
 extern Lisp_Object Vbinary_process_input;
@@ -1801,7 +1788,7 @@
 /* Signal pending mask: bit set to 1 means sig is pending */
 unsigned signal_pending_mask = 0;
 
-msw_sighandler msw_sigset (int nsig, msw_sighandler handler)
+mswindows_sighandler mswindows_sigset (int nsig, mswindows_sighandler handler)
 {
   /* We delegate some signals to the system function */
   if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
@@ -1815,13 +1802,13 @@
 
   /* Store handler ptr */
   {
-    msw_sighandler old_handler = signal_handlers[nsig];
+    mswindows_sighandler old_handler = signal_handlers[nsig];
     signal_handlers[nsig] = handler;
     return old_handler;
   }
 }
   
-int msw_sighold (int nsig)
+int mswindows_sighold (int nsig)
 {
   if (nsig < 0 || nsig > SIG_MAX)
     return errno = EINVAL;
@@ -1830,7 +1817,7 @@
   return 0;
 }
 
-int msw_sigrelse (int nsig)
+int mswindows_sigrelse (int nsig)
 {
   if (nsig < 0 || nsig > SIG_MAX)
     return errno = EINVAL;
@@ -1838,12 +1825,12 @@
   signal_block_mask &= ~sigmask(nsig);
 
   if (signal_pending_mask & sigmask(nsig))
-    msw_raise (nsig);
+    mswindows_raise (nsig);
 
   return 0;
 }
 
-int msw_sigpause (int nsig)
+int mswindows_sigpause (int nsig)
 {
   /* This is currently not called, because the only
      call to sigpause inside XEmacs is with SIGCHLD
@@ -1854,7 +1841,7 @@
   return 0;
 }
 
-int msw_raise (int nsig)
+int mswindows_raise (int nsig)
 {
   /* We delegate some raises to the system routine */
   if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
@@ -1920,7 +1907,7 @@
 				 DWORD dw1, DWORD dw2)
 {
   /* Just raise a signal indicated by dwUser parameter */
-  msw_raise (dwUser);
+  mswindows_raise (dwUser);
 }
 
 /* Divide time in ms specified by IT by DENOM. Return 1 ms
@@ -2072,13 +2059,13 @@
   return TRUE;
 }
 
-#if 1 /* !defined(__MINGW32__) */
+#if 1 /* !defined(MINGW) */
 /* Return pointer to section header for section containing the given
    relative virtual address. */
 static IMAGE_SECTION_HEADER *
 rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
 {
-  /* Synched with FSF 20.6.  We added MINGW32 stuff. */
+  /* Synched with FSF 20.6.  We added MINGW stuff. */
   PIMAGE_SECTION_HEADER section;
   int i;
 
@@ -2107,7 +2094,7 @@
 mswindows_executable_type (const char * filename, int * is_dos_app,
 			   int * is_cygnus_app)
 {
-  /* Synched with FSF 20.6.  We added MINGW32 stuff and casts. */
+  /* Synched with FSF 20.6.  We added MINGW stuff and casts. */
   file_data executable;
   char * p;
 
@@ -2143,7 +2130,7 @@
 	 start with a DOS program stub.  Note that 16-bit Windows
 	 executables use the OS/2 1.x format. */
 
-#if 0 /* defined( __MINGW32__ ) */
+#if 0 /* defined( MINGW ) */
       /* mingw32 doesn't have enough headers to detect cygwin
 	 apps, just do what we can. */
       FILHDR * exe_header;
--- a/src/nt.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/nt.h	Mon Aug 13 11:19:21 2007 +0200
@@ -26,20 +26,14 @@
 #ifndef INCLUDED_nt_h_
 #define INCLUDED_nt_h_
 
+#include "syswindows.h"
+
 #ifdef DEBUG_XEMACS
 #define DebPrint(stuff) _DebPrint stuff
 #else
 #define DebPrint(stuff)
 #endif
 
-#define R_OK 4
-#define W_OK 2
-#ifdef X_OK
-#undef X_OK
-#endif
-#define X_OK 1
-#define F_OK 0
-
 /* ------------------------------------------------------------------------- */
 
 /* child_process.status values */
@@ -145,4 +139,12 @@
 /* In process-nt.c */
 extern int compare_env (const void *strp1, const void *strp2);
 
+void mswindows_set_errno (unsigned long win32_error);
+void mswindows_set_last_errno (void);
+
+void wait_for_termination (HANDLE pid);
+
+int mswindows_fstat (int handle, struct stat *buffer);
+int mswindows_stat (const char * path, struct stat * buf);
+
 #endif /* INCLUDED_nt_h_ */
--- a/src/ntheap.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/ntheap.h	Mon Aug 13 11:19:21 2007 +0200
@@ -26,7 +26,7 @@
 #ifndef INCLUDED_ntheap_h_
 #define INCLUDED_ntheap_h_
 
-#include <windows.h>
+#include "syswindows.h"
 
 /*
  * Heap related stuff.
--- a/src/ntplay.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/ntplay.c	Mon Aug 13 11:19:21 2007 +0200
@@ -19,10 +19,10 @@
 02111-1307, USA.*/
 
 #include <config.h>
-#include <stdio.h>
+#include "lisp.h"
+
 #include "sysfile.h"
-#include "syswindows.h"
-#include "lisp.h"
+#include "nt.h"
 #include "nativesound.h"
 
 static int play_sound_data_1 (unsigned char *data, int length,
--- a/src/ntproc.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/ntproc.c	Mon Aug 13 11:19:21 2007 +0200
@@ -24,15 +24,6 @@
 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <io.h>
-#include <fcntl.h>
-#include <signal.h>
-
-/* must include CRT headers *before* config.h */
-/* #### I don't believe it - martin */
 #include <config.h>
 #undef signal
 #undef wait
@@ -41,7 +32,6 @@
 #undef kill
 
 #include <windows.h>
-#include <sys/socket.h>
 #ifdef HAVE_A_OUT_H
 #include <a.out.h>
 #endif
@@ -111,7 +101,7 @@
 #endif
 }
 
-/* sys_signal moved to nt.c. It's now called msw_signal... */
+/* sys_signal moved to nt.c. It's now called mswindows_signal... */
 
 /* Defined in <process.h> which conflicts with the local copy */
 #define _P_NOWAIT 1
@@ -791,7 +781,7 @@
 
       GetClassName (hwnd, window_class, sizeof (window_class));
       if (strcmp (window_class,
-		  msw_windows9x_p()
+		  mswindows_windows9x_p()
 		  ? "tty"
 		  : "ConsoleWindowClass") == 0)
 	{
@@ -884,7 +874,7 @@
       if (NILP (Vwin32_start_process_share_console) && cp && cp->hwnd)
 	{
 #if 1
-	  if (msw_windows9x_p())
+	  if (mswindows_windows9x_p())
 	    {
 /*
    Another possibility is to try terminating the VDM out-right by
@@ -1038,12 +1028,6 @@
 /* Some miscellaneous functions that are Windows specific, but not GUI
    specific (ie. are applicable in terminal or batch mode as well).  */
 
-/* lifted from fileio.c  */
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-       else unixtodos_filename (s); \
-  } while (0)
-
 DEFUN ("win32-short-file-name", Fwin32_short_file_name, 1, 1, "", /*
   Return the short file name version (8.3) of the full path of FILENAME.
 If FILENAME does not exist, return nil.
--- a/src/objects-x.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/objects-x.c	Mon Aug 13 11:19:21 2007 +0200
@@ -28,7 +28,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "console-x.h"
 #include "objects-x.h"
--- a/src/postgresql.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/postgresql.c	Mon Aug 13 11:19:21 2007 +0200
@@ -92,7 +92,6 @@
 */
 #if (EMACS_MAJOR_VERSION == 21) && (EMACS_MINOR_VERSION < 2)
 #define RUNNING_XEMACS_21_1 1
-#define POSTGRES_INCLUDE(file) <file>
 #endif
 
 /* #define POSTGRES_LO_IMPORT_IS_VOID 1 */
@@ -100,16 +99,12 @@
 #include "lisp.h"
 #include "sysdep.h"
 #include "buffer.h"
-
-#include POSTGRES_INCLUDE (libpq-fe.h)
 #include "postgresql.h"
 
 #ifdef RUNNING_XEMACS_21_1 /* handle interface changes */
-#define I_HATE_CONST CONST
 #define PG_OS_CODING FORMAT_FILENAME
 #define TO_EXTERNAL_FORMAT(a,from,b,to,c) GET_C_STRING_EXT_DATA_ALLOCA(from,FORMAT_FILENAME,to)
 #else
-#define I_HATE_CONST const
 #ifdef MULE
 #define PG_OS_CODING Fget_coding_system(Vpg_coding_system)
 #else
@@ -396,7 +391,7 @@
 
 /* notices */
 static void
-xemacs_notice_processor (void *arg, I_HATE_CONST char *msg)
+xemacs_notice_processor (void *arg, const char *msg)
 {
   warn_when_safe (Qpostgresql, Qnotice, "%s", msg);
 }
@@ -725,7 +720,7 @@
 }
 
 DEFUN ("pq-reset-poll", Fpq_reset_poll, 1, 1, 0, /*
-Poll an asynchronous reset for completion
+Poll an asynchronous reset for completion.
 */
 	(conn))
 {
@@ -846,12 +841,12 @@
     return build_ext_string (PQoptions(P), PG_OS_CODING);
   else if (EQ (field, Qpqstatus))
     {
-      ExecStatusType est;
+      ConnStatusType cst;
       /* PQstatus Returns the status of the connection. The status can be
 	 CONNECTION_OK or CONNECTION_BAD.
 	 ConnStatusType PQstatus(PGconn *conn)
       */
-      switch ((est = PQstatus (P)))
+      switch ((cst = PQstatus (P)))
 	{
 	case CONNECTION_OK: return Qpg_connection_ok;
 	case CONNECTION_BAD: return Qpg_connection_bad;
@@ -864,7 +859,7 @@
 #endif /* HAVE_POSTGRESQLV7 */
 	default:
 	  /* they've added a new field we don't know about */
-	  error ("Help!  Unknown exec status code %08x from backend!", est);
+	  error ("Help!  Unknown connection status code %08x from backend!", cst);
 	}
     }
   else if (EQ (field, Qpqerrormessage))
@@ -1257,7 +1252,7 @@
 }
 
 DEFUN ("pq-cmd-tuples", Fpq_cmd_tuples, 1, 1, 0, /*
-Returns the number of rows affected by the SQL command
+Returns the number of rows affected by the SQL command.
 */
 	(result))
 {
@@ -1309,7 +1304,7 @@
 }
 
 DEFUN ("pq-is-nonblocking", Fpq_is_nonblocking, 1, 1, 0, /*
-Return the blocking status of the database connection
+Return the blocking status of the database connection.
 */
        (conn))
 {
@@ -1323,7 +1318,7 @@
 }
 
 DEFUN ("pq-flush", Fpq_flush, 1, 1, 0, /*
-Force the write buffer to be written (or at least try)
+Force the write buffer to be written (or at least try).
 */
        (conn))
 {
@@ -1543,7 +1538,7 @@
   if (ret == -1) return Qt; /* done! */
   else if (!ret) return Qnil; /* no data yet */
   else return Fcons (make_int (ret),
-		     make_ext_string (buffer, ret, PG_OS_CODING));
+		     make_ext_string ((Extbyte *) buffer, ret, PG_OS_CODING));
 }
 
 DEFUN ("pq-put-nbytes", Fpq_put_nbytes, 2, 2, 0, /*
--- a/src/postgresql.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/postgresql.h	Mon Aug 13 11:19:21 2007 +0200
@@ -10,10 +10,12 @@
 xemacs-patches.
 */
 
-#ifndef XEMACS_POSTGRESQL_H__
-#define XEMACS_POSTGRESQL_H__ 1
+#ifndef INCLUDED_postgresql_h_
+#define INCLUDED_postgresql_h_ 1
 
-#define BLCKSZ 8192 /* size of a default Postres disk block */
+#include LIBPQ_FE_H_FILE /* main PostgreSQL header file */
+
+#define BLCKSZ 8192 /* size of a default Postgres disk block */
 /*
   This file contains the GCC bug workaround code for the private
   LRECORD types.
@@ -57,4 +59,4 @@
 #define CHECK_PGRESULT(x) CHECK_RECORD (x, pgresult)
 #define CONCHECK_PGRESULT(x) CONCHECK_RECORD (x, pgresult)
 
-#endif /* XEMACS_POSTGRESQL_H__ */
+#endif /* INCLUDED_postgresql_h_ */
--- a/src/print.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/print.c	Mon Aug 13 11:19:21 2007 +0200
@@ -38,11 +38,10 @@
 #include "insdel.h"
 #include "lstream.h"
 #include "sysfile.h"
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include "console-msw.h"
 #endif
 
-#include <limits.h>
 #include <float.h>
 /* Define if not in float.h */
 #ifndef DBL_DIG
@@ -106,7 +105,7 @@
 
 int stdout_needs_newline;
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 static int no_useful_stderr;
 #endif
 
@@ -120,19 +119,19 @@
 {
   if (stream)
     {
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       if (!no_useful_stderr)
 	no_useful_stderr = GetStdHandle (STD_ERROR_HANDLE) == 0 ? 1 : -1;
 
       /* we typically have no useful stdout/stderr under windows if we're
 	 being invoked graphically. */
       if (!noninteractive || no_useful_stderr > 0)
-	msw_output_console_string (extptr, extlen);
+	mswindows_output_console_string (extptr, extlen);
       else
 #endif
 	{
 	  fwrite (extptr, 1, extlen, stream);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 	  /* Q122442 says that pipes are "treated as files, not as
 	     devices", and that this is a feature. Before I found that
 	     article, I thought it was a bug. Thanks MS, I feel much
@@ -170,7 +169,7 @@
    called from fatal_error_signal().
 
    2) (to be really correct) make a new lstream that outputs using
-   msw_output_console_string().  */
+   mswindows_output_console_string().  */
 
 static int
 std_handle_out_va (FILE *stream, const char *fmt, va_list args)
@@ -934,10 +933,8 @@
 }
 #endif /* LISP_FLOAT_TYPE */
 
-/* Print NUMBER to BUFFER.  The digits are first written in reverse
-   order (the least significant digit first), and are then reversed.
-   This is equivalent to sprintf(buffer, "%ld", number), only much
-   faster.
+/* Print NUMBER to BUFFER.  This is equivalent to sprintf(buffer,
+   "%ld", number), only much faster.
 
    BUFFER should accept 24 bytes.  This should suffice for the longest
    numbers on 64-bit machines, including the `-' sign and the trailing
@@ -1559,7 +1556,7 @@
 
 Under MS Windows, this writes output to the console window (which is
 created, if necessary), unless XEmacs is being run noninteractively
-(i.e. using the `-batch' argument).
+\(i.e. using the `-batch' argument).
 
 If you have opened a termscript file (using `open-termscript'), then
 the output also will be logged to this file.
--- a/src/process-nt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/process-nt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -36,9 +36,7 @@
 #include "sysdep.h"
 
 #include <shellapi.h>
-#ifdef __MINGW32__
 #include <errno.h>
-#endif
 #include <signal.h>
 #ifdef HAVE_SOCKETS
 #include <winsock.h>
@@ -53,7 +51,6 @@
   HANDLE h_process;
   DWORD dwProcessId;
   HWND hwnd; /* console window */
-  int need_enable_child_signals;
 };
 
 /* Control how args are quoted to ensure correct parsing by child
@@ -422,7 +419,7 @@
 
       GetClassName (hwnd, window_class, sizeof (window_class));
       if (strcmp (window_class,
-		  msw_windows9x_p ()
+		  mswindows_windows9x_p ()
 		  ? "tty"
 		  : "ConsoleWindowClass") == 0)
 	{
@@ -543,7 +540,7 @@
       if (NILP (Vmswindows_start_process_share_console) && cp && cp->hwnd)
 	{
 #if 1
-	  if (msw_windows9x_p ())
+	  if (mswindows_windows9x_p ())
 	    {
 /*
    Another possibility is to try terminating the VDM out-right by
@@ -681,8 +678,8 @@
 static void
 ensure_console_window_exists (void)
 {
-  if (msw_windows9x_p ())
-    msw_hide_console ();
+  if (mswindows_windows9x_p ())
+    mswindows_hide_console ();
 }
 
 int
@@ -770,7 +767,7 @@
 
       /* Duplicate the stdout handle for use as stderr */
       DuplicateHandle(GetCurrentProcess(), hprocout, GetCurrentProcess(),
-		      &hprocerr, 0, TRUE, DUPLICATE_SAME_ACCESS);
+                      &hprocerr, 0, TRUE, DUPLICATE_SAME_ACCESS);
 
       /* Stupid Win32 allows to create a pipe with *both* ends either
 	 inheritable or not. We need process ends inheritable, and local
@@ -790,6 +787,7 @@
     int i;
     Bufbyte **quoted_args;
     int is_dos_app, is_cygnus_app;
+    int is_command_shell;
     int do_quoting = 0;
     char escape_char = 0;
 
@@ -804,6 +802,30 @@
     mswindows_executable_type (XSTRING_DATA (program),
 			       &is_dos_app, &is_cygnus_app);
 
+    {
+      /* #### Bleeeeeeeeeeeeeeeeech!!!!  The command shells appear to
+	 use '^' as a quote character, at least under NT.  #### I haven't
+	 tested 95.  If it allows no quoting conventions at all, set
+	 escape_char to 0 and the code below will work. (e.g. NT tolerates
+         no quoting -- this command
+
+         cmd /c "ls "/Program Files""
+
+         actually works.) */
+	 
+      struct gcpro gcpro1, gcpro2;
+      Lisp_Object progname = Qnil;
+
+      GCPRO2 (program, progname);
+      progname = Ffile_name_nondirectory (program);
+      progname = Fdowncase (progname, Qnil);
+
+      is_command_shell =
+	internal_equal (progname, build_string ("command.com"), 0)
+	|| internal_equal (progname, build_string ("cmd.exe"), 0);
+      UNGCPRO;
+    }
+	
 #if 0
     /* #### we need to port this. */
     /* On Windows 95, if cmdname is a DOS app, we invoke a helper
@@ -860,7 +882,7 @@
 	if (INTP (Vmswindows_quote_process_args))
 	  escape_char = (char) XINT (Vmswindows_quote_process_args);
 	else
-	  escape_char = is_cygnus_app ? '"' : '\\';
+	  escape_char = is_command_shell ? '^' : is_cygnus_app ? '"' : '\\';
       }
   
     /* do argv...  */
@@ -879,7 +901,8 @@
 	    if (*p == '"')
 	      {
 		/* allow for embedded quotes to be escaped */
-		arglen++;
+		if (escape_char)
+		  arglen++;
 		need_quotes = 1;
 		/* handle the case where the embedded quote is already escaped */
 		if (escape_char_run > 0)
@@ -895,7 +918,7 @@
 		need_quotes = 1;
 	      }
 
-	    if (*p == escape_char && escape_char != '"')
+	    if (escape_char && *p == escape_char && escape_char != '"')
 	      escape_char_run++;
 	    else
 	      escape_char_run = 0;
@@ -955,7 +978,7 @@
 #else
 	    for ( ; *p; p++)
 	      {
-		if (*p == '"')
+		if (escape_char && *p == '"')
 		  {
 		    /* double preceding escape chars if any */
 		    while (escape_char_run > 0)
@@ -968,7 +991,7 @@
 		  }
 		*parg++ = *p;
 
-		if (*p == escape_char && escape_char != '"')
+		if (escape_char && *p == escape_char && escape_char != '"')
 		  escape_char_run++;
 		else
 		  escape_char_run = 0;
@@ -1120,7 +1143,7 @@
       }
 
     flags = CREATE_SUSPENDED;
-    if (msw_windows9x_p ())
+    if (mswindows_windows9x_p ())
       flags |= (!NILP (Vmswindows_start_process_share_console)
 		? CREATE_NEW_PROCESS_GROUP
 		: CREATE_NEW_CONSOLE);
@@ -1168,18 +1191,12 @@
 	CloseHandle (pi.hProcess);
       }
 
+    if (!windowed)
+      enable_child_signals (pi.hProcess);
+
     ResumeThread (pi.hThread);
     CloseHandle (pi.hThread);
 
-    /* Remember to enable child signals later if this is not a windowed
-       app.  Can't do it right now because that screws up the MKS Toolkit
-       shell. */
-    if (!windowed)
-      {
-	NT_DATA(p)->need_enable_child_signals = 10;
-	kick_status_notify ();
-      }
-
     return ((int)pi.dwProcessId);
   }
 }
@@ -1196,18 +1213,6 @@
 nt_update_status_if_terminated (Lisp_Process* p)
 {
   DWORD exit_code;
-
-  if (NT_DATA(p)->need_enable_child_signals > 1)
-    {
-      NT_DATA(p)->need_enable_child_signals -= 1;
-      kick_status_notify ();
-    }
-  else if (NT_DATA(p)->need_enable_child_signals == 1)
-    {
-      enable_child_signals(NT_DATA(p)->h_process);
-      NT_DATA(p)->need_enable_child_signals = 0;
-    }
-
   if (GetExitCodeProcess (NT_DATA(p)->h_process, &exit_code)
       && exit_code != STILL_ACTIVE)
     {
@@ -1310,14 +1315,6 @@
 {
   Lisp_Process *p = XPROCESS (proc);
 
-  /* Enable child signals if necessary.  This may lose the first
-     but it's better than nothing. */
-  if (NT_DATA (p)->need_enable_child_signals > 0)
-    {
-      enable_child_signals (NT_DATA(p)->h_process);
-      NT_DATA (p)->need_enable_child_signals = 0;
-    }
-
   /* Signal error if SIGNO cannot be sent */
   validate_signal_number (signo);
 
--- a/src/process-unix.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/process-unix.c	Mon Aug 13 11:19:21 2007 +0200
@@ -779,7 +779,7 @@
   UNIX_DATA(p)->subtty = forkin;
 
   {
-#if !defined(__CYGWIN32__)
+#if !defined(CYGWIN)
     /* child_setup must clobber environ on systems with true vfork.
        Protect it from permanent change.  */
     char **save_environ = environ;
@@ -938,7 +938,7 @@
       } /**** End of child code ****/
 
     /**** Back in parent process ****/
-#if !defined(__CYGWIN32__)
+#if !defined(CYGWIN)
     environ = save_environ;
 #endif
   }
@@ -1855,7 +1855,7 @@
   imr.imr_multiaddr.s_addr = htonl (inet_addr ((char *) XSTRING_DATA (dest)));
   imr.imr_interface.s_addr = htonl (INADDR_ANY);
   if (setsockopt (rs, IPPROTO_IP, IP_ADD_MEMBERSHIP,
-		 (char *) &imr, sizeof (struct ip_mreq)) < 0)
+		  &imr, sizeof (struct ip_mreq)) < 0)
     {
       close (ws);
       close (rs);
@@ -1921,7 +1921,7 @@
 
   /* scope */
   if (setsockopt (ws, IPPROTO_IP, IP_MULTICAST_TTL,
-		  (char *) &thettl, sizeof (thettl)) < 0)
+		  &thettl, sizeof (thettl)) < 0)
     {
       close (rs);
       close (ws);
--- a/src/process.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/process.c	Mon Aug 13 11:19:21 2007 +0200
@@ -107,6 +107,7 @@
 Lisp_Object Vprocess_list;
 
 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
+Lisp_Object Vnull_device;
 
 
 
@@ -2075,6 +2076,22 @@
 
   delete_exited_processes = 1;
 
+  DEFVAR_CONST_LISP ("null-device", &Vnull_device /*
+Name of the null device, which differs from system to system.
+The null device is a filename that acts as a sink for arbitrary amounts of
+data, which is discarded, or as a source for a zero-length file.
+It is available on all the systems that we currently support, but with
+different names (typically either `/dev/null' or `nul').
+
+Note that there is also a /dev/zero on most modern Unix versions (including
+Cygwin), which acts like /dev/null when used as a sink, but as a source
+it sends a non-ending stream of zero bytes.  It's used most often along
+with memory-mapping.  We don't provide a Lisp variable for this because
+the operations needing this are lower level than what ELisp programs
+typically do, and in any case no equivalent exists under native MS Windows.
+*/ );
+  Vnull_device = build_string (NULL_DEVICE);
+
   DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /*
 Control type of device used to communicate with subprocesses.
 Values are nil to use a pipe, or t or `pty' to use a pty.
--- a/src/process.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/process.h	Mon Aug 13 11:19:21 2007 +0200
@@ -109,7 +109,7 @@
 
 void deactivate_process (Lisp_Object proc);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 int
 #else
 void
--- a/src/realpath.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/realpath.c	Mon Aug 13 11:19:21 2007 +0200
@@ -38,7 +38,7 @@
 #include <sys/param.h>
 #endif
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <direct.h>
 #endif
 
@@ -78,7 +78,7 @@
   strcpy (copy_path, path);
   path = copy_path;
   max_path = copy_path + PATH_MAX - 2;
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /*
   ** In NT we have two different cases:  (1) the path name begins
   ** with a drive letter, e.g., "C:"; and (2) the path name begins
--- a/src/redisplay-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/redisplay-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -985,6 +985,13 @@
   GdiFlush();
 }
 
+/* Printer version is more lightweight. */
+static void
+msprinter_frame_output_end (struct frame *f)
+{
+  GdiFlush();
+}
+
 static int
 mswindows_flash (struct device *d)
 {
@@ -1377,6 +1384,7 @@
   CONSOLE_HAS_METHOD (mswindows, output_pixmap);
 
   /* redisplay methods - printer */
+  CONSOLE_HAS_METHOD (msprinter, frame_output_end);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, text_width);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_display_block);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, divider_height);
@@ -1385,7 +1393,6 @@
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, clear_region);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, clear_frame);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, frame_output_begin);
-  CONSOLE_INHERITS_METHOD (msprinter, mswindows, frame_output_end);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, bevel_area);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_string);
   CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_pixmap);
--- a/src/redisplay-tty.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/redisplay-tty.c	Mon Aug 13 11:19:21 2007 +0200
@@ -53,17 +53,12 @@
    invoking them correctly. */
 /* # include <curses.h> */
 /* # include <term.h> */
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int tgetent (const char *, const char *);
-extern int tgetflag (const char *);
-extern int tgetnum (const char *);
-extern char *tgetstr (const char *, char **);
-extern void tputs (const char *, int, void (*)(int));
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C int tgetent (const char *, const char *);
+EXTERN_C int tgetflag (const char *);
+EXTERN_C int tgetnum (const char *);
+EXTERN_C char *tgetstr (const char *, char **);
+EXTERN_C void tputs (const char *, int, void (*)(int));
+
 #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0)
 #define OUTPUTN(c, a, n)			\
   do {						\
@@ -1059,12 +1054,12 @@
   CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044);
   bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer;
 
-#if !defined(WIN32)
+#ifdef SIGTTOU
   /* SIGTT* don't exist under win32 */
   EMACS_BLOCK_SIGNAL (SIGTTOU);
 #endif
   status = tgetent (entry_buffer, terminal_type);
-#if !defined(WIN32)
+#ifdef SIGTTOU
   EMACS_UNBLOCK_SIGNAL (SIGTTOU);
 #endif
 #if 0
--- a/src/redisplay.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/redisplay.c	Mon Aug 13 11:19:21 2007 +0200
@@ -40,7 +40,6 @@
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "commands.h"
@@ -64,11 +63,10 @@
 #include "file-coding.h"
 #endif
 
+#include "sysfile.h"
+
 #ifdef HAVE_TTY
 #include "console-tty.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* for isatty() */
-#endif
 #endif /* HAVE_TTY */
 
 /* Note: We have to be careful throughout this code to properly handle
--- a/src/s/cygwin32.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/s/cygwin32.h	Mon Aug 13 11:19:21 2007 +0200
@@ -20,13 +20,14 @@
 
 /* Building under cygwin
  *
- * The approach I have taken with this port is to use primarily the UNIX 
- * code base adding stuff that is MS-Windows specific. This works quite 
- * well, and is in keeping with my perception of the cygwin philosophy.
- * Note that if you make changes to this file you do NOT want to define 
- * WINDOWSNT, I repeat - do not define this, it will break everything 
- * horribly. What does get defined is HAVE_MS_WINDOWS, but this is 
- * done by configure and only applies to the window system.
+ * The approach I have taken with this port is to use primarily the
+ * UNIX code base adding stuff that is MS-Windows specific. This works
+ * quite well, and is in keeping with my perception of the cygwin
+ * philosophy.  Note that if you make changes to this file you do NOT
+ * want to define WIN32_NATIVE (formerly "WINDOWSNT"), I repeat - do
+ * not define this, it will break everything horribly. What does get
+ * defined is HAVE_MS_WINDOWS, but this is done by configure and only
+ * applies to the window system.
  *
  * When building make sure your HOME path is unix style - i.e. without
  * a drive letter.
@@ -40,6 +41,9 @@
  * Andy Piper <andy@xemacs.org> 8/1/98 
  * http://www.xemacs.freeserve.co.uk/ */
 
+/* Identify ourselves */
+#define CYGWIN
+
 /* cheesy way to determine cygwin version */
 #ifndef NOT_C_CODE
 # include <signal.h>
@@ -57,40 +61,41 @@
 #  endif
 # endif
 
-extern void cygwin32_win32_to_posix_path_list(const char*, char*);
-extern int cygwin32_win32_to_posix_path_list_buf_size(const char*);
-extern void cygwin32_posix_to_win32_path_list(const char*, char*);
-extern int cygwin32_posix_to_win32_path_list_buf_size(const char*);
+void cygwin32_win32_to_posix_path_list (const char*, char*);
+int cygwin32_win32_to_posix_path_list_buf_size (const char*);
+void cygwin32_posix_to_win32_path_list (const char*, char*);
+int cygwin32_posix_to_win32_path_list_buf_size (const char*);
 # if CYGWIN_VERSION_DLL_MAJOR < 20
 struct timeval;
 struct timezone;
 struct itimerval;
 struct stat;
-extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
-extern int gethostname (char* name, int namelen);
-extern char*	mktemp(char *);
-extern double	logb(double);
-extern void	sync();
-extern int	ioctl(int, int, ...);
-				/* sys/stat.h */
-extern int lstat(const char *path, struct stat *buf);
-				/* unistd.h */
-extern int readlink(const char *path, void *buf, unsigned int bufsiz);
-extern int symlink(const char *name1, const char *name2);
-				/* sys/time.h */
-extern int setitimer(int which, const struct itimerval *value,
-		     struct itimerval *ovalue);
-extern int utimes(char *file, struct timeval *tvp);
+int gettimeofday (struct timeval *tp, struct timezone *tzp);
+int gethostname (char* name, int namelen);
+char*	mktemp (char *);
+double	logb (double);
+void	sync (void);
+int	ioctl (int, int, ...);
+ 			/* sys/stat.h */
+int lstat (const char *path, struct stat *buf);
+ 			/* unistd.h */
+int readlink (const char *path, void *buf, unsigned int bufsiz);
+int symlink (const char *name1, const char *name2);
+ 			/* sys/time.h */
+int setitimer (int which, const struct itimerval *value,
+ 	      struct itimerval *ovalue);
+int utimes (char *file, struct timeval *tvp);
 
-extern int srandom( unsigned seed);
-extern long random();
+int srandom (unsigned seed);
+long random (void);
+
+# endif /* CYGWIN_VERSION_DLL_MAJOR < 20 */
 
-# endif
-#endif
+# if CYGWIN_VERSION_DLL_MAJOR <= 20
+char *getpass (const char *prompt);
+double logb (double);
+# endif /* CYGWIN_VERSION_DLL_MAJOR <= 20 */
 
-#ifdef HAVE_MS_WINDOWS
-#define HAVE_NTGUI
-#define HAVE_FACES
 #endif
 
 #ifndef ORDINARY_LINK
@@ -123,10 +128,8 @@
 #define HAVE_SOCKETS
 #endif
 #define OBJECTS_SYSTEM	ntplay.o
-#define HAVE_NATIVE_SOUND
 
 #undef MAIL_USE_SYSTEM_LOCK
-#define MAIL_USE_POP
 
 /* Define NO_ARG_ARRAY if you cannot take the address of the first of a
  * group of arguments and treat it as an array of the arguments.  */
--- a/src/s/decosf4-0.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/s/decosf4-0.h	Mon Aug 13 11:19:21 2007 +0200
@@ -2,9 +2,15 @@
 
 #include "decosf3-2.h"
 
+/* etext and edata are only available when compiling in non-ANSI mode,
+   while _etext and _edata are always available, hence more portable.
+   This allows `configure --compiler=cc --cflags=-std1' to work. */
+#define etext _etext
+#define edata _edata
+
 #ifndef NOT_C_CODE
-#include "/usr/include/sys/lc_core.h"
-#include "/usr/include/reg_types.h"
+#include "sys/lc_core.h"
+#include "reg_types.h"
 #endif /* C code */
 
 #define re_compile_pattern sys_re_compile_pattern
@@ -24,11 +30,10 @@
 #define regoff_t sys_regoff_t
 #define regmatch_t sys_regmatch_t
 
-/* A perfectly ordinary link wins again - martin 
 #undef C_SWITCH_SYSTEM
 #undef LIBS_SYSTEM
 #undef LIBS_DEBUG
-#define ORDINARY_LINK */
+/* #define ORDINARY_LINK */
 
 #undef SYSTEM_MALLOC
 
--- a/src/s/freebsd.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/s/freebsd.h	Mon Aug 13 11:19:21 2007 +0200
@@ -22,6 +22,8 @@
 
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 
+#define INTERRUPTIBLE_OPEN
+
 #define LIBS_DEBUG
 /* FreeBSD 2.2 or later */
 #ifndef __FreeBSD_version
--- a/src/s/mingw32.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/s/mingw32.h	Mon Aug 13 11:19:21 2007 +0200
@@ -20,25 +20,19 @@
 
 /* based on cygwin32.h by Andy Piper <andy@xemacs.org> */
 
-#ifndef WINDOWSNT
-#define WINDOWSNT
+/* Identify ourselves */
+#ifndef WIN32_NATIVE
+#define WIN32_NATIVE
 #endif
 
-#ifndef DOS_NT
-#define DOS_NT 	/* MSDOS or WINDOWSNT */
-#endif
-
-#ifdef HAVE_MS_WINDOWS
-#define HAVE_NTGUI
-#define HAVE_FACES
-#endif
+#define MINGW
 
 #ifndef ORDINARY_LINK
 #define ORDINARY_LINK
 #endif
 
-#define C_SWITCH_SYSTEM "-mno-cygwin -Wno-sign-compare -fno-caller-saves -Int/inc -I../nt/inc -DWINDOWSNT"
-#define LIBS_SYSTEM "-mno-cygwin -lwinmm -lwsock32"
+#define C_SWITCH_SYSTEM "-mno-cygwin -Wno-sign-compare -fno-caller-saves -DWIN32_NATIVE"
+#define LIBS_SYSTEM "-mno-cygwin -mwindows -lwinmm -lwsock32"
 #define WIN32_LEAN_AND_MEAN
 
 #define TEXT_START -1
@@ -62,10 +56,8 @@
 #define HAVE_SOCKETS
 /* #endif */
 #define OBJECTS_SYSTEM	ntplay.o nt.o ntheap.o ntproc.o dired-msw.o
-#define HAVE_NATIVE_SOUND
 
 #undef MAIL_USE_SYSTEM_LOCK
-#define MAIL_USE_POP
 #define HAVE_MSW_C_DIRED
 
 /* Define NO_ARG_ARRAY if you cannot take the address of the first of a
@@ -78,6 +70,8 @@
 #define ENCAPSULATE_OPEN
 #define ENCAPSULATE_FOPEN
 #define ENCAPSULATE_MKDIR
+#define ENCAPSULATE_STAT
+#define ENCAPSULATE_FSTAT
 
 /* Data type of load average, as read out of kmem.  */
 
@@ -134,7 +128,7 @@
 /* Define this to be the separator between devices and paths */
 #define DEVICE_SEP ':'
 
-#define DIRECTORY_SEP '\\'
+#define DIRECTORY_SEP ((char)XCHAR(Vdirectory_sep_char))
 
 /* The null device on Windows NT. */
 #define NULL_DEVICE     "NUL:"
@@ -217,6 +211,10 @@
 #define HAVE_SETITIMER
 #define HAVE_GETTIMEOFDAY
 #define HAVE_SELECT
+/* systime.h includes winsock.h which defines timeval */
+#define HAVE_TIMEVAL
+#define HAVE_GETPAGESIZE
+#define getpagesize() 4096
 /*#define HAVE_STRUCT_UTIMBUF*/
 #ifndef HAVE_H_ERRNO
 #define HAVE_H_ERRNO
@@ -233,10 +231,10 @@
 
 /* We now have emulation for some signals */
 #define HAVE_SIGHOLD
-#define sigset(s,h) msw_sigset(s,h)
-#define sighold(s) msw_sighold(s)
-#define sigrelse(s) msw_sigrelse(s)
-#define sigpause(s) msw_sigpause(s)
+#define sigset(s,h) mswindows_sigset(s,h)
+#define sighold(s) mswindows_sighold(s)
+#define sigrelse(s) mswindows_sigrelse(s)
+#define sigpause(s) mswindows_sigpause(s)
 #define signal sigset
 
 /* Defines that we need that aren't in the standard signal.h  */
@@ -249,11 +247,7 @@
 #ifndef MAXPATHLEN
 #define MAXPATHLEN      _MAX_PATH
 #endif
-
-/* For integration with MSDOS support.  */
-#define getdisk()               (_getdrive () - 1)
-#define getdefdir(_drv, _buf)   _getdcwd (_drv, _buf, MAXPATHLEN)
-#endif
+#endif /* !NOT_C_CODE */
 
 /* Define for those source files that do not include enough NT 
    system files.  */
@@ -268,5 +262,7 @@
 /* Define process implementation */
 #define HAVE_WIN32_PROCESSES
 
-/* ============================================================ */
-
+#define CORRECT_DIR_SEPS(s) \
+  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
+       else unixtodos_filename (s); \
+  } while (0)
--- a/src/s/msdos.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/* System description file for MS-DOS
-
-   Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs 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.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: FSF 19.31. */
-
-/* Note: lots of stuff here was taken from s-msdos.h in demacs. */
-
-
-/*
- *	Define symbols to identify the version of Unix this is.
- *	Define all the symbols that apply correctly.
- */
-
-/* #define UNIPLUS */
-/* #define USG5 */
-/* #define USG */
-/* #define HPUX */
-/* #define UMAX */
-/* #define BSD4_1 */
-/* #define BSD4_2 */
-/* #define BSD4_3 */
-/* #define BSD */
-#ifndef MSDOS
-#define MSDOS
-#endif
-
-#ifdef __GO32__
-#ifndef __DJGPP__
-#define __DJGPP__ 1	/* V2 defines __DJGPP__ == 2 */
-#endif
-#else
-You lose; /* Emacs for DOS must be compiled with DJGPP */
-#endif
-
-#define DOS_NT	/* MSDOS or WINDOWSNT */
-#undef BSD
-
-/* SYSTEM_TYPE should indicate the kind of system you are using.
- It sets the Lisp variable system-type.  */
-
-#define SYSTEM_TYPE "ms-dos"
-
-#define SYMS_SYSTEM syms_of_dosfns();syms_of_msdos()
-
-/* 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 */
-
-/* MSDOS has dirent.h but doesn't behave otherwise like the SYSV
-   directory functions.  We have special tests for this in
-   sysdir.h. */
-
-#undef SYSV_SYSTEM_DIR
-
-/* Define this is the compiler understands `volatile'.  */
-#define HAVE_VOLATILE
-
-#define NO_SUBPROCESSES
-
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF". */
-
-#define COFF
-
-/* 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
-   /usr/spool/mail/$USER.lock.  */
-
-/* #define MAIL_USE_FLOCK */
-
-/* Here, on a separate page, add any special hacks needed
-   to make Emacs work on this system.  For example,
-   you might define certain system call names that don't
-   exist on your system, or that do different things on
-   your system and must be used only through an encapsulation
-   (Which you should place, by convention, in sysdep.c).  */
-
-/* Avoid incompatibilities between gmalloc.c and system header files
-   in how to declare valloc.  */
-#define GMALLOC_INHIBIT_VALLOC
-
-/* setjmp and longjmp can safely replace _setjmp and _longjmp,
-   but they will run slower.  */
-
-#define _setjmp setjmp
-#define _longjmp longjmp
-
-#if __DJGPP__ < 2
-
-#define NO_MODE_T
-
-/* New chdir () routine.
-   DJGPP v2.0 and later doesn't need it because its chdir() does
-   set the drive itself. */
-#ifdef chdir
-#undef chdir
-#endif
-#define chdir sys_chdir
-
-#define LIBS_SYSTEM "-lpc"  /* isn't required in DJGPP v2.0, either */
-
-#endif /* __DJGPP__ < 2 */
-
-#if __DJGPP__ > 1
-
-#define DATA_START  (&etext + 1)
-#define TEXT_START  &start
-#define TEXT_END    &etext
-
-#define _NAIVE_DOS_REGS
-
-#else /* not __DJGPP__ > 1 */
-
-/* This somehow needs to be defined even though we use COFF.  */
-#define TEXT_START -1
-
-#endif /* not __DJGPP__ > 1 */
-
-#define ORDINARY_LINK
-
-/* command.com does not understand `...` so we define this.  */
-#define LIB_GCC "-Lgcc"
-#define DONT_NEED_ENVIRON
-#define SEPCHAR ';'
-
-#define NULL_DEVICE "nul"
-#define EXEC_SUFFIXES ".exe:.com:.bat:"
-
-#if __DJGPP__ < 2
-#define O_RDONLY        0x0001
-#define O_WRONLY        0x0002
-#define O_RDWR          0x0004
-#define O_CREAT         0x0100
-#define O_TRUNC         0x0200
-#define O_EXCL          0x0400
-#define O_APPEND        0x0800
-#define O_TEXT          0x4000
-#define O_BINARY        0x8000
-#define NO_MATHERR
-#endif
-
-#define HAVE_INVERSE_HYPERBOLIC
-#define FLOAT_CHECK_DOMAIN
-
-/* When $TERM is "internal" then this is substituted:  */
-#define INTERNAL_TERMINAL "pc|bios|IBM PC with color display:\
-:co#80:li#25:km:ms:cm=<CM>:cl=<CL>:ce=<CE>:"
-
-/* Define this to a function (Fdowncase, Fupcase) if your file system
-   likes that */
-#define FILE_SYSTEM_CASE Fmsdos_downcase_filename
-
-/* Define this to be the separator between devices and paths */
-#define DEVICE_SEP ':'
-
-/* We'll support either convention on MSDOG.  */
-#define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
-#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
-
-/* Call init_gettimeofday when TZ changes.  */
-#if __DJGPP__ < 2
-#define LOCALTIME_CACHE
-#define tzset init_gettimeofday
-#endif
-
-/* Mode line description of a buffer's type.  */
-#define MODE_LINE_BINARY_TEXT(buf) (NILP(buf->buffer_file_type) ? "T" : "B")
-
-/* Do we have POSIX signals?  */
-#if __DJGPP__ > 1
-#define POSIX_SIGNALS
-#endif
-
-/* We have (the code to control) a mouse.  */
-#define HAVE_MOUSE
-
-/* We canuse mouse menus.  */
-#define HAVE_MENUS
-
-/* We have support for faces.  */
-#define HAVE_FACES
-
-/* Define one of these for easier conditionals.  */
-#ifdef HAVE_X_WINDOWS
-/* We need a little extra space, see ../../lisp/loadup.el */
-#define SYSTEM_PURESIZE_EXTRA 15000
-#define HAVE_X11R5
-#define LIBX11_SYSTEM "-lxext -lsys"
-#else
-/* We need a little extra space, see ../../lisp/loadup.el */
-#define SYSTEM_PURESIZE_EXTRA 85000
-#endif
--- a/src/s/windows95.h	Mon Aug 13 11:18:12 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-/* Synched up with: FSF 19.31. */
-
-/* System description file for Windows 95.  */
-
-#include "windowsnt.h"
-
-#define WINDOWS95
--- a/src/s/windowsnt.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/s/windowsnt.h	Mon Aug 13 11:19:21 2007 +0200
@@ -1,4 +1,4 @@
-/* System description file for Windows NT.
+/* System description file for Windows 9x and NT.
    Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -20,12 +20,73 @@
 
 /* Synched up with: FSF 19.31. */
 
-#ifndef WINDOWSNT
-#define WINDOWSNT
-#endif
+/* Capsule summary of different preprocessor flags:
+
+1. Keep in mind that there are two possible OS environments we are dealing
+   with -- Cygwin and Native Windows.  Cygwin provides a POSIX emulation
+   layer on top of MS Windows -- in particular, providing the file-system,
+   process, tty, and signal semantics that are part of a modern, standard
+   Unix operating system.  MS Windows also provides these services, but
+   through their own API, called Win32.  When compiling in a Cygwin
+   environment, the Win32 API's are also available, and in fact are used
+   to do native GUI programming.
+
+2. There are two windowing environments we can target XEmacs for when
+   running under MS Windows -- Windows native, and X. (It may seem strange
+   to write an X application under Windows, but there are in fact many X
+   servers out there running on Windows, and as far as I know there is no
+   real (or at least, that works well) networking Window-system extension
+   under MS Windows.  Furthermore, if you're porting a Unix application to
+   Windows and use Cygwin to assist you, it might seem natural to use an
+   X server to avoid having to port all the code to Windows.) For XEmacs,
+   there are various reasons people could come up with for why we would
+   want to keep maintaining X Windows under MS Windows support.
+
+That gives us four possible build environments.  I (Ben) build
+regularly on fully-native-everything, Andy builds on Cygwin + MS
+Windows + X Windows for windowing.
+
+The build flags used for these divisions are:
+
+CYGWIN -- for Cygwin-only stuff.
+WIN32_NATIVE -- Win32 native OS-level stuff (files, process, etc.).
+HAVE_X_WINDOWS -- for X Windows (regardless of whether under MS Win)
+HAVE_MS_WINDOWS -- MS Windows native windowing system (anything related to
+                   the appearance of the graphical screen).
 
-#ifndef DOS_NT
-#define DOS_NT 	/* MSDOS or WINDOWSNT */
+Finally, there's also the MINGW build environment, which uses GCC
+\(similar to Cygwin), but native MS Windows libraries rather than a
+POSIX emulation layer (the Cygwin approach).  This environment defines
+WIN32_NATIVE, but also defines MINGW, which is used mostly because
+uses its own include files (related to Cygwin), which have a few
+things messed up.
+
+
+Formerly, we had a whole host of flags.  Here's the conversion, for porting
+code from GNU Emacs and such:
+
+
+WINDOWSNT -> WIN32_NATIVE
+WIN32 -> WIN32_NATIVE
+_WIN32 -> WIN32_NATIVE
+HAVE_WIN32 -> WIN32_NATIVE
+DOS_NT -> WIN32_NATIVE
+HAVE_NTGUI -> WIN32_NATIVE, unless it ends up already bracketed by this
+HAVE_FACES -> always true
+MSDOS -> determine whether this code is really specific to MS-DOS (and not
+         Windows -- e.g. DJGPP code); if so, delete the code; otherwise,
+         convert to WIN32_NATIVE (we do not support MS-DOS w/DOS Extender
+         under XEmacs)
+
+__CYGWIN__ -> CYGWIN
+__CYGWIN32__ -> CYGWIN
+__MINGW32__ -> MINGW
+
+*/
+
+/* Identify ourselves */
+#ifndef WIN32_NATIVE
+#define WIN32_NATIVE
 #endif
 
 /* In case non-Microsoft compiler is used, we fake _MSC_VER */
@@ -167,11 +228,6 @@
 #define HAVE_H_ERRNO
 #define HAVE_STRUCT_UTIMBUF
 
-#ifdef HAVE_NTGUI
-#define HAVE_WINDOW_SYSTEM
-#define HAVE_FACES
-#endif
-
 #define HAVE_STRCASECMP
 
 /* Compatibility macros. Some used to be routines in nt.c */
@@ -246,10 +302,10 @@
 
 /* We now have emulation for some signals */
 #define HAVE_SIGHOLD
-#define sigset(s,h) msw_sigset(s,h)
-#define sighold(s) msw_sighold(s)
-#define sigrelse(s) msw_sigrelse(s)
-#define sigpause(s) msw_sigpause(s)
+#define sigset(s,h) mswindows_sigset(s,h)
+#define sighold(s) mswindows_sighold(s)
+#define sigrelse(s) mswindows_sigrelse(s)
+#define sigpause(s) mswindows_sigpause(s)
 
 /* Defines that we need that aren't in the standard signal.h  */
 #define SIGHUP  1               /* Hang up */
@@ -258,10 +314,6 @@
 #define SIGALRM 14              /* Alarm */
 #define SIGPROF 29		/* Profiling timer exp */
 
-/* For integration with MSDOS support.  */
-#define getdisk()               (_getdrive () - 1)
-#define getdefdir(_drv, _buf)   _getdcwd (_drv, _buf, MAXPATHLEN)
-
 /* Defines size_t and alloca ().  */
 #include <malloc.h>
 
@@ -312,3 +364,8 @@
 #define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
           __declspec(noreturn) extern void decl PRINTF_ARGS(str,idx)
 #endif /* MSVC 6.0 */
+
+#define CORRECT_DIR_SEPS(s) \
+  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
+       else unixtodos_filename (s); \
+  } while (0)
--- a/src/scrollbar-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/scrollbar-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -24,7 +24,6 @@
 /* Synched up with: Not in FSF. */
 
 #include <config.h>
-#include <limits.h>
 #include "lisp.h"
 
 #include "console-msw.h"
--- a/src/select-msw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/select-msw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -24,104 +24,396 @@
 
    Written by Kevin Gallo for FSF Emacs.
    Rewritten for mswindows by Jonathan Harris, December 1997 for 21.0.
- */
-
+   Hacked by Alastair Houghton, July 2000 for enhanced clipboard support.
+*/
 
 #include <config.h>
 #include "lisp.h"
 #include "frame.h"
 #include "select.h"
+#include "opaque.h"
+#include "file-coding.h"
+#include "buffer.h"
 
 #include "console-msw.h"
 
+/* A list of handles that we must release. Not accessible from Lisp. */
+static Lisp_Object Vhandle_alist;
 
-/* Do protocol to assert ourself as a selection owner. Under mswindows
-this is easy, we just set the clipboard.  */
+/* Test if this is an X symbol that we understand */
+static int
+x_sym_p (Lisp_Object value)
+{
+  if (NILP (value) || INTP (value))
+    return 0;
+
+  /* Check for some of the X symbols */
+  if (EQ (value, QSTRING))		return 1;
+  if (EQ (value, QTEXT))		return 1;
+  if (EQ (value, QCOMPOUND_TEXT))	return 1;
+
+  return 0;
+}
+
+/* This converts a Lisp symbol to an MS-Windows clipboard format.
+   We have symbols for all predefined clipboard formats, but that
+   doesn't mean we support them all ;-)
+   The name of this function is actually a lie - it also knows about
+   integers and strings... */
+static UINT
+symbol_to_ms_cf (Lisp_Object value)
+{
+  /* If it's NIL, we're in trouble. */
+  if (NILP (value))			return 0;
+  
+  /* If it's an integer, assume it's a format ID */
+  if (INTP (value))			return (UINT) (XINT (value));
+
+  /* If it's a string, register the format(!) */
+  if (STRINGP (value))
+    return RegisterClipboardFormat (XSTRING_DATA (value));
+  
+  /* Check for Windows clipboard format symbols */
+  if (EQ (value, QCF_TEXT))		return CF_TEXT;
+  if (EQ (value, QCF_BITMAP))		return CF_BITMAP;
+  if (EQ (value, QCF_METAFILEPICT))	return CF_METAFILEPICT;
+  if (EQ (value, QCF_SYLK))		return CF_SYLK;
+  if (EQ (value, QCF_DIF))		return CF_DIF;
+  if (EQ (value, QCF_TIFF))		return CF_TIFF;
+  if (EQ (value, QCF_OEMTEXT))		return CF_OEMTEXT;
+  if (EQ (value, QCF_DIB))		return CF_DIB;
+  if (EQ (value, QCF_PALETTE))		return CF_PALETTE;
+  if (EQ (value, QCF_PENDATA))		return CF_PENDATA;
+  if (EQ (value, QCF_RIFF))		return CF_RIFF;
+  if (EQ (value, QCF_WAVE))		return CF_WAVE;
+  if (EQ (value, QCF_UNICODETEXT))	return CF_UNICODETEXT;
+  if (EQ (value, QCF_ENHMETAFILE))	return CF_ENHMETAFILE;
+  if (EQ (value, QCF_HDROP))		return CF_HDROP;
+  if (EQ (value, QCF_LOCALE))		return CF_LOCALE;
+  if (EQ (value, QCF_OWNERDISPLAY))	return CF_OWNERDISPLAY;
+  if (EQ (value, QCF_DSPTEXT))		return CF_DSPTEXT;
+  if (EQ (value, QCF_DSPBITMAP))	return CF_DSPBITMAP;
+  if (EQ (value, QCF_DSPMETAFILEPICT))	return CF_DSPMETAFILEPICT;
+  if (EQ (value, QCF_DSPENHMETAFILE))	return CF_DSPENHMETAFILE;
+
+  return 0;
+}
+
+/* This converts an MS-Windows clipboard format to its corresponding
+   Lisp symbol, or a Lisp integer otherwise. */
+static Lisp_Object
+ms_cf_to_symbol (UINT format)
+{
+  switch (format)
+    {
+    case CF_TEXT:		return QCF_TEXT;
+    case CF_BITMAP:		return QCF_BITMAP;
+    case CF_METAFILEPICT:	return QCF_METAFILEPICT;
+    case CF_SYLK:		return QCF_SYLK;
+    case CF_DIF:		return QCF_DIF;
+    case CF_TIFF:		return QCF_TIFF;
+    case CF_OEMTEXT:		return QCF_OEMTEXT;
+    case CF_DIB:		return QCF_DIB;
+    case CF_PALETTE:		return QCF_PALETTE;
+    case CF_PENDATA:		return QCF_PENDATA;
+    case CF_RIFF:		return QCF_RIFF;
+    case CF_WAVE:		return QCF_WAVE;
+    case CF_UNICODETEXT:	return QCF_UNICODETEXT;
+    case CF_ENHMETAFILE:	return QCF_ENHMETAFILE;
+    case CF_HDROP:		return QCF_HDROP;
+    case CF_LOCALE:		return QCF_LOCALE;
+    case CF_OWNERDISPLAY:	return QCF_OWNERDISPLAY;
+    case CF_DSPTEXT:		return QCF_DSPTEXT;
+    case CF_DSPBITMAP:		return QCF_DSPBITMAP;
+    case CF_DSPMETAFILEPICT:	return QCF_DSPMETAFILEPICT;
+    case CF_DSPENHMETAFILE:	return QCF_DSPENHMETAFILE;
+    default:			return make_int ((int) format);
+    }
+}
+
+/* Test if the specified clipboard format is auto-released by the OS. If
+   not, we must remember the handle on Vhandle_alist, and free it if
+   the clipboard is emptied or if we set data with the same format. */
+static int
+cf_is_autofreed (UINT format)
+{
+  switch (format)
+    {
+    /* This list comes from the SDK documentation */
+    case CF_DSPENHMETAFILE:
+    case CF_DSPMETAFILEPICT:
+    case CF_ENHMETAFILE:
+    case CF_BITMAP:
+    case CF_DSPBITMAP:
+    case CF_PALETTE:
+    case CF_DIB:
+    case CF_DSPTEXT:
+    case CF_OEMTEXT:
+    case CF_TEXT:
+    case CF_UNICODETEXT:
+      return TRUE;
+
+    default:
+      return FALSE;
+    }
+}
+
+/* Do protocol to assert ourself as a selection owner.
+   
+   Under mswindows, we:
+
+   * Only set the clipboard if (eq selection-name 'CLIPBOARD)
+
+   * Check if an X atom name has been passed. If so, convert to CF_TEXT
+     (or CF_UNICODETEXT) remembering to perform LF -> CR-LF conversion.
+
+   * Otherwise assume the data is formatted appropriately for the data type
+     that was passed.
+
+   Then set the clipboard as necessary.
+*/
 static Lisp_Object
 mswindows_own_selection (Lisp_Object selection_name,
-			 Lisp_Object selection_value)
+			 Lisp_Object selection_value,
+			 Lisp_Object how_to_add,
+			 Lisp_Object selection_type)
 {
-  Lisp_Object converted_value = get_local_selection (selection_name, QSTRING);
+  HGLOBAL 	hValue = NULL;
+  UINT		cfType;
+  int		is_X_type = FALSE;
+  Lisp_Object	cfObject;
+  Lisp_Object	data = Qnil;
+  int		size;
+  void		*src, *dst;
+  struct frame  *f = NULL;
+
+  /* Only continue if we're trying to set the clipboard - mswindows doesn't
+     use the same selection model as X */
+  if (!EQ (selection_name, QCLIPBOARD))
+    return Qnil;
 
-  if (!NILP (converted_value) &&
-      CONSP (converted_value) &&
-      EQ (XCAR (converted_value), QSTRING) &&
-      /* pure mswindows behaviour only says we can own the selection 
-	 if it is the clipboard */
-      EQ (selection_name, QCLIPBOARD))
+  /* If this is one of the X-style atom name symbols, or NIL, convert it
+     as appropriate */
+  if (NILP (selection_type) || x_sym_p (selection_type))
+    {
+      /* Should COMPOUND_TEXT map to CF_UNICODETEXT? */
+      cfType = CF_TEXT;
+      cfObject = QCF_TEXT;
+      is_X_type = TRUE;
+    }
+  else
+    {
+      cfType = symbol_to_ms_cf (selection_type);
+
+      /* Only continue if we can figure out a clipboard type */
+      if (!cfType)
+	return Qnil;
+      
+      cfObject = selection_type;
+    }
+
+  /* Convert things appropriately */
+  data = select_convert_out (selection_name,
+			     cfObject,
+			     selection_value);
+
+  if (NILP (data))
+    return Qnil;
+
+  if (CONSP (data))
     {
-      int rawsize, size, i;
-      unsigned char *src, *dst, *next;
-      HGLOBAL h = NULL;
-      struct frame *f = NULL;
-      struct gcpro gcpro1, gcpro2;
-      Lisp_Object string = XCDR (converted_value);
+      if (!EQ (XCAR (data), cfObject))
+	cfType = symbol_to_ms_cf (XCAR (data));
+
+      if (!cfType)
+	return Qnil;
 
-      GCPRO2 (converted_value, string);
-
-      CHECK_STRING (string);
+      data = XCDR (data);
+    }
+  
+  /* We support opaque or string values, but we only mention string
+     values for now... */
+  if (!OPAQUEP (data)
+      && !STRINGP (data))
+    return Qnil;
+      
+  /* Compute the data length */
+  if (OPAQUEP (data))
+    size = XOPAQUE_SIZE (data);
+  else
+    size = XSTRING_LENGTH (data) + 1;
+      
+  /* Find the frame */
+  f = selected_frame ();
 
-      /* Calculate size with LFs converted to CRLFs because
-       * CF_TEXT format uses CRLF delimited ASCIIZ */
-      src = XSTRING_DATA (string);
-      size = rawsize = XSTRING_LENGTH (string) + 1;
-      for (i=0; i<rawsize; i++)
-	if (src[i] == '\n')
-	  size++;
+  /* Open the clipboard */
+  if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+    return Qnil;
+  
+  /* Allocate memory */
+  hValue = GlobalAlloc (GMEM_DDESHARE | GMEM_MOVEABLE, size);
+      
+  if (!hValue)
+    {
+      CloseClipboard ();
 
-      f = selected_frame ();
-      if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+      return Qnil;
+    }
+      
+  /* Copy the data */
+  if (OPAQUEP (data))
+    src = XOPAQUE_DATA (data);
+  else
+    src = XSTRING_DATA (data);
+      
+  dst = GlobalLock (hValue);
+  
+  if (!dst)
+    {
+      GlobalFree (hValue);
+      CloseClipboard ();
+      
+      return Qnil;
+    }
+  
+  memcpy (dst, src, size);
+
+  GlobalUnlock (hValue);
+
+  /* Empty the clipboard if we're replacing everything */
+  if (NILP (how_to_add) || EQ (how_to_add, Qreplace_all))
+    {
+      if (!EmptyClipboard ())
 	{
-	  UNGCPRO;
+	  CloseClipboard ();
+	  GlobalFree (hValue);
+
 	  return Qnil;
 	}
-
-      /* This call to EmptyClipboard may post an event back to us if
-	 we already own the clipboard (to tell us we lost it) and this
-	 event may execute random lisp code.  Hence we must protect
-	 the string and get its address again after the call. */
-      if (!EmptyClipboard () ||
-	  (h = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, size)) == NULL ||
-	  (dst = (unsigned char *) GlobalLock (h)) == NULL)
-	{
-	  if (h != NULL) GlobalFree (h);
-	  CloseClipboard ();
-	  UNGCPRO;
-	  return Qnil;
-	}
-      src = XSTRING_DATA (string);
-
-      /* Convert LFs to CRLFs */
-      do
-	{
-	  /* copy next line or remaining bytes including '\0' */
-	  next = (char*) memccpy (dst, src, '\n', rawsize);
-	  if (next)
-	    {
-	      /* copied one line ending with '\n' */
-	      int copied = next - dst;
-	      rawsize -= copied;
-	      src += copied;
-	      /* insert '\r' before '\n' */
-	      next[-1] = '\r';
-	      next[0] = '\n';
-	      dst = next+1;
-	    }	    
-	}
-      while (next);
-    
-      GlobalUnlock (h);
-  
-      i = (SetClipboardData (CF_TEXT, h) != NULL);
-  
-      CloseClipboard ();
-
-      UNGCPRO;
-      /* #### we are supposed to return a time! */
-      /* return i ? Qt : Qnil; */
-      return Qnil;
     }
 
+  /* Append is currently handled in select.el; perhaps this should change,
+     but it only really makes sense for ordinary text in any case... */
+
+  SetClipboardData (cfType, hValue);
+
+  if (!cf_is_autofreed (cfType))
+    {
+      Lisp_Object alist_elt = Qnil, rest;
+      Lisp_Object cfType_int = make_int (cfType);
+      
+      /* First check if there's an element in the alist for this type
+	 already. */
+      alist_elt = assq_no_quit (cfType_int, Vhandle_alist);
+
+      /* Add an element to the alist */
+      Vhandle_alist = Fcons (Fcons (cfType_int, make_opaque_ptr (hValue)),
+			     Vhandle_alist);
+
+      if (!NILP (alist_elt))
+	{
+	  /* Free the original handle */
+	  GlobalFree ((HGLOBAL) get_opaque_ptr (XCDR (alist_elt)));
+	
+	  /* Remove the original one (adding first makes life easier, because
+	     we don't have to special case this being the first element)      */
+	  for (rest = Vhandle_alist; !NILP (rest); rest = Fcdr (rest))
+	    if (EQ (cfType_int, Fcar (XCDR (rest))))
+	      {
+		XCDR (rest) = Fcdr (XCDR (rest));
+		break;
+	      }
+	}
+    }
+  
+  CloseClipboard ();
+
+  /* #### Should really return a time, though this is because of the
+     X model (by the looks of things) */
+  return Qnil;
+}
+
+static Lisp_Object
+mswindows_available_selection_types (Lisp_Object selection_name)
+{
+  Lisp_Object	types = Qnil;
+  UINT		format = 0;
+  struct frame  *f = NULL;
+
+  if (!EQ (selection_name, QCLIPBOARD))
+    return Qnil;
+  
+  /* Find the frame */
+  f = selected_frame ();
+
+  /* Open the clipboard */
+  if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+    return Qnil;
+
+  /* #### ajh - Should there be an unwind-protect handler around this?
+                It could (well it probably won't, but it's always better to
+		be safe) run out of memory and leave the clipboard open... */
+  
+  while ((format = EnumClipboardFormats (format)))
+    types = Fcons (ms_cf_to_symbol (format), types);
+
+  /* Close it */
+  CloseClipboard ();
+
+  return types;
+}
+
+static Lisp_Object
+mswindows_register_selection_data_type (Lisp_Object type_name)
+{
+  /* Type already checked in select.c */
+  const char *name = XSTRING_DATA (type_name);
+  UINT	      format;
+
+  format = RegisterClipboardFormat (name);
+
+  if (format)
+    return make_int ((int) format);
+  else
+    return Qnil;
+}
+
+static Lisp_Object
+mswindows_selection_data_type_name (Lisp_Object type_id)
+{
+  UINT		format;
+  int		numchars;
+  char		name_buf[128];
+
+  /* If it's an integer, convert to a symbol if appropriate */
+  if (INTP (type_id))
+    type_id = ms_cf_to_symbol (XINT (type_id));
+  
+  /* If this is a symbol, return it */
+  if (SYMBOLP (type_id))
+    return type_id;
+
+  /* Find the format code */
+  format = symbol_to_ms_cf (type_id);
+
+  if (!format)
+    return Qnil;
+
+  /* Microsoft, stupid Microsoft */
+  numchars = GetClipboardFormatName (format, name_buf, 128);
+
+  if (numchars)
+    {
+      Lisp_Object name;
+
+      /* Do this properly - though we could support UNICODE (UCS-2) if
+         MULE could hack it. */
+      name = make_ext_string (name_buf, numchars,
+			      Fget_coding_system (Qraw_text));
+      
+      return name;
+    }
+  
   return Qnil;
 }
 
@@ -129,56 +421,91 @@
 mswindows_get_foreign_selection (Lisp_Object selection_symbol,
 				 Lisp_Object target_type)
 {
-  if (EQ (selection_symbol, QCLIPBOARD))
+  HGLOBAL	hValue = NULL;
+  UINT		cfType;
+  Lisp_Object	cfObject = Qnil, ret = Qnil, value = Qnil;
+  int		is_X_type = FALSE;
+  int		size;
+  void		*data;
+  struct frame  *f = NULL;
+  struct gcpro	gcpro1;
+  
+  /* Only continue if we're trying to read the clipboard - mswindows doesn't
+     use the same selection model as X */
+  if (!EQ (selection_symbol, QCLIPBOARD))
+    return Qnil;
+
+  /* If this is one fo the X-style atom name symbols, or NIL, convert it
+     as appropriate */
+  if (NILP (target_type) || x_sym_p (target_type))
     {
-      HANDLE h;
-      unsigned char *src, *dst, *next;
-      Lisp_Object ret = Qnil;
+      /* Should COMPOUND_TEXT map to CF_UNICODETEXT? */
+      cfType = CF_TEXT;
+      cfObject = QCF_TEXT;
+      is_X_type = TRUE;
+    }
+  else
+    {
+      cfType = symbol_to_ms_cf (target_type);
 
-      if (!OpenClipboard (NULL))
+      /* Only continue if we can figure out a clipboard type */
+      if (!cfType)
 	return Qnil;
 
-      if ((h = GetClipboardData (CF_TEXT)) != NULL &&
-	  (src = (unsigned char *) GlobalLock (h)) != NULL)
-	{
-	  int i;
-	  int size, rawsize;
-	  size = rawsize = strlen (src);
+      cfObject = ms_cf_to_symbol (cfType);
+    }
 
-	  for (i=0; i<rawsize; i++)
-	    if (src[i] == '\r' && src[i+1] == '\n')
-	      size--;
+  /* Find the frame */
+  f = selected_frame ();
 
-	  /* Convert CRLFs to LFs */
-	  ret = make_uninit_string (size);
-	  dst = XSTRING_DATA (ret);
-	  do
-	    {
-	      /* copy next line or remaining bytes excluding '\0' */
-	      next = (unsigned char *) memccpy (dst, src, '\r', rawsize);
-	      if (next)
-		{
-		  /* copied one line ending with '\r' */
-		  int copied = next - dst;
-		  rawsize -= copied;
-		  src += copied;
-		  if (*src == '\n')
-		    dst += copied - 1;		/* overwrite '\r' */
-		  else
-		    dst += copied;
-		}	    
-	    }
-	  while (next);
+  /* Open the clipboard */
+  if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+    return Qnil;
 
-	  GlobalUnlock (h);
-	}
+  /* Read the clipboard */
+  hValue = GetClipboardData (cfType);
 
+  if (!hValue)
+    {
       CloseClipboard ();
 
-      return ret;
+      return Qnil;
+    }
+
+  /* Find the data */
+  size = GlobalSize (hValue);
+  data = GlobalLock (hValue);
+
+  if (!data)
+    {
+      CloseClipboard ();
+
+      return Qnil;
     }
+
+  /* Place it in a Lisp string */
+  TO_INTERNAL_FORMAT (DATA, (data, size),
+		      LISP_STRING, ret,
+		      Qbinary);
+
+  GlobalUnlock (data);
+  CloseClipboard ();
+
+  GCPRO1 (ret);
+  
+  /* Convert this to the appropriate type. If we can't find anything,
+     then we return a cons of the form (DATA-TYPE . STRING), where the
+     string contains the raw binary data. */
+  value = select_convert_in (selection_symbol,
+			     cfObject,
+			     ret);
+
+  UNGCPRO;
+  
+  if (NILP (value))
+    return Fcons (cfObject, ret);
   else
-    return Qnil;
+    return value;
 }
 
 static void
@@ -199,11 +526,37 @@
     }
 }
 
-static Lisp_Object
-mswindows_selection_exists_p (Lisp_Object selection)
+void
+mswindows_destroy_selection (Lisp_Object selection)
 {
+  Lisp_Object alist_elt;
+  
+  /* Do nothing if this isn't for the clipboard. */
+  if (!EQ (selection, QCLIPBOARD))
+    return;
+
+  /* Right. We need to delete everything in Vhandle_alist. */
+  alist_elt = Vhandle_alist;
+
+  for (alist_elt; !NILP (alist_elt); alist_elt = Fcdr (alist_elt))
+    GlobalFree ((HGLOBAL) get_opaque_ptr (XCDR (alist_elt)));
+
+  Vhandle_alist = Qnil;
+}
+
+static Lisp_Object
+mswindows_selection_exists_p (Lisp_Object selection,
+			      Lisp_Object selection_type)
+{
+  /* We used to be picky about the format, but now we support anything. */
   if (EQ (selection, QCLIPBOARD))
-    return IsClipboardFormatAvailable (CF_TEXT) ? Qt : Qnil;
+    {
+      if (NILP (selection_type))
+	return CountClipboardFormats () ? Qt : Qnil;
+      else
+	return IsClipboardFormatAvailable (symbol_to_ms_cf (selection_type))
+	  ? Qt : Qnil;
+    }
   else
     return Qnil;
 }
@@ -220,6 +573,9 @@
   CONSOLE_HAS_METHOD (mswindows, disown_selection);
   CONSOLE_HAS_METHOD (mswindows, selection_exists_p);
   CONSOLE_HAS_METHOD (mswindows, get_foreign_selection);
+  CONSOLE_HAS_METHOD (mswindows, available_selection_types);
+  CONSOLE_HAS_METHOD (mswindows, register_selection_data_type);
+  CONSOLE_HAS_METHOD (mswindows, selection_data_type_name);
 }
 
 void
@@ -230,4 +586,7 @@
 void
 vars_of_select_mswindows (void)
 {
+  /* Initialise Vhandle_alist */
+  Vhandle_alist = Qnil;
+  staticpro (&Vhandle_alist);
 }
--- a/src/select-x.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/select-x.c	Mon Aug 13 11:19:21 2007 +0200
@@ -200,11 +200,10 @@
 
 
 /* Do protocol to assert ourself as a selection owner.
-   Update the Vselection_alist so that we can reply to later requests for
-   our selection.
  */
 static Lisp_Object
-x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
+x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
+		 Lisp_Object how_to_add, Lisp_Object selection_type)
 {
   struct device *d = decode_x_device (Qnil);
   Display *display = DEVICE_X_DISPLAY (d);
@@ -252,7 +251,7 @@
 				Lisp_Object selection_value,
 				Time thyme,
 				Display *display,
-                                                Window selecting_window)
+				Window selecting_window)
      /*				Bool owned_p)*/
 {
   struct device *d = get_device_from_display (display);
@@ -375,10 +374,34 @@
       {
 	Display *dpy = XtDisplay (widget);
 	Window window = (Window) *private_id;
-	Lisp_Object selection = assq_no_quit (QCLIPBOARD, Vselection_alist);
-	if (NILP (selection)) abort ();
-	selection = XCDR (selection);
-	if (!STRINGP (selection)) abort ();
+	Lisp_Object selection = select_convert_out (QCLIPBOARD, Qnil, Qnil);
+
+	/* Whichever lazy git wrote this originally just called abort()
+	   when anything didn't go their way... */
+	
+	/* Try some other text types */
+	if (NILP (selection))
+	  selection = select_convert_out (QCLIPBOARD, QSTRING, Qnil);
+	if (NILP (selection))
+	  selection = select_convert_out (QCLIPBOARD, QTEXT, Qnil);
+	if (NILP (selection))
+	  selection = select_convert_out (QCLIPBOARD, QCOMPOUND_TEXT, Qnil);
+	
+	if (CONSP (selection) && SYMBOLP (XCAR (selection))
+	    && (EQ (XCAR (selection), QSTRING)
+		|| EQ (XCAR (selection), QTEXT)
+		|| EQ (XCAR (selection), QCOMPOUND_TEXT)))
+	  selection = XCDR (selection);
+
+	if (NILP (selection))
+	  signal_error (Qselection_conversion_error,
+			build_string ("no selection"));
+
+	if (!STRINGP (selection))
+	  signal_error (Qselection_conversion_error,
+			build_string ("couldn't convert selection to string"));
+			       
+	
 	XmClipboardCopyByName (dpy, window, *data_id,
 			       (char *) XSTRING_DATA (selection),
 			       XSTRING_LENGTH (selection) + 1,
@@ -546,8 +569,8 @@
 x_handle_selection_request (XSelectionRequestEvent *event)
 {
   /* This function can GC */
-  struct gcpro gcpro1, gcpro2, gcpro3;
-  Lisp_Object local_selection_data = Qnil;
+  struct gcpro gcpro1, gcpro2;
+  Lisp_Object temp_obj;
   Lisp_Object selection_symbol;
   Lisp_Object target_symbol = Qnil;
   Lisp_Object converted_selection = Qnil;
@@ -556,33 +579,28 @@
   int count;
   struct device *d = get_device_from_display (event->display);
 
-  GCPRO3 (local_selection_data, converted_selection, target_symbol);
+  GCPRO2 (converted_selection, target_symbol);
 
   selection_symbol = x_atom_to_symbol (d, event->selection);
-
-  local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
+  target_symbol = x_atom_to_symbol (d, event->target);
 
-#if 0
-  /* This list isn't user-visible, so it can't "go bad." */
-  assert (CONSP (local_selection_data));
-  assert (CONSP (XCDR (local_selection_data)));
-  assert (CONSP (XCDR (XCDR (local_selection_data))));
-  assert (NILP  (XCDR (XCDR (XCDR (local_selection_data)))));
-  assert (CONSP (XCAR (XCDR (XCDR (local_selection_data)))));
-  assert (INTP  (XCAR (XCAR (XCDR (XCDR (local_selection_data))))));
-  assert (INTP  (XCDR (XCAR (XCDR (XCDR (local_selection_data))))));
+#if 0 /* #### MULTIPLE doesn't work yet */
+  if (EQ (target_symbol, QMULTIPLE))
+    target_symbol = fetch_multiple_target (event);
 #endif
 
-  if (NILP (local_selection_data))
+  temp_obj = Fget_selection_timestamp (selection_symbol);
+
+  if (NILP (temp_obj))
     {
-      /* Someone asked for the selection, but we don't have it any more. */
+      /* We don't appear to have the selection. */
       x_decline_selection_request (event);
+
       goto DONE_LABEL;
     }
 
-  local_selection_time =
-    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
-
+  local_selection_time = * (Time *) XOPAQUE_DATA (temp_obj);
+  
   if (event->time != CurrentTime &&
       local_selection_time > event->time)
     {
@@ -592,35 +610,36 @@
       goto DONE_LABEL;
     }
 
+  converted_selection = select_convert_out (selection_symbol,
+					    target_symbol, Qnil);
+
+  /* #### Is this the right thing to do? I'm no X expert. -- ajh */
+  if (NILP (converted_selection))
+    {
+      /* We don't appear to have a selection in that data type. */
+      x_decline_selection_request (event);
+      goto DONE_LABEL;
+    }
+
   count = specpdl_depth ();
   record_unwind_protect (x_selection_request_lisp_error,
 			 make_opaque_ptr (event));
-  target_symbol = x_atom_to_symbol (d, event->target);
 
-#if 0 /* #### MULTIPLE doesn't work yet */
-  if (EQ (target_symbol, QMULTIPLE))
-    target_symbol = fetch_multiple_target (event);
-#endif
-
-  /* Convert lisp objects back into binary data */
-
-  converted_selection =
-    get_local_selection (selection_symbol, target_symbol);
-
-  if (! NILP (converted_selection))
-    {
-      unsigned char *data;
-      unsigned int size;
-      int format;
-      Atom type;
-      lisp_data_to_selection_data (d, converted_selection,
-				   &data, &type, &size, &format);
-
-      x_reply_selection_request (event, format, data, size, type);
-      successful_p = Qt;
-      /* Tell x_selection_request_lisp_error() it's cool. */      event->type = 0;
-      xfree (data);
-    }
+  {
+    unsigned char *data;
+    unsigned int size;
+    int format;
+    Atom type;
+    lisp_data_to_selection_data (d, converted_selection,
+				 &data, &type, &size, &format);
+    
+    x_reply_selection_request (event, format, data, size, type);
+    successful_p = Qt;
+    /* Tell x_selection_request_lisp_error() it's cool. */
+    event->type = 0;
+    xfree (data);
+  }
+  
   unbind_to (count, Qnil);
 
  DONE_LABEL:
@@ -629,17 +648,15 @@
 
   /* Let random lisp code notice that the selection has been asked for. */
   {
-    Lisp_Object rest;
     Lisp_Object val = Vx_sent_selection_hooks;
     if (!UNBOUNDP (val) && !NILP (val))
       {
+	Lisp_Object rest;
 	if (CONSP (val) && !EQ (XCAR (val), Qlambda))
 	  for (rest = val; !NILP (rest); rest = Fcdr (rest))
-	    call3 (Fcar(rest), selection_symbol, target_symbol,
-		   successful_p);
+	    call3 (Fcar (rest), selection_symbol, target_symbol, successful_p);
 	else
-	  call3 (val, selection_symbol, target_symbol,
-		 successful_p);
+	  call3 (val, selection_symbol, target_symbol, successful_p);
       }
   }
 }
@@ -655,18 +672,18 @@
   Atom selection = event->selection;
   Time changed_owner_time = event->time;
 
-  Lisp_Object selection_symbol, local_selection_data;
+  Lisp_Object selection_symbol, local_selection_time_lisp;
   Time local_selection_time;
 
   selection_symbol = x_atom_to_symbol (d, selection);
 
-  local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
+  local_selection_time_lisp = Fget_selection_timestamp (selection_symbol);
 
-  /* Well, we already believe that we don't own it, so that's just fine. */
-  if (NILP (local_selection_data)) return;
-
-  local_selection_time =
-    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
+  /* We don't own the selection, so that's fine. */
+  if (NILP (local_selection_time_lisp))
+    return;
+  
+  local_selection_time = * (Time *) XOPAQUE_DATA (local_selection_time_lisp);
 
   /* This SelectionClear is for a selection that we no longer own, so we can
      disregard it.  (That is, we have reasserted the selection since this
@@ -920,10 +937,14 @@
   unbind_to (speccount, Qnil);
 
   /* otherwise, the selection is waiting for us on the requested property. */
-  return
-    x_get_window_property_as_lisp_data (display, requestor_window,
-					target_property, target_type,
-					selection_atom);
+
+  return select_convert_in (selection_symbol,
+			    target_type,
+			    x_get_window_property_as_lisp_data(display,
+							       requestor_window,
+							       target_property,
+							       target_type,
+							       selection_atom));
 }
 
 
@@ -1123,6 +1144,9 @@
   return val;
 }
 
+/* #### These are going to move into Lisp code(!) with the aid of
+        some new functions I'm working on - ajh */
+
 /* These functions convert from the selection data read from the server into
    something that we can use from elisp, and vice versa.
 
@@ -1467,7 +1491,8 @@
 }
 
 static Lisp_Object
-x_selection_exists_p (Lisp_Object selection)
+x_selection_exists_p (Lisp_Object selection,
+		      Lisp_Object selection_type)
 {
   struct device *d = decode_x_device (Qnil);
   Display *dpy = DEVICE_X_DISPLAY (d);
@@ -1767,5 +1792,7 @@
   DEVICE_XATOM_NULL          (d) = XInternAtom (D, "NULL",          False);
   DEVICE_XATOM_ATOM_PAIR     (d) = XInternAtom (D, "ATOM_PAIR",     False);
   DEVICE_XATOM_COMPOUND_TEXT (d) = XInternAtom (D, "COMPOUND_TEXT", False);
+
+  /* #### I don't like the looks of this... what is it for? - ajh */
   DEVICE_XATOM_EMACS_TMP     (d) = XInternAtom (D, "_EMACS_TMP_",   False);
 }
--- a/src/select.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/select.c	Mon Aug 13 11:19:21 2007 +0200
@@ -26,6 +26,7 @@
 
 #include "buffer.h"
 #include "device.h"
+#include "extents.h"
 #include "console.h"
 #include "objects.h"
 
@@ -33,28 +34,47 @@
 #include "opaque.h"
 #include "select.h"
 
+/* X Atoms */
 Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
   QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
   QATOM_PAIR, QCOMPOUND_TEXT;
 
+/* Windows clipboard formats */
+Lisp_Object QCF_TEXT, QCF_BITMAP, QCF_METAFILEPICT, QCF_SYLK, QCF_DIF,
+  QCF_TIFF, QCF_OEMTEXT, QCF_DIB, QCF_PALETTE, QCF_PENDATA, QCF_RIFF,
+  QCF_WAVE, QCF_UNICODETEXT, QCF_ENHMETAFILE, QCF_HDROP, QCF_LOCALE,
+  QCF_OWNERDISPLAY, QCF_DSPTEXT, QCF_DSPBITMAP, QCF_DSPMETAFILEPICT,
+  QCF_DSPENHMETAFILE;
+
+/* Selection strategy symbols */
+Lisp_Object Qreplace_all, Qreplace_existing;
+
 /* "Selection owner couldn't convert selection" */
 Lisp_Object Qselection_conversion_error;
 
-/* This is an alist whose CARs are selection-types (whose names are the same
-   as the names of X Atoms) and whose CDRs are the names of Lisp functions to
-   call to convert the given Emacs selection value to a string representing
-   the given selection type.  This is for elisp-level extension of the emacs
-   selection handling.
+/* A couple of Lisp functions */
+Lisp_Object Qselect_convert_in, Qselect_convert_out;
+
+/* These are alists whose CARs are selection-types (whose names are the same
+   as the names of X Atoms or Windows clipboard formats) and whose CDRs are
+   the names of Lisp functions to call to convert the given Emacs selection
+   value to a string representing the given selection type.  This is for
+   elisp-level extension of the emacs selection handling.
  */
-Lisp_Object Vselection_converter_alist;
+Lisp_Object Vselection_converter_out_alist;
+Lisp_Object Vselection_converter_in_alist;
+Lisp_Object Vselection_appender_alist;
+Lisp_Object Vselection_buffer_killed_alist;
+Lisp_Object Vselection_coercible_types;
 
 Lisp_Object Vlost_selection_hooks;
 
 /* This is an association list whose elements are of the form
      ( selection-name selection-value selection-timestamp )
    selection-name is a lisp symbol, whose name is the name of an X Atom.
-   selection-value is the value that emacs owns for that selection.
-     It may be any kind of Lisp object.
+   selection-value is a list of cons pairs that emacs owns for that selection.
+     Each pair consists of (type . value), where type is nil or a
+     selection data type, and value is any type of Lisp object.
    selection-timestamp is the time at which emacs began owning this selection,
      as a cons of two 16-bit numbers (making a 32 bit time).
    If there is an entry in this alist, then it can be assumed that emacs owns
@@ -64,145 +84,68 @@
  */
 Lisp_Object Vselection_alist;
 
+/* Given a selection-name and desired type, this looks up our local copy of
+   the selection value and converts it to the type. */
 static Lisp_Object
-clean_local_selection_data (Lisp_Object obj)
-{
-  if (CONSP (obj) &&
-      INTP (XCAR (obj)) &&
-      CONSP (XCDR (obj)) &&
-      INTP (XCAR (XCDR (obj))) &&
-      NILP (XCDR (XCDR (obj))))
-    obj = Fcons (XCAR (obj), XCDR (obj));
-
-  if (CONSP (obj) &&
-      INTP (XCAR (obj)) &&
-      INTP (XCDR (obj)))
-    {
-      if (XINT (XCAR (obj)) == 0)
-	return XCDR (obj);
-      if (XINT (XCAR (obj)) == -1)
-	return make_int (- XINT (XCDR (obj)));
-    }
-  if (VECTORP (obj))
-    {
-      int i;
-      int len = XVECTOR_LENGTH (obj);
-      Lisp_Object copy;
-      if (len == 1)
-	return clean_local_selection_data (XVECTOR_DATA (obj) [0]);
-      copy = make_vector (len, Qnil);
-      for (i = 0; i < len; i++)
-	XVECTOR_DATA (copy) [i] =
-	  clean_local_selection_data (XVECTOR_DATA (obj) [i]);
-      return copy;
-    }
-  return obj;
-}
-
-/* Given a selection-name and desired type, this looks up our local copy of
-   the selection value and converts it to the type.  It returns nil or a
-   string.  This calls random elisp code, and may signal or gc.
- */
-Lisp_Object
 get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
 {
-  /* This function can GC */
-  Lisp_Object handler_fn, value, check;
   Lisp_Object local_value = assq_no_quit (selection_symbol, Vselection_alist);
 
-  if (NILP (local_value)) return Qnil;
+  if (!NILP (local_value))
+    {
+      Lisp_Object value_list = XCAR (XCDR (local_value));
+      Lisp_Object value;
 
-  /* TIMESTAMP and MULTIPLE are special cases 'cause that's easiest. */
-  if (EQ (target_type, QTIMESTAMP))
-    {
-      handler_fn = Qnil;
-      value = XCAR (XCDR (XCDR (local_value)));
+      /* First try to find an entry of the appropriate type */
+      value = assq_no_quit (target_type, value_list);
+
+      if (!NILP (value))
+	return XCDR (value);
     }
 
-#if 0 /* #### MULTIPLE doesn't work yet and probably never will */
-  else if (CONSP (target_type) &&
-	   XCAR (target_type) == QMULTIPLE)
-    {
-      Lisp_Object pairs = XCDR (target_type);
-      int len = XVECTOR_LENGTH (pairs);
-      int i;
-      /* If the target is MULTIPLE, then target_type looks like
-	  (MULTIPLE . [[SELECTION1 TARGET1] [SELECTION2 TARGET2] ... ])
-	 We modify the second element of each pair in the vector and
-	 return it as [[SELECTION1 <value1>] [SELECTION2 <value2>] ... ]
-       */
-      for (i = 0; i < len; i++)
-	{
-	  Lisp_Object pair = XVECTOR_DATA (pairs) [i];
-	  XVECTOR_DATA (pair) [1] =
-	    x_get_local_selection (XVECTOR_DATA (pair) [0],
-				   XVECTOR_DATA (pair) [1]);
-	}
-      return pairs;
-    }
-#endif
-  else
-    {
-      CHECK_SYMBOL (target_type);
-      handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
-      if (NILP (handler_fn)) return Qnil;
-      value = call3 (handler_fn,
-		     selection_symbol, target_type,
-		     XCAR (XCDR (local_value)));
-    }
-
-  /* This lets the selection function to return (TYPE . VALUE).  For example,
-     when the selected type is LINE_NUMBER, the returned type is SPAN, not
-     INTEGER.
-   */
-  check = value;
-  if (CONSP (value) && SYMBOLP (XCAR (value)))
-    check = XCDR (value);
-
-  /* Strings, vectors, and symbols are converted to selection data format in
-     the obvious way.  Integers are converted to 16 bit quantities if they're
-     small enough, otherwise 32 bits are used.
-   */
-  if (STRINGP (check) ||
-      VECTORP (check) ||
-      SYMBOLP (check) ||
-      INTP    (check) ||
-      CHARP   (check) ||
-      NILP (value))
-    return value;
-
-  /* (N . M) or (N M) get turned into a 32 bit quantity.  So if you want to
-     always return a small quantity as 32 bits, your converter routine needs
-     to return a cons.
-   */
-  else if (CONSP (check) &&
-	   INTP (XCAR (check)) &&
-	   (INTP (XCDR (check)) ||
-	    (CONSP (XCDR (check)) &&
-	     INTP (XCAR (XCDR (check))) &&
-	     NILP (XCDR (XCDR (check))))))
-    return value;
-  /* Otherwise the lisp converter function returned something unrecognized.
-   */
-  else
-    signal_error (Qerror,
-                  list3 (build_string
-			 ("unrecognized selection-conversion type"),
-                         handler_fn,
-                         value));
-
-  return Qnil;	/* suppress compiler warning */
+  return Qnil;
 }
 
-DEFUN ("own-selection-internal", Fown_selection_internal, 2, 3, 0, /*
-Assert a selection of the given TYPE with the given VALUE.
-TYPE is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
+/* #### Should perhaps handle 'MULTIPLE. The code below is now completely
+   broken due to a re-organization of get_local_selection, but I've left
+   it here should anyone show an interest - ajh */
+#if 0
+      else if (CONSP (target_type) &&
+	       XCAR (target_type) == QMULTIPLE)
+	{
+	  Lisp_Object pairs = XCDR (target_type);
+	  int len = XVECTOR_LENGTH (pairs);
+	  int i;
+	  /* If the target is MULTIPLE, then target_type looks like
+	     (MULTIPLE . [[SELECTION1 TARGET1] [SELECTION2 TARGET2] ... ])
+	     We modify the second element of each pair in the vector and
+	     return it as [[SELECTION1 <value1>] [SELECTION2 <value2>] ... ]
+	  */
+	  for (i = 0; i < len; i++)
+	    {
+	      Lisp_Object pair = XVECTOR_DATA (pairs) [i];
+	      XVECTOR_DATA (pair) [1] =
+		x_get_local_selection (XVECTOR_DATA (pair) [0],
+				       XVECTOR_DATA (pair) [1]);
+	    }
+	  return pairs;
+	}
+#endif
+
+DEFUN ("own-selection-internal", Fown_selection_internal, 2, 5, 0, /*
+Assert a selection of the given NAME with the given VALUE, and
+optional window-system DATA-TYPE. HOW-TO-ADD specifies how the
+selection will be combined with any existing selection(s) - see
+`own-selection' for more information.
+NAME is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
 VALUE is typically a string, or a cons of two markers, but may be
-anything that the functions on selection-converter-alist know about.
+anything that the functions on selection-converter-out-alist know about.
 */
-       (selection_name, selection_value, device))
+       (selection_name, selection_value, how_to_add, data_type, device))
 {
-  Lisp_Object selection_time, selection_data, prev_value;
+  Lisp_Object selection_time, selection_data, prev_value = Qnil,
+    value_list = Qnil;
+  Lisp_Object prev_real_value = Qnil;
   struct gcpro gcpro1;
 
   CHECK_SYMBOL (selection_name);
@@ -211,35 +154,129 @@
   if (NILP (device))
     device = Fselected_device (Qnil);
 
-  /* Now update the local cache */
-  selection_data = list3 (selection_name,
-			  selection_value,
-			  Qnil);
-  GCPRO1 (selection_data);
+  if (!EQ (how_to_add, Qappend) && !EQ (how_to_add, Qt)
+      && !EQ (how_to_add, Qreplace_existing)
+      && !EQ (how_to_add, Qreplace_all) && !NILP (how_to_add))
+    error ("how-to-add must be nil, append, replace_all, "
+	   "replace_existing or t.");
+
+#ifdef MULE
+  if (NILP (data_type))
+    data_type = QCOMPOUND_TEXT;
+#else
+  if (NILP (data_type))
+    data_type = QSTRING;
+#endif
+  
+  /* Examine the how-to-add argument */
+  if (EQ (how_to_add, Qreplace_all) || NILP (how_to_add))
+    {
+      Lisp_Object local_selection_data = assq_no_quit (selection_name,
+						       Vselection_alist);
+
+      if (!NILP (local_selection_data))
+	{
+	  /* Don't use Fdelq() as that may QUIT;. */
+	  if (EQ (local_selection_data, Fcar (Vselection_alist)))
+	    Vselection_alist = Fcdr (Vselection_alist);
+	  else
+	    {
+	      Lisp_Object rest;
+	      for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+		if (EQ (local_selection_data, Fcar (XCDR (rest))))
+		  {
+		    XCDR (rest) = Fcdr (XCDR (rest));
+		    break;
+		  }
+	    }
+	}
+    }
+  else
+    {
+      /* Look for a previous value */
+      prev_value = assq_no_quit (selection_name, Vselection_alist);
 
-  prev_value = assq_no_quit (selection_name, Vselection_alist);
-  Vselection_alist = Fcons (selection_data, Vselection_alist);
+      if (!NILP (prev_value))
+	value_list = XCAR (XCDR (prev_value));
+
+      if (!NILP (value_list))
+	prev_real_value = assq_no_quit (data_type, value_list);
+    }
+  
+  /* Append values if necessary */
+  if (!NILP (value_list) && (EQ (how_to_add, Qappend) || EQ (how_to_add, Qt)))
+    {
+      /* Did we have anything of this type previously? */
+      if (!NILP (prev_real_value))
+	{
+	  if ((NILP (data_type) && STRINGP (selection_value)
+	       && STRINGP (XCDR (prev_real_value)))
+	      || !NILP (data_type))
+	    {
+	      Lisp_Object function = assq_no_quit (data_type,
+						   Vselection_appender_alist);
+
+	      if (NILP (function))
+		error ("cannot append selections of supplied types.");
+
+	      function = XCDR (function);
+	      
+	      selection_value = call4 (function,
+				       selection_name,
+				       data_type,
+				       XCDR (prev_real_value),
+				       selection_value);
+
+	      if (NILP (selection_value))
+		error ("cannot append selections of supplied types.");
+	    }
+	  else
+	    error ("cannot append selections of supplied types.");
+	}
+
+      selection_data = Fcons (data_type, selection_value);
+      value_list = Fcons (selection_data, value_list);
+    }
     
-  /* If we already owned the selection, remove the old selection data.
-     Perhaps we should destructively modify it instead.
-     Don't use Fdelq() as that may QUIT;.
-  */
-  if (!NILP (prev_value))
+  if (!NILP (prev_real_value))
     {
-      Lisp_Object rest;	/* we know it's not the CAR, so it's easy. */
-      for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
-	if (EQ (prev_value, Fcar (XCDR (rest))))
+      Lisp_Object rest; /* We know it isn't the CAR, so it's easy. */
+      
+      /* Delete the old type entry from the list */
+      for (rest = value_list; !NILP (rest); rest = Fcdr (rest))
+	if (EQ (prev_real_value, Fcar (XCDR (rest))))
 	  {
 	    XCDR (rest) = Fcdr (XCDR (rest));
 	    break;
-	  }
+	  }     
+    }
+  else
+    {
+      value_list = Fcons (Fcons (data_type, selection_value),
+			  value_list);
     }
+  
+  /* Complete the local cache update; note that we destructively
+     modify the current list entry if there is one */
+  if (NILP (prev_value))
+    {
+      selection_data = list3 (selection_name, value_list, Qnil);
+      Vselection_alist = Fcons (selection_data, Vselection_alist);
+    }
+  else
+    {
+      selection_data = prev_value;
+      Fsetcar (XCDR (selection_data), value_list);
+    }
+  
+  GCPRO1 (selection_data);
 
   /* have to do device specific stuff last so that methods can access the 
      selection_alist */
   if (HAS_DEVMETH_P (XDEVICE (device), own_selection))
     selection_time = DEVMETH (XDEVICE (device), own_selection,
-			      (selection_name, selection_value));
+			      (selection_name, selection_value,
+			       how_to_add, data_type));
   else
     selection_time = Qnil;
 
@@ -250,12 +287,103 @@
   return selection_value;
 }
 
+DEFUN ("register-selection-data-type", Fregister_selection_data_type, 1,2,0, /*
+Register a new selection data type DATA-TYPE, optionally on the specified
+DEVICE. Returns the device-specific data type identifier, or nil if the
+device does not support this feature or the registration fails. */
+       (data_type, device))
+{
+  /* Check arguments */
+  CHECK_STRING (data_type);
+
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+  if (HAS_DEVMETH_P (XDEVICE (device), register_selection_data_type))
+    return DEVMETH (XDEVICE (device), register_selection_data_type,
+		    (data_type));
+  else
+    return Qnil;
+}
+
+DEFUN ("selection-data-type-name", Fselection_data_type_name, 1, 2, 0, /*
+Retrieve the name of the specified selection data type DATA-TYPE, optionally
+on the specified DEVICE. Returns either a string or a symbol on success, and
+nil if the device does not support this feature or the type is not known. */
+       (data_type, device))
+{
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+  if (HAS_DEVMETH_P (XDEVICE (device), selection_data_type_name))
+    return DEVMETH (XDEVICE (device), selection_data_type_name, (data_type));
+  else
+    return Qnil;
+}
+
+DEFUN ("available-selection-types", Favailable_selection_types, 1, 2, 0, /*
+Retrieve a list of currently available types of selection associated with
+the given SELECTION-NAME, optionally on the specified DEVICE. This list
+does not take into account any possible conversions that might take place,
+so it should be taken as a minimal estimate of what is available.
+*/
+       (selection_name, device))
+{
+  Lisp_Object types = Qnil, rest;
+  struct gcpro gcpro1;
+
+  CHECK_SYMBOL (selection_name);
+
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+  GCPRO1 (types);
+
+  /* First check the device */
+  if (HAS_DEVMETH_P (XDEVICE (device), available_selection_types))
+    types = DEVMETH (XDEVICE (device), available_selection_types,
+		     (selection_name));
+
+  /* Now look in the list */
+  rest = assq_no_quit (selection_name, Vselection_alist);
+
+  if (NILP (rest))
+    {
+      UNGCPRO;
+
+      return types;
+    }
+
+  /* Examine the types and cons them onto the front of the list */
+  for (rest = XCAR (XCDR (rest)); !NILP (rest); rest = XCDR (rest))
+    {
+      Lisp_Object value = XCDR (XCAR (rest));
+      Lisp_Object type = XCAR (XCAR (rest));
+
+      types = Fcons (type, types);
+
+      if ((STRINGP (value) || EXTENTP (value))
+	  && (NILP (type) || EQ (type, QSTRING)
+	      || EQ (type, QTEXT) || EQ (type, QCOMPOUND_TEXT)))
+	types = Fcons (QTEXT, Fcons (QCOMPOUND_TEXT, Fcons (QSTRING, types)));
+      else if (INTP (value) && NILP (type))
+	types = Fcons (QINTEGER, types);
+      else if (SYMBOLP (value) && NILP (type))
+	types = Fcons (QATOM, types);
+    }
+  
+  UNGCPRO;
+
+  return types;
+}
+       
 /* remove a selection from our local copy
  */
 void
 handle_selection_clear (Lisp_Object selection_symbol)
 {
-  Lisp_Object local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
+  Lisp_Object local_selection_data = assq_no_quit (selection_symbol,
+						   Vselection_alist);
 
   /* Well, we already believe that we don't own it, so that's just fine. */
   if (NILP (local_selection_data)) return;
@@ -326,26 +454,44 @@
   return NILP (Fassq (selection, Vselection_alist)) ? Qnil : Qt;
 }
 
-DEFUN ("selection-exists-p", Fselection_exists_p, 0, 2, 0, /*
+DEFUN ("selection-exists-p", Fselection_exists_p, 0, 3, 0, /*
 Whether there is an owner for the given Selection.
 The arg should be the name of the selection in question, typically one of
 the symbols PRIMARY, SECONDARY, or CLIPBOARD.  (For convenience, the symbol
 nil is the same as PRIMARY, and t is the same as SECONDARY.)
+Optionally the DEVICE and the window-system DATA-TYPE may be specified.
 */
-       (selection, device))
+       (selection, data_type, device))
 {
   CHECK_SYMBOL (selection);
-  if (!NILP (Fselection_owner_p (selection)))
+  if (NILP (data_type)
+      && !NILP (Fselection_owner_p (selection)))
     return Qt;
 
   if (NILP (device))
     device = Fselected_device (Qnil);
 
   return HAS_DEVMETH_P (XDEVICE (device), selection_exists_p) ?
-    DEVMETH (XDEVICE (device), selection_exists_p, (selection))
+    DEVMETH (XDEVICE (device), selection_exists_p, (selection, data_type))
     : Qnil;
 }
 
+/* Get the timestamp of the given selection */
+DEFUN ("get-selection-timestamp", Fget_selection_timestamp, 1, 1, 0, /*
+Return the timestamp associated with the specified SELECTION, if it exists.
+Note that the timestamp is a device-specific object, and may not actually be
+visible from Lisp.
+*/
+       (selection))
+{
+  Lisp_Object local_value = assq_no_quit (selection, Vselection_alist);
+
+  if (!NILP (local_value))
+    return XCAR (XCDR (XCDR (local_value)));
+
+  return Qnil;
+}
+
 /* Request the selection value from the owner.  If we are the owner,
    simply return our selection value.  If we are not the owner, this
    will block until all of the data has arrived.
@@ -360,14 +506,22 @@
        (selection_symbol, target_type, device))
 {
   /* This function can GC */
-  Lisp_Object val = Qnil;
-  struct gcpro gcpro1, gcpro2;
-  GCPRO2 (target_type, val); /* we store newly consed data into these */
+  Lisp_Object val = Qnil, element = Qnil;
+  struct gcpro gcpro1, gcpro2, gcpro3;
+  GCPRO3 (target_type, val, element);
   CHECK_SYMBOL (selection_symbol);
 
   if (NILP (device))
     device = Fselected_device (Qnil);
 
+#ifdef MULE
+  if (NILP (target_type))
+    target_type = QCOMPOUND_TEXT;
+#else
+  if (NILP (target_type))
+    target_type = QSTRING;
+#endif
+  
 #if 0 /* #### MULTIPLE doesn't work yet and probably never will */
   if (CONSP (target_type) &&
       XCAR (target_type) == QMULTIPLE)
@@ -376,9 +530,12 @@
       /* So we don't destructively modify this... */
       target_type = copy_multiple_data (target_type);
     }
-  else
 #endif
-    CHECK_SYMBOL (target_type);
+
+  /* Used to check that target_type was a symbol. This is no longer
+     necessarily the case, because the type might be registered with
+     the device (in which case target_type would be a device-specific
+     identifier - probably an integer) - ajh */
 
   val = get_local_selection (selection_symbol, target_type);
 
@@ -387,29 +544,205 @@
       val = DEVMETH (XDEVICE (device), get_foreign_selection,
 		     (selection_symbol, target_type));
     }
-  else
+
+  if (NILP (val))
     {
-      if (CONSP (val) && SYMBOLP (XCAR (val)))
+      /* Still nothing. Try coercion. */
+      
+      /* Try looking in selection-coercible-types to see if any of
+	 them are present for this selection. We try them *in order*;
+	 the first for which a conversion succeeds gets returned. */
+      EXTERNAL_LIST_LOOP_2 (element, Vselection_coercible_types)
 	{
-	  val = XCDR (val);
-	  if (CONSP (val) && NILP (XCDR (val)))
-	    val = XCAR (val);
+	  val = get_local_selection (selection_symbol, element);
+
+	  if (NILP (val))
+	    continue;
+
+	  /* #### Probably should have a Qselection_coercion_alist and a
+	          select-coerce function. */
+	  val = call3 (Qselect_convert_out,
+		       selection_symbol, target_type, val);
+
+	  if (!NILP (val))
+	    break;
 	}
-      val = clean_local_selection_data (val);
     }
+
+  if (NILP (val))
+    {
+      UNGCPRO;
+      
+      return Qnil;
+    }
+  
+  /* Used to call clean_local_selection here... but that really belonged
+     in Lisp (so the equivalent is now built-in to the INTEGER conversion
+     function select-convert-from-integer) - ajh */
+  
   UNGCPRO;
   return val;
 }
 
+/* These two are convenient interfaces to the lisp code in select.el;
+   this way we can rename them easily rather than having to hunt everywhere.
+   Also, this gives us access to get_local_selection so that convert_out
+   can retrieve the internal selection value automatically if passed a
+   value of Qnil. */
+Lisp_Object
+select_convert_in (Lisp_Object selection,
+		   Lisp_Object type,
+		   Lisp_Object value)
+{
+  return call3 (Qselect_convert_in, selection, type, value);
+}
+
+Lisp_Object
+select_convert_out (Lisp_Object selection,
+		    Lisp_Object type,
+		    Lisp_Object value)
+{
+  if (NILP (value))
+    value = get_local_selection (selection, type);
+
+  if (NILP (value))
+    {
+      Lisp_Object element = Qnil, ret;
+      struct gcpro gcpro1;
+      GCPRO1 (element);
+
+      {
+	/* Try looking in selection-coercible-types to see if any of
+	 them are present for this selection. We try them *in order*;
+	 the first for which a conversion succeeds gets returned. */
+	EXTERNAL_LIST_LOOP_2 (element, Vselection_coercible_types)
+	  {
+	    value = get_local_selection (selection, element);
+
+	    if (NILP (value))
+	      continue;
+	  
+	    ret = call3 (Qselect_convert_out, selection, type, value);
+
+	    if (!NILP (ret))
+	      {
+		UNGCPRO;
+	      
+		return ret;
+	      }
+	  }
+      }
+      
+      UNGCPRO;
+      
+      return Qnil;
+    }
+
+  return call3 (Qselect_convert_out, selection, type, value);
+}
+		     
+
+/* Gets called from kill-buffer; this lets us dispose of buffer-dependent
+   selections (or alternatively make them independent of the buffer) when
+   it gets vaped. */
+void
+select_notify_buffer_kill (Lisp_Object buffer)
+{
+  Lisp_Object rest;
+  struct gcpro gcpro1, gcpro2, gcpro3;
+  
+  /* For each element of Vselection_alist */
+  for (rest = Vselection_alist;
+       !NILP (rest);)
+    {
+      Lisp_Object selection, values, prev = Qnil;
+
+      selection = XCAR (rest);
+      
+      for (values = XCAR (XCDR (selection));
+	   !NILP (values);
+	   values = XCDR (values))
+	{
+	  Lisp_Object value, handler_fn;
+
+	  /* Extract the (type . value) pair. */
+	  value = XCAR (values);
+
+	  /* Find the handler function (if any). */
+	  handler_fn = Fcdr (Fassq (XCAR (value),
+				    Vselection_buffer_killed_alist));
+
+	  if (!NILP (handler_fn))
+	    {
+	      Lisp_Object newval;
+
+	      /* Protect ourselves, just in case some tomfool calls
+		 own-selection from with the buffer-killed handler, then
+		 causes a GC. Just as a note, *don't do this*. */
+	      GCPRO3 (rest, values, value);
+	      
+	      newval = call4 (handler_fn, XCAR (selection), XCAR (value),
+			      XCDR (value), buffer);
+
+	      UNGCPRO;
+	      
+	      /* Set or delete the value (by destructively modifying
+		 the list). */
+	      if (!NILP (newval))
+		{
+		  Fsetcdr (value, newval);
+		  
+		  prev = values;
+		}
+	      else
+		{
+		  if (NILP (prev))
+		    Fsetcar (XCDR (selection), XCDR (values));
+		  else
+		    Fsetcdr (prev, XCDR (values));
+		}
+	    }
+	  else
+	    prev = values;
+	}
+
+      /* If we have no values for this selection */
+      if (NILP (XCAR (XCDR (selection))))
+	{
+	  /* Move on to the next element *first* */
+	  rest = XCDR (rest);
+
+	  /* Protect it and disown this selection */
+	  GCPRO1 (rest);
+
+	  Fdisown_selection_internal (XCAR (selection), Qnil, Qnil);
+
+	  UNGCPRO;
+	}
+      else
+	rest = XCDR (rest);
+    }
+}
+
+
 void
 syms_of_select (void)
 {
   DEFSUBR (Fown_selection_internal);
   DEFSUBR (Fget_selection_internal);
   DEFSUBR (Fselection_exists_p);
+  DEFSUBR (Fget_selection_timestamp);
   DEFSUBR (Fdisown_selection_internal);
   DEFSUBR (Fselection_owner_p);
+  DEFSUBR (Favailable_selection_types);
+  DEFSUBR (Fregister_selection_data_type);
+  DEFSUBR (Fselection_data_type_name);
+  
+  /* Lisp Functions */
+  defsymbol (&Qselect_convert_in, "select-convert-in");
+  defsymbol (&Qselect_convert_out, "select-convert-out");
 
+  /* X Atoms */
   defsymbol (&QPRIMARY, "PRIMARY");
   defsymbol (&QSECONDARY, "SECONDARY");
   defsymbol (&QSTRING, "STRING");
@@ -427,6 +760,33 @@
   defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT");
   defsymbol (&QNULL, "NULL");
 
+  /* Windows formats - these all start with CF_ */
+  defsymbol (&QCF_TEXT, "CF_TEXT");
+  defsymbol (&QCF_BITMAP, "CF_BITMAP");
+  defsymbol (&QCF_METAFILEPICT, "CF_METAFILEPICT");
+  defsymbol (&QCF_SYLK, "CF_SYLK");
+  defsymbol (&QCF_DIF, "CF_DIF");
+  defsymbol (&QCF_TIFF, "CF_TIFF");
+  defsymbol (&QCF_OEMTEXT, "CF_OEMTEXT");
+  defsymbol (&QCF_DIB, "CF_DIB");
+  defsymbol (&QCF_PALETTE, "CF_PALETTE");
+  defsymbol (&QCF_PENDATA, "CF_PENDATA");
+  defsymbol (&QCF_RIFF, "CF_RIFF");
+  defsymbol (&QCF_WAVE, "CF_WAVE");
+  defsymbol (&QCF_UNICODETEXT, "CF_UNICODETEXT");
+  defsymbol (&QCF_ENHMETAFILE, "CF_ENHMETAFILE");
+  defsymbol (&QCF_HDROP, "CF_HDROP");
+  defsymbol (&QCF_LOCALE, "CF_LOCALE");
+  defsymbol (&QCF_OWNERDISPLAY, "CF_OWNERDISPLAY");
+  defsymbol (&QCF_DSPTEXT, "CF_DSPTEXT");
+  defsymbol (&QCF_DSPBITMAP, "CF_DSPBITMAP");
+  defsymbol (&QCF_DSPMETAFILEPICT, "CF_DSPMETAFILEPICT");
+  defsymbol (&QCF_DSPENHMETAFILE, "CF_DSPENHMETAFILE");
+
+  /* Selection strategies */
+  defsymbol (&Qreplace_all, "replace-all");
+  defsymbol (&Qreplace_existing, "replace-existing");
+  
   deferror (&Qselection_conversion_error,
 	    "selection-conversion-error",
 	    "selection-conversion error", Qio_error);
@@ -438,14 +798,26 @@
   Vselection_alist = Qnil;
   staticpro (&Vselection_alist);
 
-  DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_alist /*
+  DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_out_alist /*
+An alist associating selection-types (such as STRING and TIMESTAMP) with
+functions.  This is an alias for `selection-converter-out-alist', and should
+be considered obsolete.  Use the new name instead. */ );
+									      
+  DEFVAR_LISP ("selection-converter-out-alist",
+	       &Vselection_converter_out_alist /*
 An alist associating selection-types (such as STRING and TIMESTAMP) with
 functions.  These functions will be called with three args: the name
 of the selection (typically PRIMARY, SECONDARY, or CLIPBOARD); a
 desired type to which the selection should be converted; and the local
-selection value (whatever had been passed to `own-selection').  For
-historical reasons these functions should return the value to send to
-an X server, which should be one of:
+selection value (whatever had been passed to `own-selection').
+
+The return type of these functions depends upon the device in question;
+for mswindows, a string should be returned containing data in the requested
+format, or nil to indicate that the conversion could not be done.  Additionally,
+it is permissible to return a cons of the form (DATA-TYPE . STRING) suggesting
+a new data type to use instead.
+
+For X, the return value should be one of:
 
 -- nil (the conversion could not be done)
 -- a cons of a symbol and any of the following values; the symbol
@@ -479,9 +851,50 @@
 -- a vector of integers and/or conses (HIGH . LOW) of integers
                         (Will be converted into a list of 16-bit integers.
                          If the type is not specified, a type of 'INTEGER
-			 will be sent.)  */ );
-  Vselection_converter_alist = Qnil;
+			 will be sent.)
+*/ );
+  Vselection_converter_out_alist = Qnil;
+
+  DEFVAR_LISP ("selection-converter-in-alist",
+	       &Vselection_converter_in_alist /*
+An alist associating selection-types (such as STRING and TIMESTAMP) with
+functions.  These functions will be called with three args: the name
+of the selection (typically PRIMARY, SECONDARY or CLIPBOARD); the
+type from which the selection should be converted; and the selection
+value.  These functions should return a suitable representation of the
+value, or nil to indicate that the conversion was not possible.
+
+See also `selection-converter-out-alist'. */ );
+  Vselection_converter_in_alist = Qnil;
 
+  DEFVAR_LISP ("selection-appender-alist",
+	       &Vselection_appender_alist /*
+An alist associating selection-types (such as STRING and TIMESTAMP) with
+functions.  These functions will be called with four args; the name
+of the selection (typically PRIMARY, SECONDARY or CLIPBOARD); the type
+of the selection; and two selection values.  The functions are expected to
+return a value representing the catenation of the two values, or nil to
+indicate that this was not possible. */ );
+  Vselection_appender_alist = Qnil;
+  
+  DEFVAR_LISP ("selection-buffer-killed-alist",
+	       &Vselection_buffer_killed_alist /*
+An alist associating selection-types (such as STRING and TIMESTAMP) with
+functions.  These functions will be called whenever a buffer is killed,
+with four args: the name of the selection (typically PRIMARY, SECONDARY
+or CLIPBOARD); the type of the selection; the value of the selection; and
+the buffer that has just been killed.  These functions should return a new
+selection value, or nil to indicate that the selection value should be
+deleted. */ );
+  Vselection_buffer_killed_alist = Qnil;
+
+  DEFVAR_LISP ("selection-coercible-types",
+	       &Vselection_coercible_types /*
+A list of selection types that are coercible---that is, types that may be
+automatically converted to another type. Selection values with types in this
+list may be subject to conversion attempts to other types. */ );
+  Vselection_coercible_types = Qnil;
+  
   DEFVAR_LISP ("lost-selection-hooks", &Vlost_selection_hooks /*
 A function or functions to be called after we have been notified
 that we have lost the selection.  The function(s) will be called with one
@@ -490,4 +903,3 @@
 */ );
   Vlost_selection_hooks = Qunbound;
 }
-
--- a/src/select.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/select.h	Mon Aug 13 11:19:21 2007 +0200
@@ -23,28 +23,43 @@
 #ifndef INCLUDED_select_h_
 #define INCLUDED_select_h_
 
-extern Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
-  QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
-  QATOM_PAIR, QCOMPOUND_TEXT;
+/* X Atoms */
+extern Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD,
+  QTIMESTAMP, QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM,
+  QNULL, QATOM_PAIR, QCOMPOUND_TEXT;
 
-/* This is an association list whose elements are of the form
-     ( selection-name selection-value selection-timestamp )
-   selection-name is a lisp symbol, whose name is the name of an X Atom.
-   selection-value is the value that emacs owns for that selection.
-     It may be any kind of Lisp object.
-   selection-timestamp is the time at which emacs began owning this selection,
-     as a cons of two 16-bit numbers (making a 32 bit time).
-   If there is an entry in this alist, then it can be assumed that emacs owns
-    that selection.
-   The only (eq) parts of this list that are visible from elisp are the
-    selection-values.
- */
-extern Lisp_Object Vselection_alist;
+/* Windows clipboard formats */
+extern Lisp_Object QCF_TEXT, QCF_BITMAP, QCF_METAFILEPICT, QCF_SYLK, QCF_DIF,
+  QCF_TIFF, QCF_OEMTEXT, QCF_DIB, QCF_PALETTE, QCF_PENDATA, QCF_RIFF,
+  QCF_WAVE, QCF_UNICODETEXT, QCF_ENHMETAFILE, QCF_HDROP, QCF_LOCALE,
+  QCF_OWNERDISPLAY, QCF_DSPTEXT, QCF_DSPBITMAP, QCF_DSPMETAFILEPICT,
+  QCF_DSPENHMETAFILE;
+
+/* Selection strategies */
+extern Lisp_Object Qreplace_all, Qreplace_existing, Qappend;
 
 /* "Selection owner couldn't convert selection" */
 extern Lisp_Object Qselection_conversion_error;
 
-Lisp_Object get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type);
+/* Selection input & output */
+Lisp_Object select_convert_in (Lisp_Object selection,
+			       Lisp_Object type,
+			       Lisp_Object value);
+Lisp_Object select_convert_out (Lisp_Object selection,
+				Lisp_Object type,
+				Lisp_Object value);
+
+/* Notifications */
 void handle_selection_clear (Lisp_Object selection_symbol);
 
+void select_notify_buffer_kill (Lisp_Object buffer);
+
+/* Lisp functions we export for other files' use */
+EXFUN (Fregister_selection_data_type, 2);
+EXFUN (Fselection_data_type_name, 2);
+EXFUN (Favailable_selection_types, 2);
+EXFUN (Fselection_owner_p, 1);
+EXFUN (Fselection_exists_p, 3);
+EXFUN (Fget_selection_timestamp, 1);
+
 #endif /* INCLUDED_select_h_ */
--- a/src/sheap.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sheap.c	Mon Aug 13 11:19:21 2007 +0200
@@ -19,8 +19,8 @@
 02111-1307, USA.*/
 
 #include <config.h>
-#include <stdio.h>
 #include "lisp.h"
+
 #include <unistd.h>
 #include <sheap-adjust.h>
 
@@ -40,6 +40,7 @@
 int 	static_heap_initialized=0;
 int 	static_heap_dumped=0;
 
+void* more_static_core ( ptrdiff_t increment );
 void* more_static_core ( ptrdiff_t increment )
 {
   int size = (int) increment;
@@ -58,7 +59,7 @@
       static_heap_ptr=static_heap_base;
       static_heap_size=STATIC_HEAP_SIZE -
 	(static_heap_base-static_heap_buffer);
-#ifdef __CYGWIN32__
+#ifdef CYGWIN
       sbrk(BLOCKSIZE);		/* force space for fork to work */
 #endif
       static_heap_initialized=1;
@@ -119,6 +120,7 @@
   fclose (stream);
 }
 
+void report_sheap_usage (int die_if_pure_storage_exceeded);
 void
 report_sheap_usage (int die_if_pure_storage_exceeded)
 {
--- a/src/signal.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/signal.c	Mon Aug 13 11:19:21 2007 +0200
@@ -31,10 +31,7 @@
 #include "syssignal.h"
 #include "systime.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
+#include "sysfile.h"
 
 /* Set to 1 when a quit-check signal (either a SIGIO interrupt or
    the asynch. timeout for poll-for-quit) occurs.  The QUITP
@@ -180,7 +177,7 @@
 	 it needs to stay the way it is. */
       quit_check_signal_happened = 1;
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
       can_break_system_calls = 0;
 #else
       /* can_break_system_calls is set when we want to break out of
--- a/src/sound.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sound.c	Mon Aug 13 11:19:21 2007 +0200
@@ -37,12 +37,10 @@
 #include "redisplay.h"
 #include "sysdep.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include "sysfile.h"
 
 #ifdef HAVE_NATIVE_SOUND
-# include <netdb.h>
+# include "sysproc.h"
 # include "nativesound.h"
 #endif
 
@@ -279,7 +277,7 @@
   /* variable `sound' is anything that can be a cdr in sound-alist */
   Lisp_Object new_volume, pitch, duration, data;
   int loop_count = 0;
-  int vol, pit, dur, succes;
+  int vol, pit, dur;
   struct device *d = decode_device (device);
 
   /* NOTE!  You'd better not signal an error in here. */
@@ -335,6 +333,7 @@
     {
       Extbyte *soundext;
       Extcount soundextlen;
+      int succes;
 
       TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen),
 			  Qbinary);
@@ -355,6 +354,7 @@
     {
       const Extbyte *soundext;
       Extcount soundextlen;
+      int succes;
 
       TO_EXTERNAL_FORMAT (LISP_STRING, sound,
 			  ALLOCA, (soundext, soundextlen),
--- a/src/specifier.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/specifier.c	Mon Aug 13 11:19:21 2007 +0200
@@ -41,7 +41,7 @@
 #include "rangetab.h"
 
 Lisp_Object Qspecifierp;
-Lisp_Object Qprepend, Qappend, Qremove_tag_set_prepend, Qremove_tag_set_append;
+Lisp_Object Qprepend, Qremove_tag_set_prepend, Qremove_tag_set_append;
 Lisp_Object Qremove_locale, Qremove_locale_type, Qremove_all;
 Lisp_Object Qfallback;
 
@@ -3229,7 +3229,6 @@
   /* locales are defined in general.c. */
 
   defsymbol (&Qprepend, "prepend");
-  defsymbol (&Qappend, "append");
   defsymbol (&Qremove_tag_set_prepend, "remove-tag-set-prepend");
   defsymbol (&Qremove_tag_set_append, "remove-tag-set-append");
   defsymbol (&Qremove_locale, "remove-locale");
--- a/src/strftime.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/strftime.c	Mon Aug 13 11:19:21 2007 +0200
@@ -94,13 +94,13 @@
 time_t mktime ();
 #endif
 
-#if defined(WINDOWSNT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
 #include <time.h>
 #else
 #if defined(HAVE_TZNAME)
 extern char *tzname[2];
 #endif
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #ifdef emacs
 #define strftime emacs_strftime
@@ -233,6 +233,7 @@
 }
 
 #if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)
+char *zone_name (const struct tm *tp);
 char *
 zone_name (const struct tm *tp)
 {
--- a/src/symsinit.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/symsinit.h	Mon Aug 13 11:19:21 2007 +0200
@@ -339,6 +339,7 @@
 void vars_of_mule_charset (void);
 void vars_of_file_coding (void);
 void vars_of_mule_wnn (void);
+void reinit_vars_of_mule_wnn (void);
 void vars_of_nt (void);
 void vars_of_ntproc (void);
 void vars_of_objects (void);
@@ -433,7 +434,6 @@
 void init_callproc (void);
 void init_console_stream (int reinit);
 void init_device_tty (void);
-void init_dosfns (void);
 void init_editfns (void);
 void init_environment (void);
 void init_event_Xt_late (void);
--- a/src/syscommctrl.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/syscommctrl.h	Mon Aug 13 11:19:21 2007 +0200
@@ -28,7 +28,11 @@
 #ifndef INCLUDED_syscommctrl_h_
 #define INCLUDED_syscommctrl_h_
 
+#if !defined (CYGWIN_VERSION_DLL_MAJOR) || CYGWIN_VERSION_DLL_MAJOR > 20
+/* Appears to be missing in Cygwin b20.1; requisite includes are in
+   Windows32/Messages.h and get included automatically with windows.h */
 #include <commctrl.h>
+#endif
 
 #ifndef TB_SETIMAGELIST
 #define TB_SETIMAGELIST (WM_USER + 48)
--- a/src/sysdep.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysdep.c	Mon Aug 13 11:19:21 2007 +0200
@@ -31,9 +31,8 @@
 
 #include <config.h>
 
-#ifdef WINDOWSNT
-#include <direct.h>
-#ifdef __MINGW32__
+#ifdef WIN32_NATIVE
+#ifdef MINGW
 #include <mingw32/process.h>
 #else
 /* <process.h> should not conflict with "process.h", as per ANSI definition.
@@ -45,13 +44,11 @@
    which will conflict with the macro defined in lisp.h
 */
 #include <../include/process.h>
-#endif /* __MINGW32__ */
-#endif /* WINDOWSNT */
+#endif /* MINGW */
+#endif /* WIN32_NATIVE */
 
 #include "lisp.h"
 
-#include <stdlib.h>
-
 /* ------------------------------- */
 /*          basic includes         */
 /* ------------------------------- */
@@ -81,16 +78,20 @@
 #include "syswait.h"
 #include "sysdir.h"
 #include "systime.h"
-#if defined(WINDOWSNT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
 #include "syssignal.h"
 #endif
-#ifndef WINDOWSNT
+
+#include "sysproc.h"
+
+#ifndef WIN32_NATIVE
 #include <sys/times.h>
 #endif
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <sys/utime.h>
 #include "ntheap.h"
+#include "nt.h"
 #endif
 
 /* ------------------------------- */
@@ -233,7 +234,7 @@
 #endif /* NO_SUBPROCESSES */
 
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 void wait_for_termination (HANDLE pHandle)
 #else
 void wait_for_termination (int pid)
@@ -347,7 +348,7 @@
 
      Since implementations may add their own error indicators on top,
      we ignore it by default.  */
-#elif defined (WINDOWSNT)
+#elif defined (WIN32_NATIVE)
   int ret = 0, status = 0;
   if (pHandle == NULL)
     {
@@ -421,7 +422,7 @@
 	   Try defining BROKEN_WAIT_FOR_SIGNAL. */
 	EMACS_WAIT_FOR_SIGNAL (SIGCHLD);
     }
-#else /* not HAVE_WAITPID and not WINDOWSNT and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
+#else /* not HAVE_WAITPID and not WIN32_NATIVE and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
   /* This approach is kind of cheesy but is guaranteed(?!) to work
      for all systems. */
   while (1)
@@ -459,7 +460,7 @@
 #endif
 }
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 /*  Set up the terminal at the other end of a pseudo-terminal that
     we will be controlling an inferior through.
     It should not echo or do line-editing, since that is done
@@ -570,7 +571,7 @@
   }
 #endif /* RTU */
 }
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #endif /* not NO_SUBPROCESSES */
 
@@ -611,7 +612,7 @@
     }
 }
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 
 pid_t
 sys_getpid (void)
@@ -619,13 +620,13 @@
   return abs (getpid ());
 }
 
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 /* Fork a subshell.  */
 static void
 sys_subshell (void)
 {
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   int pid;
 #endif
   struct save_signal saved_handlers[5];
@@ -665,13 +666,13 @@
   str[len] = 0;
  xyzzy:
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
   pid = fork ();
 
   if (pid == -1)
     error ("Can't spawn subshell");
   if (pid == 0)
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
   {
       char *sh = 0;
 
@@ -684,7 +685,7 @@
     if (str)
       sys_chdir (str);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 
     /* Waits for process completion */
     if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0)
@@ -714,7 +715,7 @@
   wait_for_termination (pid);
   restore_signal_handlers (saved_handlers);
 
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 
 }
 
@@ -961,7 +962,7 @@
   assert (DEVICE_TTY_P (d));
   {
     int input_fd = CONSOLE_TTY_DATA (con)->infd;
-#if defined (WINDOWSNT)
+#if defined (WIN32_NATIVE)
     DEVICE_TTY_DATA (d)->ospeed = 15;
 #elif defined (HAVE_TERMIOS)
     struct termios sg;
@@ -1387,7 +1388,7 @@
 /* It's wrong to encase these into #ifdef HAVE_TTY because we need
    them for child TTY processes.  */
 /* However, this does break NT support while we don't do child TTY processes */
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 
 /* Set *TC to the parameters associated with the terminal FD.
    Return zero if all's well, or -1 if we ran into an error we
@@ -1406,7 +1407,7 @@
   if (ioctl (fd, TCGETA, &settings->main) < 0)
     return -1;
 
-#elif !defined (WINDOWSNT)
+#elif !defined (WIN32_NATIVE)
   /* I give up - I hope you have the BSD ioctls.  */
   if (ioctl (fd, TIOCGETP, &settings->main) < 0)
     return -1;
@@ -1480,7 +1481,7 @@
   if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0)
     return -1;
 
-#elif !defined (WINDOWSNT)
+#elif !defined (WIN32_NATIVE)
   /* I give up - I hope you have the BSD ioctls.  */
   if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
     return -1;
@@ -1503,7 +1504,7 @@
   return 0;
 }
 
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 /* ------------------------------------------------------ */
 /*                 Initializing a device                  */
@@ -1663,14 +1664,14 @@
   tty.main.c_iflag &= ~BRKINT;
 #endif /* AIX */
 #else /* if not HAVE_TERMIO */
-#if !defined (WINDOWSNT)
+#if !defined (WIN32_NATIVE)
   con->tty_erase_char = make_char (tty.main.sg_erase);
   tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
   if (TTY_FLAGS (con).meta_key)
     tty.main.sg_flags |= ANYP;
   /* #### should we be using RAW mode here? */
   tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK;
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
 #endif /* not HAVE_TERMIO */
 
   /* If going to use CBREAK mode, we must request C-g to interrupt
@@ -2153,24 +2154,15 @@
 
 #if !defined(HAVE_TEXT_START) && !defined(PDUMP)
 
-#ifdef __cplusplus
-  extern "C" int _start (void);
-#else
-  extern int _start (void);
-#endif
+EXTERN_C int _start (void);
 
 char *
 start_of_text (void)
 {
 #ifdef TEXT_START
-  return ((char *) TEXT_START);
+  return (char *) TEXT_START;
 #else
-#ifdef GOULD
-  extern csrt ();
-  return ((char *) csrt);
-#else /* not GOULD */
-  return ((char *) _start);
-#endif /* GOULD */
+  return (char *) _start;
 #endif /* TEXT_START */
 }
 #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */
@@ -2201,7 +2193,7 @@
  *
  */
 
-#if defined(ORDINARY_LINK) && !defined(__MINGW32__)
+#if defined(ORDINARY_LINK) && !defined(MINGW)
 extern char **environ;
 #endif
 
@@ -2279,15 +2271,10 @@
 
 extern Lisp_Object Vsystem_name;
 
-#ifdef HAVE_SOCKETS
-# include <sys/socket.h>
-# include <netdb.h>
-#endif /* HAVE_SOCKETS */
-
 void
 init_system_name (void)
 {
-#if defined (WINDOWSNT)
+#if defined (WIN32_NATIVE)
   char hostname [MAX_COMPUTERNAME_LENGTH + 1];
   size_t size = sizeof (hostname);
   GetComputerName (hostname, &size);
@@ -2525,7 +2512,7 @@
 
 #endif /* ! HAVE_STRERROR */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 
 struct errentry {
   unsigned long oscode;  /* Win32 error */
@@ -2622,7 +2609,7 @@
   mswindows_set_errno (GetLastError ());
 }
 
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 
 /************************************************************************/
@@ -2665,7 +2652,7 @@
 
   PATHNAME_CONVERT_OUT (path);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Make all handles non-inheritable */
   oflag |= _O_NOINHERIT;
 #endif
@@ -2705,7 +2692,7 @@
 
   PATHNAME_CONVERT_OUT (nonreloc);
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Make all handles non-inheritable */
   oflag |= _O_NOINHERIT;
 #endif
@@ -2819,7 +2806,7 @@
 sys_fopen (const char *path, const char *type)
 {
   PATHNAME_CONVERT_OUT (path);
-#if defined (WINDOWSNT)
+#if defined (WIN32_NATIVE)
   {
     int fd;
     int oflag;
@@ -2972,7 +2959,7 @@
 sys_mkdir (const char *path, mode_t mode)
 {
   PATHNAME_CONVERT_OUT (path);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   return mkdir (path);
 #else
   return mkdir (path, mode);
@@ -3120,26 +3107,31 @@
 }
 #endif /* ENCAPSULATE_READLINK */
 
-
 #ifdef ENCAPSULATE_FSTAT
 int
 sys_fstat (int fd, struct stat *buf)
 {
+#ifdef WIN32_NATIVE
+  return mswindows_fstat (fd, buf);
+#else
   return fstat (fd, buf);
+#endif
 }
 #endif /* ENCAPSULATE_FSTAT */
 
-
 #ifdef ENCAPSULATE_STAT
 int
 sys_stat (const char *path, struct stat *buf)
 {
   PATHNAME_CONVERT_OUT (path);
+#ifdef WIN32_NATIVE
+  return mswindows_stat (path, buf);
+#else
   return stat (path, buf);
+#endif
 }
 #endif /* ENCAPSULATE_STAT */
 
-
 /****************** file-manipulation calls *****************/
 
 #ifdef ENCAPSULATE_CHMOD
@@ -3179,14 +3171,14 @@
 {
   PATHNAME_CONVERT_OUT (old);
   PATHNAME_CONVERT_OUT (new);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
   /* Windows rename fails if NEW exists */
   if (rename (old, new) == 0)
     return 0;
   if (errno != EEXIST)
     return -1;
   unlink (new);
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
   return rename (old, new);
 }
 #endif /* ENCAPSULATE_RENAME */
@@ -3401,7 +3393,7 @@
 static int
 get_process_times_1 (long *user_ticks, long *system_ticks)
 {
-#if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WINDOWSNT)
+#if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WIN32_NATIVE)
   /* We have the POSIX times() function available. */
   struct tms tttt;
   times (&tttt);
@@ -3543,7 +3535,7 @@
 
 #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST)
 
-#if defined(WINDOWSNT) || defined(__CYGWIN32__)
+#if defined(WIN32_NATIVE) || defined(CYGWIN)
 const char *sys_siglist[] =
   {
     "bum signal!!",
--- a/src/sysdep.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysdep.h	Mon Aug 13 11:19:21 2007 +0200
@@ -25,7 +25,7 @@
 
 #include <setjmp.h>
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 extern char **environ;
 #endif
 
@@ -50,10 +50,7 @@
 
 /* Wait for subprocess with process id `pid' to terminate and
    make sure it will get eliminated (not remain forever as a zombie) */
-#ifdef WINDOWSNT
-#include <windows.h>
-void wait_for_termination (HANDLE pid);
-#else
+#ifndef WIN32_NATIVE
 void wait_for_termination (int pid);
 #endif
 
@@ -168,11 +165,6 @@
 const char *strerror (int);
 #endif
 
-#ifdef WINDOWSNT
-void mswindows_set_errno (unsigned long win32_error);
-void mswindows_set_last_errno (void);
-#endif
-
 int interruptible_open (const char *path, int oflag, int mode);
 
 #ifndef HAVE_H_ERRNO
--- a/src/sysdir.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysdir.h	Mon Aug 13 11:19:21 2007 +0200
@@ -29,10 +29,11 @@
 
 #ifdef SYSV_SYSTEM_DIR
 # include <dirent.h>
+#elif defined (WIN32_NATIVE)
+# include <direct.h>
+# include "ndir.h"
 #elif defined (NONSYSTEM_DIR_LIBRARY)
 # include "ndir.h"
-#elif defined (MSDOS)
-# include <dirent.h>
 #else
 # include <sys/dir.h>
 #endif /* not NONSYSTEM_DIR_LIBRARY */
@@ -58,11 +59,7 @@
    Since applying strlen to the name always works, we'll just do that.  */
 #define NAMLEN(p) strlen (p->d_name)
 
-#ifdef MSDOS
-#define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
-#else
 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
-#endif
 
 /* encapsulation: directory calls */
 
--- a/src/sysdll.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysdll.c	Mon Aug 13 11:19:21 2007 +0200
@@ -216,7 +216,12 @@
 {
   return dld_get_symbol(n);
 }
-#elif defined(_WINDOWS) || defined(WIN32)
+#elif defined (WIN32_NATIVE)
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
 int
 dll_init (const char *arg)
 {
--- a/src/sysdll.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysdll.h	Mon Aug 13 11:19:21 2007 +0200
@@ -26,9 +26,9 @@
 extern "C" {
 #endif
 
-#if defined(WIN32)
+#if defined(WIN32_NATIVE)
 #define DLLEXPORT __declspec(dllexport)
-#elif defined(_WINDOWS)
+#elif defined(WIN16)
 #define DLLEXPORT FAR PASCAL _EXPORT
 #else
 #define DLLEXPORT
--- a/src/sysfile.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysfile.h	Mon Aug 13 11:19:21 2007 +0200
@@ -24,9 +24,8 @@
 #define INCLUDED_sysfile_h_
 
 #include <errno.h>
-#include <limits.h>
 
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #include <sys/errno.h>          /* <errno.h> does not always imply this */
 #endif
 
@@ -44,17 +43,24 @@
 #ifndef makedev
 #include <sys/types.h>		/* some typedefs are used in sys/file.h */
 #endif
+
+#ifndef WIN32_NATIVE
 #include <sys/file.h>
+#endif
+
 #include <sys/stat.h>
+
+#ifndef WIN32_NATIVE
 #include <sys/param.h>
+#endif
 
-#if defined (NeXT) || defined(__CYGWIN32__)
+#if defined (NeXT) || defined(CYGWIN)
 /* what is needed from here?  Do others need it too?
  O_BINARY is in here under cygwin. */
 # include <sys/fcntl.h>
 #endif /* NeXT */
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #include <io.h>
 #include <direct.h>
 #endif
@@ -95,7 +101,7 @@
 #endif
 
 #ifndef CREAT_MODE
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define CREAT_MODE	(S_IREAD | S_IWRITE)
 #else
 #define CREAT_MODE	(0666)
@@ -118,6 +124,30 @@
 #endif
 #endif
 
+#ifndef READ_PLUS_TEXT
+#ifdef O_TEXT
+#define READ_PLUS_TEXT "r+t"
+#else
+#define READ_PLUS_TEXT "r+"
+#endif
+#endif
+
+#ifndef READ_PLUS_BINARY
+#ifdef O_BINARY
+#define READ_PLUS_BINARY "r+b"
+#else
+#define READ_PLUS_BINARY "r+"
+#endif
+#endif
+
+#ifndef WRITE_TEXT
+#ifdef O_TEXT
+#define WRITE_TEXT "wt"
+#else
+#define WRITE_TEXT "w"
+#endif
+#endif
+
 #ifndef WRITE_BINARY
 #ifdef O_BINARY
 #define WRITE_BINARY "wb"
@@ -223,8 +253,21 @@
 # define MAXPATHLEN 1024
 #endif
 
+/* The following definitions are needed under Windows, at least */
 #ifndef X_OK
-# define X_OK 01
+# define X_OK 1
+#endif
+
+#ifndef R_OK
+# define R_OK 4
+#endif
+
+#ifndef W_OK
+# define W_OK 2
+#endif
+
+#ifndef F_OK
+# define F_OK 0
 #endif
 
 #ifndef FD_CLOEXEC
--- a/src/sysfloat.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysfloat.h	Mon Aug 13 11:19:21 2007 +0200
@@ -37,8 +37,7 @@
 #  define _NMAXLDBL THIS_FILENAME ## _nmaxldbl
 # endif
 
-#if defined(MSDOS) || (defined(LINUX) && \
-		       !(defined (__GLIBC__) && (__GLIBC__ >= 2)))
+#if defined(LINUX) && !(defined (__GLIBC__) && (__GLIBC__ >= 2))
 /* These are redefined (correctly, but differently) in values.h.  */
 #undef INTBITS
 #undef LONGBITS
@@ -47,7 +46,7 @@
 
 #include <math.h>
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 /* A quirky way to obtain logb prototype */
 #include <float.h>
 #define logb _logb
--- a/src/sysproc.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/sysproc.h	Mon Aug 13 11:19:21 2007 +0200
@@ -29,7 +29,7 @@
 
 #include "systime.h" /* necessary for sys/resource.h; also gets the
 			FD_* defines on some systems. */
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
 #include <sys/resource.h>
 #endif
 
@@ -37,17 +37,61 @@
 
 #ifdef HAVE_SOCKETS	/* TCP connection support, if kernel can do it */
 # include <sys/types.h>  /* AJK */
-# include <sys/socket.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-#ifdef NEED_NET_ERRNO_H
-#include <net/errno.h>
-#endif /* NEED_NET_ERRNO_H */
+# ifndef WIN32_NATIVE
+#  include <sys/socket.h>
+#  include <netdb.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+# endif
+# ifdef NEED_NET_ERRNO_H
+#  include <net/errno.h>
+# endif /* NEED_NET_ERRNO_H */
 #elif defined (SKTPAIR)
 # include <sys/socket.h>
 #endif /* HAVE_SOCKETS */
 
+#ifdef WIN32_NATIVE
+/* Note: winsock.h already included in systime.h above */
+/* map winsock error codes to standard names */
+#define EWOULDBLOCK             WSAEWOULDBLOCK
+#define EINPROGRESS             WSAEINPROGRESS
+#define EALREADY                WSAEALREADY
+#define ENOTSOCK                WSAENOTSOCK
+#define EDESTADDRREQ            WSAEDESTADDRREQ
+#define EMSGSIZE                WSAEMSGSIZE
+#define EPROTOTYPE              WSAEPROTOTYPE
+#define ENOPROTOOPT             WSAENOPROTOOPT
+#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#define EOPNOTSUPP              WSAEOPNOTSUPP
+#define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#define EADDRINUSE              WSAEADDRINUSE
+#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#define ENETDOWN                WSAENETDOWN
+#define ENETUNREACH             WSAENETUNREACH
+#define ENETRESET               WSAENETRESET
+#define ECONNABORTED            WSAECONNABORTED
+#define ECONNRESET              WSAECONNRESET
+#define ENOBUFS                 WSAENOBUFS
+#define EISCONN                 WSAEISCONN
+#define ENOTCONN                WSAENOTCONN
+#define ESHUTDOWN               WSAESHUTDOWN
+#define ETOOMANYREFS            WSAETOOMANYREFS
+#define ETIMEDOUT               WSAETIMEDOUT
+#define ECONNREFUSED            WSAECONNREFUSED
+#define ELOOP                   WSAELOOP
+/* #define ENAMETOOLONG            WSAENAMETOOLONG */
+#define EHOSTDOWN               WSAEHOSTDOWN
+#define EHOSTUNREACH            WSAEHOSTUNREACH
+/* #define ENOTEMPTY               WSAENOTEMPTY */
+#define EPROCLIM                WSAEPROCLIM
+#define EUSERS                  WSAEUSERS
+#define EDQUOT                  WSAEDQUOT
+#define ESTALE                  WSAESTALE
+#define EREMOTE                 WSAEREMOTE
+#endif /* WIN32_NATIVE */
+
 /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
 #ifdef HAVE_BROKEN_INET_ADDR
 # define IN_ADDR struct in_addr
@@ -101,10 +145,4 @@
 
 int poll_fds_for_input (SELECT_TYPE mask);
 
-#ifdef MSDOS
-/* #include <process.h> */
-/* Damn that local process.h!  Instead we can define P_WAIT ourselves.  */
-#define P_WAIT 1
-#endif
-
 #endif /* INCLUDED_sysproc_h_ */
--- a/src/syspwd.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/syspwd.h	Mon Aug 13 11:19:21 2007 +0200
@@ -19,5 +19,21 @@
 
 /* Synched up with: Not really in FSF. */
 
-#include <pwd.h>
+#ifndef WIN32_NATIVE
+
+# include <pwd.h>
+
+#else /* WIN32_NATIVE */
 
+struct passwd {
+    char *pw_name;
+    char *pw_passwd;
+    int   pw_uid;
+    int   pw_gid;
+    int   pw_quota;
+    char *pw_gecos;
+    char *pw_dir;
+    char *pw_shell;
+};
+
+#endif /* WIN32_NATIVE */
--- a/src/syssignal.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/syssignal.h	Mon Aug 13 11:19:21 2007 +0200
@@ -212,7 +212,7 @@
 #ifdef BSD
 #define EMACS_KILLPG(gid, signo) killpg (gid, signo)
 #else
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 #define EMACS_KILLPG(gid, signo) kill (gid, signo)
 #else
 #define EMACS_KILLPG(gid, signo) kill (-(gid), signo)
@@ -234,14 +234,14 @@
 SIGTYPE memory_warning_signal (int sig);
 #endif
 
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
 /* Prototypes for signal functions, see nt.c */
-typedef void (__cdecl *msw_sighandler) (int);
-msw_sighandler msw_sigset (int sig, msw_sighandler handler);
-int msw_sighold (int nsig);
-int msw_sigrelse (int nsig);
-int msw_sigpause (int nsig);
-int msw_raise (int nsig);
-#endif /* _WIN32 */
+typedef void (__cdecl *mswindows_sighandler) (int);
+mswindows_sighandler mswindows_sigset (int sig, mswindows_sighandler handler);
+int mswindows_sighold (int nsig);
+int mswindows_sigrelse (int nsig);
+int mswindows_sigpause (int nsig);
+int mswindows_raise (int nsig);
+#endif /* WIN32_NATIVE */
 
 #endif /* INCLUDED_syssignal_h_ */
--- a/src/systime.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/systime.h	Mon Aug 13 11:19:21 2007 +0200
@@ -24,14 +24,14 @@
 #define INCLUDED_systime_h_
 
 #ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
+# include <sys/time.h>
+# include <time.h>
 #else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
 #endif
 
 /* select() is supposed to be (Unix98) defined in sys/time.h,
@@ -41,17 +41,33 @@
 #include <unistd.h>
 #endif
 
-#if defined(WINDOWSNT) && defined(HAVE_X_WINDOWS)
+#ifdef WIN32_NATIVE
+
+/* This defines struct timeval */
+#include <winsock.h>
+
+struct timezone 
+  {
+    int	tz_minuteswest;	/* minutes west of Greenwich */
+    int	tz_dsttime;	/* type of dst correction */
+  };
+
+#ifdef HAVE_X_WINDOWS
 /* Provides gettimeofday etc */
 #include <X11/Xw32defs.h>
 #include <X11/Xos.h>
-#endif
+#else
+/* X11R6 on NT provides the single parameter version of this command */
+void gettimeofday (struct timeval *, struct timezone *);
+#endif /* HAVE_X_WINDOWS */
+
+#endif /* WIN32_NATIVE */
 
 #ifdef HAVE_UTIME_H
 # include <utime.h>
 #endif
 
-#if defined(HAVE_TZNAME) && !defined(WINDOWSNT) && !defined(__CYGWIN32__)
+#if defined(HAVE_TZNAME) && !defined(WIN32_NATIVE) && !defined(CYGWIN)
 #ifndef tzname		/* For SGI.  */
 extern char *tzname[];	/* RS6000 and others want it this way.  */
 #endif
@@ -217,7 +233,7 @@
 void get_process_times (double *user_time, double *system_time,
 			double *real_time);
 
-#if defined(WINDOWSNT) || defined(BROKEN_CYGWIN) || defined(__MINGW32__)
+#if defined(WIN32_NATIVE) || defined(BROKEN_CYGWIN)
 
 /* setitimer emulation for Win32 (see nt.c) */
 
@@ -233,6 +249,6 @@
 #define ITIMER_REAL 1
 #define ITIMER_PROF 2
 
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
 
 #endif /* INCLUDED_systime_h_ */
--- a/src/systty.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/systty.h	Mon Aug 13 11:19:21 2007 +0200
@@ -94,9 +94,9 @@
 #  include <fcntl.h>
 # endif
 
-#elif defined (DOS_NT)
+#elif defined (WIN32_NATIVE)
 
-/*****             (3) The MSDOS/NT way              *****/
+/*****             (3) The WIN32_NATIVE way              *****/
 
 /* Nothing doing */
 
@@ -124,7 +124,7 @@
 /* Generally useful to include this file: */
 
 /* But Sun OS has broken include files and doesn't want it included */
-#if !defined (DOS_NT) && !defined (WIN32) && !defined (SUNOS4)
+#if !defined (WIN32_NATIVE) && !defined (SUNOS4)
 # include <sys/ioctl.h>
 #endif
 /* UNIPLUS systems may have FIONREAD.  */
@@ -333,7 +333,7 @@
    No big loss -- it just means that ^Z won't work right
    if we're run from sh. */
 #  define EMACS_SET_PROCESS_GROUP(pg)
-#elif defined(__MINGW32__)
+#elif defined(MINGW)
 #  define EMACS_SEPARATE_PROCESS_GROUP()
 #else
 /* Under NeXTstep, a process group of 0 is not the same as specifying
@@ -384,11 +384,11 @@
 #ifdef HAVE_TERMIO
   struct termio main;
 #else /* !HAVE_TERMIO */
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
   int main;
-#else  /* not DOS_NT */
+#else  /* not WIN32_NATIVE */
   struct sgttyb main;
-#endif /* not DOS_NT */
+#endif /* not WIN32_NATIVE */
 #endif /* !HAVE_TERMIO */
 #endif /* !HAVE_TCATTR */
 
@@ -428,11 +428,11 @@
 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
 
 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
-#ifdef DOS_NT
+#ifdef WIN32_NATIVE
 #define EMACS_TTY_TABS_OK(p) 0
-#else /* not DOS_NT */
+#else /* not WIN32_NATIVE */
 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
-#endif /* not DOS_NT */
+#endif /* not WIN32_NATIVE */
 
 #endif /* not def HAVE_TERMIO */
 #endif /* not def HAVE_TERMIOS */
--- a/src/syswindows.h	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/syswindows.h	Mon Aug 13 11:19:21 2007 +0200
@@ -29,9 +29,35 @@
 #ifndef INCLUDED_syswindows_h_
 #define INCLUDED_syswindows_h_
 
+/* Note that there are currently FOUR different general
+   Windows-related include files in src!
+
+   Uses are approximately:
+
+   syswindows.h: Mostly a wrapper around <windows.h>, including missing
+   defines as necessary.  Also includes stuff needed on both Cygwin and
+   native Windows, regardless of window system chosen.
+
+   console-msw.h: Used on both Cygwin and native Windows, but only when
+   native window system (as opposed to X) chosen.
+
+   nt.h: [will be renamed to win32.h] Used only on native Windows, and
+   regardless of window system chosen -- but used on both purely native
+   Windows (s/windowsnt.h) and MinGW (s/mingw32.h).
+
+   ntheap.h: Used only on native Windows and only when standard dumping
+   mechanism (unexnt.c) used.
+
+   All of the last three files include the first.
+*/
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
 #include <windows.h>
 
-#if (defined (__CYGWIN32__) || defined(__MINGW32__)) && \
+#if (defined (CYGWIN) || defined(MINGW)) && \
 	CYGWIN_VERSION_DLL_MAJOR < 21
 extern BOOL WINAPI DdeFreeStringHandle(DWORD,HSZ);
 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
@@ -74,7 +100,7 @@
 #endif
 
 /* windows.h defines. */
-#if defined (__CYGWIN32__) && (CYGWIN_VERSION_DLL_MAJOR < 20)
+#if defined (CYGWIN) && (CYGWIN_VERSION_DLL_MAJOR < 20)
 typedef NMHDR *LPNMHDR;
 #endif
 
--- a/src/unexalpha.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/unexalpha.c	Mon Aug 13 11:19:21 2007 +0200
@@ -55,8 +55,6 @@
 	if (lseek (_fd, _position, L_SET) != _position) \
 	  fatal_unexec (_error_message, _error_arg);
 
-void *sbrk();
-
 #define EEOF -1
 
 static struct scnhdr *text_section;
@@ -83,12 +81,13 @@
 };
 
 
-
 /* Define name of label for entry point for the dumped executable.  */
 
 #ifndef DEFAULT_ENTRY_ADDRESS
 #define DEFAULT_ENTRY_ADDRESS __start
 #endif
+EXTERN_C int DEFAULT_ENTRY_ADDRESS (void);
+
 
 int
 unexec (char *new_name, char *a_name,
@@ -208,7 +207,6 @@
   nhdr.aout.bsize = 0;
   if (entry_address == 0)
     {
-      extern int DEFAULT_ENTRY_ADDRESS (void);
       nhdr.aout.entry = (unsigned long)DEFAULT_ENTRY_ADDRESS;
     }
   else
--- a/src/unexcw.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/unexcw.c	Mon Aug 13 11:19:21 2007 +0200
@@ -82,6 +82,9 @@
   exit(-1); \
 }
 
+void
+unexec (char *out_name, char *in_name, void *start_data, 
+	void * d1, void * d2);
 /* 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)
--- a/src/unexec.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/unexec.c	Mon Aug 13 11:19:21 2007 +0200
@@ -209,33 +209,7 @@
 int need_coff_header = 1;
 #include <coff-encap/a.out.encap.h> /* The location might be a poor assumption */
 #else
-#ifdef MSDOS
-#if __DJGPP__ > 1
-#include <fcntl.h>  /* for O_RDONLY, O_RDWR */
-#endif
-#include <coff.h>
-#define filehdr external_filehdr
-#define scnhdr external_scnhdr
-#define syment external_syment
-#define auxent external_auxent
-#define n_numaux e_numaux
-#define n_type e_type
-struct aouthdr
-{
-  unsigned short	magic;	/* type of file				*/
-  unsigned short	vstamp;	/* version stamp			*/
-  unsigned long		tsize;	/* text size in bytes, padded to FW bdry*/
-  unsigned long		dsize;	/* initialized data "  "		*/
-  unsigned long		bsize;	/* uninitialized data "   "		*/
-  unsigned long		entry;	/* entry pt.				*/
-  unsigned long	 	text_start;/* base of text used for this file */
-  unsigned long	 	data_start;/* base of data used for this file */
-};
-
-
-#else /* not MSDOS */
 #include <a.out.h>
-#endif /* not MSDOS */
 #endif /* not COFF_ENCAPSULATE */
 
 /* Define getpagesize if the system does not.
@@ -911,14 +885,6 @@
 
 #else /* COFF, but not USG_SHARED_LIBRARIES */
 
-#ifdef MSDOS
-#if __DJGPP__ >= 2
-  /* Dump the original table of exception handlers, not the one
-     where our exception hooks are registered.  */
-  __djgpp_exception_toggle ();
-#endif
-#endif
-
   lseek (new, (long) text_scnptr, 0);
   ptr = (char *) f_ohdr.text_start;
 #ifdef HEADER_INCL_IN_TEXT
@@ -933,13 +899,6 @@
   end = ptr + f_ohdr.dsize;
   write_segment (new, ptr, end);
 
-#ifdef MSDOS
-#if __DJGPP__ >= 2
-  /* Restore our exception hooks.  */
-  __djgpp_exception_toggle ();
-#endif
-#endif
-
 #endif /* USG_SHARED_LIBRARIES */
 
 #else /* if not COFF */
@@ -1221,11 +1180,7 @@
   if (!lnnoptr || !f_hdr.f_symptr)
     return 0;
 
-#ifdef MSDOS
-  if ((new = writedesc) < 0)
-#else
   if ((new = open (new_name, O_RDWR)) < 0)
-#endif
     {
       PERROR (new_name);
       return -1;
@@ -1247,9 +1202,7 @@
 	    }
 	}
     }
-#ifndef MSDOS
   close (new);
-#endif
   return 0;
 }
 
--- a/src/unexnt.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/unexnt.c	Mon Aug 13 11:19:21 2007 +0200
@@ -103,13 +103,6 @@
 PUCHAR bss_start = UNINIT_PTR;
 DWORD  bss_size = UNINIT_LONG;
 
-#ifdef HAVE_NTGUI
-HINSTANCE hinst = NULL;
-HINSTANCE hprevinst = NULL;
-LPSTR lpCmdLine = "";
-int nCmdShow = 0;
-#endif /* HAVE_NTGUI */
-
 /* Startup code for running on NT.  When we are running as the dumped
    version, we need to bootstrap our heap and .bss section into our
    address space before we can actually hand off control to the startup
@@ -163,7 +156,7 @@
      hit and fix all the weirdities this causes us, the better --kkm */
 #if 0
   /* The default behavior is to treat files as binary and patch up
-     text files appropriately, in accordance with the MSDOS code.  */
+     text files appropriately.  */
   _fmode = O_BINARY;
 #endif
 
@@ -173,14 +166,6 @@
   SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);
 #endif
 
-  /* Invoke the NT CRT startup routine now that our housecleaning
-     is finished.  */
-#ifdef HAVE_NTGUI
-  /* determine WinMain args like crt0.c does */
-  hinst = GetModuleHandle(NULL);
-  lpCmdLine = GetCommandLine();
-  nCmdShow = SW_SHOWDEFAULT;
-#endif
   mainCRTStartup ();
 }
 
--- a/src/vm-limit.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/vm-limit.c	Mon Aug 13 11:19:21 2007 +0200
@@ -57,6 +57,7 @@
   POINTER cp;
   unsigned long five_percent;
   unsigned long data_size;
+  void (*save_warn_fun) (const char *);
 
   if (lim_data == 0)
     get_lim_data ();
@@ -67,36 +68,43 @@
   data_size = (char *) cp - (char *) data_space_start;
 
   if (warn_function)
-    switch (warnlevel)
-      {
-      case 0:
-	if (data_size > five_percent * 15)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 75% of memory limit");
-	  }
-	break;
+    {
+      /* temporarily reset the warn_function to 0 or we will get infinite
+	 looping. */
+      save_warn_fun = warn_function;
+      warn_function = 0;
+      switch (warnlevel)
+	{
+	case 0:
+	  if (data_size > five_percent * 15)
+	    {
+	      warnlevel++;
+	      (*warn_function) ("Warning: past 75% of memory limit");
+	    }
+	  break;
 
-      case 1:
-	if (data_size > five_percent * 17)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 85% of memory limit");
-	  }
-	break;
+	case 1:
+	  if (data_size > five_percent * 17)
+	    {
+	      warnlevel++;
+	      (*warn_function) ("Warning: past 85% of memory limit");
+	    }
+	  break;
 
-      case 2:
-	if (data_size > five_percent * 19)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 95% of memory limit");
-	  }
-	break;
+	case 2:
+	  if (data_size > five_percent * 19)
+	    {
+	      warnlevel++;
+	      (*warn_function) ("Warning: past 95% of memory limit");
+	    }
+	  break;
 
-      default:
-	(*warn_function) ("Warning: past acceptable memory limits");
-	break;
-      }
+	default:
+	  (*warn_function) ("Warning: past acceptable memory limits");
+	  break;
+	}
+      warn_function = save_warn_fun;
+    }
 
   /* If we go down below 70% full, issue another 75% warning
      when we go up again.  */
--- a/src/window.c	Mon Aug 13 11:18:12 2007 +0200
+++ b/src/window.c	Mon Aug 13 11:19:21 2007 +0200
@@ -282,7 +282,7 @@
   p->glyph_cachels    = Dynarr_new (glyph_cachel);
   p->line_start_cache = Dynarr_new (line_start_cache);
   p->subwindow_instance_cache = make_lisp_hash_table (30,
-						      HASH_TABLE_KEY_WEAK,
+						      HASH_TABLE_KEY_VALUE_WEAK,
 						      HASH_TABLE_EQUAL);
   p->line_cache_last_updated = Qzero;
   INIT_DISP_VARIABLE (last_point_x, 0);
@@ -3519,7 +3519,7 @@
   p->glyph_cachels    = Dynarr_new (glyph_cachel);
   p->subwindow_instance_cache = 
     make_lisp_hash_table (30,
-			  HASH_TABLE_KEY_WEAK,
+			  HASH_TABLE_KEY_VALUE_WEAK,
 			  HASH_TABLE_EQUAL);
 
   /* Put new into window structure in place of window */
@@ -5369,7 +5369,7 @@
 	     it up as needed. */
 	  w->subwindow_instance_cache =
 	    make_lisp_hash_table (30,
-				  HASH_TABLE_KEY_WEAK,
+				  HASH_TABLE_KEY_VALUE_WEAK,
 				  HASH_TABLE_EQUAL);
 	  SET_LAST_MODIFIED (w, 1);
 	  SET_LAST_FACECHANGE (w);
--- a/tests/ChangeLog	Mon Aug 13 11:18:12 2007 +0200
+++ b/tests/ChangeLog	Mon Aug 13 11:19:21 2007 +0200
@@ -1,3 +1,11 @@
+2000-07-19  Martin Buchholz <martin@xemacs.org>
+
+	* XEmacs 21.2.35 is released.
+
+2000-06-17  Martin Buchholz  <martin@xemacs.org>
+
+	* automated/database-tests.el: Remove any previous .pag, .dir files.
+
 2000-05-28  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.34 is released.
--- a/tests/automated/database-tests.el	Mon Aug 13 11:18:12 2007 +0200
+++ b/tests/automated/database-tests.el	Mon Aug 13 11:19:21 2007 +0200
@@ -37,7 +37,10 @@
      (require 'test-harness))))
 
 (flet ((delete-database-files (filename)
-	(dolist (fn (list filename (concat filename ".db")))
+	(dolist (fn (list filename
+			  (concat filename ".db")
+			  (concat filename ".pag")
+			  (concat filename ".dir")))
 	  (ignore-file-errors (delete-file fn))))
 
        (test-database (db)
--- a/version.sh	Mon Aug 13 11:18:12 2007 +0200
+++ b/version.sh	Mon Aug 13 11:19:21 2007 +0200
@@ -2,8 +2,8 @@
 emacs_is_beta=t
 emacs_major_version=21
 emacs_minor_version=2
-emacs_beta_version=34
-xemacs_codename="Molpe"
+emacs_beta_version=35
+xemacs_codename="Nike"
 infodock_major_version=4
 infodock_minor_version=0
 infodock_build_version=8