# HG changeset patch # User Jaroslav Hajek # Date 1260867695 -3600 # Node ID 43a29eeda9949eae63aaeee54f1e5271cd35aed4 # Parent d1cc2e0ddf55807ee3b252c00d5ec20b54d62028 fix idx_vector::loop for masks diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-12-15 Jaroslav Hajek + + * idx-vector.h (idx_vector::loop, idx_vector::bloop): Fix behavior for + masks. + 2009-12-13 Rik * Makefile.am: Use DISTCLEANFILES rather than distclean-local rule. diff --git a/liboctave/idx-vector.h b/liboctave/idx-vector.h --- a/liboctave/idx-vector.h +++ b/liboctave/idx-vector.h @@ -824,8 +824,8 @@ idx_mask_rep * r = dynamic_cast (rep); const bool *data = r->get_data (); octave_idx_type ext = r->extent (0); - for (octave_idx_type i = 0, j = 0; i < ext; i++) - if (data[i]) body (j++); + for (octave_idx_type i = 0; i < ext; i++) + if (data[i]) body (i); } break; default: @@ -894,8 +894,16 @@ const bool *data = r->get_data (); octave_idx_type ext = r->extent (0), j = 0; for (octave_idx_type i = 0; i < ext; i++) - if (data[i] && body (j++)) - break; + { + if (data[i]) + { + if (body (i)) + break; + else + j++; + } + } + ret = j; } break;