diff options
Diffstat (limited to 'osdep/subprocess-win.c')
-rw-r--r-- | osdep/subprocess-win.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index 7ea6d39cba..6c9ccf2382 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -54,22 +54,22 @@ static void write_arg(bstr *cmdline, char *arg) for (int pos = 0; arg[pos]; pos++) { switch (arg[pos]) { case '\\': - // Count backslashes that appear in a row + // Count consecutive backslashes num_slashes++; break; case '"': + // Write the argument up to the point before the quote bstr_xappend(NULL, cmdline, (struct bstr){arg, pos}); + arg += pos; + pos = 0; - // Double preceding slashes + // Double backslashes preceding the quote for (int i = 0; i < num_slashes; i++) bstr_xappend(NULL, cmdline, bstr0("\\")); + num_slashes = 0; - // Escape the following quote + // Escape the quote itself bstr_xappend(NULL, cmdline, bstr0("\\")); - - arg += pos; - pos = 0; - num_slashes = 0; break; default: num_slashes = 0; @@ -79,7 +79,7 @@ static void write_arg(bstr *cmdline, char *arg) // Write the rest of the argument bstr_xappend(NULL, cmdline, bstr0(arg)); - // Double slashes that appear at the end of the string + // Double backslashes at the end of the argument for (int i = 0; i < num_slashes; i++) bstr_xappend(NULL, cmdline, bstr0("\\")); |