GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
interpreter.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cstdio>
31 #include <clocale>
32 
33 #include <iostream>
34 #include <set>
35 #include <string>
36 #include <thread>
37 
38 #include "cmd-edit.h"
39 #include "cmd-hist.h"
40 #include "file-ops.h"
41 #include "file-stat.h"
42 #include "file-ops.h"
43 #include "fpucw-wrappers.h"
44 #include "lo-blas-proto.h"
45 #include "lo-error.h"
46 #include "oct-env.h"
47 #include "quit.h"
48 #include "str-vec.h"
49 #include "signal-wrappers.h"
50 #include "unistd-wrappers.h"
51 
52 #include "builtin-defun-decls.h"
53 #include "defaults.h"
54 #include "Cell.h"
55 #include "defun.h"
56 #include "display.h"
57 #include "error.h"
58 #include "event-manager.h"
59 #include "graphics.h"
60 #include "help.h"
61 #include "input.h"
62 #include "interpreter-private.h"
63 #include "interpreter.h"
64 #include "load-path.h"
65 #include "load-save.h"
66 #include "octave.h"
67 #include "oct-hist.h"
68 #include "oct-map.h"
69 #include "oct-mutex.h"
70 #include "ovl.h"
71 #include "ov.h"
72 #include "ov-classdef.h"
73 #include "parse.h"
74 #include "pt-classdef.h"
75 #include "pt-eval.h"
76 #include "pt-jump.h"
77 #include "pt-stmt.h"
78 #include "settings.h"
79 #include "sighandlers.h"
80 #include "sysdep.h"
81 #include "unwind-prot.h"
82 #include "utils.h"
83 #include "variables.h"
84 #include "version.h"
85 
86 // TRUE means the quit() call is allowed.
87 bool quit_allowed = true;
88 
89 // TRUE means we are ready to interpret commands, but not everything
90 // is ready for interactive use.
92 
93 // TRUE means we've processed all the init code and we are good to go.
94 bool octave_initialized = false;
95 
97 
98 DEFUN (__version_info__, args, ,
99  doc: /* -*- texinfo -*-
100 @deftypefn {} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})
101 Undocumented internal function.
102 @end deftypefn */)
103 {
104  static octave_map vinfo;
105 
106  int nargin = args.length ();
107 
108  if (nargin != 0 && nargin != 4)
109  print_usage ();
110 
111  octave_value retval;
112 
113  if (nargin == 0)
114  retval = vinfo;
115  else if (nargin == 4)
116  {
117  if (vinfo.nfields () == 0)
118  {
119  vinfo.assign ("Name", args(0));
120  vinfo.assign ("Version", args(1));
121  vinfo.assign ("Release", args(2));
122  vinfo.assign ("Date", args(3));
123  }
124  else
125  {
126  octave_idx_type n = vinfo.numel () + 1;
127 
128  vinfo.resize (dim_vector (n, 1));
129 
130  octave_value idx (n);
131 
132  vinfo.assign (idx, "Name", Cell (octave_value (args(0))));
133  vinfo.assign (idx, "Version", Cell (octave_value (args(1))));
134  vinfo.assign (idx, "Release", Cell (octave_value (args(2))));
135  vinfo.assign (idx, "Date", Cell (octave_value (args(3))));
136  }
137  }
138 
139  return retval;
140 }
141 
142 DEFMETHOD (quit, interp, args, ,
143  doc: /* -*- texinfo -*-
144 @deftypefn {} {} quit
145 @deftypefnx {} {} quit cancel
146 @deftypefnx {} {} quit force
147 @deftypefnx {} {} quit ("cancel")
148 @deftypefnx {} {} quit ("force")
149 @deftypefnx {} {} quit (@var{status})
150 @deftypefnx {} {} quit (@var{status}, "force")
151 Quit the current Octave session.
152 
153 The @code{exit} function is an alias for @code{quit}.
154 
155 If the optional integer value @var{status} is supplied, pass that value to
156 the operating system as Octave's exit status. The default value is zero.
157 
158 When exiting, Octave will attempt to run the m-file @file{finish.m} if it
159 exists. User commands to save the workspace or clean up temporary files
160 may be placed in that file. Alternatively, another m-file may be scheduled
161 to run using @code{atexit}. If an error occurs while executing the
162 @file{finish.m} file, Octave does not exit and control is returned to
163 the command prompt.
164 
165 If the optional argument @qcode{"cancel"} is provided, Octave does not
166 exit and control is returned to the command prompt. This feature allows
167 the @code{finish.m} file to cancel the quit process.
168 
169 If the user preference to request confirmation before exiting, Octave
170 will display a dialog and give the user an option to cancel the exit
171 process.
172 
173 If the optional argument @qcode{"force"} is provided, no confirmation is
174 requested, and the execution of the @file{finish.m} file is skipped.
175 @seealso{atexit}
176 @end deftypefn */)
177 {
178  int numel = args.length ();
179 
180  if (numel > 2)
181  print_usage ();
182 
183  int exit_status = 0;
184 
185  bool force = false;
186  bool cancel = false;
187 
188  if (numel == 2)
189  {
190  exit_status = args(0).xnint_value ("quit: STATUS must be an integer");
191  std::string frc
192  = args(1).xstring_value ("quit: second argument must be a string");
193 
194  if (frc == "force")
195  force = true;
196  else
197  error (R"(quit: second argument must be string "force")");
198  }
199  else if (numel == 1)
200  {
201  if (args(0).is_string ())
202  {
203  const char *msg
204  = R"(quit: option must be string "cancel" or "force")";
205 
206  std::string opt = args(0).xstring_value (msg);
207 
208  if (opt == "cancel")
209  cancel = true;
210  else if (opt == "force")
211  force = true;
212  else
213  error ("%s", msg);
214  }
215  else
216  exit_status = args(0).xnint_value ("quit: STATUS must be an integer");
217  }
218 
219  if (cancel)
220  {
221  // No effect if "quit cancel" appears outside of finish script.
222 
223  if (interp.executing_finish_script ())
224  interp.cancel_quit (true);
225 
226  return ovl ();
227  }
228 
229  interp.quit (exit_status, force);
230 
231  return ovl ();
232 }
233 
234 DEFALIAS (exit, quit);
235 
236 DEFMETHOD (atexit, interp, args, nargout,
237  doc: /* -*- texinfo -*-
238 @deftypefn {} {} atexit (@var{fcn})
239 @deftypefnx {} {} atexit (@var{fcn}, true)
240 @deftypefnx {} {} atexit (@var{fcn}, false)
241 @deftypefnx {} {@var{status} =} atexit (@var{fcn}, false)
242 Register a function to be called when Octave exits.
243 
244 For example,
245 
246 @example
247 @group
248 function last_words ()
249  disp ("Bye bye");
250 endfunction
251 atexit ("last_words");
252 @end group
253 @end example
254 
255 @noindent
256 will print the message @qcode{"Bye bye"} when Octave exits.
257 
258 The additional argument @var{flag} will register or unregister @var{fcn}
259 from the list of functions to be called when Octave exits. If @var{flag} is
260 true, the function is registered, and if @var{flag} is false, it is
261 unregistered. For example, after registering the function @code{last_words}
262 above,
263 
264 @example
265 atexit ("last_words", false);
266 @end example
267 
268 @noindent
269 will remove the function from the list and Octave will not call
270 @code{last_words} when it exits.
271 
272 The optional output @var{status} is only available when unregistering a
273 function. The value is true if the unregistering was successful and false
274 otherwise.
275 
276 Programming Note: @code{atexit} only removes the first occurrence of a function
277 from the list; if a function was placed in the list multiple times with
278 @code{atexit}, it must also be removed from the list multiple times.
279 @seealso{quit}
280 @end deftypefn */)
281 {
282  int nargin = args.length ();
283 
284  if (nargin < 1 || nargin > 2)
285  print_usage ();
286 
287  std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
288 
289  bool add_mode = (nargin == 2)
290  ? args(1).xbool_value ("atexit: FLAG argument must be a logical value")
291  : true;
292 
293  octave_value_list retval;
294 
295  if (add_mode)
296  interp.add_atexit_fcn (arg);
297  else
298  {
299  bool found = interp.remove_atexit_fcn (arg);
300 
301  if (nargout > 0)
302  retval = ovl (found);
303  }
304 
305  return retval;
306 }
307 
308 DEFMETHOD (__traditional__, interp, , ,
309  doc: /* -*- texinfo -*-
310 @deftypefn {} {@var{tf} =} __traditional__ ()
311 Return true if Octave was invoked with the @w{@env{--traditional}} option.
312 @end deftypefn */)
313 {
314  return ovl (interp.traditional ());
315 }
316 
318 {
319  cleanup ();
320 }
321 
322 void temporary_file_list::insert (const std::string& file)
323 {
324  m_files.insert (file);
325 }
326 
328 {
329  while (! m_files.empty ())
330  {
331  auto it = m_files.begin ();
332 
333  octave_unlink_wrapper (it->c_str ());
334 
335  m_files.erase (it);
336  }
337 }
338 
339 // The time we last time we changed directories.
340 sys::time Vlast_chdir_time = 0.0;
341 
342 // Execute commands from a file and catch potential exceptions in a consistent
343 // way. This function should be called anywhere we might parse and execute
344 // commands from a file before we have entered the main loop in
345 // toplev.cc.
346 
347 static int safe_source_file (const std::string& file_name,
348  const std::string& context = "",
349  bool verbose = false,
350  bool require_file = true)
351 {
352  interpreter& interp = __get_interpreter__ ();
353 
354  try
355  {
356  source_file (file_name, context, verbose, require_file);
357  }
358  catch (const interrupt_exception&)
359  {
360  interp.recover_from_exception ();
361 
362  return 1;
363  }
364  catch (const execution_exception& ee)
365  {
366  interp.handle_exception (ee);
367 
368  return 1;
369  }
370 
371  return 0;
372 }
373 
374 static void initialize_version_info (void)
375 {
376  octave_value_list args;
377 
378  args(3) = OCTAVE_RELEASE_DATE;
379  args(2) = config::release ();
380  args(1) = OCTAVE_VERSION;
381  args(0) = "GNU Octave";
382 
383  F__version_info__ (args, 0);
384 }
385 
386 static void xerbla_abort (void)
387 {
388  error ("Fortran procedure terminated by call to XERBLA");
389 }
390 
392 {
393  // The idea here is to force xerbla to be referenced so that we will
394  // link to our own version instead of the one provided by the BLAS
395  // library. But numeric_limits<double>::NaN () should never be -1, so
396  // we should never actually call xerbla. FIXME (again!): If this
397  // becomes a constant expression the test might be optimized away and
398  // then the reference to the function might also disappear.
399 
400  if (numeric_limits<double>::NaN () == -1)
401  F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6));
402 
403  typedef void (*xerbla_handler_ptr) (void);
404 
405  typedef void (*octave_set_xerbla_handler_ptr) (xerbla_handler_ptr);
406 
407  dynamic_library libs ("");
408 
409  if (libs)
410  {
411  octave_set_xerbla_handler_ptr octave_set_xerbla_handler
412  = reinterpret_cast<octave_set_xerbla_handler_ptr>
413  (libs.search ("octave_set_xerbla_handler"));
414 
417  }
418 }
419 
420 OCTAVE_NORETURN static void
421 lo_error_handler (const char *fmt, ...)
422 {
423  va_list args;
424  va_start (args, fmt);
425  verror_with_cfn (fmt, args);
426  va_end (args);
427 
428  throw execution_exception ();
429 }
430 
431 OCTAVE_NORETURN static void
432 lo_error_with_id_handler (const char *id, const char *fmt, ...)
433 {
434  va_list args;
435  va_start (args, fmt);
436  verror_with_id_cfn (id, fmt, args);
437  va_end (args);
438 
439  throw execution_exception ();
440 }
441 
442 static void initialize_error_handlers (void)
443 {
448 }
449 
450 // Create an interpreter object and perform initialization up to the
451 // point of setting reading command history and setting the load
452 // path.
453 
455  : m_app_context (app_context),
456  m_tmp_files (),
457  m_atexit_fcns (),
458  m_display_info (),
459  m_environment (),
460  m_settings (),
461  m_error_system (*this),
462  m_evaluator (*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),
468  m_load_path (*this),
469  m_load_save_system (*this),
470  m_type_info (),
471  m_symbol_table (*this),
472  m_stream_list (*this),
473  m_child_list (),
474  m_url_handle_manager (),
475  m_cdef_manager (*this),
476  m_gtk_manager (),
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),
482  m_verbose (false),
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)
492 {
493  // FIXME: When thread_local storage is used by default, this message
494  // should change to say something like
495  //
496  // only one Octave interpreter may be active in any given thread
497 
498  if (m_instance)
499  throw std::runtime_error
500  ("only one Octave interpreter may be active");
501 
502  m_instance = this;
503 
504 #if defined (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE)
505  // Force a UTF-8 locale on Windows if possible
506  std::setlocale (LC_ALL, ".UTF8");
507 #else
508  std::setlocale (LC_ALL, "");
509 #endif
510  // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting
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");
515 
516  // Initialize the default floating point unit control state.
518 
519  thread::init ();
520 
521  octave_ieee_init ();
522 
524 
526 
527  if (m_app_context)
528  {
530  octave_unblock_signal_by_name ("SIGTSTP");
531  }
532  else
533  quit_allowed = false;
534 
535  if (! m_app_context)
537 
538  bool line_editing = false;
539 
540  if (m_app_context)
541  {
542  // Embedded interpreters don't execute command line options.
543  const cmdline_options& options = m_app_context->options ();
544 
545  // Make all command-line arguments available to startup files,
546  // including PKG_ADD files.
547 
548  string_vector args = options.all_args ();
549 
550  m_app_context->intern_argv (args);
551  intern_nargin (args.numel () - 1);
552 
553  bool is_octave_program = m_app_context->is_octave_program ();
554 
555  std::list<std::string> command_line_path = options.command_line_path ();
556 
557  for (const auto& pth : command_line_path)
559 
560  std::string exec_path = options.exec_path ();
561  if (! exec_path.empty ())
562  m_environment.exec_path (exec_path);
563 
564  std::string image_path = options.image_path ();
565  if (! image_path.empty ())
566  m_environment.image_path (image_path);
567 
568  if (! options.no_window_system ())
570 
571  // Is input coming from a terminal? If so, we are probably
572  // interactive.
573 
574  // If stdin is not a tty, then we are reading commands from a
575  // pipe or a redirected file.
576  bool stdin_is_tty = octave_isatty_wrapper (fileno (stdin));
577 
578  m_interactive = (! is_octave_program && stdin_is_tty
579  && octave_isatty_wrapper (fileno (stdout)));
580 
581  // Don't force interactive if we're already interactive (bug #60696).
582  bool forced_interactive = options.forced_interactive ();
583  if (m_interactive)
584  {
586  forced_interactive = false;
587  }
588 
589  // Check if the user forced an interactive session.
590  if (forced_interactive)
591  m_interactive = true;
592 
593  line_editing = options.line_editing ();
594  if ((! m_interactive || forced_interactive)
595  && ! options.forced_line_editing ())
596  line_editing = false;
597 
598  m_traditional = options.traditional ();
599 
600  // FIXME: if possible, perform the following actions directly
601  // instead of using the interpreter-level functions.
602 
603  if (options.echo_commands ())
607 
608  std::string docstrings_file = options.docstrings_file ();
609  if (! docstrings_file.empty ())
610  Fbuilt_in_docstrings_file (*this, octave_value (docstrings_file));
611 
612  std::string doc_cache_file = options.doc_cache_file ();
613  if (! doc_cache_file.empty ())
614  Fdoc_cache_file (*this, octave_value (doc_cache_file));
615 
616  std::string info_file = options.info_file ();
617  if (! info_file.empty ())
618  Finfo_file (*this, octave_value (info_file));
619 
620  std::string info_program = options.info_program ();
621  if (! info_program.empty ())
622  Finfo_program (*this, octave_value (info_program));
623 
624  std::string texi_macros_file = options.texi_macros_file ();
625  if (! texi_macros_file.empty ())
626  Ftexi_macros_file (*this, octave_value (texi_macros_file));
627  }
628 
629  // FIXME: we defer creation of the gh_manager object because it
630  // creates a root_figure object that requires the display_info
631  // object, but that is currently only accessible through the global
632  // interpreter object and that is not available until after the
633  // interpreter::instance pointer is set (above). It would be better
634  // if m_gh_manager could be an object value instead of a pointer and
635  // created as part of the interpreter initialization. To do that,
636  // we should either make the display_info object independent of the
637  // interpreter object (does it really need to cache any
638  // information?) or defer creation of the root_figure object until
639  // it is actually needed.
640  m_gh_manager = new gh_manager (*this);
641 
642  m_input_system.initialize (line_editing);
643 
644  // These can come after command line args since none of them set any
645  // defaults that might be changed by command line options.
646 
648 
649  // This should be done before initializing the load path because
650  // some PKG_ADD files might need --traditional behavior.
651 
652  if (m_traditional)
654 
656 }
657 
658 OCTAVE_THREAD_LOCAL interpreter *interpreter::m_instance = nullptr;
659 
661 {
662  if (! m_app_context)
663  shutdown ();
664 
665  delete m_gh_manager;
666 }
667 
669 {
671 }
672 
673 // Read the history file unless a command-line option inhibits that.
674 
675 void interpreter::initialize_history (bool read_history_file)
676 {
677  if (! m_history_initialized)
678  {
679  // Allow command-line option to override.
680 
681  if (m_app_context)
682  {
683  const cmdline_options& options = m_app_context->options ();
684 
685  read_history_file = options.read_history_file ();
686 
687  if (! read_history_file)
689  }
690 
691  m_history_system.initialize (read_history_file);
692 
693  if (! m_app_context)
695 
696  m_history_initialized = true;
697  }
698 }
699 
700 // Set the initial path to the system default unless command-line
701 // option says to leave it empty.
702 
703 void interpreter::initialize_load_path (bool set_initial_path)
704 {
706  {
707  // Allow command-line option to override.
708 
709  if (m_app_context)
710  {
711  const cmdline_options& options = m_app_context->options ();
712 
713  set_initial_path = options.set_initial_path ();
714  }
715 
716  // Temporarily set the execute_pkg_add function to one that
717  // catches exceptions. This is better than wrapping
718  // load_path::initialize in a try-catch block because it will
719  // not stop executing PKG_ADD files at the first exception.
720  // It's also better than changing the default execute_pkg_add
721  // function to use safe_source file because that will normally
722  // be evaluated from the normal interpreter loop where exceptions
723  // are already handled.
724 
727 
728  m_load_path.set_add_hook ([=] (const std::string& dir)
729  { this->execute_pkg_add (dir); });
730 
731  m_load_path.initialize (set_initial_path);
732 
734  }
735 }
736 
737 // This may be called separately from execute
738 
740 {
741  if (m_initialized)
742  return;
743 
744  if (m_app_context)
745  {
746  const cmdline_options& options = m_app_context->options ();
747 
748  if (options.experimental_terminal_widget ())
749  {
750  if (! options.gui ())
752  }
753  else
755  }
756  else
758 
759  // Wait to read the history file until the interpreter reads input
760  // files and begins evaluating commands.
761 
763 
764  // Initializing the load path may execute PKG_ADD files, so can't be
765  // done until the interpreter is ready to execute commands.
766 
767  // Deferring it to the execute step also allows the path to be
768  // initialized between creating and execute the interpreter, for
769  // example, to set a custom path for an embedded interpreter.
770 
772 
774 
775  can_interrupt = true;
776 
778  octave_interrupt_hook = nullptr;
779 
780  catch_interrupts ();
781 
782  // FIXME: could we eliminate this variable or make it not be global?
783  // Global used to communicate with signal handler.
784  octave_initialized = true;
785 
786  m_initialized = true;
787 }
788 
789 // Note: this function is currently only used with the new
790 // experimental terminal widget.
791 
793 {
795 }
796 
797 // Note: the following class is currently only used with the new
798 // experimental terminal widget.
799 
801 {
802 public:
803 
805  : m_interpreter (interp), m_thread () { }
806 
808 
810 
812  {
813  // FIXME: Would it be better to ensure that
814  // interpreter::get_line_and_eval exits and then call
815  // m_thread.join () here?
816 
817  m_thread.detach ();
818  }
819 
820  void start (void)
821  {
823  }
824 
825 private:
826 
828 
829  std::thread m_thread;
830 };
831 
832 void interpreter::parse_and_execute (const std::string& input,
833  bool& incomplete_parse)
834 {
835  m_evaluator.parse_and_execute (input, incomplete_parse);
836 }
837 
838 // FIXME: this function is intended to be executed only once. Should
839 // we enforce that restriction?
840 
842 {
843  int exit_status = 0;
844 
845  try
846  {
847  initialize ();
848 
850 
851  if (m_app_context)
852  {
853  const cmdline_options& options = m_app_context->options ();
854 
856  {
857  int status = execute_eval_option_code ();
858 
859  if (status )
860  exit_status = status;
861 
862  if (! options.persist ())
863  {
864  shutdown ();
865 
866  return exit_status;
867  }
868  }
869 
870  // If there is an extra argument, see if it names a file to
871  // read. Additional arguments are taken as command line options
872  // for the script.
873 
875  {
876  int status = execute_command_line_file ();
877 
878  if (status)
879  exit_status = status;
880 
881  if (! options.persist ())
882  {
883  shutdown ();
884 
885  return exit_status;
886  }
887  }
888 
889  if (options.forced_interactive ())
891 
892  if (options.server ())
893  exit_status = server_loop ();
894  else if (options.experimental_terminal_widget ())
895  {
896  if (options.gui ())
897  {
898  m_event_manager.start_gui (true);
899 
900  exit_status = server_loop ();
901  }
902  else
903  {
904  // Use an object so that the thread started for the
905  // reader will be cleaned up no matter how we exit
906  // this function.
907 
908  cli_input_reader reader (*this);
909 
910  reader.start ();
911 
912  exit_status = server_loop ();
913  }
914  }
915  else
916  exit_status = main_loop ();
917 
918  shutdown ();
919  }
920  }
921  catch (const exit_exception& xe)
922  {
923  exit_status = xe.exit_status ();
924 
925  shutdown ();
926  }
927 
928  return exit_status;
929 }
930 
931 // Call a function with exceptions handled to avoid problems with
932 // errors while shutting down.
933 
934 #define OCTAVE_IGNORE_EXCEPTION(E) \
935  catch (E) \
936  { \
937  recover_from_exception (); \
938  \
939  std::cerr << "error: ignoring " #E " while preparing to exit" \
940  << std::endl; \
941  }
942 
943 #define OCTAVE_SAFE_CALL(F, ARGS) \
944  do \
945  { \
946  try \
947  { \
948  unwind_action restore_debug_on_error \
949  (&error_system::set_debug_on_error, &m_error_system, \
950  m_error_system.debug_on_error ()); \
951  \
952  unwind_action restore_debug_on_warning \
953  (&error_system::set_debug_on_warning, &m_error_system, \
954  m_error_system.debug_on_warning ()); \
955  \
956  m_error_system.debug_on_error (false); \
957  m_error_system.debug_on_warning (false); \
958  \
959  F ARGS; \
960  } \
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&) \
965  } \
966  while (0)
967 
969 {
970  // Attempt to prevent more than one call to shutdown.
971 
972  if (! m_initialized)
973  return;
974 
975  m_initialized = false;
976 
977  OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0));
978 
979  // Any atexit functions added after this function call won't be
980  // executed. Each atexit function is executed with
981  // OCTAVE_SAFE_CALL, so we don't need that here.
982 
984 
985  // Clear all functions and variables while the event manager is
986  // still processing events and notify the event manager. This way,
987  // the workspace model will be cleared before the GUI exits.
988 
989  // FIXME: This approach seems a bit fragile since there could be
990  // other places in the GUI that have references to interpreter
991  // objects. How can we reliably ensure that they are all removed
992  // before the interpreter exits? Maybe the best solution is to
993  // always start the GUI from the interpreter and close it when the
994  // interpreter exits? However, the workspace model is owned by the
995  // base_qobject object not the workspace viewer or the main window,
996  // so simply closing the GUI window(s) is not sufficient. See also
997  // bug #61994.
998 
999  // Note that we don't force symbols to be cleared, so we will
1000  // respect mlock at this point. Later, we'll force all variables
1001  // and functions to be cleared.
1002 
1005 
1006  // If we are attached to a GUI, queue and event to close it (only
1007  // works with the new terminal widget), process pending events and
1008  // disable the link.
1009 
1013 
1015 
1016  // We may still have some figures. Close them.
1017 
1018  OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0));
1019 
1020  // What is supposed to happen if a figure has a closerequestfcn or
1021  // deletefcn callback registered that creates other figures or
1022  // variables? What if those variables are classdef objects with
1023  // destructors that can create figures? The possibilities are
1024  // endless. At some point, we have to give up and force execution
1025  // to end.
1026 
1027  // Note that we again don't force symbols to be cleared, so we
1028  // continue to respect mlock here. Later, we'll force all variables
1029  // and functions to be cleared.
1030 
1032 
1033  // Do this explicitly so that destructors for mex file objects
1034  // are called, so that functions registered with mexAtExit are
1035  // called.
1036 
1038 
1040 
1042 
1045 
1047 
1048  // Now that the graphics toolkits have been unloaded, force all
1049  // symbols to be cleared.
1050 
1051  OCTAVE_SAFE_CALL (clear_all, (true));
1052 
1053  // FIXME: May still need something like this to ensure that
1054  // destructors for class objects will run properly. Should that be
1055  // done earlier? Before or after atexit functions are executed?
1056  // What will happen if the destructor for an obect attempts to
1057  // display a figure?
1058 
1060 
1062 
1064 
1065  // Don't call singleton_cleanup_list::cleanup until we have the
1066  // problems with registering/unregistering types worked out. For
1067  // example, uncomment the following line, then use the make_int
1068  // function from the examples directory to create an integer
1069  // object and then exit Octave. Octave should crash with a
1070  // segfault when cleaning up the typinfo singleton. We need some
1071  // way to force new octave_value_X types that are created in
1072  // .oct files to be unregistered when the .oct file shared library
1073  // is unloaded.
1074  //
1075  // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ());
1076 }
1077 
1079 {
1080  // Prevent atexit functions from adding new functions to the list.
1081  m_executing_atexit = true;
1082 
1083  while (! m_atexit_fcns.empty ())
1084  {
1085  std::string fcn = m_atexit_fcns.front ();
1086 
1087  m_atexit_fcns.pop_front ();
1088 
1089  OCTAVE_SAFE_CALL (feval, (fcn, octave_value_list (), 0));
1090 
1092  }
1093 }
1094 
1096 {
1097  bool inhibit_startup_message = false;
1098 
1099  if (m_app_context)
1100  {
1101  const cmdline_options& options = m_app_context->options ();
1102 
1104  }
1105 
1107  std::cout << octave_startup_message () << "\n" << std::endl;
1108 }
1109 
1110 // Initialize by reading startup files. Return non-zero if an exception
1111 // occurs when reading any of them, but don't exit early because of an
1112 // exception.
1113 
1115 {
1118  bool verbose = m_verbose;
1120 
1121  if (m_app_context)
1122  {
1123  const cmdline_options& options = m_app_context->options ();
1124 
1125  read_site_files = options.read_site_files ();
1126  read_init_files = options.read_init_files ();
1127  verbose = options.verbose_flag ();
1129  }
1130 
1132 
1133  bool require_file = false;
1134 
1135  std::string context;
1136 
1137  int exit_status = 0;
1138 
1139  if (read_site_files)
1140  {
1141  // Execute commands from the site-wide configuration file.
1142  // First from the file $(prefix)/lib/octave/site/m/octaverc
1143  // (if it exists), then from the file
1144  // $(prefix)/share/octave/$(version)/m/octaverc (if it exists).
1145 
1147  context, verbose, require_file);
1148 
1149  if (status)
1150  exit_status = status;
1151 
1153  context, verbose, require_file);
1154 
1155  if (status)
1156  exit_status = status;
1157  }
1158 
1159  if (read_init_files)
1160  {
1161  // Try to execute commands from the Matlab compatible startup.m file
1162  // if it exists anywhere in the load path when starting Octave.
1163  std::string ff_startup_m = file_in_path ("startup.m", "");
1164 
1165  if (! ff_startup_m.empty ())
1166  {
1167  int parse_status = 0;
1168 
1169  try
1170  {
1171  eval_string (std::string ("startup"), false, parse_status, 0);
1172  }
1173  catch (const interrupt_exception&)
1174  {
1176  }
1177  catch (const execution_exception& ee)
1178  {
1179  handle_exception (ee);
1180  }
1181  }
1182 
1183  // Try to execute commands from $CONFIG/octave/octaverc, where
1184  // $CONFIG is the platform-dependent location for user local
1185  // configuration files.
1186 
1187  std::string user_config_dir = sys::env::get_user_config_directory ();
1188 
1189  std::string cfg_dir = user_config_dir + sys::file_ops::dir_sep_str ()
1190  + "octave";
1191 
1192  std::string cfg_rc = sys::env::make_absolute ("octaverc", cfg_dir);
1193 
1194  if (! cfg_rc.empty ())
1195  {
1196  int status = safe_source_file (cfg_rc, context, verbose,
1197  require_file);
1198 
1199  if (status)
1200  exit_status = status;
1201  }
1202 
1203  // Try to execute commands from $HOME/$OCTAVE_INITFILE and
1204  // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set,
1205  // .octaverc is assumed.
1206 
1207  bool home_rc_already_executed = false;
1208 
1209  std::string initfile = sys::env::getenv ("OCTAVE_INITFILE");
1210 
1211  if (initfile.empty ())
1212  initfile = ".octaverc";
1213 
1214  std::string home_dir = sys::env::get_home_directory ();
1215 
1216  std::string home_rc = sys::env::make_absolute (initfile, home_dir);
1217 
1218  std::string local_rc;
1219 
1220  if (! home_rc.empty ())
1221  {
1222  int status = safe_source_file (home_rc, context, verbose,
1223  require_file);
1224 
1225  if (status)
1226  exit_status = status;
1227 
1228  // Names alone are not enough.
1229 
1230  sys::file_stat fs_home_rc (home_rc);
1231 
1232  if (fs_home_rc)
1233  {
1234  // We want to check for curr_dir after executing home_rc
1235  // because doing that may change the working directory.
1236 
1237  local_rc = sys::env::make_absolute (initfile);
1238 
1239  home_rc_already_executed = same_file (home_rc, local_rc);
1240  }
1241  }
1242 
1243  if (! home_rc_already_executed)
1244  {
1245  if (local_rc.empty ())
1246  local_rc = sys::env::make_absolute (initfile);
1247 
1248  int status = safe_source_file (local_rc, context, verbose,
1249  require_file);
1250 
1251  if (status)
1252  exit_status = status;
1253  }
1254  }
1255 
1256  if (m_interactive && verbose)
1257  std::cout << std::endl;
1258 
1259  return exit_status;
1260 }
1261 
1262 // Execute any code specified with --eval 'CODE'
1263 
1265 {
1266  if (! m_app_context)
1267  return 0;
1268 
1269  const cmdline_options& options = m_app_context->options ();
1270 
1271  std::string code_to_eval = options.code_to_eval ();
1272 
1274 
1275  int parse_status = 0;
1276 
1277  try
1278  {
1279  eval_string (code_to_eval, false, parse_status, 0);
1280  }
1281  catch (const interrupt_exception&)
1282  {
1284 
1285  return 1;
1286  }
1287  catch (const execution_exception& ee)
1288  {
1289  handle_exception (ee);
1290 
1291  return 1;
1292  }
1293 
1294  return parse_status;
1295 }
1296 
1298 {
1299  if (! m_app_context)
1300  return 0;
1301 
1302  const cmdline_options& options = m_app_context->options ();
1303 
1304  string_vector args = options.all_args ();
1305 
1306  void (interpreter::*interactive_fptr) (bool) = &interpreter::interactive;
1307  unwind_action restore_interactive (interactive_fptr, this, m_interactive);
1308 
1309  unwind_action restore_argv (&application::intern_argv, m_app_context, args);
1310 
1311  unwind_action restore_nargin (&interpreter::intern_nargin, this,
1312  args.numel () - 1);
1313 
1314  void (application::*program_invocation_name_fptr) (const std::string&)
1316  unwind_action restore_program_invocation_name
1317  (program_invocation_name_fptr, m_app_context,
1319 
1320  void (application::*program_name_fptr) (const std::string&)
1322  unwind_action restore_program_name
1323  (program_name_fptr, m_app_context, application::program_name ());
1324 
1325  m_interactive = false;
1326 
1327  // If we are running an executable script (#! /bin/octave) then
1328  // we should only see the args passed to the script.
1329 
1330  string_vector script_args = options.remaining_args ();
1331 
1332  m_app_context->intern_argv (script_args);
1333  intern_nargin (script_args.numel () - 1);
1334 
1335  std::string fname = script_args[0];
1336 
1338 
1339  std::string context;
1340  bool verbose = false;
1341  bool require_file = true;
1342 
1343  return safe_source_file (fname, context, verbose, require_file);
1344 }
1345 
1347 {
1349 
1350  return m_evaluator.repl ();
1351 }
1352 
1354 {
1355  return m_evaluator.server_loop ();
1356 }
1357 
1359 {
1360  return m_evaluator;
1361 }
1362 
1364 {
1365  return m_stream_list;
1366 }
1367 
1369 {
1370  return m_url_handle_manager;
1371 }
1372 
1375 {
1376  return m_evaluator.get_top_scope ();
1377 }
1378 
1381 {
1382  return m_evaluator.get_current_scope ();
1383 }
1384 
1386 interpreter::require_current_scope (const std::string& who) const
1387 {
1388  symbol_scope scope = get_current_scope ();
1389 
1390  if (! scope)
1391  error ("%s: symbol table scope missing", who.c_str ());
1392 
1393  return scope;
1394 }
1395 
1397 {
1398  return m_evaluator.get_profiler ();
1399 }
1400 
1401 int interpreter::chdir (const std::string& dir)
1402 {
1403  std::string xdir = sys::file_ops::tilde_expand (dir);
1404 
1405  int cd_ok = sys::env::chdir (xdir);
1406 
1407  if (! cd_ok)
1408  error ("%s: %s", dir.c_str (), std::strerror (errno));
1409 
1410  Vlast_chdir_time.stamp ();
1411 
1412  // FIXME: should these actions be handled as a list of functions
1413  // to call so users can add their own chdir handlers?
1414 
1416  m_load_path.update ();
1417 
1418  m_event_manager.directory_changed (sys::env::get_current_directory ());
1419 
1420  return cd_ok;
1421 }
1422 
1423 void interpreter::mlock (bool skip_first) const
1424 {
1425  m_evaluator.mlock (skip_first);
1426 }
1427 
1428 void interpreter::munlock (bool skip_first) const
1429 {
1430  m_evaluator.munlock (skip_first);
1431 }
1432 
1433 bool interpreter::mislocked (bool skip_first) const
1434 {
1435  return m_evaluator.mislocked (skip_first);
1436 }
1437 
1438 void interpreter::munlock (const char *nm)
1439 {
1440  if (! nm)
1441  error ("munlock: invalid value for NAME");
1442 
1443  munlock (std::string (nm));
1444 }
1445 
1446 void interpreter::munlock (const std::string& nm)
1447 {
1449 
1450  if (val.is_defined ())
1451  {
1452  octave_function *fcn = val.function_value ();
1453 
1454  if (fcn)
1455  fcn->unlock ();
1456  }
1457 }
1458 
1459 bool interpreter::mislocked (const char *nm)
1460 {
1461  if (! nm)
1462  error ("mislocked: invalid value for NAME");
1463 
1464  return mislocked (std::string (nm));
1465 }
1466 
1467 bool interpreter::mislocked (const std::string& nm)
1468 {
1469  bool retval = false;
1470 
1472 
1473  if (val.is_defined ())
1474  {
1475  octave_function *fcn = val.function_value ();
1476 
1477  if (fcn)
1478  retval = fcn->islocked ();
1479  }
1480 
1481  return retval;
1482 }
1483 
1484 std::string interpreter::mfilename (const std::string& opt) const
1485 {
1486  return m_evaluator.mfilename (opt);
1487 }
1488 
1489 octave_value_list interpreter::eval_string (const std::string& eval_str,
1490  bool silent, int& parse_status,
1491  int nargout)
1492 {
1493  return m_evaluator.eval_string (eval_str, silent, parse_status, nargout);
1494 }
1495 
1496 octave_value interpreter::eval_string (const std::string& eval_str,
1497  bool silent, int& parse_status)
1498 {
1499  return m_evaluator.eval_string (eval_str, silent, parse_status);
1500 }
1501 
1503  bool silent, int& parse_status,
1504  int nargout)
1505 {
1506  return m_evaluator.eval_string (arg, silent, parse_status, nargout);
1507 }
1508 
1509 octave_value_list interpreter::eval (const std::string& try_code,
1510  int nargout)
1511 {
1512  return m_evaluator.eval (try_code, nargout);
1513 }
1514 
1515 octave_value_list interpreter::eval (const std::string& try_code,
1516  const std::string& catch_code,
1517  int nargout)
1518 {
1519  return m_evaluator.eval (try_code, catch_code, nargout);
1520 }
1521 
1522 octave_value_list interpreter::evalin (const std::string& context,
1523  const std::string& try_code,
1524  int nargout)
1525 {
1526  return m_evaluator.evalin (context, try_code, nargout);
1527 }
1528 
1529 octave_value_list interpreter::evalin (const std::string& context,
1530  const std::string& try_code,
1531  const std::string& catch_code,
1532  int nargout)
1533 {
1534  return m_evaluator.evalin (context, try_code, catch_code, nargout);
1535 }
1536 
1537 //! Evaluate an Octave function (built-in or interpreted) and return
1538 //! the list of result values.
1539 //!
1540 //! @param name The name of the function to call.
1541 //! @param args The arguments to the function.
1542 //! @param nargout The number of output arguments expected.
1543 //! @return A list of output values. The length of the list is not
1544 //! necessarily the same as @c nargout.
1545 
1547  const octave_value_list& args,
1548  int nargout)
1549 {
1550  return feval (std::string (name), args, nargout);
1551 }
1552 
1553 octave_value_list interpreter::feval (const std::string& name,
1554  const octave_value_list& args,
1555  int nargout)
1556 {
1557  octave_value fcn = m_symbol_table.find_function (name, args);
1558 
1559  if (fcn.is_undefined ())
1560  error ("feval: function '%s' not found", name.c_str ());
1561 
1562  octave_function *of = fcn.function_value ();
1563 
1564  return of->call (m_evaluator, nargout, args);
1565 }
1566 
1568  const octave_value_list& args,
1569  int nargout)
1570 {
1571  if (fcn)
1572  return fcn->call (m_evaluator, nargout, args);
1573 
1574  return octave_value_list ();
1575 }
1576 
1578  const octave_value_list& args,
1579  int nargout)
1580 {
1581  // FIXME: do we really want to silently return an empty ovl if
1582  // the function object is undefined? It's essentially what the
1583  // version above that accepts a pointer to an octave_function
1584  // object does and some code was apparently written to rely on it
1585  // (for example, __ode15__).
1586 
1587  if (val.is_undefined ())
1588  return ovl ();
1589 
1590  if (val.is_function ())
1591  {
1592  return feval (val.function_value (), args, nargout);
1593  }
1594  else if (val.is_function_handle () || val.is_inline_function ())
1595  {
1596  // This covers function handles, inline functions, and anonymous
1597  // functions.
1598 
1599  std::list<octave_value_list> arg_list;
1600  arg_list.push_back (args);
1601 
1602  // FIXME: could we make octave_value::subsref a const method?
1603  // It would be difficult because there are instances of
1604  // incrementing the reference count inside subsref methods,
1605  // which means they can't be const with the current way of
1606  // handling reference counting.
1607 
1608  octave_value xval = val;
1609  return xval.subsref ("(", arg_list, nargout);
1610  }
1611  else if (val.is_string ())
1612  {
1613  return feval (val.string_value (), args, nargout);
1614  }
1615  else
1616  error ("feval: first argument must be a string, inline function, or a function handle");
1617 
1618  return ovl ();
1619 }
1620 
1621 //! Evaluate an Octave function (built-in or interpreted) and return
1622 //! the list of result values.
1623 //!
1624 //! @param args The first element of @c args is the function to call.
1625 //! It may be the name of the function as a string, a function
1626 //! handle, or an inline function. The remaining arguments are
1627 //! passed to the function.
1628 //! @param nargout The number of output arguments expected.
1629 //! @return A list of output values. The length of the list is not
1630 //! necessarily the same as @c nargout.
1631 
1633  int nargout)
1634 {
1635  if (args.length () == 0)
1636  error ("feval: first argument must be a string, inline function, or a function handle");
1637 
1638  octave_value f_arg = args(0);
1639 
1640  octave_value_list tmp_args = args.slice (1, args.length () - 1, true);
1641 
1642  return feval (f_arg, tmp_args, nargout);
1643 }
1644 
1646 {
1647  return m_evaluator.make_fcn_handle (name);
1648 }
1649 
1650 void interpreter::install_variable (const std::string& name,
1651  const octave_value& value, bool global)
1652 {
1653  m_evaluator.install_variable (name, value, global);
1654 }
1655 
1656 octave_value interpreter::global_varval (const std::string& name) const
1657 {
1658  return m_evaluator.global_varval (name);
1659 }
1660 
1661 void interpreter::global_assign (const std::string& name,
1662  const octave_value& val)
1663 {
1664  m_evaluator.global_assign (name, val);
1665 }
1666 
1667 octave_value interpreter::top_level_varval (const std::string& name) const
1668 {
1669  return m_evaluator.top_level_varval (name);
1670 }
1671 
1672 void interpreter::top_level_assign (const std::string& name,
1673  const octave_value& val)
1674 {
1675  m_evaluator.top_level_assign (name, val);
1676 }
1677 
1678 bool interpreter::is_variable (const std::string& name) const
1679 {
1680  return m_evaluator.is_variable (name);
1681 }
1682 
1683 bool interpreter::is_local_variable (const std::string& name) const
1684 {
1685  return m_evaluator.is_local_variable (name);
1686 }
1687 
1688 octave_value interpreter::varval (const std::string& name) const
1689 {
1690  return m_evaluator.varval (name);
1691 }
1692 
1693 void interpreter::assign (const std::string& name,
1694  const octave_value& val)
1695 {
1696  m_evaluator.assign (name, val);
1697 }
1698 
1699 void interpreter::assignin (const std::string& context,
1700  const std::string& name,
1701  const octave_value& val)
1702 {
1703  m_evaluator.assignin (context, name, val);
1704 }
1705 
1706 void interpreter::source_file (const std::string& file_name,
1707  const std::string& context, bool verbose,
1708  bool require_file)
1709 {
1710  m_evaluator.source_file (file_name, context, verbose, require_file);
1711 }
1712 
1713 bool interpreter::at_top_level (void) const
1714 {
1715  return m_evaluator.at_top_level ();
1716 }
1717 
1718 bool interpreter::isglobal (const std::string& name) const
1719 {
1720  return m_evaluator.is_global (name);
1721 }
1722 
1723 octave_value interpreter::find (const std::string& name)
1724 {
1725  return m_evaluator.find (name);
1726 }
1727 
1728 void interpreter::clear_all (bool force)
1729 {
1730  m_evaluator.clear_all (force);
1731 }
1732 
1734 {
1736 }
1737 
1738 void interpreter::clear_variable (const std::string& name)
1739 {
1740  m_evaluator.clear_variable (name);
1741 }
1742 
1743 void interpreter::clear_variable_pattern (const std::string& pattern)
1744 {
1746 }
1747 
1748 void interpreter::clear_variable_regexp (const std::string& pattern)
1749 {
1751 }
1752 
1754 {
1756 }
1757 
1758 void interpreter::clear_global_variable (const std::string& name)
1759 {
1761 }
1762 
1763 void interpreter::clear_global_variable_pattern (const std::string& pattern)
1764 {
1766 }
1767 
1768 void interpreter::clear_global_variable_regexp (const std::string& pattern)
1769 {
1771 }
1772 
1774 {
1776 }
1777 
1779 {
1781 }
1782 
1783 void interpreter::clear_function (const std::string& name)
1784 {
1786 }
1787 
1788 void interpreter::clear_symbol (const std::string& name)
1789 {
1790  m_evaluator.clear_symbol (name);
1791 }
1792 
1793 void interpreter::clear_function_pattern (const std::string& pat)
1794 {
1796 }
1797 
1798 void interpreter::clear_function_regexp (const std::string& pat)
1799 {
1801 }
1802 
1803 void interpreter::clear_symbol_pattern (const std::string& pat)
1804 {
1805  return m_evaluator.clear_symbol_pattern (pat);
1806 }
1807 
1808 void interpreter::clear_symbol_regexp (const std::string& pat)
1809 {
1810  return m_evaluator.clear_symbol_regexp (pat);
1811 }
1812 
1813 std::list<std::string> interpreter::global_variable_names (void)
1814 {
1816 }
1817 
1818 std::list<std::string> interpreter::top_level_variable_names (void)
1819 {
1821 }
1822 
1823 std::list<std::string> interpreter::variable_names (void)
1824 {
1825  return m_evaluator.variable_names ();
1826 }
1827 
1828 std::list<std::string> interpreter::user_function_names (void)
1829 {
1831 }
1832 
1833 std::list<std::string> interpreter::autoloaded_functions (void) const
1834 {
1836 }
1837 
1838 // May be used to send an interrupt signal to the the interpreter from
1839 // another thread (for example, the GUI).
1840 
1842 {
1843  static int sigint = 0;
1844  static bool first = true;
1845 
1846  if (first)
1847  {
1848  octave_get_sig_number ("SIGINT", &sigint);
1849  first = false;
1850  }
1851 
1852  // Send SIGINT to Octave and (optionally) all other processes in its
1853  // process group. The signal handler for SIGINT will set a global
1854  // variable indicating an interrupt has happened. That variable is
1855  // checked in many places in the Octave interpreter and eventually
1856  // results in an interrupt_exception being thrown. Finally, that
1857  // exception is caught and returns control to one of the
1858  // read-eval-print loops or to the server loop. We use a signal
1859  // instead of just setting the global variables here so that we will
1860  // probably send interrupt signals to any subprocesses as well as
1861  // interrupt execution of the interpreter.
1862 
1863  pid_t pid
1865 
1866  octave_kill_wrapper (pid, sigint);
1867 }
1868 
1870 {
1871  // FIXME: To be reliable, these tree_evaluator functions must be
1872  // made thread safe.
1873 
1876 }
1877 
1879 {
1880  // FIXME: To be reliable, these tree_evaluator functions must be
1881  // made thread safe.
1882 
1883  if (m_evaluator.in_debug_repl ())
1884  m_evaluator.dbquit (true);
1885  else
1886  interrupt ();
1887 }
1888 
1890 {
1891  // FIXME: To be reliable, these tree_evaluator functions must be
1892  // made thread safe.
1893 
1894  // FIXME: Should there be any feeback about not doing anything if
1895  // not in debug mode?
1896 
1897  if (m_evaluator.in_debug_repl ())
1898  m_evaluator.dbcont ();
1899 }
1900 
1901 // Provided for convenience. Will be removed once we eliminate the
1902 // old terminal widget.
1904 {
1905  if (! m_app_context)
1906  return false;
1907 
1908  // Embedded interpreters don't execute command line options.
1909  const cmdline_options& options = m_app_context->options ();
1910 
1911  return options.experimental_terminal_widget ();
1912 }
1913 
1914 void interpreter::add_debug_watch_expression (const std::string& expr)
1915 {
1917 }
1918 
1919 void interpreter::remove_debug_watch_expression (const std::string& expr)
1920 {
1922 }
1923 
1925 {
1927 }
1928 
1929 std::set<std::string> interpreter::debug_watch_expressions (void) const
1930 {
1932 }
1933 
1935 {
1937 
1938  // FIXME: use a separate stream instead of std::cerr directly so that
1939  // error messages can be redirected more easily? Pass the message
1940  // to an event manager function?
1942 
1944 }
1945 
1947 {
1950 
1951  can_interrupt = true;
1955  catch_interrupts ();
1956 }
1957 
1958 void interpreter::mark_for_deletion (const std::string& file)
1959 {
1960  m_tmp_files.insert (file);
1961 }
1962 
1964 {
1965  m_tmp_files.cleanup ();
1966 }
1967 
1968 void interpreter::quit (int exit_status, bool force, bool confirm)
1969 {
1970  if (! force)
1971  {
1972  try
1973  {
1974  bool cancel = false;
1975 
1976  if (symbol_exist ("finish.m", "file"))
1977  {
1980 
1981  evalin ("base", "finish", 0);
1982 
1983  cancel = m_cancel_quit;
1984  }
1985 
1986  if (cancel)
1987  return;
1988 
1989  // Check for confirmation.
1990 
1991  if (confirm && ! m_event_manager.confirm_shutdown ())
1992  return;
1993  }
1994  catch (const execution_exception&)
1995  {
1996  // Catch execution_exceptions so we don't throw an
1997  // exit_exception if there is an in finish.m. But throw it
1998  // again so that will be handled as any other
1999  // execution_exception by the evaluator. This way, errors
2000  // will be ignored properly and we won't exit if quit is
2001  // called recursively from finish.m.
2002 
2003  throw;
2004  }
2005  }
2006 
2007  throw exit_exception (exit_status);
2008 }
2009 
2010 void interpreter::add_atexit_fcn (const std::string& fname)
2011 {
2012  if (m_executing_atexit)
2013  return;
2014 
2015  m_atexit_fcns.push_front (fname);
2016 }
2017 
2018 bool interpreter::remove_atexit_fcn (const std::string& fname)
2019 {
2020  bool found = false;
2021 
2022  for (auto it = m_atexit_fcns.begin ();
2023  it != m_atexit_fcns.end (); it++)
2024  {
2025  if (*it == fname)
2026  {
2027  m_atexit_fcns.erase (it);
2028  found = true;
2029  break;
2030  }
2031  }
2032 
2033  return found;
2034 }
2035 
2036 // What internal options get configured by --traditional.
2037 
2039 {
2040  m_input_system.PS1 (">> ");
2041  m_input_system.PS2 ("");
2042 
2043  m_evaluator.PS4 ("");
2044 
2046  m_load_save_system.save_default_options ("-mat-binary");
2047 
2048  m_history_system.timestamp_format_string ("%%-- %D %I:%M %p --%%");
2049 
2051 
2053  Foptimize_diagonal_matrix (octave_value (false));
2054  Foptimize_permutation_matrix (octave_value (false));
2055  Foptimize_range (octave_value (false));
2060 
2061  m_error_system.disable_warning ("Octave:abbreviated-property-match");
2062  m_error_system.disable_warning ("Octave:colon-nonscalar-argument");
2063  m_error_system.disable_warning ("Octave:data-file-in-path");
2064  m_error_system.disable_warning ("Octave:empty-index");
2065  m_error_system.disable_warning ("Octave:function-name-clash");
2066  m_error_system.disable_warning ("Octave:possible-matlab-short-circuit-operator");
2067 }
2068 
2069 void interpreter::execute_pkg_add (const std::string& dir)
2070 {
2071  try
2072  {
2074  }
2075  catch (const interrupt_exception&)
2076  {
2078  }
2079  catch (const execution_exception& ee)
2080  {
2081  handle_exception (ee);
2082  }
2083 }
2084 
OCTAVE_END_NAMESPACE(octave)
#define NaN
Definition: Faddeeva.cc:261
Definition: Cell.h:43
cmdline_options options(void) const
Definition: octave.h:267
void set_program_names(const std::string &pname)
Definition: octave.cc:301
void forced_interactive(bool arg)
Definition: octave.h:295
static std::string program_invocation_name(void)
Definition: octave.h:303
void intern_argv(const string_vector &args)
Definition: octave.cc:311
bool is_octave_program(void) const
Definition: octave.h:273
bool have_script_file(void) const
Definition: octave.h:271
bool have_eval_option_code(void) const
Definition: octave.h:269
static std::string program_name(void)
Definition: octave.h:308
interpreter & m_interpreter
Definition: interpreter.cc:827
cli_input_reader & operator=(const cli_input_reader &)=delete
std::thread m_thread
Definition: interpreter.cc:829
cli_input_reader(const cli_input_reader &)=delete
cli_input_reader(interpreter &interp)
Definition: interpreter.cc:804
void start(void)
Definition: interpreter.cc:820
std::string info_file(void) const
Definition: octave.h:85
std::string docstrings_file(void) const
Definition: octave.h:81
bool server(void) const
Definition: octave.h:74
bool line_editing(void) const
Definition: octave.h:67
std::string doc_cache_file(void) const
Definition: octave.h:82
std::string texi_macros_file(void) const
Definition: octave.h:87
string_vector remaining_args(void) const
Definition: octave.h:89
bool persist(void) const
Definition: octave.h:70
bool verbose_flag(void) const
Definition: octave.h:77
bool no_window_system(void) const
Definition: octave.h:69
std::string exec_path(void) const
Definition: octave.h:83
string_vector all_args(void) const
Definition: octave.h:88
bool gui(void) const
Definition: octave.h:64
bool traditional(void) const
Definition: octave.h:76
bool forced_interactive(void) const
Definition: octave.h:62
std::string code_to_eval(void) const
Definition: octave.h:78
bool read_site_files(void) const
Definition: octave.h:73
bool experimental_terminal_widget(void) const
Definition: octave.h:60
bool forced_line_editing(void) const
Definition: octave.h:63
bool read_history_file(void) const
Definition: octave.h:71
bool set_initial_path(void) const
Definition: octave.h:75
std::list< std::string > command_line_path(void) const
Definition: octave.h:79
std::string info_program(void) const
Definition: octave.h:86
std::string image_path(void) const
Definition: octave.h:84
bool inhibit_startup_message(void) const
Definition: octave.h:65
bool echo_commands(void) const
Definition: octave.h:58
bool read_init_files(void) const
Definition: octave.h:72
static void blink_matching_paren(bool flag)
Definition: cmd-edit.cc:1311
static void restore_terminal_state(void)
Definition: cmd-edit.cc:1304
static void add_event_hook(event_hook_fcn f)
Definition: cmd-edit.cc:1561
static bool ignoring_entries(void)
Definition: cmd-hist.cc:612
static void clean_up_and_save(const std::string &="", int=-1)
Definition: cmd-hist.cc:770
static void ignore_entries(bool=true)
Definition: cmd-hist.cc:605
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
void initialize(void)
Definition: display.cc:42
octave_value image_path(const octave_value_list &args, int nargout)
Definition: environment.cc:101
octave_value exec_path(const octave_value_list &args, int nargout)
Definition: environment.cc:81
OCTINTERP_API octave_value beep_on_error(const octave_value_list &args, int nargout)
Definition: error.cc:307
OCTINTERP_API void display_exception(const execution_exception &ee, std::ostream &os) const
Definition: error.cc:905
OCTINTERP_API void disable_warning(const std::string &id)
Definition: error.cc:827
OCTINTERP_API void save_exception(const execution_exception &ee)
Definition: error.cc:893
bool confirm_shutdown(void)
void clear_workspace(void)
OCTINTERP_API void process_events(bool disable=false)
void close_gui(void)
void directory_changed(const std::string &dir)
void start_gui(bool gui_app=false)
void interpreter_interrupted(void)
bool disable(void)
void unload_all_toolkits(void)
Definition: gtk-manager.h:99
octave_value timestamp_format_string(const octave_value_list &args, int nargout)
Definition: oct-hist.cc:305
void initialize(bool read_history_file=false)
Definition: oct-hist.cc:268
void write_timestamp(void)
Definition: oct-hist.cc:279
void initialize(bool line_editing)
Definition: input.cc:412
void clear_input_event_hooks(void)
octave_value PS2(const octave_value_list &args, int nargout)
octave_value PS1(const octave_value_list &args, int nargout)
void resume(void)
bool m_interrupt_all_in_process_group
Definition: interpreter.h:640
octave_value global_varval(const std::string &name) const
octave_value varval(const std::string &name) const
url_handle_manager m_url_handle_manager
Definition: interpreter.h:613
void clear_variable(const std::string &name)
void display_startup_message(void) const
octave_value make_function_handle(const std::string &name)
load_path m_load_path
Definition: interpreter.h:601
void assignin(const std::string &context, const std::string &varname, const octave_value &val=octave_value())
stream_list m_stream_list
Definition: interpreter.h:609
environment m_environment
Definition: interpreter.h:583
symbol_scope get_top_scope(void) const
error_system m_error_system
Definition: interpreter.h:587
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 interrupt(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 verbose(bool flag)
Definition: interpreter.h:191
void add_debug_watch_expression(const std::string &expr)
void read_site_files(bool flag)
Definition: interpreter.h:181
void add_atexit_fcn(const std::string &fname)
bool remove_atexit_fcn(const std::string &fname)
event_manager m_event_manager
Definition: interpreter.h:619
bool m_read_site_files
Definition: interpreter.h:626
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
Definition: interpreter.h:581
void shutdown(void)
Definition: interpreter.cc:968
bool m_verbose
Definition: interpreter.h:630
octave_value_list eval(const std::string &try_code, int nargout)
stream_list & get_stream_list(void)
tree_evaluator & get_evaluator(void)
void pause(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)
bool m_read_init_files
Definition: interpreter.h:628
load_save_system m_load_save_system
Definition: interpreter.h:603
void clear_symbol_pattern(const std::string &pat)
~interpreter(void)
Definition: interpreter.cc:660
void clear_global_variable_regexp(const std::string &pattern)
int main_loop(void)
bool experimental_terminal_widget(void) const
void clear_global_variable(const std::string &name)
bool m_initialized
Definition: interpreter.h:648
int execute_startup_files(void)
bool m_traditional
Definition: interpreter.h:632
history_system m_history_system
Definition: interpreter.h:597
symbol_scope get_current_scope(void) const
int chdir(const std::string &dir)
gtk_manager m_gtk_manager
Definition: interpreter.h:617
void clear_global_variable_pattern(const std::string &pattern)
void clear_global_variables(void)
void clear_function_regexp(const std::string &pat)
void stop(void)
symbol_table m_symbol_table
Definition: interpreter.h:607
int server_loop(void)
bool m_cancel_quit
Definition: interpreter.h:642
octave_value top_level_varval(const std::string &name) const
void clear_objects(void)
static OCTAVE_THREAD_LOCAL interpreter * m_instance
Definition: interpreter.h:573
void intern_nargin(octave_idx_type nargs)
Definition: interpreter.cc:668
bool m_executing_finish_script
Definition: interpreter.h:644
void parse_and_execute(const std::string &input, bool &incomplete_parse)
Definition: interpreter.cc:832
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)
Definition: interpreter.cc:454
void clear_variable_regexp(const std::string &pattern)
bool m_inhibit_startup_message
Definition: interpreter.h:634
bool mislocked(bool skip_first=false) const
temporary_file_list m_tmp_files
Definition: interpreter.h:577
void assign(const std::string &name, const octave_value &val=octave_value())
void initialize_history(bool read_history_file=false)
Definition: interpreter.cc:675
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)
Definition: interpreter.cc:703
void execute_pkg_add(const std::string &dir)
bool m_load_path_initialized
Definition: interpreter.h:636
void inhibit_startup_message(bool flag)
Definition: interpreter.h:206
void clear_variable_pattern(const std::string &pattern)
void initialize(void)
Definition: interpreter.cc:739
void clear_function_pattern(const std::string &pat)
bool m_history_initialized
Definition: interpreter.h:638
void read_init_files(bool flag)
Definition: interpreter.h:186
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
Definition: interpreter.h:593
int execute_command_line_file(void)
application * m_app_context
Definition: interpreter.h:575
bool m_executing_atexit
Definition: interpreter.h:646
bool interactive(void) const
Definition: interpreter.h:171
symbol_scope require_current_scope(const std::string &who) const
void clear_function(const std::string &name)
int execute(void)
Definition: interpreter.cc:841
gh_manager * m_gh_manager
Definition: interpreter.h:621
void remove_debug_watch_expression(const std::string &expr)
tree_evaluator m_evaluator
Definition: interpreter.h:589
void get_line_and_eval(void)
Definition: interpreter.cc:792
std::list< std::string > user_function_names(void)
void clear_all(bool force=false)
void mark_for_deletion(const std::string &file)
bool m_interactive
Definition: interpreter.h:624
std::list< std::string > m_atexit_fcns
Definition: interpreter.h:579
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)
Definition: load-path.h:184
std::function< void(const std::string &)> get_add_hook(void)
Definition: load-path.h:174
void initialize(bool set_initial_path=false)
Definition: load-path.cc:300
void read_dir_config(const std::string &dir) const
Definition: load-path.cc:1205
void execute_pkg_add(const std::string &dir)
Definition: load-path.cc:1013
void update(void)
Definition: load-path.cc:457
void set_command_line_path(const std::string &p)
Definition: load-path.h:199
OCTINTERP_API octave_value save_default_options(const octave_value_list &args, int nargout)
Definition: load-save.cc:303
OCTINTERP_API octave_value crash_dumps_octave_core(const octave_value_list &args, int nargout)
Definition: load-save.cc:279
void unlock(void)
Definition: ov-fcn.h:182
bool islocked(void) const
Definition: ov-fcn.h:188
virtual octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
Definition: ov-fcn.cc:50
void resize(const dim_vector &dv, bool fill=false)
Definition: oct-map.cc:574
octave_idx_type nfields(void) const
Definition: oct-map.h:344
octave_idx_type numel(void) const
Definition: oct-map.h:389
void assign(const std::string &k, const Cell &val)
Definition: oct-map.h:365
octave_idx_type length(void) const
Definition: oct-map.h:390
octave_idx_type length(void) const
Definition: ovl.h:113
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
Definition: ovl.h:131
bool is_function(void) const
Definition: ov.h:822
OCTINTERP_API octave_function * function_value(bool silent=false) const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov.h:525
bool is_string(void) const
Definition: ov.h:682
bool is_defined(void) const
Definition: ov.h:637
bool is_function_handle(void) const
Definition: ov.h:813
std::string string_value(bool force=false) const
Definition: ov.h:1019
bool is_undefined(void) const
Definition: ov.h:640
bool is_inline_function(void) const
Definition: ov.h:819
octave_idx_type numel(void) const
Definition: str-vec.h:100
void clear_mex_functions(void)
Definition: symtab.cc:498
void clear_function(const std::string &name)
Definition: symtab.cc:434
void clear_function_pattern(const std::string &pat)
Definition: symtab.cc:439
void clear_functions(bool force=false)
Definition: symtab.cc:426
void cleanup(void)
Definition: symtab.cc:694
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope())
Definition: symtab.cc:249
std::list< std::string > user_function_names(void)
Definition: symtab.cc:581
void clear_function_regexp(const std::string &pat)
Definition: symtab.cc:454
void insert(const std::string &file)
Definition: interpreter.cc:322
std::set< std::string > m_files
Definition: interpreter.h:110
static void init(void)
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
Definition: pt-eval.cc:1013
void reset_debug_state(void)
Definition: pt-eval.cc:1363
int server_loop(void)
Definition: pt-eval.cc:872
bool is_global(const std::string &name) const
Definition: pt-eval.cc:1932
bool mislocked(bool skip_first=false) const
Definition: pt-eval.cc:2694
std::list< std::string > autoloaded_functions(void) const
Definition: pt-eval.cc:4620
void clear_all(bool force=false)
Definition: pt-eval.cc:2800
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
Definition: pt-eval.cc:2046
octave_value echo(const octave_value_list &args, int nargout)
Definition: pt-eval.cc:4876
profiler & get_profiler(void)
Definition: pt-eval.h:431
void dbcont(void)
Definition: pt-eval.cc:5009
symbol_scope get_current_scope(void) const
Definition: pt-eval.cc:2657
symbol_scope get_top_scope(void) const
Definition: pt-eval.cc:2652
bool at_top_level(void) const
Definition: pt-eval.cc:534
void clear_global_variable(const std::string &name)
Definition: pt-eval.cc:2779
void munlock(bool skip_first=false) const
Definition: pt-eval.cc:2678
int repl(void)
Definition: pt-eval.cc:731
octave_value find(const std::string &name)
Definition: pt-eval.cc:2715
bool is_local_variable(const std::string &name) const
Definition: pt-eval.cc:1875
void clear_symbol_pattern(const std::string &pattern)
Definition: pt-eval.cc:2823
void clear_symbol(const std::string &name)
Definition: pt-eval.cc:2812
void remove_debug_watch_expression(const std::string &expr)
Definition: pt-eval.h:685
std::list< std::string > top_level_variable_names(void) const
Definition: pt-eval.cc:2850
void dbquit(bool all=false)
Definition: pt-eval.cc:5015
void clear_global_variables(void)
Definition: pt-eval.cc:2795
void clear_variables(void)
Definition: pt-eval.cc:2771
void clear_variable(const std::string &name)
Definition: pt-eval.cc:2747
bool is_variable(const std::string &name) const
Definition: pt-eval.cc:1866
std::list< std::string > global_variable_names(void) const
Definition: pt-eval.cc:2845
bool in_debug_repl(void) const
Definition: pt-eval.cc:5003
void add_debug_watch_expression(const std::string &expr)
Definition: pt-eval.h:678
void clear_global_variable_pattern(const std::string &pattern)
Definition: pt-eval.cc:2785
void assign(const std::string &name, const octave_value &val=octave_value())
Definition: pt-eval.cc:2001
void assignin(const std::string &context, const std::string &name, const octave_value &val=octave_value())
Definition: pt-eval.cc:2010
octave_value top_level_varval(const std::string &name) const
Definition: pt-eval.cc:1988
void clear_objects(void)
Definition: pt-eval.cc:2739
void clear_debug_watch_expressions(void)
Definition: pt-eval.h:692
void clear_symbol_regexp(const std::string &pattern)
Definition: pt-eval.cc:2834
@ ECHO_FUNCTIONS
Definition: pt-eval.h:75
void eval(std::shared_ptr< tree_statement_list > &stmt_list, bool interactive)
Definition: pt-eval.cc:980
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
Definition: pt-eval.cc:1162
octave_value global_varval(const std::string &name) const
Definition: pt-eval.cc:1969
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
Definition: pt-eval.cc:1994
void install_variable(const std::string &name, const octave_value &value, bool global)
Definition: pt-eval.cc:1958
std::list< std::string > variable_names(void) const
Definition: pt-eval.cc:2855
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val=octave_value())
Definition: pt-eval.cc:2198
void get_line_and_eval(void)
Definition: pt-eval.cc:639
bool break_on_next_statement(void) const
Definition: pt-eval.h:808
void clear_global_variable_regexp(const std::string &pattern)
Definition: pt-eval.cc:2790
void parse_and_execute(const std::string &input, bool &incomplete_parse)
Definition: pt-eval.cc:575
void global_assign(const std::string &name, const octave_value &val=octave_value())
Definition: pt-eval.cc:1981
std::set< std::string > debug_watch_expressions(void) const
Definition: pt-eval.h:699
octave_value make_fcn_handle(const std::string &nm)
Definition: pt-eval.cc:1605
void mlock(bool skip_first=false) const
Definition: pt-eval.cc:2662
octave_value varval(const symbol_record &sym) const
Definition: pt-eval.cc:1941
octave_value PS4(const octave_value_list &args, int nargout)
Definition: pt-eval.cc:5148
std::string mfilename(const std::string &opt="") const
Definition: pt-eval.cc:540
void clear_variable_regexp(const std::string &pattern)
Definition: pt-eval.cc:2763
void clear_variable_pattern(const std::string &pattern)
Definition: pt-eval.cc:2755
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string site_defaults_file(void)
Definition: defaults.cc:442
std::string release(void)
Definition: defaults.cc:143
std::string local_site_defaults_file(void)
Definition: defaults.cc:434
OCTINTERP_API void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
Definition: defun.h:160
OCTAVE_EXPORT octave_value_list Fconfirm_recursive_rmdir(const octave_value_list &args, int nargout)
Definition: dirfns.cc:780
void warning(const char *fmt,...)
Definition: error.cc:1054
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1069
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
Definition: error.cc:1033
void verror_with_cfn(const char *fmt, va_list args)
Definition: error.cc:1003
void error(const char *fmt,...)
Definition: error.cc:979
std::string dir_sep_str(void)
Definition: file-ops.cc:240
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:283
void octave_set_default_fpucw(void)
interpreter & __get_interpreter__(void)
#define OCTAVE_SAFE_CALL(F, ARGS)
Definition: interpreter.cc:943
bool octave_initialized
Definition: interpreter.cc:94
OCTAVE_EXPORT octave_value_list F__version_info__(const octave_value_list &args, int)
Definition: interpreter.cc:102
bool octave_interpreter_ready
Definition: interpreter.cc:91
static int safe_source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
Definition: interpreter.cc:347
sys::time Vlast_chdir_time
Definition: interpreter.cc:340
static void xerbla_abort(void)
Definition: interpreter.cc:386
static OCTAVE_NORETURN void lo_error_with_id_handler(const char *id, const char *fmt,...)
Definition: interpreter.cc:432
static void initialize_error_handlers(void)
Definition: interpreter.cc:442
static void initialize_version_info(void)
Definition: interpreter.cc:374
static OCTAVE_NORETURN void lo_error_handler(const char *fmt,...)
Definition: interpreter.cc:421
bool quit_allowed
Definition: interpreter.cc:87
static void initialize_xerbla_error_handler(void)
Definition: interpreter.cc:391
void set_liboctave_error_handler(OCTAVE_NORETURN liboctave_error_handler f)
Definition: lo-error.c:67
void set_liboctave_warning_handler(liboctave_warning_handler f)
Definition: lo-error.c:86
void set_liboctave_error_with_id_handler(OCTAVE_NORETURN liboctave_error_with_id_handler f)
Definition: lo-error.c:76
void set_liboctave_warning_with_id_handler(liboctave_warning_with_id_handler f)
Definition: lo-error.c:95
void octave_ieee_init(void)
Definition: lo-ieee.cc:124
int chdir(const std::string &path_arg)
Definition: lo-sysdep.cc:106
#define OCTAVE_VERSION
Definition: main.in.cc:63
static void install_signal_handlers(void)
Definition: main.in.cc:114
octave_idx_type n
Definition: mx-inlines.cc:753
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
Definition: oct-parse.cc:10319
int release_unreferenced_dynamic_libraries(void)
Definition: oct-shlib.cc:70
T::size_type numel(const T &str)
Definition: oct-string.cc:71
static int input(yyscan_t yyscanner)
OCTAVE_EXPORT octave_value_list Fstruct_levels_to_print(const octave_value_list &args, int nargout)
Definition: ov-struct.cc:2230
OCTAVE_EXPORT octave_value_list Fprint_struct_array_contents(const octave_value_list &args, int nargout)
Definition: ov-struct.cc:2254
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
void flush_stdout(void)
Definition: pager.cc:260
OCTAVE_EXPORT octave_value_list Ffixed_point_format(const octave_value_list &args, int nargout)
Definition: pr-output.cc:4126
OCTAVE_EXPORT octave_value_list Fprint_empty_dimensions(const octave_value_list &args, int nargout)
Definition: pr-output.cc:4157
volatile sig_atomic_t octave_signal_caught
Definition: quit.cc:40
sig_atomic_t octave_interrupt_state
Definition: quit.cc:38
void(* octave_interrupt_hook)(void)
Definition: quit.cc:43
void(* octave_signal_hook)(void)
Definition: quit.cc:42
bool can_interrupt
Definition: sighandlers.cc:68
void respond_to_pending_signals(void)
Definition: sighandlers.cc:110
interrupt_handler catch_interrupts(void)
Definition: sighandlers.cc:326
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)
Definition: sysdep.cc:527
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)
Definition: utils.cc:536
std::string file_in_path(const std::string &name, const std::string &suffix)
Definition: utils.cc:691
bool same_file(const std::string &f, const std::string &g)
Definition: utils.cc:294
static int symbol_exist(interpreter &interp, const std::string &name, const std::string &type="any")
Definition: variables.cc:161
std::string octave_startup_message(bool html)
Definition: version.cc:122
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
void octave_set_xerbla_handler(xerbla_handler_fptr fcn)
Definition: xerbla.cc:52