chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
volume_id: provide libvolume_id.a file
[elogind.git]
/
klibc
/
klibc
/
strcasecmp.c
diff --git
a/klibc/klibc/strcasecmp.c
b/klibc/klibc/strcasecmp.c
index e583491b35f8af712d8026870ece455537ba43d0..12aef40d932995136ec6ac280d5e64be62c09f57 100644
(file)
--- a/
klibc/klibc/strcasecmp.c
+++ b/
klibc/klibc/strcasecmp.c
@@
-1,6
+1,5
@@
/*
* strcasecmp.c
/*
* strcasecmp.c
- *
*/
#include <string.h>
*/
#include <string.h>
@@
-8,18
+7,17
@@
int strcasecmp(const char *s1, const char *s2)
{
int strcasecmp(const char *s1, const char *s2)
{
- char *n1, *n2;
- int i, retval;
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
- n1 = strdup(s1);
- n2 = strdup(s2);
+ while ( 1 ) {
+ /* 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;
}
}