Index: trunk/psLib/src/collections/psBitSet.c
===================================================================
--- trunk/psLib/src/collections/psBitSet.c	(revision 1406)
+++ trunk/psLib/src/collections/psBitSet.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psBitSet.c
  *
@@ -10,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -17,5 +18,7 @@
 
 /******************************************************************************/
+
 /*  INCLUDE FILES                                                             */
+
 /******************************************************************************/
 #include <string.h>
@@ -31,32 +34,41 @@
 
 /******************************************************************************/
+
 /*  DEFINE STATEMENTS                                                         */
-/******************************************************************************/
-
-// None
-
-/******************************************************************************/
+
+/******************************************************************************/
+
+// None
+
+/******************************************************************************/
+
 /*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
-
-// None
-
-/*****************************************************************************/
+
+/******************************************************************************/
+
+// None
+
+/*****************************************************************************/
+
 /*  GLOBAL VARIABLES                                                         */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
+
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+
 /*  FILE STATIC VARIABLES                                                    */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
+
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
-/*****************************************************************************/
-static void psBitSetFree(psBitSet *restrict inBitSet);
-
+
+/*****************************************************************************/
+static void psBitSetFree(psBitSet * restrict inBitSet);
 
 /** Private function to create a mask.
@@ -70,7 +82,8 @@
 {
     char mask = (char)0x01;
+
     // Ignore splint warning about negative bit shifts
-    /*@i@*/
-    mask = mask << (bit%8);
+    /* @i@ */
+    mask = mask << (bit % 8);
 
     return mask;
@@ -78,29 +91,31 @@
 
 /*****************************************************************************/
