# HG changeset patch # User Carlo de Falco # Date 1330870923 -3600 # Node ID 180a347c2ffcd7c7a1e8256f6a03e128e61ead52 # Parent 099bd779466c599a3fb545d155d1e6a1b98b4d59 fix bug in input validation for textread * textread.m: fix a bug in input validation when headerlines is the only option passed diff -r 099bd779466c -r 180a347c2ffc scripts/io/textread.m --- a/scripts/io/textread.m Fri Mar 02 22:14:27 2012 -0800 +++ b/scripts/io/textread.m Sun Mar 04 15:22:03 2012 +0100 @@ -72,7 +72,7 @@ varargin(headerlines:headerlines+1) = []; endif - if (nargin > 2 && isnumeric (varargin{1})) + if (numel (varargin) && isnumeric (varargin{1})) nlines = varargin{1}; else nlines = Inf; @@ -140,6 +140,13 @@ %! assert (b, d(4:5, 2), 1e-2); %! assert (c, d(4:5, 3), 1e-2); +%!test +%! f = tmpnam (); +%! d = rand (5, 3); +%! dlmwrite (f, d, "precision", "%5.2f"); +%! [a, b, c] = textread (f, "%f, %f, %f", "headerlines", 3); +%! unlink (f); + %% Test input validation %!error textread () %!error textread (1)