aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bible.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/bible.cc b/bible.cc
index 7c8a89f..87f6659 100644
--- a/bible.cc
+++ b/bible.cc
@@ -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;
}
}