Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8622 | Boppan | 1 | #include |
2 | #include |
||
3 | |||
4 | long atol(const char *s) |
||
5 | { |
||
6 | long n=0; |
||
7 | int neg=0; |
||
8 | while (isspace(*s)) s++; |
||
9 | switch (*s) { |
||
10 | case '-': neg=1; |
||
11 | case '+': s++; |
||
12 | } |
||
13 | /* Compute n as a negative number to avoid overflow on LONG_MIN */ |
||
14 | while (isdigit(*s)) |
||
15 | n = 10*n - (*s++ - '0'); |
||
16 | return neg ? n : -n; |
||
17 | } |