+2005-09-11 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ PR libfortran/20179
+ * io/unix.c (is_preconnected): Add function to test if a stream
+ corresponds to a preconnected unit.
+ * io/io.h: Add prototype for is_preconnected.
+ * io/transfer.c (data_transfer_init): Do not truncate
+ preconnected units.
+
2005-09-10 Janne Blomqvist <jblomqvi@cc.hut.fi>
* io/unix.c: Remove mmap code.
extern int is_seekable (stream *);
internal_proto(is_seekable);
+extern int is_preconnected (stream *);
+internal_proto(is_preconnected);
+
extern void empty_internal_buffer(stream *);
internal_proto(empty_internal_buffer);
it is always safe to truncate the file on the first write */
if (g.mode == WRITING
&& current_unit->flags.access == ACCESS_SEQUENTIAL
- && current_unit->last_record == 0)
+ && current_unit->last_record == 0 && !is_preconnected(current_unit->s))
struncate(current_unit->s);
current_unit->mode = g.mode;
return fd;
}
+int
+is_preconnected (stream * s)
+{
+ int fd;
+
+ fd = ((unix_stream *) s)->fd;
+ if (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO)
+ return 1;
+ else
+ return 0;
+}
/* write()-- Write a buffer to a descriptor, allowing for short writes */