diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index ebb1c801103..e28ff10e8e3 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1364,7 +1364,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { WINE_TRACE("FOR /L provided range from %d to %d step %d\n", numbers[0], numbers[2], numbers[1]); for (i=numbers[0]; - (numbers[1]<0)? i>numbers[2] : i=numbers[2] : i<=numbers[2]; i=i + numbers[1]) { sprintfW(thisNum, fmt, i); diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 6295f9e311f..48565784fa1 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -673,12 +673,18 @@ for /L %%i in (1,2,a) do echo %%i echo ErrorLevel %ErrorLevel% for /L %%i in (1,a,b) do echo %%i echo ErrorLevel %ErrorLevel% -rem FIXME: following test cases cannot be currently tested due to an inconsistent/buggy 'for /L' parsing. -rem for /L %%i in (a,2,b) do echo %%i -rem for /L %%i in (1,1,1) do echo %%i -rem for /L %%i in (1,-2,-1) do echo %%i -rem for /L %%i in (-1,-1,-1) do echo %%i -rem for /L %%i in (1,2, 3) do echo %%i +rem Test boundaries +for /l %%i in (1,1,4) do echo %%i +for /l %%i in (1,2,4) do echo %%i +for /l %%i in (4,-1,1) do echo %%i +for /l %%i in (4,-2,1) do echo %%i +for /l %%i in (1,-1,4) do echo %%i +for /l %%i in (4,1,1) do echo %%i +for /L %%i in (a,2,b) do echo %%i +for /L %%i in (1,1,1) do echo %%i +for /L %%i in (1,-2,-1) do echo %%i +for /L %%i in (-1,-1,-1) do echo %%i +for /L %%i in (1,2, 3) do echo %%i echo --- for /a rem No output when using "set expr" syntax, unless in interactive mode rem Need to use "set envvar=expr" to use in a batch script diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index bb7551515b8..0011d35a563 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -471,6 +471,25 @@ bar -1 @todo_wine@ErrorLevel 0 @todo_wine@ErrorLevel 0 +1 +2 +3 +4 +1 +3 +4 +3 +2 +1 +4 +2 +0 +1 +1 +-1 +-1 +1 +3 --- for /a ------ individual operations 0