xref: /csrg-svn/lib/libc/stdlib/atol.c (revision 26543)
1 #if defined(LIBC_SCCS) && !defined(lint)
2 static char sccsid[] = "@(#)atol.c	5.2 (Berkeley) 03/09/86";
3 #endif LIBC_SCCS and not lint
4 
5 long
6 atol(p)
7 register char *p;
8 {
9 	long n;
10 	register int f;
11 
12 	n = 0;
13 	f = 0;
14 	for(;;p++) {
15 		switch(*p) {
16 		case ' ':
17 		case '\t':
18 			continue;
19 		case '-':
20 			f++;
21 		case '+':
22 			p++;
23 		}
24 		break;
25 	}
26 	while(*p >= '0' && *p <= '9')
27 		n = n*10 + *p++ - '0';
28 	return(f? -n: n);
29 }
30