1 #ifndef lint 2 static char sccsid[] = "@(#)atol.c 5.1 (Berkeley) 06/05/85"; 3 #endif 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