summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-23 00:13:19 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-23 00:13:19 +0000
commit0947818440f6358a5f23f41ba7bd9849ca05ab30 (patch)
treeebb6f19d686e7bc7043bbf86c7dabbafe6051e15 /libgfortran
parent7c660b5b54deced6ef16faacec97acccc14f27f9 (diff)
downloadgcc-0947818440f6358a5f23f41ba7bd9849ca05ab30.tar.gz
2007-03-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/31052 * file_pos.c: Update Copyright year. * io/open.c (test_endfile): Restore test_endfile to fix SPEC regression. Update Copyright year. * io/io.h: Same. * io/unix.c (is_special): Add missing type for this function. Update Copyright year. * io/transfer.c (next_record_r): Restore test_endfile. (st_read): Fix whitespace. Update Copyright year git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog12
-rw-r--r--libgfortran/io/file_pos.c2
-rw-r--r--libgfortran/io/io.h6
-rw-r--r--libgfortran/io/open.c24
-rw-r--r--libgfortran/io/transfer.c8
-rw-r--r--libgfortran/io/unix.c1
6 files changed, 48 insertions, 5 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 2bf034e066d..1281bbb12ca 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,15 @@
+2007-03-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/31052
+ * file_pos.c: Update Copyright year.
+ * io/open.c (test_endfile): Restore test_endfile to fix SPEC regression.
+ Update Copyright year.
+ * io/io.h: Same.
+ * io/unix.c (is_special): Add missing type for this function.
+ Update Copyright year.
+ * io/transfer.c (next_record_r): Restore test_endfile.
+ (st_read): Fix whitespace. Update Copyright year
+
2007-03-20 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* configure.ac: Add missing check for gettimeofday.
diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
index 085921b04cc..846dae932ec 100644
--- a/libgfortran/io/file_pos.c
+++ b/libgfortran/io/file_pos.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2003, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2003, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by Andy Vaught and Janne Blomqvist
This file is part of the GNU Fortran runtime library (libgfortran).
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h
index 3ec9506abda..26273d9018e 100644
--- a/libgfortran/io/io.h
+++ b/libgfortran/io/io.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -694,6 +695,9 @@ internal_proto(unlock_unit);
/* open.c */
+extern void test_endfile (gfc_unit *);
+internal_proto(test_endfile);
+
extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
internal_proto(new_unit);
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index d22663d9d05..8c6f9fb0618 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005
+/* Copyright (C) 2002, 2003, 2004, 2005, 2007
Free Software Foundation, Inc.
Contributed by Andy Vaught
@@ -109,6 +109,19 @@ 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. */
+
+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 +208,8 @@ edit_modes (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
u->current_record = 0;
u->last_record = 0;
+
+ test_endfile (u); /* We might be at the end. */
break;
case POSITION_APPEND:
@@ -471,6 +486,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;
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index efa788cda52..77e2ab1344a 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
Contributed by Andy Vaught
Namelist transfer functions contributed by Paul Thomas
@@ -2222,6 +2223,9 @@ next_record_r (st_parameter_dt *dtp)
break;
}
+
+ if (dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
+ test_endfile (dtp->u.p.current_unit);
}
@@ -2681,7 +2685,7 @@ st_read (st_parameter_dt *dtp)
data_transfer_init (dtp, 1);
- /* Handle complications dealing with the endfile record. */
+ /* Handle complications dealing with the endfile record. */
if (dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
switch (dtp->u.p.current_unit->endfile)
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 4b9d87f4ee8..458983c4595 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1892,6 +1892,7 @@ is_seekable (stream *s)
/* is_special()-- Return nonzero if the stream is not a regular file. */
+int
is_special (stream *s)
{
return ((unix_stream *) s)->special_file;