From 3bddec9b927ffbd4064cdbb593949b70db07d9b0 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Wed, 22 Sep 2010 03:10:24 +0000 Subject: re PR libfortran/45723 (opening /dev/null for appending writes) 2010-09-21 Jerry DeLisle PR libfortran/45723 * io/open.c (new_unit): On POSITION_APPEND don't seek if file length is zero. From-SVN: r164507 --- libgfortran/ChangeLog | 9 ++++++++- libgfortran/io/open.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index bd4243f..8411513 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2010-09-21 Jerry DeLisle + + PR libfortran/45723 + * io/open.c (new_unit): On POSITION_APPEND don't seek if file length is + zero. + 2010-09-14 Jerry DeLisle PR libfortran/45532 @@ -6,7 +12,8 @@ 2010-09-12 Francois-Xavier Coudert - * intrinsics/pack_generic.c (pack): Add missing return and fix whitespace. + * intrinsics/pack_generic.c (pack): Add missing return and fix + whitespace. * intrinsics/cshift0.c (cshift0): Fix whitespace. * intrinsics/unpack_generic.c (unpack1, unpack0): Fix whitespace. diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index be8f4bb..d7448c0 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -555,7 +555,7 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags) if (flags->position == POSITION_APPEND) { - if (sseek (u->s, 0, SEEK_END) < 0) + if (file_size (opp->file, opp->file_len) > 0 && sseek (u->s, 0, SEEK_END) < 0) generate_error (&opp->common, LIBERROR_OS, NULL); u->endfile = AT_ENDFILE; } -- cgit v1.1