diff libinterp/corefcn/error.cc @ 31607:aac27ad79be6 stable

maint: Re-indent code after switch to using namespace macros. * build-env.h, build-env.in.cc, Cell.h, __betainc__.cc, __eigs__.cc, __ftp__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __magick_read__.cc, __pchip_deriv__.cc, amd.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, dasrt.cc, data.cc, debug.cc, defaults.cc, defaults.h, det.cc, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, gsvd.cc, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mexproto.h, mxarray.h, mxtypes.in.h, oct-errno.in.cc, oct-hdf5-types.cc, oct-hist.cc, oct-hist.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-default-image.h, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-output.cc, psi.cc, qr.cc, quadcc.cc, rand.cc, regexp.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xpow.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfns.cc, svd.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, __delaunayn__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audioread.cc, convhulln.cc, gzip.cc, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-lazy-idx.cc, ov-legacy-range.cc, ov-magic-int.cc, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.h, octave.cc, octave.h, op-b-sbm.cc, op-bm-sbm.cc, op-cs-scm.cc, op-fm-fcm.cc, op-fs-fcm.cc, op-s-scm.cc, op-scm-cs.cc, op-scm-s.cc, op-sm-cs.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, oct-lvalue.cc, oct-lvalue.h, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h: Re-indent code after switch to using namespace macros.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 18:02:15 -0800
parents e88a07dec498
children 23664317f0d3 96d321d59ee3
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Thu Dec 01 14:23:45 2022 -0800
+++ b/libinterp/corefcn/error.cc	Thu Dec 01 18:02:15 2022 -0800
@@ -235,697 +235,697 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
-  static octave_scalar_map
-  init_warning_options (const std::string& state)
-  {
-    octave_scalar_map initw;
+static octave_scalar_map
+init_warning_options (const std::string& state)
+{
+  octave_scalar_map initw;
 
-    initw.setfield ("identifier", "all");
-    initw.setfield ("state", state);
+  initw.setfield ("identifier", "all");
+  initw.setfield ("state", state);
 
-    return initw;
-  }
+  return initw;
+}
 
-  static octave_map
-  init_error_stack (interpreter& interp)
-  {
-    tree_evaluator& tw = interp.get_evaluator ();
+static octave_map
+init_error_stack (interpreter& interp)
+{
+  tree_evaluator& tw = interp.get_evaluator ();
 
-    return tw.empty_backtrace ();
-  }
+  return tw.empty_backtrace ();
+}
 
-  error_system::error_system (interpreter& interp)
-    : m_interpreter (interp),
-      m_debug_on_error (false),
-      m_debug_on_caught (false),
-      m_debug_on_warning (false),
-      m_discard_warning_messages (false),
-      m_beep_on_error (false),
-      m_backtrace_on_warning (true),
-      m_verbose_warning (false),
-      m_quiet_warning (false),
-      m_warning_options (init_warning_options ("on")),
-      m_last_error_message (),
-      m_last_warning_message (),
-      m_last_warning_id (),
-      m_last_error_id (),
-      m_last_error_stack (init_error_stack (interp))
-  {
-    initialize_default_warning_state ();
-  }
+error_system::error_system (interpreter& interp)
+  : m_interpreter (interp),
+    m_debug_on_error (false),
+    m_debug_on_caught (false),
+    m_debug_on_warning (false),
+    m_discard_warning_messages (false),
+    m_beep_on_error (false),
+    m_backtrace_on_warning (true),
+    m_verbose_warning (false),
+    m_quiet_warning (false),
+    m_warning_options (init_warning_options ("on")),
+    m_last_error_message (),
+    m_last_warning_message (),
+    m_last_warning_id (),
+    m_last_error_id (),
+    m_last_error_stack (init_error_stack (interp))
+{
+  initialize_default_warning_state ();
+}
 
-  octave_value
-  error_system::debug_on_error (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_debug_on_error, args, nargout,
-                                  "debug_on_error");
-  }
+octave_value
+error_system::debug_on_error (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_debug_on_error, args, nargout,
+                                "debug_on_error");
+}
 
-  octave_value
-  error_system::debug_on_caught (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_debug_on_caught, args, nargout,
-                                  "debug_on_caught");
-  }
+octave_value
+error_system::debug_on_caught (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_debug_on_caught, args, nargout,
+                                "debug_on_caught");
+}
 
-  octave_value
-  error_system::debug_on_warning (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_debug_on_warning, args, nargout,
-                                  "debug_on_warning");
-  }
+octave_value
+error_system::debug_on_warning (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_debug_on_warning, args, nargout,
+                                "debug_on_warning");
+}
 
