mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
[BZ #544]
Update. 2004-11-18 Jakub Jelinek <jakub@redhat.com> [BZ #544] * posix/regex.h (RE_NO_SUB): New define. * posix/regex_internal.h (OP_DELETED_SUBEXP): New. (re_dfa_t): Add subexp_map. * posix/regcomp.c (struct subexp_optimize): New type. (optimize_subexps): New routine. (re_compile_internal): Call it. (re_compile_pattern): Set preg->no_sub to 1 if RE_NO_SUB. (free_dfa_content): Free subexp_map. (calc_inveclosure, calc_eclosure): Skip OP_DELETED_SUBEXP nodes. * posix/regexec.c (re_search_internal): If subexp_map is not NULL, duplicate registers as needed. * posix/Makefile: Add rules to build and run tst-regex2. * posix/tst-regex2.c: New test. * posix/rxspencer/tests: Fix last two tests (\0 -> \1). Add some new tests for nested subexpressions.
This commit is contained in:
@ -882,6 +882,18 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
|
||||
pmatch[reg_idx].rm_so += match_first;
|
||||
pmatch[reg_idx].rm_eo += match_first;
|
||||
}
|
||||
|
||||
if (dfa->subexp_map)
|
||||
for (reg_idx = 0;
|
||||
reg_idx + 1 < nmatch && reg_idx < preg->re_nsub;
|
||||
reg_idx++)
|
||||
if (dfa->subexp_map[reg_idx] != reg_idx)
|
||||
{
|
||||
pmatch[reg_idx + 1].rm_so
|
||||
= pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
|
||||
pmatch[reg_idx + 1].rm_eo
|
||||
= pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
|
||||
}
|
||||
}
|
||||
|
||||
free_return:
|
||||
|
Reference in New Issue
Block a user