changeset 593:5fd7ba8b56e7

[xemacs-hg @ 2001-05-31 12:45:27 by ben] xemacs-faq.texi: Major rewrite. Update all MS Windows info to current. Redo section 6.1 almost completely. Incorporate sections 1 and 2 of Hrvoje's FAQ. etags.el: Fix infloop when going up to the root. s\cygwin32.h: Don't unilaterally include ntplay, but only when we're compiling with native sound (look in configure now). event-msw.c: Fix yet more problems with C-g handling. Implement debug-mswindows-events. event-stream.c, events.h, signal.c, sysdep.h: Rearrange the signal-handling code to eliminate the former spaghetti logic paths in it. Document clearly what "low-level" and "high-level" timeouts are. Rename some functions with unclear names (e.g. "...alarm...") to names that reflect what they actually do (e.g. "...async_timeout..."). Fix numerous bugs discovered in the process. console-x.h, event-Xt.c, event-msw.c, frame-x.c: Hopefully make XEmacs properly maintain the "iconified" state on frames at all times. This should fix the "can't delete a frame with C-x 5 0 when there's another iconified frame out there" bug. Put a notice in of further changes that should probably be made to clean up the frame-visibility support. (especially directed at Jan Vroonhof) lisp.h, miscplay.c: Rename SBufbyte to CBufbyte to avoid a misleading name. Eliminate UChar, which is not used anywhere and contributes no semantic info. Add a comment about the documentation-only properties of the char/unsigned char typedefs. Add SChar_Binary as an explicitly `signed' version of Char_Binary and put back the `signed' declarations in miscplay.c. alloc.c: Use char typedefs. console-msw.c, device-msw.c, dialog-msw.c, editfns.c, fileio.c, glyphs-eimage.c, menubar-msw.c, ntplay.c, objects-msw.c, realpath.c, redisplay-msw.c, select-msw.c, syswindows.h, win32.c: Eliminate numerous C++ errors. frame-msw.c: Eliminate numerous C++ errors and Mule-ize. glyphs-msw.c: Eliminate numerous C++ errors and use char typedefs. configure.in: Fix problems detecting both native and Linux sound on Cygwin when compiled with --with-msw=no. Rearrange file-coding handling a bit to avoid warning when compiling with Mule. configure.in, configure.usage, INSTALL: Document XEMACS_CC and corresponding compiler option --xemacs-compiler. Explain how to build xemacs using a C++ compiler.
author ben
date Thu, 31 May 2001 12:45:41 +0000
parents 4f6ba8f1fb3d
children fd49b88b9f06
files lisp/ChangeLog lisp/etags.el man/ChangeLog man/xemacs-faq.texi src/ChangeLog src/alloc.c src/console-msw.c src/console-x.h src/device-msw.c src/dialog-msw.c src/editfns.c src/event-Xt.c src/event-msw.c src/event-stream.c src/events.h src/fileio.c src/frame-msw.c src/frame-x.c src/glyphs-eimage.c src/glyphs-msw.c src/lisp.h src/menubar-msw.c src/miscplay.c src/ntplay.c src/objects-msw.c src/realpath.c src/redisplay-msw.c src/s/cygwin32.h src/select-msw.c src/signal.c src/sysdep.h src/syswindows.h src/win32.c
diffstat 33 files changed, 1508 insertions(+), 755 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu May 31 12:03:39 2001 +0000
+++ b/lisp/ChangeLog	Thu May 31 12:45:41 2001 +0000
@@ -1,3 +1,8 @@
+2001-05-30  Ben Wing  <ben@xemacs.org>
+
+	* etags.el (buffer-tag-table-list):
+	Fix infloop when going up to the root.
+
 2001-05-30  William M. Perry  <wmperry@gnu.org>
 
 	* gtk-marshal.el: Make sure that we use 'const' instead of 'CONST'
--- a/lisp/etags.el	Thu May 31 12:03:39 2001 +0000
+++ b/lisp/etags.el	Thu May 31 12:45:41 2001 +0000
@@ -193,7 +193,15 @@
     ;; Parent directories
     (when tags-check-parent-directories-for-tag-files
       (let ((cur default-directory))
-	(while (file-exists-p (setq cur (expand-file-name ".." cur)))
+	;; Fuck!  Shouldn't there be a more obvious portable way
+	;; to determine if we're the root?  Shouldn't we have a
+	;; proper path manipulation API?  Do you know how many
+	;; god-damn bugs are lurking out there because of Unix/
+	;; Windows differences?  And how much code is littered
+	;; with stuff such as 10 lines down from here?
+	(while (not (and (equal (file-name-as-directory cur) cur)
+			 (equal (directory-file-name cur) cur)))
+	  (setq cur (expand-file-name ".." cur))
 	  (let ((parent-tag-file (expand-file-name "TAGS" cur)))
 	    (when (file-readable-p parent-tag-file)
 	      (push parent-tag-file result))))))
--- a/man/ChangeLog	Thu May 31 12:03:39 2001 +0000
+++ b/man/ChangeLog	Thu May 31 12:45:41 2001 +0000
@@ -1,3 +1,27 @@
+2001-05-30  Ben Wing  <ben@xemacs.org>
+
+	* xemacs-faq.texi (Top):
+	* xemacs-faq.texi (MS Windows):
+	* xemacs-faq.texi (Q6.0.1):
+	* xemacs-faq.texi (Q6.0.2):
+	* xemacs-faq.texi (Q6.0.3):
+	* xemacs-faq.texi (Q6.0.4):
+	* xemacs-faq.texi (Q6.1.1):
+	* xemacs-faq.texi (Q6.1.4):
+	* xemacs-faq.texi (Q6.1.5):
+	* xemacs-faq.texi (Q6.1.6):
+	* xemacs-faq.texi (Q6.2.1):
+	* xemacs-faq.texi (Q6.2.2):
+	* xemacs-faq.texi (Q6.3.1):
+	* xemacs-faq.texi (Q6.3.2):
+	* xemacs-faq.texi (Q6.3.3):
+	* xemacs-faq.texi (Q6.4.1):
+	* xemacs-faq.texi (Current Events):
+	Major rewrite.
+	Update all MS Windows info to current.
+	Redo section 6.1 almost completely.
+	Incorporate sections 1 and 2 of Hrvoje's FAQ.
+
 2001-05-24  Ben Wing  <ben@xemacs.org>
 
 	* xemacs-faq.texi (Top):
--- a/man/xemacs-faq.texi	Thu May 31 12:03:39 2001 +0000
+++ b/man/xemacs-faq.texi	Thu May 31 12:45:41 2001 +0000
@@ -7,7 +7,7 @@
 @finalout
 @titlepage
 @title XEmacs FAQ
-@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2001/05/24 07:50:53 $
+@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2001/05/31 12:45:30 $
 @sp 1
 @author Tony Rossini <rossini@@biostat.washington.edu>
 @author Ben Wing <ben@@xemacs.org>
@@ -380,23 +380,27 @@
 * Q6.0.1::      What is the status of the XEmacs port to Windows?
 * Q6.0.2::      What flavors of MS Windows are supported?
 * Q6.0.3::      Are binaries available?
-* Q6.0.4::      Can I build XEmacs on MS Windows with support for X or Cygwin?
+* Q6.0.4::      Can I build XEmacs on MS Windows with X support?  Do I need to?
+* Q6.0.5::      I'd like to help out.  What do I do?
+* Q6.0.6::      What are Cygwin and MinGW, and do I need them to run XEmacs?
+* Q6.0.7::      What exactly are all the different ways to build XEmacs under Windows?
 
 Building XEmacs on MS Windows:
-* Q6.1.1::      I decided to run with X.  Where do I get an X server?
-* Q6.1.2::      What compiler do I need to compile XEmacs?
-* Q6.1.3::      How do I compile for the native port?
-* Q6.1.4::      How do I compile for the X port?
-* Q6.1.5::      How do I compile for Cygnus' Cygwin?
-* Q6.1.6::      What do I need for Cygwin?
+* Q6.1.1::      What compiler/libraries do I need to compile XEmacs?
+* Q6.1.2::      How do I compile the native port?
+* Q6.1.3::      What do I need for Cygwin?
+* Q6.1.4::      How do I compile under Cygwin?
+* Q6.1.5::      How do I compile using MinGW (aka @samp{the -mno-cygwin flag to gcc})?
+* Q6.1.6::      I decided to run with X.  Where do I get an X server?
+* Q6.1.7::      How do I compile with X support?
 
 Customization and User Interface:
-* Q6.2.1::      How will the port cope with differences in the Windows user interface?
+* Q6.2.1::      How does the port cope with differences in the Windows user interface?
 * Q6.2.2::      How do I change fonts in XEmacs on MS Windows?
 * Q6.2.3::      Where do I put my @file{init.el}/@file{.emacs} file?
 
 Miscellaneous:
-* Q6.3.1::      Will XEmacs rename all the win32-* symbols to w32-*?
+* Q6.3.1::      Does XEmacs rename all the win32-* symbols to w32-*?
 * Q6.3.2::      What are the differences between the various MS Windows emacsen?
 * Q6.3.3::      What is the porting team doing at the moment?
 
@@ -653,7 +657,7 @@
 @node Q1.0.10, Q1.0.11, Q1.0.9, Introduction
 @unnumberedsubsec Q1.0.10: Is there a port of XEmacs to Microsoft ('95 or NT)?
 
-Yes, @xref{MS Windows}.
+Yes, see @ref{MS Windows}.
 
 @node Q1.0.11, Q1.0.12, Q1.0.10, Introduction
 @unnumberedsubsec Q1.0.11: Is there a port of XEmacs to the Macintosh?
@@ -1647,7 +1651,7 @@
 
 It's possible that a core file didn't get produced, in which case you're
 out of luck.  Go complain to your system administrator and tell him not
-to disable core files by default.  Also @xref{Q2.1.15}, for tips and
+to disable core files by default.  Also see @ref{Q2.1.15}, for tips and
 techniques for dealing with a debugger.
 
 When making a problem report make sure that:
@@ -2227,7 +2231,7 @@
 @unnumberedsubsec Q2.1.18: XEmacs is outputting lots of X errors.
 
 If this is happening, we would very much like to know what's causing
-them.  To find this out, @xref{Q2.1.15}.  Try to get both a C and Lisp
+them.  To find this out, see @ref{Q2.1.15}.  Try to get both a C and Lisp
 backtrace, and send them to @email{xemacs-beta@@xemacs.org}.
 
 @node Q2.1.19, Q2.1.20, Q2.1.18, Installation
@@ -2333,7 +2337,7 @@
 happens.  The simplest explanation is that you are missing a package
 that is essential to you.  You can either track it down and install it
 (there is a list of packages and brief descriptions of their contents in
-@file{etc/PACKAGES}), or install the `Sumo Tarball' (see @pxref{Q2.0.14}).
+@file{etc/PACKAGES}), or install the `Sumo Tarball' (@pxref{Q2.0.14}).
 
 @c #### should xref to XEmacs manual here
 
@@ -3009,7 +3013,7 @@
 Yes.  Use @code{gnuclient -nw}. (Prior to 20.3, use the @code{gnuattach}
 program supplied with XEmacs instead.)
 
-Also @xref{Q5.0.12}.
+Also see @ref{Q5.0.12}.
 
 @node Q3.5.1, Q3.5.2, Q3.4.2, Customization
 @unnumberedsec 3.5: The Keyboard
@@ -3104,7 +3108,7 @@
 (global-set-key 'redirected-delete 'foo)
 @end lisp
 
-Also @xref{Q3.5.10}.
+Also see @ref{Q3.5.10}.
 
 @node Q3.5.5, Q3.5.6, Q3.5.4, Customization
 @unnumberedsubsec Q3.5.5: Scrolling one line at a time.
@@ -3244,7 +3248,7 @@
 @code{Advanced (Customize)->Emacs->Editing->Basics->Delete Key Deletes Forward} or
 type @kbd{M-x customize @key{RET} editing-basics @key{RET}}.
 
-Also @xref{Q3.5.4}.
+Also see @ref{Q3.5.4}.
 
 @node Q3.5.10, Q3.5.11, Q3.5.9, Customization
 @unnumberedsubsec Q3.5.10: Can I turn on @dfn{sticky} modifier keys?
@@ -3721,7 +3725,7 @@
 
 @strong{Warning: This command turns off all region highlighting.}
 
-Also @xref{Q3.10.1}.
+Also see @ref{Q3.10.1}.
 
 @node Q3.10.5,  , Q3.10.4, Customization
 @unnumberedsubsec Q3.10.5: The region disappears when I hit the end of buffer while scrolling.
@@ -5855,23 +5859,27 @@
 * Q6.0.1::      What is the status of the XEmacs port to Windows?
 * Q6.0.2::      What flavors of MS Windows are supported?
 * Q6.0.3::      Where are the XEmacs on MS Windows binaries?
-* Q6.0.4::      Can I build XEmacs on MS Windows with support for X or Cygwin?
+* Q6.0.4::      Can I build XEmacs on MS Windows with X support?  Do I need to?
+* Q6.0.5::      I'd like to help out.  What do I do?
+* Q6.0.6::      What are Cygwin and MinGW, and do I need them to run XEmacs?
+* Q6.0.7::      What exactly are all the different ways to build XEmacs under Windows?
 
 Building XEmacs on MS Windows
-* Q6.1.1::      I decided to run with X.  Where do I get an X server?
-* Q6.1.2::      What compiler do I need to compile XEmacs?
-* Q6.1.3::      How do I compile for the native port?
-* Q6.1.4::      How do I compile for the X port?
-* Q6.1.5::      How do I compile for Cygnus' Cygwin?
-* Q6.1.6::      What do I need for Cygwin?
+* Q6.1.1::      What compiler/libraries do I need to compile XEmacs?
+* Q6.1.2::      How do I compile the native port?
+* Q6.1.3::      What do I need for Cygwin?
+* Q6.1.4::      How do I compile under Cygwin?
+* Q6.1.5::      How do I compile using MinGW (aka @samp{the -mno-cygwin flag to gcc})?
+* Q6.1.6::      I decided to run with X.  Where do I get an X server?
+* Q6.1.7::      How do I compile with X support?
 
 Customization and User Interface
-* Q6.2.1::      How will the port cope with differences in the Windows user interface?
+* Q6.2.1::      How does the port cope with differences in the Windows user interface?
 * Q6.2.2::      How do I change fonts in XEmacs on MS Windows?
 * Q6.2.3::      Where do I put my @file{init.el}/@file{.emacs} file?
 
 Miscellaneous
-* Q6.3.1::      Will XEmacs rename all the win32-* symbols to w32-*?
+* Q6.3.1::      Does XEmacs rename all the win32-* symbols to w32-*?
 * Q6.3.2::      What are the differences between the various MS Windows emacsen?
 * Q6.3.3::      What is the porting team doing at the moment?
 
@@ -5884,37 +5892,134 @@
 @unnumberedsec 6.0: General Info
 @unnumberedsubsec Q6.0.1: What is the status of the XEmacs port to Windows?
 
-Is XEmacs really getting ported to MS Windows?  What is the status of the port?
-
-Yes, a group of volunteers actively works on making XEmacs code base
-cleanly compile and run on MS Windows operating systems.  The mailing
-list at @email{xemacs-nt@@xemacs.org} is dedicated to that effort
-(please use the -request address to subscribe).
-
-At this time, XEmacs on MS Windows is stable and full-featured.
-However, the internationalization (Mule) support does not work --
-although this is being actively worked on.
+Is XEmacs really ported to MS Windows?  What is the status of the port?
+
+Beginning with release 21.0, XEmacs has worked under MS Windows.  A
+group of dedicated developers actively maintains and improves the
+Windows-specific portions of the code.  The mailing list at
+@email{xemacs-nt@@xemacs.org} is dedicated to that effort (please use
+the -request address to subscribe). (Despite its name, XEmacs actually
+works on all versions of Windows.)
+
+As of May 2001, XEmacs on MS Windows is stable and full-featured, and
+has been so for a year or more -- in fact, some features, such as
+printing, actually work better on Windows than native Unix.  However,
+the internationalization (Mule) support does not work -- although this
+is being actively worked on.
+
 
 @node Q6.0.2, Q6.0.3, Q6.0.1, MS Windows
 @unnumberedsubsec Q6.0.2: What flavors of MS Windows are supported?  The list name implies NT only.
 
-The list name is misleading, as XEmacs will support Windows 95, Windows
-98, Windows NT, Windows 2000, Windows ME, Windows XP, and all newer
-versions of Windows.  The MS Windows-specific code is based on Microsoft
-Win32 API, and will not work on MS Windows 3.x or on MS-DOS.
+The list name is misleading, as XEmacs supports and has been compiled on
+Windows 95, Windows 98, Windows NT, Windows 2000, Windows ME, Windows
+XP, and all newer versions of Windows.  The MS Windows-specific code is
+based on Microsoft Win32 API, and will not work on MS Windows 3.x or on
+MS-DOS.
+
+XEmacs also supports the Cygwin and MinGW development and runtime
+environments, where it also uses native Windows code for graphical
+features.
 
 
 @node Q6.0.3, Q6.0.4, Q6.0.2, MS Windows
 @unnumberedsubsec Q6.0.3: Are binaries available?
 
-Binaries are available at
-@uref{ftp://ftp.xemacs.org/pub/xemacs/binaries/win32/} for the native MS
-Windows version.
-
-@node Q6.0.4, Q6.1.1, Q6.0.3, MS Windows
-@unnumberedsubsec Q6.0.4: Can I build XEmacs on MS Windows with support for X or Cygwin?
-
-Yes.  XEmacs can be built in several ways in the MS Windows environment.
+Binaries are available at @uref{http://www.xemacs.org/Download/win32/}
+for the native and Cygwin MS Windows versions of 21.4, and the native
+version of 21.1.
+
+The 21.4 binaries use a modified version of the Cygwin installer.  Run
+the provided @file{setup.exe}, and follow the instructions.
+
+
+@node Q6.0.4, Q6.0.5, Q6.0.3, MS Windows
+@unnumberedsubsec Q6.0.4: Can I build XEmacs on MS Windows with X support?  Do I need to?
+
+Yes, you can, but no you do not need to.  In fact, we recommend that you
+use a native-GUI version unless you have a specific need for an X
+version.
+
+@node Q6.0.5, Q6.0.6, Q6.0.4, MS Windows
+@unnumberedsubsec Q6.0.5: I'd like to help out.  What do I do?
+
+It depends on the knowledge and time you possess.  If you are a
+programmer, try to build XEmacs and see if you can improve it.
+Windows-specific improvements like integration with established
+Windows environments are especially sought after.
+
+Otherwise, you can still help by downloading the binaries, using
+XEmacs as your everyday editor and reporting bugs you find to the
+mailing list.
+
+Another area where we need help is the documentation: We need good
+documentation for building XEmacs and for using it.  This FAQ is a
+small step in that direction.
+
+@node Q6.0.6, Q6.0.7, Q6.0.5, MS Windows
+@unnumberedsubsec Q6.0.6: What are Cygwin and MinGW, and do I need them to run XEmacs?
+
+To answer the second part of the question: No, you, you don't need
+Cygwin or MinGW to build or to run XEmacs.  But if you have them and
+want to use them, XEmacs supports these environments.
+
+(One important reason to support Cygwin is that it lets the MS Windows
+developers test out their code in a Unix environment without actually
+having to have a Unix machine around.  For this reason alone, Cygwin
+support is likely to remain supported for a long time in XEmacs.  Same
+goes for the X support under Cygwin, for the same reasons.  MinGW
+support, on the other hand, depends on volunteers to keep it up to date;
+but this is generally not hard.)
+
+Cygwin is a set of tools providing Unix-like API on top of Win32.
+It makes it easy to port large Unix programs without significant
+changes to their source code.  It is a development environment as well
+as a runtime environment.
+
+When built with Cygwin, XEmacs supports all display types -- TTY, X &
+Win32 GUI, and can be built with support for all three simultaneously.
+If you build with Win32 GUI support then the Cygwin version uses the
+majority of the Windows-specific code, which is mostly related to
+display.  If you want to build with X support you need X libraries (and
+an X server to display XEmacs on); see @ref{Q6.1.4}.  TTY and Win32 GUI
+require no additional libraries beyond what comes standard with Cygwin.
+
+The advantages of the Cygwin version are that it integrates well with
+the Cygwin environment for existing Cygwin users; uses configure so
+building with different features is very easy; and actively supports X &
+TTY.  Furthermore, the entire Cygwin environment and compiler are free,
+whereas Visual C++ costs money.
+
+The disadvantage is that it requires the whole Cygwin environment,
+whereas the native port requires only a suitable MS Windows compiler.
+Also, it follows the Unix filesystem and process model very closely
+(some will undoubtedly view this as an advantage).
+
+See @uref{http://sources.redhat.com/cygwin/} for more information on
+Cygwin.
+
+MinGW is a collection of header files and import libraries that allow
+one to use GCC under the Cygwin environment to compile and produce
+exactly the same native Win32 programs that you can using Visual C++.
+Programs compiled with MinGW make use of the standard Microsoft runtime
+library @file{MSVCRT.DLL}, present on all Windows systems, and look,
+feel, and act like a standard Visual-C-produced application. (The only
+difference is the compiler.) This means that, unlike a
+standardly-compiled Cygwin application, no extra runtime support
+(e.g. Cygwin's @file{cygwin1.dll}) is required.  This, along with the
+fact that GCC is free (and works in a nice Unix-y way in a nice Unix-y
+environment, for those die-hard Unix hackers out there), is the main
+advantage of MinGW.  It is also potentially faster than Cygwin because
+it has less overhead when calling Windows, but you lose the POSIX
+emulation layer, which makes Unix programs harder to port. (But this is
+irrelevant for XEmacs since it's already ported to Win32.)
+
+See @uref{http://www.mingw.org/} for more information on MinGW.
+
+@node Q6.0.7, Q6.1.1, Q6.0.6, MS Windows
+@unnumberedsubsec Q6.0.7: What exactly are all the different ways to build XEmacs under Windows?
+
+XEmacs can be built in several ways in the MS Windows environment.
 
 The standard way is what we call the "native" port.  It uses the Win32
 API and has no connection with X whatsoever -- it does not require X
@@ -5923,80 +6028,60 @@
 support.  Almost all development is geared towards this version, and
 there is little reason not to use it.
 
-You can also build XEmacs "X" port---it requires X libraries to build
-and an X server to run.  Internally it uses the Xt event loop and makes
-use of X toolkits.  Its look is quite un-Windowsy, and it is not well
-maintained, but it is being kept around for the time being because it
-has a long history.
-
-There is also a third special case, the Cygwin port.  It takes
-advantage of Cygnus emulation library under Win32, which enables it to
-reuse much of the Unix XEmacs code base, such as processes and network
-support, or internal select() mechanisms.
-
-Cygwin port supports all display types---TTY, X & MS GUI, and can be
-built with support for all three.  If you build with MS GUI support
-then the Cygwin version uses the majority of the msw code, which is
-mostly related to display.  If you want to build with X support you
-need X libraries.  If you want to build with TTY support you need
-ncurses.  MS GUI requires no additional libraries.
-
-The advantages of the Cygwin version are that it integrates well with
-Cygwin environment for existing Cygwin users; uses configure so building
-with different features is very easy; and has process support in X &
-tty.
-
-The disadvantage is that it requires several Unix utilities and the
-whole Cygwin environment, whereas the native port requires only a
-suitable MS Windows compiler.  Also, it follows the Unix filesystem and
-process model very closely (some will undoubtedly view this as an
-advantage).
-
-@node Q6.1.1, Q6.1.2, Q6.0.4, MS Windows
+The second way to build is the Cygwin port.  It takes advantage of
+Cygnus emulation library under Win32.  @xref{Q6.0.6}, for more
+information.
+
+A third way is the MinGW port.  It uses the Cygwin environment to build
+but does not require it at runtime.  @xref{Q6.0.6}, for more
+information.
+
+Finally, you might also be able to build the non-Cygwin, non-MinGW "X"
+port.  This was actually the first version of XEmacs that ran under MS
+Windows, and although the code is still in XEmacs, it's essentially
+orphaned and it's unlikely it will compile without a lot of work.  If
+you want an MS Windows versin of XEmacs that supports X, use the Cygwin
+version. (The X support there is actively maintained, so that Windows
+developers can test the X support in XEmacs.)
+
+
+@node Q6.1.1, Q6.1.2, Q6.0.7, MS Windows
 @unnumberedsec 6.1: Building XEmacs on MS Windows
-@unnumberedsubsec Q6.1.1: I decided to run with X.  Where do I get an X server?
-
-Pointers to X servers can be found at
-@iftex
-@*
-@end iftex
-@uref{http://dao.gsfc.nasa.gov/software/grads/win32/X11R6.3/};
-
-look for "Where to get an X server".  Also note that, although the above
-page talks about Cygnus gnu-win32 (Cygwin), the information on X servers
-is Cygwin-independent.  You don't have to be running/using Cygwin to use
-these X servers, and you don't have to compile XEmacs under Cygwin to
-use XEmacs with these X servers.  An "X port" XEmacs compiled under
-Visual C++ will work with these X servers (as will XEmacs running on a
-Unix box, redirected to the server running on your PC).
-
+@unnumberedsubsec Q6.1.1: What compiler/libraries do I need to compile XEmacs?
+
+You need Visual C++ 4.2, 5.0, or 6.0 for the native version. (We have
+some beta testers currently trying to compile with VC.NET, aka version
+7.0, but we can't yet report complete success.) For the Cygwin and MinGW
+versions, you need the Cygwin environment, which comes with GCC, the
+compiler used for those versions.  @xref{Q6.0.6}, for more information
+on Cygwin and MinGW.
 
 @node Q6.1.2, Q6.1.3, Q6.1.1, MS Windows
-@unnumberedsubsec Q6.1.2: What compiler do I need to compile XEmacs?
-
-You need Visual C++ 4.2, 5.0, or 6.0, with the exception of the Cygwin
-port, which uses Gcc.  There is also a MINGW32 port of XEmacs (using
-Gcc, but using native libraries rather than the Cygwin libraries).  ####
-More information about this should be provided.
-
-
-@node Q6.1.3, Q6.1.4, Q6.1.2, MS Windows
-@unnumberedsubsec Q6.1.3: How do I compile for the native port?
+@unnumberedsubsec Q6.1.2: How do I compile the native port?
 
 Please read the file @file{nt/README} in the XEmacs distribution, which
 contains the full description.
 
+@node Q6.1.3, Q6.1.4, Q6.1.2, MS Windows
+@unnumberedsubsec Q6.1.3: What do I need for Cygwin?
+
+You can find the Cygwin tools and compiler at:
+
+@uref{http://sources.redhat.com/cygwin/}
+
+Click on the @samp{Install now!} link, which will download a file
+@file{setup.exe}, which you can use to download everything else. (You
+will need to pick a mirror site; @samp{mirrors.rcn.net} is probably the
+best.) You should go ahead and install everything -- you'll get various
+ancillary libraries that XEmacs needs or likes, e.g. XPM, PNG, JPEG,
+TIFF, etc.
+
+If you want to compile under X, you will also need the X libraries; see
+@ref{Q6.1.6}.
+
 
 @node Q6.1.4, Q6.1.5, Q6.1.3, MS Windows
-@unnumberedsubsec Q6.1.4: How do I compile for the X port?
-
-Again, it is described in @file{nt/README} in some detail.  Basically, you
-need to get X11 libraries from ftp.x.org, and compile them.  If the
-precompiled versions are available somewhere, I don't know of it.
-
-
-@node Q6.1.5, Q6.1.6, Q6.1.4, MS Windows
-@unnumberedsubsec Q6.1.5: How do I compile for Cygnus' Cygwin?
+@unnumberedsubsec Q6.1.4: How do I compile under Cygwin?
 
 Similar as on Unix; use the usual `configure' and `make' process.
 Some problems to watch out for:
