kolibrios-fun/contrib/media/updf/fitz/strtoll.c
Serhii Sakhno cd35d38ad2 updf: restore menuetlibc version
git-svn-id: svn://kolibrios.org@8429 a494cfbc-eb01-0410-851d-a64ba20cac60
2020-12-16 18:41:33 +00:00

31 lines
695 B
C

#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <inttypes.h>
long long int strtoll(const char *nptr, char **endptr, int base)
{
int neg=0;
unsigned long long int v;
const char*orig=nptr;
while(isspace(*nptr)) nptr++;
if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; nptr++; }
v=strtoull(nptr,endptr,base);
if (endptr && *endptr==nptr) *endptr=(char *)orig;
if (v>LLONG_MAX) {
if (v==0x8000000000000000ull && neg) {
errno=0;
return v;
}
errno=ERANGE;
return (neg?LLONG_MIN:LLONG_MAX);
}
return (neg?-v:v);
}
intmax_t strtoimax(const char *nptr, char **endptr, int base)
__attribute__((alias("strtoll")));