diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-01-25 13:55:35 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-01-25 13:55:35 +0000 |
commit | f17e09bcc8e69f124b4571309f7fa3785550d269 (patch) | |
tree | e9a868cc1f7650f4bc6ccb163d9b139422c68cdb /xpointer.c | |
parent | 48177c22d709ddfa33228b9a3653afa866e17bbf (diff) | |
download | libxml2-f17e09bcc8e69f124b4571309f7fa3785550d269.tar.gz |
Incorporated patches, some cleanup:
- xpath.[ch] xpointer.c: added xmlXPathCmpNodes, changed
xmlXPtrCmpPoints to use it.
- propagated the following patch from Alejandro Forero
- include/win32config.h xmlIO.c: applied further suggestions
from Igor Zlatkovic <igorz@dialup.nacamar.de> and cleanup
- example/gjobread.c: fixed warnings, now that it builds
Daniel
Diffstat (limited to 'xpointer.c')
-rw-r--r-- | xpointer.c | 56 |
1 files changed, 1 insertions, 55 deletions
@@ -151,9 +151,6 @@ xmlXPtrGetNthChild(xmlNodePtr cur, int no) { */ int xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) { - int depth1, depth2; - xmlNodePtr cur, root; - if ((node1 == NULL) || (node2 == NULL)) return(-2); /* @@ -166,58 +163,7 @@ xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) { return(-1); return(0); } - if (node1 == node2->prev) - return(1); - if (node1 == node2->next) - return(-1); - - /* - * compute depth to root - */ - for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) { - if (cur == node1) - return(1); - depth2++; - } - root = cur; - for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) { - if (cur == node2) - return(-1); - depth1++; - } - /* - * Distinct document (or distinct entities :-( ) case. - */ - if (root != cur) { - return(-2); - } - /* - * get the nearest common ancestor. - */ - while (depth1 > depth2) { - depth1--; - node1 = node1->parent; - } - while (depth2 > depth1) { - depth2--; - node2 = node2->parent; - } - while (node1->parent != node2->parent) { - node1 = node1->parent; - node2 = node2->parent; - /* should not happen but just in case ... */ - if ((node1 == NULL) || (node2 == NULL)) - return(-2); - } - /* - * Find who's first. - */ - if (node1 == node2->next) - return(-1); - for (cur = node1->next;cur != NULL;cur = cur->next) - if (cur == node2) - return(1); - return(-1); /* assume there is no sibling list corruption */ + return(xmlXPathCmpNodes(node1, node2)); } /** |