From: Gerd Moellmann Date: Tue, 10 Apr 2001 12:14:49 +0000 (+0000) Subject: (sys_spawnve): Quote more chars for Cygwin. X-Git-Tag: emacs-pretest-21.0.103~254 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dbb70029168d42bdb3b2fd5ba0f232469074e245;p=emacs.git (sys_spawnve): Quote more chars for Cygwin. --- diff --git a/src/w32proc.c b/src/w32proc.c index c358621f557..93dff1761bf 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -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 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) 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 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) 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 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) 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 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) arglen += escape_char_run; } } - else if (*p == ' ' || *p == '\t') + else if (strchr (sepchars, *p) != NULL) { need_quotes = 1; } @@ -876,7 +884,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) 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 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) /* 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 != '"')