fxlibc/src/libc/stdlib/strtol.c
Lephenixnoir 06f975f75c
stdlib: add a test strtol, strtoul, strtoll (DONE)
The presumed bug where the value computed without the sign overflows
even though the negative result can be represented is not actually a
problem, because this only happens with signed results and the temporary
value is computed as unsigned (thus with extra range).
2021-05-20 11:03:19 +02:00

11 lines
233 B
C

#include "stdlib_p.h"
#include <errno.h>
long int strtol(char const * restrict ptr, char ** restrict endptr, int base)
{
long n = 0;
int err = strto_int(ptr, endptr, base, &n, NULL, false);
if(err != 0) errno = err;
return n;
}