Mercurial > hg > octave-lyh
changeset 14497:9fc75cdf61ab
strread.m: Trap empty string input (bug #35999)
* strread.m: Silently return requested number of output args, all empty,
for empty input string.
author | Philip Nienhuis <prnienhuis@users.sf.net> |
---|---|
date | Sun, 25 Mar 2012 16:04:10 -0700 |
parents | bd592d5482c0 |
children | 36cfbd23fe9f |
files | scripts/io/strread.m |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -163,6 +163,12 @@ if (nargin < 1) print_usage (); endif + + if (isempty (str)) + ## Return empty args (no match), rather than raising an error + varargout = cell (1, nargout); + return; + endif if (isempty (format)) format = "%f"; @@ -889,3 +895,10 @@ %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) +%!test +%! # Bug #35999 +%! [a, b, c] = strread ("", "%f"); +%! assert (isempty (a)); +%! assert (isempty (b)); +%! assert (isempty (c)); +