mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
update.
* libio/wfileops.c (_IO_wfile_underflow): Remove incorrect test for possible conversion using __codecvt_do_in. * libio/Makefile (tests): Add tst-fgetws. * libio/tst-fgetws.c: New file. * libio/iofgetws.c: Use _IO_ferror_unlocked macros instead of coding the test here.
This commit is contained in:
@ -157,34 +157,28 @@ _IO_wfile_underflow (fp)
|
||||
/* Maybe there is something left in the external buffer. */
|
||||
if (fp->_IO_read_ptr < fp->_IO_read_end)
|
||||
{
|
||||
/* Convert it. */
|
||||
size_t avail_bytes = fp->_IO_read_end - fp->_IO_read_ptr;
|
||||
/* There is more in the external. Convert it. */
|
||||
const char *read_stop = (const char *) fp->_IO_read_ptr;
|
||||
|
||||
if (avail_bytes >= (*cd->__codecvt_do_max_length) (cd))
|
||||
fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state;
|
||||
status = (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state,
|
||||
fp->_IO_read_ptr, fp->_IO_read_end,
|
||||
&read_stop,
|
||||
fp->_wide_data->_IO_read_end,
|
||||
fp->_wide_data->_IO_buf_end,
|
||||
&fp->_wide_data->_IO_read_end);
|
||||
|
||||
fp->_IO_read_ptr = (char *) read_stop;
|
||||
|
||||
/* If we managed to generate some text return the next character. */
|
||||
if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
|
||||
return *fp->_wide_data->_IO_read_ptr;
|
||||
|
||||
if (status == __codecvt_error)
|
||||
{
|
||||
/* There is more in the external. */
|
||||
const char *read_stop = (const char *) fp->_IO_read_ptr;
|
||||
|
||||
fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state;
|
||||
status = (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state,
|
||||
fp->_IO_read_ptr, fp->_IO_read_end,
|
||||
&read_stop,
|
||||
fp->_wide_data->_IO_read_end,
|
||||
fp->_wide_data->_IO_buf_end,
|
||||
&fp->_wide_data->_IO_read_end);
|
||||
|
||||
fp->_IO_read_ptr = (char *) read_stop;
|
||||
|
||||
/* If we managed to generate some text return the next character. */
|
||||
if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
|
||||
return *fp->_wide_data->_IO_read_ptr;
|
||||
|
||||
if (status == __codecvt_error)
|
||||
{
|
||||
__set_errno (EILSEQ);
|
||||
fp->_flags |= _IO_ERR_SEEN;
|
||||
return WEOF;
|
||||
}
|
||||
__set_errno (EILSEQ);
|
||||
fp->_flags |= _IO_ERR_SEEN;
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
/* Move the remaining content of the read buffer to the beginning. */
|
||||
|
Reference in New Issue
Block a user