[sword-cvs] sword/src/modules/filters osisfootnotes.cpp,1.19,1.20 osislemma.cpp,1.8,1.9 osismorph.cpp,1.13,1.14 osisplain.cpp,1.19,1.20

sword@www.crosswire.org sword@www.crosswire.org
Fri, 16 Apr 2004 13:10:38 -0700


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

Modified Files:
	osisfootnotes.cpp osislemma.cpp osismorph.cpp osisplain.cpp 
Log Message:
filter cleanups (joachim)

Index: osisfootnotes.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisfootnotes.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- osisfootnotes.cpp	14 Apr 2004 20:08:57 -0000	1.19
+++ osisfootnotes.cpp	16 Apr 2004 20:10:33 -0000	1.20
@@ -24,6 +24,8 @@
 const SWBuf choices[3] = {"On", "Off", ""};
 const StringList oValues(&choices[0], &choices[2]);
 
+VerseKey parser;
+
 OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
 	setOptionValue("Off");
 }
@@ -42,14 +44,15 @@
 	SWBuf refs = "";
 	int footnoteNum = 1;
 	char buf[254];
-	VerseKey parser = key->getText();
+// 	VerseKey parser = key->getText();
+	parser = key->getText();
 
 	SWBuf orig = text;
 	const char *from = orig.c_str();
 	
-	XMLTag tag = "";
+	XMLTag tag;
 
-	for (text = ""; *from; from++) {
+	for (text = ""; *from; ++from) {
 
 		// remove all newlines temporarily to fix kjv2003 module
 		if ((*from == 10) || (*from == 13)) {
@@ -69,7 +72,6 @@
 		
 		if (*from == '>') {	// process tokens
 			intoken = false;			
-// 			if (!strcmp(tag.getName(), "note")) {
 			if (!strncmp(token, "note", 4) || !strncmp(token.c_str(), "/note", 5)) {
 				tag = token;
 				

Index: osislemma.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osislemma.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- osislemma.cpp	9 Apr 2004 12:31:15 -0000	1.8
+++ osislemma.cpp	16 Apr 2004 20:10:34 -0000	1.9
@@ -39,12 +39,11 @@
 		SWBuf orig = text;
 		const char *from = orig.c_str();
 
-		int len = 0; //taken out of the loop for speed
+		//taken out of the loop for speed
 		const char* start = 0;
 		const char* end = 0;
 		
-		
-		for (text = ""; *from; from++) {
+		for (text = ""; *from; ++from) {
 			if (*from == '<') {
 				intoken = true;
 				tokpos = 0;
@@ -53,20 +52,8 @@
 			}
 			if (*from == '>') {	// process tokens
 				intoken = false;
-								
-				/*XMLTag tag(token);
-				if ((!strcmp(tag.getName(), "w")) && (!tag.isEndTag())) {	// Lemma
-					SWBuf lemma = tag.getAttribute("lemma");
-					if (lemma.length()) {
-						tag.setAttribute("lemma", 0);
-					 	tag.setAttribute("savlm", lemma.c_str());
-					}
-				}
-				*/
 				
 				if ((*token == 'w') && (token[1] == ' ')) {
-// 					len = strlen(token);
-					
 					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
@@ -81,9 +68,6 @@
 					text.append(token);
 					text.append('>');
 				}
-				
-				// keep tag, possibly with the lemma removed
-				//text += tag;
 				
 				continue;
 			}

Index: osismorph.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osismorph.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- osismorph.cpp	9 Apr 2004 12:31:15 -0000	1.13
+++ osismorph.cpp	16 Apr 2004 20:10:34 -0000	1.14
@@ -42,9 +42,8 @@
 		//taken out of the loop for speed
 		const char* start = 0;
 		const char* end = 0;
-		int len = 0;
 
-		for (text = ""; *from; from++) {
+		for (text = ""; *from; ++from) {
 			if (*from == '<') {
 				intoken = true;
 				tokpos = 0;
@@ -54,22 +53,15 @@
 			if (*from == '>') {	// process tokens
 				intoken = false;
 				
-				/*XMLTag tag(token);
-				if ((!strcmp(tag.getName(), "w")) && (!tag.isEndTag())) {	// Morph
-					if (tag.getAttribute("morph"))
-						tag.setAttribute("morph", 0);
-				}*/
-				
 				if ((*token == 'w') && (token[1] == ' ')) {
-					len = strlen(token);
-					start = strstr(token, "morph=\""); //we leave out "w " at the start
+					start = strstr(token+2, "morph=\""); //we leave out "w " at the start
 					end = (start && (strlen(start)>7)) ? strchr(start+7, '"') : 0;
 
 					if (start && end) {
-						text.append("<");
+						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(">");
+						text.append(end+1, strlen(token)-(end+1 - token)); //text after the morph attr
+						text.append('>');
 					}
 				}
 				else {
@@ -78,8 +70,6 @@
 					text.append('>');
 				}
 				
-				// keep tag, possibly with the morph removed
-				//text.append(tag);
 				continue;
 			}
 			if (intoken) {

Index: osisplain.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisplain.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- osisplain.cpp	16 Apr 2004 11:25:56 -0000	1.19
+++ osisplain.cpp	16 Apr 2004 20:10:34 -0000	1.20
@@ -37,8 +37,8 @@
 	addEscapeStringSubstitute("quot", "\"");
 
         setTokenCaseSensitive(true);
-//        addTokenSubstitute("title", "\n");
-//        addTokenSubstitute("/title", "\n");
+        addTokenSubstitute("title", "\n");
+        addTokenSubstitute("/title", "\n");
         addTokenSubstitute("/l", "\n");
         addTokenSubstitute("lg", "\n");
         addTokenSubstitute("/lg", "\n");
@@ -74,8 +74,6 @@
 				buf.append(" <");
 				buf.append(val);
 				buf.append('>');
-				
-				//buf.appendFormatted(" <%s>", val);
 			}
 			if ((attrib = u->tag.getAttribute("gloss"))) {
 				val = strchr(attrib, ':');
@@ -83,8 +81,6 @@
 				buf.append(" <");
 				buf.append(val);
 				buf.append('>');
-
-// 				buf.appendFormatted(" <%s>", val);
 			}
 			if ((attrib = u->tag.getAttribute("lemma"))) {
 				int count = u->tag.getAttributePartCount("lemma");
@@ -102,8 +98,6 @@
 						buf.append(" {<");
 						buf.append(val);
 						buf.append(">}");
-
-// 						buf.appendFormatted(" <%s>}", val);
 					}
 				} while (++i < count);
 			}
@@ -120,7 +114,6 @@
 					buf.append(" (");
 					buf.append(val);
 					buf.append(')');
-// 					buf.appendFormatted(" (%s)", val);
 				} while (++i < count);
 			}
 			if ((attrib = u->tag.getAttribute("POS"))) {
@@ -130,7 +123,6 @@
 				buf.append(" <");
 				buf.append(val);
 				buf.append('>');
-// 				buf.appendFormatted(" <%s>", val);
 			}
 		}
 
@@ -143,7 +135,7 @@
 			}
 		else if (!strncmp(token, "/note", 5)) {
 			if (!u->suspendTextPassThru)
-				buf.append(")");
+				buf.append(')');
 			else	u->suspendTextPassThru = false;
 		}
 
@@ -156,10 +148,8 @@
 
                 // <milestone type="line"/>
                 else if (!strncmp(token, "milestone", 9)) {
-			const char* type = strstr(token+9, "type=\"");
+			const char* type = strstr(token+10, "type=\"");
 			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');
 			}