changeset 4452:f3c21a1d1c62

[project @ 2003-07-09 23:20:18 by jwe]
author jwe
date Wed, 09 Jul 2003 23:20:19 +0000
parents ea1d3e1a4b1b
children 4accb5d84412
files ChangeLog PROJECTS doc/faq/Octave-FAQ.texi doc/interpreter/basics.txi doc/interpreter/strings.txi doc/interpreter/var.txi emacs/octave-mod.el scripts/ChangeLog scripts/miscellaneous/dump_prefs.m scripts/statistics/base/moment.m src/ChangeLog src/error.cc src/error.h src/gripes.cc src/gripes.h src/octave.cc src/ov-base.cc src/ov-base.h src/ov-bool-mat.h src/ov-bool.cc src/ov-bool.h src/ov-cell.h src/ov-ch-mat.h src/ov-mapper.cc src/ov-range.cc src/ov-range.h src/ov-re-mat.cc src/ov-re-mat.h src/ov-scalar.cc src/ov-scalar.h src/ov-str-mat.cc src/ov.cc src/ov.h src/parse.y src/pt-mat.cc src/variables.cc test/octave.test/io/io.exp test/octave.test/linalg/linalg.exp test/octave.test/linalg/schur-3.m test/octave.test/number/ismatrix-5.m test/octave.test/number/ismatrix-6.m test/octave.test/number/ismatrix-7.m test/octave.test/number/isscalar-5.m test/octave.test/number/issquare-5.m test/octave.test/number/issquare-7.m test/octave.test/number/issymmetric-5.m test/octave.test/number/issymmetric-7.m test/octave.test/number/isvector-5.m test/octave.test/number/isvector-6.m test/octave.test/number/number.exp test/octave.test/prefer/prefer-12.m test/octave.test/prefer/prefer-13.m test/octave.test/prefer/prefer.exp test/octave.test/system/getenv-4.m test/octave.test/system/putenv-4.m test/octave.test/system/system.exp
diffstat 56 files changed, 282 insertions(+), 227 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,9 +2,10 @@
 
 	* emacs/octave-mod.el (octave-variables): Include
 	DEFAULT_EXEC_PATH, DEFAULT_LOAD_PATH, crash_dumps_octave_core,
-	sighup_dumps_octave_core, sigterm_dumps_octave_core, and
-	warn_imag_to_real in the list.
-	Delete ok_to_lose_imaginary_part from list.	
+	sighup_dumps_octave_core, sigterm_dumps_octave_core,
+	warn_imag_to_real, warn_num_to_str, and warn_str_to_num in the list.
+	Delete ok_to_lose_imaginary_part, implicit_num_to_str_ok, and
+	implicit_str_to_num_ok from the list.
 
 2003-07-08  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
--- a/PROJECTS
+++ b/PROJECTS
@@ -241,16 +241,6 @@
 
   * Fix the parser so that
 
-      function foo ()
-        implicit_str_to_num_ok = 1;
-        '#' + 0;
-      endfunction
-
-    succeeds, even when implicit_str_to_num_ok is 0 at the time the
-    function is parsed.
-
-  * Fix the parser so that
-
       if (expr) 'this is a string' end
 
     is parsed as IF expr STRING END.
--- a/doc/faq/Octave-FAQ.texi
+++ b/doc/faq/Octave-FAQ.texi
@@ -725,8 +725,6 @@
   do_fortran_indexing = 1.0
   empty_list_elements_ok = 1.0
   fixed_point_format = 1.0
-  implicit_num_to_str_ok = 1.0
-  implicit_str_to_num_ok = 1.0
   page_screen_output = 0.0
   prefer_column_vectors = 0.0
   prefer_zero_one_indexing = 1.0
--- a/doc/interpreter/basics.txi
+++ b/doc/interpreter/basics.txi
@@ -163,7 +163,6 @@
 do_fortran_indexing           = 1
 crash_dumps_octave_core       = 0
 empty_list_elements_ok        = 1
-implicit_str_to_num_ok        = 1
 page_screen_output            = 0
 prefer_column_vectors         = 0
 print_empty_dimensions        = 0
--- a/doc/interpreter/strings.txi
+++ b/doc/interpreter/strings.txi
@@ -189,9 +189,9 @@
 
 @DOCSTRING(undo_string_escapes)
 
-@DOCSTRING(implicit_num_to_str_ok)
+@DOCSTRING(warn_num_to_str)
 
-@DOCSTRING(implicit_str_to_num_ok)
+@DOCSTRING(warn_str_to_num)
 
 @DOCSTRING(warn_single_quote_string)
 
--- a/doc/interpreter/var.txi
+++ b/doc/interpreter/var.txi
@@ -301,16 +301,6 @@
 
 Default value: @code{"system"}.
 
