Module: wine Branch: stable Commit: 64f6a650d11db0e49715a8956f962b1aaec39a89 URL: https://source.winehq.org/git/wine.git/?a=commit;h=64f6a650d11db0e49715a8956...
Author: Fabian Maurer dark.shadow4@web.de Date: Sat Feb 3 17:13:11 2018 +0100
cmd.exe: Parse parameters in "FOR /F" properly.
We must not remove the quotes from parameters, or strings like "param=value" will get parsed incorrectly.
Signed-off-by: Fabian Maurer dark.shadow4@web.de Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit e62000c5c0ba17be6d3c6397e04604407cfb7601) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
programs/cmd/builtins.c | 2 +- programs/cmd/tests/test_builtins.cmd | 10 ++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 14961d7..ec66cd5 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1978,7 +1978,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart, anyduplicates |= thisduplicate;
/* Extract the token number requested and set into the next variable context */ - parm = WCMD_parameter_with_delims(buffer, (nexttoken-1), NULL, FALSE, FALSE, forf_delims); + parm = WCMD_parameter_with_delims(buffer, (nexttoken-1), NULL, TRUE, FALSE, forf_delims); WINE_TRACE("Parsed token %d(%d) as parameter %s\n", nexttoken, varidx + varoffset, wine_dbgstr_w(parm)); if (varidx >=0) { diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 62334b1..f684628 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1696,6 +1696,16 @@ for /f "tokens=2,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o cd .. rd /s/q foobar +echo ------ parameter splitting +echo forFParameterSplittingFunc "myparam1=myvalue1 myparam2=myparam2" mytest> foo +for /f "tokens=1 delims=;" %%i in (foo) do (call :%%i) +del foo +for /f "tokens=1 delims=;" %%i in ("forFParameterSplittingFunc "myparam1^=myvalue1 myparam2^=myparam2" mytest") do (call :%%i) +goto :forFParameterSplittingEnd +:forFParameterSplittingFunc +echo %~0 %~1 %~2 %~3 %~4 %~5 +goto :eof +:forFParameterSplittingEnd
echo ------------ Testing del ------------ echo abc > file diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 796550e..4663c86 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1222,6 +1222,9 @@ h=%h i=a j=b k=c l=d e f g m=%m n=%n o=%o@or_broken@h=%h i=a j=b k=c l=d e f g m h=%h i=a j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=a j=c k= l= m= n=%n o=%o h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o +------ parameter splitting +:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@ +:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@ ------------ Testing del ------------ deleting 'file' errorlevel is 0, good