libxml2 r3705 - trunk
- From: veillard svn gnome org
- To: svn-commits-list gnome org
- Subject: libxml2 r3705 - trunk
- Date: Thu, 13 Mar 2008 07:27:25 +0000 (GMT)
Author: veillard
Date: Thu Mar 13 07:27:24 2008
New Revision: 3705
URL: http://svn.gnome.org/viewvc/libxml2?rev=3705&view=rev
Log:
* xmlregexp.c: found a nasty bug in regexp automata build,
reported by Ashwin and Bjorn Reese
Daniel
Modified:
trunk/ChangeLog
trunk/xmlregexp.c
Modified: trunk/xmlregexp.c
==============================================================================
--- trunk/xmlregexp.c (original)
+++ trunk/xmlregexp.c Thu Mar 13 07:27:24 2008
@@ -1532,6 +1532,8 @@
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 @@
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]