restructuring libc
[unix-history] / usr / src / lib / libc / stdlib / atoi.c
CommitLineData
2ce81398
DS
1#if defined(LIBC_SCCS) && !defined(lint)
2static char sccsid[] = "@(#)atoi.c 5.2 (Berkeley) %G%";
3#endif LIBC_SCCS and not lint
b8f253e8 4
b58afb27
BJ
5atoi(p)
6register char *p;
47eef4bc 7{
b58afb27
BJ
8 register int n;
9 register int f;
47eef4bc 10
47eef4bc
BJ
11 n = 0;
12 f = 0;
b58afb27
BJ
13 for(;;p++) {
14 switch(*p) {
15 case ' ':
16 case '\t':
17 continue;
18 case '-':
19 f++;
20 case '+':
21 p++;
22 }
23 break;
47eef4bc
BJ
24 }
25 while(*p >= '0' && *p <= '9')
26 n = n*10 + *p++ - '0';
b58afb27 27 return(f? -n: n);
47eef4bc 28}