support ungetc