Mercurial > octave
changeset 21296:596e19e7e571 stable
fix printf regression (bug #47192)
* oct-stream.cc (printf_value_cache::get_next_value):
Flatten character matrices for "%s" format.
* io.tst: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 18 Feb 2016 15:02:28 -0500 |
parents | 1bbd799ac7c7 |
children | e0523c40a802 aaf59727f809 |
files | libinterp/corefcn/oct-stream.cc test/io.tst |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Wed Feb 17 01:21:19 2016 -0800 +++ b/libinterp/corefcn/oct-stream.cc Thu Feb 18 15:02:28 2016 -0500 @@ -2254,7 +2254,10 @@ { if (curr_val.is_string ()) { - std::string sval = curr_val.string_value (); + dim_vector dv (1, curr_val.numel ()); + octave_value tmp = curr_val.reshape (dv); + + std::string sval = tmp.string_value (); retval = sval.substr (elt_idx);
--- a/test/io.tst Wed Feb 17 01:21:19 2016 -0800 +++ b/test/io.tst Thu Feb 18 15:02:28 2016 -0500 @@ -673,3 +673,7 @@ %!assert (sprintf ("|%X|", "Octave"), "|4F||63||74||61||76||65|"); %!assert (sprintf ("|%o|", "Octave"), "|117||143||164||141||166||145|"); +## bug #47192 +%!assert (sprintf ("%s", repmat ("blah", 2, 1)), "bbllaahh") +%!assert (sprintf ("%c", repmat ("blah", 2, 1)), "bbllaahh") +%!assert (sprintf ("%c %c %s", repmat ("blah", 2, 1)), "b b llaahh")