Mercurial > octave-nkf
diff src/pt-arg-list.cc @ 4256:2b9c6dc25449
[project @ 2002-12-31 21:48:54 by jwe]
author | jwe |
---|---|
date | Tue, 31 Dec 2002 21:48:54 +0000 |
parents | f7d11c1a49e3 |
children | b8a4496d7b24 |
line wrap: on
line diff
--- a/src/pt-arg-list.cc Tue Dec 31 20:16:38 2002 +0000 +++ b/src/pt-arg-list.cc Tue Dec 31 21:48:54 2002 +0000 @@ -116,11 +116,25 @@ break; case 0: - retval = indexed_object->rows (); + { + int nr = indexed_object->rows (); + + if (nr < 0) + ::error ("invalid use of end"); + else + retval = nr; + } break; case 1: - retval = indexed_object->columns (); + { + int nc = indexed_object->columns (); + + if (nc < 0) + ::error ("invalid use of end"); + else + retval = nc; + } break; default: @@ -129,7 +143,7 @@ } } else - ::error ("__end__: internal error"); + ::error ("invalid use of end"); return retval; } @@ -137,11 +151,19 @@ octave_value_list tree_argument_list::convert_to_const_vector (const octave_value *object) { - unwind_protect::begin_frame ("convert_to_const_vector"); + // END doesn't make sense for functions. Maybe we need a different + // way of asking an octave_value object this question? + + bool stash_object = (object && object->is_constant ()); - unwind_protect_ptr (indexed_object); + if (stash_object) + { + unwind_protect::begin_frame ("convert_to_const_vector"); - indexed_object = object; + unwind_protect_ptr (indexed_object); + + indexed_object = object; + } int len = length (); @@ -214,7 +236,8 @@ args.resize (j); - unwind_protect::run_frame ("convert_to_const_vector"); + if (stash_object) + unwind_protect::run_frame ("convert_to_const_vector"); return args; }