mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
Fix an error with regexp on nullable counted char transition
This is the first of the two issues raised by Pete Cordell in https://mail.gnome.org/archives/xml/2016-April/msg00030.html
This commit is contained in:
13
xmlregexp.c
13
xmlregexp.c
@ -1544,6 +1544,7 @@ static int
|
|||||||
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
||||||
xmlRegStatePtr to, xmlRegAtomPtr atom) {
|
xmlRegStatePtr to, xmlRegAtomPtr atom) {
|
||||||
xmlRegStatePtr end;
|
xmlRegStatePtr end;
|
||||||
|
int nullable = 0;
|
||||||
|
|
||||||
if (atom == NULL) {
|
if (atom == NULL) {
|
||||||
ERROR("genrate transition: atom == NULL");
|
ERROR("genrate transition: atom == NULL");
|
||||||
@ -1730,6 +1731,13 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
|||||||
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
if ((atom->quant == XML_REGEXP_QUANT_RANGE) &&
|
||||||
|
(atom->min == 0) && (atom->max > 0)) {
|
||||||
|
nullable = 1;
|
||||||
|
atom->min = 1;
|
||||||
|
if (atom->max == 1)
|
||||||
|
atom->quant = XML_REGEXP_QUANT_OPT;
|
||||||
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
||||||
ctxt->state = end;
|
ctxt->state = end;
|
||||||
switch (atom->quant) {
|
switch (atom->quant) {
|
||||||
@ -1747,11 +1755,8 @@ 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 (nullable)
|
||||||
if (atom->min == 0) {
|
|
||||||
xmlFAGenerateEpsilonTransition(ctxt, from, to);
|
xmlFAGenerateEpsilonTransition(ctxt, from, to);
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user