Make { and } valid, first-class tokenizer elements

This commit is contained in:
Mahmoud Al-Qudsi
2018-03-11 19:36:10 -05:00
parent 7447432471
commit 00f95a978e
6 changed files with 89 additions and 89 deletions

View File

@@ -45,3 +45,21 @@ wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype) {
output.push_back(ellipsis_char);
return output;
}
wcstring trim(const wcstring &input) {
debug(0, "trimming '%ls'", input.c_str());
// auto begin = input.cbegin();
// for (begin; *begin == L' '; ++begin);
// auto end = input.cbegin() + input.size();
// for (end; end > begin && *end == L' '; ++end);
auto begin_offset = input.find_first_not_of(whitespace);
if (begin_offset == wcstring::npos) {
return wcstring{};
}
auto end = input.cbegin() + input.find_last_not_of(whitespace);
wcstring result(input.begin() + begin_offset, end + 1);
return result;
}