From 90df62b250b6b243f717cedebfd659b964a94714 Mon Sep 17 00:00:00 2001 From: davygrvy Date: Mon, 2 Feb 2004 02:36:14 +0000 Subject: * tests/winPipe.test: Six more cases added. * win/tclWinPipe.c: Fixed BuildCommandLine() to pass the new cases. --- tests/winPipe.test | 30 ++++++++++++++++++++++++------ win/tclWinPipe.c | 8 ++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tests/winPipe.test b/tests/winPipe.test index 75027e6..4ed7b08 100644 --- a/tests/winPipe.test +++ b/tests/winPipe.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: winPipe.test,v 1.25 2004/02/02 01:34:54 davygrvy Exp $ +# RCS: @(#) $Id: winPipe.test,v 1.26 2004/02/02 02:36:14 davygrvy Exp $ package require tcltest namespace import -force ::tcltest::* @@ -357,10 +357,19 @@ test winpipe-7.12 {BuildCommandLine: N backslashes followed a quote rule #4} {pc test winpipe-7.13 {BuildCommandLine: N backslashes followed a quote rule #5} {pcOnly exec} { exec $env(COMSPEC) /c echo foo \\\ \\\\\\ bar } {foo "\ \\\\\\" bar} -test winpipe-7.14 {BuildCommandLine: special chars #4} {pcOnly exec} { +test winpipe-7.14 {BuildCommandLine: N backslashes followed a quote rule #6} {pcOnly exec} { + exec $env(COMSPEC) /c echo foo \\\ \\\" bar +} {foo "\ \\\"" bar} +test winpipe-7.15 {BuildCommandLine: N backslashes followed a quote rule #7} {pcOnly exec} { + exec $env(COMSPEC) /c echo foo \\\ \\\\\" bar +} {foo "\ \\\\\"" bar} +test winpipe-7.16 {BuildCommandLine: N backslashes followed a quote rule #8} {pcOnly exec} { + exec $env(COMSPEC) /c echo foo \\\ \\\\\\\" bar +} {foo "\ \\\\\\\"" bar} +test winpipe-7.17 {BuildCommandLine: special chars #4} {pcOnly exec} { exec $env(COMSPEC) /c echo foo \{ bar } "foo \{ bar" -test winpipe-7.15 {BuildCommandLine: special chars #5} {pcOnly exec} { +test winpipe-7.18 {BuildCommandLine: special chars #5} {pcOnly exec} { exec $env(COMSPEC) /c echo foo \} bar } "foo \} bar" @@ -405,13 +414,22 @@ test winpipe-8.12 {BuildCommandLine/parse_cmdline pass-thru: N backslashes follo test winpipe-8.13 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #5} {pcOnly exec} { exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\\ bar } [list $path(echoArgs.tcl) [list foo \\\ \\\\\\ bar]] -test winpipe-8.14 {BuildCommandLine/parse_cmdline pass-thru: special chars #1} {pcOnly exec} { +test winpipe-8.14 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #6} {pcOnly exec} { + exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\" bar +} [list $path(echoArgs.tcl) [list foo \\\ \\\" bar]] +test winpipe-8.15 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #7} {pcOnly exec} { + exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\" bar +} [list $path(echoArgs.tcl) [list foo \\\ \\\\\" bar]] +test winpipe-8.16 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #8} {pcOnly exec} { + exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\\\" bar +} [list $path(echoArgs.tcl) [list foo \\\ \\\\\\\" bar]] +test winpipe-8.17 {BuildCommandLine/parse_cmdline pass-thru: special chars #1} {pcOnly exec} { exec [interpreter] $path(echoArgs.tcl) foo \{ bar } [list $path(echoArgs.tcl) [list foo \{ bar]] -test winpipe-8.15 {BuildCommandLine/parse_cmdline pass-thru: special chars #2} {pcOnly exec} { +test winpipe-8.18 {BuildCommandLine/parse_cmdline pass-thru: special chars #2} {pcOnly exec} { exec [interpreter] $path(echoArgs.tcl) foo \} bar } [list $path(echoArgs.tcl) [list foo \} bar]] -test winpipe-8.16 {ensure parse_cmdline isn't doing wildcard replacement} {pcOnly exec} { +test winpipe-8.19 {ensure parse_cmdline isn't doing wildcard replacement} {pcOnly exec} { exec [interpreter] $path(echoArgs.tcl) foo * makefile.?c bar } [list $path(echoArgs.tcl) [list foo * makefile.?c bar]] diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 4d3a7ac..469952e 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.42 2004/02/02 01:13:10 davygrvy Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.43 2004/02/02 02:36:15 davygrvy Exp $ */ #include "tclWinInt.h" @@ -1609,7 +1609,7 @@ BuildCommandLine( 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. @@ -1623,10 +1623,6 @@ BuildCommandLine( break; } } - /* - * 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; } -- cgit v0.12