반응형
wint_t ungetwc(wint_t wc, FILE *fp)
#include <errno.h> #include <stdio.h> #include <wchar.h> #include "local.h" wint_t ungetwc(wint_t wc, FILE *fp) { struct wchar_io_data *wcio; if (wc == WEOF) return WEOF; flockfile(fp); _SET_ORIENTATION(fp, 1); /* * XXX since we have no way to transform a wchar string to * a char string in reverse order, we can't use ungetc. */ /* XXX should we flush ungetc buffer? */ wcio = WCIO_GET(fp); if (wcio == 0) { funlockfile(fp); errno = ENOMEM; /* XXX */ return WEOF; } if (wcio->wcio_ungetwc_inbuf >= WCIO_UNGETWC_BUFSIZE) { funlockfile(fp); return WEOF; } wcio->wcio_ungetwc_buf[wcio->wcio_ungetwc_inbuf++] = wc; __sclearerr(fp); funlockfile(fp); return wc; }
반응형