mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to fix it.
This commit is contained in:
parent
099efae038
commit
9784d54da8
@ -1,3 +1,8 @@
|
|||||||
|
Mon Nov 20 17:04:43 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to
|
||||||
|
fix it.
|
||||||
|
|
||||||
Mon Nov 20 14:26:38 2000 Christopher Faylor <cgf@cygnus.com>
|
Mon Nov 20 14:26:38 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of
|
* spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of
|
||||||
|
@ -480,17 +480,31 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
one_line.add ("\"", 1);
|
one_line.add ("\"", 1);
|
||||||
|
/* Handle embedded special characters " and \.
|
||||||
|
A " is always preceded by a \.
|
||||||
|
A \ is not special unless it precedes a ". If it does,
|
||||||
|
then all preceding \'s must be doubled to avoid having
|
||||||
|
the Windows command line parser interpret the \ as quoting
|
||||||
|
the ". This rule applies to a string of \'s before the end
|
||||||
|
of the string, since cygwin/windows uses a " to delimit the
|
||||||
|
argument. */
|
||||||
for (; (p = strpbrk (a, "\"\\")); a = ++p)
|
for (; (p = strpbrk (a, "\"\\")); a = ++p)
|
||||||
{
|
{
|
||||||
one_line.add (a, p - a);
|
one_line.add (a, p - a);
|
||||||
if (*p == '\\' && p[1] == '\\')
|
/* Find length of string of backslashes */
|
||||||
|
int n = strspn (p, "\\");
|
||||||
|
if (!n)
|
||||||
|
one_line.add ("\\\"", 2); /* No backslashes, so it must be a ".
|
||||||
|
The " has to be protected with a backslash. */
|
||||||
|
else
|
||||||
{
|
{
|
||||||
one_line.add ("\\\\\\", 3);
|
one_line.add (p, n); /* Add the run of backslashes */
|
||||||
p++;
|
/* Need to double up all of the preceding
|
||||||
|
backslashes if they precede a quote or EOS. */
|
||||||
|
if (!p[n] || p[n] == '"')
|
||||||
|
one_line.add (p, n);
|
||||||
|
p += n - 1; /* Point to last backslash */
|
||||||
}
|
}
|
||||||
else if ((*p == '\\' && p[1] == '"') || *p == '"')
|
|
||||||
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