aboutsummaryrefslogtreecommitdiff
path: root/libio/wfileops.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-09 00:11:12 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-09 00:11:12 +0000
commit5e473a71467d30b51faadb7b5ae4305abc0a16d7 (patch)
tree2988eff040e9881835c7f813ff51d180d4ca9555 /libio/wfileops.c
parentca130fe4651a2ca547b05187bdc2804defc8a66b (diff)
downloadglibc-5e473a71467d30b51faadb7b5ae4305abc0a16d7.tar
glibc-5e473a71467d30b51faadb7b5ae4305abc0a16d7.tar.gz
glibc-5e473a71467d30b51faadb7b5ae4305abc0a16d7.tar.bz2
glibc-5e473a71467d30b51faadb7b5ae4305abc0a16d7.zip
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.
Diffstat (limited to 'libio/wfileops.c')
-rw-r--r--libio/wfileops.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/libio/wfileops.c b/libio/wfileops.c
index 04a3f5e64f..e88c0654e5 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -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))
- {
- /* 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->_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;
+ 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 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;
- }
+ if (status == __codecvt_error)
+ {
+ __set_errno (EILSEQ);
+ fp->_flags |= _IO_ERR_SEEN;
+ return WEOF;
}
/* Move the remaining content of the read buffer to the beginning. */