X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrcasecmp.c;h=c1bac0a5af93d60d1228aaf45d9cf8beb7a45ab6;hb=8de557e31178699dd6e839850056f0653cdfba89;hp=71f2eca7c94ca872e8a3100fb4e4d8de44fce245;hpb=40cdb9bf18ec808d500182c3ab071f3129861f95;p=gnulib.git diff --git a/lib/strcasecmp.c b/lib/strcasecmp.c index 71f2eca7c..c1bac0a5a 100644 --- a/lib/strcasecmp.c +++ b/lib/strcasecmp.c @@ -25,6 +25,7 @@ #include "strcase.h" #include +#include #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); } }