source:
trunk/sys/dietlibc/atoi.c
@
64
Last change on this file since 64 was 1, checked in by , 8 years ago | |
---|---|
File size: 359 bytes |
Rev | Line | |
---|---|---|
[1] | 1 | #include <endian.h> |
2 | #include <ctype.h> | |
3 | #include <stdlib.h> | |
4 | ||
5 | #if __WORDSIZE == 64 | |
6 | int atoi(const char* s) { | |
7 | long int v=0; | |
8 | int sign=1; | |
9 | while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) s++; | |
10 | switch (*s) { | |
11 | case '-': sign=-1; | |
12 | case '+': ++s; | |
13 | } | |
14 | while ((unsigned int) (*s - '0') < 10u) { | |
15 | v=v*10+*s-'0'; ++s; | |
16 | } | |
17 | return sign==-1?-v:v; | |
18 | } | |
19 | #endif |
Note: See TracBrowser
for help on using the repository browser.