[sword-cvs] sword/src/modules/filters osisstrongs.cpp,1.10,1.11

sword@www.crosswire.org sword@www.crosswire.org
Thu, 19 Feb 2004 04:53:53 -0700


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

Modified Files:
	osisstrongs.cpp 
Log Message:
Fix to make the OSISStrongs filter work, it displayed the text of the previous tag instaead of the current one in the EntryAttributes; Morph filtering is still buggy with NASB --joachim

Index: osisstrongs.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osisstrongs.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- osisstrongs.cpp	31 Jan 2004 00:09:31 -0000	1.10
+++ osisstrongs.cpp	19 Feb 2004 11:53:51 -0000	1.11
@@ -44,9 +44,6 @@
 	char wordstr[5];
 	char *valto;
 	char *ch;
-	unsigned int textStart = 0, textEnd = 0;
-	bool newText = false;
-	SWBuf tmp;
 
 	SWBuf orig = text;
 	from = orig.c_str();
@@ -60,7 +57,7 @@
 			token[0] = 0;
 			token[1] = 0;
 			token[2] = 0;
-			textEnd = text.size();
+			//textEnd = text.size();
 			continue;
 		}
 		if (*from == '>') {	// process tokens
@@ -68,19 +65,37 @@
 			if ((*token == 'w') && (token[1] == ' ')) {	// Word
 				if (module->isProcessEntryAttributes()) {
 					valto = val;
-					char *num = strstr(token, "lemma=\"x-Strongs:");
+					char *num = strstr(token, "lemma=\"x-Strongs:");					
+					int strongMarkerLength = 17;
+					if (!num) { //try alternative strong marker value
+						num = strstr(token, "lemma=\"strong:");
+						strongMarkerLength = 14;
+					}
+
 					if (num) {
-						for (num+=17; ((*num) && (*num != '\"')); num++)
+						for (num+=strongMarkerLength; ((*num) && (*num != '\"')); num++) {
 							*valto++ = *num;
+						}
 						*valto = 0;
+						
 						if (atoi((!isdigit(*val))?val+1:val) < 5627) {
 							// normal strongs number
 							sprintf(wordstr, "%03d", word++);
 							module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
-							tmp = "";
-							tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
-							module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
-							newText = true;
+							
+							//now try to find the end tag to get the text between <w> and </w> to set the entry attribute
+							
+							char* startTagEnd = index(from, '>'); //end of the opening tag
+							if (startTagEnd) {
+								startTagEnd++;
+								
+								char* endTagStart = strstr(startTagEnd, "</w>"); //end of the opening tag
+								if (endTagStart) {
+									SWBuf tmp;
+									tmp.append(startTagEnd, endTagStart - startTagEnd);
+									module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
+								}
+							}
 						}
 						else {
 							// verb morph
@@ -88,28 +103,6 @@
 							module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
 						}
 					}
-					else {
-						num = strstr(token, "lemma=\"strong:");
-						if (num) {
-							for (num+=14; ((*num) && (*num != '\"')); num++)
-								*valto++ = *num;
-							*valto = 0;
-							if (atoi((!isdigit(*val))?val+1:val) < 5627) {
-								// normal strongs number
-								sprintf(wordstr, "%03d", word++);
-								module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
-								tmp = "";
-								tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
-								module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
-								newText = true;
-							}
-							else {
-								// verb morph
-								sprintf(wordstr, "%03d", word-1);
-								module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
-							}
-						}
-					}
 				}
 				if (!option) {
 					char *num = strstr(token, "lemma=\"x-Strongs:");
@@ -117,7 +110,7 @@
 						memcpy(num, "savlm", 5);
 					}
 					else {
-						char *num = strstr(token, "lemma=\"strong:");
+						num = strstr(token, "lemma=\"strong:");
 						if (num) {
 							memcpy(num, "savlm", 5);
 						}
@@ -126,10 +119,11 @@
 			}
 			// if not a strongs token, keep token in text
 			text += '<';
-			for (char *tok = token; *tok; tok++)
+			for (char *tok = token; *tok; tok++) {
 				text += *tok;
+			}
 			text += '>';
-			if (newText) {textStart = text.size(); newText = false; }
+			
 			continue;
 		}
 		if (intoken) {