summaryrefslogtreecommitdiffstats
path: root/win/tclWinPipe.c
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-02-02 01:13:10 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-02-02 01:13:10 (GMT)
commit1c991334c489b66b7b3ea8e649792f57d0e5fa61 (patch)
tree3a68d5407d1c70877a766410144ebf8591fa225f /win/tclWinPipe.c
parent6ba5dd96a90ef6765759eeefe793ba6de434aa9e (diff)
downloadtcl-1c991334c489b66b7b3ea8e649792f57d0e5fa61.zip
tcl-1c991334c489b66b7b3ea8e649792f57d0e5fa61.tar.gz
tcl-1c991334c489b66b7b3ea8e649792f57d0e5fa61.tar.bz2
* tests/winPipe.test: Added proof that BuildCommandLine() is not
doing the "N backslashes followed a quote -> insert N * 2 + 1 backslashes then a quote" rule needed for the crt's parse_cmdline(). * win/tclWinPipe.c: Fixed BuildCommandLine() to pass the new cases.
Diffstat (limited to 'win/tclWinPipe.c')
-rw-r--r--win/tclWinPipe.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 36ff112..4d3a7ac 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.41 2004/02/01 09:37:49 davygrvy Exp $
+ * RCS: @(#) $Id: tclWinPipe.c,v 1.42 2004/02/02 01:13:10 davygrvy Exp $
*/
#include "tclWinInt.h"
@@ -1601,12 +1601,11 @@ 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++;
@@ -1616,18 +1615,23 @@ BuildCommandLine(
* 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);
+ /*
+ * Do it twice when arg is quoted.
+ */
+ if (quote) Tcl_DStringAppend(&ds, start, (int) (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;
}
@@ -1636,7 +1640,7 @@ BuildCommandLine(
}
special++;
}
- Tcl_DStringAppend(&ds, start, special - start);
+ Tcl_DStringAppend(&ds, start, (int) (special - start));
if (quote) {
Tcl_DStringAppend(&ds, "\"", 1);
}