diff options
author | davygrvy <davygrvy@pobox.com> | 2004-02-25 07:56:11 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@pobox.com> | 2004-02-25 07:56:11 (GMT) |
commit | b2af67fc995eddbfe39d32b68be14461e0a74891 (patch) | |
tree | 64a789ad55c9c8175acaf44a9de7a8466fb86f52 /win | |
parent | ae3a5b922a404fb74f27e5a721cf25beda7cccfb (diff) | |
download | tcl-b2af67fc995eddbfe39d32b68be14461e0a74891.zip tcl-b2af67fc995eddbfe39d32b68be14461e0a74891.tar.gz tcl-b2af67fc995eddbfe39d32b68be14461e0a74891.tar.bz2 |
backport of BuildCommandLine changes to mirror msvcrt's parse_cmdline() rules of quoting
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinPipe.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 320f99e..ffc6429 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.33.2.5 2003/10/21 22:57:18 andreas_kupries Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.33.2.6 2004/02/25 07:56:21 davygrvy Exp $ */ #include "tclWinInt.h" @@ -1577,10 +1577,9 @@ BuildCommandLine( arg = executable; } else { arg = argv[i]; + Tcl_DStringAppend(&ds, " ", 1); } - if(Tcl_DStringLength(&ds) > 0) Tcl_DStringAppend(&ds, " ", 1); - quote = 0; if (arg[0] == '\0') { quote = 1; @@ -1598,47 +1597,42 @@ BuildCommandLine( if (quote) { Tcl_DStringAppend(&ds, "\"", 1); } - start = arg; for (special = arg; ; ) { if ((*special == '\\') && - (special[1] == '\\' || special[1] == '"')) { - Tcl_DStringAppend(&ds, start, special - start); + (special[1] == '\\' || special[1] == '"' || (quote && special[1] == '\0'))) { + Tcl_DStringAppend(&ds, start, (int) (special - start)); start = special; while (1) { special++; - if (*special == '"') { + if (*special == '"' || (quote && *special == '\0')) { /* * N backslashes followed a quote -> insert * N * 2 + 1 backslashes then a quote. */ - Tcl_DStringAppend(&ds, start, special - start); + Tcl_DStringAppend(&ds, start, + (int) (special - start)); break; } if (*special != '\\') { break; } } - Tcl_DStringAppend(&ds, start, special - start); + Tcl_DStringAppend(&ds, start, (int) (special - start)); start = special; } if (*special == '"') { - Tcl_DStringAppend(&ds, start, special - start); + Tcl_DStringAppend(&ds, start, (int) (special - start)); Tcl_DStringAppend(&ds, "\\\"", 2); start = special + 1; } - if (*special == '{') { - Tcl_DStringAppend(&ds, start, special - start); - Tcl_DStringAppend(&ds, "\\{", 2); - start = special + 1; - } if (*special == '\0') { break; } special++; } - Tcl_DStringAppend(&ds, start, special - start); + Tcl_DStringAppend(&ds, start, (int) (special - start)); if (quote) { Tcl_DStringAppend(&ds, "\"", 1); } |