strtoimax: Don't force a replacement on systems where intmax_t is int.
authorBruno Haible <bruno@clisp.org>
Thu, 5 Jan 2012 19:18:54 +0000 (20:18 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 5 Jan 2012 19:18:54 +0000 (20:18 +0100)
* m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Use a different test if
'intmax_t' is not larger than 'int'.
Reported by Pádraig Brady <P@draigBrady.com>.

ChangeLog
m4/strtoimax.m4

index ea441d1..f1b744b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-01-05  Bruno Haible  <bruno@clisp.org>
 
+       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 <P@draigBrady.com>.
+
+2012-01-05  Bruno Haible  <bruno@clisp.org>
+
        doc: Mention NetBSD bugs.
        * doc/posix-functions/*printf.texi: Mention a NetBSD 5.1 bug.
        * doc/posix-functions/nl_langinfo.texi: Mention another NetBSD 5.1 bug.
index b4e2d40..76d5560 100644 (file)
@@ -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;
 }
 ]])],