[sword-cvs] sword/src/modules/filters osisosis.cpp,NONE,1.1 Makefile.am,1.24,1.25 gbfosis.cpp,1.20,1.21

sword@www.crosswire.org sword@www.crosswire.org
Sat, 13 Mar 2004 20:39:56 -0700


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

Modified Files:
	Makefile.am gbfosis.cpp 
Added Files:
	osisosis.cpp 
Log Message:
Updated to basic osis 2.5 support


--- NEW FILE: osisosis.cpp ---
/***************************************************************************
                     osisosis.cpp  -  internal OSIS to public OSIS filter
                             -------------------
    begin                : 2004-03-13
    copyright            : 2003 by CrossWire Bible Society
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation version 2 of the License.
 *                                                                         *
 ***************************************************************************/

#include <stdlib.h>
#include <osisosis.h>
#include <utilxml.h>
#include <versekey.h>
#include <swmodule.h>

SWORD_NAMESPACE_START


OSISOSIS::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
	osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
}


OSISOSIS::OSISOSIS() {
	setTokenStart("<");
	setTokenEnd(">");

	setEscapeStart("&");
	setEscapeEnd(";");

	setEscapeStringCaseSensitive(true);
	setTokenCaseSensitive(true);
}


bool OSISOSIS::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
	if (!substituteToken(buf, token)) {
		MyUserData *u = (MyUserData *)userData;
		XMLTag tag(token);

		if (!tag.isEmpty() && (!tag.isEndTag()))
			u->startTag = tag;

		// <w> tag
		if (!strcmp(tag.getName(), "w")) {

			// start <w> tag
			if ((!tag.isEmpty()) && (!tag.isEndTag())) {
				SWBuf attr = tag.getAttribute("lemma");
				if (attr.length()) {
					if (!strncmp(attr.c_str(), "x-Strongs:", 10)) {
						memcpy(attr.getRawData()+3, "strong", 6);
						attr << 3;
						tag.setAttribute("lemma", attr);
					}
				}
				attr = tag.getAttribute("morph");
				if (attr.length()) {
					if (!strncmp(attr.c_str(), "x-StrongsMorph:", 15)) {
						memcpy(attr.getRawData()+3, "strong", 6);
						attr << 3;
						tag.setAttribute("lemma", attr);
					}
					if (!strncmp(attr.c_str(), "x-Robinson:", 11)) {
						attr[2] = 'r';
						attr << 2;
						tag.setAttribute("lemma", attr);
					}
				}
			}

			tag.setAttribute("wn", 0);
			buf += tag;
		}

		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				if (!tag.isEmpty()) {
					SWBuf type = tag.getAttribute("type");

					if (type != "strongsMarkup") {
						buf += tag;
					}
					else u->suspendTextPassThru = true;
				}
			}
			if (tag.isEndTag()) {
				if (u->suspendTextPassThru == false)
					buf+=tag;
				else u->suspendTextPassThru = false;
			}
		}

		else {
		      return false;  // we still didn't handle token
		}
	}
	return true;
}


SWORD_NAMESPACE_END

Index: Makefile.am
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/Makefile.am,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Makefile.am	24 Oct 2003 02:43:46 -0000	1.24
+++ Makefile.am	14 Mar 2004 03:39:54 -0000	1.25
@@ -46,6 +46,7 @@
 libsword_la_SOURCES += $(filtersdir)/osisstrongs.cpp
 libsword_la_SOURCES += $(filtersdir)/osisplain.cpp
 libsword_la_SOURCES += $(filtersdir)/osisrtf.cpp
+libsword_la_SOURCES += $(filtersdir)/osisosis.cpp
 libsword_la_SOURCES += $(filtersdir)/osislemma.cpp
 libsword_la_SOURCES += $(filtersdir)/osisredletterwords.cpp
 libsword_la_SOURCES += $(filtersdir)/osisscripref.cpp

Index: gbfosis.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/gbfosis.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- gbfosis.cpp	29 Feb 2004 23:27:39 -0000	1.20
+++ gbfosis.cpp	14 Mar 2004 03:39:54 -0000	1.21
@@ -150,6 +150,20 @@
 				lastspace = false;
 				handled = true;
 			}
+			// less than
+			if (!strcmp(token, "CT")) {
+				text += "&lt;";
+				newText = true;
+				lastspace = false;
+				handled = true;
+			}
+			// greater than
+			if (!strcmp(token, "CG")) {
+				text += "&gt;";
+				newText = true;
+				lastspace = false;
+				handled = true;
+			}
 			// Paragraph break.  For now use empty paragraph element
 			if (!strcmp(token, "CM")) {
 				text += "<milestone type=\"x-p\" />";
@@ -201,13 +215,13 @@
 							attStart += 7;
 							
 							buf = "";
-							buf.appendFormatted("x-Strongs:%s|", value.c_str());
+							buf.appendFormatted("strong:%s ", value.c_str());
 						}
 						else { // no lemma attribute
 							attStart = wordStart + 3;
 							
 							buf = "";
-							buf.appendFormatted(buf, "lemma=\"x-Strongs:%s\" ", value.c_str());
+							buf.appendFormatted(buf, "lemma=\"strong:%s\" ", value.c_str());
 						}
 
 						text.insert(attStart - text.c_str(), buf);
@@ -215,13 +229,13 @@
 					else { //wordStart doesn't point to an existing <w> attribute!
 						if (!strcmp(value.c_str(), "H03068")) {	//divineName
 							buf = "";
-							buf.appendFormatted("<divineName><w lemma=\"x-Strongs:%s\">", value.c_str());
+							buf.appendFormatted("<divineName><w lemma=\"strong:%s\">", value.c_str());
 							
 							divineName = true;
 						}
 						else {
 							buf = "";
-							buf.appendFormatted("<w lemma=\"x-Strongs:%s\">", value.c_str());
+							buf.appendFormatted("<w lemma=\"strong:%s\">", value.c_str());
 						}
 
 						text.insert(wordStart - text.c_str(), buf);
@@ -248,19 +262,19 @@
 					if (attStart) { //existing morph attribute, append this one to it
 						attStart += 7;
 						buf = "";
-						buf.appendFormatted("x-%s:%s|", "StrongsMorph", value.c_str());
+						buf.appendFormatted("%s:%s ", "strongsMorph", value.c_str());
 					}
 					else {
 						attStart = wordStart + 3;
 						buf = "";
-						buf.appendFormatted("morph=\"x-%s:%s\" ", "StrongsMorph", value.c_str());
+						buf.appendFormatted("morph=\"%s:%s\" ", "strongsMorph", value.c_str());
 					}
 					
 					text.insert(attStart - text.c_str(), buf); //hack, we have to
 				}
 				else { //no existing <w> attribute fond
 					buf = "";
-					buf.appendFormatted("<w morph=\"x-%s:%s\">", "StrongsMorph", value.c_str());
+					buf.appendFormatted("<w morph=\"%s:%s\">", "strongsMorph", value.c_str());
 					
 					text.insert(wordStart - text.c_str(), buf);