Index: trunk/psLib/src/sys/psString.c
===================================================================
--- trunk/psLib/src/sys/psString.c	(revision 7251)
+++ trunk/psLib/src/sys/psString.c	(revision 7380)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-31 20:56:37 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-07 03:22:06 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -31,9 +31,9 @@
 psString psStringCopy(const char *string)
 {
-    PS_ASSERT_PTR_NON_NULL(string, NULL);
+    // Pass through NULL values!
+
     // Allocate memory using psAlloc function
     // Copy input string to memory just allocated
     // Return the copy
-    // Pass through NULL values
     return string ? strcpy(psAlloc(strlen(string) + 1), string) : NULL;
 }
@@ -218,18 +218,15 @@
 // 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
-char *psStringSubstitute (char *input, char *replace, char *key)
-{
-
-    char *p;
-
-    if (key == NULL)
+char *psStringSubstitute(char *input, const char *replace, const char *key)
+{
+    if (key == NULL || strlen(key) == 0) {
         return input;
-    if (strlen(key) == 0)
-        return input;
+    }
 
     while (true) {
-        p = strstr (input, key);
-        if (p == NULL)
+        char *p = strstr (input, key);
+        if (!p) {
             return input;
+        }
 
         // we have input = xxxkeyxxx
@@ -241,15 +238,14 @@
 
         // copy the first segement into 'output'
-        strncpy (output, input, Nc);
+        strncpy(output, input, Nc);
 
         // copy the key replacement to the start of the key
-
-        strcpy (&output[Nc], replace);
+        strcpy(&output[Nc], replace);
         Nc += strlen (replace);
 
         // copy the remainder to the end of the replacement
-        strcpy (&output[Nc], p + strlen(key));
-
-        psFree (input);
+        strcpy(&output[Nc], p + strlen(key));
+
+        psFree(input);
         input = output;
     }
@@ -257,2 +253,35 @@
 }
 
+psArray *psStringSplitArray(const char *string, const char *splitters, bool multi)
+{
+
+    psList *list = psStringSplit(string, splitters, multi);
+    psArray *array = psListToArray(list);
+    psFree (list);
+    return array;
+}
+
+#ifndef whitespace
+#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
+#endif
+
+/* Strip whitespace from the start and end of STRING. */
+size_t psStringStrip(char *string)
+{
+    long i;
+
+    if (!string || strlen(string) == 0) {
+        return 0;
+    }
+
+    for (i = 0; i < strlen(string) && whitespace(string[i]); i++)
+        ; // No action
+    if (i) {
+        memmove (string, string + i, strlen(string+i)+1);
+    }
+    for (i = strlen (string) - 1; (i > 0) && whitespace(string[i]); i--)
+        ; // No action
+    string[++i] = 0;
+
+    return i;
+}