@@ -6007,8 +6092,7 @@
 @file{init.el}/@file{.emacs} file comes from;
 
 @item
-CYGWIN needs to be set to tty for process support work. e.g. CYGWIN=tty;
-(use CYGWIN32=tty under b19 and older.)
+CYGWIN needs to be set to tty for process support to work, e.g. CYGWIN=tty;
 
 @item
 picking up some other grep or other UNIX-like tools can kill configure;
@@ -6018,95 +6102,120 @@
 number;
 
 @item
-The Cygwin version doesn't understand @file{//machine/path} type paths so you
-will need to manually mount a directory of this form under a unix style
-directory for a build to work on the directory.
+(Unconfirmed) The Cygwin version doesn't understand
+@file{//machine/path} type paths so you will need to manually mount a
+directory of this form under a unix style directory for a build to work
+on the directory;
+
+@item
+If you're building @strong{WITHOUT} X11, don't forget to change symlinks
+@file{/usr/lib/libXpm.a} and @file{/usr/lib/libXpm.dll.a} to point to
+the non-X versions of these libraries.  By default they point to the X
+versions.  So:
+
+@example
+/usr/lib/libXpm.a     -> /usr/lib/libXpm-noX.a
+/usr/lib/libXpm.dll.a -> /usr/lib/libXpm-noX.dll.a
+@end example
+
+
+@item
+Other problems are listed in the @file{PROBLEMS} file, in the top-level
+directory of the XEmacs sources.
 
 @end itemize
 
-@node Q6.1.6, Q6.2.1, Q6.1.5, MS Windows
-@unnumberedsubsec Q6.1.6: What do I need for Cygwin?
-
-You can find the Cygwin tools and compiler at:
-
-@uref{http://sourceware.cygnus.com/cygwin/}
-
-You will need version b19 or later.
-The latest current version is 1.1.1.
-Other common versions you will see are b20.1.
-
-Another location, one of the mirror sites of the site just mentioned,
-is usually a last faster:
-
-@uref{ftp://ftp.freesoftware.com/pub/sourceware/cygwin/}
-
-You can obtain the latest version (currently 1.1.1) from the
-@samp{latest/} subdirectory of either of the above two just-mentioned
-URL's.
-
-@strong{WARNING: The version of GCC supplied under @samp{latest/}, as of
-June 6th, 2000, does not appear to work.  It generates loads of spurious
-preprocessor warnings and errors, which makes it impossible to compile
-XEmacs with it.}
-
-You will also need the X libraries.  You can get them on the XEmacs FTP
-site at
-
-@uref{ftp://ftp.xemacs.org/pub/xemacs/aux/cygwin/}
-
-You will find b19 and b20 versions of the X libraries, plus b19 and b20
-versions of stuff that should go into @samp{/usr/local/}, donated by
-Andy Piper.  This includes pre-built versions of various graphics libraries,
-such as PNG, JPEG, TIFF, and XPM. (Remember, GIF support is built-in to
-XEmacs.)
-
-(X libraries for v1 and beyond of Cygwin can be found on the Cygwin site
-itself -- look in the @samp{xfree/} subdirectory.)
-
-@emph{NOTE:} There are two versions of the XPM library provided in
-Andy's packets.  Once is for building with X support, and the other for
-building without.  The X version should work if you're building with
-both X and Windows support.  The two files are called @file{libXpm-X.a}
-and @file{libXpm-noX.a} respectively, and you must symlink the
-appropriate one to @file{libXpm.a}. @strong{CAREFUL:} By default, the
-non-X version is symlinked in.  If you then configure XEmacs with X,
-you won't run into problems until you start compiling @file{events.c},
-at which point you'll get strange and decidedly non-obvious errors.
-
-Please see @uref{http://www.xemacs.freeserve.co.uk/} (Andy Piper's home
-page) for more information.
-
-BTW There are also libraries at
-@iftex
-@*
-@end iftex
-@uref{http://dao.gsfc.nasa.gov/software/grads/win32/X11R6.3/}, but
-these are not b19 compatible, and may in fact be native-compiled.
-
-
-@node Q6.2.1, Q6.2.2, Q6.1.6, MS Windows
+
+@node Q6.1.5, Q6.1.6, Q6.1.4, MS Windows
+@unnumberedsubsec Q6.1.5: How do I compile using MinGW (aka @samp{the -mno-cygwin flag to gcc})?
+
+Similar to the method for Unix.  Things to remember:
+
+@itemize @bullet
+@item
+Specify the target host on the command line for @file{./configure}, e.g.
+@samp{./configure i586-pc-mingw32}.
+
+@item
+Be sure that your build directory is mounted such that it has the
+same path either as a cygwin path (@file{/build/xemacs}) or as a Windows
+path (@file{c:\build\xemacs}).
+
+@item
+Build @samp{gcc -mno-cygwin} versions of the extra libs, i.e. @file{libpng},
+@file{compface}, etc.
+
+@item
+Specify the target location of the extra libs on the command line
+to @file{configure}, e.g.
+@samp{./configure --site-prefixes=/build/libs i586-pc-mingw32}.
+@end itemize
+
+
+@node Q6.1.6, Q6.1.7, Q6.1.5, MS Windows
+@unnumberedsubsec Q6.1.6: I decided to run with X.  Where do I get an X server?
+
+As of May 2001, we are recommending that you use the port of XFree86 to
+Cygwin.  This has recently stabilized, and will undoubtedly soon make
+most other MS Windows X servers obsolete.  It is what the Windows
+developers use to test the MS Windows X support.
+
+To install, go to @uref{http://xfree86.cygwin.com/}.  There is a
+detailed description on that site of exactly how to install it.  This
+installation also provides the libraries, include files, and other stuff
+needed for development; a large collection of internationalized fonts;
+the standard X utilities (xterm, twm, etc.) -- in a word, the works.
+
+NOTE: As of late May 2001, there is a bug in the file
+@file{startxwin.bat}, used to start X Windows.  It passes the option
+@samp{-engine -4} to the X server, which is bogus -- you need to edit
+the file and change it to @samp{-engine 4}.
+
+
+@node Q6.1.7, Q6.2.1, Q6.1.6, MS Windows
+@unnumberedsubsec Q6.1.7: How do I compile with X support?
+
+To compile under Cygwin, all you need to do is install XFree86
+(@pxref{Q6.1.6}).  Once installed, @file{configure} should automatically
+find the X libraries and compile with X support.
+
+As noted above, the non-Cygwin X support is basically orphaned, and
+probably won't work.  But if it want to try, it's described in
+@file{nt/README} in some detail.  Basically, you need to get X11
+libraries from ftp.x.org, and compile them.  If the precompiled versions
+are available somewhere, we don't know of it.
+
+
+@node Q6.2.1, Q6.2.2, Q6.1.7, MS Windows
 @unnumberedsec 6.2: Customization and User Interface
-@unnumberedsubsec Q6.2.1: How will the port cope with differences in the Windows user interface?
-
-XEmacs (and Emacs in general) UI is pretty
-different from what is expected of a typical MS Windows program.  How will
-the MS Windows port cope with it?
-
-Fortunately, Emacs is also one of the most configurable editor beasts
-in the world.  The MS Windows "look and feel" (mark via shift-arrow,
-self-inserting deletes region, etc.) can be easily configured via
-various packages distributed with XEmacs.  The `pending-delete'
-package is an example of such a utility.
-
-In future versions, some of these packages might be turned on by
+@unnumberedsubsec Q6.2.1: How does the port cope with differences in the Windows user interface?
+
+XEmacs (and Emacs in general) UI is pretty different from what is
+expected of a typical MS Windows program.  How does the MS Windows port
+cope with it?
+
+As a general rule, we follow native MS Windows conventions as much as
+possible.  In cases where there's a clear UI conflict, we currently use
+normal Unix XEmacs behavior by default, but make sure the MS Windows
+"look and feel" (mark via shift-arrow, self-inserting deletes region,
+Alt selects menu items, etc.) is easily configurable (respectively:
+using the variable @code{shifted-motion-keys-select-region} in 21.4 and
+above [it's in fact the default in these versions], or the
+@file{pc-select} package; using the @file{pending-del} package; and
+setting the variable @code{menu-accelerator-enabled} to
+@code{menu-force} in 21.4 and above).  In fact, if you use the sample
+@file{init.el} file as your init file, you will get all these behaviors
+automatically turned on.
+
+In future versions, some of these features might be turned on by
 default in the MS Windows environment.
 
 
 @node Q6.2.2, Q6.2.3, Q6.2.1, MS Windows
 @unnumberedsubsec Q6.2.2: How do I change fonts in XEmacs on MS Windows?
 
-In 21.2.*, use the font menu.  In 21.1.*, you can change font
-manually. For example:
+In 21.4 and above, use the font menu.  In all versions, you can change
+font manually. For example:
 
 @display
     (set-face-font 'default "Lucida Console:Regular:10")
@@ -6126,10 +6235,10 @@
 
 @node Q6.3.1, Q6.3.2, Q6.2.3, MS Windows
 @unnumberedsec 6.3: Miscellaneous
-@unnumberedsubsec Q6.3.1: Will XEmacs rename all the win32-* symbols to w32-*?
+@unnumberedsubsec Q6.3.1: Does XEmacs rename all the win32-* symbols to w32-*?
 
 In his flavor of Emacs 20, Richard Stallman has renamed all the win32-*
-symbols to w32-*.  Will XEmacs do the same?
+symbols to w32-*.  Does XEmacs do the same?
 
 We consider such a move counter-productive, thus we will not use the
 `w32' prefix.  However, we do recognize that Win32 name is little more
@@ -6161,41 +6270,32 @@
 @itemize @bullet
 
 @item
-Win-Emacs
-
-@itemize @minus
-
-@item
-Win-Emacs is a port of Lucid Emacs 19.6 to MS Windows using X
-compatibility libraries.  Win-Emacs has been written by Ben Wing.  The
-MS Windows code has not made it back to Lucid Emacs, which left Win-Emacs
-pretty much dead for our purposes.  Win-Emacs used to be available at
-Pearlsoft, but not anymore, since Pearlsoft went out of business.
-@end itemize
-
-@item
-GNU Emacs for DOS
+XEmacs
 
 @itemize @minus
 
 @item
-GNU Emacs features support for MS-DOS and DJGPP (D.J. Delorie's DOS
-port of Gcc).  Such an Emacs is heavily underfeatured, because it does
-not supports long file names, lacks proper subprocesses support, and
-is far too big compared to typical DOS editors.
-@end itemize
+Beginning with XEmacs 19.12, XEmacs' architecture was redesigned
+in such a way to allow clean support of multiple window systems.  At
+this time the TTY support was added, making X and TTY the first two
+"window systems" XEmacs supported.  The 19.12 design is the basis for
+the current native MS Windows code.
 
 @item
-GNU Emacs compiled with Win32
-
-@itemize @minus
+Some time during 1997, David Hobley (soon joined by Marc Paquette)
+imported some of the NT-specific portions of GNU Emacs, making XEmacs
+with X support compile under Windows NT, and creating the "X" port.
 
 @item
-Starting with version 19.30, it has been possible to compile GNU Emacs
-under MS Windows using the DJGPP compiler and X libraries.  The result
-is is very similar to GNU Emacs compiled under MS DOS, only it
-supports longer file names, etc.  This "port" is similar to the "X"
-flavor of XEmacs on MS Windows.
+Several months later, Jonathan Harris sent out initial patches to use
+the Win32 API, thus creating the native port.  Since then, various
+people have contributed, including Kirill M. Katsnelson (contributed
+support for menubars, subprocesses and network, as well as loads of
+other code), Andy Piper (ported XEmacs to Cygwin environment,
+contributed Windows unexec, Windows-specific glyphs and toolbars code,
+and more), Ben Wing (loads of improvements; currently the most active MS
+Windows developer), Jeff Sparkes (contributed scrollbars support) and
+many others.
 @end itemize
 
 @item
@@ -6215,36 +6315,43 @@
 @*
 @end iftex
 @uref{http://www.cs.washington.edu/homes/voelker/ntemacs.html}.
-
 @end itemize
 
 @item
-XEmacs
+Win-Emacs
 
 @itemize @minus
 
 @item
-Beginning with XEmacs 19.12, XEmacs' architecture has been redesigned
-in such a way to allow clean support of multiple window systems.  At
-this time the TTY support was added, making X and TTY the first two
-"window systems" XEmacs supported.  The 19.12 design is the basis for
-the current native MS Windows code.
+Win-Emacs was a port of Lucid Emacs 19.6 to MS Windows using X
+compatibility libraries.  Win-Emacs was written by Ben Wing.  The MS
+Windows code never made it back to Lucid Emacs, and its creator (Pearl
+Software) has long since gone out of business.
+@end itemize
+
+@item
+GNU Emacs for DOS
+
+@itemize @minus
 
 @item
-Some time during 1997, David Hobley (soon joined by Marc Paquette)
-imported some of the NT-specific portions of GNU Emacs, making XEmacs
-with X support compile under Windows NT, and creating the "X" port.
+GNU Emacs features support for MS-DOS and DJGPP (D.J. Delorie's DOS
+port of Gcc).  Such an Emacs is heavily underfeatured, because it does
+not support long file names, lacks proper subprocesses support, and
+is far too big compared to typical DOS editors.
+@end itemize
 
 @item
-Several months later, Jonathan Harris sent out initial patches to use
-the Win32 API, thus creating the native port.  Since then, various
-people have contributed, including Kirill M. Katsnelson (contributed
-support for menubars, subprocesses and network, as well as loads of
-other code), Andy Piper (ported XEmacs to Cygwin environment,
-contributed Windows unexec, Windows-specific glyphs and toolbars code,
-and more), Jeff Sparkes (contributed scrollbars support) and many
-others.
-
+GNU Emacs compiled with Win32
+
+@itemize @minus
+
+@item
+Starting with version 19.30, it has been possible to compile GNU Emacs
+under MS Windows using the DJGPP compiler and X libraries.  The result
+is is very similar to GNU Emacs compiled under MS DOS, only it
+supports longer file names, etc.  This "port" is similar to the "X"
+flavor of XEmacs on MS Windows.
 @end itemize
 
 @end itemize
@@ -6253,7 +6360,7 @@
 @node Q6.3.3, Q6.4.1, Q6.3.2, MS Windows
 @unnumberedsubsec Q6.3.3: What is the porting team doing at the moment?
 
-(as of March 2001)
+(as of June 2001)
 
 The porting team is continuing work on the MS Windows-specific code.
 Major projects are the development of Mule (internationalization)
@@ -6261,6 +6368,7 @@
 support for dialog boxes, buttons, edit fields, and similar UI
 elements).
 
+
 @node Q6.4.1, ,Q6.3.3, MS Windows
 @unnumberedsec 6.3: Troubleshooting
 @unnumberedsubsec Q6.4.1 XEmacs won't start on Windows. (NEW)
@@ -6269,24 +6377,18 @@
 executable. Under MS-Windows this process effectively fixes the memory
 addresses of information in the executable. When XEmacs starts up it tries
 to reserve these memory addresses so that the dumping process can be
-reversed - putting the information back at the correct addresses.
-Unfortunately some .dlls (For instance the soundblaster driver) occupy
+reversed -- putting the information back at the correct addresses.
+Unfortunately some .DLLs (for instance the soundblaster driver) occupy
 memory addresses that can conflict with those needed by the dumped XEmacs
 executable. In this instance XEmacs will fail to start without any
 explanation. Note that this is extremely machine specific.
 
 21.1.10 includes a fix for this that makes more intelligent guesses
 about which memory addresses will be free, and this should cure the
-problem for most people.  Unfortunately, no binary is yet available for
-this version.  Check back periodically at
-
-@uref{ftp://ftp.xemacs.org/pub/xemacs/binaries/}.
-
-21.2 implements "portable dumping" which will eliminate the problem
-altogether.  You might have better luck with the 21.2 beta binary,
-available at
-
-@uref{ftp://ftp.xemacs.org/pub/xemacs/beta/binaries/}.
+problem for most people.  21.4 implements "portable dumping", which
+eliminates the problem altogether.  We recommend you use the 21.4
+binaries, but you can use the 21.1 binaries if you are very paranoid
+about stability.  @xref{Q6.0.3}.
 
 
 @node Current Events,  , MS Windows, Top
--- a/src/ChangeLog	Thu May 31 12:03:39 2001 +0000
+++ b/src/ChangeLog	Thu May 31 12:45:41 2001 +0000
@@ -1,3 +1,140 @@
+2001-05-30  Ben Wing  <ben@xemacs.org>
+
+	* s\cygwin32.h:
+	Don't unilaterally include ntplay, but only when we're compiling
+	with native sound (look in configure now).
+
+2001-05-30  Ben Wing  <ben@xemacs.org>
+
+	For 21.4:
+
+	(Stephen, just take all event-msw.c patches.  This includes
+	the "iconify" fix below.)
+
+	* event-msw.c:
+	* event-msw.c (mswindows_dequeue_dispatch_event):
+	* event-msw.c (assert):
+	* event-msw.c (emacs_mswindows_quit_p):
+	* event-msw.c (debug_mswin_messages):
+	* event-msw.c (debug_output_mswin_message):
+	* event-msw.c (vars_of_event_mswindows):
+	Fix yet more problems with C-g handling.
+	Implement debug-mswindows-events.
+	
+	For 21.5:
+	
+	* event-stream.c:
+	* event-stream.c (add_low_level_timeout):
+	* event-stream.c (event_stream_generate_wakeup):
+	* event-stream.c (event_stream_resignal_wakeup):
+	* event-stream.c (event_stream_disable_wakeup):
+	* event-stream.c (event_stream_wakeup_pending_p):
+	* events.h:
+	* signal.c:
+	* signal.c (handle_async_timeout_signal):
+	* signal.c (signal_remove_async_interval_timeout):
+	* signal.c (alarm):
+	* signal.c (Fwaiting_for_user_input_p):
+	* signal.c (start_interrupts):
+	* signal.c (establish_slow_interrupt_timer):
+	* signal.c (slow_down_interrupts):
+	* signal.c (check_what_happened):
+	* signal.c (alarm_signal):
+	* signal.c (interrupt_signal):
+	* sysdep.h:
+	Rearrange the signal-handling code to eliminate the former
+	spaghetti logic paths in it.  Document clearly what
+	"low-level" and "high-level" timeouts are.  Rename some
+	functions with unclear names (e.g. "...alarm...") to names
+	that reflect what they actually do (e.g. "...async_timeout...").
+	Fix numerous bugs discovered in the process.
+
+	* console-x.h:
+	* event-Xt.c:
+	* event-Xt.c (update_frame_iconify_status):
+	* event-Xt.c (handle_map_event):
+	* event-Xt.c (emacs_Xt_handle_magic_event):
+	* event-Xt.c (emacs_Xt_event_pending_p):
+	* event-msw.c:
+	* frame-x.c:
+	* frame-x.c (x_frame_window_state):
+	* frame-x.c (x_frame_iconified_p):
+	* frame-x.c (x_frame_visible_p):
+	Hopefully make XEmacs properly maintain the "iconified"
+	state on frames at all times.  This should fix the "can't
+	delete a frame with C-x 5 0 when there's another iconified
+	frame out there" bug.
+
+	Put a notice in of further changes that should probably
+	be made to clean up the frame-visibility support.
+	(especially directed at Jan Vroonhof)
+
+	* lisp.h:
+	* miscplay.c (sndcnv8S_2mono):
+	* miscplay.c (sndcnv2monounsigned):
+	* miscplay.c (int2ulaw):
+	* miscplay.c (sndcnv2byteLE):
+	* miscplay.c (sndcnv2byteBE):
+	* miscplay.c (sndcnv2monobyteLE):
+	* miscplay.c (sndcnv2monobyteBE):
+	Rename SBufbyte to CBufbyte to avoid a misleading name.
+	Eliminate UChar, which is not used anywhere and contributes
+	no semantic info.  Add a comment about the documentation-only
+	properties of the char/unsigned char typedefs.  Add
+	SChar_Binary as an explicitly `signed' version of Char_Binary
+	and put back the `signed' declarations in miscplay.c.
+	
+	* alloc.c (build_string):
+	* alloc.c (build_ext_string):
+	* alloc.c (build_translated_string):
+	Use char typedefs.
+
+	* console-msw.c (mswindows_lisp_error):
+	* device-msw.c (sync_printer_with_devmode):
+	* device-msw.c (handle_devmode_changes):
+	* device-msw.c (Fmsprinter_select_settings):
+	* device-msw.c (Fmswindows_printer_list):
+	* dialog-msw.c:
+	* dialog-msw.c (ALIGN_TEMPLATE):
+	* dialog-msw.c (handle_question_dialog_box):
+	* editfns.c (user_login_name):
+	* fileio.c (Ffile_readable_p):
+	* glyphs-eimage.c (tiff_memory_seek):
+	* menubar-msw.c (mswindows_translate_menu_or_dialog_item):
+	* menubar-msw.c (populate_menu_add_item):
+	* ntplay.c:
+	* ntplay.c (DONT_ENCAPSULATE):
+	* ntplay.c (play_sound_file):
+	* ntplay.c (play_sound_data_1):
+	* objects-msw.c (initialize_font_instance):
+	* objects-msw.c (mswindows_list_fonts):
+	* realpath.c (cygwin_readlink):
+	* redisplay-msw.c (mswindows_text_width_single_run):
+	* select-msw.c (symbol_to_ms_cf):
+	* select-msw.c (mswindows_register_selection_data_type):
+	* syswindows.h (LOCAL_TO_WIN32_FILE_FORMAT):
+	* syswindows.h (WIN32_TO_LOCAL_FILE_FORMAT):
+	* win32.c (Fmswindows_shell_execute):
+	Eliminate numerous C++ errors.
+
+	* frame-msw.c (mswindows_set_title_from_bufbyte):
+	Eliminate numerous C++ errors and Mule-ize.
+
+	* glyphs-msw.c (convert_EImage_to_DIBitmap):
+	* glyphs-msw.c (mswindows_init_image_instance_from_eimage):
+	* glyphs-msw.c (set_mono_pixel):
+	* glyphs-msw.c (mswindows_initialize_image_instance_mask):
+	* glyphs-msw.c (xpm_to_eimage):
+	* glyphs-msw.c (mswindows_xpm_instantiate):
+	* glyphs-msw.c (read_bitmap_data):
+	* glyphs-msw.c (read_bitmap_data_from_file):
+	* glyphs-msw.c (xbm_create_bitmap_from_data):
+	* glyphs-msw.c (init_image_instance_from_xbm_inline):
+	* glyphs-msw.c (xbm_instantiate_1):
+	* glyphs-msw.c (mswindows_xbm_instantiate):
+	* glyphs-msw.c (mswindows_xface_instantiate):
+	Eliminate numerous C++ errors and use char typedefs.
+
 2001-05-29  Adrian Aichner  <adrian@xemacs.org>
 
 	* fileio.c: Include nt.h.  Remove lisp_string_set_file_times()
--- a/src/alloc.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/alloc.c	Thu May 31 12:45:41 2001 +0000
@@ -2109,14 +2109,14 @@
 }
 
 Lisp_Object
-build_string (const char *str)
+build_string (const CBufbyte *str)
 {
   /* Some strlen's crash and burn if passed null. */
   return make_string ((const Bufbyte *) str, (str ? strlen(str) : 0));
 }
 
 Lisp_Object
-build_ext_string (const char *str, Lisp_Object coding_system)
+build_ext_string (const Extbyte *str, Lisp_Object coding_system)
 {
   /* Some strlen's crash and burn if passed null. */
   return make_ext_string ((const Extbyte *) str, (str ? strlen(str) : 0),
@@ -2124,7 +2124,7 @@
 }
 
 Lisp_Object
-build_translated_string (const char *str)
+build_translated_string (const CBufbyte *str)
 {
   return build_string (GETTEXT (str));
 }
--- a/src/console-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/console-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -578,7 +578,7 @@
   TO_INTERNAL_FORMAT (C_STRING, lpMsgBuf, ALLOCA, (inres, len),
 		      Qmswindows_tstr);
   /* Messages tend to end with a period and newline */
-  if (len >= 3 && !strcmp (inres + len - 3, ".\r\n"))
+  if (len >= 3 && !bufbyte_strcmp (inres + len - 3, ".\r\n"))
     len -= 3;
   result = make_string (inres, len);
   
--- a/src/console-x.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/console-x.h	Thu May 31 12:45:41 2001 +0000
@@ -427,6 +427,9 @@
 int x_initialize_frame_menubar (struct frame *f);
 void x_init_modifier_mapping (struct device *d);
 
+int x_frame_window_state (struct frame *f);
+
+
 #define X_ERROR_OCCURRED(dpy, body)	\
      (expect_x_error (dpy), body, x_error_occurred_p (dpy))
 
--- a/src/device-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/device-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -572,7 +572,7 @@
 	     Nothing wrong on the Windows side, just forge a unique
 	     connection name. Use the memory address of d as a unique
 	     suffix. */
-	  char* new_connext = alloca (strlen (devname + 11));
+	  Extbyte *new_connext = (Extbyte *) alloca (strlen (devname + 11));
 	  sprintf (new_connext, "%s:%X", devname, d->header.uid);
 	  new_connection = build_ext_string (devname, Qmswindows_tstr);
 	}
@@ -616,7 +616,7 @@
   DEVMODE* devmode = (DEVMODE*) GlobalLock (hDevMode);
 
   /* Size and name may have changed */
-  ldm->devmode = xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
+  ldm->devmode = (DEVMODE *) xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
   if (new_name)
     {
       if (ldm->printer_name)
@@ -941,7 +941,7 @@
 		      device);
 
       assert (XDEVMODE_SIZE (ldm) <= dm_size);
-      ldm->devmode = xrealloc (ldm->devmode, dm_size);
+      ldm->devmode = (DEVMODE *) xrealloc (ldm->devmode, dm_size);
     }
 
   /* If we bail out on signal here, no damage is done, except that
@@ -1222,7 +1222,7 @@
   if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
     signal_enum_printer_error ();
 
-  data_buf = alloca (bytes_needed);
+  data_buf = (BYTE *) alloca (bytes_needed);
   ok = EnumPrinters (enum_flags, NULL, enum_level, data_buf, bytes_needed,
 		     &bytes_needed, &num_printers);
   if (!ok)
--- a/src/dialog-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/dialog-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -42,7 +42,6 @@
 static Lisp_Object Q_initial_directory;
 static Lisp_Object Q_initial_filename;
 static Lisp_Object Q_filter_list;
-static Lisp_Object Q_title;
 static Lisp_Object Q_allow_multi_select;
 static Lisp_Object Q_create_prompt_on_nonexistent;
 static Lisp_Object Q_overwrite_prompt;
@@ -286,11 +285,11 @@
 }
 
 
-#define ALIGN_TEMPLATE					\
-{							\
-  unsigned int slippage = Dynarr_length (template) & 3;	\
-  if (slippage)						\
-    Dynarr_add_many (template, &zeroes, slippage);	\
+#define ALIGN_TEMPLATE						\
+{								\
+  unsigned int slippage = Dynarr_length (template_) & 3;	\
+  if (slippage)							\
+    Dynarr_add_many (template_, &zeroes, slippage);		\
 }
 
 static struct
@@ -413,7 +412,7 @@
 handle_question_dialog_box (struct frame *f, Lisp_Object keys)
 {
   Lisp_Object_dynarr *dialog_items = Dynarr_new (Lisp_Object);
-  unsigned_char_dynarr *template = Dynarr_new (unsigned_char);
+  unsigned_char_dynarr *template_ = Dynarr_new (unsigned_char);
   unsigned int button_row_width = 0;
   unsigned int text_width, text_height;
   Lisp_Object question = Qnil, title = Qnil;
@@ -422,7 +421,7 @@
   record_unwind_protect (free_dynarr_opaque_ptr,
 			 make_opaque_ptr (dialog_items));
   record_unwind_protect (free_dynarr_opaque_ptr,
-			 make_opaque_ptr (template));
+			 make_opaque_ptr (template_));
 
   /* A big NO NEED to GCPRO gui_items stored in the array: they are just
      pointers into KEYS list, which is GC-protected by the caller */
@@ -543,20 +542,20 @@
     dlg_tem.cx = text_width + 2 * X_TEXT_FROM_EDGE;
     dlg_tem.cy = (Y_TEXT_FROM_EDGE + text_height + Y_TEXT_FROM_BUTTON
 		  + Y_BUTTON + Y_BUTTON_FROM_EDGE);
-    Dynarr_add_many (template, &dlg_tem, sizeof (dlg_tem));
+    Dynarr_add_many (template_, &dlg_tem, sizeof (dlg_tem));
 
     /* We want no menu and standard class */
-    Dynarr_add_many (template, &zeroes, 4);
+    Dynarr_add_many (template_, &zeroes, 4);
 
     /* And the third is the dialog title. "XEmacs" unless one is supplied.
        Note that the string must be in Unicode. */
     if (NILP (title))
-      Dynarr_add_many (template, L"XEmacs", 14);
+      Dynarr_add_many (template_, L"XEmacs", 14);
     else
-      push_lisp_string_as_unicode (template, title);
+      push_lisp_string_as_unicode (template_, title);
 
     /* We want standard dialog font */
-    Dynarr_add_many (template, L"\x08MS Shell Dlg", 28);
+    Dynarr_add_many (template_, L"\x08MS Shell Dlg", 28);
 
     /* Next add text control. */
     item_tem.style = WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX;
@@ -568,17 +567,17 @@
     item_tem.id = 0xFFFF;
 
     ALIGN_TEMPLATE;
-    Dynarr_add_many (template, &item_tem, sizeof (item_tem));
+    Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
 
     /* Right after class id follows */
-    Dynarr_add_many (template, &ones, 2);
-    Dynarr_add_many (template, &static_class_id, sizeof (static_class_id));
+    Dynarr_add_many (template_, &ones, 2);
+    Dynarr_add_many (template_, &static_class_id, sizeof (static_class_id));
 
     /* Next thing to add is control text, as Unicode string */
-    push_lisp_string_as_unicode (template, question);
+    push_lisp_string_as_unicode (template_, question);
 
     /* Specify 0 length creation data */
-    Dynarr_add_many (template, &zeroes, 2);
+    Dynarr_add_many (template_, &zeroes, 2);
 
     /* Now it's the button time */
     item_tem.y = Y_TEXT_FROM_EDGE + text_height + Y_TEXT_FROM_BUTTON;
@@ -601,11 +600,12 @@
 	item_tem.id = i + ID_ITEM_BIAS;
 
 	ALIGN_TEMPLATE;
-	Dynarr_add_many (template, &item_tem, sizeof (item_tem));
+	Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
 
 	/* Right after 0xFFFF and class id atom follows */
-	Dynarr_add_many (template, &ones, 2);
-	Dynarr_add_many (template, &button_class_id, sizeof (button_class_id));
+	Dynarr_add_many (template_, &ones, 2);
+	Dynarr_add_many (template_, &button_class_id,
+			 sizeof (button_class_id));
 
 	/* Next thing to add is control text, as Unicode string */
 	{
@@ -621,11 +621,11 @@
 					       2 * XSTRING_LENGTH (ctext) + 3,
 					       &accel_unused,
 					       ctext);
-	  push_bufbyte_string_as_unicode (template, trans, translen);
+	  push_bufbyte_string_as_unicode (template_, trans, translen);
 	}
 
 	/* Specify 0 length creation data. */
-	Dynarr_add_many (template, &zeroes, 2);
+	Dynarr_add_many (template_, &zeroes, 2);
 
 	item_tem.x += item_tem.cx + X_BUTTON_SPACING;
       }
@@ -654,7 +654,7 @@
     /* Woof! Everything is ready. Pop pop pop in now! */
     did->hwnd =
       CreateDialogIndirectParam (NULL,
-				 (LPDLGTEMPLATE) Dynarr_atp (template, 0),
+				 (LPDLGTEMPLATE) Dynarr_atp (template_, 0),
 				 FRAME_MSWINDOWS_HANDLE (f), dialog_proc,
 				 (LPARAM) LISP_TO_VOID (dialog_data));
     if (!did->hwnd)
--- a/src/editfns.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/editfns.c	Thu May 31 12:45:41 2001 +0000
@@ -740,7 +740,8 @@
 	     return "unknown" instead of the null if the username
 	     cannot be determined.
 	  */
-	  return pw ? pw->pw_name : "unknown";
+	  /* !!#### fix up in my mule ws */
+	  return pw ? pw->pw_name : (char *) "unknown";
 #else
 	  /* For all but Cygwin return NULL (nil) */
 	  return pw ? pw->pw_name : NULL;
--- a/src/event-Xt.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/event-Xt.c	Thu May 31 12:45:41 2001 +0000
@@ -1668,11 +1668,46 @@
 }
 
 static void
+update_frame_iconify_status (struct frame *f)
+{
+  f->iconified = (x_frame_window_state (f) == IconicState);
+}
+
+static void
 handle_map_event (struct frame *f, XEvent *event)
 {
   Lisp_Object frame;
 
   XSETFRAME (frame, f);
+
+  /* It seems that, given the multiplicity of window managers and X
+     implementations, plus the fact that X was designed without
+     window managers or icons in mind and this was then grafted on
+     with about the skill of a drunk freshman med student attempting
+     surgery with a rusty razor blade, we cannot treat any off
+     MapNotify/UnmapNotify/VisibilityNotify as more than vague hints
+     as to the actual situation.
+
+     So we should just query the actual status.  Unfortunately, things
+     are worse because (a) there aren't obvious ways to query some
+     of these values (e.g. "totally visible"), and (b) there may be
+     race conditions (see below).
+
+     However, according the the ICCCM, there's a specific way to
+     ask the window manager whether the state is (a) visible,
+     (b) iconic, (c) withdrawn.  It must be one of these three.
+     We already use this call to check for the iconified state.
+     I'd suggest we do the same for visible (i.e. NormalState),
+     and scrap most of the nasty code below.
+
+     --ben
+     */
+
+  update_frame_iconify_status (f);
+
+  /* #### Ben suggests rewriting the code below using
+     x_frame_window_state (f). */
+
   if (event->type == MapNotify)
     {
       XWindowAttributes xwa;
@@ -1691,12 +1726,7 @@
       XGetWindowAttributes (event->xany.display, event->xmap.window,
 			    &xwa);
       if (xwa.map_state != IsViewable)
-	{
-	  /* Calling Fframe_iconified_p is the only way we have to
-             correctly update FRAME_ICONIFIED_P */
-	  Fframe_iconified_p (frame);
-	  return;
-	}
+	return;
 
       FRAME_X_TOTALLY_VISIBLE_P (f) = 1;
 #if 0
@@ -1731,9 +1761,6 @@
     {
       FRAME_X_TOTALLY_VISIBLE_P (f) = 0;
       change_frame_visibility (f, 0);
-      /* Calling Fframe_iconified_p is the only way we have to
-         correctly update FRAME_ICONIFIED_P */
-      Fframe_iconified_p (frame);
     }
 }
 
@@ -1932,6 +1959,11 @@
     case VisibilityNotify: /* window visibility has changed */
       if (event->xvisibility.window == XtWindow (FRAME_X_SHELL_WIDGET (f)))
 	{
+	  /* See comment in handle_map_event */
+	  update_frame_iconify_status (f);
+
+	  /* #### Ben suggests rewriting the code below using
+	     x_frame_window_state (f). */
 	  FRAME_X_TOTALLY_VISIBLE_P (f) =
 	    (event->xvisibility.state == VisibilityUnobscured);
 	  /* Note that the fvwm pager only sends VisibilityNotify when
@@ -2987,21 +3019,20 @@
     }
 
   /* XtAppPending() can be super-slow, esp. over a network connection.
-     Quantify results have indicated that in some cases the
-     call to detect_input_pending() completely dominates the
-     running time of redisplay().  Fortunately, in a SIGIO world
-     we can more quickly determine whether there are any X events:
-     if an event has happened since the last time we checked, then
-     a SIGIO will have happened.  On a machine with broken SIGIO,
-     we'll still be in an OK state -- the sigio_happened flag
-     will get set at least once a second, so we'll be no more than
-     one second behind reality. (In general it's OK if we
-     erroneously report no input pending when input is actually
-     pending() -- preemption is just a bit less efficient, that's
-     all.  It's bad bad bad if you err the other way -- you've
-     promised that `next-event' won't block but it actually will,
-     and some action might get delayed until the next time you
-     hit a key.)
+     Quantify results have indicated that in some cases the call to
+     detect_input_pending() completely dominates the running time of
+     redisplay().  Fortunately, in a SIGIO world we can more quickly
+     determine whether there are any X events: if an event has
+     happened since the last time we checked, then a SIGIO will have
+     happened.  On a machine with broken SIGIO, we'll still be in an
+     OK state -- quit_check_signal_tick_count will get ticked at least
+     every 1/4 second, so we'll be no more than that much behind
+     reality. (In general it's OK if we erroneously report no input
+     pending when input is actually pending() -- preemption is just a
+     bit less efficient, that's all.  It's bad bad bad if you err the
+     other way -- you've promised that `next-event' won't block but it
+     actually will, and some action might get delayed until the next
+     time you hit a key.)
      */
 
   /* quit_check_signal_tick_count is volatile so try to avoid race conditions
--- a/src/event-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/event-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -151,6 +151,9 @@
 
 #ifdef DEBUG_XEMACS
 Fixnum debug_mswindows_events;
+
+static void debug_output_mswin_message (HWND hwnd, UINT message_,
+					WPARAM wParam, LPARAM lParam);
 #endif
 
 /* This is the event signaled by the event pump.
@@ -1047,14 +1050,11 @@
 			 &mswindows_s_dispatch_event_queue_tail :
 			 &mswindows_u_dispatch_event_queue_tail);
 
-  sevt = XEVENT(event);
+  sevt = XEVENT (event);
   if (sevt->event_type == key_press_event
       && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
-    {
-      sevt->event.key.modifiers &=
-	~(FAKE_MOD_QUIT | FAKE_MOD_QUIT_CRITICAL);
-      --mswindows_quit_chars_count;
-    }
+    sevt->event.key.modifiers &=
+      ~(FAKE_MOD_QUIT | FAKE_MOD_QUIT_CRITICAL);
 
   return event;
 }
@@ -2064,7 +2064,15 @@
   /* Not perfect but avoids crashes. There is potential for wierd
      behavior here. */
   if (gc_in_progress)
-    goto defproc;
+    {
+      stderr_out ("Window procedure called during GC???????\n");
+      goto defproc;
+    }
+
+#ifdef DEBUG_XEMACS
+  if (debug_mswindows_events)
+    debug_output_mswin_message (hwnd, message_, wParam, lParam);
+#endif /* DEBUG_XEMACS */
 
   assert (!GetWindowLong (hwnd, GWL_USERDATA));
   switch (message_)
@@ -2100,13 +2108,8 @@
 	int should_set_keymap = 0;
 
 #ifdef DEBUG_XEMACS
-	if (debug_mswindows_events)
-	  {
-	    stderr_out ("%s wparam=%d lparam=%d\n",
-			message_ == WM_KEYUP ? "WM_KEYUP" : "WM_SYSKEYUP",
-			wParam, (int)lParam);
-	    output_alt_keyboard_state ();
-	  }
+	if (debug_mswindows_events > 2)
+	  output_alt_keyboard_state ();
 #endif /* DEBUG_XEMACS */
 
 	mswindows_handle_sticky_modifiers (wParam, lParam, 0, 1);
@@ -2157,13 +2160,8 @@
 	int sticky_changed;
 
 #ifdef DEBUG_XEMACS
-	if (debug_mswindows_events)
-	  {
-	    stderr_out ("%s wparam=%d lparam=%d\n",
-			message_ == WM_KEYDOWN ? "WM_KEYDOWN" : "WM_SYSKEYDOWN",
-			wParam, (int)lParam);
-	    output_alt_keyboard_state ();
-	  }
+	if (debug_mswindows_events > 2)
+	  output_alt_keyboard_state ();
 #endif /* DEBUG_XEMACS */
 
 	GetKeyboardState (keymap_orig);
@@ -2258,6 +2256,16 @@
 		int mods_with_quit = mods;
 		WPARAM ch = tranmsg.wParam;
 
+#ifdef DEBUG_XEMACS
+		if (debug_mswindows_events)
+		  {
+		    stderr_out ("-> ");
+		    debug_output_mswin_message (tranmsg.hwnd, tranmsg.message,
+						tranmsg.wParam,
+						tranmsg.lParam);
+		  }
+#endif /* DEBUG_XEMACS */
+
 		/* If a quit char with no modifiers other than control and
 		   shift, then mark it with a fake modifier, which is removed
 		   upon dequeueing the event */
@@ -2276,7 +2284,7 @@
 		    mods_with_quit |= FAKE_MOD_QUIT;
 		    if (mods_with_shift & XEMACS_MOD_SHIFT)
 		      mods_with_quit |= FAKE_MOD_QUIT_CRITICAL;
-		    ++mswindows_quit_chars_count;
+		    mswindows_quit_chars_count++;
 		  }
 		else if (potential_accelerator && !got_accelerator &&
 			 mswindows_char_is_accelerator (frame, ch))
@@ -2606,6 +2614,33 @@
       mswindows_handle_paint (XFRAME (mswindows_find_frame (hwnd)));
       break;
 
+    case WM_WINDOWPOSCHANGED:
+      /* This is sent before WM_SIZE; in fact, the processing of this
+	 by DefWindowProc() sends WM_SIZE.  But WM_SIZE is not sent when
+	 a window is hidden (make-frame-invisible), so we need to process
+	 this and update the state flags. */
+      {
+	fobj = mswindows_find_frame (hwnd);
+	frame = XFRAME (fobj);
+	if (IsIconic (hwnd))
+	  {
+	    FRAME_VISIBLE_P (frame) = 0;
+	    FRAME_ICONIFIED_P (frame) = 1;
+	  }
+	else if (IsWindowVisible (hwnd))
+	  {
+	    FRAME_VISIBLE_P (frame) = 1;
+	    FRAME_ICONIFIED_P (frame) = 0;
+	  }
+	else
+	  {
+	    FRAME_VISIBLE_P (frame) = 0;
+	    FRAME_ICONIFIED_P (frame) = 0;
+	  }	    
+
+	return DefWindowProc (hwnd, message_, wParam, lParam);
+      }
+
     case WM_SIZE:
       /* We only care about this message if our size has really changed */
       if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
@@ -2624,7 +2659,6 @@
 	  if (wParam==SIZE_MINIMIZED)
 	    {
 	      /* Iconified */
-	      FRAME_VISIBLE_P (frame) = 0;
 	      mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
 	    }
 	  else
@@ -2660,7 +2694,6 @@
 		{
 		  if (!msframe->sizing && !FRAME_VISIBLE_P (frame))
 		    mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
-		  FRAME_VISIBLE_P (frame) = 1;
 
 		  if (!msframe->sizing || mswindows_dynamic_frame_resize)
 		    redisplay ();
@@ -3475,6 +3508,7 @@
   if (mswindows_in_modal_loop)
     return;
 
+  mswindows_quit_chars_count = 0;
   /* Drain windows queue.  This sets up number of quit characters in
      the queue. */
   mswindows_drain_windows_queue ();
@@ -3489,7 +3523,7 @@
       match_against.event_type = key_press_event;
       match_against.event.key.modifiers = FAKE_MOD_QUIT;
 
-      while (mswindows_quit_chars_count-- > 0)
+      while (mswindows_quit_chars_count > 0)
 	{
 	  emacs_event = mswindows_cancel_dispatch_event (&match_against);
 	  assert (!NILP (emacs_event));
@@ -3499,6 +3533,7 @@
 	    critical_p = 1;
 
 	  Fdeallocate_event (emacs_event);
+	  mswindows_quit_chars_count--;
 	}
 
       Vquit_flag = critical_p ? Qcritical : Qt;
@@ -3634,6 +3669,318 @@
 }
 #endif
 
+#ifdef DEBUG_XEMACS
+
+struct mswin_message_debug
+{
+  int mess;
+  char *string;
+};
+
+#define FROB(val) { val, #val, },
+
+struct mswin_message_debug debug_mswin_messages[] =
+{
+FROB (WM_NULL)
+FROB (WM_CREATE)
+FROB (WM_DESTROY)
+FROB (WM_MOVE)
+FROB (WM_SIZE)
+
+FROB (WM_ACTIVATE)
+
+FROB (WM_SETFOCUS)
+FROB (WM_KILLFOCUS)
+FROB (WM_ENABLE)
+FROB (WM_SETREDRAW)
+FROB (WM_SETTEXT)
+FROB (WM_GETTEXT)
+FROB (WM_GETTEXTLENGTH)
+FROB (WM_PAINT)
+FROB (WM_CLOSE)
+FROB (WM_QUERYENDSESSION)
+FROB (WM_QUIT)
+FROB (WM_QUERYOPEN)
+FROB (WM_ERASEBKGND)
+FROB (WM_SYSCOLORCHANGE)
+FROB (WM_ENDSESSION)
+FROB (WM_SHOWWINDOW)
+FROB (WM_WININICHANGE)
+#if(WINVER >= 0x0400)
+FROB (WM_SETTINGCHANGE)
+#endif /* WINVER >= 0x0400 */
+
+FROB (WM_DEVMODECHANGE)
+FROB (WM_ACTIVATEAPP)
+FROB (WM_FONTCHANGE)
+FROB (WM_TIMECHANGE)
+FROB (WM_CANCELMODE)
+FROB (WM_SETCURSOR)
+FROB (WM_MOUSEACTIVATE)
+FROB (WM_CHILDACTIVATE)
+FROB (WM_QUEUESYNC)
+
+FROB (WM_GETMINMAXINFO)
+
+FROB (WM_PAINTICON)
+FROB (WM_ICONERASEBKGND)
+FROB (WM_NEXTDLGCTL)
+FROB (WM_SPOOLERSTATUS)
+FROB (WM_DRAWITEM)
+FROB (WM_MEASUREITEM)
+FROB (WM_DELETEITEM)
+FROB (WM_VKEYTOITEM)
+FROB (WM_CHARTOITEM)
+FROB (WM_SETFONT)
+FROB (WM_GETFONT)
+FROB (WM_SETHOTKEY)
+FROB (WM_GETHOTKEY)
+FROB (WM_QUERYDRAGICON)
+FROB (WM_COMPAREITEM)
+#if(WINVER >= 0x0500)
+FROB (WM_GETOBJECT)
+#endif /* WINVER >= 0x0500 */
+FROB (WM_COMPACTING)
+FROB (WM_COMMNOTIFY)
+FROB (WM_WINDOWPOSCHANGING)
+FROB (WM_WINDOWPOSCHANGED)
+
+FROB (WM_POWER)
+
+FROB (WM_COPYDATA)
+FROB (WM_CANCELJOURNAL)
+
+#if(WINVER >= 0x0400)
+FROB (WM_NOTIFY)
+FROB (WM_INPUTLANGCHANGEREQUEST)
+FROB (WM_INPUTLANGCHANGE)
+FROB (WM_TCARD)
+FROB (WM_HELP)
+FROB (WM_USERCHANGED)
+FROB (WM_NOTIFYFORMAT)
+
+FROB (WM_CONTEXTMENU)
+FROB (WM_STYLECHANGING)
+FROB (WM_STYLECHANGED)
+FROB (WM_DISPLAYCHANGE)
+FROB (WM_GETICON)
+FROB (WM_SETICON)
+#endif /* WINVER >= 0x0400 */
+
+FROB (WM_NCCREATE)
+FROB (WM_NCDESTROY)
+FROB (WM_NCCALCSIZE)
+FROB (WM_NCHITTEST)
+FROB (WM_NCPAINT)
+FROB (WM_NCACTIVATE)
+FROB (WM_GETDLGCODE)
+FROB (WM_SYNCPAINT)
+FROB (WM_NCMOUSEMOVE)
+FROB (WM_NCLBUTTONDOWN)
+FROB (WM_NCLBUTTONUP)
+FROB (WM_NCLBUTTONDBLCLK)
+FROB (WM_NCRBUTTONDOWN)
+FROB (WM_NCRBUTTONUP)
+FROB (WM_NCRBUTTONDBLCLK)
+FROB (WM_NCMBUTTONDOWN)
+FROB (WM_NCMBUTTONUP)
+FROB (WM_NCMBUTTONDBLCLK)
+
+/* FROB (WM_KEYFIRST) */
+FROB (WM_KEYDOWN)
+FROB (WM_KEYUP)
+FROB (WM_CHAR)
+FROB (WM_DEADCHAR)
+FROB (WM_SYSKEYDOWN)
+FROB (WM_SYSKEYUP)
+FROB (WM_SYSCHAR)
+FROB (WM_SYSDEADCHAR)
+FROB (WM_KEYLAST)
+
+#if(WINVER >= 0x0400)
+FROB (WM_IME_STARTCOMPOSITION)
+FROB (WM_IME_ENDCOMPOSITION)
+FROB (WM_IME_COMPOSITION)
+FROB (WM_IME_KEYLAST)
+#endif /* WINVER >= 0x0400 */
+
+FROB (WM_INITDIALOG)
+FROB (WM_COMMAND)
+FROB (WM_SYSCOMMAND)
+FROB (WM_TIMER)
+FROB (WM_HSCROLL)
+FROB (WM_VSCROLL)
+FROB (WM_INITMENU)
+FROB (WM_INITMENUPOPUP)
+FROB (WM_MENUSELECT)
+FROB (WM_MENUCHAR)
+FROB (WM_ENTERIDLE)
+#if(WINVER >= 0x0500)
+FROB (WM_MENURBUTTONUP)
+FROB (WM_MENUDRAG)
+FROB (WM_MENUGETOBJECT)
+FROB (WM_UNINITMENUPOPUP)
+FROB (WM_MENUCOMMAND)
+#endif /* WINVER >= 0x0500 */
+
+
+FROB (WM_CTLCOLORMSGBOX)
+FROB (WM_CTLCOLOREDIT)
+FROB (WM_CTLCOLORLISTBOX)
+FROB (WM_CTLCOLORBTN)
+FROB (WM_CTLCOLORDLG)
+FROB (WM_CTLCOLORSCROLLBAR)
+FROB (WM_CTLCOLORSTATIC)
+
+
+/* FROB (WM_MOUSEFIRST) */
+FROB (WM_MOUSEMOVE)
+FROB (WM_LBUTTONDOWN)
+FROB (WM_LBUTTONUP)
+FROB (WM_LBUTTONDBLCLK)
+FROB (WM_RBUTTONDOWN)
+FROB (WM_RBUTTONUP)
+FROB (WM_RBUTTONDBLCLK)
+FROB (WM_MBUTTONDOWN)
+FROB (WM_MBUTTONUP)
+FROB (WM_MBUTTONDBLCLK)
+
+#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
+FROB (WM_MOUSEWHEEL)
+FROB (WM_MOUSELAST)
+#else
+FROB (WM_MOUSELAST)
+#endif /* if (_WIN32_WINNT < 0x0400) */
+
+FROB (WM_PARENTNOTIFY)
+FROB (WM_ENTERMENULOOP)
+FROB (WM_EXITMENULOOP)
+
+#if(WINVER >= 0x0400)
+FROB (WM_NEXTMENU)
+
+FROB (WM_SIZING)
+FROB (WM_CAPTURECHANGED)
+FROB (WM_MOVING)
+FROB (WM_POWERBROADCAST)
+
+FROB (WM_DEVICECHANGE)
+
+#endif /* WINVER >= 0x0400 */
+
+FROB (WM_MDICREATE)
+FROB (WM_MDIDESTROY)
+FROB (WM_MDIACTIVATE)
+FROB (WM_MDIRESTORE)
+FROB (WM_MDINEXT)
+FROB (WM_MDIMAXIMIZE)
+FROB (WM_MDITILE)
+FROB (WM_MDICASCADE)
+FROB (WM_MDIICONARRANGE)
+FROB (WM_MDIGETACTIVE)
+
+
+FROB (WM_MDISETMENU)
+FROB (WM_ENTERSIZEMOVE)
+FROB (WM_EXITSIZEMOVE)
+FROB (WM_DROPFILES)
+FROB (WM_MDIREFRESHMENU)
+
+
+#if(WINVER >= 0x0400)
+FROB (WM_IME_SETCONTEXT)
+FROB (WM_IME_NOTIFY)
+FROB (WM_IME_CONTROL)
+FROB (WM_IME_COMPOSITIONFULL)
+FROB (WM_IME_SELECT)
+FROB (WM_IME_CHAR)
+#endif /* WINVER >= 0x0400 */
+#if(WINVER >= 0x0500)
+FROB (WM_IME_REQUEST)
+#endif /* WINVER >= 0x0500 */
+#if(WINVER >= 0x0400)
+FROB (WM_IME_KEYDOWN)
+FROB (WM_IME_KEYUP)
+#endif /* WINVER >= 0x0400 */
+
+
+#if(_WIN32_WINNT >= 0x0400)
+FROB (WM_MOUSEHOVER)
+FROB (WM_MOUSELEAVE)
+#endif /* _WIN32_WINNT >= 0x0400 */
+
+FROB (WM_CUT)
+FROB (WM_COPY)
+FROB (WM_PASTE)
+FROB (WM_CLEAR)
+FROB (WM_UNDO)
+FROB (WM_RENDERFORMAT)
+FROB (WM_RENDERALLFORMATS)
+FROB (WM_DESTROYCLIPBOARD)
+FROB (WM_DRAWCLIPBOARD)
+FROB (WM_PAINTCLIPBOARD)
+FROB (WM_VSCROLLCLIPBOARD)
+FROB (WM_SIZECLIPBOARD)
+FROB (WM_ASKCBFORMATNAME)
+FROB (WM_CHANGECBCHAIN)
+FROB (WM_HSCROLLCLIPBOARD)
+FROB (WM_QUERYNEWPALETTE)
+FROB (WM_PALETTEISCHANGING)
+FROB (WM_PALETTECHANGED)
+FROB (WM_HOTKEY)
+
+#if(WINVER >= 0x0400)
+FROB (WM_PRINT)
+FROB (WM_PRINTCLIENT)
+
+FROB (WM_HANDHELDFIRST)
+FROB (WM_HANDHELDLAST)
+
+FROB (WM_AFXFIRST)
+FROB (WM_AFXLAST)
+#endif /* WINVER >= 0x0400 */
+
+FROB (WM_PENWINFIRST)
+FROB (WM_PENWINLAST)
+};
+
+#undef FROB
+
+static void
+debug_output_mswin_message (HWND hwnd, UINT message_, WPARAM wParam,
+			    LPARAM lParam)
+{
+  Lisp_Object frame = mswindows_find_frame (hwnd);
+  int i;
+  char *str = 0;
+  /* struct mswin_message_debug *i_hate_cranking_out_code_like_this; */
+
+  for (i = 0; i < countof (debug_mswin_messages); i++)
+    {
+      if (debug_mswin_messages[i].mess == message_)
+	{
+	  str = debug_mswin_messages[i].string;
+	  break;
+	}
+    }
+
+  if (str)
+    stderr_out ("%s", str);
+  else
+    stderr_out ("%x", message_);
+
+  if (debug_mswindows_events > 1)
+    {
+      stderr_out (" wparam=%d lparam=%d hwnd=%x frame: ",
+		  wParam, (int) lParam, (unsigned int) hwnd);
+      debug_print (frame);
+    }
+  else
+    stderr_out ("\n");
+}
+
+#endif /* DEBUG_XEMACS */
+
 /************************************************************************/
 /*                            initialization                            */
 /************************************************************************/
@@ -3693,13 +4040,12 @@
 
 #ifdef DEBUG_XEMACS
   DEFVAR_INT ("debug-mswindows-events", &debug_mswindows_events /*
-If non-zero, display debug information about Windows events that XEmacs sees.
+If non-zero, display debug information about Windows messages that XEmacs sees.
 Information is displayed in a console window.  Currently defined values are:
 
-1 == non-verbose output
-2 == verbose output
-
-#### Unfortunately, not yet implemented.
+1 == non-verbose output (just the message name)
+2 == verbose output (all parameters)
+3 == even more verbose output (extra debugging info)
 */ );
   debug_mswindows_events = 0;
 #endif
--- a/src/event-stream.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/event-stream.c	Thu May 31 12:45:41 2001 +0000
@@ -924,12 +924,28 @@
 /*                            timeouts                                */
 /**********************************************************************/
 
-/**** Low-level timeout functions. ****
+/* NOTE: "Low-level" or "interval" timeouts are one-shot timeouts that
+   measure single intervals.  "High-level timeouts" or "wakeups" are
+   the objects generated by `add-timeout' or `add-async-timout' --
+   they can fire repeatedly (and in fact can have a different initial
+   time and resignal time).  Given the nature of both setitimer() and
+   select() -- i.e. all we get is a single one-shot timer -- we have
+   to decompose all high-level timeouts into a series of intervals or
+   low-level timeouts.
+
+   Low-level timeouts are of two varieties: synchronous and asynchronous.
+   The former are handled at the window-system level, the latter in
+   signal.c.
+*/
+
+/**** Low-level timeout helper functions. ****
 
    These functions maintain a sorted list of one-shot timeouts (where
-   the timeouts are in absolute time).  They are intended for use by
-   functions that need to convert a list of absolute timeouts into a
-   series of intervals to wait for. */
+   the timeouts are in absolute time so we never lose any time as a
+   result of the delay between noting an interval and firing the next
+   one).  They are intended for use by functions that need to convert
+   a list of absolute timeouts into a series of intervals to wait
+   for. */
 
 /* We ensure that 0 is never a valid ID, so that a value of 0 can be
    used to indicate an absence of a timer. */
@@ -954,6 +970,8 @@
 
   tm = Blocktype_alloc (the_low_level_timeout_blocktype);
   tm->next = NULL;
+  /* Don't just use ++low_level_timeout_id_tick, for the (admittedly
+     rare) case in which numbers wrap around. */
   if (low_level_timeout_id_tick == 0)
     low_level_timeout_id_tick++;
   tm->id = low_level_timeout_id_tick++;
@@ -1047,8 +1065,10 @@
 }
 
 
-/**** High-level timeout functions. ****/
-
+/**** High-level timeout functions. **** */
+
+/* We ensure that 0 is never a valid ID, so that a value of 0 can be
+   used to indicate an absence of a timer. */
 static int timeout_id_tick;
 
 static Lisp_Object pending_timeout_list, pending_async_timeout_list;
@@ -1098,6 +1118,10 @@
   EMACS_TIME current_time;
   EMACS_TIME interval;
 
+  /* Don't just use ++timeout_id_tick, for the (admittedly rare) case
+     in which numbers wrap around. */
+  if (timeout_id_tick == 0)
+    timeout_id_tick++;
   timeout->id = timeout_id_tick++;
   timeout->resignal_msecs = vanilliseconds;
   timeout->function = function;
@@ -1111,9 +1135,9 @@
   if (async_p)
     {
       timeout->interval_id =
-	event_stream_add_async_timeout (timeout->next_signal_time);
-      pending_async_timeout_list = noseeum_cons (op,
-						 pending_async_timeout_list);
+	signal_add_async_interval_timeout (timeout->next_signal_time);
+      pending_async_timeout_list =
+	noseeum_cons (op, pending_async_timeout_list);
     }
   else
     {
@@ -1138,7 +1162,7 @@
    NOTE: The returned FUNCTION and OBJECT are *not* GC-protected at all.
 */
 
-static int
+int
 event_stream_resignal_wakeup (int interval_id, int async_p,
 			      Lisp_Object *function, Lisp_Object *object)
 {
@@ -1197,7 +1221,7 @@
 
       if (async_p)
         timeout->interval_id =
-	  event_stream_add_async_timeout (timeout->next_signal_time);
+	  signal_add_async_interval_timeout (timeout->next_signal_time);
       else
         timeout->interval_id =
 	  event_stream_add_timeout (timeout->next_signal_time);
@@ -1241,7 +1265,7 @@
       *timeout_list =
 	delq_no_quit_and_free_cons (op, *timeout_list);
       if (async_p)
-	event_stream_remove_async_timeout (timeout->interval_id);
+	signal_remove_async_interval_timeout (timeout->interval_id);
       else
 	event_stream_remove_timeout (timeout->interval_id);
       free_managed_lcrecord (Vtimeout_free_list, op);
@@ -1277,50 +1301,6 @@
 }
 
 
-/**** Asynch. timeout functions (see also signal.c) ****/
-
-#if !defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT)
-extern int poll_for_quit_id;
-#endif
-
-#if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
-extern int poll_for_sigchld_id;
-#endif
-
-void
-event_stream_deal_with_async_timeout (int interval_id)
-{
-  /* This function can GC */
-  Lisp_Object humpty, dumpty;
-#if ((!defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT)) \
-     || defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD))
-  int id =
-#endif
-    event_stream_resignal_wakeup (interval_id, 1, &humpty, &dumpty);
-
-#if !defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT)
-  if (id == poll_for_quit_id)
-    {
-      quit_check_signal_happened = 1;
-      quit_check_signal_tick_count++;
-      return;
-    }
-#endif
-
-#if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
-  if (id == poll_for_sigchld_id)
-    {
-      kick_status_notify ();
-      return;
-    }
-#endif
-
-  /* call1 GC-protects its arguments */
-  call1_trapping_errors ("Error in asynchronous timeout callback",
-			 humpty, dumpty);
-}
-
-
 /**** Lisp-level timeout functions. ****/
 
 static unsigned long
--- a/src/events.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/events.h	Thu May 31 12:45:41 2001 +0000
@@ -626,11 +626,13 @@
 				  Lisp_Object function,
 				  Lisp_Object object,
 				  int async_p);
