Mercurial > octave-libtiff
changeset 28546:ac7ab2a9018e stable
create empty c-s list for x.a (bug #58695)
* ov-struct.cc (octave_struct::subsref): Create empty comma-separated
list if indexing operation creates empty cell array.
From Fernando Alvarruiz.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 09 Jul 2020 09:20:10 -0400 |
parents | 3dae50cf0bc5 |
children | 66397e171801 |
files | libinterp/octave-value/ov-struct.cc |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-struct.cc Thu Jul 09 09:15:58 2020 -0400 +++ b/libinterp/octave-value/ov-struct.cc Thu Jul 09 09:20:10 2020 -0400 @@ -146,6 +146,9 @@ const Cell t = tmp.index (idx.front ()); + // Avoid creating a comma-separated list if the result is a + // single element. + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell @@ -162,8 +165,10 @@ { const Cell t = dotref (idx.front ()); - if (! map.isempty ()) - retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); + // Avoid creating a comma-separated list if the result is a + // single element. + + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); } break; @@ -207,6 +212,9 @@ const Cell t = tmp.index (idx.front (), auto_add); + // Avoid creating a comma-separated list if the result is a + // single element. + retval = (t.numel () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell @@ -225,6 +233,9 @@ { const Cell t = dotref (idx.front (), auto_add); + // Avoid creating a comma-separated list if the result is a + // single element. + retval = (t.numel () == 1) ? t(0) : octave_value (t, true); } }