00001
00002
00003 #include <ctype.h>
00004
00005 long
00006 strtol(const char *nptr, char **endptr, int base)
00007 {
00008 long result;
00009 const char *p = nptr;
00010
00011 while (isspace(*p)) {
00012 p++;
00013 }
00014 if (*p == '-') {
00015 p++;
00016 result = -strtoul(p, endptr, base);
00017 }
00018 else {
00019 if (*p == '+') p++;
00020 result = strtoul(p, endptr, base);
00021 }
00022 if (endptr != 0 && *endptr == p) {
00023 *endptr = (char *)nptr;
00024 }
00025 return result;
00026 }
00027