changeset 33241:39b6d6ca3831 bytecode-interpreter

maint: merge default to bytecode-interpreter
author John W. Eaton <jwe@octave.org>
date Sat, 23 Mar 2024 12:19:59 -0400
parents 5565b3e6eb60 (current diff) 4e5bc9c4f657 (diff)
children 106a4a07742a
files
diffstat 22 files changed, 317 insertions(+), 163 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/ButtonGroup.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/graphics/ButtonGroup.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -179,7 +179,7 @@
     frame->hide ();
 
   connect (m_buttongroup,
-           QOverload<QAbstractButton *>::of (&QButtonGroup::buttonClicked),
+           qOverload<QAbstractButton *> (&QButtonGroup::buttonClicked),
            this, &ButtonGroup::buttonClicked);
 }
 
--- a/libgui/graphics/Container.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/graphics/Container.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -69,11 +69,11 @@
           m_canvas = Canvas::create (m_interpreter, gh, this,
                                      fig.get ("renderer").string_value ());
 
-          connect (m_canvas, QOverload<const octave::fcn_callback&>::of (&Canvas::interpreter_event),
-                   this, QOverload<const octave::fcn_callback&>::of (&Container::interpreter_event));
+          connect (m_canvas, qOverload<const octave::fcn_callback&> (&Canvas::interpreter_event),
+                   this, qOverload<const octave::fcn_callback&> (&Container::interpreter_event));
 
