[sword-svn] r2322 - in trunk: bindings/swig bindings/swig/package src/modules/common src/modules/filters utilities

scribe at crosswire.org scribe at crosswire.org
Sun Apr 12 18:34:44 MST 2009


Author: scribe
Date: 2009-04-12 18:34:44 -0700 (Sun, 12 Apr 2009)
New Revision: 2322

Modified:
   trunk/bindings/swig/package/Makefile.am
   trunk/bindings/swig/sword.i
   trunk/src/modules/common/rawstr.cpp
   trunk/src/modules/common/rawstr4.cpp
   trunk/src/modules/common/zstr.cpp
   trunk/src/modules/filters/osishtmlhref.cpp
   trunk/src/modules/filters/osisruby.cpp
   trunk/src/modules/filters/teihtmlhref.cpp
   trunk/utilities/osis2mod.cpp
Log:
Applied latest fixes from Ben


Modified: trunk/bindings/swig/package/Makefile.am
===================================================================
--- trunk/bindings/swig/package/Makefile.am	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/bindings/swig/package/Makefile.am	2009-04-13 01:34:44 UTC (rev 2322)
@@ -76,7 +76,7 @@
 
 pythonswig: sword.i
 	mkdir -p python
-	$(SWIG) -python -c++ -shadow -o python/Sword.cxx -I$(top_srcdir) $(SWORD_INCLUDES) $(top_srcdir)/sword.i
+	$(SWIG) -python -DEXCLUDE_FTP -c++ -shadow -o python/Sword.cxx -I$(top_srcdir) $(SWORD_INCLUDES) $(top_srcdir)/sword.i
 
 python_makebuild: $(PYTHONSWIG)
 	mkdir -p python

Modified: trunk/bindings/swig/sword.i
===================================================================
--- trunk/bindings/swig/sword.i	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/bindings/swig/sword.i	2009-04-13 01:34:44 UTC (rev 2322)
@@ -86,9 +86,10 @@
 %include "extras.i"
 %include "swlog.i"
 
+#ifndef EXCLUDE_FTP
 %include "ftptrans.i"
 
 #ifndef EXCLUDE_INSTALLMGR
 %include "installmgr.i"
 #endif
-
+#endif

Modified: trunk/src/modules/common/rawstr.cpp
===================================================================
--- trunk/src/modules/common/rawstr.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/common/rawstr.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -172,11 +172,12 @@
 	signed char retval = -1;
 	long headoff, tailoff, tryoff = 0, maxoff = 0;
 	int diff = 0;
