Mercurial > octave
diff libinterp/corefcn/file-io.cc @ 21621:fe0a6de805e4
textscan: Leave file read position correct at exit (bug #47671)
* oct-stream.cc (delimited_stream::refresh_buf): Track movement of data within
the buffer.
* file-io.cc (Ftextscan): New BIST test.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Tue, 12 Apr 2016 21:05:50 +1000 |
parents | 6fab85c1538f |
children | fed1111e1899 |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Wed Apr 13 14:50:32 2016 -0700 +++ b/libinterp/corefcn/file-io.cc Tue Apr 12 21:05:50 2016 +1000 @@ -1872,6 +1872,18 @@ %! assert (A{4}, [4 ; 8], 1e-6); %! assert (E); +## Test leaving the file at the correct position on exit +%!test +%! f = tempname (); +%! fid = fopen (f, "w+"); +%! fprintf (fid, "1,2\n3,4\n"); +%! fseek (fid, 0, "bof"); +%! A = textscan (fid, "%s %f", 2, "Delimiter", ","); +%! E = ftell (fid); +%! fclose (fid); +%! unlink (f); +%! assert (E, 8); + ## Tests reading with empty format; empty fields & incomplete lower row %!test %! f = tempname ();