changeset 37290:6e6e46d239df

(sys_spawnve): Quote more chars for Cygwin.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 10 Apr 2001 12:14:49 +0000
parents a1af2574e64b
children 83dd2eb5365f
files src/w32proc.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32proc.c	Tue Apr 10 12:01:01 2001 +0000
+++ b/src/w32proc.c	Tue Apr 10 12:14:49 2001 +0000
@@ -1,5 +1,5 @@
 /* Process support for GNU Emacs on the Microsoft W32 API.
-   Copyright (C) 1992, 1995, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1995, 1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -720,6 +720,7 @@
      variable in their environment.  */
   char ppid_env_var_buffer[64];
   char *extra_env[] = {ppid_env_var_buffer, NULL};
+  char *sepchars = " \t";
 
   /* We don't care about the other modes */
   if (mode != _P_NOWAIT)
@@ -815,6 +816,10 @@
 	escape_char = is_cygnus_app ? '"' : '\\';
     }
   
+  /* Cygwin apps needs quoting a bit more often */ 
+  if (escape_char == '"')
+    sepchars = "\r\n\t\f '";
+
   /* do argv...  */
   arglen = 0;
   targ = argv;
@@ -828,7 +833,10 @@
 	need_quotes = 1;
       for ( ; *p; p++)
 	{
-	  if (*p == '"')
+	  if (escape_char == '"' && *p == '\\')
+	    /* If it's a Cygwin app, \ needs to be escaped.  */
+	    arglen++;
+	  else if (*p == '"')
 	    {
 	      /* allow for embedded quotes to be escaped */
 	      arglen++;
@@ -842,7 +850,7 @@
 		  arglen += escape_char_run;
 		}
 	    }
-	  else if (*p == ' ' || *p == '\t')
+	  else if (strchr (sepchars, *p) != NULL)
 	    {
 	      need_quotes = 1;
 	    }
@@ -876,7 +884,7 @@
       if (do_quoting)
 	{
 	  for ( ; *p; p++)
-	    if (*p == ' ' || *p == '\t' || *p == '"')
+	    if ((strchr (sepchars, *p) != NULL) || *p == '"')
 	      need_quotes = 1;
 	}
       if (need_quotes)
@@ -916,6 +924,8 @@
 		  /* escape all quote chars, even at beginning or end */
 		  *parg++ = escape_char;
 		}
+	      else if (escape_char == '"' && *p == '\\')
+		*parg++ = '\\';
 	      *parg++ = *p;
 
 	      if (*p == escape_char && escape_char != '"')