Index: /trunk/psLib/src/types/parse_gcov-out.c
===================================================================
--- /trunk/psLib/src/types/parse_gcov-out.c	(revision 9735)
+++ /trunk/psLib/src/types/parse_gcov-out.c	(revision 9736)
@@ -76,5 +76,5 @@
     N++;
 
-    average = average / N;
+    average = average / sum;
 
     output = fopen("Coverage-Report.txt", "w");
@@ -89,14 +89,16 @@
 }
 
-void parseINT(const char *nums)
+void parseINT(const char *nums, float percent)
 {
     sum += atoi(nums);
+    average += (float)((int)(percent * atoi(nums)));
 }
 
-void parseDBL(const char *nums)
+float parseDBL(const char *nums)
 {
     char temp[7];
     int i = 0;
     int j = 9;
+    float out = 0.0;
     while (nums[j] != '%') {
         temp[i] = nums[j];
@@ -104,5 +106,7 @@
         j++;
     }
-    average += (float)atof(temp);
+    //    average += (float)atof(temp);
+    out = (float)atof(temp);
+    return out;
 }
 
@@ -117,4 +121,5 @@
     strcat(outStr, out);
     int i;
+    float numLines = 0.0;
     while ( fscanf(in, "%s", currentStr) != EOF) {
         if ( strncmp(currentStr, searchStr, 99) == 0 ) {
@@ -122,9 +127,9 @@
                 if (i == 1) {
                     fscanf(in, "%s", out);
-                    parseDBL(out);
+                    numLines = parseDBL(out);
                     sprintf(currentStr, "%-16s", out);
                 } else if ( i == 3) {
                     fscanf(in, "%s", out);
-                    parseINT(out);
+                    parseINT(out, numLines);
                     sprintf(currentStr, "%s", out);
                 } else {
Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 9735)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 9736)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.144 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-24 01:15:47 $
+ *  @version $Revision: 1.145 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-25 00:16:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -425,4 +425,5 @@
         return NULL;
     }
+    bool errorOccurred = false;
     bool outAlloced = false;
     if (out ==  NULL) {
@@ -447,17 +448,23 @@
             psErrorStackPrint(stderr, "Error copying %s (%s) in the metadata\n", inItem->name,
                               inItem->comment);
-            psFree(newItem);
-            psFree(iter);
             if (outAlloced) {
                 psFree(out);
+                psFree(newItem);
+                psFree(iter);
+                return NULL;
+            } else {
+                errorOccurred = true;
             }
-            return NULL;
         }
         psFree(newItem);                // Drop reference
     }
     psFree(iter);
+
+    if (errorOccurred) {
+        return NULL;
+    }
+
     return out;
 }
-
 
 // may need to extend this to change the keyname in the copy
Index: /trunk/psLib/src/types/psMetadata.h
===================================================================
--- /trunk/psLib/src/types/psMetadata.h	(revision 9735)
+++ /trunk/psLib/src/types/psMetadata.h	(revision 9736)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-14 03:50:28 $
+*  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-25 00:16:33 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -385,5 +385,6 @@
  *
  *  Creates a new copy of all the psMetadataItems in the psMetadata collection, in, and
- *  returns them in out, or creates a new container if out is NULL.
+ *  returns them in out, or creates a new container if out is NULL.  If an error occurs,
+ *  NULL is returned but out may still have been updated if it is non-NULL.
  *
  *  @return psMetadata*:        the copy of the psMetadata container.
Index: /trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.c	(revision 9735)
+++ /trunk/psLib/src/types/psMetadataConfig.c	(revision 9736)
@@ -10,6 +10,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-24 22:52:56 $
+*  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-25 00:16:33 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -20,23 +20,24 @@
 #include <ctype.h>
 #include <limits.h>
-#include <inttypes.h>
 #include <strings.h>
 #include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "psAbort.h"
-#include "psType.h"
-#include "psMemory.h"
-#include "psError.h"
-#include "psString.h"
-#include "psList.h"
-#include "psHash.h"
-#include "psVector.h"
-#include "psMetadata.h"
 #include "psMetadataConfig.h"
 #include "psAssert.h"
+//#include <sys/types.h>
+//#include <sys/stat.h>
+//#include <inttypes.h>
+//#include "psHash.h"
+//#include "psMetadata.h"
+//#include "psAbort.h"
+//#include "psType.h"
+
+//#include "psMemory.h"
+//#include "psError.h"
+//#include "psString.h"
+//#include "psList.h"
+//#include "psVector.h"
 
 
@@ -1167,5 +1168,7 @@
     if (!(fd = open(filename, O_RDONLY))) {
         // 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);
+        psError(PS_ERR_IO, true,
+                _("Failed to open file '%s'. Check if it exists and it has the proper "
+                  "permissions."), filename);
         return NULL;
     }
