diff options
| author | Daniel Stenberg <daniel@haxx.se> | 2002-06-18 08:19:38 +0000 |
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2002-06-18 08:19:38 +0000 |
| commit | d38ab690727f51ac9eb38631961184d5768cfcf5 (patch) | |
| tree | 7f6ed34d87da5a3da6d72406417710e5592d296d | |
| parent | b1fe81d8c7deb6bf39a207e86f3fd383548bc78d (diff) | |
| download | rockbox-d38ab690727f51ac9eb38631961184d5768cfcf5.zip rockbox-d38ab690727f51ac9eb38631961184d5768cfcf5.tar.gz rockbox-d38ab690727f51ac9eb38631961184d5768cfcf5.tar.bz2 rockbox-d38ab690727f51ac9eb38631961184d5768cfcf5.tar.xz | |
case insensitive string comparisons
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1057 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/common/strcasecmp.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/common/strcasecmp.c b/firmware/common/strcasecmp.c new file mode 100644 index 0000000..7bd0d61 --- /dev/null +++ b/firmware/common/strcasecmp.c @@ -0,0 +1,28 @@ + +#include <string.h> +#include <ctype.h> + +int strcasecmp(const char *s1, const char *s2) +{ + while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) { + s1++; + s2++; + } + + return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); +} + +int strncasecmp(const char *s1, const char *s2, size_t n) +{ + if(!n) + return 0; + + while (n-- != 0 && tolower(*s1) == tolower(*s2)) { + if(n == 0 || *s1 == '\0') + break; + s1++; + s2++; + } + + return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); +} |