+	bool awayFromSubstrCheck = false;	
 
 	if (idxfd->getFd() >=0) {
 		tailoff = maxoff = idxfd->seek(0, SEEK_END) - 6;
 		retval = (tailoff >= 0) ? 0 : -2;	// if NOT new file
-		if (*ikey) {
+		if (*ikey && retval != -2) {
 			headoff = 0;
 
 			stdstr(&key, ikey, 3);
@@ -220,6 +221,7 @@
 			if (headoff >= tailoff) {
 				tryoff = headoff;
 				if (!substr && ((tryoff != maxoff)||(strncmp(key, maxbuf, keylen)<0))) {
+					awayFromSubstrCheck = true;
 					away--;	// if our entry doesn't startwith our key, prefer the previous entry over the next
 				}
 			}
@@ -256,7 +258,8 @@
 			else if (idxfd->seek(tryoff, SEEK_SET) < 0)
 				bad = true;
 			if (bad) {
-				retval = -1;
+				if(!awayFromSubstrCheck)
+					retval = -1;
 				*start = laststart;
 				*size = lastsize;
 				tryoff = lasttry;

Modified: trunk/src/modules/common/rawstr4.cpp
===================================================================
--- trunk/src/modules/common/rawstr4.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/common/rawstr4.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -181,11 +181,13 @@
 	signed char retval = -1;
 	long headoff, tailoff, tryoff = 0, maxoff = 0;
 	int diff = 0;
+	bool awayFromSubstrCheck = false;
 
 	if (idxfd->getFd() >=0) {
 		tailoff = maxoff = idxfd->seek(0, SEEK_END) - 8;
+
 		retval = (tailoff >= 0) ? 0 : -2;	// if NOT new file
-		if (*ikey) {
+		if (*ikey && retval != -2) {
 			headoff = 0;
 
 			stdstr(&key, ikey, 3);
@@ -229,6 +231,7 @@
 			if (headoff >= tailoff) {
 				tryoff = headoff;
 				if (!substr && ((tryoff != maxoff)||(strncmp(key, maxbuf, keylen)<0))) {
+					awayFromSubstrCheck = true;
 					away--;	// if our entry doesn't startwith our key, prefer the previous entry over the next
 				}
 			}
@@ -264,7 +267,8 @@
 			else if (idxfd->seek(tryoff, SEEK_SET) < 0)
 				bad = true;
 			if (bad) {
-				retval = -1;
+				if(!awayFromSubstrCheck)
+					retval = -1;
 				*start = laststart;
 				*size = lastsize;
 				tryoff = lasttry;

Modified: trunk/src/modules/common/zstr.cpp
===================================================================
--- trunk/src/modules/common/zstr.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/common/zstr.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -194,6 +194,7 @@
 	__s32 headoff, tailoff, tryoff = 0, maxoff = 0;
 	__u32 start, size;
 	int diff = 0;
+	bool awayFromSubstrCheck = false;
 
 	if (idxfd->getFd() >= 0) {
 		tailoff = maxoff = idxfd->seek(0, SEEK_END) - IDXENTRYSIZE;
@@ -240,6 +241,7 @@
 			if (headoff >= tailoff) {
 				tryoff = headoff;
 				if (!substr && ((tryoff != maxoff)||(strncmp(key, maxbuf, keylen)<0))) {
+					awayFromSubstrCheck = true;
 					away--;	// if our entry doesn't startwith our key, prefer the previous entry over the next
 				}
 			}
@@ -274,7 +276,8 @@
 			else	if (idxfd->seek(tryoff, SEEK_SET) < 0)
 				bad = true;
 			if (bad) {
-				retval = -1;
+				if(!awayFromSubstrCheck)
+					retval = -1;
 				start = laststart;
 				size = lastsize;
 				tryoff = lasttry;

Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/filters/osishtmlhref.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -196,8 +196,9 @@
 				if ((attrib = tag.getAttribute("gloss"))) {
 					val = strchr(attrib, ':');
 					val = (val) ? (val + 1) : attrib;
-					outText(" ", buf, u);
+					outText("(", buf, u);
 					outText(val, buf, u);
+					outText(")", buf, u);
 				}
 				if (!morphFirst) {
 					processLemma(u->suspendTextPassThru, tag, buf);
@@ -289,46 +290,53 @@
 		// <reference> tag
 		else if (!strcmp(tag.getName(), "reference")) {	
 			if (!u->inXRefNote) {	// only show these if we're not in an xref note				
-				if ((!tag.isEndTag()) && (!tag.isEmpty())) {
-					u->suspendTextPassThru = (++u->suspendLevel);
-				}
-				if (tag.isEndTag()) {
-					if (!u->BiblicalText) {
-						SWBuf refList = tag.getAttribute("passage");
-						if (!refList.length())
-							refList = u->lastTextNode;
-						SWBuf version = tag.getAttribute("version");
-						
-						buf.appendFormatted("&nbsp;<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
-							(refList.length()) ? URL::encode(refList.c_str()).c_str() : "", 
-							(version.length()) ? URL::encode(version.c_str()).c_str() : "");
-						buf += u->lastTextNode.c_str();
-						buf += "</a>&nbsp;";
+				if (!tag.isEndTag()) {
+					SWBuf target;
+					SWBuf work;
+					SWBuf ref;
+					bool is_scripRef = false;
+
+					target = tag.getAttribute("osisRef");
+					const char* the_ref = strchr(target, ':');
+					
+					if(!the_ref) {
+						// No work
+						ref = target;
+						is_scripRef = true;
 					}
 					else {
-						SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
-						VerseKey *vkey = NULL;
-						// see if we have a VerseKey * or descendant
-						SWTRY {
-							vkey = SWDYNAMIC_CAST(VerseKey, u->key);
-						}
-						SWCATCH ( ... ) {}
-						if (vkey) {
-							// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
-							//buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
-							buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup>*x</sup></small></a>",
-								URL::encode(footnoteNumber.c_str()).c_str(), 
-								URL::encode(u->version.c_str()).c_str(),
-								URL::encode(vkey->getText()).c_str());
-						
-						}
+						// Compensate for starting :
+						ref = the_ref + 1;
+
+						int size = target.size() - ref.size() - 1;
+						work.setSize(size);
+						strncpy(work.getRawData(), target, size);
+
+						// For Bible:Gen.3.15 or Bible.vulgate:Gen.3.15
+						if(!strncmp(work, "Bible", 5))
+							is_scripRef = true;
 					}
-					u->suspendTextPassThru = (--u->suspendLevel);
+
+					if(is_scripRef)
+					{
+						buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=\">",
+							URL::encode(ref.c_str()).c_str()
+//							(work.size()) ? URL::encode(work.c_str()).c_str() : "")
+							);
+					}
+					else
+					{
+						// Dictionary link, or something
+						buf.appendFormatted("<a href=\"sword://%s/%s\">",
+							URL::encode(work.c_str()).c_str(),
+							URL::encode(ref.c_str()).c_str()
+							);
+					}
 				}
-			}/*
-			if (tag.isEndTag()) {
-				u->suspendTextPassThru = false;
-			}*/
+				else {
+					outText("</a>", buf, u);
+				}
+			}
 		}
 
 		// <l> poetry, etc

Modified: trunk/src/modules/filters/osisruby.cpp
===================================================================
--- trunk/src/modules/filters/osisruby.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/filters/osisruby.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -60,15 +60,15 @@
 				intoken = false;
 				if (token.startsWith("w ")) {	// Word
 					XMLTag wtag(token);
-					int count = wtag.getAttributePartCount("gloss", ' ');
-					for (int i = 0; i < count; i++) {
-						SWBuf a = wtag.getAttribute("gloss", i, ' ');
+					const char *l = wtag.getAttribute("gloss");
+					if (l) {
+						wtag.setAttribute("gloss", 0);
+						token = wtag;
+						token.trim();
+						// drop <>
+						token << 1;
+						token--;
 					}
-					token = wtag;
-					token.trim();
-					// drop <>
-					token << 1;
-					token--;
 				}
 				
 				// keep token in text

Modified: trunk/src/modules/filters/teihtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/teihtmlhref.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/src/modules/filters/teihtmlhref.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -26,6 +26,7 @@
 #include <utilxml.h>
 #include <swmodule.h>
 #include <url.h>
+#include <iostream>
 
 
 SWORD_NAMESPACE_START
@@ -143,8 +144,8 @@
 				 !strcmp(tag.getName(), "case") || 
 				 !strcmp(tag.getName(), "gram") || 
 				 !strcmp(tag.getName(), "number") || 
-				 !strcmp(tag.getName(), "pron") ||
-				 !strcmp(tag.getName(), "def")) {
+				 !strcmp(tag.getName(), "pron") /*||
+				 !strcmp(tag.getName(), "def")*/) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
 				buf += "<i>";
 			}
@@ -178,7 +179,68 @@
 				 !strcmp(tag.getName(), "usg")) {
 			// do nothing here
 		}
+		else if (!strcmp(tag.getName(), "ref")) {
+			if (!tag.isEndTag()) {
+				u->suspendTextPassThru = true;
+				SWBuf target;
+				SWBuf work;
+				SWBuf ref;
 
+				int was_osisref = false;
+				if(tag.getAttribute("osisRef"))
+				{
+					target += tag.getAttribute("osisRef");
+					was_osisref=true;
+				}
+				else if(tag.getAttribute("target"))
+					target += tag.getAttribute("target");
+
+				if(target.size())
+				{
+					const char* the_ref = strchr(target, ':');
+					
+					if(!the_ref) {
+						// No work
+						ref = target;
+					}
+					else {
+						// Compensate for starting :
+						ref = the_ref + 1;
+
+						int size = target.size() - ref.size() - 1;
+						work.setSize(size);
+						strncpy(work.getRawData(), target, size);
+					}
+
+					if(was_osisref)
+					{
+						buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
+							(ref) ? URL::encode(ref.c_str()).c_str() : "", 
+							(work.size()) ? URL::encode(work.c_str()).c_str() : "");
+					}
+					else
+					{
+						// Dictionary link, or something
+						buf.appendFormatted("<a href=\"sword://%s/%s\">",
+							(work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
+							(ref) ? URL::encode(ref.c_str()).c_str() : ""							
+							);
+					}
+				}
+				else
+				{
+					//std::cout << "TARGET WASN'T\n";
+				}
+				
+			}
+			else {
+				buf += u->lastTextNode.c_str();
+				buf += "</a>";
+				
+				u->suspendTextPassThru = false;
+			}
+		}
+
 	   	// <note> tag
 		else if (!strcmp(tag.getName(), "note")) {
 			if (!tag.isEndTag()) {

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2009-04-13 01:17:00 UTC (rev 2321)
+++ trunk/utilities/osis2mod.cpp	2009-04-13 01:34:44 UTC (rev 2322)
@@ -609,7 +609,7 @@
 		inTitle = false;
 		titleDepth = 0;
 #ifdef DEBUG_STACK
-		cout << currentOsisID << ": pop(" << tagStack.size() << ") " << tagStack.top()->getName() << endl;
+		cout << currentOsisID << ": pop(" << tagStack.size() << ") " << tagStack.top().getName() << endl;
 #endif
 		tagStack.pop();
 		return false; // don't add </title> to the text itself
@@ -833,7 +833,12 @@
 			if (!strcmp(tokenName, "div") ||
 			    !strcmp(tokenName, "q")   ||
 			    !strcmp(tokenName, "l")   ||
-			    !strcmp(tokenName, "lb")  ||
+			    (!strcmp(tokenName, "lb") 
+				 	// If these were paragraphs, don't wrest them from their
+					// rightful place in the preverse text
+				 	&& strcmp("x-begin-paragraph", token.getAttribute("type"))
+					&& strcmp("x-end-paragraph", token.getAttribute("type"))
+				) ||
 			    !strcmp(tokenName, "lg")
 			   ) {
 #ifdef DEBUG




More information about the sword-cvs mailing list