From 1c991334c489b66b7b3ea8e649792f57d0e5fa61 Mon Sep 17 00:00:00 2001 From: davygrvy Date: Mon, 2 Feb 2004 01:13:10 +0000 Subject: * 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. --- win/tclWinPipe.c | 20 ++++++++++++-------- 1 file 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); } -- cgit v0.12