-  octave_value
-  error_system::discard_warning_messages (const octave_value_list& args,
-                                          int nargout)
-  {
-    return set_internal_variable (m_discard_warning_messages, args, nargout,
-                                  "discard_warning_messages");
-  }
+octave_value
+error_system::discard_warning_messages (const octave_value_list& args,
+                                        int nargout)
+{
+  return set_internal_variable (m_discard_warning_messages, args, nargout,
+                                "discard_warning_messages");
+}
 
-  octave_value
-  error_system::beep_on_error (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_beep_on_error, args, nargout,
-                                  "beep_on_error");
-  }
+octave_value
+error_system::beep_on_error (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_beep_on_error, args, nargout,
+                                "beep_on_error");
+}
 
-  octave_value
-  error_system::backtrace_on_warning (const octave_value_list& args,
-                                      int nargout)
-  {
-    return set_internal_variable (m_backtrace_on_warning, args, nargout,
-                                  "backtrace_on_warning");
-  }
+octave_value
+error_system::backtrace_on_warning (const octave_value_list& args,
+                                    int nargout)
+{
+  return set_internal_variable (m_backtrace_on_warning, args, nargout,
+                                "backtrace_on_warning");
+}
 
-  octave_value
-  error_system::verbose_warning (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_verbose_warning, args, nargout,
-                                  "verbose_warning");
-  }
+octave_value
+error_system::verbose_warning (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_verbose_warning, args, nargout,
+                                "verbose_warning");
+}
 
-  octave_value
-  error_system::quiet_warning (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_quiet_warning, args, nargout,
-                                  "quiet_warning");
-  }
+octave_value
+error_system::quiet_warning (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_quiet_warning, args, nargout,
+                                "quiet_warning");
+}
 
-  octave_value
-  error_system::last_error_message (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_last_error_message, args, nargout,
-                                  "last_error_message");
-  }
+octave_value
+error_system::last_error_message (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_last_error_message, args, nargout,
+                                "last_error_message");
+}
 
-  octave_value
-  error_system::last_warning_message (const octave_value_list& args,
-                                      int nargout)
-  {
-    return set_internal_variable (m_last_warning_message, args, nargout,
-                                  "last_warning_message");
-  }
+octave_value
+error_system::last_warning_message (const octave_value_list& args,
+                                    int nargout)
+{
+  return set_internal_variable (m_last_warning_message, args, nargout,
+                                "last_warning_message");
+}
 
-  octave_value
-  error_system::last_warning_id (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_last_warning_id, args, nargout,
-                                  "last_warning_id");
-  }
+octave_value
+error_system::last_warning_id (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_last_warning_id, args, nargout,
+                                "last_warning_id");
+}
 
-  octave_value
-  error_system::last_error_id (const octave_value_list& args, int nargout)
-  {
-    return set_internal_variable (m_last_error_id, args, nargout,
-                                  "last_error_id");
-  }
+octave_value
+error_system::last_error_id (const octave_value_list& args, int nargout)
+{
+  return set_internal_variable (m_last_error_id, args, nargout,
+                                "last_error_id");
+}
 
-  // Use static fields for the best efficiency.
-  // NOTE: C++0x will allow these two to be merged into one.
-  static const char *bt_fieldnames[] =
-    { "file", "name", "line", "column", nullptr };
+// Use static fields for the best efficiency.
+// NOTE: C++0x will allow these two to be merged into one.
+static const char *bt_fieldnames[] =
+{ "file", "name", "line", "column", nullptr };
 
-  static const octave_fields bt_fields (bt_fieldnames);
+static const octave_fields bt_fields (bt_fieldnames);
 
-  octave_map
-  error_system::make_stack_map (const std::list<frame_info>& frames)
-  {
-    std::size_t nframes = frames.size ();
+octave_map
+error_system::make_stack_map (const std::list<frame_info>& frames)
+{
+  std::size_t nframes = frames.size ();
 
-    octave_map retval (dim_vector (nframes, 1), bt_fields);
+  octave_map retval (dim_vector (nframes, 1), bt_fields);
 
-    Cell& file = retval.contents (0);
-    Cell& name = retval.contents (1);
-    Cell& line = retval.contents (2);
-    Cell& column = retval.contents (3);
+  Cell& file = retval.contents (0);
+  Cell& name = retval.contents (1);
+  Cell& line = retval.contents (2);
+  Cell& column = retval.contents (3);
 
-    octave_idx_type k = 0;
+  octave_idx_type k = 0;
 
-    for (const auto& frm : frames)
-      {
-        file(k) = frm.file_name ();
-        name(k) = frm.fcn_name ();
-        line(k) = frm.line ();
-        column(k) = frm.column ();
+  for (const auto& frm : frames)
+    {
+      file(k) = frm.file_name ();
+      name(k) = frm.fcn_name ();
+      line(k) = frm.line ();
+      column(k) = frm.column ();
 
-        k++;
-      }
+      k++;
+    }
 
-    return retval;
-  }
+  return retval;
+}
 
