26 #if defined (HAVE_CONFIG_H)
52 #include "builtin-defun-decls.h"
98 DEFUN (__version_info__, args, ,
106 int nargin = args.
length ();
108 if (nargin != 0 && nargin != 4)
115 else if (nargin == 4)
119 vinfo.
assign (
"Name", args(0));
120 vinfo.
assign (
"Version", args(1));
121 vinfo.
assign (
"Release", args(2));
122 vinfo.
assign (
"Date", args(3));
178 int numel = args.length ();
190 exit_status = args(0).xnint_value (
"quit: STATUS must be an integer");
192 = args(1).xstring_value (
"quit: second argument must be a string");
197 error (R
"(quit: second argument must be string "force")");
201 if (args(0).is_string ())
204 = R
"(quit: option must be string "cancel" or "force")";
206 std::string opt = args(0).xstring_value (msg);
210 else if (opt ==
"force")
216 exit_status = args(0).xnint_value (
"quit: STATUS must be an integer");
223 if (interp.executing_finish_script ())
224 interp.cancel_quit (
true);
229 interp.quit (exit_status, force);
236 DEFMETHOD (atexit, interp, args, nargout,
282 int nargin = args.length ();
284 if (nargin < 1 || nargin > 2)
287 std::string arg = args(0).xstring_value (
"atexit: FCN argument must be a string");
289 bool add_mode = (nargin == 2)
290 ? args(1).xbool_value (
"atexit: FLAG argument must be a logical value")
296 interp.add_atexit_fcn (arg);
299 bool found = interp.remove_atexit_fcn (arg);
302 retval =
ovl (found);
314 return ovl (interp.traditional ());
348 const std::string& context =
"",
349 bool verbose =
false,
350 bool require_file =
true)
356 source_file (file_name, context, verbose, require_file);
358 catch (
const interrupt_exception&)
378 args(3) = OCTAVE_RELEASE_DATE;
381 args(0) =
"GNU Octave";
388 error (
"Fortran procedure terminated by call to XERBLA");
401 F77_FUNC (xerbla, XERBLA) (
"octave", 13 F77_CHAR_ARG_LEN (6));
403 typedef void (*xerbla_handler_ptr) (void);
405 typedef void (*octave_set_xerbla_handler_ptr) (xerbla_handler_ptr);
412 =
reinterpret_cast<octave_set_xerbla_handler_ptr
>
413 (libs.search (
"octave_set_xerbla_handler"));
420 OCTAVE_NORETURN
static void
424 va_start (args, fmt);
431 OCTAVE_NORETURN
static void
435 va_start (args, fmt);
455 : m_app_context (app_context),
461 m_error_system (*this),
463 m_help_system (*this),
464 m_input_system (*this),
465 m_output_system (*this),
466 m_history_system (*this),
467 m_dynamic_loader (*this),
469 m_load_save_system (*this),
471 m_symbol_table (*this),
472 m_stream_list (*this),
474 m_url_handle_manager (),
475 m_cdef_manager (*this),
477 m_event_manager (*this),
478 m_gh_manager (nullptr),
479 m_interactive (false),
480 m_read_site_files (true),
481 m_read_init_files (m_app_context != nullptr),
483 m_traditional (false),
484 m_inhibit_startup_message (false),
485 m_load_path_initialized (false),
486 m_history_initialized (false),
487 m_interrupt_all_in_process_group (true),
488 m_cancel_quit (false),
489 m_executing_finish_script (false),
490 m_executing_atexit (false),
491 m_initialized (false)
499 throw std::runtime_error
500 (
"only one Octave interpreter may be active");
504 #if defined (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE)
506 std::setlocale (LC_ALL,
".UTF8");
508 std::setlocale (LC_ALL,
"");
511 std::setlocale (LC_NUMERIC,
"C");
512 std::setlocale (LC_TIME,
"C");
513 sys::env::putenv (
"LC_NUMERIC",
"C");
514 sys::env::putenv (
"LC_TIME",
"C");
538 bool line_editing =
false;
557 for (
const auto& pth : command_line_path)
560 std::string exec_path = options.
exec_path ();
561 if (! exec_path.empty ())
564 std::string image_path = options.
image_path ();
565 if (! image_path.empty ())
586 forced_interactive =
false;
590 if (forced_interactive)
596 line_editing =
false;
609 if (! docstrings_file.empty ())
610 Fbuilt_in_docstrings_file (*
this,
octave_value (docstrings_file));
613 if (! doc_cache_file.empty ())
616 std::string info_file = options.
info_file ();
617 if (! info_file.empty ())
621 if (! info_program.empty ())
625 if (! texi_macros_file.empty ())
626 Ftexi_macros_file (*
this,
octave_value (texi_macros_file));
687 if (! read_history_file)
750 if (! options.
gui ())
833 bool& incomplete_parse)
860 exit_status = status;
879 exit_status = status;
921 catch (
const exit_exception& xe)
923 exit_status = xe.exit_status ();
934 #define OCTAVE_IGNORE_EXCEPTION(E) \
937 recover_from_exception (); \
939 std::cerr << "error: ignoring " #E " while preparing to exit" \
943 #define OCTAVE_SAFE_CALL(F, ARGS) \
948 unwind_action restore_debug_on_error \
949 (&error_system::set_debug_on_error, &m_error_system, \
950 m_error_system.debug_on_error ()); \
952 unwind_action restore_debug_on_warning \
953 (&error_system::set_debug_on_warning, &m_error_system, \
954 m_error_system.debug_on_warning ()); \
956 m_error_system.debug_on_error (false); \
957 m_error_system.debug_on_warning (false); \
961 OCTAVE_IGNORE_EXCEPTION (const exit_exception&) \
962 OCTAVE_IGNORE_EXCEPTION (const interrupt_exception&) \
963 OCTAVE_IGNORE_EXCEPTION (const execution_exception&) \
964 OCTAVE_IGNORE_EXCEPTION (const std::bad_alloc&) \
1133 bool require_file =
false;
1135 std::string context;
1137 int exit_status = 0;
1147 context,
verbose, require_file);
1150 exit_status = status;
1153 context,
verbose, require_file);
1156 exit_status = status;
1163 std::string ff_startup_m =
file_in_path (
"startup.m",
"");
1165 if (! ff_startup_m.empty ())
1167 int parse_status = 0;
1171 eval_string (std::string (
"startup"),
false, parse_status, 0);
1173 catch (
const interrupt_exception&)
1187 std::string user_config_dir = sys::env::get_user_config_directory ();
1194 if (! cfg_rc.empty ())
1200 exit_status = status;
1207 bool home_rc_already_executed =
false;
1209 std::string initfile = sys::env::getenv (
"OCTAVE_INITFILE");
1211 if (initfile.empty ())
1212 initfile =
".octaverc";
1214 std::string home_dir = sys::env::get_home_directory ();
1218 std::string local_rc;
1220 if (! home_rc.empty ())
1226 exit_status = status;
1230 sys::file_stat fs_home_rc (home_rc);
1239 home_rc_already_executed =
same_file (home_rc, local_rc);
1243 if (! home_rc_already_executed)
1245 if (local_rc.empty ())
1252 exit_status = status;
1257 std::cout << std::endl;
1275 int parse_status = 0;
1279 eval_string (code_to_eval,
false, parse_status, 0);
1281 catch (
const interrupt_exception&)
1294 return parse_status;
1314 void (
application::*program_invocation_name_fptr) (
const std::string&)
1320 void (
application::*program_name_fptr) (
const std::string&)
1335 std::string fname = script_args[0];
1339 std::string context;
1341 bool require_file =
true;
1391 error (
"%s: symbol table scope missing", who.c_str ());
1408 error (
"%s: %s", dir.c_str (), std::strerror (errno));
1441 error (
"munlock: invalid value for NAME");
1462 error (
"mislocked: invalid value for NAME");
1469 bool retval =
false;
1490 bool silent,
int& parse_status,
1497 bool silent,
int& parse_status)
1503 bool silent,
int& parse_status,
1516 const std::string& catch_code,
1523 const std::string& try_code,
1530 const std::string& try_code,
1531 const std::string& catch_code,
1550 return feval (std::string (name), args, nargout);
1560 error (
"feval: function '%s' not found", name.c_str ());
1599 std::list<octave_value_list> arg_list;
1600 arg_list.push_back (args);
1609 return xval.
subsref (
"(", arg_list, nargout);
1616 error (
"feval: first argument must be a string, inline function, or a function handle");
1636 error (
"feval: first argument must be a string, inline function, or a function handle");
1642 return feval (f_arg, tmp_args, nargout);
1700 const std::string& name,
1707 const std::string& context,
bool verbose,
1843 static int sigint = 0;
1844 static bool first =
true;
1974 bool cancel =
false;
1981 evalin (
"base",
"finish", 0);
2007 throw exit_exception (exit_status);
2075 catch (
const interrupt_exception&)
cmdline_options options(void) const
void set_program_names(const std::string &pname)
void forced_interactive(bool arg)
static std::string program_invocation_name(void)
void intern_argv(const string_vector &args)
bool is_octave_program(void) const
bool have_script_file(void) const
bool have_eval_option_code(void) const
static std::string program_name(void)
std::string info_file(void) const
std::string docstrings_file(void) const
bool line_editing(void) const
std::string doc_cache_file(void) const
std::string texi_macros_file(void) const
string_vector remaining_args(void) const
bool verbose_flag(void) const
bool no_window_system(void) const
std::string exec_path(void) const
string_vector all_args(void) const
bool traditional(void) const
bool forced_interactive(void) const
std::string code_to_eval(void) const
bool read_site_files(void) const
bool experimental_terminal_widget(void) const
bool forced_line_editing(void) const
bool read_history_file(void) const
bool set_initial_path(void) const
std::list< std::string > command_line_path(void) const
std::string info_program(void) const
std::string image_path(void) const
bool inhibit_startup_message(void) const
bool echo_commands(void) const
bool read_init_files(void) const
static void blink_matching_paren(bool flag)
static void restore_terminal_state(void)
static void add_event_hook(event_hook_fcn f)
static bool ignoring_entries(void)
static void clean_up_and_save(const std::string &="", int=-1)
static void ignore_entries(bool=true)
Vector representing the dimensions (size) of an Array.
octave_value image_path(const octave_value_list &args, int nargout)
octave_value exec_path(const octave_value_list &args, int nargout)
OCTINTERP_API octave_value beep_on_error(const octave_value_list &args, int nargout)
OCTINTERP_API void display_exception(const execution_exception &ee, std::ostream &os) const
OCTINTERP_API void disable_warning(const std::string &id)
OCTINTERP_API void save_exception(const execution_exception &ee)
bool confirm_shutdown(void)
void clear_workspace(void)
OCTINTERP_API void process_events(bool disable=false)
void directory_changed(const std::string &dir)
void start_gui(bool gui_app=false)
void interpreter_interrupted(void)
void unload_all_toolkits(void)
octave_value timestamp_format_string(const octave_value_list &args, int nargout)
void initialize(bool read_history_file=false)
void write_timestamp(void)
bool m_interrupt_all_in_process_group
octave_value global_varval(const std::string &name) const
octave_value varval(const std::string &name) const
url_handle_manager m_url_handle_manager
void clear_variable(const std::string &name)
void display_startup_message(void) const
octave_value make_function_handle(const std::string &name)
void assignin(const std::string &context, const std::string &varname, const octave_value &val=octave_value())
stream_list m_stream_list
environment m_environment
symbol_scope get_top_scope(void) const
error_system m_error_system
void cleanup_tmp_files(void)
bool isglobal(const std::string &name) const
void quit(int exit_status, bool force=false, bool confirm=true)
void clear_debug_watch_expressions(void)
void global_assign(const std::string &name, const octave_value &val=octave_value())
int execute_eval_option_code(void)
void install_variable(const std::string &name, const octave_value &value, bool global)
std::list< std::string > top_level_variable_names(void)
url_handle_manager & get_url_handle_manager(void)
bool at_top_level(void) const
void add_debug_watch_expression(const std::string &expr)
void read_site_files(bool flag)
void add_atexit_fcn(const std::string &fname)
bool remove_atexit_fcn(const std::string &fname)
event_manager m_event_manager
octave_value find(const std::string &name)
void mlock(bool skip_first=false) const
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
void clear_variables(void)
void maximum_braindamage(void)
profiler & get_profiler(void)
std::set< std::string > debug_watch_expressions(void) const
display_info m_display_info
octave_value_list eval(const std::string &try_code, int nargout)
stream_list & get_stream_list(void)
tree_evaluator & get_evaluator(void)
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
void clear_symbol_regexp(const std::string &pat)
void handle_exception(const execution_exception &ee)
load_save_system m_load_save_system
void clear_symbol_pattern(const std::string &pat)
void clear_global_variable_regexp(const std::string &pattern)
bool experimental_terminal_widget(void) const
void clear_global_variable(const std::string &name)
int execute_startup_files(void)
history_system m_history_system
symbol_scope get_current_scope(void) const
int chdir(const std::string &dir)
gtk_manager m_gtk_manager
void clear_global_variable_pattern(const std::string &pattern)
void clear_global_variables(void)
void clear_function_regexp(const std::string &pat)
symbol_table m_symbol_table
octave_value top_level_varval(const std::string &name) const
static OCTAVE_THREAD_LOCAL interpreter * m_instance
void intern_nargin(octave_idx_type nargs)
bool m_executing_finish_script
void parse_and_execute(const std::string &input, bool &incomplete_parse)
bool is_variable(const std::string &name) const
void execute_atexit_fcns(void)
std::list< std::string > global_variable_names(void)
interpreter(application *app_context=nullptr)
void clear_variable_regexp(const std::string &pattern)
bool m_inhibit_startup_message
bool mislocked(bool skip_first=false) const
temporary_file_list m_tmp_files
void assign(const std::string &name, const octave_value &val=octave_value())
void initialize_history(bool read_history_file=false)
void clear_symbol(const std::string &name)
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
std::string mfilename(const std::string &opt="") const
void initialize_load_path(bool set_initial_path=true)
void execute_pkg_add(const std::string &dir)
bool m_load_path_initialized
void inhibit_startup_message(bool flag)
void clear_variable_pattern(const std::string &pattern)
void clear_function_pattern(const std::string &pat)
bool m_history_initialized
void read_init_files(bool flag)
bool is_local_variable(const std::string &name) const
void munlock(bool skip_first=false) const
std::list< std::string > variable_names(void)
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
input_system m_input_system
int execute_command_line_file(void)
application * m_app_context
bool interactive(void) const
symbol_scope require_current_scope(const std::string &who) const
void clear_function(const std::string &name)
gh_manager * m_gh_manager
void remove_debug_watch_expression(const std::string &expr)
tree_evaluator m_evaluator
void get_line_and_eval(void)
std::list< std::string > user_function_names(void)
void clear_all(bool force=false)
void mark_for_deletion(const std::string &file)
std::list< std::string > m_atexit_fcns
void recover_from_exception(void)
std::list< std::string > autoloaded_functions(void) const
void clear_functions(bool force=false)
void set_add_hook(const std::function< void(const std::string &)> &f)
std::function< void(const std::string &)> get_add_hook(void)
void initialize(bool set_initial_path=false)
void read_dir_config(const std::string &dir) const
void execute_pkg_add(const std::string &dir)
void set_command_line_path(const std::string &p)
OCTINTERP_API octave_value save_default_options(const octave_value_list &args, int nargout)
OCTINTERP_API octave_value crash_dumps_octave_core(const octave_value_list &args, int nargout)
bool islocked(void) const
virtual octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
void resize(const dim_vector &dv, bool fill=false)
octave_idx_type nfields(void) const
octave_idx_type numel(void) const
void assign(const std::string &k, const Cell &val)
octave_idx_type length(void) const
octave_idx_type length(void) const
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
bool is_function(void) const
OCTINTERP_API octave_function * function_value(bool silent=false) const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
bool is_string(void) const
bool is_defined(void) const
bool is_function_handle(void) const
std::string string_value(bool force=false) const
bool is_undefined(void) const
bool is_inline_function(void) const
octave_idx_type numel(void) const
void clear_mex_functions(void)
void clear_function(const std::string &name)
void clear_function_pattern(const std::string &pat)
void clear_functions(bool force=false)
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope())
std::list< std::string > user_function_names(void)
void clear_function_regexp(const std::string &pat)
void insert(const std::string &file)
std::set< std::string > m_files
~temporary_file_list(void)
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
void reset_debug_state(void)
bool is_global(const std::string &name) const
bool mislocked(bool skip_first=false) const
std::list< std::string > autoloaded_functions(void) const
void clear_all(bool force=false)
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
octave_value echo(const octave_value_list &args, int nargout)
profiler & get_profiler(void)
symbol_scope get_current_scope(void) const
symbol_scope get_top_scope(void) const
bool at_top_level(void) const
void clear_global_variable(const std::string &name)
void munlock(bool skip_first=false) const
octave_value find(const std::string &name)
bool is_local_variable(const std::string &name) const
void clear_symbol_pattern(const std::string &pattern)
void clear_symbol(const std::string &name)
void remove_debug_watch_expression(const std::string &expr)
std::list< std::string > top_level_variable_names(void) const
void dbquit(bool all=false)
void clear_global_variables(void)
void clear_variables(void)
void clear_variable(const std::string &name)
bool is_variable(const std::string &name) const
std::list< std::string > global_variable_names(void) const
bool in_debug_repl(void) const
void add_debug_watch_expression(const std::string &expr)
void clear_global_variable_pattern(const std::string &pattern)
void assign(const std::string &name, const octave_value &val=octave_value())
void assignin(const std::string &context, const std::string &name, const octave_value &val=octave_value())
octave_value top_level_varval(const std::string &name) const
void clear_debug_watch_expressions(void)
void clear_symbol_regexp(const std::string &pattern)
void eval(std::shared_ptr< tree_statement_list > &stmt_list, bool interactive)
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
octave_value global_varval(const std::string &name) const
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
void install_variable(const std::string &name, const octave_value &value, bool global)
std::list< std::string > variable_names(void) const
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val=octave_value())
void get_line_and_eval(void)
bool break_on_next_statement(void) const
void clear_global_variable_regexp(const std::string &pattern)
void parse_and_execute(const std::string &input, bool &incomplete_parse)
void global_assign(const std::string &name, const octave_value &val=octave_value())
std::set< std::string > debug_watch_expressions(void) const
octave_value make_fcn_handle(const std::string &nm)
void mlock(bool skip_first=false) const
octave_value varval(const symbol_record &sym) const
octave_value PS4(const octave_value_list &args, int nargout)
std::string mfilename(const std::string &opt="") const
void clear_variable_regexp(const std::string &pattern)
void clear_variable_pattern(const std::string &pattern)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string site_defaults_file(void)
std::string release(void)
std::string local_site_defaults_file(void)
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
OCTAVE_EXPORT octave_value_list Fconfirm_recursive_rmdir(const octave_value_list &args, int nargout)
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
void verror_with_cfn(const char *fmt, va_list args)
void error(const char *fmt,...)
std::string dir_sep_str(void)
std::string tilde_expand(const std::string &name)
void octave_set_default_fpucw(void)
interpreter & __get_interpreter__(void)
#define OCTAVE_SAFE_CALL(F, ARGS)
OCTAVE_EXPORT octave_value_list F__version_info__(const octave_value_list &args, int)
bool octave_interpreter_ready
static int safe_source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
sys::time Vlast_chdir_time
static void xerbla_abort(void)
static OCTAVE_NORETURN void lo_error_with_id_handler(const char *id, const char *fmt,...)
static void initialize_error_handlers(void)
static void initialize_version_info(void)
static OCTAVE_NORETURN void lo_error_handler(const char *fmt,...)
static void initialize_xerbla_error_handler(void)
void set_liboctave_error_handler(OCTAVE_NORETURN liboctave_error_handler f)
void set_liboctave_warning_handler(liboctave_warning_handler f)
void set_liboctave_error_with_id_handler(OCTAVE_NORETURN liboctave_error_with_id_handler f)
void set_liboctave_warning_with_id_handler(liboctave_warning_with_id_handler f)
void octave_ieee_init(void)
int chdir(const std::string &path_arg)
static void install_signal_handlers(void)
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
int release_unreferenced_dynamic_libraries(void)
T::size_type numel(const T &str)
static int input(yyscan_t yyscanner)
OCTAVE_EXPORT octave_value_list Fstruct_levels_to_print(const octave_value_list &args, int nargout)
OCTAVE_EXPORT octave_value_list Fprint_struct_array_contents(const octave_value_list &args, int nargout)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
OCTAVE_EXPORT octave_value_list Ffixed_point_format(const octave_value_list &args, int nargout)
OCTAVE_EXPORT octave_value_list Fprint_empty_dimensions(const octave_value_list &args, int nargout)
volatile sig_atomic_t octave_signal_caught
sig_atomic_t octave_interrupt_state
void(* octave_interrupt_hook)(void)
void(* octave_signal_hook)(void)
void respond_to_pending_signals(void)
interrupt_handler catch_interrupts(void)
void octave_save_signal_mask(void)
void octave_unblock_signal_by_name(const char *signame)
bool octave_get_sig_number(const char *signame, int *signum)
int octave_kill_wrapper(pid_t pid, int signum)
void octave_restore_signal_mask(void)
void sysdep_cleanup(void)
pid_t octave_getpid_wrapper(void)
int octave_unlink_wrapper(const char *nm)
int octave_isatty_wrapper(int fd)
static string_vector make_absolute(const string_vector &sv)
std::string file_in_path(const std::string &name, const std::string &suffix)
bool same_file(const std::string &f, const std::string &g)
static int symbol_exist(interpreter &interp, const std::string &name, const std::string &type="any")
std::string octave_startup_message(bool html)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
void octave_set_xerbla_handler(xerbla_handler_fptr fcn)