From f45f75ca7dece7b7549d457c6215aa314016b4b3 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Sat, 13 Oct 2012 22:24:35 +0100 Subject: [PATCH] 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 7e08b292c25..0442a38b991 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 4ea4ce0a903..0317a99dc64 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@space@ 1:"p@space@"1,2:p"@space@"2@space@ 1:p"1@space@p",2:2@space@ +--------- Testing delimiters and parameter passing -------------- +0:tell,1:1,2:2,All:'1 2'@or_broken@0:tell,1:1,2:2,All:' 1 2' +0:tell,1:1,2:2,All:'1 2'@or_broken@0:tell,1:1,2:2,All:' 1 2' +0:tell,1:1,2:2,All:'==1==2' +@todo_wine@0:tell,1:(1234),2:,All:'(1234)' +@todo_wine@0:tell,1:(12(34),2:,All:'(12(34)' +@todo_wine@0:tell,1:(12,2:34),All:'(12;34)' +@todo_wine@--------- Finished -------------- diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index eb0897af41b..f60ba849534 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 &&