changeset 20963:6ed7bae8017b stable

Fix behavior of warning ("error") call (bug #45753). * error.cc (Fwarning): Only apply to all warnings if "all" given explicitly. New test case. * error.cc (set_warning_option): "all" does not reinitialize all warnings
author Lachlan Andrew <lachlanbis@gmail.com>
date Wed, 23 Dec 2015 00:30:11 +0100
parents a7ebc9815d71
children 8281e37a5631
files libinterp/corefcn/error.cc
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Mon Dec 14 14:34:57 2015 -0800
+++ b/libinterp/corefcn/error.cc	Wed Dec 23 00:30:11 2015 +0100
@@ -1290,12 +1290,6 @@
 static void
 set_warning_option (const std::string& state, const std::string& ident)
 {
-  if (ident == "all")
-    {
-      initialize_warning_options (state);
-      return;
-    }
-
   std::string all_state = default_warning_state ();
 
   if (state != "on" && state != "off" && state != "error")
@@ -1518,7 +1512,9 @@
                   argc--;
                 }
 
-              if (arg2 == "all")
+              // If "all" is explicitly given.
+
+              if (argc >= 3 && arg2 == "all")
                 {
                   octave_map tmp;
 
@@ -1716,6 +1712,14 @@
   return retval;
 }
 
+/*
+## Test for (bug #45753)
+
+%!test
+%! warning ("error");
+%! assert (! isempty (help ("warning")));
+*/
+
 octave_value_list
 set_warning_state (const std::string& id, const std::string& state)
 {