string-util: introduce streq_skip_trailing_chars()
This commit is contained in:
committed by
Yu Watanabe
parent
46a0f5cac8
commit
8034b42ca6
@@ -1146,3 +1146,19 @@ int string_contains_word_strv(const char *string, const char *separators, char *
|
||||
*ret_word = found;
|
||||
return !!found;
|
||||
}
|
||||
|
||||
bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok) {
|
||||
if (!s1 && !s2)
|
||||
return true;
|
||||
if (!s1 || !s2)
|
||||
return false;
|
||||
|
||||
if (!ok)
|
||||
ok = WHITESPACE;
|
||||
|
||||
for (; *s1 && *s2; s1++, s2++)
|
||||
if (*s1 != *s2)
|
||||
break;
|
||||
|
||||
return in_charset(s1, ok) && in_charset(s2, ok);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user