[PATCH 0/3] MR7415: findstr should default to regex search.
Our findstr implementation defaults to textual search, while native defaults to regex. So this MR: - add tests to show that, - reverts the default, - adapt tests that were written with textual search in mind to pass textual search option Note: native fails when passing the two flags ('findstr /l /r...'). I didn't bother fixing our implementation. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7415
From: Eric Pouech <epouech(a)codeweavers.com> Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/findstr/tests/findstr.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/programs/findstr/tests/findstr.c b/programs/findstr/tests/findstr.c index f72d9220cf6..947d8243b67 100644 --- a/programs/findstr/tests/findstr.c +++ b/programs/findstr/tests/findstr.c @@ -314,6 +314,28 @@ static void test_basic(void) ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "ab$c"); ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + run_find_file("/R .", "a", 0); + ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); + ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); + ret = strcmp(stdout_buffer, "a"); + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + todo_wine + run_find_file(".", "a", 0); + todo_wine + ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); + ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); + ret = strcmp(stdout_buffer, "a"); + todo_wine + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + run_find_file("/L .", "a", 1); + ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); + todo_wine + ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); + todo_wine + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); } START_TEST(findstr) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7415
From: Eric Pouech <epouech(a)codeweavers.com> Spotted by Chromium test suite. Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/findstr/main.c | 6 +++++- programs/findstr/tests/findstr.c | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/programs/findstr/main.c b/programs/findstr/main.c index c0fc9114be5..7e8a3299e89 100644 --- a/programs/findstr/main.c +++ b/programs/findstr/main.c @@ -185,7 +185,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) struct findstr_file *file_head = NULL, *current_file, *next_file; char line[MAXSTRING]; WCHAR *string, *ptr, *buffer; - BOOL has_string = FALSE, has_file = FALSE, case_sensitive = TRUE, regular_expression = FALSE; + BOOL has_string = FALSE, has_file = FALSE, case_sensitive = TRUE, regular_expression = TRUE; int ret = 1, i, j; for (i = 0; i < argc; i++) @@ -238,6 +238,10 @@ int __cdecl wmain(int argc, WCHAR *argv[]) case 'i': case_sensitive = FALSE; break; + case 'L': + case 'l': + regular_expression = FALSE; + break; case 'R': case 'r': regular_expression = TRUE; diff --git a/programs/findstr/tests/findstr.c b/programs/findstr/tests/findstr.c index 947d8243b67..71f663626d4 100644 --- a/programs/findstr/tests/findstr.c +++ b/programs/findstr/tests/findstr.c @@ -321,20 +321,15 @@ static void test_basic(void) ret = strcmp(stdout_buffer, "a"); ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); - todo_wine run_find_file(".", "a", 0); - todo_wine ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "a"); - todo_wine ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); run_find_file("/L .", "a", 1); ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); - todo_wine ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); - todo_wine ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7415
From: Eric Pouech <epouech(a)codeweavers.com> (mainly for the tests without mode, which were written with textual mode in mind, yet run in regex mode) Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/findstr/tests/findstr.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/programs/findstr/tests/findstr.c b/programs/findstr/tests/findstr.c index 71f663626d4..e766b542bb5 100644 --- a/programs/findstr/tests/findstr.c +++ b/programs/findstr/tests/findstr.c @@ -148,69 +148,69 @@ static void test_basic(void) ok(!ret, "Got the wrong result.\n"); /* find string in stdin, LF */ - run_find_stdin("abc", "abc\n", 0); + run_find_stdin("/L abc", "abc\n", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc\n"); ok(!ret, "Got the wrong result.\n"); /* find string in stdin, CR/LF */ - run_find_stdin("abc", "abc\r\n", 0); + run_find_stdin("/L abc", "abc\r\n", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc\r\n"); ok(!ret, "Got the wrong result.\n"); /* find string in stdin fails */ - run_find_stdin("abc", "cba", 1); + run_find_stdin("/L abc", "cba", 1); ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); /* find string in file */ - run_find_file("abc", "abc", 0); + run_find_file("/L abc", "abc", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc"); ok(!ret, "Got the wrong result.\n"); /* find string in file fails */ - run_find_file("abc", "cba", 1); + run_find_file("/L abc", "cba", 1); ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); /* find string in stdin with space separator */ - run_find_stdin("\"abc cba\"", "abc", 0); + run_find_stdin("/L \"abc cba\"", "abc", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc\r\n"); ok(!ret, "Got the wrong result.\n"); /* find string in stdin with /C: */ - run_find_stdin("/C:abc", "abc", 0); + run_find_stdin("/L /C:abc", "abc", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc\r\n"); ok(!ret, "Got the wrong result.\n"); /* find string in stdin with /C:"abc" */ - run_find_stdin("/C:\"abc\"", "abc", 0); + run_find_stdin("/L /C:\"abc\"", "abc", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc\r\n"); ok(!ret, "Got the wrong result.\n"); /* find string in stdin with /C:"abc cba" fails */ - run_find_stdin("/C:\"abc cba\"", "abc", 1); + run_find_stdin("/L /C:\"abc cba\"", "abc", 1); ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); /* find string in stdin with /C: fails */ - run_find_stdin("/C:abc", "cba", 1); + run_find_stdin("/L /C:abc", "cba", 1); ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); /* find string in file, case insensitive */ - run_find_file("/I aBc", "abc", 0); + run_find_file("/L /I aBc", "abc", 0); ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ret = strcmp(stdout_buffer, "abc"); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7415
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7415
participants (3)
-
Eric Pouech -
eric pouech (@epo) -
Hans Leidekker (@hans)