-          connect (m_canvas, QOverload<const octave::meth_callback&>::of (&Canvas::interpreter_event),
-                   this, QOverload<const octave::meth_callback&>::of (&Container::interpreter_event));
+          connect (m_canvas, qOverload<const octave::meth_callback&> (&Canvas::interpreter_event),
+                   this, qOverload<const octave::meth_callback&> (&Container::interpreter_event));
 
           connect (m_canvas,
                    SIGNAL (gh_callback_event (const graphics_handle&,
--- a/libgui/graphics/Figure.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/graphics/Figure.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -122,11 +122,11 @@
   m_container = new Container (win, interp);
   win->setCentralWidget (m_container);
 
-  connect (m_container, QOverload<const octave::fcn_callback&>::of (&Container::interpreter_event),
-           this, QOverload<const octave::fcn_callback&>::of (&Figure::interpreter_event));
+  connect (m_container, qOverload<const octave::fcn_callback&> (&Container::interpreter_event),
+           this, qOverload<const octave::fcn_callback&> (&Figure::interpreter_event));
 
-  connect (m_container, QOverload<const octave::meth_callback&>::of (&Container::interpreter_event),
-           this, QOverload<const octave::meth_callback&>::of (&Figure::interpreter_event));
+  connect (m_container, qOverload<const octave::meth_callback&> (&Container::interpreter_event),
+           this, qOverload<const octave::meth_callback&> (&Figure::interpreter_event));
 
   figure::properties& fp = properties<figure> ();
 
--- a/libgui/graphics/PopupMenuControl.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/graphics/PopupMenuControl.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -64,7 +64,7 @@
 
   update (uicontrol::properties::ID_VALUE);
 
-  connect (box, QOverload<int>::of (&QComboBox::activated),
+  connect (box, qOverload<int> (&QComboBox::activated),
            this, &PopupMenuControl::currentIndexChanged);
 }
 
--- a/libgui/src/command-widget.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/command-widget.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -90,11 +90,11 @@
   connect (this, &command_widget::new_command_line_signal,
            m_console, &console::new_command_line);
 
-  connect (m_console, QOverload<const fcn_callback&>::of (&console::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&command_widget::interpreter_event));
+  connect (m_console, qOverload<const fcn_callback&> (&console::interpreter_event),
+           this, qOverload<const fcn_callback&> (&command_widget::interpreter_event));
 
-  connect (m_console, QOverload<const meth_callback&>::of (&console::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&command_widget::interpreter_event));
+  connect (m_console, qOverload<const meth_callback&> (&console::interpreter_event),
+           this, qOverload<const meth_callback&> (&command_widget::interpreter_event));
 
   insert_interpreter_output ("\n\n    Welcome to Octave\n\n");
 
--- a/libgui/src/documentation-bookmarks.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/documentation-bookmarks.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -340,7 +340,7 @@
     }
 
   menu.addAction (tr ("&Add Folder"), this,
-                  QOverload<bool>::of (&documentation_bookmarks::add_folder));
+                  qOverload<bool> (&documentation_bookmarks::add_folder));
 
   menu.addSeparator ();
 
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -232,11 +232,11 @@
   // Any interpreter_event signal from a file_editor_tab_widget is
   // handled the same as for the parent main_window object.
 
-  connect (m_edit_area, QOverload<const fcn_callback&>::of (&octave_qscintilla::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&file_editor_tab::interpreter_event));
-
-  connect (m_edit_area, QOverload<const meth_callback&>::of (&octave_qscintilla::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&file_editor_tab::interpreter_event));
+  connect (m_edit_area, qOverload<const fcn_callback&> (&octave_qscintilla::interpreter_event),
+           this, qOverload<const fcn_callback&> (&file_editor_tab::interpreter_event));
+
+  connect (m_edit_area, qOverload<const meth_callback&> (&octave_qscintilla::interpreter_event),
+           this, qOverload<const meth_callback&> (&file_editor_tab::interpreter_event));
 
   // connect modified signal
   connect (m_edit_area, SIGNAL (modificationChanged (bool)),
--- a/libgui/src/m-editor/file-editor.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/m-editor/file-editor.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -2629,8 +2629,8 @@
   connect (this, &file_editor::fetab_change_request,
            f, &file_editor_tab::change_editor_state);
 
-  connect (this, QOverload<const QWidget *, const QString&, bool>::of (&file_editor::fetab_save_file),
-           f, QOverload<const QWidget *, const QString&, bool>::of (&file_editor_tab::save_file));
+  connect (this, qOverload<const QWidget *, const QString&, bool> (&file_editor::fetab_save_file),
+           f, qOverload<const QWidget *, const QString&, bool> (&file_editor_tab::save_file));
 
   // Signals from the file_editor trivial operations
   connect (this, &file_editor::fetab_recover_from_exit,
@@ -2652,11 +2652,11 @@
   connect (this, &file_editor::fetab_context_edit,
            f, &file_editor_tab::context_edit);
 
-  connect (this, QOverload<const QWidget *>::of (&file_editor::fetab_save_file),
-           f, QOverload<const QWidget *>::of (&file_editor_tab::save_file));
+  connect (this, qOverload<const QWidget *> (&file_editor::fetab_save_file),
+           f, qOverload<const QWidget *> (&file_editor_tab::save_file));
 
   connect (this, &file_editor::fetab_save_file_as,
-           f, QOverload<const QWidget *>::of (&file_editor_tab::save_file_as));
+           f, qOverload<const QWidget *> (&file_editor_tab::save_file_as));
 
   connect (this, &file_editor::fetab_print_file,
            f, &file_editor_tab::print_file);
@@ -2756,11 +2756,11 @@
   // Any interpreter_event signal from a file_editor_tab_widget is
   // handled the same as for the parent main_window object.
 
-  connect (f, QOverload<const fcn_callback&>::of (&file_editor_tab::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&file_editor::interpreter_event));
-
-  connect (f, QOverload<const meth_callback&>::of (&file_editor_tab::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&file_editor::interpreter_event));
+  connect (f, qOverload<const fcn_callback&> (&file_editor_tab::interpreter_event),
+           this, qOverload<const fcn_callback&> (&file_editor::interpreter_event));
+
+  connect (f, qOverload<const meth_callback&> (&file_editor_tab::interpreter_event),
+           this, qOverload<const meth_callback&> (&file_editor::interpreter_event));
 
   return f;
 }
--- a/libgui/src/main-window.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/main-window.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -258,7 +258,7 @@
                this, &main_window::edit_mfile);
 
       connect (cmd_widget, &QTerminal::request_open_file_signal,
-               this, QOverload<const QString&, const QString&, int>::of (&main_window::open_file_signal));
+               this, qOverload<const QString&, const QString&, int> (&main_window::open_file_signal));
 
       connect (cmd_widget, &QTerminal::set_screen_size_signal,
                this, &main_window::set_screen_size);
