[sword-svn] r1947 - trunk/src/utilfuns

scribe at crosswire.org scribe at crosswire.org
Sat Jul 15 19:01:54 MST 2006


Author: scribe
Date: 2006-07-15 19:01:52 -0700 (Sat, 15 Jul 2006)
New Revision: 1947

Modified:
   trunk/src/utilfuns/utilxml.cpp
Log:
normalize whitespace in xml tags


Modified: trunk/src/utilfuns/utilxml.cpp
===================================================================
--- trunk/src/utilfuns/utilxml.cpp	2006-07-15 20:41:24 UTC (rev 1946)
+++ trunk/src/utilfuns/utilxml.cpp	2006-07-16 02:01:52 UTC (rev 1947)
@@ -38,6 +38,9 @@
 	for (i = 0; ((buf[i]) && (!isalpha(buf[i]))); i++);
 	for (; buf[i]; i++) {
 		if (strchr("\t\r\n ", buf[i])) {
+                        // Convert newlines, carriage returns and tabs to spaces
+			buf[i] = ' ';
+
 			for (; ((buf[i]) && (!isalpha(buf[i]))); i++);
 			if (buf[i]) {		// we have an attribute name
 				start = i;
@@ -61,7 +64,8 @@
 				for (; buf[i] == ' '; i++) ;
 
 				// skip the = sign
-				i++;
+				if (buf[i])
+					i++;
 
 				// skip space following the = sign
 				// Deprecated: this is not part of the xml spec
@@ -69,7 +73,8 @@
 
 				// remember and skip the quote sign
 				char quoteChar = buf[i];
-				i++;
+				if (quoteChar)
+					i++;
 
 				if (buf[i]) {	// we have attribute value
 					start = i;
@@ -90,9 +95,11 @@
 				}
 			}
 		}
-		if (buf[i])
-			buf[i] = ' ';
-		else break;
+
+		// if there are no more characters left then quit
+		if (!buf[i])
+			break;
+
 	}
 	for (;i;i--) {
 		if (buf[i] == '/')



More information about the sword-cvs mailing list