changeset 2254:0158c64f940c

[project @ 1996-05-22 19:13:36 by jwe]
author jwe
date Wed, 22 May 1996 19:13:36 +0000
parents 5e862d11b116
children fb9611cfc9d2
files src/pt-mat.cc
diffstat 1 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/pt-mat.cc	Wed May 22 18:45:46 1996 +0000
+++ b/src/pt-mat.cc	Wed May 22 19:13:36 1996 +0000
@@ -49,6 +49,9 @@
 // Zero means it should be considered an error.
 static int Vempty_list_elements_ok;
 
+// The character to fill with when creating string arrays.
+static char Vstring_fill_char;
+
 // 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.
@@ -443,7 +446,7 @@
       bool found_complex = tmp.is_complex ();
 
       if (all_strings)
-	chm.resize (nr, nc, 0);
+	chm.resize (nr, nc, Vstring_fill_char);
       else if (found_complex)
 	cm.resize (nr, nc, 0.0);
       else
@@ -536,11 +539,40 @@
   return 0;
 }
 
+static int
+string_fill_char (void)
+{
+  int status = 0;
+
+  string s = builtin_string_variable ("string_fill_char");
+
+  switch (s.length ())
+    {
+    case 1:
+      Vstring_fill_char = s[0];
+      break;
+
+    case 0:
+      Vstring_fill_char = '\0';
+      break;
+
+    default:
+      warning ("string_fill_char must be a single character");
+      status = -1;
+      break;
+    }
+
+  return status;
+}
+
 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]'");
+
+  DEFVAR (string_fill_char, " ", 0, string_fill_char,
+    "the character to fill with when creating string arrays.");
 }
 
 /*