diff options
Diffstat (limited to 'misc/bstr.c')
-rw-r--r-- | misc/bstr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/misc/bstr.c b/misc/bstr.c index 1a2676c537..0ef0c357e8 100644 --- a/misc/bstr.c +++ b/misc/bstr.c @@ -215,9 +215,9 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str) return r; } -struct bstr bstr_getline(struct bstr str, struct bstr *rest) +struct bstr bstr_splitchar(struct bstr str, struct bstr *rest, const char c) { - int pos = bstrchr(str, '\n'); + int pos = bstrchr(str, c); if (pos < 0) pos = str.len; if (rest) @@ -243,6 +243,14 @@ bool bstr_eatstart(struct bstr *s, struct bstr prefix) return true; } +bool bstr_eatend(struct bstr *s, struct bstr prefix) +{ + if (!bstr_endswith(*s, prefix)) + return false; + s->len -= prefix.len; + return true; +} + void bstr_lower(struct bstr str) { for (int i = 0; i < str.len; i++) |