FreeCalypso > hg > freecalypso-tools
comparison target-utils/libc/atoi.c @ 87:7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 28 Oct 2016 22:20:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:684eddecbc62 | 87:7fb62fc724dc |
---|---|
1 atoi(p) | |
2 register char *p; | |
3 { | |
4 register int n; | |
5 register int f; | |
6 | |
7 n = 0; | |
8 f = 0; | |
9 for(;;p++) { | |
10 switch(*p) { | |
11 case ' ': | |
12 case '\t': | |
13 continue; | |
14 case '-': | |
15 f++; | |
16 case '+': | |
17 p++; | |
18 } | |
19 break; | |
20 } | |
21 while(*p >= '0' && *p <= '9') | |
22 n = n*10 + *p++ - '0'; | |
23 return(f? -n: n); | |
24 } |