Commit 6ce3c2a1 by Richard Kenner

(fix_argv): Rewrite.

From-SVN: r9013
parent 3709124d
...@@ -2163,39 +2163,42 @@ pexecute (search_flag, program, argv, not_last) ...@@ -2163,39 +2163,42 @@ pexecute (search_flag, program, argv, not_last)
#ifdef WINNT #ifdef WINNT
char ** /* This is a kludge to get around the Microsoft C spawn functions' propensity
to remove the outermost set of double quotes from all arguments. */
const char * const
fix_argv (argvec) fix_argv (argvec)
char **argvec char **argvec;
{ {
int i; int i;
for (i = 1; argvec[i] != 0; i++) for (i = 1; argvec[i] != 0; i++)
{ {
int len, j; int len, j;
char *temp, *newtemp; char *temp, *newtemp;
temp = argvec[i]; temp = argvec[i];
len = strlen (temp); len = strlen (temp);
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
{ {
if (temp[j] == '"') if (temp[j] == '"')
{ {
newtemp = xmalloc (len + 2); newtemp = xmalloc (len + 2);
strncpy (newtemp, temp, j); strncpy (newtemp, temp, j);
newtemp [j] = '\\'; newtemp [j] = '\\';
strncpy (&newtemp [j+1], &temp [j], len-j); strncpy (&newtemp [j+1], &temp [j], len-j);
newtemp [len+1] = 0; newtemp [len+1] = 0;
free (temp); free (temp);
temp = newtemp; temp = newtemp;
len++; len++;
j++; j++;
} }
} }
argvec[i] = temp; argvec[i] = temp;
} }
return argvec; return (const char* const*) argvec;
} }
#define FIX_ARGV(a) fix_argv(a) #define FIX_ARGV(a) fix_argv(a)
...@@ -2204,7 +2207,7 @@ fix_argv (argvec) ...@@ -2204,7 +2207,7 @@ fix_argv (argvec)
#define FIX_ARGV(a) a #define FIX_ARGV(a) a
#endif /* OS2 or WINNT */ #endif
static int static int
pexecute (search_flag, program, argv, not_last) pexecute (search_flag, program, argv, not_last)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment