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

scribe at www.crosswire.org scribe at www.crosswire.org
Thu Sep 27 18:49:46 MST 2007


Author: scribe
Date: 2007-09-27 18:49:45 -0700 (Thu, 27 Sep 2007)
New Revision: 2091

Modified:
   trunk/include/config.h
   trunk/include/osishtmlhref.h
   trunk/src/modules/filters/osishtmlhref.cpp
Log:
Added morphFirst property to osishtmlhref


Modified: trunk/include/config.h
===================================================================
--- trunk/include/config.h	2007-09-27 22:44:20 UTC (rev 2090)
+++ trunk/include/config.h	2007-09-28 01:49:45 UTC (rev 2091)
@@ -1,4 +1,4 @@
-/* include/config.h.  Generated by configure.  */
+/* include/config.h.  Generated from config.h.in by configure.  */
 /* include/config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define to 1 if you have the <dlfcn.h> header file. */

Modified: trunk/include/osishtmlhref.h
===================================================================
--- trunk/include/osishtmlhref.h	2007-09-27 22:44:20 UTC (rev 2090)
+++ trunk/include/osishtmlhref.h	2007-09-28 01:49:45 UTC (rev 2091)
@@ -29,6 +29,7 @@
  */
 class SWDLLEXPORT OSISHTMLHREF : public SWBasicFilter {
 private:
+	bool morphFirst;
 protected:
 	// used by derived classes so we have it in the header
 	class QuoteStack;
@@ -55,6 +56,7 @@
 	virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData);
 public:
 	OSISHTMLHREF();
+	void setMorphFirst(bool val = true) { morphFirst = val; }
 };
 
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp	2007-09-27 22:44:20 UTC (rev 2090)
+++ trunk/src/modules/filters/osishtmlhref.cpp	2007-09-28 01:49:45 UTC (rev 2091)
@@ -77,6 +77,8 @@
 	
 	addTokenSubstitute("lg",  "<br />");
 	addTokenSubstitute("/lg", "<br />");
+
+	morphFirst = false;
 }
 
 // though this might be slightly slower, possibly causing an extra bool check, this is a renderFilter
@@ -84,6 +86,69 @@
 static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
 static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
 
+void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+	const char *attrib;
+	const char *val;
+	if ((attrib = tag.getAttribute("lemma"))) {
+		int count = tag.getAttributePartCount("lemma", ' ');
+		int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+		do {
+			attrib = tag.getAttribute("lemma", i, ' ');
+			if (i < 0) i = 0;	// to handle our -1 condition
+			val = strchr(attrib, ':');
+			val = (val) ? (val + 1) : attrib;
+			SWBuf gh;
+			if(*val == 'G')
+				gh = "Greek";
+			if(*val == 'H')
+				gh = "Hebrew";
+			const char *val2 = val;
+			if ((strchr("GH", *val)) && (isdigit(val[1])))
+				val2++;
+			//if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
+			//	show = false;
+			//else {
+				if (!suspendTextPassThru) {
+					buf.appendFormatted("<small><em>&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\">%s</a>&gt;</em></small>",
+							(gh.length()) ? gh.c_str() : "", 
+							URL::encode(val2).c_str(), 
+							val2);
+				}
+			//}
+			
+		} while (++i < count);
+	}
+}
+
+void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+	const char * attrib;
+	const char *val;
+	if ((attrib = tag.getAttribute("morph"))) { // && (show)) {
+		SWBuf savelemma = tag.getAttribute("savlm");
+		//if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
+		//	show = false;
+		//if (show) {
+			int count = tag.getAttributePartCount("morph", ' ');
+			int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+			do {
+				attrib = tag.getAttribute("morph", i, ' ');
+				if (i < 0) i = 0;	// to handle our -1 condition
+				val = strchr(attrib, ':');
+				val = (val) ? (val + 1) : attrib;
+				const char *val2 = val;
+				if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
+					val2+=2;
+				if (!suspendTextPassThru) {
+					buf.appendFormatted("<small><em>(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\">%s</a>)</em></small>",
+							URL::encode(tag.getAttribute("morph")).c_str(),
+							URL::encode(val).c_str(), 
+							val2);
+				}
+			} while (++i < count);
+		//}
+	}
+}
+
 bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
 	MyUserData *u = (MyUserData *)userData;
 	SWBuf scratch;
@@ -126,58 +191,13 @@
 					outText(" ", buf, u);
 					outText(val, buf, u);
 				}
-				if ((attrib = tag.getAttribute("lemma"))) {
-					int count = tag.getAttributePartCount("lemma", ' ');
-					int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
-					do {
-						attrib = tag.getAttribute("lemma", i, ' ');
-						if (i < 0) i = 0;	// to handle our -1 condition
-						val = strchr(attrib, ':');
-						val = (val) ? (val + 1) : attrib;
-						SWBuf gh;
-						if(*val == 'G')
-							gh = "Greek";
-						if(*val == 'H')
-							gh = "Hebrew";
-						const char *val2 = val;
-						if ((strchr("GH", *val)) && (isdigit(val[1])))
-							val2++;
-						//if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
-						//	show = false;
-						//else {
-							if (!u->suspendTextPassThru) {
-								buf.appendFormatted("<small><em>&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\">%s</a>&gt;</em></small>",
-										(gh.length()) ? gh.c_str() : "", 
-										URL::encode(val2).c_str(), 
-										val2);
-							}
-						//}
-						
-					} while (++i < count);
+				if (!morphFirst) {
+					processLemma(u->suspendTextPassThru, tag, buf);
+					processMorph(u->suspendTextPassThru, tag, buf);
 				}
-				if ((attrib = tag.getAttribute("morph"))) { // && (show)) {
-					SWBuf savelemma = tag.getAttribute("savlm");
-					//if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
-					//	show = false;
-					//if (show) {
-						int count = tag.getAttributePartCount("morph", ' ');
-						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
-						do {
-							attrib = tag.getAttribute("morph", i, ' ');
-							if (i < 0) i = 0;	// to handle our -1 condition
-							val = strchr(attrib, ':');
-							val = (val) ? (val + 1) : attrib;
-							const char *val2 = val;
-							if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
-								val2+=2;
-							if (!u->suspendTextPassThru) {
-								buf.appendFormatted("<small><em>(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\">%s</a>)</em></small>",
-										URL::encode(tag.getAttribute("morph")).c_str(),
-										URL::encode(val).c_str(), 
-										val2);
-							}
-						} while (++i < count);
-					//}
+				else {
+					processMorph(u->suspendTextPassThru, tag, buf);
+					processLemma(u->suspendTextPassThru, tag, buf);
 				}
 				if ((attrib = tag.getAttribute("POS"))) {
 					val = strchr(attrib, ':');




More information about the sword-cvs mailing list