"DIR /o" (no order specifier after /o) hasn't functioned the same as it does on Windows. This change makes the functionality of /o by itself equivalent to behavior on Windows.
-- v18: programs/cmd: Remove @todo_wine@ from working tests.
From: Joe Souza jsouza@yahoo.com
--- programs/cmd/directory.c | 64 ++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 16 deletions(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index 3f4f7853710..3a2a5955d12 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -35,7 +35,8 @@ typedef enum _DISPLAYTIME
typedef enum _DISPLAYORDER { - Name = 0, + Unspecified = 0, + Name, Extension, Size, Date @@ -90,16 +91,37 @@ static int __cdecl WCMD_dir_sort (const void *a, const void *b) { const WIN32_FIND_DATAW *filea = (const WIN32_FIND_DATAW *)a; const WIN32_FIND_DATAW *fileb = (const WIN32_FIND_DATAW *)b; + BOOL aDir = filea->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + BOOL bDir = fileb->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; int result = 0;
- /* If /OG or /O-G supplied, dirs go at the top or bottom, ignoring the - requested sort order for the directory components */ - if (orderGroupDirs && - ((filea->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || - (fileb->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))) - { - BOOL aDir = filea->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; - if (aDir) result = -1; + if (orderGroupDirs && dirOrder == Unspecified) { + /* Special case: If ordering groups and not sorting by other criteria, "." and ".." always go first. */ + if (aDir && !lstrcmpW(filea->cFileName, L".")) { + result = -1; + } else if (bDir && !lstrcmpW(fileb->cFileName, L".")) { + result = 1; + } else if (aDir && !lstrcmpW(filea->cFileName, L"..")) { + result = -1; + } else if (bDir && !lstrcmpW(fileb->cFileName, L"..")) { + result = 1; + } + + if (result) { + if (orderGroupDirsReverse) result = -result; + return result; + } + } + + /* If /OG or /O-G supplied, dirs go at the top or bottom, also sorted + if requested sort order is by name. */ + if (orderGroupDirs && (aDir || bDir)) { + if (aDir && bDir && dirOrder == Name) { + result = lstrcmpiW(filea->cFileName, fileb->cFileName); + if (orderReverse) result = -result; + } else if (aDir) { + result = -1; + } else result = 1; if (orderGroupDirsReverse) result = -result; return result; @@ -674,7 +696,7 @@ RETURN_CODE WCMD_directory(WCHAR *args) orderByCol = FALSE; separator = TRUE; dirTime = Written; - dirOrder = Name; + dirOrder = Unspecified; orderReverse = FALSE; orderGroupDirs = FALSE; orderGroupDirsReverse = FALSE; @@ -744,13 +766,16 @@ RETURN_CODE WCMD_directory(WCHAR *args) if (*p==':') p++; /* Skip optional : */ while (*p && *p != '/') { WINE_TRACE("Processing subparm '%c' (in %s)\n", *p, wine_dbgstr_w(quals)); + /* Options N,E,S,D are mutually-exclusive, first encountered takes precedence. */ switch (*p) { - case 'N': dirOrder = Name; break; - case 'E': dirOrder = Extension; break; - case 'S': dirOrder = Size; break; - case 'D': dirOrder = Date; break; - case '-': if (*(p+1)=='G') orderGroupDirsReverse=TRUE; - else orderReverse = TRUE; + case 'N': if (dirOrder == Unspecified) dirOrder = Name; break; + case 'E': if (dirOrder == Unspecified) dirOrder = Extension; break; + case 'S': if (dirOrder == Unspecified) dirOrder = Size; break; + case 'D': if (dirOrder == Unspecified) dirOrder = Date; break; + case '-': if (dirOrder == Unspecified) { + if (*(p+1)=='G') orderGroupDirsReverse=TRUE; + else if (*(p+1)=='N'||*(p+1)=='E'||*(p+1)=='S'||*(p+1)=='D') orderReverse = TRUE; + } break; case 'G': orderGroupDirs = TRUE; break; default: @@ -760,6 +785,13 @@ RETURN_CODE WCMD_directory(WCHAR *args) } p++; } + /* Handle default case of /O specified by itself, with no specific options. + This is equivalent to /O:GN. */ + if (dirOrder == Unspecified && !orderGroupDirs) { + orderGroupDirs = TRUE; + orderGroupDirsReverse = FALSE; + dirOrder = Name; + } p = p - 1; /* So when step on, move to '/' */ break; case 'A': p = p + 1;
From: Joe Souza jsouza@yahoo.com
--- programs/cmd/tests/test_builtins.cmd | 20 +++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 37 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 8552d51930a..95d96567d25 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -2923,6 +2923,26 @@ popd cd rd /s/q foobar
+echo ------------ Testing dir /o ------------ +mkdir foobar & cd foobar +echo AAA>a1.aa +mkdir a1.ab +echo A>a1.ac +echo AA>a2.aa +mkdir a2.ac +echo --- +dir /B /O: +echo --- +dir /B /O:GN +echo --- +dir /B /O:G-N +echo --- +dir /B /O:GNE +echo --- +dir /B /O:G-NE +echo --- +dir /B /O:G-E-N +cd .. & rd /s/q foobar echo ------------ Testing attrib ------------ rem FIXME Add tests for archive, hidden and system attributes + mixed attributes modifications mkdir foobar & cd foobar diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 292c24985e8..039c1a3631c 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1754,6 +1754,43 @@ bar\baz removed @pwd@ @drive@@path@foobar @pwd@ +------------ Testing dir /o ------------ +--- +@todo_wine@a1.ab +@todo_wine@a2.ac +@todo_wine@a1.aa +@todo_wine@a1.ac +@todo_wine@a2.aa +--- +@todo_wine@a1.ab +@todo_wine@a2.ac +a1.aa +a1.ac +a2.aa +--- +a2.ac +a1.ab +a2.aa +a1.ac +a1.aa +--- +@todo_wine@a1.ab +@todo_wine@a2.ac +@todo_wine@a1.aa +@todo_wine@a1.ac +@todo_wine@a2.aa +--- +a2.ac +a1.ab +@todo_wine@a2.aa +@todo_wine@a1.ac +a1.aa +--- +a2.ac +a1.ab +@todo_wine@a1.ac +@todo_wine@a2.aa +a1.aa ------------ Testing attrib ------------ A@spaces@@drive@@path@foobar\foo@or_broken@A I@spaces@@drive@@path@foobar\foo A@spaces@@drive@@path@foobar\foo@or_broken@A I@spaces@@drive@@path@foobar\foo
From: Joe Souza jsouza@yahoo.com
--- programs/cmd/tests/test_builtins.cmd.exp | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 039c1a3631c..19a6ec78c10 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1756,14 +1756,14 @@ bar\baz removed @pwd@ ------------ Testing dir /o ------------ --- -@todo_wine@a1.ab -@todo_wine@a2.ac -@todo_wine@a1.aa -@todo_wine@a1.ac -@todo_wine@a2.aa +a1.ab +a2.ac +a1.aa +a1.ac +a2.aa --- -@todo_wine@a1.ab -@todo_wine@a2.ac +a1.ab +a2.ac a1.aa a1.ac a2.aa @@ -1774,22 +1774,22 @@ a2.aa a1.ac a1.aa --- -@todo_wine@a1.ab -@todo_wine@a2.ac -@todo_wine@a1.aa -@todo_wine@a1.ac -@todo_wine@a2.aa +a1.ab +a2.ac +a1.aa +a1.ac +a2.aa --- a2.ac a1.ab -@todo_wine@a2.aa -@todo_wine@a1.ac +a2.aa +a1.ac a1.aa --- a2.ac a1.ab -@todo_wine@a1.ac -@todo_wine@a2.aa +a1.ac +a2.aa a1.aa ------------ Testing attrib ------------ A@spaces@@drive@@path@foobar\foo@or_broken@A I@spaces@@drive@@path@foobar\foo
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=151237
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4306: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000013100FC, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032 msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got hook 0x0009 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got hook 0x0005 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got winevent_hook 0x0003 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x030f instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x001c instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0086 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0006 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got hook 0x0009 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got winevent_hook 0x8005 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0007 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0008 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got winevent_hook 0x8005 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0007 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 3: the msg 0x00f3 was expected, but got msg 0x0138 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 5: the winevent_hook 0x800a was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 6: the msg 0x0202 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 7: the msg 0x00f3 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 8: the msg 0x0138 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 9: the winevent_hook 0x800a was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 10: the msg 0x0087 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 11: the msg 0x00f1 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 12: the msg 0x0087 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 13: the msg 0x00f1 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 14: the msg 0x0138 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 15: the winevent_hook 0x800a was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 16: the msg 0x0087 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 17: the msg 0x00f1 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 18: the msg 0x0138 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 19: the winevent_hook 0x800a was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 20: the msg 0x0087 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 21: the winevent_hook 0x0009 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 22: the msg 0x0215 was expected, but got msg 0x0111 instead msg.c:7545: Test failed: BM_CLICK on auto-radio button: 23: in msg 0x0111 expecting wParam 0x1f6 got 0x601f6 msg.c:7545: Test failed: BM_CLICK on auto-radio button: 27: the msg sequence is not complete: expected msg 0000 - actual msg 00f3