aboutsummaryrefslogtreecommitdiffstats
path: root/xpath.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-03-07 14:20:40 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-03-07 14:20:40 +0000
commitedfd588e95d7c4690b5e85880521a32c20ed4fde (patch)
treec89387d7c8f87138c8fe7a0fbb963677fdd66f08 /xpath.c
parent8339128106b72f98adc1c4aff002fae44579da58 (diff)
downloadandroid_external_libxml2-edfd588e95d7c4690b5e85880521a32c20ed4fde.tar.gz
android_external_libxml2-edfd588e95d7c4690b5e85880521a32c20ed4fde.tar.bz2
android_external_libxml2-edfd588e95d7c4690b5e85880521a32c20ed4fde.zip
fix bug #107804, the algorithm used for document order computation was
* xpath.c: fix bug #107804, the algorithm used for document order computation was failing on attributes. Daniel
Diffstat (limited to 'xpath.c')
-rw-r--r--xpath.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/xpath.c b/xpath.c
index 69a39108..1171996a 100644
--- a/xpath.c
+++ b/xpath.c
@@ -1352,6 +1352,7 @@ xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
int
xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
int depth1, depth2;
+ int attr1 = 0, attr2 = 0;
xmlNodePtr cur, root;
if ((node1 == NULL) || (node2 == NULL))
@@ -1359,8 +1360,21 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
/*
* a couple of optimizations which will avoid computations in most cases
*/
- if (node1 == node2)
- return(0);
+ if (node1->type == XML_ATTRIBUTE_NODE) {
+ attr1 = 1;
+ node1 = node1->parent;
+ }
+ if (node2->type == XML_ATTRIBUTE_NODE) {
+ attr2 = 1;
+ node2 = node2->parent;
+ }
+ if (node1 == node2) {
+ if (attr1 == attr2)
+ return(0);
+ if (attr2 == 1)
+ return(1);
+ return(-1);
+ }
if ((node1->type == XML_NAMESPACE_DECL) ||
(node2->type == XML_NAMESPACE_DECL))
return(1);