diff options
author | Tobias Burnus <burnus@net-b.de> | 2010-03-29 08:17:19 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2010-03-29 08:17:19 +0200 |
commit | 10fa280a98a0e0b2f3f155262a0886de314f46fc (patch) | |
tree | 0fa226acca58f291807801694e83907d2a7de3c8 /libgfortran/io/unix.c | |
parent | 090f6087fee1dacd55c489f85000d894d8f4f010 (diff) | |
download | gcc-10fa280a98a0e0b2f3f155262a0886de314f46fc.zip gcc-10fa280a98a0e0b2f3f155262a0886de314f46fc.tar.gz gcc-10fa280a98a0e0b2f3f155262a0886de314f46fc.tar.bz2 |
re PR libfortran/43551 (Buffered direct I/O reads wrong record)
2010-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/43551
* io/unix.c (buf_write): Set physical_offset after lseek.
2010-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/43551
* gfortran.dg/direct_io_12.f90: New test.
From-SVN: r157792
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r-- | libgfortran/io/unix.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 4435674..ea3b8bc 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -496,13 +496,17 @@ buf_write (unix_stream * s, const void * buf, ssize_t nbyte) s->ndirty += nbyte; } else - { - if (s->file_length != -1 && s->physical_offset != s->logical_offset - && lseek (s->fd, s->logical_offset, SEEK_SET) < 0) - return -1; - nbyte = raw_write (s, buf, nbyte); - s->physical_offset += nbyte; - } + { + if (s->file_length != -1 && s->physical_offset != s->logical_offset) + { + if (lseek (s->fd, s->logical_offset, SEEK_SET) < 0) + return -1; + s->physical_offset = s->logical_offset; + } + + nbyte = raw_write (s, buf, nbyte); + s->physical_offset += nbyte; + } } s->logical_offset += nbyte; /* Don't increment file_length if the file is non-seekable. */ |