Hi,

When using libxml2 git master, some lxml tests fail. The cause is this commit:

commit ba58f23c60862f2158b457f4d30031761bf4dde1
Author: Nick Wellnhofer <wellnho...@aevum.de>
Date:   Sun Mar 8 16:44:11 2015 +0100

    Fix order of root nodes
    
    Make sure root nodes are sorted before other nodes.

diff --git a/xpath.c b/xpath.c
index ffd2a48..e9f5bf9 100644
--- a/xpath.c
+++ b/xpath.c
@@ -361,13 +361,13 @@ turtle_comparison:
     /*
      * compute depth to root
      */
-    for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) {
+    for (depth2 = 0, cur = node2; cur != NULL; cur = cur->parent) {
        if (cur == node1)
            return(1);
        depth2++;
     }
     root = cur;
-    for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) {
+    for (depth1 = 0, cur = node1; cur != NULL; cur = cur->parent) {
        if (cur == node2)
            return(-1);
        depth1++;
    }
    /*                                                                          
     * Distinct document (or distinct entities :-( ) case.                      
     */
    if (root != cur) {
        return(-2);
    }


Consider the last three lines. After the change, root == NULL == cur,
and the condition (root != cur) is always false. That’s not
what we want.

Patch attached.

Regards
 Olli Pottonen

commit 39cb72740326645358bbf238f4940fbb77adc6ff
Author: Olli Pottonen <olli.potto...@iki.fi>
Date:   Sat Jul 11 09:02:48 2015 +1000

    Fix order of distinct documents.
    
    In xmlXPathCmpNodesExt, fix case where two nodes are from distinct
    documents.

diff --git a/xpath.c b/xpath.c
index e9f5bf9..441c14d 100644
--- a/xpath.c
+++ b/xpath.c
@@ -152,7 +152,7 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
     int depth1, depth2;
     int misc = 0, precedence1 = 0, precedence2 = 0;
     xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
-    xmlNodePtr cur, root;
+    xmlNodePtr cur, root1, root2;
     long l1, l2;
 
     if ((node1 == NULL) || (node2 == NULL))
@@ -365,17 +365,18 @@ turtle_comparison:
        if (cur == node1)
            return(1);
        depth2++;
+       root1 = cur;
     }
-    root = cur;
     for (depth1 = 0, cur = node1; cur != NULL; cur = cur->parent) {
        if (cur == node2)
            return(-1);
        depth1++;
+       root2 = cur;
     }
     /*
      * Distinct document (or distinct entities :-( ) case.
      */
-    if (root != cur) {
+    if (root1 != root2) {
        return(-2);
     }
     /*
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to