aboutsummaryrefslogtreecommitdiff
path: root/libbible.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-11-09 10:28:06 -0500
committerYour Name <you@example.com>2020-11-09 10:28:06 -0500
commita308af1cd84185989f1262ba66b01f6a9ceafa6a (patch)
treeb82fb14947cd869c0c7070f67db64a767c129616 /libbible.cc
parent1b7760f0c488d183648842a47ff57d36f5934225 (diff)
downloadlibbible-a308af1cd84185989f1262ba66b01f6a9ceafa6a.tar.gz
libbible-a308af1cd84185989f1262ba66b01f6a9ceafa6a.tar.bz2
libbible-a308af1cd84185989f1262ba66b01f6a9ceafa6a.zip
Fixed a bug with NT only translations displaying invalid OT text
Diffstat (limited to 'libbible.cc')
-rw-r--r--libbible.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/libbible.cc b/libbible.cc
index 29e8873..c7f3f4c 100644
--- a/libbible.cc
+++ b/libbible.cc
@@ -19,9 +19,15 @@ vector<string> getBooks(SWModule *target) {
key->setBook(b);
// Bug (whose fault??) in JPS; they CLAIM to have two testaments,
// but they only have one, which causes repeats.
- if(std::find(books.begin(), books.end(), key->getBookName()) == books.end()) {
- books.push_back(key->getBookName());
+ if(std::find(books.begin(), books.end(), key->getBookName()) != books.end()) {
+ continue;
}
+ // Another issue (maybe bug?) Some translations are NT only,
+ // but still report OT books/chapters.
+ if(string(target->renderText()).empty()) {
+ continue;
+ }
+ books.push_back(key->getBookName());
}
}
return books;
@@ -71,18 +77,24 @@ libbible::text getEmptyText(VerseKey *key) {
libbible::text t;
t.chapter = key->getChapter();
t.verse = key->getVerse();
- t.book = key->getBook();
+ t.book = key->getBookName();
t.bookShort = key->getBookAbbrev();
return t;
}
void inferMissing(libbible::passage *pass, SWModule *target) {
+ vector<string> validBooks = getBooks(target);
//printf("Hey, I'm inferring missing parts!\n");
if(! pass->reference.empty()) {
// Let's use the target to help us
target->setKey(pass->reference.c_str());
VerseKey *key = (VerseKey *) target->getKey();
pass->book = string(key->getBookName());
+ // Hold on a moment, is this book even legal?
+ if(find(validBooks.begin(), validBooks.end(), pass->book) == validBooks.end()) {
+ key->setBookName(validBooks[0].c_str());
+ pass->book = string(key->getBookName());
+ }
pass->bookShort = string(key->getBookAbbrev());
pass->chapterStart = key->getChapter();
pass->verseStart = key->getVerse();