[sword-cvs] sword/src/modules/filters gbffootnotes.cpp,1.26,1.27 gbfplain.cpp,1.18,1.19 osisfootnotes.cpp,1.16,1.17 osislemma.cpp,1.7,1.8 osismorph.cpp,1.12,1.13 osisplain.cpp,1.16,1.17 osisredletterwords.cpp,1.9,1.10 osisscripref.cpp,1.8,1.9 osisstrongs.cpp,1.16,1.17

sword@www.crosswire.org sword@www.crosswire.org
Fri, 9 Apr 2004 05:31:21 -0700


Update of /cvs/core/sword/src/modules/filters
In directory www:/tmp/cvs-serv18680/src/modules/filters

Modified Files:
	gbffootnotes.cpp gbfplain.cpp osisfootnotes.cpp osislemma.cpp 
	osismorph.cpp osisplain.cpp osisredletterwords.cpp 
	osisscripref.cpp osisstrongs.cpp 
Log Message:
fixes for filter bugs I made in the optimizing; NASB is still not displayed - bug in OSISFootnotes; some more speed improvements (jansorg)

Index: gbffootnotes.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/gbffootnotes.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- gbffootnotes.cpp	8 Apr 2004 20:57:32 -0000	1.26
+++ gbffootnotes.cpp	9 Apr 2004 12:31:14 -0000	1.27
@@ -50,7 +50,7 @@
 	SWBuf orig = text;
 	const char *from = orig.c_str();
 	
