23 #if defined (HAVE_CONFIG_H)
94 if (nargin != 0 && nargin != 4)
101 else if (nargin == 4)
136 args(0) =
"GNU Octave";
141 OCTAVE_NORETURN
static void
145 va_start (args, fmt);
152 OCTAVE_NORETURN
static void
156 va_start (args, fmt);
240 error (
"quit: not supported in embedded mode");
244 if (
args.length () > 0)
245 exit_status =
args(0).nint_value ();
262 octave_atexit_functions.push_front (fname);
270 for (std::list<std::string>::iterator
p = octave_atexit_functions.begin ();
271 p != octave_atexit_functions.end ();
p++)
275 octave_atexit_functions.erase (
p);
326 if (nargin < 1 || nargin > 2)
331 bool add_mode = (nargin == 2)
332 ?
args(1).xbool_value (
"atexit: FLAG argument must be a logical value")
344 retval =
ovl (found);
358 bool verbose =
false,
bool require_file =
true,
369 std::cerr <<
"error: index exception in " << file_name <<
": "
372 catch (
const octave::exit_exception& ex)
378 catch (
const octave::interrupt_exception&)
382 catch (
const octave::execution_exception&)
386 std::cerr <<
"error: execution exception in " << file_name << std::endl;
403 std::cerr <<
"error: index exception in " << file_name <<
": "
406 catch (
const octave::exit_exception& ex)
412 catch (
const octave::interrupt_exception&)
416 catch (
const octave::execution_exception&)
420 std::cerr <<
"error: execution exception in " << file_name << std::endl;
425 initialize_load_path (
bool set_initial_path)
447 execute_startup_files (
bool read_site_files,
bool read_init_files,
448 bool verbose_flag,
bool inhibit_startup_message)
454 bool verbose = (verbose_flag && ! inhibit_startup_message);
456 bool require_file =
false;
477 bool home_rc_already_executed =
false;
481 if (initfile.empty ())
482 initfile =
".octaverc";
490 if (! home_rc.empty ())
492 safe_source_file (home_rc, context, verbose, require_file);
505 home_rc_already_executed =
same_file (home_rc, local_rc);
509 if (! home_rc_already_executed)
511 if (local_rc.empty ())
514 safe_source_file (local_rc, context, verbose, require_file);
524 : m_app_context (app_context), m_evaluator (new tree_evaluator (
this)),
525 m_embedded (embedded), m_interactive (
false),
526 m_quitting_gracefully (
false)
528 current_evaluator = m_evaluator;
530 cmdline_options
options = m_app_context->options ();
533 setlocale (LC_NUMERIC,
"C");
534 setlocale (LC_TIME,
"C");
552 if (options.traditional ())
572 quit_allowed =
false;
584 std::list<std::string> command_line_path = options.command_line_path ();
586 for (std::list<std::string>::const_iterator it = command_line_path.begin ();
587 it != command_line_path.end (); it++)
591 if (! exec_path.empty ())
595 if (! image_path.empty ())
598 if (options.no_window_system ())
607 m_interactive = (! m_embedded
608 && ! m_app_context->is_octave_program ()
613 if (options.forced_interactive ())
614 m_interactive =
true;
616 bool line_editing = options.line_editing ();
617 if ((! m_interactive || options.forced_interactive ())
618 && ! options.forced_line_editing ())
619 line_editing =
false;
631 octave_interpreter_ready =
true;
638 app_context->intern_argv (options.all_args ());
640 initialize_load_path (options.set_initial_path ());
645 interpreter::~interpreter (
void)
647 current_evaluator = 0;
652 int interpreter::execute (
void)
654 cmdline_options options = m_app_context->options ();
656 if (m_interactive && ! options.inhibit_startup_message ())
661 execute_startup_files (options.read_site_files (),
662 options.read_init_files (),
663 options.verbose_flag (),
664 options.inhibit_startup_message ());
666 if (m_interactive && ! options.inhibit_startup_message ()
668 std::cout << std::endl;
671 std::string code_to_eval = options.code_to_eval ();
673 if (! code_to_eval.empty ())
675 int parse_status = 0;
679 parse_status = execute_eval_option_code (code_to_eval);
681 catch (
const octave::execution_exception&)
688 if (! options.persist ())
690 m_quitting_gracefully =
true;
699 if (m_app_context->have_script_file ())
710 m_app_context->intern_argv (script_args);
712 execute_command_line_file (script_args[0]);
714 catch (
const octave::execution_exception&)
722 m_app_context->intern_argv (options.all_args ());
724 if (! options.persist ())
726 m_quitting_gracefully =
true;
739 if (options.forced_interactive ())
756 int retval = main_loop ();
758 m_quitting_gracefully =
true;
779 octave_initialized =
true;
781 frame.
add_method (
this, &interpreter::interactive, m_interactive);
783 m_interactive =
false;
785 int parse_status = 0;
791 catch (
const octave::exit_exception& ex)
797 catch (
const octave::interrupt_exception&)
801 catch (
const octave::execution_exception&)
811 void interpreter::execute_command_line_file (
const std::string& fname)
825 octave_initialized =
true;
827 frame.
add_method (
this, &interpreter::interactive, m_interactive);
830 &application::program_invocation_name,
831 application::program_invocation_name ());
834 &application::program_name,
835 application::program_name ());
837 m_interactive =
false;
839 m_app_context->set_program_names (fname);
842 bool verbose =
false;
843 bool require_file =
true;
845 safe_source_file (fname, context, verbose, require_file,
"octave");
848 int interpreter::main_loop (
void)
860 octave_initialized =
true;
888 parser.stmt_list->accept (*current_evaluator);
892 if (! octave::application::interactive ())
912 else if (
parser.lexer.end_of_input)
916 catch (
const octave::exit_exception& ex)
922 catch (
const octave::interrupt_exception&)
927 if (octave::application::interactive ())
934 std::cerr <<
"error: unhandled index exception: "
935 << e.
message () <<
" -- trying to return to prompt"
938 catch (
const octave::execution_exception& e)
942 if (! stack_trace.empty ())
943 std::cerr << stack_trace;
945 if (octave::application::interactive ())
954 catch (
const std::bad_alloc&)
958 std::cerr <<
"error: out of memory -- trying to return to prompt"
962 #if defined (DBSTOP_NANINF)
963 if (Vdebug_on_naninf)
965 if (setjump (naninf_jump) != 0)
966 debug_or_throw_exception (
true);
972 if (octave::application::interactive ())
983 static bool deja_vu =
false;
987 while (! octave_atexit_functions.empty ())
991 octave_atexit_functions.pop_front ();
1040 if (! m_quitting_gracefully && octave::application::interactive ())
1088 (*octave_exit) (status);
static void close_all_figures(void)
void warning_with_id(const char *id, const char *fmt,...)
volatile sig_atomic_t octave_signal_caught
static void unload_all_toolkits(void)
void set_exec_path(const std::string &path_arg)
OCTINTERP_API void octave_sleep(double seconds)
std::string Vsite_defaults_file
Octave interface to the compression and uncompression libraries.
static void initialize_version_info(void)
void install_classdef(void)
subroutine xerbla(SRNAME, INFO)
bool same_file(const std::string &f, const std::string &g)
static void putenv(const std::string &name, const std::string &value)
void(* octave_interrupt_hook)(void)=0
static bool at_top_level(void)
static hook_fcn_ptr get_add_hook(void)
std::string octave_startup_message(bool html)
void octave_set_default_fpucw(void)
void assign(const std::string &k, const Cell &val)
void raw_mode(bool on, bool wait)
void octave_prepare_hdf5(void)
OCTINTERP_API void initialize_default_warning_state(void)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API octave_value_list Fdisable_diagonal_matrix(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API void print_usage(void)
OCTINTERP_API octave_value_list FPS1(const octave_value_list &=octave_value_list(), int=0)
interrupt_handler catch_interrupts(void)
OCTINTERP_API octave_value_list Fconfirm_recursive_rmdir(const octave_value_list &=octave_value_list(), int=0)
void octave_restore_signal_mask(void)
static void process_events(bool disable=false)
static OCTAVE_NORETURN void lo_error_handler(const char *fmt,...)
#define DEFUN(name, args_name, nargout_name, doc)
OCTINTERP_API octave_value_list FPS4(const octave_value_list &=octave_value_list(), int=0)
void error(const char *fmt,...)
static void reset_debug_state(void)
void(* octave_bad_alloc_hook)(void)=0
static std::list< std::string > octave_atexit_functions
static void set_command_line_path(const std::string &p)
static void restore_terminal_state(void)
void set_image_path(const std::string &path)
OCTINTERP_API octave_value_list Fpage_screen_output(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type numel(void) const
void sysdep_cleanup(void)
static OCTAVE_API void clear(void)
void add_method(T *obj, void(T::*method)(void))
static void clean_up_and_save(const std::string &="", int=-1)
OCTINTERP_API octave_value_list Fbeep_on_error(const octave_value_list &=octave_value_list(), int=0)
static void increment_current_command_number(void)
static void reset_current_command_number(int n)
static std::string getenv(const std::string &name)
void octave_ieee_init(void)
OCTINTERP_API octave_value_list Fdisable_range(const octave_value_list &=octave_value_list(), int=0)
virtual std::string message(void) const
void initialize_history(bool read_history_file)
void cleanup_tmp_files(void)
void set_liboctave_warning_with_id_handler(liboctave_warning_with_id_handler f)
This class gets nodes and searchs inside of 'info files'.
OCTAVE_EXPORT octave_value_list search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
#define OCTAVE_RELEASE_DATE
OCTINTERP_API octave_value_list Fdisable_permutation_matrix(const octave_value_list &=octave_value_list(), int=0)
tree_evaluator * current_evaluator
#define DEFALIAS(alias, name)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
void set_liboctave_error_with_id_handler(OCTAVE_NORETURN liboctave_error_with_id_handler f)
void verror_with_cfn(const char *fmt, va_list args)
OCTINTERP_API octave_value_list Fhistory_timestamp_format_string(const octave_value_list &=octave_value_list(), int=0)
static bool exit(int status)
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
static void initialize_error_handlers()
OCTINTERP_API void disable_warning(const std::string &id)
int octave_isatty_wrapper(int fd)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
void octave_throw_execution_exception(void)
void add_fcn(void(*fcn)(void))
OCTINTERP_API octave_value_list Fcrash_dumps_octave_core(const octave_value_list &=octave_value_list(), int=0)
static std::string get_home_directory(void)
octave_idx_type nfields(void) const
static llvm::LLVMContext & context
void octave_history_write_timestamp(void)
OCTINTERP_API octave_value_list Fecho_executing_commands(const octave_value_list &=octave_value_list(), int=0)
#define OCTAVE_SAFE_CALL(F, ARGS)
static void execute_pkg_add(const std::string &dir)
OCTINTERP_API bool octave_remove_atexit_function(const std::string &fname)
OCTAVE_API void clean_up_and_exit(int exit_status, bool safe_to_return)
sig_atomic_t octave_exception_state
void install_builtins(void)
void signal_handler(void)
static void cleanup(void)
static void initialize(bool set_initial_path=false)
OCTINTERP_API octave_value_list Fsave_default_options(const octave_value_list &=octave_value_list(), int=0)
void set_liboctave_warning_handler(liboctave_warning_handler f)
F77_RET_T F77_FUNC(xstopx, XSTOPX) const
void octave_save_signal_mask(void)
std::string Vlocal_site_defaults_file
void reset_error_handler(void)
sig_atomic_t octave_interrupt_state
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
OCTINTERP_API octave_value_list Fprint_empty_dimensions(const octave_value_list &=octave_value_list(), int=0)
static void force_default_editor(void)
sig_atomic_t octave_interrupt_immediately
static std::string concat(const std::string &, const std::string &)
bool octave_interpreter_ready
OCTAVE_EXPORT octave_value_list F__version_info__(const octave_value_list &args, int)
void warning(const char *fmt,...)
void set_liboctave_error_handler(OCTAVE_NORETURN liboctave_error_handler f)
octave::unwind_protect frame
void recover_from_exception(void)
void(* octave_signal_hook)(void)=0
static void maximum_braindamage(void)
static bool confirm_shutdown(void)
static OCTAVE_NORETURN void lo_error_with_id_handler(const char *id, const char *fmt,...)
static void no_window_system(void)
void octave_finalize_hdf5(void)
static void blink_matching_paren(bool flag)
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
static bool ignoring_entries(void)
void resize(const dim_vector &dv, bool fill=false)
OCTINTERP_API octave_value_list Ffixed_point_format(const octave_value_list &=octave_value_list(), int=0)
void initialize_file_io(void)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
interpreter(application *app_context=0, bool embedded=false)
void clear_mex_functions(void)
OCTINTERP_API octave_value_list FPS2(const octave_value_list &=octave_value_list(), int=0)
Vector representing the dimensions (size) of an Array.
OCTINTERP_API void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true, const std::string &warn_for="")
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
bool reading_startup_message_printed
void install_signal_handlers(void)
static void set_add_hook(hook_fcn_ptr f)
OCTINTERP_API octave_value_list Fstruct_levels_to_print(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API void octave_add_atexit_function(const std::string &fname)