diff options
author | Claudio Fontana <sick_soul@users.sourceforge.net> | 2006-01-06 04:52:00 +0000 |
---|---|---|
committer | Claudio Fontana <sick_soul@users.sourceforge.net> | 2006-01-06 04:52:00 +0000 |
commit | b5b7b0baf551299e058432d58d5ab2e21d16c312 (patch) | |
tree | f0535089c67a6d6fdd746532953007253dd08cdb /lib/strncasecmp.c | |
parent | a15c29c1a101a6bedc1a0ee5f6efd694a1ff4cad (diff) | |
download | idutils-b5b7b0baf551299e058432d58d5ab2e21d16c312.tar.gz idutils-b5b7b0baf551299e058432d58d5ab2e21d16c312.tar.bz2 idutils-b5b7b0baf551299e058432d58d5ab2e21d16c312.zip |
* s/id-utils/idutils/g;
* other small changes
Diffstat (limited to 'lib/strncasecmp.c')
-rw-r--r-- | lib/strncasecmp.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/strncasecmp.c b/lib/strncasecmp.c index 72ead01..0209c39 100644 --- a/lib/strncasecmp.c +++ b/lib/strncasecmp.c @@ -1,5 +1,5 @@ /* strncasecmp.c -- case insensitive string comparator - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "strcase.h" #include <ctype.h> +#include <limits.h> #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -54,5 +55,11 @@ strncasecmp (const char *s1, const char *s2, size_t n) } while (c1 == c2); - return c1 - c2; + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); } |