-  std::list<frame_info>
-  error_system::make_stack_frame_list (const octave_map& stack)
-  {
-    std::list<frame_info> frames;
+std::list<frame_info>
+error_system::make_stack_frame_list (const octave_map& stack)
+{
+  std::list<frame_info> frames;
 
-    Cell file = stack.contents ("file");
-    Cell name = stack.contents ("name");
-    Cell line = stack.contents ("line");
-    Cell column = stack.contents ("column");
+  Cell file = stack.contents ("file");
+  Cell name = stack.contents ("name");
+  Cell line = stack.contents ("line");
+  Cell column = stack.contents ("column");
 
-    octave_idx_type nel = name.numel ();
+  octave_idx_type nel = name.numel ();
 
-    for (octave_idx_type i = 0; i < nel; i++)
-      frames.push_back (frame_info (file(i).string_value (),
-                                    name(i).string_value (),
-                                    line(i).int_value (),
-                                    column(i).int_value ()));
+  for (octave_idx_type i = 0; i < nel; i++)
+    frames.push_back (frame_info (file(i).string_value (),
+                                  name(i).string_value (),
+                                  line(i).int_value (),
+                                  column(i).int_value ()));
 
-    return frames;
-  }
+  return frames;
+}
 
-  // For given warning ID, return 0 if warnings are disabled, 1 if
-  // enabled, and 2 if the given ID should be an error instead of a
-  // warning.
+// For given warning ID, return 0 if warnings are disabled, 1 if
+// enabled, and 2 if the given ID should be an error instead of a
+// warning.
 
-  int error_system::warning_enabled (const std::string& id)
-  {
-    int retval = 0;
+int error_system::warning_enabled (const std::string& id)
+{
+  int retval = 0;
 
-    int all_state = -1;
-    int id_state = -1;
+  int all_state = -1;
+  int id_state = -1;
 
-    octave_map opts = warning_options ();
+  octave_map opts = warning_options ();
 
-    octave_idx_type nel = opts.numel ();
+  octave_idx_type nel = opts.numel ();
 
-    if (nel > 0)
-      {
-        Cell identifier = opts.contents ("identifier");
-        Cell state = opts.contents ("state");
+  if (nel > 0)
+    {
+      Cell identifier = opts.contents ("identifier");
+      Cell state = opts.contents ("state");
 
-        bool all_found = false;
-        bool id_found = false;
+      bool all_found = false;
+      bool id_found = false;
 
-        for (octave_idx_type i = 0; i < nel; i++)
-          {
-            octave_value ov = identifier(i);
-            std::string ovs = ov.string_value ();
+      for (octave_idx_type i = 0; i < nel; i++)
+        {
+          octave_value ov = identifier(i);
+          std::string ovs = ov.string_value ();
 
-            if (! all_found && ovs == "all")
-              {
-                all_state = check_state (state(i).string_value ());
+          if (! all_found && ovs == "all")
+            {
+              all_state = check_state (state(i).string_value ());
 
-                if (all_state >= 0)
-                  all_found = true;
-              }
+              if (all_state >= 0)
+                all_found = true;
+            }
 
-            if (! id_found && ovs == id)
-              {
-                id_state = check_state (state(i).string_value ());
+          if (! id_found && ovs == id)
+            {
+              id_state = check_state (state(i).string_value ());
 
-                if (id_state >= 0)
-                  id_found = true;
-              }
+              if (id_state >= 0)
+                id_found = true;
+            }
 
-            if (all_found && id_found)
-              break;
-          }
-      }
+          if (all_found && id_found)
+            break;
+        }
+    }
 
-    // If "all" is not present, assume warnings are enabled.
-    if (all_state == -1)
-      all_state = 1;
+  // If "all" is not present, assume warnings are enabled.
+  if (all_state == -1)
+    all_state = 1;
 
-    if (all_state == 0)
-      {
-        if (id_state >= 0)
-          retval = id_state;
-      }
-    else if (all_state == 1)
-      {
-        if (id_state == 0 || id_state == 2)
-          retval = id_state;
-        else
-          retval = all_state;
-      }
-    else if (all_state == 2)
-      {
-        if (id_state == 0)
-          retval= id_state;
-        else
-          retval = all_state;
-      }
+  if (all_state == 0)
+    {
+      if (id_state >= 0)
+        retval = id_state;
+    }
+  else if (all_state == 1)
+    {
+      if (id_state == 0 || id_state == 2)
+        retval = id_state;
+      else
+        retval = all_state;
+    }
+  else if (all_state == 2)
+    {
+      if (id_state == 0)
+        retval= id_state;
+      else
+        retval = all_state;
+    }
 
-    return retval;
-  }
+  return retval;
+}
 
-  void error_system::vusage (const char *id, const char *fmt, va_list args)
-  {
-    std::string str_id = id ? id : "";
-    std::string message = format_message (fmt, args);
+void error_system::vusage (const char *id, const char *fmt, va_list args)
+{
+  std::string str_id = id ? id : "";
+  std::string message = format_message (fmt, args);
 
-    throw_error ("usage", str_id, message);
-  }
+  throw_error ("usage", str_id, message);
+}
 
-  void error_system::vwarning (const char *name, const char *id,
-                               const char *fmt, va_list args)
-  {
-    flush_stdout ();
+void error_system::vwarning (const char *name, const char *id,
+                             const char *fmt, va_list args)
+{
+  flush_stdout ();
 
-    std::string base_msg = format_message (fmt, args);
-    std::string msg_string;
+  std::string base_msg = format_message (fmt, args);
+  std::string msg_string;
 
-    if (name)
-      msg_string = std::string (name) + ": ";
+  if (name)
+    msg_string = std::string (name) + ": ";
 
-    msg_string += base_msg;
+  msg_string += base_msg;
 
-    bool fmt_suppresses_backtrace = false;
-    std::size_t fmt_len = (fmt ? strlen (fmt) : 0);
-    fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n');
+  bool fmt_suppresses_backtrace = false;
+  std::size_t fmt_len = (fmt ? strlen (fmt) : 0);
+  fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n');
 
-    if (! fmt_suppresses_backtrace)
-      msg_string += '\n';
+  if (! fmt_suppresses_backtrace)
+    msg_string += '\n';
 
-    last_warning_id (id);
-    last_warning_message (base_msg);
+  last_warning_id (id);
+  last_warning_message (base_msg);
 
-    if (discard_warning_messages ())
-      return;
+  if (discard_warning_messages ())
+    return;
 
-    tree_evaluator& tw = m_interpreter.get_evaluator ();
+  tree_evaluator& tw = m_interpreter.get_evaluator ();
 
-    bool in_user_code = tw.in_user_code ();
+  bool in_user_code = tw.in_user_code ();
 
-    if (! quiet_warning ())
-      {
-        octave_diary << msg_string;
-        std::cerr << msg_string;
+  if (! quiet_warning ())
+    {
+      octave_diary << msg_string;
+      std::cerr << msg_string;
 
-        if (! fmt_suppresses_backtrace && in_user_code
-            && backtrace_on_warning ()
-            && ! discard_warning_messages ())
-          {
-            std::string bt_msg = tw.backtrace_message ();
+      if (! fmt_suppresses_backtrace && in_user_code
+          && backtrace_on_warning ()
+          && ! discard_warning_messages ())
+        {
+          std::string bt_msg = tw.backtrace_message ();
 
-            if (! bt_msg.empty ())
-              bt_msg = "warning: called from\n" + bt_msg;
+          if (! bt_msg.empty ())
+            bt_msg = "warning: called from\n" + bt_msg;
 
-            octave_diary << bt_msg << std::endl;
-            std::cerr << bt_msg << std::endl;
-          }
-      }
+          octave_diary << bt_msg << std::endl;
+          std::cerr << bt_msg << std::endl;
+        }
+    }
 
-    bp_table& bptab = tw.get_bp_table ();
+  bp_table& bptab = tw.get_bp_table ();
 
-    if ((m_interpreter.interactive ()
-         || application::forced_interactive ())
-        && debug_on_warning () && in_user_code && bptab.debug_on_warn (id))
-      {
-        unwind_protect_var<bool> restore_var (m_debug_on_warning, false);
+  if ((m_interpreter.interactive ()
+       || application::forced_interactive ())
+      && debug_on_warning () && in_user_code && bptab.debug_on_warn (id))
+    {
+      unwind_protect_var<bool> restore_var (m_debug_on_warning, false);
 
-        tw.enter_debugger ();
-      }
-  }
+      tw.enter_debugger ();
+    }
+}
 
-  void error_system::error_1 (execution_exception& ee, const char *id,
-                              const char *fmt, va_list args)
-  {
-    ee.set_identifier (id);
-    ee.set_message (format_message (fmt, args));
+void error_system::error_1 (execution_exception& ee, const char *id,
+                            const char *fmt, va_list args)
+{
+  ee.set_identifier (id);
+  ee.set_message (format_message (fmt, args));
 
-    throw_error (ee);
-  }
+  throw_error (ee);
+}
 
-  void error_system::error_1 (const char *id, const char *fmt,
-                              va_list args)
-  {
-    std::string message = format_message (fmt, args);
+void error_system::error_1 (const char *id, const char *fmt,
+                            va_list args)
+{
+  std::string message = format_message (fmt, args);
 
-    std::list<frame_info> stack_info;
+  std::list<frame_info> stack_info;
 
-    throw_error ("error", id, message);
-  }
+  throw_error ("error", id, message);
+}
 
-  void error_system::vwarning (const char *id, const char *fmt, va_list args)
-  {
-    int warn_opt = warning_enabled (id);
+void error_system::vwarning (const char *id, const char *fmt, va_list args)
+{
+  int warn_opt = warning_enabled (id);
 
-    if (warn_opt == 2)
-      {
-        // Handle this warning as an error.
+  if (warn_opt == 2)
+    {
+      // Handle this warning as an error.
 
-        error_1 (id, fmt, args);
-      }
-    else if (warn_opt == 1)
-      vwarning ("warning", id, fmt, args);
-  }
+      error_1 (id, fmt, args);
+    }
+  else if (warn_opt == 1)
+    vwarning ("warning", id, fmt, args);
+}
 
-  void error_system::rethrow_error (const std::string& id,
-                                    const std::string& msg,
-                                    const octave_map& stack)
-  {
-    std::list<frame_info> stack_info;
+void error_system::rethrow_error (const std::string& id,
+                                  const std::string& msg,
+                                  const octave_map& stack)
+{
+  std::list<frame_info> stack_info;
 
-    execution_exception ee ("error", id, msg, stack_info);
+  execution_exception ee ("error", id, msg, stack_info);
 
-    if (! stack.isempty ())
-      {
-        if (! (stack.contains ("file") && stack.contains ("name")
-               && stack.contains ("line")))
-          error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'");
+  if (! stack.isempty ())
+    {
+      if (! (stack.contains ("file") && stack.contains ("name")
+             && stack.contains ("line")))
+        error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'");
 
-        if (! stack.contains ("column"))
-          {
-            octave_map new_stack = stack;
+      if (! stack.contains ("column"))
+        {
+          octave_map new_stack = stack;
 
-            new_stack.setfield ("column", Cell (octave_value (-1)));
+          new_stack.setfield ("column", Cell (octave_value (-1)));
 
-            ee.set_stack_info (make_stack_frame_list (new_stack));
-          }
-        else
-          ee.set_stack_info (make_stack_frame_list (stack));
-      }
+          ee.set_stack_info (make_stack_frame_list (new_stack));
+        }
+      else
+        ee.set_stack_info (make_stack_frame_list (stack));
+    }
 
-    throw_error (ee);
-  }
+  throw_error (ee);
+}
 
-  void error_system::vpanic (const char *fmt, va_list args)
-  {
-    // Is there any point in trying to write the panic message to the
-    // diary?
+void error_system::vpanic (const char *fmt, va_list args)
+{
+  // Is there any point in trying to write the panic message to the
+  // diary?
 
-    std::cerr << "panic: " << format_message (fmt, args) << std::endl;
+  std::cerr << "panic: " << format_message (fmt, args) << std::endl;
 
-    abort ();
-  }
+  abort ();
+}
 
-  void error_system::panic (const char *fmt, ...)
-  {
-    va_list args;
-    va_start (args, fmt);
-    vpanic (fmt, args);
-    va_end (args);
-  }
+void error_system::panic (const char *fmt, ...)
+{
+  va_list args;
+  va_start (args, fmt);
+  vpanic (fmt, args);
+  va_end (args);
+}
 
-  octave_scalar_map error_system::warning_query (const std::string& id_arg)
-  {
-    octave_scalar_map retval;
+octave_scalar_map error_system::warning_query (const std::string& id_arg)
+{
+  octave_scalar_map retval;
 
-    std::string id = id_arg;
+  std::string id = id_arg;
 
-    if (id == "last")
-      id = last_warning_id ();
+  if (id == "last")
+    id = last_warning_id ();
 
-    octave_map opts = warning_options ();
+  octave_map opts = warning_options ();
 
-    Cell ident = opts.contents ("identifier");
-    Cell state = opts.contents ("state");
+  Cell ident = opts.contents ("identifier");
+  Cell state = opts.contents ("state");
 
-    octave_idx_type nel = ident.numel ();
+  octave_idx_type nel = ident.numel ();
 
-    panic_if (nel == 0);
+  panic_if (nel == 0);
 
-    bool found = false;
+  bool found = false;
 
-    std::string val;
+  std::string val;
 
-    for (octave_idx_type i = 0; i < nel; i++)
-      {
-        if (ident(i).string_value () == id)
-          {
-            val = state(i).string_value ();
-            found = true;
-            break;
-          }
-      }
+  for (octave_idx_type i = 0; i < nel; i++)
+    {
+      if (ident(i).string_value () == id)
+        {
+          val = state(i).string_value ();
+          found = true;
+          break;
+        }
+    }
 
-    if (! found)
-      {
-        for (octave_idx_type i = 0; i < nel; i++)
-          {
-            if (ident(i).string_value () == "all")
-              {
-                val = state(i).string_value ();
-                found = true;
-                break;
-              }
-          }
-      }
+  if (! found)
+    {
+      for (octave_idx_type i = 0; i < nel; i++)
+        {
+          if (ident(i).string_value () == "all")
+            {
+              val = state(i).string_value ();
+              found = true;
+              break;
+            }
+        }
+    }
 
-    // The warning state "all" is always supposed to remain in the list,
-    // so we should always find a state, either explicitly or by using the
-    // state for "all".
-    panic_unless (found);
+  // The warning state "all" is always supposed to remain in the list,
+  // so we should always find a state, either explicitly or by using the
+  // state for "all".
+  panic_unless (found);
 
-    retval.assign ("identifier", id);
-    retval.assign ("state", val);
+  retval.assign ("identifier", id);
+  retval.assign ("state", val);
 
-    return retval;
-  }
+  return retval;
+}
 
-  std::string error_system::default_warning_state (void)
-  {
-    std::string retval = "on";
+std::string error_system::default_warning_state (void)
+{
+  std::string retval = "on";
 
-    octave_map opts = warning_options ();
+  octave_map opts = warning_options ();
 
-    Cell ident = opts.contents ("identifier");
-    Cell state = opts.contents ("state");
+  Cell ident = opts.contents ("identifier");
+  Cell state = opts.contents ("state");
 
-    octave_idx_type nel = ident.numel ();
+  octave_idx_type nel = ident.numel ();
 
-    for (octave_idx_type i = 0; i < nel; i++)
-      {
-        if (ident(i).string_value () == "all")
-          {
-            retval = state(i).string_value ();
-            break;
-          }
-      }
+  for (octave_idx_type i = 0; i < nel; i++)
+    {
+      if (ident(i).string_value () == "all")
+        {
+          retval = state(i).string_value ();
+          break;
+        }
+    }
 
-    return retval;
-  }
+  return retval;
+}
 
-  void error_system::display_warning_options (std::ostream& os)
-  {
-    octave_map opts = warning_options ();
+void error_system::display_warning_options (std::ostream& os)
+{
+  octave_map opts = warning_options ();
 
-    Cell ident = opts.contents ("identifier");
-    Cell state = opts.contents ("state");
+  Cell ident = opts.contents ("identifier");
+  Cell state = opts.contents ("state");
 
-    octave_idx_type nel = ident.numel ();
+  octave_idx_type nel = ident.numel ();
 
-    std::string all_state = default_warning_state ();
+  std::string all_state = default_warning_state ();
 
-    if (all_state == "on")
-      os << "By default, warnings are enabled.";
-    else if (all_state == "off")
-      os << "By default, warnings are disabled.";
-    else if (all_state == "error")
-      os << "By default, warnings are treated as errors.";
-    else
-      panic_impossible ();
+  if (all_state == "on")
+    os << "By default, warnings are enabled.";
+  else if (all_state == "off")
+    os << "By default, warnings are disabled.";
+  else if (all_state == "error")
+    os << "By default, warnings are treated as errors.";
+  else
+    panic_impossible ();
 
-    if (nel > 1)
-      {
-        os << "\n";
-        os << "Non-default warning states are:\n\n";
-        os << "  State  Warning ID\n";
-      }
+  if (nel > 1)
+    {
+      os << "\n";
+      os << "Non-default warning states are:\n\n";
+      os << "  State  Warning ID\n";
+    }
 
-    // The state for "all" is always supposed to be first in the list.
+  // The state for "all" is always supposed to be first in the list.
 
-    for (octave_idx_type i = 1; i < nel; i++)
-      {
-        std::string tid = ident(i).string_value ();
-        std::string tst = state(i).string_value ();
+  for (octave_idx_type i = 1; i < nel; i++)
+    {
+      std::string tid = ident(i).string_value ();
+      std::string tst = state(i).string_value ();
 
-        os << std::setw (7) << tst << "  " << tid << "\n";
-      }
+      os << std::setw (7) << tst << "  " << tid << "\n";
+    }
 
-    os << std::endl;
-  }
+  os << std::endl;
+}
 
