1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

another nasty regexp case fixed. added to regression suite Daniel

* xmlregexp.c: another nasty regexp case fixed.
* test/regexp/ranges2 result/regexp/ranges2: added to regression
  suite
Daniel

svn path=/trunk/; revision=3658
This commit is contained in:
Daniel Veillard
2007-08-28 17:33:45 +00:00
parent ec72008ba7
commit c821e03c66
4 changed files with 58 additions and 4 deletions

View File

@ -1,3 +1,9 @@
Tue Aug 28 19:32:28 CEST 2007 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: another nasty regexp case fixed.
* test/regexp/ranges2 result/regexp/ranges2: added to regression
suite
Fri Aug 24 10:58:58 HKT 2007 William Brack <wbrack@mmm.com.hk> Fri Aug 24 10:58:58 HKT 2007 William Brack <wbrack@mmm.com.hk>
* nanohttp.c: Enhanced to include port number (if not == 80) on the * nanohttp.c: Enhanced to include port number (if not == 80) on the

14
result/regexp/ranges2 Normal file
View File

@ -0,0 +1,14 @@
Regexp: (a|b{0,3}){0,1}
a: Ok
aa: Fail
b: Ok
bb: Ok
bbb: Ok
bbbb: Fail
ab: Fail
ba: Fail
Regexp: ([0-9]{0,3}|([0-9]{0}|[0-9]{0,3})){0,3}
0: Ok
00: Ok
123: Ok
abc: Fail

14
test/regexp/ranges2 Normal file
View File

@ -0,0 +1,14 @@
=>(a|b{0,3}){0,1}
a
aa
b
bb
bbb
bbbb
ab
ba
=>([0-9]{0,3}|([0-9]{0}|[0-9]{0,3})){0,3}
0
00
123
abc

View File

@ -1610,7 +1610,7 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
/* ???? For some reason it seems we never reach that /* ???? For some reason it seems we never reach that
case, I suppose this got optimized out before when case, I suppose this got optimized out before when
building the automata */ building the automata */
copy = xmlRegCopyAtom(ctxt, atom);
copy = xmlRegCopyAtom(ctxt, atom); copy = xmlRegCopyAtom(ctxt, atom);
if (copy == NULL) if (copy == NULL)
return(-1); return(-1);
@ -1711,9 +1711,11 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
break; break;
case XML_REGEXP_QUANT_RANGE: case XML_REGEXP_QUANT_RANGE:
#if DV_test
if (atom->min == 0) { if (atom->min == 0) {
xmlFAGenerateEpsilonTransition(ctxt, from, to); xmlFAGenerateEpsilonTransition(ctxt, from, to);
} }
#endif
break; break;
default: default:
break; break;
@ -3211,12 +3213,22 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
* this is a multiple input sequence * this is a multiple input sequence
* If there is a counter associated increment it now. * If there is a counter associated increment it now.
* before potentially saving and rollback * before potentially saving and rollback
* do not increment if the counter is already over the
* maximum limit in which case get to next transition
*/ */
if (trans->counter >= 0) { if (trans->counter >= 0) {
if (exec->counts == NULL) { xmlRegCounterPtr counter;
if ((exec->counts == NULL) ||
(exec->comp == NULL) ||
(exec->comp->counters == NULL)) {
exec->status = -1; exec->status = -1;
goto error; goto error;
} }
counter = &exec->comp->counters[trans->counter];
if (exec->counts[trans->counter] >= counter->max)
continue; /* for loop on transitions */
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter); printf("Increasing count %d\n", trans->counter);
#endif #endif
@ -3312,10 +3324,18 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
xmlFARegExecSave(exec); xmlFARegExecSave(exec);
} }
if (trans->counter >= 0) { if (trans->counter >= 0) {
if (exec->counts == NULL) { xmlRegCounterPtr counter;
exec->status = -1;
/* make sure we don't go over the counter maximum value */
if ((exec->counts == NULL) ||
(exec->comp == NULL) ||
(exec->comp->counters == NULL)) {
exec->status = -1;
goto error; goto error;
} }
counter = &exec->comp->counters[trans->counter];
if (exec->counts[trans->counter] >= counter->max)
continue; /* for loop on transitions */
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter); printf("Increasing count %d\n", trans->counter);
#endif #endif