diff options
author | Your Name <you@example.com> | 2024-01-30 10:13:21 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2024-01-30 10:13:21 -0500 |
commit | 6c516699d7622c9aac91ef5a309b815a5005817b (patch) | |
tree | 34b764cb555502195fad5c5508bcab258fa875be /src | |
parent | b26cf10a2ffcd353d527cc8786ae955810fe4652 (diff) | |
download | libbible-6c516699d7622c9aac91ef5a309b815a5005817b.tar.gz libbible-6c516699d7622c9aac91ef5a309b815a5005817b.tar.bz2 libbible-6c516699d7622c9aac91ef5a309b815a5005817b.zip |
Fixed infinite loop at end of bible (Rev 22)v1.0.6
Diffstat (limited to 'src')
-rw-r--r-- | src/bible.cc | 5 | ||||
-rw-r--r-- | src/lib/libbible.cc | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/bible.cc b/src/bible.cc index 0e555dc..7773732 100644 --- a/src/bible.cc +++ b/src/bible.cc @@ -310,6 +310,11 @@ int main(int argc, char* argv[]) { if(omitVerseNums && tex.verse != verse) { out << " "; } else if(!omitVerseNums && tex.verse != verse) { + // First output any whitespace at the start of tex.text + for(auto c = tex.text.begin(); c != tex.text.end() and std::isspace(*c);) { + out << *c; + tex.text.erase(c); + } if(superscript) { out << " "; map<char,string> d2s = {{'0', "⁰"}, {'1', "¹"}, {'2', "²"}, {'3', "³"}, {'4', "⁴"}, {'5', "⁵"}, {'6', "⁶"}, {'7', "⁷"}, {'8', "⁸"}, {'9', "⁹"}}; diff --git a/src/lib/libbible.cc b/src/lib/libbible.cc index c6850f7..f3b9820 100644 --- a/src/lib/libbible.cc +++ b/src/lib/libbible.cc @@ -184,11 +184,11 @@ vector<libbible::text> libbible::getText(libbible::passage pass) { string book = string(key->getBookName()); - for(; string(key->getBookName()) == book && + /*for(; string(key->getBookName()) == book && (key->getChapter() < pass.chapterEnd || (key->getChapter() == pass.chapterEnd && key->getVerse() <= pass.verseEnd)); - (*key)++) { - + (*key)++) {*/ + while(true) { string text = string(target->renderText()); //printf("Working with: %s\n", text.c_str()); @@ -276,6 +276,11 @@ vector<libbible::text> libbible::getText(libbible::passage pass) { } } endOfParagraph = ! text.empty() and text.back() == '\n'; + if(string(key->getBookName()) != book || + (key->getChapter() >= pass.chapterEnd && key->getVerse() >= pass.verseEnd)) { + break; + } + (*key)++; } return texts; } |