changeset 853:2b6fa2618f76

[xemacs-hg @ 2002-05-28 08:44:22 by ben] merge my stderr-proc ws make-docfile.c: Fix places where we forget to check for EOF. code-init.el: Don't use CRLF conversion by default on process output. CMD.EXE and friends work both ways but Cygwin programs don't like the CRs. code-process.el, multicast.el, process.el: Removed. Improvements to call-process-internal: -- allows a buffer to be specified for input and stderr output -- use it on all systems -- implement C-g as documented -- clean up and comment call-process-region uses new call-process facilities; no temp file. remove duplicate funs in process.el. comment exactly how coding systems work and fix various problems. open-multicast-group now does similar coding-system frobbing to open-network-stream. dumped-lisp.el, faces.el, msw-faces.el: Fix some hidden errors due to code not being defined at the right time. xemacs.mak: Add -DSTRICT. ================================================================ ALLOW SEPARATION OF STDOUT AND STDERR IN PROCESSES ================================================================ Standard output and standard error can be processed separately in a process. Each can have its own buffer, its own mark in that buffer, and its filter function. You can specify a separate buffer for stderr in `start-process' to get things started, or use the new primitives: set-process-stderr-buffer process-stderr-buffer process-stderr-mark set-process-stderr-filter process-stderr-filter Also, process-send-region takes a 4th optional arg, a buffer. Currently always uses a pipe() under Unix to read the error output. (#### Would a PTY be better?) sysdep.h, sysproc.h, unexfreebsd.c, unexsunos4.c, nt.c, emacs.c, callproc.c, symsinit.h, sysdep.c, Makefile.in.in, process-unix.c: Delete callproc.c. Move child_setup() to process-unix.c. wait_for_termination() now only needed on a few really old systems. console-msw.h, event-Xt.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.h, process-nt.c, process-unix.c, process.c, process.h, procimpl.h: Rewrite the process methods to handle a separate channel for error input. Create Lstreams for reading in the error channel. Many process methods need change. In general the changes are fairly clear as they involve duplicating what's used for reading the normal stdout and changing for stderr -- although tedious, as such changes are required throughout the entire process code. Rewrote the code that reads process output to do two loops, one for stdout and one for stderr. gpmevent.c, tooltalk.c: set_process_filter takes an argument for stderr. ================================================================ NEW ERROR-TRAPPING MECHANISM ================================================================ Totally rewrite error trapping code to be unified and support more features. Basic function is call_trapping_problems(), which lets you specify, by means of flags, what sorts of problems you want trapped. these can include -- quit -- errors -- throws past the function -- creation of "display objects" (e.g. buffers) -- deletion of already-existing "display objects" (e.g. buffers) -- modification of already-existing buffers -- entering the debugger -- gc -- errors->warnings (ala suspended errors) etc. All other error funs rewritten in terms of this one. Various older mechanisms removed or rewritten. window.c, insdel.c, console.c, buffer.c, device.c, frame.c: When creating a display object, added call to note_object_created(), for use with trapping_problems mechanism. When deleting, call check_allowed_operation() and note_object deleted(). The trapping-problems code records the objects created since the call-trapping-problems began. Those objects can be deleted, but none others (i.e. previously existing ones). bytecode.c, cmdloop.c: internal_catch takes another arg. eval.c: Add long comments describing the "five lists" used to maintain state (backtrace, gcpro, specbind, etc.) in the Lisp engine. backtrace.h, eval.c: Implement trapping-problems mechanism, eliminate old mechanisms or redo in terms of new one. frame.c, gutter.c: Flush out the concept of "critical display section", defined by the in_display() var. Use an internal_bind() to get it reset, rather than just doing it at end, because there may be a non-local exit. event-msw.c, event-stream.c, console-msw.h, device.c, dialog-msw.c, frame.c, frame.h, intl.c, toolbar.c, menubar-msw.c, redisplay.c, alloc.c, menubar-x.c: Make use of new trapping-errors stuff and rewrite code based on old mechanisms. glyphs-widget.c, redisplay.h: Protect calling Lisp in redisplay. insdel.c: Protect hooks against deleting existing buffers. frame-msw.c: Use EQ, not EQUAL in hash tables whose keys are just numbers. Otherwise we run into stickiness in redisplay because internal_equal() can QUIT. ================================================================ SIGNAL, C-G CHANGES ================================================================ Here we change the way that C-g interacts with event reading. The idea is that a C-g occurring while we're reading a user event should be read as C-g, but elsewhere should be a QUIT. The former code did all sorts of bizarreness -- requiring that no QUIT occurs anywhere in event-reading code (impossible to enforce given the stuff called or Lisp code invoked), and having some weird system involving enqueue/dequeue of a C-g and interaction with Vquit_flag -- and it didn't work. Now, we simply enclose all code where we want C-g read as an event with {begin/end}_dont_check_for_quit(). This completely turns off the mechanism that checks (and may remove or alter) C-g in the read-ahead queues, so we just get the C-g normal. Signal.c documents this very carefully. cmdloop.c: Correct use of dont_check_for_quit to new scheme, remove old out-of-date comments. event-stream.c: Fix C-g handling to actually work. device-x.c: Disable quit checking when err out. signal.c: Cleanup. Add large descriptive comment. process-unix.c, process-nt.c, sysdep.c: Use QUIT instead of REALLY_QUIT. It's not necessary to use REALLY_QUIT and just confuses the issue. lisp.h: Comment quit handlers. ================================================================ CONS CHANGES ================================================================ free_cons() now takes a Lisp_Object not the result of XCONS(). car and cdr have been renamed so that they don't get used directly; go through XCAR(), XCDR() instead. alloc.c, dired.c, editfns.c, emodules.c, fns.c, glyphs-msw.c, glyphs-x.c, glyphs.c, keymap.c, minibuf.c, search.c, eval.c, lread.c, lisp.h: Correct free_cons calling convention: now takes Lisp_Object, not Lisp_Cons chartab.c: Eliminate direct use of ->car, ->cdr, should be black box. callint.c: Rewrote using EXTERNAL_LIST_LOOP to avoid use of Lisp_Cons. ================================================================ USE INTERNAL-BIND-* ================================================================ eval.c: Cleanups of these funs. alloc.c, fileio.c, undo.c, specifier.c, text.c, profile.c, lread.c, redisplay.c, menubar-x.c, macros.c: Rewrote to use internal_bind_int() and internal_bind_lisp_object() in place of whatever varied and cumbersome mechanisms were formerly there. ================================================================ SPECBIND SANITY ================================================================ backtrace.h: - Improved comments backtrace.h, bytecode.c, eval.c: Add new mechanism check_specbind_stack_sanity() for sanity checking code each time the catchlist or specbind stack change. Removed older prototype of same mechanism. ================================================================ MISC ================================================================ lisp.h, insdel.c, window.c, device.c, console.c, buffer.c: Fleshed out authorship. device-msw.c: Correct bad Unicode-ization. print.c: Be more careful when not initialized or in fatal error handling. search.c: Eliminate running_asynch_code, an FSF holdover. alloc.c: Added comments about gc-cons-threshold. dialog-x.c: Use begin_gc_forbidden() around code to build up a widget value tree, like in menubar-x.c. gui.c: Use Qunbound not Qnil as the default for gethash. lisp-disunion.h, lisp-union.h: Added warnings on use of VOID_TO_LISP(). lisp.h: Use ERROR_CHECK_STRUCTURES to turn on ERROR_CHECK_TRAPPING_PROBLEMS and ERROR_CHECK_TYPECHECK lisp.h: Add assert_with_message. lisp.h: Add macros for gcproing entire arrays. (You could do this before but it required manual twiddling the gcpro structure.) lisp.h: Add prototypes for new functions defined elsewhere.
author ben
date Tue, 28 May 2002 08:45:36 +0000
parents d83885ef293b
children 1d8fb2eee1bb
files ChangeLog configure etc/ChangeLog lib-src/ChangeLog lib-src/make-docfile.c lib-src/winclient.c lisp/ChangeLog lisp/code-init.el lisp/code-process.el lisp/dumped-lisp.el lisp/faces.el lisp/msw-faces.el lisp/multicast.el lisp/process.el man/xemacs-faq.texi netinstall/ChangeLog nt/ChangeLog nt/xemacs.mak src/ChangeLog src/Makefile.in.in src/alloc.c src/backtrace.h src/buffer.c src/bytecode.c src/callint.c src/callproc.c src/chartab.c src/cmdloop.c src/console-msw.h src/console.c src/device-msw.c src/device-x.c src/device.c src/dialog-msw.c src/dialog-x.c src/dired.c src/editfns.c src/emacs.c src/emodules.c src/eval.c src/event-Xt.c src/event-gtk.c src/event-msw.c src/event-stream.c src/event-tty.c src/event-unixoid.c src/events.h src/fileio.c src/fns.c src/frame-msw.c src/frame.c src/frame.h src/general-slots.h src/glyphs-msw.c src/glyphs-widget.c src/glyphs-x.c src/glyphs.c src/gpmevent.c src/gui-x.c src/gui.c src/gutter.c src/insdel.c src/intl.c src/keymap.c src/lisp-disunion.h src/lisp-union.h src/lisp.h src/lread.c src/macros.c src/menubar-msw.c src/menubar-x.c src/minibuf.c src/nt.c src/opaque.c src/print.c src/process-nt.c src/process-unix.c src/process.c src/process.h src/procimpl.h src/profile.c src/redisplay.c src/redisplay.h src/search.c src/sheap.c src/signal.c src/specifier.c src/symsinit.h src/sysdep.c src/sysdep.h src/sysproc.h src/text.c src/toolbar.c src/tooltalk.c src/undo.c src/unexfreebsd.c src/unexsunos4.c src/win32.c src/window.c
diffstat 99 files changed, 6674 insertions(+), 4557 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,7 @@
+2001-03-26  Paul Stodghill  <stodghil@cs.cornell.edu>
+
+	* configure.in: Don't #define __STDC__ in confdefs.h
+
 2002-02-28  Malcolm Purvis  <malcolmpurvis@optushome.com.au>
 
 	* configure.in: Protect nocomboreloc linker arguments to avoid
@@ -21,10 +25,6 @@
 
 	* README.packages: Update info about --package-path.
 
-2002-04-22  Hrvoje Niksic  <hniksic@xemacs.org>
-
-	* etc/photos/hniksic.png, etc/photos/hniksic.png: Update.
-
 2002-04-14  Ben Wing  <ben@xemacs.org>
 
 	* TODO.ben-mule-21-5:
--- a/configure	Sat May 25 01:55:30 2002 +0000
+++ b/configure	Tue May 28 08:45:36 2002 +0000
@@ -2871,6 +2871,17 @@
 echo "$ac_t""no" 1>&6
 fi
 
+if test "$pdump" != "yes"; then
+  echo $ac_n "checking for \"-z nocombreloc\" linker flag""... $ac_c" 1>&6
+echo "configure:2877: checking for \"-z nocombreloc\" linker flag" >&5
+  case "`ld --help 2>&1`" in
+    *-z\ nocombreloc* ) echo "$ac_t""yes" 1>&6
+      ld_switch_site="-z nocombreloc $ld_switch_site" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-z nocombreloc\" to \$ld_switch_site"; fi ;;
+    *) echo "$ac_t""no" 1>&6 ;;
+  esac
+fi
+
+
 
 if test "$GCC" = "yes"; then
   set x $ld_switch_system; shift; ld_switch_system=""
@@ -2899,6 +2910,19 @@
 fi
 
 if test "$GCC" = "yes"; then
+  set x $ld_switch_site; shift; ld_switch_site=""
+  while test -n "$1"; do
+    case $1 in
+      -L  | -l  | -u               ) ld_switch_site="$ld_switch_site $1 $2"; shift ;;
+      -L* | -l* | -u* | -Wl* | -pg ) ld_switch_site="$ld_switch_site $1" ;;
+      -Xlinker* ) ;;
+      * ) ld_switch_site="$ld_switch_site -Xlinker $1" ;;
+    esac
+    shift
+  done
+fi
+
+if test "$GCC" = "yes"; then
   set x $LDFLAGS; shift; LDFLAGS=""
   while test -n "$1"; do
     case $1 in
@@ -2938,7 +2962,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2942: checking for dynodump" >&5
+echo "configure:2966: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2976,12 +3000,12 @@
   done
   
 echo $ac_n "checking for terminateAndUnload in -lC""... $ac_c" 1>&6
-echo "configure:2980: checking for terminateAndUnload in -lC" >&5
+echo "configure:3004: 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 2985 "configure"
+#line 3009 "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
@@ -2992,7 +3016,7 @@
 terminateAndUnload()
 ; return 0; }
 EOF
-if { (eval echo configure:2996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3020: \"$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
@@ -3100,7 +3124,7 @@
 
 if test "$add_runtime_path" = "yes"; then
       echo $ac_n "checking "for runtime libraries flag"""... $ac_c" 1>&6
-echo "configure:3104: checking "for runtime libraries flag"" >&5
+echo "configure:3128: checking "for runtime libraries flag"" >&5
   case "$opsys" in
     sol2 ) dash_r="-R" ;;
     decosf* | linux* | irix*) dash_r="-rpath " ;;
@@ -3122,14 +3146,14 @@
   done
 fi
         cat > conftest.$ac_ext <<EOF
-#line 3126 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:3133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 3150 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:3157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -3230,10 +3254,10 @@
 fi
 after_morecore_hook_exists=yes
 echo $ac_n "checking for malloc_set_state""... $ac_c" 1>&6
-echo "configure:3234: checking for malloc_set_state" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3237 "configure"
+echo "configure:3258: checking for malloc_set_state" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3261 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char malloc_set_state(); below.  */
@@ -3256,7 +3280,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3284: \"$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
@@ -3276,16 +3300,16 @@
 fi
 
 echo $ac_n "checking whether __after_morecore_hook exists""... $ac_c" 1>&6
-echo "configure:3280: checking whether __after_morecore_hook exists" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3282 "configure"
+echo "configure:3304: checking whether __after_morecore_hook exists" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3306 "configure"
 #include "confdefs.h"
 extern void (* __after_morecore_hook)();
 int main() {
 __after_morecore_hook = 0
 ; return 0; }
 EOF
-if { (eval echo configure:3289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3313: \"$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
@@ -3341,7 +3365,7 @@
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3345: checking for $ac_word" >&5
+echo "configure:3369: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -3396,7 +3420,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:3400: checking for a BSD compatible install" >&5
+echo "configure:3424: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
   IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
@@ -3450,7 +3474,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3454: checking for $ac_word" >&5
+echo "configure:3478: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -3482,15 +3506,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3486: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3489 "configure"
+echo "configure:3510: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3513 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3494: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3518: \"$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*
@@ -3520,10 +3544,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:3524: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3527 "configure"
+echo "configure:3548: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3551 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -3539,7 +3563,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:3543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -3563,10 +3587,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3567: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3570 "configure"
+echo "configure:3591: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3594 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3574,7 +3598,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3578: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3602: \"$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*
@@ -3591,7 +3615,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 3595 "configure"
+#line 3619 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3609,7 +3633,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 3613 "configure"
+#line 3637 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3627,7 +3651,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 3631 "configure"
+#line 3655 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3638,7 +3662,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:3666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
@@ -3664,10 +3688,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3668: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3671 "configure"
+echo "configure:3692: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3695 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -3676,7 +3700,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:3680: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3704: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -3700,10 +3724,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:3704: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3707 "configure"
+echo "configure:3728: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3731 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3715,7 +3739,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:3719: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3743: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -3741,9 +3765,9 @@
 
 
 echo $ac_n "checking for utime""... $ac_c" 1>&6
-echo "configure:3745: checking for utime" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3747 "configure"
+echo "configure:3769: checking for utime" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3771 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <utime.h>
@@ -3751,7 +3775,7 @@
 struct utimbuf x; x.actime = x.modtime = 0; utime ("/", &x);
 ; return 0; }
 EOF
-if { (eval echo configure:3755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3779: \"$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
@@ -3770,10 +3794,10 @@
       for ac_func in utimes
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3774: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3777 "configure"
+echo "configure:3798: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3801 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3796,7 +3820,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3824: \"$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
@@ -3828,10 +3852,10 @@
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3832: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3835 "configure"
+echo "configure:3856: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3859 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3848,7 +3872,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3852: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3876: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3870,10 +3894,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3874: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3877 "configure"
+echo "configure:3898: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3901 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3904,10 +3928,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3908: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3911 "configure"
+echo "configure:3932: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3935 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3938,10 +3962,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3942: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3945 "configure"
+echo "configure:3966: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3969 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3977,10 +4001,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3981: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3984 "configure"
+echo "configure:4005: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4008 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -4011,10 +4035,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:4015: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4018 "configure"
+echo "configure:4039: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4042 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -4045,10 +4069,10 @@
 fi
 
 echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
-echo "configure:4049: checking for ssize_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4052 "configure"
+echo "configure:4073: checking for ssize_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4076 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -4080,9 +4104,9 @@
 
 
 echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
-echo "configure:4084: checking for socklen_t" >&5
-cat > conftest.$ac_ext <<EOF
-#line 4086 "configure"
+echo "configure:4108: checking for socklen_t" >&5
+cat > conftest.$ac_ext <<EOF
+#line 4110 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
 socklen_t x;
@@ -4091,7 +4115,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -4100,7 +4124,7 @@
   rm -rf conftest*
   
 cat > conftest.$ac_ext <<EOF
-#line 4104 "configure"
+#line 4128 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
 int accept (int, struct sockaddr *, size_t *);
@@ -4109,7 +4133,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4113: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
 echo "$ac_t""size_t" 1>&6
@@ -4141,9 +4165,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:4145: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 4147 "configure"
+echo "configure:4169: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 4171 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -4159,7 +4183,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:4163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4187: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -4181,10 +4205,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:4185: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4188 "configure"
+echo "configure:4209: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4212 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -4192,7 +4216,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:4196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4220: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -4216,10 +4240,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:4220: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4223 "configure"
+echo "configure:4244: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4247 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -4227,7 +4251,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:4231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4255: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -4250,10 +4274,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:4254: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4257 "configure"
+echo "configure:4278: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4281 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -4263,7 +4287,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:4267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -4289,10 +4313,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:4293: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4296 "configure"
+echo "configure:4317: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4320 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4341,7 +4365,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4345: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -4366,7 +4390,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:4370: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:4394: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -4391,12 +4415,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:4395: checking whether byte ordering is bigendian" >&5
+echo "configure:4419: 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 4400 "configure"
+#line 4424 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4407,11 +4431,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4435: \"$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 4415 "configure"
+#line 4439 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4422,7 +4446,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4450: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -4439,7 +4463,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 4443 "configure"
+#line 4467 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -4452,7 +4476,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:4456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -4479,10 +4503,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:4483: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4486 "configure"
+echo "configure:4507: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4510 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4493,7 +4517,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -4521,10 +4545,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:4525: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4528 "configure"
+echo "configure:4549: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4552 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4535,7 +4559,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -4557,10 +4581,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:4561: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4564 "configure"
+echo "configure:4585: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4588 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4571,7 +4595,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -4593,10 +4617,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:4597: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4600 "configure"
+echo "configure:4621: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4624 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4607,7 +4631,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4635: \"$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
@@ -4629,10 +4653,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:4633: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4636 "configure"
+echo "configure:4657: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4660 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4643,7 +4667,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:4647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:4671: \"$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
@@ -4666,7 +4690,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:4670: checking for long file names" >&5
+echo "configure:4694: 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:
@@ -4712,10 +4736,10 @@
 
 
 echo $ac_n "checking for sin""... $ac_c" 1>&6
-echo "configure:4716: checking for sin" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4719 "configure"
+echo "configure:4740: checking for sin" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4743 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char sin(); below.  */
@@ -4738,7 +4762,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4766: \"$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
@@ -4756,12 +4780,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:4760: checking for sin in -lm" >&5
+echo "configure:4784: 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 4765 "configure"
+#line 4789 "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
@@ -4772,7 +4796,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:4776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4800: \"$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
@@ -4816,14 +4840,14 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 4820 "configure"
+#line 4844 "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:4827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4851: \"$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
@@ -4842,10 +4866,10 @@
 for ac_func in mkstemp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4846: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4849 "configure"
+echo "configure:4870: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4873 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4868,7 +4892,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4896: \"$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
@@ -4897,14 +4921,14 @@
 
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:4901: checking type of mail spool file locking" >&5
+echo "configure:4925: checking type of mail spool file locking" >&5
 for ac_func in lockf flock
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4905: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4908 "configure"
+echo "configure:4929: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4932 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4927,7 +4951,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4955: \"$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
@@ -5009,12 +5033,12 @@
 case "$opsys" in decosf*)
   
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:5013: checking for cma_open in -lpthreads" >&5
+echo "configure:5037: 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 5018 "configure"
+#line 5042 "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
@@ -5025,7 +5049,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:5029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5053: \"$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
@@ -5062,7 +5086,7 @@
 
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:5066: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:5090: 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;
@@ -5074,7 +5098,7 @@
 if test "$opsys" = "sol2"; then
   if test "$os_release" -ge 56; then
     echo $ac_n "checking for \"-z ignore\" linker flag""... $ac_c" 1>&6
-echo "configure:5078: checking for \"-z ignore\" linker flag" >&5
+echo "configure:5102: 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 ;;
@@ -5083,19 +5107,9 @@
   fi
 fi
 
-if test "$pdump" != "yes"; then
-  echo $ac_n "checking for \"-z nocombreloc\" linker flag""... $ac_c" 1>&6
-echo "configure:5089: checking for \"-z nocombreloc\" linker flag" >&5
-  case "`ld --help 2>&1`" in
-    *-z\ nocombreloc* ) echo "$ac_t""yes" 1>&6
-      ld_switch_site="-z nocombreloc $ld_switch_site" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-z nocombreloc\" to \$ld_switch_site"; fi ;;
-    *) echo "$ac_t""no" 1>&6 ;;
-  esac
-fi
-
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:5099: checking "for specified window system"" >&5
+echo "configure:5113: checking "for specified window system"" >&5
 
 
 GNOME_CONFIG=no
@@ -5103,7 +5117,7 @@
 
 if test "$with_gnome" != "no"; then
    echo $ac_n "checking for GNOME configuration script""... $ac_c" 1>&6
-echo "configure:5107: checking for GNOME configuration script" >&5
+echo "configure:5121: checking for GNOME configuration script" >&5
    for possible in gnome-config
    do
       possible_version=`${possible} --version 2> /dev/null`
@@ -5134,7 +5148,7 @@
 
 if test "$with_gtk" != "no";then
    echo $ac_n "checking for GTK configuration script""... $ac_c" 1>&6
-echo "configure:5138: checking for GTK configuration script" >&5
+echo "configure:5152: checking for GTK configuration script" >&5
    for possible in gtk12-config gtk14-config gtk-config
    do
       possible_version=`${possible} --version 2> /dev/null`
@@ -5156,18 +5170,18 @@
 
 if test "${GTK_CONFIG}" != "no"; then
       echo $ac_n "checking gtk version""... $ac_c" 1>&6
-echo "configure:5160: checking gtk version" >&5
+echo "configure:5174: checking gtk version" >&5
       GTK_VERSION=`${GTK_CONFIG} --version`
       echo "$ac_t""${GTK_VERSION}" 1>&6
 
       echo $ac_n "checking gtk libs""... $ac_c" 1>&6
-echo "configure:5165: checking gtk libs" >&5
+echo "configure:5179: checking gtk libs" >&5
       GTK_LIBS=`${GTK_CONFIG} --libs`
       libs_gtk="$libs_gtk ${GTK_LIBS}" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"${GTK_LIBS}\" to \$libs_gtk"; fi
       echo "$ac_t""${GTK_LIBS}" 1>&6
 
       echo $ac_n "checking gtk cflags""... $ac_c" 1>&6
-echo "configure:5171: checking gtk cflags" >&5
+echo "configure:5185: checking gtk cflags" >&5
       GTK_CFLAGS=`${GTK_CONFIG} --cflags`
       if test "$GCC" = "yes"; then
       	GTK_CFLAGS="${GTK_CFLAGS} -Wno-shadow"
@@ -5177,19 +5191,19 @@
 
       
 echo $ac_n "checking for main in -lgdk_imlib""... $ac_c" 1>&6
-echo "configure:5181: checking for main in -lgdk_imlib" >&5
+echo "configure:5195: checking for main in -lgdk_imlib" >&5
 ac_lib_var=`echo gdk_imlib'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgdk_imlib "
 cat > conftest.$ac_ext <<EOF
-#line 5186 "configure"
+#line 5200 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5207: \"$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
@@ -5211,12 +5225,12 @@
 
       
 echo $ac_n "checking for Imlib_init in -lImlib""... $ac_c" 1>&6
-echo "configure:5215: checking for Imlib_init in -lImlib" >&5
+echo "configure:5229: checking for Imlib_init in -lImlib" >&5
 ac_lib_var=`echo Imlib'_'Imlib_init | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lImlib "
 cat > conftest.$ac_ext <<EOF
-#line 5220 "configure"
+#line 5234 "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
@@ -5227,7 +5241,7 @@
 Imlib_init()
 ; return 0; }
 EOF
-if { (eval echo configure:5231: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5245: \"$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
@@ -5250,10 +5264,10 @@
       for ac_func in gdk_imlib_init
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5254: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5257 "configure"
+echo "configure:5268: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5271 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5276,7 +5290,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5294: \"$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
@@ -5342,15 +5356,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5346: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5349 "configure"
+echo "configure:5360: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5363 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5354: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5368: \"$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*
@@ -5381,19 +5395,19 @@
 
       
 echo $ac_n "checking for main in -lxml""... $ac_c" 1>&6
-echo "configure:5385: checking for main in -lxml" >&5
+echo "configure:5399: checking for main in -lxml" >&5
 ac_lib_var=`echo xml'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lxml "
 cat > conftest.$ac_ext <<EOF
-#line 5390 "configure"
+#line 5404 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5411: \"$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
@@ -5415,19 +5429,19 @@
 
       
 echo $ac_n "checking for main in -lglade""... $ac_c" 1>&6
-echo "configure:5419: checking for main in -lglade" >&5
+echo "configure:5433: checking for main in -lglade" >&5
 ac_lib_var=`echo glade'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lglade "
 cat > conftest.$ac_ext <<EOF
-#line 5424 "configure"
+#line 5438 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5445: \"$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
@@ -5449,19 +5463,19 @@
 
       
 echo $ac_n "checking for main in -lglade-gnome""... $ac_c" 1>&6
-echo "configure:5453: checking for main in -lglade-gnome" >&5
+echo "configure:5467: checking for main in -lglade-gnome" >&5
 ac_lib_var=`echo glade-gnome'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lglade-gnome "
 cat > conftest.$ac_ext <<EOF
-#line 5458 "configure"
+#line 5472 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5479: \"$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
@@ -5482,7 +5496,7 @@
 
 
       cat > conftest.$ac_ext <<EOF
-#line 5486 "configure"
+#line 5500 "configure"
 #include "confdefs.h"
 #include <glade/glade-xml.h>
 EOF
@@ -5541,7 +5555,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:5545: checking for X" >&5
+echo "configure:5559: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -5601,12 +5615,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 5605 "configure"
+#line 5619 "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:5610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5624: \"$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*
@@ -5675,14 +5689,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5679 "configure"
+#line 5693 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:5686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5700: \"$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.
@@ -5791,17 +5805,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:5795: checking whether -R must be followed by a space" >&5
+echo "configure:5809: 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 5798 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:5805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 5812 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:5819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -5817,14 +5831,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 5821 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:5828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+#line 5835 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:5842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -5860,12 +5874,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:5864: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:5878: 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 5869 "configure"
+#line 5883 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5876,7 +5890,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:5880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5894: \"$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
@@ -5900,12 +5914,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:5904: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:5918: 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 5909 "configure"
+#line 5923 "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
@@ -5916,7 +5930,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:5920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5934: \"$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
@@ -5945,10 +5959,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:5949: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5952 "configure"
+echo "configure:5963: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5966 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -5971,7 +5985,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5989: \"$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
@@ -5992,12 +6006,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:5996: checking for gethostbyname in -lnsl" >&5
+echo "configure:6010: 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 6001 "configure"
+#line 6015 "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
@@ -6008,7 +6022,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:6012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6026: \"$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
@@ -6038,10 +6052,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:6042: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6045 "configure"
+echo "configure:6056: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6059 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -6064,7 +6078,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6082: \"$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
@@ -6087,12 +6101,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:6091: checking "$xe_msg_checking"" >&5
+echo "configure:6105: 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 6096 "configure"
+#line 6110 "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
@@ -6103,7 +6117,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:6107: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6121: \"$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
@@ -6127,10 +6141,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:6131: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6134 "configure"
+echo "configure:6145: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6148 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -6153,7 +6167,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6171: \"$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
@@ -6174,12 +6188,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:6178: checking for remove in -lposix" >&5
+echo "configure:6192: 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 6183 "configure"
+#line 6197 "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
@@ -6190,7 +6204,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:6194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6208: \"$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
@@ -6214,10 +6228,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:6218: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6221 "configure"
+echo "configure:6232: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6235 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -6240,7 +6254,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6258: \"$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
@@ -6261,12 +6275,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:6265: checking for shmat in -lipc" >&5
+echo "configure:6279: 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 6270 "configure"
+#line 6284 "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
@@ -6277,7 +6291,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:6281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6295: \"$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
@@ -6313,12 +6327,12 @@
 xe_msg_checking="for IceConnectionNumber in -lICE"
 test -n "$X_EXTRA_LIBS" && xe_msg_checking="$xe_msg_checking using extra libs $X_EXTRA_LIBS"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6317: checking "$xe_msg_checking"" >&5
+echo "configure:6331: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lICE $X_EXTRA_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6322 "configure"
+#line 6336 "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
@@ -6329,7 +6343,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:6333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6347: \"$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
@@ -6496,7 +6510,7 @@
 
 
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:6500: checking for X defines extracted by xmkmf" >&5
+echo "configure:6514: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -6545,15 +6559,15 @@
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:6549: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6552 "configure"
+echo "configure:6563: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6566 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6557: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6571: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6577,12 +6591,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:6581: checking for XOpenDisplay in -lX11" >&5
+echo "configure:6595: 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 6586 "configure"
+#line 6600 "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
@@ -6593,7 +6607,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:6597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6611: \"$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
@@ -6618,12 +6632,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:6622: checking "$xe_msg_checking"" >&5
+echo "configure:6636: 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 6627 "configure"
+#line 6641 "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
@@ -6634,7 +6648,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:6638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6652: \"$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
@@ -6661,12 +6675,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:6665: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:6679: 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 6670 "configure"
+#line 6684 "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
@@ -6677,7 +6691,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:6681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6695: \"$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
@@ -6700,12 +6714,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:6704: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:6718: 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 6709 "configure"
+#line 6723 "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
@@ -6716,7 +6730,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:6720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6734: \"$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
@@ -6739,14 +6753,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:6743: checking the version of X11 being used" >&5
+echo "configure:6757: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 6745 "configure"
+#line 6759 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:6750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:6764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -6777,10 +6791,10 @@
   for ac_func in XConvertCase
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6781: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6784 "configure"
+echo "configure:6795: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6798 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6803,7 +6817,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6821: \"$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
@@ -6835,15 +6849,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6839: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6842 "configure"
+echo "configure:6853: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6856 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6847: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6861: \"$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*
@@ -6876,10 +6890,10 @@
     for ac_func in XRegisterIMInstantiateCallback
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6880: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6883 "configure"
+echo "configure:6894: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6897 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6902,7 +6916,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6920: \"$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
@@ -6930,9 +6944,9 @@
 done
 
   echo $ac_n "checking for standard XRegisterIMInstantiateCallback prototype""... $ac_c" 1>&6
-echo "configure:6934: checking for standard XRegisterIMInstantiateCallback prototype" >&5
+echo "configure:6948: checking for standard XRegisterIMInstantiateCallback prototype" >&5
   cat > conftest.$ac_ext <<EOF
-#line 6936 "configure"
+#line 6950 "configure"
 #include "confdefs.h"
 
 #define NeedFunctionPrototypes 1
@@ -6944,7 +6958,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6962: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -6965,12 +6979,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:6969: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:6983: 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 6974 "configure"
+#line 6988 "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
@@ -6981,7 +6995,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:6985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6999: \"$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
@@ -7020,19 +7034,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:7024: checking for main in -lXbsd" >&5
+echo "configure:7038: 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 7029 "configure"
+#line 7043 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:7036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7050: \"$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
@@ -7069,22 +7083,22 @@
 fi 
 if test "$with_msw" != "no"; then
   echo "checking for MS-Windows" 1>&6
-echo "configure:7073: checking for MS-Windows" >&5
+echo "configure:7087: checking for MS-Windows" >&5
   
 echo $ac_n "checking for main in -lgdi32""... $ac_c" 1>&6
-echo "configure:7076: checking for main in -lgdi32" >&5
+echo "configure:7090: 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 7081 "configure"
+#line 7095 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:7088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7102: \"$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
@@ -7135,12 +7149,12 @@
       test "$with_widgets"    != "no" && with_widgets=msw
     fi
         cat > conftest.$ac_ext <<EOF
-#line 7139 "configure"
+#line 7153 "configure"
 #include "confdefs.h"
 #include <fcntl.h>
     int main() { return (open("/dev/windows", O_RDONLY, 0) > 0)? 0 : 1; }
 EOF
-if { (eval echo configure:7144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:7158: \"$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
@@ -7201,15 +7215,15 @@
 if test "$with_x11" = "yes"; then
   ac_safe=`echo "X11/extensions/shape.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/shape.h""... $ac_c" 1>&6
-echo "configure:7205: checking for X11/extensions/shape.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7208 "configure"
+echo "configure:7219: checking for X11/extensions/shape.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7222 "configure"
 #include "confdefs.h"
 #include <X11/extensions/shape.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7213: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7227: \"$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*
@@ -7259,7 +7273,7 @@
 esac
 
 echo "checking for WM_COMMAND option" 1>&6
-echo "configure:7263: checking for WM_COMMAND option" >&5;
+echo "configure:7277: checking for WM_COMMAND option" >&5;
 if test "$with_wmcommand" != "no"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_WMCOMMAND
@@ -7274,15 +7288,15 @@
 test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
 test -z "$with_xauth" && { ac_safe=`echo "X11/Xauth.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xauth.h""... $ac_c" 1>&6
-echo "configure:7278: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7281 "configure"
+echo "configure:7292: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7295 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7300: \"$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*
@@ -7305,12 +7319,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:7309: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:7323: 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 7314 "configure"
+#line 7328 "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
@@ -7321,7 +7335,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:7325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7339: \"$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
@@ -7366,15 +7380,15 @@
       for dir in "" "Tt/" "desktop/" ; do
     ac_safe=`echo "${dir}tt_c.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}tt_c.h""... $ac_c" 1>&6
-echo "configure:7370: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7373 "configure"
+echo "configure:7384: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7387 "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:7378: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7392: \"$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*
@@ -7410,12 +7424,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:7414: checking "$xe_msg_checking"" >&5
+echo "configure:7428: 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 7419 "configure"
+#line 7433 "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
@@ -7426,7 +7440,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:7430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7444: \"$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
@@ -7480,15 +7494,15 @@
 
 test -z "$with_cde" && { ac_safe=`echo "Dt/Dt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Dt/Dt.h""... $ac_c" 1>&6
-echo "configure:7484: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7487 "configure"
+echo "configure:7498: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7501 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7492: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7506: \"$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*
@@ -7511,12 +7525,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:7515: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:7529: 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 7520 "configure"
+#line 7534 "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
@@ -7527,7 +7541,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:7531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7545: \"$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
@@ -7608,7 +7622,7 @@
 
 if test "$with_dragndrop" != "no" ; then
   echo $ac_n "checking if drag and drop API is needed""... $ac_c" 1>&6
-echo "configure:7612: checking if drag and drop API is needed" >&5
+echo "configure:7626: checking if drag and drop API is needed" >&5
   if test -n "$dragndrop_proto" ; then
     with_dragndrop=yes
     echo "$ac_t""yes (${dragndrop_proto} )" 1>&6
@@ -7628,18 +7642,18 @@
 fi
 
 echo "checking for LDAP" 1>&6
-echo "configure:7632: checking for LDAP" >&5
+echo "configure:7646: 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:7635: checking for ldap.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7638 "configure"
+echo "configure:7649: checking for ldap.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7652 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7643: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7657: \"$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*
@@ -7662,15 +7676,15 @@
  }
 test -z "$with_ldap" && { ac_safe=`echo "lber.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for lber.h""... $ac_c" 1>&6
-echo "configure:7666: checking for lber.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7669 "configure"
+echo "configure:7680: checking for lber.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7683 "configure"
 #include "confdefs.h"
 #include <lber.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7674: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7688: \"$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*
@@ -7694,12 +7708,12 @@
 if test "$with_ldap" != "no"; then
   
 echo $ac_n "checking for ldap_search in -lldap""... $ac_c" 1>&6
-echo "configure:7698: checking for ldap_search in -lldap" >&5
+echo "configure:7712: checking for ldap_search in -lldap" >&5
 ac_lib_var=`echo ldap'_'ldap_search | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap "
 cat > conftest.$ac_ext <<EOF
-#line 7703 "configure"
+#line 7717 "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
@@ -7710,7 +7724,7 @@
 ldap_search()
 ; return 0; }
 EOF
-if { (eval echo configure:7714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7728: \"$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
@@ -7735,12 +7749,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:7739: checking "$xe_msg_checking"" >&5
+echo "configure:7753: 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 7744 "configure"
+#line 7758 "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
@@ -7751,7 +7765,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:7755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7769: \"$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
@@ -7776,12 +7790,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber -lkrb" && xe_msg_checking="$xe_msg_checking using extra libs -llber -lkrb"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:7780: checking "$xe_msg_checking"" >&5
+echo "configure:7794: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber -lkrb"
 cat > conftest.$ac_ext <<EOF
-#line 7785 "configure"
+#line 7799 "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
@@ -7792,7 +7806,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:7796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7810: \"$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
@@ -7817,12 +7831,12 @@
 xe_msg_checking="for ldap_open in -lldap"
 test -n "-llber -lkrb -ldes" && xe_msg_checking="$xe_msg_checking using extra libs -llber -lkrb -ldes"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:7821: checking "$xe_msg_checking"" >&5
+echo "configure:7835: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo ldap'_'ldap_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lldap -llber -lkrb -ldes"
 cat > conftest.$ac_ext <<EOF
-#line 7826 "configure"
+#line 7840 "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
@@ -7833,7 +7847,7 @@
 ldap_open()
 ; return 0; }
 EOF
-if { (eval echo configure:7837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7851: \"$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
@@ -7881,10 +7895,10 @@
   for ac_func in ldap_set_option ldap_get_lderrno ldap_result2error ldap_parse_result
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7885: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7888 "configure"
+echo "configure:7899: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7902 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7907,7 +7921,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7925: \"$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
@@ -7938,20 +7952,20 @@
 
 if test "$with_postgresql" != "no"; then
   echo "checking for PostgreSQL" 1>&6
-echo "configure:7942: checking for PostgreSQL" >&5
+echo "configure:7956: checking for PostgreSQL" >&5
 
   for header_dir in "" "pgsql/" "postgresql/"; do
     ac_safe=`echo "${header_dir}libpq-fe.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${header_dir}libpq-fe.h""... $ac_c" 1>&6
-echo "configure:7947: checking for ${header_dir}libpq-fe.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7950 "configure"
+echo "configure:7961: checking for ${header_dir}libpq-fe.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7964 "configure"
 #include "confdefs.h"
 #include <${header_dir}libpq-fe.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7969: \"$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*
@@ -7975,12 +7989,12 @@
 
   test -n "$libpq_fe_h_file" && { 
 echo $ac_n "checking for PQconnectdb in -lpq""... $ac_c" 1>&6
-echo "configure:7979: checking for PQconnectdb in -lpq" >&5
+echo "configure:7993: checking for PQconnectdb in -lpq" >&5
 ac_lib_var=`echo pq'_'PQconnectdb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpq "
 cat > conftest.$ac_ext <<EOF
-#line 7984 "configure"
+#line 7998 "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
@@ -7991,7 +8005,7 @@
 PQconnectdb()
 ; return 0; }
 EOF
-if { (eval echo configure:7995: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8009: \"$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
@@ -8024,12 +8038,12 @@
 
     
 echo $ac_n "checking for PQconnectStart in -lpq""... $ac_c" 1>&6
-echo "configure:8028: checking for PQconnectStart in -lpq" >&5
+echo "configure:8042: checking for PQconnectStart in -lpq" >&5
 ac_lib_var=`echo pq'_'PQconnectStart | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpq "
 cat > conftest.$ac_ext <<EOF
-#line 8033 "configure"
+#line 8047 "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
@@ -8040,7 +8054,7 @@
 PQconnectStart()
 ; return 0; }
 EOF
-if { (eval echo configure:8044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8058: \"$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
@@ -8085,7 +8099,7 @@
 
 if test "$window_system" != "none"; then
   echo "checking for graphics libraries" 1>&6
-echo "configure:8089: checking for graphics libraries" >&5
+echo "configure:8103: checking for graphics libraries" >&5
 
       libpath_xpm=
   incpath_xpm=
@@ -8111,10 +8125,10 @@
     CFLAGS=""$incpath_xpm" $CFLAGS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \""$incpath_xpm"\" to \$CFLAGS"; fi
     LDFLAGS=""$libpath_xpm" $LDFLAGS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \""$libpath_xpm"\" to \$LDFLAGS"; fi
     echo $ac_n "checking for Xpm - no older than 3.4f""... $ac_c" 1>&6
-echo "configure:8115: checking for Xpm - no older than 3.4f" >&5
+echo "configure:8129: checking for Xpm - no older than 3.4f" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 8118 "configure"
+#line 8132 "configure"
 #include "confdefs.h"
 #define XPM_NUMBERS
 #include <X11/xpm.h>
@@ -8123,7 +8137,7 @@
       XpmIncludeVersion != XpmLibraryVersion() ? 1 :
       XpmIncludeVersion < 30406 ? 2 : 0 ;}
 EOF
-if { (eval echo configure:8127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:8141: \"$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
@@ -8167,17 +8181,17 @@
     libs_x="-lXpm $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lXpm\" to \$libs_x"; fi
     CFLAGS=""$incpath_xpm" $CFLAGS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \""$incpath_xpm"\" to \$CFLAGS"; fi
     echo $ac_n "checking for \"FOR_MSW\" xpm""... $ac_c" 1>&6
-echo "configure:8171: checking for \"FOR_MSW\" xpm" >&5
+echo "configure:8185: checking for \"FOR_MSW\" xpm" >&5
     xe_check_libs=-lXpm
     cat > conftest.$ac_ext <<EOF
-#line 8174 "configure"
+#line 8188 "configure"
 #include "confdefs.h"
 
 int main() {
 XpmCreatePixmapFromData()
 ; return 0; }
 EOF
-if { (eval echo configure:8181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   xpm_for_msw=no
 else
@@ -8203,15 +8217,15 @@
 
     test -z "$with_xface" && { ac_safe=`echo "compface.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for compface.h""... $ac_c" 1>&6
-echo "configure:8207: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8210 "configure"
+echo "configure:8221: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8224 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8229: \"$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*
@@ -8234,12 +8248,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:8238: checking for UnGenFace in -lcompface" >&5
+echo "configure:8252: 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 8243 "configure"
+#line 8257 "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
@@ -8250,7 +8264,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:8254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8268: \"$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
@@ -8299,12 +8313,12 @@
       if test "$with_png $with_tiff" != "no no"; then
     
 echo $ac_n "checking for inflate in -lc""... $ac_c" 1>&6
-echo "configure:8303: checking for inflate in -lc" >&5
+echo "configure:8317: 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 8308 "configure"
+#line 8322 "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
@@ -8315,7 +8329,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:8319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8333: \"$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
@@ -8334,12 +8348,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lz""... $ac_c" 1>&6
-echo "configure:8338: checking for inflate in -lz" >&5
+echo "configure:8352: 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 8343 "configure"
+#line 8357 "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
@@ -8350,7 +8364,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:8354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8368: \"$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
@@ -8369,12 +8383,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for inflate in -lgz""... $ac_c" 1>&6
-echo "configure:8373: checking for inflate in -lgz" >&5
+echo "configure:8387: 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 8378 "configure"
+#line 8392 "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
@@ -8385,7 +8399,7 @@
 inflate()
 ; return 0; }
 EOF
-if { (eval echo configure:8389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8403: \"$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
@@ -8415,15 +8429,15 @@
 
     test -z "$with_jpeg" && { ac_safe=`echo "jpeglib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for jpeglib.h""... $ac_c" 1>&6
-echo "configure:8419: checking for jpeglib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8422 "configure"
+echo "configure:8433: checking for jpeglib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8436 "configure"
 #include "confdefs.h"
 #include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8427: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8441: \"$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*
@@ -8446,12 +8460,12 @@
  }
   test -z "$with_jpeg" && { 
 echo $ac_n "checking for jpeg_destroy_decompress in -ljpeg""... $ac_c" 1>&6
-echo "configure:8450: checking for jpeg_destroy_decompress in -ljpeg" >&5
+echo "configure:8464: 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 8455 "configure"
+#line 8469 "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
@@ -8462,7 +8476,7 @@
 jpeg_destroy_decompress()
 ; return 0; }
 EOF
-if { (eval echo configure:8466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8480: \"$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
@@ -8498,10 +8512,10 @@
 
     png_problem=""
   test -z "$with_png" && { echo $ac_n "checking for pow""... $ac_c" 1>&6
-echo "configure:8502: checking for pow" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8505 "configure"
+echo "configure:8516: checking for pow" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8519 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pow(); below.  */
@@ -8524,7 +8538,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8542: \"$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
@@ -8545,15 +8559,15 @@
  }
   test -z "$with_png" && { ac_safe=`echo "png.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for png.h""... $ac_c" 1>&6
-echo "configure:8549: checking for png.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8552 "configure"
+echo "configure:8563: checking for png.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8566 "configure"
 #include "confdefs.h"
 #include <png.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8557: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8571: \"$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*
@@ -8576,12 +8590,12 @@
  }
   test -z "$with_png" && { 
 echo $ac_n "checking for png_read_image in -lpng""... $ac_c" 1>&6
-echo "configure:8580: checking for png_read_image in -lpng" >&5
+echo "configure:8594: 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 8585 "configure"
+#line 8599 "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
@@ -8592,7 +8606,7 @@
 png_read_image()
 ; return 0; }
 EOF
-if { (eval echo configure:8596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8610: \"$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
@@ -8615,10 +8629,10 @@
  }
   if test -z "$with_png"; then
     echo $ac_n "checking for workable png version information""... $ac_c" 1>&6
-echo "configure:8619: checking for workable png version information" >&5
+echo "configure:8633: checking for workable png version information" >&5
     xe_check_libs="-lpng -lz"
     cat > conftest.$ac_ext <<EOF
-#line 8622 "configure"
+#line 8636 "configure"
 #include "confdefs.h"
 #include <png.h>
     int main(int c, char **v) {
@@ -8626,7 +8640,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:8630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:8644: \"$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
@@ -8669,15 +8683,15 @@
 
     test -z "$with_tiff" && { ac_safe=`echo "tiffio.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tiffio.h""... $ac_c" 1>&6
-echo "configure:8673: checking for tiffio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8676 "configure"
+echo "configure:8687: checking for tiffio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8690 "configure"
 #include "confdefs.h"
 #include <tiffio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8681: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8695: \"$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*
@@ -8700,12 +8714,12 @@
  }
   test -z "$with_tiff" && { 
 echo $ac_n "checking for TIFFClientOpen in -ltiff""... $ac_c" 1>&6
-echo "configure:8704: checking for TIFFClientOpen in -ltiff" >&5
+echo "configure:8718: 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 8709 "configure"
+#line 8723 "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
@@ -8716,7 +8730,7 @@
 TIFFClientOpen()
 ; return 0; }
 EOF
-if { (eval echo configure:8720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8734: \"$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
@@ -8755,15 +8769,15 @@
 if test "$with_gtk" = "yes"; then
     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:8759: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8762 "configure"
+echo "configure:8773: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8776 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8767: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8786,12 +8800,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:8790: checking for UnGenFace in -lcompface" >&5
+echo "configure:8804: 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 8795 "configure"
+#line 8809 "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
@@ -8802,7 +8816,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:8806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8820: \"$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
@@ -8841,7 +8855,7 @@
 
 if test "$with_x11" = "yes"; then
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:8845: checking for X11 graphics libraries" >&5
+echo "configure:8859: checking for X11 graphics libraries" >&5
 fi
 
 case "$with_widgets" in
@@ -8851,7 +8865,7 @@
 
 if test "$with_x11" = "yes" -a "$detect_athena" = "yes" ; then
   echo "checking for the Athena widgets" 1>&6
-echo "configure:8855: checking for the Athena widgets" >&5
+echo "configure:8869: checking for the Athena widgets" >&5
 
     case "$with_athena" in
         "xaw" | "")	athena_variant=Xaw	athena_3d=no  ;;
@@ -8865,12 +8879,12 @@
     if test "$athena_3d" = "no"; then
     
 echo $ac_n "checking for XawScrollbarSetThumb in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8869: checking for XawScrollbarSetThumb in -l$athena_variant" >&5
+echo "configure:8883: checking for XawScrollbarSetThumb in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'XawScrollbarSetThumb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8874 "configure"
+#line 8888 "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
@@ -8881,7 +8895,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:8885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8899: \"$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
@@ -8897,12 +8911,12 @@
   echo "$ac_t""yes" 1>&6
           
 echo $ac_n "checking for threeDClassRec in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8901: checking for threeDClassRec in -l$athena_variant" >&5
+echo "configure:8915: checking for threeDClassRec in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8906 "configure"
+#line 8920 "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
@@ -8913,7 +8927,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8931: \"$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
@@ -8944,12 +8958,12 @@
   else
         
 echo $ac_n "checking for threeDClassRec in -l$athena_variant""... $ac_c" 1>&6
-echo "configure:8948: checking for threeDClassRec in -l$athena_variant" >&5
+echo "configure:8962: checking for threeDClassRec in -l$athena_variant" >&5
 ac_lib_var=`echo $athena_variant'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$athena_variant "
 cat > conftest.$ac_ext <<EOF
-#line 8953 "configure"
+#line 8967 "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
@@ -8960,7 +8974,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8978: \"$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
@@ -8978,12 +8992,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for threeDClassRec in -lXaw""... $ac_c" 1>&6
-echo "configure:8982: checking for threeDClassRec in -lXaw" >&5
+echo "configure:8996: checking for threeDClassRec in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'threeDClassRec | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXaw "
 cat > conftest.$ac_ext <<EOF
-#line 8987 "configure"
+#line 9001 "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
@@ -8994,7 +9008,7 @@
 threeDClassRec()
 ; return 0; }
 EOF
-if { (eval echo configure:8998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9012: \"$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
@@ -9025,15 +9039,15 @@
     if test "$athena_3d" = "no"; then
     ac_safe=`echo "X11/Xaw/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9029: checking for X11/Xaw/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9032 "configure"
+echo "configure:9043: checking for X11/Xaw/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9046 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9051: \"$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*
@@ -9053,15 +9067,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "X11/Xaw/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/XawInit.h""... $ac_c" 1>&6
-echo "configure:9057: checking for X11/Xaw/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9060 "configure"
+echo "configure:9071: checking for X11/Xaw/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9074 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9065: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9079: \"$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*
@@ -9087,15 +9101,15 @@
   else
             ac_safe=`echo "X11/$athena_variant/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/$athena_variant/XawInit.h""... $ac_c" 1>&6
-echo "configure:9091: checking for X11/$athena_variant/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9094 "configure"
+echo "configure:9105: checking for X11/$athena_variant/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9108 "configure"
 #include "confdefs.h"
 #include <X11/$athena_variant/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9099: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9113: \"$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*
@@ -9112,15 +9126,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "X11/$athena_variant/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/$athena_variant/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9116: checking for X11/$athena_variant/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9119 "configure"
+echo "configure:9130: checking for X11/$athena_variant/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9133 "configure"
 #include "confdefs.h"
 #include <X11/$athena_variant/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9138: \"$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*
@@ -9148,15 +9162,15 @@
         if test -z "$athena_h_path"; then
       ac_safe=`echo "$athena_variant/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $athena_variant/XawInit.h""... $ac_c" 1>&6
-echo "configure:9152: checking for $athena_variant/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9155 "configure"
+echo "configure:9166: checking for $athena_variant/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9169 "configure"
 #include "confdefs.h"
 #include <$athena_variant/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9160: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9174: \"$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*
@@ -9173,15 +9187,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "$athena_variant/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $athena_variant/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9177: checking for $athena_variant/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9180 "configure"
+echo "configure:9191: checking for $athena_variant/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9194 "configure"
 #include "confdefs.h"
 #include <$athena_variant/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9199: \"$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*
@@ -9210,15 +9224,15 @@
         if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
       ac_safe=`echo "X11/Xaw3d/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw3d/XawInit.h""... $ac_c" 1>&6
-echo "configure:9214: checking for X11/Xaw3d/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9217 "configure"
+echo "configure:9228: checking for X11/Xaw3d/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9231 "configure"
 #include "confdefs.h"
 #include <X11/Xaw3d/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9236: \"$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*
@@ -9235,15 +9249,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "X11/Xaw3d/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw3d/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9239: checking for X11/Xaw3d/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9242 "configure"
+echo "configure:9253: checking for X11/Xaw3d/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9256 "configure"
 #include "confdefs.h"
 #include <X11/Xaw3d/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9261: \"$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*
@@ -9275,15 +9289,15 @@
         if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
       ac_safe=`echo "Xaw3d/XawInit.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xaw3d/XawInit.h""... $ac_c" 1>&6
-echo "configure:9279: checking for Xaw3d/XawInit.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9282 "configure"
+echo "configure:9293: checking for Xaw3d/XawInit.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9296 "configure"
 #include "confdefs.h"
 #include <Xaw3d/XawInit.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9287: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9301: \"$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*
@@ -9300,15 +9314,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "Xaw3d/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xaw3d/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9304: checking for Xaw3d/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9307 "configure"
+echo "configure:9318: checking for Xaw3d/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9321 "configure"
 #include "confdefs.h"
 #include <Xaw3d/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9312: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9326: \"$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*
@@ -9340,15 +9354,15 @@
             if test -z "$athena_h_path"; then
       ac_safe=`echo "X11/Xaw/ThreeD.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/ThreeD.h""... $ac_c" 1>&6
-echo "configure:9344: checking for X11/Xaw/ThreeD.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9347 "configure"
+echo "configure:9358: checking for X11/Xaw/ThreeD.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9361 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/ThreeD.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9352: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9366: \"$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*
@@ -9387,15 +9401,15 @@
 if test "$with_x11" = "yes"; then
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:9391: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9394 "configure"
+echo "configure:9405: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9408 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9399: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9413: \"$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*
@@ -9412,12 +9426,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:9416: checking for XmStringFree in -lXm" >&5
+echo "configure:9430: 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 9421 "configure"
+#line 9435 "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
@@ -9428,7 +9442,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:9432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9446: \"$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
@@ -9457,9 +9471,9 @@
 
   if test "$have_motif" = "yes"; then
         echo $ac_n "checking for Lesstif""... $ac_c" 1>&6
-echo "configure:9461: checking for Lesstif" >&5
+echo "configure:9475: checking for Lesstif" >&5
     cat > conftest.$ac_ext <<EOF
-#line 9463 "configure"
+#line 9477 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 #ifdef LESSTIF_VERSION
@@ -9832,7 +9846,7 @@
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:9836: checking for Mule-related features" >&5
+echo "configure:9850: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -9846,15 +9860,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9850: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9853 "configure"
+echo "configure:9864: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9867 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9858: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9872: \"$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*
@@ -9885,12 +9899,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:9889: checking for strerror in -lintl" >&5
+echo "configure:9903: 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 9894 "configure"
+#line 9908 "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
@@ -9901,7 +9915,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:9905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9919: \"$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
@@ -9934,18 +9948,18 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:9938: checking for Mule input methods" >&5
+echo "configure:9952: checking for Mule input methods" >&5
         case "$with_xim" in "" | "yes" )
     echo "checking for XIM" 1>&6
-echo "configure:9941: checking for XIM" >&5
+echo "configure:9955: checking for XIM" >&5
     
 echo $ac_n "checking for XOpenIM in -lX11""... $ac_c" 1>&6
-echo "configure:9944: checking for XOpenIM in -lX11" >&5
+echo "configure:9958: 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 9949 "configure"
+#line 9963 "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
@@ -9956,7 +9970,7 @@
 XOpenIM()
 ; return 0; }
 EOF
-if { (eval echo configure:9960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9974: \"$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
@@ -9980,12 +9994,12 @@
         if test "$have_motif $have_lesstif" = "yes no"; then
       
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:9984: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:9998: 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 9989 "configure"
+#line 10003 "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
@@ -9996,7 +10010,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:10000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10014: \"$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
@@ -10061,15 +10075,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:10065: checking for XFontSet" >&5
+echo "configure:10079: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:10068: checking for XmbDrawString in -lX11" >&5
+echo "configure:10082: 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 10073 "configure"
+#line 10087 "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
@@ -10080,7 +10094,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:10084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10098: \"$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
@@ -10120,15 +10134,15 @@
     test "$with_wnn6" = "yes" && with_wnn=yes # wnn6 implies wnn support
   test -z "$with_wnn" && { ac_safe=`echo "wnn/jllib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for wnn/jllib.h""... $ac_c" 1>&6
-echo "configure:10124: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10127 "configure"
+echo "configure:10138: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10141 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10132: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10146: \"$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*
@@ -10151,15 +10165,15 @@
  }
     test -z "$with_wnn" && { ac_safe=`echo "wnn/commonhd.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for wnn/commonhd.h""... $ac_c" 1>&6
-echo "configure:10155: checking for wnn/commonhd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10158 "configure"
+echo "configure:10169: checking for wnn/commonhd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10172 "configure"
 #include "confdefs.h"
 #include <wnn/commonhd.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (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*
@@ -10184,10 +10198,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:10188: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10191 "configure"
+echo "configure:10202: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10205 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -10210,7 +10224,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10228: \"$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
@@ -10239,12 +10253,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:10243: checking for crypt in -lcrypt" >&5
+echo "configure:10257: 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 10248 "configure"
+#line 10262 "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
@@ -10255,7 +10269,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:10259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10273: \"$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
@@ -10290,12 +10304,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:10294: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:10308: 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 10299 "configure"
+#line 10313 "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
@@ -10306,7 +10320,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:10310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10324: \"$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
@@ -10324,12 +10338,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:10328: checking for jl_dic_list_e in -lwnn4" >&5
+echo "configure:10342: 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 10333 "configure"
+#line 10347 "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
@@ -10340,7 +10354,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:10344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10358: \"$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
@@ -10358,12 +10372,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:10362: checking for jl_dic_list_e in -lwnn6" >&5
+echo "configure:10376: 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 10367 "configure"
+#line 10381 "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
@@ -10374,7 +10388,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:10378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10392: \"$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
@@ -10392,12 +10406,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:10396: checking for dic_list_e in -lwnn6_fromsrc" >&5
+echo "configure:10410: 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 10401 "configure"
+#line 10415 "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
@@ -10408,7 +10422,7 @@
 dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:10412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10426: \"$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
@@ -10453,12 +10467,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:10457: checking for jl_fi_dic_list in -l$libwnn" >&5
+echo "configure:10471: 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 10462 "configure"
+#line 10476 "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
@@ -10469,7 +10483,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:10473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10487: \"$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
@@ -10504,15 +10518,15 @@
   if test "$with_canna" != "no"; then
     ac_safe=`echo "canna/jrkanji.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/jrkanji.h""... $ac_c" 1>&6
-echo "configure:10508: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10511 "configure"
+echo "configure:10522: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10525 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10516: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10530: \"$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*
@@ -10539,15 +10553,15 @@
     c_switch_site="$c_switch_site -I/usr/local/canna/include"
     ac_safe=`echo "canna/jrkanji.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/jrkanji.h""... $ac_c" 1>&6
-echo "configure:10543: checking for canna/jrkanji.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10546 "configure"
+echo "configure:10557: checking for canna/jrkanji.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10560 "configure"
 #include "confdefs.h"
 #include <canna/jrkanji.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10565: \"$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*
@@ -10575,15 +10589,15 @@
 
   test -z "$with_canna" && { ac_safe=`echo "canna/RK.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/RK.h""... $ac_c" 1>&6
-echo "configure:10579: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10582 "configure"
+echo "configure:10593: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10596 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10587: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10601: \"$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*
@@ -10606,12 +10620,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:10610: checking for RkBgnBun in -lRKC" >&5
+echo "configure:10624: 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 10615 "configure"
+#line 10629 "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
@@ -10622,7 +10636,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:10626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10640: \"$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
@@ -10645,12 +10659,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:10649: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:10663: 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 10654 "configure"
+#line 10668 "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
@@ -10661,7 +10675,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:10665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10679: \"$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
@@ -10707,12 +10721,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:10711: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:10725: 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 10716 "configure"
+#line 10730 "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
@@ -10723,7 +10737,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:10727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10741: \"$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
@@ -10809,10 +10823,10 @@
 for ac_func in cbrt closedir dup2 eaccess fmod fpathconf frexp ftime getaddrinfo gethostname getnameinfo getpagesize gettimeofday getcwd getwd link logb lrand48 matherr mkdir mktime perror poll random readlink rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf stpcpy strerror symlink tzset ulimit usleep waitpid vsnprintf fsync ftruncate umask
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:10813: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10816 "configure"
+echo "configure:10827: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10830 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -10835,7 +10849,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10853: \"$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
@@ -10867,10 +10881,10 @@
 for ac_func in getpt _getpty grantpt unlockpt ptsname killpg tcgetpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:10871: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10874 "configure"
+echo "configure:10885: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10888 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -10893,7 +10907,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10911: \"$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
@@ -10922,10 +10936,10 @@
 
 
 echo $ac_n "checking for openpty""... $ac_c" 1>&6
-echo "configure:10926: checking for openpty" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 10929 "configure"
+echo "configure:10940: checking for openpty" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 10943 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char openpty(); below.  */
@@ -10948,7 +10962,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:10952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_openpty=yes"
 else
@@ -10967,12 +10981,12 @@
 
   
 echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:10971: checking for openpty in -lutil" >&5
+echo "configure:10985: checking for openpty in -lutil" >&5
 ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lutil "
 cat > conftest.$ac_ext <<EOF
-#line 10976 "configure"
+#line 10990 "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
@@ -10983,7 +10997,7 @@
 openpty()
 ; return 0; }
 EOF
-if { (eval echo configure:10987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11001: \"$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
@@ -11018,15 +11032,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11022: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11025 "configure"
+echo "configure:11036: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11039 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11044: \"$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*
@@ -11063,15 +11077,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11067: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11070 "configure"
+echo "configure:11081: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11084 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11089: \"$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*
@@ -11104,15 +11118,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11108: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11111 "configure"
+echo "configure:11122: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11125 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11116: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11130: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11145,15 +11159,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11149: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11152 "configure"
+echo "configure:11163: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11166 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11157: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11171: \"$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*
@@ -11189,15 +11203,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11193: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11196 "configure"
+echo "configure:11207: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11210 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11201: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11215: \"$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*
@@ -11230,10 +11244,10 @@
   for ac_func in isastream
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:11234: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11237 "configure"
+echo "configure:11248: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11251 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -11256,7 +11270,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -11287,15 +11301,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11291: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11294 "configure"
+echo "configure:11305: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11308 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11299: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11313: \"$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*
@@ -11328,10 +11342,10 @@
 for ac_func in getloadavg
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:11332: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11335 "configure"
+echo "configure:11346: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11349 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -11354,7 +11368,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11372: \"$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
@@ -11387,15 +11401,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11391: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11394 "configure"
+echo "configure:11405: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11408 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11399: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11413: \"$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*
@@ -11431,12 +11445,12 @@
 
     
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:11435: checking for kstat_open in -lkstat" >&5
+echo "configure:11449: 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 11440 "configure"
+#line 11454 "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
@@ -11447,7 +11461,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:11451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11465: \"$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
@@ -11482,15 +11496,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11486: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11489 "configure"
+echo "configure:11500: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11503 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11494: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11508: \"$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*
@@ -11522,12 +11536,12 @@
 
     
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:11526: checking for kvm_read in -lkvm" >&5
+echo "configure:11540: 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 11531 "configure"
+#line 11545 "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
@@ -11538,7 +11552,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:11542: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11556: \"$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
@@ -11572,16 +11586,16 @@
 fi
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:11576: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 11578 "configure"
+echo "configure:11590: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 11592 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:11585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11599: \"$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
@@ -11601,16 +11615,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:11605: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 11607 "configure"
+echo "configure:11619: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 11621 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:11614: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:11628: \"$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
@@ -11630,11 +11644,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:11634: checking whether localtime caches TZ" >&5
+echo "configure:11648: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 11638 "configure"
+#line 11652 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -11669,7 +11683,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:11673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:11687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -11699,9 +11713,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday accepts one or two arguments""... $ac_c" 1>&6
-echo "configure:11703: checking whether gettimeofday accepts one or two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 11705 "configure"
+echo "configure:11717: checking whether gettimeofday accepts one or two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 11719 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -11722,7 +11736,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11740: \"$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
@@ -11744,19 +11758,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:11748: checking for inline" >&5
+echo "configure:11762: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 11753 "configure"
+#line 11767 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:11760: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:11774: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -11797,17 +11811,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:11801: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11804 "configure"
+echo "configure:11815: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11818 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:11811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11825: \"$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
@@ -11831,10 +11845,10 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:11835: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11838 "configure"
+echo "configure:11849: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11852 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -11862,7 +11876,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:11866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11880: \"$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
@@ -11901,10 +11915,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:11905: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11908 "configure"
+echo "configure:11919: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11922 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -11928,10 +11942,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:11932: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11935 "configure"
+echo "configure:11946: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 11949 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -11954,7 +11968,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:11958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11972: \"$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
@@ -11984,10 +11998,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:11988: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 11991 "configure"
+echo "configure:12002: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12005 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -12006,7 +12020,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:12010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:12024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -12035,10 +12049,10 @@
 fi
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:12039: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12042 "configure"
+echo "configure:12053: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12056 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -12048,7 +12062,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:12052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:12066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -12076,10 +12090,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:12080: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12083 "configure"
+echo "configure:12094: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12097 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -12102,7 +12116,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12120: \"$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
@@ -12130,10 +12144,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:12134: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12137 "configure"
+echo "configure:12148: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12151 "configure"
 #include "confdefs.h"
 
 /*
@@ -12188,7 +12202,7 @@
 }
 
 EOF
-if { (eval echo configure:12192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:12206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -12215,10 +12229,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:12219: checking for working mmap" >&5
+echo "configure:12233: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 12222 "configure"
+#line 12236 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -12251,7 +12265,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:12255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:12269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   have_mmap=yes
 else
@@ -12280,9 +12294,9 @@
 if test "$rel_alloc $have_mmap" = "default yes"; then
   if test "$doug_lea_malloc" = "yes"; then
         echo $ac_n "checking for M_MMAP_THRESHOLD""... $ac_c" 1>&6
-echo "configure:12284: checking for M_MMAP_THRESHOLD" >&5
+echo "configure:12298: checking for M_MMAP_THRESHOLD" >&5
     cat > conftest.$ac_ext <<EOF
-#line 12286 "configure"
+#line 12300 "configure"
 #include "confdefs.h"
 #include <malloc.h>
 int main() {
@@ -12294,7 +12308,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12298: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   rel_alloc=no; echo "$ac_t""yes" 1>&6;
 else
@@ -12319,15 +12333,15 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:12323: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12326 "configure"
+echo "configure:12337: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12340 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12331: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12345: \"$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*
@@ -12370,15 +12384,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "termio.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termio.h""... $ac_c" 1>&6
-echo "configure:12374: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12377 "configure"
+echo "configure:12388: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12391 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12382: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12396: \"$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*
@@ -12410,10 +12424,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:12414: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12417 "configure"
+echo "configure:12428: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12431 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -12436,7 +12450,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12454: \"$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
@@ -12451,15 +12465,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "netinet/in.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for netinet/in.h""... $ac_c" 1>&6
-echo "configure:12455: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12458 "configure"
+echo "configure:12469: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12472 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12477: \"$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*
@@ -12476,15 +12490,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "arpa/inet.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for arpa/inet.h""... $ac_c" 1>&6
-echo "configure:12480: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12483 "configure"
+echo "configure:12494: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12497 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12488: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12502: \"$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*
@@ -12509,9 +12523,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:12513: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:12527: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 12515 "configure"
+#line 12529 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -12522,7 +12536,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:12526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12540: \"$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
@@ -12540,9 +12554,9 @@
 fi
 rm -f conftest*
       echo $ac_n "checking "for ip_mreq struct in netinet/in.h"""... $ac_c" 1>&6
-echo "configure:12544: checking "for ip_mreq struct in netinet/in.h"" >&5
+echo "configure:12558: checking "for ip_mreq struct in netinet/in.h"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 12546 "configure"
+#line 12560 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -12552,7 +12566,7 @@
 static struct ip_mreq x;
 ; return 0; }
 EOF
-if { (eval echo configure:12556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12570: \"$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
@@ -12583,10 +12597,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:12587: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12590 "configure"
+echo "configure:12601: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12604 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -12609,7 +12623,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:12613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12627: \"$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
@@ -12624,15 +12638,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:12628: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12631 "configure"
+echo "configure:12642: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12645 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12636: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12650: \"$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*
@@ -12649,15 +12663,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/msg.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/msg.h""... $ac_c" 1>&6
-echo "configure:12653: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12656 "configure"
+echo "configure:12667: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12670 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12675: \"$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*
@@ -12695,15 +12709,15 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:12699: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12702 "configure"
+echo "configure:12713: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12716 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12707: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12721: \"$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*
@@ -12730,15 +12744,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "sys/dir.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/dir.h""... $ac_c" 1>&6
-echo "configure:12734: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12737 "configure"
+echo "configure:12748: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12751 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12756: \"$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*
@@ -12771,15 +12785,15 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:12775: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12778 "configure"
+echo "configure:12789: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12792 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12783: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12797: \"$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*
@@ -12809,22 +12823,22 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:12813: checking "for sound support"" >&5
+echo "configure:12827: checking "for sound support"" >&5
 test -z "$with_native_sound" -a -n "$native_sound_lib" && with_native_sound=yes
 
 if test "$with_native_sound" != "no"; then
     if test -n "$native_sound_lib"; then
     ac_safe=`echo "multimedia/audio_device.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for multimedia/audio_device.h""... $ac_c" 1>&6
-echo "configure:12820: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12823 "configure"
+echo "configure:12834: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 12837 "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:12828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12842: \"$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*
@@ -12872,12 +12886,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:12876: checking for ALopenport in -laudio" >&5
+echo "configure:12890: 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 12881 "configure"
+#line 12895 "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
@@ -12888,7 +12902,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:12892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12906: \"$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
@@ -12919,12 +12933,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:12923: checking for AOpenAudio in -lAlib" >&5
+echo "configure:12937: 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 12928 "configure"
+#line 12942 "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
@@ -12935,7 +12949,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:12939: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12953: \"$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
@@ -12983,15 +12997,15 @@
     for dir in "machine" "sys" "linux"; do
       ac_safe=`echo "${dir}/soundcard.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}/soundcard.h""... $ac_c" 1>&6
-echo "configure:12987: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 12990 "configure"
+echo "configure:13001: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13004 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13009: \"$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*
@@ -13045,15 +13059,15 @@
 if test "$with_nas_sound" != "no"; then
   ac_safe=`echo "audio/audiolib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for audio/audiolib.h""... $ac_c" 1>&6
-echo "configure:13049: checking for audio/audiolib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13052 "configure"
+echo "configure:13063: checking for audio/audiolib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13066 "configure"
 #include "confdefs.h"
 #include <audio/audiolib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13057: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13071: \"$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*
@@ -13071,12 +13085,12 @@
   
     
 echo $ac_n "checking for AuOpenServer in -laudio""... $ac_c" 1>&6
-echo "configure:13075: checking for AuOpenServer in -laudio" >&5
+echo "configure:13089: checking for AuOpenServer in -laudio" >&5
 ac_lib_var=`echo audio'_'AuOpenServer | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -laudio "
 cat > conftest.$ac_ext <<EOF
-#line 13080 "configure"
+#line 13094 "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
@@ -13087,7 +13101,7 @@
 AuOpenServer()
 ; return 0; }
 EOF
-if { (eval echo configure:13091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13105: \"$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
@@ -13126,7 +13140,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 13130 "configure"
+#line 13144 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -13157,7 +13171,7 @@
   # Extract the first word of "esd-config", so it can be a program name with args.
 set dummy esd-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:13161: checking for $ac_word" >&5
+echo "configure:13175: checking for $ac_word" >&5
 
 if test -n "$have_esd_config"; then
   ac_cv_prog_have_esd_config="$have_esd_config" # Let the user override the test.
@@ -13186,10 +13200,10 @@
     c_switch_site="$c_switch_site `esd-config --cflags`" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"`esd-config --cflags`\" to \$c_switch_site"; fi
     LIBS="`esd-config --libs` $LIBS" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"`esd-config --libs`\" to \$LIBS"; fi
     echo $ac_n "checking for esd_play_stream""... $ac_c" 1>&6
-echo "configure:13190: checking for esd_play_stream" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13193 "configure"
+echo "configure:13204: checking for esd_play_stream" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13207 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char esd_play_stream(); below.  */
@@ -13212,7 +13226,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:13216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_esd_play_stream=yes"
 else
@@ -13263,7 +13277,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:13267: checking for TTY-related features" >&5
+echo "configure:13281: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -13276,12 +13290,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:13280: checking for tgetent in -lncurses" >&5
+echo "configure:13294: 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 13285 "configure"
+#line 13299 "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
@@ -13292,7 +13306,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:13296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13310: \"$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
@@ -13325,15 +13339,15 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:13329: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13332 "configure"
+echo "configure:13343: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13346 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13337: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13351: \"$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*
@@ -13355,15 +13369,15 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:13359: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13362 "configure"
+echo "configure:13373: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13376 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13367: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13381: \"$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*
@@ -13393,15 +13407,15 @@
       c_switch_site="$c_switch_site -I/usr/include/ncurses"
       ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:13397: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13400 "configure"
+echo "configure:13411: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13414 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13419: \"$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*
@@ -13436,12 +13450,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:13440: checking for tgetent in -l$lib" >&5
+echo "configure:13454: 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 13445 "configure"
+#line 13459 "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
@@ -13452,7 +13466,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:13456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13470: \"$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
@@ -13483,12 +13497,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:13487: checking for tgetent in -lcurses" >&5
+echo "configure:13501: 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 13492 "configure"
+#line 13506 "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
@@ -13499,7 +13513,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:13503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13517: \"$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
@@ -13517,12 +13531,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:13521: checking for tgetent in -ltermcap" >&5
+echo "configure:13535: 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 13526 "configure"
+#line 13540 "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
@@ -13533,7 +13547,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:13537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13551: \"$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
@@ -13581,15 +13595,15 @@
 
     test -z "$with_gpm" && { ac_safe=`echo "gpm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for gpm.h""... $ac_c" 1>&6
-echo "configure:13585: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13588 "configure"
+echo "configure:13599: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13602 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13593: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13607: \"$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*
@@ -13612,12 +13626,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:13616: checking for Gpm_Open in -lgpm" >&5
+echo "configure:13630: 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 13621 "configure"
+#line 13635 "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
@@ -13628,7 +13642,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:13632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13646: \"$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
@@ -13671,20 +13685,20 @@
 
 test "$with_database_gdbm $with_database_dbm $with_database_berkdb" \
   != "no no no" && echo "checking for database support" 1>&6
-echo "configure:13675: checking for database support" >&5
+echo "configure:13689: checking for database support" >&5
 
 if test "$with_database_gdbm $with_database_dbm" != "no no"; then
   ac_safe=`echo "ndbm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ndbm.h""... $ac_c" 1>&6
-echo "configure:13680: checking for ndbm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13683 "configure"
+echo "configure:13694: checking for ndbm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13697 "configure"
 #include "confdefs.h"
 #include <ndbm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13688: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13702: \"$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*
@@ -13714,12 +13728,12 @@
 if test "$with_database_gdbm" != "no"; then
   
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:13718: checking for dbm_open in -lgdbm" >&5
+echo "configure:13732: 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 13723 "configure"
+#line 13737 "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
@@ -13730,7 +13744,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:13734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13748: \"$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
@@ -13758,10 +13772,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:13762: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13765 "configure"
+echo "configure:13776: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13779 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -13784,7 +13798,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:13788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13802: \"$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
@@ -13803,12 +13817,12 @@
 
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:13807: checking for dbm_open in -ldbm" >&5
+echo "configure:13821: 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 13812 "configure"
+#line 13826 "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
@@ -13819,7 +13833,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:13823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13837: \"$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
@@ -13860,10 +13874,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for Berkeley db.h""... $ac_c" 1>&6
-echo "configure:13864: checking for Berkeley db.h" >&5
+echo "configure:13878: checking for Berkeley db.h" >&5
   for header in "db/db.h" "db.h"; do
     cat > conftest.$ac_ext <<EOF
-#line 13867 "configure"
+#line 13881 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -13885,7 +13899,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:13889: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13903: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_file="$header"; break
 else
@@ -13901,9 +13915,9 @@
 
   if test "$with_database_berkdb" != "no"; then
     echo $ac_n "checking for Berkeley DB version""... $ac_c" 1>&6
-echo "configure:13905: checking for Berkeley DB version" >&5
+echo "configure:13919: checking for Berkeley DB version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 13907 "configure"
+#line 13921 "configure"
 #include "confdefs.h"
 #include <$db_h_file>
 #if DB_VERSION_MAJOR > 1
@@ -13915,7 +13929,7 @@
   egrep "yes" >/dev/null 2>&1; then
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 13919 "configure"
+#line 13933 "configure"
 #include "confdefs.h"
 #include <$db_h_file>
 #if DB_VERSION_MAJOR > 2
@@ -13942,10 +13956,10 @@
 rm -f conftest*
 
     echo $ac_n "checking for $dbfunc""... $ac_c" 1>&6
-echo "configure:13946: checking for $dbfunc" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 13949 "configure"
+echo "configure:13960: checking for $dbfunc" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 13963 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $dbfunc(); below.  */
@@ -13968,7 +13982,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:13972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13986: \"$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
@@ -13987,12 +14001,12 @@
 
     
 echo $ac_n "checking for $dbfunc in -ldb""... $ac_c" 1>&6
-echo "configure:13991: checking for $dbfunc in -ldb" >&5
+echo "configure:14005: 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 13996 "configure"
+#line 14010 "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
@@ -14003,7 +14017,7 @@
 $dbfunc()
 ; return 0; }
 EOF
-if { (eval echo configure:14007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14021: \"$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
@@ -14064,12 +14078,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:14068: checking for SOCKSinit in -lsocks" >&5
+echo "configure:14082: 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 14073 "configure"
+#line 14087 "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
@@ -14080,7 +14094,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:14084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14098: \"$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
@@ -14135,22 +14149,22 @@
 
 if test "$with_modules" != "no"; then
   echo "checking for module support" 1>&6
-echo "configure:14139: checking for module support" >&5
+echo "configure:14153: checking for module support" >&5
 
     if test "$with_msw" = "yes"; then
     have_dl=yes;
   else
         ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:14146: checking for dlfcn.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 14149 "configure"
+echo "configure:14160: checking for dlfcn.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 14163 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:14154: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:14168: \"$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*
@@ -14167,16 +14181,16 @@
   echo "$ac_t""yes" 1>&6
   
       echo $ac_n "checking for dlopen in -lc""... $ac_c" 1>&6
-echo "configure:14171: checking for dlopen in -lc" >&5
+echo "configure:14185: checking for dlopen in -lc" >&5
       cat > conftest.$ac_ext <<EOF
-#line 14173 "configure"
+#line 14187 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 int main() {
 	dlopen ("", 0);
 ; return 0; }
 EOF
-if { (eval echo configure:14180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
    have_dl=yes 
 else
@@ -14185,18 +14199,18 @@
   rm -rf conftest*
   
       echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:14189: checking for dlopen in -ldl" >&5
+echo "configure:14203: checking for dlopen in -ldl" >&5
       ac_save_LIBS="$LIBS"
       LIBS="-ldl $LIBS"
       cat > conftest.$ac_ext <<EOF
-#line 14193 "configure"
+#line 14207 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 int main() {
 	dlopen ("", 0);
 ; return 0; }
 EOF
-if { (eval echo configure:14200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
    have_dl=yes 
 else
@@ -14225,12 +14239,12 @@
     else
       
 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:14229: checking for shl_load in -ldld" >&5
+echo "configure:14243: 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 14234 "configure"
+#line 14248 "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
@@ -14241,7 +14255,7 @@
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo configure:14245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14259: \"$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
@@ -14268,12 +14282,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for dld_init in -ldld""... $ac_c" 1>&6
-echo "configure:14272: checking for dld_init in -ldld" >&5
+echo "configure:14286: 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 14277 "configure"
+#line 14291 "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
@@ -14284,7 +14298,7 @@
 dld_init()
 ; return 0; }
 EOF
-if { (eval echo configure:14288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14302: \"$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
@@ -14329,7 +14343,7 @@
 xealias=$internal_configuration
 
 echo "checking how to build dynamic libraries for ${xehost}" 1>&6
-echo "configure:14333: checking how to build dynamic libraries for ${xehost}" >&5
+echo "configure:14347: checking how to build dynamic libraries for ${xehost}" >&5
 # Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts.
 case "$xehost" in
 *-*-linux-gnu*) ;;
@@ -14357,9 +14371,9 @@
   XEGCC=yes
 else
   echo $ac_n "checking checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:14361: checking checking whether we are using GNU C" >&5
+echo "configure:14375: checking checking whether we are using GNU C" >&5
   cat > conftest.$ac_ext <<EOF
-#line 14363 "configure"
+#line 14377 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -14381,7 +14395,7 @@
 fi
 
 echo $ac_n "checking how to produce PIC code""... $ac_c" 1>&6
-echo "configure:14385: checking how to produce PIC code" >&5
+echo "configure:14399: checking how to produce PIC code" >&5
 wl=
 
 can_build_shared=yes
@@ -14482,18 +14496,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:14486: checking if PIC flag ${dll_cflags} really works" >&5
+echo "configure:14500: checking if PIC flag ${dll_cflags} really works" >&5
   save_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $dll_cflags -DPIC"
   cat > conftest.$ac_ext <<EOF
-#line 14490 "configure"
+#line 14504 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:14497: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:14511: \"$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
@@ -14524,7 +14538,7 @@
 xldf=
 xcldf=
 echo $ac_n "checking if C compiler can produce shared libraries""... $ac_c" 1>&6
-echo "configure:14528: checking if C compiler can produce shared libraries" >&5
+echo "configure:14542: checking if C compiler can produce shared libraries" >&5
 if test "$XEGCC" = yes; then
   xcldf="-shared"
   xldf="-shared"
@@ -14575,14 +14589,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 14579 "configure"
+#line 14593 "configure"
 #include "confdefs.h"
 
 int main() {
 int x=0;
 ; return 0; }
 EOF
-if { (eval echo configure:14586: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cc_produces_so=yes
 else
@@ -14607,7 +14621,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:14611: checking for ld used by GCC" >&5
+echo "configure:14625: checking for ld used by GCC" >&5
     ac_prog=`($CC -print-prog-name=ld) 2>&5`
     case "$ac_prog" in
     # Accept absolute paths.
@@ -14633,7 +14647,7 @@
     esac
   else
     echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:14637: checking for GNU ld" >&5
+echo "configure:14651: checking for GNU ld" >&5
   fi
 
   if test -z "$LTLD"; then
@@ -14671,7 +14685,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:14675: checking if the linker is GNU ld" >&5
+echo "configure:14689: 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
@@ -14699,7 +14713,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:14703: checking whether the linker supports shared libraries" >&5
+echo "configure:14717: checking whether the linker supports shared libraries" >&5
   dll_ld=$CC
   dll_ldflags=$LDFLAGS
   ld_shlibs=yes
@@ -14907,10 +14921,10 @@
     for ac_func in dlerror _dlerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14911: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 14914 "configure"
+echo "configure:14925: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 14928 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14933,7 +14947,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:14937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14951: \"$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
@@ -14972,11 +14986,11 @@
 fi
 
 cat > conftest.$ac_ext <<EOF
-#line 14976 "configure"
+#line 14990 "configure"
 #include "confdefs.h"
 int main(int c,char *v[]){return 0;}
 EOF
-if { (eval echo configure:14980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
+if { (eval echo configure:14994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit $?) 2>&5
 then
   :
 else
--- a/etc/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/etc/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,32 @@
+2001-03-30  Ben Wing  <ben@xemacs.org>
+
+	* sample.init.el:
+	* sample.init.el (Init-kill-entire-line):
+	* sample.init.el (describe-foo-at-point):
+	* sample.init.el (kill-current-buffer):
+	* sample.init.el (kill-current-buffer-and-window):
+	* sample.init.el (grep-c-files): Removed.
+	* sample.init.el (grep-all-files-history): New.
+	* sample.init.el (grep-all-files-omitted-expressions): New.
+	* sample.init.el (grep-all-files-omitted-directories): New.
+	* sample.init.el (construct-grep-all-files-command): New.
+	* sample.init.el (grep-all-files-in-current-directory): New.
+	* sample.init.el (grep-lisp-files): Removed.
+	* sample.init.el (grep-all-files-in-current-directory-and-below): New.
+	* sample.init.el (clear-select):
+	* sample.init.el ((control kp-add)):
+	* sample.init.el (pause):
+	* sample.init.el ((eq system-type 'windows-nt)):
+
+	Add documentation for defined functions.  Change grep functions to
+	be more generally useful.  Document more specifically what the
+	`menu-force' setting actually does -- what commands are overridden
+	and how to access them.
+
+2002-04-22  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* photos/hniksic.png, photos/hniksic.png: Update.
+
 2002-04-05  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.6 "bok choi" is released.
--- a/lib-src/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/lib-src/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,9 @@
+2002-05-28  Ben Wing  <ben@xemacs.org>
+
+	* make-docfile.c (scan_c_file):
+	* make-docfile.c (scan_lisp_file):
+	Fix places where we forget to check for EOF.
+
 2002-05-05  Ben Wing  <ben@xemacs.org>
 
 	* i.c:
@@ -179,6 +185,7 @@
 
 	* XEmacs 21.5.0 "alfalfa" is released.
 
+>>>>>>> 1.136
 2000-08-01  Jon Schewe  <jpschewe@eggplant.mtu.net>
 
 	* gnuclient.c (filename_expand): Let Cygwin convert Windows path
--- a/lib-src/make-docfile.c	Sat May 25 01:55:30 2002 +0000
+++ b/lib-src/make-docfile.c	Tue May 28 08:45:36 2002 +0000
@@ -744,7 +744,11 @@
       if (defunflag | defvarflag)
 	{
 	  while (c != '/')
-	    c = getc (infile);
+	    {
+	      if (c < 0)
+		goto eof;
+	      c = getc (infile);
+	    }
 	  c = getc (infile);
 	  while (c == '*')
 	    c = getc (infile);
@@ -752,7 +756,11 @@
       else
 	{
 	  while (c != ',')
-	    c = getc (infile);
+	    {
+	      if (c < 0)
+		goto eof;
+	      c = getc (infile);
+	    }
 	  c = getc (infile);
 	}
       while (c == ' ' || c == '\n' || c == '\t')
@@ -798,7 +806,11 @@
 	      /* Copy arguments into ARGBUF.  */
 	      *p++ = c;
 	      do
-		*p++ = c = getc (infile);
+		{
+		  *p++ = c = getc (infile);
+		  if (c < 0)
+		    goto eof;
+		}
 	      while (c != ')');
 	      *p = '\0';
 	      /* Output them.  */
@@ -947,7 +959,11 @@
 	      /* Skip the newline.  */
 	      c = getc_skipping_iso2022 (infile);
 	      while (c != '\n')
-		c = getc_skipping_iso2022 (infile);
+		{
+		  c = getc_skipping_iso2022 (infile);
+		  if (c < 0)
+		    continue;
+		}
 	    }
 	  continue;
 	}
@@ -984,7 +1000,11 @@
 	    }
 	  else
 	    while (c != ')')
-	      c = getc_skipping_iso2022 (infile);
+	      {
+		c = getc_skipping_iso2022 (infile);
+		if (c < 0)
+		  continue;
+	      }
 	  skip_white (infile);
 
 	  /* If the next three characters aren't `dquote bslash newline'
--- a/lib-src/winclient.c	Sat May 25 01:55:30 2002 +0000
+++ b/lib-src/winclient.c	Tue May 28 08:45:36 2002 +0000
@@ -1,490 +1,486 @@
-/* DDE client for XEmacs.
-   Copyright (C) 2002 Alastair J. Houghton
-
-   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. */
-
-/* -- Pre-Include Defines --------------------------------------------------- */
-
-#define STRICT
-
-/* -- Includes -------------------------------------------------------------- */
-
-#include <windows.h>
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-
-static void error (const char* s1, const char* s2);
-static void fatal (const char *s1, const char *s2);
-static void * xmalloc (size_t size);
-static char * getNextArg (const char **ptr, unsigned *len);
-
-/* -- Post-Include Defines -------------------------------------------------- */
-
-/* Timeouts & delays */
-#define CONNECT_DELAY		500		/* ms */
-#define TRANSACTION_TIMEOUT	5000		/* ms */
-#define MAX_INPUT_IDLE_WAIT     INFINITE	/* ms */
-
-/* DDE Strings */
-#define SERVICE_NAME	"XEmacs"
-#define TOPIC_NAME	"System"
-#define COMMAND_FORMAT	"[open(\"%s%s\")]"
-
-/* XEmacs program name */
-#define PROGRAM_TO_RUN	"xemacs.exe"
-
-/* -- Constants ------------------------------------------------------------- */
-
-/* -- Global Variables ------------------------------------------------------ */
-
-HINSTANCE hInstance;
-DWORD     idInst = 0;
-
-/* -- Function Declarations ------------------------------------------------- */
-
-HDDEDATA CALLBACK ddeCallback (UINT uType, UINT uFmt, HCONV hconv,
-			       HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
-			       DWORD dwData1, DWORD dwData2);
-
-int WINAPI WinMain (HINSTANCE hInst,
-		    HINSTANCE hPrev,
-		    LPSTR     lpCmdLine,
-		    int       nCmdShow);
-
-static HCONV openConversation (void);
-static void closeConversation (HCONV hConv);
-static int doFile (HCONV hConv, LPSTR lpszFileName1, LPSTR lpszFileName2);
-static int parseCommandLine (HCONV hConv, LPSTR lpszCommandLine);
-
-/* -- Function Definitions -------------------------------------------------- */
-
-/*
- * Name    : ddeCallback
- * Function: Gets called by DDEML.
- *
- */
-
-HDDEDATA CALLBACK
-ddeCallback (UINT uType, UINT uFmt, HCONV hconv,
-	     HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
-	     DWORD dwData1, DWORD dwData2)
-{
-  return (HDDEDATA) NULL;
-}
-
-/*
- * Name    : WinMain
- * Function: The program's entry point function.
- *
- */
-
-int WINAPI
-WinMain (HINSTANCE hInst,
-	 HINSTANCE hPrev,
-	 LPSTR     lpCmdLine,
-	 int       nCmdShow)
-{
-  HCONV hConv;
-  int   ret = 0;
-  UINT  uiRet;
-  
-  /* Initialise the DDEML library */
-  uiRet = DdeInitialize (&idInst,
-			 (PFNCALLBACK) ddeCallback,
-			 APPCMD_CLIENTONLY
-			 |CBF_FAIL_ALLSVRXACTIONS,
-			 0);
-
-  if (uiRet != DMLERR_NO_ERROR)
-    {
-      MessageBox (NULL, "Could not initialise DDE management library.",
-		  "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-      return 1;
-    }
-
-  /* Open a conversation */
-  hConv = openConversation ();
-
-  if (hConv)
-    {
-      /* OK. Next, we need to parse the command line. */
-      ret = parseCommandLine (hConv, lpCmdLine);
-
-      /* Close the conversation */
-      closeConversation (hConv);
-    }
-  
-  DdeUninitialize (idInst);
-
-  return ret;
-}
-
-/*
- * Name    : openConversation
- * Function: Start a conversation.
- *
- */
-
-static HCONV
-openConversation (void)
-{
-  HSZ             hszService = NULL, hszTopic = NULL;
-  HCONV           hConv = NULL;
-
-  /* Get the application (service) name */
-  hszService = DdeCreateStringHandle (idInst,
-				      SERVICE_NAME,
-				      CP_WINANSI);
-
-  if (!hszService)
-    {
-      MessageBox (NULL, "Could not create string handle for service.",
-		  "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-      goto error;
-    }
-  
-  /* Get the topic name */
-  hszTopic = DdeCreateStringHandle (idInst,
-				    TOPIC_NAME,
-				    CP_WINANSI);
-
-  if (!hszTopic)
-    {
-      MessageBox (NULL, "Could not create string handle for topic.",
-		  "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-      goto error;
-    }
-
-  /* Try to connect */
-  hConv = DdeConnect (idInst, hszService, hszTopic, NULL);
-
-  if (!hConv)
-    {
-      STARTUPINFO         sti;
-      PROCESS_INFORMATION pi;
-      int                 n;
-      
-      /* Try to start the program */
-      ZeroMemory (&sti, sizeof (sti));
-      sti.cb = sizeof (sti);
-      if (!CreateProcess (NULL, PROGRAM_TO_RUN, NULL, NULL, FALSE, 0,
-			  NULL, NULL, &sti, &pi))
-	{
-	  MessageBox (NULL, "Could not start process.",
-		      "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-	  goto error;
-	}
-
-      /* Wait for the process to enter an idle state */
-      WaitForInputIdle (pi.hProcess, MAX_INPUT_IDLE_WAIT);
-
-      /* Close the handles */
-      CloseHandle (pi.hThread);
-      CloseHandle (pi.hProcess);
-      
-      /* Try to connect */
-      for (n = 0; n < 5; n++)
-	{
-	  Sleep (CONNECT_DELAY);
-	  
-	  hConv = DdeConnect (idInst, hszService, hszTopic, NULL);
-
-	  if (hConv)
-	    break;
-	}
-
-      if (!hConv)
-	{
-	  /* Still couldn't connect. */
-	  MessageBox (NULL, "Could not connect to DDE server.",
-		      "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-	  goto error;
-	}
-    }
-
-  /* Release the string handles */
-  DdeFreeStringHandle (idInst, hszService);
-  DdeFreeStringHandle (idInst, hszTopic);
-
-  return hConv;
-  
- error:
-  if (hConv)
-    DdeDisconnect (hConv);
-  if (hszService)
-    DdeFreeStringHandle (idInst, hszService);
-  if (hszTopic)
-    DdeFreeStringHandle (idInst, hszTopic);
-
-  return NULL;
-}
-
-/*
- * Name    : closeConversation
- * Function: Close a conversation.
- *
- */
-
-static void
-closeConversation (HCONV hConv)
-{
-  /* Shut down */
-  DdeDisconnect (hConv);
-}
-
-/*
- * Name    : doFile
- * Function: Process a file.
- *
- */
-
-int
-doFile (HCONV hConv, LPSTR lpszFileName1, LPSTR lpszFileName2)
-{
-  char            *buf = NULL;
-  unsigned        len;
-  
-  /* Calculate the buffer length */
-  len = strlen (lpszFileName1) + strlen (lpszFileName2)
-    + strlen (COMMAND_FORMAT);
-  
-  /* Allocate a buffer */
-  buf = (char *) xmalloc (len);
-
-  if (!buf)
-    {
-      MessageBox (NULL, "Not enough memory.",
-		  "winclient", MB_ICONEXCLAMATION | MB_OK);
-
-      return 1;
-    }
-
-  /* Build the command */
-  len = wsprintf (buf, COMMAND_FORMAT, lpszFileName1, lpszFileName2);
-
-  len++;
-  
-  /* OK. We're connected. Send the message. */
-  DdeClientTransaction (buf, len, hConv, NULL,
-			0, XTYP_EXECUTE, TRANSACTION_TIMEOUT, NULL);
-
-  free (buf);
-  
-  return 0;
-}
-
-/*
- * Name    : getNextArg
- * Function: Retrieve the next command line argument.
- *
- */
-
-static char *
-getNextArg (const char **ptr, unsigned *len)
-{
-  int        in_quotes = 0, quit = 0, all_in_quotes = 0;
-  const char *p = *ptr, *start;
-  char       *buf = NULL;
-  unsigned   length = 0;
-
-  /* Skip whitespace */
-  while (*p && isspace (*p))
-    p++;
-
-  /* If this is the end, return NULL */
-  if (!*p)
-    return NULL;
-  
-  /* Remember where we are */
-  start = p;
-  
-  /* Find the next whitespace character outside quotes */
-  if (*p == '"')
-    all_in_quotes = 1;
-  
-  while (*p && !quit)
-    {
-      switch (*p)
-	{
-	case '"':
-	  in_quotes = 1 - in_quotes;
-	  p++;
-	  break;
-
-	case '\\':
-	  if (!in_quotes)
-	    all_in_quotes = 0;
-	  
-	  p++;
-
-	  if (!*p)
-	    break;
-
-	  p++;
-	  break;
-
-	default:
-	  if (isspace (*p) && !in_quotes)
-	    quit = 1;
-	  else if (!in_quotes)
-	    all_in_quotes = 0;
-
-	  if (!quit)
-	    p++;
-	}
-    }
-
-  /* Work out the length */
-  length = p - start;
-
-  /* Strip quotes if the argument is completely quoted */
-  if (all_in_quotes)
-    {
-      start++;
-      length -= 2;
-    }
-  
-  /* Copy */
-  buf = (char *) xmalloc (length + 1);
-
-  if (!buf)
-    return NULL;
-  
-  strncpy (buf, start, length);
-  buf[length] = '\0';
-
-  /* Return the pointer and length */
-  *ptr = p;
-  *len = length;
-
-  return buf;
-}
-
-/*
- * Name    : parseCommandLine
- * Function: Process the command line. This program accepts a list of strings
- *         : (which may contain wildcards) representing filenames.
- *
- */
-
-int
-parseCommandLine (HCONV hConv, LPSTR lpszCommandLine)
-{
-  char            *fullpath, *filepart;
-  char            *arg;
-  unsigned        len, pathlen;
-  int             ret = 0;
-  HANDLE          hFindFile = NULL;
-  WIN32_FIND_DATA wfd;
-
-  /* Retrieve arguments */
-  while ((arg = getNextArg ((const char**)&lpszCommandLine, &len)) != NULL)
-    {
-      /* First find the canonical path name */
-      fullpath = filepart = NULL;
-      pathlen = GetFullPathName (arg, 0, fullpath, &filepart);
-
-      fullpath = (char *) xmalloc (pathlen);
-
-      if (!fullpath)
-	{
-	  MessageBox (NULL, "Not enough memory.", "winclient",
-		      MB_ICONEXCLAMATION | MB_OK);
-	  
-	  ret = 1;
-	  free (arg);
-	  
-	  break;
-	}
-
-      GetFullPathName (arg, pathlen, fullpath, &filepart);
-
-      /* Find the first matching file */
-      hFindFile = FindFirstFile (arg, &wfd);
-
-      if (hFindFile == INVALID_HANDLE_VALUE)
-	ret = doFile (hConv, fullpath, "");
-      else
-	{
-	  /* Chop off the file part from the full path name */
-	  if (filepart)
-	    *filepart = '\0';
-
-	  /* For each matching file */
-	  do
-	    {
-	      /* Process it */
-	      ret = doFile (hConv, fullpath, wfd.cFileName);
-
-	      if (ret)
-		break;
-	    }
-	  while (FindNextFile (hFindFile, &wfd));
-
-	  FindClose (hFindFile);
-	}
-
-      /* Release the path name buffers */
-      free (fullpath);
-      free (arg);
-
-      if (ret)
-	break;
-    }
-
-  return ret;
-}
-
-static void
-fatal (const char *s1, const char *s2)
-{
-  error (s1, s2);
-  exit (1);
-}
-
-/* Print error message.  `s1' is printf control string, `s2' is arg for it. */
-static void
-error (const char* s1, const char* s2)
-{
-  fprintf (stderr, "winclient: ");
-  fprintf (stderr, s1, s2);
-  fprintf (stderr, "\n");
-}
-
-/* Like malloc but get fatal error if memory is exhausted.  */
-
-static void *
-xmalloc (size_t size)
-{
-  void *result = malloc (size);
-  if (result == NULL)
-    fatal ("virtual memory exhausted", (char *) 0);
-  return result;
-}
+/* DDE client for XEmacs.
+   Copyright (C) 2002 Alastair J. Houghton
+
+   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. */
+
+/* -- Includes -------------------------------------------------------------- */
+
+#include <windows.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+
+static void error (const char* s1, const char* s2);
+static void fatal (const char *s1, const char *s2);
+static void * xmalloc (size_t size);
+static char * getNextArg (const char **ptr, unsigned *len);
+
+/* -- Post-Include Defines -------------------------------------------------- */
+
+/* Timeouts & delays */
+#define CONNECT_DELAY		500		/* ms */
+#define TRANSACTION_TIMEOUT	5000		/* ms */
+#define MAX_INPUT_IDLE_WAIT     INFINITE	/* ms */
+
+/* DDE Strings */
+#define SERVICE_NAME	"XEmacs"
+#define TOPIC_NAME	"System"
+#define COMMAND_FORMAT	"[open(\"%s%s\")]"
+
+/* XEmacs program name */
+#define PROGRAM_TO_RUN	"xemacs.exe"
+
+/* -- Constants ------------------------------------------------------------- */
+
+/* -- Global Variables ------------------------------------------------------ */
+
+HINSTANCE hInstance;
+DWORD     idInst = 0;
+
+/* -- Function Declarations ------------------------------------------------- */
+
+HDDEDATA CALLBACK ddeCallback (UINT uType, UINT uFmt, HCONV hconv,
+			       HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
+			       DWORD dwData1, DWORD dwData2);
+
+int WINAPI WinMain (HINSTANCE hInst,
+		    HINSTANCE hPrev,
+		    LPSTR     lpCmdLine,
+		    int       nCmdShow);
+
+static HCONV openConversation (void);
+static void closeConversation (HCONV hConv);
+static int doFile (HCONV hConv, LPSTR lpszFileName1, LPSTR lpszFileName2);
+static int parseCommandLine (HCONV hConv, LPSTR lpszCommandLine);
+
+/* -- Function Definitions -------------------------------------------------- */
+
+/*
+ * Name    : ddeCallback
+ * Function: Gets called by DDEML.
+ *
+ */
+
+HDDEDATA CALLBACK
+ddeCallback (UINT uType, UINT uFmt, HCONV hconv,
+	     HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
+	     DWORD dwData1, DWORD dwData2)
+{
+  return (HDDEDATA) NULL;
+}
+
+/*
+ * Name    : WinMain
+ * Function: The program's entry point function.
+ *
+ */
+
+int WINAPI
+WinMain (HINSTANCE hInst,
+	 HINSTANCE hPrev,
+	 LPSTR     lpCmdLine,
+	 int       nCmdShow)
+{
+  HCONV hConv;
+  int   ret = 0;
+  UINT  uiRet;
+  
+  /* Initialise the DDEML library */
+  uiRet = DdeInitialize (&idInst,
+			 (PFNCALLBACK) ddeCallback,
+			 APPCMD_CLIENTONLY
+			 |CBF_FAIL_ALLSVRXACTIONS,
+			 0);
+
+  if (uiRet != DMLERR_NO_ERROR)
+    {
+      MessageBox (NULL, "Could not initialise DDE management library.",
+		  "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+      return 1;
+    }
+
+  /* Open a conversation */
+  hConv = openConversation ();
+
+  if (hConv)
+    {
+      /* OK. Next, we need to parse the command line. */
+      ret = parseCommandLine (hConv, lpCmdLine);
+
+      /* Close the conversation */
+      closeConversation (hConv);
+    }
+  
+  DdeUninitialize (idInst);
+
+  return ret;
+}
+
+/*
+ * Name    : openConversation
+ * Function: Start a conversation.
+ *
+ */
+
+static HCONV
+openConversation (void)
+{
+  HSZ             hszService = NULL, hszTopic = NULL;
+  HCONV           hConv = NULL;
+
+  /* Get the application (service) name */
+  hszService = DdeCreateStringHandle (idInst,
+				      SERVICE_NAME,
+				      CP_WINANSI);
+
+  if (!hszService)
+    {
+      MessageBox (NULL, "Could not create string handle for service.",
+		  "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+      goto error;
+    }
+  
+  /* Get the topic name */
+  hszTopic = DdeCreateStringHandle (idInst,
+				    TOPIC_NAME,
+				    CP_WINANSI);
+
+  if (!hszTopic)
+    {
+      MessageBox (NULL, "Could not create string handle for topic.",
+		  "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+      goto error;
+    }
+
+  /* Try to connect */
+  hConv = DdeConnect (idInst, hszService, hszTopic, NULL);
+
+  if (!hConv)
+    {
+      STARTUPINFO         sti;
+      PROCESS_INFORMATION pi;
+      int                 n;
+      
+      /* Try to start the program */
+      ZeroMemory (&sti, sizeof (sti));
+      sti.cb = sizeof (sti);
+      if (!CreateProcess (NULL, PROGRAM_TO_RUN, NULL, NULL, FALSE, 0,
+			  NULL, NULL, &sti, &pi))
+	{
+	  MessageBox (NULL, "Could not start process.",
+		      "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+	  goto error;
+	}
+
+      /* Wait for the process to enter an idle state */
+      WaitForInputIdle (pi.hProcess, MAX_INPUT_IDLE_WAIT);
+
+      /* Close the handles */
+      CloseHandle (pi.hThread);
+      CloseHandle (pi.hProcess);
+      
+      /* Try to connect */
+      for (n = 0; n < 5; n++)
+	{
+	  Sleep (CONNECT_DELAY);
+	  
+	  hConv = DdeConnect (idInst, hszService, hszTopic, NULL);
+
+	  if (hConv)
+	    break;
+	}
+
+      if (!hConv)
+	{
+	  /* Still couldn't connect. */
+	  MessageBox (NULL, "Could not connect to DDE server.",
+		      "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+	  goto error;
+	}
+    }
+
+  /* Release the string handles */
+  DdeFreeStringHandle (idInst, hszService);
+  DdeFreeStringHandle (idInst, hszTopic);
+
+  return hConv;
+  
+ error:
+  if (hConv)
+    DdeDisconnect (hConv);
+  if (hszService)
+    DdeFreeStringHandle (idInst, hszService);
+  if (hszTopic)
+    DdeFreeStringHandle (idInst, hszTopic);
+
+  return NULL;
+}
+
+/*
+ * Name    : closeConversation
+ * Function: Close a conversation.
+ *
+ */
+
+static void
+closeConversation (HCONV hConv)
+{
+  /* Shut down */
+  DdeDisconnect (hConv);
+}
+
+/*
+ * Name    : doFile
+ * Function: Process a file.
+ *
+ */
+
+int
+doFile (HCONV hConv, LPSTR lpszFileName1, LPSTR lpszFileName2)
+{
+  char            *buf = NULL;
+  unsigned        len;
+  
+  /* Calculate the buffer length */
+  len = strlen (lpszFileName1) + strlen (lpszFileName2)
+    + strlen (COMMAND_FORMAT);
+  
+  /* Allocate a buffer */
+  buf = (char *) xmalloc (len);
+
+  if (!buf)
+    {
+      MessageBox (NULL, "Not enough memory.",
+		  "winclient", MB_ICONEXCLAMATION | MB_OK);
+
+      return 1;
+    }
+
+  /* Build the command */
+  len = wsprintf (buf, COMMAND_FORMAT, lpszFileName1, lpszFileName2);
+
+  len++;
+  
+  /* OK. We're connected. Send the message. */
+  DdeClientTransaction (buf, len, hConv, NULL,
+			0, XTYP_EXECUTE, TRANSACTION_TIMEOUT, NULL);
+
+  free (buf);
+  
+  return 0;
+}
+
+/*
+ * Name    : getNextArg
+ * Function: Retrieve the next command line argument.
+ *
+ */
+
+static char *
+getNextArg (const char **ptr, unsigned *len)
+{
+  int        in_quotes = 0, quit = 0, all_in_quotes = 0;
+  const char *p = *ptr, *start;
+  char       *buf = NULL;
+  unsigned   length = 0;
+
+  /* Skip whitespace */
+  while (*p && isspace (*p))
+    p++;
+
+  /* If this is the end, return NULL */
+  if (!*p)
+    return NULL;
+  
+  /* Remember where we are */
+  start = p;
+  
+  /* Find the next whitespace character outside quotes */
+  if (*p == '"')
+    all_in_quotes = 1;
+  
+  while (*p && !quit)
+    {
+      switch (*p)
+	{
+	case '"':
+	  in_quotes = 1 - in_quotes;
+	  p++;
+	  break;
+
+	case '\\':
+	  if (!in_quotes)
+	    all_in_quotes = 0;
+	  
+	  p++;
+
+	  if (!*p)
+	    break;
+
+	  p++;
+	  break;
+
+	default:
+	  if (isspace (*p) && !in_quotes)
+	    quit = 1;
+	  else if (!in_quotes)
+	    all_in_quotes = 0;
+
+	  if (!quit)
+	    p++;
+	}
+    }
+
+  /* Work out the length */
+  length = p - start;
+
+  /* Strip quotes if the argument is completely quoted */
+  if (all_in_quotes)
+    {
+      start++;
+      length -= 2;
+    }
+  
+  /* Copy */
+  buf = (char *) xmalloc (length + 1);
+
+  if (!buf)
+    return NULL;
+  
+  strncpy (buf, start, length);
+  buf[length] = '\0';
+
+  /* Return the pointer and length */
+  *ptr = p;
+  *len = length;
+
+  return buf;
+}
+
+/*
+ * Name    : parseCommandLine
+ * Function: Process the command line. This program accepts a list of strings
+ *         : (which may contain wildcards) representing filenames.
+ *
+ */
+
+int
+parseCommandLine (HCONV hConv, LPSTR lpszCommandLine)
+{
+  char            *fullpath, *filepart;
+  char            *arg;
+  unsigned        len, pathlen;
+  int             ret = 0;
+  HANDLE          hFindFile = NULL;
+  WIN32_FIND_DATA wfd;
+
+  /* Retrieve arguments */
+  while ((arg = getNextArg ((const char**)&lpszCommandLine, &len)) != NULL)
+    {
+      /* First find the canonical path name */
+      fullpath = filepart = NULL;
+      pathlen = GetFullPathName (arg, 0, fullpath, &filepart);
+
+      fullpath = (char *) xmalloc (pathlen);
+
+      if (!fullpath)
+	{
+	  MessageBox (NULL, "Not enough memory.", "winclient",
+		      MB_ICONEXCLAMATION | MB_OK);
+	  
+	  ret = 1;
+	  free (arg);
+	  
+	  break;
+	}
+
+      GetFullPathName (arg, pathlen, fullpath, &filepart);
+
+      /* Find the first matching file */
+      hFindFile = FindFirstFile (arg, &wfd);
+
+      if (hFindFile == INVALID_HANDLE_VALUE)
+	ret = doFile (hConv, fullpath, "");
+      else
+	{
+	  /* Chop off the file part from the full path name */
+	  if (filepart)
+	    *filepart = '\0';
+
+	  /* For each matching file */
+	  do
+	    {
+	      /* Process it */
+	      ret = doFile (hConv, fullpath, wfd.cFileName);
+
+	      if (ret)
+		break;
+	    }
+	  while (FindNextFile (hFindFile, &wfd));
+
+	  FindClose (hFindFile);
+	}
+
+      /* Release the path name buffers */
+      free (fullpath);
+      free (arg);
+
+      if (ret)
+	break;
+    }
+
+  return ret;
+}
+
+static void
+fatal (const char *s1, const char *s2)
+{
+  error (s1, s2);
+  exit (1);
+}
+
+/* Print error message.  `s1' is printf control string, `s2' is arg for it. */
+static void
+error (const char* s1, const char* s2)
+{
+  fprintf (stderr, "winclient: ");
+  fprintf (stderr, s1, s2);
+  fprintf (stderr, "\n");
+}
+
+/* Like malloc but get fatal error if memory is exhausted.  */
+
+static void *
+xmalloc (size_t size)
+{
+  void *result = malloc (size);
+  if (result == NULL)
+    fatal ("virtual memory exhausted", (char *) 0);
+  return result;
+}
--- a/lisp/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,49 @@
+2002-05-28  Ben Wing  <ben@xemacs.org>
+
+	* code-init.el:
+	* code-init.el (coding-system-variable-default-value-table):
+	* code-init.el (coding-system-variable-default-value):
+	Don't use CRLF conversion by default on process output.  CMD.EXE and
+	friends work both ways but Cygwin programs don't like the CRs.
+	
+	* code-process.el:
+	* code-process.el (process-coding-system-alist):
+	* code-process.el (call-process):
+	* code-process.el (call-process-region):
+	* code-process.el (start-process):
+	* code-process.el (open-network-stream):
+	* code-process.el (set-buffer-process-coding-system):
+	* multicast.el:
+	* multicast.el (open-multicast-group):
+	* process.el:
+	* process.el (start-process-shell-command):
+	* process.el (call-process-internal):
+	* process.el (call-process): Removed.
+	* process.el (call-process-region): Removed.
+	* process.el (start-process): Removed.
+	* process.el (open-network-stream): Removed.
+
+	Improvements to call-process-internal:
+
+	-- allows a buffer to be specified for input and stderr output
+	-- use it on all systems
+	-- implement C-g as documented
+	-- clean up and comment
+
+	call-process-region uses new call-process facilities; no temp file.
+
+	remove duplicate funs in process.el.
+
+	comment exactly how coding systems work and fix various problems.
+
+	open-multicast-group now does similar coding-system frobbing to
+	open-network-stream.
+	
+	* dumped-lisp.el (preloaded-file-list):
+	* faces.el (init-global-faces):
+	* msw-faces.el (mswindows-init-global-faces): New.
+	Fix some hidden errors due to code not being defined at the right time.
+
 2002-05-25  Steve Youngs  <youngs@xemacs.org>
 
 	* package-ui.el (pui-help-echo): Display both installed and author
--- a/lisp/code-init.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/code-init.el	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,6 @@
 ;;; code-init.el --- Handle coding system default values
 
-;; Copyright (C) 2001 Ben Wing.
+;; Copyright (C) 2001, 2002 Ben Wing.
 
 ;; This file is part of XEmacs.
 
@@ -80,7 +80,7 @@
     ;; to not do the same translations ourselves.
     (terminal                            binary    binary      binary       binary         mswindows-multibyte-unix)
     (default-process-coding-system-read  binary    raw-text    undecided    raw-text       undecided)
-    (default-process-coding-system-write binary    binary      binary       raw-text-dos   mswindows-multibyte-system-default-dos)
+    (default-process-coding-system-write binary    binary      binary       raw-text   mswindows-multibyte-system-default)
     (no-conversion-coding-system-mapping binary    raw-text    raw-text     raw-text       mswindows-multibyte)
     ))
 
@@ -152,17 +152,17 @@
 The table of default values looks like this: (see below for abbreviations)
 
 
-                  Unix      Unix+EOL    Unix+Mule   MSW           MSW+Mule
+                 Unix      Unix+EOL    Unix+Mule   MSW           MSW+Mule
 ------------------------------------------------------------------------------
-bfcs-for-read     binary    raw-text    undecided   raw-text      undecided
-default bfcs      binary    binary      iso-2022-8  raw-text-dos  MSW-MB-dos
-file-name         binary    binary      binary      raw-text-dos  MSW-MB-SD-dos
-native            binary    binary      binary      raw-text-dos  MSW-MB-SD-dos
-keyboard          binary    raw-text    undecided   raw-text      undecided
-terminal          binary    binary      binary      binary        MSW-MB-unix
-process-read      binary    raw-text    undecided   raw-text      undecided
-process-write     binary    binary      binary      raw-text-dos  MSW-MB-dos
-no-conv-cs        binary    raw-text    raw-text    raw-text      MSW-MB
+bfcs-for-read    binary    raw-text    undecided   raw-text      undecided
+default bfcs     binary    binary      iso-2022-8  raw-text-dos  MSW-MB-dos
+file-name        binary    binary      binary      raw-text-dos  MSW-MB-SD-dos
+native           binary    binary      binary      raw-text-dos  MSW-MB-SD-dos
+keyboard         binary    raw-text    undecided   raw-text      undecided
+terminal         binary    binary      binary      binary        MSW-MB-unix
+process-read     binary    raw-text    undecided   raw-text      undecided
+process-write    binary    binary      binary      raw-text      MSW-MB-SD
+no-conv-cs       binary    raw-text    raw-text    raw-text      MSW-MB
 
 
 VAR can be one of: (abbreviations in parens)
--- a/lisp/code-process.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/code-process.el	Tue May 28 08:45:36 2002 +0000
@@ -1,7 +1,7 @@
 ;;; code-process.el --- Process coding functions for XEmacs.
 
 ;; Copyright (C) 1985-1987, 1993, 1994, 1997 Free Software Foundation, Inc.
-;; Copyright (C) 1995, 2000 Ben Wing
+;; Copyright (C) 1995, 2000, 2002 Ben Wing
 ;; Copyright (C) 1997 MORIOKA Tomohiko
 
 ;; Author: Ben Wing
@@ -39,12 +39,22 @@
 from the program and encoding what sent to the program.
 If VAL is a cons of coding systems, the car part is used for decoding,
 and the cdr part is used for encoding.
-If VAL is a function symbol, the function must return a coding system
-or a cons of coding systems which are used as above.")
+If VAL is a function symbol, it is called with two arguments, a symbol
+indicating the operation being performed (one of `start-process',
+`call-process', `open-network-stream', or `open-multicast-group') and the
+program name.  The function must return a coding system or a cons of
+coding systems which are used as above.")
 
 (defun call-process (program &optional infile buffer displayp &rest args)
   "Call PROGRAM synchronously in separate process.
+
 The program's input comes from file INFILE (nil means `/dev/null').
+XEmacs feature: INFILE can also be a list of (BUFFER [START [END]]), i.e.
+a list of one to three elements, consisting of a buffer and optionally
+a start position or start and end position.  In this case, input comes
+from the buffer, starting from START (defaults to the beginning of the
+buffer) and ending at END (defaults to the end of the buffer).
+
 Insert output in BUFFER before point; t means current buffer;
  nil for BUFFER means discard it; 0 means discard and don't wait.
 If BUFFER is a string, then find or create a buffer with that name,
@@ -53,38 +63,78 @@
 REAL-BUFFER says what to do with standard output, as above,
 while STDERR-FILE says what to do with standard error in the child.
 STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
+t (mix it with ordinary output), a file name string, or (XEmacs feature)
+a buffer object.  If STDERR-FILE is a buffer object (but not the name of
+a buffer, since that would be interpreted as a file), the standard error
+output will be inserted into the buffer before point.
 
-Fourth arg DISPLAYP non-nil means redisplay buffer as output is inserted.
+Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
 Remaining arguments are strings passed as command arguments to PROGRAM.
 
-If BUFFER is 0, `call-process' returns immediately with value nil.
-Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
- or a signal description string.
-If you quit, the process is killed with SIGINT, or SIGKILL if you
- quit again."
-  (let* ((coding-system-for-read
-	  (or coding-system-for-read
-	      (let (ret)
-		(catch 'found
-		  (let ((alist process-coding-system-alist)
-			(case-fold-search nil))
-		    (while alist
-		      (if (string-match (car (car alist)) program)
-			  (throw 'found (setq ret (cdr (car alist))))
-			)
-		      (setq alist (cdr alist))
-		      )))
-		(if (functionp ret)
-		    (setq ret (funcall ret 'call-process program))
-		  )
-		(cond ((consp ret) (car ret))
-		      ((not ret) 'undecided)
-		      ((find-coding-system ret) ret)
-		      )
-		))))
-    (apply 'call-process-internal program infile buffer displayp args)
-    ))
+If BUFFER is 0, returns immediately with value nil.
+Otherwise waits for PROGRAM to terminate and returns a numeric exit status
+or a signal description string.  If you quit, the process is first killed
+with SIGINT, then with SIGKILL if you quit again before the process exits.
+
+If INFILE is a file, we transfer its exact contents to the process without
+any encoding/decoding. (#### This policy might change.)
+
+Otherwise, the read/write coding systems used for process I/O on the
+process are determined as follows:
+
+1. `coding-system-for-read', `coding-system-for-write', if non-nil.
+      (Intended as a temporary overriding mechanism for use by Lisp
+      code.)
+2. The matching value for the process name from `process-coding-system-alist',
+      if any, and if non-nil.  The value may be either a single coding
+      system, used for both read and write; or a cons of read/write; or a
+      function, called to get one of the other two values.
+3. For writing: If a buffer was given in INFILE, the value of
+      `buffer-file-coding-system' in that buffer.
+   For reading: if a buffer was given in BUFFER, the value of
+      `buffer-file-coding-system-for-read' in that buffer.
+4. The value of `default-process-coding-system', which should be a cons
+      of read/write coding systems, if the values are non-nil.
+5. The coding system `undecided' for read, and `raw-text' for write.
+
+Note that the processes of determining the read and write coding systems
+proceed essentially independently one from the other, as in `start-process'."
+  (let (cs-r cs-w)
+    (let (ret)
+      (catch 'found
+	(let ((alist process-coding-system-alist)
+	      (case-fold-search nil))
+	  (while alist
+	    (if (string-match (car (car alist)) program)
+		(throw 'found (setq ret (cdr (car alist)))))
+	    (setq alist (cdr alist))
+	    )))
+      (if (functionp ret)
+	  (setq ret (funcall ret 'call-process program)))
+      (cond ((consp ret)
+	     (setq cs-r (car ret)
+		   cs-w (cdr ret)))
+	    ((and ret (find-coding-system ret))
+	     (setq cs-r ret
+		   cs-w ret))))
+    (let ((coding-system-for-read
+	   (or coding-system-for-read cs-r
+	       (let ((thebuf (if (consp buffer) (car buffer) buffer)))
+		 (and (or (bufferp thebuf) (stringp thebuf))
+		      (get-buffer thebuf)
+		      (symbol-value-in-buffer
+		       'buffer-file-coding-system-for-read thebuf)))
+	       (car default-process-coding-system)
+	       'undecided))
+	  (coding-system-for-write
+	   (or coding-system-for-write cs-w
+	       (and (consp infile)
+		    (symbol-value-in-buffer
+		     'buffer-file-coding-system
+		     (get-buffer (car infile))))
+	       (cdr default-process-coding-system)
+	       'raw-text)))
+      (apply 'call-process-internal program infile buffer displayp args))))
 
 (defun call-process-region (start end program
 				  &optional deletep buffer displayp
@@ -100,63 +150,77 @@
 REAL-BUFFER says what to do with standard output, as above,
 while STDERR-FILE says what to do with standard error in the child.
 STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
+t (mix it with ordinary output), a file name string, or (XEmacs feature)
+a buffer object.  If STDERR-FILE is a buffer object (but not the name of
+a buffer, since that would be interpreted as a file), the standard error
+output will be inserted into the buffer before point.
 
 Sixth arg DISPLAYP non-nil means redisplay buffer as output is inserted.
 Remaining args are passed to PROGRAM at startup as command args.
 
 If BUFFER is 0, returns immediately with value nil.
-Otherwise waits for PROGRAM to terminate
-and returns a numeric exit status or a signal description string.
-If you quit, the process is first killed with SIGINT, then with SIGKILL if
-you quit again before the process exits."
-  (let ((temp
-	 (make-temp-name
-	  (concat (file-name-as-directory (temp-directory)) "emacs"))))
-    (unwind-protect
-	(let (cs-r cs-w)
-	  (let (ret)
-	    (catch 'found
-	      (let ((alist process-coding-system-alist)
-		    (case-fold-search nil))
-		(while alist
-		  (if (string-match (car (car alist)) program)
-		      (throw 'found (setq ret (cdr (car alist)))))
-		  (setq alist (cdr alist))
-		  )))
-	    (if (functionp ret)
-		(setq ret (funcall ret 'call-process-region program)))
-	    (cond ((consp ret)
-		   (setq cs-r (car ret)
-			 cs-w (cdr ret)))
-		  ((null ret)
-		   (setq cs-r buffer-file-coding-system
-			 cs-w buffer-file-coding-system))
-		  ((find-coding-system ret)
-		   (setq cs-r ret
-			 cs-w ret))))
-	  (let ((coding-system-for-read
-		 (or coding-system-for-read cs-r))
-		(coding-system-for-write
-		 (or coding-system-for-write cs-w)))
-	    (write-region start end temp nil 'silent)
-	    (if deletep (delete-region start end))
-	    (apply #'call-process program temp buffer displayp args)))
-      (ignore-file-errors (delete-file temp)))))
+Otherwise waits for PROGRAM to terminate and returns a numeric exit status
+or a signal description string.  If you quit, the process is first killed
+with SIGINT, then with SIGKILL if you quit again before the process exits.
+
+The read/write coding systems used for process I/O on the process are
+the same as for `call-process'."
+  ;; We used to delete the text before calling call-process; that was when
+  ;; a temporary file was used to pass the text to call-process.  Now that
+  ;; we don't do that, we delete the text afterward; if it's being inserted
+  ;; in the same buffer, make sure we track the insertion, and don't get
+  ;; any of it in the deleted region if insertion happens at either end
+  ;; of the region.
+  (let ((s (and deletep (copy-marker start t)))
+	(e (and deletep (copy-marker end))))
+    (apply #'call-process program (list (current-buffer) start end)
+	   buffer displayp args)
+    (if deletep (delete-region s e))))
 
 (defun start-process (name buffer program &rest program-args)
   "Start a program in a subprocess.  Return the process object for it.
-Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS
 NAME is name for process.  It is modified if necessary to make it unique.
 BUFFER is the buffer or (buffer-name) to associate with the process.
-Process output goes at end of that buffer, unless you specify
-an output stream or filter function to handle the output.
-BUFFER may also be nil, meaning that this process is not associated
-with any buffer.
+ Process output goes at end of that buffer, unless you specify
+ an output stream or filter function to handle the output.
+ BUFFER may be also nil, meaning that this process is not associated
+ with any buffer.
+BUFFER can also have the form (REAL-BUFFER STDERR-BUFFER); in that case,
+ REAL-BUFFER says what to do with standard output, as above,
+ while STDERR-BUFFER says what to do with standard error in the child.
+ STDERR-BUFFER may be nil (discard standard error output, unless a stderr
+ filter is set).  Note that if you do not use this form at process creation,
+ stdout and stderr will be mixed in the output buffer, and this cannot be
+ changed, even by setting a stderr filter.
 Third arg is program file name.  It is searched for as in the shell.
 Remaining arguments are strings to give program as arguments.
-INCODE and OUTCODE specify the coding-system objects used in input/output
- from/to the process."
+
+The read/write coding systems used for process I/O on the process are
+determined as follows:
+
+1. `coding-system-for-read', `coding-system-for-write', if non-nil.
+      (Intended as a temporary overriding mechanism for use by Lisp
+      code.)
+2. The matching value for the process name from `process-coding-system-alist',
+      if any, and if non-nil.  The value may be either a single coding
+      system, used for both read and write; or a cons of read/write; or a
+      function, called to get one of the other two values.
+3. The value of `default-process-coding-system', which should be a cons
+      of read/write coding systems, if the values are non-nil.
+4. The coding system `undecided' for read, and `raw-text' for write.
+
+Note that the processes of determining the read and write coding systems
+proceed essentially independently one from the other.  For example, a value
+determined from `process-coding-system-alist' might specify a read coding
+system but not a write coding system, in which the read coding system is as
+specified and the write coding system comes from proceeding to step 3 (and
+looking in `default-process-coding-system').
+
+You can change the coding systems later on using
+`set-process-coding-system', `set-process-input-coding-system', or
+`set-process-output-coding-system'.
+
+See also `set-process-filter' and `set-process-stderr-filter'."
   (let (cs-r cs-w)
     (let (ret)
       (catch 'found
@@ -172,15 +236,15 @@
       (cond ((consp ret)
 	     (setq cs-r (car ret)
 		   cs-w (cdr ret)))
-	    ((find-coding-system ret)
+	    ((and ret (find-coding-system ret))
 	     (setq cs-r ret
 		   cs-w ret))))
     (let ((coding-system-for-read
 	   (or coding-system-for-read cs-r
-	       (car default-process-coding-system)))
+	       (car default-process-coding-system) 'undecided))
 	  (coding-system-for-write
 	   (or coding-system-for-write cs-w
-	       (cdr default-process-coding-system))))
+	       (cdr default-process-coding-system) 'raw-text)))
       (apply 'start-process-internal name buffer program program-args)
       )))
 
@@ -203,13 +267,12 @@
   "Open a TCP connection for a service to a host.
 Return a process object to represent the connection.
 Input and output work as for subprocesses; `delete-process' closes it.
-Args are NAME BUFFER HOST SERVICE.
 NAME is name for process.  It is modified if necessary to make it unique.
 BUFFER is the buffer (or buffer-name) to associate with the process.
  Process output goes at end of that buffer, unless you specify
  an output stream or filter function to handle the output.
  BUFFER may be also nil, meaning that this process is not associated
- with any buffer
+ with any buffer.
 Third arg is name of the host to connect to, or its IP address.
 Fourth arg SERVICE is name of the service desired, or an integer
  specifying a port number to connect to.
@@ -222,7 +285,28 @@
 not guaranteed to be sent and received in discrete packets. (But small
 datagrams around 500 bytes that are not truncated by `process-send-string'
 are usually fine.)  Note further that UDP protocol does not guard against 
-lost packets."
+lost packets.
+
+The read/write coding systems used for process I/O on the process are
+determined as follows:
+
+1. `coding-system-for-read', `coding-system-for-write', if non-nil.
+      (Intended as a temporary overriding mechanism for use by Lisp
+      code.)
+2. The matching value for the service from `network-coding-system-alist',
+      if any, and if non-nil.  The value may be either a single coding
+      system, used for both read and write; or a cons of read/write; or a
+      function, called to get one of the other two values.
+3. The value of `default-network-coding-system', which should be a cons
+      of read/write coding systems, if the values are non-nil.
+4. The coding system `undecided' for read, and `raw-text' for write.
+
+Note that the processes of determining the read and write coding systems
+proceed essentially independently one from the other, as in `start-process'.
+
+You can change the coding systems later on using
+`set-process-coding-system', `set-process-input-coding-system', or
+`set-process-output-coding-system'."
   (let (cs-r cs-w)
     (let (ret)
       (catch 'found
@@ -249,13 +333,17 @@
       (cond ((consp ret)
 	     (setq cs-r (car ret)
 		   cs-w (cdr ret)))
-	    ((find-coding-system ret)
+	    ((and ret (find-coding-system ret))
 	     (setq cs-r ret
 		   cs-w ret))))
     (let ((coding-system-for-read
-	   (or coding-system-for-read cs-r))
+	   (or coding-system-for-read cs-r
+	       (car default-network-coding-system)
+	       'undecided))
 	  (coding-system-for-write
-	   (or coding-system-for-write cs-w)))
+	   (or coding-system-for-write cs-w
+	       (cdr default-network-coding-system)
+	       'raw-text)))
       (open-network-stream-internal name buffer host service protocol))))
 
 (defun set-buffer-process-coding-system (decoding encoding)
@@ -263,7 +351,7 @@
 DECODING is the coding system to be used to decode input from the process,
 ENCODING is the coding system to be used to encode output to the process.
 
-For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]."
+For a list of possible values of CODING-SYSTEM, use \\[coding-system-list]."
   (interactive
    "zCoding-system for process input: \nzCoding-system for process output: ")
   (let ((proc (get-buffer-process (current-buffer))))
--- a/lisp/dumped-lisp.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/dumped-lisp.el	Tue May 28 08:45:36 2002 +0000
@@ -24,6 +24,10 @@
 	"console"
 	"obsolete"
 	"specifier"
+	"frame"			; needed by faces
+	(when-feature x "x-faces") ; needed by faces
+ 	(when-feature gtk "gtk-faces")
+	(when-feature mswindows "msw-faces")
 	"faces"			; must be loaded before any make-face call
 ;;(pureload "facemenu") #### not yet ported
 	"glyphs"
@@ -34,7 +38,6 @@
 	"text-props"
 	"process" ;; This is bad. network-streams may not be defined.
 	(when-feature multicast "multicast") ; #+network-streams implicitly true
-	"frame"			; move up here cause some stuff needs it here
 	"map-ynp"
 	"simple"
 	"keydefs"		; Before loaddefs so that keymap vars exist.
@@ -203,7 +206,6 @@
 ;; others to control this programmatically.
 	(when-feature (and infodock (or x mswindows gtk) menubar) "id-menus")
 ;; preload the X code.
-	(when-feature x "x-faces")
 	(when-feature x "x-iso8859-1")
 	(when-feature x "x-mouse")
 	(when-feature x "x-select")
@@ -217,7 +219,6 @@
  	(when-feature gtk "gtk-widgets")
  	(when-feature gtk "gdk")
  	(when-feature gtk "gtk-init")
- 	(when-feature gtk "gtk-faces")
  	(when-feature gtk "gtk-iso8859-1")
  	(when-feature (and gtk dialog) "dialog-gtk")
  	(when-feature gtk "gtk-select")
@@ -228,7 +229,6 @@
 
 ;; preload the mswindows code.
 	(when-feature mswindows "msw-glyphs")
-	(when-feature mswindows "msw-faces")
 	(when-feature mswindows "msw-mouse")
 	(when-feature mswindows "msw-init")
 	(when-feature mswindows "msw-select")
--- a/lisp/faces.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/faces.el	Tue May 28 08:45:36 2002 +0000
@@ -1600,6 +1600,7 @@
   ;; Further X frobbing.
   (and (featurep 'x) (declare-fboundp (x-init-global-faces)))
   (and (featurep 'gtk) (declare-fboundp (gtk-init-global-faces)))
+  (and (featurep 'mswindows) (declare-fboundp (mswindows-init-global-faces)))
 
   ;; for bold and the like, make the global specification be bold etc.
   ;; if the user didn't already specify a value.  These will also be
--- a/lisp/msw-faces.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/msw-faces.el	Tue May 28 08:45:36 2002 +0000
@@ -29,7 +29,8 @@
 ;; This file does the magic to parse mswindows font names, and make sure that
 ;; the default and modeline attributes of new frames are specified enough.
 
-(set-face-font 'gui-element "MS Sans Serif:Regular:8" nil 'mswindows)
+(defun mswindows-init-global-faces ()
+  (set-face-font 'gui-element "MS Sans Serif:Regular:8" nil 'mswindows))
 
 (defun mswindows-init-device-faces (device)
   (let ((color-default (device-system-metric device 'color-default))
--- a/lisp/multicast.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/multicast.el	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,7 @@
 ;;; multicast.el --- lisp frontend for multicast connections in XEmacs
 
 ;; Copyright (C) 1997-2000 Didier Verna.
+;; Copyright (C) 2002 Ben Wing.
 
 ;; Author:          Didier Verna <didier@xemacs.org>
 ;; Maintainer:      Didier Verna <didier@xemacs.org>
@@ -47,13 +48,12 @@
   "Open a multicast connection on the specified address.
 Returns a process object to represent the connection.
 Input and output work as for subprocesses; `delete-process' closes it.
-Args are NAME BUFFER ADDRESS.
 NAME is a name for the process. It is modified if necessary to make it unique.
 BUFFER is the buffer (or buffer-name) to associate with the process.
  Process output goes at the end of that buffer, unless you specify an output
  stream or filter function to handle the output.
  BUFFER may be also nil, meaning that this process is not associated with any
- buffer
+ buffer.
 ADDRESS specifies a standard multicast address \"dest/port/ttl\":
  dest is an internet address between 224.0.0.0 and 239.255.255.255
  port is a communication port like in traditional unicast
@@ -61,7 +61,28 @@
 
 WARNING: it is *strongly* recommended to avoid using groups beginning with
          224 or 239. Such groups are considered 'admin' groups, and may
-         behave in a surprising way ..."
+         behave in a surprising way ...
+
+The read/write coding systems used for process I/O on the process are
+determined as follows:
+
+1. `coding-system-for-read', `coding-system-for-write', if non-nil.
+      (Intended as a temporary overriding mechanism for use by Lisp
+      code.)
+2. The matching value for the port from `network-coding-system-alist',
+      if any, and if non-nil.  The value may be either a single coding
+      system, used for both read and write; or a cons of read/write; or a
+      function, called to get one of the other two values.
+3. The value of `default-network-coding-system', which should be a cons
+      of read/write coding systems, if the values are non-nil.
+4. The coding system `undecided' for read, and `raw-text' for write.
+
+Note that the processes of determining the read and write coding systems
+proceed essentially independently one from the other, as in `start-process'.
+
+You can change the coding systems later on using
+`set-process-coding-system', `set-process-input-coding-system', or
+`set-process-output-coding-system'."
   (let (dest port ttl)
     ;; We check only the general form of the multicast address.
     ;; The rest will be handled by the internal function.
@@ -75,7 +96,44 @@
 	 (error "invalid port specification."))
     (and (= 0 (setq ttl (string-to-int (match-string 3 address))))
 	 (error "invalid ttl specification."))
-    (declare-fboundp (open-multicast-group-internal name buffer dest port ttl))
-    ))
+  (let (cs-r cs-w)
+    (let (ret)
+      (catch 'found
+	(let ((alist network-coding-system-alist)
+	      (case-fold-search nil)
+	      pattern)
+	  (while alist
+	    (setq pattern (car (car alist)))
+	    (and
+	     (cond ((numberp pattern)
+		    (and (numberp port)
+			 (eq pattern port)))
+		   ((stringp pattern)
+		    (or (and (stringp port)
+			     (string-match pattern port))
+			(and (numberp port)
+			     (string-match pattern
+					   (number-to-string port))))))
+	     (throw 'found (setq ret (cdr (car alist)))))
+	    (setq alist (cdr alist))
+	    )))
+      (if (functionp ret)
+	  (setq ret (funcall ret 'open-multicast-group port)))
+      (cond ((consp ret)
+	     (setq cs-r (car ret)
+		   cs-w (cdr ret)))
+	    ((and ret (find-coding-system ret))
+	     (setq cs-r ret
+		   cs-w ret))))
+    (let ((coding-system-for-read
+	   (or coding-system-for-read cs-r
+	       (car default-network-coding-system)
+	       'undecided))
+	  (coding-system-for-write
+	   (or coding-system-for-write cs-w
+	       (cdr default-network-coding-system)
+	       'raw-text)))
+      (declare-fboundp (open-multicast-group-internal name buffer dest port
+						      ttl))))))
 
 ;;; multicast.el ends here
--- a/lisp/process.el	Sat May 25 01:55:30 2002 +0000
+++ b/lisp/process.el	Tue May 28 08:45:36 2002 +0000
@@ -1,7 +1,7 @@
 ;;; process.el --- commands for subprocesses; split out of simple.el
 
 ;; Copyright (C) 1985-7, 1993,4, 1997 Free Software Foundation, Inc.
-;; Copyright (C) 1995, 2000, 2001 Ben Wing.
+;; Copyright (C) 1995, 2000, 2001, 2002 Ben Wing.
 
 ;; Author: Ben Wing
 ;; Maintainer: XEmacs Development Team
@@ -61,7 +61,6 @@
 
 (defun start-process-shell-command (name buffer &rest args)
   "Start a program in a subprocess.  Return the process object for it.
-Args are NAME BUFFER COMMAND &rest COMMAND-ARGS.
 NAME is name for process.  It is modified if necessary to make it unique.
 BUFFER is the buffer or (buffer-name) to associate with the process.
  Process output goes at end of that buffer, unless you specify
@@ -76,162 +75,216 @@
   (start-process name buffer shell-file-name shell-command-switch
 		 (mapconcat #'identity args " ")))
 
-(defun call-process-internal (program &optional infile buffer display &rest args)
-  "Call PROGRAM synchronously in separate process, with coding-system specified.
-Arguments are
- (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS).
+(defun call-process-internal (program &optional infile buffer display
+				      &rest args)
+  "Internal function to call PROGRAM synchronously in separate process.
+Lisp callers should use `call-process' or `call-process-region'.
+
 The program's input comes from file INFILE (nil means `/dev/null').
+XEmacs feature: INFILE can also be a list of (BUFFER [START [END]]), i.e.
+a list of one to three elements, consisting of a buffer and optionally
+a start position or start and end position.  In this case, input comes
+from the buffer, starting from START (defaults to the beginning of the
+buffer) and ending at END (defaults to the end of the buffer).
+
 Insert output in BUFFER before point; t means current buffer;
  nil for BUFFER means discard it; 0 means discard and don't wait.
+If BUFFER is a string, then find or create a buffer with that name,
+then insert the output in that buffer, before point.
 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
 REAL-BUFFER says what to do with standard output, as above,
 while STDERR-FILE says what to do with standard error in the child.
 STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
+t (mix it with ordinary output), a file name string, or (XEmacs feature)
+a buffer object.  If STDERR-FILE is a buffer object (but not the name of
+a buffer, since that would be interpreted as a file), the standard error
+output will be inserted into the buffer before point.
 
 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
 Remaining arguments are strings passed as command arguments to PROGRAM.
 
-If BUFFER is 0, `call-process' returns immediately with value nil.
-Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
- or a signal description string.
-If you quit, the process is killed with SIGINT, or SIGKILL if you
- quit again."
-  ;; #### remove windows-nt check when this is ready for prime time.
-  (if (not (eq 'windows-nt system-type))
-      (apply 'old-call-process-internal program infile buffer display args)
-    (let (proc inbuf errbuf discard)
-      (unwind-protect
-	  (progn
-	    (when infile
-	      (setq infile (expand-file-name infile))
-	      (setq inbuf (generate-new-buffer "*call-process*"))
-	      (with-current-buffer inbuf
-               ;; Make sure this works with jka-compr
-               (let ((file-name-handler-alist nil))
-                 (insert-file-contents-internal infile nil nil nil nil
-                                                'binary))))
-	    (let ((stderr (if (consp buffer) (second buffer) t)))
-	      (if (consp buffer) (setq buffer (car buffer)))
-	      (setq buffer
-		    (cond ((null buffer) nil)
-			  ((eq buffer t) (current-buffer))
-			  ;; use integerp for compatibility with existing
-			  ;; call-process rmsism.
-			  ((integerp buffer) (setq discard t) nil)
-			  (t (get-buffer-create buffer))))
-	      (when (and stderr (not (eq t stderr)))
+If BUFFER is 0, returns immediately with value nil.
+Otherwise waits for PROGRAM to terminate and returns a numeric exit status
+or a signal description string.  If you quit, the process is first killed
+with SIGINT, then with SIGKILL if you quit again before the process exits.
+
+Coding systems for the process are the same as for `start-process-internal'."
+  (let (proc inbuf errbuf kill-inbuf kill-errbuf no-wait start end)
+    ;; first set up an unwind-protect to clean everything up.  this will:
+    ;;
+    ;; -- kill the process. (when we're not waiting for it to finish, we
+    ;;    set PROC to nil when we're ready to exit so this doesn't happen --
+    ;;    if we're interrupted before we're ready to exit, we should still
+    ;;    kill the process)
+    ;; -- kill temporary buffers created to handle I/O to or from a file.
+    ;;    KILL-INBUF/KILL-ERRBUF tell us if we should do so.
+    ;;
+    ;; note that we need to be *very* careful in this code to handle C-g
+    ;; at any point.
+    (unwind-protect
+	(progn
+	  ;; first handle INFILE.
+	  (cond ((stringp infile)
+		 (setq infile (expand-file-name infile))
+		 (setq kill-inbuf t)
+		 (setq inbuf (generate-new-buffer "*call-process*"))
+		 ;; transfer the exact contents of the file to the process.
+		 ;; we do that by reading in and writing out in
+		 ;; binary. #### is this even correct?  should we be doing
+		 ;; the same thing with stderr?  if so we'd need a way of
+		 ;; controlling the stderr coding system separate from
+		 ;; everything else.
+		 (with-current-buffer inbuf
+		   ;; Make sure this works with jka-compr
+		   (let ((file-name-handler-alist nil))
+		     (insert-file-contents-internal infile nil nil nil nil
+						    'binary))
+		   (setq start (point-min) end (point-max))))
+		((consp infile)
+		 (setq inbuf (get-buffer (car infile)))
+		 (setq start (or (nth 1 infile) (point-min inbuf)))
+		 (setq end (or (nth 2 infile) (point-max inbuf))))
+		((null infile) nil)
+		(t
+		 (error 'wrong-type-argument
+			"Must be filename or (BUFFER [START [END]])"
+			infile)))
+	  ;; now handle BUFFER
+	  (let ((stderr (if (consp buffer) (second buffer) t)))
+	    (if (consp buffer) (setq buffer (car buffer)))
+	    (setq buffer
+		  (cond ((null buffer) nil)
+			((eq buffer t) (current-buffer))
+			;; use integerp for compatibility with existing
+			;; call-process rmsism.
+			((integerp buffer) (setq no-wait t) nil)
+			(t (get-buffer-create buffer))))
+	    (when (and stderr (not (eq t stderr)))
+	      ;; both ERRBUF and STDERR being non-nil indicates to the
+	      ;; code below that STDERR is a file and we should write
+	      ;; ERRBUF to it; so clear out STDERR if we don't want this.
+	      (if (bufferp stderr) (setq errbuf stderr stderr nil)
 		(setq stderr (expand-file-name stderr))
-		(setq errbuf (generate-new-buffer "*call-process*")))
+		(setq kill-errbuf t)
+		(setq errbuf (generate-new-buffer "*call-process*"))))
+	    ;; now start process.  using a pty causes all sorts of
+	    ;; weirdness, at least under cygwin, when there's input. #### i
+	    ;; don't know what's going wrong and whether it's a cygwin-only
+	    ;; problem.  suffice to say that there were NO pty connections
+	    ;; in the old version.
+	    (let ((process-connection-type nil))
 	      (setq proc
 		    (apply 'start-process-internal "*call-process*"
-			   buffer
-			   ;#### not implemented until my new process
-			   ;changes go in.
-			   ;(if (eq t stderr) buffer (list buffer errbuf))
-			   program args))
-	      (if buffer
-		  (set-marker (process-mark proc) (point buffer) buffer))
-	      (unwind-protect
-		  (prog1
-		    (catch 'call-process-done
-		      (when (not discard)
-			(set-process-sentinel
-			 proc
-			 #'(lambda (proc status)
-			     (cond ((eq 'exit (process-status proc))
-				    (set-process-sentinel proc nil)
-				    (throw 'call-process-done
-					   (process-exit-status proc)))
-				   ((eq 'signal (process-status proc))
-				    (set-process-sentinel proc nil)
-				    (throw 'call-process-done status))))))
-		      (when inbuf
-			(process-send-region proc 1
-					     (1+ (buffer-size inbuf)) inbuf))
-		      (process-send-eof proc)
-		      (when discard
-			;; we're trying really really hard to emulate
-			;; the old call-process.
-			(if errbuf
-			    (set-process-sentinel
-			     proc
-			     `(lambda (proc status)
-				(write-region-internal
-				 1 (1+ (buffer-size))
-				 ,stderr
-				 nil 'major-rms-kludge-city nil
-				 coding-system-for-write))))
-			(setq errbuf nil)
-			(setq proc nil)
-			(throw 'call-process-done nil))
-		      (while t
-			(accept-process-output proc)
-			(if display (sit-for 0))))
-		    (when errbuf
-		      (with-current-buffer errbuf
-			(write-region-internal 1 (1+ (buffer-size)) stderr
-					       nil 'major-rms-kludge-city nil
-					       coding-system-for-write))))
-		(if proc (set-process-sentinel proc nil)))))
-	(if inbuf (kill-buffer inbuf))
-	(if errbuf (kill-buffer errbuf))
-	(condition-case nil
-	    (if (and proc (process-live-p proc)) (kill-process proc))
-	  (error nil))))))
-
-(defun call-process (program &optional infile buffer displayp &rest args)
-  "Call PROGRAM synchronously in separate process.
-The program's input comes from file INFILE (nil means `/dev/null').
-Insert output in BUFFER before point; t means current buffer;
- nil for BUFFER means discard it; 0 means discard and don't wait.
-BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
-REAL-BUFFER says what to do with standard output, as above,
-while STDERR-FILE says what to do with standard error in the child.
-STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
-
-Fourth arg DISPLAYP non-nil means redisplay buffer as output is inserted.
-Remaining arguments are strings passed as command arguments to PROGRAM.
-
-If BUFFER is 0, `call-process' returns immediately with value nil.
-Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
- or a signal description string.
-If you quit, the process is killed with SIGINT, or SIGKILL if you
- quit again."
-  (apply 'call-process-internal program infile buffer displayp args))
-
-(defun call-process-region (start end program
-                            &optional deletep buffer displayp
-                            &rest args)
-  "Send text from START to END to a synchronous process running PROGRAM.
-Delete the text if fourth arg DELETEP is non-nil.
-
-Insert output in BUFFER before point; t means current buffer;
- nil for BUFFER means discard it; 0 means discard and don't wait.
-BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
-REAL-BUFFER says what to do with standard output, as above,
-while STDERR-FILE says what to do with standard error in the child.
-STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
-
-Sixth arg DISPLAYP non-nil means redisplay buffer as output is inserted.
-Remaining args are passed to PROGRAM at startup as command args.
-
-If BUFFER is 0, returns immediately with value nil.
-Otherwise waits for PROGRAM to terminate
-and returns a numeric exit status or a signal description string.
-If you quit, the process is first killed with SIGINT, then with SIGKILL if
-you quit again before the process exits."
-  (let ((temp
-	 (make-temp-name
-	  (concat (file-name-as-directory (temp-directory)) "emacs"))))
-    (unwind-protect
-	(progn
-	  (write-region start end temp nil 'silent)
-	  (if deletep (delete-region start end))
-	  (apply #'call-process program temp buffer displayp args))
-      (ignore-file-errors (delete-file temp)))))
+			   (if (eq t stderr) buffer (list buffer errbuf))
+			   program args)))
+	    ;; see comment above where the data was read from the file.
+	    (if kill-inbuf
+		(set-process-output-coding-system proc 'binary))
+	    ;; point mark/stderr-mark at the right place (by default it's
+	    ;; end of buffer).
+	    (if buffer
+		(set-marker (process-mark proc) (point buffer) buffer))
+	    (if errbuf
+		(set-marker (process-stderr-mark proc) (point errbuf) errbuf))
+	    ;; now do I/O, very carefully!  the unwind-protect makes sure
+	    ;; to clear out the sentinel, since it does a `throw', which would
+	    ;; have no catch (or writes to a file -- we only want this on
+	    ;; normal exit)
+	    (unwind-protect
+		;; if not NO-WAIT, set a sentinel to return the exit
+		;; status.  it will throw to this catch so we can exit
+		;; properly.
+		(catch 'call-process-done
+		  (set-process-sentinel
+		   proc
+		   (if no-wait
+		       ;; we're trying really really hard to emulate
+		       ;; the old call-process, which would save the
+		       ;; stderr to a file even if discarding output.  so
+		       ;; we set a sentinel to save the output when
+		       ;; we finish.
+		       ;;
+		       ;; #### not clear if we should be doing this.
+		       ;;
+		       ;; NOTE NOTE NOTE: Due to the total bogosity of
+		       ;; dynamic scoping, and the lack of closures, we
+		       ;; have to be careful how we write the first
+		       ;; sentinel below since it may be executed after
+		       ;; this function has returned -- thus we fake a
+		       ;; closure. (This doesn't apply to the second one,
+		       ;; which only gets executed within the
+		       ;; unwind-protect.)
+		       (if (and errbuf stderr)
+			   (set-process-sentinel
+			    proc
+			    `(lambda (proc status)
+			       (set-process-sentinel proc nil)
+			       (with-current-buffer ,errbuf
+				 (write-region-internal
+				  1 (1+ (buffer-size))
+				  ,stderr
+				  nil 'major-rms-kludge-city nil
+				  coding-system-for-write))
+			       (kill-buffer ,errbuf))))
+		     ;; normal sentinel: maybe write out stderr and return
+		     ;; status.
+		     #'(lambda (proc status)
+			 (when (and errbuf stderr)
+			   (with-current-buffer errbuf
+			     (write-region-internal
+			      1 (1+ (buffer-size)) stderr
+			      nil 'major-rms-kludge-city nil
+			      coding-system-for-write)))
+			 (cond ((eq 'exit (process-status proc))
+				(set-process-sentinel proc nil)
+				(throw 'call-process-done
+				       (process-exit-status proc)))
+			       ((eq 'signal (process-status proc))
+				(set-process-sentinel proc nil)
+				(throw 'call-process-done status))))))
+		  (if (not no-wait)
+		      ;; we're waiting.  send the input and loop forever,
+		      ;; handling process output and maybe redisplaying.
+		      ;; exit happens through the sentinel or C-g.  if
+		      ;; C-g, send SIGINT the first time, EOF if not
+		      ;; already done so (might make the process exit),
+		      ;; and keep waiting.  Another C-g will exit the
+		      ;; whole function, and the unwind-protect will
+		      ;; kill the process. (Hence the documented semantics
+		      ;; of SIGINT/SIGKILL.)
+		      (let (eof-sent)
+			(condition-case nil
+			    (progn
+			      (when inbuf
+				(process-send-region proc start end inbuf))
+			      (process-send-eof proc)
+			      (setq eof-sent t)
+			      (while t
+				(accept-process-output proc)
+				(if display (sit-for 0))))
+			  (quit
+			   (process-send-signal 'SIGINT proc)
+			   (unless eof-sent
+			     (process-send-eof proc))
+			   (while t
+			     (accept-process-output proc)
+			     (if display (sit-for 0))))))
+		    ;; discard and no wait: send the input, set PROC
+		    ;; and ERRBUF to nil so that the unwind-protect
+		    ;; forms don't erase the sentinel, kill the process,
+		    ;; or kill ERRBUF (the sentinel does that), and exit.
+		    (when inbuf
+		      (process-send-region proc start end inbuf))
+		    (process-send-eof proc)
+		    (setq errbuf nil)
+		    (setq proc nil)))
+	      (if proc (set-process-sentinel proc nil)))))
+      ;; unwind-protect forms.
+      (if (and inbuf kill-inbuf) (kill-buffer inbuf))
+      (if (and errbuf kill-errbuf) (kill-buffer errbuf))
+      (condition-case nil
+	  (if (and proc (process-live-p proc)) (kill-process proc))
+	(error nil)))))
 
 
 (defun shell-command (command &optional output-buffer)
@@ -397,46 +450,6 @@
 		(t
 		 (set-window-start (display-buffer buffer) 1))))))))
 
-
-(defun start-process (name buffer program &rest program-args)
-  "Start a program in a subprocess.  Return the process object for it.
-Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS
-NAME is name for process.  It is modified if necessary to make it unique.
-BUFFER is the buffer or (buffer-name) to associate with the process.
- Process output goes at end of that buffer, unless you specify
- an output stream or filter function to handle the output.
- BUFFER may be also nil, meaning that this process is not associated
- with any buffer
-Third arg is program file name.  It is searched for as in the shell.
-Remaining arguments are strings to give program as arguments."
-  (apply 'start-process-internal name buffer program program-args))
-
-(defun open-network-stream (name buffer host service &optional protocol)
-  "Open a TCP connection for a service to a host.
-Returns a process object to represent the connection.
-Input and output work as for subprocesses; `delete-process' closes it.
-Args are NAME BUFFER HOST SERVICE.
-NAME is name for process.  It is modified if necessary to make it unique.
-BUFFER is the buffer (or buffer-name) to associate with the process.
- Process output goes at end of that buffer, unless you specify
- an output stream or filter function to handle the output.
- BUFFER may be also nil, meaning that this process is not associated
- with any buffer
-Third arg is name of the host to connect to, or its IP address.
-Fourth arg SERVICE is name of the service desired, or an integer
- specifying a port number to connect to.
-Fifth argument PROTOCOL is a network protocol.  Currently 'tcp
- (Transmission Control Protocol) and 'udp (User Datagram Protocol) are
- supported.  When omitted, 'tcp is assumed.
-
-Output via `process-send-string' and input via buffer or filter (see
-`set-process-filter') are stream-oriented.  That means UDP datagrams are
-not guaranteed to be sent and received in discrete packets. (But small
-datagrams around 500 bytes that are not truncated by `process-send-string'
-are usually fine.)  Note further that UDP protocol does not guard against
-lost packets."
-  (open-network-stream-internal name buffer host service protocol))
-
 (defun shell-quote-argument (argument)
   "Quote an argument for passing as argument to an inferior shell."
   (if (and (eq system-type 'windows-nt)
--- a/man/xemacs-faq.texi	Sat May 25 01:55:30 2002 +0000
+++ b/man/xemacs-faq.texi	Tue May 28 08:45:36 2002 +0000
@@ -7,7 +7,7 @@
 @finalout
 @titlepage
 @title XEmacs FAQ
-@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2002/05/11 18:19:18 $
+@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2002/05/28 08:44:34 $
 @sp 1
 @author Tony Rossini <rossini@@biostat.washington.edu>
 @author Ben Wing <ben@@xemacs.org>
--- a/netinstall/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/netinstall/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -451,7 +451,3 @@
 
 	* all: port from cygwin setup.
 
-%%% $Id: ChangeLog,v 1.16 2002/04/25 18:03:40 andyp Exp $
-$Revision: 1.16 $
-
-
--- a/nt/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/nt/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,9 @@
+2002-05-28  Ben Wing  <ben@xemacs.org>
+
+	* xemacs.mak (CFLAGS_NO_LIB):
+	* xemacs.mak (X_DEFINES):
+	Add -DSTRICT.
+
 2002-05-23  Ben Wing  <ben@xemacs.org>
 
 	* xemacs.mak (TEMACS_OBJS):
@@ -333,6 +339,7 @@
 
 	* XEmacs 21.5.0 "alfalfa" is released.
 
+>>>>>>> 1.120
 2001-03-14  Craig Lanning  <CraigL@Knology.net>
 
 	* minitar.c: Clean up some compiler warnings.
--- a/nt/xemacs.mak	Sat May 25 01:55:30 2002 +0000
+++ b/nt/xemacs.mak	Tue May 28 08:45:36 2002 +0000
@@ -375,7 +375,7 @@
 LIBC_LIB=libc.lib
 !endif
 
-CFLAGS_NO_LIB=-nologo -W3 $(DEBUGFLAGS) $(OPTFLAGS)
+CFLAGS_NO_LIB=-nologo -W3 -DSTRICT $(DEBUGFLAGS) $(OPTFLAGS)
 CFLAGS=$(CFLAGS_NO_LIB) $(C_LIBFLAG)
 
 !if $(HAVE_X_WINDOWS)
--- a/src/ChangeLog	Sat May 25 01:55:30 2002 +0000
+++ b/src/ChangeLog	Tue May 28 08:45:36 2002 +0000
@@ -1,3 +1,555 @@
+2002-05-28  Ben Wing  <ben@xemacs.org>
+
+	================================================================
+   	       ALLOW SEPARATION OF STDOUT AND STDERR IN PROCESSES   
+	================================================================
+
+	Standard output and standard error can be processed separately in
+	a process.  Each can have its own buffer, its own mark in that buffer,
+	and its filter function.  You can specify a separate buffer for stderr
+	in `start-process' to get things started, or use the new primitives:
+
+        set-process-stderr-buffer
+        process-stderr-buffer
+	process-stderr-mark
+        set-process-stderr-filter
+	process-stderr-filter
+
+        Also, process-send-region takes a 4th optional arg, a buffer.
+
+	Currently always uses a pipe() under Unix to read the error output.
+	(#### Would a PTY be better?)
+
+	* sysdep.h:
+	* sysproc.h:
+	* unexfreebsd.c (unexec):
+	* unexsunos4.c (unexec):
+	* nt.c (init_user_info):
+	* emacs.c:
+	* emacs.c (main_1):
+	* callproc.c:
+	* symsinit.h:
+	* sysdep.c:
+	* sysdep.c (wait_for_termination):
+	* Makefile.in.in (objs):
+	* process-unix.c (child_setup):
+	Delete callproc.c.  Move child_setup() to process-unix.c.
+	wait_for_termination() now only needed on a few really old systems.
+	
+	* console-msw.h:
+	* event-Xt.c (emacs_Xt_select_process):
+	* event-Xt.c (emacs_Xt_unselect_process):
+	* event-Xt.c (emacs_Xt_create_io_streams):
+	* event-Xt.c (emacs_Xt_delete_io_streams):
+	* event-Xt.c (debug_process_finalization):
+	* event-Xt.c (reinit_vars_of_event_Xt):
+	* event-msw.c (get_process_stderr_waitable):
+	* event-msw.c (emacs_mswindows_select_process):
+	* event-msw.c (emacs_mswindows_unselect_process):
+	* event-msw.c (emacs_mswindows_create_io_streams):
+	* event-msw.c (emacs_mswindows_delete_io_streams):
+	* event-msw.c (debug_process_finalization):
+	* event-msw.c (reinit_vars_of_event_mswindows):
+	* event-msw.c (vars_of_event_mswindows):
+	* event-msw.c (lstream_type_create_mswindows_selectable):
+	* event-stream.c (event_stream_select_process):
+	* event-stream.c (event_stream_unselect_process):
+	* event-stream.c (event_stream_create_io_streams):
+	* event-stream.c (event_stream_delete_io_streams):
+	* event-stream.c (Faccept_process_output):
+	* event-tty.c (emacs_tty_select_process):
+	* event-tty.c (emacs_tty_unselect_process):
+	* event-tty.c (emacs_tty_create_io_streams):
+	* event-tty.c (emacs_tty_delete_io_streams):
+	* event-tty.c (reinit_vars_of_event_tty):
+	* event-unixoid.c:
+	* event-unixoid.c (get_process_infd):
+	* event-unixoid.c (get_process_errfd):
+	* event-unixoid.c (event_stream_unixoid_select_process):
+	* event-unixoid.c (event_stream_unixoid_unselect_process):
+	* event-unixoid.c (event_stream_unixoid_create_io_streams):
+	* event-unixoid.c (event_stream_unixoid_delete_io_streams):
+	* events.h:
+	* events.h (struct event_stream):
+	* process-nt.c:
+	* process-nt.c (struct nt_process_data):
+	* process-nt.c (nt_create_process):
+	* process-nt.c (get_internet_address):
+	* process-nt.c (nt_open_network_stream):
+	* process-unix.c:
+	* process-unix.c (struct unix_process_data):
+	* process-unix.c (UNIX_DATA):
+	* process-unix.c (close_process_descs_mapfun):
+	* process-unix.c (close_process_descs):
+	* process-unix.c (connect_to_file_descriptor):
+	* process-unix.c (process_signal_char):
+	* process-unix.c (unix_alloc_process_data):
+	* process-unix.c (unix_init_process_io_handles):
+	* process-unix.c (unix_create_process):
+	* process-unix.c (io_failure): Removed.
+	* process-unix.c (unix_tooltalk_connection_p):
+	* process-unix.c (unix_set_window_size):
+	* process-unix.c (unix_reap_exited_processes):
+	* process-unix.c (unix_deactivate_process):
+	* process-unix.c (unix_kill_child_process):
+	* process.c:
+	* process.c (mark_process):
+	* process.c (get_process_streams):
+	* process.c (get_process_from_usid):
+	* process.c (get_process_selected_p):
+	* process.c (set_process_selected_p):
+	* process.c (make_process_internal):
+	* process.c (init_process_io_handles):
+	* process.c (create_process):
+	* process.c (Fstart_process_internal):
+	* process.c (Fopen_multicast_group_internal):
+	* process.c (process_setup_for_insertion):
+	* process.c (read_process_output):
+	* process.c (Fset_process_stderr_buffer):
+	* process.c (Fprocess_stderr_mark):
+	* process.c (set_process_filter):
+	* process.c (Fset_process_filter):
+	* process.c (Fset_process_stderr_filter):
+	* process.c (Fprocess_stderr_filter):
+	* process.c (exec_sentinel_unwind):
+	* process.c (exec_sentinel):
+	* process.c (status_notify):
+	* process.c (Fprocess_send_eof):
+	* process.c (deactivate_process):
+	* process.c (syms_of_process):
+	* process.c (vars_of_process):
+	* process.h:
+	* procimpl.h:
+	* procimpl.h (struct process_methods):
+	* procimpl.h (struct Lisp_Process):
+	* procimpl.h (DATA_ERRSTREAM):
+	Rewrite the process methods to handle a separate channel for
+	error input.  Create Lstreams for reading in the error channel.
+	Many process methods need change.  In general the changes are
+	fairly clear as they involve duplicating what's used for reading
+	the normal stdout and changing for stderr -- although tedious,
+	as such changes are required throughout the entire process code.
+	Rewrote the code that reads process output to do two loops, one
+	for stdout and one for stderr.
+	
+	* gpmevent.c (get_process_infd):
+	* gpmevent.c (Fgpm_enable):
+	* tooltalk.c:
+	* tooltalk.c (init_tooltalk):
+        set_process_filter takes an argument for stderr.
+
+	================================================================
+                          NEW ERROR-TRAPPING MECHANISM
+	================================================================
+
+        Totally rewrite error trapping code to be unified and support more
+        features.  Basic function is call_trapping_problems(), which lets
+	you specify, by means of flags, what sorts of problems you want
+	trapped.  these can include
+
+	-- quit
+	-- errors
+	-- throws past the function
+	-- creation of "display objects" (e.g. buffers)
+	-- deletion of already-existing "display objects" (e.g. buffers)
+	-- modification of already-existing buffers
+	-- entering the debugger
+	-- gc
+	-- errors->warnings (ala suspended errors)
+
+	etc.  All other error funs rewritten in terms of this one.
+	Various older mechanisms removed or rewritten.
+
+	* window.c (mark_window_as_deleted):
+	* window.c (Fdelete_window):
+	* window.c (Fset_window_configuration):
+	* insdel.c (prepare_to_modify_buffer):
+	* insdel.c (buffer_insert_string_1):
+	* console.c (create_console):
+	* buffer.c (finish_init_buffer):
+	* device.c (allocate_device):
+	* device.c (Fmake_device):
+	* frame.c:
+	* frame.c (Fmake_frame):
+	* frame.c (allocate_frame_core):
+	* frame.c (setup_normal_frame):
+	* frame.c (delete_frame_internal):
+	* window.c (Fsplit_window):
+	* device.c (delete_device_internal):
+	* console.c (delete_console_internal):
+	* buffer.c (Fkill_buffer):
+	When creating a display object, added call to
+	note_object_created(), for use with trapping_problems mechanism.
+	When deleting, call check_allowed_operation() and note_object
+	deleted().
+
+	The trapping-problems code records the objects created since the
+	call-trapping-problems began.  Those objects can be deleted, but
+	none others (i.e. previously existing ones).
+
+	* bytecode.c (execute_rare_opcode):
+	* cmdloop.c:
+	* cmdloop.c (initial_command_loop):
+	* cmdloop.c (Frecursive_edit):
+	* cmdloop.c (call_command_loop):
+	internal_catch takes another arg.
+
+	* eval.c:
+        Add long comments describing the "five lists" used to maintain
+	state (backtrace, gcpro, specbind, etc.) in the Lisp engine.
+
+	* backtrace.h:
+	* eval.c (current_warning_level):
+	* eval.c (call_debugger):
+	* eval.c (signal_call_debugger):
+	* eval.c (Fwhen):
+	* eval.c (Fcatch):
+	* eval.c (internal_catch):
+	* eval.c (unwind_to_catch):
+	* eval.c (throw_or_bomb_out):
+	* eval.c (condition_bind_unwind):
+	* eval.c (condition_case_1):
+	* eval.c (Fcall_with_condition_handler):
+	* eval.c (call_with_condition_handler):
+	* eval.c (Fsignal):
+	* eval.c (check_catchlist_sanity):
+	* eval.c (check_specbind_stack_sanity):
+	* eval.c (signal_quit):
+	* eval.c (Feval):
+	* eval.c (run_hook_list_with_args):
+	* eval.c (run_hook):
+	* eval.c (get_inhibit_flags):
+	* eval.c (check_allowed_operation):
+	* eval.c (note_object_created):
+	* eval.c (note_object_deleted):
+	* eval.c (struct call_trapping_problems):
+	* eval.c (flagged_a_squirmer):
+	* eval.c (call_trapping_problems_2):
+	* eval.c (call_trapping_problems_1):
+	* eval.c (call_trapping_problems):
+	* eval.c (struct va_call_trapping_problems):
+	* eval.c (va_call_trapping_problems_1):
+	* eval.c (va_call_trapping_problems):
+	* eval.c (call_with_suspended_errors):
+	* eval.c (struct calln_trapping_problems):
+	* eval.c (calln_trapping_problems_1):
+	* eval.c (calln_trapping_problems):
+	* eval.c (call1_trapping_problems):
+	* eval.c (call2_trapping_problems):
+	* eval.c (call3_trapping_problems):
+	* eval.c (call4_trapping_problems):
+	* eval.c (call5_trapping_problems):
+	* eval.c (eval_in_buffer_trapping_problems_1):
+	* eval.c (eval_in_buffer_trapping_problems):
+	* eval.c (run_hook_trapping_problems):
+	* eval.c (safe_run_hook_trapping_problems_1):
+	* eval.c (safe_run_hook_trapping_problems):
+	* eval.c (struct run_hook_with_args_in_buffer_trapping_problems):
+	* eval.c (run_hook_with_args_in_buffer_trapping_problems_1):
+	* eval.c (run_hook_with_args_in_buffer_trapping_problems):
+	* eval.c (va_run_hook_with_args_trapping_problems):
+	* eval.c (va_run_hook_with_args_in_buffer_trapping_problems):
+	* eval.c (reinit_vars_of_eval):
+	* eval.c (vars_of_eval):
+	Implement trapping-problems mechanism, eliminate old mechanisms or
+	redo in terms of new one.
+
+	* frame.c (enter_redisplay_critical_section):
+	* frame.c (exit_redisplay_critical_section):
+	* gutter.c (redraw_exposed_gutters):
+	* gutter.c (Fset_default_gutter_position):
+	* gutter.c (Fredisplay_gutter_area):
+	Flush out the concept of "critical display section", defined by
+	the in_display() var.  Use an internal_bind() to get it reset,
+	rather than just doing it at end, because there may be a non-local
+	exit.
+
+	* event-msw.c (struct mswindows_protect_modal_loop):
+	* event-msw.c (mswindows_protect_modal_loop_1):
+	* event-msw.c (mswindows_protect_modal_loop):
+	* event-msw.c (mswindows_unmodalize_signal_maybe):
+	* event-msw.c (mswindows_pump_outstanding_events):
+	* event-msw.c (mswindows_need_event):
+	* event-msw.c (mswindows_dde_callback):
+	* event-msw.c (mswindows_wnd_proc):
+	* event-msw.c:
+	* event-msw.c (vars_of_event_mswindows):
+	* event-msw.c (struct ntpipe_slurp_stream_shared_data):
+	* event-msw.c (struct ntpipe_shove_stream):
+	* event-stream.c (pre_command_hook):
+	* event-stream.c (post_command_hook):
+	* event-stream.c (vars_of_event_stream):
+	* event-stream.c (run_pre_idle_hook):
+	* console-msw.h:
+	* device.c (call_critical_lisp_code): Rewrite.
+	* dialog-msw.c (dialog_proc):
+	* frame.c (adjust_frame_size):
+	* frame.h:
+	* intl.c (init_intl):
+	* toolbar.c (Fset_default_toolbar_position):
+	* toolbar.c (update_toolbar_button):
+	* menubar-msw.c (unsafe_handle_wm_initmenu_1):
+	* menubar-msw.c (mswindows_handle_wm_initmenupopup):
+	* menubar-msw.c (mswindows_handle_wm_initmenu):
+	* redisplay.c:
+	* redisplay.c (call_redisplay_end_triggers):
+	* redisplay.c (redisplay_frame):
+	* redisplay.c (redisplay_no_pre_idle_hook):
+	* redisplay.c (eval_within_redisplay):
+	* redisplay.c (Fredisplay_echo_area):
+	* alloc.c (garbage_collect_1):
+	* menubar-x.c:
+	* menubar-x.c (menu_item_descriptor_to_widget_value_1):
+	* menubar-x.c (struct menu_item_descriptor_to_widget_value):
+	* menubar-x.c (protected_menu_item_descriptor_to_widget_value_1):
+	* menubar-x.c (protected_menu_item_descriptor_to_widget_value):
+	* menubar-x.c (pre_activate_callback):
+	Make use of new trapping-errors stuff and rewrite code based on
+	old mechanisms.
+
+	* glyphs-widget.c (widget_query_geometry):
+	* glyphs-widget.c (layout_query_geometry):
+	* redisplay.h:
+        Protect calling Lisp in redisplay.
+
+	* insdel.c (signal_first_change):
+	* insdel.c (signal_before_change):
+	* insdel.c (signal_after_change):
+        Protect hooks against deleting existing buffers.
+
+	* frame-msw.c (mswindows_init_frame_1):
+	Use EQ, not EQUAL in hash tables whose keys are just numbers.
+	Otherwise we run into stickiness in redisplay because
+	internal_equal() can QUIT.
+
+	================================================================
+                               SIGNAL, C-G CHANGES
+	================================================================
+
+	Here we change the way that C-g interacts with event reading.  The
+	idea is that a C-g occurring while we're reading a user event
+	should be read as C-g, but elsewhere should be a QUIT.  The former
+	code did all sorts of bizarreness -- requiring that no QUIT occurs
+	anywhere in event-reading code (impossible to enforce given the
+	stuff called or Lisp code invoked), and having some weird system
+	involving enqueue/dequeue of a C-g and interaction with Vquit_flag
+	-- and it didn't work.
+
+ 	Now, we simply enclose all code where we want C-g read as an event
+	with {begin/end}_dont_check_for_quit().  This completely turns off
+	the mechanism that checks (and may remove or alter) C-g in the
+	read-ahead queues, so we just get the C-g normal.
+
+	Signal.c documents this very carefully.
+	
+	* cmdloop.c (Fcommand_loop_1):
+        Correct use of dont_check_for_quit to new scheme, remove old
+        out-of-date comments.
+
+	* event-stream.c (maybe_echo_keys):
+	* event-stream.c (enqueue_command_event_1):
+	* event-stream.c (next_event_internal):
+	* event-stream.c (Fnext_event):
+	* event-stream.c (Fnext_command_event):
+	* event-stream.c (Fdispatch_non_command_events):
+	* event-stream.c (Fdiscard_input):
+	* event-stream.c (Fsleep_for):
+	* event-stream.c (Fsit_for):
+	* event-stream.c (wait_delaying_user_input):
+	* event-stream.c (execute_internal_event):
+	* event-stream.c (lookup_command_event):
+	* event-stream.c (Fread_key_sequence):
+	* event-stream.c:
+	* event-stream.c (event_stream_next_event):
+	 Fix C-g handling to actually work.
+	
+	* device-x.c (get_device_from_display):
+	* device-x.c (x_error_handler):
+	* device-x.c (x_IO_error_handler):
+	Disable quit checking when err out.
+
+	* signal.c:
+	* signal.c (handle_async_timeout_signal):
+	* signal.c (check_what_happened):
+	* signal.c (begin_dont_check_for_quit):
+	* signal.c (check_quit):
+        Cleanup.  Add large descriptive comment.
+
+	* process-unix.c (unix_open_network_stream):
+	* process-unix.c (unix_open_multicast_group):
+	* process-nt.c (nt_open_network_stream):
+	* sysdep.c (retry_read_1):
+	* sysdep.c (retry_write_1):
+        Use QUIT instead of REALLY_QUIT.
+        It's not necessary to use REALLY_QUIT and just confuses the issue.
+
+	* lisp.h (INTERNAL_QUITP): Comment quit handlers.
+
+	================================================================
+                                 CONS CHANGES
+	================================================================
+
+	free_cons() now takes a Lisp_Object not the result of XCONS().
+	car and cdr have been renamed so that they don't get used directly;
+	go through XCAR(), XCDR() instead.
+	
+	* alloc.c (Fcons):
+	* alloc.c (free_cons):
+	* alloc.c (free_list):
+	* alloc.c (free_alist):
+	* dired.c (file_name_completion_unwind):
+	* dired.c (user_name_completion_unwind):
+	* editfns.c (save_excursion_save):
+	* editfns.c (save_excursion_restore):
+	* editfns.c (save_restriction_restore):
+	* emodules.c (module_load_unwind):
+	* fns.c:
+	* fns.c (delq_no_quit_and_free_cons):
+	* fns.c (merge_pred_function):
+	* fns.c (tweaked_internal_equal):
+	* glyphs-msw.c (extract_xpm_color_names):
+	* glyphs-x.c (extract_xpm_color_names):
+	* glyphs.c (image_instantiate_cache_result):
+	* glyphs.c (image_instance_changed):
+	* keymap.c (traverse_keymaps):
+	* minibuf.c (read_minibuffer_internal_unwind):
+	* search.c (free_created_dynarrs):
+	* eval.c (specbind_unwind_local):
+	* lread.c (various):
+	* lisp.h (struct Lisp_Cons):
+	* lisp.h (cons_car):
+        Correct free_cons calling convention: now takes Lisp_Object,
+        not Lisp_Cons
+	
+	* chartab.c (word_boundary_p):
+        Eliminate direct use of ->car, ->cdr, should be black box.
+
+
+	* callint.c (quotify_args):
+        Rewrote using EXTERNAL_LIST_LOOP to avoid use of Lisp_Cons.
+
+	================================================================
+                           USE INTERNAL-BIND-*
+	================================================================
+	
+	* eval.c (restore_lisp_object):
+	* eval.c (restore_int):
+	Cleanups of these funs.
+
+	* alloc.c (begin_gc_forbidden):
+	* fileio.c:
+	* fileio.c (close_file_unwind):
+	* fileio.c (Fdo_auto_save):
+	* undo.c:
+	* undo.c (Fprimitive_undo):
+	* specifier.c:
+	* specifier.c (unlock_ghost_specifiers_protected):
+	* specifier.c (set_specifier_caching):
+	* text.c (dfc_convert_to_external_format):
+	* text.c (dfc_convert_to_internal_format):
+	* profile.c (struct get_profiling_info_closure):
+	* profile.c (Fget_profiling_info):
+	* lread.c:
+	* lread.c (load_unwind):
+	* lread.c (Fload_internal):
+	* lread.c (read0):
+	* lread.c (read1):
+	* lread.c (read_list_conser):
+	* lread.c (read_vector):
+	* lread.c (read_compiled_function):
+	* redisplay.c (Fredraw_frame):
+	* redisplay.c (Fredisplay_frame):
+	* redisplay.c (Fredraw_device):
+	* redisplay.c (Note): New.
+	* redisplay.c (Fredisplay_device):
+	* redisplay.c (redisplay_without_hooks):
+	* menubar-x.c (pre_activate_callback):
+	* macros.c (Fexecute_kbd_macro):
+        Rewrote to use internal_bind_int() and internal_bind_lisp_object()
+	in place of whatever varied and cumbersome mechanisms were
+	formerly there.
+
+
+	================================================================
+                                SPECBIND SANITY   
+	================================================================
+
+	* backtrace.h:
+        - Improved comments
+
+	* backtrace.h (SPECBIND):
+	* backtrace.h (SPECBIND_FAST_UNSAFE):
+	* backtrace.h (UNBIND_TO_GCPRO):
+	* backtrace.h (UNBIND_TO):
+	* backtrace.h (UNBIND_TO_GCPRO_VARIABLES_ONLY):
+	* bytecode.c (execute_optimized_program):
+	* eval.c (grow_specpdl):
+	* eval.c (specbind):
+	* eval.c (specbind_magic):
+	* eval.c (record_unwind_protect):
+	* eval.c (unbind_to_1):
+	* eval.c (unbind_to_hairy):
+        Add new mechanism check_specbind_stack_sanity() for sanity
+	checking code each time the catchlist or specbind stack change.
+	Removed older prototype of same mechanism.
+
+	================================================================
+                                    MISC   
+	================================================================
+
+	* lisp.h:
+	* insdel.c:
+	* window.c:
+	* device.c:
+	* console.c:
+	* buffer.c:
+	 Fleshed out authorship.
+
+	* device-msw.c (mswindows_handle_page_setup_dialog_box):
+	Correct bad Unicode-ization.
+
+	* print.c (debug_print_no_newline):
+	* print.c (debug_backtrace):
+        Be more careful when not initialized or in fatal error handling.
+
+	* search.c (looking_at_1):
+	* search.c (string_match_1):
+	* search.c (search_buffer):
+	* search.c (Fstore_match_data):
+        Eliminate running_asynch_code, an FSF holdover.
+
+	* alloc.c (vars_of_alloc):
+	* alloc.c:
+	Added comments about gc-cons-threshold.
+
+	* dialog-x.c:
+	* dialog-x.c (dbox_descriptor_to_widget_value):
+	Use begin_gc_forbidden() around code to build up a widget value
+	tree, like in menubar-x.c.
+
+	* gui.c (gui_item_id_hash): Use Qunbound not Qnil as the default for
+	gethash.
+
+	* lisp-disunion.h:
+	* lisp-union.h:
+        Added warnings on use of VOID_TO_LISP().
+
+	* lisp.h:
+	Use ERROR_CHECK_STRUCTURES to turn on
+	ERROR_CHECK_TRAPPING_PROBLEMS and ERROR_CHECK_TYPECHECK
+
+	* lisp.h (assert_with_message):
+	Add assert_with_message.
+	
+	* lisp.h (GCPRO1_ARRAY):
+	* lisp.h (NGCPRO1_ARRAY):
+	* lisp.h (NNGCPRO1_ARRAY):
+	Add macros for gcproing entire arrays. (You could do this before
+	but it required manual twiddling the gcpro structure.)
+	
+	* lisp.h:
+        Add prototypes for new functions defined elsewhere.
+
 2002-05-23  Ben Wing  <ben@xemacs.org>
 
 	* Makefile.in.in (objs):
@@ -1610,7 +2162,7 @@
 
 	Also fix warning in sysdep.c.
 
-	2002-03-31  Ben Wing  <ben@xemacs.org>
+2002-03-31  Ben Wing  <ben@xemacs.org>
 
 	* alloc.c:
 	* alloc.c (INCREMENT_CONS_COUNTER):
--- a/src/Makefile.in.in	Sat May 25 01:55:30 2002 +0000
+++ b/src/Makefile.in.in	Tue May 28 08:45:36 2002 +0000
@@ -309,7 +309,7 @@
 objs=\
  abbrev.o alloc.o alloca.o \
  $(balloon_help_objs) blocktype.o buffer.o bytecode.o \
- callint.o callproc.o casefiddle.o casetab.o chartab.o \
+ callint.o casefiddle.o casetab.o chartab.o \
  $(clash_detection_objs) cmdloop.o cmds.o $(coding_system_objs) console.o \
  console-stream.o\
  data.o $(database_objs) $(debug_objs) device.o dired.o doc.o doprnt.o\
--- a/src/alloc.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/alloc.c	Tue May 28 08:45:36 2002 +0000
@@ -155,7 +155,8 @@
 static EMACS_INT gc_cons_percentage;
 
 #ifdef ERROR_CHECK_GC
-int always_gc;			/* Debugging hack */
+int always_gc;			/* Debugging hack; equivalent to
+				   (setq gc-cons-thresold -1) */
 #else
 #define always_gc 0
 #endif
@@ -173,7 +174,7 @@
 
 /* Nonzero when calling certain hooks or doing other things where
    a GC would be bad */
-int gc_currently_forbidden;
+static int gc_currently_forbidden;
 
 /* Hooks. */
 Lisp_Object Vpre_gc_hook, Qpre_gc_hook;
@@ -929,8 +930,8 @@
 }
 
 static const struct lrecord_description cons_description[] = {
-  { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
-  { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
+  { XD_LISP_OBJECT, offsetof (Lisp_Cons, car_) },
+  { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr_) },
   { XD_END }
 };
 
@@ -958,8 +959,8 @@
   ALLOCATE_FIXED_TYPE (cons, Lisp_Cons, c);
   set_lheader_implementation (&c->lheader, &lrecord_cons);
   val = wrap_cons (c);
-  c->car = car;
-  c->cdr = cdr;
+  XSETCAR (val, car);
+  XSETCDR (val, cdr);
   return val;
 }
 
@@ -3027,8 +3028,10 @@
 
 /* Explicitly free a cons cell.  */
 void
-free_cons (Lisp_Cons *ptr)
+free_cons (Lisp_Object cons)
 {
+  Lisp_Cons *ptr = XCONS (cons);
+
 #ifdef ERROR_CHECK_GC
   /* If the CAR is not an int, then it will be a pointer, which will
      always be four-byte aligned.  If this cons cell has already been
@@ -3036,8 +3039,8 @@
      a chain pointer to the next cons on the list, which has cleverly
      had all its 0's and 1's inverted.  This allows for a quick
      check to make sure we're not freeing something already freed. */
-  if (POINTER_TYPE_P (XTYPE (ptr->car)))
-    ASSERT_VALID_POINTER (XPNTR (ptr->car));
+  if (POINTER_TYPE_P (XTYPE (cons_car (ptr))))
+    ASSERT_VALID_POINTER (XPNTR (cons_car (ptr)));
 #endif /* ERROR_CHECK_GC */
 
 #ifndef ALLOC_NO_POOLS
@@ -3058,7 +3061,7 @@
   for (rest = list; !NILP (rest); rest = next)
     {
       next = XCDR (rest);
-      free_cons (XCONS (rest));
+      free_cons (rest);
     }
 }
 
@@ -3075,8 +3078,8 @@
   for (rest = alist; !NILP (rest); rest = next)
     {
       next = XCDR (rest);
-      free_cons (XCONS (XCAR (rest)));
-      free_cons (XCONS (rest));
+      free_cons (XCAR (rest));
+      free_cons (rest);
     }
 }
 
@@ -3506,20 +3509,10 @@
 }
 
 
-static Lisp_Object
-restore_gc_inhibit (Lisp_Object val)
-{
-  gc_currently_forbidden = XINT (val);
-  return val;
-}
-
 int
 begin_gc_forbidden (void)
 {
-  int speccount = record_unwind_protect (restore_gc_inhibit,
-					 make_int (gc_currently_forbidden));
-  gc_currently_forbidden = 1;
-  return speccount;
+  return internal_bind_int (&gc_currently_forbidden, 1);
 }
 
 void
@@ -3632,7 +3625,9 @@
   speccount = begin_gc_forbidden ();
 
   if (!gc_hooks_inhibited)
-    run_hook_trapping_errors ("Error in pre-gc-hook", Qpre_gc_hook);
+    run_hook_trapping_problems
+      ("Error in pre-gc-hook", Qpre_gc_hook,
+       INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 
   /* Now show the GC cursor/message. */
   if (!noninteractive)
@@ -3743,6 +3738,7 @@
       {
 	mark_object (catch->tag);
 	mark_object (catch->val);
+	mark_object (catch->actual_tag);
       }
   }
 
@@ -3801,7 +3797,9 @@
 
   /******* End of garbage collection ********/
 
-  run_hook_trapping_errors ("Error in post-gc-hook", Qpost_gc_hook);
+  run_hook_trapping_problems
+    ("Error in post-gc-hook", Qpost_gc_hook,
+     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 
   /* Now remove the GC cursor/message */
   if (!noninteractive)
@@ -4363,6 +4361,16 @@
 By binding this temporarily to a large number, you can effectively
 prevent garbage collection during a part of the program.
 
+Normally, you cannot set this value less than 10,000 (if you do, it is
+automatically reset during the next garbage collection).  However, if
+XEmacs was compiled with DEBUG_XEMACS, this does not happen, allowing
+you to set this value very low to track down problems with insufficient
+GCPRO'ing.  If you set this to a negative number, garbage collection will
+happen at *EVERY* call to `eval' or `funcall'.  This is an extremely
+effective way to check GCPRO problems, but be warned that your XEmacs
+will be unusable!  You almost certainly won't have the patience to wait
+long enough to be able to set it back.
+ 
 See also `consing-since-gc'.
 */ );
 
--- a/src/backtrace.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/backtrace.h	Tue May 28 08:45:36 2002 +0000
@@ -1,5 +1,6 @@
 /* The lisp stack.
    Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
+   Copyright (C) 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -35,6 +36,19 @@
 
 #include <setjmp.h>
 
+#ifdef ERROR_CHECK_CATCH
+/* you can use this if you are trying to debug corruption in the
+   catchlist */
+void check_catchlist_sanity (void);
+
+/* you can use this if you are trying to debug corruption in the specbind
+   stack */
+void check_specbind_stack_sanity (void);
+#else
+#define check_catchlist_sanity()
+#define check_specbind_stack_sanity()
+#endif
+
 /* These definitions are used in eval.c and alloc.c */
 
 struct backtrace
@@ -54,18 +68,24 @@
 /* This structure helps implement the `catch' and `throw' control
    structure.  A struct catchtag contains all the information needed
    to restore the state of the interpreter after a non-local jump.
-
-   Handlers for error conditions (represented by `struct handler'
-   structures) just point to a catch tag to do the cleanup required
-   for their jumps.
+   (No information is stored concerning how to restore the state of
+   the condition-handler list; this is handled implicitly through
+   an unwind-protect.  unwind-protects are on the specbind stack,
+   which is reset to its proper value by `throw'.  In the process of
+   that, any intervening bindings are reset and unwind-protects called,
+   which fixes up the condition-handler list.
 
    catchtag structures are chained together in the C calling stack;
    the `next' member points to the next outer catchtag.
 
    A call like (throw TAG VAL) searches for a catchtag whose `tag'
-   member is TAG, and then unbinds to it.  The `val' member is used to
-   hold VAL while the stack is unwound; `val' is returned as the value
-   of the catch form.
+   member is TAG, and then unbinds to it.  A value of Vcatch_everything_tag
+   for the `tag' member of a catchtag is special and means "catch all throws,
+   regardless of the tag".  This is used internally by the C code.  The `val'
+   member is used to hold VAL while the stack is unwound; `val' is returned
+   as the value of the catch form.  The `actual_tag' member holds the value
+   of TAG as passed to throw, so that it can be retrieved when catches with
+   Vcatch_everything_tag are set up.
 
    All the other members are concerned with restoring the interpreter
    state.  */
@@ -73,6 +93,9 @@
 struct catchtag
   {
     Lisp_Object tag;
+    /* Stores the actual tag used in `throw'; the same as TAG, unless
+       TAG is Vcatch_everything_tag. */
+    Lisp_Object actual_tag;
     Lisp_Object val;
     struct catchtag *next;
     struct gcpro *gcpro;
@@ -191,6 +214,7 @@
     }									\
   else									\
     specbind_magic (SB_symbol, SB_newval);				\
+  check_specbind_stack_sanity ();					\
 } while (0)
 
 /* An even faster, but less safe inline version of specbind().
@@ -217,6 +241,7 @@
     }									\
   else									\
     specbind_magic (SFU_symbol, SFU_newval);				\
+  check_specbind_stack_sanity ();					\
 } while (0)
 /* Request enough room for SIZE future entries on special binding stack */
 #define SPECPDL_RESERVE(size) do {			\
@@ -253,6 +278,7 @@
 							\
       sym->value = specpdl_ptr->old_value;		\
     }							\
+  check_specbind_stack_sanity ();			\
 } while (0)
 
 /* A slightly faster inline version of unbind_to_1,
@@ -275,14 +301,9 @@
 							\
       sym->value = specpdl_ptr->old_value;		\
     }							\
+  check_specbind_stack_sanity ();			\
 } while (0)
 
-#ifdef ERROR_CHECK_STRUCTURES
-#define CHECK_SPECBIND_VARIABLE assert (specpdl_ptr->func == 0)
-#else
-#define CHECK_SPECBIND_VARIABLE DO_NOTHING
-#endif
-
 #if 0
 /* Unused.  It's too hard to guarantee that the current bindings
    contain only variables.  */
@@ -298,7 +319,6 @@
       --specpdl_ptr;						\
       --specpdl_depth_counter;					\
 								\
-      CHECK_SPECBIND_VARIABLE;					\
       sym = XSYMBOL (specpdl_ptr->symbol);			\
       if (!SYMBOL_VALUE_MAGIC_P (sym->value))			\
 	sym->value = specpdl_ptr->old_value;			\
--- a/src/buffer.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/buffer.c	Tue May 28 08:45:36 2002 +0000
@@ -24,12 +24,20 @@
 
 /* Authorship:
 
-   FSF: long ago.
-   JWZ: some changes for Lemacs, long ago. (e.g. separate buffer
-        list per frame.)
-   Mly: a few changes for buffer-local vars, 19.8 or 19.9.
-   Ben Wing: some changes and cleanups for Mule, 19.12.
- */
+   Based on code from pre-release FSF 19, c. 1991.
+   Some changes by Jamie Zawinski, c. 1991-1994 (e.g. separate buffer
+     list per frame, buffer slots).
+   A few changes for buffer-local vars by Richard Mlynarik for
+     19.8 or 19.9, c. 1993.
+   Many changes by Ben Wing: changes and cleanups for Mule, esp. the
+     macros in buffer.h and the intial version of the coding-system
+     conversion macros (in buffer.h) and associated fns. (in this file),
+     19.12 (c. 1995); synch. to FSF 19.30 c. 1994; memory usage stats
+     c. 1996; generated-modeline-string c. 1996 for mousable modeline in
+     19.14.
+   Indirect buffer code by Hrvoje Niksic, c. 1997?
+   Coding conversion code rewritten by Martin Buchholz, early 2000,
+     based on design by Ben Wing.  */
 
 /* This file contains functions that work with buffer objects.
    Functions that manipulate a buffer's text, however, are not
@@ -569,6 +577,7 @@
 
   /* Put this in the alist of all live buffers.  */
   push_buffer_alist (name, buf);
+  note_object_created (buf);
 
   init_buffer_markers (b);
   init_buffer_syntax_cache (b);
@@ -577,6 +586,7 @@
   b->modeline_extent_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK,
 						   HASH_TABLE_EQ);
 
+
   return buf;
 }
 
@@ -1104,6 +1114,8 @@
   if (!BUFFER_LIVE_P (b))
     return Qnil;
 
+  check_allowed_operation (OPERATION_DELETE_OBJECT, buf, Qnil);
+
   /* Don't kill the minibuffer now current.  */
   if (EQ (buf, Vminibuffer_zero))
     return Qnil;
@@ -1299,6 +1311,8 @@
      won't be protected from GC. */
     nuke_all_buffer_slots (b, Qnil);
 
+    note_object_deleted (buf);
+
     unbind_to (speccount);
   }
   return Qt;
--- a/src/bytecode.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/bytecode.c	Tue May 28 08:45:36 2002 +0000
@@ -642,6 +642,10 @@
 	      specpdl_depth_counter++;
 
 	      symbol_ptr->value = new_value;
+
+#ifdef ERROR_CHECK_CATCH
+	      check_specbind_stack_sanity ();
+#endif
 	    }
 	  else
 	    specbind_magic (symbol, new_value);
@@ -1173,7 +1177,7 @@
     case Bcatch:
       {
 	Lisp_Object arg = POP;
-	TOP = internal_catch (TOP, Feval, arg, 0);
+	TOP = internal_catch (TOP, Feval, arg, 0, 0);
 	break;
       }
 
--- a/src/callint.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/callint.c	Tue May 28 08:45:36 2002 +0000
@@ -237,12 +237,8 @@
 quotify_args (Lisp_Object expr)
 {
   Lisp_Object tail;
-  Lisp_Cons *ptr;
-  for (tail = expr; CONSP (tail); tail = ptr->cdr)
-    {
-      ptr = XCONS (tail);
-      ptr->car = Fquote_maybe (ptr->car);
-    }
+  EXTERNAL_LIST_LOOP (tail, expr)
+    XSETCAR (tail, Fquote_maybe (XCAR (tail)));
   return expr;
 }
 
--- a/src/callproc.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/callproc.c	Tue May 28 08:45:36 2002 +0000
@@ -1,673 +0,0 @@
-/* Old synchronous subprocess invocation for XEmacs.
-   Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc.
-   Copyright (C) 2000, 2001, 2002 Ben Wing.
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Mule 2.0, FSF 19.30. */
-/* Partly sync'ed with 19.36.4 */
-
-
-/* #### Everything in this file should go.  As soon as I merge my
-   stderr-proc WS, it will.
-*/
-
-#include <config.h>
-#include "lisp.h"
-
-#include "buffer.h"
-#include "commands.h"
-#include "file-coding.h"
-#include "insdel.h"
-#include "lstream.h"
-#include "process.h"
-#include "sysdep.h"
-#include "window.h"
-
-#include "sysdir.h"
-#include "sysfile.h"
-#include "sysproc.h"
-#include "syssignal.h"
-#include "systime.h"
-#include "systty.h"
-
-/* True iff we are about to fork off a synchronous process or if we
-   are waiting for it.  */
-volatile int synch_process_alive;
-
-/* Nonzero => this is a string explaining death of synchronous subprocess.  */
-const char *synch_process_death;
-
-/* If synch_process_death is zero,
-   this is exit code of synchronous subprocess.  */
-int synch_process_retcode;
-
-/* Clean up when exiting Fcall_process_internal.
-   On Windows, delete the temporary file on any kind of termination.
-   On Unix, kill the process and any children on termination by signal.  */
-
-/* Nonzero if this is termination due to exit.  */
-static int call_process_exited;
-
-static Lisp_Object
-call_process_kill (Lisp_Object fdpid)
-{
-  Lisp_Object fd = Fcar (fdpid);
-  Lisp_Object pid = Fcdr (fdpid);
-
-  if (!NILP (fd))
-    retry_close (XINT (fd));
-
-  if (!NILP (pid))
-    EMACS_KILLPG (XINT (pid), SIGKILL);
-
-  synch_process_alive = 0;
-  return Qnil;
-}
-
-static Lisp_Object
-call_process_cleanup (Lisp_Object fdpid)
-{
-  int fd  = XINT (Fcar (fdpid));
-  int pid = XINT (Fcdr (fdpid));
-
-  if (!call_process_exited &&
-      EMACS_KILLPG (pid, SIGINT) == 0)
-  {
-    int speccount = specpdl_depth ();
-
-    record_unwind_protect (call_process_kill, fdpid);
-    /* #### "c-G" -- need non-consing Single-key-description */
-    message ("Waiting for process to die...(type C-g again to kill it instantly)");
-
-    wait_for_termination (pid);
-
-    /* "Discard" the unwind protect.  */
-    XCAR (fdpid) = Qnil;
-    XCDR (fdpid) = Qnil;
-    unbind_to (speccount);
-
-    message ("Waiting for process to die... done");
-  }
-  synch_process_alive = 0;
-  retry_close (fd);
-  return Qnil;
-}
-
-DEFUN ("old-call-process-internal", Fold_call_process_internal, 1, MANY, 0, /*
-Call PROGRAM synchronously in separate process, with coding-system specified.
-Arguments are
- (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS).
-The program's input comes from file INFILE (nil means `/dev/null').
-Insert output in BUFFER before point; t means current buffer;
- nil for BUFFER means discard it; 0 means discard and don't wait.
-If BUFFER is a string, then find or create a buffer with that name,
-then insert the output in that buffer, before point.
-BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
-REAL-BUFFER says what to do with standard output, as above,
-while STDERR-FILE says what to do with standard error in the child.
-STDERR-FILE may be nil (discard standard error output),
-t (mix it with ordinary output), or a file name string.
-
-Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
-Remaining arguments are strings passed as command arguments to PROGRAM.
-
-If BUFFER is 0, `call-process' returns immediately with value nil.
-Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
- or a signal description string.
-If you quit, the process is killed with SIGINT, or SIGKILL if you
- quit again.
-*/
-       (int nargs, Lisp_Object *args))
-{
-  /* This function can GC */
-  Lisp_Object infile, buffer, current_dir, display, path;
-  int fd[2];
-  int filefd;
-  int pid;
-  char buf[16384];
-  char *bufptr = buf;
-  int bufsize = 16384;
-  int speccount = specpdl_depth ();
-  struct gcpro gcpro1, gcpro2, gcpro3;
-  Intbyte **new_argv = alloca_array (Intbyte *, max (2, nargs - 2));
-
-  /* File to use for stderr in the child.
-     t means use same as standard output.  */
-  Lisp_Object error_file;
-
-  CHECK_STRING (args[0]);
-
-  error_file = Qt;
-
-#if defined (NO_SUBPROCESSES)
-  /* Without asynchronous processes we cannot have BUFFER == 0.  */
-  if (nargs >= 3 && !INTP (args[2]))
-    signal_error (Qunimplemented, "Operating system cannot handle asynchronous subprocesses", Qunbound);
-#endif /* NO_SUBPROCESSES */
-
-  /* Do all filename munging before building new_argv because GC in
-   *  Lisp code called by various filename-hacking routines might
-   *  relocate strings */
-  locate_file (Vexec_path, args[0], Vlisp_EXEC_SUFFIXES, &path, X_OK);
-
-  /* Make sure that the child will be able to chdir to the current
-     buffer's current directory, or its unhandled equivalent. [[ We
-     can't just have the child check for an error when it does the
-     chdir, since it's in a vfork. ]] -- not any more, we don't use
-     vfork. -ben
-
-     Note: These calls are spread out to insure that the return values
-     of the calls (which may be newly-created strings) are properly
-     GC-protected. */
-  {
-    struct gcpro ngcpro1, ngcpro2;
-    NGCPRO2 (current_dir, path);   /* Caller gcprotects args[] */
-    current_dir = current_buffer->directory;
-    /* If the current dir has no terminating slash, we'll get undesirable
-       results, so put the slash back. */
-    current_dir = Ffile_name_as_directory (current_dir);
-    current_dir = Funhandled_file_name_directory (current_dir);
-    current_dir = expand_and_dir_to_file (current_dir, Qnil);
-
-#if 0
-    /* This is in FSF, but it breaks everything in the presence of
-       ange-ftp-visited files, so away with it.  */
-    if (NILP (Ffile_accessible_directory_p (current_dir)))
-      signal_error (Qprocess_error, "Setting current directory",
-		    current_buffer->directory);
-#endif /* 0 */
-    NUNGCPRO;
-  }
-
-  GCPRO2 (current_dir, path);
-
-  if (nargs >= 2 && ! NILP (args[1]))
-    {
-      struct gcpro ngcpro1;
-      NGCPRO1 (current_buffer->directory);
-      infile = Fexpand_file_name (args[1], current_buffer->directory);
-      NUNGCPRO;
-      CHECK_STRING (infile);
-    }
-  else
-    infile = build_string (NULL_DEVICE);
-
-  UNGCPRO;
-
-  GCPRO3 (infile, current_dir, path);  	/* Fexpand_file_name might trash it */
-
-  if (nargs >= 3)
-    {
-      buffer = args[2];
-
-      /* If BUFFER is a list, its meaning is
-	 (BUFFER-FOR-STDOUT FILE-FOR-STDERR).  */
-      if (CONSP (buffer))
-	{
-	  if (CONSP (XCDR (buffer)))
-	    {
-	      Lisp_Object file_for_stderr = XCAR (XCDR (buffer));
-
-	      if (NILP (file_for_stderr) || EQ (Qt, file_for_stderr))
-		error_file = file_for_stderr;
-	      else
-		error_file = Fexpand_file_name (file_for_stderr, Qnil);
-	    }
-
-	  buffer = XCAR (buffer);
-	}
-
-      if (!(EQ (buffer, Qnil)
-	    || EQ (buffer, Qt)
-	    || ZEROP (buffer)))
-	{
-	  Lisp_Object spec_buffer = buffer;
-	  buffer = Fget_buffer_create (buffer);
-	  /* Mention the buffer name for a better error message.  */
-	  if (NILP (buffer))
-	    CHECK_BUFFER (spec_buffer);
-	  CHECK_BUFFER (buffer);
-	}
-    }
-  else
-    buffer = Qnil;
-
-  UNGCPRO;
-
-  display = ((nargs >= 4) ? args[3] : Qnil);
-
-  /* From here we assume we won't GC (unless an error is signaled). */
-  {
-    REGISTER int i;
-    for (i = 4; i < nargs; i++)
-      {
-	CHECK_STRING (args[i]);
-	new_argv[i - 3] = XSTRING_DATA (args[i]);
-      }
-  }
-  new_argv[max(nargs - 3,1)] = 0;
-
-  if (NILP (path))
-    signal_error (Qprocess_error, "Searching for program",
-		  Fcons (args[0], Qnil));
-  new_argv[0] = XSTRING_DATA (path);
-
-  filefd = qxe_open (XSTRING_DATA (infile), O_RDONLY | OPEN_BINARY, 0);
-  if (filefd < 0)
-    report_process_error ("Opening process input file", infile);
-
-  if (INTP (buffer))
-    {
-      fd[1] = qxe_open ((Intbyte *) NULL_DEVICE, O_WRONLY | OPEN_BINARY, 0);
-      fd[0] = -1;
-    }
-  else
-    {
-      pipe (fd);
-#if 0
-      /* Replaced by close_process_descs */
-      set_exclusive_use (fd[0]);
-#endif
-    }
-
-  {
-    REGISTER int fd1 = fd[1];
-    int fd_error = fd1;
-
-    /* Record that we're about to create a synchronous process.  */
-    synch_process_alive = 1;
-
-    /* These vars record information from process termination.
-       Clear them now before process can possibly terminate,
-       to avoid timing error if process terminates soon.  */
-    synch_process_death = 0;
-    synch_process_retcode = 0;
-
-    if (NILP (error_file))
-      fd_error = qxe_open ((Intbyte *) NULL_DEVICE, O_WRONLY | OPEN_BINARY);
-    else if (STRINGP (error_file))
-      {
-	fd_error = qxe_open (XSTRING_DATA (error_file),
-			     O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
-			     CREAT_MODE);
-      }
-
-    if (fd_error < 0)
-      {
-	int save_errno = errno;
-	retry_close (filefd);
-	retry_close (fd[0]);
-	if (fd1 >= 0)
-	  retry_close (fd1);
-	errno = save_errno;
-	report_process_error ("Cannot open", Fcons (error_file, Qnil));
-      }
-
-    pid = fork ();
-
-    if (pid == 0)
-      {
-	if (fd[0] >= 0)
-	  retry_close (fd[0]);
-	/* This is necessary because some shells may attempt to
-	   access the current controlling terminal and will hang
-	   if they are run in the background, as will be the case
-	   when XEmacs is started in the background.  Martin
-	   Buchholz observed this problem running a subprocess
-	   that used zsh to call gzip to uncompress an info
-	   file. */
-	disconnect_controlling_terminal ();
-	child_setup (filefd, fd1, fd_error, new_argv, current_dir);
-      }
-    if (fd_error >= 0)
-      retry_close (fd_error);
-
-    /* Close most of our fd's, but not fd[0]
-       since we will use that to read input from.  */
-    retry_close (filefd);
-    if (fd1 >= 0)
-      retry_close (fd1);
-  }
-
-  if (pid < 0)
-    {
-      int save_errno = errno;
-      if (fd[0] >= 0)
-	retry_close (fd[0]);
-      errno = save_errno;
-      report_process_error ("Doing fork", Qunbound);
-    }
-
-  if (INTP (buffer))
-    {
-      if (fd[0] >= 0)
-	retry_close (fd[0]);
-#if defined (NO_SUBPROCESSES)
-      /* If Emacs has been built with asynchronous subprocess support,
-	 we don't need to do this, I think because it will then have
-	 the facilities for handling SIGCHLD.  */
-      wait_without_blocking ();
-#endif /* NO_SUBPROCESSES */
-      return Qnil;
-    }
-
-  {
-    int nread;
-    int total_read = 0;
-    Lisp_Object instream;
-    struct gcpro ngcpro1;
-
-    /* Enable sending signal if user quits below.  */
-    call_process_exited = 0;
-
-    record_unwind_protect (call_process_cleanup,
-                           Fcons (make_int (fd[0]), make_int (pid)));
-
-    /* FSFmacs calls Fset_buffer() here.  We don't have to because
-       we can insert into buffers other than the current one. */
-    if (EQ (buffer, Qt))
-      buffer = wrap_buffer (current_buffer);
-    instream = make_filedesc_input_stream (fd[0], 0, -1, LSTR_ALLOW_QUIT);
-    instream =
-      make_coding_input_stream
-	(XLSTREAM (instream),
-	 get_coding_system_for_text_file (Vcoding_system_for_read, 1),
-	 CODING_DECODE, 0);
-    NGCPRO1 (instream);
-    while (1)
-      {
-	QUIT;
-	/* Repeatedly read until we've filled as much as possible
-	   of the buffer size we have.  But don't read
-	   less than 1024--save that for the next bufferfull.  */
-
-	nread = 0;
-	while (nread < bufsize - 1024)
-	  {
-	    Bytecount this_read
-	      = Lstream_read (XLSTREAM (instream), bufptr + nread,
-			      bufsize - nread);
-
-	    if (this_read < 0)
-	      goto give_up;
-
-	    if (this_read == 0)
-	      goto give_up_1;
-
-	    nread += this_read;
-	  }
-
-      give_up_1:
-
-	/* Now NREAD is the total amount of data in the buffer.  */
-	if (nread == 0)
-	  break;
-
-#if 0
-	/* [[check Vbinary_process_output]] */
-#endif
-
-	total_read += nread;
-
-	if (!NILP (buffer))
-	  buffer_insert_raw_string (XBUFFER (buffer), (Intbyte *) bufptr,
-				    nread);
-
-	/* Make the buffer bigger as we continue to read more data,
-	   but not past 64k.  */
-	if (bufsize < 64 * 1024 && total_read > 32 * bufsize)
-	  {
-	    bufsize *= 2;
-	    bufptr = (char *) ALLOCA (bufsize);
-	  }
-
-	if (!NILP (display) && INTERACTIVE)
-	  {
-	    redisplay ();
-	  }
-      }
-  give_up:
-    Lstream_close (XLSTREAM (instream));
-    NUNGCPRO;
-
-    QUIT;
-    /* Wait for it to terminate, unless it already has.  */
-    wait_for_termination (pid);
-
-    /* Don't kill any children that the subprocess may have left behind
-       when exiting.  */
-    call_process_exited = 1;
-    unbind_to (speccount);
-
-    if (synch_process_death)
-      return build_msg_string (synch_process_death);
-    return make_int (synch_process_retcode);
-  }
-}
-
-
-
-/* Move the file descriptor FD so that its number is not less than MIN. *
-   The original file descriptor remains open.  */
-static int
-relocate_fd (int fd, int min)
-{
-  if (fd >= min)
-    return fd;
-  else
-    {
-      int newfd = dup (fd);
-      if (newfd == -1)
-	{
-	  Intbyte *errmess;
-	  GET_STRERROR (errmess, errno);
-	  stderr_out ("Error while setting up child: %s\n", errmess);
-	  _exit (1);
-	}
-      return relocate_fd (newfd, min);
-    }
-}
-
-/* This is the last thing run in a newly forked inferior
-   either synchronous or asynchronous.
-   Copy descriptors IN, OUT and ERR
-   as descriptors STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO.
-   Initialize inferior's priority, pgrp, connected dir and environment.
-   then exec another program based on new_argv.
-
-   XEmacs: We've removed the SET_PGRP argument because it's already
-   done by the callers of child_setup.
-
-   CURRENT_DIR is an elisp string giving the path of the current
-   directory the subprocess should have.  Since we can't really signal
-   a decent error from within the child (not quite correct in
-   XEmacs?), this should be verified as an executable directory by the
-   parent.  */
-
-void
-child_setup (int in, int out, int err, Intbyte **new_argv,
-	     Lisp_Object current_dir)
-{
-  Intbyte **env;
-  Intbyte *pwd;
-
-#ifdef SET_EMACS_PRIORITY
-  if (emacs_priority != 0)
-    nice (- emacs_priority);
-#endif
-
-  /* Under Windows, we are not in a child process at all, so we should
-     not close handles inherited from the parent -- we are the parent
-     and doing so will screw up all manner of things!  Similarly, most
-     of the rest of the cleanup done in this function is not done
-     under Windows.
-
-     #### This entire child_setup() function is an utter and complete
-     piece of shit.  I would rewrite it, at the very least splitting
-     out the Windows and non-Windows stuff into two completely
-     different functions; but instead I'm trying to make it go away
-     entirely, using the Lisp definition in process.el.  What's left
-     is to fix up the routines in event-msw.c (and in event-Xt.c and
-     event-tty.c) to allow for stream devices to be handled correctly.
-     There isn't much to do, in fact, and I'll fix it shortly.  That
-     way, the Lisp definition can be used non-interactively too. */
-#if !defined (NO_SUBPROCESSES)
-  /* Close Emacs's descriptors that this process should not have.  */
-  close_process_descs ();
-#endif /* not NO_SUBPROCESSES */
-  close_load_descs ();
-
-  /* [[Note that use of alloca is always safe here.  It's obvious for systems
-     that do not have true vfork or that have true (stack) alloca.
-     If using vfork and C_ALLOCA it is safe because that changes
-     the superior's static variables as if the superior had done alloca
-     and will be cleaned up in the usual way.]] -- irrelevant because
-     XEmacs does not use vfork. */
-  {
-    REGISTER Bytecount i;
-
-    i = XSTRING_LENGTH (current_dir);
-    pwd = alloca_array (Intbyte, i + 6);
-    memcpy (pwd, "PWD=", 4);
-    memcpy (pwd + 4, XSTRING_DATA (current_dir), i);
-    i += 4;
-    if (!IS_DIRECTORY_SEP (pwd[i - 1]))
-      pwd[i++] = DIRECTORY_SEP;
-    pwd[i] = 0;
-
-    /* [[We can't signal an Elisp error here; we're in a vfork.  Since
-       the callers check the current directory before forking, this
-       should only return an error if the directory's permissions
-       are changed between the check and this chdir, but we should
-       at least check.]] -- irrelevant because XEmacs does not use vfork. */
-    if (qxe_chdir (pwd + 4) < 0)
-      {
-	/* Don't report the chdir error, or ange-ftp.el doesn't work. */
-	/* (FSFmacs does _exit (errno) here.) */
-	pwd = 0;
-      }
-    else
-      {
-	/* Strip trailing "/".  Cretinous *[]&@$#^%@#$% Un*x */
-	/* leave "//" (from FSF) */
-	while (i > 6 && IS_DIRECTORY_SEP (pwd[i - 1]))
-	  pwd[--i] = 0;
-      }
-  }
-
-  /* Set `env' to a vector of the strings in Vprocess_environment.  */
-  /* + 2 to include PWD and terminating 0.  */
-  env = alloca_array (Intbyte *, XINT (Flength (Vprocess_environment)) + 2);
-  {
-    REGISTER Lisp_Object tail;
-    Intbyte **new_env = env;
-
-    /* If we have a PWD envvar and we know the real current directory,
-       pass one down, but with corrected value.  */
-    if (pwd && egetenv ("PWD"))
-      *new_env++ = pwd;
-
-    /* Copy the Vprocess_environment strings into new_env.  */
-    for (tail = Vprocess_environment;
-	 CONSP (tail) && STRINGP (XCAR (tail));
-	 tail = XCDR (tail))
-      {
-      Intbyte **ep = env;
-      Intbyte *envvar = XSTRING_DATA (XCAR (tail));
-
-      /* See if envvar duplicates any string already in the env.
-	 If so, don't put it in.
-	 When an env var has multiple definitions,
-	 we keep the definition that comes first in process-environment.  */
-      for (; ep != new_env; ep++)
-	{
-	  Intbyte *p = *ep, *q = envvar;
-	  while (1)
-	    {
-	      if (*q == 0)
-		/* The string is malformed; might as well drop it.  */
-		goto duplicate;
-	      if (*q != *p)
-		break;
-	      if (*q == '=')
-		goto duplicate;
-	      p++, q++;
-	    }
-	}
-      if (pwd && !qxestrncmp ((Intbyte *) "PWD=", envvar, 4))
-	{
-	  *new_env++ = pwd;
-	  pwd = 0;
-	}
-      else
-        *new_env++ = envvar;
-
-    duplicate: ;
-    }
-
-    *new_env = 0;
-  }
-
-  /* Make sure that in, out, and err are not actually already in
-     descriptors zero, one, or two; this could happen if Emacs is
-     started with its standard in, out, or error closed, as might
-     happen under X.  */
-  in  = relocate_fd (in,  3);
-  out = relocate_fd (out, 3);
-  err = relocate_fd (err, 3);
-
-  /* Set the standard input/output channels of the new process.  */
-  retry_close (STDIN_FILENO);
-  retry_close (STDOUT_FILENO);
-  retry_close (STDERR_FILENO);
-
-  dup2 (in,  STDIN_FILENO);
-  dup2 (out, STDOUT_FILENO);
-  dup2 (err, STDERR_FILENO);
-
-  retry_close (in);
-  retry_close (out);
-  retry_close (err);
-
-  /* I can't think of any reason why child processes need any more
-     than the standard 3 file descriptors.  It would be cleaner to
-     close just the ones that need to be, but the following brute
-     force approach is certainly effective, and not too slow. */
-  {
-    int fd;
-    for (fd=3; fd<=64; fd++)
-      retry_close (fd);
-  }
-
-#ifdef vipc
-  something missing here;
-#endif /* vipc */
-
-  /* we've wrapped execve; it translates its arguments */
-  qxe_execve (new_argv[0], new_argv, env);
-
-  stdout_out ("Can't exec program %s\n", new_argv[0]);
-  _exit (1);
-}
-
-void
-syms_of_callproc (void)
-{
-  DEFSUBR (Fold_call_process_internal);
-}
--- a/src/chartab.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/chartab.c	Tue May 28 08:45:36 2002 +0000
@@ -1737,15 +1737,15 @@
   if (NILP (category_set2))
     return default_result;
 
-  for (; CONSP (tail); tail = XCONS (tail)->cdr)
+  for (; CONSP (tail); tail = XCDR (tail))
     {
-      Lisp_Object elt = XCONS(tail)->car;
+      Lisp_Object elt = XCAR (tail);
 
       if (CONSP (elt)
-	  && CATEGORYP (XCONS (elt)->car)
-	  && CATEGORYP (XCONS (elt)->cdr)
-	  && CATEGORY_MEMBER (XCHAR (XCONS (elt)->car), category_set1)
-	  && CATEGORY_MEMBER (XCHAR (XCONS (elt)->cdr), category_set2))
+	  && CATEGORYP (XCAR (elt))
+	  && CATEGORYP (XCDR (elt))
+	  && CATEGORY_MEMBER (XCHAR (XCAR (elt)), category_set1)
+	  && CATEGORY_MEMBER (XCHAR (XCDR (elt)), category_set2))
 	return !default_result;
     }
   return default_result;
--- a/src/cmdloop.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/cmdloop.c	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,6 @@
 /* Editor command loop.
    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1996, 2001 Ben Wing.
+   Copyright (C) 1995, 1996, 2001, 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -285,7 +285,7 @@
      Otherwise, this function will return normally when all command-
      line arguments have been processed, the user's initialization
      file has been read in, and the first frame has been created. */
-  internal_catch (Qtop_level, top_level_1, Qnil, 0);
+  internal_catch (Qtop_level, top_level_1, Qnil, 0, 0);
 
   /* If an error occurred during startup and the initial console
      wasn't created, then die now (the error was already printed out
@@ -305,7 +305,7 @@
       MARK_MODELINE_CHANGED;
       /* Now invoke the command loop.  It never returns; however, a
 	 throw to 'top-level will place us at the end of this loop. */
-      internal_catch (Qtop_level, command_loop_2, Qnil, 0);
+      internal_catch (Qtop_level, command_loop_2, Qnil, 0, 0);
       /* #### wrong with selected-console? */
       /* We don't actually call clear_echo_area() here, partially
 	 at least because that runs Lisp code and it may be unsafe
@@ -368,7 +368,7 @@
   specbind (Qstandard_output, Qt);
   specbind (Qstandard_input, Qt);
 
-  val = internal_catch (Qexit, command_loop_2, Qnil, 0);
+  val = internal_catch (Qexit, command_loop_2, Qnil, 0, 0);
 
   if (EQ (val, Qt))
     /* Turn abort-recursive-edit into a quit. */
@@ -436,7 +436,7 @@
     Fcommand_loop_1 ();
   else
     internal_catch (Qtop_level,
-                    cold_load_command_loop, Qnil, 0);
+                    cold_load_command_loop, Qnil, 0, 0);
   goto loop;
   return Qnil;
 }
@@ -570,18 +570,11 @@
 	  int count = begin_dont_check_for_quit ();
 	  Fsit_for (make_int (2), Qnil);
 	  clear_echo_area (selected_frame (), Qnil, 0);
+	  Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
 	  unbind_to (count);
 	}
 
       Fnext_event (event, Qnil);
-      /* If ^G was typed while emacs was reading input from the user, then
-	 Fnext_event() will have read it as a normal event and
-	 next_event_internal() will have set Vquit_flag.  We reset this
-	 so that the ^G is treated as just another key.  This is strange,
-	 but it is what emacs 18 did.
-
-	 Do not call check_quit() here. */
-      Vquit_flag = Qnil;
       Fdispatch_event (event);
 
       if (!was_locked)
--- a/src/console-msw.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/console-msw.h	Tue May 28 08:45:36 2002 +0000
@@ -341,20 +341,16 @@
 					Lisp_Object object);
 Lisp_Object mswindows_cancel_dispatch_event (Lisp_Event *event);
 Lisp_Object mswindows_pump_outstanding_events (void);
-Lisp_Object mswindows_protect_modal_loop (Lisp_Object (*bfun)
+Lisp_Object mswindows_protect_modal_loop (const char *error_string,
+					  Lisp_Object (*bfun)
 					  (Lisp_Object barg),
-					  Lisp_Object barg);
+					  Lisp_Object barg, int flags);
 void mswindows_unmodalize_signal_maybe (void);
 
 COLORREF mswindows_string_to_color (const Intbyte *name);
-USID emacs_mswindows_create_stream_pair (void *inhandle, void *outhandle,
-					 Lisp_Object *instream,
-					 Lisp_Object *outstream,
-					 int flags);
-USID emacs_mswindows_delete_stream_pair (Lisp_Object instream,
-					 Lisp_Object outstream);
 
 #ifdef HAVE_WIN32_PROCESSES
+HANDLE get_nt_process_handle_only_first_time (Lisp_Process *p);
 HANDLE get_nt_process_handle (Lisp_Process *p);
 #endif
 
--- a/src/console.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/console.c	Tue May 28 08:45:36 2002 +0000
@@ -21,7 +21,10 @@
 
 /* Synched up with: Not in FSF. */
 
-/* Written by Ben Wing. */
+/* Written by Ben Wing, late 1995?.
+   suspend-console, set-input-mode, and related stuff largely based on
+   existing code.
+*/
 
 #include <config.h>
 #include "lisp.h"
@@ -488,6 +491,7 @@
 
   /* Do it this way so that the console list is in order of creation */
   Vconsole_list = nconc2 (Vconsole_list, Fcons (console, Qnil));
+  note_object_created (console);
 
   if (CONMETH_OR_GIVEN (con, initially_selected_for_input, (con), 0))
     event_stream_select_console (con);
@@ -603,6 +607,10 @@
     return;
 
   console = wrap_console (con);
+
+  if (!force)
+    check_allowed_operation (OPERATION_DELETE_OBJECT, console, Qnil);
+
   GCPRO1 (console);
 
   if (!called_from_kill_emacs)
@@ -726,6 +734,7 @@
      them. */
   nuke_all_console_slots (con, Qnil);
   con->conmeths = dead_console_methods;
+  note_object_deleted (console);
 
   UNGCPRO;
 }
--- a/src/device-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/device-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -871,12 +871,12 @@
   {
     Lisp_Devmode *ldm = decode_devmode (device);
     PAGESETUPDLGW pd;
-    TCHAR measure[2*MAX_XETCHAR_SIZE];
+    Extbyte measure[2 * MAX_XETCHAR_SIZE];
     int data;
 
     qxeGetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IMEASURE,
-		      measure, sizeof (measure)/MAX_XETCHAR_SIZE);
-    data = qxestrcmp (measure, XETEXT ("0"));
+		      measure, sizeof (measure) / XETCHAR_SIZE);
+    data = xetcscmp (measure, XETEXT ("0"));
 
     memset (&pd, 0, sizeof (pd));
     pd.lStructSize = sizeof (pd);
--- a/src/device-x.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/device-x.c	Tue May 28 08:45:36 2002 +0000
@@ -138,15 +138,16 @@
 # define FALLBACK_RESOURCE_NAME "infodock"
 #endif
 
-  if (!d) {
-    /* This isn't one of our displays.  Let's crash? */
-    stderr_out
-      ("\n%s: Fatal X Condition.  Asked about display we don't own: \"%s\"\n",
-       (STRINGP (Vinvocation_name) ?
-	(char *) XSTRING_DATA (Vinvocation_name) : FALLBACK_RESOURCE_NAME),
-       DisplayString (dpy) ? DisplayString (dpy) : "???");
-    abort();
-  }
+  if (!d)
+    {
+      /* This isn't one of our displays.  Let's crash? */
+      stderr_out
+	("\n%s: Fatal X Condition.  Asked about display we don't own: \"%s\"\n",
+	 (STRINGP (Vinvocation_name) ?
+	  (char *) XSTRING_DATA (Vinvocation_name) : FALLBACK_RESOURCE_NAME),
+	 DisplayString (dpy) ? DisplayString (dpy) : "???");
+      abort();
+    }
 
 #undef FALLBACK_RESOURCE_NAME
 
@@ -1048,6 +1049,8 @@
     }
   else
     {
+      int depth;
+
 #ifdef EXTERNAL_WIDGET
       struct frame *f;
       struct device *d = get_device_from_display (disp);
@@ -1083,11 +1086,14 @@
       }
 #endif /* EXTERNAL_WIDGET */
 
+      /* #### this should issue a warning instead of outputting to stderr */
+      depth = begin_dont_check_for_quit ();
       stderr_out ("\n%s: ",
 		  (STRINGP (Vinvocation_name)
 		   ? (char *) XSTRING_DATA (Vinvocation_name)
 		   : "xemacs"));
       XmuPrintDefaultErrorMessage (disp, event, stderr);
+      unbind_to (depth);
     }
   return 0;
 }
@@ -1156,6 +1162,7 @@
 
   if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
     {
+      int depth = begin_dont_check_for_quit ();
       /* We're going down. */
       Intbyte *errmess;
       GET_STRERROR (errmess, errno);
@@ -1169,6 +1176,7 @@
 		  NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
 		  QLength (disp));
       /* assert (!_Xdebug); */
+      unbind_to (depth);
     }
   else
     {
--- a/src/device.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/device.c	Tue May 28 08:45:36 2002 +0000
@@ -1,7 +1,7 @@
 /* Generic device functions.
    Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1996, 2002 Ben Wing
+   Copyright (C) 1995, 1996, 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -22,8 +22,10 @@
 
 /* Synched up with: Not in FSF. */
 
-/* Original version by Chuck Thompson;
-   rewritten and expanded by Ben Wing. */
+/* Written by Ben Wing, late 1995?
+   Based on prototype by Chuck Thompson.
+   device-system-metric stuff added 1998? by Kirill Katsnelson.
+*/
 
 #include <config.h>
 #include "lisp.h"
@@ -155,6 +157,8 @@
   struct device *d = alloc_lcrecord_type (struct device, &lrecord_device);
   struct gcpro gcpro1;
 
+  zero_lcrecord (d);
+
   device = wrap_device (d);
   GCPRO1 (device);
 
@@ -567,6 +571,8 @@
 
   /* Do it this way so that the device list is in order of creation */
   con->device_list = nconc2 (con->device_list, Fcons (device, Qnil));
+  note_object_created (device);
+
   RESET_CHANGED_SET_FLAGS;
   if (NILP (Vdefault_device) || DEVICE_STREAM_P (XDEVICE (Vdefault_device)))
     Vdefault_device = device;
@@ -687,6 +693,10 @@
     return;
 
   device = wrap_device (d);
+
+  if (!force)
+    check_allowed_operation (OPERATION_DELETE_OBJECT, device, Qnil);
+
   GCPRO1 (device);
 
   c = XCONSOLE (DEVICE_CONSOLE (d));
@@ -808,6 +818,7 @@
      them. */
   nuke_all_device_slots (d, Qnil);
   d->devmeths = dead_console_methods;
+  note_object_deleted (device);
 
   UNGCPRO;
 }
@@ -1212,7 +1223,11 @@
 call_critical_lisp_code (struct device *d, Lisp_Object function,
 			 Lisp_Object object)
 {
+  /* This function cannot GC */
   int count = begin_gc_forbidden ();
+  struct gcpro gcpro1;
+  Lisp_Object args[3];
+
   specbind (Qinhibit_quit, Qt);
   record_unwind_protect (unlock_device, wrap_device (d));
 
@@ -1225,12 +1240,17 @@
      */
   LOCK_DEVICE (d);
 
-  /* But it's useful to have an error handler; otherwise an infinite
+  args[0] = Qreally_early_error_handler;
+  args[1] = function;
+  args[2] = object;
+
+  GCPRO1_ARRAY (args, 3);
+
+  /* It's useful to have an error handler; otherwise an infinite
      loop may result. */
-  if (!NILP (object))
-    call1_with_handler (Qreally_early_error_handler, function, object);
-  else
-    call0_with_handler (Qreally_early_error_handler, function);
+  Fcall_with_condition_handler (!NILP (object) ? 3 : 2, args);
+
+  UNGCPRO;
 
   unbind_to (count);
 }
--- a/src/dialog-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/dialog-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -220,9 +220,8 @@
 	else
 	  mswindows_enqueue_misc_user_event (did->frame, Qrun_hooks,
 					     Qmenu_no_selection_hook);
-	/* #### need to error-protect!  will do so when i merge in
-	   my stderr-proc ws */
-	va_run_hook_with_args (Qdelete_dialog_box_hook, 1, data);
+	va_run_hook_with_args_trapping_problems
+	  (0, Qdelete_dialog_box_hook, 1, data, 0);
 
 	DestroyWindow (hwnd);
       }
--- a/src/dialog-x.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/dialog-x.c	Tue May 28 08:45:36 2002 +0000
@@ -1,7 +1,7 @@
 /* Implements elisp-programmable dialog boxes -- X interface.
    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
    Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
-   Copyright (C) 2000 Ben Wing.
+   Copyright (C) 2000, 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -126,7 +126,7 @@
   int allow_text_p = 1;
   widget_value *prev = 0, *kids = 0;
   int n = 0;
-  int count = specpdl_depth ();
+  int count;
   Lisp_Object wv_closure, gui_item;
   Lisp_Object question = Qnil;
   Lisp_Object title    = Qnil;  /* #### currently unused */
@@ -162,7 +162,7 @@
      the same as in menu_item_descriptor_to_widget_value(); see
      the large comment above that function. */
 
-  begin_gc_forbidden ();
+  count = begin_gc_forbidden ();
 
   kids = prev = xmalloc_widget_value ();
 
--- a/src/dired.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/dired.c	Tue May 28 08:45:36 2002 +0000
@@ -284,7 +284,7 @@
       qxe_closedir (d);
       free_opaque_ptr (obj);
     }
-  free_cons (XCONS (locative));
+  free_cons (locative);
   return Qnil;
 }
 
@@ -593,7 +593,7 @@
   if (! NILP (XCAR (cache_incomplete_p)))
     free_user_cache (&user_cache);
 
-  free_cons (XCONS (cache_incomplete_p));
+  free_cons (cache_incomplete_p);
 
   return Qnil;
 }
--- a/src/editfns.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/editfns.c	Tue May 28 08:45:36 2002 +0000
@@ -311,8 +311,9 @@
 {
   struct buffer *b;
 
-  /* #### Huh?  --hniksic */
-  /*if (preparing_for_armageddon) return Qnil;*/
+  /* There was once a check for preparing_for_armageddon here, which
+     did nothing; perhaps a left-over from FSF Emacs.  Obviously
+     incorrect. --ben */
 
 #ifdef ERROR_CHECK_TEXT
   assert (XINT (Fpoint (Qnil)) ==
@@ -362,7 +363,7 @@
      for free in terms of GC junk. */
   free_marker (XMARKER (XCAR (info)));
   free_marker (XMARKER (XCDR (info)));
-  free_cons (XCONS (info));
+  free_cons (info);
   return Qnil;
 }
 
@@ -2105,8 +2106,8 @@
      for free in terms of GC junk. */
   free_marker (XMARKER (XCAR (markers)));
   free_marker (XMARKER (XCDR (markers)));
-  free_cons (XCONS (markers));
-  free_cons (XCONS (data));
+  free_cons (markers);
+  free_cons (data);
 
   return Qnil;
 }
--- a/src/emacs.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/emacs.c	Tue May 28 08:45:36 2002 +0000
@@ -376,8 +376,6 @@
 /* Some FSF junk with running_asynch_code, to preserve the match
    data.  Not necessary because we don't call process filters
    asynchronously (i.e. from within QUIT). */
-/* #### Delete this when merging the rest of my code */
-int running_asynch_code;
 
 /* If non-zero, a window-system was specified on the command line. */
 int display_arg;
@@ -1189,9 +1187,6 @@
       syms_of_buffer ();
       syms_of_bytecode ();
       syms_of_callint ();
-#ifndef WIN32_NATIVE
-      syms_of_callproc ();
-#endif
       syms_of_casefiddle ();
       syms_of_casetab ();
       syms_of_chartab ();
@@ -1614,7 +1609,7 @@
 
       lstream_type_create ();
       lstream_type_create_file_coding ();
-#if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
+#if defined (HAVE_MS_WINDOWS) && !defined (HAVE_MSG_SELECT)
       lstream_type_create_mswindows_selectable ();
 #endif
 
--- a/src/emodules.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/emodules.c	Tue May 28 08:45:36 2002 +0000
@@ -256,7 +256,7 @@
     {
       if (INTP (XCAR (upto)))
         l = XINT (XCAR (upto));
-      free_cons (XCONS (upto));
+      free_cons (upto);
     }
   else
     l = XINT (upto);
--- a/src/eval.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/eval.c	Tue May 28 08:45:36 2002 +0000
@@ -22,6 +22,119 @@
 
 /* Synched up with: FSF 19.30 (except for Fsignal), Mule 2.0. */
 
+/* Authorship:
+
+   Based on code from pre-release FSF 19, c. 1991.
+   Some work by Richard Mlynarik long ago (c. 1993?) --
+     added call-with-condition-handler; synch. up to released FSF 19.7
+     for lemacs 19.8.  some signal changes.
+   Various work by Ben Wing, 1995-1996:
+     added all stuff dealing with trapping errors, suspended-errors, etc.
+     added most Fsignal front ends.
+     added warning code.
+     reworked the Fsignal code and synched the rest up to FSF 19.30.
+   Some changes by Martin Buchholz c. 1999?
+     e.g. PRIMITIVE_FUNCALL macros.
+   New call_trapping_problems code and large comments below
+     by Ben Wing, Mar-Apr 2000.
+*/
+
+/* This file has been Mule-ized. */
+
+/* What is in this file?
+
+   This file contains the engine for the ELisp interpreter in XEmacs.
+   The engine does the actual work of implementing function calls,
+   form evaluation, non-local exits (catch, throw, signal,
+   condition-case, call-with-condition-handler), unwind-protects,
+   dynamic bindings, let constructs, backtraces, etc.  You might say
+   that this module is the very heart of XEmacs, and everything else
+   in XEmacs is merely an auxiliary module implementing some specific
+   functionality that may be called from the heart at an appropriate
+   time.
+
+   The only exception is the alloc.c module, which implements the
+   framework upon which this module (eval.c) works.  alloc.c works
+   with creating the actual Lisp objects themselves and garbage
+   collecting them as necessary, preseting a nice, high-level
+   interface for object creation, deletion, access, and modification.
+
+   The only other exception that could be cited is the event-handling
+   module in event-stream.c.  From its perspective, it is also the
+   heart of XEmacs, and controls exactly what gets done at what time.
+   From its perspective, eval.c is merely one of the auxiliary modules
+   out there that can be invoked by event-stream.c.
+
+   Although the event-stream-centric view is a convenient fiction that
+   makes sense particularly from the user's perspective and from the
+   perspective of time, the engine-centric view is actually closest to
+   the truth, because anywhere within the event-stream module, you are
+   still somewhere in a Lisp backtrace, and event-loops are begun by
+   functions such as `command-loop-1', a Lisp function.
+
+   As the Lisp engine is doing its thing, it maintains the state of
+   the engine primarily in five list-like items, with are:
+
+   -- the backtrace list
+   -- the catchtag list
+   -- the condition-handler list
+   -- the specbind list
+   -- the GCPRO list.
+
+   These are described in detail in the next comment.
+
+   --ben
+ */
+
+/* Note that there are five separate lists used to maintain state in
+   the evaluator.  All of them conceptually are stacks (last-in,
+   first-out).  All non-local exits happen ultimately through the
+   catch/throw mechanism, which uses one of the five lists (the
+   catchtag list) and records the current state of the others in each
+   frame of the list (some other information is recorded and restored
+   as well, such as the current eval depth), so that all the state of
+   the evaluator is restored properly when a non-local exit occurs.
+   (Note that the current state of the condition-handler list is not
+   recorded in the catchtag list.  Instead, when a condition-case or
+   call-with-condition-handler is set up, it installs an
+   unwind-protect on the specbind list to restore the appropriate
+   setting for the condition-handler list.  During the course of
+   handling the non-local exit, all entries on the specbind list that
+   are past the location stored in the catch frame are "unwound"
+   (i.e. variable bindings are restored and unwind-protects are
+   executed), so the condition-handler list gets reset properly.
+
+   The five lists are
+
+   1. The backtrace list, which is chained through `struct backtrace's
+      declared in the stack frames of various primitives, and keeps
+      track of all Lisp function call entries and exits.
+   2. The catchtag list, which is chained through `struct catchtag's
+      declared in the stack frames of internal_catch and condition_case_1,
+      and keeps track of information needed to reset the internal state
+      of the evaluator to the state that was current when the catch or
+      condition-case were established, in the event of a non-local exit.
+   3. The condition-handler list, which is a simple Lisp list with new
+      entries consed onto the front of the list.  It records condition-cases
+      and call-with-condition-handlers established either from C or from
+      Lisp.  Unlike with the other lists (but similar to everything else
+      of a similar nature in the rest of the C and Lisp code), it takes care
+      of restoring itself appropriately in the event of a non-local exit
+      through the use of the unwind-protect mechanism.
+   4. The specbind list, which is a contiguous array of `struct specbinding's,
+      expanded as necessary using realloc().  It holds dynamic variable
+      bindings (the only kind we currently have in ELisp) and unwind-protects.
+   5. The GCPRO list, which is chained through `struct gcpro's declared in
+      the stack frames of any functions that need to GC-protect Lisp_Objects
+      declared on the stack.  This is one of the most fragile areas of the
+      entire scheme -- you must not forget to UNGCPRO at the end of your
+      function, you must make sure you GCPRO in many circumstances you don't
+      think you have to, etc.  See the internals manual for more information
+      about this.
+
+      --ben
+*/
+
 #include <config.h>
 #include "lisp.h"
 
@@ -30,7 +143,11 @@
 #include "bytecode.h"
 #include "buffer.h"
 #include "console.h"
+#include "device.h"
+#include "frame.h"
+#include "lstream.h"
 #include "opaque.h"
+#include "window.h"
 
 struct backtrace *backtrace_list;
 
@@ -66,6 +183,7 @@
 /* If subrs take more than 8 arguments, more cases need to be added
    to this switch.  (But wait - don't do it - if you really need
    a SUBR with more than 8 arguments, use max_args == MANY.
+   Or better, considering using a property list as one of your args.
    See the DEFUN macro in lisp.h)  */
 #define PRIMITIVE_FUNCALL(rv, fn, av, ac) do {			\
   void (*PF_fn)(void) = (void (*)(void)) fn;			\
@@ -89,15 +207,22 @@
 
 
 /* This is the list of current catches (and also condition-cases).
-   This is a stack: the most recent catch is at the head of the
-   list.  Catches are created by declaring a 'struct catchtag'
-   locally, filling the .TAG field in with the tag, and doing
-   a setjmp() on .JMP.  Fthrow() will store the value passed
-   to it in .VAL and longjmp() back to .JMP, back to the function
-   that established the catch.  This will always be either
-   internal_catch() (catches established internally or through
-   `catch') or condition_case_1 (condition-cases established
-   internally or through `condition-case').
+   This is a stack: the most recent catch is at the head of the list.
+   The list is threaded through the stack frames of the C functions
+   that set up the catches; this is similar to the way the GCPRO list
+   is handled, but different from the condition-handler list (which is
+   a simple Lisp list) and the specbind stack, which is a contiguous
+   array of `struct specbinding's, grown (using realloc()) as
+   necessary. (Note that all four of these lists behave as a stacks.)
+
+   Catches are created by declaring a 'struct catchtag' locally,
+   filling the .TAG field in with the tag, and doing a setjmp() on
+   .JMP.  Fthrow() will store the value passed to it in .VAL and
+   longjmp() back to .JMP, back to the function that established the
+   catch.  This will always be either internal_catch() (catches
+   established internally or through `catch') or condition_case_1
+   (condition-cases established internally or through
+   `condition-case').
 
    The catchtag also records the current position in the
    call stack (stored in BACKTRACE_LIST), the current position
@@ -105,10 +230,14 @@
    unwind-protects), the value of LISP_EVAL_DEPTH, and the
    current position in the GCPRO stack.  All of these are
    restored by Fthrow().
-   */
+  */
 
 struct catchtag *catchlist;
 
+/* A special tag that can be used internally from C code to catch
+   every attempt to throw past this level. */
+Lisp_Object Vcatch_everything_tag;
+
 Lisp_Object Qautoload, Qmacro, Qexit;
 Lisp_Object Qinteractive, Qcommandp, Qdefun, Qprogn, Qvalues;
 Lisp_Object Vquit_flag, Vinhibit_quit;
@@ -123,30 +252,23 @@
 Lisp_Object Vpending_warnings, Vpending_warnings_tail;
 Lisp_Object Qif;
 
-/* Records whether we want errors to occur.  This will be a boolean,
-   nil (errors OK) or t (no errors).  If t, an error will cause a
-   throw to Qunbound_suspended_errors_tag.
-
-   See call_with_suspended_errors(). */
-Lisp_Object Vcurrent_error_state;
-
-/* Current warning class when warnings occur, or nil for no warnings.
-   Only meaningful when Vcurrent_error_state is non-nil.
-   See call_with_suspended_errors(). */
-Lisp_Object Vcurrent_warning_class;
-
-/* Current warning level when warnings occur, or nil for no warnings.
-   Only meaningful when Vcurrent_error_state is non-nil.
-   See call_with_suspended_errors(). */
-Lisp_Object Vcurrent_warning_level;
+/* Flags specifying which operations are currently inhibited. */
+int inhibit_flags;
+
+/* Buffers, frames, windows, devices, and consoles created since most
+   recent active
+   call_trapping_problems (INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION).
+*/
+Lisp_Object Vdeletable_permanent_display_objects;
+
+/* Buffers created since most recent active
+   call_trapping_problems (INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION). */
+Lisp_Object Vmodifiable_buffers;
 
 /* Minimum level at which warnings are logged.  Below this, they're ignored
    entirely -- not even generated. */
 Lisp_Object Vlog_warning_minimum_level;
 
-/* Special catch tag used in call_with_suspended_errors(). */
-Lisp_Object Qunbound_suspended_errors_tag;
-
 /* Non-nil means record all fset's and provide's, to be undone
    if the file being autoloaded is not fully loaded.
    They are recorded by being consed onto the front of Vautoload_queue:
@@ -225,48 +347,64 @@
 /* Function to call to invoke the debugger */
 Lisp_Object Vdebugger;
 
-/* Chain of condition handlers currently in effect.
-   The elements of this chain are contained in the stack frames
-   of Fcondition_case and internal_condition_case.
-   When an error is signaled (by calling Fsignal, below),
-   this chain is searched for an element that applies.
+/* List of condition handlers currently in effect.
+   The elements of this lists were at one point in the past
+   threaded through the stack frames of Fcondition_case and
+   related functions, but now are stored separately in a normal
+   stack.  When an error is signaled (by calling Fsignal, below),
+   this list is searched for an element that applies.
 
    Each element of this list is one of the following:
 
-   A list of a handler function and possibly args to pass to
-   the function.  This is a handler established with
-   `call-with-condition-handler' (q.v.).
-
-   A list whose car is Qunbound and whose cdr is Qt.
-   This is a special condition-case handler established
-   by C code with condition_case_1().  All errors are
-   trapped; the debugger is not invoked even if
-   `debug-on-error' was set.
-
-   A list whose car is Qunbound and whose cdr is Qerror.
-   This is a special condition-case handler established
-   by C code with condition_case_1().  It is like Qt
-   except that the debugger is invoked normally if it is
-   called for.
-
-   A list whose car is Qunbound and whose cdr is a list
-   of lists (CONDITION-NAME BODY ...) exactly as in
-   `condition-case'.  This is a normal `condition-case'
-   handler.
-
-   Note that in all cases *except* the first, there is a
-   corresponding catch, whose TAG is the value of
-   Vcondition_handlers just after the handler data just
-   described is pushed onto it.  The reason is that
-   `condition-case' handlers need to throw back to the
-   place where the handler was installed before invoking
-   it, while `call-with-condition-handler' handlers are
-   invoked in the environment that `signal' was invoked
-   in.
-*/
+   -- A list of a handler function and possibly args to pass to the
+   function.  This is a handler established with the Lisp primitive
+   `call-with-condition-handler' or related C function
+   call_with_condition_handler():
+
+     If the handler function is an opaque ptr object, it is a handler
+     that was established in C using call_with_condition_handler(),
+     and the contents of the object are a function pointer which takes
+     three arguments, the signal name and signal data (same arguments
+     passed to `signal') and a third Lisp_Object argument, specified
+     in the call to call_with_condition_handler() and stored as the
+     second element of the list containing the handler functionl.
+  
+     If the handler function is a regular Lisp_Object, it is a handler
+     that was established using `call-with-condition-handler'.
+     Currently there are no more arguments in the list containing the
+     handler function, and only one argument is passed to the handler
+     function: a cons of the signal name and signal data arguments
+     passed to `signal'.
+  
+   -- A list whose car is Qunbound and whose cdr is Qt.  This is a
+   special condition-case handler established by C code with
+   condition_case_1().  All errors are trapped; the debugger is not
+   invoked even if `debug-on-error' was set.
+
+   -- A list whose car is Qunbound and whose cdr is Qerror.  This is a
+   special condition-case handler established by C code with
+   condition_case_1().  It is like Qt except that the debugger is
+   invoked normally if it is called for.
+
+   -- A list whose car is Qunbound and whose cdr is a list of lists
+   (CONDITION-NAME BODY ...) exactly as in `condition-case'.  This is
+   a normal `condition-case' handler.
+
+   Note that in all cases *except* the first, there is a corresponding
+   catch, whose TAG is the value of Vcondition_handlers just after the
+   handler data just described is pushed onto it.  The reason is that
+   `condition-case' handlers need to throw back to the place where the
+   handler was installed before invoking it, while
+   `call-with-condition-handler' handlers are invoked in the
+   environment that `signal' was invoked in.  */
+
+
 static Lisp_Object Vcondition_handlers;
 
-
+/* I think we should keep this enabled all the time, not just when
+   error checking is enabled, because if one of these puppies pops up,
+   it will trash the stack if not caught, making it that much harder to
+   debug.  It doesn't cause speed loss. */
 #define DEFEND_AGAINST_THROW_RECURSION
 
 #ifdef DEFEND_AGAINST_THROW_RECURSION
@@ -274,13 +412,6 @@
 static int throw_level;
 #endif
 
-#ifdef ERROR_CHECK_STRUCTURES
-static void check_error_state_sanity (void);
-#define CHECK_ERROR_STATE_SANITY() check_error_state_sanity ()
-#else
-#define CHECK_ERROR_STATE_SANITY()
-#endif
-
 
 /************************************************************************/
 /*			The subr object type				*/
@@ -317,6 +448,15 @@
 /*			 Entering the debugger				*/
 /************************************************************************/
 
+static Lisp_Object
+current_warning_level (void)
+{
+  if (inhibit_flags & ISSUE_WARNINGS_AT_DEBUG_LEVEL)
+    return Qdebug;
+  else
+    return Qwarning;
+}
+
 /* unwind-protect used by call_debugger() to restore the value of
    entering_debugger. (We cannot use specbind() because the
    variable is not Lisp-accessible.) */
@@ -386,17 +526,24 @@
   Lisp_Object val;
   int speccount;
 
+  debug_on_next_call = 0;
+
+  if (inhibit_flags & INHIBIT_ENTERING_DEBUGGER)
+    {
+      if (!(inhibit_flags & INHIBIT_WARNING_ISSUE))
+	warn_when_safe
+	  (Qdebugger, current_warning_level (),
+	   "Unable to enter debugger within critical section");
+      return Qunbound;
+    }
+
   if (lisp_eval_depth + 20 > max_lisp_eval_depth)
     max_lisp_eval_depth = lisp_eval_depth + 20;
   if (specpdl_size + 40 > max_specpdl_size)
     max_specpdl_size = specpdl_size + 40;
-  debug_on_next_call = 0;
-
-  speccount = specpdl_depth();
-  record_unwind_protect (restore_entering_debugger,
-                         (entering_debugger ? Qt : Qnil));
-  entering_debugger = 1;
-  val = internal_catch (Qdebugger, call_debugger_259, arg, &threw);
+
+  speccount = internal_bind_int (&entering_debugger, 1);
+  val = internal_catch (Qdebugger, call_debugger_259, arg, &threw, 0);
 
   return unbind_to_1 (speccount, ((threw)
 				? Qunbound /* Not returning a value */
@@ -547,13 +694,26 @@
 		      int *stack_trace_displayed,
 		      int *debugger_entered)
 {
+#ifdef PIGS_FLY_AND_ALL_C_CODE_CAN_HANDLE_GC_OCCURRING_ALMOST_ANYWHERE
   /* This function can GC */
+#else /* reality check */
+  /* This function cannot GC because it inhibits GC during its operation */
+#endif
+
   Lisp_Object val = Qunbound;
   Lisp_Object all_handlers = Vcondition_handlers;
   Lisp_Object temp_data = Qnil;
-  int speccount = specpdl_depth();
+  int outer_speccount = specpdl_depth();
+  int speccount;
+
+#ifdef PIGS_FLY_AND_ALL_C_CODE_CAN_HANDLE_GC_OCCURRING_ALMOST_ANYWHERE
   struct gcpro gcpro1, gcpro2;
   GCPRO2 (all_handlers, temp_data);
+#else
+  begin_gc_forbidden ();
+#endif
+
+  speccount = specpdl_depth();
 
   Vcondition_handlers = active_handlers;
 
@@ -592,6 +752,7 @@
       specbind (Qstack_trace_on_signal, Qnil);
 
       val = call_debugger (list2 (Qerror, (Fcons (sig, data))));
+      unbind_to (speccount);
       *debugger_entered = 1;
     }
 
@@ -629,9 +790,11 @@
       *debugger_entered = 1;
     }
 
+#ifdef PIGS_FLY_AND_ALL_C_CODE_CAN_HANDLE_GC_OCCURRING_ALMOST_ANYWHERE
   UNGCPRO;
+#endif
   Vcondition_handlers = all_handlers;
-  return unbind_to_1 (speccount, val);
+  return unbind_to_1 (outer_speccount, val);
 }
 
 
@@ -710,7 +873,7 @@
 {
   Lisp_Object cond = args[0];
   Lisp_Object body;
-
+ 
   switch (nargs)
     {
     case 1:  body = Qnil; break;
@@ -1280,7 +1443,7 @@
   /* This function can GC */
   Lisp_Object tag  = Feval (XCAR (args));
   Lisp_Object body = XCDR (args);
-  return internal_catch (tag, Fprogn, body, 0);
+  return internal_catch (tag, Fprogn, body, 0, 0);
 }
 
 /* Set up a catch, then call C function FUNC on argument ARG.
@@ -1291,7 +1454,8 @@
 internal_catch (Lisp_Object tag,
                 Lisp_Object (*func) (Lisp_Object arg),
                 Lisp_Object arg,
-                int * volatile threw)
+                int * volatile threw,
+		Lisp_Object * volatile thrown_tag)
 {
   /* This structure is made part of the chain `catchlist'.  */
   struct catchtag c;
@@ -1299,6 +1463,7 @@
   /* Fill in the components of c, and put it on the list.  */
   c.next = catchlist;
   c.tag = tag;
+  c.actual_tag = Qnil;
   c.val = Qnil;
   c.backlist = backtrace_list;
 #if 0 /* FSFmacs */
@@ -1318,12 +1483,14 @@
     {
       /* Throw works by a longjmp that comes right here.  */
       if (threw) *threw = 1;
+      if (thrown_tag) *thrown_tag = c.actual_tag;
       return c.val;
     }
   c.val = (*func) (arg);
   if (threw) *threw = 0;
+  if (thrown_tag) *thrown_tag = Qnil;
   catchlist = c.next;
-  CHECK_ERROR_STATE_SANITY ();
+  check_catchlist_sanity ();
   return c.val;
 }
 
@@ -1345,7 +1512,7 @@
    This is used for correct unwinding in Fthrow and Fsignal.  */
 
 static void
-unwind_to_catch (struct catchtag *c, Lisp_Object val)
+unwind_to_catch (struct catchtag *c, Lisp_Object val, Lisp_Object tag)
 {
   REGISTER int last_time;
 
@@ -1360,6 +1527,7 @@
      (Can't overwrite tag slot because an unwind-protect may
      want to throw to this same tag, which isn't yet invalid.) */
   c->val = val;
+  c->actual_tag = tag;
 
 #if 0 /* FSFmacs */
   /* Restore the polling-suppression count.  */
@@ -1375,7 +1543,7 @@
          handlers.  */
       unbind_to (catchlist->pdlcount);
       catchlist = catchlist->next;
-      CHECK_ERROR_STATE_SANITY ();
+      check_catchlist_sanity ();
     }
   while (! last_time);
 #else
@@ -1402,7 +1570,7 @@
   /* Unwind the specpdl stack */
   unbind_to (c->pdlcount);
   catchlist = c->next;
-  CHECK_ERROR_STATE_SANITY ();
+  check_catchlist_sanity ();
 #endif /* Former code */
 
   gcprolist = c->gcpro;
@@ -1439,7 +1607,9 @@
      established at the same time, in initial_command_loop/
      top_level_1.
 
-     #### Fix this horrifitude!
+     [[#### Fix this horrifitude!]]
+
+     I don't think this is horrifitude, just defensive programming. --ben
      */
 
   while (1)
@@ -1451,8 +1621,8 @@
 #endif
       for (c = catchlist; c; c = c->next)
 	{
-	  if (EQ (c->tag, tag))
-	    unwind_to_catch (c, val);
+	  if (EQ (c->tag, tag) || EQ (c->tag, Vcatch_everything_tag))
+	    unwind_to_catch (c, val, tag);
 	}
       if (!bomb_out_p)
         tag = Fsignal (Qno_catch, list2 (tag, val));
@@ -1522,22 +1692,25 @@
   /* There is no problem freeing stuff here like there is in
      condition_case_unwind(), because there are no outside pointers
      (like the tag below in the catchlist) pointing to the objects. */
-  Lisp_Cons *victim;
+  
   /* ((handler-fun . handler-args) ... other handlers) */
   Lisp_Object tem = XCAR (loser);
+  int first = 1;
 
   while (CONSP (tem))
     {
-      victim = XCONS (tem);
-      tem = victim->cdr;
+      Lisp_Object victim = tem;
+      if (first && OPAQUE_PTRP (XCAR (victim)))
+	free_opaque_ptr (XCAR (victim));
+      first = 0;
+      tem = XCDR (victim);
       free_cons (victim);
     }
-  victim = XCONS (loser);
 
   if (EQ (loser, Vcondition_handlers)) /* may have been rebound to some tail */
-    Vcondition_handlers = victim->cdr;
-
-  free_cons (victim);
+    Vcondition_handlers = XCDR (loser);
+
+  free_cons (loser);
   return Qnil;
 }
 
@@ -1656,6 +1829,7 @@
 			Vcondition_handlers);
 #endif
   c.val = Qnil;
+  c.actual_tag = Qnil;
   c.backlist = backtrace_list;
 #if 0 /* FSFmacs */
   /* #### */
@@ -1696,7 +1870,7 @@
   GCPRO3 (harg, c.val, c.tag);
 
   catchlist = c.next;
-  CHECK_ERROR_STATE_SANITY ();
+  check_catchlist_sanity ();
   /* Note: The unbind also resets Vcondition_handlers.  Maybe we should
      delete this here. */
   Vcondition_handlers = XCDR (c.tag);
@@ -1705,8 +1879,8 @@
   UNGCPRO;
   /* free the conses *after* the unbind, because the unbind will run
      condition_case_unwind above. */
-  free_cons (XCONS (XCAR (c.tag)));
-  free_cons (XCONS (c.tag));
+  free_cons (XCAR (c.tag));
+  free_cons (c.tag);
   return c.val;
 }
 
@@ -1855,10 +2029,12 @@
   int speccount = specpdl_depth();
   Lisp_Object tem;
 
-  /* #### If there were a way to check that args[0] were a function
-     which accepted one arg, that should be done here ... */
-
-  /* (handler-fun . handler-args) */
+  tem = Ffunction_max_args (args[0]);
+  if (! (XINT (Ffunction_min_args (args[0])) <= 1
+	 && (NILP (tem) || 1 <= XINT (tem))))
+    invalid_argument ("Must be function of one argument", args[0]);
+
+  /* (handler-fun . handler-args)  but currently there are no handler-args */
   tem = noseeum_cons (list1 (args[0]), Vcondition_handlers);
   record_unwind_protect (condition_bind_unwind, tem);
   Vcondition_handlers = tem;
@@ -1867,6 +2043,40 @@
   return unbind_to_1 (speccount, Ffuncall (nargs - 1, args + 1));
 }
 
+/* This is the C version of the above function.  It calls FUN, passing it
+   ARG, first setting up HANDLER to catch signals in the environment in
+   which they were signalled. (HANDLER is only invoked if there was no
+   handler (either from condition-case or call-with-condition-handler) set
+   later on that handled the signal; therefore, this is a real error.
+
+   HANDLER is invoked with three arguments: the ERROR-SYMBOL and DATA as
+   passed to `signal', and HANDLER_ARG.  Originally I made HANDLER_ARG and
+   ARG be void * to facilitate passing structures, but I changed to
+   Lisp_Objects because all the other C interfaces to catch/condition-case/etc.
+   take Lisp_Objects, and it is easy enough to use make_opaque_ptr() et al.
+   to convert between Lisp_Objects and structure pointers. */
+
+Lisp_Object
+call_with_condition_handler (Lisp_Object (*handler) (Lisp_Object, Lisp_Object,
+						     Lisp_Object),
+			     Lisp_Object handler_arg,
+			     Lisp_Object (*fun) (Lisp_Object),
+			     Lisp_Object arg)
+{
+  /* This function can GC */
+  int speccount = specpdl_depth();
+  Lisp_Object tem;
+
+  /* ((handler-fun . (handler-arg . nil)) ... ) */
+  tem = noseeum_cons (noseeum_cons (make_opaque_ptr (handler),
+				    noseeum_cons (handler_arg, Qnil)),
+		      Vcondition_handlers);
+  record_unwind_protect (condition_bind_unwind, tem);
+  Vcondition_handlers = tem;
+  
+  return unbind_to_1 (speccount, (*fun) (arg));
+}
+
 static int
 condition_type_p (Lisp_Object type, Lisp_Object conditions)
 {
@@ -1910,16 +2120,39 @@
 /*		 the workhorse error-signaling function			*/
 /************************************************************************/
 
+/* This exists only for debugging purposes, as a place to put a breakpoint
+   that won't get signalled for errors occurring when
+   call_with_suspended_errors() was invoked. */
+
+static void
+signal_1 (void)
+{
+}
+
 /* #### This function has not been synched with FSF.  It diverges
    significantly. */
 
-static Lisp_Object
-signal_1 (Lisp_Object sig, Lisp_Object data)
+/* The simplest external error function: it would be called
+   signal_continuable_error() in the terminology below, but it's
+   Lisp-callable. */
+
+DEFUN ("signal", Fsignal, 2, 2, 0, /*
+Signal a continuable error.  Args are ERROR-SYMBOL, and associated DATA.
+An error symbol is a symbol defined using `define-error'.
+DATA should be a list.  Its elements are printed as part of the error message.
+If the signal is handled, DATA is made available to the handler.
+See also the function `signal-error', and the functions to handle errors:
+`condition-case' and `call-with-condition-handler'.
+
+Note that this function can return, if the debugger is invoked and the
+user invokes the "return from signal" option.
+*/
+       (error_symbol, data))
 {
   /* This function can GC */
-  struct gcpro gcpro1, gcpro2;
-  Lisp_Object conditions;
-  Lisp_Object handlers;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+  Lisp_Object conditions = Qnil;
+  Lisp_Object handlers = Qnil;
   /* signal_call_debugger() could get called more than once
      (once when a call-with-condition-handler is about to
      be dealt with, and another when a condition-case handler
@@ -1927,7 +2160,16 @@
      stack trace aren't done more than once. */
   int stack_trace_displayed = 0;
   int debugger_entered = 0;
-  GCPRO2 (conditions, handlers);
+
+  /* Fsignal() is one of these functions that's called all the time
+     with newly-created Lisp objects.  We allow this; but we must GC-
+     protect the objects because all sorts of weird stuff could
+     happen. */
+
+  GCPRO4 (conditions, handlers, error_symbol, data);
+
+  if (!(inhibit_flags & CALL_WITH_SUSPENDED_ERRORS))
+    signal_1 ();
 
   if (!initialized)
     {
@@ -1937,12 +2179,22 @@
       abort ();
     }
 
-  if (gc_in_progress || in_display)
-    /* This is one of many reasons why you can't run lisp code from redisplay.
-       There is no sensible way to handle errors there. */
+  if (gc_in_progress)
+    /* We used to abort if in_display:
+
+       [[This is one of many reasons why you can't run lisp code from
+       redisplay.  There is no sensible way to handle errors there.]]
+
+       The above comment is not correct.
+
+       Inhibit GC until the redisplay code is careful enough to properly
+       GCPRO their structures;
+
+       Surround all calls to Lisp code with error-trapping wrappers that
+       catch all errors. --ben */
     abort ();
 
-  conditions = Fget (sig, Qerror_conditions, Qnil);
+  conditions = Fget (error_symbol, Qerror_conditions, Qnil);
 
   for (handlers = Vcondition_handlers;
        CONSP (handlers);
@@ -1961,30 +2213,53 @@
           NGCPRO1 (all_handlers);
           Vcondition_handlers = outer_handlers;
 
-          tem = signal_call_debugger (conditions, sig, data,
+          tem = signal_call_debugger (conditions, error_symbol, data,
 				      outer_handlers, 1,
 				      &stack_trace_displayed,
 				      &debugger_entered);
           if (!UNBOUNDP (tem))
 	    RETURN_NUNGCPRO (return_from_signal (tem));
 
-          tem = Fcons (sig, data);
-          if (NILP (handler_data))
-            tem = call1 (handler_fun, tem);
-          else
-            {
-              /* (This code won't be used (for now?).) */
-              struct gcpro nngcpro1;
-              Lisp_Object args[3];
-              NNGCPRO1 (args[0]);
-              nngcpro1.nvars = 3;
-              args[0] = handler_fun;
-              args[1] = tem;
-              args[2] = handler_data;
-              nngcpro1.var = args;
-              tem = Fapply (3, args);
-              NNUNGCPRO;
-            }
+	  if (OPAQUE_PTRP (handler_fun))
+	    {
+	      if (NILP (handler_data))
+		{
+		  Lisp_Object (*hfun) (Lisp_Object, Lisp_Object) =
+		    (Lisp_Object (*) (Lisp_Object, Lisp_Object))
+		    (get_opaque_ptr (handler_fun));
+
+		  tem = (*hfun) (error_symbol, data);
+		}
+	      else
+		{
+		  Lisp_Object (*hfun) (Lisp_Object, Lisp_Object, Lisp_Object) =
+		    (Lisp_Object (*) (Lisp_Object, Lisp_Object, Lisp_Object))
+		    (get_opaque_ptr (handler_fun));
+
+		  assert (NILP (XCDR (handler_data)));
+		  tem = (*hfun) (error_symbol, data, XCAR (handler_data));
+		}
+	    }
+	  else
+	    {
+	      tem = Fcons (error_symbol, data);
+	      if (NILP (handler_data))
+		tem = call1 (handler_fun, tem);
+	      else
+		{
+		  /* (This code won't be used (for now?).) */
+		  struct gcpro nngcpro1;
+		  Lisp_Object args[3];
+		  NNGCPRO1 (args[0]);
+		  nngcpro1.nvars = 3;
+		  args[0] = handler_fun;
+		  args[1] = tem;
+		  args[2] = handler_data;
+		  nngcpro1.var = args;
+		  tem = Fapply (3, args);
+		  NNUNGCPRO;
+		}
+	    }
           NUNGCPRO;
 #if 0
           if (!EQ (tem, Qsignal))
@@ -2001,7 +2276,7 @@
       else if (EQ (handler_data, Qt))
 	{
           UNGCPRO;
-          return Fthrow (handlers, Fcons (sig, data));
+          return Fthrow (handlers, Fcons (error_symbol, data));
 	}
       /* `error' is used similarly to the way `t' is used, but in
          addition it invokes the debugger if debug_on_error.
@@ -2009,7 +2284,8 @@
 	 handler. */
       else if (EQ (handler_data, Qerror))
         {
-          Lisp_Object tem = signal_call_debugger (conditions, sig, data,
+          Lisp_Object tem = signal_call_debugger (conditions, error_symbol,
+						  data,
                                                   outer_handlers, 0,
 						  &stack_trace_displayed,
 						  &debugger_entered);
@@ -2018,7 +2294,7 @@
           if (!UNBOUNDP (tem))
             return return_from_signal (tem);
 
-          tem = Fcons (sig, data);
+          tem = Fcons (error_symbol, data);
           return Fthrow (handlers, tem);
         }
       else
@@ -2033,7 +2309,7 @@
 
 	      if (condition_type_p (tem, conditions))
 		{
-		  tem = signal_call_debugger (conditions, sig, data,
+		  tem = signal_call_debugger (conditions, error_symbol, data,
                                               outer_handlers, 1,
 					      &stack_trace_displayed,
 					      &debugger_entered);
@@ -2042,7 +2318,7 @@
                     return return_from_signal (tem);
 
                   /* Doesn't return */
-                  tem = Fcons (Fcons (sig, data), Fcdr (clause));
+                  tem = Fcons (Fcons (error_symbol, data), Fcdr (clause));
                   return Fthrow (handlers, tem);
                 }
 	    }
@@ -2057,58 +2333,26 @@
      there is no 'top-level catch. (That's why the
      "bomb-out" hack was added.)
 
-     #### Fix this horrifitude!
-     */
-  signal_call_debugger (conditions, sig, data, Qnil, 0,
+     [[#### Fix this horrifitude!]]
+
+     I don't think this is horrifitude, but just defensive coding. --ben */
+
+  signal_call_debugger (conditions, error_symbol, data, Qnil, 0,
 			&stack_trace_displayed,
 			&debugger_entered);
   UNGCPRO;
-  throw_or_bomb_out (Qtop_level, Qt, 1, sig, data); /* Doesn't return */
+  throw_or_bomb_out (Qtop_level, Qt, 1, error_symbol,
+		     data); /* Doesn't return */
   return Qnil;
 }
 
-
 /****************** Error functions class 1 ******************/
 
 /* Class 1: General functions that signal an error.
    These functions take an error type and a list of associated error
    data. */
 
-/* The simplest external error function: it would be called
-   signal_continuable_error_1() in the terminology below, but it's
-   Lisp-callable. */
-
-DEFUN ("signal", Fsignal, 2, 2, 0, /*
-Signal a continuable error.  Args are ERROR-SYMBOL, and associated DATA.
-An error symbol is a symbol defined using `define-error'.
-DATA should be a list.  Its elements are printed as part of the error message.
-If the signal is handled, DATA is made available to the handler.
-See also the function `signal-error', and the functions to handle errors:
-`condition-case' and `call-with-condition-handler'.
-
-Note that this function can return, if the debugger is invoked and the
-user invokes the "return from signal" option.
-*/
-       (error_symbol, data))
-{
-  /* Fsignal() is one of these functions that's called all the time
-     with newly-created Lisp objects.  We allow this; but we must GC-
-     protect the objects because all sorts of weird stuff could
-     happen. */
-
-  struct gcpro gcpro1;
-
-  GCPRO1 (data);
-  if (!NILP (Vcurrent_error_state))
-    {
-      if (!NILP (Vcurrent_warning_class) && !NILP (Vcurrent_warning_level))
-	warn_when_safe_lispobj (Vcurrent_warning_class, Vcurrent_warning_level,
-				Fcons (error_symbol, data));
-      Fthrow (Qunbound_suspended_errors_tag, Qnil);
-      abort (); /* Better not get here! */
-    }
-  RETURN_UNGCPRO (signal_1 (error_symbol, data));
-}
+/* No signal_continuable_error_1(); it's called Fsignal(). */
 
 /* Signal a non-continuable error. */
 
@@ -2118,10 +2362,15 @@
   for (;;)
     Fsignal (sig, data);
 }
-#ifdef ERROR_CHECK_STRUCTURES
-static void
-check_error_state_sanity (void)
-{
+
+#ifdef ERROR_CHECK_CATCH
+
+void
+check_catchlist_sanity (void)
+{
+#if 0
+  /* vou me tomar no cu!  i just masked andy's missing-unbind
+     bug! */
   struct catchtag *c;
   int found_error_tag = 0;
 
@@ -2135,147 +2384,15 @@
     }
 
   assert (found_error_tag || NILP (Vcurrent_error_state));
-}
-#endif
-
-static Lisp_Object
-restore_current_warning_class (Lisp_Object warning_class)
-{
-  Vcurrent_warning_class = warning_class;
-  return Qnil;
-}
-
-static Lisp_Object
-restore_current_warning_level (Lisp_Object warning_level)
-{
-  Vcurrent_warning_level = warning_level;
-  return Qnil;
-}
-
-static Lisp_Object
-restore_current_error_state (Lisp_Object error_state)
-{
-  Vcurrent_error_state = error_state;
-  return Qnil;
-}
-
-static Lisp_Object
-call_with_suspended_errors_1 (Lisp_Object opaque_arg)
-{
-  Lisp_Object val;
-  Lisp_Object *kludgy_args = (Lisp_Object *) get_opaque_ptr (opaque_arg);
-  int speccount = specpdl_depth ();
-
-  if (NILP (Vcurrent_error_state))
-    {
-      record_unwind_protect (restore_current_error_state,
-			     Vcurrent_error_state);
-      Vcurrent_error_state = Qt;
-    }
-  PRIMITIVE_FUNCALL (val, get_opaque_ptr (kludgy_args[0]),
-		     kludgy_args + 2, XINT (kludgy_args[1]));
-  return unbind_to_1 (speccount, val);
-}
-
-/* Many functions would like to do one of three things if an error
-   occurs:
-
-   (1) signal the error, as usual.
-   (2) silently fail and return some error value.
-   (3) do as (2) but issue a warning in the process.
-
-   Currently there's lots of stuff that passes an Error_Behavior
-   value and calls maybe_signal_error() and other such functions.
-   This approach is inherently error-prone and broken.  A much
-   more robust and easier approach is to use call_with_suspended_errors().
-   Wrap this around any function in which you might want errors
-   to not be errors.
-*/
-
-Lisp_Object
-call_with_suspended_errors (lisp_fn_t fun, volatile Lisp_Object retval,
-			    Lisp_Object class, Error_Behavior errb,
-			    int nargs, ...)
-{
-  va_list vargs;
-  int speccount;
-  Lisp_Object kludgy_args[22];
-  Lisp_Object *args = kludgy_args + 2;
-  int i;
-
-  assert (SYMBOLP (class)); /* sanity-check */
-  assert (!NILP (class));
-  assert (nargs >= 0 && nargs < 20);
-
-  va_start (vargs, nargs);
-  for (i = 0; i < nargs; i++)
-    args[i] = va_arg (vargs, Lisp_Object);
-  va_end (vargs);
-
-  /* ERROR_ME means don't trap errors. (However, if errors are
-     already trapped, we leave them trapped.)
-
-     Otherwise, we trap errors, and display as warnings if ERROR_ME_WARN.
-
-     If ERROR_ME_NOT, we silently fail.
-     
-     If ERROR_ME_DEBUG_WARN, we display a warning, but at warning level to
-     `debug'.  Normally these disappear, but can be seen if we changed
-     log-warning-minimum-level.
-     */
-
-  /* If error-checking is not disabled, just call the function.
-     It's important not to override disabled error-checking with
-     enabled error-checking. */
-
-  if (ERRB_EQ (errb, ERROR_ME))
-    {
-      Lisp_Object val;
-      PRIMITIVE_FUNCALL (val, fun, args, nargs);
-      return val;
-    }
-
-  speccount = specpdl_depth ();
-  if (NILP (Vcurrent_warning_class))
-    {
-      /* Don't change the existing class.
-	 #### Should we be consing the two together? */
-      record_unwind_protect (restore_current_warning_class,
-			     Vcurrent_warning_class);
-      Vcurrent_warning_class = class;
-    }
-
-  record_unwind_protect (restore_current_warning_level,
-			 Vcurrent_warning_level);
-  Vcurrent_warning_level =
-    (ERRB_EQ (errb, ERROR_ME_NOT) ? Qnil :
-     ERRB_EQ (errb, ERROR_ME_DEBUG_WARN) ? Qdebug :
-     Qwarning);
-  
-
-  {
-    int threw;
-    Lisp_Object the_retval;
-    Lisp_Object opaque1 = make_opaque_ptr (kludgy_args);
-    Lisp_Object opaque2 = make_opaque_ptr ((void *) fun);
-    struct gcpro gcpro1, gcpro2;
-
-    GCPRO2 (opaque1, opaque2);
-    kludgy_args[0] = opaque2;
-    kludgy_args[1] = make_int (nargs);
-    the_retval = internal_catch (Qunbound_suspended_errors_tag,
-				 call_with_suspended_errors_1,
-				 opaque1, &threw);
-    free_opaque_ptr (opaque1);
-    free_opaque_ptr (opaque2);
-    UNGCPRO;
-    /* Use the returned value except in non-local exit, when
-       RETVAL applies. */
-    /* Some perverse compilers require the perverse cast below.  */
-    return unbind_to_1 (speccount,
-		      threw ? *((Lisp_Object*) &(retval)) : the_retval);
-  }
-}
+#endif /* vou me tomar no cul */
+}
+
+void
+check_specbind_stack_sanity (void)
+{
+}
+
+#endif /* ERROR_CHECK_CATCH */
 
 /* Signal a non-continuable error or display a warning or do nothing,
    according to ERRB.  CLASS is the class of warning and should
@@ -2606,12 +2723,19 @@
 void
 signal_quit (void)
 {
-  /* This function can GC */
+  /* This function cannot GC.  GC is prohibited because most callers do
+     not expect GC occurring in QUIT.  Remove this if/when that gets fixed.
+     --ben */
+
+  int count;
+
   if (EQ (Vquit_flag, Qcritical))
     debug_on_quit |= 2;		/* set critical bit. */
   Vquit_flag = Qnil;
+  count = begin_gc_forbidden ();
   /* note that this is continuable. */
   Fsignal (Qquit, Qnil);
+  unbind_to (count);
 }
 
 
@@ -3164,12 +3288,6 @@
 				   int nargs, Lisp_Object args[]);
 static int in_warnings;
 
-static Lisp_Object
-in_warnings_restore (Lisp_Object minimus)
-{
-  in_warnings = 0;
-  return Qnil;
-}
 
 void handle_compiled_function_with_and_rest (Lisp_Compiled_Function *f,
 					     int nargs,
@@ -3298,20 +3416,20 @@
   struct backtrace backtrace;
 
   /* I think this is a pretty safe place to call Lisp code, don't you? */
-  while (!in_warnings && !NILP (Vpending_warnings))
+  while (!in_warnings && !NILP (Vpending_warnings)
+	 /* well, perhaps not so safe after all! */
+	 && !(inhibit_flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY))
     {
       struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
-      int speccount = specpdl_depth();
       Lisp_Object this_warning_cons, this_warning, class, level, messij;
-
-      record_unwind_protect (in_warnings_restore, Qnil);
-      in_warnings = 1;
+      int speccount = internal_bind_int (&in_warnings, 1);
+
       this_warning_cons = Vpending_warnings;
       this_warning = XCAR (this_warning_cons);
       /* in case an error occurs in the warn function, at least
 	 it won't happen infinitely */
       Vpending_warnings = XCDR (Vpending_warnings);
-      free_cons (XCONS (this_warning_cons));
+      free_cons (this_warning_cons);
       class = XCAR (this_warning);
       level = XCAR (XCDR (this_warning));
       messij = XCAR (XCDR (XCDR (this_warning)));
@@ -3814,6 +3932,9 @@
 Return the minimum number of arguments a function may be called with.
 The function may be any form that can be passed to `funcall',
 any special form, or any macro.
+
+To check if a function can be called with a specified number of
+arguments, use `function-allows-args'.
 */
        (function))
 {
@@ -3826,6 +3947,9 @@
 any special form, or any macro.
 If the function takes an arbitrary number of arguments or is
 a built-in special form, nil is returned.
+
+To check if a function can be called with a specified number of
+arguments, use `function-allows-args'.
 */
        (function))
 {
@@ -4145,7 +4269,7 @@
 
 #if 0
 
-/* From FSF 19.30, not currently used */
+/* From FSF 19.30, not currently used; seems like a big kludge. */
 
 /* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual
    present value of that symbol.
@@ -4157,39 +4281,7 @@
 Lisp_Object
 run_hook_list_with_args (Lisp_Object funlist, int nargs, Lisp_Object *args)
 {
-  Lisp_Object sym = args[0];
-  Lisp_Object val;
-  struct gcpro gcpro1, gcpro2;
-
-  GCPRO2 (sym, val);
-
-  for (val = funlist; CONSP (val); val = XCDR (val))
-    {
-      if (EQ (XCAR (val), Qt))
-	{
-	  /* t indicates this hook has a local binding;
-	     it means to run the global binding too.  */
-	  Lisp_Object globals;
-
-	  for (globals = Fdefault_value (sym);
-	       CONSP (globals);
-	       globals = XCDR (globals))
-	    {
-	      args[0] = XCAR (globals);
-	      /* In a global value, t should not occur.  If it does, we
-		 must ignore it to avoid an endless loop.  */
-	      if (!EQ (args[0], Qt))
-		Ffuncall (nargs, args);
-	    }
-	}
-      else
-	{
-	  args[0] = XCAR (val);
-	  Ffuncall (nargs, args);
-	}
-    }
-  UNGCPRO;
-  return Qnil;
+  omitted;
 }
 
 #endif /* 0 */
@@ -4241,8 +4333,7 @@
 Lisp_Object
 run_hook (Lisp_Object hook)
 {
-  Frun_hooks (1, &hook);
-  return Qnil;
+  return run_hook_with_args (1, &hook, RUN_HOOKS_TO_COMPLETION);
 }
 
 
@@ -4542,161 +4633,753 @@
 /*	   Error-catching front-ends to eval, funcall, apply		*/
 /************************************************************************/
 
-/* Call function fn on no arguments, with condition handler */
-Lisp_Object
-call0_with_handler (Lisp_Object handler, Lisp_Object fn)
-{
-  /* This function can GC */
-  struct gcpro gcpro1;
-  Lisp_Object args[2];
-  args[0] = handler;
-  args[1] = fn;
-  GCPRO1 (args[0]);
-  gcpro1.nvars = 2;
-  RETURN_UNGCPRO (Fcall_with_condition_handler (2, args));
-}
-
-/* Call function fn with argument arg0, with condition handler */
-Lisp_Object
-call1_with_handler (Lisp_Object handler, Lisp_Object fn,
-                    Lisp_Object arg0)
-{
-  /* This function can GC */
-  struct gcpro gcpro1;
-  Lisp_Object args[3];
-  args[0] = handler;
-  args[1] = fn;
-  args[2] = arg0;
-  GCPRO1 (args[0]);
-  gcpro1.nvars = 3;
-  RETURN_UNGCPRO (Fcall_with_condition_handler (3, args));
-}
-
-
-/* The following functions provide you with error-trapping versions
-   of the various front-ends above.  They take an additional
-   "warning_string" argument; if non-zero, a warning with this
-   string and the actual error that occurred will be displayed
-   in the *Warnings* buffer if an error occurs.  In all cases,
-   QUIT is inhibited while these functions are running, and if
-   an error occurs, Qunbound is returned instead of the normal
-   return value.
-   */
-
-/* #### This stuff needs to catch throws as well.  We need to
-   improve internal_catch() so it can take a "catch anything"
-   argument similar to Qt or Qerror for condition_case_1(). */
+int
+get_inhibit_flags (void)
+{
+  return inhibit_flags;
+}
+
+void
+check_allowed_operation (int what, Lisp_Object obj, Lisp_Object prop)
+{
+  if (inhibit_flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION)
+    {
+      if (what == OPERATION_MODIFY_BUFFER_TEXT && BUFFERP (obj)
+	  && NILP (memq_no_quit (obj, Vmodifiable_buffers)))
+	invalid_change
+	  ("Modification of this buffer not currently permitted", obj);
+    }
+  if (inhibit_flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION)
+    {
+      if (what == OPERATION_DELETE_OBJECT
+	  && (BUFFERP (obj) || WINDOWP (obj) || FRAMEP (obj) || DEVICEP (obj)
+	      || CONSOLEP (obj))
+	  && NILP (memq_no_quit (obj, Vdeletable_permanent_display_objects)))
+	invalid_change
+	  ("Deletion of this object not currently permitted", obj);
+    }
+}
+
+void
+note_object_created (Lisp_Object obj)
+{
+  if (inhibit_flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION)
+    {
+      if (BUFFERP (obj))
+	Vmodifiable_buffers = Fcons (obj, Vmodifiable_buffers);
+    }
+  if (inhibit_flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION)
+    {
+      if (BUFFERP (obj) || WINDOWP (obj) || FRAMEP (obj) || DEVICEP (obj)
+	  || CONSOLEP (obj))
+	Vdeletable_permanent_display_objects =
+	  Fcons (obj, Vdeletable_permanent_display_objects);
+    }
+}
+
+void
+note_object_deleted (Lisp_Object obj)
+{
+  if (inhibit_flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION)
+    {
+      if (BUFFERP (obj))
+	Vmodifiable_buffers = delq_no_quit (obj, Vmodifiable_buffers);
+    }
+  if (inhibit_flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION)
+    {
+      if (BUFFERP (obj) || WINDOWP (obj) || FRAMEP (obj) || DEVICEP (obj)
+	  || CONSOLEP (obj))
+	Vdeletable_permanent_display_objects =
+	  delq_no_quit (obj, Vdeletable_permanent_display_objects);
+    }
+}
+
+struct call_trapping_problems
+{
+  Lisp_Object catchtag;
+  Lisp_Object error_conditions;
+  Lisp_Object data;
+  Lisp_Object backtrace;
+  Lisp_Object warning_class;
+
+  const CIntbyte *warning_string;
+  Lisp_Object (*fun) (void *);
+  void *arg;
+};
 
 static Lisp_Object
-caught_a_squirmer (Lisp_Object errordata, Lisp_Object arg)
-{
-  /* #### should be rewritten to work with emacs_sprintf_string_lisp(); but this
-     whole stuff is getting junked and replaced from my stderr-proc ws */
-  if (!NILP (errordata))
+flagged_a_squirmer (Lisp_Object error_conditions, Lisp_Object data,
+		    Lisp_Object opaque)
+{
+  struct call_trapping_problems *p =
+    (struct call_trapping_problems *) get_opaque_ptr (opaque);
+  struct gcpro gcpro1;
+  Lisp_Object lstream = Qnil;
+  Lisp_Object errstr;
+  int speccount = specpdl_depth ();
+
+  if (! (inhibit_flags & INHIBIT_WARNING_ISSUE))
     {
-      Lisp_Object args[2];
-
-      if (!NILP (arg))
-        {
-          Intbyte *str = (Intbyte *) get_opaque_ptr (arg);
-          args[0] = build_intstring (str);
-        }
-      else
-        args[0] = build_msg_string ("error");
+      /* We're no longer protected against errors or quit here, so at
+	 least let's temporarily inhibit quit.  We definitely do not
+	 want to inhibit quit during the calling of the function
+	 itself!!!!!!!!!!! */
+     
+      specbind (Qinhibit_quit, Qt);
+
+      GCPRO1 (lstream);
+      lstream = make_resizing_buffer_output_stream ();
+      Fbacktrace (lstream, Qt);
+      Lstream_flush (XLSTREAM (lstream));
+      p->backtrace = resizing_buffer_to_lisp_string (XLSTREAM (lstream));
+      Lstream_delete (XLSTREAM (lstream));
+      UNGCPRO;
+
       /* #### This should call
-	 (with-output-to-string (display-error errordata))
+	 (with-output-to-string (display-error (cons error_conditions data))
 	 but that stuff is all in Lisp currently. */
-      args[1] = errordata;
-      warn_when_safe_lispobj
-	(Qerror, Qwarning,
-	 emacs_vsprintf_string_lisp ("%s: %s", Qnil, 2, args));
+      errstr =
+	emacs_sprintf_string_lisp
+	("%s: (%s %s)\n\nBacktrace follows:\n\n%s",
+	 Qnil, 4,
+	 build_msg_string (p->warning_string ? p->warning_string : "error"),
+	 error_conditions, data, p->backtrace);
+
+      warn_when_safe_lispobj (p->warning_class, current_warning_level (),
+			      errstr);
+
+      unbind_to (speccount);
+
     }
-  return Qunbound;
+  else
+    p->backtrace = Qnil;
+
+  p->error_conditions = error_conditions;
+  p->data = data;
+
+  Fthrow (p->catchtag, Qnil);
+  return Qnil; /* not reached */
+}
+
+static Lisp_Object
+call_trapping_problems_2 (Lisp_Object opaque)
+{
+  struct call_trapping_problems *p =
+    (struct call_trapping_problems *) get_opaque_ptr (opaque);
+
+  return (p->fun) (p->arg);
 }
 
 static Lisp_Object
-allow_quit_caught_a_squirmer (Lisp_Object errordata, Lisp_Object arg)
-{
-  if (CONSP (errordata) && EQ (XCAR (errordata), Qquit))
-    return Fsignal (Qquit, XCDR (errordata));
-  return caught_a_squirmer (errordata, arg);
+call_trapping_problems_1 (Lisp_Object opaque)
+{
+  return call_with_condition_handler (flagged_a_squirmer, opaque,
+				      call_trapping_problems_2, opaque);
+}
+
+/* This is equivalent to (*fun) (arg), except that various conditions
+   can be trapped or inhibited, according to FLAGS.
+
+   If FLAGS does not contain NO_INHIBIT_ERRORS, when an error occurs,
+   the error is caught and a warning is issued, specifying the
+   specific error that occurred and a backtrace.  In that case,
+   WARNING_STRING should be given, and will be printed at the
+   beginning of the error to indicate where the error occurred.
+
+   If FLAGS does not contain NO_INHIBIT_THROWS, all attempts to
+   `throw' out of the function being called are trapped, and a warning
+   issued. (Again, WARNING_STRING should be given.)
+
+   (If FLAGS contains INHIBIT_WARNING_ISSUE, no warnings are issued;
+   this applies to recursive invocations of call_trapping_problems, too.
+
+   If FLAGS contains ISSUE_WARNINGS_AT_DEBUG_LEVEL, warnings will be
+   issued, but at level `debug', which normally is below the minimum
+   specified by `log-warning-minimum-level', meaning such warnings will
+   be ignored entirely.  The user can change this variable, however,
+   to see the warnings.)
+
+   Note: If neither of NO_INHIBIT_THROWS or NO_INHIBIT_ERRORS is
+   given, you are *guaranteed* that there will be no non-local exits
+   out of this function.
+
+   If FLAGS contains INHIBIT_QUIT, QUIT using C-g is inhibited.  (This
+   is *rarely* a good idea.  Unless you use NO_INHIBIT_ERRORS, QUIT is
+   automatically caught as well, and treated as an error; you can
+   check for this using EQ (problems->error_conditions, Qquit).
+
+   If FLAGS contains UNINHIBIT_QUIT, QUIT checking will be explicitly
+   turned on. (It will abort the code being called, but will still be
+   trapped and reported as an error, unless NO_INHIBIT_ERRORS is
+   given.) This is useful when QUIT checking has been turned off by a
+   higher-level caller.
+
+   If FLAGS contains INHIBIT_GC, garbage collection is inhibited.
+   This is useful for Lisp called within redisplay or inside of the
+   QUIT macro (where GC is generally not expected), for example.
+
+   If FLAGS contains INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION,
+   Lisp code is not allowed to delete any window, buffers, frames, devices,
+   or consoles that were already in existence at the time this function
+   was called. (However, it's perfectly legal for code to create a new
+   buffer and then delete it.)
+
+   #### It might be useful to have a flag that inhibits deletion of a
+   specific permanent display object and everything it's attached to
+   (e.g. a window, and the buffer, frame, device, and console it's
+   attached to.
+
+   If FLAGS contains INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION, Lisp
+   code is not allowed to modify the text of any buffers that were
+   already in existence at the time this function was called.
+   (However, it's perfectly legal for code to create a new buffer and
+   then modify its text.)
+
+       [These last two flags are implemented using global variables
+       Vdeletable_permanent_display_objects and Vmodifiable_buffers,
+       which keep track of a list of all buffers or permanent display
+       objects created since the last time one of these flags was set.
+       The code that deletes buffers, etc. and modifies buffers checks
+    
+       (1) if the corresponding flag is set (through the global variable
+       inhibit_flags or its accessor function get_inhibit_flags()), and
+    
+       (2) if the object to be modified or deleted is not in the
+       appropriate list.
+    
+       If so, it signals an error.
+    
+       Recursive calls to call_trapping_problems() are allowed.  In
+       the case of the two flags mentioned above, the current values
+       of the global variables are stored in an unwind-protect, and
+       they're reset to nil.]
+    
+   If FLAGS contains INHIBIT_ENTERING_DEBUGGER, the debugger will not
+   be entered if an error occurs inside the Lisp code being called,
+   even when the user has requested an error.  In such case, a warning
+   is issued stating that access to the debugger is denied, unless
+   INHIBIT_WARNING_ISSUE has also been supplied.  This is useful when
+   calling Lisp code inside redisplay, in menu callbacks, etc. because
+   in such cases either the display is in an inconsistent state or
+   doing window operations is explicitly forbidden by the OS, and the
+   debugger would causes visual changes on the screen and might create
+   another frame.
+
+   If FLAGS contains INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY, no
+   changes of any sort to extents, faces, glyphs, buffer text,
+   specifiers relating to display, other variables relating to
+   display, splitting, deleting, or resizing windows or frames,
+   deleting buffers, windows, frames, devices, or consoles, etc. is
+   allowed.  This is for things called absolutely in the middle of
+   redisplay, which expects things to be *exactly* the same after the
+   call as before.  This isn't completely implemented and needs to be
+   thought out some more to determine exactly what its semantics are.
+   For the moment, turning on this flag also turns on
+
+        INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION
+        INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION
+        INHIBIT_ENTERING_DEBUGGER
+        INHIBIT_WARNING_ISSUE
+        INHIBIT_GC
+
+   #### The following five flags are defined, but unimplemented:
+
+   #define INHIBIT_EXISTING_CODING_SYSTEM_DELETION (1<<6)
+   #define INHIBIT_EXISTING_CHARSET_DELETION (1<<7)
+   #define INHIBIT_PERMANENT_DISPLAY_OBJECT_CREATION (1<<8)
+   #define INHIBIT_CODING_SYSTEM_CREATION (1<<9)
+   #define INHIBIT_CHARSET_CREATION (1<<10)
+
+   FLAGS containing CALL_WITH_SUSPENDED_ERRORS is a sign that
+   call_with_suspended_errors() was invoked.  This exists only for
+   debugging purposes -- often we want to break when a signal happens,
+   but ignore signals from call_with_suspended_errors(), because they
+   occur often and for legitimate reasons.
+
+   If PROBLEM is non-zero, it should be a pointer to a structure into
+   which exact information about any occurring problems (either an
+   error or an attempted throw past this boundary).
+
+   If a problem occurred and aborted operation (error, quit, or
+   invalid throw), Qunbound is returned.  Otherwise the return value
+   from the call to (*fun) (arg) is returned.  */
+
+Lisp_Object
+call_trapping_problems (Lisp_Object warning_class,
+			const CIntbyte *warning_string,
+			int flags,
+			struct call_trapping_problems_result *problem,
+			Lisp_Object (*fun) (void *),
+			void *arg)
+{
+  int speccount = specpdl_depth();
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct call_trapping_problems package;
+  Lisp_Object opaque, thrown_tag, tem;
+  int thrown = 0;
+
+  assert (SYMBOLP (warning_class)); /* sanity-check */
+  assert (!NILP (warning_class));
+
+  flags ^= INTERNAL_INHIBIT_ERRORS | INTERNAL_INHIBIT_THROWS;
+
+  package.warning_class = warning_class;
+  package.warning_string = warning_string;
+  package.fun = fun;
+  package.arg = arg;
+  package.catchtag =
+    flags & INTERNAL_INHIBIT_THROWS ? Vcatch_everything_tag :
+    flags & INTERNAL_INHIBIT_ERRORS ? make_opaque_ptr (0) :
+    Qnil;
+  package.error_conditions = Qnil;
+  package.data = Qnil;
+  package.backtrace = Qnil;
+
+  if (flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY)
+    flags |= INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION
+      | INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION
+      | INHIBIT_ENTERING_DEBUGGER
+      | INHIBIT_WARNING_ISSUE
+      | INHIBIT_GC;
+
+  {
+    int new_inhibit_flags = inhibit_flags | flags;
+    if (new_inhibit_flags != inhibit_flags)
+      internal_bind_int (&inhibit_flags, new_inhibit_flags);
+  }
+
+  if (flags & INHIBIT_QUIT)
+    specbind (Qinhibit_quit, Qt);
+
+  if (flags & UNINHIBIT_QUIT)
+    begin_do_check_for_quit ();
+
+  if (flags & INHIBIT_GC)
+    begin_gc_forbidden ();
+
+  /* #### If we have nested calls to call_trapping_problems(), and the
+     inner one creates some buffers/etc., should the outer one be able
+     to delete them?  I think so, but it means we need to combine rather
+     than just reset the value. */
+  if (flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION)
+    internal_bind_lisp_object (&Vdeletable_permanent_display_objects, Qnil);
+
+  if (flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION)
+    internal_bind_lisp_object (&Vmodifiable_buffers, Qnil);
+
+  if (flags & (INTERNAL_INHIBIT_THROWS | INTERNAL_INHIBIT_ERRORS))
+    opaque = make_opaque_ptr (&package);
+  else
+    opaque = Qnil;
+
+  GCPRO5 (package.catchtag, package.error_conditions, package.data,
+	  package.backtrace, opaque);
+
+  if (flags & INTERNAL_INHIBIT_ERRORS)
+    /* We need a catch so that our condition-handler can throw back here
+       after printing the warning. (We print the warning in the stack
+       context of the error, so we can get a backtrace.) */
+    tem = internal_catch (package.catchtag, call_trapping_problems_1, opaque,
+			  &thrown, &thrown_tag);
+  else if (flags & INTERNAL_INHIBIT_THROWS)
+    /* We skip over the first wrapper, which traps errors. */
+    tem = internal_catch (package.catchtag, call_trapping_problems_2, opaque,
+			  &thrown, &thrown_tag);
+  else
+    /* Nothing special. */
+    tem = (fun) (arg);
+
+  if (thrown && !EQ (thrown_tag, package.catchtag)
+      && (!flags & INHIBIT_WARNING_ISSUE))
+    {
+      Lisp_Object errstr;
+
+      if (!(flags & INHIBIT_QUIT))
+	/* We're no longer protected against errors or quit here, so at
+	   least let's temporarily inhibit quit. */
+	specbind (Qinhibit_quit, Qt);
+      errstr =
+	emacs_sprintf_string_lisp
+	("%s: Attempt to throw outside of function "
+	 "to catch `%s' with value `%s'",
+	 Qnil, 3, build_msg_string (warning_string ? warning_string : "error"),
+	 thrown_tag, tem);
+
+      warn_when_safe_lispobj (Qerror, current_warning_level (), errstr);
+    }
+
+  if (problem)
+    {
+      if (!thrown)
+	{
+	  problem->caught_error = 0;
+	  problem->caught_throw = 0;
+	  problem->error_conditions = Qnil;
+	  problem->data = Qnil;
+	  problem->backtrace = Qnil;
+	  problem->thrown_tag = Qnil;
+	  problem->thrown_value = Qnil;
+	}
+      else if (EQ (thrown_tag, package.catchtag))
+	{
+	  problem->caught_error = 1;
+	  problem->caught_throw = 0;
+	  problem->error_conditions = package.error_conditions;
+	  problem->data = package.data;
+	  problem->backtrace = package.backtrace;
+	  problem->thrown_tag = Qnil;
+	  problem->thrown_value = Qnil;
+	}
+      else
+	{
+	  problem->caught_error = 0;
+	  problem->caught_throw = 1;
+	  problem->error_conditions = Qnil;
+	  problem->data = Qnil;
+	  problem->backtrace = Qnil;
+	  problem->thrown_tag = thrown_tag;
+	  problem->thrown_value = tem;
+	}
+    }
+
+  if (!NILP (package.catchtag) &&
+      !EQ (package.catchtag, Vcatch_everything_tag))
+    free_opaque_ptr (package.catchtag);
+
+  if (!NILP (opaque))
+    free_opaque_ptr (opaque);
+
+  unbind_to (speccount);
+  RETURN_UNGCPRO (thrown ? Qunbound : tem);
+}
+
+struct va_call_trapping_problems
+{
+  lisp_fn_t fun;
+  int nargs;
+  Lisp_Object *args;
+};
+
+static Lisp_Object
+va_call_trapping_problems_1 (void *ai_mi_madre)
+{
+  struct va_call_trapping_problems *ai_no_corrida =
+    (struct va_call_trapping_problems *) ai_mi_madre;
+  Lisp_Object pegar_no_bumbum;
+
+  PRIMITIVE_FUNCALL (pegar_no_bumbum, ai_no_corrida->fun,
+		     ai_no_corrida->args, ai_no_corrida->nargs);
+  return pegar_no_bumbum;
+}
+
+/* #### document me. */
+
+Lisp_Object
+va_call_trapping_problems (Lisp_Object warning_class,
+			   const CIntbyte *warning_string,
+			   int flags,
+			   struct call_trapping_problems_result *problem,
+			   lisp_fn_t fun, int nargs, ...)
+{
+  va_list vargs;
+  Lisp_Object args[20];
+  int i;
+  struct va_call_trapping_problems fazer_invocacao_atrapalhando_problemas;
+  struct gcpro gcpro1;
+
+  assert (nargs >= 0 && nargs < 20);
+
+  va_start (vargs, nargs);
+  for (i = 0; i < nargs; i++)
+    args[i] = va_arg (vargs, Lisp_Object);
+  va_end (vargs);
+
+  fazer_invocacao_atrapalhando_problemas.fun = fun;
+  fazer_invocacao_atrapalhando_problemas.nargs = nargs;
+  fazer_invocacao_atrapalhando_problemas.args = args;
+
+  GCPRO1_ARRAY (args, nargs);
+  RETURN_UNGCPRO
+    (call_trapping_problems
+     (warning_class, warning_string, flags, problem,
+      va_call_trapping_problems_1, &fazer_invocacao_atrapalhando_problemas));
+}
+
+/* this is an older interface, barely different from
+   va_call_trapping_problems.
+
+   #### eliminate this or at least merge the ERROR_BEHAVIOR stuff into
+   va_call_trapping_problems(). */
+
+Lisp_Object
+call_with_suspended_errors (lisp_fn_t fun, Lisp_Object retval,
+			    Lisp_Object class, Error_Behavior errb,
+			    int nargs, ...)
+{
+  va_list vargs;
+  Lisp_Object args[20];
+  int i;
+  struct va_call_trapping_problems fazer_invocacao_atrapalhando_problemas;
+  int flags;
+  struct gcpro gcpro1;
+
+  assert (SYMBOLP (class)); /* sanity-check */
+  assert (!NILP (class));
+  assert (nargs >= 0 && nargs < 20);
+
+  va_start (vargs, nargs);
+  for (i = 0; i < nargs; i++)
+    args[i] = va_arg (vargs, Lisp_Object);
+  va_end (vargs);
+
+  /* If error-checking is not disabled, just call the function. */
+
+  if (ERRB_EQ (errb, ERROR_ME))
+    {
+      Lisp_Object val;
+      PRIMITIVE_FUNCALL (val, fun, args, nargs);
+      return val;
+    }
+
+  if (ERRB_EQ (errb, ERROR_ME_NOT)) /* person wants no warnings */
+    flags = INHIBIT_WARNING_ISSUE | INHIBIT_ENTERING_DEBUGGER;
+  else if (ERRB_EQ (errb, ERROR_ME_DEBUG_WARN))
+    flags = ISSUE_WARNINGS_AT_DEBUG_LEVEL | INHIBIT_ENTERING_DEBUGGER;
+  else
+    {
+      assert (ERRB_EQ (errb, ERROR_ME_WARN));
+      flags = INHIBIT_ENTERING_DEBUGGER;
+    }
+
+  flags |= CALL_WITH_SUSPENDED_ERRORS;
+
+  fazer_invocacao_atrapalhando_problemas.fun = fun;
+  fazer_invocacao_atrapalhando_problemas.nargs = nargs;
+  fazer_invocacao_atrapalhando_problemas.args = args;
+
+  GCPRO1_ARRAY (args, nargs);
+  {
+    Lisp_Object its_way_too_goddamn_late =
+      call_trapping_problems
+       (class, 0, flags, 0, va_call_trapping_problems_1,
+	&fazer_invocacao_atrapalhando_problemas);
+    UNGCPRO;
+    if (UNBOUNDP (its_way_too_goddamn_late))
+      return retval;
+    else
+      return its_way_too_goddamn_late;
+  }
+}
+
+struct calln_trapping_problems
+{
+  int nargs;
+  Lisp_Object *args;
+};
+
+static Lisp_Object
+calln_trapping_problems_1 (void *puta)
+{
+  struct calln_trapping_problems *p = (struct calln_trapping_problems *) puta;
+
+  return Ffuncall (p->nargs, p->args);
 }
 
 static Lisp_Object
-safe_run_hook_caught_a_squirmer (Lisp_Object errordata, Lisp_Object arg)
-{
-  Lisp_Object hook = Fcar (arg);
-  arg = Fcdr (arg);
-  /* Clear out the hook. */
-  Fset (hook, Qnil);
-  return caught_a_squirmer (errordata, arg);
-}
-
-static Lisp_Object
-allow_quit_safe_run_hook_caught_a_squirmer (Lisp_Object errordata,
-					    Lisp_Object arg)
-{
-  Lisp_Object hook = Fcar (arg);
-  arg = Fcdr (arg);
-  if (!CONSP (errordata) || !EQ (XCAR (errordata), Qquit))
-    /* Clear out the hook. */
-    Fset (hook, Qnil);
-  return allow_quit_caught_a_squirmer (errordata, arg);
-}
-
-static Lisp_Object
-catch_them_squirmers_eval_in_buffer (Lisp_Object cons)
-{
-  return eval_in_buffer (XBUFFER (XCAR (cons)), XCDR (cons));
+calln_trapping_problems (Lisp_Object warning_class,
+			 const CIntbyte *warning_string, int flags,
+			 struct call_trapping_problems_result *problem,
+			 int nargs, Lisp_Object *args)
+{
+  struct calln_trapping_problems foo;
+  struct gcpro gcpro1;
+
+  if (SYMBOLP (args[0]))
+    {
+      Lisp_Object tem = XSYMBOL (args[0])->function;
+      if (NILP (tem) || UNBOUNDP (tem))
+	{
+	  if (problem)
+	    {
+	      problem->caught_error = 0;
+	      problem->caught_throw = 0;
+	      problem->error_conditions = Qnil;
+	      problem->data = Qnil;
+	      problem->backtrace = Qnil;
+	      problem->thrown_tag = Qnil;
+	      problem->thrown_value = Qnil;
+	    }
+	  return Qnil;
+	}
+    }
+
+  foo.nargs = nargs;
+  foo.args = args;
+
+  GCPRO1_ARRAY (args, nargs);
+  RETURN_UNGCPRO (call_trapping_problems (warning_class, warning_string,
+					  flags, problem,
+					  calln_trapping_problems_1,
+					  &foo));
+}
+
+/* #### fix these functions to follow the calling convention of
+   call_trapping_problems! */
+
+Lisp_Object
+call0_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 int flags)
+{
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 1,
+				  &function);
 }
 
 Lisp_Object
-eval_in_buffer_trapping_errors (const CIntbyte *warning_string,
-				struct buffer *buf, Lisp_Object form)
-{
-  int speccount = specpdl_depth();
-  Lisp_Object tem;
-  Lisp_Object buffer;
-  Lisp_Object cons;
-  Lisp_Object opaque;
+call1_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 Lisp_Object object, int flags)
+{
+  Lisp_Object args[2];
+
+  args[0] = function;
+  args[1] = object;
+
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 2,
+				  args);
+}
+
+Lisp_Object
+call2_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 Lisp_Object object1, Lisp_Object object2,
+			 int flags)
+{
+  Lisp_Object args[3];
+
+  args[0] = function;
+  args[1] = object1;
+  args[2] = object2;
+
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 3,
+				  args);
+}
+
+Lisp_Object
+call3_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 Lisp_Object object1, Lisp_Object object2,
+			 Lisp_Object object3, int flags)
+{
+  Lisp_Object args[4];
+
+  args[0] = function;
+  args[1] = object1;
+  args[2] = object2;
+  args[3] = object3;
+
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 4,
+				  args);
+}
+
+Lisp_Object
+call4_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 Lisp_Object object1, Lisp_Object object2,
+			 Lisp_Object object3, Lisp_Object object4,
+			 int flags)
+{
+  Lisp_Object args[5];
+
+  args[0] = function;
+  args[1] = object1;
+  args[2] = object2;
+  args[3] = object3;
+  args[4] = object4;
+
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 5,
+				  args);
+}
+
+Lisp_Object
+call5_trapping_problems (const CIntbyte *warning_string, Lisp_Object function,
+			 Lisp_Object object1, Lisp_Object object2,
+			 Lisp_Object object3, Lisp_Object object4,
+			 Lisp_Object object5, int flags)
+{
+  Lisp_Object args[6];
+
+  args[0] = function;
+  args[1] = object1;
+  args[2] = object2;
+  args[3] = object3;
+  args[4] = object4;
+  args[5] = object5;
+
+  return calln_trapping_problems (Qerror, warning_string, flags, 0, 6,
+				  args);
+}
+
+struct eval_in_buffer_trapping_problems
+{
+  struct buffer *buf;
+  Lisp_Object form;
+};
+
+static Lisp_Object
+eval_in_buffer_trapping_problems_1 (void *arg)
+{
+  struct eval_in_buffer_trapping_problems *p =
+    (struct eval_in_buffer_trapping_problems *) arg;
+
+  return eval_in_buffer (p->buf, p->form);
+}
+
+/* #### fix these functions to follow the calling convention of
+   call_trapping_problems! */
+
+Lisp_Object
+eval_in_buffer_trapping_problems (const CIntbyte *warning_string,
+				  struct buffer *buf, Lisp_Object form,
+				  int flags)
+{
+  struct eval_in_buffer_trapping_problems p;
+  Lisp_Object buffer = wrap_buffer (buf);
   struct gcpro gcpro1, gcpro2;
 
-  buffer = wrap_buffer (buf);
-
-  specbind (Qinhibit_quit, Qt);
-  /* begin_gc_forbidden(); Currently no reason to do this; */
-
-  cons = noseeum_cons (buffer, form);
-  opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil);
-  GCPRO2 (cons, opaque);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_eval_in_buffer, cons,
-			  caught_a_squirmer, opaque);
-  free_cons (XCONS (cons));
-  if (OPAQUE_PTRP (opaque))
-    free_opaque_ptr (opaque);
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
+  GCPRO2 (buffer, form);
+  p.buf = buf;
+  p.form = form;
+  RETURN_UNGCPRO (call_trapping_problems (Qerror, warning_string, flags, 0,
+					  eval_in_buffer_trapping_problems_1,
+					  &p));
+}
+
+Lisp_Object
+run_hook_trapping_problems (const CIntbyte *warning_string,
+			    Lisp_Object hook_symbol,
+			    int flags)
+{
+  return run_hook_with_args_trapping_problems (warning_string, 1, &hook_symbol,
+					       RUN_HOOKS_TO_COMPLETION,
+					       flags);
 }
 
 static Lisp_Object
-catch_them_squirmers_run_hook (Lisp_Object hook_symbol)
-{
-  /* This function can GC */
-  run_hook (hook_symbol);
+safe_run_hook_trapping_problems_1 (void *puta)
+{
+  Lisp_Object hook = VOID_TO_LISP (puta);
+
+  run_hook (hook);
   return Qnil;
 }
 
+/* Same as run_hook_trapping_problems() but also set the hook to nil
+   if an error occurs (but not a quit). */
+
 Lisp_Object
-run_hook_trapping_errors (const CIntbyte *warning_string,
-			  Lisp_Object hook_symbol)
-{
-  int speccount;
+safe_run_hook_trapping_problems (const CIntbyte *warning_string,
+				 Lisp_Object hook_symbol,
+				 int flags)
+{
   Lisp_Object tem;
-  Lisp_Object opaque;
-  struct gcpro gcpro1;
+  struct gcpro gcpro1, gcpro2;
+  struct call_trapping_problems_result prob;
 
   if (!initialized || preparing_for_armageddon)
     return Qnil;
@@ -4704,186 +5387,136 @@
   if (NILP (tem) || UNBOUNDP (tem))
     return Qnil;
 
-  speccount = specpdl_depth();
-  specbind (Qinhibit_quit, Qt);
-
-  opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil);
-  GCPRO1 (opaque);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_run_hook, hook_symbol,
-                          caught_a_squirmer, opaque);
-  if (OPAQUE_PTRP (opaque))
-    free_opaque_ptr (opaque);
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
-}
-
-/* Same as run_hook_trapping_errors() but also set the hook to nil
-   if an error occurs. */
+  GCPRO2 (hook_symbol, tem);
+  tem = call_trapping_problems (Qerror, warning_string, flags,
+				&prob,
+				safe_run_hook_trapping_problems_1,
+				LISP_TO_VOID (hook_symbol));
+  if (prob.caught_throw || (prob.caught_error && !EQ (prob.error_conditions,
+						      Qquit)))
+    Fset (hook_symbol, Qnil);
+  RETURN_UNGCPRO (tem);
+}
+
+struct run_hook_with_args_in_buffer_trapping_problems
+{
+  struct buffer *buf;
+  int nargs;
+  Lisp_Object *args;
+  enum run_hooks_condition cond;
+};
+
+static Lisp_Object
+run_hook_with_args_in_buffer_trapping_problems_1 (void *puta)
+{
+  struct run_hook_with_args_in_buffer_trapping_problems *porra =
+    (struct run_hook_with_args_in_buffer_trapping_problems *) puta;
+
+  return run_hook_with_args_in_buffer (porra->buf, porra->nargs, porra->args,
+				       porra->cond);
+}
+
+/* #### fix these functions to follow the calling convention of
+   call_trapping_problems! */
 
 Lisp_Object
-safe_run_hook_trapping_errors (const CIntbyte *warning_string,
-			       Lisp_Object hook_symbol,
-			       int allow_quit)
-{
-  int speccount = specpdl_depth();
-  Lisp_Object tem;
-  Lisp_Object cons = Qnil;
+run_hook_with_args_in_buffer_trapping_problems (const CIntbyte *warning_string,
+						struct buffer *buf, int nargs,
+						Lisp_Object *args,
+						enum run_hooks_condition cond,
+						int flags)
+{
+  Lisp_Object sym, val, ret;
+  struct run_hook_with_args_in_buffer_trapping_problems diversity_and_distrust;
   struct gcpro gcpro1;
 
   if (!initialized || preparing_for_armageddon)
-    return Qnil;
-  tem = find_symbol_value (hook_symbol);
-  if (NILP (tem) || UNBOUNDP (tem))
+    /* We need to bail out of here pronto. */
     return Qnil;
 
-  if (!allow_quit)
-    specbind (Qinhibit_quit, Qt);
-
-  cons = noseeum_cons (hook_symbol,
-		       warning_string ? make_opaque_ptr ((void *)warning_string)
-		       : Qnil);
-  GCPRO1 (cons);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_run_hook,
-			  hook_symbol,
-			  allow_quit ?
-			  allow_quit_safe_run_hook_caught_a_squirmer :
-                          safe_run_hook_caught_a_squirmer,
-			  cons);
-  if (OPAQUE_PTRP (XCDR (cons)))
-    free_opaque_ptr (XCDR (cons));
-  free_cons (XCONS (cons));
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
-}
-
-static Lisp_Object
-catch_them_squirmers_call0 (Lisp_Object function)
-{
-  /* This function can GC */
-  return call0 (function);
+  GCPRO1_ARRAY (args, nargs);
+
+  sym = args[0];
+  val = symbol_value_in_buffer (sym, wrap_buffer (buf));
+  ret = (cond == RUN_HOOKS_UNTIL_FAILURE ? Qt : Qnil);
+
+  if (UNBOUNDP (val) || NILP (val))
+    RETURN_UNGCPRO (ret);
+
+  diversity_and_distrust.buf = buf;
+  diversity_and_distrust.nargs = nargs;
+  diversity_and_distrust.args = args;
+  diversity_and_distrust.cond = cond;
+
+  RETURN_UNGCPRO
+    (call_trapping_problems
+     (Qerror, warning_string,
+      flags, 0,
+      run_hook_with_args_in_buffer_trapping_problems_1,
+      &diversity_and_distrust));
 }
 
 Lisp_Object
-call0_trapping_errors (const CIntbyte *warning_string, Lisp_Object function)
-{
-  int speccount;
-  Lisp_Object tem;
-  Lisp_Object opaque = Qnil;
-  struct gcpro gcpro1, gcpro2;
-
-  if (SYMBOLP (function))
-    {
-      tem = XSYMBOL (function)->function;
-      if (NILP (tem) || UNBOUNDP (tem))
-	return Qnil;
-    }
-
-  GCPRO2 (opaque, function);
-  speccount = specpdl_depth();
-  specbind (Qinhibit_quit, Qt);
-  /* begin_gc_forbidden(); Currently no reason to do this; */
-
-  opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_call0, function,
-                          caught_a_squirmer, opaque);
-  if (OPAQUE_PTRP (opaque))
-    free_opaque_ptr (opaque);
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
-}
-
-static Lisp_Object
-catch_them_squirmers_call1 (Lisp_Object cons)
-{
-  /* This function can GC */
-  return call1 (XCAR (cons), XCDR (cons));
-}
-
-static Lisp_Object
-catch_them_squirmers_call2 (Lisp_Object cons)
-{
-  /* This function can GC */
-  return call2 (XCAR (cons), XCAR (XCDR (cons)), XCAR (XCDR (XCDR (cons))));
+run_hook_with_args_trapping_problems (const CIntbyte *warning_string,
+				      int nargs,
+				      Lisp_Object *args,
+				      enum run_hooks_condition cond,
+				      int flags)
+{
+  return run_hook_with_args_in_buffer_trapping_problems
+    (warning_string, current_buffer, nargs, args, cond, flags);
 }
 
 Lisp_Object
-call1_trapping_errors (const CIntbyte *warning_string, Lisp_Object function,
-		       Lisp_Object object)
-{
-  int speccount = specpdl_depth();
-  Lisp_Object tem;
-  Lisp_Object cons = Qnil;
-  Lisp_Object opaque = Qnil;
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
-
-  if (SYMBOLP (function))
-    {
-      tem = XSYMBOL (function)->function;
-      if (NILP (tem) || UNBOUNDP (tem))
-	return Qnil;
-    }
-
-  GCPRO4 (cons, opaque, function, object);
-
-  specbind (Qinhibit_quit, Qt);
-  /* begin_gc_forbidden(); Currently no reason to do this; */
-
-  cons = noseeum_cons (function, object);
-  opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_call1, cons,
-                          caught_a_squirmer, opaque);
-  if (OPAQUE_PTRP (opaque))
-    free_opaque_ptr (opaque);
-  free_cons (XCONS (cons));
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
+va_run_hook_with_args_trapping_problems (const CIntbyte *warning_string,
+					 Lisp_Object hook_var,
+					 int nargs, ...)
+{
+  /* This function can GC */
+  struct gcpro gcpro1;
+  int i;
+  va_list vargs;
+  Lisp_Object *funcall_args = alloca_array (Lisp_Object, 1 + nargs);
+  int flags;
+
+  va_start (vargs, nargs);
+  funcall_args[0] = hook_var;
+  for (i = 0; i < nargs; i++)
+    funcall_args[i + 1] = va_arg (vargs, Lisp_Object);
+  flags = va_arg (vargs, int);
+  va_end (vargs);
+
+  GCPRO1_ARRAY (funcall_args, nargs + 1);
+  RETURN_UNGCPRO (run_hook_with_args_in_buffer_trapping_problems
+		  (warning_string, current_buffer, nargs + 1, funcall_args,
+		   RUN_HOOKS_TO_COMPLETION, flags));
 }
 
 Lisp_Object
-call2_trapping_errors (const CIntbyte *warning_string, Lisp_Object function,
-		       Lisp_Object object1, Lisp_Object object2)
-{
-  int speccount = specpdl_depth();
-  Lisp_Object tem;
-  Lisp_Object cons = Qnil;
-  Lisp_Object opaque = Qnil;
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
-  if (SYMBOLP (function))
-    {
-      tem = XSYMBOL (function)->function;
-      if (NILP (tem) || UNBOUNDP (tem))
-	return Qnil;
-    }
-
-  GCPRO5 (cons, opaque, function, object1, object2);
-  specbind (Qinhibit_quit, Qt);
-  /* begin_gc_forbidden(); Currently no reason to do this; */
-
-  cons = list3 (function, object1, object2);
-  opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil);
-  /* Qerror not Qt, so you can get a backtrace */
-  tem = condition_case_1 (Qerror,
-                          catch_them_squirmers_call2, cons,
-                          caught_a_squirmer, opaque);
-  if (OPAQUE_PTRP (opaque))
-    free_opaque_ptr (opaque);
-  free_list (cons);
-  UNGCPRO;
-
-  return unbind_to_1 (speccount, tem);
+va_run_hook_with_args_in_buffer_trapping_problems (const CIntbyte *
+						   warning_string,
+						   struct buffer *buf,
+						   Lisp_Object hook_var,
+						   int nargs, ...)
+{
+  /* This function can GC */
+  struct gcpro gcpro1;
+  int i;
+  va_list vargs;
+  Lisp_Object *funcall_args = alloca_array (Lisp_Object, 1 + nargs);
+  int flags;
+
+  va_start (vargs, nargs);
+  funcall_args[0] = hook_var;
+  for (i = 0; i < nargs; i++)
+    funcall_args[i + 1] = va_arg (vargs, Lisp_Object);
+  flags = va_arg (vargs, int);
+  va_end (vargs);
+
+  GCPRO1_ARRAY (funcall_args, nargs + 1);
+  RETURN_UNGCPRO (run_hook_with_args_in_buffer_trapping_problems
+		  (warning_string, buf, nargs + 1, funcall_args,
+		   RUN_HOOKS_TO_COMPLETION, flags));
 }
 
 
@@ -4922,6 +5555,7 @@
     }
   XREALLOC_ARRAY (specpdl, struct specbinding, specpdl_size);
   specpdl_ptr = specpdl + specpdl_depth();
+  check_specbind_stack_sanity ();
 }
 
 
@@ -4931,9 +5565,9 @@
 {
   Lisp_Object current = Fcurrent_buffer ();
   Lisp_Object symbol = specpdl_ptr->symbol;
-  Lisp_Cons *victim = XCONS (ovalue);
-  Lisp_Object buf = get_buffer (victim->car, 0);
-  ovalue = victim->cdr;
+  Lisp_Object victim = ovalue;
+  Lisp_Object buf = get_buffer (XCAR (victim), 0);
+  ovalue = XCDR (victim);
 
   free_cons (victim);
 
@@ -5001,6 +5635,8 @@
 specbind (Lisp_Object symbol, Lisp_Object value)
 {
   SPECBIND (symbol, value);
+
+  check_specbind_stack_sanity ();
 }
 
 void
@@ -5033,6 +5669,8 @@
   specpdl_depth_counter++;
 
   Fset (symbol, value);
+
+  check_specbind_stack_sanity ();
 }
 
 /* Record an unwind-protect -- FUNCTION will be called with ARG no matter
@@ -5052,6 +5690,7 @@
   specpdl_ptr->old_value = arg;
   specpdl_ptr++;
   specpdl_depth_counter++;
+  check_specbind_stack_sanity ();
   return specpdl_depth_counter - 1;
 }
 
@@ -5062,7 +5701,7 @@
   Lisp_Object *addr = (Lisp_Object *) get_opaque_ptr (opaque);
   *addr = XCDR (cons);
   free_opaque_ptr (opaque);
-  free_cons (XCONS (cons));
+  free_cons (cons);
   return Qnil;
 }
 
@@ -5109,7 +5748,7 @@
 
   *addr = val;
   free_opaque_ptr (opaque);
-  free_cons (XCONS (cons));
+  free_cons (cons);
   return Qnil;
 }
 
@@ -5183,6 +5822,7 @@
 unbind_to_1 (int count, Lisp_Object value)
 {
   UNBIND_TO_GCPRO (count, value);
+  check_specbind_stack_sanity ();
   return value;
 }
 
@@ -5242,6 +5882,7 @@
 #endif
     }
   Vquit_flag = oquit;
+  check_specbind_stack_sanity ();
 }
 
 
@@ -5655,9 +6296,6 @@
 {
   preparing_for_armageddon = 0;
   in_warnings = 0;
-  Qunbound_suspended_errors_tag = make_opaque_ptr (&Qunbound_suspended_errors_tag);
-  staticpro_nodump (&Qunbound_suspended_errors_tag);
-
   specpdl_size = 50;
   specpdl = xnew_array (struct specbinding, specpdl_size);
   /* XEmacs change: increase these values. */
@@ -5686,8 +6324,14 @@
 */ );
 
   DEFVAR_LISP ("quit-flag", &Vquit_flag /*
-Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.
-Typing C-G sets `quit-flag' non-nil, regardless of `inhibit-quit'.
+t causes running Lisp code to abort, unless `inhibit-quit' is non-nil.
+`critical' causes running Lisp code to abort regardless of `inhibit-quit'.
+Normally, you do not need to set this value yourself.  It is set to
+t each time a Control-G is detected, and to `critical' each time a
+Shift-Control-G is detected.  The XEmacs core C code is littered with
+calls to the QUIT; macro, which check the values of `quit-flag' and
+`inhibit-quit' and abort (or more accurately, call (signal 'quit)) if
+it's correct to do so.
 */ );
   Vquit_flag = Qnil;
 
@@ -5696,9 +6340,11 @@
 Note that `quit-flag' will still be set by typing C-g,
 so a quit will be signalled as soon as `inhibit-quit' is nil.
 To prevent this happening, set `quit-flag' to nil
-before making `inhibit-quit' nil.  The value of `inhibit-quit' is
-ignored if a critical quit is requested by typing control-shift-G in
-an X frame.
+before making `inhibit-quit' nil.
+
+The value of `inhibit-quit' is ignored if a critical quit is
+requested by typing control-shift-G in a window-system frame;
+this is explained in more detail in `quit-flag'.
 */ );
   Vinhibit_quit = Qnil;
 
@@ -5783,6 +6429,9 @@
 */ );
   Vdebugger = Qnil;
 
+  staticpro (&Vcatch_everything_tag);
+  Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0);
+
   staticpro (&Vpending_warnings);
   Vpending_warnings = Qnil;
   dump_add_root_object (&Vpending_warnings_tail);
@@ -5796,12 +6445,11 @@
 
   staticpro (&Vcondition_handlers);
 
-  staticpro (&Vcurrent_warning_class);
-  Vcurrent_warning_class = Qnil;
-
-  staticpro (&Vcurrent_warning_level);
-  Vcurrent_warning_level = Qnil;
-
-  staticpro (&Vcurrent_error_state);
-  Vcurrent_error_state = Qnil; /* errors as normal */
-}
+  staticpro (&Vdeletable_permanent_display_objects);
+  Vdeletable_permanent_display_objects = Qnil;
+
+  staticpro (&Vmodifiable_buffers);
+  Vmodifiable_buffers = Qnil;
+
+  inhibit_flags = 0;
+}
--- a/src/event-Xt.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-Xt.c	Tue May 28 08:45:36 2002 +0000
@@ -845,7 +845,7 @@
 
    Of course, we DO worry about it, so we need a special translation. */
 void
-emacs_Xt_mapping_action (Widget w, XEvent* event)
+emacs_Xt_mapping_action (Widget w, XEvent *event)
 {
   struct device *d = get_device_from_display (event->xany.display);
 
@@ -1602,9 +1602,9 @@
    with keyboard focus when FocusOut is processed, and then, when a
    widget gets unmapped, it calls this function to restore focus if
    appropriate. */
-void emacs_Xt_handle_widget_losing_focus (struct frame* f, Widget losing_widget);
+void emacs_Xt_handle_widget_losing_focus (struct frame *f, Widget losing_widget);
 void
-emacs_Xt_handle_widget_losing_focus (struct frame* f, Widget losing_widget)
+emacs_Xt_handle_widget_losing_focus (struct frame *f, Widget losing_widget)
 {
   if (losing_widget == widget_with_focus)
     {
@@ -1845,11 +1845,11 @@
    does the wrong thing.
 */
 static void
-emacs_Xt_force_event_pending (struct frame* f)
+emacs_Xt_force_event_pending (struct frame *f)
 {
   XEvent event;
 
-  Display* dpy = DEVICE_X_DISPLAY (XDEVICE (FRAME_DEVICE  (f)));
+  Display *dpy = DEVICE_X_DISPLAY (XDEVICE (FRAME_DEVICE  (f)));
   event.xclient.type		= ClientMessage;
   event.xclient.display		= dpy;
   event.xclient.message_type	= XInternAtom (dpy, "BumpQueue", False);
@@ -2309,39 +2309,62 @@
 }
 
 static void
-emacs_Xt_select_process (Lisp_Process *p)
+emacs_Xt_select_process (Lisp_Process *process, int doin, int doerr)
 {
-  Lisp_Object process;
-  int infd = event_stream_unixoid_select_process (p);
-
-  process = wrap_process (p);
-  select_filedesc (infd, process);
+  Lisp_Object proc;
+  int infd, errfd;
+
+  event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
+
+  proc = wrap_process (process);
+  if (doin)
+    select_filedesc (infd, proc);
+  if (doerr)
+    select_filedesc (errfd, proc);
+}
+
+static void
+emacs_Xt_unselect_process (Lisp_Process *process, int doin, int doerr)
+{
+  int infd, errfd;
+
+  event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
+
+  if (doin)
+    unselect_filedesc (infd);
+  if (doerr)
+    unselect_filedesc (errfd);
 }
 
 static void
-emacs_Xt_unselect_process (Lisp_Process *p)
-{
-  int infd = event_stream_unixoid_unselect_process (p);
-
-  unselect_filedesc (infd);
-}
-
-static USID
-emacs_Xt_create_stream_pair (void* inhandle, void* outhandle,
-		Lisp_Object* instream, Lisp_Object* outstream, int flags)
+emacs_Xt_create_io_streams (void *inhandle, void *outhandle,
+			    void *errhandle, Lisp_Object *instream,
+			    Lisp_Object *outstream,
+			    Lisp_Object *errstream,
+			    USID *in_usid,
+			    USID *err_usid,
+			    int flags)
 {
-  USID u = event_stream_unixoid_create_stream_pair
-		(inhandle, outhandle, instream, outstream, flags);
-  if (u != USID_ERROR)
-    u = USID_DONTHASH;
-  return u;
+  event_stream_unixoid_create_io_streams
+    (inhandle, outhandle, errhandle, instream, outstream,
+     errstream, in_usid, err_usid, flags);
+  if (*in_usid != USID_ERROR)
+    *in_usid = USID_DONTHASH;
+  if (*err_usid != USID_ERROR)
+    *err_usid = USID_DONTHASH;
 }
 
-static USID
-emacs_Xt_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream)
+static void
+emacs_Xt_delete_io_streams (Lisp_Object instream,
+			    Lisp_Object outstream,
+			    Lisp_Object errstream,
+			    USID *in_usid,
+			    USID *err_usid)
 {
-  event_stream_unixoid_delete_stream_pair (instream, outstream);
-  return USID_DONTHASH;
+  event_stream_unixoid_delete_io_streams
+    (instream, outstream, errstream, in_usid, err_usid);
+  *in_usid = USID_DONTHASH;
+  *err_usid = USID_DONTHASH;
 }
 
 /* This is called from GC when a process object is about to be freed.
@@ -2352,12 +2375,13 @@
 {
 #if 0 /* #### */
   int i;
-  Lisp_Object instr, outstr;
-
-  get_process_streams (p, &instr, &outstr);
+  Lisp_Object instr, outstr, errstr;
+
+  get_process_streams (p, &instr, &outstr, &errstr);
   /* if it still has fds, then it hasn't been killed yet. */
   assert (NILP(instr));
   assert (NILP(outstr));
+  assert (NILP(errstr));
   /* Better not still be in the "with input" table; we know it's got no fds. */
   for (i = 0; i < MAXDESC; i++)
     {
@@ -3273,7 +3297,7 @@
 				String   *params,
 				Cardinal *num_params)
 {
-  struct frame* f =
+  struct frame *f =
     x_any_widget_or_parent_to_frame (get_device_from_display (event->xany.display), w);
 
   XtSetKeyboardFocus (FRAME_X_SHELL_WIDGET (f), w);
@@ -3330,8 +3354,8 @@
   Xt_event_stream->select_process_cb 	 = emacs_Xt_select_process;
   Xt_event_stream->unselect_process_cb 	 = emacs_Xt_unselect_process;
   Xt_event_stream->quit_p_cb		 = emacs_Xt_quit_p;
-  Xt_event_stream->create_stream_pair_cb = emacs_Xt_create_stream_pair;
-  Xt_event_stream->delete_stream_pair_cb = emacs_Xt_delete_stream_pair;
+  Xt_event_stream->create_io_streams_cb  = emacs_Xt_create_io_streams;
+  Xt_event_stream->delete_io_streams_cb  = emacs_Xt_delete_io_streams;
   Xt_event_stream->current_event_timestamp_cb =
     emacs_Xt_current_event_timestamp;
 
--- a/src/event-gtk.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-gtk.c	Tue May 28 08:45:36 2002 +0000
@@ -496,10 +496,11 @@
 
 static int timeout_id_tick;
 
-struct GTK_timeout {
-    int id;
-    guint timeout_id;
-    struct GTK_timeout *next;
+struct GTK_timeout
+{
+  int id;
+  guint timeout_id;
+  struct GTK_timeout *next;
 } *pending_timeouts, *completed_timeouts;
 
 struct GTK_timeout_blocktype
@@ -526,7 +527,7 @@
   /* Add this one to the list of completed timeouts */
   timeout->next = completed_timeouts;
   completed_timeouts = timeout;
-  return(FALSE);
+  return FALSE;
 }
 
 static int
@@ -685,15 +686,11 @@
 	}
       filedesc_with_input[closure->fd] = closure->what;
       if (PROCESSP (closure->what))
-	{
-	  /* Don't increment this if the current process is already marked
-	   *  as having input. */
-	  process_events_occurred++;
-	}
+	/* Don't increment this if the current process is already marked
+	 *  as having input. */
+	process_events_occurred++;
       else
-	{
-	  tty_events_occurred++;
-	}
+	tty_events_occurred++;
     }
 }
 
@@ -778,39 +775,62 @@
 }
 
 static void
-emacs_gtk_select_process (struct Lisp_Process *p)
+emacs_gtk_select_process (Lisp_Process *process, int doin, int doerr)
 {
-  Lisp_Object process;
-  int infd = event_stream_unixoid_select_process (p);
+  Lisp_Object proc;
+  int infd, errfd;
+
+  event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
+
+  proc = wrap_process (process);
+  if (doin)
+    select_filedesc (infd, proc);
+  if (doerr)
+    select_filedesc (errfd, proc);
+}
 
-  process = wrap_process (p);
-  select_filedesc (infd, process);
+static void
+emacs_gtk_unselect_process (Lisp_Process *process, int doin, int doerr)
+{
+  int infd, errfd;
+
+  event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
+
+  if (doin)
+    unselect_filedesc (infd);
+  if (doerr)
+    unselect_filedesc (errfd);
 }
 
 static void
-emacs_gtk_unselect_process (struct Lisp_Process *p)
+emacs_gtk_create_io_streams (void *inhandle, void *outhandle,
+			     void *errhandle, Lisp_Object *instream,
+			     Lisp_Object *outstream,
+			     Lisp_Object *errstream,
+			     USID *in_usid,
+			     USID *err_usid,
+			     int flags)
 {
-  int infd = event_stream_unixoid_unselect_process (p);
-
-  unselect_filedesc (infd);
+  event_stream_unixoid_create_io_streams
+    (inhandle, outhandle, errhandle, instream, outstream,
+     errstream, in_usid, err_usid, flags);
+  if (*in_usid != USID_ERROR)
+    *in_usid = USID_DONTHASH;
+  if (*err_usid != USID_ERROR)
+    *err_usid = USID_DONTHASH;
 }
 
-static USID
-emacs_gtk_create_stream_pair (void* inhandle, void* outhandle,
-			      Lisp_Object* instream, Lisp_Object* outstream, int flags)
+static void
+emacs_gtk_delete_io_streams (Lisp_Object instream,
+			     Lisp_Object outstream,
+			     Lisp_Object errstream,
+			     USID *in_usid,
+			     USID *err_usid)
 {
-    USID u = event_stream_unixoid_create_stream_pair
-	(inhandle, outhandle, instream, outstream, flags);
-    if (u != USID_ERROR)
-	u = USID_DONTHASH;
-    return u;
-}
-
-static USID
-emacs_gtk_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream)
-{
-  event_stream_unixoid_delete_stream_pair (instream, outstream);
-  return USID_DONTHASH;
+  event_stream_unixoid_delete_io_streams
+    (instream, outstream, errstream, in_usid, err_usid);
+  *in_usid = USID_DONTHASH;
+  *err_usid = USID_DONTHASH;
 }
 
 /* This is called from GC when a process object is about to be freed.
--- a/src/event-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -39,6 +39,28 @@
 #include <config.h>
 #include "lisp.h"
 
+#if defined (CYGWIN) && !defined (HAVE_MSG_SELECT)
+#error We do not support non-select() versions (i.e. very old) of Cygwin.
+#endif
+
+/* Acceptable are:
+
+   WIN32_NATIVE and HAVE_WIN32_PROCESSES and nothing else
+
+   CYGWIN and HAVE_MSG_SELECT and HAVE_UNIX_PROCESSES and nothing else
+*/
+#ifdef WIN32_NATIVE
+# if !(defined (HAVE_WIN32_PROCESSES && !defined (HAVE_UNIX_PROCESSES) && !defined (HAVE_MSG_SELECT) && !defined (CYGWIN)))
+#  error Something is wrong with your process definitions for Windows native.
+# endif
+#elif defined (CYGWIN)
+# if !(defined (HAVE_UNIX_PROCESSES) && defined (HAVE_MSG_SELECT) && !defined (HAVE_WIN32_PROCESSES) && !defined (WIN32_NATIVE))
+#  error Something is wrong with your process definitions for Cygwin.
+# endif
+#else
+# error Something is wrong -- you are neither Windows native (possibly MinGW) nor Cygwin.
+#endif
+
 #include "buffer.h"
 #include "device.h"
 #include "events.h"
@@ -72,10 +94,8 @@
 #include "systime.h"
 #include "syswait.h"
 
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
 #include "console-tty.h"
-#elif defined (CYGWIN)
-typedef unsigned int SOCKET;
 #endif
 
 #ifdef HAVE_MENUBARS
@@ -105,12 +125,22 @@
 
 static struct event_stream *mswindows_event_stream;
 
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
+
 extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
 extern SELECT_TYPE process_only_mask, tty_only_mask;
 SELECT_TYPE zero_mask;
 extern int signal_event_pipe_initialized;
 int windows_fd;
+
+#else
+
+/* List of mswindows waitable handles. */
+static HANDLE mswindows_waitable_handles[MAX_WAITABLE];
+
+/* Number of wait handles */
+static int mswindows_waitable_count = 0;
+
 #endif
 
 /*
@@ -125,14 +155,6 @@
 /* The number of things we can wait on */
 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
 
-#ifndef HAVE_MSG_SELECT
-/* List of mswindows waitable handles. */
-static HANDLE mswindows_waitable_handles[MAX_WAITABLE];
-
-/* Number of wait handles */
-static int mswindows_waitable_count=0;
-#endif /* HAVE_MSG_SELECT */
-
 /* Brush for painting widgets */
 static HBRUSH widget_brush = 0;
 static LONG	last_widget_brushed = 0;
@@ -159,14 +181,17 @@
 
 /* This is the event signaled by the event pump.
    See mswindows_pump_outstanding_events for comments */
-static Lisp_Object mswindows_error_caught_in_modal_loop;
+static int mswindows_error_caught_in_modal_loop;
 static int mswindows_in_modal_loop;
 
 /* Count of wound timers */
 static int mswindows_pending_timers_count;
 
 static DWORD mswindows_last_mouse_button_state;
+
 
+#ifndef CYGWIN /* Skips past slurp, shove, or winsock streams */
+
 /************************************************************************/
 /*                Pipe instream - reads process output                  */
 /************************************************************************/
@@ -192,11 +217,11 @@
 struct ntpipe_slurp_stream_shared_data
 {
   HANDLE hev_thread;	/* Our thread blocks on this, signaled by caller */
-  /* This is a manual-reset object. 		 */
+			/* This is a manual-reset object. 		 */
   HANDLE hev_caller;	/* Caller blocks on this, and we signal it	 */
-  /* This is a manual-reset object. 		 */
+			/* This is a manual-reset object. 		 */
   HANDLE hev_unsleep;	/* Pipe read delay is canceled if this is set	 */
-  /* This is a manual-reset object. 		 */
+			/* This is a manual-reset object. 		 */
   HANDLE hpipe;		/* Pipe read end handle.			 */
   LONG   die_p;		/* Thread must exit ASAP if non-zero		 */
   BOOL   eof_p   : 1;	/* Set when thread saw EOF			 */
@@ -467,6 +492,7 @@
   LSTREAM_HAS_METHOD (ntpipe_slurp, reader);
   LSTREAM_HAS_METHOD (ntpipe_slurp, closer);
 }
+
 
 /************************************************************************/
 /*                Pipe outstream - writes process input                 */
@@ -481,7 +507,7 @@
 {
   LPARAM user_data;	/* Any user data stored in the stream object	 */
   HANDLE hev_thread;	/* Our thread blocks on this, signaled by caller */
-  /* This is an auto-reset object. 		 */
+			/* This is an auto-reset object. 		 */
   HANDLE hpipe;		/* Pipe write end handle.			 */
   HANDLE hthread;	/* Reader thread handle.			 */
   char	 buffer[MAX_SHOVE_BUFFER_SIZE];	/* Buffer being written		 */
@@ -494,7 +520,6 @@
 
 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-output", ntpipe_shove);
 
-#ifndef HAVE_MSG_SELECT
 static DWORD WINAPI
 shove_thread (LPVOID vparam)
 {
@@ -579,7 +604,6 @@
   struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
   return s->user_data;
 }
-#endif
 
 static Bytecount
 ntpipe_shove_writer (Lstream *stream, const unsigned char *data,
@@ -656,7 +680,6 @@
 /************************************************************************/
 /*                         Winsock I/O stream                           */
 /************************************************************************/
-#if defined (HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
 
 #define WINSOCK_READ_BUFFER_SIZE 1024
 
@@ -883,7 +906,7 @@
   LSTREAM_HAS_METHOD (winsock, closer);
   LSTREAM_HAS_METHOD (winsock, was_blocked_p);
 }
-#endif /* defined (HAVE_SOCKETS) */
+#endif /* ! CYGWIN */
 
 /************************************************************************/
 /*                     Dispatch queue management                        */
@@ -1104,7 +1127,7 @@
   return Qnil;
 }
 
-#ifndef HAVE_MSG_SELECT
+#ifndef CYGWIN
 /************************************************************************/
 /*                     Waitable handles manipulation                    */
 /************************************************************************/
@@ -1140,7 +1163,8 @@
   mswindows_waitable_handles [ix] =
     mswindows_waitable_handles [--mswindows_waitable_count];
 }
-#endif /* HAVE_MSG_SELECT */
+
+#endif /* CYGWIN */
 
 /*
  * Given a lisp process pointer remove the corresponding process handle
@@ -1152,9 +1176,9 @@
 void
 mswindows_unwait_process (Lisp_Process *p)
 {
-#ifndef HAVE_MSG_SELECT
+#ifndef CYGWIN
   remove_waitable_handle (get_nt_process_handle (p));
-#endif /* HAVE_MSG_SELECT */
+#endif /* CYGWIN */
 }
 
 
@@ -1177,24 +1201,38 @@
   return !ascii_strcasecmp (class_name_buf, XEMACS_CLASS);
 }
 
+struct mswindows_protect_modal_loop
+{
+  Lisp_Object (*bfun) (Lisp_Object barg);
+  Lisp_Object barg;
+};
+
 static Lisp_Object
-mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
-				    Lisp_Object u_n_u_s_e_d)
+mswindows_protect_modal_loop_1 (void *gack)
 {
-  mswindows_error_caught_in_modal_loop = cons_sig_data;
-  return Qunbound;
+  struct mswindows_protect_modal_loop *gata =
+    (struct mswindows_protect_modal_loop *) gack;
+
+  return (gata->bfun) (gata->barg);
 }
 
 Lisp_Object
-mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
-			      Lisp_Object barg)
+mswindows_protect_modal_loop (const char *error_string,
+			      Lisp_Object (*bfun) (Lisp_Object barg),
+			      Lisp_Object barg, int flags)
 {
   Lisp_Object tmp;
+  struct mswindows_protect_modal_loop bluh;
+
+  bluh.bfun = bfun;
+  bluh.barg = barg;
 
   ++mswindows_in_modal_loop;
-  tmp = condition_case_1 (Qt,
-			  bfun, barg,
-			  mswindows_modal_loop_error_handler, Qnil);
+  tmp = call_trapping_problems (Qevent, error_string,
+				flags, 0,
+				mswindows_protect_modal_loop_1, &bluh);
+  if (UNBOUNDP (tmp))
+    mswindows_error_caught_in_modal_loop = 1;
   --mswindows_in_modal_loop;
 
   return tmp;
@@ -1203,15 +1241,7 @@
 void
 mswindows_unmodalize_signal_maybe (void)
 {
-  if (!NILP (mswindows_error_caught_in_modal_loop))
-    {
-      /* Got an error while messages were pumped while
-	 in window procedure - have to resignal */
-      Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
-      Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
-      mswindows_error_caught_in_modal_loop = Qnil;
-      Fsignal (sym, data);
-    }
+  mswindows_error_caught_in_modal_loop = 0;
 }
 
 /*
@@ -1259,26 +1289,23 @@
  * Return value is Qt if no errors was trapped, or Qunbound if
  * there was an error.
  *
- * In case of error, a cons representing the error, in the
- * form (SIGNAL . DATA), is stored in the module local variable
- * mswindows_error_caught_in_modal_loop. This error is signaled
- * again when DispatchMessage returns. Thus, Windows internal
- * modal loops are protected against throws, which are proven
- * to corrupt internal Windows structures.
+ * In case of error, a warning is issued and the module local variable
+ * mswindows_error_caught_in_modal_loop is set to non-zero.  Thus,
+ * Windows internal modal loops are protected against throws, which
+ * are proven to corrupt internal Windows structures.
  *
  * In case of success, mswindows_error_caught_in_modal_loop is
- * assigned Qnil.
+ * assigned 0.
  *
  * If the value of mswindows_error_caught_in_modal_loop is not
- * nil already upon entry, the function just returns non-nil.
+ * zero already upon entry, the function just returns non-nil.
  * This situation means that a new event has been queued while
  * in cancel mode. The event will be dequeued on the next regular
  * call of next-event; the pump is off since error is caught.
  * The caller must *unconditionally* cancel modal loop if the
  * value returned by this function is nil. Otherwise, everything
  * will become frozen until the modal loop exits under normal
- * condition (scrollbar drag is released, menu closed etc.)
- */
+ * condition (scrollbar drag is released, menu closed etc.)  */
 Lisp_Object
 mswindows_pump_outstanding_events (void)
 {
@@ -1288,8 +1315,9 @@
   struct gcpro gcpro1;
   GCPRO1 (result);
 
-  if (NILP(mswindows_error_caught_in_modal_loop))
-    result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
+  if (!mswindows_error_caught_in_modal_loop)
+    result = mswindows_protect_modal_loop
+      ("Error during event handling", mswindows_unsafe_pump_events, Qnil, 0);
   UNGCPRO;
   return result;
 }
@@ -1409,7 +1437,7 @@
   while (NILP (mswindows_u_dispatch_event_queue)
 	 && NILP (mswindows_s_dispatch_event_queue))
     {
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
       int i;
       int active;
       SELECT_TYPE temp_mask = input_wait_mask;
@@ -1506,7 +1534,7 @@
 	{
 	  assert(0);
 	}
-#else /* not HAVE_MSG_SELECT */
+#else /* not CYGWIN */
       /* Now try getting a message or process event */
       DWORD active;
       DWORD what_events;
@@ -1592,18 +1620,18 @@
 	 (hyphen, VK_SUBTRACT) key on an 82-key keyboard.
 	 */
 
-  __try
-    {
-      active = MsgWaitForMultipleObjects (mswindows_waitable_count,
-					  mswindows_waitable_handles,
-					  FALSE, badly_p ? INFINITE : 0,
-					  what_events);
-    }
-  __except (GetExceptionCode () == EXCEPTION_BREAKPOINT ?
-	    EXCEPTION_CONTINUE_EXECUTION :
-	    EXCEPTION_CONTINUE_SEARCH)
-    {
-    }
+      __try
+	{
+	  active = MsgWaitForMultipleObjects (mswindows_waitable_count,
+					      mswindows_waitable_handles,
+					      FALSE, badly_p ? INFINITE : 0,
+					      what_events);
+	}
+      __except (GetExceptionCode () == EXCEPTION_BREAKPOINT ?
+		EXCEPTION_CONTINUE_EXECUTION :
+		EXCEPTION_CONTINUE_SEARCH)
+	{
+	}
 
       /* This will assert if handle being waited for becomes abandoned.
 	 Not the case currently tho */
@@ -1629,7 +1657,8 @@
 	  int ix = active - WAIT_OBJECT_0;
 	  /* First, try to find which process' output has signaled */
 	  Lisp_Process *p =
-	    get_process_from_usid (HANDLE_TO_USID (mswindows_waitable_handles[ix]));
+	    get_process_from_usid (HANDLE_TO_USID
+				   (mswindows_waitable_handles[ix]));
 	  if (p != NULL)
 	    {
 	      /* Found a signaled process input handle */
@@ -1652,22 +1681,20 @@
 		 (1) accept-process-output will return when called on this
 		 process, and (2) status notifications will happen in
 		 accept-process-output, sleep-for, and sit-for. */
-	      /* #### horrible kludge till my real process fixes go in.
-		 #### Replaced with a slightly less horrible kluge that
-		      at least finds the right process instead of axing the
-		      first one on the list.
-	       */
 	      if (!NILP (vproctail))
+		  mswindows_enqueue_process_event (XPROCESS (vaffanculo));
+	      else
 		{
-		  mswindows_enqueue_process_event (XPROCESS (vaffanculo));
+		  /* abort (); */
+		  /* #### FUCKME!  When can this happen?  I hit this abort()
+		     when I tried enabling it. */
+		  /* Have to return something: there may be no accompanying
+		     process event */
+		  mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
 		}
-	      else /* trash me soon. */
-		/* Have to return something: there may be no accompanying
-		   process event */
-		mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
 	    }
 	}
-#endif /* not HAVE_MSG_SELECT */
+#endif /* not CYGWIN */
     } /* while */
 }
 
@@ -1715,8 +1742,8 @@
     {
     case XTYP_CONNECT:
       if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
-	return (HDDEDATA)TRUE;
-      return (HDDEDATA)FALSE;
+	return (HDDEDATA) TRUE;
+      return (HDDEDATA) FALSE;
 
     case XTYP_WILDCONNECT:
       {
@@ -1729,10 +1756,10 @@
 	      || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
 	    !(hszTopic
 	      || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)))
-	  return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
+	  return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE) pairs,
 				       sizeof (pairs), 0L, 0, uFmt, 0));
       }
-      return (HDDEDATA)NULL;
+      return (HDDEDATA) NULL;
 
     case XTYP_EXECUTE:
       if (!mswindows_dde_enable)
@@ -1741,7 +1768,7 @@
       if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
 	{
 	  DWORD len = DdeGetData (hdata, NULL, 0, 0);
-	  LPBYTE extcmd = (LPBYTE) ALLOCA (len+1);
+	  LPBYTE extcmd = (LPBYTE) ALLOCA (len + 1);
 	  Intbyte *cmd;
 	  Intbyte *end;
 	  struct gcpro gcpro1, gcpro2;
@@ -2197,7 +2224,8 @@
 
     case WM_CLOSE:
       fobj = mswindows_find_frame (hwnd);
-      mswindows_enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
+      mswindows_enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj,
+							     Qt));
       break;
 
     case WM_KEYUP:
@@ -3163,7 +3191,7 @@
 
 	mswindows_handle_scrollbar_event (hwndScrollBar, code,  pos);
 	GCPRO2 (emacs_event, fobj);
-	if (UNBOUNDP (mswindows_pump_outstanding_events()))	/* Can GC */
+	if (UNBOUNDP (mswindows_pump_outstanding_events ())) /* Can GC */
 	  {
 	    /* Error during event pumping - cancel scroll */
 	    qxeSendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
@@ -3297,7 +3325,7 @@
       goto defproc;
 
 #ifdef HAVE_DRAGNDROP
-    case WM_DROPFILES:	/* implementation ripped-off from event-Xt.c */
+    case WM_DROPFILES:		/* implementation ripped-off from event-Xt.c */
       {
 	UINT filecount, i;
 	POINT point;
@@ -3311,7 +3339,7 @@
 	GCPRO3 (emacs_event, l_dndlist, l_item);
 
 	if (!DragQueryPoint ((HDROP) wParam, &point))
-	  point.x = point.y = -1;		/* outside client area */
+	  point.x = point.y = -1; /* outside client area */
 
 	event->event_type = misc_user_event;
 	event->channel = mswindows_find_frame (hwnd);
@@ -4095,62 +4123,121 @@
     }
 }
 
-#ifndef HAVE_MSG_SELECT
+#ifndef CYGWIN
+
 static HANDLE
 get_process_input_waitable (Lisp_Process *process)
 {
-  Lisp_Object instr, outstr, p;
+  Lisp_Object instr, outstr, errstr, p;
   p = wrap_process (process);
-  get_process_streams (process, &instr, &outstr);
+  get_process_streams (process, &instr, &outstr, &errstr);
   assert (!NILP (instr));
-#if defined (HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
   return (network_connection_p (p)
 	  ? get_winsock_stream_waitable (XLSTREAM (instr))
 	  : get_ntpipe_input_stream_waitable (XLSTREAM (instr)));
-#else
-  return get_ntpipe_input_stream_waitable (XLSTREAM (instr));
-#endif
 }
 
+static HANDLE
+get_process_stderr_waitable (Lisp_Process *process)
+{
+  Lisp_Object instr, outstr, errstr;
+  get_process_streams (process, &instr, &outstr, &errstr);
+  if (NILP (errstr))
+    return INVALID_HANDLE_VALUE;
+  return get_ntpipe_input_stream_waitable (XLSTREAM (errstr));
+}
+
+#endif /* not CYGWIN */
+
 static void
-emacs_mswindows_select_process (Lisp_Process *process)
+emacs_mswindows_select_process (Lisp_Process *process, int doin, int doerr)
 {
-  HANDLE hev = get_process_input_waitable (process);
-
-  if (!add_waitable_handle (hev))
-    invalid_operation ("Too many active processes", Qunbound);
-
-#ifdef HAVE_WIN32_PROCESSES
+#ifdef CYGWIN
+  int infd, errfd;
+
+  event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
+#else
+  HANDLE hev = INVALID_HANDLE_VALUE;
+  HANDLE herr = INVALID_HANDLE_VALUE;
+
+  if (doin)
+    {
+      hev = get_process_input_waitable (process);
+      if (!add_waitable_handle (hev))
+	{
+	  hev = INVALID_HANDLE_VALUE;
+	  goto err;
+	}
+    }
+
+  if (doerr)
+    {
+      herr = get_process_stderr_waitable (process);
+      if (herr != INVALID_HANDLE_VALUE && !add_waitable_handle (herr))
+	{
+	  herr = INVALID_HANDLE_VALUE;
+	  goto err;
+	}
+    }
+
   {
+    /* Also select on the process handle itself, so we can receive
+       exit notifications.  Only do this once, not each time this
+       function is called (which can happen many times, e.g. if
+       (set-process-filter proc t) is called and then a process filter
+       is set again).  It will be unselected in mswindows_need_event(). */
     Lisp_Object p = wrap_process (process);
 
     if (!network_connection_p (p))
       {
-	HANDLE hprocess = get_nt_process_handle (process);
-	if (!add_waitable_handle (hprocess))
-	  {
-	    remove_waitable_handle (hev);
-	    invalid_operation ("Too many active processes", Qunbound);
-	  }
+	HANDLE hprocess = get_nt_process_handle_only_first_time (process);
+	if (hprocess != INVALID_HANDLE_VALUE
+	    && !add_waitable_handle (hprocess))
+	  goto err;
       }
   }
-#endif
+
+  return;
+
+ err:
+  if (hev != INVALID_HANDLE_VALUE)
+    remove_waitable_handle (hev);
+  if (herr != INVALID_HANDLE_VALUE)
+    remove_waitable_handle (herr);
+  invalid_operation ("Too many active processes", wrap_process (process));
+#endif /* CYGWIN */
 }
 
 static void
-emacs_mswindows_unselect_process (Lisp_Process *process)
+emacs_mswindows_unselect_process (Lisp_Process *process, int doin, int doerr)
 {
-  /* Process handle is removed in the event loop as soon
-     as it is signaled, so don't bother here about it */
-  HANDLE hev = get_process_input_waitable (process);
-  remove_waitable_handle (hev);
+#ifdef CYGWIN
+  int infd, errfd;
+
+  event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
+#else
+  if (doin)
+    {
+      /* Process handle is removed in the event loop as soon
+	 as it is signaled, so don't bother here about it */
+      HANDLE hev = get_process_input_waitable (process);
+      remove_waitable_handle (hev);
+    }
+  if (doerr)
+    {
+      /* Process handle is removed in the event loop as soon
+	 as it is signaled, so don't bother here about it */
+      HANDLE herr = get_process_stderr_waitable (process);
+      if (herr != INVALID_HANDLE_VALUE)
+        remove_waitable_handle (herr);
+    }
+#endif /* CYGWIN */
 }
-#endif /* HAVE_MSG_SELECT */
 
 static void
 emacs_mswindows_select_console (struct console *con)
 {
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
   if (CONSOLE_MSWINDOWS_P (con))
     return; /* mswindows consoles are automatically selected */
 
@@ -4161,7 +4248,7 @@
 static void
 emacs_mswindows_unselect_console (struct console *con)
 {
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
   if (CONSOLE_MSWINDOWS_P (con))
     return; /* mswindows consoles are automatically selected */
 
@@ -4209,107 +4296,95 @@
     }
 }
 
-USID
-emacs_mswindows_create_stream_pair (void *inhandle, void *outhandle,
-				    Lisp_Object *instream,
-				    Lisp_Object *outstream,
-				    int flags)
+static void
+emacs_mswindows_create_io_streams (void *inhandle, void *outhandle,
+				   void *errhandle, Lisp_Object *instream,
+				   Lisp_Object *outstream,
+				   Lisp_Object *errstream,
+				   USID *in_usid,
+				   USID *err_usid,
+				   int flags)
 {
+#ifdef CYGWIN
+  event_stream_unixoid_create_io_streams (inhandle, outhandle,
+					  errhandle, instream,
+					  outstream, errstream,
+					  in_usid, err_usid, flags);
+#else
   /* Handles for streams */
-  HANDLE hin, hout;
+  HANDLE hin, hout, herr;
   /* fds. These just stored along with the streams, and are closed in
      delete stream pair method, because we need to handle fake unices
      here. */
-  int fdi, fdo;
-
-  /* Decode inhandle and outhandle. Their meaning depends on
+  int fdi, fdo, fde;
+
+  /* Decode inhandle, outhandle, errhandle. Their meaning depends on
      the process implementation being used. */
-#if defined (HAVE_WIN32_PROCESSES)
-  /* We're passed in Windows handles. That's what we like most... */
   hin = (HANDLE) inhandle;
   hout = (HANDLE) outhandle;
-  fdi = fdo = -1;
-#elif defined (HAVE_UNIX_PROCESSES)
-  /* We are passed UNIX fds. This must be Cygwin.
-     Fetch os handles */
-  hin = inhandle >= 0 ? (HANDLE)get_osfhandle ((int)inhandle) : INVALID_HANDLE_VALUE;
-  hout = outhandle >= 0 ? (HANDLE)get_osfhandle ((int)outhandle) : INVALID_HANDLE_VALUE;
-  fdi=(int)inhandle;
-  fdo=(int)outhandle;
-#else
-#error "So, WHICH kind of processes do you want?"
-#endif
+  if (errhandle == (void *) -1)
+    herr = INVALID_HANDLE_VALUE;
+  else
+    herr = (HANDLE) errhandle;
+  fdi = fdo = fde = -1;
 
   *instream = (hin == INVALID_HANDLE_VALUE
 	       ? Qnil
-#if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
 	       : flags & STREAM_NETWORK_CONNECTION
-	       ? make_winsock_input_stream ((SOCKET)hin, fdi)
-#endif
+	       ? make_winsock_input_stream ((SOCKET) hin, fdi)
 	       : make_ntpipe_input_stream (hin, fdi));
 
-#ifdef HAVE_WIN32_PROCESSES
+  *errstream = (herr == INVALID_HANDLE_VALUE
+		? Qnil
+		: make_ntpipe_input_stream (herr, fde));
+
   *outstream = (hout == INVALID_HANDLE_VALUE
 		? Qnil
-#if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
 		: flags & STREAM_NETWORK_CONNECTION
 		? make_winsock_output_stream ((SOCKET)hout, fdo)
-#endif
 		: make_ntpipe_output_stream (hout, fdo));
-#elif defined (HAVE_UNIX_PROCESSES)
-  *outstream = (fdo >= 0
-		? make_filedesc_output_stream (fdo, 0, -1, LSTR_BLOCKED_OK)
-		: Qnil);
-
-#if defined(HAVE_UNIX_PROCESSES)
-  /* FLAGS is process->pty_flag for UNIX_PROCESSES */
-  if ((flags & STREAM_PTY_FLUSHING) && fdo >= 0)
-    {
-      Intbyte eof_char = get_eof_char (fdo);
-      int pty_max_bytes = get_pty_max_bytes (fdo);
-      filedesc_stream_set_pty_flushing (XLSTREAM(*outstream), pty_max_bytes, eof_char);
-    }
-#endif
-#endif
-
-  return (NILP (*instream)
-	  ? USID_ERROR
-#if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
-	  : flags & STREAM_NETWORK_CONNECTION
-	  ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (*instream)))
-#endif
-	  : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (*instream))));
+
+  *in_usid =
+    (NILP (*instream)
+     ? USID_ERROR
+     : flags & STREAM_NETWORK_CONNECTION
+     ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (*instream)))
+     : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
+							 (*instream))));
+
+  *err_usid =
+    (NILP (*errstream)
+     ? USID_DONTHASH
+     : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
+							 (*errstream))));
+#endif /* CYGWIN */
 }
 
-USID
-emacs_mswindows_delete_stream_pair (Lisp_Object instream,
-				    Lisp_Object outstream)
+static void
+emacs_mswindows_delete_io_streams (Lisp_Object instream,
+				   Lisp_Object outstream,
+				   Lisp_Object errstream,
+				   USID *in_usid,
+				   USID *err_usid)
 {
-  /* Oh nothing special here for Win32 at all */
-#if defined (HAVE_UNIX_PROCESSES)
-  int in = (NILP(instream)
-	    ? -1
-#if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
-	    : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
-	    ? get_winsock_stream_param (XLSTREAM (instream))
-#endif
-	    : get_ntpipe_input_stream_param (XLSTREAM (instream)));
-  int out = (NILP(outstream) ? -1
-	     : filedesc_stream_fd (XLSTREAM (outstream)));
-
-  if (in >= 0)
-    retry_close (in);
-  if (out != in && out >= 0)
-    retry_close (out);
-#endif
-
-  return (NILP (instream)
-	  ? USID_DONTHASH
-#if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
-	  : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
-	  ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (instream)))
-#endif
-	  : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (instream))));
+#ifdef CYGWIN
+  event_stream_unixoid_delete_io_streams (instream, outstream, errstream,
+					  in_usid, err_usid);
+#else
+  *in_usid =
+    (NILP (instream)
+     ? USID_DONTHASH
+     : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
+     ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (instream)))
+     : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
+							 (instream))));
+
+  *err_usid =
+    (NILP (errstream)
+     ? USID_DONTHASH
+     : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
+							 (errstream))));
+#endif /* CYGWIN */
 }
 
 static int
@@ -4321,17 +4396,19 @@
 #ifndef HAVE_X_WINDOWS
 /* This is called from GC when a process object is about to be freed.
    If we've still got pointers to it in this file, we're gonna lose hard.
- */
+*/
+void debug_process_finalization (Lisp_Process *p);
 void
 debug_process_finalization (Lisp_Process *p)
 {
 #if 0 /* #### */
-  Lisp_Object instr, outstr;
-
-  get_process_streams (p, &instr, &outstr);
+  Lisp_Object instr, outstr, errstr;
+
+  get_process_streams (p, &instr, &outstr, &errstr);
   /* if it still has fds, then it hasn't been killed yet. */
   assert (NILP (instr));
   assert (NILP (outstr));
+  assert (NILP (errstr));
 
   /* #### More checks here */
 #endif
@@ -4679,19 +4756,10 @@
   mswindows_event_stream->quit_p_cb		= emacs_mswindows_quit_p;
   mswindows_event_stream->select_console_cb 	= emacs_mswindows_select_console;
   mswindows_event_stream->unselect_console_cb	= emacs_mswindows_unselect_console;
-#ifdef HAVE_MSG_SELECT
-  mswindows_event_stream->select_process_cb 	=
-    (void (*)(Lisp_Process *)) event_stream_unixoid_select_process;
-  mswindows_event_stream->unselect_process_cb	=
-    (void (*)(Lisp_Process *)) event_stream_unixoid_unselect_process;
-  mswindows_event_stream->create_stream_pair_cb = event_stream_unixoid_create_stream_pair;
-  mswindows_event_stream->delete_stream_pair_cb = event_stream_unixoid_delete_stream_pair;
-#else
   mswindows_event_stream->select_process_cb 	= emacs_mswindows_select_process;
   mswindows_event_stream->unselect_process_cb	= emacs_mswindows_unselect_process;
-  mswindows_event_stream->create_stream_pair_cb = emacs_mswindows_create_stream_pair;
-  mswindows_event_stream->delete_stream_pair_cb = emacs_mswindows_delete_stream_pair;
-#endif
+  mswindows_event_stream->create_io_streams_cb = emacs_mswindows_create_io_streams;
+  mswindows_event_stream->delete_io_streams_cb = emacs_mswindows_delete_io_streams;
   mswindows_event_stream->current_event_timestamp_cb =
     emacs_mswindows_current_event_timestamp;
 }
@@ -4711,9 +4779,7 @@
   mswindows_s_dispatch_event_queue_tail = Qnil;
   dump_add_root_object (&mswindows_s_dispatch_event_queue_tail);
 
-  mswindows_error_caught_in_modal_loop = Qnil;
-  staticpro (&mswindows_error_caught_in_modal_loop);
-
+  mswindows_error_caught_in_modal_loop = 0;
 
 #ifdef DEBUG_XEMACS
   DEFVAR_INT ("debug-mswindows-events", &debug_mswindows_events /*
@@ -4792,9 +4858,9 @@
 void
 lstream_type_create_mswindows_selectable (void)
 {
+#ifndef CYGWIN
   init_slurp_stream ();
   init_shove_stream ();
-#if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
   init_winsock_stream ();
 #endif
 }
@@ -4802,7 +4868,7 @@
 void
 init_event_mswindows_late (void)
 {
-#ifdef HAVE_MSG_SELECT
+#ifdef CYGWIN
   windows_fd = retry_open ("/dev/windows", O_RDONLY | O_NONBLOCK, 0);
   assert (windows_fd >= 0);
   FD_SET (windows_fd, &input_wait_mask);
--- a/src/event-stream.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-stream.c	Tue May 28 08:45:36 2002 +0000
@@ -520,7 +520,7 @@
   return 0;
 }
 
-void
+static void
 event_stream_next_event (Lisp_Event *event)
 {
   Lisp_Object event_obj;
@@ -529,11 +529,20 @@
 
   event_obj = wrap_event (event);
   zero_event (event);
-  /* If C-g was pressed, treat it as a character to be read.
-     Note that if C-g was pressed while we were blocking,
-     the SIGINT signal handler will be called.  It will
-     set Vquit_flag and write a byte on our "fake pipe",
-     which will unblock us. */
+  /* SIGINT occurs when C-g was pressed on a TTY. (SIGINT might have
+     been sent manually by the user, but we don't care; we treat it
+     the same.)
+
+     The SIGINT signal handler sets Vquit_flag as well as sigint_happened
+     and write a byte on our "fake pipe", which unblocks us when we are
+     waiting for an event. */
+
+  /* If SIGINT was received after we disabled quit checking (because
+     we want to read C-g's as characters), but before we got a chance
+     to start reading, notice it now and treat it as a character to be
+     read.  If above callers wanted this to be QUIT, they can
+     determine this by comparing the event against quit-char. */
+
   if (maybe_read_quit_event (event))
     {
       DEBUG_PRINT_EMACS_EVENT ("SIGINT", event_obj);
@@ -547,6 +556,14 @@
   event_stream->next_event_cb (event);
   emacs_is_blocking = 0;
 
+  /* Now check to see if C-g was pressed while we were blocking.
+     We treat it as an event, just like above. */
+  if (maybe_read_quit_event (event))
+    {
+      DEBUG_PRINT_EMACS_EVENT ("SIGINT", event_obj);
+      return;
+    }
+
 #ifdef DEBUG_XEMACS
   /* timeout events have more info set later, so
      print the event out in next_event_internal(). */
@@ -621,41 +638,90 @@
 }
 
 void
-event_stream_select_process (Lisp_Process *proc)
+event_stream_select_process (Lisp_Process *proc, int doin, int doerr)
 {
+  int cur_in, cur_err;
+
   check_event_stream_ok (EVENT_STREAM_PROCESS);
-  if (!get_process_selected_p (proc))
+
+  cur_in = get_process_selected_p (proc, 0);
+  if (cur_in)
+    doin = 0;
+
+  if (!process_has_separate_stderr (wrap_process (proc)))
     {
-      event_stream->select_process_cb (proc);
-      set_process_selected_p (proc, 1);
+      doerr = 0;
+      cur_err = 0;
+    }
+  else
+    {
+      cur_err = get_process_selected_p (proc, 1);
+      if (cur_err)
+	doerr = 0;
+    }
+
+  if (doin || doerr)
+    {
+      event_stream->select_process_cb (proc, doin, doerr);
+      set_process_selected_p (proc, cur_in || doin, cur_err || doerr);
     }
 }
 
 void
-event_stream_unselect_process (Lisp_Process *proc)
+event_stream_unselect_process (Lisp_Process *proc, int doin, int doerr)
 {
+  int cur_in, cur_err;
+
   check_event_stream_ok (EVENT_STREAM_PROCESS);
-  if (get_process_selected_p (proc))
+
+  cur_in = get_process_selected_p (proc, 0);
+  if (!cur_in)
+    doin = 0;
+
+  if (!process_has_separate_stderr (wrap_process (proc)))
     {
-      event_stream->unselect_process_cb (proc);
-      set_process_selected_p (proc, 0);
+      doerr = 0;
+      cur_err = 0;
+    }
+  else
+    {
+      cur_err = get_process_selected_p (proc, 1);
+      if (!cur_err)
+	doerr = 0;
+    }
+
+  if (doin || doerr)
+    {
+      event_stream->unselect_process_cb (proc, doin, doerr);
+      set_process_selected_p (proc, cur_in && !doin, cur_err && !doerr);
     }
 }
 
-USID
-event_stream_create_stream_pair (void *inhandle, void *outhandle,
-		Lisp_Object *instream, Lisp_Object *outstream, int flags)
+void
+event_stream_create_io_streams (void *inhandle, void *outhandle,
+				void *errhandle, Lisp_Object *instream,
+				Lisp_Object *outstream,
+				Lisp_Object *errstream,
+				USID *in_usid,
+				USID *err_usid,
+				int flags)
 {
   check_event_stream_ok (EVENT_STREAM_PROCESS);
-  return event_stream->create_stream_pair_cb
-		(inhandle, outhandle, instream, outstream, flags);
+  event_stream->create_io_streams_cb
+    (inhandle, outhandle, errhandle, instream, outstream, errstream,
+     in_usid, err_usid, flags);
 }
 
-USID
-event_stream_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream)
+void
+event_stream_delete_io_streams (Lisp_Object instream,
+				Lisp_Object outstream,
+				Lisp_Object errstream,
+				USID *in_usid,
+				USID *err_usid)
 {
   check_event_stream_ok (EVENT_STREAM_PROCESS);
-  return event_stream->delete_stream_pair_cb (instream, outstream);
+  event_stream->delete_io_streams_cb (instream, outstream, errstream,
+				      in_usid, err_usid);
 }
 
 void
@@ -734,9 +800,11 @@
   /* This function can GC */
   double echo_keystrokes;
   struct frame *f = selected_frame ();
+  int depth = begin_dont_check_for_quit ();
+
   /* Message turns off echoing unless more keystrokes turn it on again. */
   if (echo_area_active (f) && !EQ (Qcommand, echo_area_status (f)))
-    return;
+    goto done;
 
   if (INTP (Vecho_keystrokes) || FLOATP (Vecho_keystrokes))
     echo_keystrokes = extract_float (Vecho_keystrokes);
@@ -752,11 +820,9 @@
     {
       if (!no_snooze)
 	{
-	  /* #### C-g here will cause QUIT.  Setting dont_check_for_quit
-	     doesn't work.  See check_quit. */
 	  if (NILP (Fsit_for (Vecho_keystrokes, Qnil)))
 	    /* input came in, so don't echo. */
-	    return;
+	    goto done;
 	}
 
       echo_area_message (f, command_builder->echo_buf, Qnil, 0,
@@ -765,6 +831,10 @@
 			 strlen ((char *) command_builder->echo_buf),
 			 Qcommand);
     }
+
+ done:
+  Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+  unbind_to (depth);
 }
 
 static void
@@ -1548,19 +1618,10 @@
   return dequeue_event (&command_event_queue, &command_event_queue_tail);
 }
 
-/* put the event on the typeahead queue, unless
-   the event is the quit char, in which case the `QUIT'
-   which will occur on the next trip through this loop is
-   all the processing we should do - leaving it on the queue
-   would cause the quit to be processed twice.
-   */
 static void
 enqueue_command_event_1 (Lisp_Object event_to_copy)
 {
-  /* do not call check_quit() here.  Vquit_flag was set in
-     next_event_internal. */
-  if (NILP (Vquit_flag))
-    enqueue_command_event (Fcopy_event (event_to_copy, Qnil));
+  enqueue_command_event (Fcopy_event (event_to_copy, Qnil));
 }
 
 void
@@ -1969,12 +2030,23 @@
 /* the number of keyboard characters read.  callint.c wants this. */
 Charcount num_input_chars;
 
+/* Read an event from the window system (or tty).  If ALLOW_QUEUED is
+   non-zero, read from the command-event queue first.
+
+   If C-g was pressed, this function will attempt to QUIT.  If you want
+   to read C-g as an event, wrap this function with a call to
+   begin_dont_check_for_quit(), and set Vquit_flag to Qnil just before
+   you unbind.  In this case, TARGET_EVENT will contain a C-g.
+
+   Note that even if you are interested in C-g doing QUIT, a caller of you
+   might not be.
+*/
+
 static void
 next_event_internal (Lisp_Object target_event, int allow_queued)
 {
   struct gcpro gcpro1;
-  /* QUIT;   This is incorrect - the caller must do this because some
-	     callers (ie, Fnext_event()) do not want to QUIT. */
+  QUIT;
 
   assert (NILP (XEVENT_NEXT (target_event)));
 
@@ -2017,35 +2089,29 @@
 	  DEBUG_PRINT_EMACS_EVENT ("real, timeout", target_event);
 	}
 
-      /* If we read a ^G, then set quit-flag but do not discard the ^G.
-	 The callers of next_event_internal() will do one of two things:
-
-	 -- set Vquit_flag to Qnil. (next-event does this.) This will
-	    cause the ^G to be treated as a normal keystroke.
-	 -- not change Vquit_flag but attempt to enqueue the ^G, at
-	    which point it will be discarded.  The next time QUIT is
-	    called, it will notice that Vquit_flag was set.
-
+      /* If we read a ^G, then set quit-flag and try to QUIT.
+	 This may be blocked (see above).
        */
       if (e->event_type == key_press_event &&
 	  event_matches_key_specifier_p
 	  (e, make_char (CONSOLE_QUIT_CHAR (XCONSOLE (EVENT_CHANNEL (e))))))
 	{
 	  Vquit_flag = Qt;
+	  QUIT;
 	}
     }
 
   UNGCPRO;
 }
 
-static void
+void
 run_pre_idle_hook (void)
 {
   if (!NILP (Vpre_idle_hook)
       && !detect_input_pending ())
-    safe_run_hook_trapping_errors
+    safe_run_hook_trapping_problems
       ("Error in `pre-idle-hook' (setting hook to nil)",
-       Qpre_idle_hook, 1);
+       Qpre_idle_hook, INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 }
 
 static void push_this_command_keys (Lisp_Object event);
@@ -2108,10 +2174,11 @@
     XCOMMAND_BUILDER (con->command_builder);
   int store_this_key = 0;
   struct gcpro gcpro1;
+  int depth;
 
   GCPRO1 (event);
-  /* DO NOT do QUIT anywhere within this function or the functions it calls.
-     We want to read the ^G as an event. */
+
+  depth = begin_dont_check_for_quit ();
 
 #ifdef LWLIB_MENUBARS_LUCID
   /*
@@ -2174,7 +2241,7 @@
 	  if (!EVENTP (e) || !command_event_p (e))
 	    signal_error_1 (Qwrong_type_argument,
 			  list3 (Qcommand_event_p, e, Qunread_command_events));
-	  redisplay ();
+	  redisplay_no_pre_idle_hook ();
 	  if (!EQ (e, event))
 	    Fcopy_event (e, event);
 	  DEBUG_PRINT_EMACS_EVENT ("unread-command-events", event);
@@ -2194,7 +2261,7 @@
 	}
       if (!EQ (e, event))
 	Fcopy_event (e, event);
-      redisplay ();
+      redisplay_no_pre_idle_hook ();
       DEBUG_PRINT_EMACS_EVENT ("unread-command-event", event);
     }
 
@@ -2206,7 +2273,7 @@
     {
       if (!NILP (Vexecuting_macro))
 	{
-	  redisplay ();
+	  redisplay_no_pre_idle_hook ();
 	  pop_kbd_macro_event (event);  /* This throws past us at
 					   end-of-macro. */
 	  store_this_key = 1;
@@ -2217,15 +2284,18 @@
 	 recent-keys. */
       else
 	{
-	  run_pre_idle_hook ();
 	  redisplay ();
 	  next_event_internal (event, 1);
-	  Vquit_flag = Qnil; /* Read C-g as an event. */
 	  store_this_key = 1;
 	}
     }
 
+  /* temporarily reenable quit checking here, because arbitrary lisp
+     is executed */
+  Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+  unbind_to (depth);
   status_notify ();             /* Notice process change */
+  depth = begin_dont_check_for_quit ();
 
   /* Since we can free the most stuff here
    *  (since this is typically called from
@@ -2258,7 +2328,12 @@
       break;
     }
 
+  /* temporarily reenable quit checking here, because we could get stuck */
+  Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+  unbind_to (depth);
   maybe_do_auto_save ();
+  depth = begin_dont_check_for_quit ();
+
   num_input_chars++;
  STORE_AND_EXECUTE_KEY:
   if (store_this_key)
@@ -2326,18 +2401,26 @@
 	  store_kbd_macro_event (event);
 	}
     }
-  /* If this is the help char and there is a help form, then execute the
-     help form and swallow this character.  This is the only place where
-     calling Fnext_event() can cause arbitrary lisp code to run.  Note
-     that execute_help_form() calls Fnext_command_event(), which calls
-     this function, as well as Fdispatch_event.
-     */
+  /* If this is the help char and there is a help form, then execute
+     the help form and swallow this character.  Note that
+     execute_help_form() calls Fnext_command_event(), which calls this
+     function, as well as Fdispatch_event.  */
   if (!NILP (Vhelp_form) &&
       event_matches_key_specifier_p (XEVENT (event), Vhelp_char))
-    execute_help_form (command_builder, event);
+    {
+      /* temporarily reenable quit checking here, because we could get stuck */
+      Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+      unbind_to (depth);
+      execute_help_form (command_builder, event);
+      depth = begin_dont_check_for_quit ();
+    }
 
  RETURN:
+  Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+  unbind_to (depth);
+
   UNGCPRO;
+
   return event;
 }
 
@@ -2370,9 +2453,11 @@
   /* This function can GC */
   struct gcpro gcpro1;
   GCPRO1 (event);
+
   maybe_echo_keys (XCOMMAND_BUILDER
 		   (XCONSOLE (Vselected_console)->
 		    command_builder), 0); /* #### This sucks bigtime */
+
   for (;;)
     {
       event = Fnext_event (event, prompt);
@@ -2409,15 +2494,12 @@
 
   while (event_stream_event_pending_p (0))
     {
-      QUIT; /* next_event_internal() does not QUIT. */
-
       /* We're a generator of the command_event_queue, so we can't be a
 	 consumer as well.  Also, we have no reason to consult the
 	 command_event_queue; there are only user and eval-events there,
 	 and we'd just have to put them back anyway.
        */
       next_event_internal (event, 0); /* blocks */
-      /* See the comment in accept-process-output about Vquit_flag */
       if (XEVENT_TYPE (event) == magic_event ||
 	  XEVENT_TYPE (event) == timeout_event ||
 	  XEVENT_TYPE (event) == process_event ||
@@ -2457,16 +2539,14 @@
    */
   Lisp_Object event = Fmake_event (Qnil, Qnil);
   Lisp_Object head = Qnil, tail = Qnil;
-  Lisp_Object oiq = Vinhibit_quit;
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1;
   /* #### not correct here with Vselected_console?  Should
      discard-input take a console argument, or maybe map over
      all consoles? */
   struct console *con = XCONSOLE (Vselected_console);
 
   /* next_event_internal() can cause arbitrary Lisp code to be evalled */
-  GCPRO2 (event, oiq);
-  Vinhibit_quit = Qt;
+  GCPRO1 (event);
   /* If a macro was being defined then we have to mark the modeline
      has changed to ensure that it gets updated correctly. */
   if (!NILP (con->defining_kbd_macro))
@@ -2477,19 +2557,27 @@
   while (!NILP (command_event_queue)
          || event_stream_event_pending_p (1))
     {
+      /* We want to ignore C-g's along with all other keypresses. */
+      int depth = begin_dont_check_for_quit ();
       /* This will take stuff off the command_event_queue, or read it
 	 from the event_stream, but it will not block.
        */
       next_event_internal (event, 1);
-      Vquit_flag = Qnil; /* Treat C-g as a user event (ignore it).
-			    It is vitally important that we reset
-			    Vquit_flag here.  Otherwise, if we're
-			    reading from a TTY console,
-			    maybe_read_quit_event() will notice
-			    that C-g has been set and send us
-			    another C-g.  That will cause us
-			    to get right back here, and read
-			    another C-g, ad infinitum ... */
+      /* The following comment used to be here:
+
+	 [[Treat C-g as a user event (ignore it).  It is vitally
+	 important that we reset Vquit_flag here.  Otherwise, if we're
+	 reading from a TTY console, maybe_read_quit_event() will
+	 notice that C-g has been set and send us another C-g.  That
+	 will cause us to get right back here, and read another C-g,
+	 ad infinitum ...]]
+
+         but I don't think this is correct; maybe_read_quit_event()
+         checks and resets sigint_happened.  It shouldn't matter if we
+	 reset here or outside of the while loop. --ben */
+      Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */
+
+      unbind_to (depth);
 
       /* If the event is a user event, ignore it. */
       if (!command_event_p (event))
@@ -2525,7 +2613,6 @@
   Fdeallocate_event (event);
   UNGCPRO;
 
-  Vinhibit_quit = oiq;
   return Qnil;
 }
 
@@ -2648,16 +2735,7 @@
           continue;             /* Don't call next_event_internal */
 	}
 
-      QUIT;	/* next_event_internal() does not QUIT, so check for ^G
-		   before reading output from the process - this makes it
-		   less likely that the filter will actually be aborted.
-		 */
-
       next_event_internal (event, 0);
-      /* If C-g was pressed while we were waiting, Vquit_flag got
-	 set and next_event_internal() also returns C-g.  When
-	 we enqueue the C-g below, it will get discarded.  The
-	 next time through, QUIT will be called and will signal a quit. */
       switch (XEVENT_TYPE (event))
 	{
 	case process_event:
@@ -2694,6 +2772,9 @@
   unbind_to_1 (count, timeout_enabled ? make_int (timeout_id) : Qnil);
 
   Fdeallocate_event (event);
+
+  status_notify ();
+
   UNGCPRO;
   current_buffer = old_buffer;
   return result;
@@ -2730,16 +2811,11 @@
       if (!event_stream_wakeup_pending_p (id, 0))
 	goto DONE_LABEL;
 
-      QUIT;	/* next_event_internal() does not QUIT, so check for ^G
-		   before reading output from the process - this makes it
-		   less likely that the filter will actually be aborted.
-		 */
       /* We're a generator of the command_event_queue, so we can't be a
 	 consumer as well.  We don't care about command and eval-events
 	 anyway.
        */
       next_event_internal (event, 0); /* blocks */
-      /* See the comment in accept-process-output about Vquit_flag */
       switch (XEVENT_TYPE (event))
 	{
 	case timeout_event:
@@ -2808,13 +2884,10 @@
     return Qnil;
 
   /* Recursive call from a filter function or timeout handler. */
-  if (!NILP(recursive_sit_for))
+  if (!NILP (recursive_sit_for))
     {
       if (!event_stream_event_pending_p (1) && NILP (nodisplay))
-	{
-	  run_pre_idle_hook ();
 	  redisplay ();
-	}
       return Qnil;
     }
 
@@ -2843,10 +2916,7 @@
       /* If there is no user input pending, then redisplay.
        */
       if (!event_stream_event_pending_p (1) && NILP (nodisplay))
-	{
-	  run_pre_idle_hook ();
 	  redisplay ();
-	}
 
       /* If our timeout has arrived, we move along. */
       if (!event_stream_wakeup_pending_p (id, 0))
@@ -2855,24 +2925,14 @@
 	  goto DONE_LABEL;
 	}
 
-      QUIT;	/* next_event_internal() does not QUIT, so check for ^G
-		   before reading output from the process - this makes it
-		   less likely that the filter will actually be aborted.
-		 */
       /* We're a generator of the command_event_queue, so we can't be a
 	 consumer as well.  In fact, we know there's nothing on the
 	 command_event_queue that we didn't just put there.
        */
       next_event_internal (event, 0); /* blocks */
-      /* See the comment in accept-process-output about Vquit_flag */
 
       if (command_event_p (event))
 	{
-	  QUIT;			/* If the command was C-g check it here
-				   so that we abort out of the sit-for,
-				   not the next command.  sleep-for and
-				   accept-process-output continue looping
-				   so they check QUIT again implicitly.*/
 	  result = Qnil;
 	  goto DONE_LABEL;
 	}
@@ -2927,15 +2987,12 @@
 
   while (!(*predicate) (predicate_arg))
     {
-      QUIT; /* next_event_internal() does not QUIT. */
-
       /* We're a generator of the command_event_queue, so we can't be a
 	 consumer as well.  Also, we have no reason to consult the
 	 command_event_queue; there are only user and eval-events there,
 	 and we'd just have to put them back anyway.
        */
       next_event_internal (event, 0);
-      /* See the comment in accept-process-output about Vquit_flag */
       if (command_event_p (event)
           || (XEVENT_TYPE (event) == eval_event)
 	  || (XEVENT_TYPE (event) == magic_eval_event))
@@ -2989,85 +3046,79 @@
       {
 	Lisp_Object p = XEVENT (event)->event.process.process;
 	Charcount readstatus;
-
-	assert  (PROCESSP (p));
-	while ((readstatus = read_process_output (p)) > 0)
-	  ;
-	if (readstatus > 0)
-	  ; /* this clauses never gets executed but allows the #ifdefs
-	       to work cleanly. */
+	int iter;
+
+	assert (PROCESSP (p));
+	for (iter = 0; iter < 2; iter++)
+	  {
+	    if (iter == 1 && !process_has_separate_stderr (p))
+	      break;
+	    while ((readstatus = read_process_output (p, iter)) > 0)
+	      ;
+	    if (readstatus > 0)
+	      ;			/* this clauses never gets executed but
+				   allows the #ifdefs to work cleanly. */
 #ifdef EWOULDBLOCK
-	else if (readstatus == -1 && errno == EWOULDBLOCK)
-	  ;
+	    else if (readstatus == -1 && errno == EWOULDBLOCK)
+	      ;
 #endif /* EWOULDBLOCK */
 #ifdef EAGAIN
-	else if (readstatus == -1 && errno == EAGAIN)
-	  ;
+	    else if (readstatus == -1 && errno == EAGAIN)
+	      ;
 #endif /* EAGAIN */
-	else if ((readstatus == 0 &&
-		  /* Note that we cannot distinguish between no input
-		     available now and a closed pipe.
-		     With luck, a closed pipe will be accompanied by
-		     subprocess termination and SIGCHLD.  */
-		  (!network_connection_p (p) ||
-		   /*
-		      When connected to ToolTalk (i.e.
-		      connected_via_filedesc_p()), it's not possible to
-		      reliably determine whether there is a message
-		      waiting for ToolTalk to receive.  ToolTalk expects
-		      to have tt_message_receive() called exactly once
-		      every time the file descriptor becomes active, so
-		      the filter function forces this by returning 0.
-		      Emacs must not interpret this as a closed pipe. */
-		   connected_via_filedesc_p (XPROCESS (p))))
-
-		 /* On some OSs with ptys, when the process on one end of
-		    a pty exits, the other end gets an error reading with
-		    errno = EIO instead of getting an EOF (0 bytes read).
-		    Therefore, if we get an error reading and errno =
-		    EIO, just continue, because the child process has
-		    exited and should clean itself up soon (e.g. when we
-		    get a SIGCHLD). */
+	    else if ((readstatus == 0 &&
+		      /* Note that we cannot distinguish between no input
+			 available now and a closed pipe.
+			 With luck, a closed pipe will be accompanied by
+			 subprocess termination and SIGCHLD.  */
+		      (!network_connection_p (p) ||
+		       /*
+			  When connected to ToolTalk (i.e.
+			  connected_via_filedesc_p()), it's not possible to
+			  reliably determine whether there is a message
+			  waiting for ToolTalk to receive.  ToolTalk expects
+			  to have tt_message_receive() called exactly once
+			  every time the file descriptor becomes active, so
+			  the filter function forces this by returning 0.
+			  Emacs must not interpret this as a closed pipe. */
+		       connected_via_filedesc_p (XPROCESS (p))))
+
+		     /* On some OSs with ptys, when the process on one end of
+			a pty exits, the other end gets an error reading with
+			errno = EIO instead of getting an EOF (0 bytes read).
+			Therefore, if we get an error reading and errno =
+			EIO, just continue, because the child process has
+			exited and should clean itself up soon (e.g. when we
+			get a SIGCHLD). */
 #ifdef EIO
-		 || (readstatus == -1 && errno == EIO)
+		     || (readstatus == -1 && errno == EIO)
 #endif
 
-		 )
-	  {
-	    /* Currently, we rely on SIGCHLD to indicate that the
-	       process has terminated.  Unfortunately, on some systems
-	       the SIGCHLD gets missed some of the time.  So we put an
-	       additional check in status_notify() to see whether a
-	       process has terminated.  We must tell status_notify()
-	       to enable that check, and we do so now. */
-	    kick_status_notify ();
+		     )
+	      {
+		/* Currently, we rely on SIGCHLD to indicate that the
+		   process has terminated.  Unfortunately, on some systems
+		   the SIGCHLD gets missed some of the time.  So we put an
+		   additional check in status_notify() to see whether a
+		   process has terminated.  We must tell status_notify()
+		   to enable that check, and we do so now. */
+		kick_status_notify ();
+	      }
+	    
+	    /* We must call status_notify here to allow the
+	       event_stream->unselect_process_cb to be run if appropriate.
+	       Otherwise, dead fds may be selected for, and we will get a
+	       continuous stream of process events for them.  Since we don't
+	       return until all process events have been flushed, we would
+	       get stuck here, processing events on a process whose status
+	       was 'exit.  Call this after dispatch-event, or the fds will
+	       have been closed before we read the last data from them.
+	       It's safe for the filter to signal an error because
+	       status_notify() will be called on return to top-level.
+	    */
+	    status_notify ();
+	    return;
 	  }
-	else
-	  {
-	    /* Deactivate network connection */
-	    Lisp_Object status = Fprocess_status (p);
-	    if (EQ (status, Qopen)
-		/* In case somebody changes the theory of whether to
-		   return open as opposed to run for network connection
-		   "processes"... */
-		|| EQ (status, Qrun))
-	      update_process_status (p, Qexit, 256, 0);
-	    deactivate_process (p);
-	  }
-
-	/* We must call status_notify here to allow the
-	   event_stream->unselect_process_cb to be run if appropriate.
-	   Otherwise, dead fds may be selected for, and we will get a
-	   continuous stream of process events for them.  Since we don't
-	   return until all process events have been flushed, we would
-	   get stuck here, processing events on a process whose status
-	   was 'exit.  Call this after dispatch-event, or the fds will
-	   have been closed before we read the last data from them.
-	   It's safe for the filter to signal an error because
-	   status_notify() will be called on return to top-level.
-	   */
-	status_notify ();
-	return;
       }
 
     case timeout_event:
@@ -3860,6 +3911,8 @@
 	    else
 	      maybe_echo_keys (command_builder, 0);
 	  }
+	/* #### i don't trust this at all. --ben */
+#if 0
 	else if (!NILP (Vquit_flag))
 	  {
 	    Lisp_Object quit_event = Fmake_event (Qnil, Qnil);
@@ -3874,6 +3927,7 @@
 	    enqueue_command_event (quit_event);
 	    Vquit_flag = Qnil;
 	  }
+#endif
       }
     else if (!NILP (leaf))
       {
@@ -4095,9 +4149,9 @@
   last_point_position = BUF_PT (current_buffer);
   last_point_position_buffer = wrap_buffer (current_buffer);
   /* This function can GC */
-  safe_run_hook_trapping_errors
+  safe_run_hook_trapping_problems
     ("Error in `pre-command-hook' (setting hook to nil)",
-     Qpre_command_hook, 1);
+     Qpre_command_hook, INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 
   /* This is a kludge, but necessary; see simple.el */
   call0 (Qhandle_pre_motion_command);
@@ -4140,9 +4194,38 @@
   else
     zmacs_update_region ();
 
-  safe_run_hook_trapping_errors
+  safe_run_hook_trapping_problems
     ("Error in `post-command-hook' (setting hook to nil)",
-     Qpost_command_hook, 1);
+     Qpost_command_hook, INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
+
+#if 0 /* FSF Emacs crap */
+  if (!NILP (Vdeferred_action_list))
+    call0 (Vdeferred_action_function);
+
+  if (NILP (Vunread_command_events)
+      && NILP (Vexecuting_macro)
+      && !NILP (Vpost_command_idle_hook)
+      && !NILP (Fsit_for (make_float ((double) post_command_idle_delay
+				      / 1000000), Qnil)))
+  safe_run_hook_trapping_problems
+    ("Error in `post-command-idle-hook' (setting hook to nil)",
+     Qpost_command_idle_hook,
+     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
+#endif /* FSF Emacs crap */
+
+#if 0 /* FSF Emacs */
+  if (!NILP (current_buffer->mark_active))
+    {
+      if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode))
+        {
+          current_buffer->mark_active = Qnil;
+	  run_hook (intern ("deactivate-mark-hook"));
+        }
+      else if (current_buffer != prev_buffer ||
+	       BUF_MODIFF (current_buffer) != prev_modiff)
+	run_hook (intern ("activate-mark-hook"));
+    }
+#endif /* FSF Emacs */
 
   /* #### Kludge!!! This is necessary to make sure that things
      are properly positioned even if post-command-hook moves point.
@@ -4447,8 +4530,6 @@
   if (NILP (continue_echo))
     reset_this_command_keys (wrap_console (con), 1);
 
-  specbind (Qinhibit_quit, Qt);
-
   if (!NILP (dont_downcase_last))
     specbind (Qretry_undefined_key_binding_unshifted, Qnil);
 
@@ -4475,7 +4556,6 @@
 	}
     }
 
-  Vquit_flag = Qnil;  /* In case we read a ^G; do not call check_quit() here */
   Fdeallocate_event (event);
   RETURN_UNGCPRO (unbind_to_1 (speccount, result));
 }
@@ -4727,7 +4807,7 @@
 Function or functions to run before every command.
 This may examine the `this-command' variable to find out what command
 is about to be run, or may change it to cause a different command to run.
-Function on this hook must be careful to avoid signalling errors!
+Errors while running the hook are caught and turned into warnings.
 */ );
   Vpre_command_hook = Qnil;
 
@@ -4743,8 +4823,8 @@
 This occurs whenever it is going to block, waiting for an event.
 This generally happens as a result of a call to `next-event',
 `next-command-event', `sit-for', `sleep-for', `accept-process-output',
-or `x-get-selection'.
-Errors running the hook are caught and ignored.
+or `get-selection'.  Errors while running the hook are caught and
+turned into warnings.
 */ );
   Vpre_idle_hook = Qnil;
 
@@ -5063,6 +5143,8 @@
 
 
 /*
+#### this comment is at least 8 years old and some may no longer apply.
+
 useful testcases for v18/v19 compatibility:
 
 (defun foo ()
--- a/src/event-tty.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-tty.c	Tue May 28 08:45:36 2002 +0000
@@ -212,15 +212,19 @@
 
 
 static void
-emacs_tty_select_process (Lisp_Process *process)
+emacs_tty_select_process (Lisp_Process *process, int doin, int doerr)
 {
-  event_stream_unixoid_select_process (process);
+  int infd, errfd;
+
+  event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
 }
 
 static void
-emacs_tty_unselect_process (Lisp_Process *process)
+emacs_tty_unselect_process (Lisp_Process *process, int doin, int doerr)
 {
-  event_stream_unixoid_unselect_process (process);
+  int infd, errfd;
+
+  event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
 }
 
 static void
@@ -242,18 +246,29 @@
      This could change. */
 }
 
-static USID
-emacs_tty_create_stream_pair (void* inhandle, void* outhandle,
-		Lisp_Object* instream, Lisp_Object* outstream, int flags)
+static void
+emacs_tty_create_io_streams (void* inhandle, void* outhandle,
+			     void *errhandle, Lisp_Object* instream,
+			     Lisp_Object* outstream,
+			     Lisp_Object* errstream,
+			     USID* in_usid,
+			     USID* err_usid,
+			     int flags)
 {
-  return event_stream_unixoid_create_stream_pair
-		(inhandle, outhandle, instream, outstream, flags);
+  event_stream_unixoid_create_io_streams
+    (inhandle, outhandle, errhandle, instream, outstream,
+     errstream, in_usid, err_usid, flags);
 }
 
-static USID
-emacs_tty_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream)
+static void
+emacs_tty_delete_io_streams (Lisp_Object instream,
+			     Lisp_Object outstream,
+			     Lisp_Object errstream,
+			     USID* in_usid,
+			     USID* err_usid)
 {
-  return event_stream_unixoid_delete_stream_pair (instream, outstream);
+  event_stream_unixoid_delete_io_streams
+    (instream, outstream, errstream, in_usid, err_usid);
 }
 
 
@@ -280,8 +295,8 @@
   tty_event_stream->select_process_cb 	= emacs_tty_select_process;
   tty_event_stream->unselect_process_cb = emacs_tty_unselect_process;
   tty_event_stream->quit_p_cb		= emacs_tty_quit_p;
-  tty_event_stream->create_stream_pair_cb = emacs_tty_create_stream_pair;
-  tty_event_stream->delete_stream_pair_cb = emacs_tty_delete_stream_pair;
+  tty_event_stream->create_io_streams_cb = emacs_tty_create_io_streams;
+  tty_event_stream->delete_io_streams_cb = emacs_tty_delete_io_streams;
 }
 
 void
--- a/src/event-unixoid.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/event-unixoid.c	Tue May 28 08:45:36 2002 +0000
@@ -183,32 +183,71 @@
 static int
 get_process_infd (Lisp_Process *p)
 {
-  Lisp_Object instr, outstr;
-  get_process_streams (p, &instr, &outstr);
+  Lisp_Object instr, outstr, errstr;
+  get_process_streams (p, &instr, &outstr, &errstr);
   assert (!NILP (instr));
   return filedesc_stream_fd (XLSTREAM (instr));
 }
 
-int
-event_stream_unixoid_select_process (Lisp_Process *proc)
+static int
+get_process_errfd (Lisp_Process *p)
 {
-  int infd = get_process_infd (proc);
-
-  FD_SET (infd, &input_wait_mask);
-  FD_SET (infd, &non_fake_input_wait_mask);
-  FD_SET (infd, &process_only_mask);
-  return infd;
+  Lisp_Object instr, outstr, errstr;
+  get_process_streams (p, &instr, &outstr, &errstr);
+  if (!NILP (errstr))
+    return filedesc_stream_fd (XLSTREAM (errstr));
+  else
+    return -1;
 }
 
-int
-event_stream_unixoid_unselect_process (Lisp_Process *proc)
+void
+event_stream_unixoid_select_process (Lisp_Process *proc, int doin, int doerr,
+				     int *infd, int *errfd)
 {
-  int infd = get_process_infd (proc);
+  if (doin)
+    {
+      *infd = get_process_infd (proc);
+      FD_SET (*infd, &input_wait_mask);
+      FD_SET (*infd, &non_fake_input_wait_mask);
+      FD_SET (*infd, &process_only_mask);
+    }
+
+  if (doerr)
+    {
+      *errfd = get_process_errfd (proc);
 
-  FD_CLR (infd, &input_wait_mask);
-  FD_CLR (infd, &non_fake_input_wait_mask);
-  FD_CLR (infd, &process_only_mask);
-  return infd;
+      if (*errfd >= 0)
+	{
+	  FD_SET (*errfd, &input_wait_mask);
+	  FD_SET (*errfd, &non_fake_input_wait_mask);
+	  FD_SET (*errfd, &process_only_mask);
+	}
+    }
+}
+
+void
+event_stream_unixoid_unselect_process (Lisp_Process *proc, int doin, int doerr,
+				       int *infd, int *errfd)
+{
+  if (doin)
+    {
+      *infd = get_process_infd (proc);
+      FD_CLR (*infd, &input_wait_mask);
+      FD_CLR (*infd, &non_fake_input_wait_mask);
+      FD_CLR (*infd, &process_only_mask);
+    }
+
+  if (doerr)
+    {
+      *errfd = get_process_errfd (proc);
+
+      if (*errfd >= 0)
+	{
+	  FD_CLR (*errfd, &input_wait_mask);
+	  FD_CLR (*errfd, &non_fake_input_wait_mask);
+	  FD_CLR (*errfd, &process_only_mask);
+	}
+    }
 }
 
 int
@@ -245,47 +284,22 @@
 /*     Unixoid (file descriptors based) process I/O streams routines        */
 /****************************************************************************/
 
-USID
-event_stream_unixoid_create_stream_pair (void* inhandle, void* outhandle,
-					 Lisp_Object* instream,
-					 Lisp_Object* outstream,
-					 int flags)
+void
+event_stream_unixoid_create_io_streams (void* inhandle, void* outhandle,
+					void *errhandle, Lisp_Object* instream,
+					Lisp_Object* outstream,
+					Lisp_Object* errstream,
+					USID* in_usid,
+					USID* err_usid,
+					int flags)
 {
-  int infd, outfd;
+  int infd, outfd, errfd;
   /* Decode inhandle and outhandle. Their meaning depends on
      the process implementation being used. */
-#if defined (HAVE_WIN32_PROCESSES)
-  /* We're passed in Windows handles. Open new fds for them */
-  if ((HANDLE)inhandle != INVALID_HANDLE_VALUE)
-    {
-      infd = open_osfhandle ((HANDLE)inhandle, 0);
-      if (infd < 0)
-	return USID_ERROR;
-    }
-  else
-    infd = -1;
-
-  if ((HANDLE)outhandle != INVALID_HANDLE_VALUE)
-    {
-      outfd = open_osfhandle ((HANDLE)outhandle, 0);
-      if (outfd < 0)
-	{
-	  if (infd >= 0)
-	    retry_close (infd);
-	  return USID_ERROR;
-	}
-    }
-  else
-    outfd = -1;
-
-  flags = 0;
-#elif defined (HAVE_UNIX_PROCESSES)
   /* We are passed plain old file descs */
-  infd  = (int)inhandle;
-  outfd = (int)outhandle;
-#else
-# error Which processes do you have?
-#endif
+  infd  = (int) inhandle;
+  outfd = (int) outhandle;
+  errfd = (int) errhandle;
 
   *instream = (infd >= 0
 	       ? make_filedesc_input_stream (infd, 0, -1, 0)
@@ -295,34 +309,46 @@
 		? make_filedesc_output_stream (outfd, 0, -1, LSTR_BLOCKED_OK)
 		: Qnil);
 
-#if defined(HAVE_UNIX_PROCESSES)
+  *errstream = (errfd >= 0
+	       ? make_filedesc_input_stream (errfd, 0, -1, 0)
+	       : Qnil);
+
   /* FLAGS is process->pty_flag for UNIX_PROCESSES */
   if ((flags & STREAM_PTY_FLUSHING) && outfd >= 0)
     {
       Intbyte eof_char = get_eof_char (outfd);
       int pty_max_bytes = get_pty_max_bytes (outfd);
-      filedesc_stream_set_pty_flushing (XLSTREAM(*outstream), pty_max_bytes, eof_char);
+      filedesc_stream_set_pty_flushing (XLSTREAM (*outstream), pty_max_bytes,
+					eof_char);
     }
-#endif
 
-  return FD_TO_USID (infd);
+  *in_usid = FD_TO_USID (infd);
+  *err_usid = FD_TO_USID (errfd);
 }
 
-USID
-event_stream_unixoid_delete_stream_pair (Lisp_Object instream,
-					 Lisp_Object outstream)
+void
+event_stream_unixoid_delete_io_streams (Lisp_Object instream,
+					Lisp_Object outstream,
+					Lisp_Object errstream,
+					USID *in_usid,
+					USID *err_usid)
 {
-  int in = (NILP(instream) ? -1
+  int in = (NILP (instream) ? -1
 	    : filedesc_stream_fd (XLSTREAM (instream)));
-  int out = (NILP(outstream) ? -1
+  int out = (NILP (outstream) ? -1
 	     : filedesc_stream_fd (XLSTREAM (outstream)));
+  int err = (NILP (errstream) ? -1
+	     : filedesc_stream_fd (XLSTREAM (errstream)));
 
   if (in >= 0)
     retry_close (in);
   if (out != in && out >= 0)
     retry_close (out);
+  if (err != in && err != out && err >= 0)
+    retry_close (err);
 
-  return FD_TO_USID (in);
+  *in_usid = FD_TO_USID (in);
+  *err_usid = FD_TO_USID (err);
 }
 
 
--- a/src/events.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/events.h	Tue May 28 08:45:36 2002 +0000
@@ -124,9 +124,9 @@
  unselect_device_cb	(those that use select() and file descriptors and
 			have a separate input fd per device).
 
- create_stream_pair_cb  These callbacks are called by process code to
- delete_stream_pair_cb  create and delete a pair of input and output lstreams
-			which are used for subprocess I/O.
+ create_io_streams_cb   These callbacks are called by process code to
+ delete_io_streams_cb   create the input and output lstreams which are used
+                        for subprocess I/O.
 
  quitp_cb		A handler function called from the `QUIT' macro which
 			should check whether the quit character has been
@@ -160,7 +160,7 @@
   In this case, the handles passed are unix file descriptors, and the code
   may deal with these directly. Although, the same code may be used on Win32
   system with X-Windows. In this case, Win32 process implementation passes
-  handles of type HANDLE, and the create_stream_pair function must call
+  handles of type HANDLE, and the create_io_streams function must call
   appropriate function to get file descriptors given HANDLEs, so that these
   descriptors may be passed to XtAddInput.
 
@@ -203,20 +203,25 @@
   void (*remove_timeout_cb)	(int);
   void (*select_console_cb)	(struct console *);
   void (*unselect_console_cb)	(struct console *);
-  void (*select_process_cb)	(Lisp_Process *);
-  void (*unselect_process_cb)	(Lisp_Process *);
+  void (*select_process_cb)	(Lisp_Process *, int doin, int doerr);
+  void (*unselect_process_cb)	(Lisp_Process *, int doin, int doerr);
   void (*quit_p_cb)		(void);
   void (*force_event_pending)	(struct frame* f);
-  USID (*create_stream_pair_cb) (void* /* inhandle*/, void* /*outhandle*/ ,
+  void (*create_io_streams_cb)  (void* /* inhandle*/, void* /*outhandle*/ ,
+				 void * /* errhandle*/,
 				 Lisp_Object* /* instream */,
 				 Lisp_Object* /* outstream */,
+				 Lisp_Object* /* errstream */,
+				 USID * /* in_usid */, USID * /* err_usid */,
 				 int /* flags */);
-  USID (*delete_stream_pair_cb) (Lisp_Object /* instream */,
-				 Lisp_Object /* outstream */);
+  void (*delete_io_streams_cb)  (Lisp_Object /* instream */,
+				 Lisp_Object /* outstream */,
+				 Lisp_Object /* errstream */,
+				 USID * /* in_usid */, USID * /* err_usid */);
   int (*current_event_timestamp_cb) (struct console *);
 };
 
-/* Flags for create_stream_pair_cb() FLAGS parameter */
+/* Flags for create_io_streams_cb() FLAGS parameter */
 #define STREAM_PTY_FLUSHING		0x0001
 #define STREAM_NETWORK_CONNECTION	0x0002
 
@@ -621,19 +626,28 @@
 /* from event-stream.c */
 Lisp_Object allocate_command_builder (Lisp_Object console, int with_echo_buf);
 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object);
-void event_stream_next_event (Lisp_Event *event);
 void event_stream_handle_magic_event (Lisp_Event *event);
 void event_stream_format_magic_event (Lisp_Event *event, Lisp_Object pstream);
 int event_stream_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2);
 Hashcode event_stream_hash_magic_event (Lisp_Event *e);
 void event_stream_select_console   (struct console *con);
 void event_stream_unselect_console (struct console *con);
-void event_stream_select_process   (Lisp_Process *proc);
-void event_stream_unselect_process (Lisp_Process *proc);
-USID event_stream_create_stream_pair (void* inhandle, void* outhandle,
-                Lisp_Object* instream, Lisp_Object* outstream, int flags);
-USID event_stream_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream);
+void event_stream_select_process   (Lisp_Process *proc, int doin, int doerr);
+void event_stream_unselect_process (Lisp_Process *proc, int doin, int doerr);
+void event_stream_create_io_streams (void* inhandle, void* outhandle,
+				     void *errhandle, Lisp_Object* instream,
+				     Lisp_Object* outstream,
+				     Lisp_Object* errstream,
+				     USID* in_usid,
+				     USID* err_usid,
+				     int flags);
+void event_stream_delete_io_streams (Lisp_Object instream,
+				     Lisp_Object outstream,
+				     Lisp_Object errstream,
+				     USID* in_usid,
+				     USID* err_usid);
 void event_stream_quit_p (void);
+void run_pre_idle_hook (void);
 
 struct low_level_timeout
 {
@@ -694,16 +708,25 @@
 
 int event_stream_unixoid_select_console   (struct console *con);
 int event_stream_unixoid_unselect_console (struct console *con);
-int event_stream_unixoid_select_process   (Lisp_Process *proc);
-int event_stream_unixoid_unselect_process (Lisp_Process *proc);
+void event_stream_unixoid_select_process (Lisp_Process *proc, int doin,
+					  int doerr, int *infd, int *errfd);
+void event_stream_unixoid_unselect_process (Lisp_Process *proc, int doin,
+					    int doerr, int *infd, int *errfd);
 int read_event_from_tty_or_stream_desc (Lisp_Event *event,
 					struct console *con);
-USID event_stream_unixoid_create_stream_pair (void* inhandle, void* outhandle,
-                                             Lisp_Object* instream,
-                                             Lisp_Object* outstream,
-                                             int flags);
-USID event_stream_unixoid_delete_stream_pair (Lisp_Object instream,
-                                              Lisp_Object outstream);
+void event_stream_unixoid_create_io_streams (void* inhandle, void* outhandle,
+					     void *errhandle,
+					     Lisp_Object* instream,
+					     Lisp_Object* outstream,
+					     Lisp_Object* errstream,
+					     USID* in_usid,
+					     USID* err_usid,
+					     int flags);
+void event_stream_unixoid_delete_io_streams (Lisp_Object instream,
+					     Lisp_Object outstream,
+					     Lisp_Object errstream,
+					     USID* in_usid,
+					     USID* err_usid);
 
 /* Beware: this evil macro evaluates its arg many times */
 #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd)))
--- a/src/fileio.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/fileio.c	Tue May 28 08:45:36 2002 +0000
@@ -186,7 +186,7 @@
       if (INTP (XCAR (fd)))
 	retry_close (XINT (XCAR (fd)));
 
-      free_cons (XCONS (fd));
+      free_cons (fd);
     }
   else
     retry_close (XINT (fd));
@@ -3896,13 +3896,6 @@
   return (fd);
 }
 
-static Lisp_Object
-do_auto_save_unwind_2 (Lisp_Object old_auto_saving)
-{
-  auto_saving = XINT (old_auto_saving);
-  return Qnil;
-}
-
 /* Fdo_auto_save() checks whether a GC is in progress when it is called,
    and if so, tries to avoid touching lisp objects.
 
@@ -3959,10 +3952,7 @@
 				 Vauto_save_list_file_name,
 				 auto_save_expand_name_error, Qnil);
 
-  /* Make sure auto_saving is reset. */
-  record_unwind_protect (do_auto_save_unwind_2, make_int (auto_saving));
-
-  auto_saving = 1;
+  internal_bind_int (&auto_saving, 1);
 
   /* First, save all files which don't have handlers.  If Emacs is
      crashing, the handlers may tweak what is causing Emacs to crash
--- a/src/fns.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/fns.c	Tue May 28 08:45:36 2002 +0000
@@ -1668,7 +1668,7 @@
 	  else
 	    XCDR (prev) = XCDR (tail);
 	  tail = XCDR (tail);
-	  free_cons (XCONS (cons_to_free));
+	  free_cons (cons_to_free);
 	}
       else
 	{
@@ -1847,8 +1847,8 @@
   Lisp_Object tmp;
 
   /* prevents the GC from happening in call2 */
-/* Emacs' GC doesn't actually relocate pointers, so this probably
-   isn't strictly necessary */
+  /* Emacs' GC doesn't actually relocate pointers, so this probably
+     isn't strictly necessary */
   int speccount = begin_gc_forbidden ();
   tmp = call2 (pred, obj1, obj2);
   unbind_to (speccount);
@@ -2770,6 +2770,33 @@
 }
 
 
+static Lisp_Object
+tweaked_internal_equal (Lisp_Object obj1, Lisp_Object obj2,
+			Lisp_Object depth)
+{
+  return make_int (internal_equal (obj1, obj2, XINT (depth)));
+}
+
+int
+internal_equal_trapping_problems (Lisp_Object warning_class,
+				  const char *warning_string,
+				  int flags,
+				  struct call_trapping_problems_result *p,
+				  int retval,
+				  Lisp_Object obj1, Lisp_Object obj2,
+				  int depth)
+{
+  Lisp_Object glorp =
+    va_call_trapping_problems (warning_class, warning_string,
+			       flags, p,
+			       (lisp_fn_t) tweaked_internal_equal,
+			       3, obj1, obj2, make_int (depth));
+  if (UNBOUNDP (glorp))
+    return retval;
+  else
+    return XINT (glorp);
+}
+
 int
 internal_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
 {
--- a/src/frame-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/frame-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -152,13 +152,16 @@
   FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f) = 
     make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
 #endif
-  /* hashtable of instantiated glyphs on the frame. */
+  /* hashtable of instantiated glyphs on the frame.
+     make them EQ because we only use ints as keys.
+     otherwise we run into stickiness in redisplay because
+     internal_equal() can QUIT. */
   FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f) =
-    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
+    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
   FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f) =
-    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
+    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
   FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f) =
-    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
+    make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
   /* Will initialize these in WM_SIZE handler. We cannot do it now,
      because we do not know what is CW_USEDEFAULT height and width */
   FRAME_WIDTH (f) = 0;
--- a/src/frame.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/frame.c	Tue May 28 08:45:36 2002 +0000
@@ -220,6 +220,8 @@
 
   FRAME_SET_PAGENUMBER (f, 1);
 
+  note_object_created (root_window);
+
   /* Choose a buffer for the frame's root window.  */
   XWINDOW (root_window)->buffer = Qt;
   {
@@ -251,6 +253,8 @@
   f->minibuffer_window = mini_window;
   f->has_minibuffer = 1;
 
+  note_object_created (mini_window);
+
   XWINDOW (mini_window)->buffer = Qt;
   Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
 }
@@ -473,6 +477,8 @@
   DEVICE_FRAME_LIST (d) = Fcons (frame, DEVICE_FRAME_LIST (d));
   RESET_CHANGED_SET_FLAGS;
 
+  note_object_created (frame);
+
   /* Now make sure that the initial cached values are set correctly.
      Do this after the init_frame method is called because that may
      do things (e.g. create widgets) that are necessary for the
@@ -598,32 +604,61 @@
 }
 
 
+#ifdef ERROR_CHECK_TRAPPING_PROBLEMS
+
+static Lisp_Object
+commit_ritual_suicide (Lisp_Object ceci_nest_pas_une_pipe)
+{
+  assert (!in_display);
+  return Qnil;
+}
+
+#endif
+
 /*
  * window size changes are held up during critical regions.  Afterwards,
  * we want to deal with any delayed changes.
  */
-void
-hold_frame_size_changes (void)
+int
+enter_redisplay_critical_section (void)
 {
+  int depth = specpdl_depth ();
+
+#ifdef ERROR_CHECK_TRAPPING_PROBLEMS
+  /* force every call to QUIT to check for in_displayness */
+  something_happened++;
+  record_unwind_protect (commit_ritual_suicide, Qnil);
+#endif
   in_display = 1;
+
+  return depth;
 }
 
 void
-unhold_one_frame_size_changes (struct frame *f)
-{
-  in_display = 0;
-
-  if (f->size_change_pending)
-    change_frame_size (f, f->new_height, f->new_width, 0);
-}
-
-void
-unhold_frame_size_changes (void)
+exit_redisplay_critical_section (int depth)
 {
   Lisp_Object frmcons, devcons, concons;
 
+  in_display = 0;
+
+#ifdef ERROR_CHECK_TRAPPING_PROBLEMS
+  unbind_to (depth);
+  something_happened--;
+#endif
+
+  /* we used to have a function to do this for only one frame, and
+     it was typical to call it at the end of a critical section
+     (which occurs once per frame); but what then happens if multiple
+     frames have frame changes held up?
+
+     this means we are O(N^2) over frames.  i seriously doubt it matters.
+     --ben */
   FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
-    unhold_one_frame_size_changes (XFRAME (XCAR (frmcons)));
+    {
+      struct frame *f = XFRAME (XCAR (frmcons));
+      if (f->size_change_pending)
+	change_frame_size (f, f->new_height, f->new_width, 0);
+    }
 }
 
 void
@@ -670,8 +705,9 @@
 	keep_char_size = 0;
       else
 	keep_char_size =
-	  NILP (call1_trapping_errors ("Error in adjust-frame-function",
-				       Vadjust_frame_function, frame));
+	  NILP (call1_trapping_problems ("Error in adjust-frame-function",
+					 Vadjust_frame_function, frame,
+					 0));
 
       if (keep_char_size)
 	Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)),
@@ -1317,10 +1353,14 @@
   struct gcpro gcpro1;
 
   /* OK to delete an already deleted frame. */
-  if (! FRAME_LIVE_P (f))
+  if (!FRAME_LIVE_P (f))
     return;
 
   frame = wrap_frame (f);
+
+  if (!force)
+    check_allowed_operation (OPERATION_DELETE_OBJECT, frame, Qnil);
+
   GCPRO1 (frame);
 
   device = FRAME_DEVICE (f);
@@ -1575,6 +1615,7 @@
   f->visible = 0;
 
   free_window_mirror (XWINDOW_MIRROR (f->root_mirror));
+
 /*  free_line_insertion_deletion_costs (f); */
 
   /* If we've deleted the last non-minibuf frame, then try to find
@@ -1670,6 +1711,8 @@
   nuke_all_frame_slots (f);
   f->framemeths = dead_console_methods;
 
+  note_object_deleted (frame);
+
   UNGCPRO;
 }
 
--- a/src/frame.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/frame.h	Tue May 28 08:45:36 2002 +0000
@@ -780,9 +780,8 @@
 void adjust_frame_size (struct frame *frame);
 void frame_size_slipped (Lisp_Object specifier, struct frame *f,
 			 Lisp_Object oldval);
-void hold_frame_size_changes (void);
-void unhold_one_frame_size_changes (struct frame *f);
-void unhold_frame_size_changes (void);
+int enter_redisplay_critical_section (void);
+void exit_redisplay_critical_section (int);
 void select_frame_1 (Lisp_Object frame);
 void select_frame_2 (Lisp_Object frame);
 struct frame *selected_frame (void);
--- a/src/general-slots.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/general-slots.h	Tue May 28 08:45:36 2002 +0000
@@ -113,6 +113,7 @@
 SYMBOL (Qeql);
 SYMBOL (Qequal);
 SYMBOL (Qeval);
+SYMBOL (Qevent);
 SYMBOL (Qextents);
 SYMBOL (Qexternal);
 SYMBOL (Qface);
@@ -130,7 +131,9 @@
 SYMBOL (Qgeneric);
 SYMBOL (Qgeometry);
 SYMBOL (Qglobal);
+SYMBOL (Qglyph);
 SYMBOL (Qgtk);
+SYMBOL (Qgui_item);
 SYMBOL (Qgutter);
 SYMBOL (Qheight);
 SYMBOL_KEYWORD (Q_height);
--- a/src/glyphs-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/glyphs-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -779,10 +779,10 @@
 
       /* mustn't lose this when we return */
       colortbl[j].name = qxestrdup (XSTRING_DATA (XCAR (cons)));
-      free_cons (XCONS (cons));
+      free_cons (cons);
       cons = results;
       results = XCDR (results);
-      free_cons (XCONS (cons));
+      free_cons (cons);
     }
   return colortbl;
 }
@@ -1678,7 +1678,7 @@
 
   /* the compface library exports char F[], which uses a single byte per
      pixel to represent a 48x48 bitmap.  Yuck. */
-  for (i = 0, p = F; i < (PIXELS / 8); ++i)
+  for (i = 0, p = (UChar_Binary *) F; i < (PIXELS / 8); ++i)
     {
       int n, b;
       /* reverse the bit order of each byte... */
--- a/src/glyphs-widget.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/glyphs-widget.c	Tue May 28 08:45:36 2002 +0000
@@ -506,13 +506,15 @@
       /* Finish off with dynamic sizing. */
       if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
 	{
-	  dynamic_width = Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
+	  dynamic_width =
+	    eval_within_redisplay (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
 	  if (INTP (dynamic_width))
 	    *width = XINT (dynamic_width);
 	}
       if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
 	{
-	  dynamic_height = Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
+	  dynamic_height =
+	    eval_within_redisplay (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
 	  if (INTP (dynamic_height))
 	    *height = XINT (dynamic_height);
 	}
@@ -1184,7 +1186,7 @@
   if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
     {
       Lisp_Object dynamic_width =
-	Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
+	eval_within_redisplay (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
       if (INTP (dynamic_width))
 	*width = XINT (dynamic_width);
     }
@@ -1200,7 +1202,7 @@
   if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
     {
       Lisp_Object dynamic_height =
-	Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
+	eval_within_redisplay (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
       if (INTP (dynamic_height))
 	*height = XINT (dynamic_height);
     }
--- a/src/glyphs-x.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/glyphs-x.c	Tue May 28 08:45:36 2002 +0000
@@ -1164,10 +1164,10 @@
 			  symbols[i].name, Qctext);
       symbols[i].pixel = color.pixel;
       symbols[i].value = 0;
-      free_cons (XCONS (cons));
+      free_cons (cons);
       cons = results;
       results = XCDR (results);
-      free_cons (XCONS (cons));
+      free_cons (cons);
     }
   return symbols;
 }
@@ -1559,16 +1559,17 @@
 {
   Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
   int i, stattis;
-  Char_Binary *bits, *bp;
-  Char_Binary *p;
-  const Intbyte * volatile emsg = 0;
-  Char_Binary * volatile dstring;
+  UChar_Binary *p, *bits, *bp;
+  const CIntbyte * volatile emsg = 0;
+  const UChar_Binary * volatile dstring;
 
   assert (!NILP (data));
 
-  LISP_STRING_TO_EXTERNAL (data, dstring, Qbinary);
-
-  if ((p = strchr (dstring, ':')))
+  TO_EXTERNAL_FORMAT (LISP_STRING, data,
+		      C_STRING_ALLOCA, dstring,
+		      Qbinary);
+
+  if ((p = (UChar_Binary *) strchr ((char *) dstring, ':')))
     {
       dstring = p + 1;
     }
@@ -1576,7 +1577,7 @@
   /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
   if (!(stattis = setjmp (comp_env)))
     {
-      UnCompAll (dstring);
+      UnCompAll ((char *) dstring);
       UnGenFace ();
     }
 
@@ -1594,13 +1595,13 @@
     }
 
   if (emsg)
-    gui_error_2 (emsg, data, Qimage);
-
-  bp = bits = (Char_Binary *) ALLOCA (PIXELS / 8);
+    signal_image_error_2 (emsg, data, Qimage);
+
+  bp = bits = (UChar_Binary *) ALLOCA (PIXELS / 8);
 
   /* the compface library exports char F[], which uses a single byte per
      pixel to represent a 48x48 bitmap.  Yuck. */
-  for (i = 0, p = F; i < (PIXELS / 8); ++i)
+  for (i = 0, p = (UChar_Binary *) F; i < (PIXELS / 8); ++i)
     {
       int n, b;
       /* reverse the bit order of each byte... */
@@ -1608,11 +1609,11 @@
 	{
 	  n |= ((*p++) << b);
 	}
-      *bp++ = (Char_Binary) n;
+      *bp++ = (UChar_Binary) n;
     }
 
   xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
-		     pointer_bg, dest_mask, 48, 48, bits);
+		     pointer_bg, dest_mask, 48, 48, (Char_Binary *) bits);
 }
 
 #endif /* HAVE_XFACE */
--- a/src/glyphs.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/glyphs.c	Tue May 28 08:45:36 2002 +0000
@@ -3107,8 +3107,8 @@
      glyph, so as long as the glyph is marked the instantiator will be
      as well and hence the cached image instance also.*/
   Fputhash (XCAR (XCDR (locative)), XCAR (locative), XCDR (XCDR (locative)));
-  free_cons (XCONS (XCDR (locative)));
-  free_cons (XCONS (locative));
+  free_cons (XCDR (locative));
+  free_cons (locative);
   return Qnil;
 }
 
@@ -4587,8 +4587,17 @@
      layouts. We are saved by layout optimization, but I'm undecided
      as to what the correct fix is. */
   else if (WIDGET_IMAGE_INSTANCEP (subwindow)
-	   && (!internal_equal (IMAGE_INSTANCE_WIDGET_ITEMS (ii),
-				IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii), 0)
+	   && (!internal_equal_trapping_problems
+	       (Qglyph, "bad subwindow instantiator",
+		/* in this case we really don't want to be
+		   interrupted by QUIT because we care about
+		   the return value; and we know that any loops
+		   will ultimately cause errors to be issued.
+		   We specify a retval of 1 in that case so that
+		   the glyph code doesn't try to keep reoutputting
+		   a bad subwindow. */
+		  INHIBIT_QUIT, 0, 1, IMAGE_INSTANCE_WIDGET_ITEMS (ii),
+		  IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii), 0)
 	       || !NILP (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii))
 	       || IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii)))
     return 1;
--- a/src/gpmevent.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/gpmevent.c	Tue May 28 08:45:36 2002 +0000
@@ -94,8 +94,8 @@
 static int
 get_process_infd (Lisp_Process *p)
 {
-  Lisp_Object instr, outstr;
-  get_process_streams (p, &instr, &outstr);
+  Lisp_Object instr, outstr, errstr;
+  get_process_streams (p, &instr, &outstr, &errstr);
   assert (!NILP (instr));
   return filedesc_stream_fd (XLSTREAM (instr));
 }
@@ -588,7 +588,7 @@
 	  rval = 0;
 	  Fprocess_kill_without_query (gpm_process, Qnil);
 	  gpm_filter = wrap_subr (&SFreceive_gpm_event);
-	  set_process_filter (gpm_process, gpm_filter, 1);
+	  set_process_filter (gpm_process, gpm_filter, 1, 0);
 
 	  /* Keep track of the device for later */
 	  /* Fput (gpm_process, intern ("gpm-device"), device); */
--- a/src/gui-x.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/gui-x.c	Tue May 28 08:45:36 2002 +0000
@@ -382,16 +382,15 @@
   return retval;
 }
 
-/* This does the dirty work.  begin_gc_forbidden() is active when this is
- called. */
+/* This does the dirty work.  GC is inhibited when this is called.
+ */
 int
 button_item_to_widget_value (Lisp_Object gui_object_instance,
 			     Lisp_Object gui_item, widget_value *wv,
 			     int allow_text_field_p, int no_keys_p,
 			     int menu_entry_p, int accel_p)
 {
-  /* This function cannot GC because begin_gc_forbidden() is active when
-     it's called. */
+  /* This function cannot GC because GC is inhibited when it's called */
   Lisp_Gui_Item* pgui = 0;
 
   /* degenerate case */
--- a/src/gui.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/gui.c	Tue May 28 08:45:36 2002 +0000
@@ -594,8 +594,7 @@
 {
   int hashid = gui_item_hash (gitem, 0);
   int id = GUI_ITEM_ID_BITS (hashid, slot);
-  while (!NILP (Fgethash (make_int (id),
-			  hashtable, Qnil)))
+  while (!UNBOUNDP (Fgethash (make_int (id), hashtable, Qunbound)))
     {
       id = GUI_ITEM_ID_BITS (id + 1, slot);
     }
--- a/src/gutter.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/gutter.c	Tue May 28 08:45:36 2002 +0000
@@ -690,16 +690,17 @@
 			int height)
 {
   enum gutter_pos pos;
+  int depth;
 
   /* We have to be "in display" when we output the gutter - make it
      so. */
-  hold_frame_size_changes ();
+  depth = enter_redisplay_critical_section ();
   GUTTER_POS_LOOP (pos)
     {
       if (FRAME_GUTTER_VISIBLE (f, pos))
 	redraw_exposed_gutter (f, pos, x, y, width, height);
     }
-  unhold_one_frame_size_changes (f);
+  exit_redisplay_critical_section (depth);
 }
 
 void
@@ -745,11 +746,13 @@
 
   if (cur != new)
     {
+      int depth;
+
       /* The following calls will automatically cause the dirty
 	 flags to be set; we delay frame size changes to avoid
 	 lots of frame flickering. */
       /* #### I think this should be GC protected. -sb */
-      hold_frame_size_changes ();
+      depth = enter_redisplay_critical_section ();
       set_specifier_fallback (Vgutter[cur], list1 (Fcons (Qnil, Qnil)));
       set_specifier_fallback (Vgutter[new], Vdefault_gutter);
       set_specifier_fallback (Vgutter_size[cur], list1 (Fcons (Qnil, Qzero)));
@@ -765,7 +768,7 @@
       set_specifier_fallback (Vgutter_visible_p[new], Vdefault_gutter_visible_p);
 
       Vdefault_gutter_position = position;
-      unhold_frame_size_changes ();
+      exit_redisplay_critical_section (depth);
     }
 
   run_hook (Qdefault_gutter_position_changed_hook);
@@ -1079,11 +1082,13 @@
 	    redisplay_frame (f, 1);
 	  else if (FRAME_REPAINT_P (f))
 	    {
+	      int depth;
+
 	      /* We have to be "in display" when we output the gutter
                  - make it so. */
-	      hold_frame_size_changes ();
+	      depth = enter_redisplay_critical_section ();
 	      update_frame_gutters (f);
-	      unhold_one_frame_size_changes (f);
+	      exit_redisplay_critical_section (depth);
 	    }
 
 	  MAYBE_DEVMETH (d, frame_output_end, (f));
--- a/src/insdel.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/insdel.c	Tue May 28 08:45:36 2002 +0000
@@ -25,7 +25,13 @@
 
 /* This file has been Mule-ized. */
 
-/* Overhauled by Ben Wing, December 1994, for Mule implementation. */
+/* Original file from FSF, 1991.
+   Some changes for extents, c. 1991 by unknown Lucid author.
+   Completely rewritten December 1994, for Mule implementation by Ben Wing;
+     all buffer modification code ripped out of other files and consolidated
+     here.
+   Indirect buffers written c. 1997? by Hrvoje Niksic.
+*/
 
 #include <config.h>
 #include "lisp.h"
@@ -729,7 +735,9 @@
 	  record_unwind_protect (first_change_hook_restore, buffer);
 	  set_buffer_internal (buf);
 	  in_first_change = 1;
-	  run_hook (Qfirst_change_hook);
+	  run_hook_trapping_problems
+	    (0, Qfirst_change_hook,
+	     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	  unbind_to (speccount);
 	}
     }
@@ -798,11 +806,15 @@
 	      || !NILP (symbol_value_in_buffer (Qbefore_change_function, buffer)))
 	    {
 	      set_buffer_internal (buf);
-	      va_run_hook_with_args (Qbefore_change_functions, 2,
-				     make_int (start), make_int (end));
+	      va_run_hook_with_args_trapping_problems
+		(0, Qbefore_change_functions, 2,
+		 make_int (start), make_int (end),
+		 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	      /* Obsolete, for compatibility */
-	      va_run_hook_with_args (Qbefore_change_function, 2,
-				     make_int (start), make_int (end));
+	      va_run_hook_with_args_trapping_problems
+		(0, Qbefore_change_function, 2,
+		 make_int (start), make_int (end),
+		 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	    }
 	}
 
@@ -883,13 +895,17 @@
 	      set_buffer_internal (buf);
 	      /* The actual after-change functions take slightly
 		 different arguments than what we were passed. */
-	      va_run_hook_with_args (Qafter_change_functions, 3,
-				     make_int (start), make_int (new_end),
-				     make_int (orig_end - start));
+	      va_run_hook_with_args_trapping_problems
+		(0, Qafter_change_functions, 3,
+		 make_int (start), make_int (new_end),
+		 make_int (orig_end - start),
+		 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	      /* Obsolete, for compatibility */
-	      va_run_hook_with_args (Qafter_change_function, 3,
-				     make_int (start), make_int (new_end),
-				     make_int (orig_end - start));
+	      va_run_hook_with_args_trapping_problems
+		(0, Qafter_change_function, 3,
+		 make_int (start), make_int (new_end),
+		 make_int (orig_end - start),
+		 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	    }
 	}
 
@@ -930,6 +946,8 @@
 
   MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
     {
+      check_allowed_operation (OPERATION_MODIFY_BUFFER_TEXT,
+			       wrap_buffer (mbuf), Qnil);
       barf_if_buffer_read_only (mbuf, start, end);
     }
 
@@ -1140,6 +1158,8 @@
   if (STRINGP (reloc))
     nonreloc = XSTRING_DATA (reloc);
 
+  memcpy (BUF_GPT_ADDR (buf), nonreloc + offset, length);
+
   copy_text_between_formats (nonreloc + offset, length, FORMAT_DEFAULT,
 			     STRINGP (reloc) ? reloc : Qnil,
 			     BUF_GPT_ADDR (buf), length_in_buffer,
--- a/src/intl.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/intl.c	Tue May 28 08:45:36 2002 +0000
@@ -162,19 +162,23 @@
 void
 init_intl (void)
 {
+  /* This function can GC */
   if (initialized)
     {
-      /* #### port to new error-trapping system when i sync up the code */
       int count = begin_gc_forbidden ();
+      Lisp_Object args[2];
+
       specbind (Qinhibit_quit, Qt);
-      call0_with_handler (Qreally_early_error_handler,
-			  intern ("init-locale-at-early-startup"));
+      args[0] = Qreally_early_error_handler;
+      args[1] = intern ("init-locale-at-early-startup");
+      Fcall_with_condition_handler (2, args);
+
       /* Should be calling this here, but problems with
          `data-directory' and locating the files.  See comment in
          mule-cmds.el:`init-mule-at-startup'.
 
-      call0_with_handler (Qreally_early_error_handler,
-                          intern ("init-unicode-at-early-startup"));
+      args[1] = intern ("init-unicode-at-early-startup");
+      Fcall_with_condition_handler (2, args);
        */
       unbind_to (count);
     }
--- a/src/keymap.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/keymap.c	Tue May 28 08:45:36 2002 +0000
@@ -319,8 +319,8 @@
 	{
 	  while (CONSP (malloc_bites))
 	    {
-	      Lisp_Cons *victim = XCONS (malloc_bites);
-	      malloc_bites = victim->cdr;
+	      Lisp_Object victim = malloc_bites;
+	      malloc_bites = XCDR (victim);
 	      free_cons (victim);
 	    }
 	  UNGCPRO;
@@ -336,9 +336,9 @@
 	  stack_depth--;
 	  if (CONSP (malloc_bites))
 	    {
-	      Lisp_Cons *victim = XCONS (malloc_bites);
-	      tail = victim->car;
-	      malloc_bites = victim->cdr;
+	      Lisp_Object victim = malloc_bites;
+	      tail = XCAR (victim);
+	      malloc_bites = XCDR (victim);
 	      free_cons (victim);
 	    }
 	  else
--- a/src/lisp-disunion.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/lisp-disunion.h	Tue May 28 08:45:36 2002 +0000
@@ -114,6 +114,13 @@
 #define Qnull_pointer ((Lisp_Object) 0)
 #define EQ(x,y) ((x) == (y))
 
+/* WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+   You can only VOID_TO_LISP something that had previously been
+   LISP_TO_VOID'd.  You cannot go the other way, i.e. create a bogus
+   Lisp_Object.  If you want to stuff a void * into a Lisp_Object, use
+   make_opaque_ptr(). */
+
 /* Convert between a (void *) and a Lisp_Object, as when the
    Lisp_Object is passed to a toolkit callback function */
 #define VOID_TO_LISP(varg) ((Lisp_Object) (varg))
--- a/src/lisp-union.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/lisp-union.h	Tue May 28 08:45:36 2002 +0000
@@ -167,6 +167,13 @@
 #define INT_PLUS1(x)   make_int (XINT (x) + 1)
 #define INT_MINUS1(x)  make_int (XINT (x) - 1)
 
+/* WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+   You can only VOID_TO_LISP something that had previously been
+   LISP_TO_VOID'd.  You cannot go the other way, i.e. create a bogus
+   Lisp_Object.  If you want to stuff a void * into a Lisp_Object, use
+   make_opaque_ptr(). */
+
 /* Convert between a (void *) and a Lisp_Object, as when the
    Lisp_Object is passed to a toolkit callback function */
 DECLARE_INLINE_HEADER (
--- a/src/lisp.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/lisp.h	Tue May 28 08:45:36 2002 +0000
@@ -22,6 +22,31 @@
 
 /* Synched up with: FSF 19.30. */
 
+/* Authorship:
+
+   Based on code from pre-release FSF 19, c. 1991.
+   Various changes by Jamie Zawinski 1991-1994:
+     converting to ANSI C, splitting out function prototypes to a separate
+     file (later moved back for unknown reasons by Steve Baur?), debug-gcpro
+     stuff (now moribund).
+   ANSI-fication of DEFUN macros by Felix Lee, c. 1992?
+   NOT_REACHED, DOESNT_RETURN, PRINTF_ARGS by Richard Mlynarik, c. 1994.
+   Many changes over the years corresponding to Lisp_Object definition
+     changes, esp. by Richard Mlynarik (c. 1993) and Kyle Jones (c. 1998).
+     See alloc.c for more details.
+   Overhauled and reordered by Ben Wing, 1995-1996, and many things added:
+     Dynarrs, REALLOC macros, asserts, typedefs, inline header code,
+     first LIST_LOOP macros, CONCHECK_*, all error-checking code
+     (e.g. error-checking versions of XFOO macros), structure read syntax,
+     weak lists, lcrecord lists, reworking of quit handling, object hashing,
+     nested GCPRO, character objects and Ebola checking, memory usage stats,
+     others.
+   LOADHIST changes from Steve Baur, c. 1997?
+   Various macro-related changes by Martin Buchholz, 1998-1999:
+     LIST_LOOP macros greatly expanded and tortoise-hared;
+     RETURN_SANS_WARNINGS; reworked DEFUN macros; EXFUN macros (???).
+*/
+
 #ifndef INCLUDED_lisp_h_
 #define INCLUDED_lisp_h_
 
@@ -45,6 +70,21 @@
 #include <sys/types.h>
 #include <limits.h>
 
+/* --------------------- error-checking sublevels --------------------- */
+
+/* The large categories established by configure can be subdivided into
+   smaller subcategories, for problems in specific modules.  You can't
+   control this using configure, but you can manually stick in a define as
+   necessary. */
+
+#ifdef ERROR_CHECK_STRUCTURES
+/* Check for problems with the catch list and specbind stack */
+#define ERROR_CHECK_CATCH
+/* Check for insufficient use of call_trapping_problems(), particularly
+   due to glyph-related changes causing eval or QUIT within redisplay */
+#define ERROR_CHECK_TRAPPING_PROBLEMS
+#endif
+
 /* ------------------------ definition of EMACS_INT ------------------- */
 
 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
@@ -895,18 +935,44 @@
 void assert_failed (const char *, int, const char *);
 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
+# define assert_with_message(x, msg) \
+  ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg))
 # define assert_at_line(x, file, line) \
   ((x) ? (void) 0 : assert_failed (file, line, #x))
 #else
 # ifdef DEBUG_XEMACS
 #  define assert(x) ((x) ? (void) 0 : (void) abort ())
+#  define assert_with_message(x, msg) ((x) ? (void) 0 : (void) abort ())
 #  define assert_at_line(x, file, line) assert (x)
 # else
 #  define assert(x) ((void) 0)
+#  define assert_with_message(x, msg)
 #  define assert_at_line(x, file, line) assert (x)
 # endif
 #endif
 
+/* ####
+   Why the hell do we do this??????????????????????????????? */
+/*#ifdef DEBUG_XEMACS*/
+#define REGISTER
+#define register
+/*#else*/
+/*#define REGISTER register*/
+/*#endif*/
+
+
+/* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
+   In particular, it must be large enough to contain a pointer.
+   config.h can override this, e.g. to use `long long' for bigger lisp ints.
+
+   #### In point of fact, it would NOT be a good idea for config.h to mess
+   with EMACS_INT.  A lot of code makes the basic assumption that EMACS_INT
+   is the size of a pointer. */
+
+#ifndef SIZEOF_EMACS_INT
+# define SIZEOF_EMACS_INT SIZEOF_VOID_P
+#endif
+
 #if 0
 #ifdef USE_ASSERTIONS
 /* Highly dubious kludge */
@@ -1144,10 +1210,7 @@
 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats);
 #endif
 
-
-/************************************************************************/
-/*				  typedefs				*/
-/************************************************************************/
+/* Counts of bytes or chars */
 
 /* Note that the simplest typedefs are near the top of this file. */
 
@@ -1493,7 +1556,7 @@
 struct Lisp_Cons
 {
   struct lrecord_header lheader;
-  Lisp_Object car, cdr;
+  Lisp_Object car_, cdr_;
 };
 typedef struct Lisp_Cons Lisp_Cons;
 
@@ -1522,8 +1585,12 @@
 extern Lisp_Object Qnil;
 
 #define NILP(x)  EQ (x, Qnil)
-#define XCAR(a) (XCONS (a)->car)
-#define XCDR(a) (XCONS (a)->cdr)
+#define cons_car(a) ((a)->car_)
+#define cons_cdr(a) ((a)->cdr_)
+#define XCAR(a) (XCONS (a)->car_)
+#define XCDR(a) (XCONS (a)->cdr_)
+#define XSETCAR(a, b) (XCONS (a)->car_ = (b))
+#define XSETCDR(a, b) (XCONS (a)->cdr_ = (b))
 #define LISTP(x) (CONSP(x) || NILP(x))
 
 #define CHECK_LIST(x) do {			\
@@ -2163,6 +2230,7 @@
 #define BIT_VECTOR_LONG_STORAGE(len) \
   (((len) + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2)
 
+
 /*------------------------------ symbol --------------------------------*/
 
 typedef struct Lisp_Symbol Lisp_Symbol;
@@ -2206,6 +2274,8 @@
 
 /*------------------------------- subr ---------------------------------*/
 
+/* A function that takes no arguments and returns a Lisp_Object.
+   We could define such types for n arguments, if needed. */
 typedef Lisp_Object (*lisp_fn_t) (void);
 
 struct Lisp_Subr
@@ -2693,48 +2763,72 @@
 /*			   Checking for QUIT				*/
 /************************************************************************/
 
+/* The exact workings of this mechanism are described in detail in signal.c. */
+
 /* Asynchronous events set something_happened, and then are processed
    within the QUIT macro.  At this point, we are guaranteed to not be in
    any sensitive code. */
 
 extern volatile int something_happened;
 extern int dont_check_for_quit;
-int check_what_happened (void);
+void check_what_happened (void);
 
 extern volatile int quit_check_signal_happened;
 extern volatile int quit_check_signal_tick_count;
-int check_quit (void);
+void check_quit (void);
 
 void signal_quit (void);
 
+extern int dont_check_for_quit;
+int begin_dont_check_for_quit (void);
+int begin_do_check_for_quit (void);
+
+/* Nonzero if the values of `quit-flag' and `inhibit-quit' indicate
+   that a quit should be signalled. */
 #define QUIT_FLAG_SAYS_SHOULD_QUIT				\
   (!NILP (Vquit_flag) &&					\
    (NILP (Vinhibit_quit)					\
     || (EQ (Vquit_flag, Qcritical) && !dont_check_for_quit)))
 
-/* Nonzero if ought to quit now.  */
+/* Nonzero if ought to quit now.  This is the "efficient" version, which
+   respects the flags set to indicate whether the full quit check should
+   be done.  Therefore it may be inaccurate (i.e. lagging reality), esp.
+   when poll for quit is used.
+
+   This is defined for code that wants to allow quitting, but needs to
+   do some cleanup if that happens. (You could always register the cleanup
+   code using record_unwind_protect(), but sometimes it makes more sense
+   to do it using QUITP.) To use this macro, just call it at the
+   appropriate time, and if its value is non-zero, do your cleanup code
+   and then call QUIT.
+
+   A different version (below) is used for the actual QUIT macro.  */
 #define QUITP							\
-  ((quit_check_signal_happened ? check_quit () : 0),		\
+  ((quit_check_signal_happened ? check_quit () : (void) 0),	\
    QUIT_FLAG_SAYS_SHOULD_QUIT)
 
-/* QUIT used to call QUITP, but there are some places where QUITP
-   is called directly, and check_what_happened() should only be called
-   when Emacs is actually ready to quit because it could do things
-   like switch threads. */
+/* This is the version actually called by QUIT.  The difference
+   between it and QUITP is that it also has side effects in that it
+   will handle anything else that has recently signalled itself
+   asynchronously and wants to be handled now.  Currently this
+   includes executing asynchronous timeouts that may have been set
+   from Lisp or from the poll-for-quit or poll-for-sigchld
+   timers. (#### It seems that, to be slightly more accurate, we
+   should also process poll-for-quit timers in the above version.
+   However, this mechanism is inherently approximate, so it really
+   doesn't matter much.) In the future, it might also include doing a
+   thread context switch.  Callers of QUITP generally don't except
+   random side effects to happen, so we have this different
+   version. */
 #define INTERNAL_QUITP						\
-  ((something_happened ? check_what_happened () : 0),		\
-   QUIT_FLAG_SAYS_SHOULD_QUIT)
-
-#define INTERNAL_REALLY_QUITP					\
-  (check_what_happened (),					\
+  ((something_happened ? check_what_happened () : (void) 0),	\
    QUIT_FLAG_SAYS_SHOULD_QUIT)
 
 /* Check quit-flag and quit if it is non-nil.  Also do any other things
-   that might have gotten queued until it was safe. */
+   that are triggered by asynchronous events and might want to be
+   handled. */
 #define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0)
 
-#define REALLY_QUIT do { if (INTERNAL_REALLY_QUITP) signal_quit (); } while (0)
-
 
 /************************************************************************/
 /*				 hashing				*/
@@ -2924,6 +3018,21 @@
   gcpro5.next = &gcpro4,   gcpro5.var = &var5, gcpro5.nvars = 1,	\
   gcprolist = &gcpro5 ))
 
+#define GCPRO1_ARRAY(array, n) ((void) (				\
+  gcpro1.next = gcprolist, gcpro1.var = array, gcpro1.nvars = n,	\
+  gcprolist = &gcpro1 ))
+
+#define GCPRO2_ARRAY(array1, n1, array2, n2) ((void) (			\
+  gcpro1.next = gcprolist, gcpro1.var = array1, gcpro1.nvars = n1,	\
+  gcpro2.next = &gcpro1,   gcpro2.var = array2, gcpro2.nvars = n2,	\
+  gcprolist = &gcpro2 ))
+
+#define GCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) (	\
+  gcpro1.next = gcprolist, gcpro1.var = array1, gcpro1.nvars = n1,	\
+  gcpro2.next = &gcpro1,   gcpro2.var = array2, gcpro2.nvars = n2,	\
+  gcpro3.next = &gcpro2,   gcpro3.var = array3, gcpro3.nvars = n3,	\
+  gcprolist = &gcpro3 ))
+
 #define UNGCPRO ((void) (gcprolist = gcpro1.next))
 
 #define NGCPRO1(var1) ((void) (						\
@@ -2956,6 +3065,21 @@
   ngcpro5.next = &ngcpro4,  ngcpro5.var = &var5, ngcpro5.nvars = 1,	\
   gcprolist = &ngcpro5 ))
 
+#define NGCPRO1_ARRAY(array, n) ((void) (				\
+  ngcpro1.next = gcprolist, ngcpro1.var = array, ngcpro1.nvars = n,	\
+  gcprolist = &ngcpro1 ))
+
+#define NGCPRO2_ARRAY(array1, n1, array2, n2) ((void) (			\
+  ngcpro1.next = gcprolist, ngcpro1.var = array1, ngcpro1.nvars = n1,	\
+  ngcpro2.next = &ngcpro1,  ngcpro2.var = array2, ngcpro2.nvars = n2,	\
+  gcprolist = &ngcpro2 ))
+
+#define NGCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) (	\
+  ngcpro1.next = gcprolist, ngcpro1.var = array1, ngcpro1.nvars = n1,	\
+  ngcpro2.next = &ngcpro1,  ngcpro2.var = array2, ngcpro2.nvars = n2,	\
+  ngcpro3.next = &ngcpro2,  ngcpro3.var = array3, ngcpro3.nvars = n3,	\
+  gcprolist = &ngcpro3 ))
+
 #define NUNGCPRO ((void) (gcprolist = ngcpro1.next))
 
 #define NNGCPRO1(var1) ((void) (					\
@@ -2988,6 +3112,21 @@
   nngcpro5.next = &nngcpro4, nngcpro5.var = &var5, nngcpro5.nvars = 1,	\
   gcprolist = &nngcpro5 ))
 
+#define NNGCPRO1_ARRAY(array, n) ((void) (				\
+  nngcpro1.next = gcprolist, nngcpro1.var = array, nngcpro1.nvars = n,	\
+  gcprolist = &nngcpro1 ))
+
+#define NNGCPRO2_ARRAY(array1, n1, array2, n2) ((void) (		  \
+  nngcpro1.next = gcprolist,  nngcpro1.var = array1, nngcpro1.nvars = n1, \
+  nngcpro2.next = &nngcpro1,  nngcpro2.var = array2, nngcpro2.nvars = n2, \
+  gcprolist = &nngcpro2 ))
+
+#define NNGCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) (	  \
+  nngcpro1.next = gcprolist,  nngcpro1.var = array1, nngcpro1.nvars = n1, \
+  nngcpro2.next = &nngcpro1,  nngcpro2.var = array2, nngcpro2.nvars = n2, \
+  nngcpro3.next = &nngcpro2,  nngcpro3.var = array3, nngcpro3.nvars = n3, \
+  gcprolist = &nngcpro3 ))
+
 #define NNUNGCPRO ((void) (gcprolist = nngcpro1.next))
 
 #endif /* ! DEBUG_GCPRO */
@@ -3181,7 +3320,6 @@
 DECLARE_DOESNT_RETURN (memory_full (void));
 void disksave_object_finalization (void);
 extern int purify_flag;
-extern int gc_currently_forbidden;
 extern EMACS_INT gc_generation_number[1];
 int c_readonly (Lisp_Object);
 int lisp_readonly (Lisp_Object);
@@ -3196,7 +3334,7 @@
 Lisp_Object make_uninit_string (Bytecount);
 Lisp_Object make_float (double);
 Lisp_Object make_string_nocopy (const Intbyte *, Bytecount);
-void free_cons (Lisp_Cons *);
+void free_cons (Lisp_Object);
 void free_list (Lisp_Object);
 void free_alist (Lisp_Object);
 void mark_conses_in_list (Lisp_Object);
@@ -3273,11 +3411,6 @@
 DECLARE_DOESNT_RETURN (invalid_byte_code
 		       (const CIntbyte *reason, Lisp_Object frob));
 
-/* Defined in callproc.c */
-Intbyte *egetenv (const CIntbyte *var);
-void eputenv (const CIntbyte *var, const CIntbyte *value);
-extern int env_initted;
-
 /* Defined in callint.c */
 EXFUN (Fcall_interactively, 3);
 EXFUN (Fprefix_numeric_value, 1);
@@ -3469,7 +3602,6 @@
 extern int inhibit_non_essential_printing_operations;
 extern int preparing_for_armageddon;
 extern Fixnum emacs_priority;
-extern int running_asynch_code;
 extern int suppress_early_error_handler_backtrace;
 void debug_break (void);
 int debug_can_access_memory (void *ptr, Bytecount len);
@@ -3493,6 +3625,9 @@
 EXFUN (Fprogn, UNEVALLED);
 EXFUN (Fsignal, 2);
 EXFUN (Fthrow, 2);
+EXFUN (Fcall_with_condition_handler, MANY);
+EXFUN (Ffunction_max_args, 1);
+EXFUN (Ffunction_min_args, 1);
 
 DECLARE_DOESNT_RETURN (signal_error_1 (Lisp_Object, Lisp_Object));
 void maybe_signal_error_1 (Lisp_Object, Lisp_Object, Lisp_Object,
@@ -3652,21 +3787,116 @@
 			     Lisp_Object, Lisp_Object, Lisp_Object,
 			     Lisp_Object, Lisp_Object);
 Lisp_Object eval_in_buffer (struct buffer *, Lisp_Object);
-Lisp_Object call0_with_handler (Lisp_Object, Lisp_Object);
-Lisp_Object call1_with_handler (Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object eval_in_buffer_trapping_errors (const CIntbyte *, struct buffer *,
-					    Lisp_Object);
-Lisp_Object run_hook_trapping_errors (const CIntbyte *, Lisp_Object);
-Lisp_Object safe_run_hook_trapping_errors (const CIntbyte *, Lisp_Object, int);
-Lisp_Object call0_trapping_errors (const CIntbyte *, Lisp_Object);
-Lisp_Object call1_trapping_errors (const CIntbyte *, Lisp_Object, Lisp_Object);
-Lisp_Object call2_trapping_errors (const CIntbyte *,
-				   Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object call_with_suspended_errors (lisp_fn_t, volatile Lisp_Object, Lisp_Object,
+
+struct call_trapping_problems_result
+{
+  int caught_error, caught_throw;
+  Lisp_Object error_conditions, data;
+  Lisp_Object backtrace;
+  Lisp_Object thrown_tag;
+  Lisp_Object thrown_value;
+};
+
+#define NO_INHIBIT_ERRORS (1<<0)
+#define NO_INHIBIT_THROWS (1<<1)
+#define INTERNAL_INHIBIT_ERRORS (1<<0)
+#define INTERNAL_INHIBIT_THROWS (1<<1)
+#define INHIBIT_WARNING_ISSUE (1<<2)
+#define ISSUE_WARNINGS_AT_DEBUG_LEVEL (1<<3)
+#define INHIBIT_QUIT (1<<4)
+#define UNINHIBIT_QUIT (1<<5)
+#define INHIBIT_GC (1<<6)
+#define INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION (1<<7)
+#define INHIBIT_EXISTING_CODING_SYSTEM_DELETION (1<<8)
+#define INHIBIT_EXISTING_CHARSET_DELETION (1<<9)
+#define INHIBIT_PERMANENT_DISPLAY_OBJECT_CREATION (1<<10)
+#define INHIBIT_CODING_SYSTEM_CREATION (1<<11)
+#define INHIBIT_CHARSET_CREATION (1<<12)
+#define INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION (1<<13)
+#define INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY (1<<14)
+#define INHIBIT_ENTERING_DEBUGGER (1<<15)
+#define CALL_WITH_SUSPENDED_ERRORS (1<<16)
+
+enum check_allowed_operation
+{
+  OPERATION_DELETE_OBJECT,
+  OPERATION_CREATE_OBJECT,
+  OPERATION_MODIFY_BUFFER_TEXT,
+  OPERATION_MODIFY_OBJECT_PROPERTY,
+};
+
+int get_inhibit_flags (void);
+void check_allowed_operation (int what, Lisp_Object obj, Lisp_Object prop);
+void note_object_created (Lisp_Object obj);
+void note_object_deleted (Lisp_Object obj);
+Lisp_Object call_with_condition_handler (Lisp_Object (*handler) (Lisp_Object,
+								 Lisp_Object,
+								 Lisp_Object),
+					 Lisp_Object handler_arg,
+					 Lisp_Object (*fun) (Lisp_Object),
+					 Lisp_Object arg);
+Lisp_Object call_trapping_problems (Lisp_Object warning_class,
+				    const char *warning_string,
+				    int flags,
+				    struct call_trapping_problems_result
+				    *problem,
+				    Lisp_Object (*fun) (void *),
+				    void *arg);
+Lisp_Object va_call_trapping_problems (Lisp_Object warning_class,
+				       const char *warning_string,
+				       int flags,
+				       struct call_trapping_problems_result
+				       *problem,
+				       lisp_fn_t fun, int nargs, ...);
+Lisp_Object call0_trapping_problems (const char *, Lisp_Object, int);
+Lisp_Object call1_trapping_problems (const char *, Lisp_Object, Lisp_Object,
+				   int);
+Lisp_Object call2_trapping_problems (const char *, Lisp_Object, Lisp_Object,
+				   Lisp_Object, int);
+Lisp_Object call3_trapping_problems (const char *, Lisp_Object, Lisp_Object,
+				   Lisp_Object, Lisp_Object, int);
+Lisp_Object call4_trapping_problems (const char *, Lisp_Object, Lisp_Object,
+				   Lisp_Object, Lisp_Object, Lisp_Object,
+				   int);
+Lisp_Object call5_trapping_problems (const char *, Lisp_Object, Lisp_Object,
+				   Lisp_Object, Lisp_Object, Lisp_Object,
+				   Lisp_Object, int);
+Lisp_Object eval_in_buffer_trapping_problems (const char *, struct buffer *,
+					    Lisp_Object, int);
+Lisp_Object run_hook_trapping_problems (const char *, Lisp_Object, int);
+Lisp_Object safe_run_hook_trapping_problems (const char *, Lisp_Object, int);
+Lisp_Object run_hook_with_args_in_buffer_trapping_problems (const char
+							    *warning_string,
+							    struct buffer
+							    *buf, int nargs,
+							    Lisp_Object *args,
+							    enum
+							    run_hooks_condition
+							    cond, int flags);
+Lisp_Object run_hook_with_args_trapping_problems (const char *warning_string,
+						  int nargs,
+						  Lisp_Object *args,
+						  enum run_hooks_condition
+						  cond,
+						  int flags);
+Lisp_Object va_run_hook_with_args_trapping_problems (const char
+						     *warning_string,
+						     Lisp_Object hook_var,
+						     int nargs, ...);
+Lisp_Object va_run_hook_with_args_in_buffer_trapping_problems (const char
+							       *warning_string,
+							       struct buffer
+							       *buf,
+							       Lisp_Object
+							       hook_var,
+							       int nargs, ...);
+Lisp_Object call_with_suspended_errors (lisp_fn_t, Lisp_Object,
+					Lisp_Object,
 					Error_Behavior, int, ...);
 /* C Code should be using internal_catch, record_unwind_p, condition_case_1 */
 Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object),
-			    Lisp_Object, int * volatile);
+			    Lisp_Object, int * volatile,
+			    Lisp_Object * volatile);
 Lisp_Object condition_case_1 (Lisp_Object,
 			      Lisp_Object (*) (Lisp_Object),
 			      Lisp_Object,
@@ -3677,6 +3907,7 @@
 #define unbind_to(obj) unbind_to_1 (obj, Qnil)
 void specbind (Lisp_Object, Lisp_Object);
 int record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object);
+int record_unwind_protect_freeing (void *ptr);
 int record_unwind_protect_freeing_dynarr (void *ptr);
 int internal_bind_int (int *addr, int newval);
 int internal_bind_lisp_object (Lisp_Object *addr, Lisp_Object newval);
@@ -3964,6 +4195,13 @@
 void external_plist_put (Lisp_Object *, Lisp_Object,
 			 Lisp_Object, int, Error_Behavior);
 int external_remprop (Lisp_Object *, Lisp_Object, int, Error_Behavior);
+int internal_equal_trapping_problems (Lisp_Object warning_class,
+    				      const char *warning_string,
+				      int flags,
+				      struct call_trapping_problems_result *p,
+				      int retval,
+				      Lisp_Object obj1, Lisp_Object obj2,
+				      int depth);
 int internal_equal (Lisp_Object, Lisp_Object, int);
 int internal_equalp (Lisp_Object obj1, Lisp_Object obj2, int depth);
 Lisp_Object concat2 (Lisp_Object, Lisp_Object);
@@ -4199,6 +4437,10 @@
 DECLARE_DOESNT_RETURN (report_network_error (const char *, Lisp_Object));
 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
 
+Intbyte *egetenv (const CIntbyte *var);
+void eputenv (const CIntbyte *var, const CIntbyte *value);
+extern int env_initted;
+
 /* Defined in profile.c */
 void mark_profiling_info (void);
 void profile_increase_call_count (Lisp_Object);
@@ -4253,7 +4495,6 @@
 
 /* Defined in signal.c */
 void init_interrupts_late (void);
-int begin_dont_check_for_quit (void);
 
 /* Defined in sound.c */
 EXFUN (Fding, 3);
--- a/src/lread.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/lread.c	Tue May 28 08:45:36 2002 +0000
@@ -326,36 +326,6 @@
 load_unwind (Lisp_Object stream)  /* used as unwind-protect function in load */
 {
   Lstream_close (XLSTREAM (stream));
-  if (--load_in_progress < 0)
-    load_in_progress = 0;
-  return Qnil;
-}
-
-static Lisp_Object
-load_descriptor_unwind (Lisp_Object oldlist)
-{
-  Vload_descriptor_list = oldlist;
-  return Qnil;
-}
-
-static Lisp_Object
-load_file_name_internal_unwind (Lisp_Object oldval)
-{
-  Vload_file_name_internal = oldval;
-  return Qnil;
-}
-
-static Lisp_Object
-load_file_name_internal_the_purecopy_unwind (Lisp_Object oldval)
-{
-  Vload_file_name_internal_the_purecopy = oldval;
-  return Qnil;
-}
-
-static Lisp_Object
-load_byte_code_version_unwind (Lisp_Object oldval)
-{
-  load_byte_code_version = XINT (oldval);
   return Qnil;
 }
 
@@ -490,13 +460,6 @@
 
 #ifdef I18N3
 Lisp_Object Vfile_domain;
-
-Lisp_Object
-restore_file_domain (Lisp_Object val)
-{
-  Vfile_domain = val;
-  return Qnil;
-}
 #endif /* I18N3 */
 
 DEFUN ("load-internal", Fload_internal, 1, 6, 0, /*
@@ -675,28 +638,24 @@
     Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED,
 			   block_size);
     /* NOTE: Order of these is very important.  Don't rearrange them. */
+    internal_bind_int (&load_in_progress, 1 + load_in_progress);
     record_unwind_protect (load_unwind, lispstream);
-    record_unwind_protect (load_descriptor_unwind, Vload_descriptor_list);
-    record_unwind_protect (load_file_name_internal_unwind,
-			   Vload_file_name_internal);
-    record_unwind_protect (load_file_name_internal_the_purecopy_unwind,
-			   Vload_file_name_internal_the_purecopy);
+    internal_bind_lisp_object (&Vload_descriptor_list,
+			       Fcons (make_int (fd), Vload_descriptor_list));
+    internal_bind_lisp_object (&Vload_file_name_internal, found);
+    internal_bind_lisp_object (&Vload_file_name_internal_the_purecopy, Qnil);
+    /* this is not a simple internal_bind. */
     record_unwind_protect (load_force_doc_string_unwind,
 			   Vload_force_doc_string_list);
-    Vload_file_name_internal = found;
-    Vload_file_name_internal_the_purecopy = Qnil;
+    Vload_force_doc_string_list = Qnil;
     specbind (Qload_file_name, found);
-    Vload_descriptor_list = Fcons (make_int (fd), Vload_descriptor_list);
-    Vload_force_doc_string_list = Qnil;
 #ifdef I18N3
-    record_unwind_protect (restore_file_domain, Vfile_domain);
-    Vfile_domain = Qnil; /* set it to nil; a call to #'domain will set it. */
+    /* set it to nil; a call to #'domain will set it. */
+    internal_bind_lisp_object (&Vfile_domain, Qnil);
 #endif
-    load_in_progress++;
 
     /* Now determine what sort of ELC file we're reading in. */
-    record_unwind_protect (load_byte_code_version_unwind,
-			   make_int (load_byte_code_version));
+    internal_bind_int (&load_byte_code_version, load_byte_code_version);
     if (reading_elc)
       {
 	char elc_header[8];
@@ -1595,19 +1554,6 @@
 }
 
 
-#ifdef LISP_BACKQUOTES
-
-static Lisp_Object
-backquote_unwind (Lisp_Object ptr)
-{  /* used as unwind-protect function in read0() */
-  int *counter = (int *) get_opaque_ptr (ptr);
-  if (--*counter < 0)
-    *counter = 0;
-  free_opaque_ptr (ptr);
-  return Qnil;
-}
-
-#endif
 
 /* Use this for recursive reads, in contexts where internal tokens
    are not allowed.  See also read1(). */
@@ -1619,7 +1565,7 @@
   if (CONSP (val) && UNBOUNDP (XCAR (val)))
     {
       Emchar c = XCHAR (XCDR (val));
-      free_cons (XCONS (val));
+      free_cons (val);
       return Fsignal (Qinvalid_read_syntax,
 		      list1 (Fchar_to_string (make_char (c))));
     }
@@ -2202,10 +2148,8 @@
 	  case '`':
 	    {
 	      Lisp_Object tem;
-	      int speccount = specpdl_depth ();
-	      ++old_backquote_flag;
-	      record_unwind_protect (backquote_unwind,
-				     make_opaque_ptr (&old_backquote_flag));
+	      int speccount = internal_bind_int (&old_backquote_flag,
+						 1 + old_backquote_flag);
 	      tem = read0 (readcharfun);
 	      unbind_to (speccount);
 	      ch = reader_nextchar (readcharfun);
@@ -2337,7 +2281,7 @@
 	      if (!STRINGP (tmp))
 		{
 		  if (CONSP (tmp) && UNBOUNDP (XCAR (tmp)))
-		    free_cons (XCONS (tmp));
+		    free_cons (tmp);
 		  return Fsignal (Qinvalid_read_syntax,
 				   list1 (build_string ("#")));
 		}
@@ -2353,7 +2297,7 @@
 		  if (CONSP (beg) && UNBOUNDP (XCAR (beg)))
 		    {
 		      ch = XCHAR (XCDR (beg));
-		      free_cons (XCONS (beg));
+		      free_cons (beg);
 		      if (ch == ')')
 			break;
 		      else
@@ -2364,7 +2308,7 @@
 		      end = read1 (readcharfun);
 		      if (CONSP (end) && UNBOUNDP (XCAR (end)))
 			{
-			  free_cons (XCONS (end));
+			  free_cons (end);
 			  invalid = 1;
 			}
 		    }
@@ -2373,7 +2317,7 @@
 		      plist = read1 (readcharfun);
 		      if (CONSP (plist) && UNBOUNDP (XCAR (plist)))
 			{
-			  free_cons (XCONS (plist));
+			  free_cons (plist);
 			  invalid = 1;
 			}
 		    }
@@ -2513,10 +2457,8 @@
     case '`':
       {
 	Lisp_Object tem;
-	int speccount = specpdl_depth ();
-	++new_backquote_flag;
-	record_unwind_protect (backquote_unwind,
-			       make_opaque_ptr (&new_backquote_flag));
+	int speccount = internal_bind_int (&new_backquote_flag,
+					   1 + new_backquote_flag);
 	tem = read0 (readcharfun);
 	unbind_to (speccount);
 	return list2 (Qbackquote, tem);
@@ -2736,7 +2678,7 @@
       Emchar ch;
 
       elt = XCDR (elt);
-      free_cons (XCONS (tem));
+      free_cons (tem);
       tem = Qnil;
       ch = XCHAR (elt);
 #ifdef FEATUREP_SYNTAX
@@ -2765,7 +2707,7 @@
 	  if (CONSP (elt) && UNBOUNDP (XCAR (elt)))
 	    {
 	      ch = XCHAR (XCDR (elt));
-	      free_cons (XCONS (elt));
+	      free_cons (elt);
 	      if (ch == s->terminator)
 		{
 		  unreadchar (readcharfun, s->terminator);
@@ -2936,10 +2878,10 @@
        i < len;
        i++, p++)
   {
-    Lisp_Cons *otem = XCONS (tem);
+    Lisp_Object otem = tem;
     tem = Fcar (tem);
     *p = tem;
-    tem = otem->cdr;
+    tem = XCDR (otem);
     free_cons (otem);
   }
   return s.head;
@@ -2968,7 +2910,7 @@
 
   for (iii = 0; CONSP (stuff); iii++)
     {
-      Lisp_Cons *victim = XCONS (stuff);
+      Lisp_Object victim = stuff;
       make_byte_code_args[iii] = Fcar (stuff);
       if ((purify_flag || load_force_doc_strings)
 	   && CONSP (make_byte_code_args[iii])
--- a/src/macros.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/macros.c	Tue May 28 08:45:36 2002 +0000
@@ -244,16 +244,6 @@
   return Qnil;
 }
 
-/* Restore Vexecuting_macro and executing_macro_index - called when
-   the unwind-protect in Fexecute_kbd_macro gets invoked.  */
-static Lisp_Object
-pop_kbd_macro (Lisp_Object info)
-{
-  Vexecuting_macro = Fcar (info);
-  executing_macro_index = XINT (Fcdr (info));
-  return Qnil;
-}
-
 DEFUN ("execute-kbd-macro", Fexecute_kbd_macro, 1, 2, 0, /*
 Execute MACRO as string of editor command characters.
 If MACRO is a symbol, its function definition is used.
@@ -263,7 +253,6 @@
 {
   /* This function can GC */
   Lisp_Object final;
-  Lisp_Object tem;
   int speccount = specpdl_depth ();
   int repeat = 1;
   struct gcpro gcpro1;
@@ -279,8 +268,8 @@
   if (!STRINGP (final) && !VECTORP (final))
     invalid_argument ("Keyboard macros must be strings or vectors", Qunbound);
 
-  tem = Fcons (Vexecuting_macro, make_int (executing_macro_index));
-  record_unwind_protect (pop_kbd_macro, tem);
+  internal_bind_lisp_object (&Vexecuting_macro, Vexecuting_macro);
+  internal_bind_int (&executing_macro_index, executing_macro_index);
 
   GCPRO1 (final);
   do
@@ -289,7 +278,7 @@
       executing_macro_index = 0;
       con->prefix_arg = Qnil;
       internal_catch (Qexecute_kbd_macro, call_command_loop,
-		      Qnil, 0);
+		      Qnil, 0, 0);
     }
   while (--repeat != 0
 	 && (STRINGP (Vexecuting_macro) ||
--- a/src/menubar-msw.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/menubar-msw.c	Tue May 28 08:45:36 2002 +0000
@@ -733,7 +733,9 @@
 
   /* We simply ignore return value. In any case, we construct the bar
      on the fly */
-  run_hook (Qactivate_menubar_hook);
+  run_hook_trapping_problems
+    ("Error in activate-menubar-hook", Qactivate_menubar_hook,
+     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 
   update_frame_menubar_maybe (f);
 
@@ -812,7 +814,12 @@
   /* We cannot pass hmenu as a lisp object. Use static var */
   wm_initmenu_menu = hmenu;
   wm_initmenu_frame = frm;
-  return mswindows_protect_modal_loop (unsafe_handle_wm_initmenupopup, Qnil);
+  /* Allow runaway filter code, e.g. custom, to be aborted.  We are
+     usually called from next_event_internal(), which has turned off
+     quit checking to read the C-g as an event. */
+  return mswindows_protect_modal_loop ("Error during menu handling",
+				       unsafe_handle_wm_initmenupopup, Qnil,
+				       UNINHIBIT_QUIT);
 }
 
 Lisp_Object
@@ -822,7 +829,9 @@
   if (GetMenu (FRAME_MSWINDOWS_HANDLE (f)) == hmenu)
     {
       wm_initmenu_frame = f;
-      return mswindows_protect_modal_loop (unsafe_handle_wm_initmenu, Qnil);
+      return mswindows_protect_modal_loop ("Error during menu handling",
+					   unsafe_handle_wm_initmenu, Qnil,
+					   UNINHIBIT_QUIT);
     }
   return Qt;
 }
--- a/src/menubar-x.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/menubar-x.c	Tue May 28 08:45:36 2002 +0000
@@ -219,8 +219,7 @@
 	      if (filter_p || depth == 0)
 		{
 #endif
-		  desc = call1_trapping_errors ("Error in menubar filter",
-						hook_fn, desc);
+		  desc = call1 (hook_fn, desc);
 		  if (UNBOUNDP (desc))
 		    desc = Qnil;
 #if defined LWLIB_MENUBARS_LUCID || defined LWLIB_MENUBARS_MOTIF
@@ -358,46 +357,57 @@
   return wv;
 }
 
-
-#if defined LWLIB_MENUBARS_LUCID || defined LWLIB_MENUBARS_MOTIF
-int in_menu_callback;
+struct menu_item_descriptor_to_widget_value
+{
+  Lisp_Object desc;
+  int menu_type, deep_p, filter_p;
+  widget_value *wv;
+};
 
 static Lisp_Object
-restore_in_menu_callback (Lisp_Object val)
+protected_menu_item_descriptor_to_widget_value_1 (void *gack)
 {
-  in_menu_callback = XINT (val);
+  struct menu_item_descriptor_to_widget_value *midtwv =
+    (struct menu_item_descriptor_to_widget_value *) gack;
+
+  midtwv->wv = menu_item_descriptor_to_widget_value (midtwv->desc,
+						     midtwv->menu_type,
+						     midtwv->deep_p,
+						     midtwv->filter_p);
   return Qnil;
 }
-#endif /* LWLIB_MENUBARS_LUCID || LWLIB_MENUBARS_MOTIF */
+
+/* Inside of the pre_activate_callback, we absolutely need to protect
+   against errors, esp. but not exclusively in the filter code. (We do
+   other evalling, too.) We also need to reenable quit checking, which
+   was disabled by next_event_internal() so as to read C-g as an
+   event. */
 
-#if 0
-/* #### Sort of a hack needed to process Vactivate_menubar_hook
-   correctly wrt buffer-local values.  A correct solution would
-   involve adding a callback mechanism to run_hook().  This function
-   is currently unused.  */
-static int
-my_run_hook (Lisp_Object hooksym, int allow_global_p)
+static widget_value *
+protected_menu_item_descriptor_to_widget_value (Lisp_Object desc,
+						int menu_type, int deep_p,
+						int filter_p)
 {
-  /* This function can GC */
-  Lisp_Object tail;
-  Lisp_Object value = Fsymbol_value (hooksym);
-  int changes = 0;
+  struct menu_item_descriptor_to_widget_value midtwv;
 
-  if (!NILP (value) && (!CONSP (value) || EQ (XCAR (value), Qlambda)))
-    return !EQ (call0 (value), Qt);
+  midtwv.desc = desc;
+  midtwv.menu_type = menu_type;
+  midtwv.deep_p = deep_p;
+  midtwv.filter_p = filter_p;
 
-  EXTERNAL_LIST_LOOP (tail, value)
-    {
-      if (allow_global_p && EQ (XCAR (tail), Qt))
-	changes |= my_run_hook (Fdefault_value (hooksym), 0);
-      if (!EQ (call0 (XCAR (tail)), Qt))
-	changes = 1;
-    }
-  return changes;
+  if (UNBOUNDP
+      (call_trapping_problems
+       (Qmenubar, "Error during menu callback",	UNINHIBIT_QUIT, 0,
+	protected_menu_item_descriptor_to_widget_value_1, &midtwv)))
+    return 0;
+
+  return midtwv.wv;
 }
+
+#if defined (LWLIB_MENUBARS_LUCID) || (defined LWLIB_MENUBARS_MOTIF)
+int in_menu_callback;
 #endif
 
-
 /* The order in which callbacks are run is funny to say the least.
    It's sometimes tricky to avoid running a callback twice, and to
    avoid returning prematurely.  So, this function returns true
@@ -457,12 +467,9 @@
        * crash later when the code gets confused at the state
        * changes.
        */
-      count = specpdl_depth ();
-      record_unwind_protect (restore_in_menu_callback,
-			     make_int (in_menu_callback));
-      in_menu_callback = 1;
-      wv = menu_item_descriptor_to_widget_value (submenu_desc, SUBMENU_TYPE,
-						 1, 0);
+      count = internal_bind_int (&in_menu_callback, 1);
+      wv = (protected_menu_item_descriptor_to_widget_value
+	    (submenu_desc, SUBMENU_TYPE, 1, 0));
       unbind_to (count);
 
       if (!wv)
@@ -485,13 +492,6 @@
     return;
   else
     {
-#if 0 /* Unused, see comment below. */
-      int any_changes;
-
-      /* #### - this menubar update mechanism is expensively anti-social and
-	 the activate-menubar-hook is now mostly obsolete. */
-      any_changes = my_run_hook (Qactivate_menubar_hook, 1);
-
       /* #### - It is necessary to *ALWAYS* call set_frame_menubar() now that
 	 incremental menus are implemented.  If a subtree of a menu has been
 	 updated incrementally (a destructive operation), then that subtree
@@ -500,13 +500,10 @@
 	 It is difficult to undo the destructive operation in lwlib because
 	 a pointer back to lisp data needs to be hidden away somewhere.  So
 	 that an INCREMENTAL_TYPE widget_value can be recreated...  Hmmmmm. */
-      if (any_changes ||
-	  !XFRAME_MENUBAR_DATA (f)->menubar_contents_up_to_date)
-	set_frame_menubar (f, 1, 0);
-#else
-      run_hook (Qactivate_menubar_hook);
+      run_hook_trapping_problems
+	("Error in activate-menubar-hook", Qactivate_menubar_hook,
+	 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
       set_frame_menubar (f, 1, 0);
-#endif
       DEVICE_X_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) =
 	DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) =
 	x_focus_timestamp_really_sucks_fix_me_better;
--- a/src/minibuf.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/minibuf.c	Tue May 28 08:45:36 2002 +0000
@@ -97,7 +97,7 @@
     {
       Lisp_Object victim = unwind_data;
       unwind_data = XCDR (unwind_data);
-      free_cons (XCONS (victim));
+      free_cons (victim);
     }
 
   /* If cursor is on the minibuffer line,
--- a/src/nt.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/nt.c	Tue May 28 08:45:36 2002 +0000
@@ -239,7 +239,7 @@
   /* Set dir from environment variables. */
   the_passwd.pw_dir = (char *) qxestrdup (get_home_directory ());
   /* We used to set pw_shell here, but the order is wrong (SHELL gets
-     initted in callproc.c, called later in the init process) and pw_shell
+     initted in process.c, called later in the init process) and pw_shell
      is not used anywhere. */
 }
 
--- a/src/opaque.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/opaque.c	Tue May 28 08:45:36 2002 +0000
@@ -152,7 +152,7 @@
 Lisp_Object
 make_opaque_ptr (void *val)
 {
-  Lisp_Object res = allocate_managed_lcrecord(Vopaque_ptr_free_list);
+  Lisp_Object res = allocate_managed_lcrecord (Vopaque_ptr_free_list);
   set_opaque_ptr (res, val);
   return res;
 }
--- a/src/print.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/print.c	Tue May 28 08:45:36 2002 +0000
@@ -1885,7 +1885,13 @@
 debug_print_no_newline (Lisp_Object debug_print_obj)
 {
   /* This function can GC */
-  int specdepth = internal_bind_int (&print_depth, 0);
+
+  /* by doing this, we trick various things that are non-essential
+     but might cause crashes into not getting executed. */
+  int specdepth = 
+    internal_bind_int (&inhibit_non_essential_printing_operations, 1);
+
+  internal_bind_int (&print_depth, 0);
   internal_bind_int (&print_readably,
 		     debug_print_readably != -1 ? debug_print_readably : 0);
   internal_bind_int (&print_unbuffered, print_unbuffered + 1);
@@ -1920,7 +1926,13 @@
 debug_backtrace (void)
 {
   /* This function can GC */
-  int specdepth = internal_bind_int (&print_depth, 0);
+
+  /* by doing this, we trick various things that are non-essential
+     but might cause crashes into not getting executed. */
+  int specdepth = 
+    internal_bind_int (&inhibit_non_essential_printing_operations, 1);
+
+  internal_bind_int (&print_depth, 0);
   internal_bind_int (&print_readably, 0);
   internal_bind_int (&print_unbuffered, print_unbuffered + 1);
   if (debug_print_length > 0)
--- a/src/process-nt.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/process-nt.c	Tue May 28 08:45:36 2002 +0000
@@ -50,6 +50,7 @@
   HANDLE h_process;
   DWORD dwProcessId;
   HWND hwnd; /* console window */
+  int selected_for_exit_notify;
 };
 
 /* Control whether create_child causes the process to inherit Emacs'
@@ -69,8 +70,23 @@
 /* Process helpers							 */
 /*-----------------------------------------------------------------------*/
 
-/* This one breaks process abstraction. Prototype is in console-msw.h,
-   used by select_process method in event-msw.c */
+/* These break process abstraction. Prototypes in console-msw.h,
+   used by select_process method in event-msw.c.
+
+   If called the first time on a process, return the process handle, so we
+   can select on it and receive exit notification.  "First time only" so we
+   don't select the same process multiple times if someone turns off and on
+   the receipt of process data. */
+
+HANDLE
+get_nt_process_handle_only_first_time (Lisp_Process *p)
+{
+  if (NT_DATA (p)->selected_for_exit_notify)
+    return INVALID_HANDLE_VALUE;
+  NT_DATA (p)->selected_for_exit_notify = 1;
+  return (NT_DATA (p)->h_process);
+}
+
 HANDLE
 get_nt_process_handle (Lisp_Process *p)
 {
@@ -397,8 +413,6 @@
 			&d, sizeof (d));
 }
   
-#pragma warning (default : 4113)
-
 /* ---------------------------- the 95 way ------------------------------- */
 
 static BOOL CALLBACK
@@ -658,6 +672,16 @@
   WSAStartup (MAKEWORD (1,1), &wsa_data);
 }
 
+/*
+ * Fork off a subprocess. P is a pointer to newly created subprocess
+ * object. If this function signals, the caller is responsible for
+ * deleting (and finalizing) the process object.
+ *
+ * The method must return PID of the new process, a (positive??? ####) number
+ * which fits into Lisp_Int. No return value indicates an error, the method
+ * must signal an error instead.
+ */
+
 static DOESNT_RETURN
 mswindows_report_winsock_error (const char *string, Lisp_Object data,
 				int errnum)
@@ -709,11 +733,12 @@
 static int
 nt_create_process (Lisp_Process *p,
 		   Lisp_Object *argv, int nargv,
-		   Lisp_Object program, Lisp_Object cur_dir)
+		   Lisp_Object program, Lisp_Object cur_dir,
+		   int separate_err)
 {
   /* Synched up with sys_spawnve in FSF 20.6.  Significantly different
      but still synchable. */
-  HANDLE hmyshove, hmyslurp, hprocin, hprocout, hprocerr;
+  HANDLE hmyshove, hmyslurp, hmyslurp_err, hprocin, hprocout, hprocerr;
   Extbyte *command_line;
   BOOL do_io, windowed;
   Extbyte *proc_env;
@@ -775,9 +800,12 @@
       CreatePipe (&hprocin, &hmyshove, &sa, 0);
       CreatePipe (&hmyslurp, &hprocout, &sa, 0);
 
-      /* Duplicate the stdout handle for use as stderr */
-      DuplicateHandle(GetCurrentProcess(), hprocout, GetCurrentProcess(),
-                      &hprocerr, 0, TRUE, DUPLICATE_SAME_ACCESS);
+      if (separate_err)
+	CreatePipe (&hmyslurp_err, &hprocerr, &sa, 0);
+      else
+	/* Duplicate the stdout handle for use as stderr */
+	DuplicateHandle(GetCurrentProcess(), hprocout, GetCurrentProcess(),
+			&hprocerr, 0, TRUE, DUPLICATE_SAME_ACCESS);
 
       /* Stupid Win32 allows to create a pipe with *both* ends either
 	 inheritable or not. We need process ends inheritable, and local
@@ -790,6 +818,13 @@
 		       &htmp, 0, FALSE,
 		       DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
       hmyslurp = htmp;
+      if (separate_err)
+	{
+	  DuplicateHandle (GetCurrentProcess(), hmyslurp_err,
+			   GetCurrentProcess(), &htmp, 0, FALSE,
+			   DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
+	  hmyslurp_err = htmp;
+	}
     }
 
   /* Convert an argv vector into Win32 style command line by a call to
@@ -977,6 +1012,8 @@
 	  {
 	    CloseHandle (hmyshove);
 	    CloseHandle (hmyslurp);
+	    if (separate_err)
+	      CloseHandle (hmyslurp_err);
 	  }
 	mswindows_report_process_error
 	  ("Error starting",
@@ -988,7 +1025,9 @@
       {
 	NT_DATA(p)->h_process = pi.hProcess;
 	NT_DATA(p)->dwProcessId = pi.dwProcessId;
-	init_process_io_handles (p, (void *)hmyslurp, (void *)hmyshove, 0);
+	init_process_io_handles (p, (void *) hmyslurp, (void *) hmyshove,
+				 separate_err ? (void *) hmyslurp_err
+				 : (void *) -1, 0);
       }
     else
       {
@@ -1219,7 +1258,7 @@
 	      WSACancelAsyncRequest (hasync);
 	      KillTimer (hwnd, SOCK_TIMER_ID);
 	      DestroyWindow (hwnd);
-	      REALLY_QUIT;
+	      QUIT;
 	    }
 	}
       qxeDispatchMessage (&msg);
@@ -1354,7 +1393,7 @@
 		WSAAsyncSelect (s, hwnd, XM_SOCKREPLY, 0);
 		KillTimer (hwnd, SOCK_TIMER_ID);
 		DestroyWindow (hwnd);
-		REALLY_QUIT;
+		QUIT;
 	      }
 	  }
 	DispatchMessage (&msg);
@@ -1378,7 +1417,7 @@
       if (QUITP)
 	{
 	  closesocket (s);
-	  REALLY_QUIT;
+	  QUIT;
 	}
 
       /* Poll for quit every 250 ms */
--- a/src/process-unix.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/process-unix.c	Tue May 28 08:45:36 2002 +0000
@@ -51,6 +51,7 @@
 #include "file-coding.h"
 
 #include <setjmp.h>
+#include "sysdir.h"
 #include "sysfile.h"
 #include "sysproc.h"
 #include "systime.h"
@@ -77,6 +78,9 @@
   int connected_via_filedesc_p;
   /* Descriptor by which we read from this process.  -1 for dead process */
   int infd;
+  /* Descriptor by which we read stderr from this process.  -1 for
+     dead process */
+  int errfd;
   /* Descriptor for the tty which this process is using.
      -1 if we didn't record it (on some systems, there's no need).  */
   int subtty;
@@ -86,7 +90,7 @@
   char pty_flag;
 };
 
-#define UNIX_DATA(p) ((struct unix_process_data*)((p)->process_data))
+#define UNIX_DATA(p) ((struct unix_process_data*) ((p)->process_data))
 
 
 
@@ -126,17 +130,18 @@
    to get rid of irrelevant descriptors.  */
 
 static int
-close_process_descs_mapfun (const void* key, void* contents, void* arg)
+close_process_descs_mapfun (const void *key, void *contents, void *arg)
 {
-  Lisp_Object proc;
-  proc = VOID_TO_LISP (contents);
-  event_stream_delete_stream_pair (XPROCESS(proc)->pipe_instream,
-				   XPROCESS(proc)->pipe_outstream);
+  Lisp_Object proc = VOID_TO_LISP (contents);
+  USID vaffan, culo;
+
+  event_stream_delete_io_streams (XPROCESS (proc)->pipe_instream,
+				  XPROCESS (proc)->pipe_outstream,
+				  XPROCESS (proc)->pipe_errstream,
+				  &vaffan, &culo);
   return 0;
 }
 
-/* #### This function is currently called from child_setup
-   in callproc.c. It should become static though - kkm */
 void
 close_process_descs (void)
 {
@@ -186,11 +191,11 @@
 
   XPROCESS (proc)->pid = Fcons (infd, name);
   XPROCESS (proc)->buffer = buffer;
-  init_process_io_handles (XPROCESS (proc), (void*)inch, (void*)XINT (outfd),
-			   0);
+  init_process_io_handles (XPROCESS (proc), (void *) inch,
+			   (void *) XINT (outfd), (void *) -1, 0);
   UNIX_DATA (XPROCESS (proc))->connected_via_filedesc_p = 1;
 
-  event_stream_select_process (XPROCESS (proc));
+  event_stream_select_process (XPROCESS (proc), 1, 1);
 
   return proc;
 }
@@ -512,7 +517,7 @@
 #endif /* !USE_GETADDRINFO */
 
 static void
-set_socket_nonblocking_maybe (int fd, int port, const char* proto)
+set_socket_nonblocking_maybe (int fd, int port, const char *proto)
 {
 #ifdef PROCESS_IO_BLOCKING
   Lisp_Object tail;
@@ -720,17 +725,18 @@
 process_signal_char (int tty_fd, int signo)
 {
   /* If it's not a tty, pray that these default values work */
-  if (! isatty (tty_fd)) {
+  if (! isatty (tty_fd))
+    {
 #define CNTL(ch) (037 & (ch))
-    switch (signo)
-      {
-      case SIGINT:  return CNTL ('C');
-      case SIGQUIT: return CNTL ('\\');
+      switch (signo)
+	{
+	case SIGINT:  return CNTL ('C');
+	case SIGQUIT: return CNTL ('\\');
 #ifdef SIGTSTP
-      case SIGTSTP: return CNTL ('Z');
+	case SIGTSTP: return CNTL ('Z');
 #endif
-      }
-  }
+	}
+    }
 
 #ifdef HAVE_TERMIOS
   /* TERMIOS is the latest and bestest, and seems most likely to work.
@@ -805,6 +811,7 @@
 
   UNIX_DATA(p)->connected_via_filedesc_p = 0;
   UNIX_DATA(p)->infd   = -1;
+  UNIX_DATA(p)->errfd  = -1;
   UNIX_DATA(p)->subtty = -1;
   UNIX_DATA(p)->tty_name = Qnil;
   UNIX_DATA(p)->pty_flag = 0;
@@ -843,9 +850,197 @@
  */
 
 static void
-unix_init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags)
+unix_init_process_io_handles (Lisp_Process *p, void *in, void *out, void *err,
+			      int flags)
+{
+  UNIX_DATA(p)->infd = (int) in;
+  UNIX_DATA(p)->errfd = (int) err;
+}
+
+/* Move the file descriptor FD so that its number is not less than MIN. *
+   The original file descriptor remains open.  */
+static int
+relocate_fd (int fd, int min)
+{
+  if (fd >= min)
+    return fd;
+  else
+    {
+      int newfd = dup (fd);
+      if (newfd == -1)
+	{
+	  Intbyte *errmess;
+	  GET_STRERROR (errmess, errno);
+	  stderr_out ("Error while setting up child: %s\n", errmess);
+	  _exit (1);
+	}
+      return relocate_fd (newfd, min);
+    }
+}
+
+/* This is the last thing run in a newly forked inferior process.
+   Copy descriptors IN, OUT and ERR
+   as descriptors STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO.
+   Initialize inferior's priority, pgrp, connected dir and environment.
+   then exec another program based on new_argv.
+
+   XEmacs: We've removed the SET_PGRP argument because it's already
+   done by the callers of child_setup.
+
+   CURRENT_DIR is an elisp string giving the path of the current
+   directory the subprocess should have.  Since we can't really signal
+   a decent error from within the child (#### not quite correct in
+   XEmacs?), this should be verified as an executable directory by the
+   parent.  */
+
+static void
+child_setup (int in, int out, int err, Intbyte **new_argv,
+	     Lisp_Object current_dir)
 {
-  UNIX_DATA(p)->infd = (int)in;
+  Intbyte **env;
+  Intbyte *pwd;
+
+#ifdef SET_EMACS_PRIORITY
+  if (emacs_priority != 0)
+    nice (- emacs_priority);
+#endif
+
+#if !defined (NO_SUBPROCESSES)
+  /* Close Emacs's descriptors that this process should not have.  */
+  close_process_descs ();
+#endif /* not NO_SUBPROCESSES */
+  close_load_descs ();
+
+  /* [[Note that use of alloca is always safe here.  It's obvious for systems
+     that do not have true vfork or that have true (stack) alloca.
+     If using vfork and C_ALLOCA it is safe because that changes
+     the superior's static variables as if the superior had done alloca
+     and will be cleaned up in the usual way.]] -- irrelevant because
+     XEmacs does not use vfork. */
+  {
+    REGISTER Bytecount i;
+
+    i = XSTRING_LENGTH (current_dir);
+    pwd = alloca_array (Intbyte, i + 6);
+    memcpy (pwd, "PWD=", 4);
+    memcpy (pwd + 4, XSTRING_DATA (current_dir), i);
+    i += 4;
+    if (!IS_DIRECTORY_SEP (pwd[i - 1]))
+      pwd[i++] = DIRECTORY_SEP;
+    pwd[i] = 0;
+
+    /* [[We can't signal an Elisp error here; we're in a vfork.  Since
+       the callers check the current directory before forking, this
+       should only return an error if the directory's permissions
+       are changed between the check and this chdir, but we should
+       at least check.]] -- irrelevant because XEmacs does not use vfork. */
+    if (qxe_chdir (pwd + 4) < 0)
+      {
+	/* Don't report the chdir error, or ange-ftp.el doesn't work. */
+	/* (FSFmacs does _exit (errno) here.) */
+	pwd = 0;
+      }
+    else
+      {
+	/* Strip trailing "/".  Cretinous *[]&@$#^%@#$% Un*x */
+	/* leave "//" (from FSF) */
+	while (i > 6 && IS_DIRECTORY_SEP (pwd[i - 1]))
+	  pwd[--i] = 0;
+      }
+  }
+
+  /* Set `env' to a vector of the strings in Vprocess_environment.  */
+  /* + 2 to include PWD and terminating 0.  */
+  env = alloca_array (Intbyte *, XINT (Flength (Vprocess_environment)) + 2);
+  {
+    REGISTER Lisp_Object tail;
+    Intbyte **new_env = env;
+
+    /* If we have a PWD envvar and we know the real current directory,
+       pass one down, but with corrected value.  */
+    if (pwd && egetenv ("PWD"))
+      *new_env++ = pwd;
+
+    /* Copy the Vprocess_environment strings into new_env.  */
+    for (tail = Vprocess_environment;
+	 CONSP (tail) && STRINGP (XCAR (tail));
+	 tail = XCDR (tail))
+      {
+      Intbyte **ep = env;
+      Intbyte *envvar = XSTRING_DATA (XCAR (tail));
+
+      /* See if envvar duplicates any string already in the env.
+	 If so, don't put it in.
+	 When an env var has multiple definitions,
+	 we keep the definition that comes first in process-environment.  */
+      for (; ep != new_env; ep++)
+	{
+	  Intbyte *p = *ep, *q = envvar;
+	  while (1)
+	    {
+	      if (*q == 0)
+		/* The string is malformed; might as well drop it.  */
+		goto duplicate;
+	      if (*q != *p)
+		break;
+	      if (*q == '=')
+		goto duplicate;
+	      p++, q++;
+	    }
+	}
+      if (pwd && !qxestrncmp ((Intbyte *) "PWD=", envvar, 4))
+	{
+	  *new_env++ = pwd;
+	  pwd = 0;
+	}
+      else
+        *new_env++ = envvar;
+
+    duplicate: ;
+    }
+
+    *new_env = 0;
+  }
+
+  /* Make sure that in, out, and err are not actually already in
+     descriptors zero, one, or two; this could happen if Emacs is
+     started with its standard in, out, or error closed, as might
+     happen under X.  */
+  in  = relocate_fd (in,  3);
+  out = relocate_fd (out, 3);
+  err = relocate_fd (err, 3);
+
+  /* Set the standard input/output channels of the new process.  */
+  retry_close (STDIN_FILENO);
+  retry_close (STDOUT_FILENO);
+  retry_close (STDERR_FILENO);
+
+  dup2 (in,  STDIN_FILENO);
+  dup2 (out, STDOUT_FILENO);
+  dup2 (err, STDERR_FILENO);
+
+  retry_close (in);
+  retry_close (out);
+  retry_close (err);
+
+  /* I can't think of any reason why child processes need any more
+     than the standard 3 file descriptors.  It would be cleaner to
+     close just the ones that need to be, but the following brute
+     force approach is certainly effective, and not too slow.
+
+     #### Who the hell added this?  We already close the descriptors
+     by using close_process_descs()!!! --ben */
+  {
+    int fd;
+    for (fd = 3; fd <= 64; fd++)
+      retry_close (fd);
+  }
+
+  /* we've wrapped execve; it translates its arguments */
+  qxe_execve (new_argv[0], new_argv, env);
+
+  stdout_out ("Can't exec program %s\n", new_argv[0]);
+  _exit (1);
 }
 
 /*
@@ -861,14 +1056,17 @@
 static int
 unix_create_process (Lisp_Process *p,
 		     Lisp_Object *argv, int nargv,
-		     Lisp_Object program, Lisp_Object cur_dir)
+		     Lisp_Object program, Lisp_Object cur_dir,
+		     int separate_err)
 {
   int pid;
   int inchannel  = -1;
   int outchannel = -1;
+  int errchannel = -1;
   /* Use volatile to protect variables from being clobbered by longjmp.  */
   volatile int forkin   = -1;
   volatile int forkout  = -1;
+  volatile int forkerr  = -1;
   volatile int pty_flag = 0;
 
   if (!NILP (Vprocess_connection_type))
@@ -887,24 +1085,34 @@
 #if !defined(USG)
       /* On USG systems it does not work to open the pty's tty here
 	 and then close and reopen it in the child.  */
-#ifdef O_NOCTTY
+# ifdef O_NOCTTY
       /* Don't let this terminal become our controlling terminal
 	 (in case we don't have one).  */
       forkout = forkin = qxe_open (pty_name,
 				   O_RDWR | O_NOCTTY | OPEN_BINARY, 0);
-#else
+# else
       forkout = forkin = qxe_open (pty_name, O_RDWR | OPEN_BINARY, 0);
-#endif
+# endif
       if (forkin < 0)
 	goto io_failure;
 #endif /* not USG */
-      UNIX_DATA(p)->pty_flag = pty_flag = 1;
+      UNIX_DATA (p)->pty_flag = pty_flag = 1;
     }
   else
     if (create_bidirectional_pipe (&inchannel, &outchannel,
 				   &forkin, &forkout) < 0)
       goto io_failure;
 
+  if (separate_err)
+    {
+      int sv[2];
+      
+      if (pipe (sv) < 0)
+	goto io_failure;
+      forkerr = sv[1];
+      errchannel = sv[0];
+    }
+      
 #if 0
   /* Replaced by close_process_descs */
   set_exclusive_use (inchannel);
@@ -912,13 +1120,16 @@
 #endif
 
   set_descriptor_non_blocking (inchannel);
+  if (errchannel >= 0)
+    set_descriptor_non_blocking (errchannel);
 
   /* Record this as an active process, with its channels.
      As a result, child_setup will close Emacs's side of the pipes.  */
-  init_process_io_handles (p, (void*)inchannel, (void*)outchannel,
+  init_process_io_handles (p, (void *) inchannel, (void *) outchannel,
+			   (void *) errchannel,
 			   pty_flag ? STREAM_PTY_FLUSHING : 0);
   /* Record the tty descriptor used in the subprocess.  */
-  UNIX_DATA(p)->subtty = forkin;
+  UNIX_DATA (p)->subtty = forkin;
 
   {
     pid = fork ();
@@ -927,6 +1138,7 @@
 	/**** Now we're in the child process ****/
 	int xforkin = forkin;
 	int xforkout = forkout;
+	int xforkerr = forkerr;
 
 	/* Disconnect the current controlling terminal, pursuant to
 	   making the pty be the controlling terminal of the process.
@@ -967,11 +1179,12 @@
 	    /* SunOS has TIOCSCTTY but the close/open method
 	       also works. */
 
-#  if defined (USG) || !defined (TIOCSCTTY)
+#if defined (USG) || !defined (TIOCSCTTY)
 	    /* Now close the pty (if we had it open) and reopen it.
 	       This makes the pty the controlling terminal of the
 	       subprocess.  */
-	    /* I wonder if retry_close (qxe_open (pty_name, ...)) would work?  */
+	    /* I wonder if retry_close (qxe_open (pty_name, ...)) would
+	       work?  */
 	    if (xforkin >= 0)
 	      retry_close (xforkin);
 	    xforkout = xforkin = qxe_open (pty_name, O_RDWR | OPEN_BINARY, 0);
@@ -982,20 +1195,20 @@
 		retry_write (1, "\n", 1);
 		_exit (1);
 	      }
-#  endif /* USG or not TIOCSCTTY */
+#endif /* USG or not TIOCSCTTY */
 
 	    /* Miscellaneous setup required for some systems.
                Must be done before using tc* functions on xforkin.
                This guarantees that isatty(xforkin) is true. */
 
-#  if defined (HAVE_ISASTREAM) && defined (I_PUSH)
+#if defined (HAVE_ISASTREAM) && defined (I_PUSH)
 	    if (isastream (xforkin))
 	      {
-#    if defined (I_FIND)
-#      define stream_module_pushed(fd, module) (ioctl (fd, I_FIND, module) == 1)
-#    else
-#      define stream_module_pushed(fd, module) 0
-#    endif
+# if defined (I_FIND)
+#  define stream_module_pushed(fd, module) (ioctl (fd, I_FIND, module) == 1)
+# else
+#  define stream_module_pushed(fd, module) 0
+# endif
 		if (! stream_module_pushed (xforkin, "ptem"))
 		  ioctl (xforkin, I_PUSH, "ptem");
 		if (! stream_module_pushed (xforkin, "ldterm"))
@@ -1003,18 +1216,18 @@
 		if (! stream_module_pushed (xforkin, "ttcompat"))
 		  ioctl (xforkin, I_PUSH, "ttcompat");
 	      }
-#  endif /* HAVE_ISASTREAM */
+#endif /* defined (HAVE_ISASTREAM) && defined (I_PUSH) */
 
-#  ifdef TIOCSCTTY
+#ifdef TIOCSCTTY
 	    /* We ignore the return value
 	       because faith@cs.unc.edu says that is necessary on Linux.  */
             assert (isatty (xforkin));
 	    ioctl (xforkin, TIOCSCTTY, 0);
-#  endif /* TIOCSCTTY */
+#endif /* TIOCSCTTY */
 
 	    /* Change the line discipline. */
 
-# if defined (HAVE_TERMIOS) && defined (LDISC1)
+#if defined (HAVE_TERMIOS) && defined (LDISC1)
 	    {
 	      struct termios t;
               assert (isatty (xforkin));
@@ -1023,7 +1236,7 @@
 	      if (tcsetattr (xforkin, TCSANOW, &t) < 0)
 		perror ("create_process/tcsetattr LDISC1 failed\n");
 	    }
-# elif defined (NTTYDISC) && defined (TIOCSETD)
+#elif defined (NTTYDISC) && defined (TIOCSETD)
 	    {
 	      /* Use new line discipline.  TIOCSETD is accepted and
                  ignored on Sys5.4 systems with ttcompat. */
@@ -1031,7 +1244,7 @@
               assert (isatty (xforkin));
 	      ioctl (xforkin, TIOCSETD, &ldisc);
 	    }
-# endif /* TIOCSETD & NTTYDISC */
+#endif /* TIOCSETD & NTTYDISC */
 
 	    /* Make our process group be the foreground group
 	       of our new controlling terminal. */
@@ -1071,7 +1284,8 @@
 	    }
 	  new_argv[i + 1] = 0;
 
-	  child_setup (xforkin, xforkout, xforkout, new_argv, cur_dir);
+	  child_setup (xforkin, xforkout, separate_err ? xforkerr : xforkout,
+		       new_argv, cur_dir);
 	}
 
       } /**** End of child code ****/
@@ -1081,15 +1295,20 @@
 
   if (pid < 0)
     {
+      /* Note: The caller set up an unwind-protect to automatically delete
+	 the process if we fail.  This will correctly deselect and close
+	 inchannel, outchannel, and errchannel. */
       int save_errno = errno;
       close_descriptor_pair (forkin, forkout);
+      if (separate_err)
+	retry_close (forkerr);
       errno = save_errno;
       report_process_error ("Doing fork", Qunbound);
     }
 
   /* #### dmoore - why is this commented out, otherwise we leave
      subtty = forkin, but then we close forkin just below. */
-  /* UNIX_DATA(p)->subtty = -1; */
+  /* UNIX_DATA (p)->subtty = -1; */
 
   /* If the subfork execv fails, and it exits,
      this close hangs.  I don't know why.
@@ -1098,6 +1317,8 @@
     close_safely (forkin);
   if (forkin != forkout && forkout >= 0)
     retry_close (forkout);
+  if (separate_err)
+    retry_close (forkerr);
 
   UNIX_DATA (p)->tty_name = pty_flag ? build_intstring (pty_name) : Qnil;
 
@@ -1108,11 +1329,12 @@
      we're waiting for an event, when status_notify() is called). */
   return pid;
 
-io_failure:
+ io_failure:
   {
     int save_errno = errno;
     close_descriptor_pair (forkin, forkout);
     close_descriptor_pair (inchannel, outchannel);
+    close_descriptor_pair (forkerr, errchannel);
     errno = save_errno;
     report_process_error ("Opening pty or pipe", Qunbound);
     RETURN_NOT_REACHED (0)
@@ -1124,15 +1346,15 @@
 static int
 unix_tooltalk_connection_p (Lisp_Process *p)
 {
-  return UNIX_DATA(p)->connected_via_filedesc_p;
+  return UNIX_DATA (p)->connected_via_filedesc_p;
 }
 
 /* This is called to set process' virtual terminal size */
 
 static int
-unix_set_window_size (Lisp_Process* p, int cols, int rows)
+unix_set_window_size (Lisp_Process *p, int cols, int rows)
 {
-  return set_window_size (UNIX_DATA(p)->infd, cols, rows);
+  return set_window_size (UNIX_DATA (p)->infd, cols, rows);
 }
 
 /*
@@ -1145,7 +1367,7 @@
 
 #ifdef HAVE_WAITPID
 static void
-unix_update_status_if_terminated (Lisp_Process* p)
+unix_update_status_if_terminated (Lisp_Process *p)
 {
   int w;
 #ifdef SIGCHLD
@@ -1182,7 +1404,7 @@
       return;
     }
 
-#ifdef  EMACS_BLOCK_SIGNAL
+#ifdef EMACS_BLOCK_SIGNAL
   EMACS_BLOCK_SIGNAL (SIGCHLD);
 #endif
   for (i = 0; i < exited_processes_index; i++)
@@ -1215,7 +1437,7 @@
           /* If process has terminated, stop waiting for its output.  */
 	  if (WIFSIGNALED (w) || WIFEXITED (w))
 	    {
-	      if (!NILP(p->pipe_instream))
+	      if (!NILP (p->pipe_instream))
 		{
 		  /* We can't just call event_stream->unselect_process_cb (p)
 		     here, because that calls XtRemoveInput, which is not
@@ -1225,6 +1447,7 @@
 		}
 	    }
 	}
+#ifdef NEED_SYNC_PROCESS_CODE
       else
 	{
           /* There was no asynchronous process found for that id.  Check
@@ -1242,6 +1465,7 @@
 		synch_process_death = signal_name (WTERMSIG (w));
 	    }
         }
+#endif /* NEED_SYNC_PROCESS_CODE */
     }
 
   exited_processes_index = 0;
@@ -1265,7 +1489,7 @@
 }
 
 static void
-unix_send_process (Lisp_Object proc, struct lstream* lstream)
+unix_send_process (Lisp_Object proc, struct lstream *lstream)
 {
   /* Use volatile to protect variables from being clobbered by longjmp.  */
   SIGTYPE (*volatile old_sigpipe) (int) = 0;
@@ -1381,31 +1605,34 @@
  * inactive state.
  *
  * The return value is a unique stream ID, as returned by
- * event_stream_delete_stream_pair
+ * event_stream_delete_io_streams
  *
- * In the lack of this method, only event_stream_delete_stream_pair
+ * In the lack of this method, only event_stream_delete_io_streams
  * is called on both I/O streams of the process.
  *
  * The UNIX version guards this by ignoring possible SIGPIPE.
  */
 
-static USID
-unix_deactivate_process (Lisp_Process *p)
+static void
+unix_deactivate_process (Lisp_Process *p,
+			 USID *in_usid,
+			 USID *err_usid)
 {
   SIGTYPE (*old_sigpipe) (int) = 0;
-  USID usid;
 
   if (UNIX_DATA(p)->infd >= 0)
     flush_pending_output (UNIX_DATA(p)->infd);
+  if (UNIX_DATA(p)->errfd >= 0)
+    flush_pending_output (UNIX_DATA(p)->errfd);
 
   /* closing the outstream could result in SIGPIPE, so ignore it. */
   old_sigpipe = (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, SIG_IGN);
-  usid = event_stream_delete_stream_pair (p->pipe_instream, p->pipe_outstream);
+  event_stream_delete_io_streams (p->pipe_instream, p->pipe_outstream,
+				  p->pipe_errstream, in_usid, err_usid);
   EMACS_SIGNAL (SIGPIPE, old_sigpipe);
 
   UNIX_DATA(p)->infd  = -1;
-
-  return usid;
+  UNIX_DATA(p)->errfd  = -1;
 }
 
 /* If the subtty field of the process data is not filled in, do so now. */
@@ -1456,6 +1683,7 @@
     case SIGQUIT:
     case SIGKILL:
       flush_pending_output (d->infd);
+      flush_pending_output (d->errfd);
       break;
     }
 
@@ -1504,10 +1732,10 @@
       /* If possible, send signals to the entire pgrp
 	 by sending an input character to it.  */
       {
-        char sigchar = process_signal_char (d->subtty, signo);
+        Intbyte sigchar = process_signal_char (d->subtty, signo);
         if (sigchar)
 	  {
-	    send_process (proc, Qnil, (Intbyte *) &sigchar, 0, 1);
+	    send_process (proc, Qnil, &sigchar, 0, 1);
 	    return;
 	  }
       }
@@ -1785,7 +2013,7 @@
 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS
 	    speed_up_interrupts ();
 #endif
-	    REALLY_QUIT;
+	    QUIT;
 	    /* In case something really weird happens ... */
 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS
 	    slow_down_interrupts ();
@@ -1920,8 +2148,8 @@
 
 static void
 unix_open_multicast_group (Lisp_Object name, Lisp_Object dest,
-			   Lisp_Object port, Lisp_Object ttl, void** vinfd,
-			   void** voutfd)
+			   Lisp_Object port, Lisp_Object ttl, void **vinfd,
+			   void **voutfd)
 {
   struct ip_mreq imr;
   struct sockaddr_in sa;
@@ -2017,7 +2245,7 @@
 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS
       speed_up_interrupts ();
 #endif
-      REALLY_QUIT;
+      QUIT;
       /* In case something really weird happens ... */
 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS
       slow_down_interrupts ();
--- a/src/process.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/process.c	Tue May 28 08:45:36 2002 +0000
@@ -28,7 +28,10 @@
    the original author(s).
 
    Non-synch-subprocess stuff (mostly process environment) moved from
-   callproc.c, 4-3-02, Ben Wing. */
+   callproc.c, 4-3-02, Ben Wing.
+
+   callproc.c deleted entirely 5-23-02, Ben Wing.  Good riddance!
+*/
 
 #include <config.h>
 
@@ -101,7 +104,7 @@
 /* Nonzero means delete a process right away if it exits.  */
 int delete_exited_processes;
 
-/* Hash table which maps USIDs as returned by create_stream_pair_cb to
+/* Hash table which maps USIDs as returned by create_io_streams_cb to
    process objects. Processes are not GC-protected through this! */
 struct hash_table *usid_to_process;
 
@@ -113,6 +116,8 @@
 /* Cons of coding systems used to initialize process I/O on a newly-
    created process. */
 Lisp_Object Vdefault_process_coding_system;
+/* Same for a network connection. */
+Lisp_Object Vdefault_network_coding_system;
 
 Lisp_Object Qprocess_error;
 Lisp_Object Qnetwork_error;
@@ -141,14 +146,19 @@
   mark_object (process->name);
   mark_object (process->command);
   mark_object (process->filter);
+  mark_object (process->stderr_filter);
   mark_object (process->sentinel);
   mark_object (process->buffer);
   mark_object (process->mark);
+  mark_object (process->stderr_buffer);
+  mark_object (process->stderr_mark);
   mark_object (process->pid);
   mark_object (process->pipe_instream);
   mark_object (process->pipe_outstream);
+  mark_object (process->pipe_errstream);
   mark_object (process->coding_instream);
   mark_object (process->coding_outstream);
+  mark_object (process->coding_errstream);
   return process->status_symbol;
 }
 
@@ -215,15 +225,20 @@
 /* This function returns low-level streams, connected directly to the child
    process, rather than en/decoding streams */
 void
-get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr)
+get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr,
+		     Lisp_Object *errstr)
 {
   assert (p);
-  assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream));
-  assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream));
+  assert (NILP (p->pipe_instream) || LSTREAMP (p->pipe_instream));
+  assert (NILP (p->pipe_outstream) || LSTREAMP (p->pipe_outstream));
+  assert (NILP (p->pipe_errstream) || LSTREAMP (p->pipe_errstream));
   *instr = p->pipe_instream;
   *outstr = p->pipe_outstream;
+  *errstr = p->pipe_errstream;
 }
 
+/* Given a USID referring to either a process's instream or errstream,
+   return the associated process. */
 Lisp_Process *
 get_process_from_usid (USID usid)
 {
@@ -242,15 +257,16 @@
 }
 
 int
-get_process_selected_p (Lisp_Process *p)
+get_process_selected_p (Lisp_Process *p, int do_err)
 {
-  return p->selected;
+  return do_err ? p->err_selected : p->in_selected;
 }
 
 void
-set_process_selected_p (Lisp_Process *p, int selected_p)
+set_process_selected_p (Lisp_Process *p, int in_selected, int err_selected)
 {
-  p->selected = !!selected_p;
+  p->in_selected = !!in_selected;
+  p->err_selected = !!err_selected;
 }
 
 int
@@ -466,22 +482,29 @@
 
   p->command  = Qnil;
   p->filter   = Qnil;
+  p->stderr_filter   = Qnil;
   p->sentinel = Qnil;
   p->buffer   = Qnil;
   p->mark = Fmake_marker ();
+  p->stderr_buffer   = Qnil;
+  p->stderr_mark = Fmake_marker ();
   p->pid = Qnil;
   p->status_symbol = Qrun;
   p->exit_code = 0;
   p->core_dumped = 0;
   p->filter_does_read = 0;
   p->kill_without_query = 0;
-  p->selected = 0;
+  p->separate_stderr = 0;
+  p->in_selected = 0;
+  p->err_selected = 0;
   p->tick = 0;
   p->update_tick = 0;
   p->pipe_instream  = Qnil;
   p->pipe_outstream = Qnil;
+  p->pipe_errstream = Qnil;
   p->coding_instream  = Qnil;
   p->coding_outstream = Qnil;
+  p->coding_errstream = Qnil;
 
   p->process_data = 0;
   MAYBE_PROCMETH (alloc_process_data, (p));
@@ -493,19 +516,34 @@
 }
 
 void
-init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags)
+init_process_io_handles (Lisp_Process *p, void* in, void* out, void* err,
+			 int flags)
 {
-  USID usid;
+  USID in_usid, err_usid;
   Lisp_Object incode, outcode;
 
-  if (!CONSP (Vdefault_process_coding_system) ||
-      NILP (incode = (find_coding_system_for_text_file
-		      (Fcar (Vdefault_process_coding_system), 1))) ||
-      NILP (outcode = (find_coding_system_for_text_file
-		       (Fcdr (Vdefault_process_coding_system), 0))))
-    signal_error (Qinvalid_state,
-		  "Bogus value for `default-process-coding-system'",
-		  Vdefault_process_coding_system);
+  if (flags & STREAM_NETWORK_CONNECTION)
+    {
+      if (!CONSP (Vdefault_network_coding_system) ||
+	  NILP (incode = (find_coding_system_for_text_file
+			  (Fcar (Vdefault_network_coding_system), 1))) ||
+	  NILP (outcode = (find_coding_system_for_text_file
+			   (Fcdr (Vdefault_network_coding_system), 0))))
+	signal_error (Qinvalid_state,
+		      "Bogus value for `default-network-coding-system'",
+		      Vdefault_network_coding_system);
+    }
+  else
+    {
+      if (!CONSP (Vdefault_process_coding_system) ||
+	  NILP (incode = (find_coding_system_for_text_file
+			  (Fcar (Vdefault_process_coding_system), 1))) ||
+	  NILP (outcode = (find_coding_system_for_text_file
+			   (Fcdr (Vdefault_process_coding_system), 0))))
+	signal_error (Qinvalid_state,
+		      "Bogus value for `default-process-coding-system'",
+		      Vdefault_process_coding_system);
+    }
 
   if (!NILP (Vcoding_system_for_read) &&
       NILP (incode = (find_coding_system_for_text_file
@@ -521,27 +559,41 @@
 		  "Bogus value for `coding-system-for-write'",
 		  Vcoding_system_for_write);
 
-  usid = event_stream_create_stream_pair (in, out,
-					  &p->pipe_instream,
-					  &p->pipe_outstream,
-					  flags);
+  event_stream_create_io_streams (in, out, err,
+				  &p->pipe_instream,
+				  &p->pipe_outstream,
+				  &p->pipe_errstream,
+				  &in_usid, &err_usid,
+				  flags);
 
-  if (usid == USID_ERROR)
+  if (in_usid == USID_ERROR || err_usid == USID_ERROR)
     signal_error (Qprocess_error, "Setting up communication with subprocess",
-		  Qunbound);
+		  wrap_process (p));
 
-  if (usid != USID_DONTHASH)
+  if (in_usid != USID_DONTHASH)
     {
       Lisp_Object process = Qnil;
       process = wrap_process (p);
-      puthash ((const void *) usid, LISP_TO_VOID (process), usid_to_process);
+      puthash ((const void*) in_usid, LISP_TO_VOID (process), usid_to_process);
     }
 
-  MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags));
+  if (err_usid != USID_DONTHASH)
+    {
+      Lisp_Object process = Qnil;
+      process = wrap_process (p);
+      puthash ((const void*) err_usid, LISP_TO_VOID (process),
+	       usid_to_process);
+    }
+
+  MAYBE_PROCMETH (init_process_io_handles, (p, in, out, err, flags));
 
   p->coding_instream =
     make_coding_input_stream (XLSTREAM (p->pipe_instream), incode,
 			      CODING_DECODE, 0);
+  if (!NILP (p->pipe_errstream))
+    p->coding_errstream =
+      make_coding_input_stream
+      (XLSTREAM (p->pipe_errstream), incode, CODING_DECODE, 0);
   p->coding_outstream =
     make_coding_output_stream (XLSTREAM (p->pipe_outstream), outcode,
 			       CODING_ENCODE, 0);
@@ -549,7 +601,8 @@
 
 static void
 create_process (Lisp_Object process, Lisp_Object *argv, int nargv,
-		Lisp_Object program, Lisp_Object cur_dir)
+		Lisp_Object program, Lisp_Object cur_dir,
+		int separate_err)
 {
   Lisp_Process *p = XPROCESS (process);
   int pid;
@@ -559,11 +612,12 @@
   p->status_symbol = Qrun;
   p->exit_code = 0;
 
-  pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir));
+  pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir,
+				   separate_err));
 
   p->pid = make_int (pid);
   if (PROCESS_LIVE_P (p))
-    event_stream_select_process (p);
+    event_stream_select_process (p, 1, 1);
 }
 
 /* This function is the unwind_protect form for Fstart_process_internal.  If
@@ -581,23 +635,41 @@
 }
 
 DEFUN ("start-process-internal", Fstart_process_internal, 3, MANY, 0, /*
-Start a program in a subprocess.  Return the process object for it.
+Internal function to start a program in a subprocess.
+Lisp callers should use `start-process' instead.
+
+Returns the process object for it.
 Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS
 NAME is name for process.  It is modified if necessary to make it unique.
 BUFFER is the buffer or (buffer-name) to associate with the process.
  Process output goes at end of that buffer, unless you specify
  an output stream or filter function to handle the output.
  BUFFER may be also nil, meaning that this process is not associated
- with any buffer
+ with any buffer.
+BUFFER can also have the form (REAL-BUFFER STDERR-BUFFER); in that case,
+ REAL-BUFFER says what to do with standard output, as above,
+ while STDERR-BUFFER says what to do with standard error in the child.
+ STDERR-BUFFER may be nil (discard standard error output, unless a stderr
+ filter is set).  Note that if you do not use this form at process creation,
+ stdout and stderr will be mixed in the output buffer, and this cannot be
+ changed, even by setting a stderr filter.
 Third arg is program file name.  It is searched for as in the shell.
 Remaining arguments are strings to give program as arguments.
-INCODE and OUTCODE specify the coding-system objects used in input/output
- from/to the process.
+
+Read and write coding systems for the process are determined from
+`coding-system-for-read' and `coding-system-for-write' (intended as
+overriding coding systems to be *bound* by Lisp code, not set), or
+from `default-process-coding-system' if either or both are nil.  You can
+change the coding systems later on using `set-process-coding-system',
+`set-process-input-coding-system', or `set-process-output-coding-system'.
+
+See also `set-process-filter' and `set-process-stderr-filter'.
 */
        (int nargs, Lisp_Object *args))
 {
   /* This function can call lisp */
-  Lisp_Object buffer, name, program, process, current_dir;
+  Lisp_Object buffer, stderr_buffer, name, program, process, current_dir;
+  int separate_stderr;
   Lisp_Object tem;
   int speccount = specpdl_depth ();
   struct gcpro gcpro1, gcpro2, gcpro3;
@@ -610,8 +682,28 @@
   /* Protect against various file handlers doing GCs below. */
   GCPRO3 (buffer, program, current_dir);
 
+  if (CONSP (buffer))
+    {
+      if (!CONSP (XCDR (buffer)))
+	invalid_argument ("Invalid BUFFER argument to `start-process'",
+			  buffer);
+      if (!NILP (XCDR (XCDR (buffer))))
+	invalid_argument ("Invalid BUFFER argument to `start-process'",
+			  buffer);
+      stderr_buffer = XCAR (XCDR (buffer));
+      buffer = XCAR (buffer);
+      separate_stderr = 1;
+    }
+  else
+    {
+      stderr_buffer = Qnil;
+      separate_stderr = 0;
+    }
+
   if (!NILP (buffer))
     buffer = Fget_buffer_create (buffer);
+  if (!NILP (stderr_buffer))
+    stderr_buffer = Fget_buffer_create (stderr_buffer);
 
   CHECK_STRING (name);
   CHECK_STRING (program);
@@ -678,12 +770,17 @@
   process = make_process_internal (name);
 
   XPROCESS (process)->buffer = buffer;
+  XPROCESS (process)->stderr_buffer = stderr_buffer;
+  XPROCESS (process)->separate_stderr = separate_stderr;
   XPROCESS (process)->command = Flist (nargs - 2, args + 2);
 
   /* Make the process marker point into the process buffer (if any).  */
   if (!NILP (buffer))
     Fset_marker (XPROCESS (process)->mark,
 		 make_int (BUF_ZV (XBUFFER (buffer))), buffer);
+  if (!NILP (stderr_buffer))
+    Fset_marker (XPROCESS (process)->stderr_mark,
+		 make_int (BUF_ZV (XBUFFER (stderr_buffer))), stderr_buffer);
 
   /* If an error occurs and we can't start the process, we want to
      remove it from the process list.  This means that each error
@@ -691,7 +788,8 @@
      itself; it's all taken care of here.  */
   record_unwind_protect (start_process_unwind, process);
 
-  create_process (process, args + 3, nargs - 3, program, current_dir);
+  create_process (process, args + 3, nargs - 3, program, current_dir,
+		  separate_stderr);
 
   UNGCPRO;
   return unbind_to_1 (speccount, process);
@@ -781,9 +879,10 @@
   XPROCESS (process)->pid = Fcons (service, host);
   XPROCESS (process)->buffer = buffer;
   init_process_io_handles (XPROCESS (process), (void *) inch, (void *) outch,
+			   (void *) -1,
 			   STREAM_NETWORK_CONNECTION);
 
-  event_stream_select_process (XPROCESS (process));
+  event_stream_select_process (XPROCESS (process), 1, 1);
 
   UNGCPRO;
   NUNGCPRO;
@@ -830,10 +929,11 @@
 
   XPROCESS (process)->pid = Fcons (port, dest);
   XPROCESS (process)->buffer = buffer;
-  init_process_io_handles (XPROCESS (process), (void*)inch, (void*)outch,
+  init_process_io_handles (XPROCESS (process), (void *) inch, (void *) outch,
+			   (void *) -1,
 			   STREAM_NETWORK_CONNECTION);
 
-  event_stream_select_process (XPROCESS (process));
+  event_stream_select_process (XPROCESS (process), 1, 1);
 
   UNGCPRO;
   return process;
@@ -876,11 +976,13 @@
    necessary.
 */
 static int
-process_setup_for_insertion (Lisp_Object process)
+process_setup_for_insertion (Lisp_Object process, int read_stderr)
 {
   Lisp_Process *p = XPROCESS (process);
   int spec = specpdl_depth ();
-  struct buffer *buf = XBUFFER (p->buffer);
+  Lisp_Object buffer = read_stderr ? p->stderr_buffer : p->buffer;
+  Lisp_Object mark = read_stderr ? p->stderr_mark : p->mark;
+  struct buffer *buf = XBUFFER (buffer);
   Charbpos output_pt;
 
   if (buf != current_buffer)
@@ -896,8 +998,8 @@
   /* Insert new output into buffer
      at the current end-of-output marker,
      thus preserving logical ordering of input and output.  */
-  if (XMARKER (p->mark)->buffer)
-    output_pt = marker_position (p->mark);
+  if (XMARKER (mark)->buffer)
+    output_pt = marker_position (mark);
   else
     output_pt = BUF_ZV (buf);
 
@@ -923,13 +1025,16 @@
    you must call it repeatedly until it returns zero.  */
 
 Charcount
-read_process_output (Lisp_Object process)
+read_process_output (Lisp_Object process, int read_stderr)
 {
   /* This function can GC */
   Bytecount nbytes, nchars;
   Intbyte chars[1025];
   Lisp_Object outstream;
   Lisp_Process *p = XPROCESS (process);
+  Lisp_Object filter = read_stderr ? p->stderr_filter : p->filter;
+  Lisp_Object buffer = read_stderr ? p->stderr_buffer : p->buffer;
+  Lisp_Object mark = read_stderr ? p->stderr_mark : p->mark;
 
   /* If there is a lot of output from the subprocess, the loop in
      execute_internal_event() might call read_process_output() more
@@ -940,24 +1045,28 @@
      for a process-filter change, like in status_notify(); but the
      struct Lisp_Process is not exported outside of this file. */
   if (!PROCESS_LIVE_P (p))
-    return -1; /* already closed */
+    {
+      errno = 0;
+      return -1; /* already closed */
+    }
 
-  if (!NILP (p->filter) && (p->filter_does_read))
+  if (!NILP (filter) && (p->filter_does_read))
     {
       Lisp_Object filter_result;
 
       /* Some weird FSFmacs crap here with
-	 Vdeactivate_mark and current_buffer->keymap */
-      running_asynch_code = 1;
-      filter_result = call2_trapping_errors ("Error in process filter",
-					     p->filter, process, Qnil);
-      running_asynch_code = 0;
-      restore_match_data ();
+	 Vdeactivate_mark and current_buffer->keymap.
+         Some FSF junk with running_asynch_code, to preserve the match
+         data.  Not necessary because we don't call process filters
+	 asynchronously (i.e. from within QUIT). */
+      /* Don't catch errors here; we're not in any critical code. */
+      filter_result = call2 (filter, process, Qnil);
       CHECK_INT (filter_result);
       return XINT (filter_result);
     }
 
-  nbytes = Lstream_read (XLSTREAM (DATA_INSTREAM (p)), chars,
+  nbytes = Lstream_read (read_stderr ? XLSTREAM (DATA_ERRSTREAM (p)) :
+			 XLSTREAM (DATA_INSTREAM (p)), chars,
 			 sizeof (chars) - 1);
   if (nbytes <= 0) return nbytes;
 
@@ -970,25 +1079,23 @@
   /* !!#### if the coding system changed as a result of reading, we
      need to change the output coding system accordingly. */
   nchars = bytecount_to_charcount (chars, nbytes);
-  outstream = p->filter;
+  outstream = filter;
   if (!NILP (outstream))
     {
-      /* We used to bind inhibit-quit to t here, but
-	 call2_trapping_errors() does that for us. */
-      running_asynch_code = 1;
-      call2_trapping_errors ("Error in process filter",
-			     outstream, process, make_string (chars, nbytes));
-      running_asynch_code = 0;
-      restore_match_data ();
+      /* Some FSF junk with running_asynch_code, to preserve the match
+         data.  Not necessary because we don't call process filters
+	 asynchronously (i.e. from within QUIT). */
+      /* Don't catch errors here; we're not in any critical code. */
+      call2 (outstream, process, make_string (chars, nbytes));
       return nchars;
     }
 
   /* If no filter, write into buffer if it isn't dead.  */
-  if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
+  if (!NILP (buffer) && BUFFER_LIVE_P (XBUFFER (buffer)))
     {
       struct gcpro gcpro1;
-      struct buffer *buf = XBUFFER (p->buffer);
-      int spec = process_setup_for_insertion (process);
+      struct buffer *buf = XBUFFER (buffer);
+      int spec = process_setup_for_insertion (process, read_stderr);
 
       GCPRO1 (process);
 
@@ -1003,13 +1110,21 @@
       buffer_insert_raw_string (buf, chars, nbytes);
 #endif
 
-      Fset_marker (p->mark, make_int (BUF_PT (buf)), p->buffer);
+      Fset_marker (mark, make_int (BUF_PT (buf)), buffer);
+
       MARK_MODELINE_CHANGED;
       unbind_to (spec);
       UNGCPRO;
     }
   return nchars;
 }
+
+int
+process_has_separate_stderr (Lisp_Object process)
+{
+  return XPROCESS (process)->separate_stderr;
+}
+
 
 /* Sending data to subprocess */
 
@@ -1095,6 +1210,33 @@
   return XPROCESS (process)->buffer;
 }
 
+DEFUN ("set-process-stderr-buffer", Fset_process_stderr_buffer, 2, 2, 0, /*
+Set stderr buffer associated with PROCESS to BUFFER (a buffer, or nil).
+*/
+       (process, buffer))
+{
+  CHECK_PROCESS (process);
+  if (!XPROCESS (process)->separate_stderr)
+    invalid_change ("stdout and stderr not separate", process);
+  if (!NILP (buffer))
+    CHECK_BUFFER (buffer);
+  XPROCESS (process)->stderr_buffer = buffer;
+  return buffer;
+}
+
+DEFUN ("process-stderr-buffer", Fprocess_stderr_buffer, 1, 1, 0, /*
+Return the stderr buffer PROCESS is associated with.
+Output from the stderr of PROCESS is inserted in this buffer
+unless PROCESS has a stderr filter.
+*/
+       (process))
+{
+  CHECK_PROCESS (process);
+  if (!XPROCESS (process)->separate_stderr)
+    invalid_change ("stdout and stderr not separate", process);
+  return XPROCESS (process)->stderr_buffer;
+}
+
 DEFUN ("process-mark", Fprocess_mark, 1, 1, 0, /*
 Return the marker for the end of the last output from PROCESS.
 */
@@ -1104,23 +1246,58 @@
   return XPROCESS (process)->mark;
 }
 
+DEFUN ("process-stderr-mark", Fprocess_stderr_mark, 1, 1, 0, /*
+Return the marker for the end of the last stderr output from PROCESS.
+*/
+       (process))
+{
+  CHECK_PROCESS (process);
+  if (!XPROCESS (process)->separate_stderr)
+    invalid_operation ("stdout and stderr not separate", process);
+  return XPROCESS (process)->stderr_mark;
+}
+
 void
-set_process_filter (Lisp_Object process, Lisp_Object filter, int filter_does_read)
+set_process_filter (Lisp_Object process, Lisp_Object filter,
+		    int filter_does_read, int set_stderr)
 {
   CHECK_PROCESS (process);
-  if (PROCESS_LIVE_P (XPROCESS (process))) {
-    if (EQ (filter, Qt))
-      event_stream_unselect_process (XPROCESS (process));
-    else
-      event_stream_select_process (XPROCESS (process));
-  }
+  if (set_stderr && !XPROCESS (process)->separate_stderr)
+    invalid_change ("stdout and stderr not separate", process);
+  if (PROCESS_LIVE_P (XPROCESS (process)))
+    {
+      if (EQ (filter, Qt))
+	event_stream_unselect_process (XPROCESS (process), !set_stderr,
+				       set_stderr);
+      else
+	event_stream_select_process (XPROCESS (process), !set_stderr,
+				     set_stderr);
+    }
 
-  XPROCESS (process)->filter = filter;
+  if (set_stderr)
+    XPROCESS (process)->stderr_filter = filter;
+  else
+    XPROCESS (process)->filter = filter;
   XPROCESS (process)->filter_does_read = filter_does_read;
 }
 
 DEFUN ("set-process-filter", Fset_process_filter, 2, 2, 0, /*
 Give PROCESS the filter function FILTER; nil means no filter.
+t means stop accepting output from the process. (If process was created
+with 
+When a process has a filter, each time it does output
+the entire string of output is passed to the filter.
+The filter gets two arguments: the process and the string of output.
+If the process has a filter, its buffer is not used for output.
+*/
+       (process, filter))
+{
+  set_process_filter (process, filter, 0, 0);
+  return filter;
+}
+
+DEFUN ("set-process-stderr-filter", Fset_process_stderr_filter, 2, 2, 0, /*
+Give PROCESS the stderr filter function FILTER; nil means no filter.
 t means stop accepting output from the process.
 When a process has a filter, each time it does output
 the entire string of output is passed to the filter.
@@ -1129,7 +1306,7 @@
 */
        (process, filter))
 {
-  set_process_filter (process, filter, 0);
+  set_process_filter (process, filter, 0, 1);
   return filter;
 }
 
@@ -1143,14 +1320,26 @@
   return XPROCESS (process)->filter;
 }
 
+DEFUN ("process-stderr-filter", Fprocess_stderr_filter, 1, 1, 0, /*
+Return the filter function of PROCESS; nil if none.
+See `set-process-stderr-filter' for more info on filter functions.
+*/
+       (process))
+{
+  CHECK_PROCESS (process);
+  if (!XPROCESS (process)->separate_stderr)
+    invalid_operation ("stdout and stderr not separate", process);
+  return XPROCESS (process)->stderr_filter;
+}
+
 DEFUN ("process-send-region", Fprocess_send_region, 3, 4, 0, /*
 Send current contents of the region between START and END as input to PROCESS.
 PROCESS may be a process or the name of a process, or a buffer or the
 name of a buffer, in which case the buffer's process is used.  If it
 is nil, the current buffer's process is used.
 BUFFER specifies the buffer to look in; if nil, the current buffer is used.
-If STRING is more than 100 or so characters long, it may be sent in
-several chunks.  This may happen even for shorter strings.  Output
+If the region is more than 100 or so characters long, it may be sent in
+several chunks.  This may happen even for shorter regions.  Output
 from processes can arrive in between chunks.
 */
        (process, start, end, buffer))
@@ -1284,9 +1473,8 @@
 static Lisp_Object
 exec_sentinel_unwind (Lisp_Object datum)
 {
-  Lisp_Cons *d = XCONS (datum);
-  XPROCESS (d->car)->sentinel = d->cdr;
-  free_cons (d);
+  XPROCESS (XCAR (datum))->sentinel = XCDR (datum);
+  free_cons (datum);
   return Qnil;
 }
 
@@ -1304,16 +1492,20 @@
   /* Some weird FSFmacs crap here with
      Vdeactivate_mark and current_buffer->keymap */
 
+  /* Some FSF junk with running_asynch_code, to preserve the match
+     data.  Not necessary because we don't call process filters
+     asynchronously (i.e. from within QUIT). */
+
   /* Zilch the sentinel while it's running, to avoid recursive invocations;
-     assure that it gets restored no matter how the sentinel exits.  */
+     assure that it gets restored no matter how the sentinel exits.
+
+     (#### Why is this necessary?  Probably another relic of asynchronous
+     calling of process filters/sentinels.) */
   p->sentinel = Qnil;
-  record_unwind_protect (exec_sentinel_unwind, noseeum_cons (process, sentinel));
-  /* We used to bind inhibit-quit to t here, but call2_trapping_errors()
-     does that for us. */
-  running_asynch_code = 1;
-  call2_trapping_errors ("Error in process sentinel", sentinel, process, reason);
-  running_asynch_code = 0;
-  restore_match_data ();
+  record_unwind_protect (exec_sentinel_unwind,
+			 noseeum_cons (process, sentinel));
+  /* Don't catch errors here; we're not in any critical code. */
+  call2 (sentinel, process, reason);
   unbind_to (speccount);
 }
 
@@ -1401,7 +1593,7 @@
 
 /* Tell status_notify() to check for terminated processes.  We do this
    because on some systems we sometimes miss SIGCHLD calls. (Not sure
-   why.) */
+   why.) This is also used under Mswin. */
 
 void
 kick_status_notify (void)
@@ -1465,7 +1657,10 @@
 
 	  /* If process is still active, read any output that remains.  */
           while (!EQ (p->filter, Qt)
-		 && read_process_output (process) > 0)
+		 && read_process_output (process, 0) > 0)
+            ;
+          while (p->separate_stderr && !EQ (p->stderr_filter, Qt)
+		 && read_process_output (process, 1) > 0)
             ;
 
 	  /* Get the text to use for the message.  */
@@ -1494,8 +1689,7 @@
 		   BUFFER_LIVE_P (XBUFFER (p->buffer)))
 	    {
 	      struct gcpro ngcpro1;
-	      struct buffer *buf = XBUFFER (p->buffer);
-	      int spec = process_setup_for_insertion (process);
+	      int spec = process_setup_for_insertion (process, 0);
 
 	      NGCPRO1 (process);
 	      buffer_insert_c_string (current_buffer, "\nProcess ");
@@ -1889,8 +2083,11 @@
     {
       if (!NILP (DATA_OUTSTREAM (XPROCESS (process))))
 	{
+	  USID humpty, dumpty;
 	  Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process))));
-	  event_stream_delete_stream_pair (Qnil, XPROCESS (process)->pipe_outstream);
+	  event_stream_delete_io_streams (Qnil,
+					  XPROCESS (process)->pipe_outstream,
+					  Qnil, &humpty, &dumpty);
 	  XPROCESS (process)->pipe_outstream = Qnil;
 	  XPROCESS (process)->coding_outstream = Qnil;
 	}
@@ -1908,7 +2105,7 @@
 deactivate_process (Lisp_Object process)
 {
   Lisp_Process *p = XPROCESS (process);
-  USID usid;
+  USID in_usid, err_usid;
 
   /* It's possible that we got as far in the process-creation
      process as creating the descriptors but didn't get so
@@ -1916,30 +2113,38 @@
      case, p->pid is nil: p->pid is set at the same time that
      the process is selected for input. */
   /* #### The comment does not look correct. event_stream_unselect_process
-     is guarded by process->selected, so this is not a problem. - kkm*/
+     is guarded by process->*_selected, so this is not a problem. - kkm*/
   /* Must call this before setting the streams to nil */
-  event_stream_unselect_process (p);
+  event_stream_unselect_process (p, 1, 1);
 
   if (!NILP (DATA_OUTSTREAM (p)))
     Lstream_close (XLSTREAM (DATA_OUTSTREAM (p)));
   if (!NILP (DATA_INSTREAM (p)))
     Lstream_close (XLSTREAM (DATA_INSTREAM (p)));
+  if (!NILP (DATA_ERRSTREAM (p)))
+    Lstream_close (XLSTREAM (DATA_ERRSTREAM (p)));
 
   /* Provide minimal implementation for deactivate_process
      if there's no process-specific one */
   if (HAS_PROCMETH_P (deactivate_process))
-    usid = PROCMETH (deactivate_process, (p));
+    PROCMETH (deactivate_process, (p, &in_usid, &err_usid));
   else
-    usid = event_stream_delete_stream_pair (p->pipe_instream,
-					    p->pipe_outstream);
+    event_stream_delete_io_streams (p->pipe_instream,
+				    p->pipe_outstream,
+				    p->pipe_errstream,
+				    &in_usid, &err_usid);
 
-  if (usid != USID_DONTHASH)
-    remhash ((const void*)usid, usid_to_process);
+  if (in_usid != USID_DONTHASH)
+    remhash ((const void*)in_usid, usid_to_process);
+  if (err_usid != USID_DONTHASH)
+    remhash ((const void*)err_usid, usid_to_process);
 
   p->pipe_instream = Qnil;
   p->pipe_outstream = Qnil;
+  p->pipe_errstream = Qnil;
   p->coding_instream = Qnil;
   p->coding_outstream = Qnil;
+  p->coding_errstream = Qnil;
 }
 
 static void
@@ -2305,10 +2510,15 @@
   DEFSUBR (Fprocess_tty_name);
   DEFSUBR (Fprocess_command);
   DEFSUBR (Fset_process_buffer);
+  DEFSUBR (Fset_process_stderr_buffer);
   DEFSUBR (Fprocess_buffer);
   DEFSUBR (Fprocess_mark);
+  DEFSUBR (Fprocess_stderr_buffer);
+  DEFSUBR (Fprocess_stderr_mark);
   DEFSUBR (Fset_process_filter);
   DEFSUBR (Fprocess_filter);
+  DEFSUBR (Fset_process_stderr_filter);
+  DEFSUBR (Fprocess_stderr_filter);
   DEFSUBR (Fset_process_window_size);
   DEFSUBR (Fset_process_sentinel);
   DEFSUBR (Fprocess_sentinel);
@@ -2420,6 +2630,14 @@
   /* This below will get its default set correctly in code-init.el. */
     Vdefault_process_coding_system = Fcons (Qundecided, Qnil);
 
+  DEFVAR_LISP ("default-network-coding-system",
+	       &Vdefault_network_coding_system /*
+Cons of coding systems used for network I/O by default.
+The car part is used for reading (decoding) data from a process, and
+the cdr part is used for writing (encoding) data to a process.
+*/ );
+    Vdefault_network_coding_system = Fcons (Qundecided, Qnil);
+
 #ifdef PROCESS_IO_BLOCKING
   DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /*
 List of port numbers or port names to set a blocking I/O mode with connection.
--- a/src/process.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/process.h	Tue May 28 08:45:36 2002 +0000
@@ -33,7 +33,6 @@
 #define kill_buffer_processes(x) 0
 #define close_process_descs() 0
 #define init_xemacs_process() 0
-void wait_without_blocking (void);
 
 #else /* not NO_SUBPROCESSES */
 
@@ -65,31 +64,18 @@
 int connected_via_filedesc_p (Lisp_Process *p);
 void kill_buffer_processes (Lisp_Object buffer);
 void close_process_descs (void);
-
-void set_process_filter (Lisp_Object proc,
-			 Lisp_Object filter, int filter_does_read);
-
-/* True iff we are about to fork off a synchronous process or if we
-   are waiting for it.  */
-extern volatile int synch_process_alive;
-
-/* Nonzero => this is a string explaining death of synchronous subprocess.  */
-extern const char *synch_process_death;
-
-/* If synch_process_death is zero,
-   this is exit code of synchronous subprocess.  */
-extern int synch_process_retcode;
-
-
+void set_process_filter (Lisp_Object proc, Lisp_Object filter,
+			 int filter_does_read,
+			 int set_stderr);
 void update_process_status (Lisp_Object p,
 			    Lisp_Object status_symbol,
 			    int exit_code, int core_dumped);
-
 void get_process_streams (Lisp_Process *p,
-			  Lisp_Object *instr, Lisp_Object *outstr);
-int get_process_selected_p (Lisp_Process *p);
-void set_process_selected_p (Lisp_Process *p, int selected_p);
-
+			  Lisp_Object *instr, Lisp_Object *outstr,
+			  Lisp_Object *errstr);
+int get_process_selected_p (Lisp_Process *p, int do_err);
+void set_process_selected_p (Lisp_Process *p, int in_selected,
+			     int err_selected);
 Lisp_Process *get_process_from_usid (USID usid);
 
 #ifdef HAVE_SOCKETS
@@ -106,16 +92,10 @@
    This is done while Emacs is waiting for keyboard input.  */
 void status_notify (void);
 void kick_status_notify (void);
-
 void deactivate_process (Lisp_Object proc);
-
-void child_setup (int in, int out, int err,
-		  Intbyte **new_argv, Lisp_Object current_dir);
-
-Charcount read_process_output (Lisp_Object proc);
-
+Charcount read_process_output (Lisp_Object proc, int read_stderr);
+int process_has_separate_stderr (Lisp_Object proc);
 const char *signal_name (int signum);
-
 Lisp_Object canonicalize_host_name (Lisp_Object host);
 
 #endif /* not NO_SUBPROCESSES */
--- a/src/procimpl.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/procimpl.h	Tue May 28 08:45:36 2002 +0000
@@ -1,5 +1,6 @@
 /* Processes implementation header
    Copyright (C) 1985, 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright (C) 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -40,10 +41,11 @@
   void (*finalize_process_data) (Lisp_Process *proc, int for_disksave);
   void (*alloc_process_data) (Lisp_Process *p);
   void (*init_process_io_handles) (Lisp_Process *p,
-				   void* in, void* out, int flags);
+				   void* in, void* out, void *err, int flags);
   int  (*create_process) (Lisp_Process *p,
 			  Lisp_Object *argv, int nargv,
-			  Lisp_Object program, Lisp_Object cur_dir);
+			  Lisp_Object program, Lisp_Object cur_dir,
+			  int separate_err);
   int  (*tooltalk_connection_p) (Lisp_Process *p);
 #ifdef HAVE_SOCKETS
   void (*open_network_stream) (Lisp_Object name, Lisp_Object host,
@@ -65,7 +67,9 @@
   int  (*kill_process_by_pid) (int pid, int sigcode);
   int  (*process_send_eof) (Lisp_Object proc);
   Lisp_Object (*get_tty_name) (Lisp_Process *p);
-  USID (*deactivate_process) (Lisp_Process *p);
+  void (*deactivate_process) (Lisp_Process *p,
+			      USID* in_usid,
+			      USID* err_usid);
   void (*init_process) (void);
 };
 
@@ -98,12 +102,15 @@
   /* (funcall FILTER PROC STRING)  (if FILTER is non-nil)
      to dispose of a bunch of chars from the process all at once */
   Lisp_Object filter;
+  /* (funcall FILTER PROC STRING)  (if FILTER is non-nil)
+     to dispose of a bunch of chars from the stderr of process all at once */
+  Lisp_Object stderr_filter;
   /* (funcall SENTINEL PROCESS) when process state changes */
   Lisp_Object sentinel;
-  /* Buffer that output is going to */
-  Lisp_Object buffer;
+  /* Buffer that output or stderr output is going to */
+  Lisp_Object buffer, stderr_buffer;
   /* Marker set to end of last buffer-inserted output from this process */
-  Lisp_Object mark;
+  Lisp_Object mark, stderr_mark;
   /* Lisp_Int of subprocess' PID, or a cons of
      service/host if this is really a network connection */
   Lisp_Object pid;
@@ -124,19 +131,23 @@
      channel, rather than having a call to make_string.
      This only works if the filter is a subr. */
   char filter_does_read;
-  /* Non-nil means kill silently if Emacs is exited.  */
+  /* Non-zero means kill silently if Emacs is exited.  */
   char kill_without_query;
-  char selected;
+  char in_selected, err_selected;
   /* Event-count of last event in which this process changed status.  */
   volatile int tick;
   /* Event-count of last such event reported.  */
   int update_tick;
+  /* Non-zero if stderr and stdout are separated. */
+  char separate_stderr;
   /* Low level streams used in input and output, connected to child */
   Lisp_Object pipe_instream;
   Lisp_Object pipe_outstream;
+  Lisp_Object pipe_errstream;
   /* Data end streams, decoding and encoding pipe_* streams */
   Lisp_Object coding_instream;
   Lisp_Object coding_outstream;
+  Lisp_Object coding_errstream;
 
   /* Implementation dependent data */
   void *process_data;
@@ -145,6 +156,7 @@
 /* Macros to refer to data connection streams */
 #define DATA_INSTREAM(p) (p)->coding_instream
 #define DATA_OUTSTREAM(p) (p)->coding_outstream
+#define DATA_ERRSTREAM(p) (p)->coding_errstream
 
 /* Random externs from process.c */
 extern Lisp_Object Qrun, Qstop, Qopen, Qclosed;
@@ -168,7 +180,7 @@
 
 Lisp_Object make_process_internal (Lisp_Object name);
 void init_process_io_handles (Lisp_Process *p, void* in,
-			      void* out, int flags);
+			      void* out, void *err, int flags);
 void send_process (Lisp_Object proc,
 		   Lisp_Object relocatable,
 		   const Intbyte *nonrelocatable,
--- a/src/profile.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/profile.c	Tue May 28 08:45:36 2002 +0000
@@ -217,13 +217,6 @@
   return Qnil;
 }
 
-static Lisp_Object
-profile_lock_unwind (Lisp_Object ignore)
-{
-  inside_profiling = 0;
-  return Qnil;
-}
-
 struct get_profiling_info_closure
 {
   Lisp_Object accum;
@@ -258,9 +251,7 @@
   closure.accum = Qnil;
   if (big_profile_table)
     {
-      int count = specpdl_depth ();
-      record_unwind_protect (profile_lock_unwind, Qnil);
-      inside_profiling = 1;
+      int count = internal_bind_int ((int *) &inside_profiling, 1);
       maphash (get_profiling_info_maphash, big_profile_table, &closure);
       unbind_to (count);
     }
--- a/src/redisplay.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/redisplay.c	Tue May 28 08:45:36 2002 +0000
@@ -33,11 +33,24 @@
 /*****************************************************************************
  The Golden Rules of Redisplay
 
- First:		It Is Better To Be Correct Than Fast
- Second:	Thou Shalt Not Run Elisp From Within Redisplay
- Third:		It Is Better To Be Fast Than Not To Be
+ First:	  It Is Better To Be Correct Than Fast
+ Second:  Thou Shalt Use Due Caution When Running Elisp From Within Redisplay
+ Third:   It Is Better To Be Fast Than Not To Be
  ****************************************************************************/
 
+/* Note: The second rule used to prohibit running Elisp from within redisplay,
+   but that's not correct.
+
+   Use
+
+   callN_trapping_problems (..., INHIBIT_GC
+                            | INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY)
+
+   instead.
+
+   --ben
+*/
+
 #include <config.h>
 #include "lisp.h"
 
@@ -46,6 +59,7 @@
 #include "debug.h"
 #include "device.h"
 #include "elhash.h"
+#include "events.h"
 #include "extents.h"
 #include "faces.h"
 #include "frame.h"
@@ -6486,10 +6500,13 @@
 	{
 	  Lisp_Object window = wrap_window (w);
 
-	  va_run_hook_with_args_in_buffer (XBUFFER (w->buffer),
-					   Qredisplay_end_trigger_functions,
-					   2, window,
-					   w->redisplay_end_trigger);
+	  va_run_hook_with_args_in_buffer_trapping_problems
+	    ("Error in redisplay end trigger",
+	     XBUFFER (w->buffer),
+	     Qredisplay_end_trigger_functions,
+	     2, window,
+	     w->redisplay_end_trigger,
+	     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 	  w->redisplay_end_trigger = Qnil;
 	}
     }
@@ -6503,6 +6520,7 @@
 redisplay_frame (struct frame *f, int preemption_check)
 {
   struct device *d = XDEVICE (f->device);
+  int depth;
 
   if (preemption_check
       && !DEVICE_IMPL_FLAG (d, XDEVIMPF_DONT_PREEMPT_REDISPLAY))
@@ -6541,7 +6559,7 @@
     }
 
   /* The menubar, toolbar, and icon updates must be done before
-     hold_frame_size_changes is called and we are officially
+     enter_redisplay_critical_section is called and we are officially
      'in_display'.  They may eval lisp code which may call Fsignal.
      If in_display is set Fsignal will abort. */
 
@@ -6580,7 +6598,7 @@
       reset_gutter_display_lines (f);
     }
 
-  hold_frame_size_changes ();
+  depth = enter_redisplay_critical_section ();
 
   /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */
   /* Within this section, we are defenseless and assume that the
@@ -6590,7 +6608,7 @@
      2) Lisp code evaluation
      3) frame size changes
 
-     We ensure (3) by calling hold_frame_size_changes(), which
+     We ensure (3) by calling enter_redisplay_critical_section(), which
      will cause any pending frame size changes to get put on hold
      till after the end of the critical section.  (1) follows
      automatically if (2) is met.  #### Unfortunately, there are
@@ -6644,10 +6662,8 @@
 
   /* ----------------- END CRITICAL REDISPLAY SECTION ---------------- */
 
-  /* Allow frame size changes to occur again.
-
-     #### what happens if changes to other frames happen? */
-  unhold_one_frame_size_changes (f);
+  /* Allow frame size changes to occur again. */
+  exit_redisplay_critical_section (depth);
 
   map_windows (f, call_redisplay_end_triggers, 0);
   return 0;
@@ -6750,13 +6766,6 @@
   return 0;
 }
 
-static Lisp_Object
-restore_profiling_redisplay_flag (Lisp_Object val)
-{
-  profiling_redisplay_flag = XINT (val);
-  return Qnil;
-}
-
 /* Ensure that all windows on all frames on all devices are displaying
    the current contents of their respective buffers. */
 
@@ -6768,11 +6777,7 @@
   int count = specpdl_depth ();
 
   if (profiling_active)
-    {
-      record_unwind_protect (restore_profiling_redisplay_flag,
-			     make_int (profiling_redisplay_flag));
-      profiling_redisplay_flag = 1;
-    }
+    internal_bind_int (&profiling_redisplay_flag, 1);
 
   if (asynch_device_change_pending)
     handle_asynch_device_change ();
@@ -6826,36 +6831,72 @@
 #endif /* ERROR_CHECK_DISPLAY */
 }
 
+/* Note: All places in the C code that call redisplay() are prepared
+   to handle GCing.  However, we can't currently handle GC inside the
+   guts of redisplay (#### someone should fix this), so we need to use
+   INHIBIT_GC when calling Lisp.
+
+   #### We probably can't handle any deletion of existing buffers, frames,
+   windows, devices, consoles, text changes, etc. either.  We should
+
+   (a) Create the appropriate INHIBIT_ flags for this.
+   (b) In the longer run, fix redisplay to handle this.
+
+   (#### What about other external entry points to the redisplay code?
+   Someone should go through and make sure that all callers can handle
+   GC there, too.)
+*/
+
 void
 redisplay (void)
 {
+  run_pre_idle_hook ();
+  redisplay_no_pre_idle_hook ();
+}
+
+void
+redisplay_no_pre_idle_hook (void)
+{
   if (last_display_warning_tick != display_warning_tick &&
       !inhibit_warning_display)
     {
       /* If an error occurs during this function, oh well.
          If we report another warning, we could get stuck in an
 	 infinite loop reporting warnings. */
-      call0_trapping_errors (0, Qdisplay_warning_buffer);
+      call0_trapping_problems
+	(0, Qdisplay_warning_buffer,
+	 INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
       last_display_warning_tick = display_warning_tick;
     }
-  /* The run_hook_trapping_errors functions are smart enough not
+  /* The run_hook_trapping_problems functions are smart enough not
      to do any evalling if the hook function is empty, so there
-     should not be any significant time loss.  All places in the
-     C code that call redisplay() are prepared to handle GCing,
-     so we should be OK. */
+     should not be any significant time loss. */
 #ifndef INHIBIT_REDISPLAY_HOOKS
-  run_hook_trapping_errors ("Error in pre-redisplay-hook",
-			    Qpre_redisplay_hook);
+  run_hook_trapping_problems
+    ("Error in pre-redisplay-hook",
+     Qpre_redisplay_hook,
+     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 #endif /* INHIBIT_REDISPLAY_HOOKS */
 
   redisplay_without_hooks ();
 
 #ifndef INHIBIT_REDISPLAY_HOOKS
-  run_hook_trapping_errors ("Error in post-redisplay-hook",
-			    Qpost_redisplay_hook);
+  run_hook_trapping_problems
+    ("Error in post-redisplay-hook",
+     Qpost_redisplay_hook,
+     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
 #endif /* INHIBIT_REDISPLAY_HOOKS */
 }
 
+Lisp_Object
+eval_within_redisplay (Lisp_Object dont_trust_this_damn_sucker)
+{
+  return
+    eval_in_buffer_trapping_problems
+    ("Error calling function within redisplay", current_buffer,
+     dont_trust_this_damn_sucker,
+     INHIBIT_GC | INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY);
+}
 
 /* Efficiently determine the window line number, and return a pointer
    to its printed representation.  Do this regardless of whether
@@ -9014,6 +9055,7 @@
       DEVICE_FRAME_LOOP (frmcons, d)
 	{
 	  struct frame *f = XFRAME (XCAR (frmcons));
+	  int depth;
 
 	  if (FRAME_REPAINT_P (f) && FRAME_HAS_MINIBUF_P (f))
 	    {
@@ -9032,7 +9074,9 @@
 		  MAYBE_DEVMETH (d, clear_frame, (f));
 		  f->echo_area_garbaged = 0;
 		}
+	      depth = enter_redisplay_critical_section ();
 	      redisplay_window (window, 0);
+	      exit_redisplay_critical_section (depth);
 	      MAYBE_DEVMETH (d, frame_output_end, (f));
 
 	      call_redisplay_end_triggers (XWINDOW (window), 0);
@@ -9043,13 +9087,6 @@
   return Qnil;
 }
 
-static Lisp_Object
-restore_disable_preemption_value (Lisp_Object value)
-{
-  disable_preemption = XINT (value);
-  return Qnil;
-}
-
 DEFUN ("redraw-frame", Fredraw_frame, 0, 2, 0, /*
 Clear frame FRAME and output again what is supposed to appear on it.
 FRAME defaults to the selected frame if omitted.
@@ -9063,11 +9100,7 @@
   int count = specpdl_depth ();
 
   if (!NILP (no_preempt))
-    {
-      record_unwind_protect (restore_disable_preemption_value,
-			     make_int (disable_preemption));
-      disable_preemption++;
-    }
+    internal_bind_int (&disable_preemption, 1 + disable_preemption);
 
   f->clear = 1;
   redisplay_frame (f, 1);
@@ -9094,11 +9127,7 @@
   int count = specpdl_depth ();
 
   if (!NILP (no_preempt))
-    {
-      record_unwind_protect (restore_disable_preemption_value,
-			     make_int (disable_preemption));
-      disable_preemption++;
-    }
+    internal_bind_int (&disable_preemption, 1 + disable_preemption);
 
   redisplay_frame (f, 1);
 
@@ -9128,11 +9157,7 @@
   int count = specpdl_depth ();
 
   if (!NILP (no_preempt))
-    {
-      record_unwind_protect (restore_disable_preemption_value,
-			     make_int (disable_preemption));
-      disable_preemption++;
-    }
+    internal_bind_int (&disable_preemption, 1 + disable_preemption);
 
   DEVICE_FRAME_LOOP (frmcons, d)
     {
@@ -9155,6 +9180,9 @@
 Normally, redisplay is preempted as normal if input arrives.  However,
 if optional second arg NO-PREEMPT is non-nil, redisplay will not stop for
 input and is guaranteed to proceed to completion.
+
+Note: If you simply want everything redisplayed, the current idiom is
+`(sit-for 0)'.
 */
        (device, no_preempt))
 {
@@ -9162,11 +9190,7 @@
   int count = specpdl_depth ();
 
   if (!NILP (no_preempt))
-    {
-      record_unwind_protect (restore_disable_preemption_value,
-			     make_int (disable_preemption));
-      disable_preemption++;
-    }
+    internal_bind_int (&disable_preemption, 1 + disable_preemption);
 
   redisplay_device (d, 0);
 
--- a/src/redisplay.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/redisplay.h	Tue May 28 08:45:36 2002 +0000
@@ -691,7 +691,9 @@
 				       Lisp_Object reloc,
 				       Bytecount offset, Bytecount len);
 int redisplay_frame (struct frame *f, int preemption_check);
+void redisplay_no_pre_idle_hook (void);
 void redisplay (void);
+Lisp_Object eval_within_redisplay (Lisp_Object dont_trust_this_damn_sucker);
 struct display_block *get_display_block_from_line (struct display_line *dl,
 						   enum display_type type);
 layout_bounds calculate_display_line_boundaries (struct window *w,
--- a/src/search.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/search.c	Tue May 28 08:45:36 2002 +0000
@@ -304,9 +304,6 @@
   struct syntax_cache scache_struct;
   struct syntax_cache *scache = &scache_struct;
   
-  if (running_asynch_code)
-    save_search_regs ();
-
   CHECK_STRING (string);
   bufp = compile_pattern (string, &search_regs,
 			  (!NILP (buf->case_fold_search)
@@ -393,8 +390,9 @@
   Charcount s;
   struct re_pattern_buffer *bufp;
 
-  if (running_asynch_code)
-    save_search_regs ();
+  /* Some FSF junk with running_asynch_code, to preserve the match
+     data.  Not necessary because we don't call process filters
+     asynchronously (i.e. from within QUIT). */
 
   CHECK_STRING (regexp);
   CHECK_STRING (string);
@@ -1193,8 +1191,9 @@
   Bytecount s1, s2;
   Bytebpos pos, lim;
 
-  if (running_asynch_code)
-    save_search_regs ();
+  /* Some FSF junk with running_asynch_code, to preserve the match
+     data.  Not necessary because we don't call process filters
+     asynchronously (i.e. from within QUIT). */
 
   /* Null string is found at starting position.  */
   if (len == 0)
@@ -2235,7 +2234,7 @@
   Dynarr_free (get_opaque_ptr (XCDR (cons)));
   free_opaque_ptr (XCAR (cons));
   free_opaque_ptr (XCDR (cons));
-  free_cons (XCONS (cons));
+  free_cons (cons);
   return Qnil;
 }
 
@@ -2850,8 +2849,9 @@
   int num_regs;
   int length;
 
-  if (running_asynch_code)
-    save_search_regs ();
+  /* Some FSF junk with running_asynch_code, to preserve the match
+     data.  Not necessary because we don't call process filters
+     asynchronously (i.e. from within QUIT). */
 
   CONCHECK_LIST (list);
 
--- a/src/sheap.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/sheap.c	Tue May 28 08:45:36 2002 +0000
@@ -42,8 +42,8 @@
 int 	static_heap_initialized=0;
 int 	static_heap_dumped=0;
 
-void* more_static_core ( ptrdiff_t increment );
-void* more_static_core ( ptrdiff_t increment )
+void *more_static_core ( ptrdiff_t increment );
+void *more_static_core ( ptrdiff_t increment )
 {
   int size = (int) increment;
   void *result;
--- a/src/signal.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/signal.c	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,6 @@
 /* Handling asynchronous signals.
    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1996, 2001 Ben Wing.
+   Copyright (C) 1995, 1996, 2001, 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -214,8 +214,8 @@
     }
   else
     /* call1 GC-protects its arguments */
-    call1_trapping_errors ("Error in asynchronous timeout callback",
-			   fun, arg);
+    call1_trapping_problems ("Error in asynchronous timeout callback",
+			     fun, arg, INHIBIT_GC);
 
   waiting_for_user_input_p = 0;
 
@@ -425,9 +425,17 @@
 /* called from QUIT when something_happened gets set (as a result of
    a signal) */
 
-int
+void
 check_what_happened (void)
 {
+#ifdef ERROR_CHECK_TRAPPING_PROBLEMS
+  if (in_display
+      && !((get_inhibit_flags () & INTERNAL_INHIBIT_ERRORS)
+	   && (get_inhibit_flags () & INTERNAL_INHIBIT_THROWS)))
+    assert_with_message
+      (0, "QUIT called from within redisplay without being properly wrapped");
+#endif
+
   /* No GC can happen anywhere here.  handle_async_timeout_signal()
      prevents GC (from asynch timeout handler), so does check_quit()
      (from processing a message such as WM_INITMENU as a result of
@@ -446,7 +454,7 @@
       establish_slow_interrupt_timer ();
     }
 
-  return check_quit ();
+  check_quit ();
 }
 
 #ifdef SIGIO
@@ -633,6 +641,134 @@
 /*                        Control-G checking                          */
 /**********************************************************************/
 
+/* Note: The code to handle QUIT is divided between lisp.h and signal.c.
+   There is also some special-case code in the async timer code in
+   event-stream.c to notice when the poll-for-quit (and poll-for-sigchld)
+   timers have gone off. */
+
+/* OK, here's an overview of how this convoluted stuff works:
+
+[1] Scattered throughout the XEmacs core code are calls to the macro QUIT;
+    This macro checks to see whether a C-g has recently been pressed and
+    not yet handled, and if so, it handles the C-g by calling signal_quit(),
+    which invokes the standard Fsignal() code, with the error being Qquit.
+    Lisp code can establish handlers for this (using condition-case), but
+    normally there is no handler, and so execution is thrown back to the
+    innermost enclosing event loop. (One of the things that happens when
+    entering an event loop is that a condition-case is established that
+    catches *all* calls to `signal', including this one.)
+
+[2] How does the QUIT macro check to see whether C-g has been pressed;
+    obviously this needs to be extremely fast.  Now for some history.
+    In early Lemacs as inherited from the FSF going back 15 years or
+    more, there was a great fondness for using SIGIO (which is sent
+    whenever there is I/O available on a given socket, tty, etc.).
+    In fact, in GNU Emacs, perhaps even today, all reading of events
+    from the X server occurs inside the SIGIO handler!  This is crazy,
+    but not completely relevant.  What is relevant is that similar
+    stuff happened inside the SIGIO handler for C-g: it searched
+    through all the pending (i.e. not yet delivered to XEmacs yet)
+    X events for one that matched C-g.  When it saw a match, it set
+    Vquit_flag to Qt.  On TTY's, C-g is actually mapped to be the
+    interrupt character (i.e. it generates SIGINT), and XEmacs's
+    handler for this signal sets Vquit_flag to Qt.  Then, sometime
+    later after the signal handlers finished and a QUIT macro was
+    called, the macro noticed the setting of Vquit_flag and used
+    this as an indication to call signal_quit().  What signal_quit()
+    actually does is set Vquit_flag to Qnil (so that we won't get
+    repeated interruptions from a single C-g press) and then calls
+    the equivalent of (signal 'quit nil).
+
+[3] Another complication is introduced in that Vquit_flag is actually
+    exported to Lisp as `quit-flag'.  This allows users some level of
+    control over whether and when C-g is processed as quit, esp. in
+    combination with `inhibit-quit'.  This is another Lisp variable,
+    and if set to non-nil, it inhibits signal_quit() from getting
+    called, meaning that the C-g gets essentially ignored.  But not
+    completely: Because the resetting of `quit-flag' happens only
+    in signal_quit(), which isn't getting called, the C-g press is
+    still noticed, and as soon as `inhibit-quit' is set back to nil,
+    a quit will be signalled at the next QUIT macro.  Thus, what
+    `inhibit-quit' really does is defer quits until after the quit-
+    inhibitted period.
+
+[4] Another consideration, introduced by XEmacs, is critical quitting.
+    If you press Control-Shift-G instead of just C-g, `quit-flag' is
+    set to `critical' instead of to t.  When QUIT processes this value,
+    it *ignores* the value of `inhibit-quit'.  This allows you to quit
+    even out of a quit-inhibitted section of code!  Furthermore, when
+    signal_quit() notices that it was invoked as a result of a critical
+    quit, it automatically invokes the debugger (which otherwise would
+    only happen when `debug-on-quit' is set to t).
+
+[5] Well, I explained above about how `quit-flag' gets set correctly,
+    but I began with a disclaimer stating that this was the old way
+    of doing things.  What's done now?  Well, first of all, the SIGIO
+    handler (which formerly checked all pending events to see if there's
+    a C-g) now does nothing but set a flag -- or actually two flags,
+    something_happened and quit_check_signal_happened.  There are two
+    flags because the QUIT macro is now used for more than just handling
+    QUIT; it's also used for running asynchronous timeout handlers that
+    have recently expired, and perhaps other things.  The idea here is
+    that the QUIT macros occur extremely often in the code, but only occur
+    at places that are relatively safe -- in particular, if an error occurs,
+    nothing will get completely trashed.
+
+[6] Now, let's look at QUIT again.  
+
+    UNFINISHED.  Note, however, that as of the point when this comment
+    got committed to CVS (mid-2001), the interaction between reading
+    C-g as an event and processing it as QUIT was overhauled to (for
+    the first time) be understandable and actually work correctly.
+    Now, the way things work is that if C-g is pressed while XEmacs is
+    blocking at the top level, waiting for a user event, it will be
+    read as an event; otherwise, it will cause QUIT. (This includes
+    times when XEmacs is blocking, but not waiting for a user event,
+    e.g. accept-process-output and wait_delaying_user_events().)
+    Formerly, this was supposed to happen, but didn't always due to a
+    bizarre and broken scheme, documented in next_event_internal
+    like this:
+
+       If we read a ^G, then set quit-flag but do not discard the ^G.
+       The callers of next_event_internal() will do one of two things:
+
+       -- set Vquit_flag to Qnil. (next-event does this.) This will
+          cause the ^G to be treated as a normal keystroke.
+       -- not change Vquit_flag but attempt to enqueue the ^G, at
+          which point it will be discarded.  The next time QUIT is
+          called, it will notice that Vquit_flag was set.
+
+    This required weirdness in enqueue_command_event_1 like this:
+
+       put the event on the typeahead queue, unless
+       the event is the quit char, in which case the `QUIT'
+       which will occur on the next trip through this loop is
+       all the processing we should do - leaving it on the queue
+       would cause the quit to be processed twice.
+
+    And further weirdness elsewhere, none of which made any sense,
+    and didn't work, because (e.g.) it required that QUIT never
+    happen anywhere inside next_event_internal() or any callers when
+    C-g should be read as a user event, which was impossible to
+    implement in practice.
+
+    Now what we do is fairly simple.  Callers of next_event_internal()
+    that want C-g read as a user event call begin_dont_check_for_quit().
+    next_event_internal(), when it gets a C-g, simply sets Vquit_flag
+    (just as when a C-g is detected during the operation of QUIT or
+    QUITP), and then tries to QUIT.  This will fail if blocked by the
+    previous call, at which point next_event_internal() will return
+    the C-g as an event.  To unblock things, first set Vquit_flag to
+    nil (it was set to t when the C-g was read, and if we don't reset
+    it, the next call to QUIT will quit), and then unbind_to() the
+    depth returned by begin_dont_check_for_quit().  It makes no
+    difference is QUIT is called a zillion times in next_event_internal()
+    or anywhere else, because it's blocked and will never signal.
+
+  --ben
+ */
+
+
 static Lisp_Object
 restore_dont_check_for_quit (Lisp_Object val)
 {
@@ -654,19 +790,40 @@
      to check dont_check_for_quit when quit-flag == `critical', which is
      rare. */
   specbind (Qinhibit_quit, Qt);
-  record_unwind_protect (restore_dont_check_for_quit,
-			 make_int (dont_check_for_quit));
-  dont_check_for_quit = 1;
+  internal_bind_int (&dont_check_for_quit, 1);
 
   return depth;
 }
 
-/* The effect of this function is to set Vquit_flag if the user pressed
-   ^G and discard the ^G, so as to not notice the same ^G again. */
+/* If we're inside of a begin_dont_check_for_quit() section, but want
+   to temporarily enable quit-checking, call this.  This is used in
+   particular when processing menu filters -- some menu filters do
+   antisocial things like load large amounts of Lisp code (custom in
+   particular), and we obviously want a way of breaking out of any
+   problems.  If you do use this, you should really be trapping the
+   throw() that comes from the quitting (as does the code that handles
+   menus popping up). */
+
 int
+begin_do_check_for_quit (void)
+{
+  int depth = specpdl_depth ();
+  specbind (Qinhibit_quit, Qnil);
+  internal_bind_int (&dont_check_for_quit, 0);
+  /* #### should we set Vquit_flag to Qnil? */
+  return depth;
+ }
+
+/* The effect of this function is to set Vquit_flag appropriately if the
+   user pressed C-g or Sh-C-g.  After this function finishes, Vquit_flag
+   will be Qt for C-g, Qcritical for Sh-C-g, and unchanged otherwise.
+   The C-g or Sh-C-g is discarded, so it won't be noticed again. 
+*/
+
+void
 check_quit (void)
 {
-  /* dont_check_for_quit is set in two circumstances:
+  /* dont_check_for_quit is set in three circumstances:
 
      (1) when we are in the process of changing the window
      configuration.  The frame might be in an inconsistent state,
@@ -676,15 +833,11 @@
      as an event.  The normal check for quit will discard the C-g,
      which would be bad.
 
-     [[#### C-g is still often read as quit, e.g. if you type C-x C-g (the
-     C-g happens during the sit-for in maybe_echo_keys(); even if we
-     attempt to inhibit quit here, there is still a check later on for
-     QUIT.  To fix this properly requires a fairly substantial overhaul of
-     the quit-checking code, which is probably not worth it.)]] not true,
-     we just have to always do dont_check_for_quit around all code that
-     reads events.  my stderr-proc ws already does this.
+     (3) when we're going down with a fatal error.  we're most likely
+     in an inconsistent state, and we definitely don't want to be
+     interrupted. */
 
-     We should *not* conditionalize on Vinhibit_quit, or
+  /* We should *not* conditionalize on Vinhibit_quit, or
      critical-quit (Control-Shift-G) won't work right. */
 
   /* WARNING: Even calling check_quit(), without actually dispatching
@@ -824,9 +977,10 @@
 KERNEL32! BaseProcessStart@4 + 115547 bytes
 
 */
-
+  int specdepth;
+  
   if (dont_check_for_quit)
-    return 0;
+    return;
 
   if (quit_check_signal_happened)
     {
@@ -834,14 +988,11 @@
          which would majorly fuck a lot of things, e.g. re_match()
          [string gets relocated] and lots of other code that's not
          prepared to handle GC in QUIT. */
-      int specdepth = begin_gc_forbidden ();
+      specdepth = begin_gc_forbidden ();
       quit_check_signal_happened = 0;
       event_stream_quit_p ();
       unbind_to (specdepth);
-      return 1;
     }
-  else
-    return 0;
 }
 
 
@@ -880,7 +1031,7 @@
 
 #endif /* 0 */
 
-#if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
+#if defined (HAVE_UNIX_PROCESSES) && !defined (SIGCHLD)
 
 static void
 init_poll_for_sigchld (void)
@@ -1065,7 +1216,7 @@
 #endif
     }
 
-#if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
+#if defined (HAVE_UNIX_PROCESSES) && !defined (SIGCHLD)
   init_poll_for_sigchld ();
 #endif
 
--- a/src/specifier.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/specifier.c	Tue May 28 08:45:36 2002 +0000
@@ -1365,23 +1365,10 @@
 		  spec);
 }
 
-/* Helper function which unwind protects the value of
-   Vunlock_ghost_specifiers, then sets it to non-nil value */
-static Lisp_Object
-restore_unlock_value (Lisp_Object val)
-{
-  Vunlock_ghost_specifiers = val;
-  return val;
-}
-
 int
 unlock_ghost_specifiers_protected (void)
 {
-  int depth = specpdl_depth ();
-  record_unwind_protect (restore_unlock_value,
-			 Vunlock_ghost_specifiers);
-  Vunlock_ghost_specifiers = Qt;
-  return depth;
+  return internal_bind_lisp_object (&Vunlock_ghost_specifiers, Qt);
 }
 
 /* This gets hit so much that the function call overhead had a
@@ -2817,8 +2804,35 @@
 /*                 Caching in the struct window or frame                */
 /************************************************************************/
 
-/* Either STRUCT_WINDOW_OFFSET or STRUCT_FRAME_OFFSET can be 0 to indicate
-   no caching in that sort of object. */
+/* Cause the current value of SPECIFIER in the domain of each frame and/or
+   window to be cached in the struct frame at STRUCT_FRAME_OFFSET and the
+   struct window at STRUCT_WINDOW_OFFSET.  When the value changes in a
+   particular window, VALUE_CHANGED_IN_WINDOW is called.  When the value
+   changes in a particular frame, VALUE_CHANGED_IN_FRAME is called.
+
+   Either STRUCT_WINDOW_OFFSET or STRUCT_FRAME_OFFSET can be 0 to indicate
+   no caching in that sort of object.  However, if they're not 0, you
+   must supply a corresponding value-changed function. (This is the case
+   so that you are forced to consider the ramifications of a value change.
+   You nearly always need to do something, e.g. set a dirty flag.)
+
+   If you create a built-in specifier, you should do the following:
+
+   - Make sure the file you create the specifier in has a
+     specifier_vars_of_foo() function.  If not, create it, declare it in
+     symsinit.h, and make sure it's called in the appropriate place in
+     emacs.c.
+   - In specifier_vars_of_foo(), do a DEFVAR_SPECIFIER(), followed by
+     initializing the specifier using Fmake_specifier(), followed by
+     set_specifier_fallback(), followed (optionally) by
+     set_specifier_caching().
+   - If you used set_specifier_caching(), make sure to create the
+     appropriate value-changed functions.  Also make sure to add the
+     appropriate slots where the values are cached to frameslots.h and
+     winslots.h.
+
+   Do a grep for menubar_visible_p for an example.
+*/
 
 /* #### It would be nice if the specifier caching automatically knew
    about specifier fallbacks, so we didn't have to do it ourselves. */
@@ -2843,6 +2857,10 @@
   sp->caching->value_changed_in_window = value_changed_in_window;
   sp->caching->offset_into_struct_frame = struct_frame_offset;
   sp->caching->value_changed_in_frame = value_changed_in_frame;
+  if (struct_window_offset)
+    assert (value_changed_in_window);
+  if (struct_frame_offset)
+    assert (value_changed_in_frame);
   sp->caching->always_recompute = always_recompute;
   Vcached_specifiers = Fcons (specifier, Vcached_specifiers);
   if (BODILY_SPECIFIER_P (sp))
--- a/src/symsinit.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/symsinit.h	Tue May 28 08:45:36 2002 +0000
@@ -72,7 +72,6 @@
 void syms_of_buffer (void);
 void syms_of_bytecode (void);
 void syms_of_callint (void);
-void syms_of_callproc (void);
 void syms_of_casefiddle (void);
 void syms_of_casetab (void);
 void syms_of_chartab (void);
--- a/src/sysdep.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/sysdep.c	Tue May 28 08:45:36 2002 +0000
@@ -129,6 +129,21 @@
 /*                         subprocess control                           */
 /************************************************************************/
 
+#ifdef NEED_SYNC_PROCESS_CODE
+
+/* True iff we are about to fork off a synchronous process or if we
+   are waiting for it.  */
+volatile int synch_process_alive;
+
+/* Nonzero => this is a string explaining death of synchronous subprocess.  */
+const char *synch_process_death;
+
+/* If synch_process_death is zero,
+   this is exit code of synchronous subprocess.  */
+int synch_process_retcode;
+
+#endif /* NEED_SYNC_PROCESS_CODE */
+
 #ifdef HAVE_TTY
 
 #ifdef SIGTSTP
@@ -184,21 +199,9 @@
 #endif
 }
 
-#if defined (NO_SUBPROCESSES)
-
-#ifdef BSD
-void
-wait_without_blocking (void)
-{
-  wait3 (0, WNOHANG | WUNTRACED, 0);
-  synch_process_alive = 0;
-}
-#endif /* BSD */
-
-#endif /* NO_SUBPROCESSES */
-
-
-void
+#ifdef NEED_SYNC_PROCESS_CODE /* #### Used only on super-ancient systems */
+
+static void
 wait_for_termination (int pid)
 {
   /* #### With the new improved SIGCHLD handling stuff, there is much
@@ -309,8 +312,6 @@
 
      Since implementations may add their own error indicators on top,
      we ignore it by default.  */
-#elif defined (WIN32_NATIVE)
-  /* not used */
 #elif defined (EMACS_BLOCK_SIGNAL) && !defined (BROKEN_WAIT_FOR_SIGNAL) && defined (SIGCHLD)
   while (1)
     {
@@ -342,7 +343,7 @@
 	   Try defining BROKEN_WAIT_FOR_SIGNAL. */
 	EMACS_WAIT_FOR_SIGNAL (SIGCHLD);
     }
-#else /* not HAVE_WAITPID and not WIN32_NATIVE and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
+#else /* not HAVE_WAITPID and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
   /* This approach is kind of cheesy but is guaranteed(?!) to work
      for all systems. */
   while (1)
@@ -357,6 +358,7 @@
 #endif /* OS features */
 }
 
+#endif /* NEED_SYNC_PROCESS_CODE */
 
 #if !defined (NO_SUBPROCESSES)
 
@@ -927,7 +929,7 @@
 /*                       SIGIO control                    */
 /* ------------------------------------------------------ */
 
-#if defined(SIGIO) && !defined(BROKEN_SIGIO)
+#if defined (SIGIO) && !defined (BROKEN_SIGIO)
 
 static void
 init_sigio_on_device (struct device *d)
@@ -2640,7 +2642,7 @@
 	 && (errno == EINTR))
     {
       if (allow_quit)
-	REALLY_QUIT;
+	QUIT;
     }
   return rtnval;
 }
@@ -2663,7 +2665,7 @@
       ssize_t rtnval = write (fildes, b, nbyte);
 
       if (allow_quit)
-	REALLY_QUIT;
+	QUIT;
 
       if (rtnval == -1)
 	{
--- a/src/sysdep.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/sysdep.h	Tue May 28 08:45:36 2002 +0000
@@ -44,8 +44,6 @@
 
 void set_descriptor_non_blocking (int fd);
 
-void wait_without_blocking (void);
-
 int get_pty_max_bytes (int fd);
 Intbyte get_eof_char (int fd);
 
--- a/src/sysproc.h	Sat May 25 01:55:30 2002 +0000
+++ b/src/sysproc.h	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,6 @@
 /*
    Copyright (C) 1995 Free Software Foundation, Inc.
-   Copyright (C) 2000 Ben Wing.
+   Copyright (C) 2000, 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -182,4 +182,34 @@
 		Intbyte * const envp[]);
 pid_t qxe_getpid (void);
 
+/* #### I would really like to delete the remaining synchronous code entirely.
+   We are now using it only for *REALLY* old systems -- how many systems
+   nowadays
+
+   (a) lack job control, or
+   (b) lack mkdir() or rmdir()
+
+   ?????
+
+   --ben
+*/
+
+#if !defined (WIN32_NATIVE) && ((!defined (SIGTSTP) && !defined (USG_JOBCTRL)) || !defined (HAVE_MKDIR) || !defined (HAVE_RMDIR))
+
+#define NEED_SYNC_PROCESS_CODE
+
+/* True iff we are about to fork off a synchronous process or if we
+   are waiting for it.  */
+extern volatile int synch_process_alive;
+
+/* Nonzero => this is a string explaining death of synchronous subprocess.  */
+extern const char *synch_process_death;
+
+/* If synch_process_death is zero,
+   this is exit code of synchronous subprocess.  */
+extern int synch_process_retcode;
+
+#endif
+
+
 #endif /* INCLUDED_sysproc_h_ */
--- a/src/text.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/text.c	Tue May 28 08:45:36 2002 +0000
@@ -2749,20 +2749,6 @@
 static int dfc_convert_to_external_format_in_use;
 static int dfc_convert_to_internal_format_in_use;
 
-static Lisp_Object
-dfc_convert_to_external_format_reset_in_use (Lisp_Object value)
-{
-  dfc_convert_to_external_format_in_use = XINT (value);
-  return Qnil;
-}
-
-static Lisp_Object
-dfc_convert_to_internal_format_reset_in_use (Lisp_Object value)
-{
-  dfc_convert_to_internal_format_in_use = XINT (value);
-  return Qnil;
-}
-
 void
 dfc_convert_to_external_format (dfc_conversion_type source_type,
 				dfc_conversion_data *source,
@@ -2784,16 +2770,16 @@
      ((sink_type == DFC_TYPE_DATA) ||
       (sink_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object))));
 
-  record_unwind_protect (dfc_convert_to_external_format_reset_in_use,
-			 make_int (dfc_convert_to_external_format_in_use));
   if (Dynarr_length (conversion_out_dynarr_list) <=
       dfc_convert_to_external_format_in_use)
     Dynarr_add (conversion_out_dynarr_list, Dynarr_new (Extbyte));
   conversion_out_dynarr = Dynarr_at (conversion_out_dynarr_list,
 				     dfc_convert_to_external_format_in_use);
-  dfc_convert_to_external_format_in_use++;
   Dynarr_reset (conversion_out_dynarr);
 
+  internal_bind_int (&dfc_convert_to_external_format_in_use,
+		     dfc_convert_to_external_format_in_use + 1);
+
   coding_system = get_coding_system_for_text_file (coding_system, 0);
 
   /* Here we optimize in the case where the coding system does no
@@ -2979,16 +2965,16 @@
     (sink_type   == DFC_TYPE_DATA ||
      sink_type   == DFC_TYPE_LISP_LSTREAM));
 
-  record_unwind_protect (dfc_convert_to_internal_format_reset_in_use,
-			 make_int (dfc_convert_to_internal_format_in_use));
   if (Dynarr_length (conversion_in_dynarr_list) <=
       dfc_convert_to_internal_format_in_use)
     Dynarr_add (conversion_in_dynarr_list, Dynarr_new (Intbyte));
   conversion_in_dynarr = Dynarr_at (conversion_in_dynarr_list,
 				    dfc_convert_to_internal_format_in_use);
-  dfc_convert_to_internal_format_in_use++;
   Dynarr_reset (conversion_in_dynarr);
 
+  internal_bind_int (&dfc_convert_to_internal_format_in_use,
+		     dfc_convert_to_internal_format_in_use + 1);
+
   coding_system = get_coding_system_for_text_file (coding_system, 1);
 
   if (source_type != DFC_TYPE_LISP_LSTREAM &&
--- a/src/toolbar.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/toolbar.c	Tue May 28 08:45:36 2002 +0000
@@ -242,7 +242,7 @@
 	 flags to be set; we delay frame size changes to avoid
 	 lots of frame flickering. */
       /* #### I think this should be GC protected. -sb */
-      hold_frame_size_changes ();
+      int depth = enter_redisplay_critical_section ();
       set_specifier_fallback (Vtoolbar[cur], list1 (Fcons (Qnil, Qnil)));
       set_specifier_fallback (Vtoolbar[new], Vdefault_toolbar);
       set_specifier_fallback (Vtoolbar_size[cur], list1 (Fcons (Qnil, Qzero)));
@@ -259,7 +259,7 @@
       set_specifier_fallback (Vtoolbar_visible_p[new],
 			      Vdefault_toolbar_visible_p);
       Vdefault_toolbar_position = position;
-      unhold_frame_size_changes ();
+      exit_redisplay_critical_section (depth);
     }
 
   return position;
@@ -527,13 +527,14 @@
 	      tb->enabled = !NILP (tb->enabled_p);
 	    else
 	      {
+		/* #### do we really need to protect this call? */
 		Lisp_Object result =
-		  eval_in_buffer_trapping_errors
+		  eval_in_buffer_trapping_problems
 		    ("Error in toolbar enabled-p form",
 		     XBUFFER
 		     (WINDOW_BUFFER
 		      (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)))),
-		     tb->enabled_p);
+		     tb->enabled_p, 0);
 		if (UNBOUNDP (result))
 		  /* #### if there was an error in the enabled-p
 		     form, should we pretend like it's enabled
--- a/src/tooltalk.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/tooltalk.c	Tue May 28 08:45:36 2002 +0000
@@ -1,6 +1,7 @@
 /* Tooltalk support for Emacs.
    Copyright (C) 1993, 1994 Sun Microsystems, Inc.
    Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 2002 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -1257,7 +1258,7 @@
       /* Don't ask the user for confirmation when exiting Emacs */
       Fprocess_kill_without_query (lp, Qnil);
       fil = wrap_subr (&SFreceive_tooltalk_message);
-      set_process_filter (lp, fil, 1);
+      set_process_filter (lp, fil, 1, 0);
     }
   else
     {
--- a/src/undo.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/undo.c	Tue May 28 08:45:36 2002 +0000
@@ -104,14 +104,6 @@
 
 
 
-static Lisp_Object
-restore_inside_undo (Lisp_Object val)
-{
-  inside_undo = XINT (val);
-  return val;
-}
-
-
 /* Record an insertion that just happened or is about to happen,
    for LENGTH characters at position BEG.
    (It is possible to record an insertion before or after the fact
@@ -367,10 +359,7 @@
   Lisp_Object next = Qnil;
   /* This function can GC */
   int arg;
-  int speccount = specpdl_depth ();
-
-  record_unwind_protect (restore_inside_undo, make_int (inside_undo));
-  inside_undo = 1;
+  int speccount = internal_bind_int (&inside_undo, 1);
 
 #if 0  /* This is a good feature, but would make undo-start
 	  unable to do what is expected.  */
--- a/src/unexfreebsd.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/unexfreebsd.c	Tue May 28 08:45:36 2002 +0000
@@ -546,7 +546,7 @@
 
 #if 0
   /* never write protect the variable "environ", defined in /lib/crt0.o, and
-     set in process.c and callproc.c */
+     set in process.c */
   mprotect_bottom_addr = ((unsigned long) &environ) + sizeof (char **);
   /* never protect ABOVE the end of data emacs_edata specified */
   mprotect_top_addr = MIN (emacs_edata, N_DATADDR (old_hdr) + old_hdr.a_data);
--- a/src/unexsunos4.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/unexsunos4.c	Tue May 28 08:45:36 2002 +0000
@@ -487,7 +487,7 @@
     plt_end = (caddr_t) N_DATADDR (old_hdr);
 
   /* never write protect the variable "environ", defined in /lib/crt0.o, and
-     set in process.c and callproc.c */
+     set in process.c */
   mprotect_bottom_addr = ((unsigned long) &environ) + sizeof (char **);
   /* never protect ABOVE the end of data emacs_edata specified */
   mprotect_top_addr = MIN (emacs_edata, N_DATADDR (old_hdr) + old_hdr.a_data);
--- a/src/win32.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/win32.c	Tue May 28 08:45:36 2002 +0000
@@ -551,12 +551,12 @@
 /* Divide time in ms specified by IT by DENOM. Return 1 ms
    if division results in zero */
 static UINT
-setitimer_helper_period (const struct itimerval* it, UINT denom)
+setitimer_helper_period (const struct itimerval *it, UINT denom)
 {
   static TIMECAPS time_caps;
 
   UINT res;
-  const struct timeval* tv = 
+  const struct timeval *tv = 
     (it->it_value.tv_sec == 0 && it->it_value.tv_usec == 0)
     ? &it->it_interval : &it->it_value;
   
@@ -578,9 +578,9 @@
 }
 
 static int
-setitimer_helper (const struct itimerval* itnew,
-		  struct itimerval* itold, struct itimerval* itcurrent,
-		  MMRESULT* tid, DWORD sigkind)
+setitimer_helper (const struct itimerval *itnew,
+		  struct itimerval *itold, struct itimerval *itcurrent,
+		  MMRESULT *tid, DWORD sigkind)
 {
   UINT delay, resolution, event_type;
 
--- a/src/window.c	Sat May 25 01:55:30 2002 +0000
+++ b/src/window.c	Tue May 28 08:45:36 2002 +0000
@@ -24,6 +24,16 @@
 /* Synched up with: FSF 19.30. */
 /* Beginning to diverge significantly. */
 
+/* Authorship:
+
+   Based on code from pre-release FSF 19, c. 1991.
+   Significantly reworked by Chuck Thompson, 1993-1996.
+   window mirror stuff added by Chuck Thompson c. 1993.
+   various cleanup by Ben Wing c. 1995 (window slots, window init code,
+   memory usage, synch. up to FSF 19.30, other).
+   Unknown work by Andy Piper.
+   new window-width/height fns. by Ben Wing, Mar 2000. */
+
 /* This file has been Mule-ized. */
 
 #include <config.h>
@@ -2027,6 +2037,7 @@
   w->subwindow_instance_cache = Qnil;
 
   w->dead = 1;
+  note_object_deleted (wrap_window (w));
 }
 
 DEFUN ("delete-window", Fdelete_window, 0, 2, "", /*
@@ -2063,6 +2074,8 @@
   if (! WINDOW_LIVE_P (w))
     return Qnil;
 
+  check_allowed_operation (OPERATION_DELETE_OBJECT, window, Qnil);
+
   frame = WINDOW_FRAME (w);
   f = XFRAME (frame);
   d = XDEVICE (FRAME_DEVICE (f));
@@ -3898,6 +3911,9 @@
     }
 
   XFRAME (p->frame)->mirror_dirty = 1;
+
+  note_object_created (new);
+
   /* do this last (after the window is completely initialized and
      the mirror-dirty flag is set) so that specifier recomputation
      caused as a result of this will work properly and not abort. */
@@ -5546,6 +5562,8 @@
 	  w->gutter_extent_modiff[3] = 0;
 	  w->dead = 0;
 
+	  note_object_created (p->window);
+
 	  if (p->parent_index >= 0)
 	    w->parent = SAVED_WINDOW_N (config, p->parent_index)->window;
 	  else