[PATCH][BZ #14543] Fix fseek behaviour when called in wide mode
Siddhesh Poyarekar
siddhesh@redhat.com
Tue Sep 4 16:35:00 GMT 2012
Hi,
This is a patch to fix the problem Jeff Law had posted about in July:
http://sourceware.org/ml/libc-alpha/2012-07/msg00179.html
When fseek is called in wide mode, i.e. when the locale uses a
multibyte character set, it does not set the internal buffer state
correctly due to which, an ftell following it returns an invalid file
offset. This can be reproduced reliably with the reproducer program in
the bugzilla.
The attached patch sets the internal buffer state correctly whenever
the external buffer state is modified by fseek. This involves either
computing the current _IO_read_ptr/end for the internal buffer based on
the new _IO_read_ptr in the external buffer or converting the content
read into the external buffer, up to the extent of the requested fseek
offset.
The patch also includes a test case that verifies the fix. I have
verified that the patch does not cause a regression in the testsuite on
my F16 x86_64.
Regards,
Siddhesh
ChangeLog:
* libio/Makefile (tests): New test case tst-fseek.
* libio/tst-fseek.c: New test case to verify that fseek/ftell
combination works in wide mode.
* libio/wfileops.c (_IO_wfile_seekoff): Adjust internal buffer
state when the external buffer state changes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wide-fseek.patch
Type: text/x-patch
Size: 6888 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120904/a200eb84/attachment.bin>
More information about the Libc-alpha
mailing list