[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeItemsTemplate.c:1.1.2.5

Tim Peters tim.one@comcast.net
Sun, 9 Jun 2002 13:19:45 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv13297

Modified Files:
      Tag: Zope-3x-branch
	BTreeItemsTemplate.c 
Log Message:
Trimmed trailing whitespace.


=== Zope3/lib/python/Persistence/BTrees/BTreeItemsTemplate.c 1.1.2.4 => 1.1.2.5 ===
   Copyright (c) 2001, 2002 Zope Corporation and Contributors.
   All Rights Reserved.
-  
+
   This software is subject to the provisions of the Zope Public License,
   Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
   WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
   FOR A PARTICULAR PURPOSE
-  
+
  ****************************************************************************/
 
 #define BTREEITEMSTEMPLATE_C "$Id$\n"
@@ -28,7 +28,7 @@
 #define ITEMS(O)((BTreeItems*)(O))
 
 static PyObject *
-newBTreeItems(char kind, 
+newBTreeItems(char kind,
               Bucket *lowbucket, int lowoffset,
               Bucket *highbucket, int highoffset);
 
@@ -41,7 +41,7 @@
   PyObject_DEL(self);
 }
 
-static int 
+static int
 BTreeItems_length_or_nonzero(BTreeItems *self, int nonzero)
 {
     int r;
@@ -53,22 +53,22 @@
 
     r = self->last + 1 - self->first;
 
-    if (nonzero && r > 0) 
+    if (nonzero && r > 0)
 	/* Short-circuit if all we care about is nonempty */
 	return 1;
 
-    if (b == self->lastbucket) 
+    if (b == self->lastbucket)
 	return r;
 
     Py_INCREF(b);
     PER_USE_OR_RETURN(b, -1);
     while ((next = b->next)) {
 	r += b->len;
-	if (nonzero && r > 0) 
+	if (nonzero && r > 0)
 	    /* Short-circuit if all we care about is nonempty */
 	    break;
 
-	if (next == self->lastbucket) 
+	if (next == self->lastbucket)
 	    break; /* we already counted the last bucket */
 
 	Py_INCREF(next);
@@ -87,7 +87,7 @@
 
 static int
 BTreeItems_length( BTreeItems *self)
-{                              
+{
   return BTreeItems_length_or_nonzero(self, 0);
 }
 
@@ -105,7 +105,7 @@
 ** Returns 0 if successful, -1 on failure to seek
 */
 static int
-BTreeItems_seek(BTreeItems *self, int i) 
+BTreeItems_seek(BTreeItems *self, int i)
 {
   int delta, pseudoindex, currentoffset;
   Bucket *b, *currentbucket;
@@ -122,8 +122,8 @@
   currentoffset=self->currentoffset;
 
   /* Make sure that the index and psuedoindex have the same sign */
-  if (pseudoindex < 0 && i >=0) 
-    {                                
+  if (pseudoindex < 0 && i >=0)
+    {
       /* Position to the start of the sequence. */
       ASSIGNB(currentbucket, self->firstbucket);
       Py_INCREF(currentbucket);
@@ -141,14 +141,14 @@
             }
         }
       pseudoindex = 0;
-    } 
-  else if (self->pseudoindex >= 0 && i < 0) 
+    }
+  else if (self->pseudoindex >= 0 && i < 0)
     {
       /* Position to the end of the sequence. */
       ASSIGNBC(currentbucket, self->lastbucket);
       currentoffset = self->last;
       UNLESS (PER_USE(currentbucket)) goto err;
-      
+
       /* We need to be careful that we have a valid offset! */
       if (currentoffset >= currentbucket->len)
         {
@@ -164,30 +164,30 @@
   else
     {
       UNLESS (PER_USE(currentbucket)) goto err;
-      
+
       /* We need to be careful that we have a valid offset! */
       if (currentoffset >= currentbucket->len) goto no_match;
     }
-                                
+
   /* Whew, we got here so we have a valid offset! */
 
   delta = i - pseudoindex;
   if (delta)
     while (delta)
       {
-        if (delta < 0) 
+        if (delta < 0)
           {
             /* First, would we drop below zero? */
             if (pseudoindex >= 0 && pseudoindex + delta < 0) goto no_match;
-      
+
             /* Next, do we have to backup a bucket? */
-            if (currentoffset + delta < 0) 
+            if (currentoffset + delta < 0)
               {
                 if (currentbucket == self->firstbucket) goto no_match;
-              
+
                 b=PreviousBucket(currentbucket, self->firstbucket, i);
                 if (b==NULL) goto no_match;
-              
+
                 PER_ALLOW_DEACTIVATION(currentbucket);
                 PyPersist_SetATime(currentbucket);
                 ASSIGNB(currentbucket, b);
@@ -200,7 +200,7 @@
                   /* We backed into an empty bucket. Fix the psuedo index */
                   if (++pseudoindex == 0) goto no_match;
               }
-            else 
+            else
               {	/* Local adjustment */
                 pseudoindex += delta;
                 currentoffset += delta;
@@ -209,16 +209,16 @@
             if (currentbucket == self->firstbucket &&
                 currentoffset < self->first) goto no_match;
 
-          } 
+          }
         else if (delta > 0)
           {
-          
+
             /* Simple backwards range check */
-            if (pseudoindex < 0 && pseudoindex + delta >= 0) 
+            if (pseudoindex < 0 && pseudoindex + delta >= 0)
               goto no_match;
-          
+
             /* Next, do we go forward a bucket? */
-            if (currentoffset + delta >= currentbucket->len) 
+            if (currentoffset + delta >= currentbucket->len)
               {
                 while (1)
                   {
@@ -234,7 +234,7 @@
                     UNLESS (PER_USE(currentbucket)) goto err;
                     currentoffset = 0;
                     if (currentbucket->len) break;
-                  } 
+                  }
               }
             else
               {	/* Local adjustment */
@@ -243,7 +243,7 @@
               }
             if (currentbucket == self->lastbucket &&
                 currentoffset > self->last) goto no_match;
-          
+
           }
 
         delta = i - pseudoindex;
@@ -263,13 +263,13 @@
 
   self->pseudoindex=pseudoindex;
   self->currentoffset=currentoffset;
-  
+
   return 0;
 
  no_match:
 
   IndexError(i);
-  
+
   PER_ALLOW_DEACTIVATION(currentbucket);
 
  err:
@@ -291,21 +291,21 @@
 BTreeItems_item(BTreeItems *self, int i)
 {
   PyObject *r, *k=0, *v=0;
-  
+
   if (BTreeItems_seek(self, i) < 0) return NULL;
 
   PER_USE_OR_RETURN(self->currentbucket, NULL);
 
   switch(self->kind) {
 
-  case 'v': 
+  case 'v':
     COPY_VALUE_TO_OBJECT(r, self->currentbucket->values[self->currentoffset]);
     break;
 
   case 'i':
     COPY_KEY_TO_OBJECT(k, self->currentbucket->keys[self->currentoffset]);
     UNLESS (k) return NULL;
-      
+
     COPY_VALUE_TO_OBJECT(v, self->currentbucket->values[self->currentoffset]);
     UNLESS (v) return NULL;
 
@@ -340,7 +340,7 @@
 **		ilow	The start index
 **		ihigh	The end index
 **
-** Returns:	BTreeItems item 
+** Returns:	BTreeItems item
 */
 static PyObject *
 BTreeItems_slice(BTreeItems *self, int ilow, int ihigh)
@@ -349,19 +349,19 @@
   Bucket *highbucket;
   int lowoffset;
   int highoffset;
-  
+
 
   if (BTreeItems_seek(self, ilow) < 0) return NULL;
-  
+
   lowbucket = self->currentbucket;
   lowoffset = self->currentoffset;
-  
+
   if (BTreeItems_seek(self, ihigh) < 0) return NULL;
-  
+
   highbucket = self->currentbucket;
   highoffset = self->currentoffset;
-  
-  return newBTreeItems(self->kind, 
+
+  return newBTreeItems(self->kind,
                        lowbucket, lowoffset, highbucket, highoffset);
 }
 
@@ -406,19 +406,19 @@
   (reprfunc)0,				/*tp_str*/
   0,					/*tp_getattro*/
   0,					/*tp_setattro*/
-  
+
   /* Space for future expansion */
   0L,0L,
   "Sequence type used to iterate over BTree items." /* Documentation string */
 };
 
 static PyObject *
-newBTreeItems(char kind, 
+newBTreeItems(char kind,
               Bucket *lowbucket, int lowoffset,
               Bucket *highbucket, int highoffset)
 {
   BTreeItems *self;
-	
+
   UNLESS (self = PyObject_NEW(BTreeItems, &BTreeItemsType)) return NULL;
   self->kind=kind;
 
@@ -447,7 +447,7 @@
   return OBJECT(self);
 }
 
-static int 
+static int
 nextBTreeItems(SetIteration *i)
 {
   if (i->position >= 0)
@@ -457,7 +457,7 @@
           DECREF_KEY(i->key);
           DECREF_VALUE(i->value);
         }
-      
+
       if (BTreeItems_seek(ITEMS(i->set), i->position) >= 0)
         {
           Bucket *currentbucket;
@@ -469,9 +469,9 @@
           COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]);
           INCREF_KEY(i->key);
 
-          COPY_VALUE(i->value, 
+          COPY_VALUE(i->value,
                      currentbucket->values[ITEMS(i->set)->currentoffset]);
-          COPY_VALUE(i->value, 
+          COPY_VALUE(i->value,
                    BUCKET(ITEMS(i->set)->currentbucket)
                    ->values[ITEMS(i->set)->currentoffset]);
           INCREF_VALUE(i->value);
@@ -489,7 +489,7 @@
   return 0;
 }
 
-static int 
+static int
 nextTreeSetItems(SetIteration *i)
 {
   if (i->position >= 0)
@@ -498,7 +498,7 @@
         {
           DECREF_KEY(i->key);
         }
-      
+
       if (BTreeItems_seek(ITEMS(i->set), i->position) >= 0)
         {
           Bucket *currentbucket;