diff options
-rw-r--r-- | bible.cc | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -106,7 +106,6 @@ void removeMod(string mod) { libbible::uninstallMod(mod); } -// Stolen from O'Reilly void textWrap(istream& in, ostream& out, size_t width) { string word; string line; @@ -141,8 +140,10 @@ void textWrap(istream& in, ostream& out, size_t width) { //printf("Word: %s, i: %ld\n", word.c_str(), i); if(i > width) { word.erase(0, word.find_first_not_of(" ")); - line.erase(line.find_last_of(" ")); - out << line << '\n'; + if(line.find_last_of(" ") != string::npos) { + line.erase(line.find_last_of(" ")); + out << line << '\n'; + } line = word; } } |