Changes between Version 2 and Version 3 of Ticket #3145, comment 8


Ignore:
Timestamp:
Dec 30, 2010, 3:54:40 AM (13 years ago)
Author:
hamish

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3145, comment 8

    v2 v3  
    1 Before putting back the characters it switches to the backup buffer, which moves _IO_read_base back into that area. Take a look at _IO_default_pbackfail.
     1I got tst-fseek.c from the latest glibc. After disabling all the stats-related tests (stat64 stuff missing), one fread test fails. Without my patch, four fseek tests also fail.
    22
    3 I got tst-fseek.c from the latest glibc. After disabling all the stats-related tests (stat64 stuff missing), one fread test fails. Without my patch, four fseek tests also fail.
     3Yes, I was wrong about why it worked. I think I've figured it out now.
     4
     5The main read area starts at _IO_buf_base (see _IO_switch_to_get_mode). The put-back read area actually exists elsewhere in memory and isn't contiguous with the main read area. When the two areas are switched between, _IO_read_base is moved. After an ungetc(), _IO_read_base points to the put-back area, so any subsequent call to fseek() seeks in there, which it shouldn't.
     6
     7Given that fseek() should ignore put-back characters, it makes sense to seek relative to the position of the normal read buffer, which is _IO_buf_base.