From fba20a776da6d4a36db21d9b21e9e937bef00ac3 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 19 Jul 2010 07:10:53 +0000 Subject: - Many fixup patches from Savannah. - Fix the test suite on Solaris (from Boris) - Update the manual for .ONESHELL --- misc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 39c2835..7a6f773 100644 --- a/misc.c +++ b/misc.c @@ -614,6 +614,34 @@ strcasecmp (const char *s1, const char *s2) } } #endif + +#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI + +/* If we don't have strncasecmp() (from POSIX), or anything that can + substitute for it, define our own version. */ + +int +strncasecmp (const char *s1, const char *s2, int n) +{ + while (n-- > 0) + { + int c1 = (int) *(s1++); + int c2 = (int) *(s2++); + + if (isalpha (c1)) + c1 = tolower (c1); + if (isalpha (c2)) + c2 = tolower (c2); + + if (c1 != '\0' && c1 == c2) + continue; + + return (c1 - c2); + } + + return 0; +} +#endif #ifdef GETLOADAVG_PRIVILEGED -- cgit v1.2.3