Index: trunk/psLib/src/sys/psString.c
===================================================================
--- trunk/psLib/src/sys/psString.c	(revision 10286)
+++ trunk/psLib/src/sys/psString.c	(revision 10446)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-11-29 21:33:09 $
+ *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-04 22:15:04 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -275,19 +275,21 @@
 // given the input string, search for all copies of the key, and replace with the replacement value
 // the input string may be freed if not needed
-psString psStringSubstitute(psString input,
-                            const char *replace,
-                            const char *key)
-{
+ssize_t psStringSubstitute(psString *input,
+                           const char *replace,
+                           const char *key)
+{
+    PS_ASSERT_PTR_NON_NULL(input, 0);
+
     // Empty input gives empty output
-    if (!input || strlen(input) == 0) {
-        return input;
+    if (!*input || strlen(*input) == 0) {
+        return 0;
     }
     // No key gives the same as the input
     if (!key || strlen(key) == 0) {
-        return input;
-    }
-    if (!psMemCheckString(input)) {
+        return strlen(*input);
+    }
+    if (!psMemCheckString(*input)) {
         psError(PS_ERR_BAD_PARAMETER_TYPE, true, "This function requires a psString as input.\n");
-        return NULL;
+        return 0;
     }
 
@@ -302,9 +304,9 @@
     }
 
-    char *search = input;               // Search this string
+    char *search = *input;              // Search this string
     while (true) {
         char *found = strstr(search, key); // Found occurence of the key
         if (!found) {
-            return input;
+            return strlen(*input);
         }
 
@@ -313,9 +315,9 @@
 
         // this is safe since we will subtract strlen(key) elements from input
-        psString output = psStringAlloc(strlen(input) + replaceLength + 1); // Output string
-        int numChar = found - input;    // Number of characters to copy
+        psString output = psStringAlloc(strlen(*input) + replaceLength + 1); // Output string
+        int numChar = found - *input;    // Number of characters to copy
 
         // copy the first segement into 'output'
-        strncpy(output, input, numChar);
+        strncpy(output, *input, numChar);
 
         // copy the key replacement to the start of the key
@@ -328,11 +330,11 @@
         strcpy(output + numChar, found + strlen(key));
 
-        psFree(input);
-        input = output;
+        psFree(*input);
+        *input = output;
         search = output + numChar;
     }
 
     psAbort(__func__, "Should never get here.\n");
-    return NULL;
+    return 0;
 }
 
