diff options
| author | Your Name <you@example.com> | 2021-02-22 13:28:45 -0500 |
|---|---|---|
| committer | Your Name <you@example.com> | 2021-02-22 13:28:45 -0500 |
| commit | 182ee7816d5bcf794be1f44c6e9224b51567334c (patch) | |
| tree | 4cd723f57838588c7180a80aa97167b89e9afec6 | |
| parent | 79e349890265b2ba64de0fc29efa588586785b89 (diff) | |
| download | libbible-182ee7816d5bcf794be1f44c6e9224b51567334c.tar.gz libbible-182ee7816d5bcf794be1f44c6e9224b51567334c.tar.bz2 libbible-182ee7816d5bcf794be1f44c6e9224b51567334c.zip | |
Fixed crash when word is longer than width of terminal
| -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; } } |
