changeset 16233:32a96da07efe

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>.
author Bruno Haible <bruno@clisp.org>
date Thu, 05 Jan 2012 20:18:54 +0100
parents ee328959515f
children f9b906545e2f
files ChangeLog m4/strtoimax.m4
diffstat 2 files changed, 35 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -36,17 +36,34 @@
 #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;
 }
 ]])],