-@item implicit_num_to_str_ok
-@xref{String Conversions}.
-
-Default value: 0.
-
-@item implicit_str_to_num_ok
-@xref{String Conversions}.
-
-Default value: 0.
-
 @item max_recursion_depth
 @xref{Recursion}.
 
@@ -416,21 +406,41 @@
 
 Default value: 1.
 
+@item warn_function_name_clash
+@xref{Function Files}.
+
+Default value: 1.
+
 @item warn_imag_to_real
 @xref{Special Utility Matrices}.
 
 Default value: 0.
 
-@item warn_function_name_clash
-@xref{Function Files}.
+@item warn_missing_semicolon
+@xref{Defining Functions}.
+
+Default value: 0.
+
+@item warn_num_to_str
+@xref{String Conversions}.
 
 Default value: 1.
 
+@item warn_str_to_num
+@xref{String Conversions}.
+
+Default value: 0.
+
 @item warn_reload_forces_clear
 @xref{Dynamically Linked Functions}.
 
 Default value: 1.
 
+@item warn_single_quote_string)
+@xref{String Conversions}.
+
+Default value: 0.
+
 @item warn_variable_switch_label
 @xref{The switch Statement}.
 
--- a/emacs/octave-mod.el
+++ b/emacs/octave-mod.el
@@ -145,7 +145,7 @@
     "define_all_return_values" "do_fortran_indexing" "e"
     "echo_executing_commands" "empty_list_elements_ok" "eps"
     "error_text" "gnuplot_binary" "history_file"
-    "history_size" "ignore_function_time_stamp" "implicit_str_to_num_ok"
+    "history_size" "ignore_function_time_stamp"
     "inf" "nan" "nargin"
     "output_max_field_width" "output_precision"
     "page_output_immediately" "page_screen_output" "pi"
@@ -160,8 +160,8 @@
     "suppress_verbose_help_message" "treat_neg_dim_as_zero"
     "warn_assign_as_truth_value" "warn_comma_in_global_decl"
     "warn_divide_by_zero" "warn_function_name_clash"
-    "warn_imag_to_real"
-    "warn_missing_semicolon" "whitespace_in_literal_matrix")
+    "warn_imag_to_real" "warn_missing_semicolon"
+     "warn_num_to_str" "warn_str_to_num" "whitespace_in_literal_matrix")
   "Builtin variables in Octave.")
 
 (defvar octave-function-header-regexp
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,10 +1,15 @@
 2003-07-09  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* statistics/base/moment.m: Temporarily set warn_str_to_num, not
+	implict_str_to_num_ok.  Use unwind_protect block to do it.
+
 	* miscellaneous/dump_prefs.m: Include DEFAULT_EXEC_PATH,
 	DEFAULT_LOAD_PATH, crash_dumps_octave_core,
-	sighup_dumps_octave_core, sigterm_dumps_octave_core, and
-	warn_imag_to_real in the list.
-	Delete ok_to_lose_imaginary_part from list.	
+	sighup_dumps_octave_core, sigterm_dumps_octave_core,
+	warn_imag_to_real, warn_num_to_str, and warn_str_to_num in the
+	list.
+	Delete ok_to_lose_imaginary_part, implicit_num_to_str_ok, and
+	implicit_str_to_num_ok from list.
 
 2003-07-02  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
--- a/scripts/miscellaneous/dump_prefs.m
+++ b/scripts/miscellaneous/dump_prefs.m
@@ -74,8 +74,6 @@
               "history_file";
               "history_size";
               "ignore_function_time_stamp";
-              "implicit_num_to_str_ok";
-              "implicit_str_to_num_ok";
               "initialize_global_variables";
               "max_recursion_depth";
               "output_max_field_width";
@@ -105,6 +103,8 @@
               "warn_future_time_stamp";
               "warn_imag_to_real";
               "warn_missing_semicolon";
+              "warn_num_to_str";
+              "warn_str_to_num";
               "warn_variable_switch_label";
               "whitespace_in_literal_matrix"];
 
--- a/scripts/statistics/base/moment.m
+++ b/scripts/statistics/base/moment.m
@@ -57,15 +57,18 @@
   endif
 
   if (nargin == 3)
-    tmp = implicit_str_to_num_ok;
-    implicit_str_to_num_ok = "true";
-    if any (opt == "c")
-      x = x - ones (nr, 1) * sum (x) / nr;
-    endif
-    if any (opt == "a")
-      x = abs (x);
-    endif
-    implicit_str_to_num_ok = tmp;
+    tmp = warn_str_to_num;
+    unwind_protect
+      warn_str_to_num = 0;
+      if any (opt == "c")
+	x = x - ones (nr, 1) * sum (x) / nr;
+      endif
+      if any (opt == "a")
+	x = abs (x);
+      endif
+    unwind_protect_cleanup
+      warn_str_to_num = tmp;
+    end_unwind_protect
   endif
 
   m = sum(x .^ p) / nr;
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,54 @@
 2003-07-09  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* ov.cc (octave_value::convert_to_str): Call convert_to_str_internal.
