Index: trunk/psLib/src/sys/psString.c
===================================================================
--- trunk/psLib/src/sys/psString.c	(revision 8607)
+++ trunk/psLib/src/sys/psString.c	(revision 9509)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-25 22:42:37 $
+ *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-12 21:31:47 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -304,7 +304,8 @@
     }
 
+    char *search = input;               // Search this string
     while (true) {
-        char *p = strstr(input, key);
-        if (!p) {
+        char *found = strstr(search, key); // Found occurence of the key
+        if (!found) {
             return input;
         }
@@ -315,20 +316,21 @@
         // this is safe since we will subtract strlen(key) elements from input
         psString output = psStringAlloc(strlen(input) + replaceLength + 1); // Output string
-        int Nc = p - input;             // Number of characters to copy
+        int numChar = found - input;    // Number of characters to copy
 
         // copy the first segement into 'output'
-        strncpy(output, input, Nc);
+        strncpy(output, input, numChar);
 
         // copy the key replacement to the start of the key
         if (replace && replaceLength > 0) {
-            strcpy(&output[Nc], replace);
-            Nc += replaceLength;
+            strcpy(output + numChar, replace);
+            numChar += replaceLength;
         }
 
         // copy the remainder to the end of the replacement
-        strcpy(&output[Nc], p + strlen(key));
+        strcpy(output + numChar, found + strlen(key));
 
         psFree(input);
         input = output;
+        search = output + numChar;
     }
 
