| Rev | Line |   | 
|---|
| [1] | 1 | #include <ctype.h> | 
|---|
 | 2 | #include "dietfeatures.h" | 
|---|
 | 3 | #include <errno.h> | 
|---|
 | 4 | #include <limits.h> | 
|---|
 | 5 | #include <stdlib.h> | 
|---|
 | 6 |  | 
|---|
 | 7 | #if __WORDSIZE == 64 | 
|---|
 | 8 | #define ABS_LONG_MIN 9223372036854775808UL | 
|---|
 | 9 | #else | 
|---|
 | 10 | #define ABS_LONG_MIN 2147483648UL | 
|---|
 | 11 | #endif | 
|---|
 | 12 | long int strtol(const char *nptr, char **endptr, int base) | 
|---|
 | 13 | { | 
|---|
 | 14 |   int neg=0; | 
|---|
 | 15 |   unsigned long int v; | 
|---|
 | 16 |   const char*orig=nptr; | 
|---|
 | 17 |  | 
|---|
 | 18 |   while(isspace(*nptr)) nptr++; | 
|---|
 | 19 |  | 
|---|
 | 20 |   if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; } | 
|---|
 | 21 |   v=strtoul(nptr,endptr,base); | 
|---|
 | 22 |   if (endptr && *endptr==nptr) *endptr=(char *)orig; | 
|---|
 | 23 |   if (v>=ABS_LONG_MIN) { | 
|---|
 | 24 |     if (v==ABS_LONG_MIN && neg) { | 
|---|
 | 25 |       //errno=0; | 
|---|
 | 26 |       return v; | 
|---|
 | 27 |     } | 
|---|
 | 28 |     //errno=ERANGE; | 
|---|
 | 29 |     return (neg?LONG_MIN:LONG_MAX); | 
|---|
 | 30 |   } | 
|---|
 | 31 |   return (neg?-v:v); | 
|---|
 | 32 | } | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.