summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorfigec <raptor.ext@gmail.com>2015-06-19 19:04:11 +0300
committerest31 <MTest31@outlook.com>2015-06-20 03:41:51 +0200
commitd7190df07ec92067ab5f40086df84ab30994bf87 (patch)
treee578e23e01f153d0b44e4cdf96c7f415824a677d /src/util
parentdd91b3d6fbc3a0b4b18b36b14864d703213dd622 (diff)
downloadminetest-d7190df07ec92067ab5f40086df84ab30994bf87.tar.gz
minetest-d7190df07ec92067ab5f40086df84ab30994bf87.tar.bz2
minetest-d7190df07ec92067ab5f40086df84ab30994bf87.zip
More correct wrap_rows implementation
Diffstat (limited to 'src/util')
-rw-r--r--src/util/string.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/util/string.h b/src/util/string.h
index b4ce5743d..6980060e4 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -426,18 +426,12 @@ inline std::string wrap_rows(const std::string &from,
{
std::string to;
- bool need_to_wrap = false;
-
size_t character_idx = 0;
for (size_t i = 0; i < from.size(); i++) {
- if (character_idx > 0 && character_idx % row_len == 0)
- need_to_wrap = true;
if (!IS_UTF8_MULTB_INNER(from[i])) {
- // Wrap string if needed before next char started
- if (need_to_wrap) {
+ // Wrap string after last inner byte of char
+ if (character_idx > 0 && character_idx % row_len == 0)
to += '\n';
- need_to_wrap = false;
- }
character_idx++;
}
to += from[i];