# HG changeset patch # User Jaroslav Hajek # Date 1244715936 -7200 # Node ID a76f391a3d02a319be3baf22b31e219fcbe14cf1 # Parent e903c92d2f02043ce65ad541192119e712c168e6 set up proper nargout for call to subsref method diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-06-11 Jaroslav Hajek + + * ov-class.cc (subsref): Set up proper nargout for call to subsref + method. + 2009-06-10 Jaroslav Hajek * ov-base.cc (octave_base_value::numel (const octave_value_list&), diff --git a/src/ov-class.cc b/src/ov-class.cc --- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -446,7 +446,27 @@ count++; args(0) = octave_value (this); - return feval (meth.function_value (), args, nargout); + bool maybe_cs_list_query = (type[0] == '.' || type[0] == '{' + || (type.length () > 1 && type[0] == '(' + && type[1] == '.')); + + if (nargout == 1 && maybe_cs_list_query) + { + // Set up a proper nargout for the subsref call by calling numel. + octave_value_list tmp; + if (type[0] != '.') tmp = idx.front (); + octave_idx_type true_nargout = numel (tmp); + if (! error_state) + { + tmp = feval (meth.function_value (), args, true_nargout); + if (true_nargout != 1) + retval(0) = octave_value (tmp, true); + else + retval = tmp; + } + } + else + retval = feval (meth.function_value (), args, nargout); } else {