source: trunk/sys/dietlibc/strtoll.c @ 16

Last change on this file since 16 was 1, checked in by alain, 7 years ago

First import

File size: 695 bytes
Line 
1#include <ctype.h>
2#include <stdlib.h>
3#include <limits.h>
4#include <errno.h>
5#include <inttypes.h>
6
7long 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
29intmax_t strtoimax(const char *nptr, char **endptr, int base)
30        __attribute__((alias("strtoll")));
Note: See TracBrowser for help on using the repository browser.