Index: trunk/psLib/src/xml/psXML.c
===================================================================
--- trunk/psLib/src/xml/psXML.c	(revision 1973)
+++ trunk/psLib/src/xml/psXML.c	(revision 1986)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-06 01:17:39 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-06 22:51:15 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -101,6 +101,6 @@
 
 
-/** Determines if a line is blank (whitespace only) or a comment, if so returns true. The input string must
- * be null terminated. */
+/** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string
+ *  must * be null terminated. */
 bool ignoreLine(char *inString)
 {
@@ -116,26 +116,24 @@
 
 
-/** Removes leading and trailing space from a line, as well as the leading comment # character. The cleaned
- * line is a new null terminated copy of the original input string. The input string must be null terminated.
+/** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null
+ *  terminated copy of the original input string.
  */
-char *cleanLine(char *inString)
+char *cleanString(char *inString, int sLen)
 {
     char *ptrB = NULL;
     char *ptrE = NULL;
     char *cleaned = NULL;
-    int sLen = 0;
-
-
-    sLen = strlen(inString);
+
+
     ptrB = inString;
 
-    /* Skip over # and leading whitespace */
+    /* Skip over leading # or whitespace */
     while (isspace(*ptrB) || *ptrB=='#') {
         ptrB++;
     }
 
-    /* Skip over trailing whitespace */
+    /* Skip over trailing whitespace, null terminators, and # characters */
     ptrE = inString + sLen;
-    while(isspace(*ptrE) || *ptrE=='\0') {
+    while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') {
         ptrE--;
     }
@@ -150,5 +148,5 @@
 }
 
-/** Count repeated occurances of a single character within a line. The input string must be null terminated. */
+/** Count repeat occurances of a single character within a line. The input string must be null terminated. */
 int repeatedChars(char *inString, char ch)
 {
@@ -166,37 +164,31 @@
 }
 
-/** Returns individual tokens within a line of text based on delimiter. Tokens are new null terminated copies
- *  of the original input string. */
-char* getToken(char **inString, char *delimiter, bool clean)
-{
-    char *token = NULL;
+/** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location
+ * the beginning of the string. Tokens are newly allocated null terminated strings. */
+char* getToken(char **inString, char *delimiter, int *status)
+{
     char *cleanToken = NULL;
     int sLen = 0;
 
 
-    // Skip over leading blanks
+    // Skip over leading whitespace
     while(isspace(**inString)) {
         (*inString)++;
     }
 
-    // Length of next token
+    // Length of token, not including delimiter
     sLen = strcspn(*inString, delimiter);
     if(sLen) {
 
-        // Create null terminated token
-        token = psStringNCopy(*inString, sLen);
-        if(clean) {
-
-            // Remove excess from token
-            cleanToken = cleanLine(token);
-            psFree(token);
-            token = cleanToken;
-        }
-
-        // Skip to end of token
+        // Create new, cleaned, and null terminated token
+        cleanToken = cleanString(*inString, sLen);
+
+        // Move to end of token
         (*inString) += sLen;
-    }
-
-    return token;
+    } else if(**inString!='\0' && sLen==0) {
+        *status = 1;
+    }
+
+    return cleanToken;
 }
 
@@ -212,4 +204,6 @@
     if(*end != '\0') {
         *status = 1;
+    } else if(inString==end) {
+        *status = 1;
     }
 
@@ -217,5 +211,5 @@
 }
 
-/** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are parsable variations. */
+/** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */
 bool parseBool(char *inString, int *status)
 {
@@ -268,4 +262,8 @@
         while(*inString!='\0') {
             value = strtod(inString, &end);
+            if(inString==end) {
+                *status = 1;
+                return vec;
+            }
             switch(elemType) {
             case PS_TYPE_U8:
@@ -493,4 +491,6 @@
     // While loop to parse the file
     while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) {
+
+        // Initialize variables for new line
         linePtr = line;
         lineCount++;
@@ -509,10 +509,16 @@
                 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
                 continue;
-            }
+            } else if(repeatedChars(linePtr, '~') > 0) {
+                failedLines++;
+                psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
+                continue;
+            }
+
 
             // Get metadata item name
-            strName = getToken(&linePtr, " ", true);
-            if(strName==NULL) {
-                failedLines++;
+            strName = getToken(&linePtr, " ", &status);
+            if(strName==NULL || status) {
+                failedLines++;
+                status = 0;
                 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
                 continue;
@@ -520,7 +526,8 @@
 
             // Get the metadata item type
-            strType = getToken(&linePtr, " ", true);
+            strType = getToken(&linePtr, " ", &status);
             if(strType==NULL) {
                 failedLines++;
+                status = 0;
                 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
                 continue;
@@ -554,7 +561,8 @@
             // Get the metadata item value if there is one. Lines with * don't have values.
             if(mdType != PS_META_ITEM_SET) {
-                strValue = getToken(&linePtr, "#", true);
+                strValue = getToken(&linePtr, "#", &status);
                 if(strValue==NULL) {
                     failedLines++;
+                    status = 0;
                     psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
                     continue;
@@ -563,5 +571,11 @@
 
             // Get the metadata item value if there is one. Not all lines will have comments, so NULL is ok.
-            strComment = getToken(&linePtr,"!!!!", true);
+            strComment = getToken(&linePtr,"~", &status);
+            if(status) {
+                failedLines++;
+                status = 0;
+                psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
+                continue;
+            }
 
             /* If metadata item is found, is not a folder node, and overwrite is allowed, then remove existing