+	(octave_value::convert_to_str_internal): New virtual function.
+	Rename all derived class convert_to_str functions to match.	
+
+	* variables.cc (generate_struct_completions): Set
+	discard_warning_messages, not Vwarning_option.  Also protect
+	warning_state.
+
+	* parse.y (fold): Temporarily discard warning messages.
+	Also protect warning_state.
+
+	* error.cc (discard_warning_messages): New variable.
+	(vwarning): Use it.
+	(warning): Don't print backtrace if discard_warning_messages is true.
+
+	* ov.cc (octave_value::convert_to_str):
+	Handle type conversion warning here.
+
+	* gripes.cc (gripe_implicit_conversion):
+	New function accepting std::string args.
+
+	* octave.cc (maximum_braindamage): Don't set
+	implicit_num_to_str_ok or implicit_str_to_num_ok.
+
+	* ov-base.cc (octave_base_value::char_matrix_value):
+	Vimplicit_num_to_str_ok no longer exists.
+	(octave_base_value::all_strings): Likewise.
+	(octave_base_value::string_value): Likewise.
+
+	* ov-str-mat.cc (octave_char_matrix_str::matrix_value): Warn based
+	on Vwarn_str_to_num instead of Vimplicit_str_to_num_ok.
+
+	* ov.cc (Vwarn_num_to_str, Vwarn_str_to_num): New variables.
+	(warn_num_to_str, warn_str_to_num): New functions.
+	(symbols_of_ov): Add DEFVARs for warn_num_to_str and Vwarn_str_to_num.
+	* ov.h (Vwarn_num_to_str, Vwarn_str_to_num): Provide decl.
+
+	* ov.cc (Vimplicit_num_to_str_ok, Vimplicit_str_to_num_ok):
+	Delete unused variables.
+	(implicit_num_to_str_ok, implicit_str_to_num_ok):
+	Delete unused functions.
+	(symbols_of_ov): Delete DEFVARs for implicit_num_to_str_ok and
+	implicit_str_to_num_ok.
+	* ov.h (Vimplicit_num_to_str_ok, Vimplicit_str_to_num_ok):
+	Delete decls.
+
+	* pt-mat.cc (tree_matrix::rvalue): Vimplicit_num_to_str_ok no
+	longer exists.
+
 	* ov.cc (Vwarn_imag_to_real): New variable.
 	(warn_imag_to_real): New function.
 	(symbols_of_ov): Add DEFVAR for warn_imag_to_real.
--- a/src/error.cc
+++ b/src/error.cc
@@ -100,6 +100,9 @@
 // TRUE means error messages are turned off.
 bool discard_error_messages = false;
 
+// TRUE means warning messages are turned off.
+bool discard_warning_messages = false;
+
 // The message buffer.
 static OSSTREAM *error_message_buffer = 0;
 
@@ -117,6 +120,9 @@
 static void
 vwarning (const char *name, const char *fmt, va_list args)
 {
+  if (discard_warning_messages)
+    return;
+
   flush_octave_stdout ();
 
   OSSTREAM output_buf;
@@ -358,7 +364,8 @@
     {
       if (curr_sym_tab != top_level_sym_tab
 	  && Vwarning_option == "backtrace"
-	  && ! warning_state)
+	  && ! warning_state
+	  && ! discard_warning_messages)
 	pr_where ("warning");
 
       va_list args;
--- a/src/error.h
+++ b/src/error.h
@@ -52,6 +52,9 @@
 // TRUE means error messages are turned off.
 extern bool discard_error_messages;
 
+// TRUE means warning messages are turned off.
+extern bool discard_warning_messages;
+
 // The current warning state.  Valid values are "on", "off",
 // "backtrace", or "debug".
 extern std::string Vwarning_option;
--- a/src/gripes.cc
+++ b/src/gripes.cc
@@ -164,6 +164,12 @@
 }
 
 void
+gripe_implicit_conversion (const std::string& from, const std::string& to)
+{
+  warning ("implicit conversion from %s to %s", from.c_str (), to.c_str ());
+}
+
+void
 gripe_divide_by_zero (void)
 {
   if (Vwarn_divide_by_zero)
--- a/src/gripes.h
+++ b/src/gripes.h
@@ -90,6 +90,9 @@
 gripe_implicit_conversion (const char *from, const char *to);
 
 extern void
+gripe_implicit_conversion (const std::string& from, const std::string& to);
+
+extern void
 gripe_divide_by_zero (void);
 
 #endif
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -352,8 +352,6 @@
   bind_builtin_variable ("define_all_return_values", true);
   bind_builtin_variable ("do_fortran_indexing", true);
   bind_builtin_variable ("fixed_point_format", true);
-  bind_builtin_variable ("implicit_num_to_str_ok", true);
-  bind_builtin_variable ("implicit_str_to_num_ok", true);
   bind_builtin_variable ("initialize_global_variables", true);
   bind_builtin_variable ("page_screen_output", false);
   bind_builtin_variable ("prefer_column_vectors", false);
--- a/src/ov-base.cc
+++ b/src/ov-base.cc
@@ -166,9 +166,9 @@
 }
 
 octave_value
