diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-04 05:48:56 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-04 05:48:56 +0000 |
commit | e6e189fa270c5aa4aa168eef3935aa7e40f30175 (patch) | |
tree | a92ff5b1a65fe78279e0fd8b82fac273d28a6181 /libgfortran/io | |
parent | 469cf0eb8ebe007ed2ed6d9b694396fb8216f80b (diff) | |
download | gcc-e6e189fa270c5aa4aa168eef3935aa7e40f30175.tar.gz |
2009-05-04 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r147090
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@147091 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/file_pos.c | 20 | ||||
-rw-r--r-- | libgfortran/io/intrinsics.c | 14 |
2 files changed, 15 insertions, 19 deletions
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) |