changeset 546:666d73d6ac56

[xemacs-hg @ 2001-05-20 01:17:07 by ben] fixes so MinGW compiles. console-msw.h, scrollbar-msw.c, event-msw.c: we might receive scrollbar events on windows without scrollbars (e.g. holding down and moving the wheel button). dired.c: win9x support. eval.c: doc comment about gcpro'ing in record_unwind_protect. frame-msw.c: typo. frame.c: avoid problems with errors during init_frame_3. process-nt.c: remove unused mswindows-quote-process-args. rec for 21.4. unexcw.c: use do/while. autoload.el: Oops, off by one argument. mouse.el: Add an argument to mouse-track so that hooks can be overridden. (let-binding doesn't work when the hooks have been made local.) modify mouse-track-run-hook accordingly, and fix mouse-track-default and mouse-track-insert to use the new functionality. printer.el: Oops, off by one paren.
author ben
date Sun, 20 May 2001 01:17:16 +0000
parents 9a775fb11bb7
children cf82e22962ce
files lisp/ChangeLog lisp/autoload.el lisp/mouse.el lisp/printer.el src/ChangeLog src/console-msw.h src/dired.c src/eval.c src/event-msw.c src/frame-msw.c src/frame.c src/nt.c src/process-nt.c src/s/mingw32.h src/scrollbar-msw.c src/sysdep.c src/syswindows.h src/unexcw.c
diffstat 18 files changed, 264 insertions(+), 132 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri May 18 04:39:44 2001 +0000
+++ b/lisp/ChangeLog	Sun May 20 01:17:16 2001 +0000
@@ -1,3 +1,25 @@
+2001-05-19  Ben Wing  <ben@xemacs.org>
+
+	* autoload.el (batch-force-update-one-directory):
+	Oops, off by one argument.
+	
+	* mouse.el:
+	* mouse.el (Mouse-track-gensym): New.
+	* mouse.el (mouse-track-run-hook):
+	* mouse.el (mouse-track):
+	* mouse.el (mouse-track-default):
+	* mouse.el (mouse-track-insert):
+	* mouse.el (mouse-track-insert-selected-region): Removed.
+	* mouse.el (mouse-track-insert-drag-up-hook): Removed.
+	* mouse.el (mouse-track-insert-click-hook): Removed.
+	Add an argument to mouse-track so that hooks can be overridden.
+	(let-binding doesn't work when the hooks have been made local.)
+	modify mouse-track-run-hook accordingly, and fix mouse-track-default
+	and mouse-track-insert to use the new functionality.
+	
+	* printer.el (generic-print-region):
+	Oops, off by one paren.
+
 2001-05-13  Adrian Aichner  <adrian@xemacs.org>
 
 	* buff-menu.el (Buffer-menu-mode): `mouse-track-click-hook' was
--- a/lisp/autoload.el	Fri May 18 04:39:44 2001 +0000
+++ b/lisp/autoload.el	Sun May 20 01:17:16 2001 +0000
@@ -616,7 +616,7 @@
     (error "batch-update-directory is to be used only with -batch"))
   (let ((arg (car command-line-args-left)))
     (setq command-line-args-left (cdr command-line-args-left))
-    (update-autoload-files (list arg) t)))
+    (update-autoload-files (list arg) nil t)))
 
 (provide 'autoload)
 
--- a/lisp/mouse.el	Fri May 18 04:39:44 2001 +0000
+++ b/lisp/mouse.el	Sun May 20 01:17:16 2001 +0000
@@ -570,7 +570,9 @@
 	       event ex)
       t)))
 
-(defun mouse-track-run-hook (hook event &rest args)
+(defvar Mouse-track-gensym (gensym))
+
+(defun mouse-track-run-hook (hook override event &rest args)
   ;; ugh, can't use run-hook-with-args-until-success because we have
   ;; to get the value using symbol-value-in-buffer.  Doing a
   ;; save-excursion/set-buffer is wrong because the hook might want to
@@ -578,33 +580,40 @@
   ;; the hook might not want to change the buffer.
   ;; #### What we need here is a Lisp interface to
   ;; run_hook_with_args_in_buffer.  Here is a poor man's version.
-  (let ((buffer (event-buffer event)))
-    (and mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
-    (when buffer
-      (let ((value (symbol-value-in-buffer hook buffer nil)))
-	(if (and (listp value) (not (eq (car value) 'lambda)))
-	    ;; List of functions.
-	    (let (retval)
-	      (while (and value (null retval))
-		;; Found `t': should process default value.  We could
-		;; splice it into the buffer-local value, but that
-		;; would cons, which is not a good thing for
-		;; mouse-track hooks.
-		(if (eq (car value) t)
-		    (let ((global (default-value hook)))
-		      (if (and (listp global) (not (eq (car global) 'lambda)))
-			  ;; List of functions.
-			  (while (and global
-				      (null (setq retval
-						  (apply (car global) event args))))
-			    (pop global))
-			;; lambda
-			(setq retval (apply (car global) event args))))
-		  (setq retval (apply (car value) event args)))
-		(pop value))
-	      retval)
-	  ;; lambda
-	  (apply value event args))))))
+  (let ((overridden (plist-get override hook Mouse-track-gensym)))
+    (if (not (eq overridden Mouse-track-gensym))
+	(if (and (listp overridden) (not (eq (car overridden) 'lambda)))
+	    (some #'(lambda (val) (apply val event args)) overridden)
+	  (apply overridden event args))
+      (let ((buffer (event-buffer event)))
+	(and mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
+	(when buffer
+	  (let ((value (symbol-value-in-buffer hook buffer nil)))
+	    (if (and (listp value) (not (eq (car value) 'lambda)))
+		;; List of functions.
+		(let (retval)
+		  (while (and value (null retval))
+		    ;; Found `t': should process default value.  We could
+		    ;; splice it into the buffer-local value, but that
+		    ;; would cons, which is not a good thing for
+		    ;; mouse-track hooks.
+		    (if (eq (car value) t)
+			(let ((global (default-value hook)))
+			  (if (and (listp global) (not (eq (car global)
+							   'lambda)))
+			      ;; List of functions.
+			      (while (and global
+					  (null (setq retval
+						      (apply (car global)
+							     event args))))
+				(pop global))
+			    ;; lambda
+			    (setq retval (apply (car global) event args))))
+		      (setq retval (apply (car value) event args)))
+		    (pop value))
+		  retval)
+	      ;; lambda
+	      (apply value event args))))))))
 
 (defun mouse-track-scroll-undefined (random)
   ;; the old implementation didn't actually define this function,
@@ -615,7 +624,7 @@
   ;; difficult to do), this function may get called.
 )
 
-(defun mouse-track (event)
+(defun mouse-track (event &optional overriding-hooks)
   "Generalized mouse-button handler.  This should be bound to a mouse button.
 The behavior of this function is customizable using various hooks and
 variables: see `mouse-track-click-hook', `mouse-track-drag-hook',
@@ -629,6 +638,10 @@
 any custom-supplied handlers, by using the function `mouse-track-default'
 instead of `mouse-track'.
 
+\(In general, you can override specific hooks by using the argument
+OVERRIDING-HOOKS, which should be a plist of alternating hook names
+and values.)
+
 Default behavior is as follows:
 
 If you click-and-drag, the selection will be set to the region between the
@@ -669,7 +682,7 @@
       (setq mouse-track-click-count (1+ mouse-track-click-count)))
     (if (not (event-window event))
 	(error "Not over a window."))
-    (mouse-track-run-hook 'mouse-track-down-hook
+    (mouse-track-run-hook 'mouse-track-down-hook overriding-hooks
 			  event mouse-track-click-count)
     (unwind-protect
 	(while mouse-down
@@ -683,14 +696,17 @@
 		     (setq mouse-moved t))
 		 (if mouse-moved
 		     (mouse-track-run-hook 'mouse-track-drag-hook
-		      event mouse-track-click-count nil))
+					   overriding-hooks
+					   event mouse-track-click-count nil))
 		 (mouse-track-set-timeout event))
 		((and (timeout-event-p event)
 		      (eq (event-function event)
 			  'mouse-track-scroll-undefined))
 		 (if mouse-moved
 		     (mouse-track-run-hook 'mouse-track-drag-hook
-		      (event-object event) mouse-track-click-count t))
+					   overriding-hooks
+					   (event-object event)
+					   mouse-track-click-count t))
 		 (mouse-track-set-timeout (event-object event)))
 		((button-release-event-p event)
 		 (setq mouse-track-up-time (event-timestamp event))
@@ -698,12 +714,15 @@
 		 (setq mouse-track-up-y (event-y-pixel event))
 		 (setq mouse-down nil)
 		 (mouse-track-run-hook 'mouse-track-up-hook
-		  event mouse-track-click-count)
+				       overriding-hooks
+				       event mouse-track-click-count)
 		 (if mouse-moved
 		     (mouse-track-run-hook 'mouse-track-drag-up-hook
-		      event mouse-track-click-count)
+					   overriding-hooks
+					   event mouse-track-click-count)
 		   (mouse-track-run-hook 'mouse-track-click-hook
-		    event mouse-track-click-count)))
+					 overriding-hooks
+					 event mouse-track-click-count)))
 		((or (key-press-event-p event)
 		     (and (misc-user-event-p event)
 			  (eq (event-function event) 'cancel-mode-internal)))
@@ -717,7 +736,14 @@
       (and (buffer-live-p buffer)
 	   (save-excursion
 	     (set-buffer buffer)
-	     (run-hooks 'mouse-track-cleanup-hook))))))
+	     (let ((override (plist-get overriding-hooks
+					'mouse-track-cleanup-hook
+					Mouse-track-gensym)))
+	       (if (not (eq override Mouse-track-gensym))
+		   (if (and (listp override) (not (eq (car override) 'lambda)))
+		       (mapc #'funcall override)
+		     (funcall override))
+		 (run-hooks 'mouse-track-cleanup-hook))))))))
 
 
 ;;;;;;;;;;;; default handlers: new version of mouse-track
@@ -1319,12 +1345,14 @@
 (defun mouse-track-default (event)
   "Invoke `mouse-track' with only the default handlers active."
   (interactive "e")
-  (let ((mouse-track-down-hook 'default-mouse-track-down-hook)
-	(mouse-track-drag-hook 'default-mouse-track-drag-hook)
-	(mouse-track-drag-up-hook 'default-mouse-track-drag-up-hook)
-	(mouse-track-click-hook 'default-mouse-track-click-hook)
-	(mouse-track-cleanup-hook 'default-mouse-track-cleanup-hook))
-    (mouse-track event)))
+  (mouse-track event
+	       '(mouse-track-down-hook
+		 default-mouse-track-down-hook
+		 mouse-track-up-hook nil
+		 mouse-track-drag-hook default-mouse-track-drag-hook
+		 mouse-track-drag-up-hook default-mouse-track-drag-up-hook
+		 mouse-track-click-hook default-mouse-track-click-hook
+		 mouse-track-cleanup-hook default-mouse-track-cleanup-hook)))
 
 (defun mouse-track-do-rectangle (event)
   "Like `mouse-track' but selects rectangles instead of regions."
@@ -1355,37 +1383,37 @@
   (let ((default-mouse-track-adjust t))
     (mouse-track-default event)))
 
-(defvar mouse-track-insert-selected-region nil)
-
-(defun mouse-track-insert-drag-up-hook (event click-count)
-  (setq mouse-track-insert-selected-region
-	(default-mouse-track-return-dragged-selection event)))
-
 (defun mouse-track-insert (event &optional delete)
   "Make a selection with the mouse and insert it at point.
 This is exactly the same as the `mouse-track' command on \\[mouse-track],
 except that point is not moved; the selected text is immediately inserted
 after being selected\; and the selection is immediately disowned afterwards."
   (interactive "*e")
-  (setq mouse-track-insert-selected-region nil)
-  (let ((mouse-track-drag-up-hook 'mouse-track-insert-drag-up-hook)
- 	(mouse-track-click-hook 'mouse-track-insert-click-hook)
-	s)
-    (save-excursion
-      (save-window-excursion
-	(mouse-track event)
-	(if (consp mouse-track-insert-selected-region)
-	    (let ((pair mouse-track-insert-selected-region))
-	      (setq s (prog1
-			  (buffer-substring (car pair) (cdr pair))
-			(if delete
-			    (kill-region (car pair) (cdr pair)))))))))
-	(or (null s) (equal s "") (insert s))))
-
-(defun mouse-track-insert-click-hook (event click-count)
-  (default-mouse-track-drag-hook event click-count nil)
-  (mouse-track-insert-drag-up-hook event click-count)
-  t)
+  (let (s selreg)
+    (flet ((Mouse-track-insert-drag-up-hook (event count)
+	     (setq selreg
+		   (default-mouse-track-return-dragged-selection event))
+	     t)
+	   (Mouse-track-insert-click-hook (event count)
+	     (default-mouse-track-drag-hook event count nil)
+	     (setq selreg
+		   (default-mouse-track-return-dragged-selection event))
+	     t))
+      (save-excursion
+	(save-window-excursion
+	  (mouse-track
+	   event
+	   '(mouse-track-drag-up-hook
+	     Mouse-track-insert-drag-up-hook
+	     mouse-track-click-hook
+	     Mouse-track-insert-click-hook))
+	  (if (consp selreg)
+	      (let ((pair selreg))
+		(setq s (prog1
+			    (buffer-substring (car pair) (cdr pair))
+			  (if delete
+			      (kill-region (car pair) (cdr pair))))))))))
+    (or (null s) (equal s "") (insert s))))
 
 (defun mouse-track-delete-and-insert (event)
   "Make a selection with the mouse and insert it at point.
--- a/lisp/printer.el	Fri May 18 04:39:44 2001 +0000
+++ b/lisp/printer.el	Sun May 20 01:17:16 2001 +0000
@@ -436,10 +436,10 @@
 				       (let ((window-pixel-scroll-increment
 					      pixvis))
 					 (scroll-down 1))))))
-			     (setq pageno (1+ pageno))))))
-		     (and f (delete-frame f))
-		     (and header-buffer (kill-buffer header-buffer))
-		     (and footer-buffer (kill-buffer footer-buffer)))))
+			     (setq pageno (1+ pageno)))))))
+		 (and f (delete-frame f))
+		 (and header-buffer (kill-buffer header-buffer))
+		 (and footer-buffer (kill-buffer footer-buffer))))
 	     (setq copies (1- copies)))))
 	((and (not (eq system-type 'windows-nt))
 	      (fboundp 'lpr-region))
--- a/src/ChangeLog	Fri May 18 04:39:44 2001 +0000
+++ b/src/ChangeLog	Sun May 20 01:17:16 2001 +0000
@@ -1,3 +1,52 @@
+2001-05-12  Craig Lanning  <CraigL@Knology.net>
+
+        * s\mingw32.h:
+        Properly find MinGW's <process.h> inside Cygwin's restructured
+        include directories.  Don't try to include <cygwin/version.h>
+        since we are dropping support for MinGW in versions of Cygwin
+        earlier than b21.
+
+2001-05-12  Craig Lanning  <CraigL@Knology.net>
+
+        * nt.c:
+        Drop support for MinGW in versions of Cygwin before b21.
+        * sysdep.c:
+        Properly find MinGW's <process.h> inside Cygwin's restructured
+        include directories.
+        * syswindows.h:
+        Drop support for MinGW in versions of Cygwin before b21.
+        * unexcw.c:
+        Even though a.out.h is no longer detected by configure, allow
+        MinGW to use it until we figure out how to do the job with Win32.
+
+
+2001-05-19  Ben Wing  <ben@xemacs.org>
+
+	* console-msw.h:
+	* scrollbar-msw.c (mswindows_create_scrollbar_instance):
+	* scrollbar-msw.c (mswindows_handle_scrollbar_event):
+	* event-msw.c:
+	* event-msw.c (mswindows_find_frame):
+	we might receive scrollbar events on windows without scrollbars
+	(e.g. holding down and moving the wheel button).
+	
+	* dired.c (user_name_completion): win9x support.
+
+	* eval.c: doc comment about gcpro'ing in record_unwind_protect.
+
+	* frame-msw.c (msprinter_init_frame_3): typo.
+	
+	* frame.c:
+	* frame.c (restore_frame_list_to_its_unbesmirched_state):
+	* frame.c (Fmake_frame):
+	avoid problems with errors during init_frame_3.
+
+	* process-nt.c:
+	* process-nt.c (vars_of_process_nt):
+	remove unused mswindows-quote-process-args.  rec for 21.4.
+	
+	* unexcw.c (PERROR): use do/while.
+
 2001-05-03  Kirill 'Big K' Katsnelson  <kkm@dtmx.com>
 
 	* lisp.h: (dump_add_opaque): make varaddress parameter const.
--- a/src/console-msw.h	Fri May 18 04:39:44 2001 +0000
+++ b/src/console-msw.h	Sun May 20 01:17:16 2001 +0000
@@ -385,6 +385,8 @@
 
 Lisp_Object msprinter_default_printer (void);
 
+Lisp_Object mswindows_find_frame (HWND hwnd);
+
 struct mswindows_dialog_id
 {
   struct lcrecord_header header;
--- a/src/dired.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/dired.c	Sun May 20 01:17:16 2001 +0000
@@ -700,6 +700,25 @@
 	    }
 	  while (entriesread != totalentries);
 	}
+      else /* Win 9x */
+	{
+	  Extbyte name[2 * (UNLEN + 1)];
+	  DWORD length = sizeof (name);
+	  
+	  if (GetUserName (name, &length))
+	    {
+	      DO_REALLOC (user_cache.user_names, user_cache.size,
+			  user_cache.length + 1, struct user_name);
+	      TO_INTERNAL_FORMAT (C_STRING, name,
+				  MALLOC,
+				  (user_cache.
+				   user_names[user_cache.length].ptr,
+				   user_cache.
+				   user_names[user_cache.length].len),
+				  Qmswindows_tstr);
+	      user_cache.length++;
+	    }
+	}
 #endif
 
       XCAR (cache_incomplete_p) = Qnil;
--- a/src/eval.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/eval.c	Sun May 20 01:17:16 2001 +0000
@@ -4926,6 +4926,9 @@
   Fset (symbol, value);
 }
 
+/* Note: As long as the unwind-protect exists, its arg is automatically
+   GCPRO'd. */
+
 void
 record_unwind_protect (Lisp_Object (*function) (Lisp_Object arg),
                        Lisp_Object arg)
--- a/src/event-msw.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/event-msw.c	Sun May 20 01:17:16 2001 +0000
@@ -92,7 +92,6 @@
 /* Timer ID used for button2 emulation */
 #define BUTTON_2_TIMER_ID 1
 
-static Lisp_Object mswindows_find_frame (HWND hwnd);
 static Lisp_Object mswindows_find_console (HWND hwnd);
 static Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key, int mods,
 						  int extendedp);
@@ -3236,7 +3235,7 @@
 /*
  * Find the frame that matches the supplied mswindows window handle
  */
-static Lisp_Object
+Lisp_Object
 mswindows_find_frame (HWND hwnd)
 {
   LONG l = GetWindowLong (hwnd, XWL_FRAMEOBJ);
--- a/src/frame-msw.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/frame-msw.c	Sun May 20 01:17:16 2001 +0000
@@ -884,7 +884,7 @@
       || frame_top < 0
       || frame_left + frame_width > GetDeviceCaps (hdc, HORZRES)
       || frame_top + frame_height > GetDeviceCaps (hdc, VERTRES))
-    invalid_operation ("Print area is ouside of the printer's "
+    invalid_operation ("Print area is outside of the printer's "
 		       "hardware printable area",
 		       STRINGP (f->name) ? f->name : Qunbound);
 
--- a/src/frame.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/frame.c	Sun May 20 01:17:16 2001 +0000
@@ -336,6 +336,15 @@
   return foolist;
 }
 
+Lisp_Object
+restore_frame_list_to_its_unbesmirched_state (Lisp_Object kawnz)
+{
+  Lisp_Object lissed = XCDR (kawnz);
+  if (!EQ (lissed, Qunbound))
+    DEVICE_FRAME_LIST (XDEVICE (XCAR (kawnz))) = lissed;
+  return Qnil;
+}    
+
 DEFUN ("make-frame", Fmake_frame, 0, 2, "", /*
 Create and return a new frame, displaying the current buffer.
 Runs the functions listed in `create-frame-hook' after frame creation.
@@ -354,9 +363,10 @@
   struct device *d;
   Lisp_Object frame = Qnil, name = Qnil, minibuf;
   struct gcpro gcpro1, gcpro2, gcpro3;
-  int speccount = specpdl_depth ();
+  int speccount = specpdl_depth (), speccount2;
   int first_frame_on_device = 0;
   int first_frame_on_console = 0;
+  Lisp_Object besmirched_cons = Qnil;
 
   d = decode_device (device);
   XSETDEVICE (device, d);
@@ -432,6 +442,14 @@
   if (NILP (DEVICE_FRAME_LIST (d)))
     first_frame_on_device = 1;
 
+  /* It's possible for one of the init methods below to signal an error;
+     in that case, let's make sure the device isn't besmirched by
+     having a half-initialized frame attached to it */
+  speccount2 = specpdl_depth ();
+  record_unwind_protect (restore_frame_list_to_its_unbesmirched_state,
+			 besmirched_cons =
+			 Fcons (device, DEVICE_FRAME_LIST (d)));
+
   /* This *must* go before the init_*() methods.  Those functions
      call Lisp code, and if any of them causes a warning to be displayed
      and the *Warnings* buffer to be created, it won't get added to
@@ -479,6 +497,10 @@
   /* Hallelujah, praise the lord. */
   f->init_finished = 1;
 
+  XCDR (besmirched_cons) = Qunbound;
+
+  unbind_to (speccount2, Qnil);
+
   /* If this is the first frame on the device, make it the selected one. */
   if (first_frame_on_device && NILP (DEVICE_SELECTED_FRAME (d)))
     set_device_selected_frame (d, frame);
--- a/src/nt.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/nt.c	Sun May 20 01:17:16 2001 +0000
@@ -1216,11 +1216,6 @@
 }
 #else
 
-#if defined(MINGW) && CYGWIN_VERSION_DLL_MAJOR <= 21
-#define LowPart u.LowPart
-#define HighPart u.HighPart
-#endif
-
 static LARGE_INTEGER utc_base_li;
 
 time_t
--- a/src/process-nt.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/process-nt.c	Sun May 20 01:17:16 2001 +0000
@@ -56,10 +56,6 @@
   HWND hwnd; /* console window */
 };
 
-/* Control how args are quoted to ensure correct parsing by child
-   process. */
-Lisp_Object Vmswindows_quote_process_args;
-
 /* Control whether create_child causes the process to inherit Emacs'
    console window, or be given a new one of its own.  The default is
    nil, to allow multiple DOS programs to run on Win95.  Having separate
@@ -1383,20 +1379,6 @@
 void
 vars_of_process_nt (void)
 {
-  DEFVAR_LISP ("mswindows-quote-process-args",
-	       &Vmswindows_quote_process_args /*
-Non-nil enables quoting of process arguments to ensure correct parsing.
-Because Windows does not directly pass argv arrays to child processes,
-programs have to reconstruct the argv array by parsing the command
-line string.  For an argument to contain a space, it must be enclosed
-in double quotes or it will be parsed as multiple arguments.
-
-If the value is a character, that character will be used to escape any
-quote characters that appear, otherwise a suitable escape character
-will be chosen based on the type of the program (normal or Cygwin).
-*/ );								  
-  Vmswindows_quote_process_args = Qt;
-
   DEFVAR_LISP ("mswindows-start-process-share-console",
 	       &Vmswindows_start_process_share_console /*
 When nil, new child processes are given a new console.
--- a/src/s/mingw32.h	Fri May 18 04:39:44 2001 +0000
+++ b/src/s/mingw32.h	Sun May 20 01:17:16 2001 +0000
@@ -133,13 +133,10 @@
 
 #ifndef NOT_C_CODE
 #include <stdlib.h>
-#include <mingw/process.h>
+#include <../mingw/process.h>
 #define mkdir __mkdir
 #include <dir.h>
 #undef mkdir
-#ifdef HAVE_CYGWIN_VERSION_H
-#include <cygwin/version.h>
-#endif
 
 /* IO calls that are emulated or shadowed */
 #define pipe    sys_pipe
@@ -192,11 +189,6 @@
 gid_t getgid (void);
 gid_t getegid (void);
 
-#if CYGWIN_VERSION_DLL_MAJOR <= 21
-#define _ftime ftime
-#define _timeb timeb
-#endif
-
 /* Stuff that gets set wrongly or otherwise */
 #define HAVE_SETITIMER
 #define HAVE_GETTIMEOFDAY
--- a/src/scrollbar-msw.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/scrollbar-msw.c	Sun May 20 01:17:16 2001 +0000
@@ -56,25 +56,26 @@
     orientation = SBS_HORZ;
 
   SCROLLBAR_MSW_HANDLE (sb) =
-    CreateWindowEx(0, "SCROLLBAR", 0, orientation|WS_CHILD,
-		 CW_USEDEFAULT, CW_USEDEFAULT,
-		 CW_USEDEFAULT, CW_USEDEFAULT,
-		 FRAME_MSWINDOWS_HANDLE (f),
-		 NULL, NULL, NULL);
-  SCROLLBAR_MSW_INFO (sb).cbSize = sizeof(SCROLLINFO);
+    CreateWindowEx (0, "SCROLLBAR", 0, orientation|WS_CHILD,
+		    CW_USEDEFAULT, CW_USEDEFAULT,
+		    CW_USEDEFAULT, CW_USEDEFAULT,
+		    FRAME_MSWINDOWS_HANDLE (f),
+		    NULL, NULL, NULL);
+  SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO);
   SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
   GetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
 		&SCROLLBAR_MSW_INFO (sb));
-  SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
+  SetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA, (LONG) sb);
 
 #if 0
   {
-	  HWND h = SCROLLBAR_MSW_HANDLE (sb);
-	  int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
-	  int y = GetLastError();
-	  struct scrollbar_instance *z = (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
-		  GWL_USERDATA);
-	  *z = *z;
+    HWND h = SCROLLBAR_MSW_HANDLE (sb);
+    int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
+    int y = GetLastError();
+    struct scrollbar_instance *z =
+      (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
+						  GWL_USERDATA);
+    *z = *z;
   }
 #endif
 }
@@ -180,10 +181,19 @@
   int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
   int value;
 
-  sb = (struct scrollbar_instance *)GetWindowLong (hwnd, GWL_USERDATA);
-  win = real_window (sb->mirror, 1);
-  frame = XWINDOW (win)->frame;
-  f = XFRAME (frame);
+  sb = (struct scrollbar_instance *) GetWindowLong (hwnd, GWL_USERDATA);
+  if (!sb)
+    {
+      frame = mswindows_find_frame (hwnd);
+      f = XFRAME (frame);
+      win = FRAME_SELECTED_WINDOW (f);
+    }
+  else
+    {
+      win = real_window (sb->mirror, 0);
+      frame = XWINDOW (win)->frame;
+      f = XFRAME (frame);
+    }
 
   /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
      always be - any Windows is binary compatible backward with
@@ -255,7 +265,7 @@
 
     case SB_ENDSCROLL:
 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
-      if (vertical_drag_in_progress)
+      if (vertical_drag_in_progress && sb)
 	/* User has just dropped the thumb - finally update it */
 	SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
 		       &SCROLLBAR_MSW_INFO (sb), TRUE);
--- a/src/sysdep.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/sysdep.c	Sun May 20 01:17:16 2001 +0000
@@ -33,7 +33,7 @@
 
 #ifdef WIN32_NATIVE
 #ifdef MINGW
-#include <mingw/process.h>
+#include <../mingw/process.h>
 #else
 /* <process.h> should not conflict with "process.h", as per ANSI definition.
    This is not true with visual c though. The trick below works with
--- a/src/syswindows.h	Fri May 18 04:39:44 2001 +0000
+++ b/src/syswindows.h	Sun May 20 01:17:16 2001 +0000
@@ -57,8 +57,7 @@
 
 #include <windows.h>
 
-#if (defined (CYGWIN) || defined(MINGW)) && \
-	CYGWIN_VERSION_DLL_MAJOR < 21
+#if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21
 extern BOOL WINAPI DdeFreeStringHandle(DWORD,HSZ);
 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
 #define stricmp strcasecmp
@@ -79,9 +78,10 @@
 #include <ddeml.h>
 #endif
 
-#include <lmaccess.h>
+#include <lmaccess.h> /* next three for NetUserEnum and friends */
 #include <lmapibuf.h>
 #include <lmerr.h>
+#include <lmcons.h> /* for UNLEN and possibly other constants */
 
 /* mmsystem.h defines. */
 #ifndef SND_ASYNC
--- a/src/unexcw.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/unexcw.c	Sun May 20 01:17:16 2001 +0000
@@ -35,9 +35,13 @@
 #define DONT_ENCAPSULATE /* filenames are external in unex*.c */
 #include "sysfile.h"
 
-#define PERROR(arg) perror(arg);exit(-1) 
+#define PERROR(arg)				\
+do {						\
+  perror (arg);					\
+  exit (-1);					\
+} while (0)
 
-#ifndef HAVE_A_OUT_H
+#if !defined (HAVE_A_OUT_H) && !defined (WIN32_NATIVE)
 unexec (char *, char *, void *, void *,	void *)
 {
   PERROR("cannot unexec() a.out.h not installed");
@@ -47,7 +51,12 @@
 #ifndef MAX_PATH
 #define MAX_PATH 260
 #endif
+
+#ifdef MINGW
+#include <../../include/a.out.h>
+#else
 #include <a.out.h>
+#endif
 
 #define ALLOC_UNIT 0xFFFF
 #define ALLOC_MASK ~((unsigned long)(ALLOC_UNIT))