changeset 31731:06bd4e4d4a92

make safe_source_file a private member function instead of a static function * interpreter.h, interpreter.cc (interpreter::safe_source_file): New private member function, adapted from static safe_source_file function.
author John W. Eaton <jwe@octave.org>
date Fri, 13 Jan 2023 18:24:51 -0500
parents 610a85b0ff62
children 1c9143a5b5d6
files libinterp/corefcn/interpreter.cc libinterp/corefcn/interpreter.h
diffstat 2 files changed, 33 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Thu Jan 12 10:22:04 2023 -0500
+++ b/libinterp/corefcn/interpreter.cc	Fri Jan 13 18:24:51 2023 -0500
@@ -339,38 +339,6 @@
 // The time we last time we changed directories.
 sys::time Vlast_chdir_time = 0.0;
 
-// Execute commands from a file and catch potential exceptions in a consistent
-// way.  This function should be called anywhere we might parse and execute
-// commands from a file before we have entered the main loop in
-// toplev.cc.
-
-static int safe_source_file (const std::string& file_name,
-                             const std::string& context = "",
-                             bool verbose = false,
-                             bool require_file = true)
-{
-  interpreter& interp = __get_interpreter__ ();
-
-  try
-    {
-      source_file (file_name, context, verbose, require_file);
-    }
-  catch (const interrupt_exception&)
-    {
-      interp.recover_from_exception ();
-
-      return 1;
-    }
-  catch (const execution_exception& ee)
-    {
-      interp.handle_exception (ee);
-
-      return 1;
-    }
-
-  return 0;
-}
-
 static void initialize_version_info (void)
 {
   octave_value_list args;
@@ -2141,4 +2109,33 @@
     }
 }
 
+// Execute commands from a file and catch potential exceptions in a consistent
+// way.  This function should be called anywhere we might parse and execute
+// commands from a file before we have entered the main loop in
+// toplev.cc.
+
+int interpreter::safe_source_file (const std::string& file_name,
+                                   const std::string& context,
+                                   bool verbose, bool require_file)
+{
+  try
+    {
+      source_file (file_name, context, verbose, require_file);
+    }
+  catch (const interrupt_exception&)
+    {
+      recover_from_exception ();
+
+      return 1;
+    }
+  catch (const execution_exception& ee)
+    {
+      handle_exception (ee);
+
+      return 1;
+    }
+
+  return 0;
+}
+
 OCTAVE_END_NAMESPACE(octave)
--- a/libinterp/corefcn/interpreter.h	Thu Jan 12 10:22:04 2023 -0500
+++ b/libinterp/corefcn/interpreter.h	Fri Jan 13 18:24:51 2023 -0500
@@ -576,6 +576,10 @@
 
   void execute_pkg_add (const std::string& dir);
 
+  int safe_source_file (const std::string& file_name,
+                        const std::string& context = "",
+                        bool verbose = false, bool require_file = true);
+
   //--------
 
   // The interpreter instance;  Currently it is only possible to