| 175 | } |
| 176 | |
| 177 | long atol(const char *str) |
| 178 | { |
| 179 | long ret = 0; |
| 180 | long sign = 1; |
| 181 | |
| 182 | str += strspn(str, " \t\n\r\f\v"); |
| 183 | |
| 184 | if (*str == '+') { |
| 185 | sign = 1; |
| 186 | str++; |
| 187 | } else if (*str == '-') { |
| 188 | sign = -1; |
| 189 | str++; |
| 190 | } |
| 191 | |
| 192 | while (isdigit(*str)) { |
| 193 | ret *= 10; |
| 194 | ret += *str++ - '0'; |
| 195 | } |
| 196 | return ret * sign; |
| 197 | } |