changeset 1505:7b665f9a97fa

[project @ 1995-10-03 03:11:50 by jwe]
author jwe
date Tue, 03 Oct 1995 03:14:49 +0000
parents c29439c3f3fa
children 3a66934240ea
files src/user-prefs.cc src/variables.cc
diffstat 2 files changed, 68 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/src/user-prefs.cc	Tue Oct 03 03:00:29 1995 +0000
+++ b/src/user-prefs.cc	Tue Oct 03 03:14:49 1995 +0000
@@ -102,10 +102,12 @@
 // to mean "true".
 
 static int
-check_str_pref (char *var)
+check_preference (char *var)
 {
+  int pref = -1;
+
   char *val = builtin_string_variable (var);
-  int pref = -1;
+
   if (val)
     {
       if (strncmp (val, "yes", 3) == 0
@@ -115,7 +117,16 @@
 	       || strncmp (val, "no", 2) == 0
 	       || strncmp (val, "false", 5) == 0)
 	pref = 0;
+
+      delete [] val;
     }
+  else
+    {
+      double dval = 0;
+      if (builtin_real_scalar_variable (var, dval))
+	pref = NINT (dval);
+    }
+
   return pref;
 }
 
@@ -128,7 +139,7 @@
 int
 automatic_replot (void)
 {
-  user_pref.automatic_replot = check_str_pref ("automatic_replot");
+  user_pref.automatic_replot = check_preference ("automatic_replot");
 
   return 0;
 }
@@ -139,7 +150,7 @@
 int
 beep_on_error (void)
 {
-  user_pref.beep_on_error = check_str_pref ("beep_on_error");
+  user_pref.beep_on_error = check_preference ("beep_on_error");
 
   return 0;
 }
@@ -152,7 +163,7 @@
 define_all_return_values (void)
 {
   user_pref.define_all_return_values =
-    check_str_pref ("define_all_return_values");
+    check_preference ("define_all_return_values");
 
   return 0;
 }
@@ -168,7 +179,7 @@
 do_fortran_indexing (void)
 {
   user_pref.do_fortran_indexing =
-    check_str_pref ("do_fortran_indexing"); 
+    check_preference ("do_fortran_indexing"); 
 
   return 0;
 }
@@ -181,7 +192,7 @@
 empty_list_elements_ok (void)
 {
   user_pref.empty_list_elements_ok =
-    check_str_pref ("empty_list_elements_ok");
+    check_preference ("empty_list_elements_ok");
 
   return 0;
 }
@@ -193,7 +204,7 @@
 gnuplot_has_multiplot (void)
 {
   user_pref.gnuplot_has_multiplot =
-    check_str_pref ("gnuplot_has_multiplot");
+    check_preference ("gnuplot_has_multiplot");
 
   return 0;
 }
@@ -234,7 +245,7 @@
 implicit_str_to_num_ok (void)
 {
   user_pref.implicit_str_to_num_ok =
-    check_str_pref ("implicit_str_to_num_ok");
+    check_preference ("implicit_str_to_num_ok");
 
   return 0;
 }
@@ -247,7 +258,7 @@
 ok_to_lose_imaginary_part (void)
 {
   user_pref.ok_to_lose_imaginary_part =
-    check_str_pref ("ok_to_lose_imaginary_part");
+    check_preference ("ok_to_lose_imaginary_part");
 
   return 0;
 }
@@ -259,7 +270,7 @@
 int
 page_screen_output (void)
 {
-  user_pref.page_screen_output = check_str_pref ("page_screen_output");
+  user_pref.page_screen_output = check_preference ("page_screen_output");
 
   return 0;
 }
@@ -276,7 +287,7 @@
 prefer_column_vectors (void)
 {
   user_pref.prefer_column_vectors =
-    check_str_pref ("prefer_column_vectors");
+    check_preference ("prefer_column_vectors");
 
   return 0;
 }
@@ -292,7 +303,7 @@
 prefer_zero_one_indexing (void)
 {
   user_pref.prefer_zero_one_indexing =
-    check_str_pref ("prefer_zero_one_indexing");
+    check_preference ("prefer_zero_one_indexing");
 
   return 0;
 }
@@ -310,7 +321,7 @@
 print_answer_id_name (void)
 {
   user_pref.print_answer_id_name =
-    check_str_pref ("print_answer_id_name");
+    check_preference ("print_answer_id_name");
 
   return 0;
 }
