diff options
Diffstat (limited to 'bdb/clib/strcasecmp.c')
-rw-r--r-- | bdb/clib/strcasecmp.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/bdb/clib/strcasecmp.c b/bdb/clib/strcasecmp.c index 6633197bc8c..d5ce6d76d5f 100644 --- a/bdb/clib/strcasecmp.c +++ b/bdb/clib/strcasecmp.c @@ -34,7 +34,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: strcasecmp.c,v 1.4 2000/03/24 22:31:31 bostic Exp $"; +static const char revid[] = "$Id: strcasecmp.c,v 1.7 2001/11/15 17:51:38 bostic Exp $"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -78,14 +78,16 @@ static const unsigned char charmap[] = { '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377' }; /* * strcasecmp -- * Do strcmp(3) in a case-insensitive manner. * + * PUBLIC: #ifndef HAVE_STRCASECMP * PUBLIC: int strcasecmp __P((const char *, const char *)); + * PUBLIC: #endif */ int strcasecmp(s1, s2) @@ -100,3 +102,31 @@ strcasecmp(s1, s2) return (0); return (cm[*us1] - cm[*--us2]); } + +/* + * strncasecmp -- + * Do strncmp(3) in a case-insensitive manner. + * + * PUBLIC: #ifndef HAVE_STRCASECMP + * PUBLIC: int strncasecmp __P((const char *, const char *, size_t)); + * PUBLIC: #endif + */ +int +strncasecmp(s1, s2, n) + const char *s1, *s2; + register size_t n; +{ + if (n != 0) { + register const unsigned char *cm = charmap, + *us1 = (const unsigned char *)s1, + *us2 = (const unsigned char *)s2; + + do { + if (cm[*us1] != cm[*us2++]) + return (cm[*us1] - cm[*--us2]); + if (*us1++ == '\0') + break; + } while (--n != 0); + } + return (0); +} |