-	XMLTag tag;
+	//XMLTag tag;
 
 	for (text = ""; *from; from++) {
 		if (*from == '<') {
@@ -63,18 +63,18 @@
 
 			//XMLTag tag(token);
 			if (!strncmp(token, "RF",2)) {
-				tag = token;
+// 				tag = token;
 				
 				refs = "";
-				startTag = tag;
+				startTag = token;
 				hide = true;
 				tagText = "";
 				continue;
 			}
 			else if (!strncmp(token, "Rf",2)) {
-				tag = token;
-				
 				if (module->isProcessEntryAttributes()) {
+					//tag = token;
+				
 					if((tagText.length() == 1) || !strcmp(module->Name(), "IGNT")) {
 						if (option) { // for ASV marks text in verse then put explanation at end of verse
 							text.append(" <FA>(");

Index: gbfplain.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/gbfplain.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- gbfplain.cpp	8 Apr 2004 20:57:32 -0000	1.18
+++ gbfplain.cpp	9 Apr 2004 12:31:15 -0000	1.19
@@ -21,6 +21,7 @@
 	bool intoken = false;
 	SWBuf orig = text;
 	const char* from = orig.c_str();
+	
 	for (text = ""; *from; ++from) {
 		if (*from == '<') {
 			intoken = true;
@@ -36,15 +37,15 @@
 			switch (*token) {
 			case 'W':	// Strongs
 				switch(token[1]) {
-					case 'G':               // Greek
-					case 'H':               // Hebrew
-					case 'T':               // Tense
-						text.append(" <");
-						//for (char *tok = token + 2; *tok; tok++)
-						//	text += *tok;
-						text.append(token+2);
-						text.append("> ");
-						continue;
+				case 'G':               // Greek
+				case 'H':               // Hebrew
+				case 'T':               // Tense
+					text.append(" <");
+					//for (char *tok = token + 2; *tok; tok++)
+					//	text += *tok;
+					text.append(token+2);
+					text.append("> ");
+					continue;
 				}
 				break;
 			case 'R':
@@ -63,7 +64,7 @@
 					text.append((char)atoi(&token[2]));
 					continue;
 				case 'G':
-					text.append(">");
+					text.append('>');
 					continue;
 /*								Bug in WEB
 				case 'L':

Index: osisfootnotes.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisfootnotes.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- osisfootnotes.cpp	8 Apr 2004 20:57:32 -0000	1.16
+++ osisfootnotes.cpp	9 Apr 2004 12:31:15 -0000	1.17
@@ -115,7 +115,7 @@
 				}
 				
 				char* attr = strstr(token.c_str() + 9, "osisRef=\"");
-				char* end = attr ? strchr(attr+10, '"') : 0;
+				char* end  = attr ? strchr(attr+9, '"') : 0;
 				
 				if (attr && end) {
 					refs.append(attr+9, end-(attr+9));

Index: osislemma.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osislemma.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- osislemma.cpp	8 Apr 2004 20:57:32 -0000	1.7
+++ osislemma.cpp	9 Apr 2004 12:31:15 -0000	1.8
@@ -32,14 +32,18 @@
 
 char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
 	if (!option) {	// if we don't want lemmas
-		const char *from;
 		char token[2048]; // cheese.  Fix.
 		int tokpos = 0;
 		bool intoken = false;
 		bool lastspace = false;
 		SWBuf orig = text;
-		from = orig.c_str();
+		const char *from = orig.c_str();
 
+		int len = 0; //taken out of the loop for speed
+		const char* start = 0;
+		const char* end = 0;
+		
+		
 		for (text = ""; *from; from++) {
 			if (*from == '<') {
 				intoken = true;
@@ -60,18 +64,22 @@
 				}
 				*/
 				
-				if (*token == 'w') {
-					const int len = strlen(token);
+				if ((*token == 'w') && (token[1] == ' ')) {
+// 					len = strlen(token);
 					
-					const char* start = strstr(token, "lemma=\"");
-					const char* end = start ? strchr(start+6, '"') : 0;
-					if (start && end) { //we wan to leave out the moprh attribute
+					start = strstr(token, "lemma=\""); //we leave out the "w " at the start
+					end = (start && (strlen(start)>7)) ? strchr(start+7, '"') : 0;
+					if (start && end) { //we want to leave out the morph attribute
+						text.append('<');
 						text.append(token, start-token); //the text before the morph attr
-						text.append(end, len-(end - token)); //text after the morph attr
+						text.append(end+1, strlen(token) - (end+1 - token)); //text after the morph attr
+						text.append('>');
 					}
 				}
 				else {
+					text.append('<');
 					text.append(token);
+					text.append('>');
 				}
 				
 				// keep tag, possibly with the lemma removed

Index: osismorph.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osismorph.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- osismorph.cpp	8 Apr 2004 20:57:32 -0000	1.12
+++ osismorph.cpp	9 Apr 2004 12:31:15 -0000	1.13
@@ -38,6 +38,11 @@
 		bool lastspace = false;
 		SWBuf orig = text;
 		const char *from = orig.c_str();
+		
+		//taken out of the loop for speed
+		const char* start = 0;
+		const char* end = 0;
+		int len = 0;
 
 		for (text = ""; *from; from++) {
 			if (*from == '<') {
@@ -55,19 +60,22 @@
 						tag.setAttribute("morph", 0);
 				}*/
 				
-				if (*token == 'w') {
-					char* start = strstr(token, "morph=\"");
-					const int len = strlen(token);
-					if (start && (len>8)) {
-						char* end = strchr(start+8, '"');
-						if (end) { //remove the morph value
-							text.append(token, start-token); //the text before the morph attr
-							text.append(end, len-(end - token)); //text after the morph attr
-						}
+				if ((*token == 'w') && (token[1] == ' ')) {
+					len = strlen(token);
+					start = strstr(token, "morph=\""); //we leave out "w " at the start
+					end = (start && (strlen(start)>7)) ? strchr(start+7, '"') : 0;
+
+					if (start && end) {
+						text.append("<");
+						text.append(token, start-token); //the text before the morph attr
+						text.append(end+1, len-(end+1 - token)); //text after the morph attr
+						text.append(">");
 					}
 				}
 				else {
+					text.append('<');
 					text.append(token);
+					text.append('>');
 				}
 				
 				// keep tag, possibly with the morph removed

Index: osisplain.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisplain.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- osisplain.cpp	8 Apr 2004 20:57:32 -0000	1.16
+++ osisplain.cpp	9 Apr 2004 12:31:15 -0000	1.17
@@ -48,13 +48,11 @@
 
 bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
         // manually process if it wasn't a simple substitution
-	XMLTag tag;
-	
 	if (!substituteToken(buf, token)) {
 		MyUserData *u = (MyUserData *)userData;
 		if (((*token == 'w') && (token[1] == ' ')) ||
-		((*token == '/') && (token[1] == 'w') && (!token[2]))) {
-	                tag = token;
+		    ((*token == '/') && (token[1] == 'w') && (!token[2]))) {
+	                u->tag = token;
 			
 			bool start = false;
 			if (*token == 'w') {
@@ -64,36 +62,36 @@
 				}
 				start = true;
 			}
-			tag = (start) ? token : u->w.c_str();
+			u->tag = (start) ? token : u->w.c_str();
 			bool show = true;	// to handle unplaced article in kjv2003-- temporary till combined
 
 			SWBuf lastText = (start) ? "stuff" : u->lastTextNode.c_str();
 
 			const char *attrib;
 			const char *val;
-			if (attrib = tag.getAttribute("xlit")) {
+			if ((attrib = u->tag.getAttribute("xlit"))) {
 				val = strchr(attrib, ':');
 				val = (val) ? (val + 1) : attrib;
 				buf.append(" <");
 				buf.append(val);
-				buf.append(">");
+				buf.append('>');
 				
 				//buf.appendFormatted(" <%s>", val);
 			}
-			if (attrib = tag.getAttribute("gloss")) {
+			if ((attrib = u->tag.getAttribute("gloss"))) {
 				val = strchr(attrib, ':');
 				val = (val) ? (val + 1) : attrib;
 				buf.append(" <");
 				buf.append(val);
-				buf.append(">");
+				buf.append('>');
 
 // 				buf.appendFormatted(" <%s>", val);
 			}
-			if (attrib = tag.getAttribute("lemma")) {
-				int count = tag.getAttributePartCount("lemma");
+			if ((attrib = u->tag.getAttribute("lemma"))) {
+				int count = u->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);
+					attrib = u->tag.getAttribute("lemma", i);
 					if (i < 0) i = 0;	// to handle our -1 condition
 					val = strchr(attrib, ':');
 					val = (val) ? (val + 1) : attrib;
@@ -110,11 +108,11 @@
 					}
 				} while (++i < count);
 			}
-			if ((attrib = tag.getAttribute("morph")) && (show)) {
-				int count = tag.getAttributePartCount("morph");
+			if ((attrib = u->tag.getAttribute("morph")) && (show)) {
+				int count = u->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);
+					attrib = u->tag.getAttribute("morph", i);
 					if (i < 0) i = 0;	// to handle our -1 condition
 					val = strchr(attrib, ':');
 					val = (val) ? (val + 1) : attrib;
@@ -126,13 +124,13 @@
 // 					buf.appendFormatted(" (%s)", val);
 				} while (++i < count);
 			}
-			if (attrib = tag.getAttribute("POS")) {
+			if ((attrib = u->tag.getAttribute("POS"))) {
 				val = strchr(attrib, ':');
 				val = (val) ? (val + 1) : attrib;
 				
 				buf.append(" <");
 				buf.append(val);
-				buf.append(">");
+				buf.append('>');
 // 				buf.appendFormatted(" <%s>", val);
 			}
 		}
@@ -154,17 +152,17 @@
 		else if (((*token == 'p') && ((token[1] == ' ') || (!token[1]))) ||
 			((*token == '/') && (token[1] == 'p') && (!token[2]))) {
 				userData->supressAdjacentWhitespace = true;
-				buf.append("\n");
+				buf.append('\n');
 		}
 
                 // <milestone type="line"/>
                 else if (!strncmp(token, "milestone", 9)) {
 			const char* type = strstr(token+9, "type=\"");
-			if (type && strncmp(type, "line", 4)) { //we check for type != line
+			if (type && strncmp(type+6, "line", 4)) { //we check for type != line
 			
 		// && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
 				userData->supressAdjacentWhitespace = true;
-        			buf.append("\n");
+        			buf.append('\n');
 			}
                 }
 

Index: osisredletterwords.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisredletterwords.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- osisredletterwords.cpp	8 Apr 2004 20:57:32 -0000	1.9
+++ osisredletterwords.cpp	9 Apr 2004 12:31:16 -0000	1.10
@@ -39,6 +39,10 @@
 	SWBuf orig = text;
 	const char *from = orig.c_str();
 
+	//taken out of the loop
+	char* start;
+	char* end;
+	
 	if (!option)
 	for (text = ""; *from; from++) {
 		if (*from == '<') {
@@ -58,16 +62,19 @@
 				}
 			}*/
 			if (*token == 'q') {
-				char* start = strstr(token, "who=\"Jesus\"");
-				const int len = strlen(token);
-				if (start && (len>11)) {
-					char* end = start+11;
+				start = strstr(token, "who=\"Jesus\"");
+				if (start && (strlen(start) > 11)) {
+					end = start+11;
+					text.append('<');
 					text.append(token, start-token); //the text before the who attr
-					text.append(end, len-(end - token)); //text after the who attr
+					text.append(end, strlen(token)-(end - token)); //text after the who attr
+					text.append('>');
 				}
 			}
 			else {
+				text.append('<');
 				text.append(token);
+				text.append('>');
 			}
 			
 			
@@ -78,10 +85,10 @@
 			continue;
 		}
 		if (intoken) { //copy token
-			token += *from;
+			token.append(*from);
 		}
 		else { //copy text which is not inside a token
-			text += *from;
+			text.append(*from);
 		}
 	}
 	return 0;

Index: osisscripref.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisscripref.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- osisscripref.cpp	8 Apr 2004 20:57:32 -0000	1.8
+++ osisscripref.cpp	9 Apr 2004 12:31:16 -0000	1.9
@@ -65,9 +65,9 @@
 						hide = true;
 						tagText = "";
 						if (option) {	// we want the tag in the text
-							text += '<';
+							text.append('<');
 							text.append(token);
-							text += '>';
+							text.append('>');
 						}
 						continue;
 					}

Index: osisstrongs.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisstrongs.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- osisstrongs.cpp	8 Apr 2004 20:57:32 -0000	1.16
+++ osisstrongs.cpp	9 Apr 2004 12:31:16 -0000	1.17
@@ -36,7 +36,6 @@
 	char token[2048]; // cheese.  Fix.
 	int tokpos = 0;
 	bool intoken = false;
-	int len;
 	bool lastspace = false;
 	int word = 1;
 	char val[128];
@@ -44,19 +43,16 @@
 	char *valto;
 	char *ch;
 
-	SWBuf orig = text;
-	const char *from = orig.c_str();
-
-	len = strlen(text) + 1;	// shift string to right of buffer
+	const SWBuf orig = text;
+	const char * from = orig.c_str();
 
-	for (text = ""; *from; from++) {
+	for (text = ""; *from; ++from) {
 		if (*from == '<') {
 			intoken = true;
 			tokpos = 0;
 			token[0] = 0;
 			token[1] = 0;
 			token[2] = 0;
-			//textEnd = text.size();
 			continue;
 		}
 		if (*from == '>') {	// process tokens
@@ -122,11 +118,9 @@
 					}
 				}
 			}
+			
 			// if not a strongs token, keep token in text
 			text.append('<');
-			//for (char *tok = token; *tok; tok++) {
-			//	text += *tok;
-			//}
 			text.append(token);
 			text.append('>');