@@ -322,7 +333,7 @@
 print_empty_dimensions (void)
 {
   user_pref.print_empty_dimensions =
-    check_str_pref ("print_empty_dimensions");
+    check_preference ("print_empty_dimensions");
 
   return 0;
 }
@@ -335,7 +346,7 @@
 propagate_empty_matrices (void)
 {
   user_pref.propagate_empty_matrices =
-    check_str_pref ("propagate_empty_matrices");
+    check_preference ("propagate_empty_matrices");
 
   return 0;
 }
@@ -345,7 +356,7 @@
 int
 read_only_constants (void)
 {
-  user_pref.read_only_constants = check_str_pref ("read_only_constants");
+  user_pref.read_only_constants = check_preference ("read_only_constants");
 
   return 0;
 }
@@ -357,7 +368,7 @@
 resize_on_range_error (void)
 {
   user_pref.resize_on_range_error =
-    check_str_pref ("resize_on_range_error");
+    check_preference ("resize_on_range_error");
 
   return 0;
 }
@@ -370,7 +381,7 @@
 return_last_computed_value (void)
 {
   user_pref.return_last_computed_value =
-    check_str_pref ("return_last_computed_value");
+    check_preference ("return_last_computed_value");
 
   return 0;
 }
@@ -382,7 +393,7 @@
 silent_functions (void)
 {
   user_pref.silent_functions =
-    check_str_pref ("silent_functions");
+    check_preference ("silent_functions");
 
   return 0;
 }
@@ -393,7 +404,7 @@
 int
 split_long_rows (void)
 {
-  user_pref.split_long_rows = check_str_pref ("split_long_rows");
+  user_pref.split_long_rows = check_preference ("split_long_rows");
 
   return 0;
 }
