mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2025-06-26 07:36:39 +02:00
Basically removing it from the __scanf_input structure and specializing it at format sites. The reason is that pretending it's the end of the stream after the limit is reached does not work because we have to return EOF at end of stream but not when the limit is hit. So we have to handle it explicitly, and since we do, no need to have it in the structure too.
21 lines
465 B
C
21 lines
465 B
C
#include "stdlib_p.h"
|
|
#include <errno.h>
|
|
|
|
long long int strtoll(char const * restrict ptr, char ** restrict endptr,
|
|
int base)
|
|
{
|
|
long long n = 0;
|
|
if(endptr)
|
|
*endptr = (char *)ptr;
|
|
|
|
struct __scanf_input in = { .str = ptr, .fp = NULL };
|
|
__scanf_start(&in);
|
|
int err = __strto_int(&in, base, NULL, &n, false, INT_MAX);
|
|
__scanf_end(&in);
|
|
|
|
if(err != 0)
|
|
errno = (err == EOF) ? EINVAL : err;
|
|
if(err != EINVAL && endptr)
|
|
*endptr = (char *)in.str;
|
|
return n;
|
|
}
|