* spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to fix it.

This commit is contained in:
Christopher Faylor 2000-11-20 22:10:13 +00:00
parent 099efae038
commit 9784d54da8
2 changed files with 25 additions and 6 deletions

View File

@ -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>
* spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of

View File

@ -480,17 +480,31 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
else
{
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)
{
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);
p++;
one_line.add (p, n); /* Add the run of backslashes */
/* 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)
one_line.add (a);