[PATCH 3/5] [cmd] %* expands to first non-whitespace delimiter of first arg
Ann and Jason Edmeades
jason at edmeades.me.uk
Mon Oct 15 18:53:32 CDT 2012
Expansion of %* should be all the args, and tests show that if the
first arg is prefixed by delimiters which the parsing will remove,
those delimiters are still included in the %*, unless they are
whitespace.
Note NT4, also includes the whitespace delimiters as well, hence
the broken parts to the tests.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121016/7ad78caf/attachment.html>
-------------- next part --------------
From 03f4e45a7f3f312a75b482f64f30aa0731bfb7c2 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <jason at edmeades.me.uk>
Date: Sat, 13 Oct 2012 22:24:35 +0100
Subject: [PATCH 3/5] [cmd] %* expands to first non-whitespace delimiter of
first arg
Expansion of %* should be all the args, and tests show that if the
first arg is prefixed by delimiters which the parsing will remove,
those delimiters are still included in the %*, unless they are
whitespace.
Note NT4, also includes the whitespace delimiters as well, hence
the broken parts to the tests.
---
programs/cmd/tests/test_cmdline.cmd | 10 ++++++++++
programs/cmd/tests/test_cmdline.cmd.exp | 8 ++++++++
programs/cmd/wcmdmain.c | 8 +++++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/programs/cmd/tests/test_cmdline.cmd b/programs/cmd/tests/test_cmdline.cmd
index 7e08b29..0442a38 100644
--- a/programs/cmd/tests/test_cmdline.cmd
+++ b/programs/cmd/tests/test_cmdline.cmd
@@ -251,6 +251,16 @@ call tell;1;;2
if errorlevel 2 echo error %ErrorLevel%
call tell "p "1 p" "2
call tell p"1 p";2
+
+echo --------- Testing delimiters and parameter passing --------------
+echo @echo 0:%%0,1:%%1,2:%%2,All:'%%*'> tell.bat
+call;tell 1 2
+call tell 1 2
+==call==tell==1==2
+call tell(1234)
+call tell(12(34)
+call tell(12;34)
+echo --------- Finished --------------
del tell.bat say*.*
exit
:setError
diff --git a/programs/cmd/tests/test_cmdline.cmd.exp b/programs/cmd/tests/test_cmdline.cmd.exp
index 4ea4ce0..0317a99 100644
--- a/programs/cmd/tests/test_cmdline.cmd.exp
+++ b/programs/cmd/tests/test_cmdline.cmd.exp
@@ -122,3 +122,11 @@ THIS FAILS: cmd ignoreme/c say one
1:1,2:2 at space@
1:"p at space@"1,2:p"@space@"2 at space@
1:p"1 at space@p",2:2 at space@
+--------- Testing delimiters and parameter passing --------------
+0:tell,1:1,2:2,All:'1 2'@or_broken at 0:tell,1:1,2:2,All:' 1 2'
+0:tell,1:1,2:2,All:'1 2'@or_broken at 0:tell,1:1,2:2,All:' 1 2'
+0:tell,1:1,2:2,All:'==1==2'
+ at todo_wine@0:tell,1:(1234),2:,All:'(1234)'
+ at todo_wine@0:tell,1:(12(34),2:,All:'(12(34)'
+ at todo_wine@0:tell,1:(12,2:34),All:'(12;34)'
+ at todo_wine@--------- Finished --------------
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index eb0897a..f60ba84 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -843,10 +843,12 @@ static void handleExpansion(WCHAR *cmd, BOOL justFors,
/* Replace use of %* if in batch program*/
} else if (!justFors && context && *(p+1)=='*') {
WCHAR *startOfParms = NULL;
- WCMD_parameter(context -> command, 1, &startOfParms, NULL, TRUE);
- if (startOfParms != NULL)
+ WCMD_parameter(context -> command, 0, NULL, &startOfParms, TRUE);
+ if (startOfParms != NULL) {
+ startOfParms++; /* Skip to first delimiter then skip whitespace */
+ while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++;
WCMD_strsubstW(p, p+2, startOfParms, -1);
- else
+ } else
WCMD_strsubstW(p, p+2, NULL, 0);
} else if (forVariable &&
--
1.7.9.5
More information about the wine-patches
mailing list