2021-02-05 Paul Eggert <eggert@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
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
*/