# HG changeset patch # User Rik # Date 1431029050 -7200 # Node ID ea5fdb2ae63756f25e84cb3460822932d646db97 # Parent 88efded3103729e58f967c81853752779c6f694e num2str.m: Correctly parse newlines in single-quoted format strings (bug #44684). * num2str.m: Use do_string_escapes on format specification before any further processing. diff -r 88efded31037 -r ea5fdb2ae637 scripts/general/num2str.m --- a/scripts/general/num2str.m Thu May 14 14:52:09 2015 -0400 +++ b/scripts/general/num2str.m Thu May 07 22:04:10 2015 +0200 @@ -115,7 +115,8 @@ fmt = "%3d"; endif endif - fmt = [deblank(repmat(fmt, 1, columns(x))), "\n"]; + fmt = do_string_escapes (fmt); # required now that '\n' is interpreted. + fmt = [deblank(repmat (fmt, 1, columns (x))), "\n"]; nd = ndims (x); tmp = sprintf (fmt, permute (x, [2, 1, 3:nd])); retval = strtrim (char (ostrsplit (tmp(1:end-1), "\n"))); @@ -204,6 +205,9 @@ %!xtest %! assert (num2str (1e23), "100000000000000000000000"); +## Test for bug #44864, extra rows generated from newlines in format +%!assert (rows (num2str (magic (3), '%3d %3d %3d\n')), 3) + %!error num2str () %!error num2str (1, 2, 3) %!error num2str ({1})