bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strtoimax: work around AIX 5.1 bug


From: Bruno Haible
Subject: Re: strtoimax: work around AIX 5.1 bug
Date: Thu, 05 Jan 2012 20:19:55 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Pádraig Brady wrote:
> > +   const char *s = "4294967295";
> 
> Should that string be defined based on sizeof(intmax_t)?

Good point, yes. I'm applying this follow-up:


2012-01-05  Bruno Haible  <address@hidden>

        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 <address@hidden>.

--- m4/strtoimax.m4.orig        Thu Jan  5 20:18:30 2012
+++ m4/strtoimax.m4     Thu Jan  5 20:15:43 2012
@@ -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;
 }
 ]])],




reply via email to

[Prev in Thread] Current Thread [Next in Thread]