-  void error_system::set_warning_option (const std::string& state,
-                                         const std::string& ident)
-  {
-    std::string all_state = default_warning_state ();
+void error_system::set_warning_option (const std::string& state,
+                                       const std::string& ident)
+{
+  std::string all_state = default_warning_state ();
 
-    if (state != "on" && state != "off" && state != "error")
-      error ("invalid warning state: %s", state.c_str ());
+  if (state != "on" && state != "off" && state != "error")
+    error ("invalid warning state: %s", state.c_str ());
 
-    octave_map opts = warning_options ();
+  octave_map opts = warning_options ();
 
-    Cell tid = opts.contents ("identifier");
-    Cell tst = opts.contents ("state");
+  Cell tid = opts.contents ("identifier");
+  Cell tst = opts.contents ("state");
 
-    octave_idx_type nel = tid.numel ();
+  octave_idx_type nel = tid.numel ();
 
-    for (octave_idx_type i = 0; i < nel; i++)
-      {
-        if (tid(i).string_value () == ident)
-          {
-            // We found it in the current list of options.  If the state
-            // for "all" is same as arg1, we can simply remove the item
-            // from the list.
+  for (octave_idx_type i = 0; i < nel; i++)
+    {
+      if (tid(i).string_value () == ident)
+        {
+          // We found it in the current list of options.  If the state
+          // for "all" is same as arg1, we can simply remove the item
+          // from the list.
 
-            if (state == all_state && ident != "all")
-              {
-                for (i = i + 1; i < nel; i++)
-                  {
-                    tid(i-1) = tid(i);
-                    tst(i-1) = tst(i);
-                  }
+          if (state == all_state && ident != "all")
+            {
+              for (i = i + 1; i < nel; i++)
+                {
+                  tid(i-1) = tid(i);
+                  tst(i-1) = tst(i);
+                }
 
-                tid.resize (dim_vector (1, nel-1));
-                tst.resize (dim_vector (1, nel-1));
-              }
-            else
-              tst(i) = state;
+              tid.resize (dim_vector (1, nel-1));
+              tst.resize (dim_vector (1, nel-1));
+            }
+          else
+            tst(i) = state;
 
-            opts.clear ();
+          opts.clear ();
 
-            opts.assign ("identifier", tid);
-            opts.assign ("state", tst);
+          opts.assign ("identifier", tid);
+          opts.assign ("state", tst);
 
-            warning_options (opts);
+          warning_options (opts);
 
-            return;
-          }
-      }
+          return;
+        }
+    }
 
-    // The option wasn't already in the list.  Append it.
+  // The option wasn't already in the list.  Append it.
 
-    tid.resize (dim_vector (1, nel+1));
-    tst.resize (dim_vector (1, nel+1));
+  tid.resize (dim_vector (1, nel+1));
+  tst.resize (dim_vector (1, nel+1));
 
-    tid(nel) = ident;
-    tst(nel) = state;
+  tid(nel) = ident;
+  tst(nel) = state;
 
-    opts.clear ();
+  opts.clear ();
 
-    opts.assign ("identifier", tid);
-    opts.assign ("state", tst);
+  opts.assign ("identifier", tid);
+  opts.assign ("state", tst);
 
-    warning_options (opts);
-  }
+  warning_options (opts);
+}
 
-  void error_system::disable_warning (const std::string& id)
-  {
-    set_warning_option ("off", id);
-  }
+void error_system::disable_warning (const std::string& id)
+{
+  set_warning_option ("off", id);
+}
 
-  void error_system::initialize_default_warning_state (void)
-  {
-    warning_options (init_warning_options ("on"));
+void error_system::initialize_default_warning_state (void)
+{
+  warning_options (init_warning_options ("on"));
 
-    // Most people will want to have the following disabled.
+  // Most people will want to have the following disabled.
 
-    disable_warning ("Octave:array-as-logical");
-    disable_warning ("Octave:array-to-scalar");
-    disable_warning ("Octave:array-to-vector");
-    disable_warning ("Octave:imag-to-real");
-    disable_warning ("Octave:language-extension");
-    disable_warning ("Octave:missing-semicolon");
-    disable_warning ("Octave:neg-dim-as-zero");
-    disable_warning ("Octave:separator-insert");
-    disable_warning ("Octave:single-quote-string");
-    disable_warning ("Octave:str-to-num");
-    disable_warning ("Octave:mixed-string-concat");
-    disable_warning ("Octave:variable-switch-label");
-  }
+  disable_warning ("Octave:array-as-logical");
+  disable_warning ("Octave:array-to-scalar");
+  disable_warning ("Octave:array-to-vector");
+  disable_warning ("Octave:imag-to-real");
+  disable_warning ("Octave:language-extension");
+  disable_warning ("Octave:missing-semicolon");
+  disable_warning ("Octave:neg-dim-as-zero");
+  disable_warning ("Octave:separator-insert");
+  disable_warning ("Octave:single-quote-string");
+  disable_warning ("Octave:str-to-num");
+  disable_warning ("Octave:mixed-string-concat");
+  disable_warning ("Octave:variable-switch-label");
+}
 
