summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-29 16:56:38 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-29 18:16:46 -0400
commit75a4636f502908ddd406a69a4b065e29b79276da (patch)
tree8e2a514a518e4efd4746c31e629a8cf7120afcd7 /src/util.c
parent006548da91bfe05375ae0e786c6c13e9bad85a40 (diff)
downloadlibgit2-75a4636f502908ddd406a69a4b065e29b79276da.tar.gz
git__tolower: a tolower() that isn't dumb
Some brain damaged tolower() implementations appear to want to take the locale into account, and this may require taking some insanely aggressive lock on the locale and slowing down what should be the most trivial of trivial calls for people who just want to downcase ASCII.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/util.c b/src/util.c
index b8d6cf58c..c62826420 100644
--- a/src/util.c
+++ b/src/util.c
@@ -171,9 +171,9 @@ int git__strcmp(const char *a, const char *b)
int git__strcasecmp(const char *a, const char *b)
{
- while (*a && *b && tolower(*a) == tolower(*b))
+ while (*a && *b && git__tolower(*a) == git__tolower(*b))
++a, ++b;
- return ((unsigned char)tolower(*a) - (unsigned char)tolower(*b));
+ return ((unsigned char)git__tolower(*a) - (unsigned char)git__tolower(*b));
}
int git__strcasesort_cmp(const char *a, const char *b)
@@ -182,7 +182,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
while (*a && *b) {
if (*a != *b) {
- if (tolower(*a) != tolower(*b))
+ if (git__tolower(*a) != git__tolower(*b))
break;
/* use case in sort order even if not in equivalence */
if (!cmp)
@@ -193,7 +193,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
}
if (*a || *b)
- return (unsigned char)tolower(*a) - (unsigned char)tolower(*b);
+ return (unsigned char)git__tolower(*a) - (unsigned char)git__tolower(*b);
return cmp;
}
@@ -212,8 +212,8 @@ int git__strncasecmp(const char *a, const char *b, size_t sz)
int al, bl;
do {
- al = (unsigned char)tolower(*a);
- bl = (unsigned char)tolower(*b);
+ al = (unsigned char)git__tolower(*a);
+ bl = (unsigned char)git__tolower(*b);
++a, ++b;
} while (--sz && al && al == bl);
@@ -225,7 +225,7 @@ void git__strntolower(char *str, size_t len)
size_t i;
for (i = 0; i < len; ++i) {
- str[i] = (char) tolower(str[i]);
+ str[i] = (char)git__tolower(str[i]);
}
}
@@ -255,8 +255,8 @@ int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix)
int s, p;
while(str_n--) {
- s = (unsigned char)tolower(*str++);
- p = (unsigned char)tolower(*prefix++);
+ s = (unsigned char)git__tolower(*str++);
+ p = (unsigned char)git__tolower(*prefix++);
if (s != p)
return s - p;