changeset 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 e556870ce8f0
files src/ChangeLog src/pt-arg-list.cc
diffstat 2 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Dec 31 20:16:38 2002 +0000
+++ b/src/ChangeLog	Tue Dec 31 21:48:54 2002 +0000
@@ -1,6 +1,8 @@
 2002-12-31  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* pt-arg-list.cc (F__end__): Fail if rows or columns is negative.
+	(tree_argument_list::convert_to_const_vector): Only protect and
+	save pointer to the indexed object if it is a constant.
 
 	* syscalls.cc (Fmkfifo): Use long_value instead of cast.
 
--- 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;
 }