[sword-svn] r2179 - in trunk: include src/keys
scribe at www.crosswire.org
scribe at www.crosswire.org
Fri Jun 20 11:11:42 MST 2008
Author: scribe
Date: 2008-06-20 11:11:41 -0700 (Fri, 20 Jun 2008)
New Revision: 2179
Modified:
trunk/include/versekey.h
trunk/src/keys/versekey.cpp
trunk/src/keys/versetreekey.cpp
Log:
versekey testsuite now passes again
Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h 2008-06-20 15:10:47 UTC (rev 2178)
+++ trunk/include/versekey.h 2008-06-20 18:11:41 UTC (rev 2179)
@@ -269,6 +269,10 @@
*/
virtual void copyFrom(const VerseKey &ikey);
+ /** Only repositions this VerseKey to another VerseKey
+ */
+ virtual void positionFrom(const VerseKey &ikey);
+
/** Positions this key
*
* @param newpos Position to set to.
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2008-06-20 15:10:47 UTC (rev 2178)
+++ trunk/src/keys/versekey.cpp 2008-06-20 18:11:41 UTC (rev 2179)
@@ -105,6 +105,29 @@
/******************************************************************************
+ * VerseKey::positionFrom - Positions this VerseKey to another VerseKey
+ */
+
+void VerseKey::positionFrom(const VerseKey &ikey) {
+ error = 0;
+ testament = ikey.Testament();
+ book = ikey.Book();
+ chapter = ikey.Chapter();
+ verse = ikey.Verse();
+ suffix = ikey.getSuffix();
+ // should we always perform bounds checks? Tried but seems to cause infinite recursion
+ if (_compare(UpperBound()) > 0) {
+ positionFrom(UpperBound());
+ error = KEYERR_OUTOFBOUNDS;
+ }
+ if (_compare(LowerBound()) < 0) {
+ positionFrom(LowerBound());
+ error = KEYERR_OUTOFBOUNDS;
+ }
+}
+
+
+/******************************************************************************
* VerseKey::copyFrom - Equates this VerseKey to another VerseKey
*/
@@ -303,7 +326,9 @@
if (keytext) {
ListKey tmpListKey = VerseKey::ParseVerseList(keytext);
if (tmpListKey.Count()) {
- (*this) = tmpListKey.getElement(0);
+
+ this->positionFrom(tmpListKey.getElement(0));
+ error = this->error;
/*
SWKey::setText((const char *)tmpListKey);
for (int i = 1; i < 3; i++) {
@@ -581,7 +606,12 @@
curKey.Book(lastKey.Book());
}
else {
- curKey.Testament(1);
+ int t = 1;
+ if (bookno > BMAX[0]) {
+ t++;
+ bookno -= BMAX[0];
+ }
+ curKey.Testament(t);
curKey.Book(bookno);
}
@@ -784,7 +814,12 @@
curKey.Book(lastKey.Book());
}
else {
- curKey.Testament(1);
+ int t = 1;
+ if (bookno > BMAX[0]) {
+ t++;
+ bookno -= BMAX[0];
+ }
+ curKey.Testament(t);
curKey.Book(bookno);
}
@@ -1115,11 +1150,11 @@
void VerseKey::Normalize(char autocheck)
{
- error = 0;
if (((!autocheck) || (autonorm)) // only normalize if we were explicitely called or if autonorm is turned on
&&
((!headings) || ((verse) && (chapter)))) { // this is cheeze and temporary until deciding what actions should be taken; so headings should only be turned on when positioning with Index() or incrementors
+ error = 0;
while ((testament < 3) && (testament > 0)) {
@@ -1197,11 +1232,11 @@
// should we always perform bounds checks? Tried but seems to cause infinite recursion
if (_compare(UpperBound()) > 0) {
- copyFrom(UpperBound());
+ positionFrom(UpperBound());
error = KEYERR_OUTOFBOUNDS;
}
if (_compare(LowerBound()) < 0) {
- copyFrom(LowerBound());
+ positionFrom(LowerBound());
error = KEYERR_OUTOFBOUNDS;
}
}
Modified: trunk/src/keys/versetreekey.cpp
===================================================================
--- trunk/src/keys/versetreekey.cpp 2008-06-20 15:10:47 UTC (rev 2178)
+++ trunk/src/keys/versetreekey.cpp 2008-06-20 18:11:41 UTC (rev 2179)
@@ -183,15 +183,18 @@
switch (p) {
case POS_TOP:
+ Error();
treeKey->setPosition(p);
- treeKey->increment();
- treeKey->decrement();
- treeKey->Error();
+ increment();
+ decrement();
+ Error();
+ break;
case POS_BOTTOM:
+ Error();
treeKey->setPosition(p);
- treeKey->decrement();
- treeKey->increment();
- treeKey->Error();
+ decrement();
+ increment();
+ Error();
break;
case POS_MAXVERSE:
case POS_MAXCHAPTER:
More information about the sword-cvs
mailing list