Further improve scanf

This commit is contained in:
Justine Tunney 2023-08-21 16:55:29 -07:00
parent 6ef2a471e4
commit 7e08a97cea
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3 changed files with 76 additions and 37 deletions

View file

@ -26,7 +26,9 @@
int ungetc_unlocked(int c, FILE *f) {
if (c == -1) return -1;
if (f->beg) {
f->buf[--f->beg] = c;
if (c != f->buf[--f->beg]) {
f->buf[f->beg] = c;
}
} else if (f->end < f->size) {
memmove(f->buf + 1, f->buf, f->end++);
f->buf[0] = c;