Index: trunk/psLib/src/types/psArguments.c
===================================================================
--- trunk/psLib/src/types/psArguments.c	(revision 8964)
+++ trunk/psLib/src/types/psArguments.c	(revision 8965)
@@ -7,15 +7,13 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-13 21:11:11 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
 
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <inttypes.h>
-
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
 #include "psArguments.h"
 #include "fitsio.h"
@@ -317,14 +315,14 @@
         // Print the value
         switch (item->type) {
-            PRINT_CASE(U8, "%u");
-            PRINT_CASE(U16, "%u");
-            PRINT_CASE(U32, "%u");
-            PRINT_CASE(U64, "%" PRIu64);
-            PRINT_CASE(S8, "%d");
-            PRINT_CASE(S16, "%d");
-            PRINT_CASE(S32, "%d");
-            PRINT_CASE(S64, "%" PRId64);
-            PRINT_CASE(F32, "%.6e");
-            PRINT_CASE(F64, "%.6e");
+            PRINT_CASE(U8,"%u");
+            PRINT_CASE(U16,"%u");
+            PRINT_CASE(U32,"%u");
+            PRINT_CASE(U64,"%lu");
+            PRINT_CASE(S8,"%d");
+            PRINT_CASE(S16,"%d");
+            PRINT_CASE(S32,"%d");
+            PRINT_CASE(S64,"%ld");
+            PRINT_CASE(F32,"%.6e");
+            PRINT_CASE(F64,"%.6e");
         case PS_DATA_BOOL:
             if (item->data.B) {
Index: trunk/psLib/src/types/psArray.c
===================================================================
--- trunk/psLib/src/types/psArray.c	(revision 8964)
+++ trunk/psLib/src/types/psArray.c	(revision 8965)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 14:38:25 $
+ *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -164,5 +164,5 @@
     PS_ASSERT_PTR_NON_NULL(array, false);
 
-    if (position < 0 || position >= array->n) {
+    if (position > array->n) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
                 _("position > then the number of elements in the array."));
@@ -174,5 +174,5 @@
     psFree(array->data[i]);
     memmove(&array->data[i], &array->data[i + 1], (n - i - 1) * sizeof(psPtr));
-    array->n--;    // reset the array size to indicate the removed item
+    array->n = --i; // reset the array size to indicate the removed item(s)
 
     return true;
Index: trunk/psLib/src/types/psBitSet.c
===================================================================
--- trunk/psLib/src/types/psBitSet.c	(revision 8964)
+++ trunk/psLib/src/types/psBitSet.c	(revision 8965)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-26 04:34:28 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -27,4 +27,5 @@
 #include "psAbort.h"
 #include "psString.h"
+#include "psAssert.h"
 
 
@@ -60,7 +61,4 @@
 static void bitSetFree(psBitSet* inBitSet)
 {
-    if (inBitSet == NULL) {
-        return;
-    }
     psFree(inBitSet->bits);
 }
@@ -77,13 +75,13 @@
 psBitSet* psBitSetAlloc(long nalloc)
 {
+    if (nalloc < 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
+                nalloc);
+        return NULL;
+    }
+
     psS32 numBytes = 0;
     psBitSet* newObj = NULL;
-
-    if (nalloc < 0) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
-                nalloc);
-        return NULL;
-    }
 
     numBytes = ceil(nalloc / 8.0);
@@ -174,4 +172,16 @@
                      const psBitSet* inBitSet2)
 {
+    if (inBitSet1 == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("First psBitSet operand can not be NULL."));
+        psFree(outBitSet);
+        return NULL;
+    }
+    if (operator == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("Specified operator is NULL.  Must specify desired operator."));
+        psFree(outBitSet);
+        return NULL;
+    }
     psS32 i = 0;
     psS32 n = 0;
@@ -181,18 +191,6 @@
     psS32 op = UNKNOWN_OP;
 
-    if (inBitSet1 == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("First psBitSet operand can not be NULL."));
-        psFree(outBitSet);
-        return NULL;
-    }
     inBits1 = inBitSet1->bits;
 
-    if (operator == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Specified operator is NULL.  Must specify desired operator."));
-        psFree(outBitSet);
-        return NULL;
-    }
 
     // parse the operator
@@ -257,11 +255,9 @@
         break;
     case NOT_OP:
+    default:
         for (i = 0; i < n; i++) {
             outBits[i] = ~inBits1[i];
         }
         break;
-    default:
-        psAbort("psBitSetOp",
-                "Unexpected error - operator parsed successfully but not valid?");
     }
 
