diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index f00d41a09..e9e00dfec 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -272,49 +272,15 @@ _sungetwc_r (struct _reent *data, /* After ungetc, we won't be at eof anymore */ fp->_flags &= ~__SEOF; - /* - * If we are in the middle of ungetwc'ing, just continue. - * This may require expanding the current ungetc buffer. + /* All ungetwc usage in scanf un-gets the current character, so + * just back up over the string if we aren't at the start */ - - if (HASUB (fp)) - { - if (fp->_r >= fp->_ub._size && __submore (data, fp)) - { - return EOF; - } - fp->_p -= sizeof (wchar_t); - *fp->_p = (wchar_t) wc; - fp->_r += sizeof (wchar_t); - return wc; - } - - /* - * If we can handle this by simply backing up, do so, - * but never replace the original character. - * (This makes swscanf() work when scanning `const' data.) - */ - - if (fp->_bf._base != NULL && fp->_p > fp->_bf._base - && ((wchar_t *)fp->_p)[-1] == wc) + if (fp->_bf._base != NULL && fp->_p > fp->_bf._base) { fp->_p -= sizeof (wchar_t); fp->_r += sizeof (wchar_t); - return wc; } - /* - * Create an ungetc buffer. - * Initially, we will use the `reserve' buffer. - */ - - fp->_ur = fp->_r; - fp->_up = fp->_p; - fp->_ub._base = fp->_ubuf; - fp->_ub._size = sizeof (fp->_ubuf); - fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - sizeof (wchar_t)]; - *(wchar_t *) fp->_p = wc; - fp->_r = 2; return wc; }