Index: trunk/psLib/src/types/psArguments.c
===================================================================
--- trunk/psLib/src/types/psArguments.c	(revision 8966)
+++ trunk/psLib/src/types/psArguments.c	(revision 8973)
@@ -7,13 +7,15 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
 
-#include<stdio.h>
-#include<stdarg.h>
-#include<string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <inttypes.h>
+
 #include "psArguments.h"
 #include "fitsio.h"
@@ -315,14 +317,14 @@
         // Print the value
         switch (item->type) {
-            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");
+            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");
         case PS_DATA_BOOL:
             if (item->data.B) {
Index: trunk/psLib/src/types/psArray.c
===================================================================
--- trunk/psLib/src/types/psArray.c	(revision 8966)
+++ trunk/psLib/src/types/psArray.c	(revision 8973)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -164,5 +164,5 @@
     PS_ASSERT_PTR_NON_NULL(array, false);
 
-    if (position > array->n) {
+    if (position < 0 || 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 = --i; // reset the array size to indicate the removed item(s)
+    array->n--;    // reset the array size to indicate the removed item
 
     return true;
Index: trunk/psLib/src/types/psBitSet.c
===================================================================
--- trunk/psLib/src/types/psBitSet.c	(revision 8966)
+++ trunk/psLib/src/types/psBitSet.c	(revision 8973)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -27,5 +27,4 @@
 #include "psAbort.h"
 #include "psString.h"
-#include "psAssert.h"
 
 
@@ -61,4 +60,7 @@
 static void bitSetFree(psBitSet* inBitSet)
 {
+    if (inBitSet == NULL) {
+        return;
+    }
     psFree(inBitSet->bits);
 }
@@ -75,4 +77,7 @@
 psBitSet* psBitSetAlloc(long nalloc)
 {
+    psS32 numBytes = 0;
+    psBitSet* newObj = NULL;
+
     if (nalloc < 0) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
@@ -81,7 +86,4 @@
         return NULL;
     }
-
-    psS32 numBytes = 0;
-    psBitSet* newObj = NULL;
 
     numBytes = ceil(nalloc / 8.0);
@@ -172,16 +174,4 @@
                      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;
@@ -191,6 +181,18 @@
     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
@@ -255,9 +257,11 @@
         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?");
     }
 
@@ -277,4 +281,9 @@
     outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
 
+    if (outBitSet == NULL) {
+        psError(PS_ERR_UNKNOWN, false,
+                _("Could not perform NOT operation."));
+    }
+
     return outBitSet;
 }
@@ -282,9 +291,7 @@
 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);
-    psString outString = psStringAlloc(numBits + 1);
+    char *outString = psAlloc((size_t) numBits + 1);
 
     for (i = 0; i < numBits; i++) {
Index: trunk/psLib/src/types/psBitSet.h
===================================================================
--- trunk/psLib/src/types/psBitSet.h	(revision 8966)
+++ trunk/psLib/src/types/psBitSet.h	(revision 8973)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,7 +32,6 @@
 /** 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
@@ -52,5 +51,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(
@@ -61,11 +60,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
 );
 
@@ -73,7 +72,6 @@
  *
  *  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.
@@ -99,12 +97,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.
@@ -114,23 +112,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          ///< Second 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            ///< First 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
@@ -140,12 +138,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  psString:      Pointer to character array containing string data.
+ *  @return  char*: 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 8966)
+++ trunk/psLib/src/types/psHash.c	(revision 8973)
@@ -12,6 +12,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-09-26 01:41:29 $
+*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-09-26 02:55:34 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -47,9 +47,11 @@
 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);
@@ -96,12 +98,10 @@
     bucket->key = psStringCopy(key);
 
-    //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);
-    //    }
+    if (data == NULL) {
+        // NOTE: Should we flag a warning message?
+        bucket->data = NULL;
+    } else {
+        bucket->data = psMemIncrRefCounter(data);
+    }
 
     bucket->next = next;
@@ -120,5 +120,10 @@
 static void hashBucketFree(psHashBucket* bucket)
 {
+    if (bucket == NULL) {
+        return;
+    }
+
     psFree(bucket->key);
+
     psFree(bucket->data);
 }
@@ -134,10 +139,4 @@
 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
 
@@ -186,4 +185,7 @@
     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();
@@ -223,6 +225,5 @@
 static psPtr doHashWork(psHash* table,
                         const char *key,
-                        psPtr data,
-                        psBool remove
+                        psPtr data, psBool remove
                            )
 {
@@ -239,10 +240,9 @@
     // 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,6 +253,4 @@
     // 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++) {
@@ -262,9 +260,8 @@
     // 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];
@@ -400,9 +397,9 @@
                   const char *key)
 {
+    psPtr data = NULL;
+    psBool retVal = false;
+
     PS_ASSERT_PTR_NON_NULL(hash, false);
     PS_ASSERT_PTR_NON_NULL(key, false);
-
-    psPtr data = NULL;
-    psBool retVal = false;
 
     data = doHashWork(hash, key, NULL, true);
@@ -424,6 +421,4 @@
     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 8966)
+++ trunk/psLib/src/types/psHash.h	(revision 8973)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  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 8966)
+++ trunk/psLib/src/types/psMetadata.c	(revision 8973)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.134 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.135 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  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 unknown contents>\n");
+            fprintf(fd, "<a list of size %ld>\n", ((psList*)item->data.V)->n);
             break;
         case PS_DATA_TIME: {
Index: trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- trunk/psLib/src/types/psMetadataConfig.c	(revision 8966)
+++ trunk/psLib/src/types/psMetadataConfig.c	(revision 8973)
@@ -10,6 +10,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-09-26 01:41:29 $
+*  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-09-26 02:55:34 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1157,6 +1157,4 @@
     PS_ASSERT_PTR_NON_NULL(filename,NULL);
 
-    struct stat buf;
-
     // Attempt to open specified file
     int fd = 0;
@@ -1164,4 +1162,11 @@
         // 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;
     }
@@ -1329,5 +1334,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)) {
@@ -1367,6 +1372,11 @@
         break;
     case PS_DATA_STRING:
-        psStringAppend(&content, "%-15s  %-8s  -%15s",
-                       item->name, "STR", item->data.str);
+        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");
+        }
         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 8966)
+++ trunk/psLib/src/types/psPixels.c	(revision 8973)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  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 8966)
+++ trunk/psLib/src/types/psPixels.h	(revision 8973)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 01:41:29 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-26 02:55:34 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
