aboutsummaryrefslogtreecommitdiff
path: root/lib/const_strings.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/const_strings.c')
-rw-r--r--lib/const_strings.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/const_strings.c b/lib/const_strings.c
index 09d2c5f..0c0da41 100644
--- a/lib/const_strings.c
+++ b/lib/const_strings.c
@@ -55,6 +55,17 @@ const_string cs_chop_delim(const_string *str, char delim) {
return result;
}
+bool cs_try_chop_delim(const_string *str, char delim, const_string *dst) {
+ const_string str_copy = *str;
+ const_string tmp = cs_chop_delim(&str_copy, delim);
+ if (str_copy.len == 0) {
+ return false;
+ }
+ *str = str_copy;
+ *dst = tmp;
+ return true;
+}
+
int cs_find_delim(const_string str, char delim) {
int n;
for (n = 0; n < str.len && str.data[n] != delim; n++) {}