(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
[gnulib.git] / lib / strtoimax.c
index cda6b44..6bddf9a 100644 (file)
@@ -1,5 +1,5 @@
 /* Convert string representation of a number into an intmax_t value.
-   Copyright 1999, 2001 Free Software Foundation, Inc.
+   Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
 #endif
 
 #if HAVE_STDLIB_H
@@ -71,6 +75,8 @@ long long strtoll PARAMS ((char const *, char **, int));
 #endif
 
 #ifdef UNSIGNED
+# undef HAVE_LONG_LONG
+# define HAVE_LONG_LONG HAVE_UNSIGNED_LONG_LONG
 # define INT uintmax_t
 # define strtoimax strtoumax
 # define strtol strtoul
@@ -82,16 +88,16 @@ long long strtoll PARAMS ((char const *, char **, int));
 INT
 strtoimax (char const *ptr, char **endptr, int base)
 {
-#if HAVE_UNSIGNED_LONG_LONG
+#if HAVE_LONG_LONG
   verify (size_is_that_of_long_or_long_long,
-         (sizeof (INT) == sizeof strtol (ptr, endptr, base)
-          || sizeof (INT) == sizeof strtoll (ptr, endptr, base)));
+         (sizeof (INT) == sizeof (long)
+          || sizeof (INT) == sizeof (long long)));
 
-  if (sizeof (INT) != sizeof strtol (ptr, endptr, base))
+  if (sizeof (INT) != sizeof (long))
     return strtoll (ptr, endptr, base);
 #else
   verify (size_is_that_of_long,
-         sizeof (INT) == sizeof strtol (ptr, endptr, base));
+         sizeof (INT) == sizeof (long));
 #endif
 
   return strtol (ptr, endptr, base);