mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix strtol
This commit is contained in:
parent
1df136323b
commit
5eddadafbd
17 changed files with 83 additions and 105 deletions
|
@ -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++];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue