This is part XXVIII of cmd engine rewrite.
It mainly contains bug fixes in various areas, and also a functional improvement (Unix 'touch' equivalent in COPY command).
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd | 5 +++++ programs/cmd/tests/test_builtins.cmd.exp | 4 ++++ 2 files changed, 9 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 85911c0757f..c6f7f1942ce 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -953,6 +953,11 @@ echo %WINE_VAR:~2,-3% echo '%WINE_VAR:~-2,-4%' echo %WINE_VAR:~-3,-2% echo %WINE_VAR:~4,4% +set WINE_VAR=qwertyQWERTY +echo %WINE_VAR:qw=az% +echo %WINE_VAR:qw=% +echo %WINE_VAR:*TY==_% +echo %WINE_VAR:*TY=% set WINE_VAR= mkdir dummydir cd dummydir diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index cf500a516de..273b7bc57ca 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -760,6 +760,10 @@ e@or_broken@qwerty ''@or_broken@'qwerty' r@or_broken@qwerty ty +@todo_wine@azertyazERTY +ertyERTY +@todo_wine@=_QWERTY +QWERTY mmydir ------------ Testing variable substitution ------------ --- in FOR variables
From: Eric Pouech epouech@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57290
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd.exp | 4 ++-- programs/cmd/wcmdmain.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 273b7bc57ca..082cd62f99b 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -760,9 +760,9 @@ e@or_broken@qwerty ''@or_broken@'qwerty' r@or_broken@qwerty ty -@todo_wine@azertyazERTY +azertyazERTY ertyERTY -@todo_wine@=_QWERTY +=_QWERTY QWERTY mmydir ------------ Testing variable substitution ------------ diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 46131cad608..466df207f12 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -638,8 +638,6 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start) if (equalspos == NULL) return start+1; s = xstrdupW(endOfVar + 1);
- /* Null terminate both strings */ - thisVar[lstrlenW(thisVar)-1] = 0x00; *equalspos = 0x00;
/* Since we need to be case insensitive, copy the 2 buffers */
From: Eric Pouech epouech@codeweavers.com
MSDN documents a way to 'touch' a file in CMD.EXE with: COPY /B file.ext+,, (and actually the /B switch doesn't matter).
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/builtins.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index e79b7845f94..d7c5090d17f 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1065,8 +1065,20 @@ RETURN_CODE WCMD_copy(WCHAR * args) /* Do the copy as appropriate */ if (overwrite) { if (anyconcats && WCMD_IsSameFile(srcpath, outname)) { - /* Silently skip if the destination file is also a source file */ - status = TRUE; + /* behavior is as Unix 'touch' (change last-written time only) */ + HANDLE file = CreateFileW(srcpath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file != INVALID_HANDLE_VALUE) + { + FILETIME file_time; + SYSTEMTIME system_time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + status = SetFileTime(file, NULL, NULL, &file_time); + CloseHandle(file); + } + else status = FALSE; } else if (anyconcats && writtenoneconcat) { if (thiscopy->binarycopy) { status = WCMD_ManualCopy(srcpath, outname, FALSE, TRUE);
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd | 4 ++++ programs/cmd/tests/test_builtins.cmd.exp | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index c6f7f1942ce..7a2953b735d 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1603,6 +1603,10 @@ if not exist "" ( del foo subdir\bar rd subdir
+if exist %~D0 (echo ok) else echo failure +if exist %~D0\ (echo ok) else echo failure +if exist %~D0. (echo ok) else echo failure + echo ------ for numbers if -1 LSS 1 (echo negative numbers handled) if not -1 LSS -10 (echo negative numbers handled) diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 082cd62f99b..2fdb5fa256d 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1088,6 +1088,9 @@ exist subdir with /. ok exist subdir with / ok exist subdir with / and quotes ok exist empty string works +@todo_wine@ok +@todo_wine@ok +@todo_wine@ok ------ for numbers negative numbers handled negative numbers handled
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/batch.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c index c2f74a33415..15c01de4b89 100644 --- a/programs/cmd/batch.c +++ b/programs/cmd/batch.c @@ -307,11 +307,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h) */ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute) { - -#define NUMMODIFIERS 11 - static const WCHAR validmodifiers[NUMMODIFIERS] = { - '~', 'f', 'd', 'p', 'n', 'x', 's', 'a', 't', 'z', '$' - }; + static const WCHAR *validmodifiers = L"~fdpnxsatz$";
WIN32_FILE_ATTRIBUTE_DATA fileInfo; WCHAR outputparam[MAXSTRING]; @@ -321,41 +317,17 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute) WCHAR *filepart = NULL; WCHAR *pos = *start+1; WCHAR *firstModifier = pos; - WCHAR *lastModifier = NULL; + WCHAR *lastModifier = pos++; int modifierLen = 0; - BOOL finished = FALSE; - int i = 0; BOOL exists = TRUE; BOOL skipFileParsing = FALSE; BOOL doneModifier = FALSE;
/* Search forwards until find invalid character modifier */ - while (!finished) { - - /* Work on the previous character */ - if (lastModifier != NULL) { - - for (i=0; i<NUMMODIFIERS; i++) { - if (validmodifiers[i] == *lastModifier) { - - /* Special case '$' to skip until : found */ - if (*lastModifier == '$') { - while (*pos != ':' && *pos) pos++; - if (*pos == 0x00) return; /* Invalid syntax */ - pos++; /* Skip ':' */ - } - break; - } - } - - if (i==NUMMODIFIERS) { - finished = TRUE; - } - } - - /* Save this one away */ - if (!finished) { - lastModifier = pos; + for (; wcschr(validmodifiers, towlower(*lastModifier)); lastModifier = pos++) { + /* Special case '$' to skip until : found */ + if (*lastModifier == L'$') { + if (!(pos = wcschr(pos, L':'))) return; /* Invalid syntax */ pos++; } } @@ -377,6 +349,9 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute) } } if (lastModifier == firstModifier) return; /* Invalid syntax */ + /* put all modifiers in lowercase */ + for (pos = firstModifier; pos < lastModifier; pos++) + *pos = towlower(*pos);
/* So now, firstModifier points to beginning of modifiers, lastModifier points to the variable just after the modifiers. Process modifiers
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd.exp | 6 +++--- programs/cmd/wcmdmain.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 2fdb5fa256d..3c516b79fe5 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1088,9 +1088,9 @@ exist subdir with /. ok exist subdir with / ok exist subdir with / and quotes ok exist empty string works -@todo_wine@ok -@todo_wine@ok -@todo_wine@ok +ok +ok +ok ------ for numbers negative numbers handled negative numbers handled diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 466df207f12..1018fd56624 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -3196,14 +3196,14 @@ static BOOL if_condition_evaluate(CMD_IF_CONDITION *cond, int *test) handleExpansion(expanded_left, TRUE); if ((len = wcslen(expanded_left))) { - /* FindFirstFile does not like a directory path ending in '' or '/', so append a '.' */ - if ((expanded_left[len - 1] == '\' || expanded_left[len - 1] == '/') && len < MAXSTRING - 1) + if (!wcspbrk(expanded_left, L"*?")) + *test = GetFileAttributesW(expanded_left) != INVALID_FILE_ATTRIBUTES; + else { - wcscat(expanded_left, L"."); + hff = FindFirstFileW(expanded_left, &fd); + *test = (hff != INVALID_HANDLE_VALUE); + if (*test) FindClose(hff); } - hff = FindFirstFileW(expanded_left, &fd); - *test = (hff != INVALID_HANDLE_VALUE); - if (*test) FindClose(hff); } } break;
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=149616
Your paranoid android.
=== w10pro64_en_AE_u8 (32 bit report) ===
cmd.exe: batch.c:348: Test failed: unexpected char 0x66 position 9 in line 2041 (got 'start /W failed to wait', wanted 'start /W seems to really wait') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 13 (got '--- Test 7', wanted '""') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 17 (got '--- Test 9', wanted '"`"') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 19 (got '--- Test 10', wanted '"""') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 23 (got '--- Test 13', wanted 'passed1') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 25 (got '--- Test 14', wanted 'passed2@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 27 (got '--- Test 15', wanted 'foobar') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 29 (got '--- Test 16', wanted 'No whitespace') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 35 (got '------ Testing invocation of batch files ----------', wanted 'alabaster') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 36 (got '------ Testing invocation of batch files ----------', wanted 'chrome') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 37 (got '------ Testing invocation of batch files ----------', wanted '%hello1%') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 38 (got '------ Testing invocation of batch files ----------', wanted '%hello2') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 39 (got '------ Testing invocation of batch files ----------', wanted '%hello3:h=t%') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 40 (got '------ Testing invocation of batch files ----------', wanted '%hello4%%') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 41 (got '------ Testing invocation of batch files ----------', wanted 'one = %1') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 42 (got '------ Testing invocation of batch files ----------', wanted '1') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 43 (got '------ Testing invocation of batch files ----------', wanted '2') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 44 (got '------ Testing invocation of batch files ----------', wanted '3') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 45 (got '------ Testing invocation of batch files ----------', wanted '4') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 46 (got '------ Testing invocation of batch files ----------', wanted '5') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 47 (got '------ Testing invocation of batch files ----------', wanted 'var contents: 11') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 48 (got '------ Testing invocation of batch files ----------', wanted 'var=33@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 49 (got '------ Testing invocation of batch files ----------', wanted '99') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 64 (got 'error 9020', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 65 (got 'error 9020', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 66 (got 'error 9020', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 67 (got 'error 9020', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 68 (got 'error 9020', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 69 (got 'error 9020', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x50 position 0 in line 70 (got 'Passed', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 71 (got '---------- Testing CMD /C quoting -----------------', wanted '2@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 72 (got '---------- Testing CMD /C quoting -----------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 73 (got '---------- Testing CMD /C quoting -----------------', wanted '3@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 74 (got '---------- Testing CMD /C quoting -----------------', wanted '4@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 75 (got '---------- Testing CMD /C quoting -----------------', wanted 'Passed') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 77 (got 'error 9020', wanted '"hi"') batch.c:348: Test failed: unexpected char 0x65 position 0 in line 78 (got 'error 9020', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 79 (got '------- Testing CMD /C qualifier treatment ------------', wanted '""\"\"\\"@space@""\"\"\\"') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 80 (got '------- Testing CMD /C qualifier treatment ------------', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 81 (got '------- Testing CMD /C qualifier treatment ------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 82 (got '------- Testing CMD /C qualifier treatment ------------', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 83 (got '------- Testing CMD /C qualifier treatment ------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 84 (got '------- Testing CMD /C qualifier treatment ------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 85 (got '------- Testing CMD /C qualifier treatment ------------', wanted '0@space@@or_broken@3@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 86 (got '------- Testing CMD /C qualifier treatment ------------', wanted '3@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 87 (got '------- Testing CMD /C qualifier treatment ------------', wanted '2@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 88 (got '------- Testing CMD /C qualifier treatment ------------', wanted '2@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 89 (got '------- Testing CMD /C qualifier treatment ------------', wanted '2@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 90 (got '------- Testing CMD /C qualifier treatment ------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 91 (got '------- Testing CMD /C qualifier treatment ------------', wanted '5@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 92 (got '------- Testing CMD /C qualifier treatment ------------', wanted 'hi') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 93 (got '------- Testing CMD /C qualifier treatment ------------', wanted 'hi') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 94 (got '------- Testing CMD /C qualifier treatment ------------', wanted 'hi') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 96 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 97 (got '--------- Testing special characters --------------', wanted '1@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 98 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 99 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 100 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 101 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 102 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 103 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 104 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 105 (got '--------- Testing special characters --------------', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 106 (got '--------- Testing special characters --------------', wanted 'bar@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 107 (got '--------- Testing special characters --------------', wanted 'bar@space@') batch.c:348: Test failed: unexpected char 0x30 position 0 in line 118 (got '0 ', wanted '!@space@') batch.c:348: Test failed: unexpected char 0x27 position 0 in line 120 (got '' ', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x2b position 0 in line 121 (got '+ ', wanted ''@space@') batch.c:348: Test failed: unexpected char 0x30 position 0 in line 122 (got '0 ', wanted '+@space@') batch.c:348: Test failed: unexpected char 0x27 position 0 in line 123 (got '' ', wanted '0@space@') batch.c:348: Test failed: unexpected char 0x7e position 0 in line 124 (got '~ ', wanted ''@space@') batch.c:348: Test failed: unexpected char 0x2d position 0 in line 125 (got '--------- Testing parameter passing --------------', wanted '~@space@')