mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-17 02:58:56 +08:00
pexecute.c: Conditionally include string.h.
2000-01-04 Mumit Khan <khan@xraylith.wisc.edu> * pexecute.c: Conditionally include string.h. (fix_argv): Handle embedded whitespace in args for Mingw32. From-SVN: r31214
This commit is contained in:
parent
6be57663c9
commit
aeecce429e
@ -1,3 +1,8 @@
|
||||
2000-01-04 Mumit Khan <khan@xraylith.wisc.edu>
|
||||
|
||||
* pexecute.c: Conditionally include string.h.
|
||||
(fix_argv): Handle embedded whitespace in args for Mingw32.
|
||||
|
||||
2000-01-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* configure.in (ac_libiberty_warn_cflags): Turn on warnings if
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Utilities to execute a program in a subprocess (possibly linked by pipes
|
||||
with other subprocesses), and wait for it.
|
||||
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the libiberty library.
|
||||
Libiberty is free software; you can redistribute it and/or
|
||||
@ -29,6 +29,9 @@ Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -279,6 +282,45 @@ fix_argv (argvec)
|
||||
argvec[i] = temp;
|
||||
}
|
||||
|
||||
for (i = 0; argvec[i] != 0; i++)
|
||||
{
|
||||
if (strpbrk (argvec[i], " \t"))
|
||||
{
|
||||
int len, trailing_backslash;
|
||||
char *temp;
|
||||
|
||||
len = strlen (argvec[i]);
|
||||
trailing_backslash = 0;
|
||||
|
||||
/* There is an added complication when an arg with embedded white
|
||||
space ends in a backslash (such as in the case of -iprefix arg
|
||||
passed to cpp). The resulting quoted strings gets misinterpreted
|
||||
by the command interpreter -- it thinks that the ending quote
|
||||
is escaped by the trailing backslash and things get confused.
|
||||
We handle this case by escaping the trailing backslash, provided
|
||||
it was not escaped in the first place. */
|
||||
if (len > 1
|
||||
&& argvec[i][len-1] == '\\'
|
||||
&& argvec[i][len-2] != '\\')
|
||||
{
|
||||
trailing_backslash = 1;
|
||||
++len; /* to escape the final backslash. */
|
||||
}
|
||||
|
||||
len += 2; /* and for the enclosing quotes. */
|
||||
|
||||
temp = xmalloc (len + 1);
|
||||
temp[0] = '"';
|
||||
strcpy (temp + 1, argvec[i]);
|
||||
if (trailing_backslash)
|
||||
temp[len-2] = '\\';
|
||||
temp[len-1] = '"';
|
||||
temp[len] = '\0';
|
||||
|
||||
argvec[i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
return (const char * const *) argvec;
|
||||
}
|
||||
#endif /* __CYGWIN__ */
|
||||
|
Loading…
Reference in New Issue
Block a user