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