From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/batch.c | 26 +++++++++++------------- programs/cmd/tests/test_builtins.cmd.exp | 2 +- programs/cmd/wcmdmain.c | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c index 035f8accc00..e015179239a 100644 --- a/programs/cmd/batch.c +++ b/programs/cmd/batch.c @@ -655,24 +655,22 @@ RETURN_CODE WCMD_call(WCHAR *command) { RETURN_CODE return_code; WCHAR buffer[MAXSTRING]; + WCHAR *start; + WCMD_expand(command, buffer);
+ /* (call) shall return 1, while (call ) returns 0 */ + start = WCMD_skip_leading_spaces(buffer); + if (*start == L'\0') + return_code = errorlevel = start == buffer ? ERROR_INVALID_FUNCTION : NO_ERROR; /* Run other program if no leading ':' */ - if (*command != ':') + else if (*start != ':') { - if (*WCMD_skip_leading_spaces(buffer) == L'\0') - /* FIXME it's incomplete as (call) should return 1, and (call ) should return 0... - * but we need to get the untouched string in command - */ - return_code = errorlevel = NO_ERROR; - else - { - WCMD_call_command(buffer); - /* If the thing we try to run does not exist, call returns 1 */ - if (errorlevel == RETURN_CODE_CANT_LAUNCH) - errorlevel = ERROR_INVALID_FUNCTION; - return_code = errorlevel; - } + WCMD_call_command(start); + /* If the thing we try to run does not exist, call returns 1 */ + if (errorlevel == RETURN_CODE_CANT_LAUNCH) + errorlevel = ERROR_INVALID_FUNCTION; + return_code = errorlevel; } else if (WCMD_is_in_context(NULL)) { diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 1909bb9a8c1..72395eb7007 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1972,7 +1972,7 @@ Should expand foobaz batfile robinfile 0 -@todo_wine@1 +1 1 1 non-builtin dir diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 869bf3962b9..ec61c7704ca 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2221,7 +2221,7 @@ RETURN_CODE WCMD_run_builtin_command(int cmd_index, WCHAR *cmd) switch (cmd_index) { case WCMD_CALL: - return_code = WCMD_call(parms_start); + return_code = WCMD_call(&cmd[count]); break; case WCMD_CD: case WCMD_CHDIR: