This is part XIII of the cmd engine rewrite.
This serie provides tests and fixes for the success/failure return codes used in file related commands.
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd | 58 ++++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 34 +++++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index d31cb3ef72a..ccdddd289bd 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -466,6 +466,64 @@ call :setError 666 & ((for %%i in () do echo "") &&echo SUCCESS !errorlevel!||ec call :setError 666 & ((for %%i in () do call :setError 33) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & ((for %%i in (a) do call :setError 0) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & ((for %%i in (a) do call :setError 33) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) + +echo --- success/failure for TYPE command +mkdir foo & cd foo +echo a > fileA +echo b > fileB +call :setError 666 & (type &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (type NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (type i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (type file* i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +echo --- +call :setError 666 & (type i\dont\exist\at\all.txt file* &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo + +echo --- success/failure for COPY command +mkdir foo & cd foo +echo a > fileA +echo b > fileB +call :setError 666 & (copy fileA >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (copy fileA fileZ >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (copy fileA fileZ /-Y >NUL <NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (copy fileA+fileD fileZ /-Y >NUL <NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (copy fileD+fileA fileZ /-Y >NUL <NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +if exist fileD echo Unexpected fileD +cd .. && rd /q /s foo + +echo --- success/failure for MOVE command +mkdir foo & cd foo +echo a > fileA +echo b > fileB +call :setError 666 & (move >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (move fileA fileC >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (move fileC nowhere\fileC >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (move fileD fileE >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (move fileC fileB /-Y >NUL <NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo + +echo --- success/failure for RENAME command +mkdir foo & cd foo +echo a > fileA +echo b > fileB +call :setError 666 & (rename fileB >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (rename fileB fileA >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (rename fileB nowhere\fileB >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (rename fileD fileC >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (rename fileB fileC >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo + +echo --- success/failure for ERASE command +mkdir foo & cd foo +echo a > fileA +echo b > fileB +echo e > fileE +call :setError 666 & (erase &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (erase fileE &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (erase i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (erase file* i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo + echo --- setlocal DisableDelayedExpansion echo ------------ Testing 'set' ------------ diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index c2dba03b740..58e115642b2 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -464,7 +464,39 @@ SUCCESS 666 SUCCESS 666 SUCCESS 0 FAILURE 33 ---- +--- success/failure for TYPE command +@todo_wine@FAILURE 1 +SUCCESS 0 +@todo_wine@FAILURE 1 +@todo_wine@a@space@ +@todo_wine@b@space@ +@todo_wine@FAILURE 1 +@todo_wine@--- +@todo_wine@FAILURE 1 +--- success/failure for COPY command +@todo_wine@FAILURE 1 +SUCCESS 0 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +--- success/failure for MOVE command +@todo_wine@FAILURE 1 +@todo_wine@SUCCESS 0 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +--- success/failure for RENAME command +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +SUCCESS 0 +--- success/failure for ERASE command +@todo_wine@FAILURE 1 +SUCCESS 0 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@--- ------------ Testing 'set' ------------ 1 0
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 12 +++++++----- programs/cmd/tests/test_builtins.cmd.exp | 6 +++--- programs/cmd/wcmd.h | 2 +- programs/cmd/wcmdmain.c | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 708e3c6dce6..2510735f00d 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3490,21 +3490,22 @@ void WCMD_title (const WCHAR *args) { * Copy a file to standard output. */
-void WCMD_type (WCHAR *args) { - +RETURN_CODE WCMD_type(WCHAR *args) +{ + RETURN_CODE return_code; int argno = 0; WCHAR *argN = args; BOOL writeHeaders = FALSE;
if (param1[0] == 0x00) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); - return; + return errorlevel = ERROR_INVALID_FUNCTION; }
if (param2[0] != 0x00) writeHeaders = TRUE;
/* Loop through all args */ - errorlevel = NO_ERROR; + return_code = NO_ERROR; while (argN) { WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
@@ -3520,7 +3521,7 @@ void WCMD_type (WCHAR *args) { if (h == INVALID_HANDLE_VALUE) { WCMD_print_error (); WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg); - errorlevel = ERROR_INVALID_FUNCTION; + return errorlevel = ERROR_INVALID_FUNCTION; } else { if (writeHeaders) { WCMD_output_stderr(L"\n%1\n\n\n", thisArg); @@ -3533,6 +3534,7 @@ void WCMD_type (WCHAR *args) { CloseHandle (h); } } + return errorlevel = return_code; }
/**************************************************************************** diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 58e115642b2..5919bcf4f77 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -465,14 +465,14 @@ SUCCESS 666 SUCCESS 0 FAILURE 33 --- success/failure for TYPE command -@todo_wine@FAILURE 1 +FAILURE 1 SUCCESS 0 -@todo_wine@FAILURE 1 +FAILURE 1 @todo_wine@a@space@ @todo_wine@b@space@ @todo_wine@FAILURE 1 @todo_wine@--- -@todo_wine@FAILURE 1 +FAILURE 1 --- success/failure for COPY command @todo_wine@FAILURE 1 SUCCESS 0 diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 9f8bdd46044..44cdd415fbe 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -202,7 +202,7 @@ void WCMD_setshow_time (void); void WCMD_shift (const WCHAR *args); void WCMD_start (WCHAR *args); void WCMD_title (const WCHAR *); -void WCMD_type (WCHAR *); +RETURN_CODE WCMD_type(WCHAR *); void WCMD_verify (const WCHAR *args); void WCMD_version (void); int WCMD_volume (BOOL set_label, const WCHAR *args); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 46ec53587e7..cd2043b02f3 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1896,7 +1896,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) WCMD_title(&whichcmd[count+1]); break; case WCMD_TYPE: - WCMD_type (parms_start); + return_code = WCMD_type(parms_start); break; case WCMD_VER: WCMD_output_asis(L"\r\n");
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 22 +++++++++++++--------- programs/cmd/tests/test_builtins.cmd.exp | 6 +++--- programs/cmd/wcmd.h | 2 +- programs/cmd/wcmdmain.c | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 2510735f00d..2a7e08da898 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1438,37 +1438,41 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { * non-hidden files */
-BOOL WCMD_delete (WCHAR *args) { +RETURN_CODE WCMD_delete(WCHAR *args) +{ int argno; WCHAR *argN; BOOL argsProcessed = FALSE; - BOOL foundAny = FALSE;
errorlevel = NO_ERROR;
- for (argno=0; ; argno++) { - BOOL found; + for (argno = 0; ; argno++) + { WCHAR *thisArg;
argN = NULL; - thisArg = WCMD_parameter (args, argno, &argN, FALSE, FALSE); + thisArg = WCMD_parameter(args, argno, &argN, FALSE, FALSE); if (!argN) break; /* no more parameters */ if (argN[0] == '/') continue; /* skip options */
argsProcessed = TRUE; - found = WCMD_delete_one(thisArg); - if (!found) + if (!WCMD_delete_one(thisArg)) + { WCMD_output_stderr(WCMD_LoadMessage(WCMD_FILENOTFOUND), thisArg); - foundAny |= found; + errorlevel = ERROR_INVALID_FUNCTION; + } }
/* Handle no valid args */ if (!argsProcessed) + { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); + errorlevel = ERROR_INVALID_FUNCTION; + }
- return foundAny; + return errorlevel; }
/* diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 5919bcf4f77..8d23e7efaf8 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -492,10 +492,10 @@ SUCCESS 0 @todo_wine@FAILURE 1 SUCCESS 0 --- success/failure for ERASE command -@todo_wine@FAILURE 1 +FAILURE 1 SUCCESS 0 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 +FAILURE 1 +FAILURE 1 @todo_wine@--- ------------ Testing 'set' ------------ 1 diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 44cdd415fbe..db63966bffe 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -168,7 +168,7 @@ void WCMD_clear_screen (void); void WCMD_color (void); void WCMD_copy (WCHAR *); void WCMD_create_dir (WCHAR *); -BOOL WCMD_delete (WCHAR *); +RETURN_CODE WCMD_delete(WCHAR *); void WCMD_directory (WCHAR *); RETURN_CODE WCMD_echo(const WCHAR *); void WCMD_endlocal (void); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index cd2043b02f3..0ec3b014283 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1830,7 +1830,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) break; case WCMD_DEL: case WCMD_ERASE: - WCMD_delete (parms_start); + return_code = WCMD_delete(parms_start); break; case WCMD_DIR: WCMD_directory (parms_start);
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 25 +++++++++++------------- programs/cmd/tests/test_builtins.cmd.exp | 10 +++++----- programs/cmd/wcmd.h | 2 +- programs/cmd/wcmdmain.c | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 2a7e08da898..b14aa477380 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1928,11 +1928,10 @@ void WCMD_popd (void) { * Move a file, directory tree or wildcarded set of files. */
-void WCMD_move (void) +RETURN_CODE WCMD_move(void) { - BOOL status; WIN32_FIND_DATAW fd; - HANDLE hff; + HANDLE hff; WCHAR input[MAX_PATH]; WCHAR output[MAX_PATH]; WCHAR drive[10]; @@ -1942,7 +1941,7 @@ void WCMD_move (void)
if (param1[0] == 0x00) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); - return; + return errorlevel = ERROR_INVALID_FUNCTION; }
/* If no destination supplied, assume current directory */ @@ -1953,7 +1952,8 @@ void WCMD_move (void) /* If 2nd parm is directory, then use original filename */ /* Convert partial path to full path */ if (!WCMD_get_fullpath(param1, ARRAY_SIZE(input), input, NULL) || - !WCMD_get_fullpath(param2, ARRAY_SIZE(output), output, NULL)) return; + !WCMD_get_fullpath(param2, ARRAY_SIZE(output), output, NULL)) + return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Move from '%s'('%s') to '%s'\n", wine_dbgstr_w(input), wine_dbgstr_w(param1), wine_dbgstr_w(output));
@@ -1962,8 +1962,9 @@ void WCMD_move (void)
hff = FindFirstFileW(input, &fd); if (hff == INVALID_HANDLE_VALUE) - return; + return errorlevel = ERROR_INVALID_FUNCTION;
+ errorlevel = NO_ERROR; do { WCHAR dest[MAX_PATH]; WCHAR src[MAX_PATH]; @@ -2036,19 +2037,15 @@ void WCMD_move (void) flags |= MOVEFILE_REPLACE_EXISTING; }
- if (ok) { - status = MoveFileExW(src, dest, flags); - } else { - status = TRUE; - } - - if (!status) { - WCMD_print_error (); + if (!ok || !MoveFileExW(src, dest, flags)) + { + if (!ok) WCMD_print_error(); errorlevel = ERROR_INVALID_FUNCTION; } } while (FindNextFileW(hff, &fd) != 0);
FindClose(hff); + return errorlevel; }
/**************************************************************************** diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 8d23e7efaf8..0c6362d227a 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -480,11 +480,11 @@ SUCCESS 0 @todo_wine@FAILURE 1 @todo_wine@FAILURE 1 --- success/failure for MOVE command -@todo_wine@FAILURE 1 -@todo_wine@SUCCESS 0 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 +FAILURE 1 +SUCCESS 0 +FAILURE 1 +FAILURE 1 +FAILURE 1 --- success/failure for RENAME command @todo_wine@FAILURE 1 @todo_wine@FAILURE 1 diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index db63966bffe..d2ef5b46b86 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -179,7 +179,7 @@ void WCMD_give_help (const WCHAR *args); RETURN_CODE WCMD_goto(void); void WCMD_leave_paged_mode(void); void WCMD_more (WCHAR *); -void WCMD_move (void); +RETURN_CODE WCMD_move (void); WCHAR* WINAPIV WCMD_format_string (const WCHAR *format, ...); void WINAPIV WCMD_output (const WCHAR *format, ...); void WINAPIV WCMD_output_stderr (const WCHAR *format, ...); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 0ec3b014283..18315e9ce2b 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1852,7 +1852,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) WCMD_create_dir (parms_start); break; case WCMD_MOVE: - WCMD_move (); + return_code = WCMD_move(); break; case WCMD_PATH: WCMD_setshow_path (parms_start);
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 21 +++++++++------------ programs/cmd/tests/test_builtins.cmd.exp | 8 ++++---- programs/cmd/wcmd.h | 2 +- programs/cmd/wcmdmain.c | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index b14aa477380..77f40a87fd0 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -2144,10 +2144,9 @@ void WCMD_remove_dir (WCHAR *args) { * Rename a file. */
-void WCMD_rename (void) +RETURN_CODE WCMD_rename(void) { - BOOL status; - HANDLE hff; + HANDLE hff; WIN32_FIND_DATAW fd; WCHAR input[MAX_PATH]; WCHAR *dotDst = NULL; @@ -2161,20 +2160,18 @@ void WCMD_rename (void) /* Must be at least two args */ if (param1[0] == 0x00 || param2[0] == 0x00) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); - errorlevel = ERROR_INVALID_FUNCTION; - return; + return errorlevel = ERROR_INVALID_FUNCTION; }
/* Destination cannot contain a drive letter or directory separator */ if ((wcschr(param2,':') != NULL) || (wcschr(param2,'\') != NULL)) { SetLastError(ERROR_INVALID_PARAMETER); WCMD_print_error(); - errorlevel = ERROR_INVALID_FUNCTION; - return; + return errorlevel = ERROR_INVALID_FUNCTION; }
/* Convert partial path to full path */ - if (!WCMD_get_fullpath(param1, ARRAY_SIZE(input), input, NULL)) return; + if (!WCMD_get_fullpath(param1, ARRAY_SIZE(input), input, NULL)) return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Rename from '%s'('%s') to '%s'\n", wine_dbgstr_w(input), wine_dbgstr_w(param1), wine_dbgstr_w(param2)); dotDst = wcschr(param2, '.'); @@ -2184,8 +2181,9 @@ void WCMD_rename (void)
hff = FindFirstFileW(input, &fd); if (hff == INVALID_HANDLE_VALUE) - return; + return errorlevel = ERROR_INVALID_FUNCTION;
+ errorlevel = NO_ERROR; do { WCHAR dest[MAX_PATH]; WCHAR src[MAX_PATH]; @@ -2228,15 +2226,14 @@ void WCMD_rename (void) WINE_TRACE("Source '%s'\n", wine_dbgstr_w(src)); WINE_TRACE("Dest '%s'\n", wine_dbgstr_w(dest));
- status = MoveFileW(src, dest); - - if (!status) { + if (!MoveFileW(src, dest)) { WCMD_print_error (); errorlevel = ERROR_INVALID_FUNCTION; } } while (FindNextFileW(hff, &fd) != 0);
FindClose(hff); + return errorlevel; }
/***************************************************************************** diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 0c6362d227a..c17f00c0c02 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -486,10 +486,10 @@ FAILURE 1 FAILURE 1 FAILURE 1 --- success/failure for RENAME command -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 +FAILURE 1 +FAILURE 1 +FAILURE 1 +FAILURE 1 SUCCESS 0 --- success/failure for ERASE command FAILURE 1 diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index d2ef5b46b86..752ee251cd2 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -190,7 +190,7 @@ void WCMD_popd (void); void WCMD_print_error (void); void WCMD_pushd (const WCHAR *args); void WCMD_remove_dir (WCHAR *command); -void WCMD_rename (void); +RETURN_CODE WCMD_rename(void); void WCMD_run_program (WCHAR *command, BOOL called); void WCMD_setlocal (const WCHAR *args); void WCMD_setshow_date (void); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 18315e9ce2b..5e429c2f3f0 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1867,7 +1867,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) break; case WCMD_REN: case WCMD_RENAME: - WCMD_rename (); + return_code = WCMD_rename(); break; case WCMD_RD: case WCMD_RMDIR:
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 45 ++++++++++++++---------- programs/cmd/tests/test_builtins.cmd.exp | 8 ++--- programs/cmd/wcmd.h | 2 +- programs/cmd/wcmdmain.c | 2 +- 4 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 77f40a87fd0..faff537be73 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -606,8 +606,8 @@ static BOOL WCMD_ManualCopy(WCHAR *srcname, WCHAR *dstname, BOOL ascii, BOOL app * */
-void WCMD_copy(WCHAR * args) { - +RETURN_CODE WCMD_copy(WCHAR * args) +{ BOOL opt_d, opt_v, opt_n, opt_z, opt_y, opt_noty; WCHAR *thisparam; int argno = 0; @@ -639,15 +639,15 @@ void WCMD_copy(WCHAR * args) { COPY_FILES *destination = NULL; COPY_FILES *thiscopy = NULL; COPY_FILES *prevcopy = NULL; + RETURN_CODE return_code;
/* Assume we were successful! */ - errorlevel = NO_ERROR; + return_code = NO_ERROR;
/* If no args supplied at all, report an error */ if (param1[0] == 0x00) { WCMD_output_stderr (WCMD_LoadMessage(WCMD_NOARG)); - errorlevel = ERROR_INVALID_FUNCTION; - return; + return errorlevel = ERROR_INVALID_FUNCTION; }
opt_d = opt_v = opt_n = opt_z = opt_y = opt_noty = FALSE; @@ -726,7 +726,7 @@ void WCMD_copy(WCHAR * args) { if (*thisparam=='+') { if (lastcopyentry == NULL) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR)); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; goto exitreturn; } else { concatnextfilename = TRUE; @@ -781,7 +781,7 @@ void WCMD_copy(WCHAR * args) { } else { /* We have processed sources and destinations and still found more to do - invalid */ WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR)); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; goto exitreturn; } concatnextfilename = FALSE; @@ -798,7 +798,7 @@ void WCMD_copy(WCHAR * args) { /* Ensure we have at least one source file */ if (!sourcelist) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR)); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; goto exitreturn; }
@@ -828,6 +828,7 @@ void WCMD_copy(WCHAR * args) { if (destination == NULL) {
WINE_TRACE("No destination supplied, so need to calculate it\n"); + lstrcpyW(destname, L"."); lstrcatW(destname, L"\");
@@ -846,7 +847,8 @@ void WCMD_copy(WCHAR * args) { WINE_TRACE("Destination supplied, processing to see if file or directory\n");
/* Convert to fully qualified path/filename */ - if (!WCMD_get_fullpath(destination->name, ARRAY_SIZE(destname), destname, &filenamepart)) return; + if (!WCMD_get_fullpath(destination->name, ARRAY_SIZE(destname), destname, &filenamepart)) + return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Full dest name is '%s'\n", wine_dbgstr_w(destname));
/* If parameter is a directory, ensure it ends in \ */ @@ -914,6 +916,7 @@ void WCMD_copy(WCHAR * args) { thiscopy = sourcelist; prevcopy = NULL;
+ return_code = NO_ERROR; while (thiscopy != NULL) {
WCHAR srcpath[MAX_PATH]; @@ -928,7 +931,8 @@ void WCMD_copy(WCHAR * args) {
/* Convert to fully qualified path/filename in srcpath, file filenamepart pointing to where the filename portion begins (used for wildcard expansion). */ - if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) return; + if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) + return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Full src name is '%s'\n", wine_dbgstr_w(srcpath));
/* If parameter is a directory, ensure it ends in * */ @@ -938,7 +942,8 @@ void WCMD_copy(WCHAR * args) { /* We need to know where the filename part starts, so append * and recalculate the full resulting path */ lstrcatW(thiscopy->name, L"*"); - if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) return; + if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) + return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
} else if ((wcspbrk(srcpath, L"*?") == NULL) && @@ -948,7 +953,8 @@ void WCMD_copy(WCHAR * args) { /* We need to know where the filename part starts, so append * and recalculate the full resulting path */ lstrcatW(thiscopy->name, L"\*"); - if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) return; + if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) + return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); }
@@ -1046,7 +1052,7 @@ void WCMD_copy(WCHAR * args) { } if (!status) { WCMD_print_error (); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; } else { WINE_TRACE("Copied successfully\n"); if (anyconcats) writtenoneconcat = TRUE; @@ -1058,11 +1064,12 @@ void WCMD_copy(WCHAR * args) { if (!destination->binarycopy && !anyconcats && !thiscopy->binarycopy) { if (!WCMD_AppendEOF(outname)) { WCMD_print_error (); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; } } } - } + } else if (prompt) + return_code = ERROR_INVALID_FUNCTION; } } while (!srcisdevice && FindNextFileW(hff, &fd) != 0); if (!srcisdevice) FindClose (hff); @@ -1070,7 +1077,7 @@ void WCMD_copy(WCHAR * args) { /* Error if the first file was not found */ if (!anyconcats || !writtenoneconcat) { WCMD_print_error (); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; } }
@@ -1079,10 +1086,10 @@ void WCMD_copy(WCHAR * args) { }
/* Append EOF if ascii destination and we were concatenating */ - if (!errorlevel && !destination->binarycopy && anyconcats && writtenoneconcat) { + if (!return_code && !destination->binarycopy && anyconcats && writtenoneconcat) { if (!WCMD_AppendEOF(destination->name)) { WCMD_print_error (); - errorlevel = ERROR_INVALID_FUNCTION; + return_code = ERROR_INVALID_FUNCTION; } }
@@ -1104,7 +1111,7 @@ exitreturn: free(destination); }
- return; + return errorlevel = return_code; }
/**************************************************************************** diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index c17f00c0c02..8b281907624 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -474,11 +474,11 @@ FAILURE 1 @todo_wine@--- FAILURE 1 --- success/failure for COPY command -@todo_wine@FAILURE 1 +FAILURE 1 SUCCESS 0 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 -@todo_wine@FAILURE 1 +FAILURE 1 +FAILURE 1 +FAILURE 1 --- success/failure for MOVE command FAILURE 1 SUCCESS 0 diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 752ee251cd2..0b0a96c5fb8 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -166,7 +166,7 @@ void WCMD_change_tty (void); void WCMD_choice (const WCHAR *); void WCMD_clear_screen (void); void WCMD_color (void); -void WCMD_copy (WCHAR *); +RETURN_CODE WCMD_copy(WCHAR *); void WCMD_create_dir (WCHAR *); RETURN_CODE WCMD_delete(WCHAR *); void WCMD_directory (WCHAR *); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 5e429c2f3f0..c096abe3431 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1820,7 +1820,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command) WCMD_clear_screen (); break; case WCMD_COPY: - WCMD_copy (parms_start); + return_code = WCMD_copy(parms_start); break; case WCMD_CTTY: WCMD_change_tty ();
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146751
Your paranoid android.
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1002, expected around 500