[sword-svn] r2192 - trunk/src/mgr

scribe at www.crosswire.org scribe at www.crosswire.org
Sat Aug 16 09:42:29 MST 2008


Author: scribe
Date: 2008-08-16 09:42:29 -0700 (Sat, 16 Aug 2008)
New Revision: 2192

Modified:
   trunk/src/mgr/versemgr.cpp
Log:
fixed bounding error


Modified: trunk/src/mgr/versemgr.cpp
===================================================================
--- trunk/src/mgr/versemgr.cpp	2008-08-16 16:16:03 UTC (rev 2191)
+++ trunk/src/mgr/versemgr.cpp	2008-08-16 16:42:29 UTC (rev 2192)
@@ -25,6 +25,7 @@
 #include <map>
 #include <treekey.h>
 #include <canon.h>	// KJV internal versification system
+#include <swlog.h>	// KJV internal versification system
 #include <algorithm>
 
 using std::vector;
@@ -242,6 +243,7 @@
 
 	// binary search for book
 	vector<Book>::iterator b = lower_bound(p->books.begin(), p->books.end(), offset, BookOffsetLess());
+	if (b == p->books.end()) b--;
 	(*book)    = distance(p->books.begin(), b)+1;
 	if (offset < (*(b->p->offsetPrecomputed.begin()))-((((!(*book)) || (*book)==BMAX[0]+1))?2:1)) { // -1 for chapter headings
 		(*book)--;
@@ -264,7 +266,6 @@
 		(*chapter) = distance(b->p->offsetPrecomputed.begin(), c)+1;
 		(*verse)   = (offset - *c);
 	}
-
 	return 0;
 }
 




More information about the sword-cvs mailing list