From: Eric Pouech <epouech(a)codeweavers.com> Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/cmd/tests/batch.c | 11 +++++++++++ programs/cmd/tests/test_builtins.cmd | 23 ++++++++++++++++++++++- programs/cmd/tests/test_builtins.cmd.exp | 24 +++++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c index 5c5b0ab7287..c4421aa3f6c 100644 --- a/programs/cmd/tests/batch.c +++ b/programs/cmd/tests/batch.c @@ -207,6 +207,7 @@ static const char *compare_line(const char *out_line, const char *out_end, const { const char *out_ptr = out_line, *exp_ptr = exp_line; const char *err = NULL; + char ch; static const char pwd_cmd[] = {'@','p','w','d','@'}; static const char drive_cmd[] = {'@','d','r','i','v','e','@'}; @@ -216,6 +217,7 @@ static const char *compare_line(const char *out_line, const char *out_end, const static const char spaces_cmd[] = {'@','s','p','a','c','e','s','@'}; static const char tab_cmd[] = {'@','t','a','b','@'}; static const char formfeed_cmd[] = {'@','f','o','r','m', 'f', 'e', 'e', 'd', '@'}; + static const char hexadecimal_cmd[] = {'@','\\','x','0','0', '@'}; static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'}; while(exp_ptr < exp_end) { @@ -300,6 +302,15 @@ static const char *compare_line(const char *out_line, const char *out_end, const } else { err = out_end; } + }else if(exp_ptr+sizeof(hexadecimal_cmd) <= exp_end && + parse_hexadecimal(exp_ptr, &ch)) { + exp_ptr += sizeof(hexadecimal_cmd); + if(out_ptr < out_end && *out_ptr == ch) { + out_ptr++; + continue; + } else { + err = out_end; + } }else if(exp_ptr+sizeof(or_broken_cmd) <= exp_end && !memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) { if(out_ptr == out_end) diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 7d0dc27b1e0..f706a3ef57d 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -31,13 +31,26 @@ echo @tab(a)word echo @tab(a)word echo(a)tab@@tab(a)word echo @tab@ on @space@ +> nul echo a +if(a)tab@1 == 2 then @echo a +(a)rem native stores the keyword (and preserve the case) :-( +IF(a)tab@1 == 2 ThEn @EchO a +(a)rem echo is done at execution time +(a)for %%a in (1 2) do echo %%a +(a)echo --- +(a)rem this convoluted code captures ^H inside BS env variable +(a)for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do @set "BS=%%a" +(a)echo AA%BS%BB @echo --- @ with chains and brackets (echo the @ character chains until&&@echo we leave the current depth||( echo hidden @echo hidden ))&&echo and can hide brackets||(@echo command hidden)||@(echo brackets hidden) @echo --- - +(a)set V=@ +%V%echo foo1 +> nul echo a && @echo foo2 +(a)echo --- @echo off echo off(a)tab@@space@ @echo noecho1 @@ -1346,6 +1359,14 @@ set WINE_FOO=foo bar if !WINE_FOO!=="" (echo empty) else echo not empty setlocal DisableDelayedExpansion +echo --- nested expansion +setlocal EnableDelayedExpansion +set WINE_FOO_bar23=foo +set WINE_BAR=bar +set WINE_BAR=bar2 && echo !WINE_FOO_%WINE_BAR%23! +for %%a in (bar) do echo !WINE_FOO_%%a23! +endlocal + echo --- using /V cmd flag echo @echo off> tmp.cmd echo set WINE_FOO=foo>> tmp.cmd diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 72395eb7007..6979c642085 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -88,13 +88,32 @@ word @tab(a)word @pwd@>echo @tab@ on @space@@space@ ---- @ with chains and brackets + +(a)todo_wine@@pwd@>echo a 1>nul(a)space@ + +(a)todo_wine@@pwd@>if 1 == 2 then @echo a(a)space@ + +(a)todo_wine@@pwd@>IF 1 == 2 ThEn @EchO a(a)space@ +(a)todo_wine@ +(a)todo_wine@@pwd@>echo 1(a)space@ +(a)todo_wine@1 +(a)todo_wine@ +(a)todo_wine@@pwd@>echo 2(a)space@ +(a)todo_wine@2 +(a)todo_wine@--- +(a)todo_wine@AA@\x08(a)BB +(a)todo_wine@--- @ with chains and brackets @todo_wine@@pwd@>(echo the @ character chains until && ) && echo and can hide brackets || () ||@space@ @todo_wine(a)the @ character chains until @todo_wine(a)we leave the current depth @todo_wine(a)and can hide brackets @todo_wine(a)--- +foo1 + +(a)todo_wine@@pwd@>echo a 1>nul &&@space@ +foo2 +--- noecho1 noecho2 echo3 @@ -967,6 +986,9 @@ gotitright foo !WINE_FOO! not empty +--- nested expansion +foo +(a)todo_wine@foo --- using /V cmd flag foo foo(a)or_broken@!WINE_FOO! -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9554