summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-02-25 07:56:11 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-02-25 07:56:11 (GMT)
commit8858a0f2c933c07a3c497ac705e2e06463a04ff3 (patch)
tree64a789ad55c9c8175acaf44a9de7a8466fb86f52 /win
parent50a0199fe10d0229bca2a3a82c4399d1544e3f11 (diff)
downloadtcl-8858a0f2c933c07a3c497ac705e2e06463a04ff3.zip
tcl-8858a0f2c933c07a3c497ac705e2e06463a04ff3.tar.gz
tcl-8858a0f2c933c07a3c497ac705e2e06463a04ff3.tar.bz2
backport of BuildCommandLine changes to mirror msvcrt's parse_cmdline() rules of quoting
Diffstat (limited to 'win')
-rw-r--r--win/tclWinPipe.c26
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);
}