Mercurial > hg > octave-nkf
diff scripts/io/strread.m @ 16306:4a3b6a80db2e
strread.m: fix division by zero when called with no output args; test added
author | Philip Nienhuis <prnienhuis@users.sf.net> |
---|---|
date | Thu, 14 Mar 2013 23:49:34 +0100 |
parents | 8899c785cc99 |
children | 1de4ec2a856d |
line wrap: on
line diff
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -291,8 +291,8 @@ ## First parse of FORMAT if (strcmpi (strtrim (format), "%f")) ## Default format specified. Expand it (to desired nargout) - fmt_words = cell (nargout, 1); - fmt_words (1:nargout) = format; + fmt_words = cell (max (nargout, 1), 1); + fmt_words (1:max (nargout, 1)) = format; else ## Determine the number of words per line as a first guess. Forms ## like %f<literal>) (w/o delimiter in between) are fixed further on @@ -965,6 +965,10 @@ %! assert (a, [1; 2], 1e-15); %! assert (b, [1; 3], 1e-15); +%% Test for no output arg (interactive use) +%!test +%! assert (strread (",2,,4\n5,,7,", "", "delimiter", ","), [NaN; 2; NaN; 4; 5; NaN; 7]); + %% Unsupported format specifiers %!test %!error <format specifiers are not supported> strread ("a", "%c")