From a308af1cd84185989f1262ba66b01f6a9ceafa6a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 9 Nov 2020 10:28:06 -0500 Subject: Fixed a bug with NT only translations displaying invalid OT text --- bible.cc | 2 +- libbible.cc | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bible.cc b/bible.cc index 3388364..0bcd9f1 100644 --- a/bible.cc +++ b/bible.cc @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) { bool isNewline = true; for(auto tex : text) { if(!omitVerseNums && tex.chapter != chapter) { - printf("\nChapter %d:\n", tex.chapter); + printf("\n%s Chapter %d:\n", tex.book.c_str(), tex.chapter); } bool isParagraph = false; bool isIndent = false; diff --git a/libbible.cc b/libbible.cc index 29e8873..c7f3f4c 100644 --- a/libbible.cc +++ b/libbible.cc @@ -19,9 +19,15 @@ vector 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 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(); -- cgit v1.2.3