[4suite-checkins] [XPATH_OPTIMIZATIONS-branch] In 4Suite/Ft/Xml/XPath/src, files DataTypes.c

Jeremy Kloth jkloth at 4suite.org
Wed Dec 13 14:53:52 MST 2006


Branch: XPATH_OPTIMIZATIONS-branch

Modified Files:
    DataTypes.c

Log Message:
Fixed != comparison for nodesets

ViewCVS diff:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/XPath/src/DataTypes.c.diff?r1=1.1.2.2&r2=1.1.2.3
ViewCVS view:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/XPath/src/DataTypes.c?rev=1.1.2.3&content-type=text/vnd.viewcvs-markup

Index: DataTypes.c
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/XPath/src/Attic/DataTypes.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -U2 -r1.1.2.2 -r1.1.2.3
--- DataTypes.c	7 Dec 2006 22:23:01 -0000	1.1.2.2
+++ DataTypes.c	13 Dec 2006 21:53:52 -0000	1.1.2.3
@@ -577,5 +577,5 @@
   /* tp_doc            */ (char *) 0,
   /* tp_traverse       */ (traverseproc) 0,
-  /* tp_clear          */ 0,
+  /* tp_clear          */ (inquiry) 0,
   /* tp_richcompare    */ (richcmpfunc) object_richcompare,
   /* tp_weaklistoffset */ 0,
@@ -655,5 +655,5 @@
   /* tp_doc            */ (char *) string_doc,
   /* tp_traverse       */ (traverseproc) 0,
-  /* tp_clear          */ 0,
+  /* tp_clear          */ (inquiry) 0,
   /* tp_richcompare    */ (richcmpfunc) 0,
   /* tp_weaklistoffset */ 0,
@@ -1038,5 +1038,5 @@
   /* tp_doc            */ (char *) number_doc,
   /* tp_traverse       */ (traverseproc) 0,
-  /* tp_clear          */ 0,
+  /* tp_clear          */ (inquiry) 0,
   /* tp_richcompare    */ (richcmpfunc) number_richcompare,
   /* tp_weaklistoffset */ 0,
@@ -1222,5 +1222,5 @@
   /* tp_doc            */ (char *) boolean_doc,
   /* tp_traverse       */ (traverseproc) 0,
-  /* tp_clear          */ 0,
+  /* tp_clear          */ (inquiry) 0,
   /* tp_richcompare    */ (richcmpfunc) 0,
   /* tp_weaklistoffset */ 0,
@@ -1307,5 +1307,7 @@
      * done on the string value of each of the nodes. This means
      * that the values are then converted to numbers for comparison. */
-    if (op == Py_EQ || op == Py_NE) {
+    if (op == Py_EQ) {
+      /* Check for a node in `w` that has the same string value as a
+       * node in `v`. */
       rhs = PyDict_New();
       if (rhs == NULL) return NULL;
@@ -1336,4 +1338,28 @@
         Py_DECREF(a);
       }
+      Py_DECREF(rhs);
+    } else if (op == Py_NE) {
+      /* Check for a node in `w` that has a different string value as a
+       * node in `v`. */
+      for (i = 0; i < lhs_size; i++) {
+        a = String_New(PyList_GET_ITEM(v, i));
+        if (a == NULL) return NULL;
+        for (j = 0; j < rhs_size; j++) {
+          b = String_New(PyList_GET_ITEM(w, j));
+          if (b == NULL) {
+            Py_DECREF(a);
+            return NULL;
+          }
+          result = object_richcompare(a, b, Py_NE);
+          if (result != Boolean_False) {
+            assert(result == NULL || result == Boolean_True);
+            Py_DECREF(a);
+            Py_DECREF(b);
+            return result;
+          }
+          Py_DECREF(b);
+        }
+        Py_DECREF(a);
+      }
     } else {
       rhs = PyTuple_New(rhs_size);
@@ -1358,5 +1384,6 @@
           }
           result = object_richcompare(a, b, op);
-          if (result == NULL || result == Boolean_True) {
+          if (result != Boolean_False) {
+            assert(result == NULL || result == Boolean_True);
             Py_DECREF(a);
             Py_DECREF(rhs);
@@ -1366,6 +1393,6 @@
         Py_DECREF(a);
       }
+      Py_DECREF(rhs);
     }
-    Py_DECREF(rhs);
     Py_INCREF(Boolean_False);
     return Boolean_False;
@@ -1496,5 +1523,5 @@
   /* tp_doc            */ (char *) nodeset_doc,
   /* tp_traverse       */ (traverseproc) 0,
-  /* tp_clear          */ 0,
+  /* tp_clear          */ (inquiry) 0,
   /* tp_richcompare    */ (richcmpfunc) nodeset_richcompare,
   /* tp_weaklistoffset */ 0,


More information about the 4suite-checkins mailing list