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

scribe at crosswire.org scribe at crosswire.org
Thu Nov 2 04:42:24 MST 2017


Author: scribe
Date: 2017-11-02 04:42:24 -0700 (Thu, 02 Nov 2017)
New Revision: 3518

Modified:
   trunk/include/osisplain.h
   trunk/src/modules/filters/osisplain.cpp
Log:
Added soft hyphen stripping during search for OSIS SourceType

Modified: trunk/include/osisplain.h
===================================================================
--- trunk/include/osisplain.h	2017-11-01 12:08:15 UTC (rev 3517)
+++ trunk/include/osisplain.h	2017-11-02 11:42:24 UTC (rev 3518)
@@ -35,6 +35,7 @@
 protected:
 	virtual BasicFilterUserData *createUserData(const SWModule *module, const SWKey *key);
 	virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData);
+	virtual bool processStage(char stage, SWBuf &text, char *&from, BasicFilterUserData *userData);
 public:
 	OSISPlain();
 };

Modified: trunk/src/modules/filters/osisplain.cpp
===================================================================
--- trunk/src/modules/filters/osisplain.cpp	2017-11-01 12:08:15 UTC (rev 3517)
+++ trunk/src/modules/filters/osisplain.cpp	2017-11-02 11:42:24 UTC (rev 3518)
@@ -60,14 +60,17 @@
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
 
-	   setTokenCaseSensitive(true);
-	   addTokenSubstitute("title", "\n");
-	   addTokenSubstitute("/title", "\n");
-	   addTokenSubstitute("/l", "\n");
-	   addTokenSubstitute("lg", "\n");
-	   addTokenSubstitute("/lg", "\n");
+	setTokenCaseSensitive(true);
+	addTokenSubstitute("title", "\n");
+	addTokenSubstitute("/title", "\n");
+	addTokenSubstitute("/l", "\n");
+	addTokenSubstitute("lg", "\n");
+	addTokenSubstitute("/lg", "\n");
+
+	setStageProcessing(PRECHAR);
 }
 
+
 BasicFilterUserData *OSISPlain::createUserData(const SWModule *module, const SWKey *key) {
 	MyUserData *u = new MyUserData(module, key);
 	u->vk = SWDYNAMIC_CAST(VerseKey, u->key);
@@ -76,6 +79,17 @@
 }
 
 
+bool OSISPlain::processStage(char stage, SWBuf &text, char *&from, BasicFilterUserData *userData) {
+	// this is a strip filter so we want to do this as optimized as possible.  Avoid calling
+	// getUniCharFromUTF8 for slight speed improvement
+		
+	if (stage == PRECHAR) {
+		if (from[0] == 0xC2 && from[1] == 0xAD) return true;	// skip soft hyphens
+	}
+	return false;
+}
+
+
 bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
 	   // manually process if it wasn't a simple substitution
 	if (!substituteToken(buf, token)) {




More information about the sword-cvs mailing list