diff options
author | Bruno Haible <bruno@clisp.org> | 2006-07-22 14:36:52 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:13:38 +0200 |
commit | f7ea484c40020d8f2bd0d196d5f85f3c412d57ae (patch) | |
tree | 906c4f453c0dda4674ba4db43f8d61f1b81ebf9a | |
parent | 47a45b016e116b6bb186fd1359292ff18b7753c3 (diff) | |
download | external_gettext-f7ea484c40020d8f2bd0d196d5f85f3c412d57ae.zip external_gettext-f7ea484c40020d8f2bd0d196d5f85f3c412d57ae.tar.gz external_gettext-f7ea484c40020d8f2bd0d196d5f85f3c412d57ae.tar.bz2 |
Don't assume that UCHAR_MAX <= INT_MAX.
-rw-r--r-- | gettext-tools/lib/ChangeLog | 4 | ||||
-rw-r--r-- | gettext-tools/lib/c-strcasecmp.c | 10 | ||||
-rw-r--r-- | gettext-tools/lib/c-strncasecmp.c | 10 |
3 files changed, 22 insertions, 2 deletions
diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 5d981a6..e797373 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,5 +1,9 @@ 2006-07-22 Bruno Haible <bruno@clisp.org> + * c-strcasecmp.c: Update from gnulib. Don't assume that + UCHAR_MAX <= INT_MAX. + * c-strncasecmp.c: Likewise. + * copy-file.c: Update from gnulib. * atexit.c: Update from gnulib. diff --git a/gettext-tools/lib/c-strcasecmp.c b/gettext-tools/lib/c-strcasecmp.c index 2e3012e..00e3025 100644 --- a/gettext-tools/lib/c-strcasecmp.c +++ b/gettext-tools/lib/c-strcasecmp.c @@ -22,6 +22,8 @@ /* Specification. */ #include "c-strcase.h" +#include <limits.h> + #include "c-ctype.h" int @@ -47,5 +49,11 @@ c_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); } diff --git a/gettext-tools/lib/c-strncasecmp.c b/gettext-tools/lib/c-strncasecmp.c index 33e8091..2d260ef 100644 --- a/gettext-tools/lib/c-strncasecmp.c +++ b/gettext-tools/lib/c-strncasecmp.c @@ -22,6 +22,8 @@ /* Specification. */ #include "c-strcase.h" +#include <limits.h> + #include "c-ctype.h" int @@ -47,5 +49,11 @@ c_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); } |