Spelling fixes.
[bpt/emacs.git] / src / w32proc.c
index d209a21..254a325 100644 (file)
@@ -1,6 +1,5 @@
 /* Process support for GNU Emacs on the Microsoft W32 API.
-   Copyright (C) 1992, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-                2006, 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   Copyright (C) 1992, 1995, 1999-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -52,7 +51,6 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
 #endif
 
 #include "lisp.h"
-#include "character.h"
 #include "w32.h"
 #include "w32heap.h"
 #include "systime.h"
@@ -68,49 +66,6 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
            + ((DWORD)(var) - (section)->VirtualAddress)                \
            + (filedata).file_base))
 
-/* Control whether spawnve quotes arguments as necessary to ensure
-   correct parsing by child process.  Because not all uses of spawnve
-   are careful about constructing argv arrays, we make this behavior
-   conditional (off by default). */
-Lisp_Object Vw32_quote_process_args;
-
-/* Control whether create_child causes the process' window to be
-   hidden.  The default is nil. */
-Lisp_Object Vw32_start_process_show_window;
-
-/* 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
-   consoles also allows Emacs to cleanly terminate process groups.  */
-Lisp_Object Vw32_start_process_share_console;
-
-/* Control whether create_child cause the process to inherit Emacs'
-   error mode setting.  The default is t, to minimize the possibility of
-   subprocesses blocking when accessing unmounted drives.  */
-Lisp_Object Vw32_start_process_inherit_error_mode;
-
-/* Time to sleep before reading from a subprocess output pipe - this
-   avoids the inefficiency of frequently reading small amounts of data.
-   This is primarily necessary for handling DOS processes on Windows 95,
-   but is useful for W32 processes on both Windows 95 and NT as well.  */
-int w32_pipe_read_delay;
-
-/* Control conversion of upper case file names to lower case.
-   nil means no, t means yes. */
-Lisp_Object Vw32_downcase_file_names;
-
-/* Control whether stat() attempts to generate fake but hopefully
-   "accurate" inode values, by hashing the absolute truenames of files.
-   This should detect aliasing between long and short names, but still
-   allows the possibility of hash collisions.  */
-Lisp_Object Vw32_generate_fake_inodes;
-
-/* Control whether stat() attempts to determine file type and link count
-   exactly, at the expense of slower operation.  Since true hard links
-   are supported on NTFS volumes, this is only relevant on NT.  */
-Lisp_Object Vw32_get_true_file_attributes;
-extern Lisp_Object Qlocal;
-
 Lisp_Object Qhigh, Qlow;
 
 #ifdef EMACSDEBUG
@@ -167,12 +122,12 @@ new_child (void)
 
   for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
     if (!CHILD_ACTIVE (cp))
-      goto Initialise;
+      goto Initialize;
   if (child_proc_count == MAX_CHILDREN)
     return NULL;
   cp = &child_procs[child_proc_count++];
 
- Initialise:
+ Initialize:
   memset (cp, 0, sizeof (*cp));
   cp->fd = -1;
   cp->pid = -1;
@@ -219,7 +174,7 @@ delete_child (child_process *cp)
          cp->status = STATUS_READ_ERROR;
          SetEvent (cp->char_consumed);
 #if 0
-          /* We used to forceably terminate the thread here, but it
+          /* We used to forcibly terminate the thread here, but it
              is normally unnecessary, and in abnormal cases, the worst that
              will happen is we have an extra idle thread hanging around
              waiting for the zombie process.  */
@@ -286,7 +241,8 @@ reader_thread (void *arg)
 
   /* We have to wait for the go-ahead before we can start */
   if (cp == NULL
-      || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
+      || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0
+      || cp->fd < 0)
     return 1;
 
   for (;;)
@@ -865,7 +821,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
 
      The w32 GNU-based library from Cygnus doubles quotes to escape
      them, while MSVC uses backslash for escaping.  (Actually the MSVC
-     startup code does attempt to recognise doubled quotes and accept
+     startup code does attempt to recognize doubled quotes and accept
      them, but gets it wrong and ends up requiring three quotes to get a
      single embedded quote!)  So by default we decide whether to use
      quote or backslash as the escape character based on whether the
@@ -873,7 +829,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
 
      Note that using backslash to escape embedded quotes requires
      additional special handling if an embedded quote is already
-     preceeded by backslash, or if an arg requiring quoting ends with
+     preceded by backslash, or if an arg requiring quoting ends with
      backslash.  In such cases, the run of escape characters needs to be
      doubled.  For consistency, we apply this special handling as long
      as the escape character is not quote.
@@ -1095,7 +1051,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
    detect that we were woken up by C-g, we return -1 with errno set to
    EINTR as on Unix.  */
 
-/* From ntterm.c */
+/* From w32console.c */
 extern HANDLE keyboard_handle;
 
 /* From w32xfns.c */
@@ -1601,8 +1557,6 @@ sys_kill (int pid, int sig)
   return rc;
 }
 
