[sword-svn] r2188 - in trunk: . src/keys src/mgr tests/testsuite

scribe at www.crosswire.org scribe at www.crosswire.org
Tue Jul 22 08:08:05 MST 2008


Author: scribe
Date: 2008-07-22 08:08:04 -0700 (Tue, 22 Jul 2008)
New Revision: 2188

Modified:
   trunk/src/keys/versekey.cpp
   trunk/src/mgr/versemgr.cpp
   trunk/tests/testsuite/verseparsing-utf8.good
   trunk/usrinst.sh
Log:
added some error checking
fixed verse parsing to again handle preceding digit on book name (1jn)
all testsuite tests pass again


Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2008-07-22 11:00:16 UTC (rev 2187)
+++ trunk/src/keys/versekey.cpp	2008-07-22 15:08:04 UTC (rev 2188)
@@ -672,8 +672,8 @@
 					break;
 				default:
 					// suffixes (and oddly 'f'-- ff.)
-					if (*buf >= 'a' && *buf <= 'z') {
-						if (chap >=0) suffix = *buf;
+					if ((*buf >= 'a' && *buf <= 'z') && (chap >=0)) {
+						suffix = *buf;
 					}
 					else {
 						number[tonumber] = 0;

Modified: trunk/src/mgr/versemgr.cpp
===================================================================
--- trunk/src/mgr/versemgr.cpp	2008-07-22 11:00:16 UTC (rev 2187)
+++ trunk/src/mgr/versemgr.cpp	2008-07-22 15:08:04 UTC (rev 2188)
@@ -100,6 +100,7 @@
 	BMAX[1] = other.BMAX[1];
 	init();
 	(*p) = *(other.p);
+	ntStartOffset = other.ntStartOffset;
 }
 
 VerseMgr::System::System &VerseMgr::System::operator =(const System &other) {
@@ -108,22 +109,23 @@
 	BMAX[1] = other.BMAX[1];
 	init();
 	(*p) = *(other.p);
+	ntStartOffset = other.ntStartOffset;
 	return *this;
 }
 
 
 VerseMgr::System::~System() {
 	delete p;
-	p = 0;
 }
 
 const VerseMgr::Book *VerseMgr::System::getBook(int number) const {
-	return &(p->books[number]);
+	return (number < p->books.size()) ? &(p->books[number]) : 0;
 }
 
 
 int VerseMgr::System::getBookNumberByOSISName(const char *bookName) const {
-	return p->osisLookup[bookName];
+	map<SWBuf, int>::const_iterator it = p->osisLookup.find(bookName);
+	return (it != p->osisLookup.end()) ? it->second : -1;
 }
 
 
@@ -192,21 +194,26 @@
 
 VerseMgr::Book::~Book() {
 	delete p;
-	p = 0;
 }
 
 
 int VerseMgr::Book::getVerseMax(int chapter) const {
-	return p->verseMax[chapter-1];
+	chapter--;
+	return (chapter < p->verseMax.size()) ? p->verseMax[chapter] : -1;
 }
 
 
 long VerseMgr::System::getOffsetFromVerse(int book, int chapter, int verse) const {
 	long  offset = -1;
+	chapter--;
 
 	const Book *b = getBook(book);
-	offset = b->p->offsetPrecomputed[chapter-1];
 
+	if (!b)                                        return -1;	// assert we have a valid book
+	if (chapter >= b->p->offsetPrecomputed.size()) return -1;	// assert we have a valid chapter
+
+	offset = b->p->offsetPrecomputed[chapter];
+
 /* old code
  *
 	offset = offsets[testament-1][0][book];
@@ -269,7 +276,6 @@
 
 VerseMgr::~VerseMgr() {
 	delete p;
-	p = 0;
 }
 
 
@@ -278,7 +284,6 @@
 		systemVerseMgr = new VerseMgr();
 		systemVerseMgr->registerVersificationSystem("KJV", otbooks, ntbooks, vm);
 	}
-
 	return systemVerseMgr;
 }
 
@@ -291,7 +296,8 @@
 
 
 const VerseMgr::System *VerseMgr::getVersificationSystem(const char *name) const {
-	return &(p->systems[name]);
+	map<SWBuf, System>::const_iterator it = p->systems.find(name);
+	return (it != p->systems.end()) ? &(it->second) : 0;
 }
 
 void VerseMgr::registerVersificationSystem(const char *name, const sbook *ot, const sbook *nt, int *chMax) {

Modified: trunk/tests/testsuite/verseparsing-utf8.good
===================================================================
--- trunk/tests/testsuite/verseparsing-utf8.good	2008-07-22 11:00:16 UTC (rev 2187)
+++ trunk/tests/testsuite/verseparsing-utf8.good	2008-07-22 15:08:04 UTC (rev 2188)
@@ -1,16 +1,7 @@
-Matthäus 2:3 - Matthäus 2:12
-Römer 2:13
-Matthäus 1:2 - Römer 3:13
-1. Könige 2:1 - 1. Könige 2:46
-1. Könige 1:1 - 2. Könige 25:30
-Markus 1:1
-Matthäus 2:1
-Matthäus 1:1 - Matthäus 28:20
-1. Könige 1:1 - 1. Könige 22:53
-1. Könige 1:1 - 2. Könige 25:30
-Markus 1:1
-Matthäus 2:1
-Matthäus 1:1 - Matthäus 28:20
-1. Könige 1:1 - 2. Könige 25:30
-1. Könige 1:1 - Matthäus 28:20
-Maleachi 1:1 - Matthäus 2:1
+Matthäus 2:3-12 de: Matthäus 2:3-Matthäus 2:12
+Römer 2:13 de: Römer 2:13
+Matthäus 1:2-Röm 3:13 de: Matthäus 1:2-Römer 3:13
+1. Könige 2 de: 1. Könige 2:1-1. Könige 2:46
+1. Könige - 2. Könige; Markus 1:1; Matthäus 2:1; Matthäus; 1.Kön de: 1. Könige 1:1-2. Könige 25:30; Markus 1:1; Matthäus 2:1; Matthäus 1:1-Matthäus 28:20; 1. Könige 1:1-1. Könige 22:53
+1. Könige - 2. Könige; Markus 1:1; Matthäus 2:1; Matthäus; 1.Kön-2.Kön;I Kings-Matthäus de: 1. Könige 1:1-2. Könige 25:30; Markus 1:1; Matthäus 2:1; Matthäus 1:1-Matthäus 28:20; 1. Könige 1:1-2. Könige 25:30; 1. Könige 1:1-Matthäus 28:20
+Maleachi 1:1 - Matthäus 2:1 de: Maleachi 1:1-Matthäus 2:1

Modified: trunk/usrinst.sh
===================================================================
--- trunk/usrinst.sh	2008-07-22 11:00:16 UTC (rev 2187)
+++ trunk/usrinst.sh	2008-07-22 15:08:04 UTC (rev 2188)
@@ -5,7 +5,7 @@
 OPTIONS="--without-conf $OPTIONS"
 OPTIONS="--sysconfdir=/etc $OPTIONS"
 #OPTIONS="--with-vcl $OPTIONS"
-#OPTIONS="--enable-debug $OPTIONS"
+OPTIONS="--enable-debug $OPTIONS"
 #OPTIONS="--enable-profile $OPTIONS"
 OPTIONS="--with-icu $OPTIONS"
 #OPTIONS="--without-clucene $OPTIONS"




More information about the sword-cvs mailing list