summaryrefslogtreecommitdiff
path: root/src/string.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-16 10:48:14 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-16 10:48:14 +0100
commitf0f2b1c38336090746a7a2085a8aa8a1bd592273 (patch)
treeb9c2f043afb3fdc7be770fa69957c8b03d17c4dd /src/string.cc
parentd7806249d907e1a6dceb93c25d412c41e56a4ae8 (diff)
Trim whitespaces surrounding docstrings
Closes #1439
Diffstat (limited to 'src/string.cc')
-rw-r--r--src/string.cc11
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;