octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

list indexing errors


From: John W. Eaton
Subject: list indexing errors
Date: Fri, 19 Mar 2004 16:30:21 -0600

On 18-Mar-2004, Paul Kienzle <address@hidden> wrote:

| The following code crashes octave:
| 
|  > x=list(1,2,3)
|  > x(2)

Please try the following patch.

Thanks,

jwe


src/ChangeLog:

2004-03-19  John W. Eaton  <address@hidden>

        * ov-list.cc (octave_list::subsref): Correctly create return value.
        Return comma-separate list if {-style indexing extracts more than
        one value.


Index: src/ov-list.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov-list.cc,v
retrieving revision 1.37
diff -u -r1.37 ov-list.cc
--- a/src/ov-list.cc    12 Mar 2004 19:13:02 -0000      1.37
+++ b/src/ov-list.cc    19 Mar 2004 22:29:17 -0000
@@ -76,7 +76,9 @@
          {
            idx_vector i = tmp_idx (0).index_vector ();
 
-           retval = octave_list (data.index (i));
+           Cell tmp = data.index (i);
+
+           retval = octave_value (new octave_list (tmp));
          }
        else
          error ("only one index allowed for lists");
@@ -95,6 +97,8 @@
 
            if (tmp.length () == 1)
              retval = tmp(0);
+           else
+             retval = octave_value (tmp, true);
          }
        else
          error ("only one index allowed for lists");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]