Mercurial > hg > octave-nkf
changeset 19528:a791930c3bda stable
oct-stream.cc::read: Fix calculation of nc when EOF gets hit (bug #43517)
* oct-stream.cc::read: Fix nc if EOF was hit before the requested number
of rows and columns were read.
* io.tst: Add test for bug #43517
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Fri, 14 Nov 2014 22:35:19 +0100 |
parents | ed1bf35dc11c |
children | 1213af866a89 |
files | libinterp/corefcn/oct-stream.cc test/io.tst |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc +++ b/libinterp/corefcn/oct-stream.cc @@ -3330,6 +3330,8 @@ { if (count % nr != 0) nc = count / nr + 1; + else + nc = count / nr; if (count < nr) nr = count;
--- a/test/io.tst +++ b/test/io.tst @@ -604,3 +604,12 @@ %! assert (data, [256, 1798; 770, 3083; 1284, 3597]); %! assert (count, 6); %! fclose (id); + +%!test +%! id = tmpfile (); +%! fwrite (id, "abcd"); +%! frewind (id); +%! [data, count] = fread (id, [2, 3], "char"); +%! assert (data, [97, 99; 98, 100]); +%! assert (count, 4); +%! fclose (id);