changeset 414:da8ed4261e83 r21-2-15

Import from CVS: tag r21-2-15
author cvs
date Mon, 13 Aug 2007 11:21:38 +0200
parents 901169e5ca31
children a27f76b40c83
files CHANGES-beta ChangeLog README.packages configure configure.in configure.usage etc/NEWS info/dir lib-src/ChangeLog lib-src/Makefile.in.in lib-src/config.values.in lisp/ChangeLog lisp/auto-autoloads.el lisp/code-files.el lisp/dumped-lisp.el lisp/font-menu.el lisp/info.el lisp/ldap.el lisp/loadup.el lisp/make-docfile.el lisp/mouse.el lisp/msw-faces.el lisp/msw-font-menu.el lisp/msw-select.el lisp/mule/mule-charset.el lisp/mule/mule-cmds.el lisp/mule/mule-files.el lisp/select.el lisp/startup.el lisp/subr.el lisp/update-elc.el lisp/version.el lisp/x-font-menu.el lisp/x-mouse.el lisp/x-select.el lwlib/ChangeLog lwlib/xlwmenu.c man/ChangeLog man/Makefile man/custom.texi man/external-widget.texi man/internals/internals.texi man/lispref/text.texi man/xemacs/cmdargs.texi nt/ChangeLog nt/xemacs.mak src/ChangeLog src/Makefile.in.in src/alloc.c src/bytecode.c src/chartab.c src/config.h.in src/console.h src/device-msw.c src/device-x.c src/emacs.c src/file-coding.c src/fns.c src/frame-x.c src/frame.c src/indent.c src/m/alpha.h src/mule-canna.c src/mule-ccl.c src/mule-charset.c src/ntproc.c src/print.c src/s/decosf4-0.h src/select-msw.c src/select-x.c src/select.c src/select.h src/sheap.c src/symsinit.h src/sysdep.c src/toolbar-msw.c src/window.c src/xselect.c tests/ChangeLog tests/automated/base64-tests.el tests/automated/lisp-tests.el version.sh
diffstat 82 files changed, 6402 insertions(+), 4394 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES-beta	Mon Aug 13 11:20:44 2007 +0200
+++ b/CHANGES-beta	Mon Aug 13 11:21:38 2007 +0200
@@ -1,6 +1,49 @@
 							-*- indented-text -*-
-to 21.2.14 ""
+to 21.2.15 "Sakuragawa"
+-- new self tests from Oscar Figueiredo and Hrvoje Niksic
+-- Miscellaneous bug fixes from Yoshiki Hayashi, Jerry James, Hirokazu FUKUI,
+   Hrvoje Niksic, MORIOKA Tomohiko
+-- LDAP internationalization from Oscar Figueiredo
+-- DEC OSF build fixes from Steve Baur
+-- Documentation fixes from Mike McEwan, Vin Shelton and Gunnar Evermann
+-- Build fixes from Jan Vroonhof
+-- Miscellaneous fixes from Hrvoje Niksic
+-- Documentation updates from Hrvoje Niksic and Albert Chin-A-Young
+-- mule-charset.el synch with Mule from Steve Baur
+-- miscellaneous build and cosmetic fixes from Steve Baur
+-- font-menu for mswindows from Andy Piper
+-- select rationalisation for window systems from Andy Piper
+-- reinstate sheap adjustment + mingw32 fixes from Andy Piper
+
+to 21.2.14 "Dionysos"
 -- mingw32 port from Andy Piper
+-- fix for Solaris build lossage from Hrvoje Niksic
+-- THAI/Cyrillic-KOI8, Vietnamese, Ethiopic support from MORIOKA Tomohiko
+-- miscellaneous bug fixes from Gunnar Evermann
+-- Internal purespace cleanup from Olivier Galibert
+-- documentation updates from Hrvoje Niksic
+-- dump time tuning from Hrvoje Niksic
+-- miscellaneous bug fixes from Giacomo Boffi
+-- font hacking from Jan Vroonhof
+-- Czech language support from David Sauer
+-- `delete-key-deletes-forward' now defaults to t
+-- `locate-file' update from Hrvoje Niksic
+-- MS Windows build fixes from Adrian Aichner
+-- LDAP updates from Oscar Figueiredo
+-- miscellaneous bug fixes from Colin Rafferty and Kai Haberzettl
+-- disable display of images in buffers by file format
+-- miscellaneous Mule fixes from Olivier Galibert
+-- documentation updates from Albert Chin-A-Young
+-- documentation updates from Gunnar Evermann and Stephen Turnbull
+-- MS Windows build fix from Norbert Koch
+-- miscellaneous MS Windows fixes from Andy Piper
+-- redisplay bug fixes from Jan Vroonhof
+-- miscellaneous bug fixes from Robert Pluim, MORIOKA Tomohiko
+-- many, many bug fixes and enhancements from Hrvoje Niksic and Olivier
+   Galibert
+-- miscellaneous bug fixes from Martin Buchholz
+-- Miscellaneous MS Windows fixes from Philip Aston
+-- lots of new tests from Hrvoje Niksic
 
 to 21.2.13 "Demeter"
 -- Build fixes from Martin Buchholz
--- a/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,44 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-06-01  Gunnar Evermann  <ge204@eng.cam.ac.uk>
+
+	* README.packages: fix typos: user pacakge hierarchy is ~/.xemacs
+	From: Eric Veldhuyzen <eric@terra.nu>
+
+1999-05-25  Jan Vroonhof  <jan@xemacs.org>
+
+	* configure.in: For non-beta's use x.y.z format for version strings.
+
+1999-06-03  SL Baur  <steve@xemacs.org>
+
+	* version.sh: add emacs_is_beta initialization
+
+	* configure.in: Implement patch levels in version number
+	From Jan Vroonhof <vroonhof@math.ethz.ch>
+
+	* configure.in:
+	* configure.usage:
+	* config.h.in: Rename session option to wmcommand.
+	From Oliver Graf <ograf@rhein-zeitung.de>
+
+1999-05-16  Mike McEwan  <mike@lotusland.demon.co.uk>
+
+	* info/dir: Add `emodules.info' entry to the top info dir.
+
+1999-05-31  SL Baur  <steve@steve1.m17n.org>
+
+	* configure.in (CPP): Don't check for include subdirectories in
+	site-prefix directories.  This check loses in valid configurations 
+	like /usr/jp in TurboLinux.  Conditionally add include directory to
+	site switches.
+
+1999-05-14  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* configure.in (quoted_arguments): Support
+ 	--error-checking=byte-code.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/README.packages	Mon Aug 13 11:20:44 2007 +0200
+++ b/README.packages	Mon Aug 13 11:21:38 2007 +0200
@@ -213,10 +213,10 @@
 ------------------------
 
 In addition to the system wide packages, each user can have his own
-packages installed in "./xemacs" (Note that this will most likely
-change to "./xemacs/packages" in the near future). If you want to
+packages installed in "~/.xemacs" (Note that this will most likely
+change to "~/.xemacs/packages" in the near future). If you want to
 install packages there using the interactive tools, you need to set
-'pui-package-install-dest-dir' to "/xemacs"
+'pui-package-install-dest-dir' to "~/xemacs"
 
 Site lisp/Site start
 --------------------
--- a/configure	Mon Aug 13 11:20:44 2007 +0200
+++ b/configure	Mon Aug 13 11:21:38 2007 +0200
@@ -2,7 +2,7 @@
 
 #### Configuration script for XEmacs.  Largely divergent from FSF.
 #### Guess values for system-dependent variables and create Makefiles.
-#### Generated automatically using autoconf version 2.12 
+#### Generated automatically using autoconf version 2.13 
 #### Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #### Copyright (C) 1993-1995 Board of Trustees, University of Illinois.
 #### Copyright (C) 1996, 1997 Sun Microsystems, Inc.
@@ -199,6 +199,8 @@
 ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
 cross_compiling=no
 
+ac_exeext=
+ac_objext=o
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -323,7 +325,7 @@
 	with_jpeg	| \
 	with_png	| \
 	with_tiff	| \
-	with_session	| \
+	with_wmcommand	| \
 	with_xmu	| \
 	with_purify	| \
 	with_quantify	| \
@@ -501,14 +503,17 @@
 	      malloc )	      error_check_malloc=yes ;;
 	      nomalloc )      error_check_malloc=no ;;
 
+	      byte_code )     error_check_byte_code=yes ;;
+	      nobyte_code )   error_check_byte_code=no ;;
+
 	      * ) bogus_error_check=yes ;;
 	    esac
 	    if test "$bogus_error_check" -o \
 	         \( -n "$new_default" -a -n "$echeck_notfirst" \) ; then
 		if test "$error_check_default" = yes ; then
-		  types="\`all' (default), \`none', \`noextents', \`notypecheck', \`nobufpos', \`nogc', and \`nomalloc'."
+		  types="\`all' (default), \`none', \`noextents', \`notypecheck', \`nobufpos', \`nogc', \`nomalloc', and \`nobyte-code'."
 		else
-		  types="\`all', \`none' (default), \`extents', \`typecheck', \`bufpos', \`gc', and \`malloc'."
+		  types="\`all', \`none' (default), \`extents', \`typecheck', \`bufpos', \`gc', \`malloc', and \`byte-code'."
 		fi
 		(echo "$progname: Usage error:"
 echo " " "Valid types for the \`--$optname' option are:
@@ -520,6 +525,7 @@
 		error_check_bufpos=$new_default
 		error_check_gc=$new_default
 		error_check_malloc=$new_default
+		error_check_byte_code=$new_default
 		new_default=	# reset this
 	    fi
 	    echeck_notfirst=true
@@ -763,7 +769,7 @@
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:767: checking whether ln -s works" >&5
+echo "configure:773: checking whether ln -s works" >&5
 
 rm -f conftestdata
 if ln -s X conftestdata 2>/dev/null
@@ -828,7 +834,7 @@
 fi
 
 . "$srcdir/version.sh" || exit 1;
-if test -n "$emacs_beta_version"; then beta=yes; else beta=no; fi
+if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
 : "${extra_verbose=$beta}"
 version="${emacs_major_version}.${emacs_minor_version}"
 { test "$extra_verbose" = "yes" && cat << EOF
@@ -847,9 +853,10 @@
 EOF
 }
 
-if test -n "$emacs_beta_version"; then
-  version="${version}-b${emacs_beta_version}"
-  { test "$extra_verbose" = "yes" && cat << EOF
+if test -n "$emacs_beta_version" ; then
+  if test "$beta" = "yes"; then
+  	version="${version}-b${emacs_beta_version}"
+  	{ test "$extra_verbose" = "yes" && cat << EOF
     Defining EMACS_BETA_VERSION = $emacs_beta_version
 EOF
 cat >> confdefs.h <<EOF
@@ -857,6 +864,17 @@
 EOF
 }
 
+  else
+	version="${version}.${emacs_beta_version}"
+	{ test "$extra_verbose" = "yes" && cat << EOF
+    Defining EMACS_PATCH_LEVEL = $emacs_beta_version
+EOF
+cat >> confdefs.h <<EOF
+#define EMACS_PATCH_LEVEL $emacs_beta_version
+EOF
+}
+
+  fi
 fi
 { test "$extra_verbose" = "yes" && cat << EOF
     Defining XEMACS_CODENAME = "$xemacs_codename"
@@ -914,7 +932,7 @@
   PROGNAME=xemacs
 fi
 
-if test -n "$emacs_beta_version"; then beta=yes; else beta=no; fi
+if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
 test "${error_check_extents=$beta}"   = yes && { test "$extra_verbose" = "yes" && cat << \EOF
     Defining ERROR_CHECK_EXTENTS
 EOF
@@ -955,6 +973,14 @@
 EOF
 }
 
+test "${error_check_byte_code=$beta}" = yes && { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining ERROR_CHECK_BYTE_CODE
+EOF
+cat >> confdefs.h <<\EOF
+#define ERROR_CHECK_BYTE_CODE 1
+EOF
+}
+
 if test "${debug:=$beta}" = "yes"; then
   use_assertions=yes memory_usage_stats=yes
   extra_objs="$extra_objs debug.o" &&  if test "$extra_verbose" = "yes"; then
@@ -988,7 +1014,7 @@
 
 
 echo $ac_n "checking "host system type"""... $ac_c" 1>&6
-echo "configure:992: checking "host system type"" >&5
+echo "configure:1018: 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/'`
@@ -1480,13 +1506,14 @@
 # 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:1484: checking for $ac_word" >&5
+echo "configure:1510: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -1506,14 +1533,15 @@
   # 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:1510: checking for $ac_word" >&5
+echo "configure:1537: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -1547,11 +1575,42 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1585: checking for $ac_word" >&5
+
+if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1555: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1614: 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'
@@ -1562,12 +1621,14 @@
 ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
 cross_compiling=no
 
-cat > conftest.$ac_ext <<EOF
-#line 1567 "configure"
-#include "confdefs.h"
+cat > conftest.$ac_ext << EOF
+
+#line 1627 "configure"
+#include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:1571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1632: \"$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
@@ -1581,25 +1642,33 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
+xe_ldflags='$LDFLAGS $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_x_site $ld_switch_run'
+xe_libs='$ld_call_shared $xe_check_libs $X_EXTRA_LIBS $libs_x $X_PRE_LIBS $LIBS $libs_machine $libs_system $libs_standard'
+ac_cpp='$CPP '"$xe_cppflags"
+ac_compile='${CC-cc} -c $CFLAGS '"$xe_cppflags"' conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
+cross_compiling=no
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1591: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1660: 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:1596: checking whether we are using GNU C" >&5
+echo "configure:1665: 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:1603: \"$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:1672: \"$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
@@ -1609,11 +1678,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1617: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:1690: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1625,16 +1698,20 @@
 
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
     CFLAGS="-O2"
-  fi
-else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  else
+    CFLAGS=
+  fi
 fi
  
 if   test "$with_gcc" = "no"  -a "$GCC" = "yes"; then
@@ -1642,13 +1719,14 @@
   # 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:1646: checking for $ac_word" >&5
+echo "configure:1723: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -1668,14 +1746,15 @@
   # 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:1672: checking for $ac_word" >&5
+echo "configure:1750: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -1709,11 +1788,42 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1798: checking for $ac_word" >&5
+
+if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1717: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1827: 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'
@@ -1724,12 +1834,14 @@
 ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
 cross_compiling=no
 
-cat > conftest.$ac_ext <<EOF
-#line 1729 "configure"
-#include "confdefs.h"
+cat > conftest.$ac_ext << EOF
+
+#line 1840 "configure"
+#include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:1733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1845: \"$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
@@ -1743,25 +1855,33 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
+xe_ldflags='$LDFLAGS $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_x_site $ld_switch_run'
+xe_libs='$ld_call_shared $xe_check_libs $X_EXTRA_LIBS $libs_x $X_PRE_LIBS $LIBS $libs_machine $libs_system $libs_standard'
+ac_cpp='$CPP '"$xe_cppflags"
+ac_compile='${CC-cc} -c $CFLAGS '"$xe_cppflags"' conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
+cross_compiling=no
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1753: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1873: 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:1758: checking whether we are using GNU C" >&5
+echo "configure:1878: 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:1765: \"$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:1885: \"$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
@@ -1771,11 +1891,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1779: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:1903: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1787,16 +1911,20 @@
 
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
     CFLAGS="-O2"
-  fi
-else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  else
+    CFLAGS=
+  fi
 fi
 
 elif test "$with_gcc" = "yes" -a "$GCC" != "yes" ; then
@@ -1804,13 +1932,14 @@
   # 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:1808: checking for $ac_word" >&5
+echo "configure:1936: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -1830,14 +1959,15 @@
   # 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:1834: checking for $ac_word" >&5
+echo "configure:1963: checking for $ac_word" >&5
 
 if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -1871,11 +2001,42 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2011: checking for $ac_word" >&5
+
+if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1879: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2040: 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'
@@ -1886,12 +2047,14 @@
 ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
 cross_compiling=no
 
-cat > conftest.$ac_ext <<EOF
-#line 1891 "configure"
-#include "confdefs.h"
+cat > conftest.$ac_ext << EOF
+
+#line 2053 "configure"
+#include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:1895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2058: \"$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
@@ -1905,25 +2068,33 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
+xe_ldflags='$LDFLAGS $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_x_site $ld_switch_run'
+xe_libs='$ld_call_shared $xe_check_libs $X_EXTRA_LIBS $libs_x $X_PRE_LIBS $LIBS $libs_machine $libs_system $libs_standard'
+ac_cpp='$CPP '"$xe_cppflags"
+ac_compile='${CC-cc} -c $CFLAGS '"$xe_cppflags"' conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&5'
+cross_compiling=no
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1915: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2086: 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:1920: checking whether we are using GNU C" >&5
+echo "configure:2091: 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:1927: \"$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:2098: \"$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
@@ -1933,11 +2104,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1941: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:2116: checking whether ${CC-cc} accepts -g" >&5
 
 echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -1949,16 +2124,20 @@
 
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
     CFLAGS="-O2"
-  fi
-else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  else
+    CFLAGS=
+  fi
 fi
 
 fi
@@ -1970,7 +2149,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:1974: checking how to run the C preprocessor" >&5
+echo "configure:2153: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1983,14 +2162,14 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1987 "configure"
+#line 2166 "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:1993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2172: \"$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
   :
 else
@@ -2000,14 +2179,31 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2004 "configure"
+#line 2183 "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:2010: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2189: \"$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
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 2200 "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:2206: \"$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
   :
 else
@@ -2020,6 +2216,8 @@
 rm -f conftest*
 fi
 rm -f conftest*
+fi
+rm -f conftest*
   ac_cv_prog_CPP="$CPP"
   CPP="$ac_cv_prog_CPP"
 else
@@ -2029,9 +2227,9 @@
 
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:2033: checking for AIX" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2035 "configure"
+echo "configure:2231: checking for AIX" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2233 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -2058,9 +2256,9 @@
 
 
 echo $ac_n "checking for GNU libc""... $ac_c" 1>&6
-echo "configure:2062: checking for GNU libc" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2064 "configure"
+echo "configure:2260: checking for GNU libc" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2262 "configure"
 #include "confdefs.h"
 #include <features.h>
 int main() {
@@ -2072,7 +2270,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2076: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_glibc=yes
 else
@@ -2094,7 +2292,7 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 2098 "configure"
+#line 2296 "configure"
 #include "confdefs.h"
 int main () {
 #if defined __SUNPRO_C
@@ -2106,7 +2304,7 @@
 #endif
 }
 EOF
-if { (eval echo configure:2110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:2308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -2380,7 +2578,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2384: checking for dynodump" >&5
+echo "configure:2582: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2418,12 +2616,12 @@
   done
   
 echo $ac_n "checking for terminateAndUnload in -lC""... $ac_c" 1>&6
-echo "configure:2422: checking for terminateAndUnload in -lC" >&5
+echo "configure:2620: 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 2427 "configure"
+#line 2625 "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
@@ -2434,7 +2632,7 @@
 terminateAndUnload()
 ; return 0; }
 EOF
-if { (eval echo configure:2438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2636: \"$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
@@ -2501,16 +2699,15 @@
 case "$site_prefixes" in *:* ) site_prefixes="`echo '' $site_prefixes | sed -e 's/^ //' -e 's/:/ /g'`";; esac
 if test -n "$site_prefixes"; then
   for dir in $site_prefixes; do
-    inc_dir="${dir}/include"
     lib_dir="${dir}/lib"
     if test ! -d "$dir"; then
       { echo "Error:" "Invalid site prefix \`$dir': no such directory" >&2; exit 1; }
-    elif test ! -d "$inc_dir"; then
-      { echo "Error:" "Invalid site prefix \`$dir': no such directory \`$inc_dir'" >&2; exit 1; }
     elif test ! -d "$lib_dir"; then
       { echo "Error:" "Invalid site prefix \`$dir': no such directory \`$lib_dir'" >&2; exit 1; }
     else
-      c_switch_site="$c_switch_site "-I$inc_dir"" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \""-I$inc_dir"\" to \$c_switch_site"; fi
+      if test -d "$inc_dir"; then
+	c_switch_site="$c_switch_site "-I$inc_dir"" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \""-I$inc_dir"\" to \$c_switch_site"; fi
+      fi
       ld_switch_site="$ld_switch_site "-L$lib_dir"" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \""-L$lib_dir"\" to \$ld_switch_site"; fi
     fi
   done
@@ -2538,7 +2735,7 @@
 
 if test "$add_runtime_path" = "yes"; then
       echo $ac_n "checking "for runtime libraries flag"""... $ac_c" 1>&6
-echo "configure:2542: checking "for runtime libraries flag"" >&5
+echo "configure:2739: checking "for runtime libraries flag"" >&5
   case "$opsys" in
     sol2 ) dash_r="-R" ;;
     decosf* | linux* | irix*) dash_r="-rpath " ;;
@@ -2560,14 +2757,14 @@
   done
 fi
         cat > conftest.$ac_ext <<EOF
-#line 2564 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:2571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 2761 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -2669,10 +2866,10 @@
 fi
 after_morecore_hook_exists=yes
 echo $ac_n "checking for malloc_get_state""... $ac_c" 1>&6
-echo "configure:2673: checking for malloc_get_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2676 "configure"
+echo "configure:2870: checking for malloc_get_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2873 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_get_state(); below.  */
@@ -2695,7 +2892,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2699: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_malloc_get_state=yes"
 else
@@ -2715,10 +2912,10 @@
 fi
 
 echo $ac_n "checking for malloc_set_state""... $ac_c" 1>&6
-echo "configure:2719: checking for malloc_set_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2722 "configure"
+echo "configure:2916: checking for malloc_set_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2919 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_set_state(); below.  */
@@ -2741,7 +2938,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2942: \"$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
@@ -2761,16 +2958,16 @@
 fi
 
 echo $ac_n "checking whether __after_morecore_hook exists""... $ac_c" 1>&6
-echo "configure:2765: checking whether __after_morecore_hook exists" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2767 "configure"
+echo "configure:2962: checking whether __after_morecore_hook exists" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2964 "configure"
 #include "confdefs.h"
 extern void (* __after_morecore_hook)();
 int main() {
 __after_morecore_hook = 0
 ; return 0; }
 EOF
-if { (eval echo configure:2774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2971: \"$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
@@ -2829,13 +3026,14 @@
 # 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:2833: checking for $ac_word" >&5
+echo "configure:3030: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_RANLIB="ranlib"
@@ -2878,26 +3076,28 @@
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./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:2886: checking for a BSD compatible install" >&5
+echo "configure:3085: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
-  IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
   for ac_dir in $PATH; do
     # Account for people who put trailing slashes in PATH elements.
     case "$ac_dir/" in
     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd scoinst install; do
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
         if test -f $ac_dir/$ac_prog; then
 	  if test $ac_prog = install &&
             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
-	    # OSF/1 installbsd also uses dspmsg, but is usable.
 	    :
 	  else
 	    ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -2926,6 +3126,8 @@
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 for ac_prog in 'bison -y' byacc
@@ -2933,13 +3135,14 @@
 # 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:2937: checking for $ac_word" >&5
+echo "configure:3139: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_YACC="$ac_prog"
@@ -2964,16 +3167,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2968: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2971 "configure"
+echo "configure:3171: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3174 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2976: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3179: \"$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"
@@ -3005,16 +3208,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3009: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3012 "configure"
+echo "configure:3212: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3215 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3220: \"$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"
@@ -3046,16 +3249,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3050: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3053 "configure"
+echo "configure:3253: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3256 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3261: \"$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"
@@ -3084,10 +3287,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:3088: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3091 "configure"
+echo "configure:3291: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3294 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -3103,7 +3306,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:3107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3310: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -3127,10 +3330,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3131: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3134 "configure"
+echo "configure:3334: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3337 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3138,8 +3341,8 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3345: \"$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*
   ac_cv_header_stdc=yes
@@ -3155,7 +3358,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 3159 "configure"
+#line 3362 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3173,7 +3376,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 3177 "configure"
+#line 3380 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3191,7 +3394,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 3195 "configure"
+#line 3398 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3202,7 +3405,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:3409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -3228,10 +3431,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3232: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3235 "configure"
+echo "configure:3435: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3438 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -3240,7 +3443,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:3244: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3447: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -3264,10 +3467,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:3268: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3271 "configure"
+echo "configure:3471: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3474 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3279,7 +3482,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:3283: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -3304,9 +3507,9 @@
 
 
 echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6
-echo "configure:3308: checking for struct utimbuf" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3310 "configure"
+echo "configure:3511: checking for struct utimbuf" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3513 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3325,7 +3528,7 @@
 static struct utimbuf x; x.actime = x.modtime;
 ; return 0; }
 EOF
-if { (eval echo configure:3329: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3532: \"$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
@@ -3345,10 +3548,10 @@
 rm -f conftest*
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3349: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3352 "configure"
+echo "configure:3552: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3555 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3365,7 +3568,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3387,10 +3590,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3391: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3394 "configure"
+echo "configure:3594: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3597 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3399,7 +3602,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_size_t=yes
 else
@@ -3421,10 +3624,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3425: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3428 "configure"
+echo "configure:3628: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3631 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3433,7 +3636,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_pid_t=yes
 else
@@ -3455,10 +3658,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3459: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3462 "configure"
+echo "configure:3662: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3665 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3494,10 +3697,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3498: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3501 "configure"
+echo "configure:3701: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3704 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3506,7 +3709,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_mode_t=yes
 else
@@ -3528,10 +3731,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3532: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3535 "configure"
+echo "configure:3735: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3738 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3540,7 +3743,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_off_t=yes
 else
@@ -3563,9 +3766,9 @@
 
 
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:3567: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3569 "configure"
+echo "configure:3770: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3772 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3581,7 +3784,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:3585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3788: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -3603,10 +3806,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:3607: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3610 "configure"
+echo "configure:3810: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3813 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -3614,7 +3817,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:3618: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -3638,10 +3841,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:3642: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3645 "configure"
+echo "configure:3845: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3848 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -3649,7 +3852,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:3653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3856: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -3672,10 +3875,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:3676: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3679 "configure"
+echo "configure:3879: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3882 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -3685,7 +3888,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:3689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -3711,10 +3914,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3715: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3718 "configure"
+echo "configure:3918: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3921 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3763,7 +3966,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3970: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3788,7 +3991,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:3792: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:3995: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -3813,12 +4016,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3817: checking whether byte ordering is bigendian" >&5
+echo "configure:4020: 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 3822 "configure"
+#line 4025 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3829,11 +4032,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4036: \"$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 3837 "configure"
+#line 4040 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3844,7 +4047,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3848: \"$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_c_bigendian=yes
 else
@@ -3861,7 +4064,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 3865 "configure"
+#line 4068 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -3874,7 +4077,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -3901,10 +4104,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:3905: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3908 "configure"
+echo "configure:4108: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4111 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3915,7 +4118,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -3943,10 +4146,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3947: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3950 "configure"
+echo "configure:4150: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4153 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3957,7 +4160,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -3979,10 +4182,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3983: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3986 "configure"
+echo "configure:4186: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4189 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3993,7 +4196,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -4015,10 +4218,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:4019: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4022 "configure"
+echo "configure:4222: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4225 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4029,7 +4232,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4236: \"$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
@@ -4051,10 +4254,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:4055: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4058 "configure"
+echo "configure:4258: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4261 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4065,7 +4268,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4272: \"$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
@@ -4088,7 +4291,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:4092: checking for long file names" >&5
+echo "configure:4295: 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:
@@ -4134,10 +4337,10 @@
 
 
 echo $ac_n "checking for sin""... $ac_c" 1>&6
-echo "configure:4138: checking for sin" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4141 "configure"
+echo "configure:4341: checking for sin" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4344 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char sin(); below.  */
@@ -4160,7 +4363,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4367: \"$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
@@ -4178,12 +4381,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:4182: checking for sin in -lm" >&5
+echo "configure:4385: 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 4187 "configure"
+#line 4390 "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
@@ -4194,7 +4397,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:4198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4401: \"$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
@@ -4238,14 +4441,14 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 4242 "configure"
+#line 4445 "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:4249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4452: \"$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
@@ -4262,7 +4465,7 @@
 rm -f conftest*
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:4266: checking type of mail spool file locking" >&5
+echo "configure:4469: checking type of mail spool file locking" >&5
 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
 if   test "$mail_locking" = "lockf"; then { test "$extra_verbose" = "yes" && cat << \EOF
@@ -4287,12 +4490,12 @@
 case "$opsys" in decosf*)
   
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:4291: checking for cma_open in -lpthreads" >&5
+echo "configure:4494: 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 4296 "configure"
+#line 4499 "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
@@ -4303,7 +4506,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4510: \"$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
@@ -4339,7 +4542,7 @@
 esac
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:4343: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:4546: 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;
@@ -4350,7 +4553,7 @@
 
 if test "$opsys" = "sol2" && test "$OS_RELEASE" -ge 56; then
   echo $ac_n "checking for \"-z ignore\" linker flag""... $ac_c" 1>&6
-echo "configure:4354: checking for \"-z ignore\" linker flag" >&5
+echo "configure:4557: 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 ;;
@@ -4360,7 +4563,7 @@
 
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:4364: checking "for specified window system"" >&5
+echo "configure:4567: checking "for specified window system"" >&5
 
 if test "$with_x11" != "no"; then
     test "$x_includes $x_libraries" != "NONE NONE" && \
@@ -4393,7 +4596,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:4397: checking for X" >&5
+echo "configure:4600: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -4453,13 +4656,13 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 4457 "configure"
+#line 4660 "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:4462: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:4665: \"$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*
   # We can compile using X headers with no special include directory.
@@ -4527,14 +4730,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4531 "configure"
+#line 4734 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:4538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4741: \"$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.
@@ -4643,17 +4846,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:4647: checking whether -R must be followed by a space" >&5
+echo "configure:4850: 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 4650 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4853 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -4669,14 +4872,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 4673 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4876 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -4712,12 +4915,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:4716: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:4919: 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 4721 "configure"
+#line 4924 "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
@@ -4728,7 +4931,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4935: \"$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
@@ -4752,12 +4955,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:4756: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:4959: 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 4761 "configure"
+#line 4964 "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
@@ -4768,7 +4971,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4975: \"$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
@@ -4797,10 +5000,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:4801: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4804 "configure"
+echo "configure:5004: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5007 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -4823,7 +5026,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5030: \"$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
@@ -4844,12 +5047,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:4848: checking for gethostbyname in -lnsl" >&5
+echo "configure:5051: 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 4853 "configure"
+#line 5056 "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
@@ -4860,7 +5063,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:4864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5067: \"$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
@@ -4890,10 +5093,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:4894: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4897 "configure"
+echo "configure:5097: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5100 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -4916,7 +5119,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5123: \"$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
@@ -4939,12 +5142,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:4943: checking "$xe_msg_checking"" >&5
+echo "configure:5146: 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 4948 "configure"
+#line 5151 "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
@@ -4955,7 +5158,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:4959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5162: \"$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
@@ -4979,10 +5182,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:4983: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4986 "configure"
+echo "configure:5186: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5189 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -5005,7 +5208,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5212: \"$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
@@ -5026,12 +5229,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:5030: checking for remove in -lposix" >&5
+echo "configure:5233: 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 5035 "configure"
+#line 5238 "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
@@ -5042,7 +5245,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:5046: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5249: \"$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
@@ -5066,10 +5269,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:5070: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5073 "configure"
+echo "configure:5273: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5276 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -5092,7 +5295,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5299: \"$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
@@ -5113,12 +5316,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:5117: checking for shmat in -lipc" >&5
+echo "configure:5320: 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 5122 "configure"
+#line 5325 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5129,7 +5332,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:5133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5162,13 +5365,15 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   
-echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:5167: checking for IceConnectionNumber in -lICE" >&5
+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:5372: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 
-xe_check_libs=" -lICE "
-cat > conftest.$ac_ext <<EOF
-#line 5172 "configure"
+xe_check_libs=" -lICE $X_EXTRA_LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 5377 "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
@@ -5179,7 +5384,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:5183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5388: \"$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
@@ -5348,7 +5553,7 @@
 
 
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:5352: checking for X defines extracted by xmkmf" >&5
+echo "configure:5557: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -5380,16 +5585,16 @@
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:5384: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5387 "configure"
+echo "configure:5589: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5592 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5392: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:5597: \"$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"
@@ -5412,12 +5617,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:5416: checking for XOpenDisplay in -lX11" >&5
+echo "configure:5621: 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 5421 "configure"
+#line 5626 "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
@@ -5428,7 +5633,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5637: \"$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
@@ -5453,12 +5658,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:5457: checking "$xe_msg_checking"" >&5
+echo "configure:5662: 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 5462 "configure"
+#line 5667 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5469,7 +5674,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:5473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5496,12 +5701,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:5500: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:5705: 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 5505 "configure"
+#line 5710 "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
@@ -5512,7 +5717,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:5516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5721: \"$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
@@ -5535,12 +5740,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:5539: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:5744: 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 5544 "configure"
+#line 5749 "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
@@ -5551,7 +5756,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5760: \"$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
@@ -5574,14 +5779,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:5578: checking the version of X11 being used" >&5
+echo "configure:5783: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 5580 "configure"
+#line 5785 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:5585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:5790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -5606,16 +5811,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5610: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5613 "configure"
+echo "configure:5815: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5818 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5618: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:5823: \"$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"
@@ -5645,7 +5850,7 @@
 
 
     echo $ac_n "checking for XFree86""... $ac_c" 1>&6
-echo "configure:5649: checking for XFree86" >&5
+echo "configure:5854: checking for XFree86" >&5
   if test -d "/usr/X386/include" -o \
           -f "/etc/XF86Config"    -o \
 	  -f "/etc/X11/XF86Config" -o \
@@ -5665,12 +5870,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:5669: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:5874: 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 5674 "configure"
+#line 5879 "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
@@ -5681,7 +5886,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:5685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5890: \"$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
@@ -5720,19 +5925,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:5724: checking for main in -lXbsd" >&5
+echo "configure:5929: 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 5729 "configure"
+#line 5934 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5941: \"$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
@@ -5769,22 +5974,22 @@
 fi 
 if test "$with_msw" != "no"; then
   echo "checking for MS-Windows" 1>&6
-echo "configure:5773: checking for MS-Windows" >&5
+echo "configure:5978: checking for MS-Windows" >&5
   
 echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
-echo "configure:5776: checking for main in -lgdi32" >&5
+echo "configure:5981: 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 5781 "configure"
+#line 5986 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5993: \"$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
@@ -5849,12 +6054,12 @@
  fi
     fi
         cat > conftest.$ac_ext <<EOF
-#line 5853 "configure"
+#line 6058 "configure"
 #include "confdefs.h"
 #include <fcntl.h>
     int main() { return (open("/dev/windows", O_RDONLY, 0) > 0)? 0 : 1; }
 EOF
-if { (eval echo configure:5858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:6063: \"$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
@@ -5907,7 +6112,7 @@
 fi
 
 if test "$with_x11" != "yes"; then
-            for feature in tooltalk cde offix session xim xmu
+            for feature in tooltalk cde offix wmcommand xim xmu
   do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
        echo "configure: warning: --with-$feature ignored:  Not valid without X support" 1>&2
@@ -5929,14 +6134,14 @@
   test "$opsys" = "hpux9-shr" && opsysfile="s/hpux9shxr4.h"
 esac
 
-echo "checking for session-management option" 1>&6
-echo "configure:5934: checking for session-management option" >&5;
-if test "$with_session" != "no"; then
-  { test "$extra_verbose" = "yes" && cat << \EOF
-    Defining HAVE_SESSION
-EOF
-cat >> confdefs.h <<\EOF
-#define HAVE_SESSION 1
+echo "checking for WM_COMMAND option" 1>&6
+echo "configure:6139: checking for WM_COMMAND option" >&5;
+if test "$with_wmcommand" != "no"; then
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining HAVE_WMCOMMAND
+EOF
+cat >> confdefs.h <<\EOF
+#define HAVE_WMCOMMAND 1
 EOF
 }
 
@@ -5945,16 +6150,16 @@
 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:5949: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5952 "configure"
+echo "configure:6154: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6157 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6162: \"$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"
@@ -5976,12 +6181,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:5980: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:6185: 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 5985 "configure"
+#line 6190 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5992,7 +6197,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:5996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6037,16 +6242,16 @@
       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:6041: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6044 "configure"
+echo "configure:6246: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6249 "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:6049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6254: \"$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"
@@ -6081,12 +6286,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:6085: checking "$xe_msg_checking"" >&5
+echo "configure:6290: 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 6090 "configure"
+#line 6295 "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
@@ -6097,7 +6302,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:6101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6306: \"$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
@@ -6154,16 +6359,16 @@
 
 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:6158: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6161 "configure"
+echo "configure:6363: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6366 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6166: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6371: \"$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"
@@ -6185,12 +6390,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:6189: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:6394: 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 6194 "configure"
+#line 6399 "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
@@ -6201,7 +6406,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:6205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6410: \"$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
@@ -6270,7 +6475,7 @@
 fi
 
 echo $ac_n "checking if drag and drop API is needed""... $ac_c" 1>&6
-echo "configure:6274: checking if drag and drop API is needed" >&5
+echo "configure:6479: checking if drag and drop API is needed" >&5
 if test "$with_dragndrop" != "no" ; then
   if test -n "$dragndrop_proto" ; then
     with_dragndrop=yes
@@ -6291,19 +6496,19 @@
 fi
 
 echo "checking for LDAP" 1>&6
-echo "configure:6295: checking for LDAP" >&5
+echo "configure:6500: 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:6298: checking for ldap.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6301 "configure"
+echo "configure:6503: checking for ldap.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6506 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6511: \"$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"
@@ -6325,16 +6530,16 @@
  }
 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:6329: checking for lber.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6332 "configure"
+echo "configure:6534: checking for lber.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6537 "configure"
 #include "confdefs.h"
 #include <lber.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6337: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6542: \"$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"
@@ -6359,12 +6564,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:6363: checking "$xe_msg_checking"" >&5
+echo "configure:6568: 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 6368 "configure"
+#line 6573 "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
@@ -6375,7 +6580,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:6379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6584: \"$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
@@ -6398,12 +6603,12 @@
  }
   test "$with_umich_ldap" = "no" && { 
 echo $ac_n "checking for ldap_set_option in -lldap10""... $ac_c" 1>&6
-echo "configure:6402: checking for ldap_set_option in -lldap10" >&5
+echo "configure:6607: checking for ldap_set_option in -lldap10" >&5
 ac_lib_var=`echo ldap10'_'ldap_set_option | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap10 "
 cat > conftest.$ac_ext <<EOF
-#line 6407 "configure"
+#line 6612 "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
@@ -6414,7 +6619,7 @@
 ldap_set_option()
 ; return 0; }
 EOF
-if { (eval echo configure:6418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6623: \"$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
@@ -6478,15 +6683,15 @@
 
 if test "$window_system" != "none"; then
   echo "checking for graphics libraries" 1>&6
-echo "configure:6482: checking for graphics libraries" >&5
+echo "configure:6687: 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:6487: checking for Xpm - no older than 3.4f" >&5
+echo "configure:6692: checking for Xpm - no older than 3.4f" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 6490 "configure"
+#line 6695 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
     int main(int c, char **v) {
@@ -6494,7 +6699,7 @@
       XpmIncludeVersion != XpmLibraryVersion() ? 1 :
       XpmIncludeVersion < 30406 ? 2 : 0 ;}
 EOF
-if { (eval echo configure:6498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:6703: \"$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
@@ -6536,17 +6741,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:6540: checking for \"FOR_MSW\" xpm" >&5
+echo "configure:6745: checking for \"FOR_MSW\" xpm" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 6543 "configure"
+#line 6748 "configure"
 #include "confdefs.h"
 
 int main() {
 XpmCreatePixmapFromData()
 ; return 0; }
 EOF
-if { (eval echo configure:6550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   xpm_for_msw=no
 else
@@ -6572,16 +6777,16 @@
 
     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:6576: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6579 "configure"
+echo "configure:6781: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6784 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6584: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:6789: \"$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"
@@ -6603,12 +6808,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:6607: checking for UnGenFace in -lcompface" >&5
+echo "configure:6812: 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 6612 "configure"
+#line 6817 "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
@@ -6619,7 +6824,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:6623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6828: \"$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
@@ -6671,12 +6876,12 @@
       if test "$with_png $with_tiff" != "no no"; then
     
 echo $ac_n "checking for inflate in -lc""... $ac_c" 1>&6
-echo "configure:6675: checking for inflate in -lc" >&5
+echo "configure:6880: 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 6680 "configure"
+#line 6885 "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
@@ -6687,7 +6892,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:6691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6896: \"$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
@@ -6706,12 +6911,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lz""... $ac_c" 1>&6
-echo "configure:6710: checking for inflate in -lz" >&5
+echo "configure:6915: 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 6715 "configure"
+#line 6920 "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
@@ -6722,7 +6927,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:6726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6931: \"$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
@@ -6741,12 +6946,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lgz""... $ac_c" 1>&6
-echo "configure:6745: checking for inflate in -lgz" >&5
+echo "configure:6950: 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 6750 "configure"
+#line 6955 "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
@@ -6757,7 +6962,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:6761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6966: \"$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
@@ -6787,16 +6992,16 @@
 
     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:6791: checking for jpeglib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6794 "configure"
+echo "configure:6996: checking for jpeglib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6999 "configure"
 #include "confdefs.h"
 #include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6799: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:7004: \"$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"
@@ -6818,12 +7023,12 @@
  }
   test -z "$with_jpeg" && { 
 echo $ac_n "checking for jpeg_destroy_decompress in -ljpeg""... $ac_c" 1>&6
-echo "configure:6822: checking for jpeg_destroy_decompress in -ljpeg" >&5
+echo "configure:7027: 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 6827 "configure"
+#line 7032 "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
@@ -6834,7 +7039,7 @@
 jpeg_destroy_decompress()
 ; return 0; }
 EOF
-if { (eval echo configure:6838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7043: \"$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
@@ -6870,10 +7075,10 @@
 
     png_problem=""
   test -z "$with_png" && { echo $ac_n "checking for pow""... $ac_c" 1>&6
-echo "configure:6874: checking for pow" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6877 "configure"
+echo "configure:7079: checking for pow" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7082 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pow(); below.  */
@@ -6896,7 +7101,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7105: \"$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
@@ -6917,16 +7122,16 @@
  }
   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:6921: checking for png.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6924 "configure"
+echo "configure:7126: checking for png.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7129 "configure"
 #include "confdefs.h"
 #include <png.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6929: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:7134: \"$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"
@@ -6948,12 +7153,12 @@
  }
   test -z "$with_png" && { 
 echo $ac_n "checking for png_read_image in -lpng""... $ac_c" 1>&6
-echo "configure:6952: checking for png_read_image in -lpng" >&5
+echo "configure:7157: 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 6957 "configure"
+#line 7162 "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
@@ -6964,7 +7169,7 @@
 png_read_image()
 ; return 0; }
 EOF
-if { (eval echo configure:6968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7173: \"$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
@@ -6987,10 +7192,10 @@
  }
   if test -z "$with_png"; then
     echo $ac_n "checking for workable png version information""... $ac_c" 1>&6
-echo "configure:6991: checking for workable png version information" >&5
+echo "configure:7196: checking for workable png version information" >&5
     xe_check_libs="-lpng -lz"
     cat > conftest.$ac_ext <<EOF
-#line 6994 "configure"
+#line 7199 "configure"
 #include "confdefs.h"
 #include <png.h>
     int main(int c, char **v) {
@@ -6998,7 +7203,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:7002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:7207: \"$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
@@ -7041,16 +7246,16 @@
 
     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:7045: checking for tiffio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7048 "configure"
+echo "configure:7250: checking for tiffio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7253 "configure"
 #include "confdefs.h"
 #include <tiffio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7053: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:7258: \"$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"
@@ -7072,12 +7277,12 @@
  }
   test -z "$with_tiff" && { 
 echo $ac_n "checking for TIFFClientOpen in -ltiff""... $ac_c" 1>&6
-echo "configure:7076: checking for TIFFClientOpen in -ltiff" >&5
+echo "configure:7281: 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 7081 "configure"
+#line 7286 "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
@@ -7088,7 +7293,7 @@
 TIFFClientOpen()
 ; return 0; }
 EOF
-if { (eval echo configure:7092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7297: \"$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
@@ -7127,16 +7332,16 @@
 if test "$with_x11" = "yes"; then
 
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:7131: checking for X11 graphics libraries" >&5
+echo "configure:7336: checking for X11 graphics libraries" >&5
 
     
 echo $ac_n "checking for XawScrollbarSetThumb in -lXaw""... $ac_c" 1>&6
-echo "configure:7135: checking for XawScrollbarSetThumb in -lXaw" >&5
+echo "configure:7340: checking for XawScrollbarSetThumb in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'XawScrollbarSetThumb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXaw "
 cat > conftest.$ac_ext <<EOF
-#line 7140 "configure"
+#line 7345 "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
@@ -7147,7 +7352,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:7151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7356: \"$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
@@ -7171,16 +7376,16 @@
                     
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:7175: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7178 "configure"
+echo "configure:7380: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7383 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:7388: \"$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"
@@ -7196,12 +7401,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:7200: checking for XmStringFree in -lXm" >&5
+echo "configure:7405: 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 7205 "configure"
+#line 7410 "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
@@ -7212,7 +7417,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:7216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7421: \"$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
@@ -7241,9 +7446,9 @@
 
   if test "$have_motif" = "yes"; then
         echo $ac_n "checking for Lesstif""... $ac_c" 1>&6
-echo "configure:7245: checking for Lesstif" >&5
+echo "configure:7450: checking for Lesstif" >&5
     cat > conftest.$ac_ext <<EOF
-#line 7247 "configure"
+#line 7452 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 #ifdef LESSTIF_VERSION
@@ -7506,7 +7711,7 @@
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:7510: checking for Mule-related features" >&5
+echo "configure:7715: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -7531,16 +7736,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:7535: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7538 "configure"
+echo "configure:7740: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7743 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7543: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:7748: \"$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"
@@ -7570,12 +7775,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:7574: checking for strerror in -lintl" >&5
+echo "configure:7779: 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 7579 "configure"
+#line 7784 "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
@@ -7586,7 +7791,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:7590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7795: \"$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
@@ -7619,18 +7824,18 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:7623: checking for Mule input methods" >&5
+echo "configure:7828: checking for Mule input methods" >&5
         case "$with_xim" in "" | "yes" )
     echo "checking for XIM" 1>&6
-echo "configure:7626: checking for XIM" >&5
+echo "configure:7831: checking for XIM" >&5
     
 echo $ac_n "checking for XOpenIM in -lX11""... $ac_c" 1>&6
-echo "configure:7629: checking for XOpenIM in -lX11" >&5
+echo "configure:7834: 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 7634 "configure"
+#line 7839 "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
@@ -7641,7 +7846,7 @@
 XOpenIM()
 ; return 0; }
 EOF
-if { (eval echo configure:7645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7850: \"$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
@@ -7665,12 +7870,12 @@
         if test "$have_motif $have_lesstif" = "yes no"; then
       
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:7669: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:7874: 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 7674 "configure"
+#line 7879 "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
@@ -7681,7 +7886,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:7685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7890: \"$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
@@ -7746,15 +7951,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:7750: checking for XFontSet" >&5
+echo "configure:7955: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:7753: checking for XmbDrawString in -lX11" >&5
+echo "configure:7958: 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 7758 "configure"
+#line 7963 "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
@@ -7765,7 +7970,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:7769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7974: \"$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
@@ -7805,16 +8010,16 @@
     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:7809: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7812 "configure"
+echo "configure:8014: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8017 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7817: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:8022: \"$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"
@@ -7838,10 +8043,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7842: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7845 "configure"
+echo "configure:8047: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8050 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7864,7 +8069,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8073: \"$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
@@ -7893,12 +8098,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:7897: checking for crypt in -lcrypt" >&5
+echo "configure:8102: 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 7902 "configure"
+#line 8107 "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
@@ -7909,7 +8114,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:7913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8118: \"$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
@@ -7944,12 +8149,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:7948: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:8153: 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 7953 "configure"
+#line 8158 "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
@@ -7960,7 +8165,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:7964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8169: \"$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
@@ -7978,12 +8183,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:7982: checking for jl_dic_list_e in -lwnn4" >&5
+echo "configure:8187: 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 7987 "configure"
+#line 8192 "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
@@ -7994,7 +8199,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:7998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8203: \"$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
@@ -8012,12 +8217,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:8016: checking for jl_dic_list_e in -lwnn6" >&5
+echo "configure:8221: 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 8021 "configure"
+#line 8226 "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
@@ -8028,7 +8233,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:8032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8237: \"$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
@@ -8046,12 +8251,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:8050: checking for dic_list_e in -lwnn6_fromsrc" >&5
+echo "configure:8255: 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 8055 "configure"
+#line 8260 "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
@@ -8062,7 +8267,7 @@
 dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:8066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8271: \"$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
@@ -8110,12 +8315,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:8114: checking for jl_fi_dic_list in -l$libwnn" >&5
+echo "configure:8319: 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 8119 "configure"
+#line 8324 "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
@@ -8126,7 +8331,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:8130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8335: \"$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
@@ -8161,16 +8366,16 @@
   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:8165: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8168 "configure"
+echo "configure:8370: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8373 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8173: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:8378: \"$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"
@@ -8196,16 +8401,16 @@
     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:8200: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8203 "configure"
+echo "configure:8405: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8408 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8208: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:8413: \"$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"
@@ -8232,16 +8437,16 @@
 
   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:8236: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8239 "configure"
+echo "configure:8441: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8444 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8244: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:8449: \"$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"
@@ -8263,12 +8468,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:8267: checking for RkBgnBun in -lRKC" >&5
+echo "configure:8472: 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 8272 "configure"
+#line 8477 "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
@@ -8279,7 +8484,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:8283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8488: \"$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
@@ -8302,12 +8507,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:8306: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:8511: 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 8311 "configure"
+#line 8516 "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
@@ -8318,7 +8523,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:8322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8527: \"$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
@@ -8367,12 +8572,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:8371: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:8576: 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 8376 "configure"
+#line 8581 "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
@@ -8383,7 +8588,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:8387: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8592: \"$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
@@ -8469,10 +8674,10 @@
 for ac_func in cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf strcasecmp strerror tzset ulimit usleep utimes waitpid vsnprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8473: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8476 "configure"
+echo "configure:8678: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8681 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8495,7 +8700,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8704: \"$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
@@ -8536,10 +8741,10 @@
       * ) for ac_func in realpath
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8540: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8543 "configure"
+echo "configure:8745: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8748 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8562,7 +8767,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8771: \"$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
@@ -8598,10 +8803,10 @@
 for ac_func in getloadavg
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8602: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8605 "configure"
+echo "configure:8807: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8810 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8624,7 +8829,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8833: \"$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
@@ -8660,12 +8865,12 @@
 
     
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:8664: checking for kstat_open in -lkstat" >&5
+echo "configure:8869: 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 8669 "configure"
+#line 8874 "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
@@ -8676,7 +8881,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:8680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8885: \"$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
@@ -8710,12 +8915,12 @@
 
     
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:8714: checking for kvm_read in -lkvm" >&5
+echo "configure:8919: 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 8719 "configure"
+#line 8924 "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
@@ -8726,7 +8931,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:8730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8935: \"$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
@@ -8760,16 +8965,16 @@
 fi
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:8764: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 8766 "configure"
+echo "configure:8969: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 8971 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:8773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8978: \"$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
@@ -8789,16 +8994,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:8793: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 8795 "configure"
+echo "configure:8998: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 9000 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:8802: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:9007: \"$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
@@ -8818,11 +9023,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:8822: checking whether localtime caches TZ" >&5
+echo "configure:9027: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 8826 "configure"
+#line 9031 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -8857,7 +9062,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:8861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -8887,9 +9092,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday accepts one or two arguments""... $ac_c" 1>&6
-echo "configure:8891: checking whether gettimeofday accepts one or two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 8893 "configure"
+echo "configure:9096: checking whether gettimeofday accepts one or two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 9098 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -8911,7 +9116,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9120: \"$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
@@ -8933,19 +9138,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:8937: checking for inline" >&5
+echo "configure:9142: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 8942 "configure"
+#line 9147 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:8949: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:9154: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -8995,17 +9200,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:8999: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9002 "configure"
+echo "configure:9204: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9207 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:9009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9214: \"$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
@@ -9029,23 +9234,28 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:9033: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9036 "configure"
+echo "configure:9238: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9241 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
 # define alloca __builtin_alloca
 #else
-# if HAVE_ALLOCA_H
-#  include <alloca.h>
+# ifdef _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
 # else
-#  ifdef _AIX
- #pragma alloca
+#  if HAVE_ALLOCA_H
+#   include <alloca.h>
 #  else
-#   ifndef alloca /* predefined by HP cc +Olibcalls */
+#   ifdef _AIX
+ #pragma alloca
+#   else
+#    ifndef alloca /* predefined by HP cc +Olibcalls */
 char *alloca ();
+#    endif
 #   endif
 #  endif
 # endif
@@ -9055,7 +9265,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:9059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9269: \"$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
@@ -9083,7 +9293,7 @@
   # that cause trouble.  Some versions do not even contain alloca or
   # contain a buggy version.  If you still want to use their alloca,
   # use ar to extract alloca.o from them instead of compiling alloca.c.
-  ALLOCA=alloca.o
+  ALLOCA=alloca.${ac_objext}
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining C_ALLOCA
 EOF
@@ -9094,10 +9304,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:9098: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9101 "configure"
+echo "configure:9308: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9311 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -9121,10 +9331,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:9125: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9128 "configure"
+echo "configure:9335: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9338 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9147,7 +9357,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9361: \"$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
@@ -9177,10 +9387,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:9181: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9184 "configure"
+echo "configure:9391: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9394 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -9199,7 +9409,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:9203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9413: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -9228,16 +9438,16 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:9232: checking for vfork.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9235 "configure"
+echo "configure:9442: checking for vfork.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9445 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:9450: \"$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"
@@ -9264,10 +9474,10 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:9268: checking for working vfork" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9271 "configure"
+echo "configure:9478: checking for working vfork" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9481 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -9362,7 +9572,7 @@
   }
 }
 EOF
-if { (eval echo configure:9366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_vfork_works=yes
 else
@@ -9388,10 +9598,10 @@
 
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:9392: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9395 "configure"
+echo "configure:9602: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9605 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -9401,7 +9611,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:9405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -9429,10 +9639,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9433: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9436 "configure"
+echo "configure:9643: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9646 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9455,7 +9665,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9669: \"$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
@@ -9483,10 +9693,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:9487: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9490 "configure"
+echo "configure:9697: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9700 "configure"
 #include "confdefs.h"
 
 /*
@@ -9541,7 +9751,7 @@
 }
 
 EOF
-if { (eval echo configure:9545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -9568,10 +9778,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:9572: checking for working mmap" >&5
+echo "configure:9782: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 9575 "configure"
+#line 9785 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -9604,7 +9814,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:9608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:9818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   have_mmap=yes
 else
@@ -9629,16 +9839,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9633: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9636 "configure"
+echo "configure:9843: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9846 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9641: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:9851: \"$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"
@@ -9669,10 +9879,10 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9673: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9676 "configure"
+echo "configure:9883: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9886 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9695,7 +9905,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9699: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9909: \"$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
@@ -9723,10 +9933,10 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:9727: checking for working mmap" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9730 "configure"
+echo "configure:9937: checking for working mmap" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9940 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -9866,7 +10076,7 @@
 }
 
 EOF
-if { (eval echo configure:9870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:10080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -9904,16 +10114,16 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:9908: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9911 "configure"
+echo "configure:10118: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10121 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9916: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10126: \"$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"
@@ -9955,16 +10165,16 @@
   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:9959: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9962 "configure"
+echo "configure:10169: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10172 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9967: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10177: \"$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"
@@ -9995,10 +10205,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:9999: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10002 "configure"
+echo "configure:10209: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10212 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -10021,7 +10231,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10235: \"$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
@@ -10036,16 +10246,16 @@
   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:10040: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10043 "configure"
+echo "configure:10250: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10253 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10048: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10258: \"$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"
@@ -10061,16 +10271,16 @@
   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:10065: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10068 "configure"
+echo "configure:10275: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10278 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10283: \"$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"
@@ -10094,9 +10304,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:10098: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:10308: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 10100 "configure"
+#line 10310 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -10107,7 +10317,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:10111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10321: \"$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
@@ -10125,9 +10335,9 @@
 fi
 rm -f conftest*
       echo $ac_n "checking "for ip_mreq struct in netinet/in.h"""... $ac_c" 1>&6
-echo "configure:10129: checking "for ip_mreq struct in netinet/in.h"" >&5
+echo "configure:10339: checking "for ip_mreq struct in netinet/in.h"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 10131 "configure"
+#line 10341 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -10137,7 +10347,7 @@
 static struct ip_mreq x;
 ; return 0; }
 EOF
-if { (eval echo configure:10141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10351: \"$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
@@ -10168,10 +10378,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:10172: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10175 "configure"
+echo "configure:10382: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10385 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -10194,7 +10404,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10408: \"$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
@@ -10209,16 +10419,16 @@
   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:10213: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10216 "configure"
+echo "configure:10423: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10426 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10431: \"$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"
@@ -10234,16 +10444,16 @@
   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:10238: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10241 "configure"
+echo "configure:10448: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10451 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10246: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10456: \"$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"
@@ -10280,16 +10490,16 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:10284: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10287 "configure"
+echo "configure:10494: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10497 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10292: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10502: \"$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"
@@ -10315,16 +10525,16 @@
   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:10319: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10322 "configure"
+echo "configure:10529: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10532 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10327: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10537: \"$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"
@@ -10356,16 +10566,16 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:10360: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10363 "configure"
+echo "configure:10570: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10573 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10368: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10578: \"$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"
@@ -10394,7 +10604,7 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:10398: checking "for sound support"" >&5
+echo "configure:10608: checking "for sound support"" >&5
 case "$with_sound" in
   native | both ) with_native_sound=yes;;
   nas    | no   ) with_native_sound=no;;
@@ -10405,16 +10615,16 @@
     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:10409: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10412 "configure"
+echo "configure:10619: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10622 "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:10417: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10627: \"$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"
@@ -10461,12 +10671,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:10465: checking for ALopenport in -laudio" >&5
+echo "configure:10675: 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 10470 "configure"
+#line 10680 "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
@@ -10477,7 +10687,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:10481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10691: \"$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
@@ -10508,12 +10718,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:10512: checking for AOpenAudio in -lAlib" >&5
+echo "configure:10722: 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 10517 "configure"
+#line 10727 "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
@@ -10524,7 +10734,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:10528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10738: \"$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
@@ -10562,16 +10772,16 @@
     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:10566: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10569 "configure"
+echo "configure:10776: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10779 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10784: \"$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"
@@ -10640,7 +10850,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 10644 "configure"
+#line 10854 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -10667,7 +10877,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:10671: checking for TTY-related features" >&5
+echo "configure:10881: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -10683,12 +10893,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:10687: checking for tgetent in -lncurses" >&5
+echo "configure:10897: 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 10692 "configure"
+#line 10902 "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
@@ -10699,7 +10909,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:10703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:10913: \"$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
@@ -10732,16 +10942,16 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:10736: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10739 "configure"
+echo "configure:10946: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10949 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10744: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10954: \"$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"
@@ -10762,16 +10972,16 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:10766: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10769 "configure"
+echo "configure:10976: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10979 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10774: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:10984: \"$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"
@@ -10800,16 +11010,16 @@
       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:10804: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10807 "configure"
+echo "configure:11014: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11017 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:11022: \"$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"
@@ -10843,12 +11053,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:10847: checking for tgetent in -l$lib" >&5
+echo "configure:11057: 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 10852 "configure"
+#line 11062 "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
@@ -10859,7 +11069,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:10863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11073: \"$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
@@ -10890,12 +11100,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:10894: checking for tgetent in -lcurses" >&5
+echo "configure:11104: 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 10899 "configure"
+#line 11109 "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
@@ -10906,7 +11116,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:10910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11120: \"$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
@@ -10924,12 +11134,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:10928: checking for tgetent in -ltermcap" >&5
+echo "configure:11138: 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 10933 "configure"
+#line 11143 "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
@@ -10940,7 +11150,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:10944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11154: \"$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
@@ -10988,16 +11198,16 @@
 
     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:10992: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10995 "configure"
+echo "configure:11202: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11205 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:11210: \"$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"
@@ -11019,12 +11229,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:11023: checking for Gpm_Open in -lgpm" >&5
+echo "configure:11233: 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 11028 "configure"
+#line 11238 "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
@@ -11035,7 +11245,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:11039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11249: \"$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
@@ -11085,21 +11295,21 @@
 
 test "$with_database_gnudbm $with_database_dbm $with_database_berkdb" \
   != "no no no" && echo "checking for database support" 1>&6
-echo "configure:11089: checking for database support" >&5
+echo "configure:11299: checking for database support" >&5
 
 if test "$with_database_gnudbm $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:11094: checking for ndbm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11097 "configure"
+echo "configure:11304: checking for ndbm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11307 "configure"
 #include "confdefs.h"
 #include <ndbm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11102: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:11312: \"$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"
@@ -11128,12 +11338,12 @@
 if test "$with_database_gnudbm" != "no"; then
   
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:11132: checking for dbm_open in -lgdbm" >&5
+echo "configure:11342: 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 11137 "configure"
+#line 11347 "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
@@ -11144,7 +11354,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:11148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11358: \"$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
@@ -11172,10 +11382,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:11176: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11179 "configure"
+echo "configure:11386: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11389 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -11198,7 +11408,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11412: \"$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
@@ -11217,12 +11427,12 @@
 
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:11221: checking for dbm_open in -ldbm" >&5
+echo "configure:11431: 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 11226 "configure"
+#line 11436 "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
@@ -11233,7 +11443,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:11237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11447: \"$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
@@ -11274,10 +11484,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for Berkeley db.h""... $ac_c" 1>&6
-echo "configure:11278: checking for Berkeley db.h" >&5
+echo "configure:11488: checking for Berkeley db.h" >&5
   for path in "db/db.h" "db.h"; do
     cat > conftest.$ac_ext <<EOF
-#line 11281 "configure"
+#line 11491 "configure"
 #include "confdefs.h"
 #ifdef HAVE_INTTYPES_H
 #define __BIT_TYPES_DEFINED__
@@ -11295,7 +11505,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:11509: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_path="$path"; break
 else
@@ -11311,9 +11521,9 @@
 
   if test "$with_database_berkdb" != "no"; then
     echo $ac_n "checking for Berkeley DB version""... $ac_c" 1>&6
-echo "configure:11315: checking for Berkeley DB version" >&5
+echo "configure:11525: checking for Berkeley DB version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 11317 "configure"
+#line 11527 "configure"
 #include "confdefs.h"
 #include <$db_h_path>
 #if DB_VERSION_MAJOR > 1
@@ -11332,10 +11542,10 @@
 rm -f conftest*
 
     echo $ac_n "checking for $dbfunc""... $ac_c" 1>&6
-echo "configure:11336: checking for $dbfunc" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11339 "configure"
+echo "configure:11546: checking for $dbfunc" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11549 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $dbfunc(); below.  */
@@ -11358,7 +11568,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11572: \"$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
@@ -11377,12 +11587,12 @@
 
     
 echo $ac_n "checking for $dbfunc in -ldb""... $ac_c" 1>&6
-echo "configure:11381: checking for $dbfunc in -ldb" >&5
+echo "configure:11591: 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 11386 "configure"
+#line 11596 "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
@@ -11393,7 +11603,7 @@
 $dbfunc()
 ; return 0; }
 EOF
-if { (eval echo configure:11397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11607: \"$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
@@ -11457,12 +11667,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:11461: checking for SOCKSinit in -lsocks" >&5
+echo "configure:11671: 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 11466 "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
@@ -11473,7 +11683,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:11477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
@@ -11530,16 +11740,16 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11534: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11537 "configure"
+echo "configure:11744: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11747 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11542: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:11752: \"$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"
@@ -11577,12 +11787,12 @@
 
 test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:11581: checking for dlopen in -ldl" >&5
+echo "configure:11791: 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 11586 "configure"
+#line 11796 "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
@@ -11593,7 +11803,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:11597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11807: \"$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
@@ -11622,12 +11832,12 @@
  }
 test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
 echo $ac_n "checking for _dlopen in -lc""... $ac_c" 1>&6
-echo "configure:11626: checking for _dlopen in -lc" >&5
+echo "configure:11836: 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 11631 "configure"
+#line 11841 "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
@@ -11638,7 +11848,7 @@
 _dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:11642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11852: \"$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
@@ -11667,12 +11877,12 @@
  }
 test -z "$with_shlib" && test ! -z "$have_dlfcn" && { 
 echo $ac_n "checking for dlopen in -lc""... $ac_c" 1>&6
-echo "configure:11671: checking for dlopen in -lc" >&5
+echo "configure:11881: 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 11676 "configure"
+#line 11886 "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
@@ -11683,7 +11893,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:11687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11897: \"$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
@@ -11712,12 +11922,12 @@
  }
 test -z "$with_shlib" && { 
 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:11716: checking for shl_load in -ldld" >&5
+echo "configure:11926: 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 11721 "configure"
+#line 11931 "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
@@ -11728,7 +11938,7 @@
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo configure:11732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11942: \"$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
@@ -11757,12 +11967,12 @@
  }
 test -z "$with_shlib" && { 
 echo $ac_n "checking for dld_init in -ldld""... $ac_c" 1>&6
-echo "configure:11761: checking for dld_init in -ldld" >&5
+echo "configure:11971: 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 11766 "configure"
+#line 11976 "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
@@ -11773,7 +11983,7 @@
 dld_init()
 ; return 0; }
 EOF
-if { (eval echo configure:11777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:11987: \"$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
@@ -11812,7 +12022,7 @@
 xealias=$internal_configuration
 
 echo "checking how to build dynamic libraries for ${xehost}" 1>&6
-echo "configure:11816: checking how to build dynamic libraries for ${xehost}" >&5
+echo "configure:12026: checking how to build dynamic libraries for ${xehost}" >&5
 # Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts.
 case "$xehost" in
 *-*-linux-gnu*) ;;
@@ -11840,9 +12050,9 @@
   XEGCC=yes
 else
   echo $ac_n "checking checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:11844: checking checking whether we are using GNU C" >&5
+echo "configure:12054: checking checking whether we are using GNU C" >&5
   cat > conftest.$ac_ext <<EOF
-#line 11846 "configure"
+#line 12056 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -11864,7 +12074,7 @@
 fi
 
 echo $ac_n "checking how to produce PIC code""... $ac_c" 1>&6
-echo "configure:11868: checking how to produce PIC code" >&5
+echo "configure:12078: checking how to produce PIC code" >&5
 wl=
 
 can_build_shared=yes
@@ -11957,18 +12167,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:11961: checking if PIC flag ${dll_cflags} really works" >&5
+echo "configure:12171: checking if PIC flag ${dll_cflags} really works" >&5
   save_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $dll_cflags -DPIC"
   cat > conftest.$ac_ext <<EOF
-#line 11965 "configure"
+#line 12175 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:11972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12182: \"$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
@@ -11999,7 +12209,7 @@
 xldf=
 xcldf=
 echo $ac_n "checking if C compiler can produce shared libraries""... $ac_c" 1>&6
-echo "configure:12003: checking if C compiler can produce shared libraries" >&5
+echo "configure:12213: checking if C compiler can produce shared libraries" >&5
 if test "$XEGCC" = yes; then
   xcldf="-shared"
   xldf="-shared"
@@ -12050,14 +12260,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 12054 "configure"
+#line 12264 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:12061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:12271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cc_produces_so=yes
 else
@@ -12082,7 +12292,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:12086: checking for ld used by GCC" >&5
+echo "configure:12296: checking for ld used by GCC" >&5
     ac_prog=`($CC -print-prog-name=ld) 2>&5`
     case "$ac_prog" in
     # Accept absolute paths.
@@ -12107,7 +12317,7 @@
     esac
   else
     echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:12111: checking for GNU ld" >&5
+echo "configure:12321: checking for GNU ld" >&5
   fi
 
   if test -z "$LTLD"; then
@@ -12145,7 +12355,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:12149: checking if the linker is GNU ld" >&5
+echo "configure:12359: 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
@@ -12172,7 +12382,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:12176: checking whether the linker supports shared libraries" >&5
+echo "configure:12386: checking whether the linker supports shared libraries" >&5
   dll_ld=$CC
   dll_ldflags=$LDFLAGS
   ld_shlibs=yes
@@ -12388,10 +12598,10 @@
     for ac_func in dlerror _dlerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:12392: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12395 "configure"
+echo "configure:12602: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12605 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -12414,7 +12624,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:12628: \"$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
@@ -12448,11 +12658,11 @@
 fi
 
 cat > conftest.$ac_ext <<EOF
-#line 12452 "configure"
+#line 12662 "configure"
 #include "confdefs.h"
 int main(int c,char *v[]){return 0;}
 EOF
-if { (eval echo configure:12456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:12666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -13009,8 +13219,15 @@
 echo "$0 $quoted_arguments"
 ) > Installation
 
-xemacs_betaname=""
-test ! -z "${emacs_beta_version}" && xemacs_betaname="-b${emacs_beta_version}"
+if test ! -z ${emacs_beta_version} ; then
+  if test -z "${emacs_is_beta}" ; then
+	xemacs_betaname=".${emacs_beta_version}"
+  else
+	xemacs_betaname="-b${emacs_beta_version}"
+  fi
+else
+  xemacs_betaname=""	
+fi
 
 (
 echo "
@@ -13114,7 +13331,7 @@
 test "$with_offix"    = yes && echo "  Compiling in support for OffiX."
 test "$with_dragndrop" = yes && echo "  Compiling in EXPERIMENTAL support for Drag'n'Drop ($dragndrop_proto )."
 test "$with_workshop" = yes && echo "  Compiling in support for Sun WorkShop."
-test "$with_session"  != no && echo "  Compiling in support for proper session-management."
+test "$with_wmcommand"  != no && echo "  Compiling in support for proper WM_COMMAND handling."
 case "$with_menubars" in
   lucid ) echo "  Using Lucid menubars." ;;
   motif ) echo "  Using Motif menubars."
@@ -13225,7 +13442,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -13245,9 +13462,11 @@
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
 s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
 s%@DEFS@%$DEFS%g
 s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
@@ -13277,6 +13496,7 @@
 s%@lib_gcc@%$lib_gcc%g
 s%@RANLIB@%$RANLIB%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
 s%@YACC@%$YACC%g
 s%@SET_MAKE@%$SET_MAKE%g
--- a/configure.in	Mon Aug 13 11:20:44 2007 +0200
+++ b/configure.in	Mon Aug 13 11:21:38 2007 +0200
@@ -482,7 +482,7 @@
 	with_jpeg	| \
 	with_png	| \
 	with_tiff	| \
-	with_session	| \
+	with_wmcommand	| \
 	with_xmu	| \
 	with_purify	| \
 	with_quantify	| \
@@ -661,14 +661,17 @@
 	      malloc )	      error_check_malloc=yes ;;
 	      nomalloc )      error_check_malloc=no ;;
 
+	      byte_code )     error_check_byte_code=yes ;;
+	      nobyte_code )   error_check_byte_code=no ;;
+
 	      * ) bogus_error_check=yes ;;
 	    esac
 	    if test "$bogus_error_check" -o \
 	         \( -n "$new_default" -a -n "$echeck_notfirst" \) ; then
 		if test "$error_check_default" = yes ; then
-		  types="\`all' (default), \`none', \`noextents', \`notypecheck', \`nobufpos', \`nogc', and \`nomalloc'."
+		  types="\`all' (default), \`none', \`noextents', \`notypecheck', \`nobufpos', \`nogc', \`nomalloc', and \`nobyte-code'."
 		else
-		  types="\`all', \`none' (default), \`extents', \`typecheck', \`bufpos', \`gc', and \`malloc'."
+		  types="\`all', \`none' (default), \`extents', \`typecheck', \`bufpos', \`gc', \`malloc', and \`byte-code'."
 		fi
 		USAGE_ERROR(["Valid types for the \`--$optname' option are:
   $types."])
@@ -678,6 +681,7 @@
 		error_check_bufpos=$new_default
 		error_check_gc=$new_default
 		error_check_malloc=$new_default
+		error_check_byte_code=$new_default
 		new_default=	# reset this
 	    fi
 	    echeck_notfirst=true
@@ -909,14 +913,19 @@
 dnl ----------------------------------------
 . "$srcdir/version.sh" || exit 1;
 dnl Must do the following first to determine verbosity for AC_DEFINE
-if test -n "$emacs_beta_version"; then beta=yes; else beta=no; fi
+if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
 : "${extra_verbose=$beta}"
 version="${emacs_major_version}.${emacs_minor_version}"
 AC_DEFINE_UNQUOTED(EMACS_MAJOR_VERSION, $emacs_major_version)
 AC_DEFINE_UNQUOTED(EMACS_MINOR_VERSION, $emacs_minor_version)
-if test -n "$emacs_beta_version"; then
-  version="${version}-b${emacs_beta_version}"
-  AC_DEFINE_UNQUOTED(EMACS_BETA_VERSION, $emacs_beta_version)
+if test -n "$emacs_beta_version" ; then
+  if test "$beta" = "yes"; then
+  	version="${version}-b${emacs_beta_version}"
+  	AC_DEFINE_UNQUOTED(EMACS_BETA_VERSION, $emacs_beta_version)
+  else
+	version="${version}.${emacs_beta_version}"
+	AC_DEFINE_UNQUOTED(EMACS_PATCH_LEVEL, $emacs_beta_version)
+  fi
 fi
 AC_DEFINE_UNQUOTED(XEMACS_CODENAME, "$xemacs_codename")
 AC_DEFINE_UNQUOTED(EMACS_VERSION, "$version")
@@ -946,12 +955,13 @@
 dnl ----------------------------------
 dnl Error checking default to "yes" in beta versions, to "no" in releases.
 dnl Same goes for --debug and --extra-verbosity.
-if test -n "$emacs_beta_version"; then beta=yes; else beta=no; fi
+if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
 test "${error_check_extents=$beta}"   = yes && AC_DEFINE(ERROR_CHECK_EXTENTS)
 test "${error_check_typecheck=$beta}" = yes && AC_DEFINE(ERROR_CHECK_TYPECHECK)
 test "${error_check_bufpos=$beta}"    = yes && AC_DEFINE(ERROR_CHECK_BUFPOS)
 test "${error_check_gc=$beta}"        = yes && AC_DEFINE(ERROR_CHECK_GC)
 test "${error_check_malloc=$beta}"    = yes && AC_DEFINE(ERROR_CHECK_MALLOC)
+test "${error_check_byte_code=$beta}" = yes && AC_DEFINE(ERROR_CHECK_BYTE_CODE)
 dnl debug=yes must be set when error checking is present.  This should be
 dnl fixed up.
 dnl debug implies other options
@@ -1882,16 +1892,15 @@
 COLON_TO_SPACE(site_prefixes)
 if test -n "$site_prefixes"; then
   for dir in $site_prefixes; do
-    inc_dir="${dir}/include"
     lib_dir="${dir}/lib"
     if test ! -d "$dir"; then
       XE_DIE("Invalid site prefix \`$dir': no such directory")
-    elif test ! -d "$inc_dir"; then
-      XE_DIE("Invalid site prefix \`$dir': no such directory \`$inc_dir'")
     elif test ! -d "$lib_dir"; then
       XE_DIE("Invalid site prefix \`$dir': no such directory \`$lib_dir'")
     else
-      XE_APPEND("-I$inc_dir", c_switch_site)
+      if test -d "$inc_dir"; then
+	XE_APPEND("-I$inc_dir", c_switch_site)
+      fi
       XE_APPEND("-L$lib_dir", ld_switch_site)
     fi
   done
@@ -2519,7 +2528,7 @@
   dnl if test "$with_tty" = "no" ; then
   dnl   AC_MSG_ERROR([No window system support and no TTY support - Unable to proceed.])
   dnl fi
-  for feature in tooltalk cde offix session xim xmu
+  for feature in tooltalk cde offix wmcommand xim xmu
   do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
        AC_MSG_WARN([--with-$feature ignored:  Not valid without X support])
@@ -2542,11 +2551,11 @@
   test "$opsys" = "hpux9-shr" && opsysfile="s/hpux9shxr4.h"
 esac
 
-dnl Enable or disable proper session-management
-AC_CHECKING(for session-management option);
-dnl if test "$with_session" = "yes"; then
-if test "$with_session" != "no"; then
-  AC_DEFINE(HAVE_SESSION)
+dnl Enable or disable proper handling of WM_COMMAND
+AC_CHECKING(for WM_COMMAND option);
+dnl if test "$with_wmcommand" = "yes"; then
+if test "$with_wmcommand" != "no"; then
+  AC_DEFINE(HAVE_WMCOMMAND)
 fi
 
 dnl Autodetect Xauth
@@ -3963,8 +3972,15 @@
 echo "$0 $quoted_arguments"
 ) > Installation
 
-xemacs_betaname=""
-test ! -z "${emacs_beta_version}" && xemacs_betaname="-b${emacs_beta_version}"
+if test ! -z ${emacs_beta_version} ; then
+  if test -z "${emacs_is_beta}" ; then
+	xemacs_betaname=".${emacs_beta_version}"
+  else
+	xemacs_betaname="-b${emacs_beta_version}"
+  fi
+else
+  xemacs_betaname=""	
+fi
 
 dnl Start stdout redirection to '| tee -a Installation'
 (
@@ -4069,7 +4085,7 @@
 test "$with_offix"    = yes && echo "  Compiling in support for OffiX."
 test "$with_dragndrop" = yes && echo "  Compiling in EXPERIMENTAL support for Drag'n'Drop ($dragndrop_proto )."
 test "$with_workshop" = yes && echo "  Compiling in support for Sun WorkShop."
-test "$with_session"  != no && echo "  Compiling in support for proper session-management."
+test "$with_wmcommand"  != no && echo "  Compiling in support for proper WM_COMMAND handling."
 case "$with_menubars" in
   lucid ) echo "  Using Lucid menubars." ;;
   motif ) echo "  Using Motif menubars."
--- a/configure.usage	Mon Aug 13 11:20:44 2007 +0200
+++ b/configure.usage	Mon Aug 13 11:21:38 2007 +0200
@@ -56,9 +56,8 @@
 --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-session       Compile without realized leader window which will
-                        keep the WM_COMMAND property. Required for proper
-                        session-management.
+--without-wmcommand     Compile without realized leader window which will
+                        keep the WM_COMMAND property.
 --with-menubars=TYPE    Use TYPE menubars (lucid, motif, or no).  The Lucid
                         widgets emulate Motif (mostly) but are faster.
                         *WARNING*  The Motif menubar is currently broken.
--- a/etc/NEWS	Mon Aug 13 11:20:44 2007 +0200
+++ b/etc/NEWS	Mon Aug 13 11:21:38 2007 +0200
@@ -85,6 +85,9 @@
 `~hniksic/'.  To make this operation faster, a cache of user names is
 maintained internally.
 
+The new primitives available for this purpose are functions named
+`user-name-completion' and `user-name-all-completions'.
+
 
 * Lisp and internal changes in XEmacs 21.2
 ==========================================
@@ -175,6 +178,18 @@
 
 Of course, the old form is still accepted for backward compatibility.
 
+** `translate-region' has been improved in several ways.  Its TABLE
+argument used to be a 256-character string.  In addition to this, it
+can now also be a vector or a char-table (which is useful for Mule.)
+If TABLE a vector or a generic char-table, you can map characters to
+strings instead of to other characters.  For instance:
+
+    (let ((table (make-char-table 'generic)))
+      (put-char-table ?a "the letter a" table)
+      (put-char-table ?b "" table)
+      (put-char-table ?c ?\n table)
+      (translate-region (point-min) (point-max) table))
+
 ** The `keywordp' function now returns non-nil only on symbols
 interned in the global obarray.  For example:
 
@@ -185,7 +200,7 @@
 
 This behaviour is compatible with other code which treats symbols
 beginning with colon as keywords only if they are interned in the
-global obarray.  `keyword' used to wrongly return t in both cases
+global obarray.  `keywordp' used to wrongly return t in both cases
 above.
 
 ** The first argument to `intern-soft' may now also be a symbol, like
--- a/info/dir	Mon Aug 13 11:20:44 2007 +0200
+++ b/info/dir	Mon Aug 13 11:21:38 2007 +0200
@@ -44,6 +44,7 @@
 * New-Users-Guide::  XEmacs New User's Guide for XEmacs 21.2.
 * XEmacs-FAQ::	     XEmacs Frequently Asked Questions for 21.2.
 * Internals::	     Guide to the internals of XEmacs.
+* Emodules::	     XEmacs dynamic loadable module support.
 
 
 Local Packages:
--- a/lib-src/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/lib-src/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,11 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-06-03  SL Baur  <steve@steve1.m17n.org>
+
+	* Makefile.in.in: Move .PHONY up to force execution of `all'.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/lib-src/Makefile.in.in	Mon Aug 13 11:20:44 2007 +0200
+++ b/lib-src/Makefile.in.in	Mon Aug 13 11:21:38 2007 +0200
@@ -171,6 +171,8 @@
 .c.o:
 	${CC} -c $(cflags) $<
 
+.PHONY : all maybe-blessmail install uninstall
+
 all: ${UTILITIES} ${INSTALLABLES} srcdir-symlink.stamp
 
 ## Make symlinks for shell scripts if using --srcdir
@@ -229,7 +231,6 @@
 
 ## We do not need to install "wakeup" explicitly, because it will be
 ## copied when this whole directory is copied.
-.PHONY : all maybe-blessmail install uninstall
 install: ${archlibdir}
 	@echo; echo "Installing utilities for users to run."
 	for file in ${INSTALLABLES} ; do \
--- a/lib-src/config.values.in	Mon Aug 13 11:20:44 2007 +0200
+++ b/lib-src/config.values.in	Mon Aug 13 11:21:38 2007 +0200
@@ -27,6 +27,7 @@
 ETCDIR "@ETCDIR@"
 ETCDIR_USER_DEFINED "@ETCDIR_USER_DEFINED@"
 EXEC_PREFIX "@EXEC_PREFIX@"
+FFLAGS "@FFLAGS@"
 INFODIR "@INFODIR@"
 INFODIR_USER_DEFINED "@INFODIR_USER_DEFINED@"
 INFOPATH "@INFOPATH@"
@@ -35,6 +36,7 @@
 INSTALL_ARCH_DEP_SUBDIR "@INSTALL_ARCH_DEP_SUBDIR@"
 INSTALL_DATA "@INSTALL_DATA@"
 INSTALL_PROGRAM "@INSTALL_PROGRAM@"
+INSTALL_SCRIPT "@INSTALL_SCRIPT@"
 LDFLAGS "@LDFLAGS@"
 LIBS "@LIBS@"
 LISPDIR "@LISPDIR@"
@@ -52,6 +54,7 @@
 RANLIB "@RANLIB@"
 RECURSIVE_MAKE "@RECURSIVE_MAKE@"
 SET_MAKE "@SET_MAKE@"
+SHELL "@SHELL@"
 SITELISPDIR "@SITELISPDIR@"
 SITELISPDIR_USER_DEFINED "@SITELISPDIR_USER_DEFINED@"
 SITEMODULEDIR "@SITEMODULEDIR@"
--- a/lisp/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,222 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-06-02  Oscar Figueiredo  <oscar@xemacs.org>
+
+	* subr.el (split-string): Avoid infinite looping
+
+1999-05-30  Oscar Figueiredo  <Oscar.Figueiredo@di.epfl.ch>
+
+	* ldap.el (ldap-ignore-attribute-codings): New variable
+	(ldap-default-attribute-decoder): New variable
+	(ldap-coding-system): New variable
+	(ldap-attribute-syntax-encoders): New variable
+	(ldap-attribute-syntax-decoders): New variable
+	(ldap-attribute-syntaxes-alist): New variable
+	(ldap-encode-boolean): New function
+	(ldap-decode-boolean): New function
+	(ldap-encode-country-string): New function
+	(ldap-decode-string): New function
+	(ldap-decode-address): New function
+	(ldap-encode-address): New function
+	(ldap-decode-attribute): New function
+	(ldap-search): Use some of these
+
+1999-05-25  Jan Vroonhof  <jan@xemacs.org>
+
+	* version.el (emacs-version): Make the patch level/beta come
+	before the XEmacs qualifier so that it gets into (funcall
+	emacs-version) and thus in the bug reports.
+	(emacs-version>=): Support patch levels.
+
+1999-06-03  SL Baur  <steve@xemacs.org>
+
+	* version.el: implement x.y.z version number
+	From Jan Vroonhof <vroonhof@math.ethz.ch>
+
+1999-05-27  Yoshiki Hayashi <g740685@komaba.ecc.u-tokyo.ac.jp>
+
+	* mule/mule-cmds.el (read-input-method-name): set input-method properly.
+
+1999-05-22  Vin Shelton <acs@xemacs.org>
+
+	* startup.el: Document -private and break out non-standard X options.
+
+1999-05-26  SL Baur  <steve@gneiss.etl.go.jp>
+
+	* mule/mule-charset.el (charset-after): New function.
+	(charset-direction): Synch with Mule, update docstring.
+	(get-charset-property): New function.
+	(put-charset-property): New function.
+	(charset-plist): New function.
+
+	* mule/mule-charset.el (compose-region):
+	(decompose-region): remove;  these functions (which don't work
+	since we don't do composite characters) have been moved to
+	mule-util.el.
+	(toplevel): follow coding standards
+
+1999-05-26  SL Baur  <steve@gneiss.etl.go.jp>
+
+	* dumped-lisp.el (preloaded-file-list): mule-files.el does not
+	exist any more.
+
+	* code-files.el: Fix commentary to follow coding standards.  Move
+	the single line left in mule-files.el to here.
+
+	* mule/mule-files.el: delete.
+
+1999-05-24  SL Baur  <steve@gneiss.etl.go.jp>
+
+	* info.el (Info-scroll-prev): Use event functions instead of the
+	old emacs 19 interface.
+
+1999-06-02  Andy Piper  <andy@xemacs.org>
+
+	* x-font-menu.el (x-font-menu-load-font):
+ 	font-menu-registry-encoding -> x-font-menu-registry-encoding type.
+
+1999-05-31  Andy Piper  <andy@xemacs.org>
+
+	* font-menu.el (font-menu-ignore-scaled-fonts): move to font-menu
+ 	group.
+	(font-menu-this-frame-only-p): ditto.
+	(font-menu-max-items): reinstate, from Jan Vroonhof
+ 	<vroonhof@math.ethz.ch>
+	(font-menu-submenu-name-format): ditto.
+	(font-menu-split-long-menu): ditto, for use by the family
+ 	constructor.
+	(font-menu-family-constructor): use it.
+
+1999-05-30  Andy Piper  <andy@xemacs.org>
+
+	* msw-faces.el (mswindows-font-regexp): new font matching regexp
+ 	for use by the font menu.
+
+	* msw-font-menu.el: new file implementing mswindows specific
+ 	font-menu behaviour.
+ 	(mswindows-font-menu-registry-encoding): new function mirroring x version.
+	(mswindows-font-menu-junk-families): ditto.
+	(hack-font-truename): ditto.
+	(mswindows-font-regexp-ascii): ditto.
+	(mswindows-reset-device-font-menus): ditto.
+	(mswindows-font-menu-font-data): ditto.
+	(mswindows-font-menu-load-font): ditto.
+
+	* x-font-menu.el (x-reset-device-font-menus): made device specific. 
+	(x-font-menu-font-data): ditto.
+	(x-font-menu-load-font): ditto.
+
+	* font-menu.el: new file implementing generic font menu behaviour.
+ 	(font-menu-ignore-scaled-fonts): copied from x-font-menu.el and
+ 	made device independent.
+	(font-menu-this-frame-only-p): ditto.
+	(font-menu-preferred-resolution): ditto.
+	(font-menu-size-scaling): new variable used to determine whether
+ 	sizes are in points or tenths of a point.
+	(vassoc): moved from x-font-menu.el.
+	(device-fonts-cache): ditto.
+	(device-fonts-cache): ditto.
+	(flush-device-fonts-cache): ditto.
+	(reset-device-font-menus): copied from x-font-menu.el and made
+ 	device independent. Most functionality deferred to
+ 	device-dependent versions.
+	(font-menu-family-constructor): copied from x-font-menu.el and
+ 	made device independent.
+	(font-menu-size-constructor): ditto.
+	(font-menu-weight-constructor): ditto.
+	(font-menu-set-font): ditto.
+	(font-menu-change-face): ditto.
+	(font-menu-load-font): new device method.
+	(font-menu-font-data): ditto.
+
+	* x-font-menu.el: The above functions deleted.
+
+1999-05-26  Andy Piper  <andy@xemacs.org>
+
+	* update-elc.el:
+	* make-docfile.el:
+	* loadup.el: rehash expand-file-name usage to not use default-directory.
+
+1999-05-21  Andy Piper  <andy@xemacs.org>
+
+	* x-select.el (x-select-convert-to-text):
+	(x-selected-text-type):
+	(x-get-selection):
+	(xselect-convert-to-string):
+	(xselect-convert-to-compound-text):
+	(xselect-convert-to-length):
+	(xselect-convert-to-targets):
+	(xselect-convert-to-delete):
+	(xselect-convert-to-filename):
+	(xselect-convert-to-charpos):
+	(xselect-convert-to-lineno):
+	(xselect-convert-to-colno):
+	(xselect-convert-to-sourceloc):
+	(xselect-convert-to-os):
+	(xselect-convert-to-host):
+	(xselect-convert-to-user):
+	(xselect-convert-to-class):
+	(xselect-convert-to-name):
+	(xselect-convert-to-integer):
+	(xselect-convert-to-atom):
+	(xselect-convert-to-identity): functions renamed from x-* and
+ 	moved to select.el.
+	(x-get-secondary-selection): use rename get-selection.
+	(x-get-clipboard): ditto.
+	(x-own-selection): moved to select.el.
+	(x-valid-simple-selection-p): ditto.
+	(x-dehilight-selection): ditto.
+	(x-own-clipboard): ditto.
+	(x-disown-selection): ditto.
+
+	* x-mouse.el (x-yank-function): moved to mouse.el.
+	(x-insert-selection): ditto.
+	(x-set-point-and-move-selection): use renamed function.
+
+	* select.el (selected-text-type): moved and renamed from
+ 	x-select.el.
+	(selection-owner-p): moved to C.
+	(selection-exists-p): ditto.
+	(get-cutbuffer): new device method.
+	(get-selection): generalised and moved from x-select.el.
+	(own-selection): moved x-own-selection functionality into here.
+	(dehilight-selection): renamed and moved from x-select.el.
+	(own-clipboard): functionality moved from x-select.el using new
+ 	generic C builtins.
+	(disown-clipboard): ditto.
+	(select-convert-to-text):
+	(select-convert-to-string):
+	(select-convert-to-compound-text):
+	(select-convert-to-length):
+	(select-convert-to-targets):
+	(select-convert-to-delete):
+	(select-convert-to-filename):
+	(select-convert-to-charpos):
+	(select-convert-to-lineno):
+	(select-convert-to-colno):
+	(select-convert-to-sourceloc):
+	(select-convert-to-os):
+	(select-convert-to-host):
+	(select-convert-to-user):
+	(select-convert-to-class):
+	(select-convert-to-name):
+	(select-convert-to-integer):
+	(select-convert-to-atom):
+	(select-convert-to-identity): new functions renamed from x-* and
+ 	moved from x-select.el.
+
+	* mouse.el (mouse-consolidated-yank): subsume x-yank-function
+ 	into here and use as the default window-system mouse yank.
+	(insert-selection): generalised and moved from x-mouse.el.
+	(own-clipboard): moved to C.
+
+	* msw-select.el	(mswindows-selection-owned-p): deleted.
+	(mswindows-own-selection): generalised and moved to select.el.
+	(mswindows-disown-selection): generalised and moved to C.
+	(mswindows-selection-owner-p): ditto.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/lisp/auto-autoloads.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/auto-autoloads.el	Mon Aug 13 11:21:38 2007 +0200
@@ -1057,6 +1057,30 @@
 
 ;;;***
 
+;;;### (autoloads (mswindows-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 'x)
+
+(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 'x)
+
+(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 'mswindows-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)
@@ -1228,6 +1252,20 @@
 
 ;;;***
 
+;;;### (autoloads (mswindows-reset-device-font-menus) "msw-font-menu" "lisp/msw-font-menu.el")
+
+(autoload 'mswindows-reset-device-font-menus "msw-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)
+
+(defun* mswindows-font-menu-font-data (face dcache) (let* ((case-fold-search t) (domain (if font-menu-this-frame-only-p (selected-frame) (selected-device))) (name (font-instance-name (face-font-instance face domain))) (truename (font-instance-truename (face-font-instance face domain (if (featurep 'mule) 'ascii)))) family size weight entry slant) (when (string-match mswindows-font-regexp name) (setq family (capitalize (match-string 1 name))) (setq entry (vassoc family (aref dcache 0)))) (when (and (null entry) (string-match mswindows-font-regexp truename)) (setq family (capitalize (match-string 1 truename))) (setq entry (vassoc family (aref dcache 0)))) (when (null entry) (return-from font-menu-font-data (make-vector 5 nil))) (when (string-match mswindows-font-regexp name) (setq weight (capitalize (match-string 2 name))) (setq size (string-to-int (match-string 4 name)))) (when (string-match mswindows-font-regexp truename) (when (not (member weight (aref entry 1))) (setq weight (capitalize (match-string 2 truename)))) (when (not (member size (aref entry 2))) (setq size (string-to-int (match-string 4 truename)))) (setq slant (capitalize (match-string 5 truename)))) (vector entry family size weight slant)))
+
+;;;***
+
 ;;;### (autoloads (mwheel-install) "mwheel" "lisp/mwheel.el")
 
 (autoload 'mwheel-install "mwheel" "\
@@ -1719,15 +1757,9 @@
 
 ;;;***
 
-;;;### (autoloads (font-menu-weight-constructor font-menu-size-constructor font-menu-family-constructor reset-device-font-menus) "x-font-menu" "lisp/x-font-menu.el")
-
-(defcustom font-menu-ignore-scaled-fonts t "*If non-nil, then the font menu will try to show only bitmap fonts." :type 'boolean :group 'font-menu)
+;;;### (autoloads (x-reset-device-font-menus) "x-font-menu" "lisp/x-font-menu.el")
 
-(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 "x-font-menu" "\
+(autoload 'x-reset-device-font-menus "x-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
@@ -1735,11 +1767,7 @@
 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 "x-font-menu" nil nil nil)
-
-(autoload 'font-menu-size-constructor "x-font-menu" nil nil nil)
-
-(autoload 'font-menu-weight-constructor "x-font-menu" nil nil nil)
+(defun* x-font-menu-font-data (face dcache) (let* ((case-fold-search t) (domain (if font-menu-this-frame-only-p (selected-frame) (selected-device))) (name (font-instance-name (face-font-instance face domain))) (truename (font-instance-truename (face-font-instance face domain (if (featurep 'mule) 'ascii)))) family size weight entry slant) (when (string-match x-font-regexp-foundry-and-family name) (setq family (capitalize (match-string 1 name))) (setq entry (vassoc family (aref dcache 0)))) (when (and (null entry) (string-match x-font-regexp-foundry-and-family truename)) (setq family (capitalize (match-string 1 truename))) (setq entry (vassoc family (aref dcache 0)))) (when (null entry) (return-from font-menu-font-data (make-vector 5 nil))) (when (string-match x-font-regexp name) (setq weight (capitalize (match-string 1 name))) (setq size (string-to-int (match-string 6 name)))) (when (string-match x-font-regexp truename) (when (not (member weight (aref entry 1))) (setq weight (capitalize (match-string 1 truename)))) (when (not (member size (aref entry 2))) (setq size (string-to-int (match-string 6 truename)))) (setq slant (capitalize (match-string 2 truename)))) (vector entry family size weight slant)))
 
 ;;;***
 
--- a/lisp/code-files.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/code-files.el	Mon Aug 13 11:21:38 2007 +0200
@@ -6,8 +6,6 @@
 
 ;; This file is part of XEmacs.
 
-;; This file is very similar to mule-files.el
-
 ;; 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)
@@ -23,13 +21,18 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
+;;; Synched up with: Not synched.
+
 ;;; Commentary:
 
-;;; Derived from mule.el in the original Mule but heavily modified
-;;; by Ben Wing.
+;; Derived from mule.el in the original Mule but heavily modified
+;; by Ben Wing.
 
 ;; 1997/3/11 modified by MORIOKA Tomohiko to sync with Emacs 20 API.
 
+;; This file was derived from the former mule-files.el which has been removed
+;; as of XEmacs 21.2.15.
+
 ;;; Code:
 
 (setq-default buffer-file-coding-system 'no-conversion)
@@ -555,4 +558,9 @@
 			start end filename append visit lockname
 			coding-system)))
 
-;;; mule-files.el ends here
+;;; The following was all that remained in mule-files.el, so I moved it
+;;; here for neatness.  -sb
+(when (featurep 'mule)
+  (setq-default buffer-file-coding-system 'iso-2022-8))
+
+;;; code-files.el ends here
--- a/lisp/dumped-lisp.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/dumped-lisp.el	Mon Aug 13 11:21:38 2007 +0200
@@ -94,7 +94,6 @@
 	(when-feature mule "mule-coding")
 ;; Handle I/O of files with extended characters.
 	(when-feature file-coding "code-files")
-	(when-feature mule "mule-files")
 ;; Handle process with encoding/decoding non-ascii coding-system.
 	(when-feature file-coding "code-process")
 	(when-feature mule "mule-help")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/font-menu.el	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,456 @@
+;; font-menu.el --- Managing menus of fonts.
+
+;; Copyright (C) 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
+;; Copyright (C) 1997 Sun Microsystems
+
+;; Adapted from x-font-menu.el by Andy Piper <andy@xemacs.org>
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; This file contains the device-nospecific font menu stuff
+
+;;; Commentary:
+;;;
+;;; Creates three menus, "Font", "Size", and "Weight", and puts them on the
+;;; "Options" menu.  The contents of these menus are the superset of those
+;;; properties available on any fonts, but only the intersection of the three
+;;; sets is selectable at one time.
+;;;
+;;; Known Problems:
+;;; ===============
+;;; Items on the Font menu are selectable if and only if that font exists in
+;;; the same size and weight as the current font.  This means that some fonts
+;;; are simply not reachable from some other fonts - if only one font comes
+;;; in only one point size (like "Nil", which comes only in 2), you will never
+;;; be able to select it.  It would be better if the items on the Fonts menu
+;;; were always selectable, and selecting them would set the size to be the
+;;; closest size to the current font's size.
+;;;
+;;; This attempts to change all other faces in an analagous way to the change
+;;; that was made to the default face; if it can't, it will skip over the face.
+;;; However, this could leave incongruous font sizes around, which may cause
+;;; some nonreversibility problems if further changes are made.  Perhaps it
+;;; should remember the initial fonts of all faces, and derive all subsequent
+;;; fonts from that initial state.
+;;;
+;;; xfontsel(1) is a lot more flexible (but probably harder to understand).
+;;;
+;;; The code to construct menus from all of the x11 fonts available from the
+;;; server is autoloaded and executed the very first time that one of the Font
+;;; menus is selected on each device.  That is, if XEmacs has frames on two
+;;; different devices, then separate font menu information will be maintained
+;;; for each X display.  If the font path changes after emacs has already
+;;; asked the X server on a particular display for its list of fonts, this
+;;; won't notice.  Also, the first time that a font menu is posted on each
+;;; display will entail a lengthy delay, but that's better than slowing down
+;;; XEmacs startup.  At any time (i.e.: after a font-path change or
+;;; immediately after device creation), you can call
+;;; `reset-device-font-menus' to rebuild the menus from all currently
+;;; available fonts.
+;;;
+;;; There is knowledge here about the regexp match numbers in
+;;; `mswindows-font-regexp' and `mswindows-font-regexp-foundry-and-family' defined in
+;;; mswindows-faces.el.
+;;;
+;;; There are at least three kinds of fonts under X11r5:
+;;;
+;;; - bitmap fonts, which can be assumed to look as good as possible;
+;;; - bitmap fonts which have been (or can be) automatically scaled to
+;;;   a new size, and which almost always look awful;
+;;; - and true outline fonts, which should look ok at any size, but in
+;;;   practice (on at least some systems) look awful at any size, and
+;;;   even in theory are unlikely ever to look as good as non-scaled
+;;;   bitmap fonts.
+;;;
+;;; It would be nice to get this code to look for non-scaled bitmap fonts
+;;; first, then outline fonts, then scaled bitmap fonts as a last resort.
+;;; But it's not clear to me how to tell them apart based on their truenames
+;;; and/or the result of XListFonts().  I welcome any and all explanations
+;;; of the subtleties involved...
+;;;
+;;;
+;;; If You Think You'Re Seeing A Bug:
+;;; =================================
+;;; When reporting problems, send the following information:
+;;;
+;;; - Exactly what behavior you're seeing;
+;;; - The output of the `xlsfonts' program;
+;;; - The value of the variable `device-fonts-cache';
+;;; - The values of the following expressions, both before and after
+;;;   making a selection from any of the fonts-related menus:
+;;;	(face-font 'default)
+;;;	(font-truename   (face-font 'default))
+;;;	(font-properties (face-font 'default))
+;;; - The values of the following variables after making a selection:
+;;;	font-menu-preferred-resolution
+;;;	font-menu-registry-encoding
+;;;
+;;; There is a common misconception that "*-courier-medium-r-*-11-*", also
+;;; known as "-adobe-courier-medium-r-normal--11-80-100-100-m-60-iso8859-1",
+;;; is an 11-point font.  It is not -- it is an 11-pixel font at 100dpi,
+;;; which is an 8-point font (the number after -11- is the size in tenths
+;;; of points).  So if you expect to be seeing an "11" entry in the "Size"
+;;; menu and are not, this may be why.
+;;;
+;;; In the real world (aka Solaris), one has to deal with fonts that
+;;; appear to be medium-i but are really light-r, and fonts that
+;;; resolve to different resolutions depending on the charset:
+;;;
+;;; (font-instance-truename
+;;;  (make-font-instance "-*-mincho-medium-i-normal-*-*-*-*-*-*-*-jisx0201*-*"))
+;;; ==>
+;;; "-morisawa-ryumin light kl-light-r-normal--10-100-72-72-m-50-jisx0201.1976-0"
+;;;
+;;; (list-fonts "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*")
+;;; ==>
+;;; ("-dt-interface user-medium-r-normal-s sans-12-120-72-72-m-70-iso8859-1"
+;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-120-jisx0208.1983-0"
+;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-60-jisx0201.1976-0")
+
+;;;###autoload
+(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)
+
+;;;###autoload
+(defcustom font-menu-this-frame-only-p nil
+  "*If non-nil, then changing the default font from the font menu will only
+affect one frame instead of all frames."
+  :type 'boolean
+  :group 'font-menu)
+
+(defcustom font-menu-max-items 25
+  "*Maximum number of items in the font menu
+If number of entries in a menu is larger than this value, split menu
+into submenus of nearly equal length.  If nil, never split menu into
+submenus."
+  :group 'font-menu
+  :type '(choice (const :tag "no submenus" nil)
+		 (integer)))
+
+(defcustom font-menu-submenu-name-format "%-12.12s ... %.12s"
+  "*Format specification of the submenu name.
+Used by `font-menu-split-long-menu' if the number of entries in a menu is
+larger than `font-menu-menu-max-items'.
+This string should contain one %s for the name of the first entry and
+one %s for the name of the last entry in the submenu.
+If the value is a function, it should return the submenu name.  The
+function is be called with two arguments, the names of the first and
+the last entry in the menu."
+  :group 'font-menu
+  :type '(choice (string :tag "Format string")
+		 (function)))
+
+(defvar font-menu-preferred-resolution 
+  (make-specifier-and-init 'generic '((global ((mswindows) . ":")
+					      ((x) . "*-*"))) t)
+  "Preferred horizontal and vertical font menu resolution (e.g. \"75:75\").")
+
+(defvar font-menu-size-scaling
+  (make-specifier-and-init 'integer '((global ((mswindows) . 1)
+					      ((x) . 10))) t)
+  "Scale factor used in defining font sizes.")
+
+(defun vassoc (key valist)
+  "Search VALIST for a vector whose first element is equal to KEY.
+See also `assoc'."
+  ;; by Stig@hackvan.com
+  (let (el)
+    (catch 'done
+      (while (setq el (pop valist))
+	(and (equal key (aref el 0))
+	     (throw 'done el))))))
+
+;; only call XListFonts (and parse) once per device.
+;; ( (device . [parsed-list-fonts family-menu size-menu weight-menu]) ...)
+(defvar device-fonts-cache nil)
+
+(defsubst device-fonts-cache ()
+  (or (cdr (assq (selected-device) device-fonts-cache))
+      (and (reset-device-font-menus (selected-device))
+	   (cdr (assq (selected-device) device-fonts-cache)))))
+
+;;;###autoload
+(fset 'install-font-menus 'reset-device-font-menus)
+(make-obsolete 'install-font-menus 'reset-device-font-menus)
+
+;;;###autoload
+(defun reset-device-font-menus (&optional device debug)
+  "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."
+  (message "Getting list of fonts from server... ")
+  (if (or noninteractive
+	  (not (or device (setq device (selected-device)))))
+      nil
+    (call-device-method 'reset-device-font-menus device device debug)
+    (message "Getting list of fonts from server... done.")))
+
+(defun font-menu-split-long-menu (menu)
+  "Split MENU according to `font-menu-max-items'."
+  (let ((len (length menu)))
+    (if (or (null font-menu-max-items)
+	    (null (featurep 'lisp-float-type))
+	    (<= len font-menu-max-items))
+	menu
+      ;; Submenu is max 2 entries longer than menu, never shorter, number of
+      ;; entries in submenus differ by at most one (with longer submenus first)
+      (let* ((outer (floor (sqrt len)))
+	     (inner (/ len outer))
+	     (rest (% len outer))
+	     (result nil))
+	(setq menu (reverse menu))
+	(while menu
+	  (let ((in inner)
+		(sub nil)
+		(to (car menu)))
+	    (while (> in 0)
+	      (setq in   (1- in)
+		    sub  (cons (car menu) sub)
+		    menu (cdr menu)))
+	    (setq result
+		  (cons (cons (if (stringp font-menu-submenu-name-format)
+				  (format font-menu-submenu-name-format
+					  (aref (car sub) 0) (aref to 0))
+				(funcall font-menu-submenu-name-format
+					 (aref (car sub) 0) (aref to 0)))
+			      sub)
+			result)
+		  rest  (1+ rest))
+	    (if (= rest outer) (setq inner (1+ inner)))))
+	result))))
+
+;;;###autoload
+(defun font-menu-family-constructor (ignored)
+  (catch 'menu
+    (unless (console-on-window-system-p)
+      (throw 'menu '(["Cannot parse current font" ding nil])))
+    (let* ((dcache (device-fonts-cache))
+	   (font-data (font-menu-font-data 'default dcache))
+	   (entry  (aref font-data 0))
+	   (family (aref font-data 1))
+	   (size   (aref font-data 2))
+	   (weight (aref font-data 3))
+	   f)
+      (unless family
+	(throw 'menu '(["Cannot parse current font" ding nil])))
+      ;; Items on the Font menu are enabled iff that font exists in
+      ;; the same size and weight as the current font (scalable fonts
+      ;; exist in every size).  Only the current font is marked as
+      ;; selected.
+      (font-menu-split-long-menu
+       (mapcar
+	(lambda (item)
+	  (setq f (aref item 0)
+		entry (vassoc f (aref dcache 0)))
+	  (if (and (or (member weight (aref entry 1))
+		       ;; mswindows often allows any weight
+		       (member "" (aref entry 1)))
+		   (or (member size (aref entry 2))
+		       (and (not font-menu-ignore-scaled-fonts)
+			    (member 0 (aref entry 2)))))
+	      (enable-menu-item item)
+	    (disable-menu-item item))
+	  (if (string-equal family f)
+	      (select-toggle-menu-item item)
+	    (deselect-toggle-menu-item item))
+	  item)
+	(aref dcache 1))))))
+
+(define-device-method* font-menu-font-data)
+
+;;;###autoload
+(defun font-menu-size-constructor (ignored)
+  (catch 'menu
+    (unless (console-on-window-system-p)
+      (throw 'menu '(["Cannot parse current font" ding nil])))
+    (let* ((dcache (device-fonts-cache))
+	   (font-data (font-menu-font-data 'default dcache))
+	   (entry  (aref font-data 0))
+	   (family (aref font-data 1))
+	   (size   (aref font-data 2))
+	   ;;(weight (aref font-data 3))
+	   s)
+      (unless family
+	(throw 'menu '(["Cannot parse current font" ding nil])))
+      ;; Items on the Size menu are enabled iff current font has
+      ;; that size.  Only the size of the current font is selected.
+      ;; (If the current font comes in size 0, it is scalable, and
+      ;; thus has every size.)
+      (mapcar
+       (lambda (item)
+	 (setq s (nth 3 (aref item 1)))
+	 (if (or (member s (aref entry 2))
+		 (and (not font-menu-ignore-scaled-fonts)
+		      (member 0 (aref entry 2))))
+	     (enable-menu-item item)
+	   (disable-menu-item item))
+	 (if (eq size s)
+	     (select-toggle-menu-item item)
+	   (deselect-toggle-menu-item item))
+	 item)
+       (aref dcache 2)))))
+
+;;;###autoload
+(defun font-menu-weight-constructor (ignored)
+  (catch 'menu
+    (unless (console-on-window-system-p)
+      (throw 'menu '(["Cannot parse current font" ding nil])))
+    (let* ((dcache (device-fonts-cache))
+	   (font-data (font-menu-font-data 'default dcache))
+	   (entry  (aref font-data 0))
+	   (family (aref font-data 1))
+	   ;;(size   (aref font-data 2))
+	   (weight (aref font-data 3))
+	   w)
+      (unless family
+	(throw 'menu '(["Cannot parse current font" ding nil])))
+      ;; Items on the Weight menu are enabled iff current font
+      ;; has that weight.  Only the weight of the current font
+      ;; is selected.
+      (mapcar
+       (lambda (item)
+	 (setq w (aref item 0))
+	 (if (member w (aref entry 1))
+	     (enable-menu-item item)
+	   (disable-menu-item item))
+	 (if (string-equal weight w)
+	     (select-toggle-menu-item item)
+	   (deselect-toggle-menu-item item))
+	 item)
+       (aref dcache 3)))))
+
+
+;;; Changing font sizes
+
+(defun font-menu-set-font (family weight size)
+  ;; This is what gets run when an item is selected from any of the three
+  ;; fonts menus.  It needs to be rather clever.
+  ;; (size is measured in 10ths of points.)
+  (let* ((dcache (device-fonts-cache))
+	 (font-data (font-menu-font-data 'default dcache))
+	 (from-family (aref font-data 1))
+	 (from-size   (aref font-data 2))
+	 (from-weight (aref font-data 3))
+	 (from-slant  (aref font-data 4))
+	 (face-list-to-change (delq 'default (face-list)))
+	 new-default-face-font
+	 new-props)
+    (unless from-family
+      (signal 'error '("couldn't parse font name for default face")))
+    (when weight
+      (signal 'error '("Setting weight currently not supported")))
+    (setq new-default-face-font
+	  (font-menu-load-font 
+	   (or family from-family)
+	   (or weight from-weight)
+	   (or size   from-size)
+	   from-slant
+	   (specifier-instance
+	    font-menu-preferred-resolution (selected-device))))
+    ;; This is such a gross hack. The border-glyph face under
+    ;; mswindows is in a symbol font. Thus it will not appear in the
+    ;; cache - being a junk family.  What we should do is change the
+    ;; size but not the family, but this is more work than I care to
+    ;; invest at the moment.
+    (when (eq (device-type) 'mswindows)
+      (setq face-list-to-change
+	    (delq 'border-glyph face-list-to-change)))
+    (dolist (face face-list-to-change)
+      (when (face-font-instance face)
+	(message "Changing font of `%s'..." face)
+	(condition-case c
+	    (font-menu-change-face face
+				   from-family from-weight from-size
+				   family      weight      size)
+	  (error
+	   (display-error c nil)
+	   (sit-for 1)))))
+    ;; Set the default face's font after hacking the other faces, so that
+    ;; the frame size doesn't change until we are all done.
+
+    ;; If we need to be frame local we do the changes ourselves.
+    (if font-menu-this-frame-only-p
+    ;;; WMP - we need to honor font-menu-this-frame-only-p here!
+	(set-face-font 'default new-default-face-font
+		       (and font-menu-this-frame-only-p (selected-frame)))
+      ;; OK Let Customize do it.
+      (when (and family (not (equal family from-family)))
+	(setq new-props (append (list :family family) new-props)))
+      (when (and size (not (equal size from-size)))
+	(setq new-props (append
+	   (list :size (concat (int-to-string (/ size (specifier-instance
+						       font-menu-size-scaling
+						       (selected-device)))) "pt")) new-props)))
+      (custom-set-face-update-spec 'default '((type x)) new-props)
+      (message "Font %s" (face-font-name 'default)))))
+
+
+(defun font-menu-change-face (face
+			      from-family from-weight from-size
+			      to-family   to-weight   to-size)
+  (or (symbolp face) (signal 'wrong-type-argument (list 'symbolp face)))
+  (let* ((dcache (device-fonts-cache))
+	 (font-data (font-menu-font-data face dcache))
+	 (face-family (aref font-data 1))
+	 (face-size   (aref font-data 2))
+	 (face-weight (aref font-data 3))
+	 (face-slant  (aref font-data 4)))
+
+    (or face-family
+	(signal 'error (list "couldn't parse font name for face" face)))
+
+    ;; If this face matches the old default face in the attribute we
+    ;; are changing, then change it to the new attribute along that
+    ;; dimension.  Also, the face must have its own global attribute.
+    ;; If its value is inherited, we don't touch it.  If any of this
+    ;; is not true, we leave it alone.
+    (when (and (face-font face 'global)
+	       (cond 
+		(to-family (string-equal face-family from-family))
+		(to-weight (string-equal face-weight from-weight))
+		(to-size   (=            face-size   from-size))))
+      (set-face-font face
+		     (font-menu-load-font (or to-family face-family)
+					  (or to-weight face-weight)
+					  (or to-size   face-size)
+					  face-slant
+					  (specifier-instance
+					   font-menu-preferred-resolution 
+					   (selected-device)))
+		     (and font-menu-this-frame-only-p
+			  (selected-frame))))))
+
+(define-device-method font-menu-load-font)
+
+(defun flush-device-fonts-cache (device)
+  ;; by Stig@hackvan.com
+  (let ((elt (assq device device-fonts-cache)))
+    (and elt
+	 (setq device-fonts-cache (delq elt device-fonts-cache)))))
+
+(add-hook 'delete-device-hook 'flush-device-fonts-cache)
+
+(provide 'font-menu)
+
+;; font-menu ends here
--- a/lisp/info.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/info.el	Mon Aug 13 11:21:38 2007 +0200
@@ -2074,9 +2074,9 @@
 	       (not (eq Info-auto-advance t))
 	       (not (eq last-command this-command)))
 	  (message "Hit %s again to go to previous node"
-		   (if (= last-command-char 0)
+		   (if (mouse-event-p last-command-event)
 		       "mouse button"
-		     (key-description (char-to-string last-command-char))))
+		     (key-description (event-key last-command-event))))
 	(Info-page-prev)
 	(setq this-command 'Info))
     (scroll-down arg)))
--- a/lisp/ldap.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/ldap.el	Mon Aug 13 11:21:38 2007 +0200
@@ -5,7 +5,7 @@
 ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
 ;; Created: Jan 1998
-;; Version: $Revision: 1.7.2.4 $
+;; Version: $Revision: 1.7.2.5 $
 ;; Keywords: help comm
 
 ;; This file is part of XEmacs
@@ -145,14 +145,301 @@
 				   (integer :tag "(number of records)")))))
 :group 'ldap)
 
+(defcustom ldap-ignore-attribute-codings nil
+  "*If non-nil, do not perform any encoding/decoding on LDAP attribute values."
+  :type 'boolean
+  :group 'ldap)
+
+(defcustom ldap-default-attribute-decoder nil
+  "*Decoder function to use for attributes whose syntax is unknown."
+  :type 'symbol
+  :group 'ldap)
+
+(defcustom ldap-coding-system (if (featurep 'mule)
+				  'utf-8
+				nil)
+  "*Coding system of LDAP string values.
+LDAP v3 specifies the coding system of strings to be UTF-8.  
+Mule support is needed for this."
+  :type 'symbol
+  :group 'ldap)
+
+(defvar ldap-attribute-syntax-encoders
+  [nil					; 1  ACI Item                        N  
+   nil					; 2  Access Point                    Y  
+   nil					; 3  Attribute Type Description      Y  
+   nil					; 4  Audio                           N  
+   nil					; 5  Binary                          N  
+   nil					; 6  Bit String                      Y  
+   ldap-encode-boolean			; 7  Boolean                         Y  
+   nil					; 8  Certificate                     N  
+   nil					; 9  Certificate List                N  
+   nil					; 10 Certificate Pair                N  
+   ldap-encode-country-string		; 11 Country String                  Y  
+   ldap-encode-string			; 12 DN                              Y  
+   nil					; 13 Data Quality Syntax             Y  
+   nil					; 14 Delivery Method                 Y  
+   ldap-encode-string			; 15 Directory String                Y  
+   nil					; 16 DIT Content Rule Description    Y  
+   nil					; 17 DIT Structure Rule Description  Y  
+   nil					; 18 DL Submit Permission            Y  
+   nil					; 19 DSA Quality Syntax              Y  
+   nil					; 20 DSE Type                        Y  
+   nil					; 21 Enhanced Guide                  Y  
+   nil					; 22 Facsimile Telephone Number      Y  
+   nil					; 23 Fax                             N  
+   nil					; 24 Generalized Time                Y  
+   nil					; 25 Guide                           Y  
+   nil					; 26 IA5 String                      Y  
+   number-to-string			; 27 INTEGER                         Y  
+   nil					; 28 JPEG                            N  
+   nil					; 29 Master And Shadow Access Points Y  
+   nil					; 30 Matching Rule Description       Y  
+   nil					; 31 Matching Rule Use Description   Y  
+   nil					; 32 Mail Preference                 Y  
+   nil					; 33 MHS OR Address                  Y  
+   nil					; 34 Name And Optional UID           Y  
+   nil					; 35 Name Form Description           Y  
+   nil					; 36 Numeric String                  Y  
+   nil					; 37 Object Class Description        Y  
+   nil					; 38 OID                             Y  
+   nil					; 39 Other Mailbox                   Y  
+   nil					; 40 Octet String                    Y  
+   ldap-encode-address			; 41 Postal Address                  Y  
+   nil					; 42 Protocol Information            Y  
+   nil					; 43 Presentation Address            Y  
+   ldap-encode-string			; 44 Printable String                Y  
+   nil					; 45 Subtree Specification           Y  
+   nil					; 46 Supplier Information            Y  
+   nil					; 47 Supplier Or Consumer            Y  
+   nil					; 48 Supplier And Consumer           Y  
+   nil					; 49 Supported Algorithm             N  
+   nil					; 50 Telephone Number                Y  
+   nil					; 51 Teletex Terminal Identifier     Y  
+   nil					; 52 Telex Number                    Y  
+   nil					; 53 UTC Time                        Y  
+   nil					; 54 LDAP Syntax Description         Y  
+   nil					; 55 Modify Rights                   Y  
+   nil					; 56 LDAP Schema Definition          Y  
+   nil					; 57 LDAP Schema Description         Y  
+   nil					; 58 Substring Assertion             Y  
+   ]  
+  "A vector of functions used to encode LDAP attribute values.
+The sequence of functions corresponds to the sequence of LDAP attribute syntax
+object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in 
+RFC2252 section 4.3.2")
+
+(defvar ldap-attribute-syntax-decoders
+  [nil					; 1  ACI Item                        N  
+   nil					; 2  Access Point                    Y  
+   nil					; 3  Attribute Type Description      Y  
+   nil					; 4  Audio                           N  
+   nil					; 5  Binary                          N  
+   nil					; 6  Bit String                      Y  
+   ldap-decode-boolean			; 7  Boolean                         Y  
+   nil					; 8  Certificate                     N  
+   nil					; 9  Certificate List                N  
+   nil					; 10 Certificate Pair                N  
+   ldap-decode-string			; 11 Country String                  Y  
+   ldap-decode-string			; 12 DN                              Y  
+   nil					; 13 Data Quality Syntax             Y  
+   nil					; 14 Delivery Method                 Y  
+   ldap-decode-string			; 15 Directory String                Y  
+   nil					; 16 DIT Content Rule Description    Y  
+   nil					; 17 DIT Structure Rule Description  Y  
+   nil					; 18 DL Submit Permission            Y  
+   nil					; 19 DSA Quality Syntax              Y  
+   nil					; 20 DSE Type                        Y  
+   nil					; 21 Enhanced Guide                  Y  
+   nil					; 22 Facsimile Telephone Number      Y  
+   nil					; 23 Fax                             N  
+   nil					; 24 Generalized Time                Y  
+   nil					; 25 Guide                           Y  
+   nil					; 26 IA5 String                      Y  
+   string-to-number			; 27 INTEGER                         Y  
+   nil					; 28 JPEG                            N  
+   nil					; 29 Master And Shadow Access Points Y  
+   nil					; 30 Matching Rule Description       Y  
+   nil					; 31 Matching Rule Use Description   Y  
+   nil					; 32 Mail Preference                 Y  
+   nil					; 33 MHS OR Address                  Y  
+   nil					; 34 Name And Optional UID           Y  
+   nil					; 35 Name Form Description           Y  
+   nil					; 36 Numeric String                  Y  
+   nil					; 37 Object Class Description        Y  
+   nil					; 38 OID                             Y  
+   nil					; 39 Other Mailbox                   Y  
+   nil					; 40 Octet String                    Y  
+   ldap-decode-address			; 41 Postal Address                  Y  
+   nil					; 42 Protocol Information            Y  
+   nil					; 43 Presentation Address            Y  
+   ldap-decode-string			; 44 Printable String                Y  
+   nil					; 45 Subtree Specification           Y  
+   nil					; 46 Supplier Information            Y  
+   nil					; 47 Supplier Or Consumer            Y  
+   nil					; 48 Supplier And Consumer           Y  
+   nil					; 49 Supported Algorithm             N  
+   nil					; 50 Telephone Number                Y  
+   nil					; 51 Teletex Terminal Identifier     Y  
+   nil					; 52 Telex Number                    Y  
+   nil					; 53 UTC Time                        Y  
+   nil					; 54 LDAP Syntax Description         Y  
+   nil					; 55 Modify Rights                   Y  
+   nil					; 56 LDAP Schema Definition          Y  
+   nil					; 57 LDAP Schema Description         Y  
+   nil					; 58 Substring Assertion             Y  
+   ]  
+  "A vector of functions used to decode LDAP attribute values.
+The sequence of functions corresponds to the sequence of LDAP attribute syntax
+object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in 
+RFC2252 section 4.3.2")
+
+
+(defvar ldap-attribute-syntaxes-alist
+  '((createtimestamp . 24)
+    (modifytimestamp . 24)
+    (creatorsname . 12)
+    (modifiersname . 12)
+    (subschemasubentry . 12)
+    (attributetypes . 3)
+    (objectclasses . 37)
+    (matchingrules . 30)
+    (matchingruleuse . 31)
+    (namingcontexts . 12)
+    (altserver . 26)
+    (supportedextension . 38)
+    (supportedcontrol . 38)
+    (supportedsaslmechanisms . 15)
+    (supportedldapversion . 27)
+    (ldapsyntaxes . 16)
+    (ditstructurerules . 17)
+    (nameforms . 35)
+    (ditcontentrules . 16)
+    (objectclass . 38)
+    (aliasedobjectname . 12)
+    (cn . 15)
+    (sn . 15)
+    (serialnumber . 44)
+    (c . 15)
+    (l . 15)
+    (st . 15)
+    (street . 15)
+    (o . 15)
+    (ou . 15)
+    (title . 15)
+    (description . 15)
+    (searchguide . 25)
+    (businesscategory . 15)
+    (postaladdress . 41)
+    (postalcode . 15)
+    (postofficebox . 15)
+    (physicaldeliveryofficename . 15)
+    (telephonenumber . 50)
+    (telexnumber . 52)
+    (telexterminalidentifier . 51)
+    (facsimiletelephonenumber . 22)
+    (x121address . 36)
+    (internationalisdnnumber . 36)
+    (registeredaddress . 41)
+    (destinationindicator . 44)
+    (preferreddeliverymethod . 14)
+    (presentationaddress . 43)
+    (supportedapplicationcontext . 38)
+    (member . 12)
+    (owner . 12)
+    (roleoccupant . 12)
+    (seealso . 12)
+    (userpassword . 40)
+    (usercertificate . 8)
+    (cacertificate . 8)
+    (authorityrevocationlist . 9)
+    (certificaterevocationlist . 9)
+    (crosscertificatepair . 10)
+    (name . 15)
+    (givenname . 15)
+    (initials . 15)
+    (generationqualifier . 15)
+    (x500uniqueidentifier . 6)
+    (dnqualifier . 44)
+    (enhancedsearchguide . 21)
+    (protocolinformation . 42)
+    (distinguishedname . 12)
+    (uniquemember . 34)
+    (houseidentifier . 15)
+    (supportedalgorithms . 49)
+    (deltarevocationlist . 9)
+    (dmdname . 15))
+  "A map of LDAP attribute names to their type object id minor number.
+This table is built from RFC2252 Section 5 and RFC2256 Section 5")
+
+
+;; Coding/decoding functions
+
+(defun ldap-encode-boolean (bool)
+  (if bool
+      "TRUE"
+    "FALSE"))
+
+(defun ldap-decode-boolean (str)
+  (cond
+   ((string-equal str "TRUE")
+    t)
+   ((string-equal str "FALSE")
+    nil)
+   (t
+    (error "Wrong LDAP boolean string: %s" str))))
+    
+(defun ldap-encode-country-string (str)
+  ;; We should do something useful here...
+  (if (not (= 2 (length str)))
+      (error "Invalid country string: %s" str)))
+
+(defun ldap-decode-string (str)
+  (decode-coding-string str ldap-coding-system))
+
+(defun ldap-encode-string (str)
+  (encode-coding-string str ldap-coding-system))
+
+(defun ldap-decode-address (str)
+  (mapconcat 'ldap-decode-string
+	     (split-string str "\\$")
+	     "\n"))
+
+(defun ldap-encode-address (str)
+  (mapconcat 'ldap-encode-string
+	     (split-string str "\n")
+	     "$"))
+
+
+;; LDAP protocol functions
+    
 (defun ldap-get-host-parameter (host parameter)
   "Get the value of PARAMETER for HOST in `ldap-host-parameters-alist'."
   (plist-get (cdr (assoc host ldap-host-parameters-alist))
 	     parameter))
 	
+(defun ldap-decode-attribute (attr)
+  "Decode the attribute/value pair ATTR according to LDAP rules.
+The attribute name is looked up in `ldap-attribute-syntaxes-alist' 
+and the corresponding decoder is then retrieved from 
+`ldap-attribute-syntax-decoders' and applied on the value(s)."
+  (let* ((name (car attr))
+	 (values (cdr attr))
+	 (syntax-id (cdr (assq (intern (downcase name))
+			       ldap-attribute-syntaxes-alist)))
+	 decoder)
+    (if syntax-id
+	(setq decoder (aref ldap-attribute-syntax-decoders
+			    (1- syntax-id)))
+      (setq decoder ldap-default-attribute-decoder))
+    (if decoder
+	(cons name (mapcar decoder values))
+      attr)))
+    
+
 (defun ldap-search (filter &optional host attributes attrsonly withdn)
   "Perform an LDAP search.
-FILTER is the search filter in RFC1558 syntax, i.e. something that
+FILTER is the search filter in RFC1558 syntax, i.e., something that
 looks like \"(cn=John Smith)\".
 HOST is the LDAP host on which to perform the search.
 ATTRIBUTES is a list of attributes to retrieve; nil means retrieve all.
@@ -167,19 +454,25 @@
 entry according to the value of WITHDN."
   (interactive "sFilter:")
   (or host
-      (setq host ldap-default-host))
-  (or host
+      (setq host ldap-default-host)
       (error "No LDAP host specified"))
   (let ((host-plist (cdr (assoc host ldap-host-parameters-alist)))
-	ldap)
+	ldap
+	result)
     (message "Opening LDAP connection to %s..." host)
     (setq ldap (ldap-open host host-plist))
     (message "Searching with LDAP on %s..." host)
-    (prog1 (ldap-search-internal ldap filter 
-				 (plist-get host-plist 'base)
-				 (plist-get host-plist 'scope)
-				 attributes attrsonly withdn)
-      (ldap-close ldap))))
+    (setq result (ldap-search-internal ldap filter 
+				       (plist-get host-plist 'base)
+				       (plist-get host-plist 'scope)
+				       attributes attrsonly withdn))
+    (ldap-close ldap)
+    (if ldap-ignore-attribute-codings
+	result
+      (mapcar (function 
+	       (lambda (record)
+		 (mapcar 'ldap-decode-attribute record)))
+	      result))))
 
 (provide 'ldap)
 		
--- a/lisp/loadup.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/loadup.el	Mon Aug 13 11:21:38 2007 +0200
@@ -117,7 +117,7 @@
 	      ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name)))
 	      nil)))
 
-	(load (concat default-directory "../lisp/dumped-lisp.el"))
+	(load (expand-file-name "../lisp/dumped-lisp.el"))
 
 	(let ((files preloaded-file-list)
 	      file)
--- a/lisp/make-docfile.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/make-docfile.el	Mon Aug 13 11:21:38 2007 +0200
@@ -91,7 +91,7 @@
  (nconc load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH"))))
 
 (let (preloaded-file-list)
-  (load (concat default-directory "../lisp/dumped-lisp.el"))
+  (load (expand-file-name "../lisp/dumped-lisp.el"))
 
   (let ((package-preloaded-file-list
 	 (packages-collect-package-dumped-lisps late-package-load-path)))
--- a/lisp/mouse.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/mouse.el	Mon Aug 13 11:21:38 2007 +0200
@@ -84,11 +84,48 @@
   "Function that is called upon by `mouse-yank' to actually insert text.")
 
 (defun mouse-consolidated-yank ()
+  "Insert the current selection or, if there is none under X insert the X cutbuffer.
+A mark is pushed, so that the inserted text lies between point and mark."
   (interactive)
-  (case (device-type)
-    (x (x-yank-function))
-    (tty (yank))
-    (otherwise (yank))))
+  (if (not (console-on-window-system-p))
+      (yank)
+    (push-mark)
+    (if (region-active-p)
+	(if (consp zmacs-region-extent)
+	    ;; pirated code from insert-rectangle in rect.el
+	    ;; perhaps that code should be modified to handle a list of extents
+	    ;; as the rectangle to be inserted?
+	    (let ((lines zmacs-region-extent)
+		  (insertcolumn (current-column))
+		  (first t))
+	      (push-mark)
+	      (while lines
+		(or first
+		    (progn
+		      (forward-line 1)
+		      (or (bolp) (insert ?\n))
+		      (move-to-column insertcolumn t)))
+		(setq first nil)
+		(insert (extent-string (car lines)))
+		(setq lines (cdr lines))))
+	  (insert (extent-string zmacs-region-extent)))
+      (insert-selection t))))
+
+(defun insert-selection (&optional check-cutbuffer-p move-point-event)
+  "Insert the current selection into buffer at point."
+  (interactive "P")
+  (let ((text (if check-cutbuffer-p
+		  (or (condition-case () (get-selection) (error ()))
+		      (get-cutbuffer)
+		      (error "No selection or cut buffer available"))
+		(get-selection))))
+    (cond (move-point-event
+	   (mouse-set-point move-point-event)
+	   (push-mark (point)))
+	  ((interactive-p)
+	   (push-mark (point))))
+    (insert text)
+    ))
 
 
 (defun mouse-select ()
--- a/lisp/msw-faces.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/msw-faces.el	Mon Aug 13 11:21:38 2007 +0200
@@ -39,6 +39,19 @@
 (defun mswindows-init-frame-faces (frame)
   )
 
+;; Other functions expect these regexps
+(defconst mswindows-font-regexp
+  (let
+      ((- 		":")
+       (fontname	"\\([a-zA-Z ]+\\)")
+       (weight	"\\([a-zA-Z]*\\)?")
+       (style	"\\( [a-zA-Z]*\\)?")
+       (pointsize	"\\([0-9]+\\)?")
+       (effects	"\\([a-zA-Z ]*\\)?")
+       (charset	"\\([a-zA-Z 0-9]*\\)")
+       )
+    (concat "^"
+	    fontname - weight style - pointsize - effects - charset "$")))
 
 ;;; Fill in missing parts of a font spec. This is primarily intended as a
 ;;; helper function for the functions below.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/msw-font-menu.el	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,213 @@
+;; msw-font-menu.el --- Managing menus of mswindows fonts.
+
+;; Copyright (C) 1999 Free Software Foundation, Inc.
+
+;; Adapted from x-font-menu.el by Andy Piper <andy@xemacs.org>
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; mswindows fonts look like:
+;;;	fontname[:[weight][ style][:pointsize[:effects]]][:charset]
+;;; ie:
+;;;	Lucida Console:Regular:10
+;;; minimal:
+;;;	Courier New
+;;; maximal:
+;;;	Courier New:Bold Italic:10:underline strikeout:western
+
+;;; Code:
+
+;; #### - implement these...
+;;
+;;; (defvar font-menu-ignore-proportional-fonts nil
+;;;   "*If non-nil, then the font menu will only show fixed-width fonts.")
+
+(require 'font-menu)
+
+(defvar mswindows-font-menu-registry-encoding nil
+  "Registry and encoding to use with font menu fonts.")
+
+(defvar mswindows-font-menu-junk-families
+  (purecopy
+   (mapconcat
+    #'identity
+    '("Symbol" 
+      )
+    "\\|"))
+  "A regexp matching font families which are uninteresting (e.g. cursor fonts).")
+
+(defvar mswindows-font-regexp-ascii nil
+  "This is used to filter out font families that can't display ASCII text.
+It must be set at run-time.")
+
+;;;###autoload
+(defun mswindows-reset-device-font-menus (device &optional debug)
+  "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."
+  (unless mswindows-font-regexp-ascii
+    (setq mswindows-font-regexp-ascii (if (featurep 'mule)
+					  (charset-registry 'ascii)
+					"Western")))
+  (setq mswindows-font-menu-registry-encoding (if (featurep 'mule) "" "Western"))
+  (let ((case-fold-search t)
+	family size weight entry
+	dev-cache cache families sizes weights)
+    (dolist (name (cond ((null debug)	; debugging kludge
+			 (list-fonts "::::" device))
+			((stringp debug) (split-string debug "\n"))
+			(t debug)))
+      (when (and (string-match mswindows-font-regexp-ascii name)
+		 (string-match mswindows-font-regexp name))
+	(setq weight (capitalize (match-string 2 name))
+	      size   (string-to-int (or (match-string 4 name) "0"))
+	      family (match-string 1 name))
+	(unless (string-match mswindows-font-menu-junk-families family)
+	  (setq entry (or (vassoc name cache)
+			  (car (setq cache
+				     (cons (vector family nil nil t)
+					   cache)))))
+	  (or (member family families) (push family families))
+	  (or (member weight weights)  (push weight weights))
+	  (or (member size   sizes)    (push size   sizes))
+	  (or (member weight (aref entry 1)) (push weight (aref entry 1)))
+	  (or (member size   (aref entry 2)) (push size   (aref entry 2))))))
+      ;;
+      ;; Hack scalable fonts.
+      ;; Some fonts come only in scalable versions (the only size is 0)
+      ;; and some fonts come in both scalable and non-scalable versions
+      ;; (one size is 0).  If there are any scalable fonts at all, make
+      ;; sure that the union of all point sizes contains at least some
+      ;; common sizes - it's possible that some sensible sizes might end
+      ;; up not getting mentioned explicitly.
+      ;;
+      (if (member 0 sizes)
+	  (let ((common '(6 8 10 12 14 16 18 24)))
+	    (while common
+	      (or;;(member (car common) sizes)   ; not enough slack
+	       (let ((rest sizes)
+		     (done nil))
+		 (while (and (not done) rest)
+		   (if (and (> (car common) (- (car rest) 1))
+			    (< (car common) (+ (car rest) 1)))
+		       (setq done t))
+		   (setq rest (cdr rest)))
+		 done)
+	       (setq sizes (cons (car common) sizes)))
+	      (setq common (cdr common)))
+	    (setq sizes (delq 0 sizes))))
+
+      (setq families (sort families 'string-lessp)
+	    weights  (sort weights 'string-lessp)
+	    sizes    (sort sizes '<))
+      
+      (dolist (entry cache)
+	(aset entry 1 (sort (aref entry 1) 'string-lessp))
+	(aset entry 2 (sort (aref entry 2) '<)))
+
+      (setq dev-cache (assq device device-fonts-cache))
+      (or dev-cache
+	  (setq dev-cache (car (push (list device) device-fonts-cache))))
+      (setcdr
+       dev-cache
+       (vector
+	cache
+	(mapcar (lambda (x)
+		  (vector x
+			  (list 'font-menu-set-font x nil nil)
+			  ':style 'radio ':active nil ':selected nil))
+		families)
+	(mapcar (lambda (x)
+		  (vector (int-to-string x)
+			  (list 'font-menu-set-font nil nil x)
+			  ':style 'radio ':active nil ':selected nil))
+		sizes)
+	(mapcar (lambda (x)
+		  (vector x
+			  (list 'font-menu-set-font nil x nil)
+			  ':style 'radio ':active nil ':selected nil))
+		weights)))
+      (cdr dev-cache)))
+
+;; Extract font information from a face.  We examine both the
+;; user-specified font name and the canonical (`true') font name.
+;; These can appear to have totally different properties.
+
+;; We use the user-specified one if possible, else use the truename.
+;; If the user didn't specify one get the truename and use the
+;; possibly suboptimal data from that.
+;;;###autoload
+(defun* mswindows-font-menu-font-data (face dcache)
+  (let* ((case-fold-search t)
+	 (domain (if font-menu-this-frame-only-p
+				  (selected-frame)
+				(selected-device)))
+	 (name (font-instance-name (face-font-instance face domain)))
+	 (truename (font-instance-truename
+		    (face-font-instance face domain
+					(if (featurep 'mule) 'ascii))))
+	 family size weight entry slant)
+    (when (string-match mswindows-font-regexp name)
+      (setq family (match-string 1 name))
+      (setq entry (vassoc family (aref dcache 0))))
+    (when (and (null entry)
+	       (string-match mswindows-font-regexp truename))
+      (setq family (match-string 1 truename))
+      (setq entry  (vassoc family (aref dcache 0))))
+    (when (null entry)
+      (return-from mswindows-font-menu-font-data (make-vector 5 nil)))
+    
+    (when (string-match mswindows-font-regexp name)
+      (setq weight (match-string 2 name))
+      (setq size   (string-to-int (match-string 4 name))))
+      
+    (when (string-match mswindows-font-regexp truename)
+      (when (not (member weight (aref entry 1)))
+	(setq weight (match-string 2 truename)))
+      (when (not (member size   (aref entry 2)))
+	(setq size (string-to-int (match-string 4 truename))))
+      (setq slant (match-string 5 truename)))
+      
+    (vector entry family size weight slant)))
+
+(defun mswindows-font-menu-load-font (family weight size slant resolution)
+  "Try to load a font with the requested properties.
+The weight, slant and resolution are only hints."
+  (when (integerp size) (setq size (int-to-string size)))
+  (let (font)
+    (catch 'got-font
+      (dolist (weight (list weight ""))
+	(dolist (slant
+		 ;; oblique is not currently implemented
+		 (cond ((string-equal slant "Oblique") '(" Italic" ""))
+		       ((string-equal slant "Italic") '(" Italic" ""))
+		       (t (list slant ""))))
+	  (when (setq font
+		      (make-font-instance
+		       (concat  family ":" weight slant ":"
+				size "::"
+				mswindows-font-menu-registry-encoding)
+		       nil t))
+	    (throw 'got-font font)))))))
+
+(provide 'mswindows-font-menu)
+
+;;; msw-font-menu.el ends here
--- a/lisp/msw-select.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/msw-select.el	Mon Aug 13 11:21:38 2007 +0200
@@ -49,61 +49,6 @@
 	(insert-rectangle clip)
       (insert clip))))
 
-(defun mswindows-own-clipboard (string)
-  "Paste the given string to the mswindows clipboard."
-  (mswindows-set-clipboard string))
 
-(defvar mswindows-selection-owned-p nil
-  "Whether we have a selection or not. 
-MS-Windows has no concept of ownership; don't use this.")
-
-(defun mswindows-own-selection (data &optional type)
-  "Make an MS-Windows selection of type TYPE and value DATA.
-The argument TYPE is ignored, 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).
-
-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*.
-Thus, editing done in the buffer after you specify the selection
-can alter the effective value of the selection.
-
-The data may also be a vector of valid non-vector selection values.
 
-Interactively, the text of the region is used as the selection value."
-  (interactive (if (not current-prefix-arg)
-		   (list (read-string "Store text for pasting: "))
-		 (list (substring (region-beginning) (region-end)))))
-  (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)))
-  (if data
-      (progn
-;	(mswindows-set-clipboard data)
-	(setq mswindows-selection-owned-p data))
-    (setq mswindows-selection-owned-p nil))
-  (setq primary-selection-extent
-	(select-make-extent-for-selection
-	 data primary-selection-extent))
-  (setq zmacs-region-stays t)
-  data)
 
-(defun mswindows-disown-selection (&optional secondary-p)
-  "Assuming we own the selection, disown it.  With an argument, discard the
-secondary selection instead of the primary selection."
-  (setq mswindows-selection-owned-p nil)
-  (mswindows-delete-selection))
-
-(defun mswindows-selection-owner-p (&optional selection)
-  "Return t if current emacs process owns the given Selection.
-The arg is ignored."
-  (not (eq mswindows-selection-owned-p nil)))
-
--- a/lisp/mule/mule-charset.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/mule/mule-charset.el	Mon Aug 13 11:21:38 2007 +0200
@@ -1,8 +1,12 @@
 ;;; mule-charset.el --- Charset functions for Mule.
+
 ;; Copyright (C) 1992 Free Software Foundation, Inc.
 ;; Copyright (C) 1995 Amdahl Corporation.
 ;; Copyright (C) 1996 Sun Microsystems.
 
+;; Author: Unknown
+;; Keywords: i18n, mule, internal
+
 ;; This file is part of XEmacs.
 
 ;; XEmacs is free software; you can redistribute it and/or modify it
@@ -20,40 +24,14 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-
-;;;; Composite character support
+;;; Synched up with: Not synched.  API at source level synched with FSF 20.3.9.
 
-(defun compose-region (start end &optional buffer)
-  "Compose characters in the current region into one composite character.
-From a Lisp program, pass two arguments, START to END.
-The composite character replaces the composed characters.
-BUFFER defaults to the current buffer if omitted."
-  (interactive "r")
-  (let ((ch (make-composite-char (buffer-substring start end buffer))))
-    (delete-region start end buffer)
-    (insert-char ch nil nil buffer)))
+;;; Commentary:
 
-(defun decompose-region (start end &optional buffer)
-  "Decompose any composite characters in the current region.
-From a Lisp program, pass two arguments, START to END.
-This converts each composite character into one or more characters,
-the individual characters out of which the composite character was formed.
-Non-composite characters are left as-is.  BUFFER defaults to the current
-buffer if omitted."
-  (interactive "r")
-  (save-excursion
-    (set-buffer buffer)
-    (save-restriction
-      (narrow-to-region start end)
-      (goto-char (point-min))
-      (let ((compcharset (get-charset 'composite)))
-	(while (< (point) (point-max))
-	  (let ((ch (char-after (point))))
-	    (if (eq compcharset (char-charset ch))
-		(progn
-		  (delete-char 1)
-		  (insert (composite-char-string ch))))))))))
+;; These functions are not compatible at the bytecode level with Emacs/Mule,
+;; and they never will be.  -sb [1999-05-26]
 
+;;; Code:
 
 ;;;; Classifying text according to charsets
 
@@ -116,10 +94,15 @@
 be automatically determined)."
   (charset-property charset 'columns))
 
+;; #### FSFmacs returns 0
 (defun charset-direction (charset)
-  "Return the display direction (`l2r' or `r2l') of CHARSET."
-  (charset-property charset 'direction))
+  "Return the display direction (0 for `l2r' or 1 for `r2l') of CHARSET.
+Only left-to-right is currently implemented."
+  (if (eq (charset-property charset 'direction) 'l2r)
+      0
+    1))
 
+;; Not in Emacs/Mule
 (defun charset-registry (charset)
   "Return the registry of CHARSET.
 This is a regular expression matching the registry field of fonts
@@ -144,3 +127,126 @@
 
 (defsetf charset-registry    set-charset-registry)
 (defsetf charset-ccl-program set-charset-ccl-program)
+
+;;; FSF compatibility functions
+(defun charset-after (&optional pos)
+  "Return charset of a character in current buffer at position POS.
+If POS is nil, it defauls to the current point.
+If POS is out of range, the value is nil."
+  (when (null pos)
+    (setq pos (point)))
+  (check-argument-type 'integerp pos)
+  (unless (or (< pos (point-min))
+	      (> pos (point-max)))
+    (char-charset (char-after pos))))
+
+;; Yuck!
+;; We're not going to support this.
+;(defun charset-info (charset)
+;  "Return a vector of information of CHARSET.
+;The elements of the vector are:
+;        CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
+;        LEADING-CODE-BASE, LEADING-CODE-EXT,
+;        ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
+;        REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
+;        PLIST,
+;where
+;CHARSET-ID (integer) is the identification number of the charset.
+;BYTES (integer) is the length of multi-byte form of a character in
+;  the charset: one of 1, 2, 3, and 4.
+;DIMENSION (integer) is the number of bytes to represent a character of
+;the charset: 1 or 2.
+;CHARS (integer) is the number of characters in a dimension: 94 or 96.
+;WIDTH (integer) is the number of columns a character in the charset
+;  occupies on the screen: one of 0, 1, and 2.
+;DIRECTION (integer) is the rendering direction of characters in the
+;  charset when rendering.  If 0, render from left to right, else
+;  render from right to left.
+;LEADING-CODE-BASE (integer) is the base leading-code for the
+;  charset.
+;LEADING-CODE-EXT (integer) is the extended leading-code for the
+;  charset.  All charsets of less than 0xA0 has the value 0.
+;ISO-FINAL-CHAR (character) is the final character of the
+;  corresponding ISO 2022 charset.
+;ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
+;  while encoding to variants of ISO 2022 coding system, one of the
+;  following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
+;REVERSE-CHARSET (integer) is the charset which differs only in
+;  LEFT-TO-RIGHT value from the charset.  If there's no such a
+;  charset, the value is -1.
+;SHORT-NAME (string) is the short name to refer to the charset.
+;LONG-NAME (string) is the long name to refer to the charset
+;DESCRIPTION (string) is the description string of the charset.
+;PLIST (property list) may contain any type of information a user
+;  want to put and get by functions `put-charset-property' and
+;  `get-charset-property' respectively."
+;  (vector
+;   (charset-id charset)
+;   1
+;   (charset-dimension charset)
+;   (charset-chars charset)
+;   (charset-width charset)
+;   (charset-direction charset)
+;   nil ;; (charset-leading-code-base (charset))
+;   nil ;; (charset-leading-code-ext (charset))
+;   (charset-iso-final-char charset)
+;   (charset-iso-graphic-plane charset)
+;   -1
+;   (charset-short-name charset)
+;   (charset-long-name charset)
+;   (charset-description charset)
+;   (charset-plist charset)))
+
+;(make-compatible 'charset-info "Don't use this if you can help it.")
+
+(defun define-charset (charset-id charset property-vector)
+  "Define CHARSET-ID as the identification number of CHARSET with INFO-VECTOR.
+If CHARSET-ID is nil, it is decided automatically, which means CHARSET is
+ treated as a private charset.
+INFO-VECTOR is a vector of the format:
+   [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
+    SHORT-NAME LONG-NAME DESCRIPTION]
+The meanings of each elements is as follows:
+DIMENSION (integer) is the number of bytes to represent a character: 1 or 2.
+CHARS (integer) is the number of characters in a dimension: 94 or 96.
+WIDTH (integer) is the number of columns a character in the charset
+occupies on the screen: one of 0, 1, and 2.
+
+DIRECTION (integer) is the rendering direction of characters in the
+charset when rendering.  If 0, render from left to right, else
+render from right to left.
+
+ISO-FINAL-CHAR (character) is the final character of the
+corresponding ISO 2022 charset.
+
+ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
+while encoding to variants of ISO 2022 coding system, one of the
+following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
+
+
+SHORT-NAME (string) is the short name to refer to the charset.
+
+LONG-NAME (string) is the long name to refer to the charset.
+
+DESCRIPTION (string) is the description string of the charset."
+  (make-charset charset (aref property-vector 8)
+		(list
+		 'short-name (aref property-vector 6)
+		 'long-name (aref property-vector 7)
+		 'dimension (aref property-vector 0)
+		 'columns (aref property-vector 2)
+		 'chars (aref property-vector 1)
+		 'final (aref property-vector 4)
+		 'graphic (aref property-vector 5)
+		 'direction (aref property-vector 3))))
+
+(make-compatible 'define-charset "")
+
+;;; Charset property
+
+(defalias 'get-charset-property 'get)
+(defalias 'put-charset-property 'put)
+(defalias 'charset-plist 'object-plist)
+(defalias 'set-charset-plist 'setplist)
+
+;;; mule-charset.el ends here
--- a/lisp/mule/mule-cmds.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/mule/mule-cmds.el	Mon Aug 13 11:21:38 2007 +0200
@@ -390,6 +390,8 @@
 					nil t nil 'input-method-history)
 		       ;;default)
 		       ))
+    (if (string-equal input-method "")
+	(setq input-method default))
     (if (> (length input-method) 0)
 	input-method
       (if inhibit-null
--- a/lisp/mule/mule-files.el	Mon Aug 13 11:20:44 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-;;; mule-files.el --- File I/O functions for XEmacs/Mule.
-
-;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
-;; Copyright (C) 1995 Amdahl Corporation.
-;; Copyright (C) 1995 Sun Microsystems.
-
-;; 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.
-
-;;; Commentary:
-
-;;; Derived from mule.el in the original Mule but heavily modified
-;;; by Ben Wing. Mostly moved to code-files.el
-
-;; 1997/3/11 modified by MORIOKA Tomohiko to sync with Emacs 20 API.
-
-;;; Code:
-
-(setq-default buffer-file-coding-system 'iso-2022-8)
-
-;;; mule-files.el ends here
--- a/lisp/select.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/select.el	Mon Aug 13 11:21:38 2007 +0200
@@ -32,32 +32,31 @@
 
 ;;; Code:
 
+(defvar selected-text-type
+  (if (featurep 'mule) '(COMPOUND_TEXT STRING) 'STRING)
+  "The type atom used to obtain selections from the X server.
+Can be either a valid X selection data type, or a list of such types.
+COMPOUND_TEXT and STRING are the most commonly used data types.
+If a list is provided, the types are tried in sequence until
+there is a successful conversion.")
+
 (defun copy-primary-selection ()
   "Copy the selection to the Clipboard and the kill ring."
   (interactive)
   (and (console-on-window-system-p)
        (cut-copy-clear-internal 'copy)))
-(define-obsolete-function-alias
-  'x-copy-primary-selection
-  'copy-primary-selection)
 
 (defun kill-primary-selection ()
   "Copy the selection to the Clipboard and the kill ring, then delete it."
   (interactive "*")
   (and (console-on-window-system-p)
        (cut-copy-clear-internal 'cut)))
-(define-obsolete-function-alias
-  'x-kill-primary-selection
-  'kill-primary-selection)
 
 (defun delete-primary-selection ()
   "Delete the selection without copying it to the Clipboard or the kill ring."
   (interactive "*")
   (and (console-on-window-system-p)
        (cut-copy-clear-internal 'clear)))
-(define-obsolete-function-alias
-  'x-delete-primary-selection
-  'delete-primary-selection)
 
 (defun yank-clipboard-selection ()
   "Insert the current Clipboard selection at point."
@@ -67,30 +66,34 @@
     (mswindows (mswindows-paste-clipboard))
     (otherwise nil)))
 
-(defun selection-owner-p (&optional selection)
-  "Return t if current XEmacs process owns 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.)"
-  (interactive)
-  (case (device-type (selected-device))
-    (x (x-selection-owner-p selection))
-    (mswindows (mswindows-selection-owner-p selection))
-    (otherwise nil)))
+(define-device-method get-cutbuffer
+  "Return the value of one of the cut buffers.
+This will do nothing under anything other than X.")
 
-(defun selection-exists-p (&optional selection)
-  "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."
-  (interactive)
-  (case (device-type (selected-device))
-    (x (x-selection-exists-p selection))
-    (mswindows (mswindows-selection-exists-p))
-    (otherwise nil)))
+(defun get-selection (&optional type data-type)
+  "Return the value of a Windows selection.
+The argument TYPE (default `PRIMARY') says which selection,
+and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
+says how to convert the data."
+  (or type (setq type 'PRIMARY))
+  (or data-type (setq data-type selected-text-type))
+  (let ((text
+	 (if (consp data-type)
+	     (condition-case err
+		 (get-selection-internal type (car data-type))
+	       (selection-conversion-error
+		(if (cdr data-type)
+		    (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
+;; arguments (duh ...).  This order is more logical.
 (defun own-selection (data &optional type)
   "Make an Windows selection of type TYPE and value DATA.
 The argument TYPE (default `PRIMARY') says which selection,
@@ -109,26 +112,64 @@
   (interactive (if (not current-prefix-arg)
 		   (list (read-string "Store text for pasting: "))
 		 (list (substring (region-beginning) (region-end)))))
-  (case (device-type (selected-device))
-    (x (x-own-selection data type))
-    (mswindows (mswindows-own-selection data type))
-    (otherwise nil)))
+  ;FSFmacs huh??  It says:
+  ;; "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))
+  (if data
+      (own-selection-internal type data)
+    (disown-selection-internal type))
+  (cond ((eq type 'PRIMARY)
+	 (setq primary-selection-extent
+	       (select-make-extent-for-selection
+		data primary-selection-extent)))
+	((eq type 'SECONDARY)
+	 (setq secondary-selection-extent
+	       (select-make-extent-for-selection
+		data secondary-selection-extent))))
+  (setq zmacs-region-stays t)
+  data)
+
+(defun dehilight-selection (selection)
+  "for use as a value of `lost-selection-hooks'."
+  (cond ((eq selection 'PRIMARY)
+	 (if primary-selection-extent
+	     (let ((inhibit-quit t))
+	       (if (consp primary-selection-extent)
+		   (mapcar 'delete-extent primary-selection-extent)
+		 (delete-extent primary-selection-extent))
+	       (setq primary-selection-extent nil)))
+	 (if zmacs-regions (zmacs-deactivate-region)))
+	((eq selection 'SECONDARY)
+	 (if secondary-selection-extent
+	     (let ((inhibit-quit t))
+	       (if (consp secondary-selection-extent)
+		   (mapcar 'delete-extent secondary-selection-extent)
+		 (delete-extent secondary-selection-extent))
+	       (setq secondary-selection-extent nil)))))
+  nil)
+
+(setq lost-selection-hooks 'dehilight-selection)
 
 (defun own-clipboard (string)
-  "Paste the given string to the Clipboard."
-  (case (device-type (selected-device))
-    (x (x-own-clipboard string))
-    (mswindows (mswindows-own-clipboard string))
-    (otherwise nil)))
+  "Paste the given string to the X Clipboard."
+  (own-selection string 'CLIPBOARD))
 
 (defun disown-selection (&optional secondary-p)
   "Assuming we own the selection, disown it.  With an argument, discard the
 secondary selection instead of the primary selection."
-  (case (device-type (selected-device))
-    (x (x-disown-selection secondary-p))
-    (mswindows (mswindows-disown-selection secondary-p))
-    (otherwise nil)))
-
+  (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY)))
 
 ;; from x-init.el
 ;; selections and active regions
@@ -218,9 +259,6 @@
 	  (default-mouse-track-next-move-rect start end previous-extent)
 	  ))
 	previous-extent))))
-(define-obsolete-function-alias
-  'x-select-make-extent-for-selection
-  'select-make-extent-for-selection)
 
 ;; moved from x-select.el
 (defun valid-simple-selection-p (data)
@@ -242,9 +280,6 @@
 	       (marker-buffer (cdr data)))
 	   (buffer-live-p (marker-buffer (car data)))
 	   (buffer-live-p (marker-buffer (cdr data))))))
-(define-obsolete-function-alias
-  'x-valid-simple-selection-p
-  'valid-simple-selection-p)
 
 (defun cut-copy-clear-internal (mode)
   (or (memq mode '(cut copy clear)) (error "unkown mode %S" mode))
@@ -287,8 +322,241 @@
 	       (delete-region s e))))
       (disown-selection nil)
       )))
-(define-obsolete-function-alias
-  'x-cut-copy-clear-internal
-  'cut-copy-clear-internal)
+
+;;; 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
+
+(defun select-convert-to-text (selection type value)
+  (cond ((stringp value)
+	 value)
+	((extentp value)
+	 (save-excursion
+	   (set-buffer (extent-object value))
+	   (save-restriction
+	     (widen)
+	     (buffer-substring (extent-start-position value)
+			       (extent-end-position value)))))
+	((and (consp value)
+	      (markerp (car value))
+	      (markerp (cdr value)))
+	 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
+	     (signal 'error
+		     (list "markers must be in the same buffer"
+			   (car value) (cdr value))))
+	 (save-excursion
+	   (set-buffer (or (marker-buffer (car value))
+			   (error "selection is in a killed buffer")))
+	   (save-restriction
+	     (widen)
+	     (buffer-substring (car value) (cdr value)))))
+	(t nil)))
+
+(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.
+    (if (stringp outval)
+	(cons 'STRING outval)
+      outval)))
+
+(defun select-convert-to-compound-text (selection type value)
+  ;; converts to compound text automatically
+  (select-convert-to-text selection type value))
+
+(defun select-convert-to-length (selection type value)
+  (let ((value
+	 (cond ((stringp value)
+		(length value))
+	       ((extentp value)
+		(extent-length value))
+	       ((and (consp value)
+		     (markerp (car value))
+		     (markerp (cdr value)))
+		(or (eq (marker-buffer (car value))
+			(marker-buffer (cdr value)))
+		    (signal 'error
+			    (list "markers must be in the same buffer"
+				  (car value) (cdr value))))
+		(abs (- (car value) (cdr value)))))))
+    (if value ; force it to be in 32-bit format.
+	(cons (ash value -16) (logand value 65535))
+      nil)))
+
+(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)))
+	 (rest all))
+    (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)))
+
+(defun select-convert-to-delete (selection type value)
+  (disown-selection-internal selection)
+  ;; A return value of nil means that we do not know how to do this conversion,
+  ;; and replies with an "error".  A return value of NULL means that we have
+  ;; done the conversion (and any side-effects) but have no value to return.
+  'NULL)
+
+(defun select-convert-to-filename (selection type value)
+  (cond ((extentp value)
+	 (buffer-file-name (or (extent-object value)
+			       (error "selection is in a killed buffer"))))
+	((and (consp value)
+	      (markerp (car value))
+	      (markerp (cdr value)))
+	 (buffer-file-name (or (marker-buffer (car value))
+			       (error "selection is in a killed buffer"))))
+	(t nil)))
+
+(defun select-convert-to-charpos (selection type value)
+  (let (a b tmp)
+    (cond ((cond ((extentp value)
+		  (setq a (extent-start-position value)
+			b (extent-end-position value)))
+		 ((and (consp value)
+		       (markerp (car value))
+		       (markerp (cdr value)))
+		  (setq a (car value)
+			b (cdr value))))
+	   (setq a (1- a) b (1- b)) ; zero-based
+	   (if (< b a) (setq tmp a a b b tmp))
+	   (cons 'SPAN
+		 (vector (cons (ash a -16) (logand a 65535))
+			 (cons (ash b -16) (logand b 65535))))))))
+
+(defun select-convert-to-lineno (selection type value)
+  (let (a b buf tmp)
+    (cond ((cond ((extentp value)
+		  (setq buf (extent-object value)
+			a (extent-start-position value)
+			b (extent-end-position value)))
+		 ((and (consp value)
+		       (markerp (car value))
+		       (markerp (cdr value)))
+		  (setq a (marker-position (car value))
+			b (marker-position (cdr value))
+			buf (marker-buffer (car value)))))
+	   (save-excursion
+	     (set-buffer buf)
+	     (save-restriction
+	       (widen)
+	       (goto-char a)
+	       (beginning-of-line)
+	       (setq a (1+ (count-lines 1 (point))))
+	       (goto-char b)
+	       (beginning-of-line)
+	       (setq b (1+ (count-lines 1 (point))))))
+	   (if (< b a) (setq tmp a a b b tmp))
+	   (cons 'SPAN
+		 (vector (cons (ash a -16) (logand a 65535))
+			 (cons (ash b -16) (logand b 65535))))))))
+
+(defun select-convert-to-colno (selection type value)
+  (let (a b buf tmp)
+    (cond ((cond ((extentp value)
+		  (setq buf (extent-object value)
+			a (extent-start-position value)
+			b (extent-end-position value)))
+		 ((and (consp value)
+		       (markerp (car value))
+		       (markerp (cdr value)))
+		  (setq a (car value)
+			b (cdr value)
+			buf (marker-buffer a))))
+	   (save-excursion
+	     (set-buffer buf)
+	     (goto-char a)
+	     (setq a (current-column))
+	     (goto-char b)
+	     (setq b (current-column)))
+	   (if (< b a) (setq tmp a a b b tmp))
+	   (cons 'SPAN
+		 (vector (cons (ash a -16) (logand a 65535))
+			 (cons (ash b -16) (logand b 65535))))))))
+
+(defun select-convert-to-sourceloc (selection type value)
+  (let (a b buf file-name tmp)
+    (cond ((cond ((extentp value)
+		  (setq buf (or (extent-object value)
+				(error "selection is in a killed buffer"))
+			a (extent-start-position value)
+			b (extent-end-position value)
+			file-name (buffer-file-name buf)))
+		 ((and (consp value)
+		       (markerp (car value))
+		       (markerp (cdr value)))
+		  (setq a (marker-position (car value))
+			b (marker-position (cdr value))
+			buf (or (marker-buffer (car value))
+				(error "selection is in a killed buffer"))
+			file-name (buffer-file-name buf))))
+	   (save-excursion
+	     (set-buffer buf)
+	     (save-restriction
+	       (widen)
+	       (goto-char a)
+	       (beginning-of-line)
+	       (setq a (1+ (count-lines 1 (point))))
+	       (goto-char b)
+	       (beginning-of-line)
+	       (setq b (1+ (count-lines 1 (point))))))
+	   (if (< b a) (setq tmp a a b b tmp))
+	   (format "%s:%d" file-name a)))))
+
+(defun select-convert-to-os (selection type size)
+  (symbol-name system-type))
+
+(defun select-convert-to-host (selection type size)
+  (system-name))
+
+(defun select-convert-to-user (selection type size)
+  (user-full-name))
+
+(defun select-convert-to-class (selection type size)
+  x-emacs-application-class)
+
+;; We do not try to determine the name Emacs was invoked with,
+;; because it is not clean for a program's behavior to depend on that.
+(defun select-convert-to-name (selection type size)
+  ;invocation-name
+  "xemacs")
+
+(defun select-convert-to-integer (selection type value)
+  (and (integerp value)
+       (cons (ash value -16) (logand value 65535))))
+
+(defun select-convert-to-atom (selection type value)
+  (and (symbolp value) value))
+
+(defun select-convert-to-identity (selection type value) ; used internally
+  (vector value))
+
+(setq selection-converter-alist
+      '((TEXT . select-convert-to-text)
+	(STRING . select-convert-to-string)
+	(COMPOUND_TEXT . select-convert-to-compound-text)
+	(TARGETS . select-convert-to-targets)
+	(LENGTH . select-convert-to-length)
+	(DELETE . select-convert-to-delete)
+	(FILE_NAME . select-convert-to-filename)
+	(CHARACTER_POSITION . select-convert-to-charpos)
+	(SOURCE_LOC . select-convert-to-sourceloc)
+	(LINE_NUMBER . select-convert-to-lineno)
+	(COLUMN_NUMBER . select-convert-to-colno)
+	(OWNER_OS . select-convert-to-os)
+	(HOST_NAME . select-convert-to-host)
+	(USER . select-convert-to-user)
+	(CLASS . select-convert-to-class)
+	(NAME . select-convert-to-name)
+	(ATOM . select-convert-to-atom)
+	(INTEGER . select-convert-to-integer)
+	(_EMACS_INTERNAL . select-convert-to-identity)
+	))
 
 ;;; select.el ends here
--- a/lisp/startup.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/startup.el	Mon Aug 13 11:21:38 2007 +0200
@@ -200,12 +200,18 @@
     (princ (concat "\n" (emacs-version) "\n\n"))
     (princ
      (if (featurep 'x)
-	 (concat (emacs-name)
-		 " accepts all standard X Toolkit command line options.\n"
-		 "In addition, the")
+	 (concat "When creating a window on an X display, "
+		 (emacs-name)
+		 " accepts all standard X Toolkit
+command line options plus the following:
+  -iconname <title>     Use title as the icon name.
+  -mc <color>           Use color as the mouse color.
+  -cr <color>           Use color as the text-cursor foregound color.
+  -private              Install a private colormap.
+
+In addition, the")
        "The"))
     (princ " following options are accepted:
-
   -t <device>           Use TTY <device> instead of the terminal for input
                         and output.  This implies the -nw option.
   -nw                   Inhibit the use of any window-system-specific
--- a/lisp/subr.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/subr.el	Mon Aug 13 11:21:38 2007 +0200
@@ -294,10 +294,14 @@
 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
   (or pattern
       (setq pattern "[ \f\t\n\r\v]+"))
-  ;; The FSF version of this function takes care not to cons in case
-  ;; of infloop.  Maybe we should synch?
-  (let (parts (start 0))
-    (while (string-match pattern string start)
+  (let (parts (start 0) (len (length string)))
+    (if (string-match pattern string)
+	(setq parts (cons (substring string 0 (match-beginning 0)) parts)
+	      start (match-end 0)))
+    (while (and (< start len)
+		(string-match pattern string (if (> start (match-beginning 0))
+						 start
+					       (1+ start))))
       (setq parts (cons (substring string start (match-beginning 0)) parts)
 	    start (match-end 0)))
     (nreverse (cons (substring string start) parts))))
--- a/lisp/update-elc.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/update-elc.el	Mon Aug 13 11:21:38 2007 +0200
@@ -84,7 +84,7 @@
 ;; (print (prin1-to-string update-elc-files-to-compile))
 
 (let (preloaded-file-list site-load-packages)
-  (load (concat default-directory "../lisp/dumped-lisp.el"))
+  (load (expand-file-name "../lisp/dumped-lisp.el"))
 
   ;; Path setup
   (let ((package-preloaded-file-list
--- a/lisp/version.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/version.el	Mon Aug 13 11:21:38 2007 +0200
@@ -37,16 +37,19 @@
 
 (defconst emacs-version
   (purecopy
-   (format "%d.%d %s%s%s"
+   (format "%d.%d %s%s%s%s"
 	   emacs-major-version
 	   emacs-minor-version
-	   (if xemacs-codename
-	       (concat "\"" xemacs-codename "\"")
+	   (if emacs-patch-level
+	       (format "(patch %d)" emacs-patch-level)
 	     "")
-	   " XEmacs Lucid"
 	   (if xemacs-betaname
 	       (concat " " xemacs-betaname)
-	     "")))
+	     "")
+	   (if xemacs-codename
+	       (concat " \"" xemacs-codename "\"")
+	     "")
+	   " XEmacs Lucid"))
   "Version numbers of this version of XEmacs.")
 
 (if (featurep 'infodock)
@@ -107,16 +110,19 @@
        (t          (insert version-string))))))
 
 ;; from emacs-vers.el
-(defun emacs-version>= (major &optional minor)
-  "Return true if the Emacs version is >= to the given MAJOR and MINOR numbers.
-The MAJOR version number argument is required, but the MINOR version number
-argument is optional.  If the minor version number is not specified (or is the
-symbol `nil') then only the major version numbers are considered in the test."
-  (if (null minor)
-      (>= emacs-major-version major)
-    (or (> emacs-major-version major)
-	(and (=  emacs-major-version major)
-	     (>= emacs-minor-version minor)))))
+(defun emacs-version>= (major &optional minor patch)
+  "Return true if the Emacs version is >= to the given MAJOR, MINOR,
+   and PATCH numbers.
+The MAJOR version number argument is required, but the other arguments
+argument are optional. Only the Non-nil arguments are used in the test."
+  (let ((emacs-patch (or emacs-patch-level emacs-beta-version -1)))
+    (cond ((> emacs-major-version major))
+	  ((< emacs-major-version major) nil)
+	  ((null minor))
+	  ((> emacs-minor-version minor))
+	  ((< emacs-minor-version minor) nil)
+	  ((null patch))
+	  ((>= emacs-patch patch)))))
 
 ;;; We hope that this alias is easier for people to find.
 (define-function 'version 'emacs-version)
--- a/lisp/x-font-menu.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/x-font-menu.el	Mon Aug 13 11:21:38 2007 +0200
@@ -7,6 +7,7 @@
 ;; Author: Jamie Zawinski <jwz@netscape.com>
 ;; Restructured by: Jonathan Stigelman <Stig@hackvan.com>
 ;; Mule-ized by: Martin Buchholz
+;; More restructuring for MS-Windows by Andy Piper <andy@xemacs.org>
 
 ;; This file is part of XEmacs.
 
@@ -24,105 +25,6 @@
 ;; along with XEmacs; see the file COPYING.  If not, write to the 
 ;; Free Software Foundation, 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;;
-;;; Creates three menus, "Font", "Size", and "Weight", and puts them on the
-;;; "Options" menu.  The contents of these menus are the superset of those
-;;; properties available on any fonts, but only the intersection of the three
-;;; sets is selectable at one time.
-;;;
-;;; Known Problems:
-;;; ===============
-;;; Items on the Font menu are selectable if and only if that font exists in
-;;; the same size and weight as the current font.  This means that some fonts
-;;; are simply not reachable from some other fonts - if only one font comes
-;;; in only one point size (like "Nil", which comes only in 2), you will never
-;;; be able to select it.  It would be better if the items on the Fonts menu
-;;; were always selectable, and selecting them would set the size to be the
-;;; closest size to the current font's size.
-;;;
-;;; This attempts to change all other faces in an analagous way to the change
-;;; that was made to the default face; if it can't, it will skip over the face.
-;;; However, this could leave incongruous font sizes around, which may cause
-;;; some nonreversibility problems if further changes are made.  Perhaps it
-;;; should remember the initial fonts of all faces, and derive all subsequent
-;;; fonts from that initial state.
-;;;
-;;; xfontsel(1) is a lot more flexible (but probably harder to understand).
-;;;
-;;; The code to construct menus from all of the x11 fonts available from the
-;;; server is autoloaded and executed the very first time that one of the Font
-;;; menus is selected on each device.  That is, if XEmacs has frames on two
-;;; different devices, then separate font menu information will be maintained
-;;; for each X display.  If the font path changes after emacs has already
-;;; asked the X server on a particular display for its list of fonts, this
-;;; won't notice.  Also, the first time that a font menu is posted on each
-;;; display will entail a lengthy delay, but that's better than slowing down
-;;; XEmacs startup.  At any time (i.e.: after a font-path change or
-;;; immediately after device creation), you can call
-;;; `reset-device-font-menus' to rebuild the menus from all currently
-;;; available fonts.
-;;;
-;;; There is knowledge here about the regexp match numbers in
-;;; `x-font-regexp' and `x-font-regexp-foundry-and-family' defined in
-;;; x-faces.el.
-;;;
-;;; There are at least three kinds of fonts under X11r5:
-;;;
-;;; - bitmap fonts, which can be assumed to look as good as possible;
-;;; - bitmap fonts which have been (or can be) automatically scaled to
-;;;   a new size, and which almost always look awful;
-;;; - and true outline fonts, which should look ok at any size, but in
-;;;   practice (on at least some systems) look awful at any size, and
-;;;   even in theory are unlikely ever to look as good as non-scaled
-;;;   bitmap fonts.
-;;;
-;;; It would be nice to get this code to look for non-scaled bitmap fonts
-;;; first, then outline fonts, then scaled bitmap fonts as a last resort.
-;;; But it's not clear to me how to tell them apart based on their truenames
-;;; and/or the result of XListFonts().  I welcome any and all explanations
-;;; of the subtleties involved...
-;;;
-;;;
-;;; If You Think You'Re Seeing A Bug:
-;;; =================================
-;;; When reporting problems, send the following information:
-;;;
-;;; - Exactly what behavior you're seeing;
-;;; - The output of the `xlsfonts' program;
-;;; - The value of the variable `device-fonts-cache';
-;;; - The values of the following expressions, both before and after
-;;;   making a selection from any of the fonts-related menus:
-;;;	(face-font 'default)
-;;;	(font-truename   (face-font 'default))
-;;;	(font-properties (face-font 'default))
-;;; - The values of the following variables after making a selection:
-;;;	font-menu-preferred-resolution
-;;;	font-menu-registry-encoding
-;;;
-;;; There is a common misconception that "*-courier-medium-r-*-11-*", also
-;;; known as "-adobe-courier-medium-r-normal--11-80-100-100-m-60-iso8859-1",
-;;; is an 11-point font.  It is not -- it is an 11-pixel font at 100dpi,
-;;; which is an 8-point font (the number after -11- is the size in tenths
-;;; of points).  So if you expect to be seeing an "11" entry in the "Size"
-;;; menu and are not, this may be why.
-;;;
-;;; In the real world (aka Solaris), one has to deal with fonts that
-;;; appear to be medium-i but are really light-r, and fonts that
-;;; resolve to different resolutions depending on the charset:
-;;;
-;;; (font-instance-truename
-;;;  (make-font-instance "-*-mincho-medium-i-normal-*-*-*-*-*-*-*-jisx0201*-*"))
-;;; ==>
-;;; "-morisawa-ryumin light kl-light-r-normal--10-100-72-72-m-50-jisx0201.1976-0"
-;;;
-;;; (list-fonts "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*")
-;;; ==>
-;;; ("-dt-interface user-medium-r-normal-s sans-12-120-72-72-m-70-iso8859-1"
-;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-120-jisx0208.1983-0"
-;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-60-jisx0201.1976-0")
-
 ;;; Code:
 
 ;; #### - implement these...
@@ -130,57 +32,12 @@
 ;;; (defvar font-menu-ignore-proportional-fonts nil
 ;;;   "*If non-nil, then the font menu will only show fixed-width fonts.")
 
-(defgroup font-menu ()
-  "Settings for the font menu"
-  :group 'x)
-
-;;;###autoload
-(defcustom font-menu-ignore-scaled-fonts t
-  "*If non-nil, then the font menu will try to show only bitmap fonts."
-  :type 'boolean
-  :group 'font-menu)
-
-;;;###autoload
-(defcustom font-menu-this-frame-only-p nil
-  "*If non-nil, then changing the default font from the font menu will only
-affect one frame instead of all frames."
-  :type 'boolean
-  :group 'font-menu)
+(require 'font-menu)
 
-(defcustom font-menu-max-items 25
-  "*Maximum number of items in the font menu
-If number of entries in a menu is larger than this value, split menu
-into submenus of nearly equal length.  If nil, never split menu into
-submenus."
-  :group 'font-menu
-  :type '(choice (const :tag "no submenus" nil)
-		 (integer)))
-
-(defcustom font-menu-submenu-name-format "%-12.12s ... %.12s"
-  "*Format specification of the submenu name.
-Used by `font-menu-split-long-menu' if the number of entries in a menu is
-larger than `font-menu-menu-max-items'.
-This string should contain one %s for the name of the first entry and
-one %s for the name of the last entry in the submenu.
-If the value is a function, it should return the submenu name.  The
-function is be called with two arguments, the names of the first and
-the last entry in the menu."
-  :group 'font-menu
-  :type '(choice (string :tag "Format string")
-		 (function)))
-
-
-;; only call XListFonts (and parse) once per device.
-;; ( (device . [parsed-list-fonts family-menu size-menu weight-menu]) ...)
-(defvar device-fonts-cache nil)
-
-(defvar font-menu-registry-encoding nil
+(defvar x-font-menu-registry-encoding nil
   "Registry and encoding to use with font menu fonts.")
 
-(defvar font-menu-preferred-resolution "*-*"
-  "Preferred horizontal and vertical font menu resolution (e.g. \"75-75\").")
-
-(defvar fonts-menu-junk-families
+(defvar x-fonts-menu-junk-families
   (purecopy
    (mapconcat
     #'identity
@@ -194,11 +51,6 @@
     "\\|"))
   "A regexp matching font families which are uninteresting (e.g. cursor fonts).")
 
-(eval-when-compile
-  (defsubst device-fonts-cache ()
-    (or (cdr (assq (selected-device) device-fonts-cache))
-	(reset-device-font-menus (selected-device)))))
-
 (defun hack-font-truename (fn)
   "Filter the output of `font-instance-truename' to deal with Japanese fontsets."
   (if (string-match "," (font-instance-truename fn))
@@ -213,26 +65,12 @@
 	ret)
     (font-instance-truename fn)))
 
-;;;###autoload
-(fset 'install-font-menus 'reset-device-font-menus)
-(make-obsolete 'install-font-menus 'reset-device-font-menus)
-
 (defvar x-font-regexp-ascii nil
   "This is used to filter out font families that can't display ASCII text.
 It must be set at run-time.")
 
-(defun vassoc (key valist)
-  "Search VALIST for a vector whose first element is equal to KEY.
-See also `assoc'."
-  ;; by Stig@hackvan.com
-  (let (el)
-    (catch 'done
-      (while (setq el (pop valist))
-	(and (equal key (aref el 0))
-	     (throw 'done el))))))
-
 ;;;###autoload
-(defun reset-device-font-menus (&optional device debug)
+(defun x-reset-device-font-menus (device &optional debug)
   "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
@@ -242,107 +80,100 @@
   ;; by Stig@hackvan.com
   ;; #### - this should implement a `menus-only' option, which would
   ;; recalculate the menus from the cache w/o having to do list-fonts again.
-  (message "Getting list of fonts from server... ")
-  (if (or noninteractive
-	  (not (or device (setq device (selected-device))))
-	  (not (eq (device-type device) 'x)))
-      nil
-    (unless x-font-regexp-ascii
-      (setq x-font-regexp-ascii (if (featurep 'mule)
-				    (charset-registry 'ascii)
-				  "iso8859-1")))
-    (setq font-menu-registry-encoding
-	  (if (featurep 'mule) "*-*" "iso8859-1"))
-    (let ((case-fold-search t)
-	  family size weight entry monospaced-p
-	  dev-cache cache families sizes weights)
-      (dolist (name (cond ((null debug)	; debugging kludge
-			   (list-fonts "*-*-*-*-*-*-*-*-*-*-*-*-*-*" device))
-			  ((stringp debug) (split-string debug "\n"))
-			  (t debug)))
-	(when (and (string-match x-font-regexp-ascii name)
-		   (string-match x-font-regexp name))
-	  (setq weight (capitalize (match-string 1 name))
-		size   (string-to-int (match-string 6 name)))
-	  (or (string-match x-font-regexp-foundry-and-family name)
-	      (error "internal error"))
-	  (setq family (capitalize (match-string 1 name)))
-	  (or (string-match x-font-regexp-spacing name)
-	      (error "internal error"))
-	  (setq monospaced-p (string= "m" (match-string 1 name)))
-	  (unless (string-match fonts-menu-junk-families family)
-	    (setq entry (or (vassoc family cache)
-			    (car (setq cache
-				       (cons (vector family nil nil t)
-					     cache)))))
-	    (or (member family families) (push family families))
-	    (or (member weight weights)  (push weight weights))
-	    (or (member size   sizes)    (push size   sizes))
-	    (or (member weight (aref entry 1)) (push weight (aref entry 1)))
-	    (or (member size   (aref entry 2)) (push size   (aref entry 2)))
-	    (aset entry 3 (and (aref entry 3) monospaced-p)))))
-      ;;
-      ;; Hack scalable fonts.
-      ;; Some fonts come only in scalable versions (the only size is 0)
-      ;; and some fonts come in both scalable and non-scalable versions
-      ;; (one size is 0).  If there are any scalable fonts at all, make
-      ;; sure that the union of all point sizes contains at least some
-      ;; common sizes - it's possible that some sensible sizes might end
-      ;; up not getting mentioned explicitly.
-      ;;
-      (if (member 0 sizes)
-	  (let ((common '(60 80 100 120 140 160 180 240)))
-	    (while common
-	      (or;;(member (car common) sizes)   ; not enough slack
-	       (let ((rest sizes)
-		     (done nil))
-		 (while (and (not done) rest)
-		   (if (and (> (car common) (- (car rest) 5))
-			    (< (car common) (+ (car rest) 5)))
-		       (setq done t))
-		   (setq rest (cdr rest)))
-		 done)
-	       (setq sizes (cons (car common) sizes)))
-	      (setq common (cdr common)))
-	    (setq sizes (delq 0 sizes))))
+  (unless x-font-regexp-ascii
+    (setq x-font-regexp-ascii (if (featurep 'mule)
+				  (charset-registry 'ascii)
+				"iso8859-1")))
+  (setq x-font-menu-registry-encoding
+	(if (featurep 'mule) "*-*" "iso8859-1"))
+  (let ((case-fold-search t)
+	family size weight entry monospaced-p
+	dev-cache cache families sizes weights)
+    (dolist (name (cond ((null debug)	; debugging kludge
+			 (list-fonts "*-*-*-*-*-*-*-*-*-*-*-*-*-*" device))
+			((stringp debug) (split-string debug "\n"))
+			(t debug)))
+      (when (and (string-match x-font-regexp-ascii name)
+		 (string-match x-font-regexp name))
+	(setq weight (capitalize (match-string 1 name))
+	      size   (string-to-int (match-string 6 name)))
+	(or (string-match x-font-regexp-foundry-and-family name)
+	    (error "internal error"))
+	(setq family (capitalize (match-string 1 name)))
+	(or (string-match x-font-regexp-spacing name)
+	    (error "internal error"))
+	(setq monospaced-p (string= "m" (match-string 1 name)))
+	(unless (string-match x-fonts-menu-junk-families family)
+	  (setq entry (or (vassoc family cache)
+			  (car (setq cache
+				     (cons (vector family nil nil t)
+					   cache)))))
+	  (or (member family families) (push family families))
+	  (or (member weight weights)  (push weight weights))
+	  (or (member size   sizes)    (push size   sizes))
+	  (or (member weight (aref entry 1)) (push weight (aref entry 1)))
+	  (or (member size   (aref entry 2)) (push size   (aref entry 2)))
+	  (aset entry 3 (and (aref entry 3) monospaced-p)))))
+    ;;
+    ;; Hack scalable fonts.
+    ;; Some fonts come only in scalable versions (the only size is 0)
+    ;; and some fonts come in both scalable and non-scalable versions
+    ;; (one size is 0).  If there are any scalable fonts at all, make
+    ;; sure that the union of all point sizes contains at least some
+    ;; common sizes - it's possible that some sensible sizes might end
+    ;; up not getting mentioned explicitly.
+    ;;
+    (if (member 0 sizes)
+	(let ((common '(60 80 100 120 140 160 180 240)))
+	  (while common
+	    (or;;(member (car common) sizes)   ; not enough slack
+	     (let ((rest sizes)
+		   (done nil))
+	       (while (and (not done) rest)
+		 (if (and (> (car common) (- (car rest) 5))
+			  (< (car common) (+ (car rest) 5)))
+		     (setq done t))
+		 (setq rest (cdr rest)))
+	       done)
+	     (setq sizes (cons (car common) sizes)))
+	    (setq common (cdr common)))
+	  (setq sizes (delq 0 sizes))))
+    
+    (setq families (sort families 'string-lessp)
+	  weights  (sort weights 'string-lessp)
+	  sizes    (sort sizes '<))
+    
+    (dolist (entry cache)
+      (aset entry 1 (sort (aref entry 1) 'string-lessp))
+      (aset entry 2 (sort (aref entry 2) '<)))
 
-      (setq families (sort families 'string-lessp)
-	    weights  (sort weights 'string-lessp)
-	    sizes    (sort sizes '<))
-
-      (dolist (entry cache)
-	  (aset entry 1 (sort (aref entry 1) 'string-lessp))
-	  (aset entry 2 (sort (aref entry 2) '<)))
-
-      (message "Getting list of fonts from server... done.")
-
-      (setq dev-cache (assq device device-fonts-cache))
-      (or dev-cache
-	  (setq dev-cache (car (push (list device) device-fonts-cache))))
-      (setcdr
-       dev-cache
-       (vector
-	cache
-	(mapcar (lambda (x)
-		  (vector x
-			  (list 'font-menu-set-font x nil nil)
-			  ':style 'radio ':active nil ':selected nil))
-		families)
-	(mapcar (lambda (x)
-		  (vector (if (/= 0 (% x 10))
-			      ;; works with no LISP_FLOAT_TYPE
-			      (concat (int-to-string (/ x 10)) "."
-				      (int-to-string (% x 10)))
-			    (int-to-string (/ x 10)))
-			  (list 'font-menu-set-font nil nil x)
-			  ':style 'radio ':active nil ':selected nil))
-		sizes)
-	(mapcar (lambda (x)
-		  (vector x
-			  (list 'font-menu-set-font nil x nil)
-			  ':style 'radio ':active nil ':selected nil))
-		weights)))
-      (cdr dev-cache))))
+    (setq dev-cache (assq device device-fonts-cache))
+    (or dev-cache
+	(setq dev-cache (car (push (list device) device-fonts-cache))))
+    (setcdr
+     dev-cache
+     (vector
+      cache
+      (mapcar (lambda (x)
+		(vector x
+			(list 'font-menu-set-font x nil nil)
+			':style 'radio ':active nil ':selected nil))
+	      families)
+      (mapcar (lambda (x)
+		(vector (if (/= 0 (% x 10))
+			    ;; works with no LISP_FLOAT_TYPE
+			    (concat (int-to-string (/ x 10)) "."
+				    (int-to-string (% x 10)))
+			  (int-to-string (/ x 10)))
+			(list 'font-menu-set-font nil nil x)
+			':style 'radio ':active nil ':selected nil))
+	      sizes)
+      (mapcar (lambda (x)
+		(vector x
+			(list 'font-menu-set-font nil x nil)
+			':style 'radio ':active nil ':selected nil))
+	      weights)))
+    (cdr dev-cache)))
 
 ;; Extract font information from a face.  We examine both the
 ;; user-specified font name and the canonical (`true') font name.
@@ -352,7 +183,8 @@
 ;; We use the user-specified one if possible, else use the truename.
 ;; If the user didn't specify one (with "-dt-*-*", for example)
 ;; get the truename and use the possibly suboptimal data from that.
-(defun* font-menu-font-data (face dcache)
+;;;###autoload
+(defun* x-font-menu-font-data (face dcache)
   (let* ((case-fold-search t)
 	 (domain (if font-menu-this-frame-only-p
 				  (selected-frame)
@@ -370,7 +202,7 @@
       (setq family (capitalize (match-string 1 truename)))
       (setq entry  (vassoc family (aref dcache 0))))
     (when (null entry)
-      (return-from font-menu-font-data (make-vector 5 nil)))
+      (return-from x-font-menu-font-data (make-vector 5 nil)))
     
     (when (string-match x-font-regexp name)
       (setq weight (capitalize    (match-string 1 name)))
@@ -385,229 +217,7 @@
       
     (vector entry family size weight slant)))
 
-(defun font-menu-split-long-menu (menu)
-  "Split MENU according to `font-menu-max-items'."
-  (let ((len (length menu)))
-    (if (or (null font-menu-max-items)
-	    (null (featurep 'lisp-float-type))
-	    (<= len font-menu-max-items))
-	menu
-      ;; Submenu is max 2 entries longer than menu, never shorter, number of
-      ;; entries in submenus differ by at most one (with longer submenus first)
-      (let* ((outer (floor (sqrt len)))
-	     (inner (/ len outer))
-	     (rest (% len outer))
-	     (result nil))
-	(setq menu (reverse menu))
-	(while menu
-	  (let ((in inner)
-		(sub nil)
-		(to (car menu)))
-	    (while (> in 0)
-	      (setq in   (1- in)
-		    sub  (cons (car menu) sub)
-		    menu (cdr menu)))
-	    (setq result
-		  (cons (cons (if (stringp font-menu-submenu-name-format)
-				  (format font-menu-submenu-name-format
-					  (aref (car sub) 0) (aref to 0))
-				(funcall font-menu-submenu-name-format
-					 (aref (car sub) 0) (aref to 0)))
-			      sub)
-			result)
-		  rest  (1+ rest))
-	    (if (= rest outer) (setq inner (1+ inner)))))
-	result))))
-
-;;;###autoload
-(defun font-menu-family-constructor (ignored)
-  (catch 'menu
-    (unless (eq 'x (device-type (selected-device)))
-      (throw 'menu '(["Cannot parse current font" ding nil])))
-    (let* ((dcache (device-fonts-cache))
-	   (font-data (font-menu-font-data 'default dcache))
-	   (entry  (aref font-data 0))
-	   (family (aref font-data 1))
-	   (size   (aref font-data 2))
-	   (weight (aref font-data 3))
-	   f)
-      (unless family
-	(throw 'menu '(["Cannot parse current font" ding nil])))
-      ;; Items on the Font menu are enabled iff that font exists in
-      ;; the same size and weight as the current font (scalable fonts
-      ;; exist in every size).  Only the current font is marked as
-      ;; selected.
-      (font-menu-split-long-menu
-       (mapcar
-	(lambda (item)
-	  (setq f (aref item 0)
-		entry (vassoc f (aref dcache 0)))
-	  ;; The user can no longer easily control the weight using the menu
-	  ;; Note it is silly anyway as it could very well be that the font
-	  ;; has no common size+weight combinations with the default font.
-;;	  (if (and (member weight (aref entry 1))
-;;		   (or (member size (aref entry 2))
-;;		       (and (not font-menu-ignore-scaled-fonts)
-;;			    (member 0 (aref entry 2)))))
-;;	      (enable-menu-item item)
-;;	    (disable-menu-item item))
-	  (if (and font-menu-ignore-scaled-fonts (member 0 (aref entry 2)))
-	      (disable-menu-item item)
-	    (enable-menu-item item))	  
-	  (if (string-equal family f)
-	      (select-toggle-menu-item item)
-	    (deselect-toggle-menu-item item))
-	  item)
-	(aref dcache 1))))))
-
-;;;###autoload
-(defun font-menu-size-constructor (ignored)
-  (catch 'menu
-    (unless (eq 'x (device-type (selected-device)))
-      (throw 'menu '(["Cannot parse current font" ding nil])))
-    (let* ((dcache (device-fonts-cache))
-	   (font-data (font-menu-font-data 'default dcache))
-	   (entry  (aref font-data 0))
-	   (family (aref font-data 1))
-	   (size   (aref font-data 2))
-	   ;;(weight (aref font-data 3))
-	   s)
-      (unless family
-	(throw 'menu '(["Cannot parse current font" ding nil])))
-      ;; Items on the Size menu are enabled iff current font has
-      ;; that size.  Only the size of the current font is selected.
-      ;; (If the current font comes in size 0, it is scalable, and
-      ;; thus has every size.)
-      (mapcar
-       (lambda (item)
-	 (setq s (nth 3 (aref item 1)))
-	 (if (or (member s (aref entry 2))
-		 (and (not font-menu-ignore-scaled-fonts)
-		      (member 0 (aref entry 2))))
-	     (enable-menu-item item)
-	   (disable-menu-item item))
-	 (if (eq size s)
-	     (select-toggle-menu-item item)
-	   (deselect-toggle-menu-item item))
-	 item)
-       (aref dcache 2)))))
-
-;;;###autoload
-(defun font-menu-weight-constructor (ignored)
-  (catch 'menu
-    (unless (eq 'x (device-type (selected-device)))
-      (throw 'menu '(["Cannot parse current font" ding nil])))
-    (let* ((dcache (device-fonts-cache))
-	   (font-data (font-menu-font-data 'default dcache))
-	   (entry  (aref font-data 0))
-	   (family (aref font-data 1))
-	   ;;(size   (aref font-data 2))
-	   (weight (aref font-data 3))
-	   w)
-      (unless family
-	(throw 'menu '(["Cannot parse current font" ding nil])))
-      ;; Items on the Weight menu are enabled iff current font
-      ;; has that weight.  Only the weight of the current font
-      ;; is selected.
-      (mapcar
-       (lambda (item)
-	 (setq w (aref item 0))
-	 (if (member w (aref entry 1))
-	     (enable-menu-item item)
-	   (disable-menu-item item))
-	 (if (string-equal weight w)
-	     (select-toggle-menu-item item)
-	   (deselect-toggle-menu-item item))
-	 item)
-       (aref dcache 3)))))
-
-
-;;; Changing font sizes
-
-(defun font-menu-set-font (family weight size)
-  ;; This is what gets run when an item is selected from any of the three
-  ;; fonts menus.  It needs to be rather clever.
-  ;; (size is measured in 10ths of points.)
-  (let* ((dcache (device-fonts-cache))
-	 (font-data (font-menu-font-data 'default dcache))
-	 (from-family (aref font-data 1))
-	 (from-size   (aref font-data 2))
-	 (from-weight (aref font-data 3))
-	 (from-slant  (aref font-data 4))
-	 new-default-face-font
-	 new-props)
-    (unless from-family
-      (signal 'error '("couldn't parse font name for default face")))
-    (when weight
-      (signal 'error '("Setting weight currently not supported")))
-    (setq new-default-face-font
-	  (font-menu-load-font (or family from-family)
-			       (or weight from-weight)
-			       (or size   from-size)
-			       from-slant
-			       font-menu-preferred-resolution))
-    (dolist (face (delq 'default (face-list)))
-      (when (face-font-instance face)
-	(message "Changing font of `%s'..." face)
-	(condition-case c
-	    (font-menu-change-face face
-				   from-family from-weight from-size
-				   family      weight      size)
-	  (error
-	   (display-error c nil)
-	   (sit-for 1)))))
-    ;; Set the default face's font after hacking the other faces, so that
-    ;; the frame size doesn't change until we are all done.
-
-    ;; If we need to be frame local we do the changes ourselves.
-    (if font-menu-this-frame-only-p
-    ;;; WMP - we need to honor font-menu-this-frame-only-p here!
-	(set-face-font 'default new-default-face-font
-		       (and font-menu-this-frame-only-p (selected-frame)))
-      ;; OK Let Customize do it.
-      (when (and family (not (equal family from-family)))
-	(setq new-props (append (list :family family) new-props)))
-      (when (and size (not (equal size from-size)))
-	(setq new-props (append
-	   (list :size (concat (int-to-string (/ size 10)) "pt")) new-props)))
-      (custom-set-face-update-spec 'default '((type x)) new-props)
-      (message "Font %s" (face-font-name 'default)))))
-
-
-(defun font-menu-change-face (face
-			      from-family from-weight from-size
-			      to-family   to-weight   to-size)
-  (or (symbolp face) (signal 'wrong-type-argument (list 'symbolp face)))
-  (let* ((dcache (device-fonts-cache))
-	 (font-data (font-menu-font-data face dcache))
-	 (face-family (aref font-data 1))
-	 (face-size   (aref font-data 2))
-	 (face-weight (aref font-data 3))
-	 (face-slant  (aref font-data 4)))
-
-    (or face-family
-	(signal 'error (list "couldn't parse font name for face" face)))
-
-    ;; If this face matches the old default face in the attribute we
-    ;; are changing, then change it to the new attribute along that
-    ;; dimension.  Also, the face must have its own global attribute.
-    ;; If its value is inherited, we don't touch it.  If any of this
-    ;; is not true, we leave it alone.
-    (when (and (face-font face 'global)
-	       (cond 
-		(to-family (string-equal face-family from-family))
-		(to-weight (string-equal face-weight from-weight))
-		(to-size   (=            face-size   from-size))))
-      (set-face-font face
-		     (font-menu-load-font (or to-family face-family)
-					  (or to-weight face-weight)
-					  (or to-size   face-size)
-					  face-slant
-					  font-menu-preferred-resolution)
-		     (and font-menu-this-frame-only-p
-			  (selected-frame))))))
-
-(defun font-menu-load-font (family weight size slant resolution)
+(defun x-font-menu-load-font (family weight size slant resolution)
   "Try to load a font with the requested properties.
 The weight, slant and resolution are only hints."
   (when (integerp size) (setq size (int-to-string size)))
@@ -627,18 +237,10 @@
 			(make-font-instance
 			 (concat  "-*-" family "-" weight "-" slant "-*-*-*-"
 				  size "-" resolution "-*-*-"
-				  font-menu-registry-encoding)
+				  x-font-menu-registry-encoding)
 			 nil t))
 	      (throw 'got-font font))))))))
 
-(defun flush-device-fonts-cache (device)
-  ;; by Stig@hackvan.com
-  (let ((elt (assq device device-fonts-cache)))
-    (and elt
-	 (setq device-fonts-cache (delq elt device-fonts-cache)))))
-
-(add-hook 'delete-device-hook 'flush-device-fonts-cache)
-
 (provide 'x-font-menu)
 
 ;;; x-font-menu.el ends here
--- a/lisp/x-mouse.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/x-mouse.el	Mon Aug 13 11:21:38 2007 +0200
@@ -36,6 +36,8 @@
 ;;(define-key global-map '(shift button2) 'x-mouse-kill)
 (define-key global-map '(control button2) 'x-set-point-and-move-selection)
 
+(define-obsolete-function-alias 'x-insert-selection 'insert-selection)
+
 (defun x-mouse-kill (event)
   "Kill the text between the point and mouse and copy it to the clipboard and
 to the cut buffer"
@@ -43,51 +45,10 @@
   (let ((old-point (point)))
     (mouse-set-point event)
     (let ((s (buffer-substring old-point (point))))
-      (x-own-clipboard s)
+      (own-clipboard s)
       (x-store-cutbuffer s))
     (kill-region old-point (point))))
 
-(defun x-yank-function ()
-  "Insert the current X selection or, if there is none, insert the X cutbuffer.
-A mark is pushed, so that the inserted text lies between point and mark."
-  (push-mark)
-  (if (region-active-p)
-      (if (consp zmacs-region-extent)
-	  ;; pirated code from insert-rectangle in rect.el
-	  ;; perhaps that code should be modified to handle a list of extents
-	  ;; as the rectangle to be inserted?
-	  (let ((lines zmacs-region-extent)
-		(insertcolumn (current-column))
-		(first t))
-	    (push-mark)
-	    (while lines
-	      (or first
-		  (progn
-		    (forward-line 1)
-		    (or (bolp) (insert ?\n))
-		    (move-to-column insertcolumn t)))
-	      (setq first nil)
-	      (insert (extent-string (car lines)))
-	      (setq lines (cdr lines))))
-	(insert (extent-string zmacs-region-extent)))
-    (x-insert-selection t)))
-
-(defun x-insert-selection (&optional check-cutbuffer-p move-point-event)
-  "Insert the current selection into buffer at point."
-  (interactive "P")
-  (let ((text (if check-cutbuffer-p
-		  (or (condition-case () (x-get-selection) (error ()))
-		      (x-get-cutbuffer)
-		      (error "No selection or cut buffer available"))
-		(x-get-selection))))
-    (cond (move-point-event
-	   (mouse-set-point move-point-event)
-	   (push-mark (point)))
-	  ((interactive-p)
-	   (push-mark (point))))
-    (insert text)
-    ))
-
 (make-obsolete 'x-set-point-and-insert-selection 'mouse-yank)
 (defun x-set-point-and-insert-selection (event)
   "Set point where clicked and insert the primary selection or the cut buffer."
@@ -102,9 +63,9 @@
   ;; to fail; just let the appropriate error message get issued. (We need
   ;; to insert the selection and set point first, or the selection may
   ;; get inserted at the wrong place.)
-  (and (x-selection-owner-p)
+  (and (selection-owner-p)
        primary-selection-extent
-       (x-insert-selection t event))
+       (insert-selection t event))
   (kill-primary-selection))
 
 (defun mouse-track-and-copy-to-cutbuffer (event)
--- a/lisp/x-select.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/x-select.el	Mon Aug 13 11:21:38 2007 +0200
@@ -35,95 +35,29 @@
 
 ;;; Code:
 
-(defvar x-selected-text-type
-  (if (featurep 'mule) '(COMPOUND_TEXT STRING) 'STRING)
-  "The type atom used to obtain selections from the X server.
-Can be either a valid X selection data type, or a list of such types.
-COMPOUND_TEXT and STRING are the most commonly used data types.
-If a list is provided, the types are tried in sequence until
-there is a successful conversion.")
-
-(defun x-get-selection (&optional type data-type)
-  "Return the value of an X Windows selection.
-The argument TYPE (default `PRIMARY') says which selection,
-and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
-says how to convert the data."
-  (or type (setq type 'PRIMARY))
-  (or data-type (setq data-type x-selected-text-type))
-  (let ((text
-	 (if (consp data-type)
-	     (condition-case err
-		 (x-get-selection-internal type (car data-type))
-	       (selection-conversion-error
-		(if (cdr data-type)
-		    (x-get-selection type (cdr data-type))
-		  (signal (car err) (cdr err)))))
-	   (x-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))
+(define-obsolete-function-alias 'x-selection-exists-p 'selection-exists-p)
+(define-obsolete-function-alias 'x-selection-owner-p 'selection-owner-p)
+(define-obsolete-variable-alias 'x-selection-converter-alist 'selection-converter-alist)
+(define-obsolete-variable-alias 'x-lost-selection-hooks 'lost-selection-hooks)
+(define-obsolete-variable-alias 'x-selected-text-type 'selected-text-type)
+(define-obsolete-function-alias 'x-valid-simple-selection-p 'valid-simple-selection-p)
+(define-obsolete-function-alias 'x-own-selection 'own-selection)
+(define-obsolete-function-alias 'x-disown-selection 'disown-selection)
+(define-obsolete-function-alias 'x-delete-primary-selection 'delete-primary-selection)
+(define-obsolete-function-alias 'x-copy-primary-selection 'copy-primary-selection)
+(define-obsolete-function-alias 'x-kill-primary-selection 'kill-primary-selection)
+(define-obsolete-function-alias 'x-select-make-extent-for-selection
+  'select-make-extent-for-selection)
+(define-obsolete-function-alias 'x-cut-copy-clear-internal 'cut-copy-clear-internal)
+(define-obsolete-function-alias 'x-get-selection 'get-selection)
 
 (defun x-get-secondary-selection ()
   "Return text selected from some X window."
-  (x-get-selection 'SECONDARY))
+  (get-selection 'SECONDARY))
 
 (defun x-get-clipboard ()
   "Return text pasted to the clipboard."
-  (x-get-selection 'CLIPBOARD))
-
-;; FSFmacs calls this `x-set-selection', and reverses the
-;; arguments (duh ...).  This order is more logical.
-(defun x-own-selection (data &optional type)
-  "Make an X Windows 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).
-
-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*.
-Thus, editing done in the buffer after you specify the selection
-can alter the effective value of the selection.
-
-The data may also be a vector of valid non-vector selection values.
-
-Interactively, the text of the region is used as the selection value."
-  (interactive (if (not current-prefix-arg)
-		   (list (read-string "Store text for pasting: "))
-		 (list (substring (region-beginning) (region-end)))))
-  ;FSFmacs huh??  It says:
-  ;; "This is for temporary compatibility with pre-release Emacs 19."
-  ;(if (stringp type)
-  ;    (setq type (intern type)))
-  (or (x-valid-simple-selection-p data)
-      (and (vectorp data)
-	   (let ((valid t)
-		 (i (1- (length data))))
-	     (while (>= i 0)
-	       (or (x-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))
-  (if data
-      (x-own-selection-internal type data)
-    (x-disown-selection-internal type))
-  (cond ((eq type 'PRIMARY)
-	 (setq primary-selection-extent
-	       (select-make-extent-for-selection
-		data primary-selection-extent)))
-	((eq type 'SECONDARY)
-	 (setq secondary-selection-extent
-	       (select-make-extent-for-selection
-		data secondary-selection-extent))))
-  (setq zmacs-region-stays t)
-  data)
-
-(defun x-valid-simple-selection-p (data)
-  (valid-simple-selection-p data))
+  (get-selection 'CLIPBOARD))
 
 (defun x-own-secondary-selection (selection &optional type)
   "Make a secondary X Selection of the given argument.  The argument may be a
@@ -136,38 +70,6 @@
 			(copy-marker (mark-marker))))))
   (x-own-selection selection 'SECONDARY))
 
-
-(defun x-own-clipboard (string)
-  "Paste the given string to the X Clipboard."
-  (x-own-selection string 'CLIPBOARD))
-
-
-(defun x-disown-selection (&optional secondary-p)
-  "Assuming we own the selection, disown it.  With an argument, discard the
-secondary selection instead of the primary selection."
-  (x-disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY)))
-
-(defun x-dehilight-selection (selection)
-  "for use as a value of `x-lost-selection-hooks'."
-  (cond ((eq selection 'PRIMARY)
-	 (if primary-selection-extent
-	     (let ((inhibit-quit t))
-	       (if (consp primary-selection-extent)
-		   (mapcar 'delete-extent primary-selection-extent)
-		 (delete-extent primary-selection-extent))
-	       (setq primary-selection-extent nil)))
-	 (if zmacs-regions (zmacs-deactivate-region)))
-	((eq selection 'SECONDARY)
-	 (if secondary-selection-extent
-	     (let ((inhibit-quit t))
-	       (if (consp secondary-selection-extent)
-		   (mapcar 'delete-extent secondary-selection-extent)
-		 (delete-extent secondary-selection-extent))
-	       (setq secondary-selection-extent nil)))))
-  nil)
-
-(setq x-lost-selection-hooks 'x-dehilight-selection)
-
 (defun x-notice-selection-requests (selection type successful)
   "for possible use as the value of x-sent-selection-hooks."
   (if (not successful)
@@ -200,7 +102,7 @@
 (defun xselect-kill-buffer-hook-1 (selection)
   (let (value)
     (if (and (x-selection-owner-p selection)
-	     (setq value (x-get-selection-internal selection '_EMACS_INTERNAL))
+	     (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
@@ -262,240 +164,6 @@
     (push-mark)
     (insert clip)))
 
-;;; 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.
-
-(defun xselect-convert-to-text (selection type value)
-  (cond ((stringp value)
-	 value)
-	((extentp value)
-	 (save-excursion
-	   (set-buffer (extent-object value))
-	   (save-restriction
-	     (widen)
-	     (buffer-substring (extent-start-position value)
-			       (extent-end-position value)))))
-	((and (consp value)
-	      (markerp (car value))
-	      (markerp (cdr value)))
-	 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
-	     (signal 'error
-		     (list "markers must be in the same buffer"
-			   (car value) (cdr value))))
-	 (save-excursion
-	   (set-buffer (or (marker-buffer (car value))
-			   (error "selection is in a killed buffer")))
-	   (save-restriction
-	     (widen)
-	     (buffer-substring (car value) (cdr value)))))
-	(t nil)))
-
-(defun xselect-convert-to-string (selection type value)
-  (let ((outval (xselect-convert-to-text selection type value)))
-    ;; force the string to be not in Compound Text format.
-    (if (stringp outval)
-	(cons 'STRING outval)
-      outval)))
-
-(defun xselect-convert-to-compound-text (selection type value)
-  ;; converts to compound text automatically
-  (xselect-convert-to-text selection type value))
-
-(defun xselect-convert-to-length (selection type value)
-  (let ((value
-	 (cond ((stringp value)
-		(length value))
-	       ((extentp value)
-		(extent-length value))
-	       ((and (consp value)
-		     (markerp (car value))
-		     (markerp (cdr value)))
-		(or (eq (marker-buffer (car value))
-			(marker-buffer (cdr value)))
-		    (signal 'error
-			    (list "markers must be in the same buffer"
-				  (car value) (cdr value))))
-		(abs (- (car value) (cdr value)))))))
-    (if value ; force it to be in 32-bit format.
-	(cons (ash value -16) (logand value 65535))
-      nil)))
-
-(defun xselect-convert-to-targets (selection type value)
-  ;; return a vector of atoms, but remove duplicates first.
-  (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
-	 (rest all))
-    (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)))
-
-(defun xselect-convert-to-delete (selection type value)
-  (x-disown-selection-internal selection)
-  ;; A return value of nil means that we do not know how to do this conversion,
-  ;; and replies with an "error".  A return value of NULL means that we have
-  ;; done the conversion (and any side-effects) but have no value to return.
-  'NULL)
-
-(defun xselect-convert-to-filename (selection type value)
-  (cond ((extentp value)
-	 (buffer-file-name (or (extent-object value)
-			       (error "selection is in a killed buffer"))))
-	((and (consp value)
-	      (markerp (car value))
-	      (markerp (cdr value)))
-	 (buffer-file-name (or (marker-buffer (car value))
-			       (error "selection is in a killed buffer"))))
-	(t nil)))
-
-(defun xselect-convert-to-charpos (selection type value)
-  (let (a b tmp)
-    (cond ((cond ((extentp value)
-		  (setq a (extent-start-position value)
-			b (extent-end-position value)))
-		 ((and (consp value)
-		       (markerp (car value))
-		       (markerp (cdr value)))
-		  (setq a (car value)
-			b (cdr value))))
-	   (setq a (1- a) b (1- b)) ; zero-based
-	   (if (< b a) (setq tmp a a b b tmp))
-	   (cons 'SPAN
-		 (vector (cons (ash a -16) (logand a 65535))
-			 (cons (ash b -16) (logand b 65535))))))))
-
-(defun xselect-convert-to-lineno (selection type value)
-  (let (a b buf tmp)
-    (cond ((cond ((extentp value)
-		  (setq buf (extent-object value)
-			a (extent-start-position value)
-			b (extent-end-position value)))
-		 ((and (consp value)
-		       (markerp (car value))
-		       (markerp (cdr value)))
-		  (setq a (marker-position (car value))
-			b (marker-position (cdr value))
-			buf (marker-buffer (car value)))))
-	   (save-excursion
-	     (set-buffer buf)
-	     (save-restriction
-	       (widen)
-	       (goto-char a)
-	       (beginning-of-line)
-	       (setq a (1+ (count-lines 1 (point))))
-	       (goto-char b)
-	       (beginning-of-line)
-	       (setq b (1+ (count-lines 1 (point))))))
-	   (if (< b a) (setq tmp a a b b tmp))
-	   (cons 'SPAN
-		 (vector (cons (ash a -16) (logand a 65535))
-			 (cons (ash b -16) (logand b 65535))))))))
-
-(defun xselect-convert-to-colno (selection type value)
-  (let (a b buf tmp)
-    (cond ((cond ((extentp value)
-		  (setq buf (extent-object value)
-			a (extent-start-position value)
-			b (extent-end-position value)))
-		 ((and (consp value)
-		       (markerp (car value))
-		       (markerp (cdr value)))
-		  (setq a (car value)
-			b (cdr value)
-			buf (marker-buffer a))))
-	   (save-excursion
-	     (set-buffer buf)
-	     (goto-char a)
-	     (setq a (current-column))
-	     (goto-char b)
-	     (setq b (current-column)))
-	   (if (< b a) (setq tmp a a b b tmp))
-	   (cons 'SPAN
-		 (vector (cons (ash a -16) (logand a 65535))
-			 (cons (ash b -16) (logand b 65535))))))))
-
-(defun xselect-convert-to-sourceloc (selection type value)
-  (let (a b buf file-name tmp)
-    (cond ((cond ((extentp value)
-		  (setq buf (or (extent-object value)
-				(error "selection is in a killed buffer"))
-			a (extent-start-position value)
-			b (extent-end-position value)
-			file-name (buffer-file-name buf)))
-		 ((and (consp value)
-		       (markerp (car value))
-		       (markerp (cdr value)))
-		  (setq a (marker-position (car value))
-			b (marker-position (cdr value))
-			buf (or (marker-buffer (car value))
-				(error "selection is in a killed buffer"))
-			file-name (buffer-file-name buf))))
-	   (save-excursion
-	     (set-buffer buf)
-	     (save-restriction
-	       (widen)
-	       (goto-char a)
-	       (beginning-of-line)
-	       (setq a (1+ (count-lines 1 (point))))
-	       (goto-char b)
-	       (beginning-of-line)
-	       (setq b (1+ (count-lines 1 (point))))))
-	   (if (< b a) (setq tmp a a b b tmp))
-	   (format "%s:%d" file-name a)))))
-
-(defun xselect-convert-to-os (selection type size)
-  (symbol-name system-type))
-
-(defun xselect-convert-to-host (selection type size)
-  (system-name))
-
-(defun xselect-convert-to-user (selection type size)
-  (user-full-name))
-
-(defun xselect-convert-to-class (selection type size)
-  x-emacs-application-class)
-
-;; We do not try to determine the name Emacs was invoked with,
-;; because it is not clean for a program's behavior to depend on that.
-(defun xselect-convert-to-name (selection type size)
-  ;invocation-name
-  "xemacs")
-
-(defun xselect-convert-to-integer (selection type value)
-  (and (integerp value)
-       (cons (ash value -16) (logand value 65535))))
-
-(defun xselect-convert-to-atom (selection type value)
-  (and (symbolp value) value))
-
-(defun xselect-convert-to-identity (selection type value) ; used internally
-  (vector value))
-
-(setq selection-converter-alist
-      '((TEXT . xselect-convert-to-text)
-	(STRING . xselect-convert-to-string)
-	(COMPOUND_TEXT . xselect-convert-to-compound-text)
-	(TARGETS . xselect-convert-to-targets)
-	(LENGTH . xselect-convert-to-length)
-	(DELETE . xselect-convert-to-delete)
-	(FILE_NAME . xselect-convert-to-filename)
-	(CHARACTER_POSITION . xselect-convert-to-charpos)
-	(SOURCE_LOC . xselect-convert-to-sourceloc)
-	(LINE_NUMBER . xselect-convert-to-lineno)
-	(COLUMN_NUMBER . xselect-convert-to-colno)
-	(OWNER_OS . xselect-convert-to-os)
-	(HOST_NAME . xselect-convert-to-host)
-	(USER . xselect-convert-to-user)
-	(CLASS . xselect-convert-to-class)
-	(NAME . xselect-convert-to-name)
-	(ATOM . xselect-convert-to-atom)
-	(INTEGER . xselect-convert-to-integer)
-	(_EMACS_INTERNAL . xselect-convert-to-identity)
-	))
 
 ;FSFmacs (provide 'select)
 
--- a/lwlib/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/lwlib/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,12 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-05-17  Jerry James  <jerry@cs.ucsb.edu>
+
+	* xlwmenu.c (make_shadow_gcs): Test bottom_shadow_pixmap before
+	using it.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/lwlib/xlwmenu.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/lwlib/xlwmenu.c	Mon Aug 13 11:21:38 2007 +0200
@@ -2825,8 +2825,8 @@
   xgcv.foreground = mw->menu.bottom_shadow_color;
 /*  xgcv.stipple = mw->menu.bottom_shadow_pixmap; gtb */
 #ifdef NEED_MOTIF
-  if (mw->menu.top_shadow_pixmap &&
-      mw->menu.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
+  if (mw->menu.bottom_shadow_pixmap &&
+      mw->menu.bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
      xgcv.stipple = mw->menu.bottom_shadow_pixmap;
   else
      xgcv.stipple = 0;
--- a/man/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,31 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-05-30  Albert Chin-A-Young <china@thewrittenword.com>
+
+	* custom.texi, external-widget.texi: Minor
+	fix to get info DIR entry correct.
+
+1999-05-22  Vin Shelton <acs@xemacs.org>
+
+	* xemacs/cmdargs.texi:
+	Document -private.
+
+1999-05-16  Mike McEwan  <mike@lotusland.demon.co.uk>
+
+	* Makefile: Added `emodules.info' to info targets.
+
+1999-05-20  Karl M. Hegbloom  <karlheg@debian.org>
+
+	* internals/internals.texi (The XEmacs Object System
+	  (Abstractly Speaking)): typo.
+
+1999-05-16  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* lispref/text.texi (Substitution): Document improvements in
+ 	`translate-region'.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/man/Makefile	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/Makefile	Mon Aug 13 11:21:38 2007 +0200
@@ -43,6 +43,7 @@
 info_files = \
 	$(INFODIR)/cl.info \
 	$(INFODIR)/custom.info \
+	$(INFODIR)/emodules.info \
 	$(INFODIR)/external-widget.info \
 	$(INFODIR)/info.info \
 	$(INFODIR)/standards.info \
@@ -55,6 +56,7 @@
 dvi_files = \
 	cl.dvi \
 	custom.dvi \
+	emodules.dvi \
 	external-widget.dvi \
 	info.dvi \
 	standards.dvi \
@@ -70,6 +72,9 @@
 ../info/custom.info : custom.texi
 	-$(MAKEINFO) custom.texi -o ../info/custom.info
 
+../info/emodules.info : emodules.texi
+	-$(MAKEINFO) emodules.texi -o ../info/emodules.info
+
 ../info/external-widget.info : external-widget.texi
 	-$(MAKEINFO) external-widget.texi -o ../info/external-widget.info
 
--- a/man/custom.texi	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/custom.texi	Mon Aug 13 11:21:38 2007 +0200
@@ -13,7 +13,6 @@
 @dircategory XEmacs Editor
 @direntry
 * Customizations: (custom).	Customization Library.
-package.
 @end direntry
 @end ifinfo
 
--- a/man/external-widget.texi	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/external-widget.texi	Mon Aug 13 11:21:38 2007 +0200
@@ -5,7 +5,6 @@
 @dircategory XEmacs Editor
 @direntry
 * External Widget: (external-widget) External Client Widget.
-package.
 @end direntry
 @end ifinfo
 
--- a/man/internals/internals.texi	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/internals/internals.texi	Mon Aug 13 11:21:38 2007 +0200
@@ -1462,7 +1462,7 @@
 1.983e-4
 @end example
 
-converts to a float whose value is 1983.23e-4, or .0001983.
+converts to a float whose value is 1.983e-4, or .0001983.
 
 @example
 ?b
--- a/man/lispref/text.texi	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/lispref/text.texi	Mon Aug 13 11:21:38 2007 +0200
@@ -2464,18 +2464,59 @@
 
 @defun translate-region start end table
 This function applies a translation table to the characters in the
-buffer between positions @var{start} and @var{end}.
-
-The translation table @var{table} is a string; @code{(aref @var{table}
-@var{ochar})} gives the translated character corresponding to
-@var{ochar}.  If the length of @var{table} is less than 256, any
-characters with codes larger than the length of @var{table} are not
-altered by the translation.
+buffer between positions @var{start} and @var{end}.  The translation
+table @var{table} can be either a string, a vector, or a char-table.
+
+If @var{table} is a string, its @var{n}th element is the mapping for the 
+character with code @var{n}.
+
+If @var{table} is a vector, its @var{n}th element is the mapping for
+character with code @var{n}.  Legal mappings are characters, strings, or
+@code{nil} (meaning don't replace.)
+
+If @var{table} is a char-table, its elements describe the mapping
+between characters and their replacements.  The char-table should be of
+type @code{char} or @code{generic}.
+
+When the @var{table} is a string or vector and its length is less than
+the total number of characters (256 without Mule), any characters with
+codes larger than the length of @var{table} are not altered by the
+translation.
 
 The return value of @code{translate-region} is the number of
 characters that were actually changed by the translation.  This does
 not count characters that were mapped into themselves in the
 translation table.
+
+@strong{NOTE}: Prior to XEmacs 21.2, the @var{table} argument was
+allowed only to be a string.  This is still the case in FSF Emacs.
+
+The following example creates a char-table that is passed to
+@code{translate-region}, which translates character @samp{a} to
+@samp{the letter a}, removes character @samp{b}, and translates
+character @samp{c} to newline.
+
+@example
+@group
+---------- Buffer: foo ----------
+Here is a sentence in the buffer.
+---------- Buffer: foo ----------
+@end group
+
+@group
+(let ((table (make-char-table 'generic)))
+  (put-char-table ?a "the letter a" table)
+  (put-char-table ?b "" table)
+  (put-char-table ?c ?\n table)
+  (translate-region (point-min) (point-max) table))
+     @result{} 3
+
+---------- Buffer: foo ----------
+Here is the letter a senten
+e in the uffer.
+---------- Buffer: foo ----------
+@end group
+@end example
 @end defun
 
 @node Registers
--- a/man/xemacs/cmdargs.texi	Mon Aug 13 11:20:44 2007 +0200
+++ b/man/xemacs/cmdargs.texi	Mon Aug 13 11:21:38 2007 +0200
@@ -224,6 +224,9 @@
 
 @item -cr @var{color}
 Use @var{color} as the text-cursor foreground color.
+
+@item -private
+Install a private colormap for XEmacs.
 @end table
 
 In addition, XEmacs allows you to use a number of standard Xt
--- a/nt/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/nt/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,11 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-05-31  Andy Piper  <andy@xemacs.org>
+
+	* xemacs.mak: add select & select-x targets.
+	
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/nt/xemacs.mak	Mon Aug 13 11:20:44 2007 +0200
+++ b/nt/xemacs.mak	Mon Aug 13 11:21:38 2007 +0200
@@ -582,6 +582,7 @@
  $(XEMACS)\src\regex.c \
  $(XEMACS)\src\scrollbar.c \
  $(XEMACS)\src\search.c \
+ $(XEMACS)\src\select.c \
  $(XEMACS)\src\signal.c \
  $(XEMACS)\src\sound.c 
 DOC_SRC5=\
@@ -620,7 +621,7 @@
  $(XEMACS)\src\balloon-x.c \
  $(XEMACS)\src\xgccache.c \
  $(XEMACS)\src\xmu.c \
- $(XEMACS)\src\xselect.c 
+ $(XEMACS)\src\select-x.c 
 !endif
 
 !if $(HAVE_MSW)
@@ -709,7 +710,7 @@
 	$(OUTDIR)\scrollbar-x.obj \
 	$(OUTDIR)\xgccache.obj \
 	$(OUTDIR)\xmu.obj \
-	$(OUTDIR)\xselect.obj
+	$(OUTDIR)\select-x.obj
 !endif
 
 !if $(HAVE_MSW)
@@ -829,6 +830,7 @@
 	$(OUTDIR)\regex.obj \
 	$(OUTDIR)\scrollbar.obj \
 	$(OUTDIR)\search.obj \
+	$(OUTDIR)\select.obj \
 	$(OUTDIR)\signal.obj \
 	$(OUTDIR)\sound.obj \
 	$(OUTDIR)\specifier.obj \
--- a/src/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,173 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-06-01  Hirokazu FUKUI  <fukui@atesoft.advantest.co.jp>
+
+	* frame.c (Fset_mouse_position):
+	(Fset_mouse_pixel_position):
+	* window.c (Fsplit_window):
+	(Fmove_to_window_line):
+	Fix crash when invoking functions with an already-deleted window
+	argument.
+
+	* indent.c (vertical_motion_1):
+	(vmotion_pixels):
+	(Fvertical_motion_pixels):
+	* window.c (Fwindow_displayed_text_pixel_height):
+	Fix error message when invoking functions with an already-deleted
+	window argument.
+
+1999-06-01  Jan Vroonhof  <vroonhof@math.ethz.ch>
+
+	* sysdep.c (request_sigio_on_device): Guard against glibc
+	2.1's stub streams implementation.
+
+1999-06-03  SL Baur  <steve@xemacs.org>
+
+	* config.h.in:
+	* emacs.c:  Implement x.y.z version numbers
+	From Jan Vroonhof <vroonhof@math.ethz.ch>
+
+1999-05-20  MORIOKA Tomohiko  <tomo@etl.go.jp>
+
+	* mule-charset.c (complex_vars_of_mule_charset): Registry of
+	japanese-jisx0208-1978 should not match with "jisx0208.1983" nor
+	"jisc6226.1983".
+
+1999-06-03  SL Baur  <steve@xemacs.org>
+
+	* frame-x.c:
+	* device-x.c: rename session option to wmcommand.
+	From Oliver Graf <ograf@rhein-zeitung.de>
+
+1999-05-27  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* fns.c (Fsubstring): Don't traverse the same region twice with
+ 	charcount_to_bytecount().
+
+1999-06-03  SL Baur  <steve@steve1.m17n.org>
+
+	* m/alpha.h (SYSTEM_MALLOC): Fix indented preprocessor directive
+	garbage.
+
+	* s/decosf4-0.h: Defining ORDINARY_LINK here is redundant (and it
+	doesn't really work as is implied by the commentary).
+	Don't define SYSTEM_MALLOC so the old GNU malloc can be used.
+
+1999-06-02  SL Baur  <steve@steve1.m17n.org>
+
+	* symsinit.h: Declare vars_of_ntproc.
+	* emacs.c (main_1): Call it.
+
+	* ntproc.c (syms_of_ntproc): Move variable initializations from
+	here ...
+	(vars_of_ntproc): ... to here [new function].
+
+	* file-coding.c (syms_of_file_coding): Rename.
+	(vars_of_file_coding): Ditto.
+	(complex_vars_of_file_coding): Ditto.
+
+	* symsinit.h: Rename *_mule_coding to *_file_coding.
+
+	* emacs.c (main_1): Call them by the proper name.
+
+	* device-msw.c (syms_of_device_mswindows): Move variable
+	initializations from here ...
+	(vars_of_device_mswindows): ... to here.
+
+	* chartab.c (vars_of_chartab): New function.
+
+	* symsinit.h: New function, vars_of_chartab.
+
+	* emacs.c (main_1): Call it.
+
+	* mule-canna.c (syms_of_mule_canna): Move CANNA initialization ...
+	(vars_of_mule_canna): ... to here.
+
+	* mule-ccl.c (vars_of_mule_ccl): New function.  Move variable
+	initializations out of syms_of_mule_ccl.
+
+	* symsinit.h: Declare new function vars_of_mule_ccl.
+
+	* emacs.c (main_1): Call it.
+
+1999-05-27  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* fns.c (base64_decode_1): Ignore whitespace.
+
+1999-05-27  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* mule-charset.c (Fmake_char): Strip the eighth bit off ARG1 and
+ 	ARG2.
+
+1999-05-21  Andy Piper  <andy@xemacs.org>
+	
+	* xselect.c: deleted.
+	
+	* symsinit.h: declare select initialisation.
+
+	* select.h: new file. declare commonly used select functions and
+ 	variables.
+
+	* select.c: new file. generalised from xselect.c.
+	(clean_local_selection_data): moved from xselect.c.
+	(get_local_selection): ditto. device specific pieces called via a
+ 	devmeth.
+	(handle_selection_clear): ditto.
+	(Fown_selection_internal): renamed and generalised from
+ 	Fx_own_selection_internal. moved from xselect.c.
+	(Fdisown_selection_internal): ditto.
+	(Fselection_owner_p): ditto.
+	(Fselection_exists_p): ditto.
+	(Fget_selection_internal): ditto.
+	(syms_of_select): new function. QXXXX values moved from xselect.c
+	(vars_of_select): new function. selection_converter_alist,
+ 	lost_selection_hooks moved and renamed from xselect.c
+
+	* select-x.c: renamed from xselect.c.
+ 	(x_own_selection): converted to device specific. non-X-specific
+ 	bits moved to select.c.
+	(x_get_foreign_selection): ditto.
+	(x_disown_selection): ditto.
+	(x_selection_exists_p): ditto.
+	(console_type_create_select_x): new function.
+
+	* select-msw.c (mswindows_own_selection): new device method to set
+ 	the clipboard when we 'own' the selection.
+	(mswindows_get_foreign_selection): new device method to get the
+ 	clipboard.
+	(mswindows_disown_selection): new device method to delete the
+ 	selection when we 'disown' it.
+	(console_type_create_select_mswindows): new function.
+
+	* emacs.c (main_1): add select to things to initialise.
+
+	* console.h (struct console_methods): new console methods for
+ 	selection.
+
+	* Makefile.in.in (x_objs): xselect.c renamed to select-x.c
+
+1999-05-20  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* print.c (long_to_string): Install a faster version.
+
+1999-05-16  Andy Piper  <andy@xemacs.org>
+
+	* ntproc.c (syms_of_ntproc): default
+ 	win32-start-process-share-console to t.
+
+1999-05-14  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* config.h.in: Do it here.
+
+	* bytecode.c: Don't define ERROR_CHECK_TYPECHECK here.
+
+1999-05-14  Andy Piper  <andy@xemacs.org>
+
+	* toolbar-msw.c (mswindows_output_toolbar): hash on something
+ 	hashable.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- a/src/Makefile.in.in	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/Makefile.in.in	Mon Aug 13 11:21:38 2007 +0200
@@ -117,7 +117,7 @@
 	cd ../lwlib && $(RECURSIVE_MAKE)
 
 x_objs=balloon_help.o balloon-x.o console-x.o device-x.o event-Xt.o frame-x.o\
- glyphs-x.o objects-x.o redisplay-x.o xgccache.o xselect.o 
+ glyphs-x.o objects-x.o redisplay-x.o select-x.o xgccache.o  
 
 #ifdef AIX4
 LIBI18N = -li18n
@@ -181,7 +181,7 @@
  macros.o marker.o md5.o minibuf.o objects.o opaque.o\
  print.o process.o profile.o\
  rangetab.o redisplay.o redisplay-output.o regex.o\
- search.o $(sheap_obj) signal.o sound.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
 
@@ -340,10 +340,21 @@
 #endif /* ! defined (CANNOT_DUMP) */
 
 ${PROGNAME}: temacs ${libsrc}DOC $(mo_file) ${other_files} update-elc.stamp
+#ifdef HEAP_IN_DATA
+	@$(RM) $@ $@.exe && touch SATISFIED
+	-${dump_temacs}
+	@if test -f $@;        then if test -f SATISFIED; then \
+		echo "Testing for Lisp shadows ..."; \
+		./${PROGNAME} -batch -vanilla -f list-load-path-shadows; fi; \
+		$(RM) SATISFIED; exit 0; fi; \
+	if test -f SATISFIED; then $(RM) SATISFIED; exit 1; fi; \
+	$(RECURSIVE_MAKE) $@;
+#else
 	@$(RM) $@
 	-${dump_temacs}
 	@echo "Testing for Lisp shadows ..."
 	@./${PROGNAME} -batch -vanilla -f list-load-path-shadows
+#endif
 
 fastdump: temacs 
 	@$(RM) ${PROGNAME} && touch SATISFIED
--- a/src/alloc.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/alloc.c	Mon Aug 13 11:21:38 2007 +0200
@@ -176,10 +176,6 @@
 /* Non-zero means we're in the process of doing the dump */
 int purify_flag;
 
-#ifdef HEAP_IN_DATA
-extern void sheap_adjust_h();
-#endif
-
 #ifdef ERROR_CHECK_TYPECHECK
 
 Error_behavior ERROR_ME, ERROR_ME_NOT, ERROR_ME_WARN;
--- a/src/bytecode.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/bytecode.c	Mon Aug 13 11:21:38 2007 +0200
@@ -226,12 +226,6 @@
 
 extern Lisp_Object Qand_rest, Qand_optional;
 
-/* Define ERROR_CHECK_BYTE_CODE to enable some minor sanity checking.
-   Useful for debugging the byte compiler.  */
-#ifdef DEBUG_XEMACS
-#define ERROR_CHECK_BYTE_CODE
-#endif
-
 /* Define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
    This isn't defined in FSF Emacs and isn't defined in XEmacs v19. */
 /* #define BYTE_CODE_METER */
--- a/src/chartab.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/chartab.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1750,6 +1750,11 @@
   DEFSUBR (Fcategory_table_value_p);
 #endif /* MULE */
 
+}
+
+void
+vars_of_chartab (void)
+{
   /* DO NOT staticpro this.  It works just like Vweak_hash_tables. */
   Vall_syntax_tables = Qnil;
 }
--- a/src/config.h.in	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/config.h.in	Mon Aug 13 11:21:38 2007 +0200
@@ -61,6 +61,7 @@
 /* The version info from version.sh. Used in #pragma ident in emacs.c */
 #undef EMACS_MAJOR_VERSION
 #undef EMACS_MINOR_VERSION
+#undef EMACS_PATCH_LEVEL
 #undef EMACS_BETA_VERSION
 #undef EMACS_VERSION
 #undef XEMACS_CODENAME
@@ -399,6 +400,9 @@
 #undef ERROR_CHECK_GC
 /* Attempt to catch freeing of a non-malloc()ed block, heap corruption, etc. */
 #undef ERROR_CHECK_MALLOC
+/* Minor sanity checking of the bytecode interpreter.  Useful for
+   debugging the byte compiler.  */
+#undef ERROR_CHECK_BYTE_CODE
 
 /* Define DEBUG_XEMACS if you want extra debugging code compiled in.
    This is mainly intended for use by developers. */
@@ -453,8 +457,8 @@
 /* Compile in generic Drag'n'Drop API */
 #undef HAVE_DRAGNDROP
 
-/* Compile in support for proper session-management. */
-#undef HAVE_SESSION
+/* Compile in support for proper handling of WM_COMMAND. */
+#undef HAVE_WMCOMMAND
 
 /* Define this if you want Mule support (multi-byte character support).
    There may be some performance penalty, although it should be small
--- a/src/console.h	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/console.h	Mon Aug 13 11:21:38 2007 +0200
@@ -90,6 +90,11 @@
   void (*asynch_device_change_method) (void);
   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);
 
   /* frame methods */
   Lisp_Object *device_specific_frame_props;
--- a/src/device-msw.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/device-msw.c	Mon Aug 13 11:21:38 2007 +0200
@@ -300,20 +300,6 @@
 {
   defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win");
   defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win");
-
-  DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /*
-Non-nil means convert all-upper case file names to lower case.
-This applies when performing completions and file name expansion.
-*/ );
-  Vmswindows_downcase_file_names = Qnil;
-
-  DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /*
-Non-nil means determine accurate link count in file-attributes.
-This option slows down file-attributes noticeably, so is disabled by
-default.  Note that it is only useful for files on NTFS volumes,
-where hard links are supported.
-*/ );
-  Vmswindows_get_true_file_attributes = Qnil;
 }
 
 void
@@ -330,4 +316,17 @@
 void
 vars_of_device_mswindows (void)
 {
+  DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /*
+Non-nil means convert all-upper case file names to lower case.
+This applies when performing completions and file name expansion.
+*/ );
+  Vmswindows_downcase_file_names = Qnil;
+
+  DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /*
+Non-nil means determine accurate link count in file-attributes.
+This option slows down file-attributes noticeably, so is disabled by
+default.  Note that it is only useful for files on NTFS volumes,
+where hard links are supported.
+*/ );
+  Vmswindows_get_true_file_attributes = Qnil;
 }
--- a/src/device-x.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/device-x.c	Mon Aug 13 11:21:38 2007 +0200
@@ -696,7 +696,7 @@
     XtRealizeWidget (app_shell);
   }
 
-#ifdef HAVE_SESSION
+#ifdef HAVE_WMCOMMAND
   {
     int new_argc;
     char **new_argv;
@@ -704,7 +704,7 @@
     XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), new_argv, new_argc);
     free_argc_argv (new_argv);
   }
-#endif /* HAVE_SESSION */
+#endif /* HAVE_WMCOMMAND */
 
 
 #ifdef HAVE_OFFIX_DND
--- a/src/emacs.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/emacs.c	Mon Aug 13 11:21:38 2007 +0200
@@ -73,6 +73,10 @@
 /* For PATH_EXEC */
 #include <paths.h>
 
+#ifdef HEAP_IN_DATA
+void report_sheap_usage (int die_if_pure_storage_exceeded);
+#endif
+
 #if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
 extern void *(*__malloc_hook)(size_t);
 extern void *(*__realloc_hook)(void *, size_t);
@@ -111,6 +115,7 @@
 /* Version numbers and strings */
 Lisp_Object Vemacs_major_version;
 Lisp_Object Vemacs_minor_version;
+Lisp_Object Vemacs_patch_level;
 Lisp_Object Vemacs_beta_version;
 Lisp_Object Vxemacs_codename;
 #ifdef INFODOCK
@@ -970,6 +975,7 @@
       syms_of_rangetab ();
       syms_of_redisplay ();
       syms_of_search ();
+      syms_of_select ();
       syms_of_signal ();
       syms_of_sound ();
       syms_of_specifier ();
@@ -1035,7 +1041,7 @@
       syms_of_mule_charset ();
 #endif
 #ifdef FILE_CODING
-      syms_of_mule_coding ();
+      syms_of_file_coding ();
 #endif
 #ifdef MULE
 #ifdef HAVE_WNN
@@ -1107,6 +1113,7 @@
       console_type_create_device_x ();
       console_type_create_frame_x ();
       console_type_create_glyphs_x ();
+      console_type_create_select_x ();
 #ifdef HAVE_MENUBARS
       console_type_create_menubar_x ();
 #endif
@@ -1130,6 +1137,7 @@
       console_type_create_objects_mswindows ();
       console_type_create_redisplay_mswindows ();
       console_type_create_glyphs_mswindows ();
+      console_type_create_select_mswindows ();
 # ifdef HAVE_SCROLLBARS
       console_type_create_scrollbar_mswindows ();
 # endif
@@ -1209,7 +1217,7 @@
 
       lstream_type_create ();
 #ifdef FILE_CODING
-      lstream_type_create_mule_coding ();
+      lstream_type_create_file_coding ();
 #endif
 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
       lstream_type_create_mswindows_selectable ();
@@ -1280,6 +1288,7 @@
       vars_of_bytecode ();
       vars_of_callint ();
       vars_of_callproc ();
+      vars_of_chartab ();
       vars_of_cmdloop ();
       vars_of_cmds ();
       vars_of_console ();
@@ -1351,6 +1360,9 @@
 #ifdef HAVE_SHLIB
       vars_of_module ();
 #endif
+#ifdef WINDOWSNT
+      vars_of_ntproc ();
+#endif
       vars_of_objects ();
       vars_of_print ();
 
@@ -1373,6 +1385,7 @@
       vars_of_scrollbar ();
 #endif
       vars_of_search ();
+      vars_of_select ();
       vars_of_sound ();
       vars_of_specifier ();
       vars_of_symbols ();
@@ -1432,10 +1445,11 @@
 
 #ifdef MULE
       vars_of_mule ();
+      vars_of_mule_ccl ();
       vars_of_mule_charset ();
 #endif
 #ifdef FILE_CODING
-      vars_of_mule_coding ();
+      vars_of_file_coding ();
 #endif
 #ifdef MULE
 #ifdef HAVE_WNN
@@ -1507,7 +1521,7 @@
       complex_vars_of_mule_charset ();
 #endif
 #if defined(FILE_CODING)
-      complex_vars_of_mule_coding ();
+      complex_vars_of_file_coding ();
 #endif
 
       /* This calls allocate_glyph(), which creates specifiers
@@ -2037,6 +2051,9 @@
   unbind_to (0, Qnil); /* this closes loadup.el */
   purify_flag = 0;
   run_temacs_argc = nargs + 1;
+#ifdef HEAP_IN_DATA
+  report_sheap_usage (0);
+#endif
   LONGJMP (run_temacs_catch, 1);
   return Qnil; /* not reached; warning suppression */
 }
@@ -2445,6 +2462,10 @@
   opurify = purify_flag;
   purify_flag = 0;
 
+#ifdef HEAP_IN_DATA
+  report_sheap_usage (1);
+#endif
+
   fflush (stderr);
   fflush (stdout);
 
@@ -2781,7 +2802,20 @@
 */ );
   Vemacs_minor_version = make_int (EMACS_MINOR_VERSION);
 
-  DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
+  DEFVAR_LISP ("emacs-patch-level", &Vemacs_patch_level /*
+The patch level of this version of Emacs, as an integer.
+The value is non-nil if this version of XEmacs is part of a series of
+stable XEmacsen, but has bug fixes applied.
+Warning: this variable does not exist in FSF Emacs or in XEmacs versions
+earlier than 21.1.1
+*/ );
+#ifdef EMACS_PATCH_LEVEL
+  Vemacs_patch_level = make_int (EMACS_PATCH_LEVEL);
+#else
+  Vemacs_patch_level = Qnil;
+#endif
+
+    DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
 Beta number of this version of Emacs, as an integer.
 The value is nil if this is an officially released version of XEmacs.
 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
--- a/src/file-coding.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/file-coding.c	Mon Aug 13 11:21:38 2007 +0200
@@ -5403,7 +5403,7 @@
 /************************************************************************/
 
 void
-syms_of_mule_coding (void)
+syms_of_file_coding (void)
 {
   defsymbol (&Qbuffer_file_coding_system, "buffer-file-coding-system");
   deferror (&Qcoding_system_error, "coding-system-error",
@@ -5515,7 +5515,7 @@
 }
 
 void
-lstream_type_create_mule_coding (void)
+lstream_type_create_file_coding (void)
 {
   LSTREAM_HAS_METHOD (decoding, reader);
   LSTREAM_HAS_METHOD (decoding, writer);
@@ -5535,7 +5535,7 @@
 }
 
 void
-vars_of_mule_coding (void)
+vars_of_file_coding (void)
 {
   int i;
 
@@ -5597,7 +5597,7 @@
 }
 
 void
-complex_vars_of_mule_coding (void)
+complex_vars_of_file_coding (void)
 {
   staticpro (&Vcoding_system_hash_table);
   Vcoding_system_hash_table =
--- a/src/fns.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/fns.c	Mon Aug 13 11:21:38 2007 +0200
@@ -881,7 +881,7 @@
        (string, from, to))
 {
   Charcount ccfr, ccto;
-  Bytecount bfr, bto;
+  Bytecount bfr, blen;
   Lisp_Object val;
 
   CHECK_STRING (string);
@@ -889,10 +889,10 @@
   get_string_range_char (string, from, to, &ccfr, &ccto,
 			 GB_HISTORICAL_STRING_BEHAVIOR);
   bfr = charcount_to_bytecount (XSTRING_DATA (string), ccfr);
-  bto = charcount_to_bytecount (XSTRING_DATA (string), ccto);
-  val = make_string (XSTRING_DATA (string) + bfr, bto - bfr);
+  blen = charcount_to_bytecount (XSTRING_DATA (string) + bfr, ccto - ccfr);
+  val = make_string (XSTRING_DATA (string) + bfr, blen);
   /* Copy any applicable extent information into the new string: */
-  copy_string_extents (val, string, 0, bfr, bto - bfr);
+  copy_string_extents (val, string, 0, bfr, blen);
   return val;
 }
 
@@ -3440,11 +3440,11 @@
    base64 characters.  */
 
 #define ADVANCE_INPUT(c, stream)				\
- (ec = Lstream_get_emchar (stream),				\
-  ec == -1 ? 0 :						\
+ ((ec = Lstream_get_emchar (stream)) == -1 ? 0 :		\
   ((ec > 255) ?							\
-   (error ("Non-ascii character detected in base64 input"), 0)	\
-   : (c = (Bufbyte)ec, 1)))
+   (signal_simple_error ("Non-ascii character in base64 input",	\
+			 make_char (ec)), 0)			\
+   : (c = (Bufbyte)ec), 1))
 
 static Bytind
 base64_encode_1 (Lstream *istream, Bufbyte *to, int line_break)
@@ -3504,10 +3504,24 @@
 }
 #undef ADVANCE_INPUT
 
+/* Semantically identical to ADVANCE_INPUT above, only no >255
+   checking is needed for decoding -- checking is covered by IS_BASE64
+   below.  */
 #define ADVANCE_INPUT(c, stream)		\
  (ec = Lstream_get_emchar (stream),		\
   ec == -1 ? 0 : (c = (Bufbyte)ec, 1))
 
+/* Get next character from the stream, but ignore it if it's
+   whitespace.  ENDP is set to 1 if EOF is hit.  */
+#define ADVANCE_INPUT_IGNORE_WHITESPACE(c, endp, stream) do {		\
+  endp = 0;								\
+  do {									\
+    if (!ADVANCE_INPUT (c, stream))					\
+      endp = 1;								\
+  } while (!endp && (c == ' ' || c == '\t' || c == '\r' || c == '\n'	\
+		     || c == '\f' || c == '\v'));			\
+} while (0)
+
 #define STORE_BYTE(pos, val) do {					\
   pos += set_charptr_emchar (pos, (Emchar)((unsigned char)(val)));	\
   ++*ccptr;								\
@@ -3516,7 +3530,6 @@
 static Bytind
 base64_decode_1 (Lstream *istream, Bufbyte *to, Charcount *ccptr)
 {
-  Emchar ec;
   Bufbyte *e = to;
   unsigned long value;
 
@@ -3524,33 +3537,21 @@
   while (1)
     {
       Bufbyte c;
-
-      if (!ADVANCE_INPUT (c, istream))
+      Emchar ec;
+      int endp;
+
+      ADVANCE_INPUT_IGNORE_WHITESPACE (c, endp, istream);
+      if (endp)
 	break;
 
-      /* Accept wrapping lines.  */
-      if (c == '\r')
-	{
-	  if (!ADVANCE_INPUT (c, istream)
-	      || c != '\n')
-	    return -1;
-	}
-      if (c == '\n')
-	{
-	  if (!ADVANCE_INPUT (c, istream))
-	    break;
-	  /* FSF checks for end of text here, but that's wrong. */
-	  /* FSF checks for correct line length here; that's also
-             wrong; some MIME encoders use different line lengths.  */
-	}
-
       /* Process first byte of a quadruplet.  */
       if (!IS_BASE64 (c))
 	return -1;
       value = base64_char_to_value[c] << 18;
 
       /* Process second byte of a quadruplet.  */
-      if (!ADVANCE_INPUT (c, istream))
+      ADVANCE_INPUT_IGNORE_WHITESPACE (c, endp, istream);
+      if (endp)
 	return -1;
 
       if (!IS_BASE64 (c))
@@ -3560,12 +3561,14 @@
       STORE_BYTE (e, value >> 16);
 
       /* Process third byte of a quadruplet.  */
-      if (!ADVANCE_INPUT (c, istream))
+      ADVANCE_INPUT_IGNORE_WHITESPACE (c, endp, istream);
+      if (endp)
 	return -1;
 
       if (c == '=')
 	{
-	  if (!ADVANCE_INPUT (c, istream))
+	  ADVANCE_INPUT_IGNORE_WHITESPACE (c, endp, istream);
+	  if (endp)
 	    return -1;
 	  if (c != '=')
 	    return -1;
@@ -3579,7 +3582,8 @@
       STORE_BYTE (e, 0xff & value >> 8);
 
       /* Process fourth byte of a quadruplet.  */
-      if (!ADVANCE_INPUT (c, istream))
+      ADVANCE_INPUT_IGNORE_WHITESPACE (c, endp, istream);
+      if (endp)
 	return -1;
 
       if (c == '=')
@@ -3595,7 +3599,8 @@
   return e - to;
 }
 #undef ADVANCE_INPUT
-#undef INPUT_EOF_P
+#undef ADVANCE_INPUT_IGNORE_WHITESPACE
+#undef STORE_BYTE
 
 static Lisp_Object
 free_malloced_ptr (Lisp_Object unwind_obj)
--- a/src/frame-x.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/frame-x.c	Mon Aug 13 11:21:38 2007 +0200
@@ -328,7 +328,7 @@
   XSetClassHint (dpy, XtWindow (shell), &classhint);
 }
 
-#ifndef HAVE_SESSION
+#ifndef HAVE_WMCOMMAND
 static void
 x_wm_maybe_store_wm_command (struct frame *f)
 {
@@ -379,7 +379,7 @@
 
     }
 }
-#endif /* !HAVE_SESSION */
+#endif /* !HAVE_WMCOMMAND */
 
 static int
 x_frame_iconified_p (struct frame *f)
@@ -2059,9 +2059,9 @@
 	/* tell the window manager about us. */
 	x_wm_store_class_hints (shell_widget, XtName (frame_widget));
 
-#ifndef HAVE_SESSION
+#ifndef HAVE_WMCOMMAND
 	x_wm_maybe_store_wm_command (f);
-#endif /* HAVE_SESSION */
+#endif /* HAVE_WMCOMMAND */
 
 	x_wm_hack_wm_protocols (shell_widget);
       }
@@ -2625,10 +2625,10 @@
 {
   Display *dpy;
 
-#ifndef HAVE_SESSION
+#ifndef HAVE_WMCOMMAND
   if (FRAME_X_TOP_LEVEL_FRAME_P (f))
     x_wm_maybe_move_wm_command (f);
-#endif /* HAVE_SESSION */
+#endif /* HAVE_WMCOMMAND */
 
 #ifdef HAVE_CDE
   DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f));
--- a/src/frame.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/frame.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1838,7 +1838,7 @@
   struct window *w;
   int pix_x, pix_y;
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   CHECK_INT (x);
   CHECK_INT (y);
 
@@ -1862,7 +1862,7 @@
 {
   struct window *w;
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   CHECK_INT (x);
   CHECK_INT (y);
 
--- a/src/indent.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/indent.c	Mon Aug 13 11:21:38 2007 +0200
@@ -665,7 +665,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   CHECK_INT (lines);
 
   selected = (EQ (window, Fselected_window (Qnil)));
@@ -739,7 +739,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   w = XWINDOW (window);
 
   eobuf = BUF_ZV (XBUFFER (w->buffer));
@@ -842,7 +842,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   CHECK_INT (pixels);
 
   selected = (EQ (window, Fselected_window (Qnil)));
--- a/src/m/alpha.h	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/m/alpha.h	Mon Aug 13 11:21:38 2007 +0200
@@ -20,7 +20,7 @@
 
 
 #ifdef LINUX
- # define SYSTEM_MALLOC
+# define SYSTEM_MALLOC
 #endif
 
 #ifdef OSF1
--- a/src/mule-canna.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/mule-canna.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1022,9 +1022,6 @@
 void
 syms_of_mule_canna (void)
 {
-  DEFVAR_LISP ("CANNA", &VCANNA);		/* hir@nec, 1992.5.21 */
-  VCANNA = Qt;					/* hir@nec, 1992.5.21 */
-
   DEFSUBR (Fcanna_key_proc);
   DEFSUBR (Fcanna_initialize);
   DEFSUBR (Fcanna_finalize);
@@ -1048,6 +1045,9 @@
 void
 vars_of_mule_canna (void)
 {
+  DEFVAR_LISP ("CANNA", &VCANNA);		/* hir@nec, 1992.5.21 */
+  VCANNA = Qt;					/* hir@nec, 1992.5.21 */
+
   DEFVAR_LISP ("canna-kakutei-string", &Vcanna_kakutei_string /*
 
 */ );
--- a/src/mule-ccl.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/mule-ccl.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1097,6 +1097,14 @@
 void
 syms_of_mule_ccl (void)
 {
+  DEFSUBR (Fccl_execute);
+  DEFSUBR (Fccl_execute_on_string);
+  DEFSUBR (Fregister_ccl_program);
+}
+
+void
+vars_of_mule_ccl (void)
+{
   staticpro (&Vccl_program_table);
   Vccl_program_table = Fmake_vector (make_int (32), Qnil);
 
@@ -1113,10 +1121,6 @@
 If the font is single-byte font, the register R2 is not used.
 */ );
   Vfont_ccl_encoder_alist = Qnil;
-
-  DEFSUBR (Fccl_execute);
-  DEFSUBR (Fccl_execute_on_string);
-  DEFSUBR (Fregister_ccl_program);
 }
 
 #endif  /* emacs */
--- a/src/mule-charset.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/mule-charset.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1067,7 +1067,11 @@
   else	/* CHARSET_CHARS (cs) == 96) */	     lowlim = 32, highlim = 127;
 
   CHECK_INT (arg1);
-  a1 = XINT (arg1);
+  /* It is useful (and safe, according to Olivier Galibert) to strip
+     the 8th bit off ARG1 and ARG2 becaue it allows programmers to
+     write (make-char 'latin-iso8859-2 CODE) where code is the actual
+     Latin 2 code of the character.  */
+  a1 = XINT (arg1) & 0x7f;
   if (a1 < lowlim || a1 > highlim)
     args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim));
 
@@ -1080,7 +1084,7 @@
     }
 
   CHECK_INT (arg2);
-  a2 = XINT (arg2);
+  a2 = XINT (arg2) & 0x7f;
   if (a2 < lowlim || a2 > highlim)
     args_out_of_range_3 (arg2, make_int (lowlim), make_int (highlim));
 
@@ -1421,7 +1425,7 @@
 		  build_string ("JISX0208.1978 (Japanese)"),
 		  build_string
 		  ("JISX0208.1978 Japanese Kanji (so called \"old JIS\")"),
-		  build_string ("\\(jisx0208\\|jisc6226\\).19"));
+		  build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"));
   Vcharset_chinese_gb2312 =
     make_charset (LEADING_BYTE_CHINESE_GB2312, Qchinese_gb2312, 3,
 		  CHARSET_TYPE_94X94, 2, 0, 'A',
--- a/src/ntproc.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/ntproc.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1442,9 +1442,6 @@
 void
 syms_of_ntproc ()
 {
-  Qhigh = intern ("high");
-  Qlow = intern ("low");
-
   DEFSUBR (Fwin32_short_file_name);
   DEFSUBR (Fwin32_long_file_name);
   DEFSUBR (Fwin32_set_process_priority);
@@ -1453,6 +1450,14 @@
   DEFSUBR (Fwin32_get_default_locale_id);
   DEFSUBR (Fwin32_get_valid_locale_ids);
   DEFSUBR (Fwin32_set_current_locale);
+}
+
+
+void
+vars_of_ntproc (void)
+{
+  Qhigh = intern ("high");
+  Qlow = intern ("low");
 
   DEFVAR_LISP ("win32-quote-process-args", &Vwin32_quote_process_args /*
     Non-nil enables quoting of process arguments to ensure correct parsing.
@@ -1483,7 +1488,7 @@
 subprocess group, but may allow Emacs to interrupt a subprocess that doesn't
 otherwise respond to interrupts from Emacs.
 */ );
-  Vwin32_start_process_share_console = Qnil;
+  Vwin32_start_process_share_console = Qt;
 
   DEFVAR_LISP ("win32-pipe-read-delay", &Vwin32_pipe_read_delay /*
     Forced delay before reading subprocess output.
@@ -1508,4 +1513,5 @@
   Vwin32_generate_fake_inodes = Qnil;
 #endif
 }
+
 /* end of ntproc.c */
--- a/src/print.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/print.c	Mon Aug 13 11:21:38 2007 +0200
@@ -806,37 +806,52 @@
    faster.
 
    BUFFER should accept 24 bytes.  This should suffice for the longest
-   numbers on 64-bit machines.  */
+   numbers on 64-bit machines, including the `-' sign and the trailing
+   \0.  */
 void
 long_to_string (char *buffer, long number)
 {
-  char *p;
-  int i, len;
+#if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8)
+  /* Huh? */
+  sprintf (buffer, "%ld", number);
+#else /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
+  char *p = buffer;
+  int force = 0;
 
   if (number < 0)
     {
-      *buffer++ = '-';
+      *p++ = '-';
       number = -number;
     }
-  p = buffer;
 
-  /* Print the digits to the string.  */
-  do
-    {
-      *p++ = number % 10 + '0';
-      number /= 10;
-    }
-  while (number);
-
-  /* And reverse them.  */
-  len = p - buffer - 1;
-  for (i = len / 2; i >= 0; i--)
-    {
-      char c = buffer[i];
-      buffer[i] = buffer[len - i];
-      buffer[len - i] = c;
-    }
-  buffer[len + 1] = '\0';
+#define FROB(figure) do {						\
+    if (force || number >= figure)					\
+      *p++ = number / figure + '0', number %= figure, force = 1;	\
+    } while (0)
+#if SIZEOF_LONG == 8
+  FROB (1000000000000000000L);
+  FROB (100000000000000000L);
+  FROB (10000000000000000L);
+  FROB (1000000000000000L);
+  FROB (100000000000000L);
+  FROB (10000000000000L);
+  FROB (1000000000000L);
+  FROB (100000000000L);
+  FROB (10000000000L);
+#endif /* SIZEOF_LONG == 8 */
+  FROB (1000000000);
+  FROB (100000000);
+  FROB (10000000);
+  FROB (1000000);
+  FROB (100000);
+  FROB (10000);
+  FROB (1000);
+  FROB (100);
+  FROB (10);
+#undef FROB
+  *p++ = number + '0';
+  *p = '\0';
+#endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
 }
 
 static void
--- a/src/s/decosf4-0.h	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/s/decosf4-0.h	Mon Aug 13 11:21:38 2007 +0200
@@ -24,13 +24,13 @@
 #define regoff_t sys_regoff_t
 #define regmatch_t sys_regmatch_t
 
-/* A perfectly ordinary link wins again - martin */
+/* A perfectly ordinary link wins again - martin 
 #undef C_SWITCH_SYSTEM
 #undef LIBS_SYSTEM
 #undef LIBS_DEBUG
-#define ORDINARY_LINK
+#define ORDINARY_LINK */
 
-#define SYSTEM_MALLOC
+/*#define SYSTEM_MALLOC*/
 
 #if 0 /* martin */
 /* Some V4.0* versions before V4.0B don't detect rename properly. */
--- a/src/select-msw.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/select-msw.c	Mon Aug 13 11:21:38 2007 +0200
@@ -29,6 +29,7 @@
 
 #include <config.h>
 #include "lisp.h"
+#include "select.h"
 
 #include "console-msw.h"
 
@@ -92,6 +93,20 @@
   return i ? Qt : Qnil;
 }
 
+/* Do protocol to assert ourself as a selection owner. Under mswindows
+this is easy, we just set the clipboard.  */
+static Lisp_Object
+mswindows_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
+{
+  Lisp_Object converted_value = get_local_selection (selection_name, QSTRING);
+  if (!NILP (converted_value) &&
+      CONSP (converted_value) &&
+      EQ (XCAR (converted_value), QSTRING))
+    Fmswindows_set_clipboard (XCDR (converted_value));
+
+  return Qnil;
+}
+
 DEFUN ("mswindows-get-clipboard", Fmswindows_get_clipboard, 0, 0, 0, /*
 Return the contents of the mswindows clipboard.
 */
@@ -144,6 +159,12 @@
   return ret;
 }
 
+static Lisp_Object
+mswindows_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
+{
+  return Fmswindows_get_clipboard ();
+}
+
 DEFUN ("mswindows-selection-exists-p", Fmswindows_selection_exists_p, 0, 0, 0, /*
 Whether there is an MS-Windows selection.
 */
@@ -160,12 +181,26 @@
   return EmptyClipboard () ? Qt : Qnil;
 }
 
+static void
+mswindows_disown_selection (Lisp_Object selection, Lisp_Object timeval)
+{
+  Fmswindows_delete_selection ();
+}
+
 
 /************************************************************************/
 /*                            initialization                            */
 /************************************************************************/
 
 void
+console_type_create_select_mswindows (void)
+{
+  CONSOLE_HAS_METHOD (mswindows, own_selection);
+  CONSOLE_HAS_METHOD (mswindows, disown_selection);
+  CONSOLE_HAS_METHOD (mswindows, get_foreign_selection);
+}
+
+void
 syms_of_select_mswindows (void)
 {
   DEFSUBR (Fmswindows_set_clipboard);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/select-x.c	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,1751 @@
+/* X Selection processing for XEmacs
+   Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not synched with FSF. */
+
+/* Rewritten by jwz */
+
+#include <config.h>
+#include "lisp.h"
+
+#include "buffer.h"
+#include "console-x.h"
+#include "objects-x.h"
+
+#include "frame.h"
+#include "opaque.h"
+#include "systime.h"
+#include "select.h"
+
+int lisp_to_time (Lisp_Object, time_t *);
+Lisp_Object time_to_lisp (time_t);
+
+#ifdef LWLIB_USES_MOTIF
+# define MOTIF_CLIPBOARDS
+#endif
+
+#ifdef MOTIF_CLIPBOARDS
+# include <Xm/CutPaste.h>
+static void hack_motif_clipboard_selection (Atom selection_atom,
+					    Lisp_Object selection_value,
+					    Time thyme, Display *display,
+					    Window selecting_window);
+#endif
+
+#define CUT_BUFFER_SUPPORT
+
+#ifdef CUT_BUFFER_SUPPORT
+Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3,
+  QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7;
+#endif
+
+Lisp_Object Vx_sent_selection_hooks;
+
+/* If this is a smaller number than the max-request-size of the display,
+   emacs will use INCR selection transfer when the selection is larger
+   than this.  The max-request-size is usually around 64k, so if you want
+   emacs to use incremental selection transfers when the selection is
+   smaller than that, set this.  I added this mostly for debugging the
+   incremental transfer stuff, but it might improve server performance.
+ */
+#define MAX_SELECTION_QUANTUM 0xFFFFFF
+
+#define SELECTION_QUANTUM(dpy) ((XMaxRequestSize (dpy) << 2) - 100)
+
+/* If the selection owner takes too long to reply to a selection request,
+   we give up on it.  This is in seconds (0 = no timeout).
+ */
+int x_selection_timeout;
+
+
+/* Utility functions */
+
+static void lisp_data_to_selection_data (struct device *,
+					 Lisp_Object obj,
+					 unsigned char **data_ret,
+					 Atom *type_ret,
+					 unsigned int *size_ret,
+					 int *format_ret);
+static Lisp_Object selection_data_to_lisp_data (struct device *,
+						unsigned char *data,
+						size_t size,
+						Atom type,
+						int format);
+static Lisp_Object x_get_window_property_as_lisp_data (Display *,
+						       Window,
+						       Atom property,
+						       Lisp_Object target_type,
+						       Atom selection_atom);
+
+static int expect_property_change (Display *, Window, Atom prop, int state);
+static void wait_for_property_change (long);
+static void unexpect_property_change (int);
+static int waiting_for_other_props_on_window (Display *, Window);
+
+/* This converts a Lisp symbol to a server Atom, avoiding a server
+   roundtrip whenever possible.
+ */
+static Atom
+symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists)
+{
+  Display *display = DEVICE_X_DISPLAY (d);
+
+  if (NILP (sym))		return XA_PRIMARY;
+  if (EQ (sym, Qt))		return XA_SECONDARY;
+  if (EQ (sym, QPRIMARY))	return XA_PRIMARY;
+  if (EQ (sym, QSECONDARY))	return XA_SECONDARY;
+  if (EQ (sym, QSTRING))	return XA_STRING;
+  if (EQ (sym, QINTEGER))	return XA_INTEGER;
+  if (EQ (sym, QATOM))		return XA_ATOM;
+  if (EQ (sym, QCLIPBOARD))	return DEVICE_XATOM_CLIPBOARD (d);
+  if (EQ (sym, QTIMESTAMP))	return DEVICE_XATOM_TIMESTAMP (d);
+  if (EQ (sym, QTEXT))		return DEVICE_XATOM_TEXT      (d);
+  if (EQ (sym, QDELETE))	return DEVICE_XATOM_DELETE    (d);
+  if (EQ (sym, QMULTIPLE))	return DEVICE_XATOM_MULTIPLE  (d);
+  if (EQ (sym, QINCR))		return DEVICE_XATOM_INCR      (d);
+  if (EQ (sym, QEMACS_TMP))	return DEVICE_XATOM_EMACS_TMP (d);
+  if (EQ (sym, QTARGETS))	return DEVICE_XATOM_TARGETS   (d);
+  if (EQ (sym, QNULL))		return DEVICE_XATOM_NULL      (d);
+  if (EQ (sym, QATOM_PAIR))	return DEVICE_XATOM_ATOM_PAIR (d);
+  if (EQ (sym, QCOMPOUND_TEXT)) return DEVICE_XATOM_COMPOUND_TEXT (d);
+
+#ifdef CUT_BUFFER_SUPPORT
+  if (EQ (sym, QCUT_BUFFER0))	return XA_CUT_BUFFER0;
+  if (EQ (sym, QCUT_BUFFER1))	return XA_CUT_BUFFER1;
+  if (EQ (sym, QCUT_BUFFER2))	return XA_CUT_BUFFER2;
+  if (EQ (sym, QCUT_BUFFER3))	return XA_CUT_BUFFER3;
+  if (EQ (sym, QCUT_BUFFER4))	return XA_CUT_BUFFER4;
+  if (EQ (sym, QCUT_BUFFER5))	return XA_CUT_BUFFER5;
+  if (EQ (sym, QCUT_BUFFER6))	return XA_CUT_BUFFER6;
+  if (EQ (sym, QCUT_BUFFER7))	return XA_CUT_BUFFER7;
+#endif /* CUT_BUFFER_SUPPORT */
+
+  {
+    CONST char *nameext;
+    GET_C_STRING_CTEXT_DATA_ALLOCA (Fsymbol_name (sym), nameext);
+    return XInternAtom (display, nameext, only_if_exists ? True : False);
+  }
+}
+
+
+/* This converts a server Atom to a Lisp symbol, avoiding server roundtrips
+   and calls to intern whenever possible.
+ */
+static Lisp_Object
+x_atom_to_symbol (struct device *d, Atom atom)
+{
+  Display *display = DEVICE_X_DISPLAY (d);
+
+  if (! atom) return Qnil;
+  if (atom == XA_PRIMARY)	return QPRIMARY;
+  if (atom == XA_SECONDARY)	return QSECONDARY;
+  if (atom == XA_STRING)	return QSTRING;
+  if (atom == XA_INTEGER)	return QINTEGER;
+  if (atom == XA_ATOM)		return QATOM;
+  if (atom == DEVICE_XATOM_CLIPBOARD (d)) return QCLIPBOARD;
+  if (atom == DEVICE_XATOM_TIMESTAMP (d)) return QTIMESTAMP;
+  if (atom == DEVICE_XATOM_TEXT      (d)) return QTEXT;
+  if (atom == DEVICE_XATOM_DELETE    (d)) return QDELETE;
+  if (atom == DEVICE_XATOM_MULTIPLE  (d)) return QMULTIPLE;
+  if (atom == DEVICE_XATOM_INCR      (d)) return QINCR;
+  if (atom == DEVICE_XATOM_EMACS_TMP (d)) return QEMACS_TMP;
+  if (atom == DEVICE_XATOM_TARGETS   (d)) return QTARGETS;
+  if (atom == DEVICE_XATOM_NULL      (d)) return QNULL;
+  if (atom == DEVICE_XATOM_ATOM_PAIR (d)) return QATOM_PAIR;
+  if (atom == DEVICE_XATOM_COMPOUND_TEXT (d)) return QCOMPOUND_TEXT;
+
+#ifdef CUT_BUFFER_SUPPORT
+  if (atom == XA_CUT_BUFFER0)	return QCUT_BUFFER0;
+  if (atom == XA_CUT_BUFFER1)	return QCUT_BUFFER1;
+  if (atom == XA_CUT_BUFFER2)	return QCUT_BUFFER2;
+  if (atom == XA_CUT_BUFFER3)	return QCUT_BUFFER3;
+  if (atom == XA_CUT_BUFFER4)	return QCUT_BUFFER4;
+  if (atom == XA_CUT_BUFFER5)	return QCUT_BUFFER5;
+  if (atom == XA_CUT_BUFFER6)	return QCUT_BUFFER6;
+  if (atom == XA_CUT_BUFFER7)	return QCUT_BUFFER7;
+#endif
+
+  {
+    Lisp_Object newsym;
+    CONST Bufbyte *intstr;
+    char *str = XGetAtomName (display, atom);
+
+    if (! str) return Qnil;
+
+    GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA (str, intstr);
+    newsym = intern ((char *) intstr);
+    XFree (str);
+    return newsym;
+  }
+}
+
+
+/* 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)
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  struct frame *sel_frame = selected_frame ();
+  Window selecting_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
+  Lisp_Object selection_time;
+  /* Use the time of the last-read mouse or keyboard event.
+     For selection purposes, we use this as a sleazy way of knowing what the
+     current time is in server-time.  This assumes that the most recently read
+     mouse or keyboard event has something to do with the assertion of the
+     selection, which is probably true.
+     */
+  Time thyme = DEVICE_X_MOUSE_TIMESTAMP (d);
+  Atom selection_atom;
+
+  CHECK_SYMBOL (selection_name);
+  selection_atom = symbol_to_x_atom (d, selection_name, 0);
+
+  XSetSelectionOwner (display, selection_atom, selecting_window, thyme);
+
+  /* We do NOT use time_to_lisp() here any more, like we used to.
+     That assumed equivalence of time_t and Time, which is not
+     necessarily the case (e.g. under OSF on the Alphas, where
+     Time is a 64-bit quantity and time_t is a 32-bit quantity).
+     
+     Opaque pointers are the clean way to go here.
+  */
+  selection_time = make_opaque (sizeof (thyme), (void *) &thyme);
+
+#ifdef MOTIF_CLIPBOARDS
+  hack_motif_clipboard_selection (selection_atom, selection_value,
+				  thyme, display, selecting_window);
+#endif
+  return selection_time;
+}
+
+#ifdef MOTIF_CLIPBOARDS /* Bend over baby.  Take it and like it. */
+
+# ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
+static void motif_clipboard_cb ();
+# endif
+
+static void
+hack_motif_clipboard_selection (Atom selection_atom,
+				Lisp_Object selection_value,
+				Time thyme,
+				Display *display,
+                                                Window selecting_window)
+     /*				Bool owned_p)*/
+{
+  struct device *d = get_device_from_display (display);
+  /* Those Motif wankers can't be bothered to follow the ICCCM, and do
+     their own non-Xlib non-Xt clipboard processing.  So we have to do
+     this so that linked-in Motif widgets don't get themselves wedged.
+   */
+  if (selection_atom == DEVICE_XATOM_CLIPBOARD (d)
+      && STRINGP (selection_value)
+
+      /* If we already own the clipboard, don't own it again in the Motif
+	 way.  This might lose in some subtle way, since the timestamp won't
+	 be current, but owning the selection on the Motif way does a
+	 SHITLOAD of X protocol, and it makes killing text be incredibly
+	 slow when using an X terminal.  ARRRRGGGHHH!!!!
+       */
+      /* No, this is no good, because then Motif text fields don't bother
+	 to look up the new value, and you can't Copy from a buffer, Paste
+	 into a text field, then Copy something else from the buffer and
+	 paste it into the text field -- it pastes the first thing again. */
+/*      && !owned_p */
+      )
+    {
+#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
+      Widget widget = FRAME_X_TEXT_WIDGET (selected_frame());
+#endif
+      long itemid;
+#if XmVersion >= 1002
+      long dataid;
+#else
+      int dataid;	/* 1.2 wants long, but 1.1.5 wants int... */
+#endif
+      XmString fmh;
+      String encoding = "STRING";
+      CONST Extbyte *data  = XSTRING_DATA (selection_value);
+      Extcount bytes = XSTRING_LENGTH (selection_value);
+
+#ifdef MULE
+      {
+	enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
+	CONST Bufbyte *ptr = data, *end = ptr + bytes;
+	/* Optimize for the common ASCII case */
+	while (ptr <= end)
+	  {
+	    if (BYTE_ASCII_P (*ptr))
+	      {
+		ptr++;
+		continue;
+	      }
+
+	    if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
+		(*ptr) == LEADING_BYTE_CONTROL_1)
+	      {
+		chartypes = LATIN_1;
+		ptr += 2;
+		continue;
+	      }
+
+	    chartypes = WORLD;
+	    break;
+	  }
+
+	if (chartypes == LATIN_1)
+	  GET_STRING_BINARY_DATA_ALLOCA (selection_value, data, bytes);
+	else if (chartypes == WORLD)
+	  {
+	    GET_STRING_CTEXT_DATA_ALLOCA (selection_value, data, bytes);
+	    encoding = "COMPOUND_TEXT";
+	  }
+      }
+#endif /* MULE */
+
+      fmh = XmStringCreateLtoR ("Clipboard", XmSTRING_DEFAULT_CHARSET);
+      while (ClipboardSuccess !=
+	     XmClipboardStartCopy (display, selecting_window, fmh, thyme,
+#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
+				   widget, motif_clipboard_cb,
+#else
+				   0, NULL,
+#endif
+				   &itemid))
+	;
+      XmStringFree (fmh);
+      while (ClipboardSuccess !=
+	     XmClipboardCopy (display, selecting_window, itemid, encoding,
+#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
+			      /* O'Reilly examples say size can be 0,
+				 but this clearly is not the case. */
+			      0, bytes, (int) selecting_window, /* private id */
+#else /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
+			      (XtPointer) data, bytes, 0,
+#endif /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
+			      &dataid))
+	;
+      while (ClipboardSuccess !=
+	     XmClipboardEndCopy (display, selecting_window, itemid))
+	;
+    }
+}
+
+# ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
+/* I tried to treat the clipboard like a real selection, and not send
+   the data until it was requested, but it looks like that just doesn't
+   work at all unless the selection owner and requestor are in different
+   processes.  From reading the Motif source, it looks like they never
+   even considered having two widgets in the same application transfer
+   data between each other using "by-name" clipboard values.  What a
+   bunch of fuckups.
+ */
+static void
+motif_clipboard_cb (Widget widget, int *data_id, int *private_id, int *reason)
+{
+  switch (*reason)
+    {
+    case XmCR_CLIPBOARD_DATA_REQUEST:
+      {
+	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 ();
+	XmClipboardCopyByName (dpy, window, *data_id,
+			       (char *) XSTRING_DATA (selection),
+			       XSTRING_LENGTH (selection) + 1,
+			       0);
+      }
+      break;
+    case XmCR_CLIPBOARD_DATA_DELETE:
+    default:
+      /* don't need to free anything */
+      break;
+    }
+}
+# endif /* MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
+#endif /* MOTIF_CLIPBOARDS */
+
+
+
+
+/* Send a SelectionNotify event to the requestor with property=None, meaning
+   we were unable to do what they wanted.
+ */
+static void
+x_decline_selection_request (XSelectionRequestEvent *event)
+{
+  XSelectionEvent reply;
+  reply.type      = SelectionNotify;
+  reply.display   = event->display;
+  reply.requestor = event->requestor;
+  reply.selection = event->selection;
+  reply.time      = event->time;
+  reply.target    = event->target;
+  reply.property  = None;
+
+  XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
+  XFlush (reply.display);
+}
+
+
+/* Used as an unwind-protect clause so that, if a selection-converter signals
+   an error, we tell the requestor that we were unable to do what they wanted
+   before we throw to top-level or go into the debugger or whatever.
+ */
+static Lisp_Object
+x_selection_request_lisp_error (Lisp_Object closure)
+{
+  XSelectionRequestEvent *event = (XSelectionRequestEvent *)
+    get_opaque_ptr (closure);
+
+  free_opaque_ptr (closure);
+  if (event->type == 0) /* we set this to mean "completed normally" */
+    return Qnil;
+  x_decline_selection_request (event);
+  return Qnil;
+}
+
+
+/* Convert our selection to the requested type, and put that data where the
+   requestor wants it.  Then tell them whether we've succeeded.
+ */
+static void
+x_reply_selection_request (XSelectionRequestEvent *event, int format,
+			   unsigned char *data, int size, Atom type)
+{
+  /* This function can GC */
+  XSelectionEvent reply;
+  Display *display = event->display;
+  struct device *d = get_device_from_display (display);
+  Window window = event->requestor;
+  int bytes_remaining;
+  int format_bytes = format/8;
+  int max_bytes = SELECTION_QUANTUM (display);
+  if (max_bytes > MAX_SELECTION_QUANTUM) max_bytes = MAX_SELECTION_QUANTUM;
+
+  reply.type      = SelectionNotify;
+  reply.display   = display;
+  reply.requestor = window;
+  reply.selection = event->selection;
+  reply.time      = event->time;
+  reply.target    = event->target;
+  reply.property  = (event->property == None ? event->target : event->property);
+
+  /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
+
+  /* Store the data on the requested property.
+     If the selection is large, only store the first N bytes of it.
+   */
+  bytes_remaining = size * format_bytes;
+  if (bytes_remaining <= max_bytes)
+    {
+      /* Send all the data at once, with minimal handshaking. */
+#if 0
+      stderr_out ("\nStoring all %d\n", bytes_remaining);
+#endif
+      XChangeProperty (display, window, reply.property, type, format,
+		       PropModeReplace, data, size);
+      /* At this point, the selection was successfully stored; ack it. */
+      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
+      XFlush (display);
+    }
+  else
+    {
+      /* Send an INCR selection. */
+      int prop_id;
+
+      if (x_window_to_frame (d, window)) /* #### debug */
+	error ("attempt to transfer an INCR to ourself!");
+#if 0
+      stderr_out ("\nINCR %d\n", bytes_remaining);
+#endif
+      prop_id = expect_property_change (display, window, reply.property,
+					PropertyDelete);
+
+      XChangeProperty (display, window, reply.property, DEVICE_XATOM_INCR (d),
+		       32, PropModeReplace, (unsigned char *)
+		       &bytes_remaining, 1);
+      XSelectInput (display, window, PropertyChangeMask);
+      /* Tell 'em the INCR data is there... */
+      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
+      XFlush (display);
+
+      /* First, wait for the requestor to ack by deleting the property.
+	 This can run random lisp code (process handlers) or signal.
+       */
+      wait_for_property_change (prop_id);
+
+      while (bytes_remaining)
+	{
+	  int i = ((bytes_remaining < max_bytes)
+		   ? bytes_remaining
+		   : max_bytes);
+	  prop_id = expect_property_change (display, window, reply.property,
+					    PropertyDelete);
+#if 0
+	  stderr_out ("  INCR adding %d\n", i);
+#endif
+	  /* Append the next chunk of data to the property. */
+	  XChangeProperty (display, window, reply.property, type, format,
+			   PropModeAppend, data, i / format_bytes);
+	  bytes_remaining -= i;
+	  data += i;
+
+	  /* Now wait for the requestor to ack this chunk by deleting the
+	     property.	 This can run random lisp code or signal.
+	   */
+	  wait_for_property_change (prop_id);
+	}
+      /* Now write a zero-length chunk to the property to tell the requestor
+	 that we're done. */
+#if 0
+      stderr_out ("  INCR done\n");
+#endif
+      if (! waiting_for_other_props_on_window (display, window))
+	XSelectInput (display, window, 0L);
+
+      XChangeProperty (display, window, reply.property, type, format,
+		       PropModeReplace, data, 0);
+    }
+}
+
+
+
+/* Called from the event-loop in response to a SelectionRequest event.
+ */
+void
+x_handle_selection_request (XSelectionRequestEvent *event)
+{
+  /* This function can GC */
+  struct gcpro gcpro1, gcpro2, gcpro3;
+  Lisp_Object local_selection_data = Qnil;
+  Lisp_Object selection_symbol;
+  Lisp_Object target_symbol = Qnil;
+  Lisp_Object converted_selection = Qnil;
+  Time local_selection_time;
+  Lisp_Object successful_p = Qnil;
+  int count;
+  struct device *d = get_device_from_display (event->display);
+
+  GCPRO3 (local_selection_data, converted_selection, target_symbol);
+
+  selection_symbol = x_atom_to_symbol (d, event->selection);
+
+  local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
+
+#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))))));
+#endif
+
+  if (NILP (local_selection_data))
+    {
+      /* Someone asked for the selection, but we don't have it any more. */
+      x_decline_selection_request (event);
+      goto DONE_LABEL;
+    }
+
+  local_selection_time =
+    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
+
+  if (event->time != CurrentTime &&
+      local_selection_time > event->time)
+    {
+      /* Someone asked for the selection, and we have one, but not the one
+	 they're looking for. */
+      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);
+    }
+  unbind_to (count, Qnil);
+
+ DONE_LABEL:
+
+  UNGCPRO;
+
+  /* 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))
+      {
+	if (CONSP (val) && !EQ (XCAR (val), Qlambda))
+	  for (rest = val; !NILP (rest); rest = Fcdr (rest))
+	    call3 (Fcar(rest), selection_symbol, target_symbol,
+		   successful_p);
+	else
+	  call3 (val, selection_symbol, target_symbol,
+		 successful_p);
+      }
+  }
+}
+
+
+/* Called from the event-loop in response to a SelectionClear event.
+ */
+void
+x_handle_selection_clear (XSelectionClearEvent *event)
+{
+  Display *display = event->display;
+  struct device *d = get_device_from_display (display);
+  Atom selection = event->selection;
+  Time changed_owner_time = event->time;
+
+  Lisp_Object selection_symbol, local_selection_data;
+  Time local_selection_time;
+
+  selection_symbol = x_atom_to_symbol (d, selection);
+
+  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;
+
+  local_selection_time =
+    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
+
+  /* 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
+     request was generated.)
+   */
+  if (changed_owner_time != CurrentTime &&
+      local_selection_time > changed_owner_time)
+    return;
+  
+  handle_selection_clear (selection_symbol);
+}
+
+
+/* This stuff is so that INCR selections are reentrant (that is, so we can
+   be servicing multiple INCR selection requests simultaneously).  I haven't
+   actually tested that yet.
+ */
+
+static int prop_location_tick;
+
+static struct prop_location {
+  int tick;
+  Display *display;
+  Window window;
+  Atom property;
+  int desired_state;
+  struct prop_location *next;
+} *for_whom_the_bell_tolls;
+
+
+static int
+property_deleted_p (void *tick)
+{
+  struct prop_location *rest = for_whom_the_bell_tolls;
+  while (rest)
+    if (rest->tick == (long) tick)
+      return 0;
+    else
+      rest = rest->next;
+  return 1;
+}
+
+static int
+waiting_for_other_props_on_window (Display *display, Window window)
+{
+  struct prop_location *rest = for_whom_the_bell_tolls;
+  while (rest)
+    if (rest->display == display && rest->window == window)
+      return 1;
+    else
+      rest = rest->next;
+  return 0;
+}
+
+
+static int
+expect_property_change (Display *display, Window window,
+			Atom property, int state)
+{
+  struct prop_location *pl = xnew (struct prop_location);
+  pl->tick = ++prop_location_tick;
+  pl->display = display;
+  pl->window = window;
+  pl->property = property;
+  pl->desired_state = state;
+  pl->next = for_whom_the_bell_tolls;
+  for_whom_the_bell_tolls = pl;
+  return pl->tick;
+}
+
+static void
+unexpect_property_change (int tick)
+{
+  struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
+  while (rest)
+    {
+      if (rest->tick == tick)
+	{
+	  if (prev)
+	    prev->next = rest->next;
+	  else
+	    for_whom_the_bell_tolls = rest->next;
+	  xfree (rest);
+	  return;
+	}
+      prev = rest;
+      rest = rest->next;
+    }
+}
+
+static void
+wait_for_property_change (long tick)
+{
+  /* This function can GC */
+  wait_delaying_user_input (property_deleted_p, (void *) tick);
+}
+
+
+/* Called from the event-loop in response to a PropertyNotify event.
+ */
+void
+x_handle_property_notify (XPropertyEvent *event)
+{
+  struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
+  while (rest)
+    {
+      if (rest->property == event->atom &&
+	  rest->window == event->window &&
+	  rest->display == event->display &&
+	  rest->desired_state == event->state)
+	{
+#if 0
+	  stderr_out ("Saw expected prop-%s on %s\n",
+		   (event->state == PropertyDelete ? "delete" : "change"),
+		      (char *) string_data (XSYMBOL (x_atom_to_symbol (get_device_from_display (event->display), event->atom))->name);
+#endif
+	  if (prev)
+	    prev->next = rest->next;
+	  else
+	    for_whom_the_bell_tolls = rest->next;
+	  xfree (rest);
+	  return;
+	}
+      prev = rest;
+      rest = rest->next;
+    }
+#if 0
+  stderr_out ("Saw UNexpected prop-%s on %s\n",
+	   (event->state == PropertyDelete ? "delete" : "change"),
+	   (char *) string_data (XSYMBOL (x_atom_to_symbol (get_device_from_display (event->display), event->atom))->name));
+#endif
+}
+
+
+
+#if 0 /* #### MULTIPLE doesn't work yet */
+
+static Lisp_Object
+fetch_multiple_target (XSelectionRequestEvent *event)
+{
+  /* This function can GC */
+  Display *display = event->display;
+  Window window = event->requestor;
+  Atom target = event->target;
+  Atom selection_atom = event->selection;
+  int result;
+
+  return
+    Fcons (QMULTIPLE,
+	   x_get_window_property_as_lisp_data (display, window, target,
+					       QMULTIPLE,
+					       selection_atom));
+}
+
+static Lisp_Object
+copy_multiple_data (Lisp_Object obj)
+{
+  Lisp_Object vec;
+  int i;
+  int len;
+  if (CONSP (obj))
+    return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
+
+  CHECK_VECTOR (obj);
+  len = XVECTOR_LENGTH (obj);
+  vec = make_vector (len, Qnil);
+  for (i = 0; i < len; i++)
+    {
+      Lisp_Object vec2 = XVECTOR_DATA (obj) [i];
+      CHECK_VECTOR (vec2);
+      if (XVECTOR_LENGTH (vec2) != 2)
+	signal_error (Qerror, list2 (build_string
+				     ("vectors must be of length 2"),
+                                     vec2));
+      XVECTOR_DATA (vec) [i] = make_vector (2, Qnil);
+      XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [0] = XVECTOR_DATA (vec2) [0];
+      XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [1] = XVECTOR_DATA (vec2) [1];
+    }
+  return vec;
+}
+
+#endif /* 0 */
+
+
+static Window reading_selection_reply;
+static Atom reading_which_selection;
+static int selection_reply_timed_out;
+
+static int
+selection_reply_done (void *ignore)
+{
+  return !reading_selection_reply;
+}
+
+static Lisp_Object Qx_selection_reply_timeout_internal;
+
+DEFUN ("x-selection-reply-timeout-internal", Fx_selection_reply_timeout_internal,
+       1, 1, 0, /*
+*/
+       (arg))
+{
+  selection_reply_timed_out = 1;
+  reading_selection_reply = 0;
+  return Qnil;
+}
+
+
+/* Do protocol to read selection-data from the server.
+   Converts this to lisp data and returns it.
+ */
+static Lisp_Object
+x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
+{
+  /* This function can GC */
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  struct frame *sel_frame = selected_frame ();
+  Window requestor_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
+  Time requestor_time = DEVICE_X_MOUSE_TIMESTAMP (d);
+  Atom target_property = DEVICE_XATOM_EMACS_TMP (d);
+  Atom selection_atom = symbol_to_x_atom (d, selection_symbol, 0);
+  int speccount;
+  Atom type_atom = symbol_to_x_atom (d, (CONSP (target_type) ?
+					 XCAR (target_type) : target_type), 0);
+
+  XConvertSelection (display, selection_atom, type_atom, target_property,
+		     requestor_window, requestor_time);
+
+  /* Block until the reply has been read. */
+  reading_selection_reply = requestor_window;
+  reading_which_selection = selection_atom;
+  selection_reply_timed_out = 0;
+
+  speccount = specpdl_depth ();
+
+  /* add a timeout handler */
+  if (x_selection_timeout > 0)
+    {
+      Lisp_Object id = Fadd_timeout (make_int (x_selection_timeout),
+				     Qx_selection_reply_timeout_internal,
+				     Qnil, Qnil);
+      record_unwind_protect (Fdisable_timeout, id);
+    }
+
+  /* This is ^Gable */
+  wait_delaying_user_input (selection_reply_done, 0);
+
+  if (selection_reply_timed_out)
+    error ("timed out waiting for reply from selection owner");
+
+  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);
+}
+
+
+static void
+x_get_window_property (Display *display, Window window, Atom property,
+		       unsigned char **data_ret, int *bytes_ret,
+		       Atom *actual_type_ret, int *actual_format_ret,
+		       unsigned long *actual_size_ret, int delete_p)
+{
+  int total_size;
+  unsigned long bytes_remaining;
+  int offset = 0;
+  unsigned char *tmp_data = 0;
+  int result;
+  int buffer_size = SELECTION_QUANTUM (display);
+  if (buffer_size > MAX_SELECTION_QUANTUM) buffer_size = MAX_SELECTION_QUANTUM;
+
+  /* First probe the thing to find out how big it is. */
+  result = XGetWindowProperty (display, window, property,
+			       0, 0, False, AnyPropertyType,
+			       actual_type_ret, actual_format_ret,
+			       actual_size_ret,
+			       &bytes_remaining, &tmp_data);
+  if (result != Success)
+    {
+      *data_ret = 0;
+      *bytes_ret = 0;
+      return;
+    }
+  XFree ((char *) tmp_data);
+
+  if (*actual_type_ret == None || *actual_format_ret == 0)
+    {
+      if (delete_p) XDeleteProperty (display, window, property);
+      *data_ret = 0;
+      *bytes_ret = 0;
+      return;
+    }
+
+  total_size = bytes_remaining + 1;
+  *data_ret = (unsigned char *) xmalloc (total_size);
+
+  /* Now read, until we've gotten it all. */
+  while (bytes_remaining)
+    {
+#if 0
+      int last = bytes_remaining;
+#endif
+      result =
+	XGetWindowProperty (display, window, property,
+			    offset/4, buffer_size/4,
+			    (delete_p ? True : False),
+			    AnyPropertyType,
+			    actual_type_ret, actual_format_ret,
+			    actual_size_ret, &bytes_remaining, &tmp_data);
+#if 0
+      stderr_out ("<< read %d\n", last-bytes_remaining);
+#endif
+      /* If this doesn't return Success at this point, it means that
+	 some clod deleted the selection while we were in the midst of
+	 reading it.  Deal with that, I guess....
+       */
+      if (result != Success) break;
+      *actual_size_ret *= *actual_format_ret / 8;
+      memcpy ((*data_ret) + offset, tmp_data, *actual_size_ret);
+      offset += *actual_size_ret;
+      XFree ((char *) tmp_data);
+    }
+  *bytes_ret = offset;
+}
+
+
+static void
+receive_incremental_selection (Display *display, Window window, Atom property,
+			       /* this one is for error messages only */
+			       Lisp_Object target_type,
+			       unsigned int min_size_bytes,
+			       unsigned char **data_ret, int *size_bytes_ret,
+			       Atom *type_ret, int *format_ret,
+			       unsigned long *size_ret)
+{
+  /* This function can GC */
+  int offset = 0;
+  int prop_id;
+  *size_bytes_ret = min_size_bytes;
+  *data_ret = (unsigned char *) xmalloc (*size_bytes_ret);
+#if 0
+  stderr_out ("\nread INCR %d\n", min_size_bytes);
+#endif
+  /* At this point, we have read an INCR property, and deleted it (which
+     is how we ack its receipt: the sending window will be selecting
+     PropertyNotify events on our window to notice this).
+
+     Now, we must loop, waiting for the sending window to put a value on
+     that property, then reading the property, then deleting it to ack.
+     We are done when the sender places a property of length 0.
+   */
+  prop_id = expect_property_change (display, window, property,
+				    PropertyNewValue);
+  while (1)
+    {
+      unsigned char *tmp_data;
+      int tmp_size_bytes;
+      wait_for_property_change (prop_id);
+      /* expect it again immediately, because x_get_window_property may
+	 .. no it won't, I don't get it.
+	 .. Ok, I get it now, the Xt code that implements INCR is broken.
+       */
+      prop_id = expect_property_change (display, window, property,
+					PropertyNewValue);
+      x_get_window_property (display, window, property,
+			     &tmp_data, &tmp_size_bytes,
+			     type_ret, format_ret, size_ret, 1);
+
+      if (tmp_size_bytes == 0) /* we're done */
+	{
+#if 0
+	  stderr_out ("  read INCR done\n");
+#endif
+	  unexpect_property_change (prop_id);
+	  if (tmp_data) xfree (tmp_data);
+	  break;
+	}
+#if 0
+      stderr_out ("  read INCR %d\n", tmp_size_bytes);
+#endif
+      if (*size_bytes_ret < offset + tmp_size_bytes)
+	{
+#if 0
+	  stderr_out ("  read INCR realloc %d -> %d\n",
+		   *size_bytes_ret, offset + tmp_size_bytes);
+#endif
+	  *size_bytes_ret = offset + tmp_size_bytes;
+	  *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret);
+	}
+      memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes);
+      offset += tmp_size_bytes;
+      xfree (tmp_data);
+    }
+}
+
+
+static Lisp_Object
+x_get_window_property_as_lisp_data (Display *display,
+				    Window window,
+				    Atom property,
+				    /* next two for error messages only */
+				    Lisp_Object target_type,
+				    Atom selection_atom)
+{
+  /* This function can GC */
+  Atom actual_type;
+  int actual_format;
+  unsigned long actual_size;
+  unsigned char *data = NULL;
+  int bytes = 0;
+  Lisp_Object val;
+  struct device *d = get_device_from_display (display);
+
+  x_get_window_property (display, window, property, &data, &bytes,
+			 &actual_type, &actual_format, &actual_size, 1);
+  if (! data)
+    {
+      if (XGetSelectionOwner (display, selection_atom))
+	/* there is a selection owner */
+	signal_error
+	  (Qselection_conversion_error,
+	   Fcons (build_string ("selection owner couldn't convert"),
+		  Fcons (x_atom_to_symbol (d, selection_atom),
+			 actual_type ?
+			 list2 (target_type, x_atom_to_symbol (d, actual_type)) :
+			 list1 (target_type))));
+      else
+	signal_error (Qerror,
+		      list2 (build_string ("no selection"),
+			     x_atom_to_symbol (d, selection_atom)));
+    }
+
+  if (actual_type == DEVICE_XATOM_INCR (d))
+    {
+      /* Ok, that data wasn't *the* data, it was just the beginning. */
+
+      unsigned int min_size_bytes = * ((unsigned int *) data);
+      xfree (data);
+      receive_incremental_selection (display, window, property, target_type,
+				     min_size_bytes, &data, &bytes,
+				     &actual_type, &actual_format,
+				     &actual_size);
+    }
+
+  /* It's been read.  Now convert it to a lisp object in some semi-rational
+     manner. */
+  val = selection_data_to_lisp_data (d, data, bytes,
+				     actual_type, actual_format);
+
+  xfree (data);
+  return val;
+}
+
+/* These functions convert from the selection data read from the server into
+   something that we can use from elisp, and vice versa.
+
+	Type:	Format:	Size:		Elisp Type:
+	-----	-------	-----		-----------
+	*	8	*		String
+	ATOM	32	1		Symbol
+	ATOM	32	> 1		Vector of Symbols
+	*	16	1		Integer
+	*	16	> 1		Vector of Integers
+	*	32	1		if <=16 bits: Integer
+					if > 16 bits: Cons of top16, bot16
+	*	32	> 1		Vector of the above
+
+   When converting a Lisp number to C, it is assumed to be of format 16 if
+   it is an integer, and of format 32 if it is a cons of two integers.
+
+   When converting a vector of numbers from Elisp to C, it is assumed to be
+   of format 16 if every element in the vector is an integer, and is assumed
+   to be of format 32 if any element is a cons of two integers.
+
+   When converting an object to C, it may be of the form (SYMBOL . <data>)
+   where SYMBOL is what we should claim that the type is.  Format and
+   representation are as above.
+
+   NOTE: Under Mule, when someone shoves us a string without a type, we
+   set the type to 'COMPOUND_TEXT and automatically convert to Compound
+   Text.  If the string has a type, we assume that the user wants the
+   data sent as-is so we just do "binary" conversion.
+ */
+
+
+static Lisp_Object
+selection_data_to_lisp_data (struct device *d,
+			     unsigned char *data,
+			     size_t size,
+			     Atom type,
+			     int format)
+{
+  if (type == DEVICE_XATOM_NULL (d))
+    return QNULL;
+
+  /* Convert any 8-bit data to a string, for compactness. */
+  else if (format == 8)
+    return make_ext_string (data, size,
+			    type == DEVICE_XATOM_TEXT (d) ||
+			    type == DEVICE_XATOM_COMPOUND_TEXT (d)
+			    ? FORMAT_CTEXT : FORMAT_BINARY);
+
+  /* Convert a single atom to a Lisp Symbol.
+     Convert a set of atoms to a vector of symbols. */
+  else if (type == XA_ATOM)
+    {
+      if (size == sizeof (Atom))
+	return x_atom_to_symbol (d, *((Atom *) data));
+      else
+	{
+	  int i;
+	  int len = size / sizeof (Atom);
+	  Lisp_Object v = Fmake_vector (make_int (len), Qzero);
+	  for (i = 0; i < len; i++)
+	    Faset (v, make_int (i), x_atom_to_symbol (d, ((Atom *) data) [i]));
+	  return v;
+	}
+    }
+
+  /* Convert a single 16 or small 32 bit number to a Lisp Int.
+     If the number is > 16 bits, convert it to a cons of integers,
+     16 bits in each half.
+   */
+  else if (format == 32 && size == sizeof (long))
+    return word_to_lisp (((unsigned long *) data) [0]);
+  else if (format == 16 && size == sizeof (short))
+    return make_int ((int) (((unsigned short *) data) [0]));
+
+  /* Convert any other kind of data to a vector of numbers, represented
+     as above (as an integer, or a cons of two 16 bit integers).
+
+     #### Perhaps we should return the actual type to lisp as well.
+
+	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
+	==> [4 4]
+
+     and perhaps it should be
+
+	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
+	==> (SPAN . [4 4])
+
+     Right now the fact that the return type was SPAN is discarded before
+     lisp code gets to see it.
+   */
+  else if (format == 16)
+    {
+      int i;
+      Lisp_Object v = make_vector (size / 4, Qzero);
+      for (i = 0; i < (int) size / 4; i++)
+	{
+	  int j = (int) ((unsigned short *) data) [i];
+	  Faset (v, make_int (i), make_int (j));
+	}
+      return v;
+    }
+  else
+    {
+      int i;
+      Lisp_Object v = make_vector (size / 4, Qzero);
+      for (i = 0; i < (int) size / 4; i++)
+	{
+	  unsigned long j = ((unsigned long *) data) [i];
+	  Faset (v, make_int (i), word_to_lisp (j));
+	}
+      return v;
+    }
+}
+
+
+static void
+lisp_data_to_selection_data (struct device *d,
+			     Lisp_Object obj,
+			     unsigned char **data_ret,
+			     Atom *type_ret,
+			     unsigned int *size_ret,
+			     int *format_ret)
+{
+  Lisp_Object type = Qnil;
+
+  if (CONSP (obj) && SYMBOLP (XCAR (obj)))
+    {
+      type = XCAR (obj);
+      obj = XCDR (obj);
+      if (CONSP (obj) && NILP (XCDR (obj)))
+	obj = XCAR (obj);
+    }
+
+  if (EQ (obj, QNULL) || (EQ (type, QNULL)))
+    {				/* This is not the same as declining */
+      *format_ret = 32;
+      *size_ret = 0;
+      *data_ret = 0;
+      type = QNULL;
+    }
+  else if (STRINGP (obj))
+    {
+      CONST Extbyte *extval;
+      Extcount extvallen;
+
+      if (NILP (type))
+	GET_STRING_CTEXT_DATA_ALLOCA (obj, extval, extvallen);
+      else
+	GET_STRING_BINARY_DATA_ALLOCA (obj, extval, extvallen);
+      *format_ret = 8;
+      *size_ret = extvallen;
+      *data_ret = (unsigned char *) xmalloc (*size_ret);
+      memcpy (*data_ret, extval, *size_ret);
+#ifdef MULE
+      if (NILP (type)) type = QCOMPOUND_TEXT;
+#else
+      if (NILP (type)) type = QSTRING;
+#endif
+    }
+  else if (CHARP (obj))
+    {
+      Bufbyte buf[MAX_EMCHAR_LEN];
+      Bytecount len;
+      CONST Extbyte *extval;
+      Extcount extvallen;
+
+      *format_ret = 8;
+      len = set_charptr_emchar (buf, XCHAR (obj));
+      GET_CHARPTR_EXT_CTEXT_DATA_ALLOCA (buf, len, extval, extvallen);
+      *size_ret = extvallen;
+      *data_ret = (unsigned char *) xmalloc (*size_ret);
+      memcpy (*data_ret, extval, *size_ret);
+#ifdef MULE
+      if (NILP (type)) type = QCOMPOUND_TEXT;
+#else
+      if (NILP (type)) type = QSTRING;
+#endif
+    }
+  else if (SYMBOLP (obj))
+    {
+      *format_ret = 32;
+      *size_ret = 1;
+      *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
+      (*data_ret) [sizeof (Atom)] = 0;
+      (*(Atom **) data_ret) [0] = symbol_to_x_atom (d, obj, 0);
+      if (NILP (type)) type = QATOM;
+    }
+  else if (INTP (obj) &&
+	   XINT (obj) <= 0x7FFF &&
+	   XINT (obj) >= -0x8000)
+    {
+      *format_ret = 16;
+      *size_ret = 1;
+      *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1);
+      (*data_ret) [sizeof (short)] = 0;
+      (*(short **) data_ret) [0] = (short) XINT (obj);
+      if (NILP (type)) type = QINTEGER;
+    }
+  else if (INTP (obj) || CONSP (obj))
+    {
+      *format_ret = 32;
+      *size_ret = 1;
+      *data_ret = (unsigned char *) xmalloc (sizeof (long) + 1);
+      (*data_ret) [sizeof (long)] = 0;
+      (*(unsigned long **) data_ret) [0] = lisp_to_word (obj);
+      if (NILP (type)) type = QINTEGER;
+    }
+  else if (VECTORP (obj))
+    {
+      /* Lisp Vectors may represent a set of ATOMs;
+	 a set of 16 or 32 bit INTEGERs;
+	 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...]
+       */
+      int i;
+
+      if (SYMBOLP (XVECTOR_DATA (obj) [0]))
+	/* This vector is an ATOM set */
+	{
+	  if (NILP (type)) type = QATOM;
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  *format_ret = 32;
+	  *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom));
+	  for (i = 0; i < (int) (*size_ret); i++)
+	    if (SYMBOLP (XVECTOR_DATA (obj) [i]))
+	      (*(Atom **) data_ret) [i] =
+		symbol_to_x_atom (d, XVECTOR_DATA (obj) [i], 0);
+	    else
+              signal_error (Qerror, /* Qselection_error */
+                            list2 (build_string
+		   ("all elements of the vector must be of the same type"),
+                                   obj));
+	}
+#if 0 /* #### MULTIPLE doesn't work yet */
+      else if (VECTORP (XVECTOR_DATA (obj) [0]))
+	/* This vector is an ATOM_PAIR set */
+	{
+	  if (NILP (type)) type = QATOM_PAIR;
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  *format_ret = 32;
+	  *data_ret = (unsigned char *)
+	    xmalloc ((*size_ret) * sizeof (Atom) * 2);
+	  for (i = 0; i < *size_ret; i++)
+	    if (VECTORP (XVECTOR_DATA (obj) [i]))
+	      {
+		Lisp_Object pair = XVECTOR_DATA (obj) [i];
+		if (XVECTOR_LENGTH (pair) != 2)
+		  signal_error (Qerror,
+                                list2 (build_string
+       ("elements of the vector must be vectors of exactly two elements"),
+				  pair));
+
+		(*(Atom **) data_ret) [i * 2] =
+		  symbol_to_x_atom (d, XVECTOR_DATA (pair) [0], 0);
+		(*(Atom **) data_ret) [(i * 2) + 1] =
+		  symbol_to_x_atom (d, XVECTOR_DATA (pair) [1], 0);
+	      }
+	    else
+	      signal_error (Qerror,
+                            list2 (build_string
+		   ("all elements of the vector must be of the same type"),
+                                   obj));
+	}
+#endif
+      else
+	/* This vector is an INTEGER set, or something like it */
+	{
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  if (NILP (type)) type = QINTEGER;
+	  *format_ret = 16;
+	  for (i = 0; i < (int) (*size_ret); i++)
+	    if (CONSP (XVECTOR_DATA (obj) [i]))
+	      *format_ret = 32;
+	    else if (!INTP (XVECTOR_DATA (obj) [i]))
+	      signal_error (Qerror, /* Qselection_error */
+                            list2 (build_string
+	("all elements of the vector must be integers or conses of integers"),
+                                   obj));
+
+	  *data_ret = (unsigned char *) xmalloc (*size_ret * (*format_ret/8));
+	  for (i = 0; i < (int) (*size_ret); i++)
+	    if (*format_ret == 32)
+	      (*((unsigned long **) data_ret)) [i] =
+		lisp_to_word (XVECTOR_DATA (obj) [i]);
+	    else
+	      (*((unsigned short **) data_ret)) [i] =
+		(unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]);
+	}
+    }
+  else
+    signal_error (Qerror, /* Qselection_error */
+                  list2 (build_string ("unrecognized selection data"),
+                         obj));
+
+  *type_ret = symbol_to_x_atom (d, type, 0);
+}
+
+
+
+/* Called from the event loop to handle SelectionNotify events.
+   I don't think this needs to be reentrant.
+ */
+void
+x_handle_selection_notify (XSelectionEvent *event)
+{
+  if (! reading_selection_reply)
+    message ("received an unexpected SelectionNotify event");
+  else if (event->requestor != reading_selection_reply)
+    message ("received a SelectionNotify event for the wrong window");
+  else if (event->selection != reading_which_selection)
+    message ("received the wrong selection type in SelectionNotify!");
+  else
+    reading_selection_reply = 0; /* we're done now. */
+}
+
+static void
+x_disown_selection (Lisp_Object selection, Lisp_Object timeval)
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  Time timestamp;
+  Atom selection_atom;
+
+  CHECK_SYMBOL (selection);
+  if (NILP (timeval))
+    timestamp = DEVICE_X_MOUSE_TIMESTAMP (d);
+  else
+    {
+      /* #### This is bogus.  See the comment above about problems
+	 on OSF/1 and DEC Alphas.  Yet another reason why it sucks
+	 to have the implementation (i.e. cons of two 16-bit
+	 integers) exposed. */
+      time_t the_time;
+      lisp_to_time (timeval, &the_time);
+      timestamp = (Time) the_time;
+    }
+
+  selection_atom = symbol_to_x_atom (d, selection, 0);
+
+  XSetSelectionOwner (display, selection_atom, None, timestamp);
+}
+
+static Lisp_Object
+x_selection_exists_p (Lisp_Object selection)
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *dpy = DEVICE_X_DISPLAY (d);
+  return XGetSelectionOwner (dpy, symbol_to_x_atom (d, selection, 0)) != None ?
+    Qt : Qnil;
+}
+
+
+#ifdef CUT_BUFFER_SUPPORT
+
+static int cut_buffers_initialized; /* Whether we're sure they all exist */
+
+/* Ensure that all 8 cut buffers exist.  ICCCM says we gotta... */
+static void
+initialize_cut_buffers (Display *display, Window window)
+{
+  static unsigned CONST char * CONST data = (unsigned CONST char *) "";
+#define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \
+				    PropModeAppend, data, 0)
+  FROB (XA_CUT_BUFFER0);
+  FROB (XA_CUT_BUFFER1);
+  FROB (XA_CUT_BUFFER2);
+  FROB (XA_CUT_BUFFER3);
+  FROB (XA_CUT_BUFFER4);
+  FROB (XA_CUT_BUFFER5);
+  FROB (XA_CUT_BUFFER6);
+  FROB (XA_CUT_BUFFER7);
+#undef FROB
+  cut_buffers_initialized = 1;
+}
+
+#define CHECK_CUTBUFFER(symbol)						\
+  { CHECK_SYMBOL (symbol);						\
+    if (!EQ((symbol),QCUT_BUFFER0) && !EQ((symbol),QCUT_BUFFER1) &&	\
+	!EQ((symbol),QCUT_BUFFER2) && !EQ((symbol),QCUT_BUFFER3) &&	\
+	!EQ((symbol),QCUT_BUFFER4) && !EQ((symbol),QCUT_BUFFER5) &&	\
+	!EQ((symbol),QCUT_BUFFER6) && !EQ((symbol),QCUT_BUFFER7))	\
+      signal_error (Qerror, list2 (build_string ("Doesn't name a cutbuffer"), \
+                                   (symbol))); \
+  }
+
+DEFUN ("x-get-cutbuffer-internal", Fx_get_cutbuffer_internal, 1, 1, 0, /*
+Return the value of the named CUTBUFFER (typically CUT_BUFFER0).
+*/
+       (cutbuffer))
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
+  Atom cut_buffer_atom;
+  unsigned char *data;
+  int bytes;
+  Atom type;
+  int format;
+  unsigned long size;
+  Lisp_Object ret;
+
+  CHECK_CUTBUFFER (cutbuffer);
+  cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
+
+  x_get_window_property (display, window, cut_buffer_atom, &data, &bytes,
+			 &type, &format, &size, 0);
+  if (!data) return Qnil;
+
+  if (format != 8 || type != XA_STRING)
+    signal_simple_error_2 ("Cut buffer doesn't contain 8-bit STRING data",
+			   x_atom_to_symbol (d, type),
+			   make_int (format));
+
+  /* We cheat - if the string contains an ESC character, that's
+     technically not allowed in a STRING, so we assume it's
+     COMPOUND_TEXT that we stored there ourselves earlier,
+     in x-store-cutbuffer-internal  */
+  ret = (bytes ?
+	 make_ext_string (data, bytes,
+			  memchr (data, 0x1b, bytes) ?
+			  FORMAT_CTEXT : FORMAT_BINARY)
+	 : Qnil);
+  xfree (data);
+  return ret;
+}
+
+
+DEFUN ("x-store-cutbuffer-internal", Fx_store_cutbuffer_internal, 2, 2, 0, /*
+Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING.
+*/
+       (cutbuffer, string))
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
+  Atom cut_buffer_atom;
+  CONST Extbyte *data  = XSTRING_DATA (string);
+  Extcount bytes = XSTRING_LENGTH (string);
+  Extcount bytes_remaining;
+  int max_bytes = SELECTION_QUANTUM (display);
+#ifdef MULE
+  CONST Bufbyte *ptr, *end;
+  enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
+#endif
+
+  if (max_bytes > MAX_SELECTION_QUANTUM)
+    max_bytes = MAX_SELECTION_QUANTUM;
+
+  CHECK_CUTBUFFER (cutbuffer);
+  CHECK_STRING (string);
+  cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
+
+  if (! cut_buffers_initialized)
+    initialize_cut_buffers (display, window);
+
+  /* We use the STRING encoding (Latin-1 only) if we can, else COMPOUND_TEXT.
+     We cheat and use type = `STRING' even when using COMPOUND_TEXT.
+     The ICCCM requires that this be so, and other clients assume it,
+     as we do ourselves in initialize_cut_buffers.  */
+
+#ifdef MULE
+  /* Optimize for the common ASCII case */
+  for (ptr = data, end = ptr + bytes; ptr <= end; )
+    {
+      if (BYTE_ASCII_P (*ptr))
+	{
+	  ptr++;
+	  continue;
+	}
+
+      if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
+	  (*ptr) == LEADING_BYTE_CONTROL_1)
+	{
+	  chartypes = LATIN_1;
+	  ptr += 2;
+	  continue;
+	}
+
+      chartypes = WORLD;
+      break;
+    }
+
+  if (chartypes == LATIN_1)
+    GET_STRING_BINARY_DATA_ALLOCA (string, data, bytes);
+  else if (chartypes == WORLD)
+    GET_STRING_CTEXT_DATA_ALLOCA  (string, data, bytes);
+#endif /* MULE */
+
+  bytes_remaining = bytes;
+
+  while (bytes_remaining)
+    {
+      int chunk = bytes_remaining < max_bytes ? bytes_remaining : max_bytes;
+      XChangeProperty (display, window, cut_buffer_atom, XA_STRING, 8,
+		       (bytes_remaining == bytes
+			? PropModeReplace : PropModeAppend),
+		       data, chunk);
+      data += chunk;
+      bytes_remaining -= chunk;
+    }
+  return string;
+}
+
+
+DEFUN ("x-rotate-cutbuffers-internal", Fx_rotate_cutbuffers_internal, 1, 1, 0, /*
+Rotate the values of the cutbuffers by the given number of steps;
+positive means move values forward, negative means backward.
+*/
+       (n))
+{
+  struct device *d = decode_x_device (Qnil);
+  Display *display = DEVICE_X_DISPLAY (d);
+  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
+  Atom props [8];
+
+  CHECK_INT (n);
+  if (XINT (n) == 0)
+    return n;
+  if (! cut_buffers_initialized)
+    initialize_cut_buffers (display, window);
+  props[0] = XA_CUT_BUFFER0;
+  props[1] = XA_CUT_BUFFER1;
+  props[2] = XA_CUT_BUFFER2;
+  props[3] = XA_CUT_BUFFER3;
+  props[4] = XA_CUT_BUFFER4;
+  props[5] = XA_CUT_BUFFER5;
+  props[6] = XA_CUT_BUFFER6;
+  props[7] = XA_CUT_BUFFER7;
+  XRotateWindowProperties (display, window, props, 8, XINT (n));
+  return n;
+}
+
+#endif /* CUT_BUFFER_SUPPORT */
+
+
+
+/************************************************************************/
+/*                            initialization                            */
+/************************************************************************/
+
+void
+syms_of_xselect (void)
+{
+
+#ifdef CUT_BUFFER_SUPPORT
+  DEFSUBR (Fx_get_cutbuffer_internal);
+  DEFSUBR (Fx_store_cutbuffer_internal);
+  DEFSUBR (Fx_rotate_cutbuffers_internal);
+#endif /* CUT_BUFFER_SUPPORT */
+
+  /* Unfortunately, timeout handlers must be lisp functions. */
+  defsymbol (&Qx_selection_reply_timeout_internal,
+             "x-selection-reply-timeout-internal");
+  DEFSUBR (Fx_selection_reply_timeout_internal);
+
+#ifdef CUT_BUFFER_SUPPORT
+  defsymbol (&QCUT_BUFFER0, "CUT_BUFFER0");
+  defsymbol (&QCUT_BUFFER1, "CUT_BUFFER1");
+  defsymbol (&QCUT_BUFFER2, "CUT_BUFFER2");
+  defsymbol (&QCUT_BUFFER3, "CUT_BUFFER3");
+  defsymbol (&QCUT_BUFFER4, "CUT_BUFFER4");
+  defsymbol (&QCUT_BUFFER5, "CUT_BUFFER5");
+  defsymbol (&QCUT_BUFFER6, "CUT_BUFFER6");
+  defsymbol (&QCUT_BUFFER7, "CUT_BUFFER7");
+#endif /* CUT_BUFFER_SUPPORT */
+}
+
+void
+console_type_create_select_x (void)
+{
+  CONSOLE_HAS_METHOD (x, own_selection);
+  CONSOLE_HAS_METHOD (x, disown_selection);
+  CONSOLE_HAS_METHOD (x, get_foreign_selection);
+  CONSOLE_HAS_METHOD (x, selection_exists_p);
+}
+
+void
+vars_of_xselect (void)
+{
+#ifdef CUT_BUFFER_SUPPORT
+  cut_buffers_initialized = 0;
+  Fprovide (intern ("cut-buffer"));
+#endif
+
+  reading_selection_reply = 0;
+  reading_which_selection = 0;
+  selection_reply_timed_out = 0;
+  for_whom_the_bell_tolls = 0;
+  prop_location_tick = 0;
+
+  DEFVAR_LISP ("x-sent-selection-hooks", &Vx_sent_selection_hooks /*
+A function or functions to be called after we have responded to some
+other client's request for the value of a selection that we own.  The
+function(s) will be called with four arguments:
+  - the name of the selection (typically PRIMARY, SECONDARY, or CLIPBOARD);
+  - the name of the selection-type which we were requested to convert the
+    selection into before sending (for example, STRING or LENGTH);
+  - and whether we successfully transmitted the selection.
+We might have failed (and declined the request) for any number of reasons,
+including being asked for a selection that we no longer own, or being asked
+to convert into a type that we don't know about or that is inappropriate.
+This hook doesn't let you change the behavior of emacs's selection replies,
+it merely informs you that they have happened.
+*/ );
+  Vx_sent_selection_hooks = Qunbound;
+
+  DEFVAR_INT ("x-selection-timeout", &x_selection_timeout /*
+If the selection owner doesn't reply in this many seconds, we give up.
+A value of 0 means wait as long as necessary.  This is initialized from the
+\"*selectionTimeout\" resource (which is expressed in milliseconds).
+*/ );
+  x_selection_timeout = 0;
+}
+
+void
+Xatoms_of_xselect (struct device *d)
+{
+  Display *D = DEVICE_X_DISPLAY (d);
+
+  /* Non-predefined atoms that we might end up using a lot */
+  DEVICE_XATOM_CLIPBOARD     (d) = XInternAtom (D, "CLIPBOARD",     False);
+  DEVICE_XATOM_TIMESTAMP     (d) = XInternAtom (D, "TIMESTAMP",     False);
+  DEVICE_XATOM_TEXT          (d) = XInternAtom (D, "TEXT",          False);
+  DEVICE_XATOM_DELETE        (d) = XInternAtom (D, "DELETE",        False);
+  DEVICE_XATOM_MULTIPLE      (d) = XInternAtom (D, "MULTIPLE",      False);
+  DEVICE_XATOM_INCR          (d) = XInternAtom (D, "INCR",          False);
+  DEVICE_XATOM_TARGETS       (d) = XInternAtom (D, "TARGETS",       False);
+  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);
+  DEVICE_XATOM_EMACS_TMP     (d) = XInternAtom (D, "_EMACS_TMP_",   False);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/select.c	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,488 @@
+/* Generic selection processing for XEmacs
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999 Andy Piper.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not synched with FSF. */
+
+#include <config.h>
+#include "lisp.h"
+
+#include "buffer.h"
+#include "device.h"
+#include "console.h"
+#include "objects.h"
+
+#include "frame.h"
+#include "opaque.h"
+#include "select.h"
+
+Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
+  QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
+  QATOM_PAIR, QCOMPOUND_TEXT;
+
+/* "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.
+ */
+Lisp_Object Vselection_converter_alist;
+
+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-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.
+ */
+Lisp_Object Vselection_alist;
+
+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;
+
+  /* TIMESTAMP and MULTIPLE are special cases 'cause that's easiest. */
+  if (EQ (target_type, QTIMESTAMP))
+    {
+      handler_fn = Qnil;
+      value = XCAR (XCDR (XCDR (local_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 */
+}
+
+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.
+VALUE is typically a string, or a cons of two markers, but may be
+anything that the functions on selection-converter-alist know about.
+*/
+       (selection_name, selection_value, device))
+{
+  Lisp_Object selection_time, selection_data, prev_value;
+
+  CHECK_SYMBOL (selection_name);
+  if (NILP (selection_value)) error ("selection-value may not be nil.");
+
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+  /* Now update the local cache */
+  selection_data = list3 (selection_name,
+			  selection_value,
+			  Qnil);
+  prev_value = assq_no_quit (selection_name, Vselection_alist);
+  Vselection_alist = Fcons (selection_data, Vselection_alist);
+    
+  /* 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))
+    {
+      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))))
+	  {
+	    XCDR (rest) = Fcdr (XCDR (rest));
+	    break;
+	  }
+    }
+
+  /* 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));
+  else
+    selection_time = Qnil;
+
+  Fsetcar (XCDR (XCDR (selection_data)), selection_time);
+
+  return selection_value;
+}
+
+/* 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);
+
+  /* Well, we already believe that we don't own it, so that's just fine. */
+  if (NILP (local_selection_data)) return;
+
+  /* Otherwise, we're really honest and truly being told to drop it.
+     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;
+	  }
+    }
+
+  /* Let random lisp code notice that the selection has been stolen.
+   */
+  {
+    Lisp_Object rest;
+    Lisp_Object val = Vlost_selection_hooks;
+    if (!UNBOUNDP (val) && !NILP (val))
+      {
+	if (CONSP (val) && !EQ (XCAR (val), Qlambda))
+	  for (rest = val; !NILP (rest); rest = Fcdr (rest))
+	    call1 (Fcar (rest), selection_symbol);
+	else
+	  call1 (val, selection_symbol);
+      }
+  }
+}
+
+DEFUN ("disown-selection-internal", Fdisown_selection_internal, 1, 3, 0, /*
+If we own the named selection, then disown it (make there be no selection).
+*/
+       (selection_name, selection_time, device))
+{
+  if (NILP (assq_no_quit (selection_name, Vselection_alist)))
+    return Qnil;  /* Don't disown the selection when we're not the owner. */
+
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+  MAYBE_DEVMETH (XDEVICE (device), disown_selection,
+		 (selection_name, selection_time));
+  
+  handle_selection_clear (selection_name);
+
+  return Qt;
+}
+
+DEFUN ("selection-owner-p", Fselection_owner_p, 0, 1, 0, /*
+Return t if current emacs process owns 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.)
+*/
+       (selection))
+{
+  CHECK_SYMBOL (selection);
+  if      (EQ (selection, Qnil)) selection = QPRIMARY;
+  else if (EQ (selection, Qt))   selection = QSECONDARY;
+
+  return NILP (Fassq (selection, Vselection_alist)) ? Qnil : Qt;
+}
+
+DEFUN ("selection-exists-p", Fselection_exists_p, 0, 2, 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.)
+*/
+       (selection, device))
+{
+  CHECK_SYMBOL (selection);
+  if (!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))
+    : 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.
+ */
+DEFUN ("get-selection-internal", Fget_selection_internal, 2, 3, 0, /*
+Return text selected from some window-system window.
+SELECTION_SYMBOL is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
+TARGET_TYPE is the type of data desired, typically STRING or COMPOUND_TEXT.
+Under Mule, if the resultant data comes back as 8-bit data in type
+TEXT or COMPOUND_TEXT, it will be decoded as Compound Text.
+*/
+       (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 */
+  CHECK_SYMBOL (selection_symbol);
+
+  if (NILP (device))
+    device = Fselected_device (Qnil);
+
+#if 0 /* #### MULTIPLE doesn't work yet and probably never will */
+  if (CONSP (target_type) &&
+      XCAR (target_type) == QMULTIPLE)
+    {
+      CHECK_VECTOR (XCDR (target_type));
+      /* So we don't destructively modify this... */
+      target_type = copy_multiple_data (target_type);
+    }
+  else
+#endif
+    CHECK_SYMBOL (target_type);
+
+  val = get_local_selection (selection_symbol, target_type);
+
+  if (NILP (val) && (HAS_DEVMETH_P (XDEVICE (device), get_foreign_selection)))
+    {
+      val = DEVMETH (XDEVICE (device), get_foreign_selection,
+		     (selection_symbol, target_type));
+    }
+  else
+    {
+      if (CONSP (val) && SYMBOLP (XCAR (val)))
+	{
+	  val = XCDR (val);
+	  if (CONSP (val) && NILP (XCDR (val)))
+	    val = XCAR (val);
+	}
+      val = clean_local_selection_data (val);
+    }
+  UNGCPRO;
+  return val;
+}
+
+void
+syms_of_select (void)
+{
+  DEFSUBR (Fown_selection_internal);
+  DEFSUBR (Fget_selection_internal);
+  DEFSUBR (Fselection_exists_p);
+  DEFSUBR (Fdisown_selection_internal);
+  DEFSUBR (Fselection_owner_p);
+
+  defsymbol (&QPRIMARY, "PRIMARY");
+  defsymbol (&QSECONDARY, "SECONDARY");
+  defsymbol (&QSTRING, "STRING");
+  defsymbol (&QINTEGER, "INTEGER");
+  defsymbol (&QCLIPBOARD, "CLIPBOARD");
+  defsymbol (&QTIMESTAMP, "TIMESTAMP");
+  defsymbol (&QTEXT, "TEXT");
+  defsymbol (&QDELETE, "DELETE");
+  defsymbol (&QMULTIPLE, "MULTIPLE");
+  defsymbol (&QINCR, "INCR");
+  defsymbol (&QEMACS_TMP, "_EMACS_TMP_");
+  defsymbol (&QTARGETS, "TARGETS");
+  defsymbol (&QATOM, "ATOM");
+  defsymbol (&QATOM_PAIR, "ATOM_PAIR");
+  defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT");
+  defsymbol (&QNULL, "NULL");
+
+  deferror (&Qselection_conversion_error,
+	    "selection-conversion-error",
+	    "selection-conversion error", Qio_error);
+}
+
+void
+vars_of_select (void)
+{
+  Vselection_alist = Qnil;
+  staticpro (&Vselection_alist);
+
+  DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_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:
+
+-- nil (the conversion could not be done)
+-- a cons of a symbol and any of the following values; the symbol
+   explicitly specifies the type that will be sent.
+-- a string (If the type is not specified, then if Mule support exists,
+             the string will be converted to Compound Text and sent in
+             the 'COMPOUND_TEXT format; otherwise (no Mule support),
+             the string will be left as-is and sent in the 'STRING
+             format.  If the type is specified, the string will be
+             left as-is (or converted to binary format under Mule).
+             In all cases, 8-bit data it sent.)
+-- a character (With Mule support, will be converted to Compound Text
+                whether or not a type is specified.  If a type is not
+                specified, a type of 'STRING or 'COMPOUND_TEXT will be
+		sent, as for strings.)
+-- the symbol 'NULL (Indicates that there is no meaningful return value.
+                     Empty 32-bit data with a type of 'NULL will be sent.)
+-- a symbol (Will be converted into an atom.  If the type is not specified,
+             a type of 'ATOM will be sent.)
+-- an integer (Will be converted into a 16-bit or 32-bit integer depending
+               on the value.  If the type is not specified, a type of
+	       'INTEGER will be sent.)
+-- a cons (HIGH . LOW) of integers (Will be converted into a 32-bit integer.
+                                    If the type is not specified, a type of
+				    'INTEGER will be sent.)
+-- a vector of symbols (Will be converted into a list of atoms.  If the type
+                        is not specified, a type of 'ATOM will be sent.)
+-- a vector 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.)
+-- 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;
+
+  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
+argument, a symbol naming the selection (typically PRIMARY, SECONDARY, or
+CLIPBOARD).
+*/ );
+  Vlost_selection_hooks = Qunbound;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/select.h	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,50 @@
+/* Generic select data structures functions
+   Copyright (C) 1999 Andy Piper
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in FSF. */
+
+#ifndef _XEMACS_SELECT_H_
+#define _XEMACS_SELECT_H_
+
+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;
+
+/* "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);
+void handle_selection_clear (Lisp_Object selection_symbol);
+
+#endif
--- a/src/sheap.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/sheap.c	Mon Aug 13 11:21:38 2007 +0200
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <sheap-adjust.h>
 
-#define STATIC_HEAP_BASE	0x600000
+#define STATIC_HEAP_BASE	0x800000
 #define STATIC_HEAP_SLOP	0x40000
 #define STATIC_HEAP_SIZE \
 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
@@ -103,7 +103,7 @@
   return result;
 }
 
-void
+static void
 sheap_adjust_h ()
 {
   FILE *stream = fopen ("sheap-adjust.h", "w");
@@ -120,3 +120,31 @@
   fclose (stream);
 }
 
+void
+report_sheap_usage (int die_if_pure_storage_exceeded)
+{
+  int rc = 0;
+
+  size_t lost = (STATIC_HEAP_BASE + STATIC_HEAP_SLOP + SHEAP_ADJUSTMENT)
+    - (static_heap_ptr - static_heap_buffer);
+  char buf[200];
+  sprintf (buf, "Static heap usage: %ld of %ld",
+               (long) (static_heap_ptr - static_heap_buffer),
+	   (long) (STATIC_HEAP_BASE + STATIC_HEAP_SLOP + SHEAP_ADJUSTMENT));
+
+  if (lost > STATIC_HEAP_SLOP) {
+    sprintf (buf + strlen (buf), " -- %ldk wasted", (long)(lost/1024));
+    if (die_if_pure_storage_exceeded) {
+      sheap_adjust_h();
+      rc = -1;
+    }
+    message ("%s", buf);
+  }
+
+  if (rc < 0) {
+    unlink("SATISFIED");
+    fatal ("Static heap size adjusted, Don't Panic!  I will restart the `make'");
+  }
+}
+
+
--- a/src/symsinit.h	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/symsinit.h	Mon Aug 13 11:21:38 2007 +0200
@@ -113,7 +113,7 @@
 void syms_of_mule_canna (void);
 void syms_of_mule_ccl (void);
 void syms_of_mule_charset (void);
-void syms_of_mule_coding (void);
+void syms_of_file_coding (void);
 void syms_of_mule_wnn (void);
 void syms_of_ntproc (void);
 void syms_of_objects_tty (void);
@@ -130,6 +130,7 @@
 void syms_of_scrollbar (void);
 void syms_of_scrollbar_mswindows(void);
 void syms_of_search (void);
+void syms_of_select (void);
 void syms_of_select_mswindows (void);
 void syms_of_signal (void);
 void syms_of_sound (void);
@@ -162,6 +163,7 @@
 void console_type_create_objects_x (void);
 void console_type_create_redisplay_x (void);
 void console_type_create_scrollbar_x (void);
+void console_type_create_select_x (void);
 void console_type_create_toolbar_x (void);
 void console_type_create_dialog_x (void);
 void console_type_create_mswindows (void);
@@ -174,6 +176,7 @@
 void console_type_create_toolbar_mswindows (void);
 void console_type_create_glyphs_mswindows (void);
 void console_type_create_dialog_mswindows (void);
+void console_type_create_select_mswindows (void);
 
 /* Initialize the specifier types (dump-time only). */
 
@@ -201,7 +204,7 @@
 /* Initialize the lstream types (dump-time only). */
 
 void lstream_type_create (void);
-void lstream_type_create_mule_coding (void);
+void lstream_type_create_file_coding (void);
 void lstream_type_create_print (void);
 void lstream_type_create_mswindows_selectable (void);
 
@@ -223,6 +226,7 @@
 void vars_of_bytecode (void);
 void vars_of_callint (void);
 void vars_of_callproc (void);
+void vars_of_chartab (void);
 void vars_of_cmdloop (void);
 void vars_of_cmds (void);
 void vars_of_console (void);
@@ -285,9 +289,11 @@
 void vars_of_module (void);
 void vars_of_mule (void);
 void vars_of_mule_canna (void);
+void vars_of_mule_ccl(void);
 void vars_of_mule_charset (void);
-void vars_of_mule_coding (void);
+void vars_of_file_coding (void);
 void vars_of_mule_wnn (void);
+void vars_of_ntproc (void);
 void vars_of_objects (void);
 void vars_of_objects_tty (void);
 void vars_of_objects_mswindows (void);
@@ -303,6 +309,7 @@
 void vars_of_scrollbar (void);
 void vars_of_scrollbar_mswindows (void);
 void vars_of_search (void);
+void vars_of_select (void);
 void vars_of_select_mswindows (void);
 void vars_of_sound (void);
 void vars_of_specifier (void);
@@ -334,7 +341,7 @@
 void complex_vars_of_extents (void);
 void complex_vars_of_faces (void);
 void complex_vars_of_mule_charset (void);
-void complex_vars_of_mule_coding (void);
+void complex_vars_of_file_coding (void);
 void complex_vars_of_glyphs (void);
 void complex_vars_of_glyphs_x (void);
 void complex_vars_of_glyphs_mswindows (void);
--- a/src/sysdep.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/sysdep.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1019,7 +1019,7 @@
 {
   int filedesc = DEVICE_INFD (d);
 
-#if defined (I_SETSIG) && !defined(HPUX10)
+#if defined (I_SETSIG) && !defined(HPUX10) && !defined(LINUX)
   {
     int events=0;
     ioctl (filedesc, I_GETSIG, &events);
--- a/src/toolbar-msw.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/toolbar-msw.c	Mon Aug 13 11:21:38 2007 +0200
@@ -209,7 +209,7 @@
 			internal_hash (get_toolbar_button_glyph(w, tb), 0),
 			internal_hash (tb->callback, 0),
 			width,
-			w->toolbar_buttons_captioned_p);
+			LISP_HASH (w->toolbar_buttons_captioned_p));
       button = tb->next;
       nbuttons++;
     }
--- a/src/window.c	Mon Aug 13 11:20:44 2007 +0200
+++ b/src/window.c	Mon Aug 13 11:21:38 2007 +0200
@@ -1345,7 +1345,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   w = XWINDOW (window);
 
   start  = marker_position (w->start[CURRENT_DISP]);
@@ -3366,7 +3366,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
   else
-    CHECK_WINDOW (window);
+    CHECK_LIVE_WINDOW (window);
 
   o = XWINDOW (window);
   f = XFRAME (WINDOW_FRAME (o));
@@ -4304,7 +4304,7 @@
   if (NILP (window))
     window = Fselected_window (Qnil);
   else
-    CHECK_WINDOW (window);
+    CHECK_LIVE_WINDOW (window);
   w = XWINDOW (window);
   b = XBUFFER (w->buffer);
 
--- a/src/xselect.c	Mon Aug 13 11:20:44 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2144 +0,0 @@
-/* X Selection processing for XEmacs
-   Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Not synched with FSF. */
-
-/* Rewritten by jwz */
-
-#include <config.h>
-#include "lisp.h"
-
-#include "buffer.h"
-#include "console-x.h"
-#include "objects-x.h"
-
-#include "frame.h"
-#include "opaque.h"
-#include "systime.h"
-
-int lisp_to_time (Lisp_Object, time_t *);
-Lisp_Object time_to_lisp (time_t);
-
-#ifdef LWLIB_USES_MOTIF
-# define MOTIF_CLIPBOARDS
-#endif
-
-#ifdef MOTIF_CLIPBOARDS
-# include <Xm/CutPaste.h>
-static void hack_motif_clipboard_selection (Atom selection_atom,
-					    Lisp_Object selection_value,
-					    Time thyme, Display *display,
-					    Window selecting_window,
-					    Bool owned_p);
-#endif
-
-#define CUT_BUFFER_SUPPORT
-
-Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
-  QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
-  QATOM_PAIR, QCOMPOUND_TEXT;
-
-#ifdef CUT_BUFFER_SUPPORT
-Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3,
-  QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7;
-#endif
-
-Lisp_Object Vx_lost_selection_hooks;
-Lisp_Object Vx_sent_selection_hooks;
-
-/* If this is a smaller number than the max-request-size of the display,
-   emacs will use INCR selection transfer when the selection is larger
-   than this.  The max-request-size is usually around 64k, so if you want
-   emacs to use incremental selection transfers when the selection is
-   smaller than that, set this.  I added this mostly for debugging the
-   incremental transfer stuff, but it might improve server performance.
- */
-#define MAX_SELECTION_QUANTUM 0xFFFFFF
-
-#define SELECTION_QUANTUM(dpy) ((XMaxRequestSize (dpy) << 2) - 100)
-
-/* 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.
- */
-Lisp_Object Vselection_alist;
-
-/* 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.
- */
-Lisp_Object Vselection_converter_alist;
-
-/* "Selection owner couldn't convert selection" */
-Lisp_Object Qselection_conversion_error;
-
-/* If the selection owner takes too long to reply to a selection request,
-   we give up on it.  This is in seconds (0 = no timeout).
- */
-int x_selection_timeout;
-
-
-/* Utility functions */
-
-static void lisp_data_to_selection_data (struct device *,
-					 Lisp_Object obj,
-					 unsigned char **data_ret,
-					 Atom *type_ret,
-					 unsigned int *size_ret,
-					 int *format_ret);
-static Lisp_Object selection_data_to_lisp_data (struct device *,
-						unsigned char *data,
-						size_t size,
-						Atom type,
-						int format);
-static Lisp_Object x_get_window_property_as_lisp_data (Display *,
-						       Window,
-						       Atom property,
-						       Lisp_Object target_type,
-						       Atom selection_atom);
-
-static int expect_property_change (Display *, Window, Atom prop, int state);
-static void wait_for_property_change (long);
-static void unexpect_property_change (int);
-static int waiting_for_other_props_on_window (Display *, Window);
-
-/* This converts a Lisp symbol to a server Atom, avoiding a server
-   roundtrip whenever possible.
- */
-static Atom
-symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists)
-{
-  Display *display = DEVICE_X_DISPLAY (d);
-
-  if (NILP (sym))		return XA_PRIMARY;
-  if (EQ (sym, Qt))		return XA_SECONDARY;
-  if (EQ (sym, QPRIMARY))	return XA_PRIMARY;
-  if (EQ (sym, QSECONDARY))	return XA_SECONDARY;
-  if (EQ (sym, QSTRING))	return XA_STRING;
-  if (EQ (sym, QINTEGER))	return XA_INTEGER;
-  if (EQ (sym, QATOM))		return XA_ATOM;
-  if (EQ (sym, QCLIPBOARD))	return DEVICE_XATOM_CLIPBOARD (d);
-  if (EQ (sym, QTIMESTAMP))	return DEVICE_XATOM_TIMESTAMP (d);
-  if (EQ (sym, QTEXT))		return DEVICE_XATOM_TEXT      (d);
-  if (EQ (sym, QDELETE))	return DEVICE_XATOM_DELETE    (d);
-  if (EQ (sym, QMULTIPLE))	return DEVICE_XATOM_MULTIPLE  (d);
-  if (EQ (sym, QINCR))		return DEVICE_XATOM_INCR      (d);
-  if (EQ (sym, QEMACS_TMP))	return DEVICE_XATOM_EMACS_TMP (d);
-  if (EQ (sym, QTARGETS))	return DEVICE_XATOM_TARGETS   (d);
-  if (EQ (sym, QNULL))		return DEVICE_XATOM_NULL      (d);
-  if (EQ (sym, QATOM_PAIR))	return DEVICE_XATOM_ATOM_PAIR (d);
-  if (EQ (sym, QCOMPOUND_TEXT)) return DEVICE_XATOM_COMPOUND_TEXT (d);
-
-#ifdef CUT_BUFFER_SUPPORT
-  if (EQ (sym, QCUT_BUFFER0))	return XA_CUT_BUFFER0;
-  if (EQ (sym, QCUT_BUFFER1))	return XA_CUT_BUFFER1;
-  if (EQ (sym, QCUT_BUFFER2))	return XA_CUT_BUFFER2;
-  if (EQ (sym, QCUT_BUFFER3))	return XA_CUT_BUFFER3;
-  if (EQ (sym, QCUT_BUFFER4))	return XA_CUT_BUFFER4;
-  if (EQ (sym, QCUT_BUFFER5))	return XA_CUT_BUFFER5;
-  if (EQ (sym, QCUT_BUFFER6))	return XA_CUT_BUFFER6;
-  if (EQ (sym, QCUT_BUFFER7))	return XA_CUT_BUFFER7;
-#endif /* CUT_BUFFER_SUPPORT */
-
-  {
-    CONST char *nameext;
-    GET_C_STRING_CTEXT_DATA_ALLOCA (Fsymbol_name (sym), nameext);
-    return XInternAtom (display, nameext, only_if_exists ? True : False);
-  }
-}
-
-
-/* This converts a server Atom to a Lisp symbol, avoiding server roundtrips
-   and calls to intern whenever possible.
- */
-static Lisp_Object
-x_atom_to_symbol (struct device *d, Atom atom)
-{
-  Display *display = DEVICE_X_DISPLAY (d);
-
-  if (! atom) return Qnil;
-  if (atom == XA_PRIMARY)	return QPRIMARY;
-  if (atom == XA_SECONDARY)	return QSECONDARY;
-  if (atom == XA_STRING)	return QSTRING;
-  if (atom == XA_INTEGER)	return QINTEGER;
-  if (atom == XA_ATOM)		return QATOM;
-  if (atom == DEVICE_XATOM_CLIPBOARD (d)) return QCLIPBOARD;
-  if (atom == DEVICE_XATOM_TIMESTAMP (d)) return QTIMESTAMP;
-  if (atom == DEVICE_XATOM_TEXT      (d)) return QTEXT;
-  if (atom == DEVICE_XATOM_DELETE    (d)) return QDELETE;
-  if (atom == DEVICE_XATOM_MULTIPLE  (d)) return QMULTIPLE;
-  if (atom == DEVICE_XATOM_INCR      (d)) return QINCR;
-  if (atom == DEVICE_XATOM_EMACS_TMP (d)) return QEMACS_TMP;
-  if (atom == DEVICE_XATOM_TARGETS   (d)) return QTARGETS;
-  if (atom == DEVICE_XATOM_NULL      (d)) return QNULL;
-  if (atom == DEVICE_XATOM_ATOM_PAIR (d)) return QATOM_PAIR;
-  if (atom == DEVICE_XATOM_COMPOUND_TEXT (d)) return QCOMPOUND_TEXT;
-
-#ifdef CUT_BUFFER_SUPPORT
-  if (atom == XA_CUT_BUFFER0)	return QCUT_BUFFER0;
-  if (atom == XA_CUT_BUFFER1)	return QCUT_BUFFER1;
-  if (atom == XA_CUT_BUFFER2)	return QCUT_BUFFER2;
-  if (atom == XA_CUT_BUFFER3)	return QCUT_BUFFER3;
-  if (atom == XA_CUT_BUFFER4)	return QCUT_BUFFER4;
-  if (atom == XA_CUT_BUFFER5)	return QCUT_BUFFER5;
-  if (atom == XA_CUT_BUFFER6)	return QCUT_BUFFER6;
-  if (atom == XA_CUT_BUFFER7)	return QCUT_BUFFER7;
-#endif
-
-  {
-    Lisp_Object newsym;
-    CONST Bufbyte *intstr;
-    char *str = XGetAtomName (display, atom);
-
-    if (! str) return Qnil;
-
-    GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA (str, intstr);
-    newsym = intern ((char *) intstr);
-    XFree (str);
-    return newsym;
-  }
-}
-
-
-/* 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 void
-x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  struct frame *sel_frame = selected_frame ();
-  Window selecting_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
-  /* Use the time of the last-read mouse or keyboard event.
-     For selection purposes, we use this as a sleazy way of knowing what the
-     current time is in server-time.  This assumes that the most recently read
-     mouse or keyboard event has something to do with the assertion of the
-     selection, which is probably true.
-     */
-  Time thyme = DEVICE_X_MOUSE_TIMESTAMP (d);
-  Atom selection_atom;
-
-  CHECK_SYMBOL (selection_name);
-  selection_atom = symbol_to_x_atom (d, selection_name, 0);
-
-  XSetSelectionOwner (display, selection_atom, selecting_window, thyme);
-
-  /* Now update the local cache */
-  {
-    /* We do NOT use time_to_lisp() here any more, like we used to.
-       That assumed equivalence of time_t and Time, which is not
-       necessarily the case (e.g. under OSF on the Alphas, where
-       Time is a 64-bit quantity and time_t is a 32-bit quantity).
-
-       Opaque pointers are the clean way to go here.
-     */
-    Lisp_Object selection_time = make_opaque (sizeof (thyme), (void *) &thyme);
-    Lisp_Object selection_data = list3 (selection_name,
-					selection_value,
-					selection_time);
-    Lisp_Object prev_value = assq_no_quit (selection_name, Vselection_alist);
-    Vselection_alist = Fcons (selection_data, Vselection_alist);
-
-    /* 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))
-      {
-	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))))
-	    {
-	      XCDR (rest) = Fcdr (XCDR (rest));
-	      break;
-	    }
-      }
-#ifdef MOTIF_CLIPBOARDS
-    hack_motif_clipboard_selection (selection_atom, selection_value,
-				    thyme, display, selecting_window,
-				    !NILP (prev_value));
-#endif
-  }
-}
-
-
-#ifdef MOTIF_CLIPBOARDS /* Bend over baby.  Take it and like it. */
-
-# ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
-static void motif_clipboard_cb ();
-# endif
-
-static void
-hack_motif_clipboard_selection (Atom selection_atom,
-				Lisp_Object selection_value,
-				Time thyme,
-				Display *display,
-				Window selecting_window,
-				Bool owned_p)
-{
-  struct device *d = get_device_from_display (display);
-  /* Those Motif wankers can't be bothered to follow the ICCCM, and do
-     their own non-Xlib non-Xt clipboard processing.  So we have to do
-     this so that linked-in Motif widgets don't get themselves wedged.
-   */
-  if (selection_atom == DEVICE_XATOM_CLIPBOARD (d)
-      && STRINGP (selection_value)
-
-      /* If we already own the clipboard, don't own it again in the Motif
-	 way.  This might lose in some subtle way, since the timestamp won't
-	 be current, but owning the selection on the Motif way does a
-	 SHITLOAD of X protocol, and it makes killing text be incredibly
-	 slow when using an X terminal.  ARRRRGGGHHH!!!!
-       */
-      /* No, this is no good, because then Motif text fields don't bother
-	 to look up the new value, and you can't Copy from a buffer, Paste
-	 into a text field, then Copy something else from the buffer and
-	 paste it into the text field -- it pastes the first thing again. */
-/*      && !owned_p */
-      )
-    {
-#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
-      Widget widget = FRAME_X_TEXT_WIDGET (selected_frame());
-#endif
-      long itemid;
-#if XmVersion >= 1002
-      long dataid;
-#else
-      int dataid;	/* 1.2 wants long, but 1.1.5 wants int... */
-#endif
-      XmString fmh;
-      String encoding = "STRING";
-      CONST Extbyte *data  = XSTRING_DATA (selection_value);
-      Extcount bytes = XSTRING_LENGTH (selection_value);
-
-#ifdef MULE
-      {
-	enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
-	CONST Bufbyte *ptr = data, *end = ptr + bytes;
-	/* Optimize for the common ASCII case */
-	while (ptr <= end)
-	  {
-	    if (BYTE_ASCII_P (*ptr))
-	      {
-		ptr++;
-		continue;
-	      }
-
-	    if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
-		(*ptr) == LEADING_BYTE_CONTROL_1)
-	      {
-		chartypes = LATIN_1;
-		ptr += 2;
-		continue;
-	      }
-
-	    chartypes = WORLD;
-	    break;
-	  }
-
-	if (chartypes == LATIN_1)
-	  GET_STRING_BINARY_DATA_ALLOCA (selection_value, data, bytes);
-	else if (chartypes == WORLD)
-	  {
-	    GET_STRING_CTEXT_DATA_ALLOCA (selection_value, data, bytes);
-	    encoding = "COMPOUND_TEXT";
-	  }
-      }
-#endif /* MULE */
-
-      fmh = XmStringCreateLtoR ("Clipboard", XmSTRING_DEFAULT_CHARSET);
-      while (ClipboardSuccess !=
-	     XmClipboardStartCopy (display, selecting_window, fmh, thyme,
-#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
-				   widget, motif_clipboard_cb,
-#else
-				   0, NULL,
-#endif
-				   &itemid))
-	;
-      XmStringFree (fmh);
-      while (ClipboardSuccess !=
-	     XmClipboardCopy (display, selecting_window, itemid, encoding,
-#ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
-			      /* O'Reilly examples say size can be 0,
-				 but this clearly is not the case. */
-			      0, bytes, (int) selecting_window, /* private id */
-#else /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
-			      (XtPointer) data, bytes, 0,
-#endif /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
-			      &dataid))
-	;
-      while (ClipboardSuccess !=
-	     XmClipboardEndCopy (display, selecting_window, itemid))
-	;
-    }
-}
-
-# ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
-/* I tried to treat the clipboard like a real selection, and not send
-   the data until it was requested, but it looks like that just doesn't
-   work at all unless the selection owner and requestor are in different
-   processes.  From reading the Motif source, it looks like they never
-   even considered having two widgets in the same application transfer
-   data between each other using "by-name" clipboard values.  What a
-   bunch of fuckups.
- */
-static void
-motif_clipboard_cb (Widget widget, int *data_id, int *private_id, int *reason)
-{
-  switch (*reason)
-    {
-    case XmCR_CLIPBOARD_DATA_REQUEST:
-      {
-	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 ();
-	XmClipboardCopyByName (dpy, window, *data_id,
-			       (char *) XSTRING_DATA (selection),
-			       XSTRING_LENGTH (selection) + 1,
-			       0);
-      }
-      break;
-    case XmCR_CLIPBOARD_DATA_DELETE:
-    default:
-      /* don't need to free anything */
-      break;
-    }
-}
-# endif /* MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
-#endif /* MOTIF_CLIPBOARDS */
-
-
-/* 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.
- */
-static Lisp_Object
-x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
-{
-  /* This function can GC */
-  Lisp_Object local_value = assq_no_quit (selection_symbol, Vselection_alist);
-  Lisp_Object handler_fn, value, check;
-
-  if (NILP (local_value)) return Qnil;
-
-  /* TIMESTAMP and MULTIPLE are special cases 'cause that's easiest. */
-  if (EQ (target_type, QTIMESTAMP))
-    {
-      handler_fn = Qnil;
-      value = XCAR (XCDR (XCDR (local_value)));
-    }
-
-#if 0 /* #### MULTIPLE doesn't work yet */
-  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 */
-}
-
-
-
-/* Send a SelectionNotify event to the requestor with property=None, meaning
-   we were unable to do what they wanted.
- */
-static void
-x_decline_selection_request (XSelectionRequestEvent *event)
-{
-  XSelectionEvent reply;
-  reply.type      = SelectionNotify;
-  reply.display   = event->display;
-  reply.requestor = event->requestor;
-  reply.selection = event->selection;
-  reply.time      = event->time;
-  reply.target    = event->target;
-  reply.property  = None;
-
-  XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
-  XFlush (reply.display);
-}
-
-
-/* Used as an unwind-protect clause so that, if a selection-converter signals
-   an error, we tell the requestor that we were unable to do what they wanted
-   before we throw to top-level or go into the debugger or whatever.
- */
-static Lisp_Object
-x_selection_request_lisp_error (Lisp_Object closure)
-{
-  XSelectionRequestEvent *event = (XSelectionRequestEvent *)
-    get_opaque_ptr (closure);
-
-  free_opaque_ptr (closure);
-  if (event->type == 0) /* we set this to mean "completed normally" */
-    return Qnil;
-  x_decline_selection_request (event);
-  return Qnil;
-}
-
-
-/* Convert our selection to the requested type, and put that data where the
-   requestor wants it.  Then tell them whether we've succeeded.
- */
-static void
-x_reply_selection_request (XSelectionRequestEvent *event, int format,
-			   unsigned char *data, int size, Atom type)
-{
-  /* This function can GC */
-  XSelectionEvent reply;
-  Display *display = event->display;
-  struct device *d = get_device_from_display (display);
-  Window window = event->requestor;
-  int bytes_remaining;
-  int format_bytes = format/8;
-  int max_bytes = SELECTION_QUANTUM (display);
-  if (max_bytes > MAX_SELECTION_QUANTUM) max_bytes = MAX_SELECTION_QUANTUM;
-
-  reply.type      = SelectionNotify;
-  reply.display   = display;
-  reply.requestor = window;
-  reply.selection = event->selection;
-  reply.time      = event->time;
-  reply.target    = event->target;
-  reply.property  = (event->property == None ? event->target : event->property);
-
-  /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
-
-  /* Store the data on the requested property.
-     If the selection is large, only store the first N bytes of it.
-   */
-  bytes_remaining = size * format_bytes;
-  if (bytes_remaining <= max_bytes)
-    {
-      /* Send all the data at once, with minimal handshaking. */
-#if 0
-      stderr_out ("\nStoring all %d\n", bytes_remaining);
-#endif
-      XChangeProperty (display, window, reply.property, type, format,
-		       PropModeReplace, data, size);
-      /* At this point, the selection was successfully stored; ack it. */
-      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
-      XFlush (display);
-    }
-  else
-    {
-      /* Send an INCR selection. */
-      int prop_id;
-
-      if (x_window_to_frame (d, window)) /* #### debug */
-	error ("attempt to transfer an INCR to ourself!");
-#if 0
-      stderr_out ("\nINCR %d\n", bytes_remaining);
-#endif
-      prop_id = expect_property_change (display, window, reply.property,
-					PropertyDelete);
-
-      XChangeProperty (display, window, reply.property, DEVICE_XATOM_INCR (d),
-		       32, PropModeReplace, (unsigned char *)
-		       &bytes_remaining, 1);
-      XSelectInput (display, window, PropertyChangeMask);
-      /* Tell 'em the INCR data is there... */
-      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
-      XFlush (display);
-
-      /* First, wait for the requestor to ack by deleting the property.
-	 This can run random lisp code (process handlers) or signal.
-       */
-      wait_for_property_change (prop_id);
-
-      while (bytes_remaining)
-	{
-	  int i = ((bytes_remaining < max_bytes)
-		   ? bytes_remaining
-		   : max_bytes);
-	  prop_id = expect_property_change (display, window, reply.property,
-					    PropertyDelete);
-#if 0
-	  stderr_out ("  INCR adding %d\n", i);
-#endif
-	  /* Append the next chunk of data to the property. */
-	  XChangeProperty (display, window, reply.property, type, format,
-			   PropModeAppend, data, i / format_bytes);
-	  bytes_remaining -= i;
-	  data += i;
-
-	  /* Now wait for the requestor to ack this chunk by deleting the
-	     property.	 This can run random lisp code or signal.
-	   */
-	  wait_for_property_change (prop_id);
-	}
-      /* Now write a zero-length chunk to the property to tell the requestor
-	 that we're done. */
-#if 0
-      stderr_out ("  INCR done\n");
-#endif
-      if (! waiting_for_other_props_on_window (display, window))
-	XSelectInput (display, window, 0L);
-
-      XChangeProperty (display, window, reply.property, type, format,
-		       PropModeReplace, data, 0);
-    }
-}
-
-
-
-/* Called from the event-loop in response to a SelectionRequest event.
- */
-void
-x_handle_selection_request (XSelectionRequestEvent *event)
-{
-  /* This function can GC */
-  struct gcpro gcpro1, gcpro2, gcpro3;
-  Lisp_Object local_selection_data = Qnil;
-  Lisp_Object selection_symbol;
-  Lisp_Object target_symbol = Qnil;
-  Lisp_Object converted_selection = Qnil;
-  Time local_selection_time;
-  Lisp_Object successful_p = Qnil;
-  int count;
-  struct device *d = get_device_from_display (event->display);
-
-  GCPRO3 (local_selection_data, converted_selection, target_symbol);
-
-  selection_symbol = x_atom_to_symbol (d, event->selection);
-
-  local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
-
-#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))))));
-#endif
-
-  if (NILP (local_selection_data))
-    {
-      /* Someone asked for the selection, but we don't have it any more. */
-      x_decline_selection_request (event);
-      goto DONE_LABEL;
-    }
-
-  local_selection_time =
-    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
-
-  if (event->time != CurrentTime &&
-      local_selection_time > event->time)
-    {
-      /* Someone asked for the selection, and we have one, but not the one
-	 they're looking for. */
-      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 =
-    x_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);
-    }
-  unbind_to (count, Qnil);
-
- DONE_LABEL:
-
-  UNGCPRO;
-
-  /* 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))
-      {
-	if (CONSP (val) && !EQ (XCAR (val), Qlambda))
-	  for (rest = val; !NILP (rest); rest = Fcdr (rest))
-	    call3 (Fcar(rest), selection_symbol, target_symbol,
-		   successful_p);
-	else
-	  call3 (val, selection_symbol, target_symbol,
-		 successful_p);
-      }
-  }
-}
-
-
-/* Called from the event-loop in response to a SelectionClear event.
- */
-void
-x_handle_selection_clear (XSelectionClearEvent *event)
-{
-  Display *display = event->display;
-  struct device *d = get_device_from_display (display);
-  Atom selection = event->selection;
-  Time changed_owner_time = event->time;
-
-  Lisp_Object selection_symbol, local_selection_data;
-  Time local_selection_time;
-
-  selection_symbol = x_atom_to_symbol (d, selection);
-
-  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;
-
-  local_selection_time =
-    * (Time *) XOPAQUE_DATA (XCAR (XCDR (XCDR (local_selection_data))));
-
-  /* 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
-     request was generated.)
-   */
-  if (changed_owner_time != CurrentTime &&
-      local_selection_time > changed_owner_time)
-    return;
-
-  /* Otherwise, we're really honest and truly being told to drop it.
-     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;
-	  }
-    }
-
-  /* Let random lisp code notice that the selection has been stolen.
-   */
-  {
-    Lisp_Object rest;
-    Lisp_Object val = Vx_lost_selection_hooks;
-    if (!UNBOUNDP (val) && !NILP (val))
-      {
-	if (CONSP (val) && !EQ (XCAR (val), Qlambda))
-	  for (rest = val; !NILP (rest); rest = Fcdr (rest))
-	    call1 (Fcar (rest), selection_symbol);
-	else
-	  call1 (val, selection_symbol);
-      }
-  }
-}
-
-
-/* This stuff is so that INCR selections are reentrant (that is, so we can
-   be servicing multiple INCR selection requests simultaneously).  I haven't
-   actually tested that yet.
- */
-
-static int prop_location_tick;
-
-static struct prop_location {
-  int tick;
-  Display *display;
-  Window window;
-  Atom property;
-  int desired_state;
-  struct prop_location *next;
-} *for_whom_the_bell_tolls;
-
-
-static int
-property_deleted_p (void *tick)
-{
-  struct prop_location *rest = for_whom_the_bell_tolls;
-  while (rest)
-    if (rest->tick == (long) tick)
-      return 0;
-    else
-      rest = rest->next;
-  return 1;
-}
-
-static int
-waiting_for_other_props_on_window (Display *display, Window window)
-{
-  struct prop_location *rest = for_whom_the_bell_tolls;
-  while (rest)
-    if (rest->display == display && rest->window == window)
-      return 1;
-    else
-      rest = rest->next;
-  return 0;
-}
-
-
-static int
-expect_property_change (Display *display, Window window,
-			Atom property, int state)
-{
-  struct prop_location *pl = xnew (struct prop_location);
-  pl->tick = ++prop_location_tick;
-  pl->display = display;
-  pl->window = window;
-  pl->property = property;
-  pl->desired_state = state;
-  pl->next = for_whom_the_bell_tolls;
-  for_whom_the_bell_tolls = pl;
-  return pl->tick;
-}
-
-static void
-unexpect_property_change (int tick)
-{
-  struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
-  while (rest)
-    {
-      if (rest->tick == tick)
-	{
-	  if (prev)
-	    prev->next = rest->next;
-	  else
-	    for_whom_the_bell_tolls = rest->next;
-	  xfree (rest);
-	  return;
-	}
-      prev = rest;
-      rest = rest->next;
-    }
-}
-
-static void
-wait_for_property_change (long tick)
-{
-  /* This function can GC */
-  wait_delaying_user_input (property_deleted_p, (void *) tick);
-}
-
-
-/* Called from the event-loop in response to a PropertyNotify event.
- */
-void
-x_handle_property_notify (XPropertyEvent *event)
-{
-  struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
-  while (rest)
-    {
-      if (rest->property == event->atom &&
-	  rest->window == event->window &&
-	  rest->display == event->display &&
-	  rest->desired_state == event->state)
-	{
-#if 0
-	  stderr_out ("Saw expected prop-%s on %s\n",
-		   (event->state == PropertyDelete ? "delete" : "change"),
-		      (char *) string_data (XSYMBOL (x_atom_to_symbol (get_device_from_display (event->display), event->atom))->name);
-#endif
-	  if (prev)
-	    prev->next = rest->next;
-	  else
-	    for_whom_the_bell_tolls = rest->next;
-	  xfree (rest);
-	  return;
-	}
-      prev = rest;
-      rest = rest->next;
-    }
-#if 0
-  stderr_out ("Saw UNexpected prop-%s on %s\n",
-	   (event->state == PropertyDelete ? "delete" : "change"),
-	   (char *) string_data (XSYMBOL (x_atom_to_symbol (get_device_from_display (event->display), event->atom))->name));
-#endif
-}
-
-
-
-#if 0 /* #### MULTIPLE doesn't work yet */
-
-static Lisp_Object
-fetch_multiple_target (XSelectionRequestEvent *event)
-{
-  /* This function can GC */
-  Display *display = event->display;
-  Window window = event->requestor;
-  Atom target = event->target;
-  Atom selection_atom = event->selection;
-  int result;
-
-  return
-    Fcons (QMULTIPLE,
-	   x_get_window_property_as_lisp_data (display, window, target,
-					       QMULTIPLE,
-					       selection_atom));
-}
-
-static Lisp_Object
-copy_multiple_data (Lisp_Object obj)
-{
-  Lisp_Object vec;
-  int i;
-  int len;
-  if (CONSP (obj))
-    return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
-
-  CHECK_VECTOR (obj);
-  len = XVECTOR_LENGTH (obj);
-  vec = make_vector (len, Qnil);
-  for (i = 0; i < len; i++)
-    {
-      Lisp_Object vec2 = XVECTOR_DATA (obj) [i];
-      CHECK_VECTOR (vec2);
-      if (XVECTOR_LENGTH (vec2) != 2)
-	signal_error (Qerror, list2 (build_string
-				     ("vectors must be of length 2"),
-                                     vec2));
-      XVECTOR_DATA (vec) [i] = make_vector (2, Qnil);
-      XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [0] = XVECTOR_DATA (vec2) [0];
-      XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [1] = XVECTOR_DATA (vec2) [1];
-    }
-  return vec;
-}
-
-#endif /* 0 */
-
-
-static Window reading_selection_reply;
-static Atom reading_which_selection;
-static int selection_reply_timed_out;
-
-static int
-selection_reply_done (void *ignore)
-{
-  return !reading_selection_reply;
-}
-
-static Lisp_Object Qx_selection_reply_timeout_internal;
-
-DEFUN ("x-selection-reply-timeout-internal", Fx_selection_reply_timeout_internal,
-       1, 1, 0, /*
-*/
-       (arg))
-{
-  selection_reply_timed_out = 1;
-  reading_selection_reply = 0;
-  return Qnil;
-}
-
-
-/* Do protocol to read selection-data from the server.
-   Converts this to lisp data and returns it.
- */
-static Lisp_Object
-x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
-{
-  /* This function can GC */
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  struct frame *sel_frame = selected_frame ();
-  Window requestor_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
-  Time requestor_time = DEVICE_X_MOUSE_TIMESTAMP (d);
-  Atom target_property = DEVICE_XATOM_EMACS_TMP (d);
-  Atom selection_atom = symbol_to_x_atom (d, selection_symbol, 0);
-  int speccount;
-  Atom type_atom = symbol_to_x_atom (d, (CONSP (target_type) ?
-					 XCAR (target_type) : target_type), 0);
-
-  XConvertSelection (display, selection_atom, type_atom, target_property,
-		     requestor_window, requestor_time);
-
-  /* Block until the reply has been read. */
-  reading_selection_reply = requestor_window;
-  reading_which_selection = selection_atom;
-  selection_reply_timed_out = 0;
-
-  speccount = specpdl_depth ();
-
-  /* add a timeout handler */
-  if (x_selection_timeout > 0)
-    {
-      Lisp_Object id = Fadd_timeout (make_int (x_selection_timeout),
-				     Qx_selection_reply_timeout_internal,
-				     Qnil, Qnil);
-      record_unwind_protect (Fdisable_timeout, id);
-    }
-
-  /* This is ^Gable */
-  wait_delaying_user_input (selection_reply_done, 0);
-
-  if (selection_reply_timed_out)
-    error ("timed out waiting for reply from selection owner");
-
-  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);
-}
-
-
-static void
-x_get_window_property (Display *display, Window window, Atom property,
-		       unsigned char **data_ret, int *bytes_ret,
-		       Atom *actual_type_ret, int *actual_format_ret,
-		       unsigned long *actual_size_ret, int delete_p)
-{
-  int total_size;
-  unsigned long bytes_remaining;
-  int offset = 0;
-  unsigned char *tmp_data = 0;
-  int result;
-  int buffer_size = SELECTION_QUANTUM (display);
-  if (buffer_size > MAX_SELECTION_QUANTUM) buffer_size = MAX_SELECTION_QUANTUM;
-
-  /* First probe the thing to find out how big it is. */
-  result = XGetWindowProperty (display, window, property,
-			       0, 0, False, AnyPropertyType,
-			       actual_type_ret, actual_format_ret,
-			       actual_size_ret,
-			       &bytes_remaining, &tmp_data);
-  if (result != Success)
-    {
-      *data_ret = 0;
-      *bytes_ret = 0;
-      return;
-    }
-  XFree ((char *) tmp_data);
-
-  if (*actual_type_ret == None || *actual_format_ret == 0)
-    {
-      if (delete_p) XDeleteProperty (display, window, property);
-      *data_ret = 0;
-      *bytes_ret = 0;
-      return;
-    }
-
-  total_size = bytes_remaining + 1;
-  *data_ret = (unsigned char *) xmalloc (total_size);
-
-  /* Now read, until we've gotten it all. */
-  while (bytes_remaining)
-    {
-#if 0
-      int last = bytes_remaining;
-#endif
-      result =
-	XGetWindowProperty (display, window, property,
-			    offset/4, buffer_size/4,
-			    (delete_p ? True : False),
-			    AnyPropertyType,
-			    actual_type_ret, actual_format_ret,
-			    actual_size_ret, &bytes_remaining, &tmp_data);
-#if 0
-      stderr_out ("<< read %d\n", last-bytes_remaining);
-#endif
-      /* If this doesn't return Success at this point, it means that
-	 some clod deleted the selection while we were in the midst of
-	 reading it.  Deal with that, I guess....
-       */
-      if (result != Success) break;
-      *actual_size_ret *= *actual_format_ret / 8;
-      memcpy ((*data_ret) + offset, tmp_data, *actual_size_ret);
-      offset += *actual_size_ret;
-      XFree ((char *) tmp_data);
-    }
-  *bytes_ret = offset;
-}
-
-
-static void
-receive_incremental_selection (Display *display, Window window, Atom property,
-			       /* this one is for error messages only */
-			       Lisp_Object target_type,
-			       unsigned int min_size_bytes,
-			       unsigned char **data_ret, int *size_bytes_ret,
-			       Atom *type_ret, int *format_ret,
-			       unsigned long *size_ret)
-{
-  /* This function can GC */
-  int offset = 0;
-  int prop_id;
-  *size_bytes_ret = min_size_bytes;
-  *data_ret = (unsigned char *) xmalloc (*size_bytes_ret);
-#if 0
-  stderr_out ("\nread INCR %d\n", min_size_bytes);
-#endif
-  /* At this point, we have read an INCR property, and deleted it (which
-     is how we ack its receipt: the sending window will be selecting
-     PropertyNotify events on our window to notice this).
-
-     Now, we must loop, waiting for the sending window to put a value on
-     that property, then reading the property, then deleting it to ack.
-     We are done when the sender places a property of length 0.
-   */
-  prop_id = expect_property_change (display, window, property,
-				    PropertyNewValue);
-  while (1)
-    {
-      unsigned char *tmp_data;
-      int tmp_size_bytes;
-      wait_for_property_change (prop_id);
-      /* expect it again immediately, because x_get_window_property may
-	 .. no it won't, I don't get it.
-	 .. Ok, I get it now, the Xt code that implements INCR is broken.
-       */
-      prop_id = expect_property_change (display, window, property,
-					PropertyNewValue);
-      x_get_window_property (display, window, property,
-			     &tmp_data, &tmp_size_bytes,
-			     type_ret, format_ret, size_ret, 1);
-
-      if (tmp_size_bytes == 0) /* we're done */
-	{
-#if 0
-	  stderr_out ("  read INCR done\n");
-#endif
-	  unexpect_property_change (prop_id);
-	  if (tmp_data) xfree (tmp_data);
-	  break;
-	}
-#if 0
-      stderr_out ("  read INCR %d\n", tmp_size_bytes);
-#endif
-      if (*size_bytes_ret < offset + tmp_size_bytes)
-	{
-#if 0
-	  stderr_out ("  read INCR realloc %d -> %d\n",
-		   *size_bytes_ret, offset + tmp_size_bytes);
-#endif
-	  *size_bytes_ret = offset + tmp_size_bytes;
-	  *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret);
-	}
-      memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes);
-      offset += tmp_size_bytes;
-      xfree (tmp_data);
-    }
-}
-
-
-static Lisp_Object
-x_get_window_property_as_lisp_data (Display *display,
-				    Window window,
-				    Atom property,
-				    /* next two for error messages only */
-				    Lisp_Object target_type,
-				    Atom selection_atom)
-{
-  /* This function can GC */
-  Atom actual_type;
-  int actual_format;
-  unsigned long actual_size;
-  unsigned char *data = NULL;
-  int bytes = 0;
-  Lisp_Object val;
-  struct device *d = get_device_from_display (display);
-
-  x_get_window_property (display, window, property, &data, &bytes,
-			 &actual_type, &actual_format, &actual_size, 1);
-  if (! data)
-    {
-      if (XGetSelectionOwner (display, selection_atom))
-	/* there is a selection owner */
-	signal_error
-	  (Qselection_conversion_error,
-	   Fcons (build_string ("selection owner couldn't convert"),
-		  Fcons (x_atom_to_symbol (d, selection_atom),
-			 actual_type ?
-			 list2 (target_type, x_atom_to_symbol (d, actual_type)) :
-			 list1 (target_type))));
-      else
-	signal_error (Qerror,
-		      list2 (build_string ("no selection"),
-			     x_atom_to_symbol (d, selection_atom)));
-    }
-
-  if (actual_type == DEVICE_XATOM_INCR (d))
-    {
-      /* Ok, that data wasn't *the* data, it was just the beginning. */
-
-      unsigned int min_size_bytes = * ((unsigned int *) data);
-      xfree (data);
-      receive_incremental_selection (display, window, property, target_type,
-				     min_size_bytes, &data, &bytes,
-				     &actual_type, &actual_format,
-				     &actual_size);
-    }
-
-  /* It's been read.  Now convert it to a lisp object in some semi-rational
-     manner. */
-  val = selection_data_to_lisp_data (d, data, bytes,
-				     actual_type, actual_format);
-
-  xfree (data);
-  return val;
-}
-
-/* These functions convert from the selection data read from the server into
-   something that we can use from elisp, and vice versa.
-
-	Type:	Format:	Size:		Elisp Type:
-	-----	-------	-----		-----------
-	*	8	*		String
-	ATOM	32	1		Symbol
-	ATOM	32	> 1		Vector of Symbols
-	*	16	1		Integer
-	*	16	> 1		Vector of Integers
-	*	32	1		if <=16 bits: Integer
-					if > 16 bits: Cons of top16, bot16
-	*	32	> 1		Vector of the above
-
-   When converting a Lisp number to C, it is assumed to be of format 16 if
-   it is an integer, and of format 32 if it is a cons of two integers.
-
-   When converting a vector of numbers from Elisp to C, it is assumed to be
-   of format 16 if every element in the vector is an integer, and is assumed
-   to be of format 32 if any element is a cons of two integers.
-
-   When converting an object to C, it may be of the form (SYMBOL . <data>)
-   where SYMBOL is what we should claim that the type is.  Format and
-   representation are as above.
-
-   NOTE: Under Mule, when someone shoves us a string without a type, we
-   set the type to 'COMPOUND_TEXT and automatically convert to Compound
-   Text.  If the string has a type, we assume that the user wants the
-   data sent as-is so we just do "binary" conversion.
- */
-
-
-static Lisp_Object
-selection_data_to_lisp_data (struct device *d,
-			     unsigned char *data,
-			     size_t size,
-			     Atom type,
-			     int format)
-{
-  if (type == DEVICE_XATOM_NULL (d))
-    return QNULL;
-
-  /* Convert any 8-bit data to a string, for compactness. */
-  else if (format == 8)
-    return make_ext_string (data, size,
-			    type == DEVICE_XATOM_TEXT (d) ||
-			    type == DEVICE_XATOM_COMPOUND_TEXT (d)
-			    ? FORMAT_CTEXT : FORMAT_BINARY);
-
-  /* Convert a single atom to a Lisp Symbol.
-     Convert a set of atoms to a vector of symbols. */
-  else if (type == XA_ATOM)
-    {
-      if (size == sizeof (Atom))
-	return x_atom_to_symbol (d, *((Atom *) data));
-      else
-	{
-	  int i;
-	  int len = size / sizeof (Atom);
-	  Lisp_Object v = Fmake_vector (make_int (len), Qzero);
-	  for (i = 0; i < len; i++)
-	    Faset (v, make_int (i), x_atom_to_symbol (d, ((Atom *) data) [i]));
-	  return v;
-	}
-    }
-
-  /* Convert a single 16 or small 32 bit number to a Lisp Int.
-     If the number is > 16 bits, convert it to a cons of integers,
-     16 bits in each half.
-   */
-  else if (format == 32 && size == sizeof (long))
-    return word_to_lisp (((unsigned long *) data) [0]);
-  else if (format == 16 && size == sizeof (short))
-    return make_int ((int) (((unsigned short *) data) [0]));
-
-  /* Convert any other kind of data to a vector of numbers, represented
-     as above (as an integer, or a cons of two 16 bit integers).
-
-     #### Perhaps we should return the actual type to lisp as well.
-
-	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
-	==> [4 4]
-
-     and perhaps it should be
-
-	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
-	==> (SPAN . [4 4])
-
-     Right now the fact that the return type was SPAN is discarded before
-     lisp code gets to see it.
-   */
-  else if (format == 16)
-    {
-      int i;
-      Lisp_Object v = make_vector (size / 4, Qzero);
-      for (i = 0; i < (int) size / 4; i++)
-	{
-	  int j = (int) ((unsigned short *) data) [i];
-	  Faset (v, make_int (i), make_int (j));
-	}
-      return v;
-    }
-  else
-    {
-      int i;
-      Lisp_Object v = make_vector (size / 4, Qzero);
-      for (i = 0; i < (int) size / 4; i++)
-	{
-	  unsigned long j = ((unsigned long *) data) [i];
-	  Faset (v, make_int (i), word_to_lisp (j));
-	}
-      return v;
-    }
-}
-
-
-static void
-lisp_data_to_selection_data (struct device *d,
-			     Lisp_Object obj,
-			     unsigned char **data_ret,
-			     Atom *type_ret,
-			     unsigned int *size_ret,
-			     int *format_ret)
-{
-  Lisp_Object type = Qnil;
-
-  if (CONSP (obj) && SYMBOLP (XCAR (obj)))
-    {
-      type = XCAR (obj);
-      obj = XCDR (obj);
-      if (CONSP (obj) && NILP (XCDR (obj)))
-	obj = XCAR (obj);
-    }
-
-  if (EQ (obj, QNULL) || (EQ (type, QNULL)))
-    {				/* This is not the same as declining */
-      *format_ret = 32;
-      *size_ret = 0;
-      *data_ret = 0;
-      type = QNULL;
-    }
-  else if (STRINGP (obj))
-    {
-      CONST Extbyte *extval;
-      Extcount extvallen;
-
-      if (NILP (type))
-	GET_STRING_CTEXT_DATA_ALLOCA (obj, extval, extvallen);
-      else
-	GET_STRING_BINARY_DATA_ALLOCA (obj, extval, extvallen);
-      *format_ret = 8;
-      *size_ret = extvallen;
-      *data_ret = (unsigned char *) xmalloc (*size_ret);
-      memcpy (*data_ret, extval, *size_ret);
-#ifdef MULE
-      if (NILP (type)) type = QCOMPOUND_TEXT;
-#else
-      if (NILP (type)) type = QSTRING;
-#endif
-    }
-  else if (CHARP (obj))
-    {
-      Bufbyte buf[MAX_EMCHAR_LEN];
-      Bytecount len;
-      CONST Extbyte *extval;
-      Extcount extvallen;
-
-      *format_ret = 8;
-      len = set_charptr_emchar (buf, XCHAR (obj));
-      GET_CHARPTR_EXT_CTEXT_DATA_ALLOCA (buf, len, extval, extvallen);
-      *size_ret = extvallen;
-      *data_ret = (unsigned char *) xmalloc (*size_ret);
-      memcpy (*data_ret, extval, *size_ret);
-#ifdef MULE
-      if (NILP (type)) type = QCOMPOUND_TEXT;
-#else
-      if (NILP (type)) type = QSTRING;
-#endif
-    }
-  else if (SYMBOLP (obj))
-    {
-      *format_ret = 32;
-      *size_ret = 1;
-      *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
-      (*data_ret) [sizeof (Atom)] = 0;
-      (*(Atom **) data_ret) [0] = symbol_to_x_atom (d, obj, 0);
-      if (NILP (type)) type = QATOM;
-    }
-  else if (INTP (obj) &&
-	   XINT (obj) <= 0x7FFF &&
-	   XINT (obj) >= -0x8000)
-    {
-      *format_ret = 16;
-      *size_ret = 1;
-      *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1);
-      (*data_ret) [sizeof (short)] = 0;
-      (*(short **) data_ret) [0] = (short) XINT (obj);
-      if (NILP (type)) type = QINTEGER;
-    }
-  else if (INTP (obj) || CONSP (obj))
-    {
-      *format_ret = 32;
-      *size_ret = 1;
-      *data_ret = (unsigned char *) xmalloc (sizeof (long) + 1);
-      (*data_ret) [sizeof (long)] = 0;
-      (*(unsigned long **) data_ret) [0] = lisp_to_word (obj);
-      if (NILP (type)) type = QINTEGER;
-    }
-  else if (VECTORP (obj))
-    {
-      /* Lisp Vectors may represent a set of ATOMs;
-	 a set of 16 or 32 bit INTEGERs;
-	 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...]
-       */
-      int i;
-
-      if (SYMBOLP (XVECTOR_DATA (obj) [0]))
-	/* This vector is an ATOM set */
-	{
-	  if (NILP (type)) type = QATOM;
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  *format_ret = 32;
-	  *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom));
-	  for (i = 0; i < (int) (*size_ret); i++)
-	    if (SYMBOLP (XVECTOR_DATA (obj) [i]))
-	      (*(Atom **) data_ret) [i] =
-		symbol_to_x_atom (d, XVECTOR_DATA (obj) [i], 0);
-	    else
-              signal_error (Qerror, /* Qselection_error */
-                            list2 (build_string
-		   ("all elements of the vector must be of the same type"),
-                                   obj));
-	}
-#if 0 /* #### MULTIPLE doesn't work yet */
-      else if (VECTORP (XVECTOR_DATA (obj) [0]))
-	/* This vector is an ATOM_PAIR set */
-	{
-	  if (NILP (type)) type = QATOM_PAIR;
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  *format_ret = 32;
-	  *data_ret = (unsigned char *)
-	    xmalloc ((*size_ret) * sizeof (Atom) * 2);
-	  for (i = 0; i < *size_ret; i++)
-	    if (VECTORP (XVECTOR_DATA (obj) [i]))
-	      {
-		Lisp_Object pair = XVECTOR_DATA (obj) [i];
-		if (XVECTOR_LENGTH (pair) != 2)
-		  signal_error (Qerror,
-                                list2 (build_string
-       ("elements of the vector must be vectors of exactly two elements"),
-				  pair));
-
-		(*(Atom **) data_ret) [i * 2] =
-		  symbol_to_x_atom (d, XVECTOR_DATA (pair) [0], 0);
-		(*(Atom **) data_ret) [(i * 2) + 1] =
-		  symbol_to_x_atom (d, XVECTOR_DATA (pair) [1], 0);
-	      }
-	    else
-	      signal_error (Qerror,
-                            list2 (build_string
-		   ("all elements of the vector must be of the same type"),
-                                   obj));
-	}
-#endif
-      else
-	/* This vector is an INTEGER set, or something like it */
-	{
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  if (NILP (type)) type = QINTEGER;
-	  *format_ret = 16;
-	  for (i = 0; i < (int) (*size_ret); i++)
-	    if (CONSP (XVECTOR_DATA (obj) [i]))
-	      *format_ret = 32;
-	    else if (!INTP (XVECTOR_DATA (obj) [i]))
-	      signal_error (Qerror, /* Qselection_error */
-                            list2 (build_string
-	("all elements of the vector must be integers or conses of integers"),
-                                   obj));
-
-	  *data_ret = (unsigned char *) xmalloc (*size_ret * (*format_ret/8));
-	  for (i = 0; i < (int) (*size_ret); i++)
-	    if (*format_ret == 32)
-	      (*((unsigned long **) data_ret)) [i] =
-		lisp_to_word (XVECTOR_DATA (obj) [i]);
-	    else
-	      (*((unsigned short **) data_ret)) [i] =
-		(unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]);
-	}
-    }
-  else
-    signal_error (Qerror, /* Qselection_error */
-                  list2 (build_string ("unrecognized selection data"),
-                         obj));
-
-  *type_ret = symbol_to_x_atom (d, type, 0);
-}
-
-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;
-}
-
-
-/* Called from the event loop to handle SelectionNotify events.
-   I don't think this needs to be reentrant.
- */
-void
-x_handle_selection_notify (XSelectionEvent *event)
-{
-  if (! reading_selection_reply)
-    message ("received an unexpected SelectionNotify event");
-  else if (event->requestor != reading_selection_reply)
-    message ("received a SelectionNotify event for the wrong window");
-  else if (event->selection != reading_which_selection)
-    message ("received the wrong selection type in SelectionNotify!");
-  else
-    reading_selection_reply = 0; /* we're done now. */
-}
-
-
-DEFUN ("x-own-selection-internal", Fx_own_selection_internal, 2, 2, 0, /*
-Assert an X selection of the given TYPE with the given VALUE.
-TYPE 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.
-*/
-       (selection_name, selection_value))
-{
-  CHECK_SYMBOL (selection_name);
-  if (NILP (selection_value)) error ("selection-value may not be nil.");
-  x_own_selection (selection_name, selection_value);
-  return selection_value;
-}
-
-
-/* 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.
- */
-DEFUN ("x-get-selection-internal", Fx_get_selection_internal, 2, 2, 0, /*
-Return text selected from some X window.
-SELECTION_SYMBOL is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
-TARGET_TYPE is the type of data desired, typically STRING or COMPOUND_TEXT.
-Under Mule, if the resultant data comes back as 8-bit data in type
-TEXT or COMPOUND_TEXT, it will be decoded as Compound Text.
-*/
-       (selection_symbol, target_type))
-{
-  /* This function can GC */
-  Lisp_Object val = Qnil;
-  struct gcpro gcpro1, gcpro2;
-  GCPRO2 (target_type, val); /* we store newly consed data into these */
-  CHECK_SYMBOL (selection_symbol);
-
-#if 0 /* #### MULTIPLE doesn't work yet */
-  if (CONSP (target_type) &&
-      XCAR (target_type) == QMULTIPLE)
-    {
-      CHECK_VECTOR (XCDR (target_type));
-      /* So we don't destructively modify this... */
-      target_type = copy_multiple_data (target_type);
-    }
-  else
-#endif
-    CHECK_SYMBOL (target_type);
-
-  val = x_get_local_selection (selection_symbol, target_type);
-
-  if (NILP (val))
-    {
-      val = x_get_foreign_selection (selection_symbol, target_type);
-    }
-  else
-    {
-      if (CONSP (val) && SYMBOLP (XCAR (val)))
-	{
-	  val = XCDR (val);
-	  if (CONSP (val) && NILP (XCDR (val)))
-	    val = XCAR (val);
-	}
-      val = clean_local_selection_data (val);
-    }
-  UNGCPRO;
-  return val;
-}
-
-DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal, 1, 2, 0, /*
-If we own the named selection, then disown it (make there be no selection).
-*/
-       (selection, timeval))
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  Time timestamp;
-  Atom selection_atom;
-  XSelectionClearEvent event;
-
-  CHECK_SYMBOL (selection);
-  if (NILP (timeval))
-    timestamp = DEVICE_X_MOUSE_TIMESTAMP (d);
-  else
-    {
-      /* #### This is bogus.  See the comment above about problems
-	 on OSF/1 and DEC Alphas.  Yet another reason why it sucks
-	 to have the implementation (i.e. cons of two 16-bit
-	 integers) exposed. */
-      time_t the_time;
-      lisp_to_time (timeval, &the_time);
-      timestamp = (Time) the_time;
-    }
-
-  if (NILP (assq_no_quit (selection, Vselection_alist)))
-    return Qnil;  /* Don't disown the selection when we're not the owner. */
-
-  selection_atom = symbol_to_x_atom (d, selection, 0);
-
-  XSetSelectionOwner (display, selection_atom, None, timestamp);
-
-  /* It doesn't seem to be guaranteed that a SelectionClear event will be
-     generated for a window which owns the selection when that window sets
-     the selection owner to None.  The NCD server does, the MIT Sun4 server
-     doesn't.  So we synthesize one; this means we might get two, but
-     that's ok, because the second one won't have any effect.
-   */
-  event.display = display;
-  event.selection = selection_atom;
-  event.time = timestamp;
-  x_handle_selection_clear (&event);
-
-  return Qt;
-}
-
-
-DEFUN ("x-selection-owner-p", Fx_selection_owner_p, 0, 1, 0, /*
-Return t if current emacs process owns the given X 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.)
-*/
-       (selection))
-{
-  CHECK_SYMBOL (selection);
-  if      (EQ (selection, Qnil)) selection = QPRIMARY;
-  else if (EQ (selection, Qt))   selection = QSECONDARY;
-
-  return NILP (Fassq (selection, Vselection_alist)) ? Qnil : Qt;
-}
-
-DEFUN ("x-selection-exists-p", Fx_selection_exists_p, 0, 1, 0, /*
-Whether there is an owner for the given X 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.)
-*/
-       (selection))
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *dpy = DEVICE_X_DISPLAY (d);
-  CHECK_SYMBOL (selection);
-  if (!NILP (Fx_selection_owner_p (selection)))
-    return Qt;
-  return XGetSelectionOwner (dpy, symbol_to_x_atom (d, selection, 0)) != None ?
-    Qt : Qnil;
-}
-
-
-#ifdef CUT_BUFFER_SUPPORT
-
-static int cut_buffers_initialized; /* Whether we're sure they all exist */
-
-/* Ensure that all 8 cut buffers exist.  ICCCM says we gotta... */
-static void
-initialize_cut_buffers (Display *display, Window window)
-{
-  static unsigned CONST char * CONST data = (unsigned CONST char *) "";
-#define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \
-				    PropModeAppend, data, 0)
-  FROB (XA_CUT_BUFFER0);
-  FROB (XA_CUT_BUFFER1);
-  FROB (XA_CUT_BUFFER2);
-  FROB (XA_CUT_BUFFER3);
-  FROB (XA_CUT_BUFFER4);
-  FROB (XA_CUT_BUFFER5);
-  FROB (XA_CUT_BUFFER6);
-  FROB (XA_CUT_BUFFER7);
-#undef FROB
-  cut_buffers_initialized = 1;
-}
-
-#define CHECK_CUTBUFFER(symbol)						\
-  { CHECK_SYMBOL (symbol);						\
-    if (!EQ((symbol),QCUT_BUFFER0) && !EQ((symbol),QCUT_BUFFER1) &&	\
-	!EQ((symbol),QCUT_BUFFER2) && !EQ((symbol),QCUT_BUFFER3) &&	\
-	!EQ((symbol),QCUT_BUFFER4) && !EQ((symbol),QCUT_BUFFER5) &&	\
-	!EQ((symbol),QCUT_BUFFER6) && !EQ((symbol),QCUT_BUFFER7))	\
-      signal_error (Qerror, list2 (build_string ("Doesn't name a cutbuffer"), \
-                                   (symbol))); \
-  }
-
-DEFUN ("x-get-cutbuffer-internal", Fx_get_cutbuffer_internal, 1, 1, 0, /*
-Return the value of the named CUTBUFFER (typically CUT_BUFFER0).
-*/
-       (cutbuffer))
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
-  Atom cut_buffer_atom;
-  unsigned char *data;
-  int bytes;
-  Atom type;
-  int format;
-  unsigned long size;
-  Lisp_Object ret;
-
-  CHECK_CUTBUFFER (cutbuffer);
-  cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
-
-  x_get_window_property (display, window, cut_buffer_atom, &data, &bytes,
-			 &type, &format, &size, 0);
-  if (!data) return Qnil;
-
-  if (format != 8 || type != XA_STRING)
-    signal_simple_error_2 ("Cut buffer doesn't contain 8-bit STRING data",
-			   x_atom_to_symbol (d, type),
-			   make_int (format));
-
-  /* We cheat - if the string contains an ESC character, that's
-     technically not allowed in a STRING, so we assume it's
-     COMPOUND_TEXT that we stored there ourselves earlier,
-     in x-store-cutbuffer-internal  */
-  ret = (bytes ?
-	 make_ext_string (data, bytes,
-			  memchr (data, 0x1b, bytes) ?
-			  FORMAT_CTEXT : FORMAT_BINARY)
-	 : Qnil);
-  xfree (data);
-  return ret;
-}
-
-
-DEFUN ("x-store-cutbuffer-internal", Fx_store_cutbuffer_internal, 2, 2, 0, /*
-Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING.
-*/
-       (cutbuffer, string))
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
-  Atom cut_buffer_atom;
-  CONST Extbyte *data  = XSTRING_DATA (string);
-  Extcount bytes = XSTRING_LENGTH (string);
-  Extcount bytes_remaining;
-  int max_bytes = SELECTION_QUANTUM (display);
-#ifdef MULE
-  CONST Bufbyte *ptr, *end;
-  enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
-#endif
-
-  if (max_bytes > MAX_SELECTION_QUANTUM)
-    max_bytes = MAX_SELECTION_QUANTUM;
-
-  CHECK_CUTBUFFER (cutbuffer);
-  CHECK_STRING (string);
-  cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
-
-  if (! cut_buffers_initialized)
-    initialize_cut_buffers (display, window);
-
-  /* We use the STRING encoding (Latin-1 only) if we can, else COMPOUND_TEXT.
-     We cheat and use type = `STRING' even when using COMPOUND_TEXT.
-     The ICCCM requires that this be so, and other clients assume it,
-     as we do ourselves in initialize_cut_buffers.  */
-
-#ifdef MULE
-  /* Optimize for the common ASCII case */
-  for (ptr = data, end = ptr + bytes; ptr <= end; )
-    {
-      if (BYTE_ASCII_P (*ptr))
-	{
-	  ptr++;
-	  continue;
-	}
-
-      if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
-	  (*ptr) == LEADING_BYTE_CONTROL_1)
-	{
-	  chartypes = LATIN_1;
-	  ptr += 2;
-	  continue;
-	}
-
-      chartypes = WORLD;
-      break;
-    }
-
-  if (chartypes == LATIN_1)
-    GET_STRING_BINARY_DATA_ALLOCA (string, data, bytes);
-  else if (chartypes == WORLD)
-    GET_STRING_CTEXT_DATA_ALLOCA  (string, data, bytes);
-#endif /* MULE */
-
-  bytes_remaining = bytes;
-
-  while (bytes_remaining)
-    {
-      int chunk = bytes_remaining < max_bytes ? bytes_remaining : max_bytes;
-      XChangeProperty (display, window, cut_buffer_atom, XA_STRING, 8,
-		       (bytes_remaining == bytes
-			? PropModeReplace : PropModeAppend),
-		       data, chunk);
-      data += chunk;
-      bytes_remaining -= chunk;
-    }
-  return string;
-}
-
-
-DEFUN ("x-rotate-cutbuffers-internal", Fx_rotate_cutbuffers_internal, 1, 1, 0, /*
-Rotate the values of the cutbuffers by the given number of steps;
-positive means move values forward, negative means backward.
-*/
-       (n))
-{
-  struct device *d = decode_x_device (Qnil);
-  Display *display = DEVICE_X_DISPLAY (d);
-  Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
-  Atom props [8];
-
-  CHECK_INT (n);
-  if (XINT (n) == 0)
-    return n;
-  if (! cut_buffers_initialized)
-    initialize_cut_buffers (display, window);
-  props[0] = XA_CUT_BUFFER0;
-  props[1] = XA_CUT_BUFFER1;
-  props[2] = XA_CUT_BUFFER2;
-  props[3] = XA_CUT_BUFFER3;
-  props[4] = XA_CUT_BUFFER4;
-  props[5] = XA_CUT_BUFFER5;
-  props[6] = XA_CUT_BUFFER6;
-  props[7] = XA_CUT_BUFFER7;
-  XRotateWindowProperties (display, window, props, 8, XINT (n));
-  return n;
-}
-
-#endif /* CUT_BUFFER_SUPPORT */
-
-
-
-/************************************************************************/
-/*                            initialization                            */
-/************************************************************************/
-
-void
-syms_of_xselect (void)
-{
-  DEFSUBR (Fx_get_selection_internal);
-  DEFSUBR (Fx_own_selection_internal);
-  DEFSUBR (Fx_disown_selection_internal);
-  DEFSUBR (Fx_selection_owner_p);
-  DEFSUBR (Fx_selection_exists_p);
-
-#ifdef CUT_BUFFER_SUPPORT
-  DEFSUBR (Fx_get_cutbuffer_internal);
-  DEFSUBR (Fx_store_cutbuffer_internal);
-  DEFSUBR (Fx_rotate_cutbuffers_internal);
-#endif /* CUT_BUFFER_SUPPORT */
-
-  /* Unfortunately, timeout handlers must be lisp functions. */
-  defsymbol (&Qx_selection_reply_timeout_internal,
-             "x-selection-reply-timeout-internal");
-  DEFSUBR (Fx_selection_reply_timeout_internal);
-
-  defsymbol (&QPRIMARY, "PRIMARY");
-  defsymbol (&QSECONDARY, "SECONDARY");
-  defsymbol (&QSTRING, "STRING");
-  defsymbol (&QINTEGER, "INTEGER");
-  defsymbol (&QCLIPBOARD, "CLIPBOARD");
-  defsymbol (&QTIMESTAMP, "TIMESTAMP");
-  defsymbol (&QTEXT, "TEXT");
-  defsymbol (&QDELETE, "DELETE");
-  defsymbol (&QMULTIPLE, "MULTIPLE");
-  defsymbol (&QINCR, "INCR");
-  defsymbol (&QEMACS_TMP, "_EMACS_TMP_");
-  defsymbol (&QTARGETS, "TARGETS");
-  defsymbol (&QATOM, "ATOM");
-  defsymbol (&QATOM_PAIR, "ATOM_PAIR");
-  defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT");
-  defsymbol (&QNULL, "NULL");
-
-#ifdef CUT_BUFFER_SUPPORT
-  defsymbol (&QCUT_BUFFER0, "CUT_BUFFER0");
-  defsymbol (&QCUT_BUFFER1, "CUT_BUFFER1");
-  defsymbol (&QCUT_BUFFER2, "CUT_BUFFER2");
-  defsymbol (&QCUT_BUFFER3, "CUT_BUFFER3");
-  defsymbol (&QCUT_BUFFER4, "CUT_BUFFER4");
-  defsymbol (&QCUT_BUFFER5, "CUT_BUFFER5");
-  defsymbol (&QCUT_BUFFER6, "CUT_BUFFER6");
-  defsymbol (&QCUT_BUFFER7, "CUT_BUFFER7");
-#endif /* CUT_BUFFER_SUPPORT */
-
-  deferror (&Qselection_conversion_error,
-	    "selection-conversion-error",
-	    "selection-conversion error", Qio_error);
-}
-
-void
-vars_of_xselect (void)
-{
-#ifdef CUT_BUFFER_SUPPORT
-  cut_buffers_initialized = 0;
-  Fprovide (intern ("cut-buffer"));
-#endif
-
-  reading_selection_reply = 0;
-  reading_which_selection = 0;
-  selection_reply_timed_out = 0;
-  for_whom_the_bell_tolls = 0;
-  prop_location_tick = 0;
-
-  Vselection_alist = Qnil;
-  staticpro (&Vselection_alist);
-
-  DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_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 `x-own-selection').  These functions should
-return the value to send to the X server, which should be one of:
-
--- nil (the conversion could not be done)
--- a cons of a symbol and any of the following values; the symbol
-   explicitly specifies the type that will be sent.
--- a string (If the type is not specified, then if Mule support exists,
-             the string will be converted to Compound Text and sent in
-             the 'COMPOUND_TEXT format; otherwise (no Mule support),
-             the string will be left as-is and sent in the 'STRING
-             format.  If the type is specified, the string will be
-             left as-is (or converted to binary format under Mule).
-             In all cases, 8-bit data it sent.)
--- a character (With Mule support, will be converted to Compound Text
-                whether or not a type is specified.  If a type is not
-                specified, a type of 'STRING or 'COMPOUND_TEXT will be
-		sent, as for strings.)
--- the symbol 'NULL (Indicates that there is no meaningful return value.
-                     Empty 32-bit data with a type of 'NULL will be sent.)
--- a symbol (Will be converted into an atom.  If the type is not specified,
-             a type of 'ATOM will be sent.)
--- an integer (Will be converted into a 16-bit or 32-bit integer depending
-               on the value.  If the type is not specified, a type of
-	       'INTEGER will be sent.)
--- a cons (HIGH . LOW) of integers (Will be converted into a 32-bit integer.
-                                    If the type is not specified, a type of
-				    'INTEGER will be sent.)
--- a vector of symbols (Will be converted into a list of atoms.  If the type
-                        is not specified, a type of 'ATOM will be sent.)
--- a vector 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.)
--- 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;
-
-  DEFVAR_LISP ("x-lost-selection-hooks", &Vx_lost_selection_hooks /*
-A function or functions to be called after the X server has notified us
-that we have lost the selection.  The function(s) will be called with one
-argument, a symbol naming the selection (typically PRIMARY, SECONDARY, or
-CLIPBOARD).
-*/ );
-  Vx_lost_selection_hooks = Qunbound;
-
-  DEFVAR_LISP ("x-sent-selection-hooks", &Vx_sent_selection_hooks /*
-A function or functions to be called after we have responded to some
-other client's request for the value of a selection that we own.  The
-function(s) will be called with four arguments:
-  - the name of the selection (typically PRIMARY, SECONDARY, or CLIPBOARD);
-  - the name of the selection-type which we were requested to convert the
-    selection into before sending (for example, STRING or LENGTH);
-  - and whether we successfully transmitted the selection.
-We might have failed (and declined the request) for any number of reasons,
-including being asked for a selection that we no longer own, or being asked
-to convert into a type that we don't know about or that is inappropriate.
-This hook doesn't let you change the behavior of emacs's selection replies,
-it merely informs you that they have happened.
-*/ );
-  Vx_sent_selection_hooks = Qunbound;
-
-  DEFVAR_INT ("x-selection-timeout", &x_selection_timeout /*
-If the selection owner doesn't reply in this many seconds, we give up.
-A value of 0 means wait as long as necessary.  This is initialized from the
-\"*selectionTimeout\" resource (which is expressed in milliseconds).
-*/ );
-  x_selection_timeout = 0;
-}
-
-void
-Xatoms_of_xselect (struct device *d)
-{
-  Display *D = DEVICE_X_DISPLAY (d);
-
-  /* Non-predefined atoms that we might end up using a lot */
-  DEVICE_XATOM_CLIPBOARD     (d) = XInternAtom (D, "CLIPBOARD",     False);
-  DEVICE_XATOM_TIMESTAMP     (d) = XInternAtom (D, "TIMESTAMP",     False);
-  DEVICE_XATOM_TEXT          (d) = XInternAtom (D, "TEXT",          False);
-  DEVICE_XATOM_DELETE        (d) = XInternAtom (D, "DELETE",        False);
-  DEVICE_XATOM_MULTIPLE      (d) = XInternAtom (D, "MULTIPLE",      False);
-  DEVICE_XATOM_INCR          (d) = XInternAtom (D, "INCR",          False);
-  DEVICE_XATOM_TARGETS       (d) = XInternAtom (D, "TARGETS",       False);
-  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);
-  DEVICE_XATOM_EMACS_TMP     (d) = XInternAtom (D, "_EMACS_TMP_",   False);
-}
--- a/tests/ChangeLog	Mon Aug 13 11:20:44 2007 +0200
+++ b/tests/ChangeLog	Mon Aug 13 11:21:38 2007 +0200
@@ -1,3 +1,15 @@
+1999-06-04  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+	* XEmacs 21.2.15 is released
+
+1999-06-02  Oscar Figueiredo  <oscar@xemacs.org>
+
+	* automated/lisp-tests.el: Test `split-string'
+
+1999-05-27  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* automated/base64-tests.el: New file.
+
 1999-05-14  XEmacs Build Bot <builds@cvs.xemacs.org>
 
 	* XEmacs 21.2.14 is released
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/automated/base64-tests.el	Mon Aug 13 11:21:38 2007 +0200
@@ -0,0 +1,271 @@
+;; Copyright (C) 1999 Free Software Foundation, Inc.
+
+;; Author: Hrvoje Niksic <hniksic@srce.hr>
+;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
+;; Created: 1999
+;; Keywords: tests
+
+;; 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:
+
+;; Test base64 functions.
+;; See test-harness.el for instructions on how to run these tests.
+
+(eval-when-compile
+  (condition-case nil
+      (require 'test-harness)
+    (file-error
+     (push "." load-path)
+     (when (and (boundp 'load-file-name) (stringp load-file-name))
+       (push (file-name-directory load-file-name) load-path))
+     (require 'test-harness))))
+
+;; We need to test the buffer and string functions.  We do it by
+;; testing them in various circumstances, asserting the same result,
+;; and returning that result.
+
+(defvar bt-test-buffer (get-buffer-create " *base64-workhorse*"))
+
+(defun bt-base64-encode-string (string &optional no-line-break)
+  (let ((string-result (base64-encode-string string no-line-break))
+	length)
+    (with-current-buffer bt-test-buffer
+      ;; the whole buffer
+      (erase-buffer)
+      (insert string)
+      (setq length (base64-encode-region (point-min) (point-max) no-line-break))
+      (Assert (eq length (- (point-max) (point-min))))
+      (Assert (equal (buffer-string) string-result))
+      ;; partial
+      (erase-buffer)
+      (insert "random junk........\0\0';'eqwrkw[erpqf")
+      (let ((p1 (point)) p2)
+	(insert string)
+	(setq p2 (point-marker))
+	(insert "...more random junk.q,f3/.qrm314.r,m2typ' 2436T@W$^@$#^T@")
+	(setq length (base64-encode-region p1 p2 no-line-break))
+	(Assert (eq length (- p2 p1)))
+	(Assert (equal (buffer-substring p1 p2) string-result))))
+    string-result))
+
+(defun bt-base64-decode-string (string)
+  (let ((string-result (base64-decode-string string))
+	length)
+    (with-current-buffer bt-test-buffer
+      ;; the whole buffer
+      (erase-buffer)
+      (insert string)
+      (setq length (base64-decode-region (point-min) (point-max)))
+      (cond (string-result
+	     (Assert (eq length (- (point-max) (point-min))))
+	     (Assert (equal (buffer-string) string-result)))
+	    (t
+	     (Assert (null length))
+	     ;; The buffer should not have been modified.
+	     (Assert (equal (buffer-string) string))))
+      ;; partial
+      (erase-buffer)
+      (insert "random junk........\0\0';'eqwrkw[erpqf")
+      (let ((p1 (point)) p2)
+	(insert string)
+	(setq p2 (point-marker))
+	(insert "...more random junk.q,f3/.qrm314.\0\0r,m2typ' 2436T@W$^@$#T@")
+	(setq length (base64-decode-region p1 p2))
+	(cond (string-result
+	       (Assert (eq length (- p2 p1)))
+	       (Assert (equal (buffer-substring p1 p2) string-result)))
+	      (t
+	       (Assert (null length))
+	       ;; The buffer should not have been modified.
+	       (Assert (equal (buffer-substring p1 p2) string))))))
+    string-result))
+
+(defun bt-remove-newlines (str)
+  (apply #'string (delete ?\n (mapcar #'identity str))))
+
+(defconst bt-allchars
+  (let ((str (make-string 256 ?\0)))
+    (dotimes (i 256)
+      (aset str i (int-char i)))
+    str))
+
+(defconst bt-test-strings
+  `(("" "")
+    ("foo" "Zm9v")
+    ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+     "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0
+NTY3ODk=")
+    (,bt-allchars
+     "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4
+OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3Bx
+cnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmq
+q6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj
+5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==")
+    ))
+
+;;-----------------------------------------------------
+;; Encoding base64
+;;-----------------------------------------------------
+
+(loop for (raw encoded) in bt-test-strings do
+  (Assert (equal (bt-base64-encode-string raw) encoded))
+  ;; test the NO-LINE-BREAK flag
+  (Assert (equal (bt-base64-encode-string raw t) (bt-remove-newlines encoded))))
+
+;; When Mule is around, Lisp programmers should make sure that the
+;; buffer contains only characters whose `char-int' is in the [0, 256)
+;; range.  If this condition is not satisfied for any character, an
+;; error is signaled.
+(when (featurep 'mule)
+  ;; #### remove subtraction of 128 -- no longer needed with make-char
+  ;; patch!
+  (let* ((mule-string (format "Hrvoje Nik%ci%c"
+			      ;; scaron == 185 in Latin 2
+			      (make-char 'latin-iso8859-2 (- 185 128))
+			      ;; cacute == 230 in Latin 2
+			      (make-char 'latin-iso8859-2 (- 230 128)))))
+    (Check-Error-Message error "Non-ascii character in base64 input"
+      (bt-base64-encode-string mule-string))))
+
+;;-----------------------------------------------------
+;; Decoding base64
+;;-----------------------------------------------------
+
+(loop for (raw encoded) in bt-test-strings do
+  (Assert (equal (bt-base64-decode-string encoded) raw))
+  (Assert (equal (bt-base64-decode-string (bt-remove-newlines encoded)) raw)))
+
+;; Test errors
+(dolist (str `("foo" "AAC" "foo\0bar" ,bt-allchars))
+  (Assert (eq (bt-base64-decode-string str) nil)))
+
+;; base64-decode-string is supposed to handle whitespaces anywhere in
+;; the string.  We test this in the cheesis manner possible, by
+;; inserting whitespaces at the beginning, at the end, in the middle
+;; of the string, and mixed.
+
+(defconst bt-whitespace-chars '(?\  ?\t ?\r ?\n ?\f ?\v))
+
+(loop for (raw encoded) in bt-test-strings do
+  ;; Whitespace at the beginning
+  (dolist (char bt-whitespace-chars)
+    ;; One char...
+    (let ((mangled (concat (list char) encoded)))
+      (Assert (equal (bt-base64-decode-string mangled) raw))))
+  ;; ...all chars.
+  (let ((mangled (concat bt-whitespace-chars encoded)))
+    (Assert (equal (bt-base64-decode-string mangled) raw)))
+
+  ;; Whitespace at the end
+  (dolist (char bt-whitespace-chars)
+    ;; One char...
+    (let ((mangled (concat encoded (list char))))
+      (Assert (equal (bt-base64-decode-string mangled) raw))))
+  ;; ...all chars.
+  (let ((mangled (concat encoded bt-whitespace-chars)))
+    (Assert (equal (bt-base64-decode-string mangled) raw)))
+
+  (unless (equal raw "")
+    ;; Whitespace in the middle
+    (let* ((middlepos (/ (1+ (length encoded)) 2))
+	   (left (substring encoded 0 middlepos))
+	   (right (substring encoded middlepos)))
+      (dolist (char bt-whitespace-chars)
+	;; One char...
+	(let ((mangled (concat left (list char) right)))
+	  (Assert (equal (bt-base64-decode-string mangled) raw))))
+      ;; ...all chars.
+      (let ((mangled (concat left bt-whitespace-chars right)))
+	(Assert (equal (bt-base64-decode-string mangled) raw)))
+
+      ;; Whitespace at the beginning, end, and middle.
+      (dolist (char bt-whitespace-chars)
+	;; One char...
+	(let ((mangled (concat (list char) left (list char) right (list char))))
+	  (Assert (equal (bt-base64-decode-string mangled) raw))))
+      ;; ...all chars.
+      (let ((mangled (concat bt-whitespace-chars left bt-whitespace-chars right
+			     bt-whitespace-chars)))
+	(Assert (equal (bt-base64-decode-string mangled) raw)))
+
+      ;; Whitespace between every char.
+      (dolist (char bt-whitespace-chars)
+	;; One char...
+	(let ((mangled (concat (list char)
+			       ;; ENCODED with char between every character.
+			       (mapconcat #'char-to-string encoded
+					  (char-to-string char))
+			       (list char))))
+	  (Assert (equal (bt-base64-decode-string mangled) raw))))
+      ;; ...all chars.
+      (let ((mangled (concat bt-whitespace-chars
+			     ;; ENCODED with bt-whitespace-chars
+			     ;; between every character.
+			     (mapconcat #'char-to-string encoded
+					(apply #'string bt-whitespace-chars))
+			     bt-whitespace-chars)))
+	  (Assert (equal (bt-base64-decode-string mangled) raw))))))
+
+;;-----------------------------------------------------
+;; Mixed...
+;;-----------------------------------------------------
+
+;; The crux of the whole base64 business is to ensure that
+;; (base64-decode-string (base64-decode-string FOO)) equals FOO.  The
+;; following stunts stress-test practically all aspects of the
+;; encoding and decoding process.
+
+(loop for (string1 ignored) in bt-test-strings do
+  (Assert (equal (bt-base64-decode-string
+		  (bt-base64-encode-string string1))
+		 string1))
+  (Assert (equal (bt-base64-decode-string
+		  (bt-base64-decode-string
+		   (bt-base64-encode-string
+		    (bt-base64-encode-string string1))))
+		 string1))
+  (Assert (equal (bt-base64-decode-string
+		  (bt-base64-decode-string
+		   (bt-base64-decode-string
+		    (bt-base64-encode-string
+		     (bt-base64-encode-string
+		      (bt-base64-encode-string string1))))))
+		 string1))
+  (Assert (equal (bt-base64-decode-string
+		  (bt-base64-decode-string
+		   (bt-base64-decode-string
+		    (bt-base64-decode-string
+		     (bt-base64-encode-string
+		      (bt-base64-encode-string
+		       (bt-base64-encode-string
+			(bt-base64-encode-string string1))))))))
+		 string1))
+  (Assert (equal (bt-base64-decode-string
+		  (bt-base64-decode-string
+		   (bt-base64-decode-string
+		    (bt-base64-decode-string
+		     (bt-base64-decode-string
+		      (bt-base64-encode-string
+		       (bt-base64-encode-string
+			(bt-base64-encode-string
+			 (bt-base64-encode-string
+			  (bt-base64-encode-string string1))))))))))
+		 string1)))
--- a/tests/automated/lisp-tests.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/tests/automated/lisp-tests.el	Mon Aug 13 11:21:38 2007 +0200
@@ -785,3 +785,20 @@
  (defun test-emacs-buffer-local-parameter (test-emacs-buffer-local-variable)
    (setq test-emacs-buffer-local-variable nil)))
 (test-emacs-buffer-local-parameter nil)
+
+;;-----------------------------------------------------
+;; Test split-string
+;;-----------------------------------------------------
+;; Hrvoje didn't like these tests so I'm disabling them for now. -sb
+;(Assert (equal (split-string "foo" "") '("" "f" "o" "o" "")))
+;(Assert (equal (split-string "foo" "^") '("" "foo")))
+;(Assert (equal (split-string "foo" "$") '("foo" "")))
+(Assert (equal (split-string "foo,bar" ",") '("foo" "bar")))
+(Assert (equal (split-string ",foo,bar," ",") '("" "foo" "bar" "")))
+(Assert (equal (split-string ",foo,bar," "^,") '("" "foo,bar,")))
+(Assert (equal (split-string ",foo,bar," ",$") '(",foo,bar" "")))
+(Assert (equal (split-string ",foo,,bar," ",") '("" "foo" "" "bar" "")))
+(Assert (equal (split-string "foo,,,bar" ",") '("foo" "" "" "bar")))
+(Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" "")))
+(Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar")))
+(Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" "")))
--- a/version.sh	Mon Aug 13 11:20:44 2007 +0200
+++ b/version.sh	Mon Aug 13 11:21:38 2007 +0200
@@ -1,8 +1,9 @@
 #!/bin/sh
+emacs_is_beta=t
 emacs_major_version=21
 emacs_minor_version=2
-emacs_beta_version=14
-xemacs_codename="Dionysos"
+emacs_beta_version=15
+xemacs_codename="Sakuragawa"
 infodock_major_version=4
 infodock_minor_version=0
 infodock_build_version=7