Jason Edmeades : cmd: %* expands to first non-whitespace delimiter of first arg.

Alexandre Julliard julliard at winehq.org
Tue Oct 16 15:27:46 CDT 2012


Module: wine
Branch: master
Commit: f45f75ca7dece7b7549d457c6215aa314016b4b3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f45f75ca7dece7b7549d457c6215aa314016b4b3

Author: Jason Edmeades <jason at edmeades.me.uk>
Date:   Sat Oct 13 22:24:35 2012 +0100

cmd: %* expands to first non-whitespace delimiter of first arg.

---

 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 &&




More information about the wine-cvs mailing list