mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-12 09:17:37 +03:00
seems a test to avoid duplicate transition is really needed at all times.
* xmlregexp.c: seems a test to avoid duplicate transition is really needed at all times. Luka Por gave an example hitting this. Changed back the internal API. Daniel
This commit is contained in:
parent
47fffb40d9
commit
5de0938fd1
@ -1,3 +1,9 @@
|
|||||||
|
Mon Sep 26 19:18:24 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlregexp.c: seems a test to avoid duplicate transition is
|
||||||
|
really needed at all times. Luka Por gave an example hitting
|
||||||
|
this. Changed back the internal API.
|
||||||
|
|
||||||
Thu Sep 22 13:14:07 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
Thu Sep 22 13:14:07 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xmlreader.c: fixing leak in xmlTextReaderReadString() #316924
|
* xmlreader.c: fixing leak in xmlTextReaderReadString() #316924
|
||||||
|
61
xmlregexp.c
61
xmlregexp.c
@ -1238,7 +1238,7 @@ xmlRegStateAddTransTo(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr target,
|
|||||||
static void
|
static void
|
||||||
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||||
xmlRegAtomPtr atom, xmlRegStatePtr target,
|
xmlRegAtomPtr atom, xmlRegStatePtr target,
|
||||||
int counter, int count, int nchk) {
|
int counter, int count) {
|
||||||
|
|
||||||
int nrtrans;
|
int nrtrans;
|
||||||
|
|
||||||
@ -1256,19 +1256,17 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
|||||||
* so, silently ignore this request.
|
* so, silently ignore this request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nchk == 0) {
|
for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) {
|
||||||
for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) {
|
xmlRegTransPtr trans = &(state->trans[nrtrans]);
|
||||||
xmlRegTransPtr trans = &(state->trans[nrtrans]);
|
if ((trans->atom == atom) &&
|
||||||
if ((trans->atom == atom) &&
|
(trans->to == target->no) &&
|
||||||
(trans->to == target->no) &&
|
(trans->counter == counter) &&
|
||||||
(trans->counter == counter) &&
|
(trans->count == count)) {
|
||||||
(trans->count == count)) {
|
|
||||||
#ifdef DEBUG_REGEXP_GRAPH
|
#ifdef DEBUG_REGEXP_GRAPH
|
||||||
printf("Ignoring duplicate transition from %d to %d\n",
|
printf("Ignoring duplicate transition from %d to %d\n",
|
||||||
state->no, target->no);
|
state->no, target->no);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1362,9 +1360,9 @@ xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt,
|
|||||||
ctxt->state = to;
|
ctxt->state = to;
|
||||||
}
|
}
|
||||||
if (lax)
|
if (lax)
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER, 0);
|
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER);
|
||||||
else
|
else
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER, 0);
|
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1382,7 +1380,7 @@ xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt,
|
|||||||
xmlRegStatePush(ctxt, to);
|
xmlRegStatePush(ctxt, to);
|
||||||
ctxt->state = to;
|
ctxt->state = to;
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1, 0);
|
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1401,7 +1399,7 @@ xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt,
|
|||||||
xmlRegStatePush(ctxt, to);
|
xmlRegStatePush(ctxt, to);
|
||||||
ctxt->state = to;
|
ctxt->state = to;
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1, 0);
|
xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1420,7 +1418,7 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
|
|||||||
xmlRegStatePush(ctxt, to);
|
xmlRegStatePush(ctxt, to);
|
||||||
ctxt->state = to;
|
ctxt->state = to;
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter, 0);
|
xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1545,7 +1543,7 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
|||||||
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1, 0);
|
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
||||||
ctxt->state = to;
|
ctxt->state = to;
|
||||||
}
|
}
|
||||||
switch (atom->quant) {
|
switch (atom->quant) {
|
||||||
@ -1556,11 +1554,11 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
|||||||
case XML_REGEXP_QUANT_MULT:
|
case XML_REGEXP_QUANT_MULT:
|
||||||
atom->quant = XML_REGEXP_QUANT_ONCE;
|
atom->quant = XML_REGEXP_QUANT_ONCE;
|
||||||
xmlFAGenerateEpsilonTransition(ctxt, from, to);
|
xmlFAGenerateEpsilonTransition(ctxt, from, to);
|
||||||
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1, 0);
|
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
|
||||||
break;
|
break;
|
||||||
case XML_REGEXP_QUANT_PLUS:
|
case XML_REGEXP_QUANT_PLUS:
|
||||||
atom->quant = XML_REGEXP_QUANT_ONCE;
|
atom->quant = XML_REGEXP_QUANT_ONCE;
|
||||||
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1, 0);
|
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1617,7 +1615,7 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
|
|||||||
|
|
||||||
xmlRegStateAddTrans(ctxt, from, NULL,
|
xmlRegStateAddTrans(ctxt, from, NULL,
|
||||||
ctxt->states[newto],
|
ctxt->states[newto],
|
||||||
-1, to->trans[transnr].count, 0);
|
-1, to->trans[transnr].count);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_REGEXP_GRAPH
|
#ifdef DEBUG_REGEXP_GRAPH
|
||||||
printf("Found epsilon trans %d from %d to %d\n",
|
printf("Found epsilon trans %d from %d to %d\n",
|
||||||
@ -1640,10 +1638,10 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
|
|||||||
if (to->trans[transnr].counter >= 0) {
|
if (to->trans[transnr].counter >= 0) {
|
||||||
xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
|
xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
|
||||||
ctxt->states[newto],
|
ctxt->states[newto],
|
||||||
to->trans[transnr].counter, -1, 1);
|
to->trans[transnr].counter, -1);
|
||||||
} else {
|
} else {
|
||||||
xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
|
xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
|
||||||
ctxt->states[newto], counter, -1, 1);
|
ctxt->states[newto], counter, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1926,12 +1924,17 @@ static int
|
|||||||
xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||||
int to, xmlRegAtomPtr atom) {
|
int to, xmlRegAtomPtr atom) {
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int transnr;
|
int transnr, nbTrans;
|
||||||
xmlRegTransPtr t1;
|
xmlRegTransPtr t1;
|
||||||
|
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
return(ret);
|
return(ret);
|
||||||
for (transnr = 0;transnr < state->nbTrans;transnr++) {
|
/*
|
||||||
|
* don't recurse on transitions potentially added in the course of
|
||||||
|
* the elimination.
|
||||||
|
*/
|
||||||
|
nbTrans = state->nbTrans;
|
||||||
|
for (transnr = 0;transnr < nbTrans;transnr++) {
|
||||||
t1 = &(state->trans[transnr]);
|
t1 = &(state->trans[transnr]);
|
||||||
/*
|
/*
|
||||||
* check transitions conflicting with the one looked at
|
* check transitions conflicting with the one looked at
|
||||||
@ -5095,7 +5098,7 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
|||||||
to = xmlRegNewState(am);
|
to = xmlRegNewState(am);
|
||||||
xmlRegStatePush(am, to);
|
xmlRegStatePush(am, to);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(am, from, atom, to, counter, -1, 0);
|
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
|
||||||
xmlRegAtomPush(am, atom);
|
xmlRegAtomPush(am, atom);
|
||||||
am->state = to;
|
am->state = to;
|
||||||
|
|
||||||
@ -5161,7 +5164,7 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
|||||||
to = xmlRegNewState(am);
|
to = xmlRegNewState(am);
|
||||||
xmlRegStatePush(am, to);
|
xmlRegStatePush(am, to);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(am, from, atom, to, counter, -1, 0);
|
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
|
||||||
xmlRegAtomPush(am, atom);
|
xmlRegAtomPush(am, atom);
|
||||||
am->state = to;
|
am->state = to;
|
||||||
|
|
||||||
@ -5250,7 +5253,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
|||||||
to = xmlRegNewState(am);
|
to = xmlRegNewState(am);
|
||||||
xmlRegStatePush(am, to);
|
xmlRegStatePush(am, to);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(am, from, atom, to, counter, -1, 0);
|
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
|
||||||
xmlRegAtomPush(am, atom);
|
xmlRegAtomPush(am, atom);
|
||||||
am->state = to;
|
am->state = to;
|
||||||
return(to);
|
return(to);
|
||||||
@ -5312,7 +5315,7 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
|||||||
to = xmlRegNewState(am);
|
to = xmlRegNewState(am);
|
||||||
xmlRegStatePush(am, to);
|
xmlRegStatePush(am, to);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(am, from, atom, to, counter, -1, 0);
|
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
|
||||||
xmlRegAtomPush(am, atom);
|
xmlRegAtomPush(am, atom);
|
||||||
am->state = to;
|
am->state = to;
|
||||||
return(to);
|
return(to);
|
||||||
|
Loading…
Reference in New Issue
Block a user