summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorDale Ranta <dir@lanl.gov>2005-04-03 08:07:43 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-04-03 08:07:43 +0000
commit00f07d96bdb702f5c6020d1f447d7572dc1aa452 (patch)
tree1d304b753d205a7b07e5e32e0562a965e1ae648b /libgfortran
parent25af5506aab83668a1d7c0e1efbe88f2b0de3dfb (diff)
downloadgcc-00f07d96bdb702f5c6020d1f447d7572dc1aa452.tar.gz
re PR libfortran/20068 (Backspace problems)
PR libfortran/20068 PR libfortran/20125 PR libfortran/20156 PR libfortran/20471 * io/backspace.c (unformatted_backspace): Fix error in arithmetic. (st_backspace): When in WRITING mode, we flush and falling back into READING mode. In all cases, correctly position the stream. * gfortran.dg/backspace.f: New test. Co-Authored-By: Francois-Xavier Coudert <coudert@clipper.ens.fr> From-SVN: r97478
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog11
-rw-r--r--libgfortran/io/backspace.c15
2 files changed, 22 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 027263899d0..ebcac0bb919 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-03 Dale Ranta <dir@lanl.gov>
+ Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ PR libfortran/20068
+ PR libfortran/20125
+ PR libfortran/20156
+ PR libfortran/20471
+ * io/backspace.c (unformatted_backspace): Fix error in arithmetic.
+ (st_backspace): When in WRITING mode, we flush and falling back
+ into READING mode. In all cases, correctly position the stream.
+
2005-03-31 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20660
diff --git a/libgfortran/io/backspace.c b/libgfortran/io/backspace.c
index f8ab01c3488..225f69cc45a 100644
--- a/libgfortran/io/backspace.c
+++ b/libgfortran/io/backspace.c
@@ -111,7 +111,7 @@ unformatted_backspace (void)
if (p == NULL)
goto io_error;
- new = file_position (current_unit->s) - *p - length;
+ new = file_position (current_unit->s) - *p - 2*length;
if (sseek (current_unit->s, new) == FAILURE)
goto io_error;
@@ -155,16 +155,23 @@ st_backspace (void)
u->endfile = AT_ENDFILE;
else
{
- if (u->current_record)
- next_record (1);
-
if (file_position (u->s) == 0)
goto done; /* Common special case */
+ if (u->mode == WRITING)
+ {
+ flush (u->s);
+ struncate (u->s);
+ u->mode = READING;
+ }
+
if (u->flags.form == FORM_FORMATTED)
formatted_backspace ();
else
unformatted_backspace ();
+
+ u->endfile = NO_ENDFILE;
+ u->current_record = 0;
}
done: