[sword-svn] r3313 - in branches/sword-1-7-x: . utilities

greg.hellings at crosswire.org greg.hellings at crosswire.org
Tue Dec 23 23:09:55 MST 2014


Author: greg.hellings
Date: 2014-12-23 23:09:55 -0700 (Tue, 23 Dec 2014)
New Revision: 3313

Modified:
   branches/sword-1-7-x/ChangeLog
   branches/sword-1-7-x/utilities/osis2mod.cpp
Log:
MODTOOLS-55 osis2mod produces endless loop

Modified: branches/sword-1-7-x/ChangeLog
===================================================================
--- branches/sword-1-7-x/ChangeLog	2014-12-24 06:07:25 UTC (rev 3312)
+++ branches/sword-1-7-x/ChangeLog	2014-12-24 06:09:55 UTC (rev 3313)
@@ -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: branches/sword-1-7-x/utilities/osis2mod.cpp
===================================================================
--- branches/sword-1-7-x/utilities/osis2mod.cpp	2014-12-24 06:07:25 UTC (rev 3312)
+++ branches/sword-1-7-x/utilities/osis2mod.cpp	2014-12-24 06:09:55 UTC (rev 3313)
@@ -351,7 +351,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
@@ -382,7 +382,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;
@@ -494,7 +494,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);
 		}
 
@@ -563,7 +563,7 @@
 void linkToEntry(VerseKey &linkKey, VerseKey &dest) {
 
 	// Only link verses that are in the versification.
-	if (!isValidRef(linkKey)) {
+	if (!isValidRef(linkKey, "linkToEntry")) {
 		return;
 	}
 
@@ -795,7 +795,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.
@@ -805,6 +805,7 @@
 					verseKeys.setPosition(TOP);
 					verseKeys.increment(1);
 					if (!verseKeys.popError()) {
+					cout << "DEBUG(LINK): " << currentVerse.getOSISRef() << endl;
 						linkedVerses.push_back(verseKeys);
 					}
 				}
@@ -1302,8 +1303,8 @@
 
 		while (!verseKeys.popError()) {
 			linkKey = verseKeys.getElement();
+			linkToEntry(linkKey, destKey);
 			verseKeys.increment(1);
-			linkToEntry(linkKey, destKey);
 		}
 	}
 }




More information about the sword-cvs mailing list