diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2008-03-13 07:27:24 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2008-03-13 07:27:24 +0000 |
commit | 10bda629bf8fe279f02493f0921110c552be3171 (patch) | |
tree | 745331f45bd2f2116d9f3783639f5003d7945d60 /xmlregexp.c | |
parent | 35fcbb84d2c480f29c7a870ec9b75fc8c8a5de07 (diff) | |
download | android_external_libxml2-10bda629bf8fe279f02493f0921110c552be3171.tar.gz android_external_libxml2-10bda629bf8fe279f02493f0921110c552be3171.tar.bz2 android_external_libxml2-10bda629bf8fe279f02493f0921110c552be3171.zip |
found a nasty bug in regexp automata build, reported by Ashwin and Bjorn
* xmlregexp.c: found a nasty bug in regexp automata build,
reported by Ashwin and Bjorn Reese
Daniel
svn path=/trunk/; revision=3705
Diffstat (limited to 'xmlregexp.c')
-rw-r--r-- | xmlregexp.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/xmlregexp.c b/xmlregexp.c index 52e484cb..389453b9 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -1532,6 +1532,8 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt, static int xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, xmlRegAtomPtr atom) { + xmlRegStatePtr end; + if (atom == NULL) { ERROR("genrate transition: atom == NULL"); return(-1); @@ -1689,12 +1691,31 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, else { return(-1); } + } + end = to; + if ((atom->quant == XML_REGEXP_QUANT_MULT) || + (atom->quant == XML_REGEXP_QUANT_PLUS)) { + /* + * Do not pollute the target state by adding transitions from + * it as it is likely to be the shared target of multiple branches. + * So isolate with an epsilon transition. + */ + xmlRegStatePtr tmp; + + tmp = xmlRegNewState(ctxt); + if (tmp != NULL) + xmlRegStatePush(ctxt, tmp); + else { + return(-1); + } + xmlFAGenerateEpsilonTransition(ctxt, tmp, to); + to = tmp; } if (xmlRegAtomPush(ctxt, atom) < 0) { return(-1); } xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1); - ctxt->state = to; + ctxt->state = end; switch (atom->quant) { case XML_REGEXP_QUANT_OPT: atom->quant = XML_REGEXP_QUANT_ONCE; |