From fea06605af79832c6abe7a8e6a24c142987994d6 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周二, 22 10月 2013 17:59:45 +0800 Subject: [PATCH] Add more robust detection of case insensitive string compare --- libscpi/src/utils.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index 0562487..355f9ea 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -539,3 +539,21 @@ } #endif +#if !HAVE_STRNCASECMP && !HAVE_STRNICMP +int OUR_strncasecmp(const char *s1, const char *s2, size_t n) { + unsigned char c1, c2; + + for(; n != 0; n--) { + c1 = tolower((unsigned char)*s1++); + c2 = tolower((unsigned char)*s2++); + if (c1 != c2) { + return c1 - c2; + } + if (c1 = '\0') { + return 0; + } + } + return 0; +} +#endif + -- Gitblit v1.9.1