summaryrefslogtreecommitdiff
path: root/src/string.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-30 13:33:46 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-03-30 13:33:46 +0100
commit8439059758089aa0c21668fd5fc2315fb26753c4 (patch)
treeee4ed6c27a09de9bb50ea487825927f685a5ad0c /src/string.cc
parentadaf6ecc40d91389783e01bd3ac8bca8579f3d28 (diff)
Fix wrong implicit conversions from int/Codepoint to StringView
Diffstat (limited to 'src/string.cc')
-rw-r--r--src/string.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/string.cc b/src/string.cc
index ba8403f7..df7bfa68 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -148,16 +148,22 @@ String expand_tabs(StringView line, CharCount tabstop, CharCount col)
{
String res;
res.reserve(line.length());
- using Utf8It = utf8::iterator<const char*>;
- for (Utf8It it = line.begin(); it.base() < line.end(); ++it)
+ for (auto it = line.begin(), end = line.end(); it != end; )
{
if (*it == '\t')
{
CharCount end_col = (col / tabstop + 1) * tabstop;
res += String{' ', end_col - col};
+ col = end_col;
+ ++it;
}
else
- res += *it;
+ {
+ auto char_end = utf8::next(it, end);
+ res += {it, char_end};
+ ++col;
+ it = char_end;
+ }
}
return res;
}