Fix strtol

This commit is contained in:
Justine Tunney 2020-12-29 21:39:43 -08:00
parent 1df136323b
commit 5eddadafbd
17 changed files with 83 additions and 105 deletions

View file

@ -19,14 +19,19 @@
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
static noinline int __fgetc(FILE *f) {
if (!f->reader) return __fseteof(f);
if (f->reader(f) == -1) return -1;
return f->buf[f->beg++];
}
/**
* Reads uint8_t from stream.
*/
int fgetc(FILE *f) {
int c;
if (f->beg >= f->end) {
if (!f->reader) return __fseteof(f);
if (f->reader(f) == -1) return -1;
if (f->beg < f->end) {
return f->buf[f->beg++];
} else {
return __fgetc(f);
}
return f->buf[f->beg++];
}