diff options
author | Mystery Man <unknown@mandriva.org> | 2003-10-29 16:07:11 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2003-10-29 16:07:11 +0000 |
commit | fa40f30b4253b1e05c46cc5e0c111176825b7623 (patch) | |
tree | 76cf2d26c0ce0ee7c6a2c1a1a2b65bc4d8e33029 /mdk-stage1/dietlibc/lib/atoi.c | |
parent | 327bd24f8e4291bd1882de1990dd7339f781a9cb (diff) | |
download | drakx-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar drakx-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.gz drakx-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.bz2 drakx-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.xz drakx-fa40f30b4253b1e05c46cc5e0c111176825b7623.zip |
This commit was manufactured by cvs2svn to create tag 'Corpo_2_1_1'.Corpo_2_1_1
Diffstat (limited to 'mdk-stage1/dietlibc/lib/atoi.c')
-rw-r--r-- | mdk-stage1/dietlibc/lib/atoi.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/mdk-stage1/dietlibc/lib/atoi.c b/mdk-stage1/dietlibc/lib/atoi.c index fe952b8c4..10b618950 100644 --- a/mdk-stage1/dietlibc/lib/atoi.c +++ b/mdk-stage1/dietlibc/lib/atoi.c @@ -1,8 +1,19 @@ +#include <endian.h> +#include <ctype.h> +#include <stdlib.h> + +#if __WORDSIZE == 64 int atoi(const char* s) { - int v=0; + long int v=0; int sign=1; - if (*s=='-') { sign=-1; ++s; } else if (*s=='+') ++s; - while (*s && (*s>='0') && (*s<='9')) - v=v*10+*s++-'0'; - return v*sign; + while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) s++; + switch (*s) { + case '-': sign=-1; + case '+': ++s; + } + while ((unsigned int) (*s - '0') < 10u) { + v=v*10+*s-'0'; ++s; + } + return sign==-1?-v:v; } +#endif |