# HG changeset patch # User jwe # Date 1081447243 0 # Node ID 499d2ca4698240fe49e481a5f82d35240df9c8fd # Parent 9794d526639ca02c1d42cef248db438beed9feb5 [project @ 2004-04-08 18:00:43 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-04-08 John W. Eaton + + * ov-base-mat.cc (octave_base_matrix::do_index_op): Quit early + if an error occurs when creating index vector object. + + * ov.cc (octave_value::numeric_assign): Always call maybe_mutate + on return value. + 2004-04-06 David Bateman * DLD_FUNCTIONS/sort.cc: Use the new template sort class, adapt for diff --git a/src/ov-base-mat.cc b/src/ov-base-mat.cc --- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -149,7 +149,8 @@ { idx_vector i = idx (0).index_vector (); - retval = MT (matrix.index (i, resize_ok, MT::resize_fill_value ())); + if (! error_state) + retval = MT (matrix.index (i, resize_ok, MT::resize_fill_value ())); } break; @@ -158,20 +159,31 @@ if (n_idx == 2 && nd == 2) { idx_vector i = idx (0).index_vector (); - idx_vector j = idx (1).index_vector (); + + if (! error_state) + { + idx_vector j = idx (1).index_vector (); - retval = MT (matrix.index (i, j, resize_ok, - MT::resize_fill_value ())); + if (! error_state) + retval = MT (matrix.index (i, j, resize_ok, + MT::resize_fill_value ())); + } } else { Array idx_vec (n_idx); for (int i = 0; i < n_idx; i++) - idx_vec(i) = idx(i).index_vector (); + { + idx_vec(i) = idx(i).index_vector (); - retval = MT (matrix.index (idx_vec, resize_ok, - MT::resize_fill_value ())); + if (error_state) + break; + } + + if (! error_state) + retval = MT (matrix.index (idx_vec, resize_ok, + MT::resize_fill_value ())); } } break; diff --git a/src/ov-base-nd-array.cc b/src/ov-base-nd-array.cc deleted file mode 100644 --- a/src/ov-base-nd-array.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - -Copyright (C) 2000 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "oct-obj.h" -#include "ov-base.h" -#include "ov-base-nd-array.h" -#include "pr-output.h" - -static inline Array -idx_list_to_idx_array (const octave_value_list& idx) -{ - int n = idx.length (); - - Array retval (n); - - for (int i = 0; i < n; i++) - retval(i) = idx(i).index_vector (); - - return retval; -} - -template -octave_value -octave_base_nd_array::do_index_op (const octave_value_list& idx, - int resize_ok) -{ - octave_value retval; - - int len = idx.length (); - - if (len > 1) - { - Array i = idx_list_to_idx_array (idx); - - retval - = octave_value (new octave_base_nd_array (AT (array.index (i, resize_ok)))); - } - else if (len == 1) - { - idx_vector i = idx(0).index_vector (); - - retval - = octave_value (new octave_base_nd_array (AT (array.index (i, resize_ok)))); - } - else - { - std::string n = type_name (); - - error ("invalid number of indices (%d) for %s value", - len, n.c_str ()); - } - - return retval; -} - -template -bool -octave_base_nd_array::is_true (void) const -{ - // XXX FIXME XXX - return false; -} - -template -bool -octave_base_nd_array::print_as_scalar (void) const -{ - // XXX FIXME XXX - return false; -} - -template -void -octave_base_nd_array::print (std::ostream& os, - bool pr_as_read_syntax) const -{ - print_raw (os, pr_as_read_syntax); - newline (os); -} - -template -void -octave_base_nd_array::print_raw (std::ostream& os, - bool pr_as_read_syntax) const -{ - // XXX FIXME XX - os << array; -#if 0 - octave_print_internal (os, array, pr_as_read_syntax, - current_print_indent_level ()); -#endif -} - -template -bool -octave_base_nd_array::print_name_tag (std::ostream& os, - const std::string& name) const -{ - bool retval = false; - - indent (os); - - if (print_as_scalar ()) - os << name << " = "; - else - { - os << name << " ="; - newline (os); - newline (os); - retval = true; - } - - return retval; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff --git a/src/ov-base-nd-array.h b/src/ov-base-nd-array.h deleted file mode 100644 --- a/src/ov-base-nd-array.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - -Copyright (C) 2000 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if !defined (octave_base_nd_array_h) -#define octave_base_nd_array_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include - -#include -#include - -#include "mx-base.h" -#include "str-vec.h" - -#include "error.h" -#include "ov-base.h" -#include "ov-typeinfo.h" - -class Octave_map; -class octave_value_list; - -class tree_walker; - -// ND array values values. - -template -class -octave_base_nd_array : public octave_base_value -{ -public: - - octave_base_nd_array (void) - : octave_base_value () { } - - octave_base_nd_array (const AT& a) - : octave_base_value (), array (a) { } - - octave_base_nd_array (const octave_base_nd_array& a) - : octave_base_value (), array (a.array) { } - - ~octave_base_nd_array (void) { } - - octave_value *clone (void) const { return new octave_base_nd_array (*this); } - octave_value *empty_clone (void) const { return new octave_base_nd_array (); } - - octave_value do_index_op (const octave_value_list& idx, int resize_ok); - - bool is_matrix_type (void) const { return false; } - - bool is_numeric_type (void) const { return true; } - - bool is_defined (void) const { return true; } - - bool is_constant (void) const { return true; } - - bool is_true (void) const; - - virtual bool print_as_scalar (void) const; - - void print (std::ostream& os, bool pr_as_read_syntax = false) const; - - void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - - bool print_name_tag (std::ostream& os, const std::string& name) const; - -protected: - - AT array; -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff --git a/src/ov.cc b/src/ov.cc --- a/src/ov.cc +++ b/src/ov.cc @@ -1367,11 +1367,6 @@ { retval = tmp->subsasgn (type, idx, rhs); - // The assignment may have converted to a type that - // is wider than necessary. - - retval.maybe_mutate (); - done = (! error_state); } else @@ -1433,6 +1428,11 @@ } } + // The assignment may have converted to a type that is wider than + // necessary. + + retval.maybe_mutate (); + return retval; }