mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
another small change on the algorithm for the elimination of epsilon
* xmlregexp.c: another small change on the algorithm for the elimination of epsilon transitions, should help on #362989 too Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 2 11:29:17 CET 2006 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlregexp.c: another small change on the algorithm for the
|
||||||
|
elimination of epsilon transitions, should help on #362989 too
|
||||||
|
|
||||||
Wed Nov 1 16:33:10 CET 2006 Daniel Veillard <daniel@veillard.com>
|
Wed Nov 1 16:33:10 CET 2006 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* tree.c: applied documentation patches from Markus Keim
|
* tree.c: applied documentation patches from Markus Keim
|
||||||
|
28
xmlregexp.c
28
xmlregexp.c
@ -1738,11 +1738,6 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
|||||||
printf("Changed transition %d on %d to go to %d\n",
|
printf("Changed transition %d on %d to go to %d\n",
|
||||||
j, tmp->no, newto);
|
j, tmp->no, newto);
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
|
||||||
tmp->trans[j].to = newto;
|
|
||||||
xmlRegStateAddTransTo(ctxt, ctxt->states[newto],
|
|
||||||
tmp->no);
|
|
||||||
#endif
|
|
||||||
tmp->trans[j].to = -1;
|
tmp->trans[j].to = -1;
|
||||||
xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom,
|
xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom,
|
||||||
ctxt->states[newto],
|
ctxt->states[newto],
|
||||||
@ -1751,20 +1746,6 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
for (i = 0;i < ctxt->nbStates;i++) {
|
|
||||||
tmp = ctxt->states[i];
|
|
||||||
for (j = 0;j < tmp->nbTrans;j++) {
|
|
||||||
if (tmp->trans[j].to == statenr) {
|
|
||||||
tmp->trans[j].to = newto;
|
|
||||||
#ifdef DEBUG_REGEXP_GRAPH
|
|
||||||
printf("Changed transition %d on %d to go to %d\n",
|
|
||||||
j, tmp->no, newto);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (state->type == XML_REGEXP_FINAL_STATE)
|
if (state->type == XML_REGEXP_FINAL_STATE)
|
||||||
ctxt->states[newto]->type = XML_REGEXP_FINAL_STATE;
|
ctxt->states[newto]->type = XML_REGEXP_FINAL_STATE;
|
||||||
/* eliminate the transition completely */
|
/* eliminate the transition completely */
|
||||||
@ -1809,11 +1790,14 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
|||||||
has_epsilon = 0;
|
has_epsilon = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* build the completed transitions bypassing the epsilons
|
* Build the completed transitions bypassing the epsilons
|
||||||
* Use a marking algorithm to avoid loops
|
* Use a marking algorithm to avoid loops
|
||||||
* mark sink states too.
|
* Mark sink states too.
|
||||||
|
* Process from the latests states backward to the start when
|
||||||
|
* there is long cascading epsilon chains this minimize the
|
||||||
|
* recursions and transition compares when adding the new ones
|
||||||
*/
|
*/
|
||||||
for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
|
for (statenr = ctxt->nbStates - 1;statenr >= 0;statenr--) {
|
||||||
state = ctxt->states[statenr];
|
state = ctxt->states[statenr];
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user