summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-08 06:59:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-08 06:59:22 (GMT)
commit1ac0ce4d32ab7a3546e7e84a562625576208c7db (patch)
tree23ebffb680b2fe7b69453bb55d8170f69d767a69 /strbuf.c
parent7d7d051c5e2b9f70adfe5538bd9ccbf60f35d4be (diff)
parente92d6225361eba5ff34696122d1491dc7ace2a5a (diff)
downloadgit-1ac0ce4d32ab7a3546e7e84a562625576208c7db.zip
git-1ac0ce4d32ab7a3546e7e84a562625576208c7db.tar.gz
git-1ac0ce4d32ab7a3546e7e84a562625576208c7db.tar.bz2
Merge branch 'ls/checkout-encoding'
The new "checkout-encoding" attribute can ask Git to convert the contents to the specified encoding when checking out to the working tree (and the other way around when checking in). * ls/checkout-encoding: convert: add round trip check based on 'core.checkRoundtripEncoding' convert: add tracing for 'working-tree-encoding' attribute convert: check for detectable errors in UTF encodings convert: add 'working-tree-encoding' attribute utf8: add function to detect a missing UTF-16/32 BOM utf8: add function to detect prohibited UTF-16/32 BOM utf8: teach same_encoding() alternative UTF encoding names strbuf: add a case insensitive starts_with() strbuf: add xstrdup_toupper() strbuf: remove unnecessary NUL assignment in xstrdup_tolower()
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/strbuf.c b/strbuf.c
index 43a840c..622c462 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)
{
@@ -793,7 +802,18 @@ char *xstrdup_tolower(const char *string)
result = xmallocz(len);
for (i = 0; i < len; i++)
result[i] = tolower(string[i]);
- result[i] = '\0';
+ return result;
+}
+
+char *xstrdup_toupper(const char *string)
+{
+ char *result;
+ size_t len, i;
+
+ len = strlen(string);
+ result = xmallocz(len);
+ for (i = 0; i < len; i++)
+ result[i] = toupper(string[i]);
return result;
}