From 99c394d9c50efdaca1d4c437cf22c9c160ed9c65 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 14 Jul 2005 12:58:49 +0000 Subject: [PATCH] fixed where xmlMemoryDump() should be called. fixed handling of {0}, \n, * testRegexp.c: fixed where xmlMemoryDump() should be called. * xmlregexp.c: fixed handling of {0}, \n, \r and \t, two bugs affecting NIST regression tests Daniel --- ChangeLog | 6 ++++++ testRegexp.c | 3 +-- xmlregexp.c | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d706db5..60a67014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jul 14 14:57:36 CEST 2005 Daniel Veillard + + * testRegexp.c: fixed where xmlMemoryDump() should be called. + * xmlregexp.c: fixed handling of {0}, \n, \r and \t, two bugs + affecting NIST regression tests + Thu Jul 14 11:30:24 CEST 2005 Daniel Veillard * configure.in: applied a patch from Gerrit P. Haase to add diff --git a/testRegexp.c b/testRegexp.c index 7f344148..4f79481e 100644 --- a/testRegexp.c +++ b/testRegexp.c @@ -140,12 +140,11 @@ int main(int argc, char **argv) { } } } - xmlMemoryDump(); if (comp != NULL) xmlRegFreeRegexp(comp); } xmlCleanupParser(); - /* xmlMemoryDump(); */ + xmlMemoryDump(); return(0); } diff --git a/xmlregexp.c b/xmlregexp.c index ee635f1e..e65c1a66 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -1467,6 +1467,23 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, break; } return(0); + } else if ((atom->min == 0) && (atom->max == 0) && + (atom->quant == XML_REGEXP_QUANT_RANGE)) { + /* + * we can discard the atom and generate an epsilon transition instead + */ + if (to == NULL) { + to = xmlRegNewState(ctxt); + if (to != NULL) + xmlRegStatePush(ctxt, to); + else { + return(-1); + } + } + xmlFAGenerateEpsilonTransition(ctxt, from, to); + ctxt->state = to; + xmlRegFreeAtom(atom); + return(0); } else { if (to == NULL) { to = xmlRegNewState(ctxt); @@ -3815,8 +3832,21 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) { (cur == 0x5E)) { if (ctxt->atom == NULL) { ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL); - if (ctxt->atom != NULL) - ctxt->atom->codepoint = cur; + if (ctxt->atom != NULL) { + switch (cur) { + case 'n': + ctxt->atom->codepoint = '\n'; + break; + case 'r': + ctxt->atom->codepoint = '\r'; + break; + case 't': + ctxt->atom->codepoint = '\t'; + break; + default: + ctxt->atom->codepoint = cur; + } + } } else if (ctxt->atom->type == XML_REGEXP_RANGES) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, cur, cur, NULL);