From 09e967c2d732783b2579e4e120cd9b608404cb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Wed, 4 Jun 2003 18:31:57 +0000 Subject: Merge from R9_0-AMD64, most notably: - AMD64 support to insmod-busybox, minilibc, et al. - Sync with insmod-modutils 2.4.19 something but everyone should use dietlibc nowadays - Factor out compilation and prefix with $(DIET) for dietlibc builds - 64-bit & varargs fixes --- mdk-stage1/dietlibc/lib/strtol.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'mdk-stage1/dietlibc/lib/strtol.c') diff --git a/mdk-stage1/dietlibc/lib/strtol.c b/mdk-stage1/dietlibc/lib/strtol.c index ead89f408..2624aca0e 100644 --- a/mdk-stage1/dietlibc/lib/strtol.c +++ b/mdk-stage1/dietlibc/lib/strtol.c @@ -1,7 +1,10 @@ #include +#include "dietfeatures.h" +#include +#include +#include -extern unsigned long int strtoul(const char *nptr, char **endptr, int base); - +#define ABS_LONG_MIN 2147483648UL long int strtol(const char *nptr, char **endptr, int base) { int neg=0; @@ -9,7 +12,15 @@ long int strtol(const char *nptr, char **endptr, int base) while(isspace(*nptr)) nptr++; - if (*nptr == '-' && isdigit(nptr[1])) { neg=-1; nptr++; } + if (*nptr == '-') { neg=-1; ++nptr; } v=strtoul(nptr,endptr,base); + if (v>=ABS_LONG_MIN) { + if (v==ABS_LONG_MIN && neg) { + errno=0; + return v; + } + errno=ERANGE; + return (neg?LONG_MIN:LONG_MAX); + } return (neg?-v:v); } -- cgit v1.2.1