From 02ef22d50e513ba49488b1150cc37007f518199f Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Wed, 21 Nov 2001 02:15:47 +0000 Subject: [PATCH] Integrate change #13145 from maintperl; another compatibility tweak to change#12559: avoid quoting arguments that already have quotes; add test case p4raw-link: @13145 on //depot/maint-5.6/perl: dce2855c8524456fc5a80f5983430856fe9de05d p4raw-link: @12559 on //depot/maint-5.6/perl: c196af81e4de7395bbcca7607214cb47be8a55c0 p4raw-id: //depot/perl@13150 p4raw-integrated: from //depot/maint-5.6/perl@13148 'copy in' t/op/system_tests (@12747..) 'merge in' win32/win32.c (@13058..) --- t/op/system_tests | 26 ++++++++++++++++++-------- win32/win32.c | 18 ++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/t/op/system_tests b/t/op/system_tests index 8df8770..f73745a 100644 --- a/t/op/system_tests +++ b/t/op/system_tests @@ -1,5 +1,6 @@ #!perl +use Config; use Cwd; use strict; @@ -80,6 +81,7 @@ my @av = ( ["\ta b c ", " "], ["", "\ta b c ", "abc"], [" ", "\ta b c ", "abc"], + ['" "', 'a" "b" "c', "abc"], ); print "1.." . (@commands * @av * 2) . "\n"; @@ -89,21 +91,29 @@ for my $cmds (@commands) { my @cmds = defined($cmds) ? (ref($cmds) ? @$cmds : $cmds) : (); my @args = defined($args) ? (ref($args) ? @$args : $args) : (); print "######## [@cmds]\n"; - print "<", join('><', $cmds[$#cmds], @args), ">\n"; + print "<", join('><', + $cmds[$#cmds], + map { my $x = $_; $x =~ s/"//g; $x } @args), + ">\n"; if (system(@cmds,@args) != 0) { print "Failed, status($?)\n"; -# print "Running again in debug mode\n"; -# $^D = 1; # -Dp -# system(@cmds,@args); + if ($Config{ccflags} =~ /\bDDEBUGGING\b/) { + print "Running again in debug mode\n"; + $^D = 1; # -Dp + system(@cmds,@args); + } } $^D = 0; - my $cmdstr = join " ", map { /\s|^$/ ? qq["$_"] : $_ } @cmds, @args; + my $cmdstr = join " ", map { /\s|^$/ && !/\"/ + ? qq["$_"] : $_ } @cmds, @args; print "######## '$cmdstr'\n"; if (system($cmdstr) != 0) { print "Failed, status($?)\n"; -# print "Running again in debug mode\n"; -# $^D = 1; # -Dp -# system($cmdstr); + if ($Config{ccflags} =~ /\bDDEBUGGING\b/) { + print "Running again in debug mode\n"; + $^D = 1; # -Dp + system($cmdstr); + } } $^D = 0; } diff --git a/win32/win32.c b/win32/win32.c index 4c36cc7..2877da8 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3192,23 +3192,25 @@ create_command_line(char *cname, STRLEN clen, const char * const *args) if (!curlen) { do_quote = 1; } + else if (quote_next) { + /* see if it really is multiple arguments pretending to + * be one and force a set of quotes around it */ + if (*find_next_space(arg)) + do_quote = 1; + } else if (!(arg[0] == '"' && curlen > 1 && arg[curlen-1] == '"')) { STRLEN i = 0; while (i < curlen) { if (isSPACE(arg[i])) { do_quote = 1; + } + else if (arg[i] == '"') { + do_quote = 0; break; } i++; } } - else if (quote_next) { - /* ok, we know the argument already has quotes; see if it - * really is multiple arguments pretending to be one and - * force a set of quotes around it */ - if (*find_next_space(arg)) - do_quote = 1; - } } if (do_quote) @@ -3235,7 +3237,7 @@ create_command_line(char *cname, STRLEN clen, const char * const *args) extra_quotes = TRUE; } else { - /* single argument, force quoting if unquoted */ + /* single argument, force quoting if it has spaces */ quote_next = TRUE; } } -- 2.7.4