+int event_stream_resignal_wakeup (int interval_id, int async_p,
+				  Lisp_Object *function, Lisp_Object *object);
 void event_stream_disable_wakeup (int id, int async_p);
-void event_stream_deal_with_async_timeout (int interval_id);
 
-int event_stream_add_async_timeout (EMACS_TIME thyme);
-void event_stream_remove_async_timeout (int id);
+/* from signal.c */
+int signal_add_async_interval_timeout (EMACS_TIME thyme);
+void signal_remove_async_interval_timeout (int id);
 
 /* from event-stream.c -- focus sanity */
 extern int focus_follows_mouse;
--- a/src/fileio.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/fileio.c	Thu May 31 12:45:41 2001 +0000
@@ -2218,7 +2218,7 @@
 #if defined(WIN32_NATIVE) || defined(CYGWIN)
   /* Under MS-DOS and Windows, open does not work for directories.  */
   UNGCPRO;
-  if (access (XSTRING_DATA (abspath), 0) == 0)
+  if (access ((char *) XSTRING_DATA (abspath), 0) == 0)
     return Qt;
   else
     return Qnil;
--- a/src/frame-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/frame-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -518,11 +518,14 @@
 static void
 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
 {
-  unsigned int new_checksum = hash_string (title, strlen (title));
-  if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f))
+  unsigned int new_checksum = hash_string (title, strlen ((char *) title));
+  if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM (f))
     {
-      FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum;
-      SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
+      Extbyte *title_ext;
+
+      FRAME_MSWINDOWS_TITLE_CHECKSUM (f) = new_checksum;
+      C_STRING_TO_EXTERNAL (title, title_ext, Qmswindows_tstr);
+      SetWindowText (FRAME_MSWINDOWS_HANDLE (f), title_ext);
     }
 }
 
