* tests/test-regex.c (main): New test case for glibc bug 11053. --- ChangeLog | 3 +++ tests/test-regex.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
diff --git a/ChangeLog b/ChangeLog index 69abc35dc..d838ad0d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2021-02-05 Paul Eggert <egg...@cs.ucla.edu> + regex-tests: add bug 11053 test + * tests/test-regex.c (main): New test case for glibc bug 11053. + regex: debug check for set member duplicates * lib/regex_internal.c (re_node_set_insert): Add a DEBUG_ASSERT that would have caught some recently-fixed performance bugs diff --git a/tests/test-regex.c b/tests/test-regex.c index a14619805..adccf2187 100644 --- a/tests/test-regex.c +++ b/tests/test-regex.c @@ -407,6 +407,35 @@ main (void) free (regs.end); } + /* glibc bug 11053. */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC); + memset (®ex, 0, sizeof regex); + static char const pat_sub2[] = "\\(a*\\)*a*\\1"; + s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, ®ex); + if (s) + report_error ("%s: %s", pat_sub2, s); + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "a"; + int datalen = sizeof data - 1; + i = re_search (®ex, data, datalen, 0, datalen, ®s); + if (i != 0) + report_error ("re_search '%s' on '%s' returned %d", pat_sub2, data, i); + else if (regs.num_regs < 2) + report_error ("re_search '%s' on '%s' returned only %d registers", + pat_sub2, data, (int) regs.num_regs); + else if (! (regs.start[0] == 0 && regs.end[0] == 1)) + report_error ("re_search '%s' on '%s' returned wrong match [%d,%d)", + pat_sub2, data, (int) regs.start[0], (int) regs.end[0]); + else if (! (regs.start[1] == 0 && regs.end[1] == 0)) + report_error ("re_search '%s' on '%s' returned wrong submatch [%d,%d)", + pat_sub2, data, regs.start[1], regs.end[1]); + regfree (®ex); + free (regs.start); + free (regs.end); + } + /* Catch a bug reported by Vin Shelton in https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html */ -- 2.27.0