summaryrefslogtreecommitdiff
path: root/lib/strcasecmp.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-01-10 17:47:56 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-01-10 17:47:56 +0000
commitd11af4159eb8836696ef29f1e1ac9ad4db348d47 (patch)
tree87dc9cf5d37eebdd601ef33b9925bfb955ff87ff /lib/strcasecmp.c
parent71520b31c09c843d37c84abd12694e06428cdd47 (diff)
downloadcoreutils-d11af4159eb8836696ef29f1e1ac9ad4db348d47.tar.xz
Sync from gnulib.
Diffstat (limited to 'lib/strcasecmp.c')
-rw-r--r--lib/strcasecmp.c9
1 files changed, 8 insertions, 1 deletions
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 <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);
}
}