chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix the gentoo udev rules to allow the box to boot properly
[elogind.git]
/
klibc
/
klibc
/
strncasecmp.c
diff --git
a/klibc/klibc/strncasecmp.c
b/klibc/klibc/strncasecmp.c
index 542493de0f83e541c5a623ec70a5e51413b31239..3309d1a7fe6b4074f3285b6d4a764007ab8b9085 100644
(file)
--- a/
klibc/klibc/strncasecmp.c
+++ b/
klibc/klibc/strncasecmp.c
@@
-7,18
+7,17
@@
int strncasecmp(const char *s1, const char *s2, size_t n)
{
int strncasecmp(const char *s1, const char *s2, size_t n)
{
- char *n1, *n2;
- int i, retval;
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
- n1 = strndup(s1, n);
- n2 = strndup(s2, n);
+ while ( n-- ) {
+ /* toupper() expects an unsigned char (implicitly cast to int)
+ as input, and returns an int, which is exactly what we want. */
+ d = toupper(ch = *c1++) - toupper(*c2++);
+ if ( d || !ch )
+ break;
+ }
- for (i = 0; i < strlen(n1); i++)
- n1[i] = toupper(n1[i]);
- for (i = 0; i < strlen(n2); i++)
- n2[i] = toupper(n2[i]);
- retval = strcmp(n1, n2);
- free(n1);
- free(n2);
- return retval;
+ return d;
}
}