--- a/src/frame-x.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/frame-x.c	Thu May 31 12:45:41 2001 +0000
@@ -396,15 +396,15 @@
 }
 #endif /* !HAVE_WMCOMMAND */
 
-static int
-x_frame_iconified_p (struct frame *f)
+int
+x_frame_window_state (struct frame *f)
 {
   Atom actual_type;
   int actual_format;
   unsigned long nitems, bytesafter;
   unsigned long *datap = 0;
   Widget widget;
-  int result = 0;
+  int result = -1;
   struct device *d = XDEVICE (FRAME_DEVICE (f));
 
   widget = FRAME_X_SHELL_WIDGET (f);
@@ -415,14 +415,20 @@
 				     (unsigned char **) &datap)
       && datap)
     {
-      if (nitems <= 2	/* "suggested" by ICCCM version 1 */
-	  && datap[0] == IconicState)
-	result = 1;
+      if (nitems <= 2)	/* "suggested" by ICCCM version 1 */
+	result = (int) datap[0];
       XFree ((char *) datap);
     }
+
   return result;
 }
 
+static int
+x_frame_iconified_p (struct frame *f)
+{
+  return x_frame_window_state (f) == IconicState;
+}
+
 
 /************************************************************************/
 /*                          frame properties                            */
@@ -2527,6 +2533,9 @@
 x_frame_visible_p (struct frame *f)
 {
 #if 0
+
+  /* #### Ben suggests using x_frame_window_state (f) == NormalState. */
+
   Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
   XWindowAttributes xwa;
   int result;
--- a/src/glyphs-eimage.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/glyphs-eimage.c	Thu May 31 12:45:41 2001 +0000
@@ -1123,11 +1123,11 @@
     break;
   default:
     fprintf(stderr,"Eh? invalid seek mode in tiff_memory_seek\n");
-    return -1;
+    return (toff_t) -1;
   }
 
   if ((newidx > mem->len) || (newidx < 0))
