aboutsummaryrefslogtreecommitdiff
path: root/libio/wfileops.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-07-15 23:37:22 +0000
committerUlrich Drepper <drepper@redhat.com>2002-07-15 23:37:22 +0000
commit706d1dee4692cc5419275fcddc4518933ff2a39e (patch)
treec795b0e8236092f2345ac7803181e41c13c5427c /libio/wfileops.c
parentc3da4f0cba685e6918d2babb286bd731ae7eab71 (diff)
downloadglibc-706d1dee4692cc5419275fcddc4518933ff2a39e.zip
glibc-706d1dee4692cc5419275fcddc4518933ff2a39e.tar.gz
glibc-706d1dee4692cc5419275fcddc4518933ff2a39e.tar.bz2
Update.
2002-07-15 Ulrich Drepper <drepper@redhat.com> * libio/wfileops.c (_IO_wfile_seekoff): Reposition wide pointers and adjust state for seek position. [PR libc/4070] * libio/Makefile (tests): Add bug-rewind. * libio/bug-rewind.c: New file.
Diffstat (limited to 'libio/wfileops.c')
-rw-r--r--libio/wfileops.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b633daf..04a8f27 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -635,6 +635,10 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
#endif
if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
{
+ enum __codecvt_result status;
+ struct _IO_codecvt *cd = fp->_codecvt;
+ const char *read_ptr_copy;
+
fp->_IO_read_ptr = fp->_IO_read_base + rel_offset;
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
@@ -643,11 +647,33 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
pointer is somewhere in the current external buffer
this does not mean we can convert this whole buffer
at once fitting in the internal buffer. */
+ fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
+ read_ptr_copy = fp->_IO_read_base;
+ fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
do
{
-
+ wchar_t buffer[1024];
+ wchar_t *ignore;
+ status = (*cd->__codecvt_do_in) (cd,
+ &fp->_wide_data->_IO_state,
+ read_ptr_copy,
+ fp->_IO_read_ptr,
+ &read_ptr_copy,
+ buffer,
+ buffer
+ + (sizeof (buffer)
+ / sizeof (buffer[0])),
+ &ignore);
+ if (status != __codecvt_ok && status != __codecvt_partial)
+ {
+ fp->_flags |= _IO_ERR_SEEN;
+ goto dumb;
+ }
}
- while (0);
+ while (read_ptr_copy != fp->_IO_read_ptr);
+
+ fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end
+ = fp->_wide_data->_IO_read_base;
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
goto resync;