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

scribe at crosswire.org scribe at crosswire.org
Thu Oct 14 07:11:54 MST 2010


Author: scribe
Date: 2010-10-14 07:11:54 -0700 (Thu, 14 Oct 2010)
New Revision: 2568

Modified:
   trunk/include/osishtmlhref.h
   trunk/src/modules/filters/osishtmlhref.cpp
Log:
Next attempt to solve the <hi> mismatch bug while still preserving binary compat for 1.6.x


Modified: trunk/include/osishtmlhref.h
===================================================================
--- trunk/include/osishtmlhref.h	2010-10-14 13:41:50 UTC (rev 2567)
+++ trunk/include/osishtmlhref.h	2010-10-14 14:11:54 UTC (rev 2568)
@@ -32,17 +32,18 @@
 	bool morphFirst;
 protected:
 	// used by derived classes so we have it in the header
-	class TagStack;
+	class TagStacks;
 	class SWDLLEXPORT MyUserData : public BasicFilterUserData {
 	public:
 		bool osisQToTick;
+		bool inBold;	// TODO: obsolete. left for binary compat for 1.6.x
 		bool inXRefNote;
 		bool BiblicalText;
 		int suspendLevel;
 		SWBuf wordsOfChristStart;
 		SWBuf wordsOfChristEnd;
-                TagStack *quoteStack;
-                TagStack *hiStack;
+                TagStacks *tagStacks;	// TODO: modified to wrap all TagStacks necessary for this filter until 1.7.x
+//                TagStack *hiStack;	// TODO: commented out for binary compat for 1.6.x	 wrapped in quoteStack until 1.7.x
 		SWBuf lastTransChange;
 		SWBuf w;
 		SWBuf fn;

Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp	2010-10-14 13:41:50 UTC (rev 2567)
+++ trunk/src/modules/filters/osishtmlhref.cpp	2010-10-14 14:11:54 UTC (rev 2568)
@@ -34,14 +34,21 @@
 
 SWORD_NAMESPACE_START
 
-class OSISHTMLHREF::TagStack : public std::stack<SWBuf> {
+namespace {
+	typedef std::stack<SWBuf> TagStack;
+}
+
+// TODO: this bridge pattern is to preserve binary compat on 1.6.x
+class OSISHTMLHREF::TagStacks {
+public:
+	TagStack quoteStack;
+	TagStack hiStack;
 };
 
 OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
 	inXRefNote    = false;
 	suspendLevel = 0;
-	quoteStack = new TagStack();
-	hiStack = new TagStack();
+	tagStacks = new TagStacks();
 	wordsOfChristStart = "<font color=\"red\"> ";
 	wordsOfChristEnd   = "</font> ";
 	if (module) {
@@ -56,8 +63,7 @@
 }
 
 OSISHTMLHREF::MyUserData::~MyUserData() {
-	delete quoteStack;
-	delete hiStack;
+	delete tagStacks;
 }
 
 OSISHTMLHREF::OSISHTMLHREF() {
@@ -486,12 +492,15 @@
 				else {	// all other types
 					outText("<i>", buf, u);
 				}
-				u->hiStack->push(tag.toString());
+				u->tagStacks->hiStack.push(tag.toString());
 			}
 			else if (tag.isEndTag()) {
-				XMLTag tag(u->hiStack->top());
-				u->hiStack->pop();
-				SWBuf type = tag.getAttribute("type");
+				SWBuf type = "";
+				if (!u->tagStacks->hiStack.empty()) {
+					XMLTag tag(u->tagStacks->hiStack.top());
+					u->tagStacks->hiStack.pop();
+					type = tag.getAttribute("type");
+				}
 				if (type == "bold" || type == "b" || type == "x-b") {
 					outText("</b>", buf, u);
 				}
@@ -520,7 +529,7 @@
 			if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("sID"))) {
 				// if <q> then remember it for the </q>
 				if (!tag.isEmpty()) {
-					u->quoteStack->push(tag.toString());
+					u->tagStacks->quoteStack.push(tag.toString());
 				}
 
 				// Do this first so quote marks are included as WoC
@@ -537,9 +546,9 @@
 			// close </q> or <q eID... />
 			else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("eID"))) {
 				// if it is </q> then pop the stack for the attributes
-				if (tag.isEndTag() && !u->quoteStack->empty()) {
-					XMLTag qTag(u->quoteStack->top());
-					u->quoteStack->pop();
+				if (tag.isEndTag() && !u->tagStacks->quoteStack.empty()) {
+					XMLTag qTag(u->tagStacks->quoteStack.top());
+					u->tagStacks->quoteStack.pop();
 
 					type    = qTag.getAttribute("type");
 					who     = qTag.getAttribute("who");




More information about the sword-cvs mailing list