# New Ticket Created by # Please include the string: [perl #41875] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41875 >
The patch makes PIO_unix_seek to update io->fsize value if lseek exceeds the file boundaries.
Index: src/io/io_unix.c =================================================================== --- src/io/io_unix.c (Revision 17524) +++ src/io/io_unix.c (Arbeitskopie) @@ -571,12 +571,25 @@ PIO_unix_seek(Interp *interp, ParrotIOLayer *layer, ParrotIO *io, PIOOFF_T offset, INTVAL whence) { - PIOOFF_T pos; + PIOOFF_T pos, avail; UNUSED(interp); UNUSED(layer); + + if ((pos = lseek(io->fd, offset, whence)) >= 0) { + switch (whence) { + case SEEK_SET: + io->fsize = offset > io->fsize ? offset : io->fsize; + break; + case SEEK_CUR: + avail = io->b.next - io->b.startb + offset; + io->fsize = ( avail > io->fsize) ? avail : io->fsize; + break; + case SEEK_END: + default: + break; + } - if ((pos = lseek(io->fd, offset, whence)) >= 0) { io->lpos = io->fpos; io->fpos = pos; }