Discussion:
[patch, libgfortran] PR78351 comma not terminating READ of formatted input field
Jerry DeLisle
2018-11-03 22:33:07 UTC
Permalink
Hi all,

The attached patch adds code in read_sf_internal to handle early
termination of reads in the presence of comma's. This is to support
legacy codes which are not standard conforming as far as we can tell.

The additions are executed only if -std=legacy is given at compile time.
It does not support kind=4 internal units since in legacy years there
should be no kind=4 internal units.

I have provuded a simplified test case for various combinations of comma
embedded strings.

This has been regression tested on x86_64-pc-linux-gnu.

OK for trunk?

This use to work way back in early versions so should probably go to 7
and 8 branches. Opinions welcome.

Regards,

Jerry

2018-11-04 Jerry DeLisle <***@gcc.gnu.org>

* io/transfer.c (read_sf_internal): Add support for early
comma termination of internal unit formatted reads.
Andreas Schwab
2018-11-04 06:48:13 UTC
Permalink
+ /* To support legacy code we have to scan the input string one byte
+ at a time because we don't no where an early comma may be and the
s/no/know/

Andreas.
--
Andreas Schwab, ***@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Bernhard Reutner-Fischer
2018-11-04 09:51:43 UTC
Permalink
On Sat, 3 Nov 2018 15:33:07 -0700
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 31198a3cc39..0d26101cef0 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -260,22 +250,80 @@ read_sf_internal (st_parameter_dt *dtp, size_t *length)
sseek (dtp->u.p.current_unit->s, -1, SEEK_CUR);
}
- lorig = *length;
- if (is_char4_unit(dtp))
+ /* To support legacy code we have to scan the input string one byte
+ at a time because we don't no where an early comma may be and the
As Andreas said s/no/know/
+ requested length could go passed the end of a comma shortened
s/passed/past/
+ /* Get the first chracter of the string to establish the base
s/chracter/character/
+ /* Now we scan the rest and exit deal with an end-of-file
s/ exit// ?
Jerry DeLisle
2018-11-04 15:14:09 UTC
Permalink
Post by Bernhard Reutner-Fischer
On Sat, 3 Nov 2018 15:33:07 -0700
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 31198a3cc39..0d26101cef0 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -260,22 +250,80 @@ read_sf_internal (st_parameter_dt *dtp, size_t *length)
sseek (dtp->u.p.current_unit->s, -1, SEEK_CUR);
}
- lorig = *length;
- if (is_char4_unit(dtp))
+ /* To support legacy code we have to scan the input string one byte
+ at a time because we don't no where an early comma may be and the
As Andreas said s/no/know/
+ requested length could go passed the end of a comma shortened
s/passed/past/
+ /* Get the first chracter of the string to establish the base
s/chracter/character/
+ /* Now we scan the rest and exit deal with an end-of-file
s/ exit// ?
Fixed all my typos, thanks.

Jerry
Thomas Koenig
2018-11-08 19:13:52 UTC
Permalink
Hi Jerry!
Post by Jerry DeLisle
Hi all,
The attached patch adds code in read_sf_internal to handle early
termination of reads in the presence of comma's. This is to support
legacy codes which are not standard conforming as far as we can tell.
The additions are executed only if -std=legacy is given at compile time.
 It does not support kind=4 internal units since in legacy years there
should be no kind=4 internal units.
I have provuded a simplified test case for various combinations of comma
embedded strings.
This has been regression tested on x86_64-pc-linux-gnu.
OK for trunk?
Yes, OK. I like the fact that the old, slow behavior is restricted
to -std=legacy :-)
Post by Jerry DeLisle
This use to work way back in early versions so should probably go to 7
and 8 branches. Opinions welcome.
I agree, it should go in.

Thanks a lot for the patch!

Regards

Thomas

Loading...