diff --git a/src/option_types.hh b/src/option_types.hh index 0f204b70..a8fd7d78 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -32,7 +32,7 @@ inline void option_from_string(StringView str, bool& opt) throw runtime_error("boolean values are either true, yes, false or no"); } -constexpr Codepoint list_separator = ':'; +constexpr char list_separator = ':'; template String option_to_string(const Vector& opt) @@ -98,7 +98,7 @@ void option_from_string(StringView str, UnorderedMap& opt) } } -constexpr Codepoint tuple_separator = ','; +constexpr char tuple_separator = ','; template struct TupleOptionDetail 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; - 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; } diff --git a/src/string.hh b/src/string.hh index fba20f15..b1e51e7e 100644 --- a/src/string.hh +++ b/src/string.hh @@ -150,6 +150,7 @@ public: constexpr StringView(const char* begin, const char* end) : m_data{begin}, m_length{(int)(end - begin)} {} StringView(const String& str) : m_data{str.data()}, m_length{(int)str.length()} {} StringView(const char& c) : m_data(&c), m_length(1) {} + StringView(int c) = delete; [[gnu::always_inline]] constexpr const char* data() const { return m_data; }