-octave_base_value::convert_to_str (bool) const
+octave_base_value::convert_to_str_internal (bool) const
 {
-  gripe_wrong_type_arg ("octave_base_value::convert_to_str ()",
+  gripe_wrong_type_arg ("octave_base_value::convert_to_str_internal ()",
 			type_name ());
   return octave_value ();
 }
@@ -314,16 +314,11 @@
 {
   charMatrix retval;
 
-  if (Vimplicit_num_to_str_ok)
-    {
-      octave_value tmp = convert_to_str ();
+  octave_value tmp = convert_to_str ();
 
-      if (! error_state)
-	retval = tmp.char_matrix_value ();
-    }
-  else
-    gripe_wrong_type_arg ("octave_base_value::char_matrix_value()",
-			  type_name ());
+  if (! error_state)
+    retval = tmp.char_matrix_value ();
+
   return retval;
 }
 
@@ -332,15 +327,10 @@
 {
   string_vector retval;
 
-  if (Vimplicit_num_to_str_ok)
-    {
-      octave_value tmp = convert_to_str (pad);
+  octave_value tmp = convert_to_str (pad);
 
-      if (! error_state)
-	retval = tmp.all_strings ();
-    }
-  else
-    gripe_wrong_type_arg ("octave_base_value::all_strings()", type_name ());
+  if (! error_state)
+    retval = tmp.all_strings ();
 
   return retval;
 }
@@ -350,15 +340,10 @@
 {
   std::string retval;
 
-  if (Vimplicit_num_to_str_ok)
-    {
-      octave_value tmp = convert_to_str ();
+  octave_value tmp = convert_to_str ();
 
-      if (! error_state)
-	retval = tmp.string_value ();
-    }
-  else
-    gripe_wrong_type_arg ("octave_base_value::string_value()", type_name ());
+  if (! error_state)
+    retval = tmp.string_value ();
 
   return retval;
 }
--- a/src/ov-base.h
+++ b/src/ov-base.h
@@ -219,7 +219,7 @@
 
   boolMatrix bool_matrix_value (void) const;
 
-  octave_value convert_to_str (bool pad = false) const;
+  octave_value convert_to_str_internal (bool pad = false) const;
 
   void convert_to_row_or_column_vector (void);
 
--- a/src/ov-bool-mat.h
+++ b/src/ov-bool-mat.h
@@ -98,7 +98,7 @@
   boolMatrix bool_matrix_value (void) const
     { return matrix; }
 
-  octave_value convert_to_str (bool = false) const
+  octave_value convert_to_str_internal (bool = false) const
     { return octave_value (matrix); }
 
 protected:
--- a/src/ov-bool.cc
+++ b/src/ov-bool.cc
@@ -103,7 +103,7 @@
 }
 
 octave_value
