aboutsummaryrefslogtreecommitdiffstats
path: root/xmlregexp.c
diff options
context:
space:
mode:
authorWilliam M. Brack <wbrack@src.gnome.org>2004-05-10 07:52:15 +0000
committerWilliam M. Brack <wbrack@src.gnome.org>2004-05-10 07:52:15 +0000
commitf9b5fa2dec22e88683d96d0a2782c244df2ca766 (patch)
treec735869a66008811fd037580d98c0f8564f8dad0 /xmlregexp.c
parent6d38c750b71f9d5f379b0abdccd01533f494d1ed (diff)
downloadandroid_external_libxml2-f9b5fa2dec22e88683d96d0a2782c244df2ca766.tar.gz
android_external_libxml2-f9b5fa2dec22e88683d96d0a2782c244df2ca766.tar.bz2
android_external_libxml2-f9b5fa2dec22e88683d96d0a2782c244df2ca766.zip
enhanced xmlRegStateAddTrans to check if transition is already present
* xmlregexp.c: enhanced xmlRegStateAddTrans to check if transition is already present and, if so, to ignore the request to add it. This has a very dramatic effect on memory requirements as well as efficiency. It also fixes bug 141762.
Diffstat (limited to 'xmlregexp.c')
-rw-r--r--xmlregexp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/xmlregexp.c b/xmlregexp.c
index 0befd124..12ecd83f 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -1182,6 +1182,9 @@ static void
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
xmlRegAtomPtr atom, xmlRegStatePtr target,
int counter, int count) {
+
+ int nrtrans;
+
if (state == NULL) {
ERROR("add state: state is NULL");
return;
@@ -1190,6 +1193,25 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
ERROR("add state: target is NULL");
return;
}
+ /*
+ * Other routines follow the philosophy 'When in doubt, add a transition'
+ * so we check here whether such a transition is already present and, if
+ * so, silently ignore this request.
+ */
+
+ for (nrtrans=0; nrtrans<state->nbTrans; nrtrans++) {
+ if ((state->trans[nrtrans].atom == atom) &&
+ (state->trans[nrtrans].to == target->no) &&
+ (state->trans[nrtrans].counter == counter) &&
+ (state->trans[nrtrans].count == count)) {
+#ifdef DEBUG_REGEXP_GRAPH
+ printf("Ignoring duplicate transition from %d to %d\n",
+ state->no, target->no);
+#endif
+ return;
+ }
+ }
+
if (state->maxTrans == 0) {
state->maxTrans = 4;
state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans *