[Zodb-checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.34

Tim Peters tim.one@comcast.net
Sat, 8 Jun 2002 11:57:50 -0400


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv15852

Modified Files:
	BucketTemplate.c 
Log Message:
Trimmed trailing whitespace.


=== Zope/lib/python/BTrees/BucketTemplate.c 1.33 => 1.34 ===
   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 BUCKETTEMPLATE_C "$Id$\n"
@@ -33,7 +33,7 @@
   int min, max, i, l, cmp, copied=1;
   PyObject *r;
   KEY_TYPE key;
-  
+
   COPY_KEY_FROM_ARG(key, keyarg, copied);
   UNLESS (copied) return NULL;
 
@@ -92,7 +92,7 @@
 ** Returns:     -1      on error, and MemoryError exception is set
 **               0      on success
 */
-static int 
+static int
 Bucket_grow(Bucket *self, int newsize, int noval)
 {
   KEY_TYPE *keys;
@@ -133,7 +133,7 @@
 
 Overflow:
   PyErr_NoMemory();
-  return -1;  
+  return -1;
 }
 
 /*
@@ -151,12 +151,12 @@
 **		 1	on success with a new value (growth)
 */
 static int
-_bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, 
+_bucket_set(Bucket *self, PyObject *keyarg, PyObject *v,
             int unique, int noval, int *changed)
 {
   int min, max, i, l, cmp, copied=1;
   KEY_TYPE key;
-  
+
   COPY_KEY_FROM_ARG(key, keyarg, copied);
   UNLESS(copied) return -1;
 
@@ -200,19 +200,19 @@
 	      self->len--;
 
 	      DECREF_KEY(self->keys[i]);
-	      if (i < self->len)	
+	      if (i < self->len)
                 memmove(self->keys+i, self->keys+i+1,
                         sizeof(KEY_TYPE)*(self->len-i));
 
               if (self->values && ! noval)
                 {
                   DECREF_VALUE(self->values[i]);
-                  if (i < self->len)	
+                  if (i < self->len)
                     memmove(self->values+i, self->values+i+1,
                             sizeof(VALUE_TYPE)*(self->len-i));
 
                 }
-	      
+
               if (! self->len)
 		{
 		  self->size=0;
@@ -317,7 +317,7 @@
       Py_INCREF(Py_None);
       return Py_None;
     }
-    
+
   if (!PySequence_Check(seq))
     {
       items = PyObject_GetAttr(seq, items_str);
@@ -422,7 +422,7 @@
   return 0;
 }
 
-static int 
+static int
 Bucket_deleteNextBucket(Bucket *self)
 {
   PER_USE_OR_RETURN(self, -1);
@@ -442,14 +442,14 @@
   return -1;
 }
 /*
- Bucket_findRangeEnd -- Find the index of a range endpoint 
+ Bucket_findRangeEnd -- Find the index of a range endpoint
  (possibly) contained in a bucket.
 
  Arguments:	self		The bucket
 		key		the key to match against
 		low             end flag
                 offset          The output offset
-	
+
 
  If low, return bucket and index of the smallest item >= key,
  otherwise return bucket and index of the largest item <= key.
@@ -467,7 +467,7 @@
 
   PER_USE_OR_RETURN(self, -1);
 
-  for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2) 
+  for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
     {
       TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
       if (cmp < 0)
@@ -478,7 +478,7 @@
           PER_ACCESSED(self);
           *offset=i;
           return 1;
-        } 
+        }
       else
         max=i;
   }
@@ -486,10 +486,10 @@
   /* OK, no matches, pick max or min, depending on whether
      we want an upper or low end.
   */
-  if (low) 
+  if (low)
     {
       if (max == self->len) i=0;
-      else 
+      else
         {
           i=1;
           *offset=max;
@@ -498,7 +498,7 @@
   else
     {
       if (max == 0) i=0;
-      else 
+      else
         {
           i=1;
           *offset=min;
@@ -520,15 +520,15 @@
 {
   PyObject *key=0;
   int rc, offset;
-  
+
   if (args && ! PyArg_ParseTuple(args, "|O", &key)) return NULL;
-    
+
   PER_USE_OR_RETURN(self, NULL);
 
   UNLESS (self->len) goto empty;
-  
-  /* Find the low range */  
-  if (key) 
+
+  /* Find the low range */
+  if (key)
     {
       if ((rc = Bucket_findRangeEnd(self, key, min, &offset)) <= 0)
         {
@@ -544,7 +544,7 @@
   PER_ACCESSED(self);
 
   return key;
-  
+
  empty:
   PyErr_SetString(PyExc_ValueError, "empty bucket");
   PER_ALLOW_DEACTIVATION(self);
@@ -564,35 +564,35 @@
   return Bucket_maxminKey(self, args, 0);
 }
 
-static int 
+static int
 Bucket_rangeSearch(Bucket *self, PyObject *args, int *low, int *high)
 {
   PyObject *f=0, *l=0;
   int rc;
-  
+
   if (args && ! PyArg_ParseTuple(args,"|OO",&f, &l)) return -1;
-    
+
   UNLESS (self->len) goto empty;
-  
-  /* Find the low range */  
-  if (f && f != Py_None) 
+
+  /* Find the low range */
+  if (f && f != Py_None)
     {
       UNLESS (rc = Bucket_findRangeEnd(self, f, 1, low))
         {
           if (rc < 0) return -1;
           goto empty;
         }
-    } 
+    }
   else *low = 0;
-  
+
   /* Find the high range */
-  if (l && l != Py_None) 
+  if (l && l != Py_None)
     {
       UNLESS (rc = Bucket_findRangeEnd(self, l, 0, high))
         {
           if (rc < 0) return -1;
           goto empty;
-        } 
+        }
     }
   else *high=self->len - 1;
 
@@ -613,13 +613,13 @@
 **		args	(unused)
 **
 ** Returns:	list of bucket keys
-*/  
+*/
 static PyObject *
 bucket_keys(Bucket *self, PyObject *args)
 {
   PyObject *r=0, *key;
   int i, low, high;
-  
+
   PER_USE_OR_RETURN(self, NULL);
 
   if (Bucket_rangeSearch(self, args, &low, &high) < 0) goto err;
@@ -690,7 +690,7 @@
 **
 ** Arguments:	self	The Bucket
 **		args	(unused)
-**		
+**
 ** Returns:	list of all items in the bucket
 */
 static PyObject *
@@ -716,7 +716,7 @@
       COPY_VALUE_TO_OBJECT(o, self->values[i]);
       UNLESS (o) goto err;
       PyTuple_SET_ITEM(item, 1, o);
-      
+
       if (PyList_SetItem(r, i-low, item) < 0) goto err;
 
       item = 0;
@@ -748,16 +748,16 @@
   COPY_VALUE_FROM_ARG(min, omin, copied);
   UNLESS(copied) return NULL;
 
-  for (i=0, l=0; i < self->len; i++) 
-    if (TEST_VALUE(self->values[i], min) >= 0) 
+  for (i=0, l=0; i < self->len; i++)
+    if (TEST_VALUE(self->values[i], min) >= 0)
       l++;
-    
+
   UNLESS (r=PyList_New(l)) goto err;
 
   for (i=0, l=0; i < self->len; i++)
     {
       if (TEST_VALUE(self->values[i], min) < 0) continue;
-      
+
       UNLESS (item = PyTuple_New(2)) goto err;
 
       COPY_KEY_TO_OBJECT(o, self->keys[i]);
@@ -770,7 +770,7 @@
       DECREF_VALUE(v);
       UNLESS (o) goto err;
       PyTuple_SET_ITEM(item, 0, o);
-      
+
       if (PyList_SetItem(r, l, item) < 0) goto err;
       l++;
 
@@ -804,7 +804,7 @@
 {
   int i;
 
-  if (self->next) 
+  if (self->next)
     {
       Py_DECREF(self->next);
       self->next=0;
@@ -813,13 +813,13 @@
   for (i=self->len; --i >= 0; )
     {
       DECREF_KEY(self->keys[i]);
-      if (self->values) 
+      if (self->values)
         {
           DECREF_VALUE(self->values[i]);
         }
     }
   self->len=0;
-  if (self->values) 
+  if (self->values)
     {
       free(self->values);
       self->values=0;
@@ -861,7 +861,7 @@
     }
   PER_ALLOW_DEACTIVATION(self);
   PER_ACCESSED(self);
-  Py_INCREF(Py_None); 
+  Py_INCREF(Py_None);
   return Py_None;
 
 err:
@@ -891,7 +891,7 @@
           UNLESS (o) goto err;
           PyTuple_SET_ITEM(items, l, o);
           l++;
-          
+
           COPY_VALUE_TO_OBJECT(o, self->values[i]);
           UNLESS (o) goto err;
           PyTuple_SET_ITEM(items, l, o);
@@ -909,11 +909,11 @@
         }
     }
 
-  if (self->next) 
+  if (self->next)
     ASSIGN(items, Py_BuildValue("OO", items, self->next));
   else
     ASSIGN(items, Py_BuildValue("(O)", items));
-  
+
   PER_ALLOW_DEACTIVATION(self);
   PER_ACCESSED(self);
 
@@ -953,10 +953,10 @@
       Py_DECREF(self->next);
       self->next=0;
     }
-  
+
   if (len > self->size)
     {
-      UNLESS (keys=PyRealloc(self->keys, sizeof(KEY_TYPE)*len)) 
+      UNLESS (keys=PyRealloc(self->keys, sizeof(KEY_TYPE)*len))
         return -1;
       UNLESS (values=PyRealloc(self->values, sizeof(VALUE_TYPE)*len))
         return -1;
@@ -964,7 +964,7 @@
       self->values=values;
       self->size=len;
     }
-  
+
   for (i=0, l=0; i<len; i++)
     {
       k=PyTuple_GET_ITEM(items, l);
@@ -1001,7 +1001,7 @@
 
   UNLESS (PyArg_ParseTuple(args, "O", &args)) return NULL;
 
-  PER_PREVENT_DEACTIVATION(self); 
+  PER_PREVENT_DEACTIVATION(self);
   r=_bucket_setstate(self, args);
   PER_ALLOW_DEACTIVATION(self);
   PER_ACCESSED(self);
@@ -1051,7 +1051,7 @@
   PyObject *r=0, *a;
   Bucket *b[3];
   int i;
-  
+
   for (i=0; i < 3; i++)
     {
       if ((b[i]=(Bucket*)PyObject_CallObject(OBJECT(ob_type), NULL)))
@@ -1197,7 +1197,7 @@
   static PyObject *format;
   PyObject *r, *t;
 
-  UNLESS (format) UNLESS (format=PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)")) 
+  UNLESS (format) UNLESS (format=PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)"))
     return NULL;
   UNLESS (t=PyTuple_New(1)) return NULL;
   UNLESS (r=bucket_items(self,NULL)) goto err;
@@ -1231,26 +1231,26 @@
   (reprfunc)0,			/*tp_str*/
   (getattrofunc)0,		/*tp_getattro*/
   0,				/*tp_setattro*/
-  
+
   /* Space for future expansion */
   0L,0L,
-  "Mapping type implemented as sorted list of items", 
+  "Mapping type implemented as sorted list of items",
   METHOD_CHAIN(Bucket_methods),
   EXTENSIONCLASS_BASICNEW_FLAG
 #ifdef PERSISTENT
-  | PERSISTENT_TYPE_FLAG 
+  | PERSISTENT_TYPE_FLAG
 #endif
   | EXTENSIONCLASS_NOINSTDICT_FLAG,
 };
 
 
-static int 
+static int
 nextBucket(SetIteration *i)
 {
   if (i->position >= 0)
     {
       UNLESS(PER_USE(BUCKET(i->set))) return -1;
-          
+
       if (i->position)
         {
           DECREF_KEY(i->key);
@@ -1274,6 +1274,6 @@
       PER_ALLOW_DEACTIVATION(BUCKET(i->set));
     }
 
-          
+
   return 0;
 }