Mercurial > octave-nkf
comparison src/ov-struct.cc @ 12181:88ff30dcc048
fix another bug in class assignment to undefined object with index
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 27 Jan 2011 06:16:50 -0500 |
parents | ed129a03f93c |
children | 7a5aacf65f81 |
comparison
equal
deleted
inserted
replaced
12180:6d64359487b4 | 12181:88ff30dcc048 |
---|---|
326 { | 326 { |
327 if (tmpc.numel () == 1) | 327 if (tmpc.numel () == 1) |
328 { | 328 { |
329 octave_value& tmp = tmpc(0); | 329 octave_value& tmp = tmpc(0); |
330 | 330 |
331 if (! tmp.is_defined () || tmp.is_zero_by_zero ()) | 331 bool orig_undefined = tmp.is_undefined (); |
332 | |
333 if (orig_undefined || tmp.is_zero_by_zero ()) | |
332 { | 334 { |
333 tmp = octave_value::empty_conv (next_type, rhs); | 335 tmp = octave_value::empty_conv (next_type, rhs); |
334 tmp.make_unique (); // probably a no-op. | 336 tmp.make_unique (); // probably a no-op. |
335 } | 337 } |
336 else | 338 else |
337 // optimization: ignore the copy still stored inside our map. | 339 // optimization: ignore the copy still stored inside our map. |
338 tmp.make_unique (1); | 340 tmp.make_unique (1); |
339 | 341 |
340 if (! error_state) | 342 if (! error_state) |
341 t_rhs = tmp.subsasgn (next_type, next_idx, rhs); | 343 t_rhs = (orig_undefined |
344 ? tmp.undef_subsasgn (next_type, next_idx, rhs) | |
345 : tmp.subsasgn (next_type, next_idx, rhs)); | |
342 } | 346 } |
343 else | 347 else |
344 gripe_indexed_cs_list (); | 348 gripe_indexed_cs_list (); |
345 } | 349 } |
346 } | 350 } |
376 { | 380 { |
377 if (tmpc.numel () == 1) | 381 if (tmpc.numel () == 1) |
378 { | 382 { |
379 octave_value& tmp = tmpc(0); | 383 octave_value& tmp = tmpc(0); |
380 | 384 |
381 if (! tmp.is_defined () || tmp.is_zero_by_zero ()) | 385 bool orig_undefined = tmp.is_undefined (); |
386 | |
387 if (orig_undefined || tmp.is_zero_by_zero ()) | |
382 { | 388 { |
383 tmp = octave_value::empty_conv (next_type, rhs); | 389 tmp = octave_value::empty_conv (next_type, rhs); |
384 tmp.make_unique (); // probably a no-op. | 390 tmp.make_unique (); // probably a no-op. |
385 } | 391 } |
386 else | 392 else |
387 // optimization: ignore the copy still stored inside our map. | 393 // optimization: ignore the copy still stored inside our map. |
388 tmp.make_unique (1); | 394 tmp.make_unique (1); |
389 | 395 |
390 if (! error_state) | 396 if (! error_state) |
391 t_rhs = tmp.subsasgn (next_type, next_idx, rhs); | 397 t_rhs = (orig_undefined |
398 ? tmp.undef_subsasgn (next_type, next_idx, rhs) | |
399 : tmp.subsasgn (next_type, next_idx, rhs)); | |
392 } | 400 } |
393 else | 401 else |
394 gripe_indexed_cs_list (); | 402 gripe_indexed_cs_list (); |
395 } | 403 } |
396 } | 404 } |
1242 tmp = map.contents (pkey); | 1250 tmp = map.contents (pkey); |
1243 } | 1251 } |
1244 | 1252 |
1245 if (! error_state) | 1253 if (! error_state) |
1246 { | 1254 { |
1247 if (! tmp.is_defined () || tmp.is_zero_by_zero ()) | 1255 bool orig_undefined = tmp.is_undefined (); |
1256 | |
1257 if (orig_undefined || tmp.is_zero_by_zero ()) | |
1248 { | 1258 { |
1249 tmp = octave_value::empty_conv (next_type, rhs); | 1259 tmp = octave_value::empty_conv (next_type, rhs); |
1250 tmp.make_unique (); // probably a no-op. | 1260 tmp.make_unique (); // probably a no-op. |
1251 } | 1261 } |
1252 else | 1262 else |
1253 // optimization: ignore the copy still stored inside our map. | 1263 // optimization: ignore the copy still stored inside our map. |
1254 tmp.make_unique (1); | 1264 tmp.make_unique (1); |
1255 | 1265 |
1256 if (! error_state) | 1266 if (! error_state) |
1257 t_rhs = tmp.subsasgn (next_type, next_idx, rhs); | 1267 t_rhs = (orig_undefined |
1268 ? tmp.undef_subsasgn (next_type, next_idx, rhs) | |
1269 : tmp.subsasgn (next_type, next_idx, rhs)); | |
1258 } | 1270 } |
1259 } | 1271 } |
1260 | 1272 |
1261 if (! error_state) | 1273 if (! error_state) |
1262 map.setfield (key, t_rhs.storable_value ()); | 1274 map.setfield (key, t_rhs.storable_value ()); |