Author: chromatic
Date: Sat Jun 16 17:13:12 2007
New Revision: 19050
Modified:
trunk/src/io/io_unix.c
Log:
[IO] Update io->fsize if lseek exceeds file boundaries (Ruben Porras, RT
#41875).
Modified: trunk/src/io/io_unix.c
==============================================================================
--- trunk/src/io/io_unix.c (original)
+++ trunk/src/io/io_unix.c Sat Jun 16 17:13:12 2007
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2006, The Perl Foundation.
+Copyright (C) 2001-2007, The Perl Foundation.
$Id$
=head1 NAME
@@ -573,12 +573,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;
+ }
+
io->lpos = io->fpos;
io->fpos = pos;
}