GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
interpreter.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2026 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 "blas-proto.h"
39#include "cmd-edit.h"
40#include "cmd-hist.h"
41#include "file-ops.h"
42#include "file-ops.h"
43#include "file-stat.h"
44#include "fpucw-wrappers.h"
45#include "oct-env.h"
46#include "oct-error.h"
47#include "oct-sysdep.h"
48#include "quit.h"
49#include "signal-wrappers.h"
50#include "str-vec.h"
51#include "unistd-wrappers.h"
52
53#include "builtin-defun-decls.h"
54#include "defaults.h"
55#include "Cell.h"
56#include "defun.h"
57#include "display.h"
58#include "error.h"
59#include "event-manager.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 "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.
87bool 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.
94std::atomic<bool> octave_initialized{false};
95
97
98DEFUN (__version_info__, args, ,
99 doc: /* -*- texinfo -*-
100@deftypefn {} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})
101Undocumented 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
142DEFMETHOD (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@deftypefnx {} {} exit (@dots{})
152Quit the current Octave session.
153
154If the optional integer value @var{status} is supplied, pass that value to
155the operating system as Octave's exit status. The default value is zero.
156
157When exiting, Octave will attempt to run the m-file @file{finish.m} if it
158exists. User commands to save the workspace or clean up temporary files
159may be placed in that file. Alternatively, another m-file may be scheduled
160to run using @code{atexit}. If an error occurs while executing the
161@file{finish.m} file, Octave does not exit and control is returned to
162the command prompt.
163
164If the optional argument @qcode{"cancel"} is provided, Octave does not
165exit and control is returned to the command prompt. This feature allows
166the @code{finish.m} file to cancel the quit process.
167
168If the user preference to request confirmation before exiting, Octave
169will display a dialog and give the user an option to cancel the exit
170process.
171
172If the optional argument @qcode{"force"} is provided, no confirmation is
173requested, and the execution of the @file{finish.m} file is skipped.
174
175Programming Note: @code{exit} is an alias for @code{quit} and can be used
176interchangeably.
177@seealso{atexit}
178@end deftypefn */)
179{
180 int numel = args.length ();
181
182 if (numel > 2)
183 print_usage ();
184
185 int exit_status = 0;
186
187 bool force = false;
188 bool cancel = false;
189
190 if (numel == 2)
191 {
192 exit_status = args(0).xnint_value ("quit: STATUS must be an integer");
193 std::string frc
194 = args(1).xstring_value ("quit: second argument must be a string");
195
196 if (frc == "force")
197 force = true;
198 else
199 error (R"(quit: second argument must be string "force")");
200 }
201 else if (numel == 1)
202 {
203 if (args(0).is_string ())
204 {
205 const char *msg
206 = R"(quit: option must be string "cancel" or "force")";
207
208 std::string opt = args(0).xstring_value (msg);
209
210 if (opt == "cancel")
211 cancel = true;
212 else if (opt == "force")
213 force = true;
214 else
215 error ("%s", msg);
216 }
217 else
218 exit_status = args(0).xnint_value ("quit: STATUS must be an integer");
219 }
220
221 if (cancel)
222 {
223 // No effect if "quit cancel" appears outside of finish script.
224
225 if (interp.executing_finish_script ())
226 interp.cancel_quit (true);
227
228 return ovl ();
229 }
230
231 interp.quit (exit_status, force);
232
233 return ovl ();
234}
235
236DEFALIAS (exit, quit);
237
238DEFMETHOD (atexit, interp, args, nargout,
239 doc: /* -*- texinfo -*-
240@deftypefn {} {} atexit (@var{fcn})
241@deftypefnx {} {} atexit (@var{fcn}, true)
242@deftypefnx {} {} atexit (@var{fcn}, false)
243@deftypefnx {} {@var{status} =} atexit (@var{fcn}, false)
244Register a function to be called when Octave exits.
245
246For example,
247
248@example
249@group
250function last_words ()
251 disp ("Bye bye");
252endfunction
253atexit ("last_words");
254@end group
255@end example
256
257@noindent
258will print the message @qcode{"Bye bye"} when Octave exits.
259
260The additional argument @var{flag} will register or unregister @var{fcn}
261from the list of functions to be called when Octave exits. If @var{flag} is
262true, the function is registered, and if @var{flag} is false, it is
263unregistered. For example, after registering the function @code{last_words}
264above,
265
266@example
267atexit ("last_words", false);
268@end example
269
270@noindent
271will remove the function from the list and Octave will not call
272@code{last_words} when it exits.
273
274The optional output @var{status} is only available when unregistering a
275function. The value is true if the unregistering was successful and false
276otherwise.
277
278Programming Note: @code{atexit} only removes the first occurrence of a function
279from the list; if a function was placed in the list multiple times with
280@code{atexit}, it must also be removed from the list multiple times.
281@seealso{quit}
282@end deftypefn */)
283{
284 int nargin = args.length ();
285
286 if (nargin < 1 || nargin > 2)
287 print_usage ();
288
289 std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
290
291 bool add_mode = (nargin == 2)
292 ? args(1).strict_bool_value ("atexit: FLAG argument must be a logical value")
293 : true;
294
295 octave_value_list retval;
296
297 if (add_mode)
298 interp.add_atexit_fcn (arg);
299 else
300 {
301 bool found = interp.remove_atexit_fcn (arg);
302
303 if (nargout > 0)
304 retval = ovl (found);
305 }
306
307 return retval;
308}
309
310DEFMETHOD (__traditional__, interp, , ,
311 doc: /* -*- texinfo -*-
312@deftypefn {} {@var{tf} =} __traditional__ ()
313Return true if Octave was invoked with the @w{@env{--traditional}}@ option.
314@end deftypefn */)
315{
316 return ovl (interp.traditional ());
317}
318
323
324void
325temporary_file_list::insert (const std::string& file)
326{
327 m_files.insert (file);
328}
329
330void
332{
333 while (! m_files.empty ())
334 {
335 auto it = m_files.begin ();
336
337 octave_unlink_wrapper (it->c_str ());
338
339 m_files.erase (it);
340 }
341}
342
343// The time we last time we changed directories.
344sys::time Vlast_chdir_time = 0.0;
345
346static void
347initialize_version_info ()
348{
349 octave_value_list args (4);
350
351 args(0) = "GNU Octave";
352 args(1) = OCTAVE_VERSION;
353 args(2) = config::release ();
354 args(3) = OCTAVE_RELEASE_DATE;
355
356 F__version_info__ (args);
357}
358
359static void
360xerbla_abort ()
361{
362 error ("Fortran procedure terminated by call to XERBLA");
363}
364
365static void
366initialize_xerbla_error_handler ()
367{
368 // The idea here is to force xerbla to be referenced so that we will
369 // link to our own version instead of the one provided by the BLAS
370 // library. But numeric_limits<double>::NaN () should never be -1, so
371 // we should never actually call xerbla. FIXME (again!): If this
372 // becomes a constant expression the test might be optimized away and
373 // then the reference to the function might also disappear.
374
375 if (numeric_limits<double>::NaN () == -1)
376 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6));
377
378 typedef void (*xerbla_handler_ptr) ();
379
380 typedef void (*octave_set_xerbla_handler_ptr) (xerbla_handler_ptr);
381
382 dynamic_library libs ("");
383
384 if (libs)
385 {
386 octave_set_xerbla_handler_ptr octave_set_xerbla_handler
387 = reinterpret_cast<octave_set_xerbla_handler_ptr>
388 (libs.search ("octave_set_xerbla_handler"));
389
391 octave_set_xerbla_handler (xerbla_abort);
392 }
393}
394
395OCTAVE_NORETURN static void
396lo_error_handler (const char *fmt, ...)
397{
398 va_list args;
399 va_start (args, fmt);
400 verror_with_cfn (fmt, args);
401 va_end (args);
402
403 throw execution_exception ();
404}
405
406OCTAVE_NORETURN static void
407lo_error_with_id_handler (const char *id, const char *fmt, ...)
408{
409 va_list args;
410 va_start (args, fmt);
411 verror_with_id_cfn (id, fmt, args);
412 va_end (args);
413
414 throw execution_exception ();
415}
416
417static void
418initialize_error_handlers ()
419{
420 set_liboctave_error_handler (lo_error_handler);
421 set_liboctave_error_with_id_handler (lo_error_with_id_handler);
424}
425
426// Create an interpreter object and perform initialization up to the
427// point of setting reading command history and setting the load
428// path.
429
431 : m_app_context (app_context),
432 m_tmp_files (),
433 m_atexit_fcns (),
434 m_display_info (),
435 m_environment (),
436 m_evaluator (*this),
437 m_help_system (*this),
438 m_input_system (*this),
439 m_output_system (*this),
440 m_history_system (*this),
441 m_dynamic_loader (*this),
442 m_load_path (*this),
443 m_load_save_system (*this),
444 m_type_info (),
445 m_symbol_table (*this),
446 m_stream_list (*this),
447 m_child_list (),
448 m_url_handle_manager (),
449 m_cdef_manager (*this),
450 m_gtk_manager (*this),
451 m_event_manager (*this),
452 m_gh_manager (nullptr),
453 m_interactive (false),
454 m_read_site_files (true),
455 m_read_user_files (m_app_context != nullptr),
456 m_init_trace (false),
457 m_traditional (false),
458 m_inhibit_startup_message (false),
459 m_load_path_initialized (false),
460 m_history_initialized (false),
461 m_interrupt_all_in_process_group (true),
462 m_cancel_quit (false),
463 m_executing_finish_script (false),
464 m_executing_atexit (false),
465 m_initialized (false)
466{
467 // FIXME: When thread_local storage is used by default, this message
468 // should change to say something like
469 //
470 // only one Octave interpreter may be active in any given thread
471
472 if (s_instance)
473 throw std::runtime_error
474 ("only one Octave interpreter may be active");
475
476 s_instance = this;
477
478#if defined (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE)
479 // Force a UTF-8 locale on Windows if possible
480 std::setlocale (LC_ALL, ".UTF8");
481#else
482 std::setlocale (LC_ALL, "");
483#endif
484 // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting
485 std::setlocale (LC_NUMERIC, "C");
486 std::setlocale (LC_TIME, "C");
487 sys::env::putenv ("LC_NUMERIC", "C");
488 sys::env::putenv ("LC_TIME", "C");
489
490 // Perform system-dependent initialization here in case it has not
491 // already been executed (for example, by the application
492 // constructor).
493 sysdep_init ();
494
495 // Initialize the default floating point unit control state.
497
498 thread::init ();
499
501
502 initialize_xerbla_error_handler ();
503
504 initialize_error_handlers ();
505
506 if (m_app_context)
507 {
510 }
511 else
512 quit_allowed = false;
513
514 if (! m_app_context)
515 m_display_info.initialize ();
516
517 bool line_editing = false;
518
519 if (m_app_context)
520 {
521 // Embedded interpreters don't execute command line options.
522 const cmdline_options& options = m_app_context->options ();
523
524 // Make all command-line arguments available to startup files,
525 // including PKG_ADD files.
526
527 string_vector args = options.all_args ();
528
529 m_app_context->intern_argv (args);
530 intern_nargin (args.numel () - 1);
531
532 bool is_octave_program = m_app_context->is_octave_program ();
533
534 std::list<std::string> command_line_path = options.command_line_path ();
535
536 for (const auto& pth : command_line_path)
537 m_load_path.set_command_line_path (pth);
538
539 std::string exec_path = options.exec_path ();
540 if (! exec_path.empty ())
541 m_environment.exec_path (exec_path);
542
543 std::string image_path = options.image_path ();
544 if (! image_path.empty ())
545 m_environment.image_path (image_path);
546
547 if (! options.no_window_system ())
548 m_display_info.initialize ();
549
550 // Is input coming from a terminal? If so, we are probably
551 // interactive.
552
553 // If stdin is not a tty, then we are reading commands from a
554 // pipe or a redirected file.
555 bool stdin_is_tty = octave_isatty_wrapper (fileno (stdin));
556
557 m_interactive = (! is_octave_program && stdin_is_tty
558 && octave_isatty_wrapper (fileno (stdout)));
559
560 // Don't force interactive if we're already interactive (bug #60696).
561 bool forced_interactive = options.forced_interactive ();
562 if (m_interactive)
563 {
564 m_app_context->forced_interactive (false);
565 forced_interactive = false;
566 }
567
568 // Check if the user forced an interactive session.
569 if (forced_interactive)
570 m_interactive = true;
571
572 line_editing = options.line_editing ();
573 if ((! m_interactive || forced_interactive)
574 && ! options.forced_line_editing ())
575 line_editing = false;
576
577 m_traditional = options.traditional ();
578
579 // FIXME: if possible, perform the following actions directly
580 // instead of using the interpreter-level functions.
581
582 if (options.echo_commands ())
583 m_evaluator.echo
586
587 std::string docstrings_file = options.docstrings_file ();
588 if (! docstrings_file.empty ())
589 Fbuilt_in_docstrings_file (*this, ovl (docstrings_file));
590
591 std::string doc_cache_file = options.doc_cache_file ();
592 if (! doc_cache_file.empty ())
593 Fdoc_cache_file (*this, ovl (doc_cache_file));
594
595 std::string info_file = options.info_file ();
596 if (! info_file.empty ())
597 Finfo_file (*this, ovl (info_file));
598
599 std::string info_program = options.info_program ();
600 if (! info_program.empty ())
601 Finfo_program (*this, ovl (info_program));
602
603 std::string texi_macros_file = options.texi_macros_file ();
604 if (! texi_macros_file.empty ())
605 Ftexi_macros_file (*this, ovl (texi_macros_file));
606 }
607 else
608 // No arguments for embedded interpreters
609 intern_nargin (0);
610
611 // FIXME: we defer creation of the gh_manager object because it
612 // creates a root_figure object that requires the display_info
613 // object, but that is currently only accessible through the global
614 // interpreter object and that is not available until after the
615 // interpreter::instance pointer is set (above). It would be better
616 // if m_gh_manager could be an object value instead of a pointer and
617 // created as part of the interpreter initialization. To do that,
618 // we should either make the display_info object independent of the
619 // interpreter object (does it really need to cache any
620 // information?) or defer creation of the root_figure object until
621 // it is actually needed.
622 m_gh_manager = new gh_manager (*this);
623
624 m_input_system.initialize (line_editing);
625
626 // These can come after command line args since none of them set any
627 // defaults that might be changed by command line options.
628
629 initialize_version_info ();
630
631 // This should be done before initializing the load path because
632 // some PKG_ADD files might need --traditional behavior.
633
634 if (m_traditional)
635 maximum_braindamage ();
636
638}
639
640OCTAVE_THREAD_LOCAL interpreter *interpreter::s_instance = nullptr;
641
643{
644 if (! m_app_context)
645 shutdown ();
646
647 delete m_gh_manager;
648}
649
650void
655
656// Read the history file unless a command-line option inhibits that.
657
658void
659interpreter::initialize_history (bool read_history_file)
660{
661 if (! m_history_initialized)
662 {
663 // Allow command-line option to override.
664
665 if (m_app_context)
666 {
667 const cmdline_options& options = m_app_context->options ();
668
669 read_history_file = options.read_history_file ();
670
671 if (! read_history_file)
673 }
674
675 m_history_system.initialize (read_history_file);
676
677 if (! m_app_context)
679
680 m_history_initialized = true;
681 }
682}
683
684// Set the initial path to the system default unless command-line
685// option says to leave it empty.
686
687void
689{
690 if (! m_load_path_initialized)
691 {
692 // Allow command-line option to override.
693
694 if (m_app_context)
695 {
696 const cmdline_options& options = m_app_context->options ();
697
698 set_initial_path = options.set_initial_path ();
699 }
700
701 // Temporarily set the execute_pkg_add function to one that
702 // catches exceptions. This is better than wrapping
703 // load_path::initialize in a try-catch block because it will
704 // not stop executing PKG_ADD files at the first exception.
705 // It's also better than changing the default execute_pkg_add
706 // function to use safe_source file because that will normally
707 // be evaluated from the normal interpreter loop where exceptions
708 // are already handled.
709
710 unwind_action restore_add_hook (&load_path::set_add_hook, &m_load_path,
711 m_load_path.get_add_hook ());
712
713 m_load_path.set_add_hook ([this] (const std::string& dir) { this->execute_pkg_add (dir); });
714
715 m_load_path.initialize (set_initial_path);
716
717 m_load_path_initialized = true;
718 }
719}
720
721// This may be called separately from execute
722
723void
725{
726 if (m_initialized)
727 return;
728
729 if (m_app_context)
730 {
731 const cmdline_options& options = m_app_context->options ();
732
733 if (options.experimental_terminal_widget ())
734 {
735 if (! options.gui ())
736 display_startup_message ();
737 }
738 else
739 display_startup_message ();
740 }
741 else
742 display_startup_message ();
743
744 // Wait to read the history file until the interpreter reads input
745 // files and begins evaluating commands.
746
748
749 // Initializing the load path may execute PKG_ADD files, so can't be
750 // done until the interpreter is ready to execute commands.
751
752 // Deferring it to the execute step also allows the path to be
753 // initialized between creating and execute the interpreter, for
754 // example, to set a custom path for an embedded interpreter.
755
757
759
760 can_interrupt = true;
761
763 octave_interrupt_hook = nullptr;
764
766
767 // FIXME: could we eliminate this variable or make it not be global?
768 // Global used to communicate with signal handler.
769 octave_initialized = true;
770
771 m_initialized = true;
772
773 run_startup_tests ();
774}
775
776// Note: this function is currently only used with the new
777// experimental terminal widget.
778
779void
781{
782 m_evaluator.get_line_and_eval ();
783}
784
785// Note: the following class is currently only used with the new
786// experimental terminal widget.
787
788class cli_input_reader
789{
790public:
791
792 cli_input_reader (interpreter& interp)
793 : m_interpreter (interp), m_thread () { }
794
795 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (cli_input_reader)
796
797 ~cli_input_reader ()
798 {
799 // FIXME: Would it be better to ensure that
800 // interpreter::get_line_and_eval exits and then call
801 // m_thread.join () here?
802
803 m_thread.detach ();
804 }
805
806 void start ()
807 {
808 m_thread = std::thread (&interpreter::get_line_and_eval, &m_interpreter);
809 }
810
811private:
812
813 interpreter& m_interpreter;
814
815 std::thread m_thread;
816};
817
818void
819interpreter::parse_and_execute (const std::string& input,
820 bool& incomplete_parse)
821{
822 m_evaluator.parse_and_execute (input, incomplete_parse);
823}
824
825// FIXME: this function is intended to be executed only once. Should
826// we enforce that restriction?
827
828int
830{
831 int exit_status = 0;
832
833 try
834 {
835 initialize ();
836
837 execute_startup_files ();
838
839 if (m_app_context)
840 {
841 const cmdline_options& options = m_app_context->options ();
842
843 if (m_app_context->have_eval_option_code ())
844 {
845 int status = execute_eval_option_code ();
846
847 if (status )
848 exit_status = status;
849
850 if (! options.persist ())
851 {
852 shutdown ();
853
854 return exit_status;
855 }
856 }
857
858 // If there is an extra argument, see if it names a file to
859 // read. Additional arguments are taken as command line options
860 // for the script.
861
862 if (m_app_context->have_script_file ())
863 {
864 int status = execute_command_line_file ();
865
866 if (status)
867 exit_status = status;
868
869 if (! options.persist ())
870 {
871 shutdown ();
872
873 return exit_status;
874 }
875 }
876
877 if (options.forced_interactive ())
879
880 if (options.server ())
881 exit_status = server_loop ();
882 else if (options.experimental_terminal_widget ())
883 {
884 if (options.gui ())
885 {
886 m_event_manager.start_gui (true);
887
888 exit_status = server_loop ();
889 }
890 else
891 {
892 // Use an object so that the thread started for the
893 // reader will be cleaned up no matter how we exit
894 // this function.
895
896 cli_input_reader reader (*this);
897
898 reader.start ();
899
900 exit_status = server_loop ();
901 }
902 }
903 else
904 exit_status = main_loop ();
905
906 shutdown ();
907 }
908 }
909 catch (const exit_exception& xe)
910 {
911 exit_status = xe.exit_status ();
912
913 shutdown ();
914 }
915
916 return exit_status;
917}
918
919// Call a function with exceptions handled to avoid problems with
920// errors while shutting down.
921
922#define OCTAVE_IGNORE_EXCEPTION(E) \
923 catch (E) \
924 { \
925 recover_from_exception (); \
926 \
927 std::cerr << "error: ignoring " #E " while preparing to exit" \
928 << std::endl; \
929 }
930
931#define OCTAVE_SAFE_CALL(F, ARGS) \
932 do \
933 { \
934 try \
935 { \
936 error_system& es = get_error_system (); \
937 unwind_action restore_debug_on_error \
938 (&error_system::set_debug_on_error, &es, \
939 es.debug_on_error ()); \
940 \
941 unwind_action restore_debug_on_warning \
942 (&error_system::set_debug_on_warning, &es, \
943 es.debug_on_warning ()); \
944 \
945 es.debug_on_error (false); \
946 es.debug_on_warning (false); \
947 \
948 F ARGS; \
949 } \
950 OCTAVE_IGNORE_EXCEPTION (const exit_exception&) \
951 OCTAVE_IGNORE_EXCEPTION (const interrupt_exception&) \
952 OCTAVE_IGNORE_EXCEPTION (const execution_exception&) \
953 OCTAVE_IGNORE_EXCEPTION (const std::bad_alloc&) \
954 } \
955 while (0)
956
957void
958interpreter::shutdown ()
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
973 execute_atexit_fcns ();
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
994 OCTAVE_SAFE_CALL (m_event_manager.clear_workspace, ());
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
1000 OCTAVE_SAFE_CALL (m_event_manager.close_gui, ());
1001 OCTAVE_SAFE_CALL (m_event_manager.process_events, (true));
1002 OCTAVE_SAFE_CALL (m_event_manager.disable, ());
1003
1004 OCTAVE_SAFE_CALL (m_input_system.clear_input_event_hooks, ());
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
1027 OCTAVE_SAFE_CALL (m_symbol_table.clear_mex_functions, ());
1028
1030
1031 OCTAVE_SAFE_CALL (m_history_system.write_timestamp, ());
1032
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
1049 OCTAVE_SAFE_CALL (m_symbol_table.cleanup, ());
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
1068void
1069interpreter::execute_atexit_fcns ()
1070{
1071 // Prevent atexit functions from adding new functions to the list.
1072 m_executing_atexit = true;
1073
1074 while (! m_atexit_fcns.empty ())
1075 {
1076 std::string fcn = m_atexit_fcns.front ();
1077
1078 m_atexit_fcns.pop_front ();
1079
1081
1083 }
1084}
1085
1086void
1087interpreter::run_startup_tests ()
1088{
1089 bool inhibit_startup_tests = false;
1090
1091 if (m_app_context)
1092 {
1093 const cmdline_options& options = m_app_context->options ();
1094
1095 inhibit_startup_tests = options.inhibit_startup_tests ();
1096 }
1097
1098 if (! inhibit_startup_tests)
1099 {
1100 // Check if BLAS implementation returns single precision values
1101 F77_REAL retval = 0.0;
1102 F77_INT n = 2;
1103 F77_REAL x[2] = {1.0, 2.0};
1104 F77_REAL y[2] = {3.0, 4.0};
1105 F77_FUNC (xsdot, XSDOT) (n, x, 1, y, 1, retval);
1106
1107 if (retval != 11.0f)
1108 {
1109 std::cerr << "BLAS implementation returns incorrect single "
1110 "precision floating-point type" << std::endl;
1111 quit (1, true, false);
1112 }
1113 }
1114}
1115
1116void
1117interpreter::display_startup_message () const
1118{
1119 bool inhibit_startup_message = false;
1120
1121 if (m_app_context)
1122 {
1123 const cmdline_options& options = m_app_context->options ();
1124
1126 }
1127
1128 if (m_interactive && ! inhibit_startup_message)
1129 std::cout << octave_startup_message () << "\n" << std::endl;
1130}
1131
1132// Initialize by reading startup files. Return nonzero if an exception
1133// occurs when reading any of them, but don't exit early because of an
1134// exception.
1135
1136int
1137interpreter::execute_startup_files ()
1138{
1139 bool read_site_files = m_read_site_files;
1140 bool read_user_files = m_read_user_files;
1141 bool trace = m_init_trace;
1142 bool inhibit_startup_message = m_inhibit_startup_message;
1143
1144 if (m_app_context)
1145 {
1146 const cmdline_options& options = m_app_context->options ();
1147
1148 read_site_files = options.read_site_files ();
1149 read_user_files = options.read_user_files ();
1150 trace = options.init_trace ();
1152 }
1153
1154 trace = (trace && ! inhibit_startup_message);
1155
1156 bool require_file = false;
1157
1158 std::string context;
1159
1160 int exit_status = 0;
1161
1162 if (read_site_files)
1163 {
1164 // Execute commands from the site-wide configuration file.
1165 // First from the file $(prefix)/lib/octave/site/m/octaverc
1166 // (if it exists), then from the file
1167 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists).
1168
1169 int status = safe_source_file (config::local_site_defaults_file (),
1170 context, trace, require_file);
1171
1172 if (status)
1173 exit_status = status;
1174
1175 status = safe_source_file (config::site_defaults_file (),
1176 context, trace, require_file);
1177
1178 if (status)
1179 exit_status = status;
1180 }
1181
1182 if (read_user_files)
1183 {
1184 // Try to execute commands from the Matlab compatible startup.m file
1185 // if it exists anywhere in the load path when starting Octave.
1186 std::string ff_startup_m = file_in_path ("startup.m", "");
1187
1188 if (! ff_startup_m.empty ())
1189 {
1190 int parse_status = 0;
1191
1192 try
1193 {
1194 eval_string (std::string ("startup"), false, parse_status, 0);
1195 }
1196 catch (const interrupt_exception&)
1197 {
1199 }
1200 catch (const execution_exception& ee)
1201 {
1202 handle_exception (ee);
1203 }
1204 }
1205
1206 // Try to execute commands from $CONFIG/octave/octaverc, where
1207 // $CONFIG is the platform-dependent location for user local
1208 // configuration files.
1209
1210 std::string user_config_dir = sys::env::get_user_config_directory ();
1211
1212 std::string cfg_dir = user_config_dir + sys::file_ops::dir_sep_str ()
1213 + "octave";
1214
1215 std::string cfg_rc = sys::env::make_absolute ("octaverc", cfg_dir);
1216
1217 if (! cfg_rc.empty ())
1218 {
1219 int status = safe_source_file (cfg_rc, context, trace,
1220 require_file);
1221
1222 if (status)
1223 exit_status = status;
1224 }
1225
1226 // Try to execute commands from $HOME/$OCTAVE_INITFILE and
1227 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set,
1228 // .octaverc is assumed.
1229
1230 bool home_rc_already_executed = false;
1231
1232 std::string initfile = sys::env::getenv ("OCTAVE_INITFILE");
1233
1234 if (initfile.empty ())
1235 initfile = ".octaverc";
1236
1237 std::string home_dir = sys::env::get_home_directory ();
1238
1239 std::string home_rc = sys::env::make_absolute (initfile, home_dir);
1240
1241 std::string local_rc;
1242
1243 if (! home_rc.empty ())
1244 {
1245 int status = safe_source_file (home_rc, context, trace,
1246 require_file);
1247
1248 if (status)
1249 exit_status = status;
1250
1251 // Names alone are not enough.
1252
1253 if (sys::file_exists (home_rc))
1254 {
1255 // We want to check for curr_dir after executing home_rc
1256 // because doing that may change the working directory.
1257
1258 local_rc = sys::env::make_absolute (initfile);
1259
1260 home_rc_already_executed = sys::same_file (home_rc, local_rc);
1261 }
1262 }
1263
1264 if (! home_rc_already_executed)
1265 {
1266 if (local_rc.empty ())
1267 local_rc = sys::env::make_absolute (initfile);
1268
1269 int status = safe_source_file (local_rc, context, trace,
1270 require_file);
1271
1272 if (status)
1273 exit_status = status;
1274 }
1275 }
1276
1277 if (m_interactive && trace)
1278 octave_stdout << std::endl;
1279
1280 return exit_status;
1281}
1282
1283// Execute any code specified with --eval 'CODE'
1284
1285int
1286interpreter::execute_eval_option_code ()
1287{
1288 if (! m_app_context)
1289 return 0;
1290
1291 const cmdline_options& options = m_app_context->options ();
1292
1293 std::string code_to_eval = options.code_to_eval ();
1294
1295 unwind_protect_var<bool> upv (m_interactive, false);
1296
1297 int parse_status = 0;
1298
1299 try
1300 {
1301 eval_string (code_to_eval, false, parse_status, 0);
1302 }
1303 catch (const interrupt_exception&)
1304 {
1306
1307 return 1;
1308 }
1309 catch (const execution_exception& ee)
1310 {
1311 handle_exception (ee);
1312
1313 return 1;
1314 }
1315
1316 return parse_status;
1317}
1318
1319int
1320interpreter::execute_command_line_file ()
1321{
1322 if (! m_app_context)
1323 return 0;
1324
1325 const cmdline_options& options = m_app_context->options ();
1326
1327 string_vector args = options.all_args ();
1328
1329 void (interpreter::*interactive_fptr) (bool) = &interpreter::interactive;
1330 unwind_action restore_interactive (interactive_fptr, this, m_interactive);
1331
1332 unwind_action restore_argv (&application::intern_argv, m_app_context, args);
1333
1334 unwind_action restore_nargin (&interpreter::intern_nargin, this,
1335 args.numel () - 1);
1336
1337 void (application::*program_invocation_name_fptr) (const std::string&)
1338 = &application::program_invocation_name;
1339 unwind_action restore_program_invocation_name
1340 (program_invocation_name_fptr, m_app_context,
1342
1343 void (application::*program_name_fptr) (const std::string&)
1344 = &application::program_name;
1345 unwind_action restore_program_name
1346 (program_name_fptr, m_app_context, application::program_name ());
1347
1348 m_interactive = false;
1349
1350 // If we are running an executable script (#! /bin/octave) then
1351 // we should only see the args passed to the script.
1352
1353 string_vector script_args = options.remaining_args ();
1354
1355 m_app_context->intern_argv (script_args);
1356 intern_nargin (script_args.numel () - 1);
1357
1358 std::string fname = script_args[0];
1359
1360 m_app_context->set_program_names (fname);
1361
1362 std::string context;
1363 bool verbose = false;
1364 bool require_file = true;
1365
1366 return safe_source_file (fname, context, verbose, require_file);
1367}
1368
1369int
1370interpreter::main_loop ()
1371{
1373
1374 return m_evaluator.repl ();
1375}
1376
1377int
1378interpreter::server_loop ()
1379{
1380 return m_evaluator.server_loop ();
1381}
1382
1385{
1386 return m_evaluator;
1387}
1388
1391{
1392 return m_stream_list;
1393}
1394
1397{
1398 return m_url_handle_manager;
1399}
1400
1403{
1404 return m_evaluator.get_top_scope ();
1405}
1406
1409{
1410 return m_evaluator.get_current_scope ();
1411}
1412
1414interpreter::require_current_scope (const std::string& who) const
1415{
1417
1418 if (! scope)
1419 error ("%s: symbol table scope missing", who.c_str ());
1420
1421 return scope;
1422}
1423
1424profiler&
1426{
1427 return m_evaluator.get_profiler ();
1428}
1429
1430int
1431interpreter::chdir (const std::string& dir)
1432{
1433 std::string xdir = sys::file_ops::tilde_expand (dir);
1434
1435 int cd_ok = sys::env::chdir (xdir);
1436
1437 if (! cd_ok)
1438 error ("%s: %s", dir.c_str (), std::strerror (errno));
1439
1440 Vlast_chdir_time.stamp ();
1441
1442 // FIXME: should these actions be handled as a list of functions
1443 // to call so users can add their own chdir handlers?
1444
1445 m_load_path.read_dir_config (".");
1446 m_load_path.update ();
1447 // Updating the last prompt time stamp avoids skipping a fcn-info refresh
1448 // so that functions in the new current directory can shadow functions
1449 // further back in the load path order.
1450 Vlast_prompt_time.stamp ();
1451
1452 m_event_manager.directory_changed (sys::env::get_current_directory ());
1453
1454 return cd_ok;
1455}
1456
1457void
1458interpreter::mlock (bool skip_first) const
1459{
1460 m_evaluator.mlock (skip_first);
1461}
1462
1463void
1464interpreter::munlock (bool skip_first) const
1465{
1466 m_evaluator.munlock (skip_first);
1467}
1468
1469bool
1470interpreter::mislocked (bool skip_first) const
1471{
1472 return m_evaluator.mislocked (skip_first);
1473}
1474
1475void
1476interpreter::munlock (const char *nm)
1477{
1478 if (! nm)
1479 error ("munlock: invalid value for NAME");
1480
1481 munlock (std::string (nm));
1482}
1483
1484void
1485interpreter::munlock (const std::string& nm)
1486{
1487 octave_value val = m_symbol_table.find_function (nm);
1488
1489 if (val.is_defined ())
1490 {
1491 octave_function *fcn = val.function_value ();
1492
1493 if (fcn)
1494 fcn->unlock ();
1495 }
1496}
1497
1498bool
1500{
1501 if (! nm)
1502 error ("mislocked: invalid value for NAME");
1503
1504 return mislocked (std::string (nm));
1505}
1506
1507bool
1508interpreter::mislocked (const std::string& nm)
1509{
1510 bool retval = false;
1511
1512 octave_value val = m_symbol_table.find_function (nm);
1513
1514 if (val.is_defined ())
1515 {
1516 octave_function *fcn = val.function_value ();
1517
1518 if (fcn)
1519 retval = fcn->islocked ();
1520 }
1521
1522 return retval;
1523}
1524
1525std::string
1526interpreter::mfilename (const std::string& opt) const
1527{
1528 return m_evaluator.mfilename (opt);
1529}
1530
1532interpreter::eval_string (const std::string& eval_str,
1533 bool silent, int& parse_status,
1534 int nargout)
1535{
1536 return m_evaluator.eval_string (eval_str, silent, parse_status, nargout);
1537}
1538
1540interpreter::eval_string (const std::string& eval_str,
1541 bool silent, int& parse_status)
1542{
1543 return m_evaluator.eval_string (eval_str, silent, parse_status);
1544}
1545
1548 bool silent, int& parse_status,
1549 int nargout)
1550{
1551 return m_evaluator.eval_string (arg, silent, parse_status, nargout);
1552}
1553
1555interpreter::eval (const std::string& try_code,
1556 int nargout)
1557{
1558 return m_evaluator.eval (try_code, nargout);
1559}
1560
1562interpreter::eval (const std::string& try_code,
1563 const std::string& catch_code,
1564 int nargout)
1565{
1566 return m_evaluator.eval (try_code, catch_code, nargout);
1567}
1568
1570interpreter::evalin (const std::string& context,
1571 const std::string& try_code,
1572 int nargout)
1573{
1574 return m_evaluator.evalin (context, try_code, nargout);
1575}
1576
1578interpreter::evalin (const std::string& context,
1579 const std::string& try_code,
1580 const std::string& catch_code,
1581 int nargout)
1582{
1583 return m_evaluator.evalin (context, try_code, catch_code, nargout);
1584}
1585
1586//! Evaluate an Octave function (built-in or interpreted) and return
1587//! the list of result values.
1588//!
1589//! @param name The name of the function to call.
1590//! @param args The arguments to the function.
1591//! @param nargout The number of output arguments expected.
1592//! @return A list of output values. The length of the list is not
1593//! necessarily the same as @c nargout.
1594
1596interpreter::feval (const char *name,
1597 const octave_value_list& args,
1598 int nargout)
1599{
1600 return feval (std::string (name), args, nargout);
1601}
1602
1604interpreter::feval (const std::string& name,
1605 const octave_value_list& args,
1606 int nargout)
1607{
1608 octave_value fcn = m_symbol_table.find_function (name, args);
1609
1610 if (fcn.is_undefined ())
1611 error ("feval: function '%s' not found", name.c_str ());
1612
1613 octave_function *of = fcn.function_value ();
1614
1615 return of->call (m_evaluator, nargout, args);
1616}
1617
1620 const octave_value_list& args,
1621 int nargout)
1622{
1623 if (fcn)
1624 return fcn->call (m_evaluator, nargout, args);
1625
1626 return octave_value_list ();
1627}
1628
1631 const octave_value_list& args,
1632 int nargout)
1633{
1634 // FIXME: do we really want to silently return an empty ovl if
1635 // the function object is undefined? It's essentially what the
1636 // version above that accepts a pointer to an octave_function
1637 // object does and some code was apparently written to rely on it
1638 // (for example, __ode15__).
1639
1640 if (val.is_undefined ())
1641 return ovl ();
1642
1643 if (val.is_function ())
1644 {
1645 return feval (val.function_value (), args, nargout);
1646 }
1647 else if (val.is_function_handle () || val.is_inline_function ())
1648 {
1649 // This covers function handles, inline functions, and anonymous
1650 // functions.
1651
1652 std::list<octave_value_list> arg_list;
1653 arg_list.push_back (args);
1654
1655 // FIXME: could we make octave_value::subsref a const method?
1656 // It would be difficult because there are instances of
1657 // incrementing the reference count inside subsref methods,
1658 // which means they can't be const with the current way of
1659 // handling reference counting.
1660
1661 octave_value xval = val;
1662 return xval.subsref ("(", arg_list, nargout);
1663 }
1664 else if (val.is_string ())
1665 {
1666 return feval (val.string_value (), args, nargout);
1667 }
1668 else
1669 error ("feval: first argument must be a string, inline function, or a function handle");
1670
1671 return ovl ();
1672}
1673
1674//! Evaluate an Octave function (built-in or interpreted) and return
1675//! the list of result values.
1676//!
1677//! @param args The first element of @c args is the function to call.
1678//! It may be the name of the function as a string, a function
1679//! handle, or an inline function. The remaining arguments are
1680//! passed to the function.
1681//! @param nargout The number of output arguments expected.
1682//! @return A list of output values. The length of the list is not
1683//! necessarily the same as @c nargout.
1684
1687 int nargout)
1688{
1689 if (args.length () == 0)
1690 error ("feval: first argument must be a string, inline function, or a function handle");
1691
1692 octave_value f_arg = args(0);
1693
1694 octave_value_list tmp_args = args.slice (1, args.length () - 1, true);
1695
1696 return feval (f_arg, tmp_args, nargout);
1697}
1698
1699std::string
1700interpreter::inputname (int n, bool ids_only) const
1701{
1702 return m_evaluator.inputname (n, ids_only);
1703}
1704
1706interpreter::make_function_handle (const std::string& name)
1707{
1708 return m_evaluator.make_fcn_handle (name);
1709}
1710
1711void
1712interpreter::install_variable (const std::string& name,
1713 const octave_value& value, bool global)
1714{
1715 m_evaluator.install_variable (name, value, global);
1716}
1717
1719interpreter::global_varval (const std::string& name) const
1720{
1721 return m_evaluator.global_varval (name);
1722}
1723
1724void
1725interpreter::global_assign (const std::string& name,
1726 const octave_value& val)
1727{
1728 m_evaluator.global_assign (name, val);
1729}
1730
1732interpreter::top_level_varval (const std::string& name) const
1733{
1734 return m_evaluator.top_level_varval (name);
1735}
1736
1737void
1738interpreter::top_level_assign (const std::string& name,
1739 const octave_value& val)
1740{
1741 m_evaluator.top_level_assign (name, val);
1742}
1743
1744bool
1745interpreter::is_variable (const std::string& name) const
1746{
1747 return m_evaluator.is_variable (name);
1748}
1749
1750bool
1751interpreter::is_local_variable (const std::string& name) const
1752{
1753 return m_evaluator.is_local_variable (name);
1754}
1755
1757interpreter::varval (const std::string& name) const
1758{
1759 return m_evaluator.varval (name);
1760}
1761
1762void
1763interpreter::assign (const std::string& name,
1764 const octave_value& val)
1765{
1766 m_evaluator.assign (name, val);
1767}
1768
1769void
1770interpreter::assignin (const std::string& context,
1771 const std::string& name,
1772 const octave_value& val)
1773{
1774 m_evaluator.assignin (context, name, val);
1775}
1776
1777void
1778interpreter::source_file (const std::string& file_name,
1779 const std::string& context, bool verbose,
1780 bool require_file)
1781{
1782 m_evaluator.source_file (file_name, context, verbose, require_file);
1783}
1784
1785bool
1787{
1788 return m_evaluator.at_top_level ();
1789}
1790
1791bool
1792interpreter::isglobal (const std::string& name) const
1793{
1794 return m_evaluator.is_global (name);
1795}
1796
1798interpreter::find (const std::string& name)
1799{
1800 return m_evaluator.find (name);
1801}
1802
1803void
1805{
1806 m_evaluator.clear_all (force);
1807}
1808
1809void
1811{
1812 m_evaluator.clear_objects ();
1813}
1814
1815void
1816interpreter::clear_variable (const std::string& name)
1817{
1818 m_evaluator.clear_variable (name);
1819}
1820
1821void
1822interpreter::clear_variable_pattern (const std::string& pattern)
1823{
1824 m_evaluator.clear_variable_pattern (pattern);
1825}
1826
1827void
1828interpreter::clear_variable_regexp (const std::string& pattern)
1829{
1830 m_evaluator.clear_variable_regexp (pattern);
1831}
1832
1833void
1835{
1836 m_evaluator.clear_variables ();
1837}
1838
1839void
1840interpreter::clear_global_variable (const std::string& name)
1841{
1842 m_evaluator.clear_global_variable (name);
1843}
1844
1845void
1847{
1848 m_evaluator.clear_global_variable_pattern (pattern);
1849}
1850
1851void
1853{
1854 m_evaluator.clear_global_variable_regexp (pattern);
1855}
1856
1857void
1862
1863void
1865{
1866 m_symbol_table.clear_functions (force);
1867}
1868
1869void
1870interpreter::clear_function (const std::string& name)
1871{
1872 m_symbol_table.clear_function (name);
1873}
1874
1875void
1876interpreter::clear_symbol (const std::string& name)
1877{
1878 m_evaluator.clear_symbol (name);
1879}
1880
1881void
1883{
1884 m_symbol_table.clear_function_pattern (pat);
1885}
1886
1887void
1889{
1890 m_symbol_table.clear_function_regexp (pat);
1891}
1892
1893void
1895{
1896 return m_evaluator.clear_symbol_pattern (pat);
1897}
1898
1899void
1900interpreter::clear_symbol_regexp (const std::string& pat)
1901{
1902 return m_evaluator.clear_symbol_regexp (pat);
1903}
1904
1905std::list<std::string>
1907{
1908 return m_evaluator.global_variable_names ();
1909}
1910
1911std::list<std::string>
1913{
1914 return m_evaluator.top_level_variable_names ();
1915}
1916
1917std::list<std::string>
1919{
1920 return m_evaluator.variable_names ();
1921}
1922
1923std::list<std::string>
1925{
1926 return m_symbol_table.user_function_names ();
1927}
1928
1929std::list<std::string>
1931{
1932 return m_evaluator.autoloaded_functions ();
1933}
1934
1935// May be used to send an interrupt signal to the the interpreter from
1936// another thread (for example, the GUI).
1937
1938void
1940{
1941 static int sigint = 0;
1942 static bool first = true;
1943
1944 if (first)
1945 {
1946 octave_get_sig_number ("SIGINT", &sigint);
1947 first = false;
1948 }
1949
1950 // Send SIGINT to Octave and (optionally) all other processes in its
1951 // process group. The signal handler for SIGINT will set a global
1952 // variable indicating an interrupt has happened. That variable is
1953 // checked in many places in the Octave interpreter and eventually
1954 // results in an interrupt_exception being thrown. Finally, that
1955 // exception is caught and returns control to one of the
1956 // read-eval-print loops or to the server loop. We use a signal
1957 // instead of just setting the global variables here so that we will
1958 // probably send interrupt signals to any subprocesses as well as
1959 // interrupt execution of the interpreter.
1960
1961 pid_t pid
1962 = m_interrupt_all_in_process_group ? 0 : octave_getpid_wrapper ();
1963
1964 octave_kill_wrapper (pid, sigint);
1965}
1966
1967void
1969{
1970 // FIXME: To be reliable, these tree_evaluator functions must be
1971 // made thread safe.
1972
1973 m_evaluator.break_on_next_statement (true);
1974 m_evaluator.reset_debug_state ();
1975}
1976
1977void
1979{
1980 // FIXME: To be reliable, these tree_evaluator functions must be
1981 // made thread safe.
1982
1983 if (m_evaluator.in_debug_repl ())
1984 m_evaluator.dbquit (true);
1985 else
1986 interrupt ();
1987}
1988
1989void
1991{
1992 // FIXME: To be reliable, these tree_evaluator functions must be
1993 // made thread safe.
1994
1995 // FIXME: Should there be any feeback about not doing anything if
1996 // not in debug mode?
1997
1998 if (m_evaluator.in_debug_repl ())
1999 m_evaluator.dbcont ();
2000}
2001
2003interpreter::PS1 (const octave_value_list& args, int nargout)
2004{
2005 return m_input_system.PS1 (args, nargout);
2006}
2007
2008std::string
2010{
2011 return m_input_system.PS1 ();
2012}
2013
2014std::string
2015interpreter::PS1 (const std::string& s)
2016{
2017 return m_input_system.PS1 (s);
2018}
2019
2020void
2021interpreter::set_PS1 (const std::string& s)
2022{
2023 m_input_system.set_PS1 (s);
2024}
2025
2027interpreter::PS2 (const octave_value_list& args, int nargout)
2028{
2029 return m_input_system.PS2 (args, nargout);
2030}
2031
2032std::string
2034{
2035 return m_input_system.PS2 ();
2036}
2037
2038std::string
2039interpreter::PS2 (const std::string& s)
2040{
2041 return m_input_system.PS2 (s);
2042}
2043
2044void
2045interpreter::set_PS2 (const std::string& s)
2046{
2047 m_input_system.set_PS2 (s);
2048}
2049
2051interpreter::PS4 (const octave_value_list& args, int nargout)
2052{
2053 return m_evaluator.PS4 (args, nargout);
2054}
2055
2056std::string
2058{
2059 return m_evaluator.PS4 ();
2060}
2061
2062std::string
2063interpreter::PS4 (const std::string& s)
2064{
2065 return m_evaluator.PS4 (s);
2066}
2067
2068void
2069interpreter::set_PS4 (const std::string& s)
2070{
2071 m_evaluator.set_PS4 (s);
2072}
2073
2074// Provided for convenience. Will be removed once we eliminate the
2075// old terminal widget.
2076bool
2078{
2079 if (! m_app_context)
2080 return false;
2081
2082 // Embedded interpreters don't execute command line options.
2083 const cmdline_options& options = m_app_context->options ();
2084
2085 return options.experimental_terminal_widget ();
2086}
2087
2088void
2090{
2091 m_evaluator.add_debug_watch_expression (expr);
2092}
2093
2094void
2096{
2097 m_evaluator.remove_debug_watch_expression (expr);
2098}
2099
2100void
2105
2106std::set<std::string>
2108{
2109 return m_evaluator.debug_watch_expressions ();
2110}
2111
2112void
2114{
2116
2117 es.save_exception (ee);
2118
2119 // FIXME: use a separate stream instead of std::cerr directly so that
2120 // error messages can be redirected more easily? Pass the message
2121 // to an event manager function?
2122 es.display_exception (ee);
2123
2125}
2126
2127void
2139
2140void
2141interpreter::mark_for_deletion (const std::string& file)
2142{
2143 m_tmp_files.insert (file);
2144}
2145
2146void
2148{
2149 m_tmp_files.cleanup ();
2150}
2151
2152void
2153interpreter::quit (int exit_status, bool force, bool confirm)
2154{
2155 if (! force)
2156 {
2157 try
2158 {
2159 bool cancel = false;
2160
2161 if (symbol_exist ("finish.m", "file"))
2162 {
2163 unwind_protect_var<bool> upv1 (m_executing_finish_script, true);
2164 unwind_protect_var<bool> upv2 (m_cancel_quit);
2165
2166 evalin ("base", "finish", 0);
2167
2168 cancel = m_cancel_quit;
2169 }
2170
2171 if (cancel)
2172 return;
2173
2174 // Check for confirmation.
2175
2176 if (confirm && ! m_event_manager.confirm_shutdown ())
2177 return;
2178 }
2179 catch (const execution_exception&)
2180 {
2181 // Catch execution_exceptions so we don't throw an
2182 // exit_exception if there is an in finish.m. But throw it
2183 // again so that will be handled as any other
2184 // execution_exception by the evaluator. This way, errors
2185 // will be ignored properly and we won't exit if quit is
2186 // called recursively from finish.m.
2187
2188 throw;
2189 }
2190 }
2191
2192 throw exit_exception (exit_status);
2193}
2194
2195void
2196interpreter::add_atexit_fcn (const std::string& fname)
2197{
2198 if (m_executing_atexit)
2199 return;
2200
2201 m_atexit_fcns.push_front (fname);
2202}
2203
2204bool
2205interpreter::remove_atexit_fcn (const std::string& fname)
2206{
2207 bool found = false;
2208
2209 for (auto it = m_atexit_fcns.begin ();
2210 it != m_atexit_fcns.end (); it++)
2211 {
2212 if (*it == fname)
2213 {
2214 m_atexit_fcns.erase (it);
2215 found = true;
2216 break;
2217 }
2218 }
2219
2220 return found;
2221}
2222
2223// What internal options get configured by --traditional.
2224
2225void
2226interpreter::maximum_braindamage ()
2227{
2228 PS1 (">> ");
2229 PS2 ("");
2230 PS4 ("");
2232 es.beep_on_error (true);
2233 Fconfirm_recursive_rmdir (ovl (false));
2234 m_load_save_system.crash_dumps_octave_core (false);
2235 Foptimize_diagonal_matrix (ovl (false));
2236 Foptimize_permutation_matrix (ovl (false));
2237 Foptimize_range (ovl (false));
2238 Ffixed_point_format (ovl (true));
2239 m_history_system.timestamp_format_string ("%%-- %D %I:%M %p --%%");
2241 m_load_save_system.save_default_options ("-mat-binary");
2243
2244 es.disable_warning ("Octave:abbreviated-property-match");
2245 es.disable_warning ("Octave:colon-nonscalar-argument");
2246 es.disable_warning ("Octave:data-file-in-path");
2247 es.disable_warning ("Octave:empty-index");
2248 es.disable_warning ("Octave:function-name-clash");
2249 es.disable_warning ("Octave:possible-matlab-short-circuit-operator");
2250}
2251
2252void
2253interpreter::execute_pkg_add (const std::string& dir)
2254{
2255 try
2256 {
2257 m_load_path.execute_pkg_add (dir);
2258 }
2259 catch (const interrupt_exception&)
2260 {
2262 }
2263 catch (const execution_exception& ee)
2264 {
2265 handle_exception (ee);
2266 }
2267}
2268
2269// Execute commands from a file and catch potential exceptions in a consistent
2270// way. This function should be called anywhere we might parse and execute
2271// commands from a file before we have entered the main loop in
2272// toplev.cc.
2273
2274int
2275interpreter::safe_source_file (const std::string& file_name,
2276 const std::string& context,
2277 bool verbose, bool require_file)
2278{
2279 try
2280 {
2281 source_file (file_name, context, verbose, require_file);
2282 }
2283 catch (const interrupt_exception&)
2284 {
2286
2287 return 1;
2288 }
2289 catch (const execution_exception& ee)
2290 {
2291 handle_exception (ee);
2292
2293 return 1;
2294 }
2295
2296 return 0;
2297}
2298
2299OCTAVE_END_NAMESPACE(octave)
Definition Cell.h:41
void set_program_names(const std::string &pname)
Definition octave.cc:315
void forced_interactive(bool arg)
Definition octave.h:312
void intern_argv(const string_vector &args)
Definition octave.cc:325
bool have_eval_option_code() const
Definition octave.h:283
cmdline_options options() const
Definition octave.h:281
static std::string program_name()
Definition octave.h:325
bool is_octave_program() const
Definition octave.h:287
bool have_script_file() const
Definition octave.h:285
static std::string program_invocation_name()
Definition octave.h:320
bool line_editing() const
Definition octave.h:68
bool forced_interactive() const
Definition octave.h:61
bool experimental_terminal_widget() const
Definition octave.h:59
std::string texi_macros_file() const
Definition octave.h:93
bool inhibit_startup_message() const
Definition octave.h:66
std::string doc_cache_file() const
Definition octave.h:88
bool init_trace() const
Definition octave.h:83
std::string image_path() const
Definition octave.h:90
bool read_site_files() const
Definition octave.h:73
string_vector remaining_args() const
Definition octave.h:95
bool persist() const
Definition octave.h:71
bool read_user_files() const
Definition octave.h:74
std::string info_program() const
Definition octave.h:92
bool server() const
Definition octave.h:77
bool read_history_file() const
Definition octave.h:72
std::string exec_path() const
Definition octave.h:89
bool no_window_system() const
Definition octave.h:70
std::string code_to_eval() const
Definition octave.h:84
string_vector all_args() const
Definition octave.h:94
std::string info_file() const
Definition octave.h:91
std::string docstrings_file() const
Definition octave.h:87
bool echo_commands() const
Definition octave.h:57
bool gui() const
Definition octave.h:63
bool traditional() const
Definition octave.h:79
bool set_initial_path() const
Definition octave.h:78
bool forced_line_editing() const
Definition octave.h:62
bool inhibit_startup_tests() const
Definition octave.h:64
std::list< std::string > command_line_path() const
Definition octave.h:85
static void blink_matching_paren(bool flag)
Definition cmd-edit.cc:1306
static void restore_terminal_state()
Definition cmd-edit.cc:1299
static void add_event_hook(event_hook_fcn f)
Definition cmd-edit.cc:1556
static bool ignoring_entries()
Definition cmd-hist.cc:610
static void clean_up_and_save(const std::string &="", int=-1)
Definition cmd-hist.cc:768
static void ignore_entries(bool=true)
Definition cmd-hist.cc:603
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:92
void initialize()
Definition display.cc:42
octave_value image_path(const octave_value_list &args, int nargout)
octave_value exec_path(const octave_value_list &args, int nargout)
octave_value beep_on_error(const octave_value_list &args, int nargout)
Definition error.cc:308
void disable_warning(const std::string &id)
Definition error.cc:861
void save_exception(const execution_exception &ee)
Definition error.cc:932
void display_exception(const execution_exception &ee) const
Definition error.cc:944
bool confirm_shutdown()
void process_events(bool disable=false)
void interpreter_interrupted()
void directory_changed(const std::string &dir)
void start_gui(bool gui_app=false)
void clear_workspace()
void unload_all_toolkits()
void write_timestamp()
Definition oct-hist.cc:281
octave_value timestamp_format_string(const octave_value_list &args, int nargout)
Definition oct-hist.cc:307
void initialize(bool read_history_file=false)
Definition oct-hist.cc:269
void initialize(bool line_editing)
Definition input.cc:412
void clear_input_event_hooks()
void set_PS2(const std::string &s)
Definition input.h:91
void set_PS1(const std::string &s)
Definition input.h:78
octave_value PS2(const octave_value_list &args, int nargout)
octave_value PS1(const octave_value_list &args, int nargout)
octave_value global_varval(const std::string &name) const
octave_value varval(const std::string &name) const
void clear_variable(const std::string &name)
octave_value make_function_handle(const std::string &name)
void assignin(const std::string &context, const std::string &varname, const octave_value &val=octave_value())
bool isglobal(const std::string &name) const
void quit(int exit_status, bool force=false, bool confirm=true)
void clear_global_variables()
std::list< std::string > autoloaded_functions() const
void global_assign(const std::string &name, const octave_value &val=octave_value())
void install_variable(const std::string &name, const octave_value &value, bool global)
error_system & get_error_system()
void verbose(bool flag)
void add_debug_watch_expression(const std::string &expr)
bool at_top_level() const
void read_site_files(bool flag)
void add_atexit_fcn(const std::string &fname)
bool remove_atexit_fcn(const std::string &fname)
void initialize()
void clear_objects()
octave_value find(const std::string &name)
void mlock(bool skip_first=false) const
profiler & get_profiler()
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
std::list< std::string > variable_names()
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
std::set< std::string > debug_watch_expressions() const
octave_value_list eval(const std::string &try_code, int nargout)
std::string PS2() const
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
std::string PS1() const
void clear_symbol_regexp(const std::string &pat)
void handle_exception(const execution_exception &ee)
bool experimental_terminal_widget() const
symbol_scope get_current_scope() const
void clear_symbol_pattern(const std::string &pat)
void clear_global_variable_regexp(const std::string &pattern)
void clear_global_variable(const std::string &name)
void set_PS1(const std::string &s)
int chdir(const std::string &dir)
std::list< std::string > user_function_names()
void clear_global_variable_pattern(const std::string &pattern)
void clear_function_regexp(const std::string &pat)
octave_value top_level_varval(const std::string &name) const
symbol_scope get_top_scope() const
void intern_nargin(octave_idx_type nargs)
void clear_variables()
void parse_and_execute(const std::string &input, bool &incomplete_parse)
bool is_variable(const std::string &name) const
interpreter(application *app_context=nullptr)
void clear_variable_regexp(const std::string &pattern)
bool interactive() const
std::string PS4() const
bool mislocked(bool skip_first=false) const
tree_evaluator & get_evaluator()
void assign(const std::string &name, const octave_value &val=octave_value())
void initialize_history(bool read_history_file=false)
void clear_symbol(const std::string &name)
std::list< std::string > global_variable_names()
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
void read_user_files(bool flag)
void cleanup_tmp_files()
std::string mfilename(const std::string &opt="") const
void initialize_load_path(bool set_initial_path=true)
void clear_debug_watch_expressions()
void inhibit_startup_message(bool flag)
void clear_variable_pattern(const std::string &pattern)
void clear_function_pattern(const std::string &pat)
bool is_local_variable(const std::string &name) const
std::list< std::string > top_level_variable_names()
void munlock(bool skip_first=false) const
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.
void get_line_and_eval()
url_handle_manager & get_url_handle_manager()
symbol_scope require_current_scope(const std::string &who) const
std::string inputname(int n, bool ids_only=true) const
void clear_function(const std::string &name)
void remove_debug_watch_expression(const std::string &expr)
void recover_from_exception()
void clear_all(bool force=false)
void mark_for_deletion(const std::string &file)
void set_PS2(const std::string &s)
stream_list & get_stream_list()
void set_PS4(const std::string &s)
void clear_functions(bool force=false)
void set_add_hook(const std::function< void(const std::string &)> &f)
Definition load-path.h:180
void initialize(bool set_initial_path=false)
Definition load-path.cc:262
void read_dir_config(const std::string &dir) const
std::function< void(const std::string &)> get_add_hook()
Definition load-path.h:170
void execute_pkg_add(const std::string &dir)
Definition load-path.cc:970
void update()
Definition load-path.cc:427
void set_command_line_path(const std::string &p)
Definition load-path.h:195
octave_value save_default_options(const octave_value_list &args, int nargout)
Definition load-save.cc:301
octave_value crash_dumps_octave_core(const octave_value_list &args, int nargout)
Definition load-save.cc:277
bool islocked() const
Definition ov-fcn.h:192
void unlock()
Definition ov-fcn.h:186
virtual octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
Definition ov-fcn.cc:79
void resize(const dim_vector &dv, bool fill=false)
Definition oct-map.cc:574
octave_idx_type nfields() const
Definition oct-map.h:323
octave_idx_type length() const
Definition oct-map.h:369
octave_idx_type numel() const
Definition oct-map.h:368
void assign(const std::string &k, const Cell &val)
Definition oct-map.h:344
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
Definition ovl.h:129
octave_idx_type length() const
Definition ovl.h:111
bool is_function_handle() const
Definition ov.h:766
bool is_undefined() const
Definition ov.h:593
bool is_inline_function() const
Definition ov.h:772
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition ov.h:474
octave_function * function_value(bool silent=false) const
bool is_string() const
Definition ov.h:635
bool is_defined() const
Definition ov.h:590
bool is_function() const
Definition ov.h:775
std::string string_value(bool force=false) const
Definition ov.h:981
octave_idx_type length() const
octave_idx_type numel() const
Definition str-vec.h:98
void clear_function(const std::string &name)
Definition symtab.cc:446
void clear_function_pattern(const std::string &pat)
Definition symtab.cc:452
void clear_functions(bool force=false)
Definition symtab.cc:437
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
Definition symtab.cc:254
void clear_mex_functions()
Definition symtab.cc:515
void cleanup()
Definition symtab.cc:722
std::list< std::string > user_function_names()
Definition symtab.cc:603
void clear_function_regexp(const std::string &pat)
Definition symtab.cc:468
void insert(const std::string &file)
static void init()
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
Definition pt-eval.cc:1034
bool is_global(const std::string &name) const
Definition pt-eval.cc:1954
bool mislocked(bool skip_first=false) const
Definition pt-eval.cc:2811
void clear_all(bool force=false)
Definition pt-eval.cc:2928
void reset_debug_state()
Definition pt-eval.cc:1390
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
Definition pt-eval.cc:2069
symbol_scope get_current_scope() const
Definition pt-eval.cc:2771
octave_value echo(const octave_value_list &args, int nargout)
Definition pt-eval.cc:5022
void set_PS4(const std::string &s)
Definition pt-eval.h:721
void clear_global_variables()
Definition pt-eval.cc:2922
void clear_global_variable(const std::string &name)
Definition pt-eval.cc:2904
bool break_on_next_statement() const
Definition pt-eval.h:816
std::string inputname(int n, bool ids_only=true) const
Definition pt-eval.cc:1474
void munlock(bool skip_first=false) const
Definition pt-eval.cc:2794
bool at_top_level() const
Definition pt-eval.cc:550
octave_value find(const std::string &name)
Definition pt-eval.cc:2834
std::list< std::string > variable_names() const
Definition pt-eval.cc:2989
bool is_local_variable(const std::string &name) const
Definition pt-eval.cc:1896
bool in_debug_repl() const
Definition pt-eval.cc:5150
profiler & get_profiler()
Definition pt-eval.h:432
symbol_scope get_top_scope() const
Definition pt-eval.cc:2765
void clear_symbol_pattern(const std::string &pattern)
Definition pt-eval.cc:2953
void clear_symbol(const std::string &name)
Definition pt-eval.cc:2941
void remove_debug_watch_expression(const std::string &expr)
Definition pt-eval.h:691
void dbquit(bool all=false)
Definition pt-eval.cc:5164
void clear_objects()
Definition pt-eval.cc:2859
int server_loop()
Definition pt-eval.cc:892
void clear_variable(const std::string &name)
Definition pt-eval.cc:2868
bool is_variable(const std::string &name) const
Definition pt-eval.cc:1887
void add_debug_watch_expression(const std::string &expr)
Definition pt-eval.h:684
std::list< std::string > global_variable_names() const
Definition pt-eval.cc:2977
void clear_global_variable_pattern(const std::string &pattern)
Definition pt-eval.cc:2910
void assign(const std::string &name, const octave_value &val=octave_value())
Definition pt-eval.cc:2024
void assignin(const std::string &context, const std::string &name, const octave_value &val=octave_value())
Definition pt-eval.cc:2033
octave_value top_level_varval(const std::string &name) const
Definition pt-eval.cc:2011
void clear_symbol_regexp(const std::string &pattern)
Definition pt-eval.cc:2965
void get_line_and_eval()
Definition pt-eval.cc:657
std::list< std::string > autoloaded_functions() const
Definition pt-eval.cc:4762
void eval(std::shared_ptr< tree_statement_list > &stmt_list, bool interactive)
Definition pt-eval.cc:1001
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
Definition pt-eval.cc:1188
octave_value global_varval(const std::string &name) const
Definition pt-eval.cc:1992
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
Definition pt-eval.cc:2017
void install_variable(const std::string &name, const octave_value &value, bool global)
Definition pt-eval.cc:1981
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val=octave_value())
Definition pt-eval.cc:2228
std::set< std::string > debug_watch_expressions() const
Definition pt-eval.h:705
void clear_global_variable_regexp(const std::string &pattern)
Definition pt-eval.cc:2916
void parse_and_execute(const std::string &input, bool &incomplete_parse)
Definition pt-eval.cc:592
void clear_debug_watch_expressions()
Definition pt-eval.h:698
std::list< std::string > top_level_variable_names() const
Definition pt-eval.cc:2983
void global_assign(const std::string &name, const octave_value &val=octave_value())
Definition pt-eval.cc:2004
octave_value make_fcn_handle(const std::string &nm)
Definition pt-eval.cc:1630
void mlock(bool skip_first=false) const
Definition pt-eval.cc:2777
octave_value varval(const symbol_record &sym) const
Definition pt-eval.cc:1963
octave_value PS4(const octave_value_list &args, int nargout)
Definition pt-eval.cc:5268
std::string mfilename(const std::string &opt="") const
Definition pt-eval.cc:556
void clear_variable_regexp(const std::string &pattern)
Definition pt-eval.cc:2886
void clear_variable_pattern(const std::string &pattern)
Definition pt-eval.cc:2877
void clear_variables()
Definition pt-eval.cc:2895
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage()
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_value_list Fconfirm_recursive_rmdir(const octave_value_list &args, int nargout)
Definition dirfns.cc:779
void warning(const char *fmt,...)
Definition error.cc:1083
void warning_with_id(const char *id, const char *fmt,...)
Definition error.cc:1098
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
Definition error.cc:1062
void verror_with_cfn(const char *fmt, va_list args)
Definition error.cc:1032
void error(const char *fmt,...)
Definition error.cc:1008
float F77_REAL
Definition f77-fcn.h:303
octave_f77_int_type F77_INT
Definition f77-fcn.h:306
void octave_set_default_fpucw(void)
octave::sys::time Vlast_prompt_time
Definition input.cc:82
#define OCTAVE_SAFE_CALL(F, ARGS)
octave_value_list F__version_info__(const octave_value_list &args, int)
bool octave_interpreter_ready
sys::time Vlast_chdir_time
std::atomic< bool > octave_initialized
bool quit_allowed
bool octave_interpreter_ready
sys::time Vlast_chdir_time
std::atomic< bool > octave_initialized
bool quit_allowed
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()
Definition lo-ieee.cc:124
#define OCTAVE_VERSION
Definition main.in.cc:63
int release_unreferenced_dynamic_libraries()
Definition oct-shlib.cc:72
T::size_type numel(const T &str)
Definition oct-string.cc:81
octave_value_list Fprint_struct_array_contents(const octave_value_list &args, int nargout)
octave_value_list Fstruct_levels_to_print(const octave_value_list &args, int nargout)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition ovl.h:217
void flush_stdout()
Definition pager.cc:268
#define octave_stdout
Definition pager.h:301
octave_value_list Ffixed_point_format(const octave_value_list &args, int nargout)
std::atomic< bool > octave_signal_caught
Definition quit.cc:41
void(* octave_interrupt_hook)()
Definition quit.cc:44
void(* octave_signal_hook)()
Definition quit.cc:43
std::atomic< int > octave_interrupt_state
Definition quit.cc:39
void respond_to_pending_signals()
std::atomic< bool > can_interrupt
interrupt_handler catch_interrupts()
void install_signal_handlers()
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)
F77_RET_T const F77_DBLE * x
void sysdep_cleanup()
Definition sysdep.cc:465
void sysdep_init()
Definition sysdep.cc:439
pid_t octave_getpid_wrapper(void)
int octave_unlink_wrapper(const char *nm)
int octave_isatty_wrapper(int fd)
std::string file_in_path(const std::string &name, const std::string &suffix)
Definition utils.cc:698
int symbol_exist(const std::string &name, const std::string &type)
Definition variables.cc:327
std::string octave_startup_message(bool html)
Definition version.cc:125
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
subroutine xsdot(n, dx, incx, dy, incy, retval)
Definition xsdot.f:2