summaryrefslogtreecommitdiffstats
path: root/bstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'bstr.c')
-rw-r--r--bstr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bstr.c b/bstr.c
index d86b488912..f4d3bdef42 100644
--- a/bstr.c
+++ b/bstr.c
@@ -62,6 +62,14 @@ int bstrchr(struct bstr str, int c)
return -1;
}
+int bstrrchr(struct bstr str, int c)
+{
+ for (int i = str.len - 1; i >= 0; i--)
+ if (str.start[i] == c)
+ return i;
+ return -1;
+}
+
struct bstr bstr_strip(struct bstr str)
{
while (str.len && isspace(*str.start)) {