GNU shell utilities
[gnulib.git] / lib / strtol.c
index 09d8f86..392f6eb 100644 (file)
@@ -16,18 +16,36 @@ License along with the GNU C Library; see the file COPYING.LIB.  If
 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+   (which it would do because it found this file in $srcdir).  */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
 #include <ctype.h>
 #include <errno.h>
 
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
+
 #ifndef ULONG_MAX
-#define        LONG_MAX (~(1 << (sizeof (long) * 8 - 1)))
-#define LONG_MIN (-LONG_MAX-1)
 #define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
 #endif
 
+#ifndef LONG_MAX
+#define        LONG_MAX (~(1 << (sizeof (long) * 8 - 1)))
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN (-LONG_MAX - 1)
+#endif
+
 #if STDC_HEADERS
 #include <stddef.h>
 #include <stdlib.h>
@@ -36,10 +54,6 @@ Cambridge, MA 02139, USA.  */
 extern int errno;
 #endif
 
-#if !__STDC__
-#define const
-#endif
-
 #ifndef        UNSIGNED
 #define        UNSIGNED        0
 #endif
@@ -156,7 +170,7 @@ strtol (nptr, endptr, base)
   /* Check for a value that is within the range of
      `unsigned long int', but outside the range of `long int'.  */
   if (i > (negative ?
-          - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX))
+          -(unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX))
     overflow = 1;
 #endif
 
@@ -171,7 +185,7 @@ strtol (nptr, endptr, base)
     }
 
   /* Return the result of the appropriate sign.  */
-  return (negative ? - i : i);
+  return (negative ? -i : i);
 
 noconv:;
   /* There was no number to convert.  */