-/* extern int report_file_error (char *, Lisp_Object); */
-
 /* The following two routines are used to manipulate stdin, stdout, and
    stderr of our child processes.
 
@@ -1702,13 +1656,11 @@ set_process_dir (char * dir)
    dial-up users to only be connected when they actually need to use
    socket services.  */
 
-/* From nt.c */
+/* From w32.c */
 extern HANDLE winsock_lib;
 extern BOOL term_winsock (void);
 extern BOOL init_winsock (int load_now);
 
-extern Lisp_Object Vsystem_name;
-
 DEFUN ("w32-has-winsock", Fw32_has_winsock, Sw32_has_winsock, 0, 1, 0,
        doc: /* Test for presence of the Windows socket library `winsock'.
 Returns non-nil if winsock support is present, nil otherwise.
@@ -2284,7 +2236,7 @@ syms_of_ntproc (void)
   defsubr (&Sw32_get_keyboard_layout);
   defsubr (&Sw32_set_keyboard_layout);
 
-  DEFVAR_LISP ("w32-quote-process-args", &Vw32_quote_process_args,
+  DEFVAR_LISP ("w32-quote-process-args", Vw32_quote_process_args,
               doc: /* 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
@@ -2297,14 +2249,14 @@ will be chosen based on the type of the program.  */);
   Vw32_quote_process_args = Qt;
 
   DEFVAR_LISP ("w32-start-process-show-window",
-              &Vw32_start_process_show_window,
+              Vw32_start_process_show_window,
               doc: /* When nil, new child processes hide their windows.
 When non-nil, they show their window in the method of their choice.
 This variable doesn't affect GUI applications, which will never be hidden.  */);
   Vw32_start_process_show_window = Qnil;
 
   DEFVAR_LISP ("w32-start-process-share-console",
-              &Vw32_start_process_share_console,
+              Vw32_start_process_share_console,
               doc: /* When nil, new child processes are given a new console.
 When non-nil, they share the Emacs console; this has the limitation of
 allowing only one DOS subprocess to run at a time (whether started directly
@@ -2314,13 +2266,13 @@ otherwise respond to interrupts from Emacs.  */);
   Vw32_start_process_share_console = Qnil;
 
   DEFVAR_LISP ("w32-start-process-inherit-error-mode",
-              &Vw32_start_process_inherit_error_mode,
+              Vw32_start_process_inherit_error_mode,
               doc: /* When nil, new child processes revert to the default error mode.
 When non-nil, they inherit their error mode setting from Emacs, which stops
 them blocking when trying to access unmounted drives etc.  */);
   Vw32_start_process_inherit_error_mode = Qt;
 
-  DEFVAR_INT ("w32-pipe-read-delay", &w32_pipe_read_delay,
+  DEFVAR_INT ("w32-pipe-read-delay", w32_pipe_read_delay,
              doc: /* Forced delay before reading subprocess output.
 This is done to improve the buffering of subprocess output, by
 avoiding the inefficiency of frequently reading small amounts of data.
@@ -2331,7 +2283,7 @@ of time slices to wait (effectively boosting the priority of the child
 process temporarily).  A value of zero disables waiting entirely.  */);
   w32_pipe_read_delay = 50;
 
-  DEFVAR_LISP ("w32-downcase-file-names", &Vw32_downcase_file_names,
+  DEFVAR_LISP ("w32-downcase-file-names", Vw32_downcase_file_names,
               doc: /* Non-nil means convert all-upper case file names to lower case.
 This applies when performing completions and file name expansion.
 Note that the value of this setting also affects remote file names,
@@ -2340,16 +2292,16 @@ filesystems via ange-ftp.  */);
   Vw32_downcase_file_names = Qnil;
 
 #if 0
-  DEFVAR_LISP ("w32-generate-fake-inodes", &Vw32_generate_fake_inodes,
+  DEFVAR_LISP ("w32-generate-fake-inodes", Vw32_generate_fake_inodes,
               doc: /* Non-nil means attempt to fake realistic inode values.
 This works by hashing the truename of files, and should detect
 aliasing between long and short (8.3 DOS) names, but can have
-false positives because of hash collisions.  Note that determing
+false positives because of hash collisions.  Note that determining
 the truename of a file can be slow.  */);
   Vw32_generate_fake_inodes = Qnil;
 #endif
 
-  DEFVAR_LISP ("w32-get-true-file-attributes", &Vw32_get_true_file_attributes,
+  DEFVAR_LISP ("w32-get-true-file-attributes", Vw32_get_true_file_attributes,
               doc: /* Non-nil means determine accurate file attributes in `file-attributes'.
 This option controls whether to issue additional system calls to determine
 accurate link counts, file type, and ownership information.  It is more
@@ -2368,4 +2320,3 @@ where the performance impact may be noticeable even on modern hardware.  */);
   staticpro (&Vw32_valid_codepages);
 }
 /* end of w32proc.c */
-