summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-15 01:53:43 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-15 01:53:43 +0000
commitf1015055c78bcdf3ecbcf4b77d689e15cd39f89c (patch)
tree36af4e0cbb1f0d8e076f231c0d95fdfaa9a90049 /libgfortran
parent2df8008620a31efa38bc481ae67180d7716b3b5b (diff)
downloadgcc-f1015055c78bcdf3ecbcf4b77d689e15cd39f89c.tar.gz
2007-04-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* io/open.c (test_endfile): Revert changes for 31052, restoring this function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123842 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/open.c23
2 files changed, 29 insertions, 1 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 17f0885c48c..153a442a22a 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,9 +1,14 @@
+2007-04-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ * io/open.c (test_endfile): Revert changes for 31052, restoring this
+ function.
+
2007-04-14 Steve Ellcey <sje@cup.hp.com>
* Makefile.am: Add -I .. to ACLOCAL_AMFLAGS. Add libgfortran_la_LINK.
* Makefile.in: Regenerate.
-2007-04-11 Kai Tietz <kai.tietz@onevision.com>
+2007-04-11 Kai Tietz <kai.tietz@onevision.com>
* configure: Regenerate.
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 742610a3ef6..55c376939e8 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -109,6 +109,20 @@ static const st_option convert_opt[] =
{ NULL, 0}
};
+
+/* Given a unit, test to see if the file is positioned at the terminal
+ point, and if so, change state from NO_ENDFILE flag to AT_ENDFILE.
+ This prevents us from changing the state from AFTER_ENDFILE to
+ AT_ENDFILE. */
+
+static void
+test_endfile (gfc_unit * u)
+{
+ if (u->endfile == NO_ENDFILE && file_length (u->s) == file_position (u->s))
+ u->endfile = AT_ENDFILE;
+}
+
+
/* Change the modes of a file, those that are allowed * to be
changed. */
@@ -195,6 +209,8 @@ edit_modes (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
u->current_record = 0;
u->last_record = 0;
+
+ test_endfile (u);
break;
case POSITION_APPEND:
@@ -472,6 +488,13 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags)
memmove (u->file, opp->file, opp->file_len);
u->file_len = opp->file_len;
+ /* Curiously, the standard requires that the
+ position specifier be ignored for new files so a newly connected
+ file starts out at the initial point. We still need to figure
+ out if the file is at the end or not. */
+
+ test_endfile (u);
+
if (flags->status == STATUS_SCRATCH && opp->file != NULL)
free_mem (opp->file);
return u;