summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index da15a039d..8536c9513 100644
--- a/src/util.c
+++ b/src/util.c
@@ -279,6 +279,31 @@ int git__strcasecmp(const char *a, const char *b)
return (tolower(*a) - tolower(*b));
}
+int git__strcasesort_cmp(const char *a, const char *b)
+{
+ int cmp = 0;
+
+ const char *orig_a = a;
+ const char *orig_b = b;
+
+ while (*a && *b) {
+ if (*a == *b)
+ ;
+ else if (tolower(*a) == tolower(*b)) {
+ if (!cmp)
+ cmp = (int)(*(const unsigned char *)a) - (int)(*(const unsigned char *)b);
+ } else
+ break;
+
+ ++a, ++b;
+ }
+
+ if (*a || *b)
+ return tolower(*a) - tolower(*b);
+
+ return cmp;
+}
+
int git__strncmp(const char *a, const char *b, size_t sz)
{
while (sz && *a && *b && *a == *b)