# HG changeset patch # User jwe # Date 831999642 0 # Node ID 0de32e6149300e2af3d736f50bed2b41e8e0669d # Parent 977f7dd0999ca0e61aa838cab29983fb74266fa7 [project @ 1996-05-13 15:00:42 by jwe] diff -r 977f7dd0999c -r 0de32e614930 src/pt-mat.cc --- a/src/pt-mat.cc Mon May 13 14:46:42 1996 +0000 +++ b/src/pt-mat.cc Mon May 13 15:00:42 1996 +0000 @@ -31,6 +31,7 @@ #include #include +#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++ ***