diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-01-19 17:51:34 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-01-19 17:51:34 +0000 |
commit | 284749da8bfa7720960381f6681157f6ab44547d (patch) | |
tree | 04d7d91eb0790ff56bcda167adcd1f3e09ffeed5 /libio/wfileops.c | |
parent | 53e9699b6d8562d1f64bb16b558811b766da4e8b (diff) | |
download | glibc-284749da8bfa7720960381f6681157f6ab44547d.tar.gz |
Update.
2002-01-19 Ulrich Drepper <drepper@redhat.com>
* libio/fileops.c (_IO_file_underflow_mmap): Don't define as static.
Set offset if read end wasn't the buffer end.
(_IO_file_seekoff_mmap): New function.
(_IO_file_xsgetn_mmap): New function.
(_IO_file_jumps_mmap): Use the two new functions.
* libio/wfileops.c (_IO_wfile_underflow_mmap): Handle end read buffer
!= end buffer.
* libio/libioP.h: Declare _IO_file_seekoff_mmap and
_IO_file_underflow_mmap.
* libio/iofopen.c: Don't position file descriptor at end of file.
* libio/tst-widetext.c: Improve error messages.
* stdio-common/tst-rndseek.c: Likewise.
Diffstat (limited to 'libio/wfileops.c')
-rw-r--r-- | libio/wfileops.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/libio/wfileops.c b/libio/wfileops.c index 35d201b939..54624f0a61 100644 --- a/libio/wfileops.c +++ b/libio/wfileops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,95,97,98,99,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1993,95,97,98,99,2000,2001,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@cygnus.com>. Based on the single byte version by Per Bothner <bothner@cygnus.com>. @@ -313,6 +313,7 @@ _IO_wfile_underflow_mmap (_IO_FILE *fp) { struct _IO_codecvt *cd; enum __codecvt_result status; + const char *read_stop; if (__builtin_expect (fp->_flags & _IO_NO_READS, 0)) { @@ -326,45 +327,48 @@ _IO_wfile_underflow_mmap (_IO_FILE *fp) cd = fp->_codecvt; /* Maybe there is something left in the external buffer. */ - if (fp->_IO_read_ptr < fp->_IO_read_end) + if (fp->_IO_read_ptr >= fp->_IO_read_end + /* No. But maybe the read buffer is not fully set up. */ + && _IO_file_underflow_mmap (fp) == EOF) { - /* There is more in the external. Convert it. */ - const char *read_stop = (const char *) fp->_IO_read_ptr; + /* Nothing available. */ + fp->_flags |= _IO_EOF_SEEN; + return WEOF; + } + + /* There is more in the external. Convert it. */ + read_stop = (const char *) fp->_IO_read_ptr; - if (fp->_wide_data->_IO_buf_base == NULL) + if (fp->_wide_data->_IO_buf_base == NULL) + { + /* Maybe we already have a push back pointer. */ + if (fp->_wide_data->_IO_save_base != NULL) { - /* Maybe we already have a push back pointer. */ - if (fp->_wide_data->_IO_save_base != NULL) - { - free (fp->_wide_data->_IO_save_base); - fp->_flags &= ~_IO_IN_BACKUP; - } - _IO_wdoallocbuf (fp); + free (fp->_wide_data->_IO_save_base); + fp->_flags &= ~_IO_IN_BACKUP; } + _IO_wdoallocbuf (fp); + } - fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state; - fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr = - fp->_wide_data->_IO_buf_base; - 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_ptr, - fp->_wide_data->_IO_buf_end, - &fp->_wide_data->_IO_read_end); - - fp->_IO_read_ptr = (char *) read_stop; + fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state; + fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr = + fp->_wide_data->_IO_buf_base; + 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_ptr, + fp->_wide_data->_IO_buf_end, + &fp->_wide_data->_IO_read_end); - /* 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; + fp->_IO_read_ptr = (char *) read_stop; - /* There is some garbage at the end of the file. */ - __set_errno (EILSEQ); - fp->_flags |= _IO_ERR_SEEN; - return WEOF; - } + /* 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; - fp->_flags |= _IO_EOF_SEEN; + /* There is some garbage at the end of the file. */ + __set_errno (EILSEQ); + fp->_flags |= _IO_ERR_SEEN; return WEOF; } |