[PATCH 0/1] MR8005: find: Support switch /i or /I
Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com> find supports /I for case-insensitive search. In practice, however, find /i also works (tested on WinXP, Win7, and Win10). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8005
From: YeshunYe <yeyeshun(a)uniontech.com> Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com> --- programs/find/Makefile.in | 2 +- programs/find/find.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/programs/find/Makefile.in b/programs/find/Makefile.in index 2d8469f6317..44efe18759a 100644 --- a/programs/find/Makefile.in +++ b/programs/find/Makefile.in @@ -1,5 +1,5 @@ MODULE = find.exe -IMPORTS = user32 +IMPORTS = user32 shlwapi EXTRADLLFLAGS = -mconsole -municode diff --git a/programs/find/find.c b/programs/find/find.c index b4eb4d1949b..29417111945 100644 --- a/programs/find/find.c +++ b/programs/find/find.c @@ -25,6 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(find); +static int flag_case_sensitive = 1; + static BOOL read_char_from_handle(HANDLE handle, char *char_out) { static char buffer[4096]; @@ -120,7 +122,7 @@ static BOOL run_find_for_line(const WCHAR *line, const WCHAR *tofind) if (lstrlenW(line) == 0 || lstrlenW(tofind) == 0) return FALSE; - found = wcsstr(line, tofind); + found = flag_case_sensitive ? wcsstr(line, tofind) : StrStrIW(line, tofind); if (found) { @@ -160,8 +162,17 @@ int __cdecl wmain(int argc, WCHAR *argv[]) { if (argv[i][0] == '/') { - output_resource_message(IDS_INVALID_SWITCH); - return 2; + switch (argv[i][1]) + { + case 'i': + case 'I': + flag_case_sensitive = 0; + break; + + default: + output_resource_message(IDS_INVALID_SWITCH); + return 2; + } } else if (tofind == NULL) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8005
Hans Leidekker (@hans) commented about programs/find/Makefile.in:
MODULE = find.exe -IMPORTS = user32 +IMPORTS = user32 shlwapi shlwapi imports StrStrIW() from kernelbase, so you can import from kernelbase instead.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/8005#note_102967
participants (3)
-
Hans Leidekker (@hans) -
Yeshun Ye (@yeyeshun) -
YeshunYe