string-util: introduce streq_skip_trailing_chars()

This commit is contained in:
Antony Deepak Thomas
2021-09-29 12:57:30 +09:00
committed by Yu Watanabe
parent 46a0f5cac8
commit 8034b42ca6
3 changed files with 46 additions and 0 deletions
+16
View File
@@ -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);
}