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 --- libbible.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'libbible.cc') 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