diff --git a/libiberty/argv.c b/libiberty/argv.c index 3084248..b5cf71f 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -177,7 +177,8 @@ returned, as appropriate. */ -char **buildargv (const char *input) +char ** +buildargv (const char *input) { char *arg; char *copybuf; @@ -189,6 +190,15 @@ char **buildargv (const char *input) char **argv = NULL; char **nargv; +/* On Windows hosts, the backslash character should not be treated + as an escape character. Define a constant bs_is_escape whose value + is non-zero when the backslash is an escape character. */ +#if !defined (__MINGW32__) + const int bs_is_escape = 1; +#else + const int bs_is_escape = 0; +#endif + if (input != NULL) { copybuf = (char *) alloca (strlen (input) + 1); @@ -234,12 +244,12 @@ char **buildargv (const char *input) } else { - if (bsquote) + if (bs_is_escape && bsquote) { bsquote = 0; *arg++ = *input; } - else if (*input == '\\') + else if (bs_is_escape && (*input == '\\')) { bsquote = 1; }