diff options
author | Mike Hommey <glandium@debian.org> | 2010-11-05 08:17:59 +0100 |
---|---|---|
committer | Mike Hommey <glandium@debian.org> | 2010-11-05 08:17:59 +0100 |
commit | 2d1849b271fa8697b88d07ba7d78dc83591e1363 (patch) | |
tree | ea10e1d707176e335e17cce9ae634cedfe0d5135 /xpath.c | |
parent | eb5d521a2df72fa829a7f8196b957c696e7ccc58 (diff) | |
download | libxml2-2d1849b271fa8697b88d07ba7d78dc83591e1363.tar.gz |
Import upstream version 2.7.8upstream/2.7.8.dfsg
Diffstat (limited to 'xpath.c')
-rw-r--r-- | xpath.c | 46 |
1 files changed, 35 insertions, 11 deletions
@@ -8106,9 +8106,17 @@ xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); - if (cur != NULL && cur->children != NULL) - return cur->children ; - if (cur == NULL) cur = ctxt->context->node; + if ((cur != NULL) && (cur->type != XML_ATTRIBUTE_NODE) && + (cur->type != XML_NAMESPACE_DECL) && (cur->children != NULL)) + return(cur->children); + + if (cur == NULL) { + cur = ctxt->context->node; + if (cur->type == XML_NAMESPACE_DECL) + return(NULL); + if (cur->type == XML_ATTRIBUTE_NODE) + cur = cur->parent; + } if (cur == NULL) return(NULL) ; /* ERROR */ if (cur->next != NULL) return(cur->next) ; do { @@ -8162,8 +8170,13 @@ xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); - if (cur == NULL) + if (cur == NULL) { cur = ctxt->context->node; + if (cur->type == XML_NAMESPACE_DECL) + return(NULL); + if (cur->type == XML_ATTRIBUTE_NODE) + return(cur->parent); + } if (cur == NULL) return (NULL); if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) @@ -8207,8 +8220,8 @@ xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt, cur = ctxt->context->node; if (cur == NULL) return (NULL); - if (cur->type == XML_NAMESPACE_DECL) - cur = (xmlNodePtr)((xmlNsPtr)cur)->next; + if (cur->type == XML_NAMESPACE_DECL) + return (NULL); ctxt->ancestor = cur->parent; } if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) @@ -10067,15 +10080,23 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) } #endif if (CUR == '.') { + int v, frac = 0; + double fraction = 0; + NEXT; if (((CUR < '0') || (CUR > '9')) && (!ok)) { XP_ERROR(XPATH_NUMBER_ERROR); } - while ((CUR >= '0') && (CUR <= '9')) { - mult /= 10; - ret = ret + (CUR - '0') * mult; + while ((CUR >= '0') && (CUR <= '9') && (frac < MAX_FRAC)) { + v = (CUR - '0'); + fraction = fraction * 10 + v; + frac = frac + 1; NEXT; } + fraction /= my_pow10[frac]; + ret = ret + fraction; + while ((CUR >= '0') && (CUR <= '9')) + NEXT; } if ((CUR == 'e') || (CUR == 'E')) { NEXT; @@ -11249,7 +11270,10 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) { } } - CHECK_ERROR; + if (ctxt->error != XPATH_EXPRESSION_OK) { + xmlFree(name); + return; + } name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name); if (test == 0) @@ -12655,7 +12679,7 @@ xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt, return (total); #ifdef XP_OPTIMIZED_FILTER_FIRST case XPATH_OP_FILTER: - total =+ xmlXPathCompOpEvalFilterFirst(ctxt, op, first); + total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first); return (total); #endif default: |