# HG changeset patch # User Philip Nienhuis # Date 1332716650 25200 # Node ID 9fc75cdf61abbc1949ad6468203d643bf0ed9e34 # Parent bd592d5482c0d49c97cef2c5e8c72d3f94aa976a strread.m: Trap empty string input (bug #35999) * strread.m: Silently return requested number of output args, all empty, for empty input string. diff --git a/scripts/io/strread.m b/scripts/io/strread.m --- 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)); +