This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran] PR libfortran/20006
- From: FX Coudert <fxcoudert at gmail dot com>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 23 May 2005 00:22:40 +0200
- Subject: [gfortran] PR libfortran/20006
Attached patch allows the use of the $ edit descriptor as a request for
non-advancing I/O. It comes with some tests to warn that this is an
extension, when it is possible at compile-time. Run-time warnings will
be added once a library warning framework is put in place.
Regtesting nearing completion on i686-linux. OK for mainline and 4.0?
FX
2005-05-22 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20006
* io.c (format_item_1): Add check and extension warning for
$ edit descriptor.
2005-05-22 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20006
* io/format.c (parse_format_list): Set repeat count of $ format
node to 1.
* io/transfer.c (read_sf): Add g.seen_dollar to the test
concerning advancing I/O.
(data_transfer_init): Likewise.
(finalize_transfer): Likewise.
Index: gcc/fortran/io.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/io.c,v
retrieving revision 1.22
diff -p -u -r1.22 io.c
--- gcc/fortran/io.c 11 May 2005 22:32:02 -0000 1.22
+++ gcc/fortran/io.c 22 May 2005 22:12:10 -0000
@@ -491,6 +491,10 @@ format_item_1:
case FMT_DOLLAR:
t = format_lex ();
+
+ if (gfc_notify_std (GFC_STD_GNU, "Extension: $ descriptor at %C")
+ == FAILURE)
+ return FAILURE;
if (t != FMT_RPAREN || level > 0)
{
error = "$ must the last specifier";
Index: libgfortran/io/format.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/format.c,v
retrieving revision 1.12
diff -p -u -r1.12 format.c
--- libgfortran/io/format.c 17 May 2005 16:54:52 -0000 1.12
+++ libgfortran/io/format.c 22 May 2005 22:12:19 -0000
@@ -579,6 +579,7 @@ parse_format_list (void)
case FMT_DOLLAR:
get_fnode (&head, &tail, FMT_DOLLAR);
+ tail->repeat = 1;
goto between_desc;
case FMT_T:
Index: libgfortran/io/transfer.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/transfer.c,v
retrieving revision 1.41
diff -p -u -r1.41 transfer.c
--- libgfortran/io/transfer.c 17 May 2005 16:54:51 -0000 1.41
+++ libgfortran/io/transfer.c 22 May 2005 22:12:19 -0000
@@ -191,7 +191,7 @@ read_sf (int *length)
/* If we see an EOR during non-advancing I/O, we need to skip
the rest of the I/O statement. Set the corresponding flag. */
- if (advance_status == ADVANCE_NO)
+ if (advance_status == ADVANCE_NO || g.seen_dollar)
eor_condition = 1;
/* Without padding, terminate the I/O statement without assigning
@@ -1187,7 +1187,7 @@ data_transfer_init (int read_flag)
}
else
{
- if (advance_status == ADVANCE_YES)
+ if (advance_status == ADVANCE_YES && !g.seen_dollar)
current_unit->read_bad = 1;
}
@@ -1459,11 +1459,12 @@ finalize_transfer (void)
{
free_fnodes ();
- if (advance_status == ADVANCE_NO)
+ if (advance_status == ADVANCE_NO || g.seen_dollar)
{
/* Most systems buffer lines, so force the partial record
to be written out. */
flush (current_unit->s);
+ g.seen_dollar = 0;
return;
}
! { dg-do run }
! PR libfortran/20006
character*5 c
open (42,status='scratch')
write (42,'(A,$)') 'abc'
write (42,'(A)') 'de'
rewind (42)
read (42,'(A)') c
close (42)
if (c /= 'abcde') call abort
end