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