mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
bstr: add bstr_eatstart()
This commit is contained in:
parent
4352f9feca
commit
70bf672096
8
bstr.c
8
bstr.c
@ -198,6 +198,14 @@ struct bstr bstr_getline(struct bstr str, struct bstr *rest)
|
||||
return str;
|
||||
}
|
||||
|
||||
bool bstr_eatstart(struct bstr *s, struct bstr prefix)
|
||||
{
|
||||
if (!bstr_startswith(*s, prefix))
|
||||
return false;
|
||||
*s = bstr_cut(*s, prefix.len);
|
||||
return true;
|
||||
}
|
||||
|
||||
void bstr_lower(struct bstr str)
|
||||
{
|
||||
for (int i = 0; i < str.len; i++)
|
||||
|
3
bstr.h
3
bstr.h
@ -88,6 +88,9 @@ int bstr_parse_utf8_code_length(unsigned char b);
|
||||
// line breaks are stripped.
|
||||
struct bstr bstr_getline(struct bstr str, struct bstr *rest);
|
||||
|
||||
// If s starts with prefix, return true and return the rest of the string in s.
|
||||
bool bstr_eatstart(struct bstr *s, struct bstr prefix);
|
||||
|
||||
bool bstr_case_startswith(struct bstr s, struct bstr prefix);
|
||||
bool bstr_case_endswith(struct bstr s, struct bstr suffix);
|
||||
struct bstr bstr_strip_ext(struct bstr str);
|
||||
|
Loading…
Reference in New Issue
Block a user