From 5e642ab44d458b85bcde5b20dccbb68dbe0cd3d9 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Wed, 8 Feb 2006 20:26:58 +0000 Subject: Merge from gcc-4_1-branch revision 110478. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl/sourcerygxx-4_1@110766 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 17 +++++++++++++++++ libgfortran/io/transfer.c | 27 ++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) (limited to 'libgfortran') diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 3c66b6f0bc0..97285426a74 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,20 @@ +2006-01-28 Jerry DeLisle + + PR libgfortran/25835 + * io/transfer.c (st_read_done): Flush buffers when read is done. + +2006-01-20 Jerry DeLisle + + PR libgfortran/25697 + * io/transfer.c (us_read): Detect end of file condition from previous + operations and bail out (no need to pre-position). + +2006-01-17 Jerry DeLisle + + PR libgfortran/25631 + * io/transfer.c (formatted_transfer_scalar): Adjust pending_spaces and + skips so that TL works correctly when no bytes_used yet. + 2006-01-16 Roger Sayle * intrinsics/c99_functions.c: Add function prototypes to avoid diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 049ebb24771..1d8330fe453 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Andy Vaught Namelist transfer functions contributed by Paul Thomas @@ -868,7 +868,21 @@ formatted_transfer_scalar (st_parameter_dt *dtp, bt type, void *p, int len, case FMT_TL: case FMT_T: if (f->format == FMT_TL) - pos = bytes_used - f->u.n; + { + + /* Handle the special case when no bytes have been used yet. + Cannot go below zero. */ + if (bytes_used == 0) + { + dtp->u.p.pending_spaces -= f->u.n; + dtp->u.p.pending_spaces = dtp->u.p.pending_spaces < 0 ? 0 + : dtp->u.p.pending_spaces; + dtp->u.p.skips -= f->u.n; + dtp->u.p.skips = dtp->u.p.skips < 0 ? 0 : dtp->u.p.skips; + } + + pos = bytes_used - f->u.n; + } else /* FMT_T */ { consume_data_flag = 0; @@ -1205,11 +1219,17 @@ us_read (st_parameter_dt *dtp) int n; gfc_offset i; + if (dtp->u.p.current_unit->endfile == AT_ENDFILE) + return; + n = sizeof (gfc_offset); p = salloc_r (dtp->u.p.current_unit->s, &n); if (n == 0) - return; /* end of file */ + { + dtp->u.p.current_unit->endfile = AT_ENDFILE; + return; /* end of file */ + } if (p == NULL || n != sizeof (gfc_offset)) { @@ -2153,6 +2173,7 @@ export_proto(st_read_done); void st_read_done (st_parameter_dt *dtp) { + flush(dtp->u.p.current_unit->s); finalize_transfer (dtp); free_format_data (dtp); free_ionml (dtp); -- cgit v1.2.3