summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-03-09 16:34:11 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-04-30 22:36:41 +0200
commit90759c598da91ae14258d57c251dd835267f46be (patch)
tree8d1d8d65b1129045170ea1201a4920ccb801a2ca
parent9f7b114232904a7d0e304bff30ed4b255f34a572 (diff)
downloadlibxml2-90759c598da91ae14258d57c251dd835267f46be.tar.gz
regexp: Simplify xmlFAReduceEpsilonTransitions
-rw-r--r--xmlregexp.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/xmlregexp.c b/xmlregexp.c
index ddae0851..353d879b 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -1821,47 +1821,38 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
from->type = XML_REGEXP_FINAL_STATE;
}
for (transnr = 0;transnr < to->nbTrans;transnr++) {
- if (to->trans[transnr].to < 0)
+ xmlRegTransPtr t1 = &to->trans[transnr];
+ int tcounter;
+
+ if (t1->to < 0)
continue;
- if (to->trans[transnr].atom == NULL) {
+ if (t1->counter >= 0) {
+ /* assert(counter < 0); */
+ tcounter = t1->counter;
+ } else {
+ tcounter = counter;
+ }
+ if (t1->atom == NULL) {
/*
* Don't remove counted transitions
* Don't loop either
*/
- if (to->trans[transnr].to != fromnr) {
- if (to->trans[transnr].count >= 0) {
- int newto = to->trans[transnr].to;
-
- xmlRegStateAddTrans(ctxt, from, NULL,
- ctxt->states[newto],
- -1, to->trans[transnr].count);
+ if (t1->to != fromnr) {
+ if (t1->count >= 0) {
+ xmlRegStateAddTrans(ctxt, from, NULL, ctxt->states[t1->to],
+ -1, t1->count);
} else {
#ifdef DEBUG_REGEXP_GRAPH
printf("Found epsilon trans %d from %d to %d\n",
- transnr, tonr, to->trans[transnr].to);
+ transnr, tonr, t1->to);
#endif
- if (to->trans[transnr].counter >= 0) {
- xmlFAReduceEpsilonTransitions(ctxt, fromnr,
- to->trans[transnr].to,
- to->trans[transnr].counter);
- } else {
- xmlFAReduceEpsilonTransitions(ctxt, fromnr,
- to->trans[transnr].to,
- counter);
- }
+ xmlFAReduceEpsilonTransitions(ctxt, fromnr, t1->to,
+ tcounter);
}
}
} else {
- int newto = to->trans[transnr].to;
-
- if (to->trans[transnr].counter >= 0) {
- xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
- ctxt->states[newto],
- to->trans[transnr].counter, -1);
- } else {
- xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
- ctxt->states[newto], counter, -1);
- }
+ xmlRegStateAddTrans(ctxt, from, t1->atom,
+ ctxt->states[t1->to], tcounter, -1);
}
}
}