This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/20661] End of record not detected
- From: "Thomas dot Koenig at online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Apr 2005 13:34:27 -0000
- Subject: [Bug libfortran/20661] End of record not detected
- References: <20050327215956.20661.kargl@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From Thomas dot Koenig at online dot de 2005-04-01 13:34 -------
This patch fixes the test case. It also includes my
EOR patch for advancing I/O.
This is regression-tested on mainline. I'll submit a proper
patch when I have finished regression-testing it on 4.0.
--- transfer.c.orig 2005-03-25 14:35:29.000000000 +0100
+++ transfer.c 2005-04-01 15:34:19.000000000 +0200
@@ -150,7 +150,12 @@ read_sf (int *length)
else
p = base = data;
- memset(base,'\0',*length);
+ memset(base,' ',*length);
+
+ /* If we have seen an eor previously, return blanks. */
+
+ if (sf_seen_eor)
+ return base;
current_unit->bytes_left = options.default_recl;
readlen = 1;
@@ -179,12 +184,6 @@ read_sf (int *length)
if (readlen < 1 || *q == '\n' || *q == '\r')
{
- /* ??? What is this for? */
- if (current_unit->unit_number == options.stdin_unit)
- {
- if (n <= 0)
- continue;
- }
/* Unexpected end of line. */
if (current_unit->flags.pad == PAD_NO)
{
@@ -193,8 +192,13 @@ read_sf (int *length)
}
current_unit->bytes_left = 0;
- *length = n;
sf_seen_eor = 1;
+
+ if (advance_status == ADVANCE_NO)
+ ioparm.library_return = LIBRARY_EOR;
+ else
+ *length = n;
+
break;
}
@@ -748,6 +752,9 @@ formatted_transfer (bt type, void *p, in
internal_error ("Bad format node");
}
+ if (ioparm.library_return == LIBRARY_EOR)
+ generate_error (ERROR_EOR, NULL);
+
/* Free a buffer that we had to allocate during a sequential
formatted read of a block that was larger than the static
buffer. */
@@ -1223,7 +1230,10 @@ next_record_r (int done)
length = 1;
/* sf_read has already terminated input because of an '\n' */
if (sf_seen_eor)
- break;
+ {
+ sf_seen_eor=0;
+ break;
+ }
do
{
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20661