changeset 24175:fadab2fc567f stable

Properly restore the input stream pointer at end of textscan (bug #52116 et al.) * oct-stream.cc (delimited_stream::refresh_buf): Do not update stream pointer buf_in_file from the current input stream position unless the delimited stream buffer is completely empty, e.g., at start of processing.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Wed, 27 Sep 2017 03:58:28 -0500
parents 7db56856b870
children d2ef665c7c91 379efee40924
files libinterp/corefcn/oct-stream.cc
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc	Mon Oct 16 19:45:02 2017 +0200
+++ b/libinterp/corefcn/oct-stream.cc	Wed Sep 27 03:58:28 2017 -0500
@@ -1468,6 +1468,8 @@
         buf_in_file += (idx - buf);
         memmove (buf, idx, old_remaining);
       }
+    else
+      buf_in_file = i_stream.tellg ();    // record for destructor
 
     progress_marker -= idx - buf;         // where original idx would have been
     idx = buf;
@@ -1475,7 +1477,6 @@
     int gcount;   // chars read
     if (! i_stream.eof ())
       {
-        buf_in_file = i_stream.tellg ();   // record for destructor
         i_stream.read (buf + old_remaining, bufsize - old_remaining);
         gcount = i_stream.gcount ();
       }