@@ -1562,4 +1565,10 @@
     PS_ASSERT_PTR_NON_NULL(md, NULL);
     PS_ASSERT_PTR_NON_NULL(filename, NULL);
+    FILE *file;
+    if ( !(file = fopen(filename, "w")) ) {
+        psError(PS_ERR_IO, true,
+                "Failed to open specified file, %s\n", filename);
+        return false;
+    }
     psString fileString = NULL;
     fileString = psMetadataConfigFormat(md);
@@ -1569,11 +1578,4 @@
         return false;
     }
-    FILE *file;
-    if ( !(file = fopen(filename, "w")) ) {
-        psError(PS_ERR_IO, true,
-                "Failed to open specified file, %s\n", filename);
-        psFree(fileString);
-        return false;
-    }
     fprintf(file, "%s", fileString);
     fclose(file);
@@ -1586,4 +1588,10 @@
 {
     PS_ASSERT_PTR_NON_NULL(md, false);
+    PS_ASSERT_PTR_NON_NULL(stream, false);
+    if (fprintf(stream, "\n") <= 0) {
+        psError(PS_ERR_IO, false,
+                "Unable to write to specified file.");
+        return false;
+    }
 
     psString str = psMetadataConfigFormat(md);
Index: /trunk/psLib/test/types/Makefile.am
===================================================================
--- /trunk/psLib/test/types/Makefile.am	(revision 9735)
+++ /trunk/psLib/test/types/Makefile.am	(revision 9736)
@@ -29,5 +29,7 @@
 	tap_psBitSet_all \
 	tap_psList_all \
-	tap_psLookupTable_all
+	tap_psLookupTable_all \
+	tap_psMetadataConfig_output \
+	tap_psMetadataConfig_input
 
 if BUILD_TESTS
Index: /trunk/psLib/test/types/execute_tap
===================================================================
--- /trunk/psLib/test/types/execute_tap	(revision 9735)
+++ /trunk/psLib/test/types/execute_tap	(revision 9736)
@@ -1,3 +1,3 @@
-make
+make test
 ./tap_psArray_all
 ./tap_psListIterator
@@ -18,2 +18,4 @@
 ./tap_psList_all
 ./tap_psLookupTable_all
+./tap_psMetadataConfig_output
+./tap_psMetadataConfig_input
Index: /trunk/psLib/test/types/tap_psMetadata_copying.c
===================================================================
--- /trunk/psLib/test/types/tap_psMetadata_copying.c	(revision 9735)
+++ /trunk/psLib/test/types/tap_psMetadata_copying.c	(revision 9736)
@@ -23,5 +23,5 @@
 int main(void)
 {
-    plan_tests(34);
+    plan_tests(35);
 
     diag("psMetadataCopy and psMetadataItemCopy tests");
@@ -59,21 +59,29 @@
         out = NULL;
     }
-    //Return NULL for attempt to copy item of unsupported data type
+    //Return NULL for attempt to copy item of unsupported data type - NULL out metadata
+    psMetadataItem *notype = NULL;
     {
         in = psMetadataAlloc();
         psMetadataAddS32(in, PS_LIST_HEAD, "S32", 0, "", 1);
-        psMetadataItem *notype = psMetadataGet(in, PS_LIST_HEAD);
-        //        notype->type = PS_DATA_METADATA_MULTI + 1000;
+        notype = psMetadataGet(in, PS_LIST_HEAD);
         notype->type = -1;
-        psFree(outTest);
-        outTest = NULL;
+        outTest = psMetadataCopy(out, in);
+        ok( outTest == NULL,
+            "psMetadataCopy:  return NULL for metadata with item of bad type.");
+        psFree(out);
+        out = NULL;
+    }
+    //Return NULL for attempt to copy item of unsupported data type - allocated out metadata
+    {
+        out = psMetadataAlloc();
+        psMetadataAddS32(out, PS_LIST_TAIL, "S32", 0, "", 2);
         outTest = psMetadataCopy(out, in);
         ok( outTest == NULL,
             "psMetadataCopy:  return NULL for metadata with item of bad type.");
         notype->type = PS_DATA_S32;
+        psFree(out);
+        out = NULL;
         psFree(in);
         in = NULL;
-        psFree(out);
-        out = NULL;
     }
 
