diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-06-16 10:48:14 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-06-16 10:48:14 +0100 |
| commit | f0f2b1c38336090746a7a2085a8aa8a1bd592273 (patch) | |
| tree | b9c2f043afb3fdc7be770fa69957c8b03d17c4dd /src/string.cc | |
| parent | d7806249d907e1a6dceb93c25d412c41e56a4ae8 (diff) | |
Trim whitespaces surrounding docstrings
Closes #1439
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc index 18ae5d80..6fb64098 100644 --- a/src/string.cc +++ b/src/string.cc @@ -207,6 +207,17 @@ Vector<StringView> split(StringView str, char separator) return res; } +StringView trim_whitespaces(StringView str) +{ + auto beg = str.begin(), end = str.end(); + while (beg != end and is_blank(*beg)) + ++beg; + while (beg != end and is_blank(*(end-1))) + --end; + return {beg, end}; +} + + String escape(StringView str, StringView characters, char escape) { String res; |
