X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrtol.c;h=392f6ebee3a11c410e0b914dfdd3c3c41ad1225b;hb=refs%2Ftags%2FSHELLUTILS-1_9_2;hp=09d8f86e9327ed072a41593eefb46a9cd8ccd289;hpb=abaeb5ade82e7c65494c394ddcc14d99bc1fe075;p=gnulib.git diff --git a/lib/strtol.c b/lib/strtol.c index 09d8f86e9..392f6ebee 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -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 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 +#else +#include "config.h" +#endif +#endif + #include #include #if HAVE_LIMITS_H #include #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 #include @@ -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. */