-    return -1;
+    return (toff_t) -1;
 
   mem->index = newidx;
   return newidx;
--- a/src/glyphs-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/glyphs-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -160,16 +160,16 @@
 /************************************************************************/
 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
 					       int width, int height,
-					       unsigned char *pic,
+					       UChar_Binary *pic,
 					       int *bit_count,
-					       unsigned char** bmp_data)
+					       UChar_Binary** bmp_data)
 {
   struct device *d = XDEVICE (device);
   int i,j;
   RGBQUAD* colortbl;
   int		ncolors;
   BITMAPINFO*	bmp_info;
-  unsigned char *ip, *dp;
+  UChar_Binary *ip, *dp;
 
   if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0)
     {
@@ -194,7 +194,7 @@
 
       /* bitmap data needs to be in blue, green, red triples - in that
 	 order, eimage is in RGB format so we need to convert */
-      *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
+      *bmp_data = xnew_array_and_zero (UChar_Binary, bpline * height);
       *bit_count = bpline * height;
 
       if (!bmp_data)
@@ -234,7 +234,7 @@
 	  return NULL;
 	}
 
-      colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
+      colortbl=(RGBQUAD*)(((UChar_Binary*)bmp_info)+sizeof(BITMAPINFOHEADER));
 
       bmp_info->bmiHeader.biBitCount=8;
       bmp_info->bmiHeader.biCompression=BI_RGB;
