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/strtoul.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'mdk-stage1/dietlibc/lib/strtoul.c') diff --git a/mdk-stage1/dietlibc/lib/strtoul.c b/mdk-stage1/dietlibc/lib/strtoul.c index 3f93962a9..e9c09fb59 100644 --- a/mdk-stage1/dietlibc/lib/strtoul.c +++ b/mdk-stage1/dietlibc/lib/strtoul.c @@ -1,32 +1,44 @@ #include - -/* static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; */ +#include "dietfeatures.h" +#include +#include +#include unsigned long int strtoul(const char *nptr, char **endptr, int base) { - long int v=0; + int neg = 0; + unsigned long int v=0; while(isspace(*nptr)) ++nptr; - + if (*nptr == '-') { neg=1; nptr++; } if (*nptr == '+') ++nptr; + if (base==16 && nptr[0]=='0') goto skip0x; if (!base) { if (*nptr=='0') { base=8; - if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) { +skip0x: + if (nptr[1]=='x'||nptr[1]=='X') { nptr+=2; base=16; } - } - else + } else base=10; } while(*nptr) { register unsigned char c=*nptr; - c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c-'0'); + c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff); if (c>=base) break; - v=v*base+c; + { + register unsigned long int w=v*base; + if (w