[PATCH v13 0/2] MR10294: Fix start word position \\< at start of line
findstr.exe accepts both ^ and \\\\\< as start-of-line designations, although the latter wasn't implemented. -- v13: findstr.exe: fix start word position \\< at start of line. https://gitlab.winehq.org/wine/wine/-/merge_requests/10294
From: Trent Waddington <trent.waddington@tensorworks.com.au> --- programs/findstr/tests/findstr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/programs/findstr/tests/findstr.c b/programs/findstr/tests/findstr.c index e766b542bb5..04a24dc31c4 100644 --- a/programs/findstr/tests/findstr.c +++ b/programs/findstr/tests/findstr.c @@ -331,6 +331,33 @@ static void test_basic(void) ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size); ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size); ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + /* Failing start of line test */ + run_find_file("^c", "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); + ret = strcmp(stdout_buffer, ""); + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + /* Successful start of line test */ + run_find_file("^c", "cab", 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, "cab"); + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + /* Start of word at start of line should be the same */ + run_find_file("\\<c", "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); + ret = strcmp(stdout_buffer, ""); + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); + + run_find_file("\\<c", "cab", 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, "cab"); + ok(!ret, "Got the wrong result. '%s'\n", stdout_buffer); } START_TEST(findstr) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10294
From: Trent Waddington <trent.waddington@tensorworks.com.au> --- programs/findstr/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/programs/findstr/main.c b/programs/findstr/main.c index 7e8a3299e89..233a0e5734e 100644 --- a/programs/findstr/main.c +++ b/programs/findstr/main.c @@ -172,7 +172,10 @@ static BOOL match_star(char c, const char *str, const char *regexp, UINT pos, BO static BOOL match_regexp(const char *str, const char *regexp, BOOL case_sensitive) { if (strstr(regexp, "[")) FIXME("character ranges (i.e. [abc], [^a-z]) are not supported\n"); - if (strstr(regexp, "\\<") || strstr(regexp, "\\>")) FIXME("word position (i.e. \\< and \\>) not supported\n"); + if ((strstr(regexp, "\\<") && strstr(regexp, "\\<") != regexp) || strstr(regexp, "\\>")) + FIXME("word position (i.e. \\< and \\>) not supported\n"); + + if (regexp[0] == '\\' && regexp[1] == '<') return match_here(str, regexp, 2, case_sensitive); if (regexp[0] == '^') return match_here(str, regexp, 1, case_sensitive); do { if (match_here(str, regexp, 0, case_sensitive)) return TRUE; } while (*str++); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10294
Putting the tests first is also an option but then you have to mark them todo_wine so they pass without the fix. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10294#note_132940
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10294
participants (3)
-
Hans Leidekker (@hans) -
Trent Waddington -
Trent Waddington (@trent.waddington)