diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-30 15:12:37 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-30 15:12:37 +0000 |
commit | 7ee4f67a4372ce1c2a9ef5510a6a6de4d55eb540 (patch) | |
tree | 164be18da851f117899e247478ee56e7245b26dc /libgfortran | |
parent | f274e293da2a206765d9449aa09bf6c64ce1a9c1 (diff) | |
download | gcc-7ee4f67a4372ce1c2a9ef5510a6a6de4d55eb540.tar.gz |
Fix PR libfortran/39667
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147004 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 7 | ||||
-rw-r--r-- | libgfortran/io/file_pos.c | 20 | ||||
-rw-r--r-- | libgfortran/io/intrinsics.c | 14 |
3 files changed, 22 insertions, 19 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 6763ad1a993..8b2fb21704f 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2009-04-30 Janne Blomqvist <jb@gcc.gnu.org> + + PR libfortran/39667 + * io/file_pos.c (st_rewind): Don't truncate or flush. + * io/intrinsics.c (fgetc): Flush if switching mode. + (fputc): Likewise. + 2009-04-18 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/39782 diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c index 84992323918..c1690173658 100644 --- a/libgfortran/io/file_pos.c +++ b/libgfortran/io/file_pos.c @@ -341,26 +341,8 @@ st_rewind (st_parameter_filepos *fpp) u->previous_nonadvancing_write = 0; - /* Flush the buffers. If we have been writing to the file, the last - written record is the last record in the file, so truncate the - file now. Reset to read mode so two consecutive rewind - statements do not delete the file contents. */ - if (u->mode == WRITING) - { - /* unit_truncate takes care of flushing. */ - unit_truncate (u, stell (u->s), &fpp->common); - /* .. but we still need to reset since we're going to seek. */ - fbuf_reset (u); - } - else - { - /* Make sure buffers are reset. */ - if (u->flags.form == FORM_FORMATTED) - fbuf_reset (u); - sflush (u->s); - } + fbuf_reset (u); - u->mode = READING; u->last_record = 0; if (sseek (u->s, 0, SEEK_SET) < 0) diff --git a/libgfortran/io/intrinsics.c b/libgfortran/io/intrinsics.c index 0a894aac43e..0e33e8490da 100644 --- a/libgfortran/io/intrinsics.c +++ b/libgfortran/io/intrinsics.c @@ -46,6 +46,13 @@ PREFIX(fgetc) (const int * unit, char * c, gfc_charlen_type c_len) if (u == NULL) return -1; + fbuf_reset (u); + if (u->mode == WRITING) + { + sflush (u->s); + u->mode = READING; + } + memset (c, ' ', c_len); ret = sread (u->s, c, 1); unlock_unit (u); @@ -118,6 +125,13 @@ PREFIX(fputc) (const int * unit, char * c, if (u == NULL) return -1; + fbuf_reset (u); + if (u->mode == READING) + { + sflush (u->s); + u->mode = WRITING; + } + s = swrite (u->s, c, 1); unlock_unit (u); if (s < 0) |