[PATCH v2 0/2] MR9975: where: Add quiet mode.
Fixes Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59234 -- v2: where: Fix index for option parsing https://gitlab.winehq.org/wine/wine/-/merge_requests/9975
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- programs/where/main.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/programs/where/main.c b/programs/where/main.c index 3307ace1f45..bd24d57b411 100644 --- a/programs/where/main.c +++ b/programs/where/main.c @@ -25,9 +25,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(where); +#define OPT_QUIET 0x00000001 + static BOOL found; -static void search(const WCHAR *search_path, const WCHAR *pattern) +static void search(const WCHAR *search_path, const WCHAR *pattern, DWORD flags) { static const WCHAR *extensions[] = {L"", L".bat", L".cmd", L".com", L".exe"}; WCHAR glob[MAX_PATH]; @@ -56,7 +58,8 @@ static void search(const WCHAR *search_path, const WCHAR *pattern) { if (PathCombineW(match_path, search_path, match.cFileName)) { - printf("%ls\n", match_path); + if(!(flags & OPT_QUIET)) + printf("%ls\n", match_path); found = TRUE; } } @@ -69,13 +72,25 @@ static void search(const WCHAR *search_path, const WCHAR *pattern) int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR *pattern, *colon, *search_paths, *search_path, *next_search_path; + DWORD flags = 0; int i; for (i = 0; i < argc; i++) { - if (argv[i][0] == '/') + if (argv[i][0] == '/' && wcslen(argv[i]) == 2) + { + switch(toupper(argv[i][1])) + { + case 'Q': flags |= OPT_QUIET; break; + default: + FIXME("Unsupported option %ls -- %c\n", argv[i], argv[i][1]); + return 1; + + } + } + else if (argv[i][0] == '/') { - FIXME("Unsupported option %ls\n", argv[i]); + FIXME("Unsupported option %ls len %lld\n", argv[i], (long long)wcslen(argv[i])); return 1; } } @@ -104,17 +119,18 @@ int __cdecl wmain(int argc, WCHAR *argv[]) /* If the search paths were not explicitly specified, search the current directory first */ WCHAR current_dir[MAX_PATH]; if (GetCurrentDirectoryW(ARRAY_SIZE(current_dir), current_dir)) - search(current_dir, pattern); + search(current_dir, pattern, flags); } next_search_path = wcsdup(search_paths); while ((search_path = wcstok(NULL, L";", &next_search_path))) - search(search_path, pattern); + search(search_path, pattern, flags); } if (!found) { - fputs("File not found\n", stderr); + if(!(flags & OPT_QUIET)) + fputs("File not found\n", stderr); return 1; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9975
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- programs/where/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/where/main.c b/programs/where/main.c index bd24d57b411..d65279da602 100644 --- a/programs/where/main.c +++ b/programs/where/main.c @@ -75,7 +75,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) DWORD flags = 0; int i; - for (i = 0; i < argc; i++) + for (i = 1; i < argc; i++) { if (argv[i][0] == '/' && wcslen(argv[i]) == 2) { @@ -90,7 +90,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) } else if (argv[i][0] == '/') { - FIXME("Unsupported option %ls len %lld\n", argv[i], (long long)wcslen(argv[i])); + FIXME("Unsupported option %ls\n", argv[i]); return 1; } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9975
On Tue Jan 27 14:32:34 2026 +0000, Thomas Csovcsity wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/9975/diffs?diff_id=240473&start_sha=07d471a59220cbb9e528e441f6bcbb96dccf3a75#4cd83d135efc7c3438e8bd4841e19b2fd8eabb52_78_78) good catch
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128157
On Tue Jan 27 14:23:49 2026 +0000, Thomas Csovcsity wrote:
I do not see your point. It parses '/Q' and prints fixme statement for not supported '/' parameters. The second for loop starting at line 98, parses the rest as before and ignores all patterns with '/', see line 115. sorry, I somehow missed the forward slash in wcsbrk call; that should be fine
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128262
participants (3)
-
eric pouech (@epo) -
Thomas Csovcsity -
Thomas Csovcsity (@thc13)