From: Bruno Haible Date: Thu, 5 Jan 2012 19:18:54 +0000 (+0100) Subject: strtoimax: Don't force a replacement on systems where intmax_t is int. X-Git-Tag: v0.1~1293 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9bbbd8bf098ef3bb05eccb0cac204742945f6a49;p=gnulib.git strtoimax: Don't force a replacement on systems where intmax_t is int. * m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Use a different test if 'intmax_t' is not larger than 'int'. Reported by Pádraig Brady . --- diff --git a/ChangeLog b/ChangeLog index ea441d10cd..f1b744b0af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-01-05 Bruno Haible + + strtoimax: Don't force a replacement on systems where intmax_t is int. + * m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Use a different test if + 'intmax_t' is not larger than 'int'. + Reported by Pádraig Brady . + 2012-01-05 Bruno Haible doc: Mention NetBSD bugs. diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4 index b4e2d4098e..76d55600d8 100644 --- a/m4/strtoimax.m4 +++ b/m4/strtoimax.m4 @@ -36,17 +36,34 @@ AC_DEFUN([gl_FUNC_STRTOIMAX], #endif int main () { - const char *s = "4294967295"; - char *p; - intmax_t res; - errno = 0; - res = strtoimax (s, &p, 10); - if (p != s + strlen (s)) - return 1; - if (errno != 0) - return 2; - if (res != (intmax_t) 65535 * (intmax_t) 65537) - return 3; + if (sizeof (intmax_t) > sizeof (int)) + { + const char *s = "4294967295"; + char *p; + intmax_t res; + errno = 0; + res = strtoimax (s, &p, 10); + if (p != s + strlen (s)) + return 1; + if (errno != 0) + return 2; + if (res != (intmax_t) 65535 * (intmax_t) 65537) + return 3; + } + else + { + const char *s = "2147483647"; + char *p; + intmax_t res; + errno = 0; + res = strtoimax (s, &p, 10); + if (p != s + strlen (s)) + return 1; + if (errno != 0) + return 2; + if (res != 2147483647) + return 3; + } return 0; } ]])],