[Zope-Checkins] CVS: Zope2 - MergeTemplate.c:1.1.2.4

Jim Fulton jim@digiciool.com
Wed, 14 Mar 2001 21:00:39 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/BTrees
In directory korak:/tmp/cvs-serv10869

Modified Files:
      Tag: Catalog-BTrees-Integration
	MergeTemplate.c 
Log Message:
Fixed conflict-resolution bug: I forgot to include the next bucket in
the output state.



--- Updated File MergeTemplate.c in package Zope2 --
--- MergeTemplate.c	2001/03/14 21:08:47	1.1.2.3
+++ MergeTemplate.c	2001/03/15 02:00:39	1.1.2.4
@@ -115,16 +115,16 @@
 }
 
 static PyObject *
-bucket_merge(PyObject *s1, PyObject *s2, PyObject *s3)
+bucket_merge(Bucket *s1, Bucket *s2, Bucket *s3)
 {
   Bucket *r=0;
   PyObject *s;
   SetIteration i1 = {0,0,0}, i2 = {0,0,0}, i3 = {0,0,0}, it;
   int cmp12, cmp13, cmp23, mapping=0, set;
 
-  if (initSetIteration(&i1, s1, 0, &mapping) < 0) return NULL;
-  if (initSetIteration(&i2, s2, 0, &mapping) < 0) return NULL;
-  if (initSetIteration(&i3, s3, 0, &mapping) < 0) return NULL;
+  if (initSetIteration(&i1, OBJECT(s1), 0, &mapping) < 0) return NULL;
+  if (initSetIteration(&i2, OBJECT(s2), 0, &mapping) < 0) return NULL;
+  if (initSetIteration(&i3, OBJECT(s3), 0, &mapping) < 0) return NULL;
 
   set = ! mapping;
 
@@ -151,11 +151,11 @@
         {
           if (cmp13==0)
             {
-              if (set || TEST_VALUE(i1.value, i2.value) == 0)
+              if (set || (TEST_VALUE(i1.value, i2.value) == 0))
                 {               /* change in i3 or all same */
                   if (merge_output(r, &i3, mapping) < 0) goto err;
                 }
-              else if (set || TEST_VALUE(i1.value, i3.value) == 0)
+              else if (set || (TEST_VALUE(i1.value, i3.value) == 0))
                 {               /* change in i2 */
                   if (merge_output(r, &i2, mapping) < 0) goto err;
                 }
@@ -173,7 +173,7 @@
               if (merge_output(r, &i3, mapping) < 0) goto err;
               if (i3.next(&i3) < 0) goto err;
             }
-          else if (set || TEST_VALUE(i1.value, i2.value) == 0)
+          else if (set || (TEST_VALUE(i1.value, i2.value) == 0))
             {                   /* delete i3 */
               if (i1.next(&i1) < 0) goto err;
               if (i2.next(&i2) < 0) goto err;
@@ -191,7 +191,7 @@
               if (merge_output(r, &i2, mapping) < 0) goto err;
               if (i2.next(&i2) < 0) goto err;
             }
-          else if (set || TEST_VALUE(i1.value, i3.value) == 0)
+          else if (set || (TEST_VALUE(i1.value, i3.value) == 0))
             {                   /* delete i2 */
               if (i1.next(&i1) < 0) goto err;
               if (i3.next(&i3) < 0) goto err;
@@ -264,7 +264,7 @@
           if (merge_output(r, &i2, mapping) < 0) goto err;
           if (i2.next(&i2) < 0) goto err;
         }
-      else if (cmp12==0 && (set || TEST_VALUE(i1.value, i2.value) == 0))
+      else if (cmp12==0 && (set || (TEST_VALUE(i1.value, i2.value) == 0)))
         {                       /* delete i3 */
           if (i1.next(&i1) < 0) goto err;
           if (i2.next(&i2) < 0) goto err;
@@ -284,7 +284,7 @@
           if (merge_output(r, &i3, mapping) < 0) goto err;
           if (i3.next(&i3) < 0) goto err;
         }
-      else if (cmp13==0 && (set || TEST_VALUE(i1.value, i3.value) == 0))
+      else if (cmp13==0 && (set || (TEST_VALUE(i1.value, i3.value) == 0)))
         {                       /* delete i2 */
           if (i1.next(&i1) < 0) goto err;
           if (i3.next(&i3) < 0) goto err;
@@ -318,6 +318,11 @@
   Py_DECREF(i2.set);
   Py_DECREF(i3.set);
 
+  if (s1->next)
+    {
+      Py_INCREF(s1->next);
+      r->next = s1->next;
+    }
   s=bucket_getstate(r, NULL);
   Py_DECREF(r);