Mercurial > octave
comparison libinterp/octave-value/ov-struct.cc @ 21098:99d373870017
Fix assigning to trailing singletons for structs and cell (bug #39789, bug #35841)
* Array.cc (index (Array<idx_vector> ia, bool, T)):
Only return empty array if resized dimension mismatches ia.
* ov-struct.cc (subsasgn): Remove workaround for index(_,_,_) returning an
empty array for trailing singletons introduced to solve bug #35841.
* index.tst: Add tests for bug #35841, #39789.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Wed, 16 Dec 2015 12:09:59 +1100 |
parents | ebc439187d29 |
children | e39e05d90788 |
comparison
equal
deleted
inserted
replaced
21097:87b3348d8d76 | 21098:99d373870017 |
---|---|
315 octave_map::iterator pkey = map.seek (key); | 315 octave_map::iterator pkey = map.seek (key); |
316 if (pkey != map.end ()) | 316 if (pkey != map.end ()) |
317 { | 317 { |
318 map.contents (pkey).make_unique (); | 318 map.contents (pkey).make_unique (); |
319 tmpc = map.contents (pkey).index (idx.front (), true); | 319 tmpc = map.contents (pkey).index (idx.front (), true); |
320 // See bug #35841, assigning to struct with trailing | |
321 // singleton dimensions. | |
322 if (tmpc.is_empty ()) | |
323 tmpc = Cell (1,1); | |
324 } | 320 } |
325 | 321 |
326 // FIXME: better code reuse? | 322 // FIXME: better code reuse? |
327 // cf. octave_cell::subsasgn and the case below. | 323 // cf. octave_cell::subsasgn and the case below. |
328 if (tmpc.numel () == 1) | 324 if (tmpc.numel () == 1) |
453 { | 449 { |
454 const octave_map& cmap = | 450 const octave_map& cmap = |
455 const_cast<const octave_map &> (map); | 451 const_cast<const octave_map &> (map); |
456 // cast to const reference, avoid forced key insertion. | 452 // cast to const reference, avoid forced key insertion. |
457 if (idxf.all_scalars () | 453 if (idxf.all_scalars () |
458 || cmap.contents (key).index (idxf, true).numel () | 454 || cmap.contents (key).index (idxf, true).numel () == 1) |
459 <= 1) | |
460 { | 455 { |
461 map.assign (idxf, | 456 map.assign (idxf, |
462 key, Cell (t_rhs.storable_value ())); | 457 key, Cell (t_rhs.storable_value ())); |
463 | 458 |
464 count++; | 459 count++; |