Mercurial > hg > octave-lyh
diff src/pt-mat.cc @ 2172:0de32e614930
[project @ 1996-05-13 15:00:42 by jwe]
author | jwe |
---|---|
date | Mon, 13 May 1996 15:00:42 +0000 |
parents | 97a566037a75 |
children | 6abec42e52f6 |
line wrap: on
line diff
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -31,6 +31,7 @@ #include <iostream.h> #include <strstream.h> +#include "defun.h" #include "error.h" #include "oct-obj.h" #include "pt-const.h" @@ -42,6 +43,12 @@ #include "pt-walk.h" #include "user-prefs.h" +// Are empty elements in a matrix list ok? For example, is the empty +// matrix in an expression like `[[], 1]' ok? A positive value means +// yes. A negative value means yes, but print a warning message. +// Zero means it should be considered an error. +static int Vempty_list_elements_ok; + // General matrices. This list type is much more work to handle than // constant matrices, but it allows us to construct matrices from // other matrices, variables, and functions. @@ -153,8 +160,6 @@ { all_str = true; - int empties_ok = user_pref.empty_list_elements_ok; - bool first_elem = true; for (Pix p = mr.first (); p != 0; mr.next (p)) @@ -172,9 +177,9 @@ if (this_elt_nr == 0 || this_elt_nc == 0) { - if (empties_ok < 0) + if (Vempty_list_elements_ok < 0) warning ("empty matrix found in matrix list"); - else if (empties_ok == 0) + else if (Vempty_list_elements_ok == 0) { ::error ("empty matrix found in matrix list"); break; @@ -257,8 +262,6 @@ { all_str = true; - int empties_ok = user_pref.empty_list_elements_ok; - bool first_elem = true; // Just eval and figure out if what we have is complex or all @@ -297,9 +300,9 @@ if (this_elt_nr == 0 || this_elt_nc == 0) { - if (empties_ok < 0) + if (Vempty_list_elements_ok < 0) warning ("empty matrix found in matrix list"); - else if (empties_ok == 0) + else if (Vempty_list_elements_ok == 0) { ::error ("empty matrix found in matrix list"); break; @@ -525,6 +528,21 @@ tw.visit_matrix (*this); } +static int +empty_list_elements_ok (void) +{ + Vempty_list_elements_ok = check_preference ("empty_list_elements_ok"); + + return 0; +} + +void +symbols_of_pt_mat (void) +{ + DEFVAR (empty_list_elements_ok, "warn", 0, empty_list_elements_ok, + "ignore the empty element in expressions like `a = [[], 1]'"); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***