@@ -242,7 +242,7 @@
       bmp_info->bmiHeader.biClrUsed=ncolors;
       bmp_info->bmiHeader.biClrImportant=ncolors;
 
-      *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
+      *bmp_data = (UChar_Binary *) xmalloc_and_zero (bpline * height);
       *bit_count = bpline * height;
 
       if (!*bmp_data)
@@ -429,14 +429,14 @@
 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
 					   int width, int height,
 					   int slices,
-					   unsigned char *eimage,
+					   UChar_Binary *eimage,
 					   int dest_mask,
 					   Lisp_Object instantiator,
 					   Lisp_Object domain)
 {
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
   BITMAPINFO*		bmp_info;
-  unsigned char*	bmp_data;
+  UChar_Binary*	bmp_data;
   int			bmp_bits;
   COLORREF		bkcolor;
   int slice;
@@ -474,18 +474,18 @@
 }
 
 inline static void
-set_mono_pixel (unsigned char* bits,
+set_mono_pixel (UChar_Binary* bits,
 		int bpline, int height,
 		int x, int y, int white)
 {
   int i;
-  unsigned char bitnum;
+  UChar_Binary bitnum;
   /* Find the byte on which this scanline begins */
   i = (height - y - 1) * bpline;
   /* Find the byte containing this pixel */
   i += (x >> 3);
   /* Which bit is it? */
-  bitnum = (unsigned char) (7 - (x & 7));
+  bitnum = (UChar_Binary) (7 - (x & 7));
   if (white)	/* Turn it on */
     bits[i] |= (1 << bitnum);
   else          /* Turn it off */
@@ -498,7 +498,7 @@
 {
   HBITMAP mask;
   HGDIOBJ old = NULL;
-  unsigned char *dibits, *and_bits;
+  UChar_Binary *dibits, *and_bits;
   BITMAPINFO *bmp_info =
     (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD));
   int i, j;
@@ -552,7 +552,7 @@
   bmp_info->bmiHeader.biClrImportant = 0;
   bmp_info->bmiHeader.biSizeImage = height * bpline;
 
-  dibits = (unsigned char*) xmalloc_and_zero (bpline * height);
+  dibits = (UChar_Binary*) xmalloc_and_zero (bpline * height);
   if (GetDIBits (hcdc,
 		 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
 		 0,
@@ -571,7 +571,7 @@
     {
       for (j=0; j<height; j++)
 	{
-	  unsigned char* idx = &dibits[j * bpline + i * 3];
+	  UChar_Binary* idx = &dibits[j * bpline + i * 3];
 
 	  if (RGB (idx[2], idx[1], idx[0]) == transparent_color)
 	    {
@@ -786,7 +786,7 @@
 }
 
 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer,
-			  unsigned char** data,
+			  UChar_Binary** data,
 			  int* width, int* height,
 			  int* x_hot, int* y_hot,
 			  int* transp,
@@ -796,7 +796,7 @@
   XpmImage xpmimage;
   XpmInfo xpminfo;
   int result, i, j, transp_idx, maskbpline;
-  unsigned char* dptr;
+  UChar_Binary* dptr;
   unsigned int* sptr;
   COLORREF color; /* the american spelling virus hits again .. */
   COLORREF* colortbl;
@@ -834,7 +834,7 @@
   *height = xpmimage.height;
   maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8);
 
-  *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
+  *data = xnew_array_and_zero (UChar_Binary, *width * *height * 3);
 
   if (!*data)
     {
@@ -943,10 +943,10 @@
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
   const Extbyte		*bytes;
   Extcount 		len;
-  unsigned char		*eimage;
+  UChar_Binary		*eimage;
   int			width, height, x_hot, y_hot;
   BITMAPINFO*		bmp_info;
-  unsigned char*	bmp_data;
+  UChar_Binary*	bmp_data;
   int			bmp_bits;
   int 			nsymbols=0, transp;
   struct color_symbol*	color_symbols=NULL;
@@ -1499,10 +1499,10 @@
  * like the Xlib routine XReadBitmapfile as possible.
  */
 int read_bitmap_data (FILE* fstream, unsigned int *width,
-		      unsigned int *height, unsigned char **datap,
+		      unsigned int *height, UChar_Binary **datap,
 		      int *x_hot, int *y_hot)
 {
-    unsigned char *data = NULL;		/* working variable */
+    UChar_Binary *data = NULL;		/* working variable */
     char line[MAX_SIZE];		/* input line from file */
     int size;				/* number of bytes of data */
     char name_and_type[MAX_SIZE];	/* an input line */
@@ -1577,12 +1577,12 @@
 	bytes_per_line = (ww+7)/8 + padding;
 
 	size = bytes_per_line * hh;
-	data = (unsigned char *) Xmalloc ((unsigned int) size);
+	data = (UChar_Binary *) Xmalloc ((unsigned int) size);
 	if (!data)
 	  RETURN (BitmapNoMemory);
 
 	if (version10p) {
-	    unsigned char *ptr;
+	    UChar_Binary *ptr;
 	    int bytes;
 
 	    for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
@@ -1593,7 +1593,7 @@
 		  *(ptr++) = value >> 8;
 	    }
 	} else {
-	    unsigned char *ptr;
+	    UChar_Binary *ptr;
 	    int bytes;
 
 	    for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
@@ -1621,7 +1621,7 @@
 
 
 int read_bitmap_data_from_file (const char *filename, unsigned int *width,
-				unsigned int *height, unsigned char **datap,
+				unsigned int *height, UChar_Binary **datap,
 				int *x_hot, int *y_hot)
 {
     FILE *fstream;
@@ -1650,15 +1650,15 @@
    byte order from left to right, big-endian within a byte.  0 =
    black, 1 = white.  */
 static HBITMAP
-xbm_create_bitmap_from_data (HDC hdc, char *data,
+xbm_create_bitmap_from_data (HDC hdc, const UChar_Binary *data,
 			     unsigned int width, unsigned int height,
 			     int mask, COLORREF fg, COLORREF bg)
 {
   int old_width = (width + 7)/8;
   int new_width = BPLINE (2*((width + 15)/16));
-  unsigned char *offset;
+  const UChar_Binary *offset;
   void *bmp_buf = 0;
-  unsigned char *new_data, *new_offset;
+  UChar_Binary *new_data, *new_offset;
   int i, j;
   BITMAPINFO *bmp_info =
     (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
@@ -1667,7 +1667,7 @@
   if (!bmp_info)
     return NULL;
 
-  new_data = (unsigned char *) xmalloc_and_zero (height * new_width);
+  new_data = (UChar_Binary *) xmalloc_and_zero (height * new_width);
 
   if (!new_data)
     {
@@ -1683,7 +1683,7 @@
       for (j=0; j<old_width; j++)
 	{
 	  int byte = offset[j];
-	  new_offset[j] = ~ (unsigned char)
+	  new_offset[j] = ~ (UChar_Binary)
 	    ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
 	}
     }
@@ -1743,8 +1743,7 @@
 static void
 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
 				     int width, int height,
-				     /* Note that data is in ext-format! */
-				     const char *bits,
+				     const UChar_Binary *bits,
 				     Lisp_Object instantiator,
 				     Lisp_Object pointer_fg,
 				     Lisp_Object pointer_bg,
@@ -1795,14 +1794,13 @@
   init_image_instance_geometry (ii);
 
   IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
-    xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
-				 TRUE, black, white);
+    xbm_create_bitmap_from_data (hdc, bits, width, height, TRUE, black, white);
 
   switch (type)
     {
     case IMAGE_MONO_PIXMAP:
       IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
-	xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
+	xbm_create_bitmap_from_data (hdc, bits, width, height,
 				     FALSE, black, black);
       break;
 
@@ -1831,7 +1829,7 @@
 	IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
 
 	IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
-	  xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
+	  xbm_create_bitmap_from_data (hdc, bits, width, height,
 				       FALSE, fg, black);
       }
       break;
@@ -1858,7 +1856,7 @@
 	  bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
 
 	IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
-	  xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
+	  xbm_create_bitmap_from_data (hdc, bits, width, height,
 				       TRUE, fg, black);
 	mswindows_initialize_image_instance_icon (ii, TRUE);
       }
@@ -1873,8 +1871,7 @@
 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
 		   Lisp_Object pointer_fg, Lisp_Object pointer_bg,
 		   int dest_mask, int width, int height,
-		   /* Note that data is in ext-format! */
-		   const char *bits)
+		   const UChar_Binary *bits)
 {
   Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
   Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
@@ -1884,13 +1881,13 @@
 
   if (!NILP (mask_data))
     {
-      const char *ext_data;
+      UChar_Binary *ext_data;
 
       TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
 			  C_STRING_ALLOCA, ext_data,
 			  Qbinary);
       mask = xbm_create_bitmap_from_data (hdc,
-					  (unsigned char *) ext_data,
+					  ext_data,
 					  XINT (XCAR (mask_data)),
 					  XINT (XCAR (XCDR (mask_data))),
 					  FALSE,
@@ -1912,7 +1909,7 @@
 			   int dest_mask, Lisp_Object domain)
 {
   Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
-  const char *ext_data;
+  const UChar_Binary *ext_data;
 
   assert (!NILP (data));
 
@@ -1957,9 +1954,9 @@
 {
   Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
   int i, stattis;
-  char *p, *bits, *bp;
-  const char * volatile emsg = 0;
-  const char * volatile dstring;
+  UChar_Binary *p, *bits, *bp;
+  const CBufbyte * volatile emsg = 0;
+  const UChar_Binary * volatile dstring;
 
   assert (!NILP (data));
 
@@ -1967,7 +1964,7 @@
 		      C_STRING_ALLOCA, dstring,
 		      Qbinary);
 
-  if ((p = strchr (dstring, ':')))
+  if ((p = (UChar_Binary *) strchr ((char *) dstring, ':')))
     {
       dstring = p + 1;
     }
@@ -1995,7 +1992,7 @@
   if (emsg)
     signal_image_error_2 (emsg, data, Qimage);
 
-  bp = bits = (char *) alloca (PIXELS / 8);
+  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. */
@@ -2007,7 +2004,7 @@
 	{
 	  n |= ((*p++) << b);
 	}
-      *bp++ = (char) n;
+      *bp++ = (UChar_Binary) n;
     }
 
   xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
--- a/src/lisp.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/lisp.h	Thu May 31 12:45:41 2001 +0000
@@ -318,18 +318,20 @@
    be interpreted as text. [A fifth possible type "e) a general pointer
    to memory" should be replaced with void *.]  Using these more specific
    types rather than the general ones helps avoid the confusions that
-   occur when the semantics of a char * argument being studied are unclear. */
-
-typedef unsigned char UChar;
+   occur when the semantics of a char * argument being studied are unclear.
+
+   Note that these typedefs are purely for documentation purposes; from
+   the C code's perspective, they are exactly equivalent to `char *',
+   `unsigned char *', etc., so you can freely use them with library
+   functions declared as such. */
 
 /* The data representing the text in a buffer is logically a set
    of Bufbytes, declared as follows. */
 
-typedef UChar Bufbyte;
-
-/* Explicitly signed or unsigned versions: */
-typedef UChar UBufbyte;
-typedef char  SBufbyte;
+typedef unsigned char Bufbyte;
+/* The following should only be used when you have to apply a stdlib
+   string function to internal data */
+typedef char CBufbyte;
 
 /* The data representing a string in "external" format (binary or any
    external encoding) is logically a set of Extbytes, declared as
@@ -341,13 +343,14 @@
 
 /* A byte in a string in binary format: */
 typedef char Char_Binary;
-typedef UChar UChar_Binary;
+typedef signed char SChar_Binary;
+typedef unsigned char UChar_Binary;
 
 /* A byte in a string in entirely US-ASCII format: (Nothing outside
  the range 00 - 7F) */
 
 typedef char Char_ASCII;
-typedef UChar UChar_ASCII;
+typedef unsigned char UChar_ASCII;
 
 
 /* To the user, a buffer is made up of characters, declared as follows.
@@ -2361,7 +2364,8 @@
 extern int find_file_use_truenames;
 
 /* Defined in bytecode.c */
-DOESNT_RETURN invalid_byte_code (const char *reason, Lisp_Object frob);
+DECLARE_DOESNT_RETURN (invalid_byte_code
+		       (const char *reason, Lisp_Object frob));
 
 /* Defined in callproc.c */
 char *egetenv (const char *);
--- a/src/menubar-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/menubar-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -160,7 +160,7 @@
   /* Replace XEmacs accelerator '%_' with Windows accelerator '&'
      and `%%' with `%'. */
   ptr = item;
-  while ((ptr = memchr (ptr, '%', len - (ptr - item))) != NULL)
+  while ((ptr = (Bufbyte *) memchr (ptr, '%', len - (ptr - item))) != NULL)
     {
       if (*(ptr + 1) == '_')
 	{
@@ -354,7 +354,8 @@
 	{
 	  item_info.fType = MFT_STRING;
 	  item_info.fState = MFS_DISABLED;
-	  item_info.dwTypeData = XSTRING_DATA (item);
+	  /* !!#### mule-bogosity, fixed in my mule ws */
+	  item_info.dwTypeData = (Extbyte *) XSTRING_DATA (item);
 	  oldflags |= MF_STRING | MF_DISABLED;
 	  oldlpnewitem = item_info.dwTypeData;
 	}
--- a/src/miscplay.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/miscplay.c	Thu May 31 12:45:41 2001 +0000
@@ -386,8 +386,8 @@
   dest    = miscplay_sndbuf;
   while (count--)
     {
-      *dest++ = (UChar_Binary)(((int)*((Char_Binary *)(src)) +
-				 (int)*((Char_Binary *)(src+1))) / 2);
+      *dest++ = (UChar_Binary)(((int)*((SChar_Binary *)(src)) +
+				 (int)*((SChar_Binary *)(src+1))) / 2);
       src  += 2;
     }
   *data   = src;
@@ -410,8 +410,8 @@
   dest    = miscplay_sndbuf;
   while (count--)
     {
-      *dest++ = (UChar_Binary)(((int)*((Char_Binary *)(src)) +
-				 (int)*((Char_Binary *)(src+1))) / 2) ^ 0x80;
+      *dest++ = (UChar_Binary)(((int)*((SChar_Binary *)(src)) +
+				 (int)*((SChar_Binary *)(src+1))) / 2) ^ 0x80;
       src += 2;
     }
   *data   = src;
@@ -440,7 +440,7 @@
 
 /* Convert a number in the range -32768..32767 to an 8 bit ulaw encoded
    number --- I hope, I got this conversion right :-) */
-static inline Char_Binary int2ulaw(int i)
+static inline SChar_Binary int2ulaw(int i)
 {
     /* Lookup table for fast calculation of number of bits that need shifting*/
     static short int t_bits[128] = {
@@ -664,7 +664,7 @@
   *outbuf =
   dest    = miscplay_sndbuf;
   while (count--) {
-    *dest++ = (UChar_Binary)(((Char_Binary *)src)[1] ^ (Char_Binary)0x80);
+    *dest++ = (UChar_Binary)(((SChar_Binary *)src)[1] ^ (SChar_Binary)0x80);
     src += 2;
   }
   *data = src;
@@ -686,7 +686,7 @@
   *outbuf =
   dest    = miscplay_sndbuf;
   while (count--) {
-    *dest++ = (UChar_Binary)(((Char_Binary *)src)[0] ^ (Char_Binary)0x80);
+    *dest++ = (UChar_Binary)(((SChar_Binary *)src)[0] ^ (SChar_Binary)0x80);
     src += 2;
   }
   *data = src;
@@ -709,8 +709,8 @@
   *outbuf =
   dest    = miscplay_sndbuf;
   while (count--) {
-    *dest++ = (UChar_Binary)(((int)((Char_Binary *)src)[1] +
-                              (int)((Char_Binary *)src)[3]) / 2 ^ 0x80);
+    *dest++ = (UChar_Binary)(((int)((SChar_Binary *)src)[1] +
+                              (int)((SChar_Binary *)src)[3]) / 2 ^ 0x80);
     src += 4;
   }
   *data = src;
@@ -733,8 +733,8 @@
   *outbuf =
   dest    = miscplay_sndbuf;
   while (count--) {
-    *dest++ = (UChar_Binary)(((int)((Char_Binary *)src)[0] +
-                              (int)((Char_Binary *)src)[2]) / 2 ^ 0x80);
+    *dest++ = (UChar_Binary)(((int)((SChar_Binary *)src)[0] +
+                              (int)((SChar_Binary *)src)[2]) / 2 ^ 0x80);
     src += 4;
   }
   *data = src;
--- a/src/ntplay.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/ntplay.c	Thu May 31 12:45:41 2001 +0000
@@ -22,6 +22,8 @@
 
 /* This file Mule-ized by Ben Wing, 5-15-01. */
 
+#define DONT_ENCAPSULATE
+
 #include <config.h>
 #include "lisp.h"
 
@@ -49,14 +51,14 @@
     {
       /* file isn't in the path so read it as data */
       int size;
-      UChar_Binary* data;
+      UChar_Binary *data;
       int ofd = open (sound_file, O_RDONLY | OPEN_BINARY, 0);
       
       if (ofd <0)
 	return;
 
       size = lseek (ofd, 0, SEEK_END);
-      data = (UChar_Binary *)xmalloc (size);
+      data = (UChar_Binary *) xmalloc (size);
       lseek (ofd, 0, SEEK_SET);
       
       if (!data)
@@ -86,23 +88,23 @@
 		   int convert_to_malloc)
 {
   DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT;
-  static UChar_Binary* sound_data=0;
+  static UChar_Binary *sound_data = 0;
   if (sound_data)
     {
       PlaySound (NULL, NULL, flags);
       xfree (sound_data);
-      sound_data=0;
+      sound_data = 0;
     }
 
   if (convert_to_malloc)
     {
-      sound_data = (UChar_Binary *)xmalloc (length);
+      sound_data = (UChar_Binary *) xmalloc (length);
       memcpy (sound_data, data, length);
     }
   else
     sound_data = data;
 
-  PlaySound(sound_data, NULL, flags);
+  PlaySound ((Extbyte *) sound_data, NULL, flags);
 
   /* #### Error handling? */ 
   return 1;
--- a/src/objects-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/objects-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -1276,7 +1276,8 @@
   HFONT hfont, hfont2;
   TEXTMETRIC metrics;
 
-  extname = XSTRING_DATA (name);
+  /* !!#### more mule bogosity */
+  extname = (const char *) XSTRING_DATA (name);
 
   /*
    * mswindows fonts look like:
@@ -1489,7 +1490,8 @@
       sprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects, charset);
       LIST_LOOP (fonttail, device_font_list)
 	{
-	  if (match_font (XSTRING_DATA (XCAR (fonttail)), truename, NULL))
+	  /* !!#### more mule bogosity */
+	  if (match_font ((char *) XSTRING_DATA (XCAR (fonttail)), truename, NULL))
 	    break;
 	}
       if (NILP (fonttail))
@@ -1604,7 +1606,8 @@
 
   LIST_LOOP (fonttail, DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device)))
     {
-      if (match_font (XSTRING_DATA (XCAR (fonttail)), extpattern, NULL))
+      /* !!#### more mule bogosity */
+      if (match_font ((char *) XSTRING_DATA (XCAR (fonttail)), extpattern, NULL))
 	result = Fcons (XCAR (fonttail), result);
     }
 
--- a/src/realpath.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/realpath.c	Thu May 31 12:45:41 2001 +0000
@@ -129,7 +129,8 @@
     {
       /* The file may exist, but isn't a symlink. Try to find the
          right name. */
-      char* tmp = alloca (cygwin_posix_to_win32_path_list_buf_size (name));
+      /* !!#### mule-bogosity */
+      char* tmp = (char *) alloca (cygwin_posix_to_win32_path_list_buf_size (name));
       cygwin_posix_to_win32_path_list (name, tmp);
       n = win32_readlink (tmp, buf, size);
     }
--- a/src/redisplay-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/redisplay-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -195,7 +195,8 @@
       assert(run->dimension == 1);	/* #### FIXME! */
       mswindows_set_dc_font (hdc, font_inst,
 			     cachel->underline, cachel->strikethru);
-      GetTextExtentPoint32 (hdc, run->ptr, run->len, &size);
+      /* !!#### more mule bogosity */
+      GetTextExtentPoint32 (hdc, (char *) run->ptr, run->len, &size);
       return(size.cx);
     }
 }
--- a/src/s/cygwin32.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/s/cygwin32.h	Thu May 31 12:45:41 2001 +0000
@@ -82,7 +82,6 @@
 #ifndef HAVE_SOCKETS
 #define HAVE_SOCKETS
 #endif
-#define OBJECTS_SYSTEM	ntplay.o
 
 #undef MAIL_USE_SYSTEM_LOCK
 
@@ -150,6 +149,7 @@
 #define CYGWIN_CONV_PATH(src, dst) \
 dst = alloca (cygwin_win32_to_posix_path_list_buf_size(src)); \
 cygwin_win32_to_posix_path_list(src, dst)
+     /* !!#### more mule bogosity */
 #define CYGWIN_WIN32_PATH(src, dst) \
-dst = alloca (cygwin_posix_to_win32_path_list_buf_size(src)); \
+dst = (Extbyte *) alloca (cygwin_posix_to_win32_path_list_buf_size(src)); \
 cygwin_posix_to_win32_path_list(src, dst)
--- a/src/select-msw.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/select-msw.c	Thu May 31 12:45:41 2001 +0000
@@ -71,7 +71,8 @@
 
   /* If it's a string, register the format(!) */
   if (STRINGP (value))
-    return RegisterClipboardFormat (XSTRING_DATA (value));
+    /* !!#### more mule bogosity */
+    return RegisterClipboardFormat ((Extbyte *) XSTRING_DATA (value));
 
   /* Check for Windows clipboard format symbols */
   if (EQ (value, QCF_TEXT))		return CF_TEXT;
@@ -378,7 +379,8 @@
 mswindows_register_selection_data_type (Lisp_Object type_name)
 {
   /* Type already checked in select.c */
-  const char *name = XSTRING_DATA (type_name);
+  /* !!#### more mule bogosity */
+  const char *name = (char *) XSTRING_DATA (type_name);
   UINT	      format;
 
   format = RegisterClipboardFormat (name);
--- a/src/signal.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/signal.c	Thu May 31 12:45:41 2001 +0000
@@ -1,6 +1,6 @@
 /* Handling asynchronous signals.
    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1996 Ben Wing.
+   Copyright (C) 1995, 1996, 2001 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -27,6 +27,7 @@
 #include "console.h"
 #include "events.h" /* for signal_fake_event() */
 #include "frame.h"
+#include "process.h"
 #include "sysdep.h"
 #include "syssignal.h"
 #include "systime.h"
@@ -47,22 +48,21 @@
 volatile int sigint_happened;
 
 /* Set to 1 when an asynch. timeout signal occurs. */
-static volatile int alarm_happened;
+static volatile int async_timeout_happened;
+
+/* Set to 1 when a multiple of SLOWED_DOWN_INTERRUPTS_SECS elapses,
+   after slow_down_interrupts() is called. */
+static volatile int slowed_interrupt_timeout_happened;
 
 /* This is used to synchronize setting the waiting_for_user_input_p
    flag. */
-static volatile int alarm_happened_while_emacs_was_blocking;
+static volatile int async_timeout_happened_while_emacs_was_blocking;
 
 /* See check_quit() for when this is set. */
 int dont_check_for_quit;
 
-#if !defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT)
-int poll_for_quit_id;
-#endif
-
-#if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
-int poll_for_sigchld_id;
-#endif
+static int poll_for_quit_id;
+static int poll_for_sigchld_id;
 
 /* This variable is used to communicate to a lisp
    process-filter/sentinel/asynchronous callback (via the function
@@ -82,11 +82,18 @@
 JMP_BUF break_system_call_jump;
 volatile int can_break_system_calls;
 
+static SIGTYPE alarm_signal (int signo);
+
+
 
 /**********************************************************************/
 /*                  Asynchronous timeout functions                    */
 /**********************************************************************/
 
+/* See the comment in event-stream.c, under major heading "Timeouts",
+   for the difference between low-level (one-shot) and high-level
+   (periodic/resignaling) timeouts. */
+
 /* The pending timers are stored in an ordered list, where the first timer
    on the list is the first one to fire.  Times recorded here are
    absolute. */
@@ -131,91 +138,6 @@
   set_one_shot_timer (interval);
 }
 
-int
-event_stream_add_async_timeout (EMACS_TIME thyme)
-{
-  int id = add_low_level_timeout (&async_timer_queue, thyme);
-
-  /* If this timeout is at the head of the queue, then we need to
-     set the timer right now for this timeout.  Otherwise, things
-     are fine as-is; after the timers ahead of us are signalled,
-     the timer will be set for us. */
-
-  if (async_timer_queue->id == id)
-    reset_interval_timer ();
-
-  return id;
-}
-
-void
-event_stream_remove_async_timeout (int id)
-{
-  int first = (async_timer_queue && async_timer_queue->id == id);
-  remove_low_level_timeout (&async_timer_queue, id);
-
-  /* If we removed the timeout from the head of the queue, then
-     we need to reset the interval timer right now. */
-  if (first)
-    reset_interval_timer ();
-}
-
-/* Handle an alarm once each second and read pending input
-   so as to handle a C-g if it comes in.  */
-
-static SIGTYPE
-alarm_signal (int signo)
-{
-  if (interrupts_slowed_down)
-    {
-      something_happened = 1; /* tell QUIT to wake up */
-      /* we are in "slowed-down interrupts" mode; the only alarm
-	 happening here is the slowed-down quit-check alarm, so
-	 we set this flag.
-
-	 Do NOT set alarm_happened, because we don't want anyone
-	 looking at the timeout queue.  We didn't set it and
-	 it needs to stay the way it is. */
-      quit_check_signal_happened = 1;
-
-#ifdef WIN32_NATIVE
-      can_break_system_calls = 0;
-#else
-      /* can_break_system_calls is set when we want to break out of
-	 non-interruptible system calls. */
-      if (can_break_system_calls)
-	{
-	  /* reset the flag for safety and such.  Do this *before*
-	     unblocking or reestablishing the signal to avoid potential
-	     race conditions. */
-	  can_break_system_calls = 0;
-	  EMACS_UNBLOCK_SIGNAL (signo);
-	  EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
-	  LONGJMP (break_system_call_jump, 0);
-	}
-#endif
-
-      EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
-      SIGRETURN;
-    }
-
-  something_happened = 1; /* tell QUIT to wake up */
-  alarm_happened = 1;
-  if (emacs_is_blocking)
-    alarm_happened_while_emacs_was_blocking = 1;
-  /* #### This is for QUITP.  When it is run, it may not be the
-     place to do arbitrary stuff like run asynch. handlers, but
-     it needs to know whether the poll-for-quit asynch. timeout
-     went off.  Rather than put the code in to compute this
-     specially, we just set this flag.  Should fix this. */
-  quit_check_signal_happened = 1;
-
-#ifdef HAVE_UNIXOID_EVENT_LOOP
-  signal_fake_event ();
-#endif
-
-  EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
-  SIGRETURN;
-}
 
 static void
 init_async_timeouts (void)
@@ -255,76 +177,90 @@
     }
 }
 
-/* Some functions don't like being interrupted with SIGALRM or SIGIO.
-   Previously we were calling stop_interrupts() / start_interrupts(),
-   but then if the program hangs in one of those functions, e.g.
-   waiting for a connect(), we're really screwed.  So instead we
-   just "slow them down".  We do this by disabling all interrupts
-   and then installing a timer of length fairly large, like 5 or
-   10 secs.  That way, any "legitimate" connections (which should
-   take a fairly short amount of time) go through OK, but we can
-   interrupt bogus ones. */
-
-void
-slow_down_interrupts (void)
+static void
+handle_async_timeout_signal (void)
 {
-  EMACS_TIME thyme;
+  int interval_id;
+  int wakeup_id;
+  Lisp_Object fun, arg;
+
+  /* No checks for Vinhibit_quit here or anywhere else in this file!!!
+     Otherwise critical quit will not work right.
+     The only check for Vinhibit_quit is in QUIT itself. */
+  interval_id = pop_low_level_timeout (&async_timer_queue, 0);
+
+  reset_interval_timer ();
+  if (async_timeout_happened_while_emacs_was_blocking)
+    {
+      async_timeout_happened_while_emacs_was_blocking = 0;
+      waiting_for_user_input_p = 1;
+    }
+
+  wakeup_id = event_stream_resignal_wakeup (interval_id, 1, &fun, &arg);
 
-  /* We have to set the flag *before* setting the slowed-down timer,
-     to avoid a race condition -- if the signal occurs between the
-     call to set_one_shot_timer() and the setting of this flag,
-     alarm_happened will get set, which will be a Bad Thing if
-     there were no timeouts on the queue. */
-  interrupts_slowed_down++;
-  if (interrupts_slowed_down == 1)
+  if (wakeup_id == poll_for_quit_id)
+    {
+      quit_check_signal_happened = 1;
+      quit_check_signal_tick_count++;
+    }
+  else if (wakeup_id == poll_for_sigchld_id)
     {
-      stop_interrupts ();
-      EMACS_SET_SECS_USECS (thyme, SLOWED_DOWN_INTERRUPTS_SECS, 0);
-      set_one_shot_timer (thyme);
+      kick_status_notify ();
     }
+  else
+    /* call1 GC-protects its arguments */
+    call1_trapping_errors ("Error in asynchronous timeout callback",
+			   fun, arg);
+
+  waiting_for_user_input_p = 0;
+}
+
+/* The following two functions are the external interface onto
+   creating/deleting asynchronous interval timeouts, and are
+   called by event-stream.c.  We call back to event-stream.c using
+   event_stream_resignal_wakeup(), when an interval goes off. */
+
+int
+signal_add_async_interval_timeout (EMACS_TIME thyme)
+{
+  int id = add_low_level_timeout (&async_timer_queue, thyme);
+
+  /* If this timeout is at the head of the queue, then we need to
+     set the timer right now for this timeout.  Otherwise, things
+     are fine as-is; after the timers ahead of us are signalled,
+     the timer will be set for us. */
+
+  if (async_timer_queue->id == id)
+    reset_interval_timer ();
+
+  return id;
 }
 
 void
-speed_up_interrupts (void)
+signal_remove_async_interval_timeout (int id)
 {
-  if (interrupts_slowed_down > 0)
-    {
-      start_interrupts ();
-      /* Change this flag AFTER fiddling with interrupts, for the same
-	 race-condition reasons as above. */
-      interrupts_slowed_down--;
-    }
+  int first = (async_timer_queue && async_timer_queue->id == id);
+  remove_low_level_timeout (&async_timer_queue, id);
+
+  /* If we removed the timeout from the head of the queue, then
+     we need to reset the interval timer right now. */
+  if (first)
+    reset_interval_timer ();
 }
 
-static void
-handle_alarm_going_off (void)
-{
-  int interval_id;
-
-  /* If asynch. timeouts are blocked, then don't do anything now,
-     but make this function get called again next QUIT.
-
-     #### This is a bit inefficient because there will be function call
-     overhead each time QUIT occurs. */
+/* If alarm() gets called when polling isn't disabled, it will mess up
+   the asynchronous timeouts, and then C-g checking won't work again.
+   Some libraries call alarm() directly, so we override the standard
+   library's alarm() and abort() if the caller of the library function
+   didn't wrap in stop_interrupts()/start_interrupts().
 
-  if (!NILP (Vinhibit_quit))
-    {
-      something_happened = 1;
-      alarm_happened = 1;
-      return;
-    }
-
-  interval_id = pop_low_level_timeout (&async_timer_queue, 0);
-
-  reset_interval_timer ();
-  if (alarm_happened_while_emacs_was_blocking)
-    {
-      alarm_happened_while_emacs_was_blocking = 0;
-      waiting_for_user_input_p = 1;
-    }
-  event_stream_deal_with_async_timeout (interval_id);
-  waiting_for_user_input_p = 0;
-}
+   NOTE: We could potentially avoid the need to wrap by adding a
+   one-shot timeout to simulate the alarm(), smashing our signal
+   handler back into place, and calling the library function when the
+   alarm goes off.  But do we want to?  We're not going to gain the
+   ability to C-g out of library functions this way (unless we forcibly
+   longjmp() out of a signal handler, which is likely to lead to a
+   crash). --ben */
 
 #ifdef HAVE_SETITIMER
 unsigned int
@@ -332,8 +268,6 @@
 {
   struct itimerval old_it, new_it;
 
-  /* If alarm() gets called when polling isn't disabled, it can mess
-     up the periodic timer. */
   assert (async_timer_suppress_count > 0);
 
   new_it.it_value.tv_sec = howlong;
@@ -361,21 +295,229 @@
 
 
 /**********************************************************************/
-/*                        Control-G checking                          */
+/*                     Enabling/disabling signals                     */
+/**********************************************************************/
+
+static int interrupts_initted;
+
+void
+stop_interrupts (void)
+{
+  if (!interrupts_initted)
+    return;
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
+  unrequest_sigio ();
+#endif
+  stop_async_timeouts ();
+}
+
+void
+start_interrupts (void)
+{
+  if (!interrupts_initted)
+    return;
+#if defined(SIGIO) && !defined(BROKEN_SIGIO)
+  request_sigio ();
+#endif
+  start_async_timeouts ();
+}
+
+
+static void
+establish_slow_interrupt_timer (void)
+{
+  EMACS_TIME thyme;
+
+  EMACS_SET_SECS_USECS (thyme, SLOWED_DOWN_INTERRUPTS_SECS, 0);
+  set_one_shot_timer (thyme);
+}
+
+/* Some functions don't like being interrupted with SIGALRM or SIGIO.
+   Previously we were calling stop_interrupts() / start_interrupts(),
+   but then if the program hangs in one of those functions, e.g.
+   waiting for a connect(), we're really screwed.  So instead we
+   just "slow them down".  We do this by disabling all interrupts
+   and then installing a timer of length fairly large, like 5 or
+   10 secs.  That way, any "legitimate" connections (which should
+   take a fairly short amount of time) go through OK, but we can
+   interrupt bogus ones. */
+
+void
+slow_down_interrupts (void)
+{
+  /* We have to set the flag *before* setting the slowed-down timer,
+     to avoid a race condition -- if the signal occurs between the
+     call to set_one_shot_timer() and the setting of this flag,
+     async_timeout_happened will get set, which will be a Bad Thing if
+     there were no timeouts on the queue. */
+  interrupts_slowed_down++;
+  if (interrupts_slowed_down == 1)
+    {
+      stop_interrupts ();
+      establish_slow_interrupt_timer ();
+    }
+}
+
+void
+speed_up_interrupts (void)
+{
+  if (interrupts_slowed_down > 0)
+    {
+      start_interrupts ();
+      /* Change this flag AFTER fiddling with interrupts, for the same
+	 race-condition reasons as above. */
+      interrupts_slowed_down--;
+    }
+}
+
+/* Cheesy but workable implementation of sleep() that doesn't
+   interfere with our periodic timers. */
+
+void
+emacs_sleep (int secs)
+{
+  stop_interrupts ();
+  sleep (secs);
+  start_interrupts ();
+}
+
+
+/**********************************************************************/
+/*                 The mechanism that drives it all                   */
 /**********************************************************************/
 
+/* called from QUIT when something_happened gets set (as a result of
+   a signal) */
+
+int
+check_what_happened (void)
+{
+  something_happened = 0;
+  if (async_timeout_happened)
+    {
+      async_timeout_happened = 0;
+      handle_async_timeout_signal ();
+    }
+  if (slowed_interrupt_timeout_happened)
+    {
+      slowed_interrupt_timeout_happened = 0;
+      establish_slow_interrupt_timer ();
+    }
+
+  return check_quit ();
+}
+
+#ifdef SIGIO
+
+/* Signal handler for SIGIO. */
+
+static void
+input_available_signal (int signo)
+{
+  something_happened = 1; /* tell QUIT to wake up */
+  quit_check_signal_happened = 1;
+  quit_check_signal_tick_count++;
+  EMACS_REESTABLISH_SIGNAL (signo, input_available_signal);
+  SIGRETURN;
+}
+
+#endif /* SIGIO */
+
+/* Actual signal handler for SIGALRM.  Called when:
+
+   -- asynchronous timeouts (added with `add-async-timeout') go off
+
+   -- when the poll-for-quit timer (used for C-g handling; more or
+      less when SIGIO is unavailable or BROKEN_SIGIO is defined) or
+      poll-for-sigchld timer (used when BROKEN_SIGCHLD is defined) go
+      off.  The latter two timers, if set, normally go off every 1/4
+      of a second -- see NORMAL_QUIT_CHECK_TIMEOUT_MSECS and
+      NORMAL_SIGCHLD_CHECK_TIMEOUT_MSECS. (Both of these timers are
+      treated like other asynchronous timeouts, but special-cased
+      in handle_async_timeout_signal().)
+
+   -- we called slow_down_interrupts() and SLOWED_DOWN_INTERRUPTS_SECS
+      (or a multiple of it) has elapsed.
+
+   Note that under Windows, we have no working setitimer(), so we
+   simulate it using the multimedia timeout functions,
+   e.g. timeSetEvent().  See setitimer() in nt.c.
+
+   Note also that we don't actually *do* anything here (except in the
+   case of can_break_system_calls).  Instead, we just set various
+   flags; next time QUIT is called, the flags will cause
+   check_what_happened() to be called, at which point we do everything
+   indicated by the flags.
+*/
+
+static SIGTYPE
+alarm_signal (int signo)
+{
+  something_happened = 1; /* tell QUIT to wake up and call
+			     check_what_happened() */
+
+  if (interrupts_slowed_down)
+    {
+      /* we are in "slowed-down interrupts" mode; the only alarm
+	 happening here is the slowed-down quit-check alarm, so
+	 we set this flag.
+
+	 Do NOT set async_timeout_happened, because we don't want
+	 anyone looking at the timeout queue -- async timeouts
+	 are disabled. */
+      quit_check_signal_happened = 1;
+      quit_check_signal_tick_count++;
+      /* make sure we establish the slow timer again. */
+      slowed_interrupt_timeout_happened = 1;
+
+      /* can_break_system_calls is set when we want to break out of
+	 non-interruptible system calls. */
+      if (can_break_system_calls)
+	{
+	  /* reset the flag for safety and such.  Do this *before*
+	     unblocking or reestablishing the signal to avoid potential
+	     race conditions. */
+	  can_break_system_calls = 0;
+#ifndef WIN32_NATIVE
+	  /* #### I didn't add this WIN32_NATIVE check.  I'm not sure
+	     why it's here.  But then again, someone needs to review
+	     this can_break_system_calls stuff and see if it still
+	     makes sense. --ben */
+	  EMACS_UNBLOCK_SIGNAL (signo);
+	  EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
+	  LONGJMP (break_system_call_jump, 0);
+#endif
+	}
+    }
+  else
+    {
+      async_timeout_happened = 1;
+      if (emacs_is_blocking)
+	async_timeout_happened_while_emacs_was_blocking = 1;
+      /* #### This is for QUITP.  When it is run, it may not be the
+	 place to do arbitrary stuff like run asynch. handlers, but
+	 it needs to know whether the poll-for-quit asynch. timeout
+	 went off.  Rather than put the code in to compute this
+	 specially, we just set this flag.  Should fix this. */
+      quit_check_signal_happened = 1;
+
+#ifdef HAVE_UNIXOID_EVENT_LOOP
+      signal_fake_event ();
+#endif
+    }
+
+  EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
+  SIGRETURN;
+}
+
 /* Set this for debugging, to have a way to get out */
 int stop_character; /* #### not currently implemented */
 
-/* This routine is called in response to a SIGINT or SIGQUIT.
-   On TTY's, one of these two signals will get generated in response
-   to C-g.  (When running under X, C-g is handled using the SIGIO
-   handler, which sets a flag telling the QUIT macro to scan the
-   unread events for a ^G.)
-
-   Otherwise it sets the Lisp variable  quit-flag  not-nil.
-   This causes  eval  to throw, when it gets a chance.
-   If  quit-flag  is already non-nil, it stops the job right away.  */
+/* Signal handler for SIGINT and SIGQUIT.  On TTY's, one of these two
+   signals will get generated in response to C-g.  (When running under
+   X, C-g is handled using the SIGIO handler, which sets a flag
+   telling the QUIT macro to scan the unread events for a ^G.)
+   */
 
 static SIGTYPE
 interrupt_signal (int sig)
@@ -388,14 +530,12 @@
 
   EMACS_REESTABLISH_SIGNAL (sig, interrupt_signal);
 
-/* with the macroized error-checking stuff, the garbage below
-   may mess things up because XCONSOLE() and such can use and
-   change global vars. */
-#if ! (defined (ERROR_CHECK_TYPECHECK) && defined (MACROIZE_ERROR_CHECKING))
   if (sigint_happened && CONSOLEP (Vcontrolling_terminal) &&
       CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal)) &&
       !emacs_is_blocking)
     {
+      /* #### this is inherited from GNU Emacs.  Do we really want this?
+	 --ben */
       char c;
       fflush (stdout);
       reset_initial_console ();
@@ -434,7 +574,6 @@
 					     (Vcontrolling_terminal))))));
     }
   else
-#endif /* ! (defined (ERROR_CHECKING) && defined (MACROIZE_ERROR_CHECKING)) */
     {
       /* Else request quit when it's safe */
       Vquit_flag = Qt;
@@ -447,6 +586,11 @@
   SIGRETURN;
 }
 
+
+/**********************************************************************/
+/*                        Control-G checking                          */
+/**********************************************************************/
+
 static Lisp_Object
 restore_dont_check_for_quit (Lisp_Object val)
 {
@@ -501,19 +645,6 @@
     return 0;
 }
 
-int
-check_what_happened (void)		/* called from QUIT when
-					   something_happened gets set */
-{
-  something_happened = 0;
-  if (alarm_happened)
-    {
-      alarm_happened = 0;
-      handle_alarm_going_off ();
-    }
-  return check_quit ();
-}
-
 
 
 void
@@ -534,6 +665,8 @@
 #endif /* not SIGIO and not DONT_POLL_FOR_QUIT */
 }
 
+#if 0 /* not used anywhere */
+
 void
 reset_poll_for_quit (void)
 {
@@ -546,6 +679,8 @@
 #endif /* not SIGIO and not DONT_POLL_FOR_QUIT */
 }
 
+#endif /* 0 */
+
 #if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)
 
 static void
@@ -566,60 +701,6 @@
 
 #endif /* not SIGCHLD */
 
-#ifdef SIGIO
-
-static void
-input_available_signal (int signo)
-{
-  something_happened = 1; /* tell QUIT to wake up */
-  quit_check_signal_happened = 1;
-  quit_check_signal_tick_count++;
-  EMACS_REESTABLISH_SIGNAL (signo, input_available_signal);
-  SIGRETURN;
-}
-
-#endif /* SIGIO */
-
-
-/**********************************************************************/
-/*                     Enabling/disabling signals                     */
-/**********************************************************************/
-
-static int interrupts_initted;
-
-void
-stop_interrupts (void)
-{
-  if (!interrupts_initted)
-    return;
-#if defined(SIGIO) && !defined(BROKEN_SIGIO)
-  unrequest_sigio ();
-#endif
-  stop_async_timeouts ();
-}
-
-void
-start_interrupts (void)
-{
-  if (!interrupts_initted)
-    return;
-#if defined(SIGIO) && !defined(BROKEN_SIGIO)
-  request_sigio ();
-#endif
-  start_async_timeouts ();
-}
-
-/* Cheesy but workable implementation of sleep() that doesn't
-   interfere with our periodic timers. */
-
-void
-emacs_sleep (int secs)
-{
-  stop_interrupts ();
-  sleep (secs);
-  start_interrupts ();
-}
-
 
 /************************************************************************/
 /*                            initialization                            */
--- a/src/sysdep.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/sysdep.h	Thu May 31 12:45:41 2001 +0000
@@ -74,7 +74,6 @@
 void slow_down_interrupts (void);
 void speed_up_interrupts (void);
 void init_poll_for_quit (void);
-void reset_poll_for_quit (void);
 
 /* Used so that signals can break out of system calls that aren't
    naturally interruptible. */
--- a/src/syswindows.h	Thu May 31 12:03:39 2001 +0000
+++ b/src/syswindows.h	Thu May 31 12:45:41 2001 +0000
@@ -236,11 +236,20 @@
 #ifdef CYGWIN
 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)			\
 do {									\
+  /* NOTE: It is a bit evil that here and below we are passing		\
+     internal-format data to a function that (nominally) should work	\
+     with external-format data.  But in point of fact, the Cygwin	\
+     conversion functions are *NOT* localized, and will fail if they	\
+     get 7-bit ISO2022-encoded data.  We know that our internal format	\
+     is ASCII-compatible, and so these functions will work fine with	\
+     this data. */							\
   Lisp_Object ltwff1 = (path);						\
   int ltwff2 =								\
-    cygwin_posix_to_win32_path_list_buf_size (XSTRING_DATA (ltwff1));	\
+    cygwin_posix_to_win32_path_list_buf_size ((char *)			\
+					      XSTRING_DATA (ltwff1));	\
   pathout = (Bufbyte *) alloca (ltwff2);				\
-  cygwin_posix_to_win32_path_list (XSTRING_DATA (ltwff1), pathout);	\
+  cygwin_posix_to_win32_path_list ((char *) XSTRING_DATA (ltwff1),	\
+				   (char *) pathout);			\
 } while (0)
 #else
 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)	\
