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

scribe at crosswire.org scribe at crosswire.org
Tue May 12 22:02:34 MST 2009


Author: scribe
Date: 2009-05-12 22:02:34 -0700 (Tue, 12 May 2009)
New Revision: 2402

Modified:
   trunk/src/keys/versekey.cpp
   trunk/tests/testsuite/versekeytest.good
   trunk/tests/versekeytest.cpp
Log:
fixed chapter-- logic when going to previous book


Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2009-05-13 03:30:03 UTC (rev 2401)
+++ trunk/src/keys/versekey.cpp	2009-05-13 05:02:34 UTC (rev 2402)
@@ -1235,17 +1235,19 @@
                     continue;
                }
 
-               if (chapter < 1) {
-                    if (--book > 0) {
-                         chapter += getChapterMax();
-                    }
-                    else	{
-                         if (testament > 1) {
-						chapter += refSys->getBook(BMAX[0]-1)->getChapterMax();
-                         }
-                    }
-                    continue;
-               }
+		if (chapter < 1) {
+			if (--book > 0) {
+				chapter += getChapterMax();
+				verse = getVerseMax();
+			}
+			else {
+				if (testament > 1) {
+					chapter += refSys->getBook(BMAX[0]-1)->getChapterMax();
+					verse = refSys->getBook(BMAX[0]-1)->getVerseMax(chapter);
+				}
+			}
+			continue;
+		}
 
                if (verse > getVerseMax()) { // -1 because e.g chapter 1 of Matthew is books[1][0].versemax[0]
                     verse -= getVerseMax();
@@ -1379,7 +1381,7 @@
 
 void VerseKey::setBook(char ibook)
 {
-	Chapter(ibook ? 1 : 0);
+	chapter = ibook ? 1 : 0;
 	book = ibook;
 	Normalize(1);
 }
@@ -1415,7 +1417,7 @@
 
 void VerseKey::setChapter(int ichapter)
 {
-	Verse(ichapter ? 1 : 0);
+	verse = ichapter ? 1 : 0;
 	chapter = ichapter;
 	Normalize(1);
 }

Modified: trunk/tests/testsuite/versekeytest.good
===================================================================
--- trunk/tests/testsuite/versekeytest.good	2009-05-13 03:30:03 UTC (rev 2401)
+++ trunk/tests/testsuite/versekeytest.good	2009-05-13 05:02:34 UTC (rev 2402)
@@ -39,3 +39,5 @@
 TOP: Genesis 1:1
 BOTTOM: Revelation of John 22:21
 John 3:16: 0
+I Samuel 1:1: Chapter() - 1: Ruth 4:22
+

Modified: trunk/tests/versekeytest.cpp
===================================================================
--- trunk/tests/versekeytest.cpp	2009-05-13 03:30:03 UTC (rev 2401)
+++ trunk/tests/versekeytest.cpp	2009-05-13 05:02:34 UTC (rev 2402)
@@ -210,5 +210,15 @@
 	VerseKey yo2 = yo++;
 	cout << yo2 << ": " << (int)yo2.Error() <<  endl;
 
+	VerseKey vkey;
+	VerseKey tmpkey = "1sam 1:1";
+	vkey.AutoNormalize(1);                          // line 147
+	vkey = tmpkey;
+	int chapter = (vkey.Chapter()-1);
+	vkey.Chapter(chapter);
+
+	cout << tmpkey << ": Chapter() - 1: " << vkey << endl;
+
+
 	return 0;
 }




More information about the sword-cvs mailing list