strbuf: add a case insensitive starts_with()
Check in a case insensitive manner if one string is a prefix of another string. This function is used in a subsequent commit. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
13ecb4638e
commit
66b8af3e12
9
strbuf.c
9
strbuf.c
@ -11,6 +11,15 @@ int starts_with(const char *str, const char *prefix)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int istarts_with(const char *str, const char *prefix)
|
||||
{
|
||||
for (; ; str++, prefix++)
|
||||
if (!*prefix)
|
||||
return 1;
|
||||
else if (tolower(*str) != tolower(*prefix))
|
||||
return 0;
|
||||
}
|
||||
|
||||
int skip_to_optional_arg_default(const char *str, const char *prefix,
|
||||
const char **arg, const char *def)
|
||||
{
|
||||
|
Reference in New Issue
Block a user