# HG changeset patch # User Lachlan Andrew # Date 1449191742 -39600 # Node ID 8d612114e54ddbb190a29e9d2723a4ef0e3ace29 # Parent c06cbec3a88328a3bf531f431d830567f3d4dcf2 set last warning id and message even if warning state is off (bug #41028) * error.cc (vwarning): New arg, warn_opt. Only flush octave_stdout and print warning message if warn_opt is 1. (warning_1): Pass warn_opt to vwarning. diff -r c06cbec3a883 -r 8d612114e54d libinterp/corefcn/error.cc --- a/libinterp/corefcn/error.cc Sun Nov 29 19:58:52 2015 +1100 +++ b/libinterp/corefcn/error.cc Fri Dec 04 12:15:42 2015 +1100 @@ -325,13 +325,12 @@ debug_or_throw_exception (bool show_stac // Warning messages are never buffered. static void -vwarning (const char *name, const char *id, const char *fmt, va_list args) +vwarning (const char *name, const char *id, int warn_opt, + const char *fmt, va_list args) { if (discard_warning_messages) return; - flush_octave_stdout (); - std::ostringstream output_buf; octave_vformat (output_buf, fmt, args); @@ -351,11 +350,16 @@ vwarning (const char *name, const char * Vlast_warning_id = id; Vlast_warning_message = base_msg; - if (! Vquiet_warning) + if (warn_opt == 1) { - octave_diary << msg_string; + flush_octave_stdout (); - std::cerr << msg_string; + if (! Vquiet_warning) + { + octave_diary << msg_string; + + std::cerr << msg_string; + } } } @@ -668,7 +672,7 @@ warning_1 (const char *id, const char *f error_1 (std::cerr, "error", id, fmt, args); } - else if (warn_opt == 1) + else { bool fmt_suppresses_backtrace = false; size_t fmt_len = fmt ? strlen (fmt) : 0; @@ -678,30 +682,34 @@ warning_1 (const char *id, const char *f { // Strip newline before issuing warning std::string tmp_fmt (fmt, fmt_len - 1); - vwarning ("warning", id, tmp_fmt.c_str (), args); + vwarning ("warning", id, warn_opt, tmp_fmt.c_str (), args); } else - vwarning ("warning", id, fmt, args); + vwarning ("warning", id, warn_opt, fmt, args); - bool in_user_code = octave_call_stack::caller_user_code () != 0; + if (warn_opt == 1) + { + bool in_user_code = octave_call_stack::caller_user_code () != 0; - if (! fmt_suppresses_backtrace && in_user_code - && Vbacktrace_on_warning - && ! discard_warning_messages) - pr_where (std::cerr, "warning"); + if (! fmt_suppresses_backtrace && in_user_code + && Vbacktrace_on_warning + && ! discard_warning_messages) + pr_where (std::cerr, "warning"); - if ((interactive || forced_interactive) - && Vdebug_on_warning && in_user_code) - { - unwind_protect frame; - frame.protect_var (Vdebug_on_warning); - Vdebug_on_warning = false; + if ((interactive || forced_interactive) + && Vdebug_on_warning && in_user_code) + { + unwind_protect frame; + frame.protect_var (Vdebug_on_warning); + Vdebug_on_warning = false; - tree_evaluator::debug_mode = true; + tree_evaluator::debug_mode = true; - tree_evaluator::current_frame = octave_call_stack::current_frame (); + tree_evaluator::current_frame + = octave_call_stack::current_frame (); - do_keyboard (octave_value_list ()); + do_keyboard (octave_value_list ()); + } } } }