mirror of git://sourceware.org/git/glibc.git
Cleanup _IO_wfile_seekoff.
This reformulates the in-buffer optimisation check to match the code in _IO_new_file_seekoff. No functional changes, but easier to understand.
This commit is contained in:
parent
a050d2a5e7
commit
d840539e12
|
|
@ -1,3 +1,9 @@
|
||||||
|
2009-08-31 Andreas Schwab <schwab@redhat.com>
|
||||||
|
|
||||||
|
* libio/wfileops.c (_IO_wfile_seekoff): Remove dead code and
|
||||||
|
reformulate in-buffer optimisation check to match code in
|
||||||
|
_IO_new_file_seekoff.
|
||||||
|
|
||||||
2009-08-31 Joshua W. Boyer <jwboyer@linux.vnet.ibm.com>
|
2009-08-31 Joshua W. Boyer <jwboyer@linux.vnet.ibm.com>
|
||||||
|
|
||||||
* sysdeps/powerpc/powerpc32/power6/memcpy.S: Change srdi instruction
|
* sysdeps/powerpc/powerpc32/power6/memcpy.S: Change srdi instruction
|
||||||
|
|
|
||||||
114
libio/wfileops.c
114
libio/wfileops.c
|
|
@ -678,88 +678,56 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
|
||||||
if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
|
if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
|
||||||
&& !_IO_in_backup (fp))
|
&& !_IO_in_backup (fp))
|
||||||
{
|
{
|
||||||
/* Offset relative to start of main get area. */
|
_IO_off64_t start_offset = (fp->_offset
|
||||||
_IO_off64_t rel_offset = (offset - fp->_offset
|
- (fp->_IO_read_end - fp->_IO_buf_base));
|
||||||
+ (fp->_IO_read_end - fp->_IO_read_base));
|
if (offset >= start_offset && offset < fp->_offset)
|
||||||
if (rel_offset >= 0)
|
|
||||||
{
|
{
|
||||||
#if 0
|
enum __codecvt_result status;
|
||||||
if (_IO_in_backup (fp))
|
struct _IO_codecvt *cd = fp->_codecvt;
|
||||||
_IO_switch_to_main_get_area (fp);
|
const char *read_ptr_copy;
|
||||||
#endif
|
|
||||||
if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
|
_IO_setg (fp, fp->_IO_buf_base,
|
||||||
|
fp->_IO_buf_base + (offset - start_offset),
|
||||||
|
fp->_IO_read_end);
|
||||||
|
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
|
||||||
|
|
||||||
|
/* Now set the pointer for the internal buffer. This
|
||||||
|
might be an iterative process. Though the read
|
||||||
|
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
|
||||||
{
|
{
|
||||||
enum __codecvt_result status;
|
wchar_t buffer[1024];
|
||||||
struct _IO_codecvt *cd = fp->_codecvt;
|
wchar_t *ignore;
|
||||||
const char *read_ptr_copy;
|
status = (*cd->__codecvt_do_in) (cd,
|
||||||
|
&fp->_wide_data->_IO_state,
|
||||||
fp->_IO_read_ptr = fp->_IO_read_base + rel_offset;
|
read_ptr_copy,
|
||||||
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
|
fp->_IO_read_ptr,
|
||||||
|
&read_ptr_copy,
|
||||||
/* Now set the pointer for the internal buffer. This
|
buffer,
|
||||||
might be an iterative process. Though the read
|
buffer
|
||||||
pointer is somewhere in the current external buffer
|
+ (sizeof (buffer)
|
||||||
this does not mean we can convert this whole buffer
|
/ sizeof (buffer[0])),
|
||||||
at once fitting in the internal buffer. */
|
&ignore);
|
||||||
fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
|
if (status != __codecvt_ok && status != __codecvt_partial)
|
||||||
read_ptr_copy = fp->_IO_read_base;
|
|
||||||
fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
wchar_t buffer[1024];
|
fp->_flags |= _IO_ERR_SEEN;
|
||||||
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 (read_ptr_copy != fp->_IO_read_ptr);
|
|
||||||
|
|
||||||
fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
|
|
||||||
|
|
||||||
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
|
|
||||||
goto resync;
|
|
||||||
}
|
|
||||||
#ifdef TODO
|
|
||||||
/* If we have streammarkers, seek forward by reading ahead. */
|
|
||||||
if (_IO_have_markers (fp))
|
|
||||||
{
|
|
||||||
int to_skip = rel_offset
|
|
||||||
- (fp->_IO_read_ptr - fp->_IO_read_base);
|
|
||||||
if (ignore (to_skip) != to_skip)
|
|
||||||
goto dumb;
|
goto dumb;
|
||||||
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
|
}
|
||||||
goto resync;
|
}
|
||||||
}
|
while (read_ptr_copy != fp->_IO_read_ptr);
|
||||||
#endif
|
|
||||||
}
|
fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
|
||||||
#ifdef TODO
|
|
||||||
if (rel_offset < 0 && rel_offset >= Bbase () - Bptr ())
|
|
||||||
{
|
|
||||||
if (!_IO_in_backup (fp))
|
|
||||||
_IO_switch_to_backup_area (fp);
|
|
||||||
gbump (fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
|
|
||||||
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
|
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
|
||||||
goto resync;
|
goto resync;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
INTUSE(_IO_unsave_markers) (fp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fp->_flags & _IO_NO_READS)
|
if (fp->_flags & _IO_NO_READS)
|
||||||
goto dumb;
|
goto dumb;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue