Update the discussion of themeing in the manual, and put a note in the wps tags appen...
[kugel-rb.git] / apps / plugins / lua / strtol.c
blob184951b8448f566c9e1e547d2f101e5e6dee3ea4
1 #include "rocklibc.h"
3 extern unsigned long int strtoul(const char *ptr, char **endptr, int base);
5 #define ABS_LONG_MIN 2147483648UL
6 long int strtol(const char *nptr, char **endptr, int base)
8 int neg=0;
9 unsigned long int v;
10 const char*orig=nptr;
12 while(isspace(*nptr)) nptr++;
14 if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; }
15 v=strtoul(nptr,endptr,base);
16 if (endptr && *endptr==nptr) *endptr=(char *)orig;
17 if (v>=ABS_LONG_MIN) {
18 if (v==ABS_LONG_MIN && neg) {
19 errno=0;
20 return v;
22 errno=ERANGE;
23 return (neg?LONG_MIN:LONG_MAX);
25 return (neg?-v:v);