-  void error_system::interpreter_try (unwind_protect& frame)
-  {
-    frame.protect_var (m_debug_on_error);
-    m_debug_on_error = false;
+void error_system::interpreter_try (unwind_protect& frame)
+{
+  frame.protect_var (m_debug_on_error);
+  m_debug_on_error = false;
 
-    frame.protect_var (m_debug_on_warning);
-    m_debug_on_warning = false;
+  frame.protect_var (m_debug_on_warning);
+  m_debug_on_warning = false;
 
-    // Leave debug_on_caught as it was, so errors in try/catch are still
-    // caught.
-  }
+  // Leave debug_on_caught as it was, so errors in try/catch are still
+  // caught.
+}
 
-  void error_system::throw_error (const std::string& err_type,
-                                  const std::string& id,
-                                  const std::string& message,
-                                  const std::list<frame_info>& stack_info_arg)
-  {
-    std::list<frame_info> stack_info = stack_info_arg;
+void error_system::throw_error (const std::string& err_type,
+                                const std::string& id,
+                                const std::string& message,
+                                const std::list<frame_info>& stack_info_arg)
+{
+  std::list<frame_info> stack_info = stack_info_arg;
 
-    if (stack_info.empty ())
-      {
-        tree_evaluator& tw = m_interpreter.get_evaluator ();
+  if (stack_info.empty ())
+    {
+      tree_evaluator& tw = m_interpreter.get_evaluator ();
 
-        stack_info = tw.backtrace_info ();
+      stack_info = tw.backtrace_info ();
 
-        // Print the error message only if it is different from the
-        // previous one; makes the output more concise and readable.
+      // Print the error message only if it is different from the
+      // previous one; makes the output more concise and readable.
 
-        stack_info.unique ();
-      }
+      stack_info.unique ();
+    }
 
-    execution_exception ex (err_type, id, message, stack_info);
+  execution_exception ex (err_type, id, message, stack_info);
 
-    throw_error (ex);
-  }
+  throw_error (ex);
+}
 
-  void error_system::throw_error (execution_exception& ex)
-  {
-    throw ex;
-  }
+void error_system::throw_error (execution_exception& ex)
+{
+  throw ex;
+}
 
-  void error_system::save_exception (const execution_exception& ee)
-  {
-    last_error_id (ee.identifier ());
-    std::string message = ee.message ();
-    std::string xmsg
-      = (message.size () > 0 && message.back () == '\n'
-         ? message.substr (0, message.size () - 1) : message);
-    last_error_message (xmsg);
-    last_error_stack (make_stack_map (ee.stack_info ()));
-  }
+void error_system::save_exception (const execution_exception& ee)
+{
+  last_error_id (ee.identifier ());
+  std::string message = ee.message ();
+  std::string xmsg
+    = (message.size () > 0 && message.back () == '\n'
+       ? message.substr (0, message.size () - 1) : message);
+  last_error_message (xmsg);
+  last_error_stack (make_stack_map (ee.stack_info ()));
+}
 
-  // DEPRECATED in Octave 7.
-  void error_system::display_exception (const execution_exception& ee,
-                                        std::ostream& os) const
-  {
-    if (m_beep_on_error)
-      os << "\a";
+// DEPRECATED in Octave 7.
+void error_system::display_exception (const execution_exception& ee,
+                                      std::ostream& os) const
+{
+  if (m_beep_on_error)
+    os << "\a";
 
-    ee.display (octave_diary);
-    ee.display (os);
-  }
+  ee.display (octave_diary);
+  ee.display (os);
+}
 
-  void error_system::display_exception (const execution_exception& ee) const
-  {
-    // FIXME: How should we handle beep_on_error?
+void error_system::display_exception (const execution_exception& ee) const
+{
+  // FIXME: How should we handle beep_on_error?
 
-    ee.display (octave_diary);
+  ee.display (octave_diary);
 
-    // FIXME: Handle display using an event manager message so that the
-    // GUI or other client can receive error messages without needing to
-    // capture them from std::cerr or some other stream.
+  // FIXME: Handle display using an event manager message so that the
+  // GUI or other client can receive error messages without needing to
+  // capture them from std::cerr or some other stream.
 
-    event_manager& evmgr = m_interpreter.get_event_manager ();
+  event_manager& evmgr = m_interpreter.get_event_manager ();
 
-    evmgr.display_exception (ee, m_beep_on_error);
-  }
+  evmgr.display_exception (ee, m_beep_on_error);
+}
 
 OCTAVE_END_NAMESPACE(octave)
 
@@ -1694,8 +1694,8 @@
                   octave_scalar_map tmp = es.warning_query (arg2);
 
                   octave_stdout << '"' << arg2 << R"(" warning state is ")" <<
-                                   tmp.getfield ("state").string_value () <<
-                                   "\"\n";
+                                tmp.getfield ("state").string_value () <<
+                                "\"\n";
                 }
             }