string-helpers.c: add str_starts_with()

This commit is contained in:
Johan Malm 2024-08-20 17:59:46 +01:00 committed by Johan Malm
parent 5db953aa89
commit 2446c46069
5 changed files with 45 additions and 7 deletions

View file

@ -170,3 +170,10 @@ str_endswith(const char *const string, const char *const suffix)
return strcmp(string + len_str - len_sfx, suffix) == 0;
}
bool
str_starts_with(const char *s, char needle, const char *ignore_chars)
{
return (s + strspn(s, ignore_chars))[0] == needle;
}