[committed] PR92100 Formatted stream IO irreproducible read with binary data in file

Message ID 29e80b0a-c259-8f4b-3c64-82a6863cb223@charter.net
State New
Headers show
Series
  • [committed] PR92100 Formatted stream IO irreproducible read with binary data in file
Related show

Commit Message

Jerry Nov. 24, 2019, 10:20 p.m.
Committed this as simple one liner.  I will probably backport this in a few days.

Jerry

Committed r278660
	M	libgfortran/ChangeLog
	M	libgfortran/io/transfer.c

2019-11-24  Jerry DeLisle  <jvdelisle@gcc.ngu.org>

	PR fortran/92100
	io/transfer.c (data_transfer_init_worker): Use fbuf_reset
	instead of fbuf_flush before the seek. Note that fbuf_reset
	calls fbuf_flush and adjusts fbuf pointers.

                    return;

Comments

Jerry Nov. 25, 2019, 2:29 a.m. | #1
On 11/24/19 2:20 PM, Jerry DeLisle wrote:
> Committed this as simple one liner.  I will probably backport this in a few days.

> 

> Jerry

> 

> Committed r278660

>      M    libgfortran/ChangeLog

>      M    libgfortran/io/transfer.c

> 

> 2019-11-24  Jerry DeLisle  <jvdelisle@gcc.ngu.org>

> 

>      PR fortran/92100

>      io/transfer.c (data_transfer_init_worker): Use fbuf_reset

>      instead of fbuf_flush before the seek. Note that fbuf_reset

>      calls fbuf_flush and adjusts fbuf pointers.


Also commited a testcase, streamio_18.f90.

Jerry

Patch

diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 6382d0dad09..bb104db3584 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -3273,8 +3273,9 @@  data_transfer_init_worker (st_parameter_dt *dtp, int 
read_flag)

            if (dtp->pos != dtp->u.p.current_unit->strm_pos)
              {
-              fbuf_flush (dtp->u.p.current_unit, dtp->u.p.mode);
-              if (sseek (dtp->u.p.current_unit->s, dtp->pos - 1, SEEK_SET) < 0)
+	      fbuf_reset (dtp->u.p.current_unit);
+	      if (sseek (dtp->u.p.current_unit->s, dtp->pos - 1,
+			 SEEK_SET) < 0)
                  {
                    generate_error (&dtp->common, LIBERROR_OS, NULL);