changeset 5001:6690d8cd9bee

[project @ 2004-09-16 00:31:42 by jwe]
author jwe
date Thu, 16 Sep 2004 00:31:43 +0000
parents 9a7ec88c8b5e
children d894b803ccb5
files src/ChangeLog src/DLD-FUNCTIONS/sort.cc src/oct-lvalue.cc src/oct-lvalue.h src/ov.cc test/octave.test/matrix/sort-3.m
diffstat 6 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Sep 15 22:03:24 2004 +0000
+++ b/src/ChangeLog	Thu Sep 16 00:31:43 2004 +0000
@@ -1,5 +1,8 @@
 2004-09-15  John W. Eaton  <jwe@octave.org>
 
+	* ov.cc (octave_value::assign): Handle subsref for containers.
+	* oct-lvalue.cc (octave_lvale::value): Likewise.
+
 	* DLD-FUNCTIONS/sort.cc (mx_sort): Return octave_value, not
 	octave_value list.
 
--- a/src/DLD-FUNCTIONS/sort.cc	Wed Sep 15 22:03:24 2004 +0000
+++ b/src/DLD-FUNCTIONS/sort.cc	Thu Sep 16 00:31:43 2004 +0000
@@ -653,7 +653,7 @@
   int nargin = args.length ();
   sortmode smode = ASCENDING;
 
-  if (nargin < 1 && nargin > 3)
+  if (nargin < 1 || nargin > 3)
     {
       print_usage ("sort");
       return retval;
--- a/src/oct-lvalue.cc	Wed Sep 15 22:03:24 2004 +0000
+++ b/src/oct-lvalue.cc	Thu Sep 16 00:31:43 2004 +0000
@@ -65,6 +65,28 @@
     *val = tmp;
 }
 
+octave_value
+octave_lvalue::value (void)
+{
+  octave_value retval;
+
+  if (idx.empty ())
+    retval = *val;
+  else
+    {
+      if (val->is_constant ())
+	retval = val->subsref (type, idx);
+      else
+	{
+	  octave_value_list t = val->subsref (type, idx, 1);
+	  if (t.length () > 0)
+	    retval = t(0);	      
+	}
+    }
+
+  return retval;
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/oct-lvalue.h	Wed Sep 15 22:03:24 2004 +0000
+++ b/src/oct-lvalue.h	Thu Sep 16 00:31:43 2004 +0000
@@ -82,8 +82,7 @@
 
   void do_unary_op (octave_value::unary_op op);
 
-  octave_value value (void)
-    { return idx.empty () ? *val : val->subsref (type, idx); }
+  octave_value value (void);
 
   const octave_value *object (void) const { return val; }
 
--- a/src/ov.cc	Wed Sep 15 22:03:24 2004 +0000
+++ b/src/ov.cc	Thu Sep 16 00:31:43 2004 +0000
@@ -926,7 +926,15 @@
       // a specific function to call to handle the op= operation for
       // the types we have.
 
-      octave_value t = subsref (type, idx);
+      octave_value t;
+      if (is_constant ())
+	t = subsref (type, idx);
+      else
+	{
+	  octave_value_list tl = subsref (type, idx, 1);
+	  if (tl.length () > 0)
+	    t = tl(0);
+	}
 
       if (! error_state)
 	{
--- a/test/octave.test/matrix/sort-3.m	Wed Sep 15 22:03:24 2004 +0000
+++ b/test/octave.test/matrix/sort-3.m	Thu Sep 16 00:31:43 2004 +0000
@@ -1,1 +1,1 @@
-sort (1, 2, 3)
+sort (1, 2, 3, 4)