Mercurial > hg > octave-lyh
changeset 16305:23636765e00a
textscan.m: re-enable reading from file id, test added (bug #38517)
author | Philip Nienhuis <prnienhuis@users.sf.net> |
---|---|
date | Thu, 14 Mar 2013 23:38:22 +0100 |
parents | c8e1b0213e34 |
children | 4a3b6a80db2e |
files | scripts/io/textscan.m |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -183,7 +183,10 @@ elseif (args{headerlines + 1} < 0) warning ("textscan.m: negative headerline value ignored"); endif - endif + endif + ## Read a first file chunk. Rest follows after endofline processing + [str, count] = fscanf (fid, "%c", BUFLENGTH); + endif ## Check for empty result @@ -507,6 +510,19 @@ %! assert (strcmp (lh, rh)); %! end +%% Test reading from a real file +%!test +%! f = tmpnam (); +%! fid = fopen (f, "w+"); +%! d = rand (1, 4); +%! fprintf (fid, " %f %f %f %f ", d); +%! fseek (fid, 0, "bof"); +%! A = textscan (fid, "%f %f"); +%! fclose (fid); +%! unlink (f); +%! assert (A{1}, [d(1); d(3)], 1e-6); +%! assert (A{2}, [d(2); d(4)], 1e-6); + %!error <missing or illegal value for> textread (file_in_loadpath ("textscan.m"), "", "headerlines") %!error <missing or illegal value for> textread (file_in_loadpath ("textscan.m"), "", "headerlines", 'hh') %!error <character value required for> textread (file_in_loadpath ("textscan.m"), "", "endofline", true)