@@ -289,7 +289,7 @@
   make_dock_widget_connections (m_file_browser_window);
 
   connect (m_file_browser_window, &files_dock_widget::open_file,
-           this, QOverload<const QString&>::of (&main_window::open_file_signal));
+           this, qOverload<const QString&> (&main_window::open_file_signal));
   connect (m_file_browser_window,
            &files_dock_widget::displayed_directory_changed,
            this, &main_window::set_current_working_directory);
@@ -357,7 +357,7 @@
            &workspace_model::show_symbol_tooltip);
 
   connect (editor, &file_editor::request_settings_dialog,
-           this, QOverload<const QString&>::of (&main_window::process_settings_dialog_request));
+           this, qOverload<const QString&> (&main_window::process_settings_dialog_request));
 
   connect (editor, &file_editor::request_dbcont_signal,
            this, &main_window::debug_continue);
@@ -1894,11 +1894,11 @@
   // Any interpreter_event signal from a set_path_dialog object is
   // handled the same as for the main_window object.
 
-  connect (m_set_path_dlg, QOverload<const fcn_callback&>::of (&set_path_dialog::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&main_window::interpreter_event));
-
-  connect (m_set_path_dlg, QOverload<const meth_callback&>::of (&set_path_dialog::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&main_window::interpreter_event));
+  connect (m_set_path_dlg, qOverload<const fcn_callback&> (&set_path_dialog::interpreter_event),
+           this, qOverload<const fcn_callback&> (&main_window::interpreter_event));
+
+  connect (m_set_path_dlg, qOverload<const meth_callback&> (&set_path_dialog::interpreter_event),
+           this, qOverload<const meth_callback&> (&main_window::interpreter_event));
 
   connect (m_set_path_dlg, &set_path_dialog::modify_path_signal,
            this, &main_window::modify_path);
@@ -1931,7 +1931,7 @@
                m_file_browser_window, &files_dock_widget::set_current_directory);
 
       connect (m_find_files_dlg, &find_files_dialog::file_selected,
-               this, QOverload<const QString&>::of (&main_window::open_file_signal));
+               this, qOverload<const QString&> (&main_window::open_file_signal));
 
       m_find_files_dlg->setWindowModality (Qt::NonModal);
     }
@@ -2166,11 +2166,11 @@
   connect (qt_link, &qt_interpreter_events::file_remove_signal,
            this, &main_window::file_remove_proxy);
 
-  connect (this, QOverload<const fcn_callback&>::of (&main_window::interpreter_event),
-           &m_octave_qobj, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event));
-
-  connect (this, QOverload<const meth_callback&>::of (&main_window::interpreter_event),
-           &m_octave_qobj, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event));
+  connect (this, qOverload<const fcn_callback&> (&main_window::interpreter_event),
+           &m_octave_qobj, qOverload<const fcn_callback&> (&base_qobject::interpreter_event));
+
+  connect (this, qOverload<const meth_callback&> (&main_window::interpreter_event),
+           &m_octave_qobj, qOverload<const meth_callback&> (&base_qobject::interpreter_event));
 
   configure_shortcuts ();
 }
--- a/libgui/src/octave-qobject.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/octave-qobject.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -239,11 +239,11 @@
   // Handle any interpreter_event signal from the octave_qapplication
   // object here.
 
-  connect (m_qapplication, QOverload<const fcn_callback&>::of (&octave_qapplication::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event));
+  connect (m_qapplication, qOverload<const fcn_callback&> (&octave_qapplication::interpreter_event),
+           this, qOverload<const fcn_callback&> (&base_qobject::interpreter_event));
 
