iconv: add aliases for GBK
[musl.git] / src / stdio / ungetc.c
blobbc629d4ca511f812976abb93224e2732e0788e6e
1 #include "stdio_impl.h"
3 int ungetc(int c, FILE *f)
5 if (c == EOF) return c;
7 FLOCK(f);
9 if (!f->rpos) __toread(f);
10 if (!f->rpos || f->rpos <= f->buf - UNGET) {
11 FUNLOCK(f);
12 return EOF;
15 *--f->rpos = c;
16 f->flags &= ~F_EOF;
18 FUNLOCK(f);
19 return (unsigned char)c;