diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-02 21:04:28 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-02 21:04:28 +0000 |
commit | bd07d623d9f5c058d73ba3e454363c2fee542997 (patch) | |
tree | 4e87c5833062379b4e97b7878180b6b880b59b17 /crawl-ref/source/format.cc | |
parent | 54b17c9b542a0ab1f7f8d478abf5c9809b38efbc (diff) | |
download | crawl-ref-bd07d623d9f5c058d73ba3e454363c2fee542997.tar.gz crawl-ref-bd07d623d9f5c058d73ba3e454363c2fee542997.zip |
Fix [1952926]: Break overly long formatted strings at EOLs whenever
possible.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5440 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/format.cc')
-rw-r--r-- | crawl-ref/source/format.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 8f03c0480b..f4120ce281 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -147,9 +147,17 @@ void formatted_string::parse_string1( // Break string up if it gets too big. if (currs.size() >= 999) { - fs.cprintf(currs.substr(0, 999)); - if (currs.size() > 999) - currs = currs.substr(999); + // Break the string at the end of a line, if possible, so + // that none of the broken string ends up overwritten. + std::string::size_type bound = currs.rfind(EOL, 999); + if (bound != endpos) + bound += strlen(EOL); + else + bound = 999; + + fs.cprintf(currs.substr(0, bound)); + if (currs.size() > bound) + currs = currs.substr(bound); else currs.clear(); tag--; |