Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <ctype.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <errno.h>
  5. #include <inttypes.h>
  6.  
  7. long long int strtoll(const char *nptr, char **endptr, int base)
  8. {
  9.   int neg=0;
  10.   unsigned long long int v;
  11.   const char*orig=nptr;
  12.  
  13.   while(isspace(*nptr)) nptr++;
  14.  
  15.   if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; nptr++; }
  16.   v=strtoull(nptr,endptr,base);
  17.   if (endptr && *endptr==nptr) *endptr=(char *)orig;
  18.   if (v>LLONG_MAX) {
  19.     if (v==0x8000000000000000ull && neg) {
  20.       errno=0;
  21.       return v;
  22.     }
  23.     errno=ERANGE;
  24.     return (neg?LLONG_MIN:LLONG_MAX);
  25.   }
  26.   return (neg?-v:v);
  27. }
  28.  
  29. intmax_t strtoimax(const char *nptr, char **endptr, int base)
  30.         __attribute__((alias("strtoll")));
  31.