[sword-svn] r1952 - in trunk: include src/modules/filters

scribe at crosswire.org scribe at crosswire.org
Sun Jul 30 12:08:25 MST 2006


Author: scribe
Date: 2006-07-30 12:08:20 -0700 (Sun, 30 Jul 2006)
New Revision: 1952

Modified:
   trunk/include/utilxml.h
   trunk/src/modules/filters/osishtmlhref.cpp
   trunk/src/modules/filters/osisrtf.cpp
Log:
Changed to not depend on an extended life of return values from XMLTag.


Modified: trunk/include/utilxml.h
===================================================================
--- trunk/include/utilxml.h	2006-07-30 08:58:31 UTC (rev 1951)
+++ trunk/include/utilxml.h	2006-07-30 19:08:20 UTC (rev 1952)
@@ -73,6 +73,8 @@
 
 	const StringList getAttributeNames() const;
 	int getAttributePartCount(const char *attribName, char partSplit = '|') const;
+
+	// return values should not be considered to persist beyond the return of the function.
 	const char *getAttribute(const char *attribName, int partNum = -1, char partSplit = '|') const;
 	const char *setAttribute(const char *attribName, const char *attribValue);
 	const char *toString() const;

Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp	2006-07-30 08:58:31 UTC (rev 1951)
+++ trunk/src/modules/filters/osishtmlhref.cpp	2006-07-30 19:08:20 UTC (rev 1952)
@@ -285,12 +285,14 @@
 				else outText("<!p>", buf, u);
 			}
 			else if (!strcmp(tag.getAttribute("type"), "cQuote")) {
-				const char *mark = tag.getAttribute("marker");
-				const char *lev = tag.getAttribute("level");
-				int level = (lev) ? atoi(lev) : 1;
+				const char *tmp = tag.getAttribute("marker");
+				bool hasMark    = tmp;
+				SWBuf mark      = tmp;
+				tmp             = tag.getAttribute("level");
+				int level       = (tmp) ? atoi(tmp) : 1;
 
 				// first check to see if we've been given an explicit mark
-				if (mark)
+				if (hasMark)
 					outText(mark, buf, u);
 				// finally, alternate " and ', if config says we should supply a mark
 				else if (u->osisQToTick)
@@ -376,11 +378,13 @@
 		// If there is a marker attribute, possibly empty, this overrides osisQToTick.
 		// If osisQToTick, then output the marker, using level to determine the type of mark.
 		else if (!strcmp(tag.getName(), "q")) {
-			SWBuf type = tag.getAttribute("type");
-			SWBuf who = tag.getAttribute("who");
-			const char *lev = tag.getAttribute("level");
-			const char *mark = tag.getAttribute("marker");
-			int level = (lev) ? atoi(lev) : 1;
+			SWBuf type      = tag.getAttribute("type");
+			SWBuf who       = tag.getAttribute("who");
+			const char *tmp = tag.getAttribute("level");
+			int level       = (tmp) ? atoi(tmp) : 1;
+			tmp             = tag.getAttribute("marker");
+			bool hasMark    = tmp;
+			SWBuf mark      = tmp;
 
 			// open <q> or <q sID... />
 			if ((!tag.isEmpty()) || (tag.getAttribute("sID"))) {
@@ -396,7 +400,7 @@
 					outText(u->wordsOfChristStart, buf, u);
 
 				// first check to see if we've been given an explicit mark
-				if (mark)
+				if (hasMark)
 					outText(mark, buf, u);
 				//alternate " and '
 				else if (u->osisQToTick)
@@ -411,15 +415,17 @@
 					XMLTag qTag(tagData);
 					delete tagData;
 
-					type  = qTag.getAttribute("type");
-					who   = qTag.getAttribute("who");
-					lev   = qTag.getAttribute("level");
-					mark  = qTag.getAttribute("marker");
-					level = (lev) ? atoi(lev) : 1;
+					type    = qTag.getAttribute("type");
+					who     = qTag.getAttribute("who");
+					tmp     = qTag.getAttribute("level");
+					level   = (tmp) ? atoi(tmp) : 1;
+					tmp     = qTag.getAttribute("marker");
+					hasMark = tmp;
+					mark    = tmp;
 				}
 
 				// first check to see if we've been given an explicit mark
-				if (mark)
+				if (hasMark)
 					outText(mark, buf, u);
 				// finally, alternate " and ', if config says we should supply a mark
 				else if (u->osisQToTick)

Modified: trunk/src/modules/filters/osisrtf.cpp
===================================================================
--- trunk/src/modules/filters/osisrtf.cpp	2006-07-30 08:58:31 UTC (rev 1951)
+++ trunk/src/modules/filters/osisrtf.cpp	2006-07-30 19:08:20 UTC (rev 1952)
@@ -296,11 +296,13 @@
 		// If there is a marker attribute, possibly empty, this overrides osisQToTick.
 		// If osisQToTick, then output the marker, using level to determine the type of mark.
 		else if (!strcmp(tag.getName(), "q")) {
-			SWBuf type = tag.getAttribute("type");
-			SWBuf who = tag.getAttribute("who");
-			const char *lev = tag.getAttribute("level");
-			const char *mark = tag.getAttribute("marker");
-			int level = (lev) ? atoi(lev) : 1;
+			SWBuf type      = tag.getAttribute("type");
+			SWBuf who       = tag.getAttribute("who");
+			const char *tmp = tag.getAttribute("level");
+			int level       = (tmp) ? atoi(tmp) : 1;
+			tmp             = tag.getAttribute("marker");
+			bool hasMark    = tmp;
+			SWBuf mark      = tmp;
 
 			// open <q> or <q sID... />
 			if ((!tag.isEmpty()) || (tag.getAttribute("sID"))) {
@@ -316,7 +318,7 @@
 					buf += "\\cf6 ";
 
 				// first check to see if we've been given an explicit mark
-				if (mark)
+				if (hasMark)
 					buf += mark;
 				//alternate " and '
 				else if (u->osisQToTick)
@@ -331,15 +333,17 @@
 					XMLTag qTag(tagData);
 					delete tagData;
 
-					type  = qTag.getAttribute("type");
-					who   = qTag.getAttribute("who");
-					lev   = qTag.getAttribute("level");
-					mark  = qTag.getAttribute("marker");
-					level = (lev) ? atoi(lev) : 1;
+					type    = qTag.getAttribute("type");
+					who     = qTag.getAttribute("who");
+					tmp     = qTag.getAttribute("level");
+					level   = (tmp) ? atoi(tmp) : 1;
+					tmp     = qTag.getAttribute("marker");
+					hasMark = tmp;
+					mark    = tmp;
 				}
 
 				// first check to see if we've been given an explicit mark
-				if (mark)
+				if (hasMark)
 					buf += mark;
 				// finally, alternate " and ', if config says we should supply a mark
 				else if (u->osisQToTick)
@@ -354,12 +358,14 @@
 
 		// <milestone type="cQuote" marker="x"/>
 		else if (!strcmp(tag.getName(), "milestone") && tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "cQuote")) {
-			const char *mark = tag.getAttribute("marker");
-			const char *lev = tag.getAttribute("level");
-			int level = (lev) ? atoi(lev) : 1;
+			const char *tmp = tag.getAttribute("marker");
+			bool hasMark    = tmp;
+			SWBuf mark      = tmp;
+			tmp             = tag.getAttribute("level");
+			int level       = (tmp) ? atoi(tmp) : 1;
 
 			// first check to see if we've been given an explicit mark
-			if (mark)
+			if (hasMark)
 				buf += mark;
 			// finally, alternate " and ', if config says we should supply a mark
 			else if (u->osisQToTick)



More information about the sword-cvs mailing list