mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-02 13:05:42 +08:00
* spawn.cc (spawn_guts): Use \ for quoting '"'.
* dcrt0.cc (quoted): Understand \ quoting for '"'.
This commit is contained in:
parent
2768430b64
commit
8e382d8049
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jul 16 02:30:09 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* spawn.cc (spawn_guts): Use \ for quoting '"'.
|
||||||
|
* dcrt0.cc (quoted): Understand \ quoting for '"'.
|
||||||
|
|
||||||
Sun Jul 16 00:32:58 2000 Christopher Faylor <cgf@cygnus.com>
|
Sun Jul 16 00:32:58 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* dcrt0.cc (build_argv): Strip quotes from argv[0] since it should
|
* dcrt0.cc (build_argv): Strip quotes from argv[0] since it should
|
||||||
|
@ -277,7 +277,7 @@ isquote (char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Step over a run of characters delimited by quotes */
|
/* Step over a run of characters delimited by quotes */
|
||||||
static __inline char *
|
static /*__inline*/ char *
|
||||||
quoted (char *cmd, int winshell)
|
quoted (char *cmd, int winshell)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@ -293,10 +293,10 @@ quoted (char *cmd, int winshell)
|
|||||||
cmd = strchr (cmd, '\0'); // no closing quote
|
cmd = strchr (cmd, '\0'); // no closing quote
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (p[1] == quote)
|
else if (p[1] == quote && p[-1] != '\\')
|
||||||
{
|
{
|
||||||
*p++ = '\\';
|
*p = '\\';
|
||||||
cmd = p; // a quoted quote
|
cmd = ++p; // a quoted quote
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -310,20 +310,26 @@ quoted (char *cmd, int winshell)
|
|||||||
characters should have been placed here by spawn_guts, so
|
characters should have been placed here by spawn_guts, so
|
||||||
we'll just pinch them out of the command string unless
|
we'll just pinch them out of the command string unless
|
||||||
they're quoted with a preceding \ */
|
they're quoted with a preceding \ */
|
||||||
strcpy (cmd, cmd + 1);
|
p = cmd + 1;
|
||||||
while (*cmd)
|
while (*p)
|
||||||
{
|
{
|
||||||
if (*cmd != quote)
|
if (*p != quote)
|
||||||
cmd++;
|
p++;
|
||||||
else if (cmd[1] == quote)
|
else if (p[-1] == '\\')
|
||||||
strcpy (cmd++, cmd + 1);
|
strcpy (p - 1, p);
|
||||||
|
else if (p[1] == quote)
|
||||||
|
{
|
||||||
|
strcpy (p, p + 1);
|
||||||
|
p++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy (cmd, cmd + 1);
|
strcpy (p, p + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmd;
|
strcpy (cmd, cmd + 1);
|
||||||
|
return p - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform a glob on word if it contains wildcard characters.
|
/* Perform a glob on word if it contains wildcard characters.
|
||||||
|
@ -407,16 +407,17 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
|||||||
|
|
||||||
newargv0 = NULL;
|
newargv0 = NULL;
|
||||||
int len = strlen (a);
|
int len = strlen (a);
|
||||||
if (len != 0 && !(p = strpbrk (a, " \t\n\r\"")))
|
if (len != 0 && !strpbrk (a, " \t\n\r\""))
|
||||||
one_line.add (a, len);
|
one_line.add (a, len);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
one_line.add ("\"", 1);
|
one_line.add ("\"", 1);
|
||||||
for (; p; a = p, p = strchr (p, '"'))
|
for (0; p = strpbrk (a, "\"\\"); a = ++p)
|
||||||
{
|
{
|
||||||
one_line.add (a, ++p - a);
|
one_line.add (a, p - a);
|
||||||
if (p[-1] == '"')
|
if (*p == '\\' || *p == '"')
|
||||||
one_line.add ("\"", 1);
|
one_line.add ("\\", 1);
|
||||||
|
one_line.add (p, 1);
|
||||||
}
|
}
|
||||||
if (*a)
|
if (*a)
|
||||||
one_line.add (a);
|
one_line.add (a);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user