changeset 2172:0de32e614930

[project @ 1996-05-13 15:00:42 by jwe]
author jwe
date Mon, 13 May 1996 15:00:42 +0000
parents 977f7dd0999c
children b9cfacab52d1
files src/pt-mat.cc
diffstat 1 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 <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++ ***