* enc/trans/utf_16_32.erb.c (fun_so_from_utf_32le): implemented.
[ruby-svn.git] / missing / strtol.c
blobda6636f316959d84cd725672d36230268f8396c0
1 /* public domain rewrite of strtol(3) */
3 #include <ctype.h>
5 long
6 strtol(const char *nptr, char **endptr, int base)
8 long result;
9 const char *p = nptr;
11 while (isspace(*p)) {
12 p++;
14 if (*p == '-') {
15 p++;
16 result = -strtoul(p, endptr, base);
18 else {
19 if (*p == '+') p++;
20 result = strtoul(p, endptr, base);
22 if (endptr != 0 && *endptr == p) {
23 *endptr = (char *)nptr;
25 return result;