[sword-cvs] sword/src/modules/filters osisplain.cpp,1.8,1.9 osisrtf.cpp,1.17,1.18 swbasicfilter.cpp,1.26,1.27

sword@www.crosswire.org sword@www.crosswire.org
Tue, 29 Jul 2003 18:32:22 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv26682/src/modules/filters

Modified Files:
	osisplain.cpp osisrtf.cpp swbasicfilter.cpp 
Log Message:


Index: osisplain.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisplain.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- osisplain.cpp	30 Jul 2003 00:51:34 -0000	1.8
+++ osisplain.cpp	30 Jul 2003 01:32:20 -0000	1.9
@@ -44,26 +44,22 @@
         addTokenSubstitute("/lg", "\n");
 
         setTokenCaseSensitive(true);
+	setStageProcessing(PRECHAR);		// just at top of for loop
 }
 
-char OSISPlain::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
-        SWBasicFilter::processText(text, key, module);  //handle tokens as usual
-	const char *from;
-	SWBuf orig = text;
-	from = orig.c_str();
-	for (text = ""; *from; from++) {  //loop to remove extra spaces
-                if ((strchr(" \t\n\r", *from))) {
-                        while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
-                                from++;
-                        }
-                        text += " ";
-                }
-                else {
-                        text += *from;
-                }
-        }
-        text += (char)0;
-        return 0;
+
+bool OSISPlain::processStage(char stage, SWBuf &text, const char *&from, UserData *userData) {
+	switch (stage) {
+	PRECHAR:
+		if ((strchr(" \t\n\r", *from))) {
+			while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
+				from++;
+			}
+			text += " ";
+			return true;
+		}
+	}
+	return false;
 }
 
 

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- osisrtf.cpp	30 Jul 2003 00:51:34 -0000	1.17
+++ osisrtf.cpp	30 Jul 2003 01:32:20 -0000	1.18
@@ -42,24 +42,25 @@
 	addEscapeStringSubstitute("lt", "<");
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
-	setStageProcessing(POSTCHAR);		// just at bottom of for loop
         addTokenSubstitute("lg", "\\par ");
         addTokenSubstitute("/lg", "\\par ");
 	setTokenCaseSensitive(true);
+	setStageProcessing(PRECHAR);		// just at top of for loop
 }
 
 
 bool OSISRTF::processStage(char stage, SWBuf &text, const char *&from, UserData *userData) {
 	switch (stage) {
-	POSTCHAR:
+	PRECHAR:
 		if ((strchr(" \t\n\r", *from))) {
 			while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
 				from++;
 			}
 			text += " ";
-			from++;
+			return true;
 		}
 	}
+	return false;
 }
 
 

Index: swbasicfilter.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/swbasicfilter.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- swbasicfilter.cpp	30 Jul 2003 01:14:34 -0000	1.26
+++ swbasicfilter.cpp	30 Jul 2003 01:32:20 -0000	1.27
@@ -218,13 +218,19 @@
 	from = orig.c_str();
 	text = "";
 
-	if (processStages & INITIALIZE)
-		processStage(INITIALIZE, text, from, userData);
+	if (processStages & INITIALIZE) {
+		if (processStage(INITIALIZE, text, from, userData)) {	// processStage handled it all
+			delete userData;
+			return 0;
+		}
+	}
 
 	for (;*from; from++) {
 
-		if (processStages & PRECHAR)
-			processStage(PRECHAR, text, from, userData);
+		if (processStages & PRECHAR) {
+			if (processStage(PRECHAR, text, from, userData))	// processStage handled this char
+				continue;
+		}
 
 		if (*from == tokenStart[tokenStartPos]) {
 			if (tokenStartPos == (tokenStartLen - 1)) {