From ae7c300b6722969513f14ec5dfe6412fb64f1be6 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sun, 7 Oct 2001 11:19:37 +0000 Subject: [PATCH] fixed bug #61070, number ANY formatting should be faster too. updated the * libxslt/numbers.c: fixed bug #61070, number ANY formatting should be faster too. * tests/docbook/result/xtchunk/html/* tests/xmlspec/REC-xml-20001006*.html: updated the result of the tests. A subtle bug unnnoticed yet in the XML Rec formatting got fixed. Daniel --- ChangeLog | 8 ++ libxslt/numbers.c | 112 +++++++++++---------- tests/docbook/result/xtchunk/html/apa.orig | 6 +- .../xtchunk/html/{apas17.orig => apas02.orig} | 6 +- .../xtchunk/html/{apas18.orig => apas03.orig} | 6 +- tests/docbook/result/xtchunk/html/index.orig | 8 +- tests/docbook/result/xtchunk/html/indexs02.orig | 20 ++-- tests/docbook/result/xtchunk/html/indexs04.orig | 68 ++++++------- tests/docbook/result/xtchunk/html/indexs06.orig | 10 +- tests/docbook/result/xtchunk/html/indexs07.orig | 4 +- tests/docbook/result/xtchunk/html/indexs08.orig | 4 +- tests/docbook/result/xtchunk/html/indexs09.orig | 2 +- tests/docbook/result/xtchunk/html/indexs12.orig | 8 +- tests/xmlspec/REC-xml-20001006-review.html | 6 +- tests/xmlspec/REC-xml-20001006.html | 6 +- 15 files changed, 143 insertions(+), 131 deletions(-) rename tests/docbook/result/xtchunk/html/{apas17.orig => apas02.orig} (98%) rename tests/docbook/result/xtchunk/html/{apas18.orig => apas03.orig} (99%) diff --git a/ChangeLog b/ChangeLog index 528fd1c..d7e92d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Oct 7 13:15:33 CEST 2001 Daniel Veillard + + * libxslt/numbers.c: fixed bug #61070, number ANY formatting + should be faster too. + * tests/docbook/result/xtchunk/html/* tests/xmlspec/REC-xml-20001006*.html: + updated the result of the tests. A subtle bug unnnoticed yet + in the XML Rec formatting got fixed. + Sat Oct 6 19:45:07 CEST 2001 Daniel Veillard * libxslt/numbers.c: trying to fix bug #61070, seems there diff --git a/libxslt/numbers.c b/libxslt/numbers.c index 2f6a970..6c933fd 100644 --- a/libxslt/numbers.c +++ b/libxslt/numbers.c @@ -369,69 +369,73 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context, { int amount = 0; int cnt = 0; - int keep_going = TRUE; - xmlNodePtr ancestor; - xmlNodePtr preceding; - xmlXPathParserContextPtr parser; - xsltCompMatchPtr countPat; - xsltCompMatchPtr fromPat; + xmlNodePtr cur; + xsltCompMatchPtr countPat = NULL; + xsltCompMatchPtr fromPat = NULL; if (count != NULL) countPat = xsltCompilePattern(count, doc, elem); - else - countPat = NULL; if (from != NULL) fromPat = xsltCompilePattern(from, doc, elem); - else - fromPat = NULL; - context->xpathCtxt->node = node; - parser = xmlXPathNewParserContext(NULL, context->xpathCtxt); - if (parser) { - /* preceding */ - for (preceding = xmlXPathNextPreceding(parser, node); - preceding != NULL; - preceding = xmlXPathNextPreceding(parser, preceding)) { - if ((from != NULL) && - xsltTestCompMatchList(context, preceding, fromPat)) { - keep_going = FALSE; - break; /* for */ - } - if (count == NULL) { - if ((node->type == preceding->type) && - /* FIXME: must use expanded-name instead of local name */ - xmlStrEqual(node->name, preceding->name)) - cnt++; - } else { - if (xsltTestCompMatchList(context, preceding, countPat)) - cnt++; - } + + /* select the starting node */ + switch (node->type) { + case XML_ELEMENT_NODE: + cur = node; + break; + case XML_ATTRIBUTE_NODE: + cur = ((xmlAttrPtr) node)->parent; + break; + case XML_TEXT_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + cur = node->parent; + break; + default: + cur = NULL; + break; + } + + while (cur != NULL) { + /* process current node */ + if (count == NULL) { + if ((node->type == cur->type) && + /* FIXME: must use expanded-name instead of local name */ + xmlStrEqual(node->name, cur->name)) + cnt++; + } else { + if (xsltTestCompMatchList(context, cur, countPat)) + cnt++; + } + if ((from != NULL) && + xsltTestCompMatchList(context, cur, fromPat)) { + break; /* while */ } - if (keep_going) { - /* ancestor-or-self */ - for (ancestor = node; - ancestor != NULL; - ancestor = xmlXPathNextAncestor(parser, ancestor)) { - if ((from != NULL) && - xsltTestCompMatchList(context, ancestor, fromPat)) { - break; /* for */ - } - if (count == NULL) { - if ((node->type == ancestor->type) && - /* FIXME */ - xmlStrEqual(node->name, ancestor->name)) - cnt++; - } else { - if (xsltTestCompMatchList(context, ancestor, countPat)) - cnt++; - } - } + /* Skip to next preceding or ancestor */ + if ((cur->type == XML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (cur->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (cur->type == XML_HTML_DOCUMENT_NODE)) + break; /* while */ + + while ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) + cur = cur->prev; + if (cur->prev != NULL) { + for (cur = cur->prev; cur->last != NULL; cur = cur->last); + } else { + cur = cur->parent; } - array[amount++] = (double)cnt; - xmlXPathFreeParserContext(parser); + } - xsltFreeCompMatchList(countPat); - xsltFreeCompMatchList(fromPat); + + array[amount++] = (double) cnt; + + if (countPat != NULL) + xsltFreeCompMatchList(countPat); + if (fromPat != NULL) + xsltFreeCompMatchList(fromPat); return(amount); } diff --git a/tests/docbook/result/xtchunk/html/apa.orig b/tests/docbook/result/xtchunk/html/apa.orig index d5cb0b8..8f10138 100644 --- a/tests/docbook/result/xtchunk/html/apa.orig +++ b/tests/docbook/result/xtchunk/html/apa.orig @@ -7,7 +7,7 @@ - +