@@ -250,19 +259,19 @@
 #endif
 
 #ifdef CYGWIN
-#define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)	\
-do {							\
-  Bufbyte *wtlff1 = (path);				\
-  int wtlff2 =						\
-    cygwin_win32_to_posix_path_list_buf_size (wtlff1);	\
-  Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);	\
-  cygwin_win32_to_posix_path_list (wtlff1, wtlff3);	\
-  (pathout) = build_string (wtlff3);			\
+#define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)			\
+do {									\
+  Bufbyte *wtlff1 = (path);						\
+  int wtlff2 =								\
+    cygwin_win32_to_posix_path_list_buf_size ((char *) wtlff1);		\
+  Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);			\
+  cygwin_win32_to_posix_path_list ((char *) wtlff1, (char *) wtlff3);	\
+  (pathout) = build_string ((CBufbyte *) wtlff3);			\
 } while (0)
 #else
 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)	\
 do {							\
-  (pathout) = build_string (path);			\
+  (pathout) = build_string ((CBufbyte *) path);		\
 } while (0)
 #endif
 
--- a/src/win32.c	Thu May 31 12:03:39 2001 +0000
+++ b/src/win32.c	Thu May 31 12:45:41 2001 +0000
@@ -221,10 +221,12 @@
 
   ret = (int) ShellExecute (NULL,
 			    (STRINGP (operation) ?
-			     XSTRING_DATA (operation) : NULL),
+			     /* !!#### more mule bogosity */
+			     (char *) XSTRING_DATA (operation) : NULL),
 			    doc, 
 			    (STRINGP (parameters) ?
-			     XSTRING_DATA (parameters) : NULL),
+			     /* !!#### more mule bogosity */
+			     (char *) XSTRING_DATA (parameters) : NULL),
 			    path,
 			    (INTP (show_flag) ?
 			     XINT (show_flag) : SW_SHOWDEFAULT));