-  connect (m_qapplication, QOverload<const meth_callback&>::of (&octave_qapplication::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event));
+  connect (m_qapplication, qOverload<const meth_callback&> (&octave_qapplication::interpreter_event),
+           this, qOverload<const meth_callback&> (&base_qobject::interpreter_event));
 
   if (m_app_context.experimental_terminal_widget ())
     {
--- a/libgui/src/octave-qobject.h	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/octave-qobject.h	Sat Mar 23 12:19:59 2024 -0400
@@ -194,11 +194,11 @@
 
   template <typename T> void connect_interpreter_events (T *widget)
   {
-    connect (widget, QOverload<const fcn_callback&>::of (&T::interpreter_event),
-             this, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event));
+    connect (widget, qOverload<const fcn_callback&> (&T::interpreter_event),
+             this, qOverload<const fcn_callback&> (&base_qobject::interpreter_event));
 
-    connect (widget, QOverload<const meth_callback&>::of (&T::interpreter_event),
-             this, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event));
+    connect (widget, qOverload<const meth_callback&> (&T::interpreter_event),
+             this, qOverload<const meth_callback&> (&base_qobject::interpreter_event));
   }
 
 public slots:
--- a/libgui/src/set-path-dialog.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/set-path-dialog.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -120,11 +120,11 @@
   // Any interpreter_event signal from a set_path_model object is
   // handled the same as for the parent set_path_dialog object.
 
-  connect (model, QOverload<const fcn_callback&>::of (&set_path_model::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&set_path_dialog::interpreter_event));
+  connect (model, qOverload<const fcn_callback&> (&set_path_model::interpreter_event),
+           this, qOverload<const fcn_callback&> (&set_path_dialog::interpreter_event));
 
-  connect (model, QOverload<const meth_callback&>::of (&set_path_model::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&set_path_dialog::interpreter_event));
+  connect (model, qOverload<const meth_callback&> (&set_path_model::interpreter_event),
+           this, qOverload<const meth_callback&> (&set_path_dialog::interpreter_event));
 
   m_path_list = new QListView (this);
   m_path_list->setWordWrap (false);
--- a/libgui/src/settings-dialog.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/settings-dialog.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -437,7 +437,7 @@
     {
       proxy_type->addItems (global_proxy_all_types);
       // Connect relevant signals for dis-/enabling some elements
-      connect (proxy_type, QOverload<int>::of (&QComboBox::currentIndexChanged),
+      connect (proxy_type, qOverload<int> (&QComboBox::currentIndexChanged),
                this, &settings_dialog::proxy_items_update);
       connect (use_proxy_server, &QCheckBox::toggled,
                this, &settings_dialog::proxy_items_update);
--- a/libgui/src/terminal-dock-widget.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/terminal-dock-widget.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -92,11 +92,11 @@
       connect (this, &terminal_dock_widget::visibilityChanged,
                widget, &QTerminal::handle_visibility_changed);
 
-      connect (widget, QOverload<const fcn_callback&>::of (&QTerminal::interpreter_event),
-               this, QOverload<const fcn_callback&>::of (&terminal_dock_widget::interpreter_event));
+      connect (widget, qOverload<const fcn_callback&> (&QTerminal::interpreter_event),
+               this, qOverload<const fcn_callback&> (&terminal_dock_widget::interpreter_event));
 
-      connect (widget, QOverload<const meth_callback&>::of (&QTerminal::interpreter_event),
-               this, QOverload<const meth_callback&>::of (&terminal_dock_widget::interpreter_event));
+      connect (widget, qOverload<const meth_callback&> (&QTerminal::interpreter_event),
+               this, qOverload<const meth_callback&> (&terminal_dock_widget::interpreter_event));
 
       m_terminal = widget;
     }
--- a/libgui/src/variable-editor.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libgui/src/variable-editor.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -1297,11 +1297,11 @@
 
   // Any interpreter_event signal from a variable_editor_stack object is
   // handled the same as for the parent variable_editor object.
-  connect (stack, QOverload<const fcn_callback&>::of (&variable_editor_stack::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&variable_editor::interpreter_event));
+  connect (stack, qOverload<const fcn_callback&> (&variable_editor_stack::interpreter_event),
+           this, qOverload<const fcn_callback&> (&variable_editor::interpreter_event));
 
-  connect (stack, QOverload<const meth_callback&>::of (&variable_editor_stack::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&variable_editor::interpreter_event));
+  connect (stack, qOverload<const meth_callback&> (&variable_editor_stack::interpreter_event),
+           this, qOverload<const meth_callback&> (&variable_editor::interpreter_event));
 
   connect (stack, &variable_editor_stack::edit_variable_signal,
            this, &variable_editor::edit_variable);
@@ -1373,11 +1373,11 @@
   // Any interpreter_event signal from a variable_editor_model object is
   // handled the same as for the parent variable_editor object.
 
-  connect (model, QOverload<const fcn_callback&>::of (&variable_editor_model::interpreter_event),
-           this, QOverload<const fcn_callback&>::of (&variable_editor::interpreter_event));
+  connect (model, qOverload<const fcn_callback&> (&variable_editor_model::interpreter_event),
+           this, qOverload<const fcn_callback&> (&variable_editor::interpreter_event));
 
-  connect (model, QOverload<const meth_callback&>::of (&variable_editor_model::interpreter_event),
-           this, QOverload<const meth_callback&>::of (&variable_editor::interpreter_event));
+  connect (model, qOverload<const meth_callback&> (&variable_editor_model::interpreter_event),
+           this, qOverload<const meth_callback&> (&variable_editor::interpreter_event));
 
   // Must supply a title for a QLabel to be created.  Calling set_title()
   // more than once will add more QLabels.  Could change octave_dock_widget
--- a/libinterp/corefcn/debug.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libinterp/corefcn/debug.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -592,6 +592,69 @@
   return ovl ();
 }
 
