Index: trunk/psLib/src/sys/psString.c
===================================================================
--- trunk/psLib/src/sys/psString.c	(revision 8598)
+++ trunk/psLib/src/sys/psString.c	(revision 8607)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-25 21:50:07 $
+ *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-08-25 22:42:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -98,4 +98,7 @@
                        ...)
 {
+    PS_ASSERT_PTR_NON_NULL(dest, 0);
+    PS_ASSERT_PTR_NON_NULL(format, 0);
+
     va_list ap;
     va_start(ap, format);
@@ -110,12 +113,10 @@
                         va_list ap)
 {
+    PS_ASSERT_PTR_NON_NULL(dest, 0);
     PS_ASSERT_PTR_NON_NULL(format, 0);
+
     size_t          length;             // complete string length (sans \0)
     size_t          oldLength;          // original string length (sans \0)
     ssize_t         tailLength;         // length of string to append
-
-    if (!dest || !format) {
-        return 0;
-    }
 
     if (*dest) {
@@ -125,6 +126,7 @@
     }
 
+    va_list         apCopy;
+
     // find the size of the string to append
-    va_list         apCopy;
     // C99 guarentees vsnprintf() to work as expected with size = 0
     va_copy(apCopy, ap);
@@ -160,13 +162,25 @@
                         ...)
 {
+    PS_ASSERT_PTR_NON_NULL(dest, 0);
     PS_ASSERT_PTR_NON_NULL(format, 0);
-    va_list         args;
+
+    va_list ap;
+    va_start(ap, format);
+    ssize_t length = psStringPrependV(dest, format, ap);
+    va_end(ap);
+
+    return length;
+}
+
+ssize_t psStringPrependV(char **dest,
+                         const char *format,
+                         va_list ap)
+{
+    PS_ASSERT_PTR_NON_NULL(dest, 0);
+    PS_ASSERT_PTR_NON_NULL(format, 0);
+
     size_t          length;             // complete string length (sans \0)
     ssize_t         headLength;         // length of string to prepend
     char            *oldDest;           // copy of original string
-
-    if (!dest || !format) {
-        return 0;
-    }
 
     if (!*dest) {
@@ -179,9 +193,11 @@
     }
 
+    va_list apCopy;
+
     // find the size of the string to prepend
-    va_start(args, format);
     // C99 guarentees vsnprintf() to work as expected with size = 0
-    headLength = vsnprintf(*dest, 0, format, args);
-    va_end(args);
+    va_copy(apCopy, ap);
+    headLength = vsnprintf(*dest, 0, format, apCopy);
+    va_end(apCopy);
 
     // if the new head is zero length, return the length of the old string.  if
@@ -201,7 +217,10 @@
 
     // copy the new head to the beginning of string
-    va_start(args, format);
-    vsnprintf(*dest, length + 1, format, args);
-    va_end(args);
+    // XXX this second call to va_copy() isn't strictly nessicary as the
+    // calling function can't assume we won't modify the va_list.  However, we
+    // have decided to error on the side of caution.
+    va_copy(apCopy, ap);
+    vsnprintf(*dest, length + 1, format, apCopy);
+    va_end(apCopy);
 
     // append the original string
