[sword-svn] r3309 - in trunk: . utilities

dmsmith at crosswire.org dmsmith at crosswire.org
Mon Dec 15 13:13:35 MST 2014


Author: dmsmith
Date: 2014-12-15 13:13:35 -0700 (Mon, 15 Dec 2014)
New Revision: 3309

Modified:
   trunk/ChangeLog
   trunk/utilities/osis2mod.cpp
Log:
MODTOOLS-55 osis2mod produces endless loop

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2014-12-15 15:20:53 UTC (rev 3308)
+++ trunk/ChangeLog	2014-12-15 20:13:35 UTC (rev 3309)
@@ -1,6 +1,9 @@
 API ChangeLog
 
 15-Dec-2014	DM Smith <dmsmith at crosswire.org>
+	Fixed endless loop in osis2mod for some inputs.
+
+15-Dec-2014	DM Smith <dmsmith at crosswire.org>
 	Added support for Psalm Book divisions using <div type=majorSection>
 	from GHellings
 

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2014-12-15 15:20:53 UTC (rev 3308)
+++ trunk/utilities/osis2mod.cpp	2014-12-15 20:13:35 UTC (rev 3309)
@@ -368,7 +368,7 @@
  * Determine whether a verse as given is valid for the versification.
  * This is done by comparing the before and after of normalization.
  */
-bool isValidRef(const char *buf) {
+bool isValidRef(const char *buf, const char *caller) {
 	// Create a VerseKey that does not do auto normalization
 	// Note: need to turn on headings so that a heading does not get normalized anyway
 	// And set it to the reference under question
@@ -399,7 +399,7 @@
 	// If we have gotten here the reference is not in the selected versification.
 	// cout << "INFO(V11N): " << before << " is not in the " << currentVerse.getVersificationSystem() << " versification." << endl;
 	if (debug & DEBUG_REV11N) {
-		cout << "DEBUG(V11N): " << before << " normalizes to "  << after << endl;
+		cout << "DEBUG(V11N)[" << caller << "]: " << before << " normalizes to "  << after << endl;
 	}
 
 	return false;
@@ -511,7 +511,7 @@
 	// If we have seen a verse and the supplied one is different then we output the collected one.
 	if (*activeOsisID && strcmp(activeOsisID, keyOsisID)) {
 
-		if (!isValidRef(lastKey)) {
+		if (!isValidRef(lastKey, "writeEntry")) {
 			makeValidRef(lastKey);
 		}
 
@@ -594,7 +594,7 @@
 void linkToEntry(VerseKey &linkKey, VerseKey &dest) {
 
 	// Only link verses that are in the versification.
-	if (!isValidRef(linkKey)) {
+	if (!isValidRef(linkKey, "linkToEntry")) {
 		return;
 	}
 
@@ -826,7 +826,7 @@
 				// This should never happen if the references are valid OSIS references
 				ListKey verseKeys = currentVerse.parseVerseList(keyVal, currentVerse, true);
 				int memberKeyCount = verseKeys.getCount();
-				if (memberKeyCount) {
+				if (memberKeyCount > 1) {
 					currentVerse = verseKeys.getElement(0);
 					// See if this osisID or annotateRef refers to more than one verse.
 					// If it does, save it until all verses have been seen.
@@ -836,6 +836,7 @@
 					verseKeys.setPosition(TOP);
 					verseKeys.increment(1);
 					if (!verseKeys.popError()) {
+					cout << "DEBUG(LINK): " << currentVerse.getOSISRef() << endl;
 						linkedVerses.push_back(verseKeys);
 					}
 				}
@@ -1333,8 +1334,8 @@
 
 		while (!verseKeys.popError()) {
 			linkKey = verseKeys.getElement();
+			linkToEntry(linkKey, destKey);
 			verseKeys.increment(1);
-			linkToEntry(linkKey, destKey);
 		}
 	}
 }




More information about the sword-cvs mailing list