-octave_bool::convert_to_str (bool) const
+octave_bool::convert_to_str_internal (bool) const
 {
   char s[2];
   s[0] = static_cast<char> (scalar);
--- a/src/ov-bool.h
+++ b/src/ov-bool.h
@@ -102,7 +102,7 @@
   boolMatrix bool_matrix_value (void) const
     { return boolMatrix (1, 1, scalar); }
 
-  octave_value convert_to_str (bool pad = false) const;
+  octave_value convert_to_str_internal (bool pad = false) const;
 
 private:
 
--- a/src/ov-cell.h
+++ b/src/ov-cell.h
@@ -98,7 +98,7 @@
 
   octave_value_list list_value (void) const;
 
-  octave_value convert_to_str (bool pad = false) const
+  octave_value convert_to_str_internal (bool pad = false) const
     { return all_strings (pad); }
 
   string_vector all_strings (bool pad = false) const;
--- a/src/ov-ch-mat.h
+++ b/src/ov-ch-mat.h
@@ -101,7 +101,7 @@
   charMatrix char_matrix_value (bool = false) const
     { return matrix; }
 
-  octave_value convert_to_str (bool = false) const
+  octave_value convert_to_str_internal (bool = false) const
     { return octave_value (matrix, true); }
 
 protected:
--- a/src/ov-mapper.cc
+++ b/src/ov-mapper.cc
@@ -117,9 +117,8 @@
 {
   octave_value retval;
 
-  // XXX FIXME XXX -- is_real_type can return true for strings if
-  // implicit_str_to_num_ok is nonzero.  Should it really work that
-  // way?
+  // XXX FIXME XXX -- is_real_type can return true.  Should it really
+  // work that way?
 
   if (arg.is_real_type () && ! (arg.is_string () && ch_map_fcn))
     {
--- a/src/ov-range.cc
+++ b/src/ov-range.cc
@@ -205,7 +205,7 @@
 }
 
 octave_value
-octave_range::convert_to_str (bool pad) const
+octave_range::convert_to_str_internal (bool pad) const
 {
   octave_value tmp (range.matrix_value ());
   return tmp.convert_to_str (pad);
--- a/src/ov-range.h
+++ b/src/ov-range.h
@@ -154,7 +154,7 @@
 
   Range range_value (void) const { return range; }
 
-  octave_value convert_to_str (bool pad = false) const;
+  octave_value convert_to_str_internal (bool pad = false) const;
 
   void print (std::ostream& os, bool pr_as_read_syntax = false) const;
 
--- a/src/ov-re-mat.cc
+++ b/src/ov-re-mat.cc
@@ -112,7 +112,7 @@
 }
 
 octave_value
-octave_matrix::convert_to_str (bool) const
+octave_matrix::convert_to_str_internal (bool) const
 {
   octave_value retval;
 
--- a/src/ov-re-mat.h
+++ b/src/ov-re-mat.h
@@ -102,7 +102,7 @@
 
   void decrement (void) { matrix -= 1.0; }
 
-  octave_value convert_to_str (bool pad = false) const;
+  octave_value convert_to_str_internal (bool pad = false) const;
 
 private:
 
--- a/src/ov-scalar.cc
+++ b/src/ov-scalar.cc
@@ -77,7 +77,7 @@
 }
 
 octave_value
-octave_scalar::convert_to_str (bool) const
+octave_scalar::convert_to_str_internal (bool) const
 {
   octave_value retval;
 
--- a/src/ov-scalar.h
+++ b/src/ov-scalar.h
@@ -94,7 +94,7 @@
   ComplexMatrix complex_matrix_value (bool = false) const
     { return  ComplexMatrix (1, 1, Complex (scalar)); }
 
-  octave_value convert_to_str (bool pad = false) const;
+  octave_value convert_to_str_internal (bool pad = false) const;
 
   void increment (void) { ++scalar; }
 
--- a/src/ov-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -152,18 +152,10 @@
 {
   Matrix retval;
 
-  int flag = force_string_conv;
-
-  if (! flag)
-    flag = Vimplicit_str_to_num_ok;
-
-  if (flag < 0)
+  if (! force_string_conv && Vwarn_str_to_num)
     gripe_implicit_conversion ("string", "real matrix");
 
-  if (flag)
-    retval = Matrix (matrix);
-  else
-    gripe_invalid_conversion ("string", "real matrix");
+  retval = Matrix (matrix);
 
   return retval;
 }
--- a/src/ov.cc
+++ b/src/ov.cc
@@ -82,21 +82,19 @@
 // for A already defined and a matrix type.
 bool Vdo_fortran_indexing;
 
-// Should `[97, 98, 99, "123"]' be a string?
-bool Vimplicit_num_to_str_ok;
+// Should we warn about conversions from complex to real?
+int Vwarn_imag_to_real;
 
-// Should we allow things like:
+// Should we print a warning when converting `[97, 98, 99, "123"]'
+// to a character string?
+bool Vwarn_num_to_str;
+
+// If TRUE, warn for operations like
 //
 //   octave> 'abc' + 0
 //   97 98 99
 //
-// to happen?  A positive value means yes.  A negative value means
-// yes, but print a warning message.  Zero means it should be
-// considered an error.
-int Vimplicit_str_to_num_ok;
-
-// Should we warn about conversions from complex to real?
-int Vwarn_imag_to_real;
+int Vwarn_str_to_num;
 
 // If TRUE, create column vectors when doing assignments like:
 //
@@ -1128,6 +1126,17 @@
   return retval;
 }
 
+octave_value
+octave_value::convert_to_str (bool pad) const
+{
+  octave_value retval = convert_to_str_internal (pad);
+
+  if (is_numeric_type () && Vwarn_num_to_str)
+    gripe_implicit_conversion (type_name (), retval.type_name ());
+
+  return retval;
+}
+
 void
 octave_value::print_with_name (std::ostream& output_buf,
 			       const std::string& name, 
@@ -1754,25 +1763,25 @@
 }
 
 static int
-implicit_num_to_str_ok (void)
+warn_imag_to_real (void)
 {
-  Vimplicit_num_to_str_ok = check_preference ("implicit_num_to_str_ok");
+  Vwarn_imag_to_real = check_preference ("warn_imag_to_real");
 
   return 0;
 }
 
 static int
-implicit_str_to_num_ok (void)
+warn_num_to_str (void)
 {
-  Vimplicit_str_to_num_ok = check_preference ("implicit_str_to_num_ok");
+  Vwarn_num_to_str = check_preference ("warn_num_to_str");
 
   return 0;
 }
 
 static int
-warn_imag_to_real (void)
+warn_str_to_num (void)
 {
-  Vwarn_imag_to_real = check_preference ("warn_imag_to_real");
+  Vwarn_str_to_num = check_preference ("warn_str_to_num");
 
   return 0;
 }
@@ -1860,33 +1869,6 @@
 the matrix.  The default value is 0. \n\
 @end defvr");
 
-  DEFVAR (implicit_num_to_str_ok, false, implicit_num_to_str_ok,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} implicit_num_to_str_ok\n\
-If the value of @code{implicit_num_to_str_ok} is nonzero, implicit\n\
-conversions of numbers to their ASCII character equivalents are\n\
-allowed when strings are constructed using a mixture of strings and\n\
-numbers in matrix notation.  Otherwise, an error message is printed and\n\
-control is returned to the top level. The default value is 0.  For\n\
-example,\n\
-\n\
-@example\n\
-@group\n\
-[ \"f\", 111, 111 ]\n\
-     @result{} \"foo\"\n\
-@end group\n\
-@end example\n\
-@end defvr");
-
-  DEFVAR (implicit_str_to_num_ok, false, implicit_str_to_num_ok,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} implicit_str_to_num_ok\n\
-If the value of @code{implicit_str_to_num_ok} is nonzero, implicit\n\
-conversions of strings to their numeric ASCII equivalents are allowed.\n\
-Otherwise, an error message is printed and control is returned to the\n\
-top level.  The default value is 0.\n\
-@end defvr");
-
   DEFVAR (prefer_column_vectors, true, prefer_column_vectors,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} prefer_column_vectors\n\
@@ -1986,6 +1968,40 @@
 printed for implicit conversions of complex numbers to real numbers.\n\
 The default value is 0.\n\
 @end defvr");
+
+  DEFVAR (warn_num_to_str, true, warn_num_to_str,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} warn_num_to_str\n\
+If the value of @code{warn_num_to_str} is nonzero, a warning is\n\
+printed for implicit conversions of numbers to their ASCII character\n\
+equivalents when strings are constructed using a mixture of strings and\n\
+numbers in matrix notation.  For example,\n\
+\n\
+@example\n\
+@group\n\
+[ \"f\", 111, 111 ]\n\
+     @result{} \"foo\"\n\
+@end group\n\
+@end example\n\
+elicits a warning if @code{warn_num_to_str} is nonzero.  The default\n\
+value is 1.\n\
+@end defvr");
+
+  DEFVAR (warn_str_to_num, false, warn_str_to_num,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} warn_str_to_num\n\
+If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\
+for implicit conversions of strings to their numeric ASCII equivalents.\n\
+For example,\n\
+@example\n\
+@group\n\
+\"abc\" + 0\n\
+     @result{} 97 98 99\n\
+@end group\n\
+@end example\n\
+elicits a warning if @code{warn_str_to_num} is nonzero.  The default\n\
+value is 0.\n\
+@end defvr");
 }
 
 /*
--- a/src/ov.h
+++ b/src/ov.h
@@ -536,8 +536,10 @@
   // class wants a certain kind of constant, he should simply ask for
   // it, and we should convert it if possible.
 
-  virtual octave_value convert_to_str (bool pad = false) const
-    { return rep->convert_to_str (pad); }
+  octave_value convert_to_str (bool pad = false) const;
+
+  virtual octave_value convert_to_str_internal (bool pad = false) const
+    { return rep->convert_to_str_internal (pad); }
 
   virtual void convert_to_row_or_column_vector (void)
     { rep->convert_to_row_or_column_vector (); }
@@ -723,18 +725,16 @@
 // for A already defined and a matrix type.
 extern bool Vdo_fortran_indexing;
 
-// Should `[97, 98, 99, "123"]' be a string?
-extern bool Vimplicit_num_to_str_ok;
+// Should we print a warning when converting `[97, 98, 99, "123"]'
+// to a character string?
+extern bool Vwarn_num_to_str;
 
-// Should we allow things like:
+// If TRUE, warn for operations like
 //
 //   octave> 'abc' + 0
 //   97 98 99
 //
-// to happen?  A positive value means yes.  A negative value means
-// yes, but print a warning message.  Zero means it should be
-// considered an error.
-extern int Vimplicit_str_to_num_ok;
+extern int Vwarn_str_to_num;
 
 // Should we warn about conversions from complex to real?
 extern int Vwarn_imag_to_real;
--- a/src/parse.y
+++ b/src/parse.y
@@ -1734,9 +1734,13 @@
   unwind_protect::begin_frame ("fold_binary_expression");
 
   unwind_protect_int (error_state);
+  unwind_protect_int (warning_state);
 
   unwind_protect_bool (discard_error_messages);
+  unwind_protect_bool (discard_warning_messages);
+
   discard_error_messages = true;
+  discard_warning_messages = true;
 
   tree_expression *op1 = e->lhs ();
   tree_expression *op2 = e->rhs ();
@@ -1780,9 +1784,13 @@
   unwind_protect::begin_frame ("fold_unary_expression");
 
   unwind_protect_int (error_state);
+  unwind_protect_int (warning_state);
 
   unwind_protect_bool (discard_error_messages);
+  unwind_protect_bool (discard_warning_messages);
+
   discard_error_messages = true;
+  discard_warning_messages = true;
 
   tree_expression *op = e->operand ();
 
@@ -1827,9 +1835,13 @@
   unwind_protect::begin_frame ("finish_colon_expression");
 
   unwind_protect_int (error_state);
+  unwind_protect_int (warning_state);
 
   unwind_protect_bool (discard_error_messages);
+  unwind_protect_bool (discard_warning_messages);
+
   discard_error_messages = true;
+  discard_warning_messages = true;
 
   tree_expression *base = e->base ();
   tree_expression *limit = e->limit ();
@@ -2803,9 +2815,13 @@
   unwind_protect::begin_frame ("finish_matrix");
 
   unwind_protect_int (error_state);
+  unwind_protect_int (warning_state);
 
   unwind_protect_bool (discard_error_messages);
+  unwind_protect_bool (discard_warning_messages);
+
   discard_error_messages = true;
+  discard_warning_messages = true;
 
   if (m->all_elements_are_constant ())
     {
--- a/src/pt-mat.cc
+++ b/src/pt-mat.cc
@@ -486,7 +486,7 @@
       some_strings_p = tmp.some_strings_p ();
       all_empty_p = tmp.all_empty_p ();
 
-      frc_str_conv = Vimplicit_num_to_str_ok && some_strings_p;
+      frc_str_conv = some_strings_p;
 
       if (all_strings_p)
 	chm.resize (nr, nc, Vstring_fill_char);
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -439,12 +439,14 @@
 
 	  unwind_protect::begin_frame ("generate_struct_completions");
 
-	  unwind_protect_str (Vwarning_option);
+	  unwind_protect_int (error_state);
+	  unwind_protect_int (warning_state);
+
 	  unwind_protect_bool (discard_error_messages);
-	  unwind_protect_int (error_state);
+	  unwind_protect_bool (discard_warning_messages);
 
-	  Vwarning_option = "off";
 	  discard_error_messages = true;
+	  discard_warning_messages = true;
 
 	  octave_value tmp = eval_string (prefix, true, parse_status);
 
--- a/test/octave.test/io/io.exp
+++ b/test/octave.test/io/io.exp
@@ -107,11 +107,11 @@
 do_test tmpnam-1.m
 
 set test tmpnam-2
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test tmpnam-2.m
 
 set test tmpnam-3
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test tmpnam-3.m
 
 set test tmpnam-4
--- a/test/octave.test/linalg/linalg.exp
+++ b/test/octave.test/linalg/linalg.exp
@@ -199,7 +199,7 @@
 do_test schur-2.m
 
 set test schur-3
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test schur-3.m
 
 set test schur-4
--- a/test/octave.test/linalg/schur-3.m
+++ b/test/octave.test/linalg/schur-3.m
@@ -1,1 +1,2 @@
+warn_num_to_str = 1;
 schur ([1, 2; 3, 4], 2)
--- a/test/octave.test/number/ismatrix-5.m
+++ b/test/octave.test/number/ismatrix-5.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! ismatrix ("t");
-implicit_str_to_num_ok = 1;
-t2 = ! ismatrix ("t");
-t1 && t2
+warn_str_to_num = 0;
+ismatrix ("t")
--- a/test/octave.test/number/ismatrix-6.m
+++ b/test/octave.test/number/ismatrix-6.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! ismatrix ("test");
-implicit_str_to_num_ok = 1;
-t2 = ! ismatrix ("test");
-t1 && t2
+warn_str_to_num = 0;
+ismatrix ("test")
--- a/test/octave.test/number/ismatrix-7.m
+++ b/test/octave.test/number/ismatrix-7.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! ismatrix (["test"; "ing"]);
-implicit_str_to_num_ok = 1;
-t2 = ! ismatrix (["test"; "ing"]);
-t1 && t2
+warn_str_to_num = 0;
+ismatrix (["test"; "ing"])
--- a/test/octave.test/number/isscalar-5.m
+++ b/test/octave.test/number/isscalar-5.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! isscalar ("t");
-implicit_str_to_num_ok = 1;
-t2 = ! isscalar ("t");
-t1 && t2
+warn_str_to_num = 0;
+isscalar ("t")
--- a/test/octave.test/number/issquare-5.m
+++ b/test/octave.test/number/issquare-5.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! issquare ("t");
-implicit_str_to_num_ok = 1;
-t2 = ! issquare ("t");
-t1 && t2
+warn_str_to_num = 0;
+issquare ("t")
--- a/test/octave.test/number/issquare-7.m
+++ b/test/octave.test/number/issquare-7.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! issquare (["test"; "ing"; "1"; "2"]);
-implicit_str_to_num_ok = 1;
-t2 = ! issquare (["test"; "ing"; "1"; "2"]);
-t1 && t2
+warn_str_to_num = 0;
+issquare (["test"; "ing"; "1"; "2"])
--- a/test/octave.test/number/issymmetric-5.m
+++ b/test/octave.test/number/issymmetric-5.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! issymmetric ("t");
-implicit_str_to_num_ok = 1;
-t2 = ! issymmetric ("t");
-t1 && t2
+warn_str_to_num = 0;
+issymmetric ("t")
--- a/test/octave.test/number/issymmetric-7.m
+++ b/test/octave.test/number/issymmetric-7.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! issymmetric (["te"; "et"]);
-implicit_str_to_num_ok = 1;
-t2 = ! issymmetric (["te"; "et"]);
-t1 && t2
+warn_str_to_num = 0;
+issymmetric (["te"; "et"])
--- a/test/octave.test/number/isvector-5.m
+++ b/test/octave.test/number/isvector-5.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! isvector ("t");
-implicit_str_to_num_ok = 1;
-t2 = ! isvector ("t");
-t1 && t2
+warn_str_to_num = 0;
+isvector ("t")
--- a/test/octave.test/number/isvector-6.m
+++ b/test/octave.test/number/isvector-6.m
@@ -1,5 +1,2 @@
-implicit_str_to_num_ok = 0;
-t1 = ! isvector ("test");
-implicit_str_to_num_ok = 1;
-t2 = ! isvector ("test");
-t1 && t2
+warn_str_to_num = 0;
+isvector ("test")
--- a/test/octave.test/number/number.exp
+++ b/test/octave.test/number/number.exp
@@ -15,15 +15,15 @@
 do_test ismatrix-4.m
 
 set test ismatrix-5
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test ismatrix-5.m
 
 set test ismatrix-6
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test ismatrix-6.m
 
 set test ismatrix-7
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test ismatrix-7.m
 
 set test ismatrix-8
@@ -55,11 +55,11 @@
 do_test isvector-4.m
 
 set test isvector-5
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test isvector-5.m
 
 set test isvector-6
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test isvector-6.m
 
 set test isvector-7
@@ -95,7 +95,7 @@
 do_test isscalar-4.m
 
 set test isscalar-5
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test isscalar-5.m
 
 set test isscalar-6
@@ -135,7 +135,7 @@
 do_test issquare-4.m
 
 set test issquare-5
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test issquare-5.m
 
 set test issquare-6
@@ -143,7 +143,7 @@
 do_test issquare-6.m
 
 set test issquare-7
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test issquare-7.m
 
 set test issquare-8
@@ -179,7 +179,7 @@
 do_test issymmetric-4.m
 
 set test issymmetric-5
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test issymmetric-5.m
 
 set test issymmetric-6
@@ -187,7 +187,7 @@
 do_test issymmetric-6.m
 
 set test issymmetric-7
-set prog_output "ans = 1"
+set prog_output "ans = 0"
 do_test issymmetric-7.m
 
 set test issymmetric-8
--- a/test/octave.test/prefer/prefer-12.m
+++ b/test/octave.test/prefer/prefer-12.m
@@ -1,2 +1,2 @@
-implicit_str_to_num_ok = 1;
+warn_str_to_num = 1;
 "d" + 0
--- a/test/octave.test/prefer/prefer-13.m
+++ b/test/octave.test/prefer/prefer-13.m
@@ -1,2 +1,2 @@
-implicit_str_to_num_ok = 0;
+warn_str_to_num = 1;
 "d" + 0
--- a/test/octave.test/prefer/prefer.exp
+++ b/test/octave.test/prefer/prefer.exp
@@ -44,14 +44,14 @@
 set prog_output "ans = 1"
 do_test prefer-11.m
 
-## implicit_str_to_num_ok
+## warn_str_to_num
 
 set test implicit-str-to-num-ok-1
 set prog_output "ans = 100"
 do_test prefer-12.m
 
 set test implicit-str-to-num-ok-2
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test prefer-13.m
 
 ## warn_imag_to_real
--- a/test/octave.test/system/getenv-4.m
+++ b/test/octave.test/system/getenv-4.m
@@ -1,1 +1,2 @@
+warn_num_to_str = 1;
 getenv (1)
--- a/test/octave.test/system/putenv-4.m
+++ b/test/octave.test/system/putenv-4.m
@@ -1,1 +1,2 @@
+warn_num_to_str = 1;
 putenv (1, 2)
--- a/test/octave.test/system/system.exp
+++ b/test/octave.test/system/system.exp
@@ -368,7 +368,7 @@
 do_test getenv-3.m
 
 set test getenv-4
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test getenv-4.m
 
 set test putenv-1
@@ -384,7 +384,7 @@
 do_test putenv-3.m
 
 set test putenv-4
-set prog_output "error:.*"
+set prog_output "warning:.*"
 do_test putenv-4.m
 
 set test cd-1