diff options
Diffstat (limited to 'libbible.cc')
-rw-r--r-- | libbible.cc | 18 |
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(); |