Module: wine Branch: master Commit: a78746972fd19b6facec7e0cc596c3ed27a0f131 URL: https://gitlab.winehq.org/wine/wine/-/commit/a78746972fd19b6facec7e0cc596c3e...
Author: Eric Pouech epouech@codeweavers.com Date: Mon Jul 15 15:26:04 2024 +0200
cmd: Set success/failure for change drive command.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
programs/cmd/tests/test_builtins.cmd.exp | 4 ++-- programs/cmd/wcmdmain.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 58b4dcfb00e..0ad3b0c80bd 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -534,9 +534,9 @@ SUCCESS 0 FAILURE 1 FAILURE 1 --- success/failure for change drive command -@todo_wine@SUCCESS 666 +SUCCESS 666 FAILURE 1 -@todo_wine@SUCCESS 0 +SUCCESS 0 FAILURE 1 --- success/failure for MKDIR,MD command FAILURE 1 diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 5f55e4c8d9e..dd49f2ab65d 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1732,7 +1732,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) { RETURN_CODE return_code; WCHAR *cmd, *parms_start; - int status, cmd_index, count; + int cmd_index, count; WCHAR *whichcmd; WCHAR *new_cmd = NULL; BOOL prev_echo_mode; @@ -1767,27 +1767,29 @@ static RETURN_CODE execute_single_command(const WCHAR *command) * else if it exists after whitespace is ignored */
- if ((cmd[1] == ':') && IsCharAlphaW(cmd[0]) && - (!cmd[2] || cmd[2] == ' ' || cmd[2] == '\t')) { + if (cmd[1] == L':' && (!cmd[2] || iswspace(cmd[2]))) { WCHAR envvar[5]; WCHAR dir[MAX_PATH];
/* Ignore potential garbage on the same line */ - cmd[2]=0x00; + cmd[2] = L'\0';
/* According to MSDN CreateProcess docs, special env vars record the current directory on each drive, in the form =C: so see if one specified, and if so go back to it */ lstrcpyW(envvar, L"="); lstrcatW(envvar, cmd); - if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) { + if (GetEnvironmentVariableW(envvar, dir, ARRAY_SIZE(dir)) == 0) { wsprintfW(cmd, L"%s\", cmd); WINE_TRACE("No special directory settings, using dir of %s\n", wine_dbgstr_w(cmd)); } WINE_TRACE("Got directory %s as %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(cmd)); - status = SetCurrentDirectoryW(cmd); - if (!status) WCMD_print_error (); - return_code = ERROR_INVALID_FUNCTION; + if (!SetCurrentDirectoryW(cmd)) + { + WCMD_print_error(); + return_code = errorlevel = ERROR_INVALID_FUNCTION; + } + else return_code = NO_ERROR; goto cleanup; }