[sword-svn] r2253 - in trunk: include src/keys tests tests/testsuite

scribe at crosswire.org scribe at crosswire.org
Sat Feb 14 17:40:48 MST 2009


Author: scribe
Date: 2009-02-14 17:40:48 -0700 (Sat, 14 Feb 2009)
New Revision: 2253

Modified:
   trunk/include/versekey.h
   trunk/src/keys/versekey.cpp
   trunk/tests/testsuite/versekey.good
   trunk/tests/versekeytest.cpp
Log:
changed some areas of possible recursion.
fixed error set when key is out of bound
all regression tests pass again


Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2009-02-14 09:53:56 UTC (rev 2252)
+++ trunk/include/versekey.h	2009-02-15 00:40:48 UTC (rev 2253)
@@ -106,6 +106,9 @@
 	// bounds caching is mutable, thus const
 	void initBounds() const;
 
+	// private with no bounds check
+	void setFromOther(const VerseKey &vk);
+
 	/** Binary search to find the index closest, but less
 	* than the given value.
 	*

Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2009-02-14 09:53:56 UTC (rev 2252)
+++ trunk/src/keys/versekey.cpp	2009-02-15 00:40:48 UTC (rev 2253)
@@ -121,20 +121,25 @@
  * VerseKey::positionFrom - Positions this VerseKey to another VerseKey
  */
 
-void VerseKey::positionFrom(const VerseKey &ikey) {
-	error = 0;
+void VerseKey::setFromOther(const VerseKey &ikey) {
 	testament = ikey.Testament();
 	book = ikey.Book();
 	chapter = ikey.Chapter();
 	verse = ikey.Verse();
 	suffix = ikey.getSuffix();
+}
+
+
+void VerseKey::positionFrom(const VerseKey &ikey) {
+	error = 0;
+	setFromOther(ikey);
 	// should we always perform bounds checks?  Tried but seems to cause infinite recursion
 	if (_compare(UpperBound()) > 0) {
-		positionFrom(UpperBound());
+		setFromOther(UpperBound());
 		error = KEYERR_OUTOFBOUNDS;
 	}
 	if (_compare(LowerBound()) < 0) {
-		positionFrom(LowerBound());
+		setFromOther(LowerBound());
 		error = KEYERR_OUTOFBOUNDS;
 	}
 }
@@ -467,6 +472,8 @@
 
 	VerseKey *curKey  = (VerseKey *)this->clone();
 	VerseKey *lastKey = (VerseKey *)this->clone();
+	lastKey->ClearBounds();
+	curKey->ClearBounds();
 
 	// some silly checks for corner cases
 	if (!strcmp(buf, "[ Module Heading ]")) {
@@ -958,8 +965,8 @@
 {
 	delete tmpClone;
 	tmpClone = 0;
+	boundSet = false;
 	initBounds();
-	boundSet = false;
 }
 
 

Modified: trunk/tests/testsuite/versekey.good
===================================================================
--- trunk/tests/testsuite/versekey.good	2009-02-14 09:53:56 UTC (rev 2252)
+++ trunk/tests/testsuite/versekey.good	2009-02-15 00:40:48 UTC (rev 2253)
@@ -1,5 +1,5 @@
 x: Amos 1:5
 Amos 1:5
 Amos 1:5
-Error: 1
-Error: 1
+Error: 1: Luke 1:1
+Error: 1: Luke 1:1

Modified: trunk/tests/versekeytest.cpp
===================================================================
--- trunk/tests/versekeytest.cpp	2009-02-14 09:53:56 UTC (rev 2252)
+++ trunk/tests/versekeytest.cpp	2009-02-15 00:40:48 UTC (rev 2253)
@@ -74,9 +74,9 @@
      VerseKey boundTest("lk", "acts");
 
      boundTest.setText("Is.1.13");
-     std::cout << "Error: " << (int)boundTest.Error() << "\n";
+     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
      boundTest.setText("1Sam.21.1");
-     std::cout << "Error: " << (int)boundTest.Error() << "\n";
+     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
 
 
      *x = "Is.1.13";




More information about the sword-cvs mailing list