diff options
Diffstat (limited to 'lib/strcasecmp.c')
-rw-r--r-- | lib/strcasecmp.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/strcasecmp.c b/lib/strcasecmp.c index 71f2eca..c1bac0a 100644 --- a/lib/strcasecmp.c +++ b/lib/strcasecmp.c @@ -25,6 +25,7 @@ #include "strcase.h" #include <ctype.h> +#include <limits.h> #if HAVE_MBRTOWC # include "mbuiter.h" @@ -93,6 +94,12 @@ strcasecmp (const char *s1, const char *s2) } 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); } } |