+static bool
+parse_start_end (const std::string& arg, int& start, int& end, const char *who)
+{
+  start = 0;
+  end = 0;
+
+  std::size_t ind = arg.find (':');
+
+  if (ind != std::string::npos)  // (start:end)
+    {
+      std::string start_str = arg.substr (0, ind);
+      std::string end_str = arg.substr (ind+1);
+
+      try
+        {
+          start = std::stoi (start_str);
+
+          if (end_str == "end")
+            end = std::numeric_limits<int>::max ();
+          else
+            end = std::stoi (end_str);
+        }
+      catch (const std::invalid_argument&)
+        {
+          error ("%s: invalid integer conversion while parsing range '%s'", who, arg.c_str ());
+        }
+      catch (const std::out_of_range&)
+        {
+          error ("%s: integer value out of bounds while parsing range '%s'", who, arg.c_str ());
+        }
+
+      if (std::min (start, end) <= 0)
+        error ("%s: start and end lines must be >= 1\n", who);
+
+      if (start > end)
+        error ("%s: start line must be less than end line\n", who);
+    }
+  else  // (dbtype lineno)
+    {
+      try
+        {
+          int line = std::stoi (arg);
+
+          if (line <= 0)
+            error ("%s: start and end lines must be >= 1\n", who);
+
+          start = line;
+          end = line;
+        }
+      catch (const std::invalid_argument&)
+        {
+          // May be a name instead of a number.
+          return false;
+        }
+      catch (const std::out_of_range&)
+        {
+          error ("%s: integer value out of bounds while parsing '%s'", who, arg.c_str ());
+        }
+    }
+
+  return true;
+}
+
 DEFMETHOD (dbtype, interp, args, ,
            doc: /* -*- texinfo -*-
 @deftypefn  {} {} dbtype
@@ -633,40 +696,8 @@
       {
         std::string arg = argv[1];
 
-        std::size_t ind = arg.find (':');
-
-        if (ind != std::string::npos)  // (dbtype start:end)
-          {
-            std::string start_str = arg.substr (0, ind);
-            std::string end_str = arg.substr (ind + 1);
-
-            start = atoi (start_str.c_str ());
-            if (end_str == "end")
-              end = std::numeric_limits<int>::max ();
-            else
-              end = atoi (end_str.c_str ());
-
-            if (std::min (start, end) <= 0)
-              error ("dbtype: start and end lines must be >= 1\n");
-
-            if (start > end)
-              error ("dbtype: start line must be less than end line\n");
-          }
-        else  // (dbtype fcn) || (dbtype lineno)
-          {
-            int line = atoi (arg.c_str ());
-
-            if (line == 0)  // (dbtype fcn)
-              fcn_name = arg;
-            else  // (dbtype lineno)
-              {
-                if (line <= 0)
-                  error ("dbtype: start and end lines must be >= 1\n");
-
-                start = line;
-                end = line;
-              }
-          }
+        if (! parse_start_end (arg, start, end, "dbtype"))
+          fcn_name = arg;
       }
       break;
 
@@ -674,31 +705,8 @@
       {
         fcn_name = argv[1];
 
-        std::string arg = argv[2];
-        std::size_t ind = arg.find (':');
-
-        if (ind != std::string::npos)
-          {
-            std::string start_str = arg.substr (0, ind);
-            std::string end_str = arg.substr (ind + 1);
-
-            start = atoi (start_str.c_str ());
-            if (end_str == "end")
-              end = std::numeric_limits<int>::max ();
-            else
-              end = atoi (end_str.c_str ());
-          }
-        else
-          {
-            start = atoi (arg.c_str ());
-            end = start;
-          }
-
-        if (std::min (start, end) <= 0)
-          error ("dbtype: start and end lines must be >= 1\n");
-
-        if (start > end)
-          error ("dbtype: start line must be less than end line\n");
+        if (! parse_start_end (argv[2], start, end, "dbtype"))
+          error ("dbtype: expecting start:end or location argument, found '%s'", argv[2].c_str ());
       }
       break;
 
@@ -725,6 +733,27 @@
   return ovl ();
 }
 
+static int
+parse_integer_argument (const std::string& arg, const char *who)
+{
+  int n = 0;
+
+  try
+    {
+      n = std::stoi (arg);
+    }
+  catch (const std::invalid_argument&)
+    {
+      error ("%s: invalid value of N, found '%s'", arg.c_str (), who);
+    }
+  catch (const std::out_of_range&)
+    {
+      error ("%s: value of N ('%s') is out of range", arg.c_str (), who);
+    }
+
+  return n;
+}
+
 DEFMETHOD (dblist, interp, args, ,
            doc: /* -*- texinfo -*-
 @deftypefn  {} {} dblist
@@ -748,11 +777,7 @@
       octave_value arg = args(0);
 
       if (arg.is_string ())
-        {
-          std::string s_arg = arg.string_value ();
-
-          n = atoi (s_arg.c_str ());
-        }
+        n = parse_integer_argument (arg.string_value (), "dblist");
       else
         n = args(0).int_value ();
 
@@ -798,7 +823,7 @@
               if (s_arg == "-completenames")
                 continue;
 
-              n = atoi (s_arg.c_str ());
+              n = parse_integer_argument (s_arg, "dbstack");
             }
           else
             n = arg.int_value ();
@@ -944,11 +969,7 @@
       octave_value arg = args(0);
 
       if (arg.is_string ())
-        {
-          std::string s_arg = arg.string_value ();
-
-          n = atoi (s_arg.c_str ());
-        }
+        n = parse_integer_argument (arg.string_value (), who.c_str ());
       else
         n = args(0).int_value ();
     }
@@ -1038,10 +1059,10 @@
         n = -2;
       else
         {
-          n = atoi (arg.c_str ());
+          n = parse_integer_argument (arg, "dbstep");
 
           if (n < 1)
-            error ("dbstep: invalid argument");
+            error ("dbstep: N must be greater than zero");
         }
     }
   else
--- a/libinterp/corefcn/event-manager.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libinterp/corefcn/event-manager.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -362,7 +362,19 @@
               if (idx != 2)
                 retval(idx++) = str;
               else
-                retval(idx++) = atoi (str.c_str ());
+                {
+                  // FIXME: Should we warn or error on invalid or out of
+                  // range values in STR?  When atoi was used for
+                  // conversion instead of std::stoi we did not.  Was
+                  // that intentional?
+
+                  try
+                    {
+                      retval(idx++) = std::stoi (str);
+                    }
+                  catch (const std::invalid_argument&) { }
+                  catch (const std::out_of_range&) { }
+                }
             }
         }
     }
@@ -377,7 +389,22 @@
       for (int idx = 0; idx < nel; idx++, it++)
         items.xelem (idx) = *it;
 
-      retval = ovl (items, *it++, atoi (it->c_str ()));
+      auto fpath = *it++;
+
+      int idx = 0;
+
+      // FIXME: Should we warn or error on invalid or out of range
+      // values in *IT?  When atoi was used for conversion instead of
+      // std::stoi we did not.  Was that intentional?
+
+      try
+        {
+          idx = std::stoi (*it);
+        }
+      catch (const std::invalid_argument&) { }
+      catch (const std::out_of_range&) { }
+
+      retval = ovl (items, fpath, idx);
     }
 
   return retval;
--- a/libinterp/corefcn/syscalls.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libinterp/corefcn/syscalls.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -485,7 +485,7 @@
       if (status < 0)
         retval = ovl (-1.0, msg);
       else
-        retval = ovl (0.0, "");
+        retval = ovl (status, "");
     }
 
   return retval;
--- a/libinterp/dldfcn/__init_fltk__.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libinterp/dldfcn/__init_fltk__.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -603,9 +603,21 @@
                   {
                     std::string valstr = fltk_label.substr (idx1 + 1, len - 1);
                     fltk_label.erase (idx1, len + 1);
-                    val = atoi (valstr.c_str ());
-                    if (val > 0 && val < 99)
-                      val++;
+
+                    // FIXME: Should we warn or error on invalid or out
+                    // of range values in VALSTR?  When atoi was used
+                    // for conversion instead of std::stoi we did not.
+                    // Was that intentional?
+
+                    try
+                      {
+                        val = std::stoi (valstr);
+
+                        if (val > 0 && val < 99)
+                          val++;
+                      }
+                    catch (const std::invalid_argument&) { }
+                    catch (const std::out_of_range&) { }
                   }
                 std::ostringstream valstream;
                 valstream << val;
--- a/libinterp/parse-tree/bp-table.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/libinterp/parse-tree/bp-table.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -370,6 +370,9 @@
       // allow "in" and "at" to be implicit
       if (args(pos).is_string ())
         {
+          // Default value.
+          tok = dbstop_in;
+
           std::string arg = args(pos).string_value ();
           if (arg == "in")
             {
@@ -386,10 +389,16 @@
               tok = dbstop_if;
               pos++;
             }
-          else if (atoi (args(pos).string_value ().c_str ()) > 0)
-            tok = dbstop_at;
           else
-            tok = dbstop_in;
+            {
+              try
+                {
+                  if (std::stoi (args(pos).string_value ()) > 0)
+                    tok = dbstop_at;
+                }
+              catch (const std::invalid_argument&) { }
+              catch (const std::out_of_range&) { }
+            }
         }
       else
         tok = dbstop_at;
@@ -431,8 +440,27 @@
               // FIXME: we really want to distinguish number
               // vs. method name here.
 
-              if (atoi (arg.c_str ()) == 0)
+              // FIXME: I'm not sure what the
+
+              bool int_conv_ok = true;
+
+              try
+                {
+                  if (std::stoi (arg) == 0)
+                    int_conv_ok = false;
+                }
+              catch (const std::invalid_argument&)
                 {
+                  int_conv_ok = false;
+                }
+              catch (const std::out_of_range&)
+                {
+                  int_conv_ok = false;
+                }
+
+              if (! int_conv_ok)
+                {
+                  // Assume we are looking at a function name.
                   // We have class and function names but already
                   // stored the class name in fcn_name.
                   class_name = fcn_name;
@@ -458,12 +486,27 @@
             {
               if (args(pos).is_string ())
                 {
-                  int line = atoi (args(pos).string_value ().c_str ());
+                  bool skip = false;
+
+                  std::string str = args(pos).string_value ();
+
+                  try
+                    {
+                      int line = std::stoi (str);
 
-                  if (line > 0)
-                    lines.insert (line);
-                  else
-                    break;        // may be "if" or a method name
+                      if (line > 0)
+                        lines.insert (line);
+                      else
+                        break; // may be "if" or a method name
+                    }
+                  catch (const std::invalid_argument&)
+                    {
+                      break; // may be "if" or a method name
+                    }
+                  catch (const std::out_of_range&)
+                    {
+                      error ("dbstop: location value out of range '%s'", str.c_str ());
+                    }
                 }
               else if (args(pos).isnumeric ())
                 {
--- a/liboctave/util/data-conv.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/liboctave/util/data-conv.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -391,8 +391,21 @@
         {
           if (s[pos] == '*')
             {
-              block_size = atoi (s.c_str ());
-              s = s.substr (pos+1);
+              try
+                {
+                  block_size = std::stoi (s);
+                  s = s.substr (pos+1);
+                }
+              catch (const std::invalid_argument&)
+                {
+                  (*current_liboctave_error_handler)
+                    ("invalid repeat count in '%s'", s.c_str ());
+                }
+              catch (const std::out_of_range&)
+                {
+                  (*current_liboctave_error_handler)
+                    ("repeat count out of range in '%s'", s.c_str ());
+                }
             }
           else
             (*current_liboctave_error_handler)
@@ -458,8 +471,21 @@
     {
       if (s[pos] == '*')
         {
-          block_size = atoi (s.c_str ());
-          s = s.substr (pos+1);
+          try
+            {
+              block_size = std::stoi (s);
+              s = s.substr (pos+1);
+            }
+          catch (const std::invalid_argument&)
+            {
+              (*current_liboctave_error_handler)
+                ("invalid repeat count in '%s'", s.c_str ());
+            }
+          catch (const std::out_of_range&)
+            {
+              (*current_liboctave_error_handler)
+                ("repeat count out of range in '%s'", s.c_str ());
+            }
         }
       else
         (*current_liboctave_error_handler)
--- a/liboctave/util/pathsearch.cc	Fri Mar 22 19:45:02 2024 +0100
+++ b/liboctave/util/pathsearch.cc	Sat Mar 23 12:19:59 2024 -0400
@@ -108,10 +108,35 @@
 
   if (! octave_kpse_initialized)
     {
-      std::string val = sys::env::getenv ("KPATHSEA_DEBUG");
+      std::string env_val = sys::env::getenv ("KPATHSEA_DEBUG");
+
+      if (! env_val.empty ())
+        {
+          unsigned int env_debug_flags = 0;
+
+          try
+            {
+              unsigned long val = std::stoul (env_val);
 
-      if (! val.empty ())
-        kpse_debug |= atoi (val.c_str ());
+              if (val > std::numeric_limits<unsigned int>::max ())
+                (*current_liboctave_warning_with_id_handler)
+                  ("Octave:kpathsea-debug-value-ignored", "directory_path::init: ignoring out of range KPATHSEA_DEBUG value '%s'", env_val.c_str ());
+              else
+                env_debug_flags = val;
+            }
+          catch (const std::invalid_argument&)
+              {
+                (*current_liboctave_warning_with_id_handler)
+                  ("Octave:kpathsea-debug-value-ignored", "directory_path::init: ignoring invalid KPATHSEA_DEBUG value '%s'", env_val.c_str ());
+              }
+            catch (const std::out_of_range&)
+              {
+                (*current_liboctave_warning_with_id_handler)
+                  ("Octave:kpathsea-debug-value-ignored", "directory_path::init: ignoring out of range KPATHSEA_DEBUG value '%s'", env_val.c_str ());
+              }
+
+          kpse_debug |= env_debug_flags;
+        }
 
       octave_kpse_initialized = true;
     }