Mercurial > octave
changeset 24339:648616b26cc6
maint: merge of stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 30 Nov 2017 10:11:11 -0800 |
parents | 999b167e5b4a (current diff) 1212ffc13d24 (diff) |
children | 2b836112d943 |
files | libinterp/parse-tree/pt-mat.cc libinterp/parse-tree/pt-tm-const.cc test/parser.tst |
diffstat | 2 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-tm-const.cc Wed Nov 29 13:47:23 2017 -0800 +++ b/libinterp/parse-tree/pt-tm-const.cc Thu Nov 30 10:11:11 2017 -0800 @@ -341,11 +341,20 @@ else if (all_str && dv.ndims () == 2 && this_elt_dv.ndims () == 2) { - // FIXME: this is Octave's specialty. - // Character matrices allow rows of unequal length. - if (this_elt_nc > cols ()) - dv(1) = this_elt_nc; - dv(0) += this_elt_nr; + // This is Octave's specialty. + // Character matrices support rows of unequal length. + if (dv.any_zero ()) + { + // Empty existing element (bug #52542). + // Replace empty element with non-empty one. + dv = this_elt_dv; + } + else + { + if (this_elt_nc > cols ()) + dv(1) = this_elt_nc; + dv(0) += this_elt_nr; + } } else if ((! any_class) && (! dv.hvcat (this_elt_dv, 0))) eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
--- a/test/parser.tst Wed Nov 29 13:47:23 2017 -0800 +++ b/test/parser.tst Thu Nov 30 10:11:11 2017 -0800 @@ -331,3 +331,9 @@ %! f = @(s,t=toeplitz(s),u=t(x=2:end-1,x)=32)t; %! assert (f (1), 1); %! assert (f (1, 2), 2); + +## FIXME: We need a sequence of concatenation tests since this seems +## to be a frequently reported source of incompatibilities w/Matlab +## Check concatenation of empty char matrices (bug #52542) +%!assert (double ([char(ones(0,3)); 'A']), 65) +%!assert (double ([char(ones(0,3)); char(ones(2,0)); 'A']), 65)