@@ -405,7 +416,7 @@
 struct_levels_to_print (void)
 {
   double val;
-  if (builtin_real_scalar_variable ("struct_levels_to_print", val) == 0
+  if (builtin_real_scalar_variable ("struct_levels_to_print", val)
       && ! xisnan (val))
     {
       int ival = NINT (val);
@@ -427,7 +438,7 @@
 suppress_verbose_help_message (void)
 {
   user_pref.suppress_verbose_help_message =
-    check_str_pref ("suppress_verbose_help_message");
+    check_preference ("suppress_verbose_help_message");
 
   return 0;
 }
@@ -443,7 +454,7 @@
 treat_neg_dim_as_zero (void)
 {
   user_pref.treat_neg_dim_as_zero =
-    check_str_pref ("treat_neg_dim_as_zero");
+    check_preference ("treat_neg_dim_as_zero");
 
   return 0;
 }
@@ -461,7 +472,7 @@
 warn_assign_as_truth_value (void)
 {
   user_pref.warn_assign_as_truth_value =
-    check_str_pref ("warn_assign_as_truth_value");
+    check_preference ("warn_assign_as_truth_value");
 
   return 0;
 }
@@ -475,7 +486,7 @@
 warn_comma_in_global_decl (void)
 {
   user_pref.warn_comma_in_global_decl =
-    check_str_pref ("warn_comma_in_global_decl");
+    check_preference ("warn_comma_in_global_decl");
 
   return 0;
 }
@@ -486,7 +497,7 @@
 int
 warn_divide_by_zero (void)
 {
-  user_pref.warn_divide_by_zero = check_str_pref ("warn_divide_by_zero");
+  user_pref.warn_divide_by_zero = check_preference ("warn_divide_by_zero");
 
   return 0;
 }
@@ -498,7 +509,7 @@
 warn_function_name_clash (void)
 {
   user_pref.warn_function_name_clash =
-    check_str_pref ("warn_function_name_clash");
+    check_preference ("warn_function_name_clash");
 
   return 0;
 }
@@ -565,7 +576,7 @@
 set_output_max_field_width (void)
 {
   double val;
-  if (builtin_real_scalar_variable ("output_max_field_width", val) == 0
+  if (builtin_real_scalar_variable ("output_max_field_width", val)
       && ! xisnan (val))
     {
       int ival = NINT (val);
@@ -583,7 +594,7 @@
 set_output_precision (void)
 {
   double val;
-  if (builtin_real_scalar_variable ("output_precision", val) == 0
+  if (builtin_real_scalar_variable ("output_precision", val)
       && ! xisnan (val))
     {
       int ival = NINT (val);
@@ -601,7 +612,7 @@
 set_save_precision (void)
 {
   double val;
-  if (builtin_real_scalar_variable ("save_precision", val) == 0
+  if (builtin_real_scalar_variable ("save_precision", val)
       && ! xisnan (val))
     {
       int ival = NINT (val);
--- a/src/variables.cc	Tue Oct 03 03:00:29 1995 +0000
+++ b/src/variables.cc	Tue Oct 03 03:14:49 1995 +0000
@@ -1617,11 +1617,11 @@
   DEFCONST ("argv", SBV_argv, , 0, 0,
     "the command line arguments this program was invoked with");
 
-  DEFVAR ("automatic_replot", SBV_automatic_replot, "false",
+  DEFVAR ("automatic_replot", SBV_automatic_replot, 0.0,
 	  0, automatic_replot,
     "if true, auto-insert a replot command when a plot changes");
 
-  DEFVAR ("beep_on_error", SBV_beep_on_error, "false", 0,
+  DEFVAR ("beep_on_error", SBV_beep_on_error, 0.0, 0,
 	  beep_on_error,
     "if true, beep before printing error messages");
 
@@ -1649,12 +1649,12 @@
 \"binary\", \"text\", or \"mat-binary\"");
 
   DEFVAR ("define_all_return_values", SBV_define_all_return_values,
-	  "false", 0, define_all_return_values,
+	  0.0, 0, define_all_return_values,
     "control whether values returned from functions should have a\n\
 value even if one has not been explicitly assigned.  See also\n\
 default_return_value");
 
-  DEFVAR ("do_fortran_indexing", SBV_do_fortran_indexing, "false", 0,
+  DEFVAR ("do_fortran_indexing", SBV_do_fortran_indexing, 0.0, 0,
 	  do_fortran_indexing,
     "allow single indices for matrices");
 
@@ -1673,9 +1673,9 @@
     "path to gnuplot binary");
 
 #ifdef GNUPLOT_HAS_MULTIPLOT
-  char *with_multiplot = "true";
+  char *with_multiplot = 1.0;
 #else
-  char *with_multiplot = "false";
+  char *with_multiplot = 0.0;
 #endif
 
   DEFVAR ("gnuplot_has_multiplot", SBV_gnuplot_has_multiplot,
@@ -1692,7 +1692,7 @@
   last compiled.  Possible values are \"system\" and \"all\"");
 
   DEFVAR ("implicit_str_to_num_ok", SBV_implicit_str_to_num_ok,
-	  "false", 0, implicit_str_to_num_ok,
+	  0.0, 0, implicit_str_to_num_ok,
     "allow implicit string to number conversion");
 
   DEFCONST ("inf", SBV_inf, octave_Inf, 0, 0,
@@ -1716,27 +1716,27 @@
 	  set_output_precision,
     "number of significant figures to display for numeric output");
 
-  DEFVAR ("page_screen_output", SBV_page_screen_output, "true", 0,
+  DEFVAR ("page_screen_output", SBV_page_screen_output, 1.0, 0,
 	  page_screen_output,
     "if possible, send output intended for the screen through the pager");
 
   DEFCONST ("pi", SBV_pi, 4.0 * atan (1.0), 0, 0,
     "ratio of the circumference of a circle to its diameter");
 
-  DEFVAR ("prefer_column_vectors", SBV_prefer_column_vectors, "true",
+  DEFVAR ("prefer_column_vectors", SBV_prefer_column_vectors, 1.0,
 	  0, prefer_column_vectors,
     "prefer column/row vectors");
 
   DEFVAR ("prefer_zero_one_indexing", SBV_prefer_zero_one_indexing,
-	  "false", 0, prefer_zero_one_indexing,
+	  0.0, 0, prefer_zero_one_indexing,
     "when there is a conflict, prefer zero-one style indexing");
 
-  DEFVAR ("print_answer_id_name", SBV_print_answer_id_name, "true", 0,
+  DEFVAR ("print_answer_id_name", SBV_print_answer_id_name, 1.0, 0,
 	  print_answer_id_name,
     "set output style to print `var_name = ...'");
 
   DEFVAR ("print_empty_dimensions", SBV_print_empty_dimensions,
-	  "true", 0, print_empty_dimensions,
+	  1.0, 0, print_empty_dimensions,
     "also print dimensions of empty matrices");
 
   DEFCONST ("program_invocation_name", SBV_program_invocation_name,
@@ -1748,11 +1748,11 @@
     "the name of the current program or script");
 
   DEFVAR ("propagate_empty_matrices", SBV_propagate_empty_matrices,
-	  "true", 0, propagate_empty_matrices,
+	  1.0, 0, propagate_empty_matrices,
     "operations on empty matrices return an empty matrix, not an error");
 
 #if 0
-  DEFVAR ("read_only_constants", SBV_read_only_constants, "true", 0,
+  DEFVAR ("read_only_constants", SBV_read_only_constants, 1.0, 0,
 	  read_only_constants,
     "allow built-in constants to be modified");
 #endif
@@ -1763,25 +1763,25 @@
   DEFCONST ("realmin", SBV_realmin, DBL_MIN, 0, 0,
     "realmin (): return smallest representable floating point number");
 
-  DEFVAR ("resize_on_range_error", SBV_resize_on_range_error, "true",
+  DEFVAR ("resize_on_range_error", SBV_resize_on_range_error, 1.0,
 	  0, resize_on_range_error,
     "enlarge matrices on assignment");
 
   DEFVAR ("return_last_computed_value",
-	  SBV_return_last_computed_value, "false", 0,
+	  SBV_return_last_computed_value, 0.0, 0,
 	  return_last_computed_value,
     "if a function does not return any values explicitly, return the\n\
   last computed value");
 
-  DEFVAR ("save_precision", SBV_save_precision, 17.0, 0,
+  DEFVAR ("save_precision", SBV_save_precision, 15.0, 0,
 	  set_save_precision,
     "number of significant figures kept by the ASCII save command");
 
-  DEFVAR ("silent_functions", SBV_silent_functions, "false", 0,
+  DEFVAR ("silent_functions", SBV_silent_functions, 0.0, 0,
 	  silent_functions,
     "suppress printing results in called functions");
 
-  DEFVAR ("split_long_rows", SBV_split_long_rows, "true", 0,
+  DEFVAR ("split_long_rows", SBV_split_long_rows, 1.0, 0,
 	  split_long_rows,
     "split long matrix rows instead of wrapping");
 
@@ -1791,7 +1791,7 @@
 
 #ifdef USE_GNU_INFO
   DEFVAR ("suppress_verbose_help_message",
-	  SBV_suppress_verbose_help_message, "false", 0,
+	  SBV_suppress_verbose_help_message, 0.0, 0,
 	  suppress_verbose_help_message,
     "suppress printing of message pointing to additional help in the\n\
 help and usage functions");
@@ -1806,25 +1806,25 @@
   DEFCONST ("stderr", SBV_stderr, 2.0, 0, 0,
     "file number of the standard error stream");
 
-  DEFVAR ("treat_neg_dim_as_zero", SBV_treat_neg_dim_as_zero, "false",
-	  0, treat_neg_dim_as_zero,
+  DEFVAR ("treat_neg_dim_as_zero", SBV_treat_neg_dim_as_zero, 0.0, 0,
+	  treat_neg_dim_as_zero,
     "convert negative dimensions to zero");
 
   DEFVAR ("warn_assign_as_truth_value",
-	  SBV_warn_assign_as_truth_value, "true", 0,
+	  SBV_warn_assign_as_truth_value, 1.0, 0,
 	  warn_assign_as_truth_value,
     "produce warning for assignments used as truth values");
 
   DEFVAR ("warn_comma_in_global_decl", SBV_warn_comma_in_global_decl,
-	  "true", 0, warn_comma_in_global_decl,
+	  1.0, 0, warn_comma_in_global_decl,
     "produce warning for commas in global declarations");
 
-  DEFVAR ("warn_divide_by_zero", SBV_warn_divide_by_zero, "true", 0,
+  DEFVAR ("warn_divide_by_zero", SBV_warn_divide_by_zero, 1.0, 0,
 	  warn_divide_by_zero,
     "on IEEE machines, allow divide by zero errors to be suppressed");
 
   DEFVAR ("warn_function_name_clash", SBV_warn_function_name_clash,
-	  "true", 0, warn_function_name_clash,
+	  1.0, 0, warn_function_name_clash,
     "produce warning if function name conflicts with file name");
 
   DEFVAR ("whitespace_in_literal_matrix",