summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorLars Schneider <larsxschneider@gmail.com>2018-03-09 17:35:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-09 18:17:23 (GMT)
commit66b8af3e124a0c9dbad05f40c2f6d27614f34349 (patch)
tree177c2fdb410f395172a8c2365f93b67febcb3d83 /strbuf.c
parent13ecb4638ed92a56e855d2e6d3a9b71c4125eb51 (diff)
downloadgit-66b8af3e124a0c9dbad05f40c2f6d27614f34349.zip
git-66b8af3e124a0c9dbad05f40c2f6d27614f34349.tar.gz
git-66b8af3e124a0c9dbad05f40c2f6d27614f34349.tar.bz2
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>
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index a20af69..0a24c3d 100644
--- a/strbuf.c
+++ b/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)
{