+
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
-/*****************************************************************************/
-psBitSet* psBitSetAlloc(int n)
+
+/*****************************************************************************/
+psBitSet *psBitSetAlloc(int n)
 {
     int numBytes = 0;
     psBitSet *newObj = NULL;
 
-    if(n <= 0) {
+    if (n <= 0) {
         psError(__func__, " : Line %d - Allocation size must be > 0: size = %d", __LINE__, n);
         return 0;
     }
 
-    numBytes = ceil(n/8.0);
+    numBytes = ceil(n / 8.0);
     newObj = psAlloc(sizeof(psBitSet));
-    if(newObj == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-    p_psMemSetDeallocator(newObj,(psFreeFcn)psBitSetFree);
+    if (newObj == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+    p_psMemSetDeallocator(newObj, (psFreeFcn) psBitSetFree);
     newObj->n = numBytes;
 
     // Ignore splint warning about releasing pointer members, since they've not been allocated yet
-    /*@i@*/
-    newObj->bits = psAlloc(sizeof(char)*numBytes);
-    if(newObj->bits == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
+    /* @i@ */
+    newObj->bits = psAlloc(sizeof(char) * numBytes);
+    if (newObj->bits == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
     }
 
@@ -110,7 +125,7 @@
 }
 
-static void psBitSetFree(psBitSet *restrict inBitSet)
-{
-    if(inBitSet == NULL) {
+static void psBitSetFree(psBitSet * restrict inBitSet)
+{
+    if (inBitSet == NULL) {
         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
         return;
@@ -119,23 +134,20 @@
 }
 
-psBitSet* psBitSetSet(psBitSet *inBitSet, int bit)
-{
-    char* byte = NULL;
-
-    if(inBitSet == NULL) {
+psBitSet *psBitSetSet(psBitSet * inBitSet, int bit)
+{
+    char *byte = NULL;
+
+    if (inBitSet == NULL) {
         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
         return inBitSet;
-    } else
-        if(bit < 0) {
-            psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
-            return inBitSet;
-        } else
-            if(bit > inBitSet->n*8-1) {
-                psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
-                return inBitSet;
-            }
-
+    } else if (bit < 0) {
+        psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
+        return inBitSet;
+    } else if (bit > inBitSet->n * 8 - 1) {
+        psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
+        return inBitSet;
+    }
     // Variable byte is the byte in the array that contains the bit to be set
-    byte = inBitSet->bits+bit/8;
+    byte = inBitSet->bits + bit / 8;
     *byte |= mask(bit);
 
@@ -143,24 +155,21 @@
 }
 
-bool psBitSetTest(const psBitSet *inBitSet, int bit)
-{
-    char* byte = NULL;
-
-    if(inBitSet == NULL) {
-        psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
-        return 0;
-    } else
-        if(bit < 0) {
-            psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
-            return 0;
-        } else
-            if(bit > inBitSet->n*8-1) {
-                psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
-                return 0;
-            }
-
+bool psBitSetTest(const psBitSet * inBitSet, int bit)
+{
+    char *byte = NULL;
+
+    if (inBitSet == NULL) {
+        psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
+        return 0;
+    } else if (bit < 0) {
+        psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
+        return 0;
+    } else if (bit > inBitSet->n * 8 - 1) {
+        psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
+        return 0;
+    }
     // Variable byte is the byte in the array that contains the bit to be tested
-    byte = inBitSet->bits+bit/8;
-    if((int)(*byte&mask(bit)) == 0) {
+    byte = inBitSet->bits + bit / 8;
+    if ((int)(*byte & mask(bit)) == 0) {
         return 0;
     }
@@ -169,6 +178,6 @@
 }
 
-psBitSet* psBitSetOp(psBitSet *outBitSet, const psBitSet *restrict inBitSet1, char *operator,
-                     const psBitSet *restrict inBitSet2)
+psBitSet *psBitSetOp(psBitSet * outBitSet, const psBitSet * restrict inBitSet1, char *operator,
+                     const psBitSet * restrict inBitSet2)
 {
     int i = 0;
@@ -179,24 +188,24 @@
     char *inBits2 = NULL;
 
-    if(inBitSet1 == NULL) {
+    if (inBitSet1 == NULL) {
         psError(__func__, " : Line %d - Null psBitSet for inBitSet1 argument", __LINE__);
         return outBitSet;
     }
 
-    if(operator == NULL) {
+    if (operator == NULL) {
         psError(__func__, " : Line %d - Null input operator\n", __LINE__);
         return outBitSet;
     }
 
-    if(inBitSet2 == NULL) {
+    if (inBitSet2 == NULL) {
         psError(__func__, " : Line %d - Null psBitSet for inBitSet2 argument", __LINE__);
         return outBitSet;
     }
 
-    if(outBitSet == NULL) {
-        outBitSet = psBitSetAlloc(inBitSet1->n*8);
-    }
-
-    if(inBitSet1->n != inBitSet2->n || outBitSet->n != inBitSet1->n) {
+    if (outBitSet == NULL) {
+        outBitSet = psBitSetAlloc(inBitSet1->n * 8);
+    }
+
+    if (inBitSet1->n != inBitSet2->n || outBitSet->n != inBitSet1->n) {
         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
         return outBitSet;
@@ -209,17 +218,17 @@
 
     tempChar = toupper(operator[0]);
-    switch(tempChar) {
+    switch (tempChar) {
     case 'A':
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             outBits[i] = inBits1[i] & inBits2[i];
         }
         break;
     case 'O':
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             outBits[i] = inBits1[i] | inBits2[i];
         }
         break;
     case 'X':
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             outBits[i] = inBits1[i] ^ inBits2[i];
         }
@@ -232,5 +241,5 @@
 }
 
-psBitSet* psBitSetNot(psBitSet *outBitSet, const psBitSet *restrict inBitSet)
+psBitSet *psBitSetNot(psBitSet * outBitSet, const psBitSet * restrict inBitSet)
 {
     int i = 0;
@@ -239,5 +248,5 @@
     char *inBits = NULL;
 
-    if(inBitSet == NULL) {
+    if (inBitSet == NULL) {
         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
         return outBitSet;
@@ -245,14 +254,14 @@
 
     n = inBitSet->n;
-    if(n == 0) {
+    if (n == 0) {
         psError(__func__, " : Line %d - No elements in inBitSet", __LINE__);
         return outBitSet;
     }
 
-    if(outBitSet == NULL) {
-        outBitSet = psBitSetAlloc(n*8);
-    }
-
-    if(inBitSet->n != outBitSet->n) {
+    if (outBitSet == NULL) {
+        outBitSet = psBitSetAlloc(n * 8);
+    }
+
+    if (inBitSet->n != outBitSet->n) {
         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
         return outBitSet;
@@ -262,5 +271,5 @@
     inBits = inBitSet->bits;
 
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         outBits[i] = ~inBits[i];
     }
@@ -269,15 +278,16 @@
 }
 
-char *psBitSetToString(const psBitSet *restrict inBitSet)
+char *psBitSetToString(const psBitSet * restrict inBitSet)
 {
     int i = 0;
-    int numBits = inBitSet->n*8;
-    char* outString = psAlloc((size_t)numBits+1);
-    if(outString == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-    for(i=0; i<numBits; i++) {
-        outString[numBits-i-1] = (psBitSetTest(inBitSet, i) == 1)?'1':'0';
+    int numBits = inBitSet->n * 8;
+    char *outString = psAlloc((size_t) numBits + 1);
+
+    if (outString == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    for (i = 0; i < numBits; i++) {
+        outString[numBits - i - 1] = (psBitSetTest(inBitSet, i) == 1) ? '1' : '0';
     }
 