@@ -281,9 +277,4 @@
     outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
 
-    if (outBitSet == NULL) {
-        psError(PS_ERR_UNKNOWN, false,
-                _("Could not perform NOT operation."));
-    }
-
     return outBitSet;
 }
@@ -291,7 +282,9 @@
 psString psBitSetToString(const psBitSet* bitSet)
 {
+    PS_ASSERT_PTR_NON_NULL(bitSet, NULL);
     psS32 i = 0;
     psS32 numBits = bitSet->n * 8;
-    char *outString = psAlloc((size_t) numBits + 1);
+    //    char *outString = psAlloc((size_t) numBits + 1);
+    psString outString = psStringAlloc(numBits + 1);
 
     for (i = 0; i < numBits; i++) {
Index: trunk/psLib/src/types/psBitSet.h
===================================================================
--- trunk/psLib/src/types/psBitSet.h	(revision 8964)
+++ trunk/psLib/src/types/psBitSet.h	(revision 8965)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-15 21:22:22 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,6 +32,7 @@
 /** Struct containing array of bytes to hold bit data and corresponding array length.
  *
- *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are
- *  arranged with the LSB in first (right most) position of the first array element.
+ *  The bits in the struct are assembled in as an array of bytes with eight bits per
+ *  byte. The bits are arranged with the LSB in first (right most) position of the
+ *  first array element.
  */
 typedef struct
@@ -51,5 +52,5 @@
  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
  *
- *  @return bool:       True if the pointer matches a psBitSet structure, false otherwise.
+ *  @return bool:     True if the pointer matches a psBitSet structure, false otherwise.
  */
 bool psMemCheckBitSet(
@@ -60,11 +61,11 @@
 /** Allocate a psBitSet.
  *
- *  Create a psBitSet with the number of bits specified by the user. All bits are set to zero upon
- *  allocation.
+ *  Create a psBitSet with the number of bits specified by the user. All bits are set
+ *  to zero upon allocation.
  *
  *  @return  psBitSet* : Pointer to struct containing array of bits and size of array.
  */
 psBitSet* psBitSetAlloc(
-    long nalloc                            ///< Number of bits in psBitSet array
+    long nalloc                        ///< Number of bits in psBitSet array
 );
 
@@ -72,6 +73,7 @@
  *
  *  Sets a bit at a given bit location. The bit is set based on a zero index with the
- *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
- *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
+ *  first bit set in the zero bit slot of the zero element of the byte array. As an
+ *  example, setting bit 3 in an array with two elements would result in an psBitSet
+ *  that looks like 00000000 00001000.
  *
  *  @return  psBitSet* : Pointer to struct containing psBitSet.
@@ -97,12 +99,12 @@
 /** Test the value of a bit.
  *
- *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a
- *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array
- *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
- *  value of one, since that is the value that was set.
+ *  Prints the value of a bit at a given bit location, either one or zero. The resulting
+ *  bit is based on a zero index format with the first bit set in the zero bit slot of
+ *  the zero element of the byte array.  As an example, testing bit 3 in a psBitSet with
+ *  two bytes that looks like 00000000 00001000 would return a value of one, since that
+ *  is the value that was set.
  *
  *  @return  bool:      True if successful, otherwise false
  */
-
 bool psBitSetTest(
     const psBitSet* bitSet,            ///< Pointer psBitSet to be tested.
@@ -112,23 +114,23 @@
 /** Perform a binary operation on two psBitSets
  *
- *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
- *  be performed and an error message will be logged.
+ *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size,
+ *  the operation will not be performed and an error message will be logged.
  *
  *  @return  psBitSet* : Pointer to struct containing result of binary operation.
  */
 psBitSet* psBitSetOp(
-    psBitSet* outBitSet,                 ///< Resulting psBitSet from binary operation
-    const psBitSet* inBitSet1,           ///< First psBitSet on which to operate
-    const char *operator,                    ///< Bit operation
-    const psBitSet* inBitSet2            ///< First psBitSet on which to operate
+    psBitSet* outBitSet,               ///< Resulting psBitSet from binary operation
+    const psBitSet* inBitSet1,         ///< First psBitSet on which to operate
+    const char *operator,              ///< Bit operation
+    const psBitSet* inBitSet2          ///< Second psBitSet on which to operate
 );
 
 /** Perform a not operation on a psBitSet
  *
- *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set to zero.
+ *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set
+ *  to zero.
  *
  *  @return  psBitSet* : Pointer to struct containing result of operation.
  */
-
 psBitSet* psBitSetNot(
     psBitSet* outBitSet,               ///< Resulting psBitSet from operation
@@ -138,12 +140,12 @@
 /** Convert the psBitSet to a string of ones and zeros.
  *
- *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
- *  LSB is the right-most chracter. Each set of eight characters represents one byte.
+ *  Converts the contents of a psBitSet to a string representation of its binary form of
+ *  ones and zeros. The LSB is the right-most chracter. Each set of eight characters
+ *  represents one byte.
  *
- *  @return  char*: Pointer to character array containing string data.
+ *  @return  psString:      Pointer to character array containing string data.
  */
-
 psString psBitSetToString(
-    const psBitSet* bitSet             ///< psBitSet to convert */
+    const psBitSet* bitSet             ///< psBitSet to convert
 );
 
Index: trunk/psLib/src/types/psHash.c
===================================================================
--- trunk/psLib/src/types/psHash.c	(revision 8964)
+++ trunk/psLib/src/types/psHash.c	(revision 8965)
@@ -12,6 +12,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-08-29 20:23:54 $
+*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-09-26 01:41:29 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -47,11 +47,9 @@
 psList* psHashKeyList(const psHash* hash)
 {
+    PS_ASSERT_PTR_NON_NULL(hash, NULL);
     psS32 i = 0;                  // Loop index variable
     psList* myLinkList = NULL;  // The output data structure
     psHashBucket* ptr = NULL;   // Used to step thru linked list.
 
-    if (hash == NULL) {
-        return NULL;
-    }
     // Create the linked list
     myLinkList = psListAlloc(NULL);
@@ -98,10 +96,12 @@
     bucket->key = psStringCopy(key);
 
-    if (data == NULL) {
-        // NOTE: Should we flag a warning message?
-        bucket->data = NULL;
-    } else {
-        bucket->data = psMemIncrRefCounter(data);
-    }
+    //XXX:  Since this function is static and only called by doHashWork,
+    //data can never be NULL here.
+    //    if (data == NULL) {
+    // NOTE: Should we flag a warning message?
+    //        bucket->data = NULL;
+    //    } else {
+    bucket->data = psMemIncrRefCounter(data);
+    //    }
 
     bucket->next = next;
@@ -120,10 +120,5 @@
 static void hashBucketFree(psHashBucket* bucket)
 {
-    if (bucket == NULL) {
-        return;
-    }
-
     psFree(bucket->key);
-
     psFree(bucket->data);
 }
@@ -139,4 +134,10 @@
 psHash* psHashAlloc(long nalloc)        // initial number of buckets
 {
+    if (nalloc < 0)
+    {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Can't allocate a psHash of negative size.");
+        return NULL;
+    }
     psS32 i = 0;                  // loop index variable
 
@@ -185,7 +186,4 @@
     psS32 i = 0;                  // Loop index variable.
 
-    if (table == NULL) {
-        return;
-    }
     // Loop through each bucket in the hash table.  If that bucket is not
     // NULL, then free the bucket via a function call to hashBucketFree();
@@ -225,5 +223,6 @@
 static psPtr doHashWork(psHash* table,
                         const char *key,
-                        psPtr data, psBool remove
+                        psPtr data,
+                        psBool remove
                            )
 {
@@ -240,9 +239,10 @@
     // function, but I'm checking it anyway since future coders might change
     // the way this procedure is called.
-    if ((table == NULL) || (key == NULL)) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Input key can not be NULL."));
-        return NULL;
-    }
+    /*    if ((table == NULL) || (key == NULL)) {
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    _("Input key can not be NULL."));
+            return NULL;
+        }
+    */
     // NOTE: This is the originally supplied hash function.
     // for (psS32 i = 0, len = strlen(key); i < len; i++) {
@@ -253,4 +253,6 @@
     // This hash algorithm is from Sedgewick.  NOTE: must reread to ensure that
     // the size of the hash table is not required to be a prime number.
+    if (table->n <= 0)
+        return NULL;
     tmpchar = (char *)key;
     for (hash = 0; *tmpchar != '\0'; tmpchar++) {
@@ -260,8 +262,9 @@
     // NOTE: This should not be necessary, but for now, I'm checking bounds
     // anyway.
-    if ((hash < 0) || (hash >= table->n)) {
-        psError(PS_ERR_UNKNOWN, true,
-                "Internal hash function out of range (%" PRId64 ")", hash);
-    }
+    /*    if ((hash < 0) || (hash >= table->n)) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "Internal hash function out of range (%" PRId64 ")", hash);
+        }
+    */
     // ptr will have the correct hash bucket.
     ptr = table->buckets[hash];
@@ -397,9 +400,9 @@
                   const char *key)
 {
+    PS_ASSERT_PTR_NON_NULL(hash, false);
+    PS_ASSERT_PTR_NON_NULL(key, false);
+
     psPtr data = NULL;
     psBool retVal = false;
-
-    PS_ASSERT_PTR_NON_NULL(hash, false);
-    PS_ASSERT_PTR_NON_NULL(key, false);
 
     data = doHashWork(hash, key, NULL, true);
@@ -421,4 +424,6 @@
     int nElements = 0;
     int nbucket = hash->n;
+    //XXX:  If we do psArrayAlloc(0) here and use psArrayAdd(result, 1, tmpBucket->data)
+    //we can eliminate the 2nd for loop below.
     for (int i = 0; i < nbucket; i++) {
         psHashBucket* tmpBucket = hash->buckets[i];
Index: trunk/psLib/src/types/psHash.h
===================================================================
--- trunk/psLib/src/types/psHash.h	(revision 8964)
+++ trunk/psLib/src/types/psHash.h	(revision 8965)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-19 23:54:43 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Index: trunk/psLib/src/types/psMetadata.c
===================================================================
--- trunk/psLib/src/types/psMetadata.c	(revision 8964)
+++ trunk/psLib/src/types/psMetadata.c	(revision 8965)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.133 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-20 02:08:43 $
+ *  @version $Revision: 1.134 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -605,5 +605,5 @@
         // Node doesn't exist - Add new metadata item to metadata collection's hash
         /*  The following is unneeded.  HashAdd can't return false with non-null inputs.
-
+         
                 if(!psHashAdd(mdTable, key, (psPtr)item)) {
                     psError(PS_ERR_UNKNOWN,false,
@@ -1315,5 +1315,5 @@
             }
         case PS_DATA_LIST:
-            fprintf(fd, "<a list of size %ld>\n", ((psList*)item->data.V)->n);
+            fprintf(fd, "<a list of unknown contents>\n");
             break;
         case PS_DATA_TIME: {
Index: trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- trunk/psLib/src/types/psMetadataConfig.c	(revision 8964)
+++ trunk/psLib/src/types/psMetadataConfig.c	(revision 8965)
@@ -10,6 +10,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.90 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-09-19 03:45:24 $
+*  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-09-26 01:41:29 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1157,4 +1157,6 @@
     PS_ASSERT_PTR_NON_NULL(filename,NULL);
 
+    struct stat buf;
+
     // Attempt to open specified file
     int fd = 0;
@@ -1162,11 +1164,4 @@
         // XXX really should return strerror() here
         psError(PS_ERR_IO, true, _("Failed to open file '%s'. Check if it exists and it has the proper permissions."), filename);
-        return NULL;
-    }
-
-    struct stat buf;                    // Results of stat() for file
-    if (fstat(fd, &buf) != 0) {
-        psError(PS_ERR_IO, true, _("Unable to stat file '%s'.\n"), filename);
-        close(fd);
         return NULL;
     }
@@ -1334,5 +1329,5 @@
         break;
     case PS_DATA_BOOL:
-        psStringAppend (&content, "%-15s  %-8s  %-15s",
+        psStringAppend (&content, "%-15s  %-8s  -%15s",
                         item->name, "BOOL", item->data.B ? "T" : "F");
         if (item->comment && strncmp(item->comment, "", 2)) {
@@ -1372,11 +1367,6 @@
         break;
     case PS_DATA_STRING:
-        if (item->data.str && strlen(item->data.str) > 0) {
-            psStringAppend(&content, "%-15s  %-8s  %-15s",
-                           item->name, "STR", item->data.str);
-        } else {
-            psStringAppend(&content, "%-15s  %-8s  %-15s",
-                           item->name, "STR", "NULL");
-        }
+        psStringAppend(&content, "%-15s  %-8s  -%15s",
+                       item->name, "STR", item->data.str);
         if (item->comment && strncmp(item->comment,"",2)) {
             psStringAppend(&content, "  # %s", item->comment);
Index: trunk/psLib/src/types/psPixels.c
===================================================================
--- trunk/psLib/src/types/psPixels.c	(revision 8964)
+++ trunk/psLib/src/types/psPixels.c	(revision 8965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-19 23:54:43 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Index: trunk/psLib/src/types/psPixels.h
===================================================================
--- trunk/psLib/src/types/psPixels.h	(revision 8964)
+++ trunk/psLib/src/types/psPixels.h	(revision 8965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-19 23:54:43 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 01:41:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
