# HG changeset patch # User John W. Eaton # Date 1238022135 14400 # Node ID 12ca81f1fa9951c06c895f1ad7fe4b170fdbe006 # Parent 9057df9bb8a1364744da1b5dabba9df9d7335216 compatibility fix for find called for empty arguments diff -r 9057df9bb8a1 -r 12ca81f1fa99 src/ChangeLog --- a/src/ChangeLog Wed Mar 25 17:34:19 2009 -0400 +++ b/src/ChangeLog Wed Mar 25 19:02:15 2009 -0400 @@ -1,5 +1,8 @@ 2009-03-25 John W. Eaton + * DLD-FUNCTIONS/find.cc (find_nonzero_elem_idx): Also return + [](0x0) if the array has 0 rows and it is not a column vector. + * oct-stream.cc (octave_stream::write (const Array&, octave_idx_type, oct_data_conv::data_type, octave_idx_type, oct_mach_info::float_format)): Seek to skip if still inside bounds diff -r 9057df9bb8a1 -r 12ca81f1fa99 src/DLD-FUNCTIONS/find.cc --- a/src/DLD-FUNCTIONS/find.cc Wed Mar 25 17:34:19 2009 -0400 +++ b/src/DLD-FUNCTIONS/find.cc Wed Mar 25 19:02:15 2009 -0400 @@ -89,14 +89,23 @@ octave_idx_type result_nr = count; octave_idx_type result_nc = 1; + bool column_vector_arg = false; bool scalar_arg = false; - if (nda.ndims () == 2 && nda.rows () == 1) + if (nda.ndims () == 2) { - result_nr = 1; - result_nc = count; + octave_idx_type nr = nda.rows (); + octave_idx_type nc = nda.columns (); - scalar_arg = (nda.columns () == 1); + if (nr == 1) + { + result_nr = 1; + result_nc = count; + + scalar_arg = (nc == 1); + } + else if (nc == 1) + column_vector_arg = true; } Matrix idx (result_nr, result_nc); @@ -141,7 +150,7 @@ i++; } } - else if (scalar_arg) + else if (scalar_arg || (nda.rows () == 0 && ! column_vector_arg)) { idx.resize (0, 0);