aboutsummaryrefslogtreecommitdiffstats
path: root/src/keys/versekey.cpp
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-10-23 13:01:43 +0000
committerdanglassey <danglassey>2002-10-23 13:01:43 +0000
commit910dcb756342568dcd9e883d7b7d355ab850f91c (patch)
treeb5ae53e2f367cf35bbd084327181ab24efc79917 /src/keys/versekey.cpp
parentcaba6ff484a20e8ddc2d4912f0edbbe9f926499c (diff)
downloadsword-sf-cvs-910dcb756342568dcd9e883d7b7d355ab850f91c.tar.gz
sync with crosswire 20021023-1300
Diffstat (limited to 'src/keys/versekey.cpp')
-rw-r--r--src/keys/versekey.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/keys/versekey.cpp b/src/keys/versekey.cpp
index c9f50ab..371577d 100644
--- a/src/keys/versekey.cpp
+++ b/src/keys/versekey.cpp
@@ -238,10 +238,11 @@ char VerseKey::parse()
{
- testament = 1;
- book = 1;
+ testament = 2;
+ book = BMAX[1];
chapter = 1;
verse = 1;
+ int booklen = 0;
int error = 0;
@@ -249,17 +250,21 @@ char VerseKey::parse()
ListKey tmpListKey = VerseKey::ParseVerseList(keytext);
if (tmpListKey.Count()) {
SWKey::setText((const char *)tmpListKey);
- for (testament = 1; testament < 3; testament++) {
- for (book = 1; book <= BMAX[testament-1]; book++) {
- if (!strncmp(keytext, books[testament-1][book-1].name, strlen(books[testament-1][book-1].name)))
- break;
+ for (int i = 1; i < 3; i++) {
+ for (int j = 1; j <= BMAX[i-1]; j++) {
+ int matchlen = strlen(books[i-1][j-1].name);
+ if (!strncmp(keytext, books[i-1][j-1].name, matchlen)) {
+ if (matchlen > booklen) {
+ booklen = matchlen;
+ testament = i;
+ book = j;
+ }
+ }
}
- if (book <= BMAX[testament-1])
- break;
}
- if (testament < 3) {
- sscanf(&keytext[strlen(books[testament-1][book-1].name)], "%d:%d", &chapter, &verse);
+ if (booklen) {
+ sscanf(&keytext[booklen], "%d:%d", &chapter, &verse);
}
else error = 1;
} else error = 1;